@readmagic/workmate 0.0.12 → 0.0.14

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 (439) hide show
  1. package/dist/chunks/AddWorkspaceDirectory-m2d3nOQJ.js +1 -0
  2. package/dist/chunks/AgentsMdExternalIncludesDialog-BRXGkHO4.js +1 -0
  3. package/dist/chunks/{AgentsMdExternalIncludesDialog-_yJJ0wqu.js → AgentsMdExternalIncludesDialog-D58Vn3SK.js} +1 -1
  4. package/dist/chunks/App-CeC-2dzL.js +1 -0
  5. package/dist/chunks/ApproveApiKey-DFpddLyp.js +1 -0
  6. package/dist/chunks/ApproveApiKey-NXTWIAMj.js +1 -0
  7. package/dist/chunks/BackgroundTasksDialog-9ruzl1jm.js +2 -0
  8. package/dist/chunks/{BypassPermissionsModeDialog-COI_V57z.js → BypassPermissionsModeDialog-C4QGpcBT.js} +1 -1
  9. package/dist/chunks/DiffDialog-LTdtTqsC.js +6 -0
  10. package/dist/chunks/Doctor-DmiDH-lg.js +1 -0
  11. package/dist/chunks/Doctor-Yvrzcrvx.js +3 -0
  12. package/dist/chunks/ExitFlow-DH0L3tyY.js +2 -0
  13. package/dist/chunks/{Grove-DRZrhbF0.js → Grove-BhhnrFX9.js} +2 -2
  14. package/dist/chunks/{HybridTransport-BadJQe6u.js → HybridTransport-CEWG9ZRi.js} +2 -4
  15. package/dist/chunks/InvalidConfigDialog-Ue3kJUPJ.js +1 -0
  16. package/dist/chunks/InvalidSettingsDialog-BO2AOTVf.js +1 -0
  17. package/dist/chunks/MCPConnectionManager-Ciy9y9VV.js +1 -0
  18. package/dist/chunks/MCPToolListView-Ddmu2UcL.js +1 -0
  19. package/dist/chunks/{McpParsingWarnings-xv0RZCSL.js → McpParsingWarnings-BsCDFWci.js} +1 -1
  20. package/dist/chunks/MessageSelector-DY5K0NHd.js +3 -0
  21. package/dist/chunks/Messages-LD6ZO301.js +10 -0
  22. package/dist/chunks/Onboarding-w0-VVsDz.js +1 -0
  23. package/dist/chunks/PermissionDialog-BPhvs5xH.js +1 -0
  24. package/dist/chunks/PressEnterToContinue-Dwoh6CaW.js +1 -0
  25. package/dist/chunks/{PromptInputFooterSuggestions-8-awCxOn.js → PromptInputFooterSuggestions-OEXx0Abp.js} +1 -1
  26. package/dist/chunks/PromptInputHelpMenu-DyaUsvNx.js +1 -0
  27. package/dist/chunks/QueryEngine-sH-KjJIq.js +1 -0
  28. package/dist/chunks/REPL-BMH_RItw.js +128 -0
  29. package/dist/chunks/REPL-DkPd3vk5.js +1 -0
  30. package/dist/chunks/{RemoteSessionManager-B4jqKVd3.js → RemoteSessionManager-DJhrR1dz.js} +2 -2
  31. package/dist/chunks/ResumeConversation-BbNrpSFB.js +1 -0
  32. package/dist/chunks/SSETransport-CLiI2qnD.js +2 -0
  33. package/dist/chunks/{SearchBox-C9vUA4IM.js → SearchBox-CwwV0W-w.js} +1 -1
  34. package/dist/chunks/SearchExtraToolsTool-DupzA6Vm.js +1 -0
  35. package/dist/chunks/Settings-B1EI5LOU.js +2 -0
  36. package/dist/chunks/{TeleportProgress-zmdAsogZ.js → TeleportProgress-IB--CbqZ.js} +1 -1
  37. package/dist/chunks/{TeleportRepoMismatchDialog-CG32I4cO.js → TeleportRepoMismatchDialog-KjdlS_gA.js} +1 -1
  38. package/dist/chunks/{TeleportResumeWrapper-2Yjr74Lq.js → TeleportResumeWrapper-DnHTI39O.js} +1 -1
  39. package/dist/chunks/ThemePicker-BrD_T7xF.js +1 -0
  40. package/dist/chunks/{TrustDialog-BVcny9vs.js → TrustDialog-L0rvvpit.js} +1 -1
  41. package/dist/chunks/ValidationErrorsList-QZvtUrAy.js +2 -0
  42. package/dist/chunks/add-dir-CpWXReCi.js +1 -0
  43. package/dist/chunks/{agentDisplay-CfMLGPGH.js → agentDisplay-CrQvGkTT.js} +1 -1
  44. package/dist/chunks/agents-BYQO6DbG.js +101 -0
  45. package/dist/chunks/{agents-BT82hwBN.js → agents-C99yMsVF.js} +1 -1
  46. package/dist/chunks/allErrors-uyOMiF9U.js +1 -0
  47. package/dist/chunks/{api-DAubp5q9.js → api-C5I2xwgd.js} +1 -1
  48. package/dist/chunks/api-j0iE1mkR.js +1 -0
  49. package/dist/chunks/attributionHooks-C0aXyx9L.js +1 -0
  50. package/dist/chunks/{auth-yDsvFcM7.js → auth-BYCRa_mb.js} +7 -12
  51. package/dist/chunks/auth-C9FUZzpW.js +1 -0
  52. package/dist/chunks/auth-DwPrlTHv.js +1 -0
  53. package/dist/chunks/backgroundHousekeeping-BxcVB3By.js +1 -0
  54. package/dist/chunks/backgroundHousekeeping-CjD8bACB.js +17 -0
  55. package/dist/chunks/{banner-BcAM7iSx.js → banner-HfMnBd03.js} +2 -2
  56. package/dist/chunks/{bg-Ci7pG4eo.js → bg-DltfF1_K.js} +2 -2
  57. package/dist/chunks/branch-BOWBZo5K.js +2 -0
  58. package/dist/chunks/{break-cache-4rlQORVk.js → break-cache-Cd1yQ-0h.js} +2 -3
  59. package/dist/chunks/bridgeConfig-Bxs5dqjH.js +1 -0
  60. package/dist/chunks/{bridgeConfig-BB6Hgali.js → bridgeConfig-CgAVrQfz.js} +1 -1
  61. package/dist/chunks/{bridgeMessaging-C9D0Lly2.js → bridgeMessaging-cOFtbkf_.js} +1 -1
  62. package/dist/chunks/{bridgePointer-DHWK3LEe.js → bridgePointer-CiHy2tTN.js} +1 -1
  63. package/dist/chunks/{bridgeStatusUtil-D8UbcVrZ.js → bridgeStatusUtil-BQF0AJDO.js} +1 -1
  64. package/dist/chunks/btw-B0UmiVKl.js +1 -0
  65. package/dist/chunks/caches-C9--b9a7.js +1 -0
  66. package/dist/chunks/caches-wN3JyvNE.js +1 -0
  67. package/dist/chunks/{capacityWake-ByL6fM6I.js → capacityWake-LRiPhPeM.js} +1 -1
  68. package/dist/chunks/{ccrClient-BG9HU_fW.js → ccrClient-wtUIz75R.js} +1 -1
  69. package/dist/chunks/{claudeDesktop-Ct_hyICL.js → claudeDesktop-DPIJpc1V.js} +1 -1
  70. package/dist/chunks/{clear-B4XN2fib.js → clear-CNzBoL7O.js} +1 -1
  71. package/dist/chunks/{cliLaunch-OPOtzhvA.js → cliLaunch-xIVvtPZy.js} +1 -1
  72. package/dist/chunks/{client-BMA05FW8.js → client-B7WkO81L.js} +1 -1
  73. package/dist/chunks/client-BCzhAEd0.js +1 -0
  74. package/dist/chunks/client-Dr9AYB-r.js +1 -0
  75. package/dist/chunks/commands-DTB0Qzd5.js +1 -0
  76. package/dist/chunks/compact-Bj8mdDYN.js +2 -0
  77. package/dist/chunks/config-B1kYcRIP.js +1 -0
  78. package/dist/chunks/{config-9rLTDOYW.js → config-BkbL2e5Q.js} +1 -1
  79. package/dist/chunks/{config-DMKtiMzJ.js → config-WMxn2jLl.js} +1 -1
  80. package/dist/chunks/context-DB1Ar85E.js +1 -0
  81. package/dist/chunks/context-noninteractive-Bno2Xsmp.js +1 -0
  82. package/dist/chunks/{context-noninteractive-mAQt1p9l.js → context-noninteractive-CqnJTDcI.js} +2 -2
  83. package/dist/chunks/conversation-DOgBzrm0.js +1 -0
  84. package/dist/chunks/conversation-hNXWaswI.js +1 -0
  85. package/dist/chunks/{createSSHSession-DjLSGm-0.js → createSSHSession-Cf2tOgK_.js} +3 -4
  86. package/dist/chunks/createSession-BZx-2UIB.js +1 -0
  87. package/dist/chunks/{createSession-CftIZ3aq.js → createSession-DD5YaQKM.js} +1 -1
  88. package/dist/chunks/crossProjectResume-CkiPQYYE.js +40 -0
  89. package/dist/chunks/{datadog-BGati3aQ.js → datadog-DcLf1QpG.js} +1 -1
  90. package/dist/chunks/{debug-Dr1SjdXn.js → debug-BQj6h99Q.js} +1 -1
  91. package/dist/chunks/debugUtils-B86DM1Sp.js +1 -0
  92. package/dist/chunks/{detached-CqfQYVOi.js → detached--wGwkuHX.js} +1 -2
  93. package/dist/chunks/{detectRepository-CMEkS5_2.js → detectRepository-Qy3zKoyn.js} +1 -1
  94. package/dist/chunks/detectRepository-tRUoPOKy.js +1 -0
  95. package/dist/chunks/{diff-1HsxKGBh.js → diff-dfXWiuLA.js} +1 -1
  96. package/dist/chunks/directoryCompletion-BtlRKLzw.js +1 -0
  97. package/dist/chunks/doctor-aKE2bG5C.js +1 -0
  98. package/dist/chunks/entry-wISucmYc.js +13 -0
  99. package/dist/chunks/esm-CrJVXrKW.js +1 -0
  100. package/dist/chunks/{execFileNoThrow-mXq4K0rl.js → execFileNoThrow-DYm1GeGn.js} +1 -1
  101. package/dist/chunks/{execSyncWrapper-Ne33rRiD.js → execSyncWrapper-CqvQqke-.js} +1 -1
  102. package/dist/chunks/exit-pjN4EJHV.js +1 -0
  103. package/dist/chunks/exit-s9XGerrH.js +1 -0
  104. package/dist/chunks/{extraUsage-0pUcYexI.js → extraUsage-CwDhpClH.js} +1 -1
  105. package/dist/chunks/extractMemories-WmPLOLUT.js +1 -0
  106. package/dist/chunks/fast-BVABmasw.js +1 -0
  107. package/dist/chunks/fast-Cuj3bfFm.js +1 -0
  108. package/dist/chunks/{fileSuggestions-Be-pyLLq.js → fileSuggestions-Dy2BUZzd.js} +2 -2
  109. package/dist/chunks/firstPartyEventLogger-CabA8fu0.js +1 -0
  110. package/dist/chunks/{firstPartyEventLogger-aFhcruXA.js → firstPartyEventLogger-D4yuDP-n.js} +3 -5
  111. package/dist/chunks/flushGate-B6ecrC4j.js +1 -0
  112. package/dist/chunks/{fpsMetrics-DffAomdg.js → fpsMetrics-Dk_pnSHJ.js} +1 -1
  113. package/dist/chunks/gemini-BC-BxZmj.js +1 -0
  114. package/dist/chunks/generateSessionName-JTR8nPYD.js +1 -0
  115. package/dist/chunks/{genericProcessUtils-Dc1pfb7J.js → genericProcessUtils-Bbcbi11g.js} +1 -1
  116. package/dist/chunks/git-BaSq69E7.js +1 -0
  117. package/dist/chunks/{git-CoQQ6YEf.js → git-DplvjXEY.js} +2 -3
  118. package/dist/chunks/{githubRepoPathMapping-CmpEaQoo.js → githubRepoPathMapping-Bk4FZrng.js} +1 -1
  119. package/dist/chunks/goal-B09SOyra.js +3 -0
  120. package/dist/chunks/grok-BBo3jGfP.js +1 -0
  121. package/dist/chunks/{grove-BnzBbGsX.js → grove-DsAIY-rZ.js} +1 -1
  122. package/dist/chunks/help-CELr6oJZ.js +1 -0
  123. package/dist/chunks/hooks-9rkDD2iw.js +1 -0
  124. package/dist/chunks/{hooks-BZS105Rd.js → hooks-BI4NY5IC.js} +2 -2
  125. package/dist/chunks/initReplBridge-BYrL6ou1.js +1 -0
  126. package/dist/chunks/{install-NZvHd_40.js → install-Dn3_M1Ui.js} +1 -1
  127. package/dist/chunks/{instrumentation-CjBlVlFq.js → instrumentation-5cSwEKaF.js} +4 -4
  128. package/dist/chunks/{job-D502Zf8J.js → job-rW1mEYtm.js} +1 -1
  129. package/dist/chunks/{jwtUtils-FQWtM6iM.js → jwtUtils-YCoZL0FW.js} +1 -1
  130. package/dist/chunks/keybindings-B5kUoxvg.js +1 -0
  131. package/dist/chunks/{launchLocalMemory-DxC3LojF.js → launchLocalMemory-CPucX8Xj.js} +2 -2
  132. package/dist/chunks/launchOnboarding--GCJWeeS.js +8 -0
  133. package/dist/chunks/loadAgentsDir-D-a1uUb5.js +1 -0
  134. package/dist/chunks/{loadAgentsDir-BXtV2jiO.js → loadAgentsDir-JrGMJN05.js} +659 -697
  135. package/dist/chunks/loadPluginHooks-C4zrlV0u.js +1 -0
  136. package/dist/chunks/localSearch-C-stDP9C.js +1 -0
  137. package/dist/chunks/localSearch-hOERAH9v.js +1 -0
  138. package/dist/chunks/{log-27kCA_9u.js → log-BlJ7CcKG.js} +1 -1
  139. package/dist/chunks/{logoV2Utils-CEnU8qad.js → logoV2Utils-J2Sqfube.js} +1 -1
  140. package/dist/chunks/{magicDocs-YtfrqVC6.js → magicDocs-Dpe3YhyL.js} +2 -2
  141. package/dist/chunks/main-C_PDzJdv.js +356 -0
  142. package/dist/chunks/{main-CGLCy2pM.js → main-Zh18lf2J.js} +2 -2
  143. package/dist/chunks/managedEnv-AEhH_HUs.js +1 -0
  144. package/dist/chunks/{managedEnv-B-BNY0xC.js → managedEnv-C8SisyLk.js} +1 -1
  145. package/dist/chunks/{mappers-IuJeXgvr.js → mappers-CMJorgSL.js} +1 -1
  146. package/dist/chunks/mcp-B2mJmWKt.js +6 -0
  147. package/dist/chunks/mcp-SuAh71Ht.js +2 -0
  148. package/dist/chunks/mcp-_tBxhPV-.js +1 -0
  149. package/dist/chunks/{memoize-Co4vS6UF.js → memoize-_2f7NWDv.js} +1 -1
  150. package/dist/chunks/memory-DK8bOrUr.js +1 -0
  151. package/dist/chunks/{modalContext-CUThy6Ph.js → modalContext-wY9CeN4G.js} +1 -1
  152. package/dist/chunks/{mode-GzBwK--u.js → mode-BhfhEpnW.js} +2 -2
  153. package/dist/chunks/model-BCM7RpVk.js +1 -0
  154. package/dist/chunks/model-BWR43D3c.js +1 -0
  155. package/dist/chunks/model-CmDF8O9G.js +1 -0
  156. package/dist/chunks/modelOptions-DEQat7lU.js +1 -0
  157. package/dist/chunks/nativeInstaller-xxyUjXbl.js +1 -0
  158. package/dist/chunks/{omit-D4Udf-p-.js → omit-od_CYp5o.js} +1 -1
  159. package/dist/chunks/{onChangeAppState-WbvtqDtk.js → onChangeAppState-CqTb0yEa.js} +1 -1
  160. package/dist/chunks/{openai-DaVFXyBB.js → openai-qW8mATAs.js} +3 -3
  161. package/dist/chunks/{panel-CoF2a-h4.js → panel-Bg_0PHE6.js} +1 -1
  162. package/dist/chunks/{parser-CUUiH40T.js → parser-a2S_eFyE.js} +1 -1
  163. package/dist/chunks/parser-x-w3ikxt.js +1 -0
  164. package/dist/chunks/{partition-CzW_31Y1.js → partition-CYoWXLNU.js} +1 -1
  165. package/dist/chunks/permissions--iKUbWBw.js +3 -0
  166. package/dist/chunks/pidLock-BR4hzYgp.js +3 -0
  167. package/dist/chunks/plan-DiHCGXhM.js +1 -0
  168. package/dist/chunks/{platform-Dg1c9F_1.js → platform-DVeTi9mp.js} +2 -2
  169. package/dist/chunks/plugin-BeC4D7XF.js +17 -0
  170. package/dist/chunks/pluginAutoupdate-Bj-CrFuO.js +1 -0
  171. package/dist/chunks/pluginBlocklist-DzOs-RS1.js +1 -0
  172. package/dist/chunks/pluginCliCommands-DwIGn58t.js +1 -0
  173. package/dist/chunks/{pluginFlagging-CXSSOj4J.js → pluginFlagging-BzuymJuf.js} +1 -1
  174. package/dist/chunks/pluginOperations-CP1v-nu0.js +2 -0
  175. package/dist/chunks/pluginStartupCheck-BGN6Je6d.js +1 -0
  176. package/dist/chunks/{pluginStartupCheck-BEd0VeQC.js → pluginStartupCheck-BUeBiYVq.js} +1 -1
  177. package/dist/chunks/plugins-D1N31THW.js +4 -0
  178. package/dist/chunks/{poorMode-DxgO_bUb.js → poorMode-D4L_-yWS.js} +1 -1
  179. package/dist/chunks/poorMode-XDBnxTiF.js +1 -0
  180. package/dist/chunks/print-DaJi1wF_.js +14 -0
  181. package/dist/chunks/processBashCommand-BGCIqxc9.js +1 -0
  182. package/dist/chunks/processSlashCommand-qR_j1DE8.js +5 -0
  183. package/dist/chunks/prompt-B0gADAvI.js +1 -0
  184. package/dist/chunks/{prompt-CRc2QEZ5.js → prompt-DnPppVz8.js} +21 -23
  185. package/dist/chunks/prompt-DqyEtC_I2.js +1 -0
  186. package/dist/chunks/{promptEditor-Bo1d8ZLq.js → promptEditor-Cilc9N3L.js} +3 -3
  187. package/dist/chunks/protocolHandler-DdbiucQa.js +13 -0
  188. package/dist/chunks/{proxy-BEKNaTXI.js → proxy-C0j74LqT.js} +1 -1
  189. package/dist/chunks/reconciler-Bte4gdP-.js +1 -0
  190. package/dist/chunks/refresh-MiZ0acBm.js +1 -0
  191. package/dist/chunks/registerProtocol-Bpte9dly.js +1 -0
  192. package/dist/chunks/{reload-plugins-DNEgQ5vo.js → reload-plugins-GdqFZblC.js} +1 -1
  193. package/dist/chunks/{remoteBridgeCore-BGOqHADF.js → remoteBridgeCore-CAl3_H-O.js} +1 -1
  194. package/dist/chunks/{remoteManagedSettings-26nhzuca.js → remoteManagedSettings-BcLJLEr7.js} +1 -1
  195. package/dist/chunks/rename-BDo5qIK0.js +1 -0
  196. package/dist/chunks/{renderOptions-45A-EdsK.js → renderOptions-CkqTbz6d.js} +1 -1
  197. package/dist/chunks/resume-Bbweh2hA.js +2 -0
  198. package/dist/chunks/ripgrep-DrpZ79Pp.js +1 -0
  199. package/dist/chunks/{ripgrep-DQ_ILUJV.js → ripgrep-X5m4gJ-3.js} +1 -1
  200. package/dist/chunks/{runtimeObserver-CBV-7-w7.js → runtimeObserver-CxXxUcrm.js} +1 -1
  201. package/dist/chunks/{runtimeObserver-BZrF3GnQ.js → runtimeObserver-Hjbo43xj.js} +3 -3
  202. package/dist/chunks/sandbox-adapter-DQ_fJSIo.js +1 -0
  203. package/dist/chunks/sandbox-toggle-DmNSThQK.js +1 -0
  204. package/dist/chunks/searchExtraTools-C7b2x2p_.js +1 -0
  205. package/dist/chunks/{session-Dy-_R7KP.js → session-CkuTMD_4.js} +2 -2
  206. package/dist/chunks/sessionFileAccessHooks-CQvGAbvL.js +1 -0
  207. package/dist/chunks/{sessionIdCompat-DMayYBrf.js → sessionIdCompat-Dgp6PW_1.js} +1 -1
  208. package/dist/chunks/sessionObserver-BoQY7nOa.js +1 -0
  209. package/dist/chunks/{sessionObserver-CyLpHSkw.js → sessionObserver-CvQ6oyoj.js} +1 -1
  210. package/dist/chunks/sessionState-C2REgUrs.js +11 -0
  211. package/dist/chunks/sessionStorage-BeaEgnaa.js +1 -0
  212. package/dist/chunks/sessionStoragePortable-x0Yn02-G.js +3 -0
  213. package/dist/chunks/{sessionTitle-L5tyJgdU.js → sessionTitle-2IWcNB8H.js} +2 -2
  214. package/dist/chunks/{sessionTracing-DpHGGIZm.js → sessionTracing-Bm7hQKHA.js} +2 -2
  215. package/dist/chunks/settings-Da6ax5aI.js +1 -0
  216. package/dist/chunks/{settings-DiBMs2gM.js → settings-aUygByiZ.js} +4 -5
  217. package/dist/chunks/settingsSync-DgzCU1BZ.js +1 -0
  218. package/dist/chunks/setup-CvaG4nl5.js +3 -0
  219. package/dist/chunks/{shadowedRuleDetection-DZ0AA2Rw.js → shadowedRuleDetection-CWCQ5dZ0.js} +1 -1
  220. package/dist/chunks/{shellQuote-C_I6DHLV.js → shellQuote-D3Ocv_U-.js} +1 -1
  221. package/dist/chunks/{sideQuestion-BYT8FdPF.js → sideQuestion-BoW-xYkh.js} +3 -3
  222. package/dist/chunks/sinks-B_ehGpvp.js +1 -0
  223. package/dist/chunks/sinks-ZHKfs6gv.js +1 -0
  224. package/dist/chunks/skillChangeDetector-C-HWR_8v.js +1 -0
  225. package/dist/chunks/{skillGapStore-DQXHqoP7.js → skillGapStore-CCNeSjIb.js} +2 -2
  226. package/dist/chunks/{skillLifecycle-BG_RnGSh.js → skillLifecycle-wU4JDNYQ.js} +2 -2
  227. package/dist/chunks/{skillSearchPanel-DxYP4Q6R.js → skillSearchPanel-Cxr1QQn4.js} +2 -2
  228. package/dist/chunks/skills-BghnKnNo.js +1 -0
  229. package/dist/chunks/{src-r6ZFgWPx2.js → src-D3yIF9I42.js} +1 -1
  230. package/dist/chunks/src-DL3w8VPk2.js +51 -0
  231. package/dist/chunks/{startupProfiler-Dc5r6LgE.js → startupProfiler-2sjXZkIP.js} +1 -1
  232. package/dist/chunks/startupProfiler-B2fyaBEa.js +1 -0
  233. package/dist/chunks/{staticRender-DrU6eWoq.js → staticRender-D9AbnQFr.js} +1 -1
  234. package/dist/chunks/{stats-BkadEKa-.js → stats-unp6R0Ah.js} +1 -1
  235. package/dist/chunks/{status-BmHu-c7I.js → status-BraYBx4N.js} +2 -2
  236. package/dist/chunks/status-DwyWiaVc.js +1 -0
  237. package/dist/chunks/statusNoticeHelpers-Dm1aiibR.js +1 -0
  238. package/dist/chunks/{stringUtils-Df-Lnjxd.js → stringUtils-BjnclTLB.js} +3 -3
  239. package/dist/chunks/{switcher-sYTxnJQA.js → switcher-BUNSEJ-7.js} +1 -1
  240. package/dist/chunks/switcher-DDUnWU_4.js +1 -0
  241. package/dist/chunks/{syncCache-BofuFJEe.js → syncCache-1s9xV8WV.js} +1 -1
  242. package/dist/chunks/tasks-BjFot03S.js +1 -0
  243. package/dist/chunks/teleport-Dj2Kvbmx.js +1 -0
  244. package/dist/chunks/{templateJobs-C94jEE6O.js → templateJobs-CY7GNRo5.js} +1 -3
  245. package/dist/chunks/{terminalSetup-fwhFTxGi.js → terminalSetup-CpMNk6dc.js} +5 -6
  246. package/dist/chunks/{terminalSetup-CbXKCpWM.js → terminalSetup-Ty8T8ePM.js} +1 -1
  247. package/dist/chunks/theme-c6grxWNn.js +1 -0
  248. package/dist/chunks/{tmux-d3cNCIZA.js → tmux-g0cQ0Buz.js} +1 -1
  249. package/dist/chunks/{toolEventObserver-DlL9CHmI.js → toolEventObserver-D7WbjgFR.js} +1 -1
  250. package/dist/chunks/toolPool-O5nkEFb1.js +1 -0
  251. package/dist/chunks/{trustedDevice-Bzz03jCy.js → trustedDevice-BF78PNK8.js} +1 -1
  252. package/dist/chunks/trustedDevice-D_z7bAQh.js +1 -0
  253. package/dist/chunks/{types-BJ7qTz75.js → types-BomO8WUz.js} +1 -1
  254. package/dist/chunks/{udsClient-CF8BmZgN.js → udsClient-DSvRPCvR.js} +1 -1
  255. package/dist/chunks/updateCCB-ts7Joyve.js +5 -0
  256. package/dist/chunks/upstreamproxy-DYoLvdM9.js +10 -0
  257. package/dist/chunks/useExitOnCtrlCDWithKeybindings-qLfN0tc-.js +1 -0
  258. package/dist/chunks/useMainLoopModel-DkjG_ikT.js +1 -0
  259. package/dist/chunks/useManagePlugins-E0Qzj-ws.js +1 -0
  260. package/dist/chunks/useMergedTools-B7iYaNwM.js +1 -0
  261. package/dist/chunks/{useSearchInput-q2CFPU4W.js → useSearchInput-CsxiM9i0.js} +1 -1
  262. package/dist/chunks/useSettingsErrors-DdVTahNa.js +1 -0
  263. package/dist/chunks/{userAgent-B7WkjI6I.js → userAgent-BggRZ-ZE.js} +1 -1
  264. package/dist/chunks/util-Xdy1nOjj.js +1 -0
  265. package/dist/chunks/{validatePlugin-jrcrYEIu.js → validatePlugin-Be5aSSnP.js} +1 -1
  266. package/dist/chunks/{vim-C4Hs5U2h.js → vim-cFcxfuac.js} +1 -1
  267. package/dist/chunks/{which-mplwBbc0.js → which-BR8YVCCW.js} +1 -1
  268. package/dist/chunks/{windowsPaths-C7Mdo9aU.js → windowsPaths-BmXyrasP.js} +1 -1
  269. package/dist/chunks/windowsPaths-BybjGW7e.js +1 -0
  270. package/dist/chunks/{workSecret-XLodD7tw.js → workSecret-BUd8cQ6-.js} +1 -1
  271. package/dist/chunks/workerRegistry-GrD7IAVQ.js +2 -0
  272. package/dist/chunks/worktree-V7xiUAtl.js +1 -0
  273. package/dist/cli.js +1 -1
  274. package/package.json +1 -1
  275. package/dist/chunks/AddWorkspaceDirectory-CtRxzRny.js +0 -1
  276. package/dist/chunks/AgentsMdExternalIncludesDialog-_bI4jo_P.js +0 -1
  277. package/dist/chunks/App-DoAZ7CYS.js +0 -1
  278. package/dist/chunks/ApproveApiKey-C8LwmDM2.js +0 -1
  279. package/dist/chunks/ApproveApiKey-DQP3qmb0.js +0 -1
  280. package/dist/chunks/BackgroundTasksDialog-CDA2noEk.js +0 -2
  281. package/dist/chunks/ConsoleOAuthFlow-Dn8fO-o_.js +0 -1
  282. package/dist/chunks/DiffDialog-CRWtQ1R5.js +0 -6
  283. package/dist/chunks/Doctor-CZ513Df9.js +0 -3
  284. package/dist/chunks/Doctor-CzPvNZzF.js +0 -1
  285. package/dist/chunks/ExitFlow-BFeftDv0.js +0 -2
  286. package/dist/chunks/InvalidConfigDialog-DQaT6aen.js +0 -1
  287. package/dist/chunks/InvalidSettingsDialog-ISzcIGPU.js +0 -1
  288. package/dist/chunks/MCPConnectionManager-BpjC7CEo.js +0 -1
  289. package/dist/chunks/MCPToolListView-Rb1Q--jG.js +0 -1
  290. package/dist/chunks/MessageSelector-BHB55sZb.js +0 -3
  291. package/dist/chunks/Messages-CPX-nIdA.js +0 -11
  292. package/dist/chunks/Onboarding-CymgipoF.js +0 -1
  293. package/dist/chunks/PermissionDialog-Cb3z8OUP.js +0 -1
  294. package/dist/chunks/PressEnterToContinue-Dq0Imo9c.js +0 -1
  295. package/dist/chunks/PromptInputHelpMenu-BP3UgCdi.js +0 -1
  296. package/dist/chunks/QueryEngine-HkswHUNv.js +0 -1
  297. package/dist/chunks/REPL-CZfg65kg.js +0 -133
  298. package/dist/chunks/REPL-eZsYNBfl.js +0 -1
  299. package/dist/chunks/ResumeConversation-B03XN_SP.js +0 -1
  300. package/dist/chunks/SSETransport-je346ofV.js +0 -4
  301. package/dist/chunks/SearchExtraToolsTool-C85Sanww.js +0 -1
  302. package/dist/chunks/Settings-C8GKWod1.js +0 -2
  303. package/dist/chunks/ThemePicker-p7_hHk1V.js +0 -1
  304. package/dist/chunks/ValidationErrorsList-DSSUWdgd.js +0 -2
  305. package/dist/chunks/WelcomeV2-BnSYhyfu.js +0 -1
  306. package/dist/chunks/add-dir-Bd7pilVx.js +0 -1
  307. package/dist/chunks/agents-qR6r94-F.js +0 -103
  308. package/dist/chunks/allErrors-CS77lRvU.js +0 -1
  309. package/dist/chunks/api-C4VflFau.js +0 -1
  310. package/dist/chunks/attributionHooks-CUAoGkU6.js +0 -1
  311. package/dist/chunks/auth-CNCehj7y.js +0 -1
  312. package/dist/chunks/auth-DrD9DW6X.js +0 -1
  313. package/dist/chunks/autoMode-C2lnBot9.js +0 -45
  314. package/dist/chunks/autoModeDenials-BxNzGJdR.js +0 -1
  315. package/dist/chunks/backgroundHousekeeping-DbpTGbwl.js +0 -1
  316. package/dist/chunks/backgroundHousekeeping-SpTxViUq.js +0 -17
  317. package/dist/chunks/branch-DJiMa8td.js +0 -3
  318. package/dist/chunks/bridgeConfig-Ccm79Jze.js +0 -1
  319. package/dist/chunks/btw-BO2B23f-.js +0 -1
  320. package/dist/chunks/caches-BQmbXerw.js +0 -1
  321. package/dist/chunks/caches-Dtjmjm6G.js +0 -1
  322. package/dist/chunks/client-7lIxWcaM.js +0 -1
  323. package/dist/chunks/client-B-2ccQZk.js +0 -1
  324. package/dist/chunks/commands-D_-v6_A0.js +0 -1
  325. package/dist/chunks/compact-kM0ETtB2.js +0 -2
  326. package/dist/chunks/config-Crf6Mzu3.js +0 -1
  327. package/dist/chunks/connectHeadless-CqRoEtrg.js +0 -1
  328. package/dist/chunks/context-BY5oO5is.js +0 -1
  329. package/dist/chunks/context-noninteractive-tc4KTYfI.js +0 -1
  330. package/dist/chunks/conversation-CFIn-KsW.js +0 -1
  331. package/dist/chunks/conversation-DPI7VKBL.js +0 -1
  332. package/dist/chunks/createSession-CjdLcRec.js +0 -1
  333. package/dist/chunks/crossProjectResume-BJqXBzkf.js +0 -40
  334. package/dist/chunks/dangerousBackend-DwcP0P08.js +0 -1
  335. package/dist/chunks/debugUtils-cK-iOsEV.js +0 -1
  336. package/dist/chunks/detectRepository-BsKZDRoI.js +0 -1
  337. package/dist/chunks/directoryCompletion-ByBTSuLu.js +0 -1
  338. package/dist/chunks/doctor-CJfvt9zR.js +0 -1
  339. package/dist/chunks/entry-CrZCZQQC.js +0 -14
  340. package/dist/chunks/esm-BkOWaWVb.js +0 -1
  341. package/dist/chunks/exit-B8MA4Ltm.js +0 -1
  342. package/dist/chunks/exit-BOhGfSlm.js +0 -2
  343. package/dist/chunks/extractMemories-DqhN0lba.js +0 -1
  344. package/dist/chunks/fast-DT5WDe3L.js +0 -1
  345. package/dist/chunks/fast-VOu2FUlV.js +0 -1
  346. package/dist/chunks/firstPartyEventLogger-B8RVGBQB.js +0 -1
  347. package/dist/chunks/flushGate-BUSrMj_6.js +0 -1
  348. package/dist/chunks/gemini-DB4M-MYv.js +0 -1
  349. package/dist/chunks/generateSessionName-DhCypqJ_.js +0 -1
  350. package/dist/chunks/git-Bs1vtuvX.js +0 -1
  351. package/dist/chunks/goal-TxXtfkQ6.js +0 -3
  352. package/dist/chunks/grok-D2a_J5wE.js +0 -1
  353. package/dist/chunks/help-C5ankDi4.js +0 -1
  354. package/dist/chunks/hooks-D-twhU_z.js +0 -1
  355. package/dist/chunks/initReplBridge-DL4klK0C.js +0 -1
  356. package/dist/chunks/keybindings-D9Boc8FD.js +0 -2
  357. package/dist/chunks/launchOnboarding-BLp5k_H4.js +0 -8
  358. package/dist/chunks/loadAgentsDir-BjsAQWqt.js +0 -1
  359. package/dist/chunks/loadPluginHooks-Dt3XQ-3N.js +0 -1
  360. package/dist/chunks/localSearch-CeP4ef0a.js +0 -1
  361. package/dist/chunks/localSearch-Cz8Ot7k2.js +0 -1
  362. package/dist/chunks/lockfile-D5-j7HOZ.js +0 -1
  363. package/dist/chunks/main-CkjTzYj1.js +0 -513
  364. package/dist/chunks/managedEnv-K9Si1UuL.js +0 -1
  365. package/dist/chunks/mcp-DMBoeQzm.js +0 -6
  366. package/dist/chunks/mcp-TMOPfLcW.js +0 -1
  367. package/dist/chunks/mcp-x5rgv-uv.js +0 -2
  368. package/dist/chunks/memory-DDUoR63T.js +0 -1
  369. package/dist/chunks/model-BydaMaPr.js +0 -1
  370. package/dist/chunks/model-CDnVaVDR.js +0 -1
  371. package/dist/chunks/model-CIvbC7rW.js +0 -1
  372. package/dist/chunks/modelOptions-ut0xePEe.js +0 -1
  373. package/dist/chunks/nativeInstaller-fgCMR_c0.js +0 -1
  374. package/dist/chunks/parseConnectUrl-BiyKR5-x.js +0 -1
  375. package/dist/chunks/parser-B2PlJg4C.js +0 -1
  376. package/dist/chunks/permissions-BT3lxYBM.js +0 -3
  377. package/dist/chunks/pidLock-d1VPd6CG.js +0 -3
  378. package/dist/chunks/plan-M9DG3AqN.js +0 -1
  379. package/dist/chunks/plugin-BiNHuq3h.js +0 -17
  380. package/dist/chunks/pluginAutoupdate-B5lel6s5.js +0 -1
  381. package/dist/chunks/pluginBlocklist-CNGmIlwU.js +0 -1
  382. package/dist/chunks/pluginCliCommands-WLOEhb2M.js +0 -1
  383. package/dist/chunks/pluginOperations-BFbty6WT.js +0 -2
  384. package/dist/chunks/pluginStartupCheck-Bcdxg484.js +0 -1
  385. package/dist/chunks/plugins-BMZ3aYKP.js +0 -4
  386. package/dist/chunks/poorMode-Djw0P9Gu.js +0 -1
  387. package/dist/chunks/print-DmoLcwVq.js +0 -26
  388. package/dist/chunks/processBashCommand-B-VqME9O.js +0 -1
  389. package/dist/chunks/processSlashCommand-D6zEooTy.js +0 -5
  390. package/dist/chunks/prompt-C3RRe4kW.js +0 -1
  391. package/dist/chunks/prompt-EtAanewG.js +0 -1
  392. package/dist/chunks/protocolHandler-B83fCYI4.js +0 -13
  393. package/dist/chunks/reconciler-BGav_ezX.js +0 -1
  394. package/dist/chunks/refresh-DumNiLvM.js +0 -1
  395. package/dist/chunks/registerProtocol-DduKPsn_.js +0 -36
  396. package/dist/chunks/rename-BPknfVGF.js +0 -1
  397. package/dist/chunks/resume-DGz04xDh.js +0 -2
  398. package/dist/chunks/ripgrep-BLQnqPnE.js +0 -1
  399. package/dist/chunks/sandbox-adapter-DUqeqkQD.js +0 -1
  400. package/dist/chunks/sandbox-toggle-D61gVqcT.js +0 -1
  401. package/dist/chunks/searchExtraTools-CgsV6kb1.js +0 -1
  402. package/dist/chunks/server-LdbAb0sV.js +0 -1
  403. package/dist/chunks/serverBanner-BdExKFHT.js +0 -1
  404. package/dist/chunks/serverLog-BFmvyJ93.js +0 -1
  405. package/dist/chunks/sessionFileAccessHooks-BJlrZaRD.js +0 -1
  406. package/dist/chunks/sessionManager-CPa049BO.js +0 -1
  407. package/dist/chunks/sessionObserver-BGYoLRGx.js +0 -1
  408. package/dist/chunks/sessionState-DSWN4tMV.js +0 -11
  409. package/dist/chunks/sessionStorage-zJ1esSCE.js +0 -1
  410. package/dist/chunks/sessionStoragePortable-BhkGMZWp.js +0 -3
  411. package/dist/chunks/settings-3ionQKNv.js +0 -1
  412. package/dist/chunks/settingsSync-dBqlrbcU.js +0 -1
  413. package/dist/chunks/setup-zf3v3ICe.js +0 -3
  414. package/dist/chunks/sinks-DppGvgz1.js +0 -1
  415. package/dist/chunks/sinks-mFsijQ_S.js +0 -2
  416. package/dist/chunks/skillChangeDetector-D-iq09Xs.js +0 -1
  417. package/dist/chunks/skills-BD-2ofXA.js +0 -1
  418. package/dist/chunks/src-P_wYS_NJ2.js +0 -53
  419. package/dist/chunks/startupProfiler-CUlV07MD.js +0 -1
  420. package/dist/chunks/status-CrmnCDIE.js +0 -1
  421. package/dist/chunks/statusNoticeHelpers-DakAVtQO.js +0 -1
  422. package/dist/chunks/switcher-Dm646gO5.js +0 -1
  423. package/dist/chunks/tasks-NpI1iEem.js +0 -1
  424. package/dist/chunks/teleport-Bs3kEipi.js +0 -1
  425. package/dist/chunks/theme-CEi3b_8f.js +0 -1
  426. package/dist/chunks/toolPool-DIT_uhtD.js +0 -1
  427. package/dist/chunks/trustedDevice-BokywSKL.js +0 -1
  428. package/dist/chunks/updateCCB-CzBxsuJe.js +0 -11
  429. package/dist/chunks/upstreamproxy-BuBFDFAD.js +0 -11
  430. package/dist/chunks/useExitOnCtrlCDWithKeybindings-BHQfwlAl.js +0 -1
  431. package/dist/chunks/useMainLoopModel-BkyIIW9t.js +0 -1
  432. package/dist/chunks/useManagePlugins-BWROoGDs.js +0 -1
  433. package/dist/chunks/useMergedTools-CHxnwR7R.js +0 -1
  434. package/dist/chunks/useSettingsErrors-CPVQbsqq.js +0 -1
  435. package/dist/chunks/util-BfqXOA-P.js +0 -1
  436. package/dist/chunks/windowsPaths-B8p9tFRF.js +0 -1
  437. package/dist/chunks/workerRegistry-Cfo7bKlm.js +0 -6
  438. package/dist/chunks/worktree-D0k_pCEz.js +0 -1
  439. package/dist/chunks/xdg-DcF9ejUM.js +0 -1
@@ -1,133 +0,0 @@
1
- import{a as e,n as t,o as n,r}from"./rolldown-runtime-DaDcL9Zw.js";import{c as i,i as a,l as o,o as s}from"./envUtils-DcaKZlRU.js";import{n as c,t as l}from"./defineProperty-C-QyHrDq.js";import{n as u,t as d}from"./figures-5ThXQEtq.js";import{t as f}from"./semver-DQo45qGo.js";import{n as p,t as m}from"./axios-DaWTGg7G.js";import{$ as h,$C as g,$a as _,$f as v,$g as y,$h as b,$n as x,$p as S,$r as C,$t as w,$u as T,$v as E,$y as D,AC as O,Aa as k,Ac as A,Ad as ee,Ag as j,Ai as te,Ap as ne,As as M,Ay as N,Ba as P,Bd as F,Bf as re,Bg as I,Bh as ie,Bi as ae,Bl as oe,Bo as se,Br as ce,Bs as le,C as ue,CC as L,CT as R,Ca as de,Cb as fe,Cc as pe,Cf as z,Ch as me,Cr as he,Cs as ge,Cu as _e,Cv as ve,Cy as ye,Db as be,Dc as xe,Dg as Se,Di as Ce,Dm as we,Ds as Te,Du as Ee,Dy as De,E as Oe,ET as ke,Ec as Ae,Eg as je,Em as Me,Ep as Ne,Er as Pe,Ey as Fe,F as Ie,FC as Le,Fb as Re,Fd as ze,Fg as Be,Fi as Ve,Fl as He,Fm as Ue,Fo as We,Fu as Ge,Fy as Ke,GC as qe,Gc as Je,Gd as Ye,Gg as Xe,Gh as Ze,Gi as Qe,Gm as $e,Gn as et,Gs as tt,Gu as nt,Gy as rt,HC as it,Hd as at,Hf as ot,Hh as st,Hi as ct,Hl as lt,Hm as ut,Hs as dt,Ht as ft,Hu as pt,Hw as mt,IC as ht,Ib as gt,Id as _t,If as vt,Il as yt,Im as bt,In as xt,Io as St,Iv as Ct,Iw as wt,JC as Tt,Ja as Et,Jc as Dt,Jd as Ot,Jg as kt,Jm as At,Js as jt,Ju as Mt,Jv as Nt,K as Pt,KC as Ft,Kc as It,Kd as Lt,Kg as Rt,Kh as zt,Ki as Bt,Km as Vt,Ko as Ht,Kp as Ut,Kr as Wt,Ks as Gt,Ku as Kt,Kv as qt,Ky as Jt,LC as Yt,La as Xt,Ld as Zt,Lf as Qt,Lh as $t,Lo as en,Lw as tn,Ly as nn,M as rn,MC as an,MT as on,Ma as sn,Mb as B,Md as cn,Mg as ln,Ml as un,Mm as dn,Mp as fn,Ms as pn,Mu as mn,My as hn,N as gn,NC as _n,NT as vn,Nb as yn,Nd as bn,Ng as xn,Nh as Sn,Ni as Cn,Nl as wn,Nm as Tn,Nn as En,No as Dn,Ns as On,Nu as kn,Ny as An,Oa as jn,Ob as Mn,Oc as Nn,Od as Pn,Og as Fn,Om as In,Oo as Ln,Op as Rn,Or as zn,Ou as Bn,Oy as Vn,PC as Hn,Pb as Un,Pd as Wn,Pf as Gn,Pg as Kn,Ph as qn,Pi as Jn,Pl as Yn,Pm as Xn,Po as Zn,Pt as Qn,Pu as $n,Pv as V,Py as er,QT as tr,Qd as nr,Qf as rr,Qh as H,Qm as ir,Qu as ar,Qy as or,RC as sr,Rb as cr,Rf as lr,Rg as ur,Rh as dr,Rn as fr,Ro as pr,Rv as mr,Rw as hr,Sa as gr,Sf as _r,Sg as vr,Sh as yr,Sp as br,Ss as xr,St as Sr,Su as Cr,Sy as wr,TC as Tr,T_ as Er,Ta as Dr,Tb as Or,Tc as kr,Tm as Ar,Tt as jr,Ty as Mr,U as Nr,Ud as Pr,Uf as Fr,Ug as Ir,Uh as Lr,Ul as Rr,Um as zr,Us as Br,Uu as Vr,Uw as Hr,Uy as Ur,VC as Wr,Va as Gr,Vd as Kr,Vf as qr,Vh as Jr,Vl as Yr,Vm as Xr,Vn as Zr,Vs as Qr,Vu as $r,Vy as ei,W as ti,WC as ni,Wd as ri,Wf as ii,Wg as ai,Wh as oi,Wi as si,Wl as ci,Wm as li,Wo as ui,Ws as di,Wt as fi,Wu as pi,Wv as mi,Ww as hi,Wy as gi,X as _i,Xd as vi,Xh as yi,Xm as bi,Xo as xi,Xs as Si,Xt as Ci,Xu as wi,Xv as Ti,Y as Ei,YC as Di,Ya as Oi,Yd as ki,Yg as Ai,Ym as ji,Yn as Mi,Yo as Ni,Yu as Pi,Yv as Fi,Z as Ii,Zc as Li,Zd as Ri,Zf as zi,Zh as Bi,Zm as Vi,Zu as Hi,Zv as Ui,Zy as Wi,_C as Gi,_E as Ki,_a as qi,_b as Ji,_g as Yi,_l as Xi,_o as Zi,_y as Qi,aS as $i,ab as ea,ac as ta,ag as na,ah as ra,ai as ia,al as aa,ao as oa,ap as sa,au as ca,av as la,ay as ua,bC as da,bS as fa,bT as pa,b_ as ma,bb as ha,bd as ga,bh as _a,by as va,ca as ya,cd as ba,cg as xa,cl as Sa,cp as Ca,ct as wa,cy as Ta,dE as Ea,d_ as Da,dd as Oa,dl as ka,dm as Aa,do as ja,dp as Ma,dy as Na,eE as Pa,e_ as Fa,eb as Ia,eg as La,el as Ra,em as za,ep as Ba,et as Va,ev as Ha,ex as Ua,ey as Wa,fE as Ga,f_ as Ka,fd as qa,fh as Ja,fl as Ya,fm as Xa,fp as Za,fv as Qa,gC as $a,gb as eo,gc as to,gd as no,gg as ro,gl as io,gy as ao,hC as oo,hE as so,ha as co,hb as lo,hc as uo,hd as fo,hg as po,hh as mo,hi as ho,ho as go,hr as _o,hw as vo,hy as yo,i_ as bo,id as xo,ig as So,ih as Co,ii as wo,il as To,ip as Eo,is as Do,iu as Oo,iv as ko,iy as Ao,j as jo,jC as Mo,ja as No,jd as Po,jg as Fo,jm as Io,jp as Lo,kC as Ro,ka as zo,kb as Bo,kc as Vo,kd as Ho,kg as Uo,kp as Wo,ks as Go,ky as Ko,lT as qo,l_ as Jo,la as Yo,ld as Xo,lf as Zo,lg as Qo,li as $o,ll as es,lp as ts,lt as ns,ly as rs,mC as is,mE as as,mb as os,md as ss,mg as cs,mh as ls,mi as us,mm as ds,mv as fs,my as ps,nc as ms,nd as hs,ng as gs,nl as _s,nr as vs,nv as ys,oS as bs,o_ as xs,og as U,oi as Ss,ol as Cs,or as ws,ov as Ts,oy as Es,pE as Ds,p_ as Os,pb as ks,pd as As,ph as js,pl as Ms,pm as Ns,pv as Ps,py as Fs,q as Is,qC as Ls,qc as Rs,qd as zs,qg as Bs,qm as Vs,qp as Hs,qs as Us,qu as Ws,qv as Gs,qy as Ks,r_ as qs,ra as Js,rc as Ys,rd as Xs,rg as Zs,rh as Qs,rr as $s,rs as ec,rt as tc,s_ as nc,sa as rc,sb as ic,sd as ac,sf as oc,sg as W,sl as sc,so as cc,sp as lc,sy as uc,t_ as dc,td as fc,tg as pc,ti as mc,tl as hc,to as gc,tp as _c,tv as vc,tw as yc,tx as bc,ty as xc,uT as Sc,u_ as Cc,ua as wc,ud as Tc,ul as Ec,un as Dc,up as Oc,uv as kc,uy as Ac,vE as jc,va as Mc,vc as Nc,vd as Pc,vg as Fc,vl as Ic,vn as Lc,vo as Rc,vr as zc,vw as Bc,vy as Vc,w_ as Hc,wb as Uc,wc as Wc,wf as Gc,wg as Kc,wm as qc,wo as Jc,wr as Yc,ws as Xc,wy as Zc,xC as Qc,xS as $c,x_ as el,xc as tl,xd as nl,xf as rl,xh as il,xp as al,yb as ol,yc as sl,yd as cl,yg as ll,yh as ul,yw as dl,yy as fl,zC as pl,zf as ml,zg as hl,zh as gl,zi as _l,zl as vl,zn as yl,zo as bl,zv as xl}from"./loadAgentsDir-BXtV2jiO.js";import{C as Sl,D as Cl,Ft as wl,Gr as Tl,Gt as El,H as Dl,I as G,Kr as Ol,Kt as kl,Lt as Al,P as K,Pn as jl,Rn as Ml,T as Nl,Tt as Pl,Vn as Fl,Wt as Il,Xn as Ll,Xt as Rl,Y as zl,Yt as Bl,Z as Vl,Zn as Hl,_n as Ul,bn as Wl,ct as Gl,di as Kl,dr as ql,et as Jl,fi as Yl,hn as Xl,ir as Zl,j as Ql,lr as $l,lt as eu,ot as tu,p as nu,q as ru,qr as iu,t as q,tr as au,ui as ou,vn as su,x as cu,y as lu,yn as uu,yt as du}from"./src-P_wYS_NJ2.js";import{t as fu}from"./jsx-runtime-Bb4Xn-E0.js";import{A as pu,C as mu,S as hu,a as gu,b as _u,l as vu,r as yu,w as bu}from"./external-CEp-aPkt.js";import{n as xu,r as Su,t as Cu}from"./lazySchema-B4D4qJVE.js";import{At as wu,B as Tu,D as Eu,Dt as Du,Et as Ou,Ft as ku,Gt as Au,Ln as ju,Ot as Mu,Rn as Nu,St as Pu,V as Fu,Vt as Iu,W as Lu,Wt as Ru,Y as zu,_n as Bu,ar as Vu,b as Hu,dt as Uu,en as Wu,et as Gu,it as Ku,jn as qu,jt as Ju,kt as Yu,lr as Xu,nn as Zu,or as Qu,pt as $u,rn as ed,sr as td,tn as nd,un as rd,ur as id,z as ad,zt as od}from"./state-BPFYBqm1.js";import{n as sd,t as cd}from"./cwd-Besi3Os3.js";import{B as ld,C as ud,E as dd,P as fd,R as pd,S as md,U as hd,W as gd,Z as _d,c as J,f as vd,g as yd,i as bd,nt as xd,tt as Sd,u as Cd,x as wd}from"./debug-Dr1SjdXn.js";import{H as Td,Ht as Ed,Jn as Dd,Kt as Od,Ln as kd,Lt as Ad,Mt as jd,Nt as Md,Rn as Nd,Rt as Pd,Ut as Fd,Wt as Id,Yn as Ld,Yt as Rd,c as zd,cr as Bd,ct as Vd,f as Hd,g as Ud,jt as Wd,kn as Gd,ln as Kd,n as qd,on as Jd,or as Yd,qn as Xd,qt as Zd,sr as Qd,vt as $d,wn as ef,x as tf,xn as nf,z as rf,zn as af,zt as of}from"./settings-DiBMs2gM.js";import{M as sf,c as cf,h as lf,n as uf,y as df}from"./config-9rLTDOYW.js";import{O as ff,a as pf,i as mf,k as hf,l as gf,m as _f}from"./git-CoQQ6YEf.js";import{r as vf,t as yf}from"./execFileNoThrow-mXq4K0rl.js";import{B as bf,H as xf,L as Sf,N as Cf,R as wf,k as Tf,o as Ef,q as Df,s as Y}from"./log-27kCA_9u.js";import{n as Of,t as kf}from"./memoize-Co4vS6UF.js";import{n as Af,t as jf}from"./which-mplwBbc0.js";import{i as Mf,o as Nf}from"./platform-Dg1c9F_1.js";import{s as Pf,u as Ff}from"./types-BJ7qTz75.js";import{n as If,r as X}from"./analytics-DJobLaWP.js";import{n as Lf,o as Rf,s as zf,t as Bf}from"./intl-D2kgJmX7.js";import{C as Vf,_ as Hf,d as Uf,l as Wf,u as Gf,v as Kf}from"./startupProfiler-Dc5r6LgE.js";import{n as qf,t as Jf}from"./bundledMode--fG1S62b.js";import{a as Yf,d as Xf,l as Zf,o as Qf,r as $f,s as ep}from"./stringUtils-Df-Lnjxd.js";import{$n as tp,At as np,Bn as rp,Bt as ip,Ct as ap,D as op,Et as sp,Ft as cp,Gt as lp,Hr as up,Ht as dp,Kn as fp,St as pp,T as mp,Vn as hp,Wr as gp,X as _p,_ as vp,_r as yp,at as bp,b as xp,ct as Sp,et as Cp,h as wp,ii as Tp,it as Ep,m as Dp,mt as Op,nr as kp,nt as Ap,ot as jp,ri as Mp,rt as Np,st as Pp,tr as Fp,tt as Ip,u as Lp,vr as Rp,x as zp}from"./model-CDnVaVDR.js";import{Bt as Bp,Ct as Vp,Jt as Hp,St as Up,Yt as Wp,an as Gp,bn as Kp,dn as qp,fn as Jp,hn as Yp,mn as Xp,nt as Zp,on as Qp,rn as $p,vn as em,zt as tm}from"./prompt-CRc2QEZ5.js";import{i as nm,m as rm,n as im,p as am}from"./terminalSetup-fwhFTxGi.js";import{C as om,D as sm,S as cm,T as lm,_ as um,at as dm,b as fm,dt as pm,n as mm,r as hm,ut as gm,v as _m,x as vm,y as ym}from"./sessionState-DSWN4tMV.js";import{a as bm,i as xm,r as Sm}from"./shellQuote-C_I6DHLV.js";import{a as Cm}from"./ripgrep-DQ_ILUJV.js";import{c as wm}from"./switcher-sYTxnJQA.js";import{et as Tm,rt as Em}from"./esm-BkOWaWVb.js";import{i as Dm,n as Om,r as km}from"./parser-CUUiH40T.js";import{T as Am,c as jm,r as Mm,w as Nm}from"./sessionTracing-DpHGGIZm.js";import{n as Pm,t as Fm}from"./poorMode-DxgO_bUb.js";import{o as Im,u as Lm}from"./api-DAubp5q9.js";import{f as Rm,m as zm,n as Bm}from"./firstPartyEventLogger-aFhcruXA.js";import{n as Vm,t as Hm}from"./mappers-IuJeXgvr.js";import{n as Um,r as Wm}from"./sessionTitle-L5tyJgdU.js";import{t as Gm}from"./bridgeMessaging-C9D0Lly2.js";import{C as Km,S as qm,d as Jm,l as Ym}from"./pidLock-d1VPd6CG.js";import{n as Xm,t as Zm}from"./nativeInstaller-fgCMR_c0.js";import{t as Qm}from"./useManagePlugins-BWROoGDs.js";import{n as $m,t as eh}from"./MCPConnectionManager-BpjC7CEo.js";import{n as th,t as nh}from"./toolPool-DIT_uhtD.js";import{a as rh,i as ih,o as ah,r as oh,t as sh}from"./MessageSelector-BHB55sZb.js";import{n as ch,t as lh}from"./useExitOnCtrlCDWithKeybindings-BHQfwlAl.js";import{a as uh,i as dh,n as fh,t as ph}from"./bridgeStatusUtil-D8UbcVrZ.js";import{n as mh,t as hh}from"./sideQuestion-BYT8FdPF.js";import{a as gh,n as _h,o as vh,r as yh,s as bh,t as xh}from"./skillChangeDetector-D-iq09Xs.js";import{n as Sh,t as Ch}from"./reconciler-BGav_ezX.js";import{n as wh,t as Th}from"./refresh-DumNiLvM.js";import{i as Eh,n as Dh,r as Oh,t as kh}from"./directoryCompletion-ByBTSuLu.js";import{r as Ah,t as jh}from"./PromptInputFooterSuggestions-8-awCxOn.js";import{n as Mh,t as Nh}from"./useMergedTools-CHxnwR7R.js";import{a as Ph,i as Fh,n as Ih,o as Lh,r as Rh,t as zh}from"./promptEditor-Bo1d8ZLq.js";import{n as Bh,t as Vh}from"./useMainLoopModel-BkyIIW9t.js";import{a as Hh,i as Uh,o as Wh,r as Gh,s as Kh,t as qh}from"./fileSuggestions-Be-pyLLq.js";import{i as Jh,n as Yh,r as Xh,t as Zh}from"./extraUsage-0pUcYexI.js";import{n as Qh,t as $h}from"./useSearchInput-q2CFPU4W.js";import{n as eg,t as tg}from"./staticRender-DrU6eWoq.js";import{n as ng,t as rg}from"./useSettingsErrors-CPVQbsqq.js";import{n as ig,t as ag}from"./shadowedRuleDetection-DZ0AA2Rw.js";import{n as og,t as sg}from"./ExitFlow-BFeftDv0.js";import{a as cg,i as lg,r as ug,t as dg}from"./fast-VOu2FUlV.js";import{i as fg,n as pg,r as mg,t as hg}from"./PermissionDialog-Cb3z8OUP.js";import{a as gg,i as _g,n as vg,r as yg,t as bg}from"./PromptInputHelpMenu-BP3UgCdi.js";import{n as xg,r as Sg}from"./autoModeDenials-BxNzGJdR.js";import{n as Cg,r as wg}from"./pluginAutoupdate-B5lel6s5.js";import{n as Tg,t as Eg}from"./generateSessionName-DhCypqJ_.js";import{a as Dg,c as Og,i as kg,l as Ag,n as jg,o as Mg,r as Ng,s as Pg,t as Fg}from"./Messages-CPX-nIdA.js";import{t as Ig}from"./lib-BlVGipXx.js";import{a as Lg,i as Rg,n as zg,o as Bg,r as Vg,t as Hg}from"./BackgroundTasksDialog-CDA2noEk.js";import{n as Ug}from"./fpsMetrics-DffAomdg.js";import{t as Wg}from"./earlyInput-IghoCjG5.js";import{a as Gg,i as Kg,o as qg,r as Jg,s as Yg,t as Xg}from"./RemoteSessionManager-B4jqKVd3.js";import{n as Zg,t as Qg}from"./backgroundHousekeeping-SpTxViUq.js";import{homedir as $g,tmpdir as e_}from"os";import*as t_ from"path";import{basename as n_,dirname as r_,extname as i_,join as a_,relative as o_,sep as s_}from"path";import{dirname as c_,join as l_}from"node:path";import{createHash as u_}from"node:crypto";import{randomUUID as d_}from"crypto";import{readFile as f_,readdir as p_,stat as m_,writeFile as h_}from"fs/promises";import{spawn as g_,spawnSync as __}from"child_process";import{mkdir as v_,readFile as y_,rename as b_,writeFile as x_}from"node:fs/promises";function S_(e){return Array.isArray?Array.isArray(e):M_(e)===`[object Array]`}function C_(e){if(typeof e==`string`)return e;if(typeof e==`bigint`)return e.toString();let t=e+``;return t==`0`&&1/e==-1/0?`-0`:t}function w_(e){return e==null?``:C_(e)}function T_(e){return typeof e==`string`}function E_(e){return typeof e==`number`}function D_(e){return e===!0||e===!1||k_(e)&&M_(e)==`[object Boolean]`}function O_(e){return typeof e==`object`}function k_(e){return O_(e)&&e!==null}function A_(e){return e!=null}function j_(e){return!e.trim().length}function M_(e){return e==null?e===void 0?`[object Undefined]`:`[object Null]`:Object.prototype.toString.call(e)}function N_(e){let t=null,n=null,r=null,i=1,a=null;if(T_(e)||S_(e))r=e,t=P_(e),n=F_(e);else{if(!_v.call(e,`name`))throw Error(mv(`name`));let o=e.name;if(r=o,_v.call(e,`weight`)&&e.weight!==void 0&&(i=e.weight,i<=0))throw Error(hv(F_(o)));t=P_(o),n=F_(o),a=e.getFn??null}return{path:t,id:n,weight:i,src:r,getFn:a}}function P_(e){return S_(e)?e:e.split(`.`)}function F_(e){return S_(e)?e.join(`.`):e}function I_(e,t){let n=[],r=!1,i=(e,t,a,o)=>{if(A_(e))if(!t[a])n.push(o===void 0?e:{v:e,i:o});else{let s=e[t[a]];if(!A_(s))return;if(a===t.length-1&&(T_(s)||E_(s)||D_(s)||typeof s==`bigint`))n.push(o===void 0?w_(s):{v:w_(s),i:o});else if(S_(s)){r=!0;for(let e=0,n=s.length;e<n;e+=1)i(s[e],t,a+1,e)}else t.length&&i(s,t,a+1,o)}};return i(e,T_(t)?t.split(`.`):t,0),r?n:n[0]}function L_(e=1,t=3){let n=new Map,r=10**t;return{get(t){let i=1,a=!1;for(let e=0;e<t.length;e++)t.charCodeAt(e)===32?a||(i++,a=!0):a=!1;if(n.has(i))return n.get(i);let o=Math.round(r/i**(.5*e))/r;return n.set(i,o),o},clear(){n.clear()}}}function R_(e,t,{getFn:n=Z.getFn,fieldNormWeight:r=Z.fieldNormWeight}={}){let i=new Cv({getFn:n,fieldNormWeight:r});return i.setKeys(e.map(N_)),i.setSources(t),i.create(),i}function z_(e,{getFn:t=Z.getFn,fieldNormWeight:n=Z.fieldNormWeight}={}){let{keys:r,records:i}=e,a=new Cv({getFn:t,fieldNormWeight:n});return a.setKeys(r),a.setIndexRecords(i),a}function B_(e=[],t=Z.minMatchCharLength){let n=[],r=-1,i=-1,a=0;for(let o=e.length;a<o;a+=1){let o=e[a];o&&r===-1?r=a:!o&&r!==-1&&(i=a-1,i-r+1>=t&&n.push([r,i]),r=-1)}return e[a-1]&&a-r>=t&&n.push([r,a-1]),n}function V_(e,t,n,{location:r=Z.location,distance:i=Z.distance,threshold:a=Z.threshold,findAllMatches:o=Z.findAllMatches,minMatchCharLength:s=Z.minMatchCharLength,includeMatches:c=Z.includeMatches,ignoreLocation:l=Z.ignoreLocation}={}){if(t.length>32)throw Error(pv(32));let u=t.length,d=e.length,f=Math.max(0,Math.min(r,d)),p=a,m=f,h=(e,t)=>{let n=e/u;if(l)return n;let r=Math.abs(f-t);return i?n+r/i:r?1:n},g=s>1||c,_=g?Array(d):[],v;for(;(v=e.indexOf(t,m))>-1;){let e=h(0,v);if(p=Math.min(e,p),m=v+u,g){let e=0;for(;e<u;)_[v+e]=1,e+=1}}m=-1;let y=[],b=1,x=0,S=u+d,C=1<<u-1;for(let t=0;t<u;t+=1){let r=0,i=S;for(;r<i;)h(t,f+i)<=p?r=i:S=i,i=Math.floor((S-r)/2+r);S=i;let a=Math.max(1,f-i+1),s=o?d:Math.min(f+i,d)+u,c=Array(s+2);c[s+1]=(1<<t)-1;for(let r=s;r>=a;--r){let i=r-1,o=n[e[i]];if(c[r]=(c[r+1]<<1|1)&o,t&&(c[r]|=(y[r+1]|y[r])<<1|1|y[r+1]),c[r]&C&&(b=h(t,i),b<=p)){if(p=b,m=i,x=t,m<=f)break;a=Math.max(1,2*f-m)}}if(h(t+1,f)>p)break;y=c}if(g&&m>=0){let t=Math.min(d-1,m+u-1+x);for(let r=m;r<=t;r+=1)n[e[r]]&&(_[r]=1)}let w={isMatch:m>=0,score:Math.max(.001,b)};if(g){let e=B_(_,s);e.length?c&&(w.indices=e):w.isMatch=!1}return w}function H_(e){let t={};for(let n=0,r=e.length;n<r;n+=1){let i=e.charAt(n);t[i]=(t[i]||0)|1<<r-n-1}return t}function U_(e){if(e.length<=1)return e;e.sort((e,t)=>e[0]-t[0]||e[1]-t[1]);let t=[e[0]];for(let n=1,r=e.length;n<r;n+=1){let r=t[t.length-1],i=e[n];i[0]<=r[1]+1?r[1]=Math.max(r[1],i[1]):t.push(i)}return t}function W_(e){return e.startsWith(`inverse`)}function G_(e){let t=[],n=e.length,r=0;for(;r<n;){for(;r<n&&e[r]===` `;)r++;if(r>=n)break;let i=r;for(;i<n&&e[i]!==` `&&e[i]!==`"`;)i++;if(i<n&&e[i]===`"`){for(i++;i<n;){if(e[i]===`"`){let t=i+1;if(t>=n||e[t]===` `){i++;break}if(e[t]===`$`&&(t+1>=n||e[t+1]===` `)){i+=2;break}}i++}t.push(e.substring(r,i)),r=i}else{for(;i<n&&e[i]!==` `;)i++;t.push(e.substring(r,i)),r=i}}return t}function K_(e,t){let n=e.match(t);return n?n[1]:null}function q_(e,t={}){return e.replace(/\\\|/g,jv).split(Mv).map(e=>{let n=G_(e.replace(/\u0000/g,`|`).trim()).filter(e=>e&&!!e.trim()),r=[];for(let e=0,i=n.length;e<i;e+=1){let i=n[e],a=!1,o=-1;for(;!a&&++o<Av;){let e=kv[o],n=K_(i,e.multiRegex);n&&(r.push(e.create(n,t)),a=!0)}if(!a)for(o=-1;++o<Av;){let e=kv[o],n=K_(i,e.singleRegex);if(n){r.push(e.create(n,t));break}}}return r})}function J_(...e){Pv.push(...e)}function Y_(e,t){for(let n=0,r=Pv.length;n<r;n+=1){let r=Pv[n];if(r.condition(e,t))return new r(e,t)}return new Dv(e,t)}function X_(e,t,{auto:n=!0}={}){let r=e=>{if(T_(e)){let r={keyId:null,pattern:e};return n&&(r.searcher=Y_(e,t)),r}let i=Object.keys(e),a=Rv(e);if(!a&&i.length>1&&!Lv(e))return r(Bv(e));if(zv(e)){let r=a?e[Iv.PATH]:i[0],o=a?e[Iv.PATTERN]:e[r];if(!T_(o))throw Error(fv(r));let s={keyId:F_(r),pattern:o};return n&&(s.searcher=Y_(o,t)),s}let o={children:[],operator:i[0]};return i.forEach(t=>{let n=e[t];S_(n)&&n.forEach(e=>{o.children.push(r(e))})}),o};return Lv(e)||(e=Bv(e)),r(e)}function Z_(e,{ignoreFieldNorm:t=Z.ignoreFieldNorm}){let n=1;return e.forEach(({key:e,norm:r,score:i})=>{let a=e?e.weight:null;n*=(i===0&&a?2**-52:i)**+((a||1)*(t?1:r))}),n}function Q_(e,{ignoreFieldNorm:t=Z.ignoreFieldNorm}){e.forEach(e=>{e.score=Z_(e.matches,{ignoreFieldNorm:t})})}function $_(e){let t=[];return e.matches.forEach(e=>{if(!A_(e.indices)||!e.indices.length)return;let n={indices:e.indices,value:e.value};e.key&&(n.key=e.key.id),e.idx>-1&&(n.refIndex=e.idx),t.push(n)}),t}function ev(e,t,{includeMatches:n=Z.includeMatches,includeScore:r=Z.includeScore}={}){return e.map(e=>{let{idx:i}=e,a={item:t[i],refIndex:i};return n&&(a.matches=$_(e)),r&&(a.score=e.score),a})}function tv(e){Uv.has(e)||(Uv.add(e),console.warn(`[Fuse] tokenize regex ${e} lacks the global flag; only the first match per text will be returned. Add the 'g' flag.`))}function nv(e){if(typeof e==`function`){let t=!1;return n=>{let r=e(n);if(!t&&(t=!0,!Array.isArray(r)||r.some(e=>typeof e!=`string`)))throw Error(`[Fuse] tokenize function must return string[]; received ${Array.isArray(r)?`array containing non-strings`:typeof r}.`);return r}}return e instanceof RegExp?(e.global||tv(e),t=>t.match(e)||[]):e=>e.match(Hv)||[]}function rv({isCaseSensitive:e=!1,ignoreDiacritics:t=!1,tokenize:n}={}){let r=nv(n);return{tokenize(n){return e||(n=n.toLowerCase()),t&&(n=Ev(n)),r(n)}}}function iv(e,t,n,r){let i=r.tokenize(t);if(!i.length)return;e.fieldCount++,e.docFieldCount.set(n,(e.docFieldCount.get(n)||0)+1);let a=new Set(i),o=e.docTermFieldHits.get(n);o||(o=new Map,e.docTermFieldHits.set(n,o));for(let t of a)o.set(t,(o.get(t)||0)+1),e.df.set(t,(e.df.get(t)||0)+1)}function av(e,t,n,r){let{i,v:a,$:o}=t;if(a!==void 0){iv(e,a,i,r);return}if(o)for(let t=0;t<n;t++){let n=o[t];if(n)if(Array.isArray(n))for(let t of n)iv(e,t.v,i,r);else iv(e,n.v,i,r)}}function ov(e,t,n){let r={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(let i of e)av(r,i,t,n);return r}function sv(e,t,n,r){av(e,t,n,r)}function cv(e,t){let n=e.docFieldCount.get(t);if(n===void 0)return;e.fieldCount-=n,e.docFieldCount.delete(t);let r=e.docTermFieldHits.get(t);if(r){for(let[t,n]of r){let r=(e.df.get(t)||0)-n;r<=0?e.df.delete(t):e.df.set(t,r)}e.docTermFieldHits.delete(t)}}function lv(e,t){if(t.length===0)return;let n=Array.from(new Set(t)).sort((e,t)=>e-t);for(let t of n)cv(e,t);let r=e=>{let t=0,r=n.length;for(;t<r;){let i=t+r>>>1;n[i]<e?t=i+1:r=i}return e-t},i=n[0],a=new Map;for(let[t,n]of e.docFieldCount)a.set(t>i?r(t):t,n);e.docFieldCount=a;let o=new Map;for(let[t,n]of e.docTermFieldHits)o.set(t>i?r(t):t,n);e.docTermFieldHits=o}var uv,dv,fv,pv,mv,hv,gv,_v,vv,yv,bv,xv,Sv,Z,Cv,wv,Tv,Ev,Dv,Ov,kv,Av,jv,Mv,Nv,Pv,Fv,Iv,Lv,Rv,zv,Bv,Vv,Hv,Uv,Wv,Gv,Kv,qv=t((()=>{uv=`Incorrect 'index' type`,dv=`Invalid doc index: must be a non-negative integer within the bounds of the docs array`,fv=e=>`Invalid value for key ${e}`,pv=e=>`Pattern length exceeds max of ${e}.`,mv=e=>`Missing ${e} property in key`,hv=e=>`Property 'weight' in key '${e}' must be a positive integer`,gv=`Fuse.match does not support useTokenSearch: token search requires corpus-level statistics (df, fieldCount) that a one-off string comparison does not have. Use new Fuse(...).search(...) instead.`,_v=Object.prototype.hasOwnProperty,vv=class{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach(e=>{let n=N_(e);this._keys.push(n),this._keyMap[n.id]=n,t+=n.weight}),this._keys.forEach(e=>{e.weight/=t})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}},yv={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},bv={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,t)=>e.score===t.score?e.idx<t.idx?-1:1:e.score<t.score?-1:1},xv={location:0,threshold:.6,distance:100},Sv={useExtendedSearch:!1,useTokenSearch:!1,tokenize:void 0,tokenMatch:`any`,getFn:I_,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1},Z=Object.freeze({...bv,...yv,...xv,...Sv}),Cv=class{constructor({getFn:e=Z.getFn,fieldNormWeight:t=Z.fieldNormWeight}={}){this.norm=L_(t,3),this.getFn=e,this.isCreated=!1,this.docs=[],this.keys=[],this._keysMap={},this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((e,t)=>{this._keysMap[e.id]=t})}create(){if(this.isCreated||!this.docs.length)return;this.isCreated=!0;let e=this.docs.length;this.records=Array(e);let t=0;if(T_(this.docs[0]))for(let n=0;n<e;n++){let e=this._createStringRecord(this.docs[n],n);e&&(this.records[t++]=e)}else for(let n=0;n<e;n++)this.records[t++]=this._createObjectRecord(this.docs[n],n);this.records.length=t,this.norm.clear()}add(e,t){if(!Number.isInteger(t)||t<0)throw Error(dv);if(T_(e)){let n=this._createStringRecord(e,t);return n&&this.records.push(n),n}let n=this._createObjectRecord(e,t);return this.records.push(n),n}removeAt(e){if(!Number.isInteger(e)||e<0)throw Error(dv);for(let t=0,n=this.records.length;t<n;t+=1)if(this.records[t].i===e){this.records.splice(t,1);break}for(let t=0,n=this.records.length;t<n;t+=1)this.records[t].i>e&&--this.records[t].i}removeAll(e){let t=new Set;for(let n of e)Number.isInteger(n)&&n>=0&&t.add(n);if(t.size===0)return;this.records=this.records.filter(e=>!t.has(e.i));let n=Array.from(t).sort((e,t)=>e-t);for(let e of this.records){let t=0,r=n.length;for(;t<r;){let i=t+r>>>1;n[i]<e.i?t=i+1:r=i}e.i-=t}}getValueForItemAtKeyId(e,t){return e[this._keysMap[t]]}size(){return this.records.length}_createStringRecord(e,t){return!A_(e)||j_(e)?null:{v:e,i:t,n:this.norm.get(e)}}_createObjectRecord(e,t){let n={i:t,$:{}};for(let t=0,r=this.keys.length;t<r;t++){let r=this.keys[t],i=r.getFn?r.getFn(e):this.getFn(e,r.path);if(A_(i)){if(S_(i)){let e=[];for(let t=0,n=i.length;t<n;t+=1){let n=i[t];if(A_(n)){if(T_(n)){if(!j_(n)){let r={v:n,i:t,n:this.norm.get(n)};e.push(r)}}else if(A_(n.v)){let t=T_(n.v)?n.v:w_(n.v);if(!j_(t)){let r={v:t,i:n.i,n:this.norm.get(t)};e.push(r)}}}}n.$[t]=e}else if(T_(i)&&!j_(i)){let e={v:i,n:this.norm.get(i)};n.$[t]=e}}}return n}toJSON(){return{keys:this.keys.map(({getFn:e,...t})=>t),records:this.records}}},wv={ł:`l`,Ł:`L`,đ:`d`,Đ:`D`,ø:`o`,Ø:`O`,ħ:`h`,Ħ:`H`,ŧ:`t`,Ŧ:`T`,ı:`i`,ß:`ss`},Tv=RegExp(`[`+Object.keys(wv).join(``)+`]`,`g`),Ev=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFD`).replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,``).replace(Tv,e=>wv[e]):e=>e,Dv=class{constructor(e,{location:t=Z.location,threshold:n=Z.threshold,distance:r=Z.distance,includeMatches:i=Z.includeMatches,findAllMatches:a=Z.findAllMatches,minMatchCharLength:o=Z.minMatchCharLength,isCaseSensitive:s=Z.isCaseSensitive,ignoreDiacritics:c=Z.ignoreDiacritics,ignoreLocation:l=Z.ignoreLocation}={}){if(this.options={location:t,threshold:n,distance:r,includeMatches:i,findAllMatches:a,minMatchCharLength:o,isCaseSensitive:s,ignoreDiacritics:c,ignoreLocation:l},e=s?e:e.toLowerCase(),e=c?Ev(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;let u=(e,t)=>{this.chunks.push({pattern:e,alphabet:H_(e),startIndex:t})},d=this.pattern.length;if(d>32){let e=0,t=d%32,n=d-t;for(;e<n;)u(this.pattern.substr(e,32),e),e+=32;if(t){let e=d-32;u(this.pattern.substr(e),e)}}else u(this.pattern,0)}searchIn(e){let{isCaseSensitive:t,ignoreDiacritics:n,includeMatches:r}=this.options;if(e=t?e:e.toLowerCase(),e=n?Ev(e):e,this.pattern===e){let t={isMatch:!0,score:0};return r&&(t.indices=[[0,e.length-1]]),t}let{location:i,distance:a,threshold:o,findAllMatches:s,minMatchCharLength:c,ignoreLocation:l}=this.options,u=[],d=0,f=!1;this.chunks.forEach(({pattern:t,alphabet:n,startIndex:p})=>{let{isMatch:m,score:h,indices:g}=V_(e,t,n,{location:i+p,distance:a,threshold:o,findAllMatches:s,minMatchCharLength:c,includeMatches:r,ignoreLocation:l});m&&(f=!0),d+=h,m&&g&&u.push(...g)});let p={isMatch:f,score:f?d/this.chunks.length:1};return f&&r&&(p.indices=U_(u)),p}},Ov=new Set([`fuzzy`,`include`]),kv=[{type:`exact`,multiRegex:/^="(.*)"$/,singleRegex:/^=(.*)$/,create:e=>({type:`exact`,search(t){let n=t===e;return{isMatch:n,score:+!n,indices:[0,e.length-1]}}})},{type:`include`,multiRegex:/^'"(.*)"$/,singleRegex:/^'(.*)$/,create:e=>({type:`include`,search(t){let n=0,r,i=[],a=e.length;for(;(r=t.indexOf(e,n))>-1;)n=r+a,i.push([r,n-1]);let o=!!i.length;return{isMatch:o,score:+!o,indices:i}}})},{type:`prefix-exact`,multiRegex:/^\^"(.*)"$/,singleRegex:/^\^(.*)$/,create:e=>({type:`prefix-exact`,search(t){let n=t.startsWith(e);return{isMatch:n,score:+!n,indices:[0,e.length-1]}}})},{type:`inverse-prefix-exact`,multiRegex:/^!\^"(.*)"$/,singleRegex:/^!\^(.*)$/,create:e=>({type:`inverse-prefix-exact`,search(t){let n=!t.startsWith(e);return{isMatch:n,score:+!n,indices:[0,t.length-1]}}})},{type:`inverse-suffix-exact`,multiRegex:/^!"(.*)"\$$/,singleRegex:/^!(.*)\$$/,create:e=>({type:`inverse-suffix-exact`,search(t){let n=!t.endsWith(e);return{isMatch:n,score:+!n,indices:[0,t.length-1]}}})},{type:`suffix-exact`,multiRegex:/^"(.*)"\$$/,singleRegex:/^(.*)\$$/,create:e=>({type:`suffix-exact`,search(t){let n=t.endsWith(e);return{isMatch:n,score:+!n,indices:[t.length-e.length,t.length-1]}}})},{type:`inverse-exact`,multiRegex:/^!"(.*)"$/,singleRegex:/^!(.*)$/,create:e=>({type:`inverse-exact`,search(t){let n=t.indexOf(e)===-1;return{isMatch:n,score:+!n,indices:[0,t.length-1]}}})},{type:`fuzzy`,multiRegex:/^"(.*)"$/,singleRegex:/^(.*)$/,create:(e,t={})=>{let n=new Dv(e,{location:t.location??Z.location,threshold:t.threshold??Z.threshold,distance:t.distance??Z.distance,includeMatches:t.includeMatches??Z.includeMatches,findAllMatches:t.findAllMatches??Z.findAllMatches,minMatchCharLength:t.minMatchCharLength??Z.minMatchCharLength,isCaseSensitive:t.isCaseSensitive??Z.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics??Z.ignoreDiacritics,ignoreLocation:t.ignoreLocation??Z.ignoreLocation});return{type:`fuzzy`,search(e){return n.searchIn(e)}}}}],Av=kv.length,jv=`\0`,Mv=`|`,Nv=class{constructor(e,{isCaseSensitive:t=Z.isCaseSensitive,ignoreDiacritics:n=Z.ignoreDiacritics,includeMatches:r=Z.includeMatches,minMatchCharLength:i=Z.minMatchCharLength,ignoreLocation:a=Z.ignoreLocation,findAllMatches:o=Z.findAllMatches,location:s=Z.location,threshold:c=Z.threshold,distance:l=Z.distance}={}){this.query=null,this.options={isCaseSensitive:t,ignoreDiacritics:n,includeMatches:r,minMatchCharLength:i,findAllMatches:o,ignoreLocation:a,location:s,threshold:c,distance:l},e=t?e:e.toLowerCase(),e=n?Ev(e):e,this.pattern=e,this.query=q_(this.pattern,this.options)}static condition(e,t){return t.useExtendedSearch}searchIn(e){let t=this.query;if(!t)return{isMatch:!1,score:1};let{includeMatches:n,isCaseSensitive:r,ignoreDiacritics:i}=this.options;e=r?e:e.toLowerCase(),e=i?Ev(e):e;let a=0,o=[],s=0,c=!1;for(let r=0,i=t.length;r<i;r+=1){let i=t[r];o.length=0,a=0,c=!1;for(let t=0,r=i.length;t<r;t+=1){let r=i[t],{isMatch:l,indices:u,score:d}=r.search(e);if(l)a+=1,s+=d,W_(r.type)&&(c=!0),n&&(Ov.has(r.type)?o.push(...u):o.push(u));else{s=0,a=0,o.length=0,c=!1;break}}if(a){let e={isMatch:!0,score:s/a};return c&&(e.hasInverse=!0),n&&(e.indices=U_(o)),e}}return{isMatch:!1,score:1}}},Pv=[],Fv={AND:`$and`,OR:`$or`},Iv={PATH:`$path`,PATTERN:`$val`},Lv=e=>!!(e[Fv.AND]||e[Fv.OR]),Rv=e=>!!e[Iv.PATH],zv=e=>!S_(e)&&O_(e)&&!Lv(e),Bv=e=>({[Fv.AND]:Object.keys(e).map(t=>({[t]:e[t]}))}),Vv=class{constructor(e){this.limit=e,this.heap=[]}get size(){return this.heap.length}shouldInsert(e){return this.size<this.limit||e<this.heap[0].score}insert(e){this.size<this.limit?(this.heap.push(e),this._bubbleUp(this.size-1)):e.score<this.heap[0].score&&(this.heap[0]=e,this._sinkDown(0))}extractSorted(e){return this.heap.sort(e)}_bubbleUp(e){let t=this.heap;for(;e>0;){let n=e-1>>1;if(t[e].score<=t[n].score)break;let r=t[e];t[e]=t[n],t[n]=r,e=n}}_sinkDown(e){let t=this.heap,n=t.length,r=e;do{e=r;let i=2*e+1,a=2*e+2;if(i<n&&t[i].score>t[r].score&&(r=i),a<n&&t[a].score>t[r].score&&(r=a),r!==e){let n=t[e];t[e]=t[r],t[r]=n}}while(r!==e)}},Hv=/[\p{L}\p{M}\p{N}_]+/gu,Uv=new WeakSet,Wv=class{static condition(e,t){return t.useTokenSearch}constructor(e,t){this.options=t,this.analyzer=rv({isCaseSensitive:t.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics,tokenize:t.tokenize});let n=this.analyzer.tokenize(e),{df:r,fieldCount:i}=t._invertedIndex;this.termSearchers=[],this.idfWeights=[];for(let e of n){this.termSearchers.push(new Dv(e,{location:t.location,threshold:t.threshold,distance:t.distance,includeMatches:t.includeMatches,findAllMatches:t.findAllMatches,minMatchCharLength:t.minMatchCharLength,isCaseSensitive:t.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics,ignoreLocation:!0}));let n=r.get(e)||0,a=Math.log(1+(i-n+.5)/(n+.5));this.idfWeights.push(a)}this.combineAll=t.tokenMatch===`all`,this.numTerms=this.termSearchers.length,this.useMask=this.numTerms<=31}searchIn(e){if(!this.termSearchers.length)return{isMatch:!1,score:1};let t=[],n=0,r=0,i=0,a=0,o=this.combineAll&&!this.useMask?new Set:null;for(let s=0;s<this.termSearchers.length;s++){let c=this.termSearchers[s].searchIn(e),l=this.idfWeights[s];r+=l,c.isMatch&&(i++,n+=l*(1-c.score),c.indices&&t.push(...c.indices),this.combineAll&&(this.useMask?a|=1<<s:o.add(s)))}if(i===0)return{isMatch:!1,score:1};let s=r>0?1-n/r:0,c={isMatch:!0,score:Math.max(.001,s)};return this.options.includeMatches&&t.length&&(c.indices=U_(t)),this.combineAll&&(this.useMask?c.matchedMask=a:c.matchedTerms=o,c.termCount=this.numTerms),c}},Gv=class{constructor(e,t,n){this.options={...Z,...t},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new vv(this.options.keys),this._docs=e,this._myIndex=null,this._invertedIndex=null,this.setCollection(e,n),this._lastQuery=null,this._lastSearcher=null}_getSearcher(e){if(this._lastQuery===e)return this._lastSearcher;let t=Y_(e,this._invertedIndex?{...this.options,_invertedIndex:this._invertedIndex}:this.options);return this._lastQuery=e,this._lastSearcher=t,t}setCollection(e,t){if(this._docs=e,t&&!(t instanceof Cv))throw Error(uv);if(this._myIndex=t||R_(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){let e=rv({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=ov(this._myIndex.records,this._myIndex.keys.length,e)}this._invalidateSearcherCache()}add(e){if(!A_(e))return;this._docs.push(e);let t=this._myIndex.add(e,this._docs.length-1);if(this._invertedIndex&&t){let e=rv({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});sv(this._invertedIndex,t,this._myIndex.keys.length,e)}this._invalidateSearcherCache()}remove(e=()=>!1){let t=[],n=[];for(let r=0,i=this._docs.length;r<i;r+=1)e(this._docs[r],r)&&(t.push(this._docs[r]),n.push(r));if(n.length){this._invertedIndex&&lv(this._invertedIndex,n);let e=new Set(n);this._docs=this._docs.filter((t,n)=>!e.has(n)),this._myIndex.removeAll(n),this._invalidateSearcherCache()}return t}removeAt(e){if(!Number.isInteger(e)||e<0||e>=this._docs.length)throw Error(dv);this._invertedIndex&&lv(this._invertedIndex,[e]);let t=this._docs.splice(e,1)[0];return this._myIndex.removeAt(e),this._invalidateSearcherCache(),t}_invalidateSearcherCache(){this._lastQuery=null,this._lastSearcher=null}getIndex(){return this._myIndex}search(e,t){let{limit:n=-1}=t||{},{includeMatches:r,includeScore:i,shouldSort:a,sortFn:o,ignoreFieldNorm:s}=this.options;if(T_(e)&&!e.trim()){let e=this._docs.map((e,t)=>({item:e,refIndex:t}));return E_(n)&&n>-1&&(e=e.slice(0,n)),e}let c=E_(n)&&n>0&&T_(e),l;if(c){let t=new Vv(n);T_(this._docs[0])?this._searchStringList(e,{heap:t,ignoreFieldNorm:s}):this._searchObjectList(e,{heap:t,ignoreFieldNorm:s}),l=t.extractSorted(o)}else l=T_(e)?T_(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e),Q_(l,{ignoreFieldNorm:s}),a&&l.sort(o),E_(n)&&n>-1&&(l=l.slice(0,n));return ev(l,this._docs,{includeMatches:r,includeScore:i})}_searchStringList(e,{heap:t,ignoreFieldNorm:n}={}){let r=this._getSearcher(e),i=this.options.useTokenSearch&&this.options.tokenMatch===`all`,{records:a}=this._myIndex,o=t?null:[];return a.forEach(({v:e,i:a,n:s})=>{if(!A_(e))return;let c=r.searchIn(e);if(c.isMatch){let r={score:c.score,value:e,norm:s,indices:c.indices};i&&(r.matchedMask=c.matchedMask,r.matchedTerms=c.matchedTerms,r.termCount=c.termCount);let l=[r];if(!i||this._coversAllTokens(l)){let r={item:e,idx:a,matches:l};t?(r.score=Z_(r.matches,{ignoreFieldNorm:n}),t.shouldInsert(r.score)&&t.insert(r)):o.push(r)}}}),o}_searchLogical(e){let t=X_(e,this.options),n=(e,t,r)=>{if(!(`children`in e)){let{keyId:n,searcher:i}=e,a;return n===null?(a=[],this._myIndex.keys.forEach((e,n)=>{a.push(...this._findMatches({key:e,value:t[n],searcher:i}))})):a=this._findMatches({key:this._keyStore.get(n),value:this._myIndex.getValueForItemAtKeyId(t,n),searcher:i}),a&&a.length?[{idx:r,item:t,matches:a}]:[]}let{children:i,operator:a}=e,o=[];for(let e=0,s=i.length;e<s;e+=1){let s=i[e],c=n(s,t,r);if(c.length)o.push(...c);else if(a===Fv.AND)return[]}return o},r=this._myIndex.records,i=new Map,a=[];return r.forEach(({$:e,i:r})=>{if(A_(e)){let o=n(t,e,r);o.length&&(i.has(r)||(i.set(r,{idx:r,item:e,matches:[]}),a.push(i.get(r))),o.forEach(({matches:e})=>{i.get(r).matches.push(...e)}))}}),a}_searchObjectList(e,{heap:t,ignoreFieldNorm:n}={}){let r=this._getSearcher(e),i=this.options.useTokenSearch&&this.options.tokenMatch===`all`,{keys:a,records:o}=this._myIndex,s=t?null:[];return o.forEach(({$:e,i:o})=>{if(!A_(e))return;let c=[],l=!1,u=!1;if(a.forEach((t,n)=>{let i=this._findMatches({key:t,value:e[n],searcher:r});i.length?(c.push(...i),i[0].hasInverse&&(u=!0)):l=!0}),!(u&&l)&&c.length&&(!i||this._coversAllTokens(c))){let r={idx:o,item:e,matches:c};t?(r.score=Z_(r.matches,{ignoreFieldNorm:n}),t.shouldInsert(r.score)&&t.insert(r)):s.push(r)}}),s}_findMatches({key:e,value:t,searcher:n}){if(!A_(t))return[];let r=[];if(S_(t))t.forEach(({v:t,i,n:a})=>{if(!A_(t))return;let o=n.searchIn(t);if(o.isMatch){let n={score:o.score,key:e,value:t,idx:i,norm:a,indices:o.indices,hasInverse:o.hasInverse};o.termCount!==void 0&&(n.matchedMask=o.matchedMask,n.matchedTerms=o.matchedTerms,n.termCount=o.termCount),r.push(n)}});else{let{v:i,n:a}=t,o=n.searchIn(i);if(o.isMatch){let t={score:o.score,key:e,value:i,norm:a,indices:o.indices,hasInverse:o.hasInverse};o.termCount!==void 0&&(t.matchedMask=o.matchedMask,t.matchedTerms=o.matchedTerms,t.termCount=o.termCount),r.push(t)}}return r}_coversAllTokens(e){let t=e.length?e[0].termCount:void 0;if(t===void 0)return!0;if(t<=31){let n=0;for(let t=0;t<e.length;t++)n|=e[t].matchedMask||0;return n===2**t-1}let n=new Set;for(let t=0;t<e.length;t++){let r=e[t].matchedTerms;if(r)for(let e of r)n.add(e)}return n.size===t}},Gv.version=`7.4.2`,Gv.createIndex=R_,Gv.parseIndex=z_,Gv.config=Z,Gv.match=function(e,t,n){if(n&&n.useTokenSearch)throw Error(gv);return Y_(e,{...Z,...n}).searchIn(t)},Gv.parseQuery=X_,J_(Nv),J_(Wv),Gv.use=function(...e){e.forEach(e=>J_(e))},Kv=Gv}));s(),c();var Jv=f();Kl(),su(),u(),q(),Su(),id(),Ru(),sd(),Sd(),gd(),pd(),wd(),vd(),bd(),ff(),Df(),Ef(),vf(),kf(),jf(),_f(),Nf(),Bd(),Dd(),Nd(),If(),ef(),Pf(),Rf(),Kf(),Kd(),Cu(),Jf(),Rd(),Id(),jd(),$d(),rf(),Qf(),Ud(),sf(),Mp(),Kp(),lf(),Yp(),gp(),Rp(),kp(),fp(),ip(),Cp(),vp(),Qp(),$p(),Wp(),Ki(),pm(),on(),Cm(),R(),Tm(),hi(),tn(),Bc(),vo(),g(),Sm(),Di(),Ft(),it(),sr(),Yt(),ht(),O(),oo(),Bp(),bs(),bc(),gt(),Uc(),os(),ic(),Ia(),Wi(),Jt(),Ke(),N(),Fe(),ps(),sm(),xc(),Nt(),mi(),mr(),ve(),Vp(),Zp(),fs(),kc(),Ts(),ys(),um(),Hc(),ma(),km(),Ka(),xs(),dc(),Ai(),Bs(),Ir(),I(),xn(),j(),Yi(),cs(),me(),_a(),mo(),js(),Co(),ir(),bi(),$e(),Nm(),Xr(),Ue(),Tn(),Io(),we(),Ma(),Ba(),rr(),ot(),Gc(),_r(),Rm(),Bm(),nr(),Pc(),ar(),pt(),lt(),oe(),He(),wn(),Xi(),hc(),jm(),Je(),Vo(),Nc(),uo(),Ys(),Si(),Gt(),le(),pn(),M(),ec(),xi(),bl(),Jc(),Zi(),ja(),oa(),P(),Bt(),ae(),he(),xt(),Lc(),h(),_i(),Pt(),ti(),ue(),$h(),fg(),pg();var Q=n(Yl(),1);Ol(),jg(),_n(),tr(),U(),tg();var $=fu();function Yv({children:e}){let{bindings:t}=Pa(),n=(0,Q.useRef)(null),r=(0,Q.useRef)(new Map),i=(0,Q.useRef)(new Set).current;return(0,$.jsx)(kl,{bindings:t,pendingChordRef:n,pendingChord:null,setPendingChord:()=>{},activeContexts:i,registerActiveContext:()=>{},unregisterActiveContext:()=>{},handlerRegistryRef:r,children:e})}function Xv(e){if(!(`message`in e))return 1;let t=e.message.content;return Array.isArray(t)?t.length:1}async function Zv(e,t,n,{columns:r,verbose:i=!1,chunkSize:a=40,onProgress:o}={}){let s=n=>eg((0,$.jsx)(na,{children:(0,$.jsx)(Yv,{children:(0,$.jsx)(Fg,{messages:e,tools:t,commands:[],verbose:i,toolJSX:null,toolUseConfirmQueue:[],inProgressToolUseIDs:new Set,isMessageSelectorVisible:!1,conversationId:`export`,screen:`prompt`,streamingToolUses:[],showAllInTranscript:!0,isLoading:!1,renderRange:n})})}),r),c=a;for(let t of e)c+=Xv(t);for(let e=0;e<c;e+=a){let t=await s([e,e+a]);if(iu(t).trim()===``)break;await n(t),o?.(e+a)}}async function Qv(e,t=[],n){let r=[];return await Zv(e,t,e=>void r.push(iu(e)),{columns:n}),r.join(``)}Mo(),Tr(),Zs(),b(),H(),ne(),Rn(),Ph(),wi();function $v({onDone:e}){return(0,$.jsxs)(lu,{title:`You've spent $5 on the API this session.`,onCancel:e,children:[(0,$.jsxs)(G,{flexDirection:`column`,children:[(0,$.jsx)(K,{children:`Learn more about how to monitor your spending:`}),(0,$.jsx)(Al,{url:`https://code.workmate.com/docs/en/costs`})]}),(0,$.jsx)(Hi,{options:[{value:`ok`,label:`Got it, thanks!`}],onChange:e})]})}q(),wi();function ey({idleMinutes:e,totalInputTokens:t,onDone:n}){return(0,$.jsxs)(lu,{title:`You've been away ${ty(e)} and this conversation is ${Hf(t)} tokens.`,onCancel:()=>n(`dismiss`),children:[(0,$.jsx)(G,{flexDirection:`column`,children:(0,$.jsx)(K,{children:`If this is a new task, clearing context will save usage and be faster.`})}),(0,$.jsx)(Hi,{options:[{value:`continue`,label:`Continue this conversation`},{value:`clear`,label:`Send message as a new conversation`},{value:`never`,label:`Don't ask me again`}],onChange:e=>n(e)})]})}function ty(e){if(e<1)return`< 1m`;if(e<60)return`${Math.floor(e)}m`;let t=Math.floor(e/60),n=Math.floor(e%60);return n===0?`${t}h`:`${t}h ${n}m`}Ot();async function ny(e,t){let n=cf().preferredNotifChannel;await ft(e),X(`tengu_notification_method_used`,{configured_channel:n,method_used:await iy(n,e,t),term:Od.terminal})}var ry=`Work Mate`;async function iy(e,t,n){let r=t.title||ry;try{switch(e){case`auto`:return ay(t,n);case`iterm2`:return n.notifyITerm2(t),`iterm2`;case`iterm2_with_bell`:return n.notifyITerm2(t),n.notifyBell(),`iterm2_with_bell`;case`kitty`:return n.notifyKitty({...t,title:r,id:oy()}),`kitty`;case`ghostty`:return n.notifyGhostty({...t,title:r}),`ghostty`;case`terminal_bell`:return n.notifyBell(),`terminal_bell`;case`notifications_disabled`:return`disabled`;default:return`none`}}catch{return`error`}}async function ay(e,t){let n=e.title||ry;switch(Od.terminal){case`Apple_Terminal`:return await sy()?(t.notifyBell(),`terminal_bell`):`no_method_available`;case`iTerm.app`:return t.notifyITerm2(e),`iterm2`;case`kitty`:return t.notifyKitty({...e,title:n,id:oy()}),`kitty`;case`ghostty`:return t.notifyGhostty({...e,title:n}),`ghostty`;default:return`no_method_available`}}function oy(){return Math.floor(Math.random()*1e4)}async function sy(){try{if(Od.terminal!==`Apple_Terminal`)return!1;let e=(await yf(`osascript`,[`-e`,`tell application "Terminal" to name of current settings of front window`])).stdout.trim();if(!e)return!1;let t=await yf(`defaults`,[`export`,`com.apple.Terminal`,`-`]);if(t.code!==0)return!1;let r=(await import(`./plist-Bzo2VMe9.js`).then(e=>n(e.default,1))).parse(t.stdout)?.[`Window Settings`]?.[e];return r?r.Bell===!1:!1}catch(e){return Y(e),!1}}var cy=300,ly=240*1e3,uy=null,dy=null,fy=0,py=!1;function my(){fy++,fy===1&&(yy(),_y())}function hy(){fy>0&&fy--,fy===0&&(vy(),by())}function gy(){fy=0,vy(),by()}function _y(){process.platform===`darwin`&&dy===null&&(dy=setInterval(()=>{fy>0&&(J(`Restarting caffeinate to maintain sleep prevention`),by(),yy())},ly),dy.unref())}function vy(){dy!==null&&(clearInterval(dy),dy=null)}function yy(){if(process.platform===`darwin`&&uy===null){py||(py=!0,xd(async()=>{gy()}));try{uy=g_(`caffeinate`,[`-i`,`-t`,String(cy)],{stdio:`ignore`}),uy.unref();let e=uy;uy.on(`error`,t=>{J(`caffeinate spawn error: ${t.message}`),uy===e&&(uy=null)}),uy.on(`exit`,()=>{uy===e&&(uy=null)}),J(`Started caffeinate to prevent sleep`)}catch{uy=null}}}function by(){if(uy!==null){let e=uy;uy=null;try{e.kill(`SIGKILL`),J(`Stopped caffeinate, allowing sleep`)}catch{}}}var xy=class{constructor(){l(this,`_status`,`idle`),l(this,`_generation`,0),l(this,`_changed`,Xu()),l(this,`subscribe`,this._changed.subscribe),l(this,`getSnapshot`,()=>this._status!==`idle`)}reserve(){return this._status===`idle`?(this._status=`dispatching`,this._notify(),!0):!1}cancelReservation(){this._status===`dispatching`&&(this._status=`idle`,this._notify())}tryStart(){return this._status===`running`?null:(this._status=`running`,++this._generation,this._notify(),this._generation)}end(e){return this._generation!==e||this._status!==`running`?!1:(this._status=`idle`,this._notify(),!0)}forceEnd(){this._status!==`idle`&&(this._status=`idle`,++this._generation,this._notify())}get isActive(){return this._status!==`idle`}get generation(){return this._generation}_notify(){this._changed.emit()}};function Sy(e,t=!1){let n=(0,Q.useRef)(0),r=(0,Q.useRef)(void 0),i=(0,Q.useRef)(void 0),a=(0,Q.useRef)(0);(0,Q.useEffect)(()=>{if(t)return;let o=e[0]?.uuid,s=n.current,c=i.current===void 0,l=o!==void 0&&!c&&o===i.current&&s<=e.length,u=o!==void 0&&!c&&o===i.current&&s>e.length,d=l?s:0;if(d===e.length)return;let f=d===0?e:e.slice(d),p=l?r.current:void 0,m=++a.current;if(C(f,{},p,e).then(e=>{m===a.current&&e&&!l&&(r.current=e)}),l||c||u){let t=et(f,e).findLast(Yc);t&&(r.current=t.uuid)}n.current=e.length,i.current=o},[e,t])}function Cy(e,t,n,r,i){return{sendBridgeResult:(0,Q.useCallback)(()=>{},[])}}Pi(),Ws(),Vr(),kn(),lh(),oh(),If();var wy=xu(()=>bu({method:_u(`log_event`),params:bu({eventName:pu(),eventData:bu({}).passthrough()})}));function Ty(e){(0,Q.useEffect)(()=>{if(!e.length)return;let t=ol(e);t&&t.client.setNotificationHandler(wy(),e=>{let{eventName:t,eventData:n}=e.params;X(`tengu_ide_${t}`,n)})},[e])}q();var Ey=6e3;function Dy(){return Date.now()-Lu()}function Oy(e){return Dy()<e}function ky(e){return!Oy(e)}function Ay(e,t){let n=jl();(0,Q.useEffect)(()=>{td(!0)},[]),(0,Q.useEffect)(()=>{let r=!1,i=setInterval(()=>{ky(6e3)&&!r&&(r=!0,clearInterval(i),ny({message:e,notificationType:t},n))},Ey);return()=>clearInterval(i)},[e,t,n])}am(),Le(),Gi(),Eo(),zs(),ri(),at(),nm(),Wn(),fo(),As(),Tc(),ba(),Ec(),sc(),To(),Rh(),q(),da();var jy={topLeft:`┌`,topRight:`┐`,bottomLeft:`└`,bottomRight:`┘`,horizontal:`─`,vertical:`│`,teeLeft:`├`,teeRight:`┤`};function My(e){return So().syntaxHighlightingDisabled?(0,$.jsx)(Py,{...e,highlight:null}):(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(Py,{...e,highlight:null}),children:(0,$.jsx)(Ny,{...e})})}function Ny(e){let t=(0,Q.use)(yi());return(0,$.jsx)(Py,{...e,highlight:t})}function Py({content:e,maxLines:t,minHeight:n,minWidth:r=40,maxWidth:i,highlight:a}){let{columns:o}=tu(),[s]=Dl(),c=i??o-4,l=t??20,u=(0,Q.useMemo)(()=>Wo(e,s,a),[e,s,a]).split(`
2
- `),d=u.length>l,f=d?u.slice(0,l):u,p=Math.max(0,Math.min(n??0,l)-f.length-+!!d),m=p>0?[...f,...Array(p).fill(``)]:f,h=Math.max(r,...m.map(e=>Tl(e))),g=Math.min(h+4,c),_=g-4,v=`${jy.topLeft}${jy.horizontal.repeat(g-2)}${jy.topRight}`,y=`${jy.bottomLeft}${jy.horizontal.repeat(g-2)}${jy.bottomRight}`,b=d?(()=>{let e=u.length-l,t=`${jy.horizontal.repeat(3)} \u2702 ${jy.horizontal.repeat(3)} ${e} lines hidden `,n=Tl(t),r=Math.max(0,g-2-n);return`${jy.teeLeft}${t}${jy.horizontal.repeat(r)}${jy.teeRight}`})():null;return(0,$.jsxs)(G,{flexDirection:`column`,children:[(0,$.jsx)(K,{dimColor:!0,children:v}),m.map((e,t)=>{let n=Tl(e)>_?Qc(e,0,_):e,r=` `.repeat(Math.max(0,_-Tl(n)));return(0,$.jsxs)(G,{flexDirection:`row`,children:[(0,$.jsxs)(K,{dimColor:!0,children:[jy.vertical,` `]}),(0,$.jsx)(wl,{children:n}),(0,$.jsxs)(K,{dimColor:!0,children:[r,` `,jy.vertical]})]},t)}),b&&(0,$.jsx)(K,{color:`warning`,children:b}),(0,$.jsx)(K,{dimColor:!0,children:y})]})}ht(),q(),Kf();function Fy({questions:e,currentQuestionIndex:t,answers:n,hideSubmitTab:r=!1}){let{columns:i}=tu(),a=(0,Q.useMemo)(()=>{let n=r?``:` ${d.tick} Submit `,a=Tl(`← `)+Tl(` →`)+Tl(n),o=i-a;if(o<=0)return e.map((e,n)=>{let r=e?.header||`Q${n+1}`;return n===t?r.slice(0,3):``});let s=e.map((e,t)=>e?.header||`Q${t+1}`);if(s.map(e=>4+Tl(e)).reduce((e,t)=>e+t,0)<=o)return s;let c=4+Tl(s[t]||``),l=Math.min(c,o/2),u=o-l,f=e.length-1,p=Math.max(6,Math.floor(u/Math.max(f,1)));return s.map((e,n)=>n===t?Vf(e,l-2-2):Vf(e,p-2-2))},[e,t,i,r]),o=e.length===1&&r;return(0,$.jsxs)(G,{flexDirection:`row`,marginBottom:1,children:[!o&&(0,$.jsx)(K,{color:t===0?`inactive`:void 0,children:`← `}),e.map((e,r)=>{let i=r===t,o=e?.question&&n[e.question]?d.checkboxOn:d.checkboxOff,s=a[r]||e?.header||`Q${r+1}`;return(0,$.jsx)(G,{children:i?(0,$.jsxs)(K,{backgroundColor:`permission`,color:`inverseText`,children:[` `,o,` `,s,` `]}):(0,$.jsxs)(K,{children:[` `,o,` `,s,` `]})},e?.question||`question-${r}`)}),!r&&(0,$.jsx)(G,{children:t===e.length?(0,$.jsxs)(K,{backgroundColor:`permission`,color:`inverseText`,children:[` `,d.tick,` Submit`,` `]}):(0,$.jsxs)(K,{children:[` `,d.tick,` Submit `]})},`submit`),!o&&(0,$.jsx)(K,{color:t===e.length?`inactive`:void 0,children:` →`})]})}u(),ht(),q(),U(),Uc();function Iy({question:e,questions:t,currentQuestionIndex:n,answers:r,questionStates:i,hideSubmitTab:a=!1,minContentHeight:o,minContentWidth:s,onUpdateQuestionState:c,onAnswer:l,onTextInputFocus:u,onCancel:f,onTabPrev:p,onTabNext:m,onRespondToClaude:h,onFinishPlanInterview:g}){let _=W(e=>e.toolPermissionContext.mode)===`plan`,[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(0),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(0),E=Fh(),D=E?B(E):null,O=e.question,k=i[O],A=e.options,[ee,j]=(0,Q.useState)(0),te=(0,Q.useRef)(O);if(te.current!==O){te.current=O;let e=k?.selectedValue,t=e?A.findIndex(t=>t.label===e):-1;j(t>=0?t:0)}let ne=A[ee],M=k?.selectedValue,N=k?.textInputValue||``,P=(0,Q.useCallback)(e=>{let t=A[e];t&&(j(e),c(O,{selectedValue:t.label},!1),l(O,t.label))},[A,O,c,l]),F=(0,Q.useCallback)(e=>{if(S)return;let t;t=typeof e==`number`?e:e===`up`?ee>0?ee-1:ee:ee<A.length-1?ee+1:ee,t>=0&&t<A.length&&j(t)},[ee,A.length,S]);Il(`chat:externalEditor`,async()=>{let e=k?.textInputValue||``,t=await Ih(e);t.content!==null&&t.content!==e&&c(O,{textInputValue:t.content},!1)},{context:`Chat`,isActive:S&&!!E}),El({"tabs:previous":()=>p?.(),"tabs:next":()=>m?.()},{context:`Tabs`,isActive:!S&&!v});let re=(0,Q.useCallback)(()=>{C(!1),u(!1),M&&l(O,M)},[M,O,l,u]),I=(0,Q.useCallback)(()=>{y(!0)},[]),ie=(0,Q.useCallback)(()=>{y(!1)},[]),ae=(0,Q.useCallback)(e=>{if(v){if(e.key===`up`||e.ctrl&&e.key===`p`){e.preventDefault(),b===0?ie():x(0);return}if(e.key===`down`||e.ctrl&&e.key===`n`){e.preventDefault(),_&&b===0&&x(1);return}if(e.key===`return`){e.preventDefault(),b===0?h():g();return}e.key===`escape`&&(e.preventDefault(),f());return}if(S){e.key===`escape`&&(e.preventDefault(),re());return}if(e.key===`up`||e.ctrl&&e.key===`p`)e.preventDefault(),ee>0&&F(`up`);else if(e.key===`down`||e.ctrl&&e.key===`n`)e.preventDefault(),ee===A.length-1?I():F(`down`);else if(e.key===`return`)e.preventDefault(),P(ee);else if(e.key===`n`&&!e.ctrl&&!e.meta)e.preventDefault(),C(!0),u(!0);else if(e.key===`escape`)e.preventDefault(),f();else if(e.key.length===1&&e.key>=`1`&&e.key<=`9`){e.preventDefault();let t=parseInt(e.key,10)-1;t<A.length&&F(t)}},[v,b,_,S,ee,A.length,ie,I,F,P,re,h,g,f,u]),oe=ne?.preview||null,{columns:se}=tu(),ce=se-30-4,le=(0,Q.useMemo)(()=>o?Math.max(1,o-11):void 0,[o]);return(0,$.jsxs)(G,{flexDirection:`column`,marginTop:1,tabIndex:0,autoFocus:!0,onKeyDown:ae,children:[(0,$.jsx)(Sl,{color:`inactive`}),(0,$.jsxs)(G,{flexDirection:`column`,paddingTop:0,children:[(0,$.jsx)(Fy,{questions:t,currentQuestionIndex:n,answers:r,hideSubmitTab:a}),(0,$.jsx)(mg,{title:e.question,color:`text`}),(0,$.jsxs)(G,{flexDirection:`column`,minHeight:o,children:[(0,$.jsxs)(G,{marginTop:1,flexDirection:`row`,gap:4,children:[(0,$.jsx)(G,{flexDirection:`column`,width:30,children:A.map((e,t)=>{let n=ee===t,r=M===e.label;return(0,$.jsxs)(G,{flexDirection:`row`,children:[n?(0,$.jsx)(K,{color:`suggestion`,children:d.pointer}):(0,$.jsx)(K,{children:` `}),(0,$.jsxs)(K,{dimColor:!0,children:[` `,t+1,`.`]}),(0,$.jsxs)(K,{color:r?`success`:n?`suggestion`:void 0,bold:n,children:[` `,e.label]}),r&&(0,$.jsxs)(K,{color:`success`,children:[` `,d.tick]})]},e.label)})}),(0,$.jsxs)(G,{flexDirection:`column`,flexGrow:1,children:[(0,$.jsx)(My,{content:oe||`No preview available`,maxLines:le,minWidth:s,maxWidth:ce}),(0,$.jsxs)(G,{marginTop:1,flexDirection:`row`,gap:1,children:[(0,$.jsx)(K,{color:`suggestion`,children:`Notes:`}),S?(0,$.jsx)(ac,{value:N,placeholder:`Add notes on this design…`,onChange:e=>{c(O,{textInputValue:e},!1)},onSubmit:re,onExit:re,focus:!0,showCursor:!0,columns:60,cursorOffset:w,onChangeCursorOffset:T}):(0,$.jsx)(K,{dimColor:!0,italic:!0,children:N||`press n to add notes`})]})]})]}),(0,$.jsxs)(G,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(Sl,{color:`inactive`}),(0,$.jsxs)(G,{flexDirection:`row`,gap:1,children:[v&&b===0?(0,$.jsx)(K,{color:`suggestion`,children:d.pointer}):(0,$.jsx)(K,{children:` `}),(0,$.jsx)(K,{color:v&&b===0?`suggestion`:void 0,children:`Chat about this`})]}),_&&(0,$.jsxs)(G,{flexDirection:`row`,gap:1,children:[v&&b===1?(0,$.jsx)(K,{color:`suggestion`,children:d.pointer}):(0,$.jsx)(K,{children:` `}),(0,$.jsx)(K,{color:v&&b===1?`suggestion`:void 0,children:`Skip interview and plan immediately`})]})]}),(0,$.jsx)(G,{marginTop:1,children:(0,$.jsxs)(K,{color:`inactive`,dimColor:!0,children:[`Enter to select · `,d.arrowUp,`/`,d.arrowDown,` to navigate · n to add notes`,t.length>1&&(0,$.jsx)($.Fragment,{children:` · Tab to switch questions`}),S&&D&&(0,$.jsxs)($.Fragment,{children:[` · ctrl+g to edit in `,D]}),` · Esc to cancel`]})})]})]})]})}u(),q(),U(),Ph(),Uc(),Rh(),wi(),fg();function Ly({question:e,questions:t,currentQuestionIndex:n,answers:r,questionStates:i,hideSubmitTab:a=!1,planFilePath:o,minContentHeight:s,minContentWidth:c,onUpdateQuestionState:l,onAnswer:u,onTextInputFocus:f,onCancel:p,onSubmit:m,onTabPrev:h,onTabNext:g,onRespondToClaude:_,onFinishPlanInterview:v,onImagePaste:y,pastedContents:b,onRemoveImage:x}){let S=W(e=>e.toolPermissionContext.mode)===`plan`,[C,w]=(0,Q.useState)(!1),[E,D]=(0,Q.useState)(0),[O,k]=(0,Q.useState)(!1),A=Fh(),ee=A?B(A):null,j=(0,Q.useCallback)(e=>{let t=e===`__other__`;k(t),f(t)},[f]),te=(0,Q.useCallback)(()=>{w(!0)},[]),ne=(0,Q.useCallback)(()=>{w(!1)},[]),M=(0,Q.useCallback)(e=>{if(C){if(e.key===`up`||e.ctrl&&e.key===`p`){e.preventDefault(),E===0?ne():D(0);return}if(e.key===`down`||e.ctrl&&e.key===`n`){e.preventDefault(),S&&E===0&&D(1);return}if(e.key===`return`){e.preventDefault(),E===0?_():v();return}e.key===`escape`&&(e.preventDefault(),p())}},[C,E,S,ne,_,v,p]),N=e.options.map(e=>({type:`text`,value:e.label,label:e.label,description:e.description})),P=e.question,F=i[P],re=(0,Q.useCallback)(async(t,n)=>{let r=await Ih(t);r.content!==null&&r.content!==t&&(n(r.content),l(P,{textInputValue:r.content},e.multiSelect??!1))},[P,l,e.multiSelect]),I={type:`input`,value:`__other__`,label:`Other`,placeholder:e.multiSelect?`Type something`:`Type something.`,initialValue:F?.textInputValue??``,onChange:t=>{l(P,{textInputValue:t},e.multiSelect??!1)}},ie=[...N,I];return!e.multiSelect&&e.options.some(e=>e.preview)?(0,$.jsx)(Iy,{question:e,questions:t,currentQuestionIndex:n,answers:r,questionStates:i,hideSubmitTab:a,minContentHeight:s,minContentWidth:c,onUpdateQuestionState:l,onAnswer:u,onTextInputFocus:f,onCancel:p,onTabPrev:h,onTabNext:g,onRespondToClaude:_,onFinishPlanInterview:v}):(0,$.jsxs)(G,{flexDirection:`column`,marginTop:0,tabIndex:0,autoFocus:!0,onKeyDown:M,children:[S&&o&&(0,$.jsxs)(G,{flexDirection:`column`,gap:0,children:[(0,$.jsx)(Sl,{color:`inactive`}),(0,$.jsxs)(K,{color:`inactive`,children:[`Planning: `,(0,$.jsx)($a,{filePath:o})]})]}),(0,$.jsx)(G,{marginTop:-1,children:(0,$.jsx)(Sl,{color:`inactive`})}),(0,$.jsxs)(G,{flexDirection:`column`,paddingTop:0,children:[(0,$.jsx)(Fy,{questions:t,currentQuestionIndex:n,answers:r,hideSubmitTab:a}),(0,$.jsx)(mg,{title:e.question,color:`text`}),(0,$.jsxs)(G,{flexDirection:`column`,minHeight:s,children:[(0,$.jsx)(G,{marginTop:1,children:e.multiSelect?(0,$.jsx)(T,{options:ie,defaultValue:i[e.question]?.selectedValue,onChange:e=>{l(P,{selectedValue:e},!0);let t=e.includes(`__other__`)?i[P]?.textInputValue:void 0,n=e.filter(e=>e!==`__other__`).concat(t?[t]:[]);u(P,n,void 0,!1)},onFocus:j,onCancel:p,submitButtonText:n===t.length-1?`Submit`:`Next`,onSubmit:m,onDownFromLastItem:te,isDisabled:C,onOpenEditor:re,onImagePaste:y,pastedContents:b,onRemoveImage:x},e.question):(0,$.jsx)(Hi,{options:ie,defaultValue:i[e.question]?.selectedValue,onChange:e=>{l(P,{selectedValue:e},!1);let t=e===`__other__`?i[P]?.textInputValue:void 0;u(P,e,t)},onFocus:j,onCancel:p,onDownFromLastItem:te,isDisabled:C,layout:`compact-vertical`,onOpenEditor:re,onImagePaste:y,pastedContents:b,onRemoveImage:x},e.question)}),(0,$.jsxs)(G,{flexDirection:`column`,children:[(0,$.jsx)(Sl,{color:`inactive`}),(0,$.jsxs)(G,{flexDirection:`row`,gap:1,children:[C&&E===0?(0,$.jsx)(K,{color:`suggestion`,children:d.pointer}):(0,$.jsx)(K,{children:` `}),(0,$.jsxs)(K,{color:C&&E===0?`suggestion`:void 0,children:[ie.length+1,`. Chat about this`]})]}),S&&(0,$.jsxs)(G,{flexDirection:`row`,gap:1,children:[C&&E===1?(0,$.jsx)(K,{color:`suggestion`,children:d.pointer}):(0,$.jsx)(K,{children:` `}),(0,$.jsxs)(K,{color:C&&E===1?`suggestion`:void 0,children:[ie.length+2,`. Skip interview and plan immediately`]})]})]}),(0,$.jsx)(G,{marginTop:1,children:(0,$.jsxs)(K,{color:`inactive`,dimColor:!0,children:[`Enter to select ·`,` `,t.length===1?(0,$.jsxs)($.Fragment,{children:[d.arrowUp,`/`,d.arrowDown,` to navigate`]}):`Tab/Arrow keys to navigate`,O&&ee&&(0,$.jsxs)($.Fragment,{children:[` · ctrl+g to edit in `,ee]}),` · Esc to cancel`]})})]})]})]})}function Ry(e,t){if(!e)return null;if(e.type===`classifier`)return e.classifier===`auto-mode`?{reasonString:`Auto mode classifier requires confirmation for this ${t}.\n${e.reason}`,configString:void 0,themeColor:`error`}:{reasonString:`Classifier ${ou.bold(e.classifier)} requires confirmation for this ${t}.\n${e.reason}`,configString:void 0};switch(e.type){case`rule`:return{reasonString:`Permission rule ${ou.bold(Td(e.rule.ruleValue))} requires confirmation for this ${t}.`,configString:e.rule.source===`policySettings`?void 0:`/permissions to update rules`};case`hook`:{let n=e.reason?`:\n${e.reason}`:`.`,r=e.hookSource?` ${ou.dim(`[${e.hookSource}]`)}`:``;return{reasonString:`Hook ${ou.bold(e.hookName)} requires confirmation for this ${t}${n}${r}`,configString:`/hooks to update`}}case`safetyCheck`:case`other`:return{reasonString:e.reason,configString:void 0};case`workingDir`:return{reasonString:e.reason,configString:`/permissions to update rules`};default:return null}}function zy({permissionResult:e,toolType:t}){let n=W(e=>e.toolPermissionContext.mode),r=Ry(e?.decisionReason,t);if(!r)return null;let i=r.themeColor??(e?.decisionReason?.type===`hook`&&n===`auto`?`warning`:void 0);return(0,By.jsxs)(G,{marginBottom:1,flexDirection:`column`,children:[i?(0,By.jsx)(K,{color:i,children:r.reasonString}):(0,By.jsx)(K,{children:(0,By.jsx)(wl,{children:r.reasonString})}),r.configString&&(0,By.jsx)(K,{dimColor:!0,children:r.configString})]})}var By,Vy=t((()=>{Yl(),q(),U(),By=fu()}));u(),q(),wi(),fg(),Vy();function Hy({questions:e,currentQuestionIndex:t,answers:n,allQuestionsAnswered:r,permissionResult:i,minContentHeight:a,onFinalResponse:o}){return(0,$.jsxs)(G,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(Sl,{color:`inactive`}),(0,$.jsxs)(G,{flexDirection:`column`,borderTop:!0,borderColor:`inactive`,paddingTop:0,children:[(0,$.jsx)(Fy,{questions:e,currentQuestionIndex:t,answers:n}),(0,$.jsx)(mg,{title:`Review your answers`,color:`text`}),(0,$.jsxs)(G,{flexDirection:`column`,marginTop:1,minHeight:a,children:[!r&&(0,$.jsx)(G,{marginBottom:1,children:(0,$.jsxs)(K,{color:`warning`,children:[d.warning,` You have not answered all questions`]})}),Object.keys(n).length>0&&(0,$.jsx)(G,{flexDirection:`column`,marginBottom:1,children:e.filter(e=>e?.question&&n[e.question]).map(e=>{let t=n[e?.question];return(0,$.jsxs)(G,{flexDirection:`column`,marginLeft:1,children:[(0,$.jsxs)(K,{children:[d.bullet,` `,e?.question||`Question`]}),(0,$.jsx)(G,{marginLeft:2,children:(0,$.jsxs)(K,{color:`success`,children:[d.arrowRight,` `,t]})})]},e?.question||`answer`)})}),(0,$.jsx)(zy,{permissionResult:i,toolType:`tool`}),(0,$.jsx)(K,{color:`inactive`,children:`Ready to submit your answers?`}),(0,$.jsx)(G,{marginTop:1,children:(0,$.jsx)(Hi,{options:[{type:`text`,label:`Submit answers`,value:`submit`},{type:`text`,label:`Cancel`,value:`cancel`}],onChange:e=>o(e),onCancel:()=>o(`cancel`)})})]})]})]})}function Uy(e,t){switch(t.type){case`next-question`:return{...e,currentQuestionIndex:e.currentQuestionIndex+1,isInTextInput:!1};case`prev-question`:return{...e,currentQuestionIndex:Math.max(0,e.currentQuestionIndex-1),isInTextInput:!1};case`update-question-state`:{let n=e.questionStates[t.questionText],r={selectedValue:t.updates.selectedValue??n?.selectedValue??(t.isMultiSelect?[]:void 0),textInputValue:t.updates.textInputValue??n?.textInputValue??``};return{...e,questionStates:{...e.questionStates,[t.questionText]:r}}}case`set-answer`:{let n={...e,answers:{...e.answers,[t.questionText]:t.answer}};return t.shouldAdvance?{...n,currentQuestionIndex:n.currentQuestionIndex+1,isInTextInput:!1}:n}case`set-text-input-mode`:return{...e,isInTextInput:t.isInInput}}}var Wy={currentQuestionIndex:0,answers:{},questionStates:{},isInTextInput:!1};function Gy(){let[e,t]=(0,Q.useReducer)(Uy,Wy),n=(0,Q.useCallback)(()=>{t({type:`next-question`})},[]),r=(0,Q.useCallback)(()=>{t({type:`prev-question`})},[]),i=(0,Q.useCallback)((e,n,r)=>{t({type:`update-question-state`,questionText:e,updates:n,isMultiSelect:r})},[]),a=(0,Q.useCallback)((e,n,r=!0)=>{t({type:`set-answer`,questionText:e,answer:n,shouldAdvance:r})},[]),o=(0,Q.useCallback)(e=>{t({type:`set-text-input-mode`,isInInput:e})},[]);return{currentQuestionIndex:e.currentQuestionIndex,answers:e.answers,questionStates:e.questionStates,isInTextInput:e.isInTextInput,nextQuestion:n,prevQuestion:r,updateQuestionState:i,setAnswer:a,setTextInputMode:o}}Zs(),ht(),q(),O(),If(),U(),H(),Ef(),ne();var Ky=12,qy=40,Jy=15;function Yy(e){return So().syntaxHighlightingDisabled?(0,$.jsx)(Zy,{...e,highlight:null}):(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(Zy,{...e,highlight:null}),children:(0,$.jsx)(Xy,{...e})})}function Xy(e){let t=(0,Q.use)(yi());return(0,$.jsx)(Zy,{...e,highlight:t})}function Zy({toolUseConfirm:e,onDone:t,onReject:n,highlight:r}){let i=(0,Q.useMemo)(()=>vl.inputSchema.safeParse(e.input),[e.input]),a=i.success&&i.data.questions||[],{rows:o}=tu(),[s]=Dl(),{globalContentHeight:c,globalContentWidth:l}=(0,Q.useMemo)(()=>{let e=0,t=0,n=Math.max(Ky,o-Jy);for(let i of a)if(i.options.some(e=>e.preview)){let a=Math.max(1,n-11),o=0;for(let e of i.options)if(e.preview){let n=Wo(e.preview,s,r).split(`
3
- `),i=n.length>a,c=i?a:n.length;o=Math.max(o,c+ +!!i+2);for(let e of n)t=Math.max(t,Tl(e))}let c=o+2,l=i.options.length+2;e=Math.max(e,Math.max(l,c)+7)}else e=Math.max(e,i.options.length+3+7);return{globalContentHeight:Math.min(Math.max(e,Ky),n),globalContentWidth:Math.max(t,qy)}},[a,o,s,r]),u=i.success?i.data.metadata?.source:void 0,[d,f]=(0,Q.useState)({}),p=(0,Q.useRef)(0);function m(e,t,n,r,i,a){let o=p.current++,s={id:o,type:`image`,content:t,mediaType:n||`image/png`,filename:r||`Pasted image`,dimensions:i};_c(s),sa(s),f(t=>({...t,[e]:{...t[e]??{},[o]:s}}))}let h=(0,Q.useCallback)((e,t)=>{f(n=>{let r={...n[e]??{}};return delete r[t],{...n,[e]:r}})},[]),g=Object.values(d).flatMap(e=>Object.values(e)).filter(e=>e.type===`image`),_=W(e=>e.toolPermissionContext.mode)===`plan`,v=_?as():void 0,{currentQuestionIndex:y,answers:b,questionStates:x,isInTextInput:S,nextQuestion:C,prevQuestion:w,updateQuestionState:T,setAnswer:E,setTextInputMode:D}=Gy(),O=y<(a?.length||0)?a?.[y]:null,k=y===(a?.length||0),A=a?.every(e=>e?.question&&!!b[e.question])??!1,ee=a.length===1&&!a[0]?.multiSelect,j=(0,Q.useCallback)(()=>{u&&X(`tengu_ask_user_question_rejected`,{source:u,questionCount:a.length,isInPlanMode:_,interviewPhaseEnabled:_&&yt()}),t(),n(),e.onReject()},[t,n,e,u,a.length,_]),te=(0,Q.useCallback)(async()=>{let n=`The user wants to clarify these questions.
4
- This means they may have additional information, context or questions for you.
5
- Take their response into account and then reformulate the questions if appropriate.
6
- Start by asking them what they would like to clarify.
7
-
8
- Questions asked:\n${a.map(e=>{let t=b[e.question];return t?`- "${e.question}"\n Answer: ${t}`:`- "${e.question}"\n (No answer provided)`}).join(`
9
- `)}`;u&&X(`tengu_ask_user_question_respond_to_claude`,{source:u,questionCount:a.length,isInPlanMode:_,interviewPhaseEnabled:_&&yt()});let r=await Qy(g);t(),e.onReject(n,r&&r.length>0?r:void 0)},[a,b,t,e,u,_,g]),ne=(0,Q.useCallback)(async()=>{let n=`The user has indicated they have provided enough answers for the plan interview.
10
- Stop asking clarifying questions and proceed to finish the plan with the information you have.
11
-
12
- Questions asked and answers provided:\n${a.map(e=>{let t=b[e.question];return t?`- "${e.question}"\n Answer: ${t}`:`- "${e.question}"\n (No answer provided)`}).join(`
13
- `)}`;u&&X(`tengu_ask_user_question_finish_plan_interview`,{source:u,questionCount:a.length,isInPlanMode:_,interviewPhaseEnabled:_&&yt()});let r=await Qy(g);t(),e.onReject(n,r&&r.length>0?r:void 0)},[a,b,t,e,u,_,g]),M=(0,Q.useCallback)(async n=>{u&&X(`tengu_ask_user_question_accepted`,{source:u,questionCount:a.length,answerCount:Object.keys(n).length,isInPlanMode:_,interviewPhaseEnabled:_&&yt()});let r={};for(let e of a){let t=n[e.question],i=x[e.question]?.textInputValue,a=(t?e.options.find(e=>e.label===t):void 0)?.preview;(a||i?.trim())&&(r[e.question]={...a&&{preview:a},...i?.trim()&&{notes:i.trim()}})}let i={...e.input,answers:n,...Object.keys(r).length>0&&{annotations:r}},o=await Qy(g);t(),e.onAllow(i,[],void 0,o&&o.length>0?o:void 0)},[e,t,u,a,x,_,g]),N=(0,Q.useCallback)((e,t,n,r=!0)=>{let i,o=Array.isArray(t);i=o?t.join(`, `):n?Object.values(d[e]??{}).filter(e=>e.type===`image`).length>0?`${n} (Image attached)`:n:t===`__other__`&&Object.values(d[e]??{}).filter(e=>e.type===`image`).length>0?`(Image attached)`:t;let s=a.length===1;if(!o&&s&&r){let t={...b,[e]:i};M(t).catch(Y);return}E(e,i,r)},[E,a.length,b,M,d]);function P(e){if(e===`cancel`){j();return}e===`submit`&&M(b).catch(Y)}let F=ee?(a?.length||1)-1:a?.length||0,re=(0,Q.useCallback)(()=>{y>0&&w()},[y,w]),I=(0,Q.useCallback)(()=>{y<F&&C()},[y,F,C]);return El({"tabs:previous":re,"tabs:next":I},{context:`Tabs`,isActive:!(S&&!k)}),O?(0,$.jsx)($.Fragment,{children:(0,$.jsx)(Ly,{question:O,questions:a,currentQuestionIndex:y,answers:b,questionStates:x,hideSubmitTab:ee,minContentHeight:c,minContentWidth:l,planFilePath:v,onUpdateQuestionState:T,onAnswer:N,onTextInputFocus:D,onCancel:j,onSubmit:C,onTabPrev:re,onTabNext:I,onRespondToClaude:te,onFinishPlanInterview:ne,onImagePaste:(e,t,n,r,i)=>m(O.question,e,t,n,r,i),pastedContents:d[O.question]??{},onRemoveImage:e=>h(O.question,e)})}):k?(0,$.jsx)($.Fragment,{children:(0,$.jsx)(Hy,{questions:a,currentQuestionIndex:y,answers:b,allQuestionsAnswered:A,permissionResult:e.permissionResult,minContentHeight:c,onFinalResponse:P})}):null}async function Qy(e){if(e.length!==0)return Promise.all(e.map(async e=>(await dl({type:`image`,source:{type:`base64`,media_type:e.mediaType||`image/png`,data:e.content}})).block))}var $y=[`http://`,`https://`,`ftp://`],eb={rg:2,"pre-commit":2,gcloud:4,"gcloud compute":6,"gcloud beta":6,aws:4,az:4,kubectl:3,docker:3,dotnet:3,"git push":2},tb=e=>Array.isArray(e)?e:[e];function nb(e,t){if(!t?.subcommands?.length)return!1;let n=e.toLowerCase();return t.subcommands.some(e=>Array.isArray(e.name)?e.name.some(e=>e.toLowerCase()===n):e.name.toLowerCase()===n)}function rb(e,t,n){if(n?.options){let t=n.options.find(t=>Array.isArray(t.name)?t.name.includes(e):t.name===e);if(t)return!!t.args}return n?.subcommands?.length&&t&&!t.startsWith(`-`)?!nb(t,n):!1}function ib(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(r){if(r.startsWith(`-`)){rb(r,e[n+1],t)&&n++;continue}if(!t?.subcommands?.length||nb(r,t))return r}}}async function ab(e,t,n){let r=await ob(e,t,n),i=[e],a=!!n?.subcommands?.length,o=!1;for(let s=0;s<t.length;s++){let c=t[s];if(!c||i.length>=r)break;if(c.startsWith(`-`)){if(c===`-c`&&[`python`,`python3`].includes(e.toLowerCase()))break;if(n?.options){let e=n.options.find(e=>Array.isArray(e.name)?e.name.includes(c):e.name===c);if(e?.args&&tb(e.args).some(e=>e?.isCommand||e?.isModule)){i.push(c);continue}}if(a&&!o){rb(c,t[s+1],n)&&s++;continue}break}if(await sb(c,t.slice(0,s),n))break;a&&!o&&(o=nb(c,n)),i.push(c)}return i.join(` `)}async function ob(e,t,n){let r=ib(t,n),i=e.toLowerCase(),a=r?`${i} ${r.toLowerCase()}`:i;if(eb[a])return eb[a];if(eb[i])return eb[i];if(!n)return 2;if(n.options&&t.some(e=>e?.startsWith(`-`)))for(let e of t){if(!e?.startsWith(`-`))continue;let t=n.options.find(t=>Array.isArray(t.name)?t.name.includes(e):t.name===e);if(t?.args&&tb(t.args).some(e=>e?.isCommand||e?.isModule))return 3}if(r&&n.subcommands?.length){let e=r.toLowerCase(),t=n.subcommands.find(t=>Array.isArray(t.name)?t.name.some(t=>t.toLowerCase()===e):t.name.toLowerCase()===e);if(t){if(t.args){let e=tb(t.args);if(e.some(e=>e?.isCommand))return 3;if(e.some(e=>e?.isVariadic))return 2}return t.subcommands?.length?4:t.args?3:2}}if(n.args){let e=tb(n.args);if(e.some(e=>e?.isCommand))return!Array.isArray(n.args)&&n.args.isCommand?2:Math.min(2+e.findIndex(e=>e?.isCommand),3);if(!n.subcommands?.length){if(e.some(e=>e?.isVariadic))return 1;if(e[0]&&!e[0].isOptional)return 2}}return n.args&&tb(n.args).some(e=>e?.isDangerous)?3:2}async function sb(e,t,n){if(e.startsWith(`-`))return!0;let r=e.lastIndexOf(`.`),i=r>0&&r<e.length-1&&!e.substring(r+1).includes(`:`),a=e.includes(`/`)||i,o=$y.some(t=>e.startsWith(t));if(!a&&!o)return!1;if(n?.options&&t.length>0&&t[t.length-1]===`-m`){let e=n.options.find(e=>Array.isArray(e.name)?e.name.includes(`-m`):e.name===`-m`);if(e?.args&&tb(e.args).some(e=>e?.isModule))return!1}return!0}var cb=[{name:`pyright`,description:`Type checker for Python`,options:[{name:[`--help`,`-h`],description:`Show help message`},{name:`--version`,description:`Print pyright version and exit`},{name:[`--watch`,`-w`],description:`Continue to run and watch for changes`},{name:[`--project`,`-p`],description:`Use the configuration file at this location`,args:{name:`FILE OR DIRECTORY`}},{name:`-`,description:`Read file or directory list from stdin`},{name:`--createstub`,description:`Create type stub file(s) for import`,args:{name:`IMPORT`}},{name:[`--typeshedpath`,`-t`],description:`Use typeshed type stubs at this location`,args:{name:`DIRECTORY`}},{name:`--verifytypes`,description:`Verify completeness of types in py.typed package`,args:{name:`IMPORT`}},{name:`--ignoreexternal`,description:`Ignore external imports for --verifytypes`},{name:`--pythonpath`,description:`Path to the Python interpreter`,args:{name:`FILE`}},{name:`--pythonplatform`,description:`Analyze for platform`,args:{name:`PLATFORM`}},{name:`--pythonversion`,description:`Analyze for Python version`,args:{name:`VERSION`}},{name:[`--venvpath`,`-v`],description:`Directory that contains virtual environments`,args:{name:`DIRECTORY`}},{name:`--outputjson`,description:`Output results in JSON format`},{name:`--verbose`,description:`Emit verbose diagnostics`},{name:`--stats`,description:`Print detailed performance stats`},{name:`--dependencies`,description:`Emit import dependency information`},{name:`--level`,description:`Minimum diagnostic level`,args:{name:`LEVEL`}},{name:`--skipunannotated`,description:`Skip type analysis of unannotated functions`},{name:`--warnings`,description:`Use exit code of 1 if warnings are reported`},{name:`--threads`,description:`Use up to N threads to parallelize type checking`,args:{name:`N`,isOptional:!0}}],args:{name:`files`,description:`Specify files or directories to analyze (overrides config file)`,isVariadic:!0,isOptional:!0}},{name:`timeout`,description:`Run a command with a time limit`,args:[{name:`duration`,description:`Duration to wait before timing out (e.g., 10, 5s, 2m)`,isOptional:!1},{name:`command`,description:`Command to run`,isCommand:!0}]},{name:`sleep`,description:`Delay for a specified amount of time`,args:{name:`duration`,description:`Duration to sleep (seconds or with suffix like 5s, 2m, 1h)`,isOptional:!1}},{name:`alias`,description:`Create or list command aliases`,args:{name:`definition`,description:`Alias definition in the form name=value`,isOptional:!0,isVariadic:!0}},{name:`nohup`,description:`Run a command immune to hangups`,args:{name:`command`,description:`Command to run with nohup`,isCommand:!0}},{name:`time`,description:`Time a command`,args:{name:`command`,description:`Command to time`,isCommand:!0}},{name:`srun`,description:`Run a command on SLURM cluster nodes`,options:[{name:[`-n`,`--ntasks`],description:`Number of tasks`,args:{name:`count`,description:`Number of tasks to run`}},{name:[`-N`,`--nodes`],description:`Number of nodes`,args:{name:`count`,description:`Number of nodes to allocate`}}],args:{name:`command`,description:`Command to run on the cluster`,isCommand:!0}}];async function lb(e){if(!e||e.includes(`/`)||e.includes(`\\`)||e.includes(`..`)||e.startsWith(`-`)&&e!==`-`)return null;try{let t=await import(`@withfig/autocomplete/build/${e}.js`);return t.default||t}catch{return null}}var ub=Of(async e=>cb.find(t=>t.name===e)||await lb(e)||null,e=>e),db=/^\d+$/,fb=/^[A-Za-z_][A-Za-z0-9_]*=/,pb=new Set([`nice`]),mb=e=>Array.isArray(e)?e:[e];function hb(e,t){return t?.subcommands?.length?t.subcommands.some(t=>Array.isArray(t.name)?t.name.includes(e):t.name===e):!1}async function gb(e,t=0,n=0){if(n>2||t>10)return null;let r=await Dm(e);if(!r)return null;if(!r.commandNode)return{commandPrefix:null};let{envVars:i,commandNode:a}=r,[o,...s]=Om(a);if(!o)return{commandPrefix:null};let c=await ub(o),l=pb.has(o)||c?.args&&mb(c.args).some(e=>e?.isCommand);l&&s[0]&&hb(s[0],c)&&(l=!1);let u=l?await _b(o,s,t,n):await ab(o,s,c);if(u===null&&t===0&&l)return null;let d=i.length?`${i.join(` `)} `:``;return{commandPrefix:u?d+u:null}}async function _b(e,t,n,r){let i=await ub(e);if(i?.args){let a=mb(i.args).findIndex(e=>e?.isCommand);if(a!==-1){let i=[e];for(let e=0;e<t.length&&e<=a;e++)if(e===a){let a=await gb(t.slice(e).join(` `),n+1,r+1);if(a?.commandPrefix)return i.push(...a.commandPrefix.split(` `)),i.join(` `);break}else t[e]&&!t[e].startsWith(`-`)&&!fb.test(t[e])&&i.push(t[e])}}let a=t.find(e=>!e.startsWith(`-`)&&!db.test(e)&&!fb.test(e));if(!a)return e;let o=await gb(t.slice(t.indexOf(a)).join(` `),n+1,r+1);return o?.commandPrefix?`${e} ${o.commandPrefix}`:null}async function vb(e,t){let n=Ii(e);if(n.length<=1){let t=await gb(e);return t?.commandPrefix?[t.commandPrefix]:[]}let r=[];for(let e of n){let n=e.trim();if(t?.(n))continue;let i=await gb(n);i?.commandPrefix&&r.push(i.commandPrefix)}if(r.length===0)return[];let i=new Map;for(let e of r){let t=e.split(` `)[0],n=i.get(t);n?n.push(e):i.set(t,[e])}let a=[];for(let[,e]of i)a.push(yb(e));return a}function yb(e){if(e.length===0)return``;if(e.length===1)return e[0];let t=e[0].split(` `),n=t.length;for(let r=1;r<e.length;r++){let i=e[r].split(` `),a=0;for(;a<n&&a<i.length&&t[a]===i[a];)a++;n=a}return t.slice(0,Math.max(1,n)).join(` `)}async function bb(e){X(`tengu_unary_event`,{event:e.event,completion_type:e.completion_type,language_name:await e.metadata.language_name,message_id:e.metadata.message_id,platform:e.metadata.platform,...e.metadata.hasFeedback!==void 0&&{hasFeedback:e.metadata.hasFeedback}})}var xb=t((()=>{If()}));qa(),$n(),If(),U(),Rd(),xb();function Sb(e,t){let n=Qo(),r=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{r.current!==e.toolUseID&&(r.current=e.toolUseID,n(e=>({...e,attribution:{...e.attribution,permissionPromptCount:e.attribution.permissionPromptCount+1}})),X(`tengu_tool_use_show_permission_request`,{messageID:e.assistantMessage.message.id,toolName:Em(e.tool.name),isMcp:e.tool.isMcp??!1,decisionReasonType:e.permissionResult.decisionReason?.type,sandboxEnabled:pa.isSandboxingEnabled()}),bb({completion_type:t.completion_type,event:`response`,metadata:{language_name:t.language_name,message_id:e.assistantMessage.message.id,platform:Od.platform}}))},[e,t,n])}Kl(),u(),q(),U(),rf(),ig(),R();function Cb(e){if(e.type===`classifier`)return`${ou.bold(e.classifier)} classifier: ${e.reason}`;switch(e.type){case`rule`:return`${ou.bold(Td(e.rule.ruleValue))} rule from ${Jd(e.rule.source)}`;case`mode`:return`${Pd(e.mode)} mode`;case`sandboxOverride`:return`Requires permission to bypass sandbox`;case`workingDir`:return e.reason;case`safetyCheck`:case`other`:return e.reason;case`permissionPromptTool`:return`${ou.bold(e.permissionPromptToolName)} permission prompt tool`;case`hook`:return e.reason?`${ou.bold(e.hookName)} hook: ${e.reason}`:`${ou.bold(e.hookName)} hook`;case`asyncAgent`:return e.reason;default:return``}}function wb({title:e,decisionReason:t}){let[n]=Dl();function r(){switch(t.type){case`subcommandResults`:return(0,$.jsx)(G,{flexDirection:`column`,children:Array.from(t.reasons.entries()).map(([e,t])=>(0,$.jsxs)(G,{flexDirection:`column`,children:[(0,$.jsxs)(K,{children:[t.behavior===`allow`?Ql(`success`,n)(d.tick):Ql(`error`,n)(d.cross),` `,e]}),t.decisionReason!==void 0&&t.decisionReason.type!==`subcommandResults`&&(0,$.jsxs)(K,{children:[(0,$.jsxs)(K,{dimColor:!0,children:[` `,`⎿`,` `]}),(0,$.jsx)(wl,{children:Cb(t.decisionReason)})]}),t.behavior===`ask`&&(0,$.jsx)(Tb,{suggestions:t.suggestions})]},e))});default:return(0,$.jsx)(K,{children:(0,$.jsx)(wl,{children:Cb(t)})})}}return(0,$.jsxs)(G,{flexDirection:`column`,children:[e&&(0,$.jsx)(K,{children:e}),r()]})}function Tb({suggestions:e}){let t=Fa(e);return t.length===0?null:(0,$.jsxs)(K,{children:[(0,$.jsxs)(K,{dimColor:!0,children:[` `,`⎿`,` `]}),`Suggested rules: `,(0,$.jsx)(wl,{children:t.map(e=>ou.bold(Td(e))).join(`, `)})]})}function Eb(e){return e?e.flatMap(e=>{switch(e.type){case`addDirectories`:return e.directories;default:return[]}}):[]}function Db(e){if(!e)return;let t=e.findLast(e=>e.type===`setMode`);return t?.type===`setMode`?t.mode:void 0}function Ob({suggestions:e,width:t}){if(!e||e.length===0)return(0,$.jsxs)(G,{flexDirection:`row`,children:[(0,$.jsx)(G,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(K,{dimColor:!0,children:`Suggestions `})}),(0,$.jsx)(K,{children:`None`})]});let n=Fa(e),r=Eb(e),i=Db(e);return n.length===0&&r.length===0&&!i?(0,$.jsxs)(G,{flexDirection:`row`,children:[(0,$.jsx)(G,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(K,{dimColor:!0,children:`Suggestion `})}),(0,$.jsx)(K,{children:`None`})]}):(0,$.jsxs)(G,{flexDirection:`column`,children:[(0,$.jsxs)(G,{flexDirection:`row`,children:[(0,$.jsx)(G,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(K,{dimColor:!0,children:`Suggestions `})}),(0,$.jsx)(K,{children:` `})]}),n.length>0&&(0,$.jsxs)(G,{flexDirection:`row`,children:[(0,$.jsx)(G,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(K,{dimColor:!0,children:` Rules `})}),(0,$.jsx)(G,{flexDirection:`column`,children:n.map((e,t)=>(0,$.jsxs)(K,{children:[d.bullet,` `,Td(e)]},t))})]}),r.length>0&&(0,$.jsxs)(G,{flexDirection:`row`,children:[(0,$.jsx)(G,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(K,{dimColor:!0,children:` Directories `})}),(0,$.jsx)(G,{flexDirection:`column`,children:r.map((e,t)=>(0,$.jsxs)(K,{children:[d.bullet,` `,e]},t))})]}),i&&(0,$.jsxs)(G,{flexDirection:`row`,children:[(0,$.jsx)(G,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(K,{dimColor:!0,children:` Mode `})}),(0,$.jsx)(K,{children:Pd(i)})]})]})}function kb({permissionResult:e,toolName:t}){let n=W(e=>e.toolPermissionContext),r=e.decisionReason,i=`suggestions`in e?e.suggestions:void 0,a=(0,Q.useMemo)(()=>{let e=pa.isSandboxingEnabled()&&pa.isAutoAllowBashIfSandboxedEnabled(),r=ag(n,{sandboxAutoAllowEnabled:e}),a=Fa(i);return a.length>0?r.filter(e=>a.some(t=>t.toolName===e.rule.ruleValue.toolName&&t.ruleContent===e.rule.ruleValue.ruleContent)):t?r.filter(e=>e.rule.ruleValue.toolName===t):r},[n,t,i]);return(0,$.jsxs)(G,{flexDirection:`column`,children:[(0,$.jsxs)(G,{flexDirection:`row`,children:[(0,$.jsx)(G,{justifyContent:`flex-end`,minWidth:10,children:(0,$.jsx)(K,{dimColor:!0,children:`Behavior `})}),(0,$.jsx)(K,{children:e.behavior})]}),e.behavior!==`allow`&&(0,$.jsxs)(G,{flexDirection:`row`,children:[(0,$.jsx)(G,{justifyContent:`flex-end`,minWidth:10,children:(0,$.jsx)(K,{dimColor:!0,children:`Message `})}),(0,$.jsx)(K,{children:e.message})]}),(0,$.jsxs)(G,{flexDirection:`row`,children:[(0,$.jsx)(G,{justifyContent:`flex-end`,minWidth:10,children:(0,$.jsx)(K,{dimColor:!0,children:`Reason `})}),r===void 0?(0,$.jsx)(K,{children:`undefined`}):(0,$.jsx)(wb,{decisionReason:r})]}),(0,$.jsx)(Ob,{suggestions:i,width:10}),a.length>0&&(0,$.jsxs)(G,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(K,{color:`warning`,children:[d.warning,` Unreachable Rules (`,a.length,`)`]}),a.map((e,t)=>(0,$.jsxs)(G,{flexDirection:`column`,marginLeft:2,children:[(0,$.jsx)(K,{color:`warning`,children:Td(e.rule.ruleValue)}),(0,$.jsxs)(K,{dimColor:!0,children:[` `,e.reason]}),(0,$.jsxs)(K,{dimColor:!0,children:[` `,`Fix: `,e.fix]})]},t))]})]})}Su(),If(),Tm(),lf(),bd(),Cu(),Ef(),Fm(),qo();var Ab={LOW:1,MEDIUM:2,HIGH:3},jb=1,Mb=2,Nb=3,Pb=`Analyze shell commands and explain what they do, why you're running them, and potential risks.`,Fb={name:`explain_command`,description:`Provide an explanation of a shell command`,input_schema:{type:`object`,properties:{explanation:{type:`string`,description:`What this command does (1-2 sentences)`},reasoning:{type:`string`,description:`Why YOU are running this command. Start with "I" - e.g. "I need to check the file contents"`},risk:{type:`string`,description:`What could go wrong, under 15 words`},riskLevel:{type:`string`,enum:[`LOW`,`MEDIUM`,`HIGH`],description:`LOW (safe dev workflows), MEDIUM (recoverable changes), HIGH (dangerous/irreversible)`}},required:[`explanation`,`reasoning`,`risk`,`riskLevel`]}},Ib=xu(()=>bu({riskLevel:vu([`LOW`,`MEDIUM`,`HIGH`]),explanation:pu(),reasoning:pu(),risk:pu()}));function Lb(e){if(typeof e==`string`)return e;try{return ud(e,null,2)}catch{return String(e)}}function Rb(e,t=1e3){let n=e.filter(e=>e.type===`assistant`).slice(-3),r=[],i=0;for(let e of n.reverse()){let n=(Array.isArray(e.message.content)?e.message.content:[]).filter(e=>e.type===`text`).map(e=>`text`in e?e.text:``).join(` `);if(n&&i<t){let e=t-i,a=n.length>e?n.slice(0,e)+`...`:n;r.unshift(a),i+=a.length}}return r.join(`
14
-
15
- `)}function zb(){return cf().permissionExplainerEnabled!==!1}async function Bb({toolName:e,toolInput:t,toolDescription:n,messages:r,signal:i}){if(!zb())return null;let a=Date.now();try{let o=Lb(t),s=r?.length?Rb(r):``,c=`Tool: ${e}
16
- ${n?`Description: ${n}\n`:``}
17
- Input:
18
- ${o}
19
- ${s?`\nRecent conversation context:\n${s}`:``}
20
-
21
- Explain this command in context.`,l=await Sc({model:Pm()?wp():Lp(),system:Pb,messages:[{role:`user`,content:c}],tools:[Fb],tool_choice:{type:`tool`,name:`explain_command`},signal:i,querySource:`permission_explainer`}),u=Date.now()-a;J(`Permission explainer: API returned in ${u}ms, stop_reason=${l.stop_reason}`);let d=l.content.find(e=>e.type===`tool_use`);if(d&&d.type===`tool_use`){J(`Permission explainer: tool input: ${ud(d.input).slice(0,500)}`);let t=Ib().safeParse(d.input);if(t.success){let n={riskLevel:t.data.riskLevel,explanation:t.data.explanation,reasoning:t.data.reasoning,risk:t.data.risk};return X(`tengu_permission_explainer_generated`,{tool_name:Em(e),risk_level:Ab[n.riskLevel],latency_ms:u}),J(`Permission explainer: ${n.riskLevel} risk for ${e} (${u}ms)`),n}}return X(`tengu_permission_explainer_error`,{tool_name:Em(e),error_type:jb,latency_ms:u}),J(`Permission explainer: no parsed output in response`),null}catch(t){let n=Date.now()-a;return i.aborted?(J(`Permission explainer: request aborted for ${e}`),null):(J(`Permission explainer error: ${fd(t)}`),Y(t),X(`tengu_permission_explainer_error`,{tool_name:Em(e),error_type:t instanceof Error&&t.name===`AbortError`?Mb:Nb,latency_ms:n}),null)}}q(),O(),If();var Vb=`Loading explanation…`;function Hb(){let[e,t]=Ge(`responding`,Vb,!1);return(0,$.jsx)(G,{ref:e,children:(0,$.jsx)(K,{children:Vb.split(``).map((e,n)=>(0,$.jsx)(Oa,{char:e,index:n,glimmerIndex:t,messageColor:`inactive`,shimmerColor:`text`},n))})})}function Ub(e){switch(e){case`LOW`:return`success`;case`MEDIUM`:return`warning`;case`HIGH`:return`error`}}function Wb(e){switch(e){case`LOW`:return`Low risk`;case`MEDIUM`:return`Med risk`;case`HIGH`:return`High risk`}}function Gb(e){return Bb({toolName:e.toolName,toolInput:e.toolInput,toolDescription:e.toolDescription,messages:e.messages,signal:new AbortController().signal}).catch(()=>null)}function Kb(e){let t=zb(),[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(null);return Il(`confirm:toggleExplanation`,()=>{n||(X(`tengu_permission_explainer_shortcut_used`,{}),i||a(Gb(e))),r(e=>!e)},{context:`Confirmation`,isActive:t}),{visible:n,enabled:t,promise:i}}function qb({promise:e}){let t=(0,Q.use)(e);return t?(0,$.jsxs)(G,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(K,{children:t.explanation}),(0,$.jsx)(G,{marginTop:1,children:(0,$.jsx)(K,{children:t.reasoning})}),(0,$.jsx)(G,{marginTop:1,children:(0,$.jsxs)(K,{children:[(0,$.jsxs)(K,{color:Ub(t.riskLevel),children:[Wb(t.riskLevel),`:`]}),(0,$.jsxs)(K,{children:[` `,t.risk]})]})})]}):(0,$.jsx)(G,{marginTop:1,children:(0,$.jsx)(K,{dimColor:!0,children:`Explanation unavailable`})})}function Jb({visible:e,promise:t}){return!e||!t?null:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(G,{marginTop:1,children:(0,$.jsx)(Hb,{})}),children:(0,$.jsx)(qb,{promise:t})})}ht(),q(),Ef(),$t(),st();function Yb(e){let[t]=(0,Q.useState)(()=>Qb(e.file_path,e.edits));return(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(Zb,{placeholder:!0}),children:(0,$.jsx)(Xb,{promise:t,file_path:e.file_path})})}function Xb({promise:e,file_path:t}){let{patch:n,firstLine:r,fileContent:i}=(0,Q.use)(e),{columns:a}=tu();return(0,$.jsx)(Zb,{children:(0,$.jsx)(Jr,{hunks:n,dim:!1,width:a,filePath:t,firstLine:r,fileContent:i})})}function Zb({children:e,placeholder:t}){return(0,$.jsx)(G,{flexDirection:`column`,children:(0,$.jsx)(G,{borderColor:`subtle`,borderStyle:`dashed`,flexDirection:`column`,borderLeft:!1,borderRight:!1,children:t?(0,$.jsx)(K,{dimColor:!0,children:`…`}):e})})}async function Qb(e,t){let n=t.filter(e=>e.old_string!=null&&e.new_string!=null),r=n.length===1?n[0]:void 0;if(r&&r.old_string.length>=8192)return $b(e,[r]);try{let t=await dr(e);if(t===null)return $b(e,n);try{if(!r||r.old_string===``){let r=await gl(t);return r===null?$b(e,n):{patch:Vn({filePath:e,fileContents:r,edits:n.map(e=>ex(r,e))}),firstLine:Yf(r),fileContent:r}}let i=await ie(t,r.old_string,3);if(i.truncated||i.content===``)return $b(e,[r]);let a=ex(i.content,r);return{patch:De(Vn({filePath:e,fileContents:i.content,edits:[a]}),i.lineOffset-1),firstLine:i.lineOffset===1?Yf(i.content):null,fileContent:i.content}}finally{await t.close()}}catch(t){return Y(t),$b(e,n)}}function $b(e,t){return{patch:t.flatMap(t=>Vn({filePath:e,fileContents:t.old_string,edits:[t]})),firstLine:null,fileContent:void 0}}function ex(e,t){let n=ye(e,t.old_string)||t.old_string;return{...t,old_string:n}}oi(),If(),Fe(),lf(),N(),pd(),Uc(),Ef();function tx({onChange:e,toolUseContext:t,filePath:n,edits:r,editMode:i}){let a=(0,Q.useRef)(!1),[o,s]=(0,Q.useState)(!1),c=(0,Q.useMemo)(()=>d_().slice(0,6),[]),l=(0,Q.useMemo)(()=>`✻ [Work Mate] ${n_(n)} (${c}) ⧉`,[n,c]),u=fe(t.options.mcpClients)&&cf().diffTool===`auto`&&!n.endsWith(`.ipynb`),d=ha(t.options.mcpClients)??`IDE`;async function f(){if(u)try{X(`tengu_ext_will_show_diff`,{});let{oldContent:o,newContent:s}=await rx(n,r,t,l);if(a.current)return;X(`tengu_ext_diff_accepted`,{});let c=nx(n,o,s,i);if(c.length===0){X(`tengu_ext_diff_rejected`,{});let i=ol(t.options.mcpClients);i&&await ix(l,i),e({type:`reject`},{file_path:n,edits:r});return}e({type:`accept-once`},{file_path:n,edits:c})}catch(e){Y(e),s(!0)}}return(0,Q.useEffect)(()=>(f(),()=>{a.current=!0}),[]),{closeTabInIDE(){let e=ol(t.options.mcpClients);return e?ix(l,e):Promise.resolve()},showingDiffInIDE:u&&!o,ideName:d,hasError:o}}function nx(e,t,n,r){let i=r===`single`,a=Ko({filePath:e,oldContent:t,newContent:n,singleHunk:i});return a.length===0?[]:(i&&a.length>1&&Y(Error(`Unexpected number of hunks: ${a.length}. Expected 1 hunk.`)),Zc(a))}async function rx(e,t,n,r){let i=!1,a=Yd(e),o=``;try{o=Ld(a)}catch(e){if(!ld(e))throw e}async function s(){if(!i){i=!0;try{await ix(r,c)}catch(e){Y(e)}process.off(`beforeExit`,s),n.abortController.signal.removeEventListener(`abort`,s)}}n.abortController.signal.addEventListener(`abort`,s),process.on(`beforeExit`,s);let c=ol(n.options.mcpClients);try{let{updatedFile:e}=Mr({filePath:a,fileContents:o,edits:t});if(!c||c.type!==`connected`)throw Error(`IDE client not available`);let n=a,i=c.config.ideRunningInWindows===!0;Mf()===`wsl`&&i&&process.env.WSL_DISTRO_NAME&&(n=new Re(process.env.WSL_DISTRO_NAME).toIDEPath(a));let l=await cr(`openDiff`,{old_file_path:n,new_file_path:n,new_file_contents:e,tab_name:r},c),u=Array.isArray(l)?l:[l];if(sx(u))return s(),{oldContent:o,newContent:u[1].text};if(ax(u))return s(),{oldContent:o,newContent:e};if(ox(u))return s(),{oldContent:o,newContent:o};throw Error(`Not accepted`)}catch(e){throw Y(e),s(),e}}async function ix(e,t){try{if(!t||t.type!==`connected`)throw Error(`IDE client not available`);await cr(`close_tab`,{tab_name:e},t)}catch(e){Y(e)}}function ax(e){return Array.isArray(e)&&typeof e[0]==`object`&&e[0]!==null&&`type`in e[0]&&e[0].type===`text`&&`text`in e[0]&&e[0].text===`TAB_CLOSED`}function ox(e){return Array.isArray(e)&&typeof e[0]==`object`&&e[0]!==null&&`type`in e[0]&&e[0].type===`text`&&`text`in e[0]&&e[0].text===`DIFF_REJECTED`}function sx(e){return Array.isArray(e)&&e[0]?.type===`text`&&e[0].text===`FILE_SAVED`&&typeof e[1].text==`string`}q(),Uc(),wi();function cx({onChange:e,options:t,input:n,filePath:r,ideName:i,symlinkTarget:a,rejectFeedback:o,acceptFeedback:s,setFocusedOption:c,onInputModeToggle:l,focusedOption:u,yesInputMode:d,noInputMode:f}){return(0,$.jsx)(cu,{color:`permission`,children:(0,$.jsxs)(G,{flexDirection:`column`,gap:1,children:[(0,$.jsxs)(K,{bold:!0,color:`permission`,children:[`Opened changes in `,i,` ⧉`]}),a&&(0,$.jsx)(K,{color:`warning`,children:o_(cd(),a).startsWith(`..`)?`This will modify ${a} (outside working directory) via a symlink`:`Symlink target: ${a}`}),Bo()&&(0,$.jsx)(K,{dimColor:!0,children:`Save file to continue…`}),(0,$.jsxs)(G,{flexDirection:`column`,children:[(0,$.jsxs)(K,{children:[`Do you want to make this edit to `,(0,$.jsx)(K,{bold:!0,children:n_(r)}),`?`]}),(0,$.jsx)(Hi,{options:t,inlineDescriptions:!0,onChange:r=>{let i=t.find(e=>e.value===r);if(i){if(i.option.type===`reject`){let t=o.trim();e(i.option,n,t||void 0);return}if(i.option.type===`accept-once`){let t=s.trim();e(i.option,n,t||void 0);return}e(i.option,n)}},onCancel:()=>e({type:`reject`},n),onFocus:e=>c(e),onInputModeToggle:l})]}),(0,$.jsx)(G,{marginTop:1,children:(0,$.jsxs)(K,{dimColor:!0,children:[`Esc to cancel`,(u===`yes`&&!d||u===`no`&&!f)&&` · Tab to amend`]})})]})})}Ru(),q(),Bd();function lx(e){let t=Yd(e),n=Yd(`${Gu()}/.workmate`),r=fr(t),i=fr(n);return r.startsWith(i+s_.toLowerCase())||r.startsWith(i+`/`)}function ux(e){let t=Yd(e),n=a_($g(),`.workmate`),r=fr(t),i=fr(n);return r.startsWith(i+s_.toLowerCase())||r.startsWith(i+`/`)}function dx({filePath:e,toolPermissionContext:t,operationType:n=`write`,onRejectFeedbackChange:r,onAcceptFeedbackChange:i,yesInputMode:a=!1,noInputMode:o=!1}){let s=[],c=Hn(`chat:cycleMode`,`Chat`,`shift+tab`);a&&i?s.push({type:`input`,label:`Yes`,value:`yes`,placeholder:`and tell Claude what to do next`,onChange:i,allowEmptySubmitToCancel:!0,option:{type:`accept-once`}}):s.push({label:`Yes`,value:`yes`,option:{type:`accept-once`}});let l=yl(e,t),u=lx(e),d=ux(e);if((u||d)&&n!==`read`)s.push({label:`Yes, allow edits to .workmate/ config for this session`,value:`yes-claude-folder`,option:{type:`accept-session`,scope:d?`global-claude-folder`:`claude-folder`}});else{let t;if(l)t=n===`read`?`Yes, during this session`:(0,$.jsxs)(K,{children:[`Yes, allow all edits during this session `,(0,$.jsxs)(K,{bold:!0,children:[`(`,c,`)`]})]});else{let r=n_(Qd(e))||`this directory`;t=n===`read`?(0,$.jsxs)(K,{children:[`Yes, allow reading from `,(0,$.jsxs)(K,{bold:!0,children:[r,`/`]}),` during this session`]}):(0,$.jsxs)(K,{children:[`Yes, allow all edits in `,(0,$.jsxs)(K,{bold:!0,children:[r,`/`]}),` during this session`,` `,(0,$.jsxs)(K,{bold:!0,children:[`(`,c,`)`]})]})}s.push({label:t,value:`yes-session`,option:{type:`accept-session`}})}return o&&r?s.push({type:`input`,label:`No`,value:`no`,placeholder:`and tell Claude what to do differently`,onChange:r,allowEmptySubmitToCancel:!0,option:{type:`reject`}}):s.push({label:`No`,value:`no`,option:{type:`reject`}}),s}If(),Tm(),Rd(),xt(),xb();function fx(e,t,n,r,i){bb({completion_type:t,event:e,metadata:{language_name:n,message_id:r,platform:Od.platform,hasFeedback:i??!1}})}function px(e,t){let{messageId:n,toolUseConfirm:r,onDone:i,completionType:a,languageName:o}=e;fx(`accept`,a,o,n),X(`tengu_accept_submitted`,{toolName:Em(r.tool.name),isMcp:r.tool.isMcp??!1,has_instructions:!!t?.feedback,instructions_length:t?.feedback?.length??0,entered_feedback_mode:t?.enteredFeedbackMode??!1}),i(),r.onAllow(r.input,[],t?.feedback)}function mx(e,t){let{messageId:n,path:r,toolUseConfirm:i,toolPermissionContext:a,onDone:o,completionType:s,languageName:c,operationType:l}=e;if(fx(`accept`,s,c,n),t?.scope===`claude-folder`||t?.scope===`global-claude-folder`){let e=[{type:`addRules`,rules:[{toolName:Jp,ruleContent:t.scope===`global-claude-folder`?Xp:qp}],behavior:`allow`,destination:`session`}];o(),i.onAllow(i.input,e);return}let u=r?En(r,l,a):[];o(),i.onAllow(i.input,u)}function hx(e,t){let{messageId:n,toolUseConfirm:r,onDone:i,onReject:a,completionType:o,languageName:s}=e;fx(`reject`,o,s,n,t?.hasFeedback),X(`tengu_reject_submitted`,{toolName:Em(r.tool.name),isMcp:r.tool.isMcp??!1,has_instructions:!!t?.feedback,instructions_length:t?.feedback?.length??0,entered_feedback_mode:t?.enteredFeedbackMode??!1}),i(),a(),r.onReject(t?.feedback)}var gx={"accept-once":px,"accept-session":mx,reject:hx};U(),O(),If(),Tm();function _x({filePath:e,completionType:t,languageName:n,toolUseConfirm:r,onDone:i,onReject:a,parseInput:o,operationType:s=`write`}){let c=W(e=>e.toolPermissionContext),[l,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)(``),[p,m]=(0,Q.useState)(`yes`),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(!1),C=(0,Q.useMemo)(()=>dx({filePath:e,toolPermissionContext:c,operationType:s,onRejectFeedbackChange:f,onAcceptFeedbackChange:u,yesInputMode:h,noInputMode:_}),[e,c,s,h,_]),w=(0,Q.useCallback)((o,l,u)=>{let d={messageId:r.assistantMessage.message.id,path:e,toolUseConfirm:r,toolPermissionContext:c,onDone:i,onReject:a,completionType:t,languageName:n,operationType:s},f=r.onAllow;r.onAllow=(e,t,n)=>{f(l,t,n)};let p=gx[o.type];p(d,{feedback:u,hasFeedback:!!u,enteredFeedbackMode:o.type===`accept-once`?y:x,scope:o.type===`accept-session`?o.scope:void 0})},[e,t,n,r,c,i,a,s,y,x]);return El({"confirm:cycleMode":(0,Q.useCallback)(()=>{let e=C.find(e=>e.option.type===`accept-session`);if(e){let t=o(r.input);w(e.option,t)}},[C,o,r.input,w])},{context:`Confirmation`}),{options:C,onChange:w,acceptFeedback:l,rejectFeedback:d,focusedOption:p,setFocusedOption:(0,Q.useCallback)(e=>{e!==`yes`&&h&&!l.trim()&&g(!1),e!==`no`&&_&&!d.trim()&&v(!1),m(e)},[h,_,l,d]),handleInputModeToggle:(0,Q.useCallback)(e=>{let t={toolName:Em(r.tool.name),isMcp:r.tool.isMcp??!1};e===`yes`?h?(g(!1),X(`tengu_accept_feedback_mode_collapsed`,t)):(g(!0),b(!0),X(`tengu_accept_feedback_mode_entered`,t)):e===`no`&&(_?(v(!1),X(`tengu_reject_feedback_mode_collapsed`,t)):(v(!0),S(!0),X(`tengu_reject_feedback_mode_entered`,t)))},[h,_,r]),yesInputMode:h,noInputMode:_}}q(),H(),sd(),Bd(),wi();function vx({toolUseConfirm:e,toolUseContext:t,onDone:n,onReject:r,title:i,subtitle:a,question:o=`Do you want to proceed?`,content:s,completionType:c=`tool_use_single`,path:l,parseInput:u,operationType:d=`write`,ideDiffSupport:f,languageName:p}){let m=(0,Q.useMemo)(()=>p??(l?Bi(l):`none`),[p,l]);Sb(e,(0,Q.useMemo)(()=>({completion_type:c,language_name:m}),[c,m]));let h=(0,Q.useMemo)(()=>{if(!l||d===`read`)return null;let e=Yd(l),{resolvedPath:t,isSymlink:n}=yd(Cd(),e);return n?t:null},[l,d]),g=_x({filePath:l||``,completionType:c,languageName:m,toolUseConfirm:e,onDone:n,onReject:r,parseInput:u,operationType:d}),{options:_,acceptFeedback:v,rejectFeedback:y,setFocusedOption:b,handleInputModeToggle:x,focusedOption:S,yesInputMode:C,noInputMode:w}=g,T=u(e.input),E=(0,Q.useMemo)(()=>f?f.getConfig(u(e.input)):null,[f,e.input]),{closeTabInIDE:D,showingDiffInIDE:O,ideName:k}=tx(E?{onChange:(e,t)=>{let n=f.applyChanges(T,t.edits);g.onChange(e,n)},toolUseContext:t,filePath:E.filePath,edits:(E.edits||[]).map(e=>({old_string:e.old_string,new_string:e.new_string,replace_all:e.replace_all||!1})),editMode:E.editMode||`single`}:{onChange:()=>{},toolUseContext:t,filePath:``,edits:[],editMode:`single`}),A=(e,t)=>{D?.(),g.onChange(e,T,t?.trim())};if(O&&E&&l)return(0,$.jsx)(cx,{onChange:(e,t,n)=>A(e,n),options:_,filePath:l,input:T,ideName:k,symlinkTarget:h,rejectFeedback:y,acceptFeedback:v,setFocusedOption:b,onInputModeToggle:x,focusedOption:S,yesInputMode:C,noInputMode:w});let ee=h!=null&&o_(cd(),h).startsWith(`..`);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(hg,{title:i,subtitle:a,innerPaddingX:0,children:[h?(0,$.jsx)(G,{paddingX:1,marginBottom:1,children:(0,$.jsx)(K,{color:`warning`,children:ee?`This will modify ${h} (outside working directory) via a symlink`:`Symlink target: ${h}`})}):null,s,(0,$.jsxs)(G,{flexDirection:`column`,paddingX:1,children:[typeof o==`string`?(0,$.jsx)(K,{children:o}):o,(0,$.jsx)(Hi,{options:_,inlineDescriptions:!0,onChange:e=>{let t=_.find(t=>t.value===e);if(t){if(t.option.type===`reject`){let e=y.trim();A(t.option,e||void 0);return}if(t.option.type===`accept-once`){let e=v.trim();A(t.option,e||void 0);return}A(t.option)}},onCancel:()=>A({type:`reject`}),onFocus:e=>b(e),onInputModeToggle:x})]})]}),(0,$.jsx)(G,{paddingX:1,marginTop:1,children:(0,$.jsxs)(K,{dimColor:!0,children:[`Esc to reject`,(S===`yes`&&!C||S===`no`&&!w)&&` · Tab to add feedback`]})})]})}sd(),pd(),Dd(),vd(),q();function yx({sedInfo:e,...t}){let{filePath:n}=e;return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(bx,{sedInfo:e,contentPromise:(0,Q.useMemo)(()=>(async()=>{let e=Xd(n);return{oldContent:(await Cd().readFile(n,{encoding:e})).replaceAll(`\r
22
- `,`
23
- `),fileExists:!0}})().catch(e=>{if(!ld(e))throw e;return{oldContent:``,fileExists:!1}}),[n]),...t})})}function bx({sedInfo:e,contentPromise:t,...n}){let{filePath:r}=e,{oldContent:i,fileExists:a}=(0,Q.use)(t),o=(0,Q.useMemo)(()=>Qs(i,e),[i,e]),s=(0,Q.useMemo)(()=>i===o?[]:[{old_string:i,new_string:o,replace_all:!1}],[i,o]),c=(0,Q.useMemo)(()=>a?`Pattern did not match any content`:`File does not exist`,[a]);return(0,$.jsx)(vx,{toolUseConfirm:n.toolUseConfirm,toolUseContext:n.toolUseContext,onDone:n.onDone,onReject:n.onReject,title:`Edit file`,subtitle:o_(cd(),r),question:(0,$.jsxs)(K,{children:[`Do you want to make this edit to `,(0,$.jsx)(K,{bold:!0,children:n_(r)}),`?`]}),content:s.length>0?(0,$.jsx)(Yb,{file_path:r,edits:s}):(0,$.jsx)(K,{dimColor:!0,children:c}),path:r,completionType:`str_replace_single`,parseInput:e=>({...Vi.inputSchema.parse(e),_simulatedSedEdit:{filePath:r,newContent:o}})})}Rd(),xb();function xx(e,{assistantMessage:{message:{id:t}}},n,r){bb({completion_type:e,event:n,metadata:{language_name:`none`,message_id:t,platform:Zd(),hasFeedback:r??!1}})}If(),Tm(),U();function Sx({toolUseConfirm:e,onDone:t,onReject:n,explainerVisible:r}){let i=Qo(),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(`yes`),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(!1);function y(t){e.onUserInteraction();let n={toolName:Em(e.tool.name),isMcp:e.tool.isMcp??!1};t===`yes`?l?(u(!1),X(`tengu_accept_feedback_mode_collapsed`,n)):(u(!0),g(!0),X(`tengu_accept_feedback_mode_entered`,n)):t===`no`&&(d?(f(!1),X(`tengu_reject_feedback_mode_collapsed`,n)):(f(!0),v(!0),X(`tengu_reject_feedback_mode_entered`,n)))}function b(a){let o=a?.trim(),s=!!o;s||(X(`tengu_permission_request_escape`,{explainer_visible:r}),i(e=>({...e,attribution:{...e.attribution,escapeCount:e.attribution.escapeCount+1}}))),xx(`tool_use_single`,e,`reject`,s),o?e.onReject(o):e.onReject(),n(),t()}function x(t){t!==p&&e.onUserInteraction(),t!==`yes`&&l&&!s.trim()&&u(!1),t!==`no`&&d&&!a.trim()&&f(!1),m(t)}return{yesInputMode:l,noInputMode:d,yesFeedbackModeEntered:h,noFeedbackModeEntered:_,acceptFeedback:s,rejectFeedback:a,setAcceptFeedback:c,setRejectFeedback:o,focusedOption:p,handleInputModeToggle:y,handleReject:b,handleFocus:x}}Ru(),q();function Cx(e){switch(e.length){case 0:return``;case 1:return(0,$.jsx)(K,{bold:!0,children:e[0]});case 2:return(0,$.jsxs)(K,{children:[(0,$.jsx)(K,{bold:!0,children:e[0]}),` and `,(0,$.jsx)(K,{bold:!0,children:e[1]})]});default:return(0,$.jsxs)(K,{children:[(0,$.jsx)(K,{bold:!0,children:e.slice(0,-1).join(`, `)}),`, and `,(0,$.jsx)(K,{bold:!0,children:e.slice(-1)[0]})]})}}function wx(e){return e.join(`, `).length>50?`similar`:Cx(e)}function Tx(e){if(e.length===0)return``;let t=e.map(e=>n_(e)||e);return t.length===1?(0,$.jsxs)(K,{children:[(0,$.jsx)(K,{bold:!0,children:t[0]}),s_]}):t.length===2?(0,$.jsxs)(K,{children:[(0,$.jsx)(K,{bold:!0,children:t[0]}),s_,` and `,(0,$.jsx)(K,{bold:!0,children:t[1]}),s_]}):(0,$.jsxs)(K,{children:[(0,$.jsx)(K,{bold:!0,children:t[0]}),s_,`, `,(0,$.jsx)(K,{bold:!0,children:t[1]}),s_,` and `,e.length-2,` more`]})}function Ex(e,t,n){let r=e.filter(e=>e.type===`addRules`).flatMap(e=>e.rules||[]),i=r.filter(e=>e.toolName===`Read`),a=r.filter(e=>e.toolName===t),o=e.filter(e=>e.type===`addDirectories`).flatMap(e=>e.directories||[]),s=i.map(e=>e.ruleContent?.replace(`/**`,``)||``).filter(e=>e),c=[...new Set(a.flatMap(e=>{if(!e.ruleContent)return[];let t=pl(e.ruleContent)??e.ruleContent;return n?n(t):t}))],l=o.length>0,u=s.length>0,d=c.length>0;if(u&&!l&&!d){if(s.length===1){let e=s[0];return(0,$.jsxs)(K,{children:[`Yes, allow reading from `,(0,$.jsx)(K,{bold:!0,children:n_(e)||e}),s_,` from this project`]})}return(0,$.jsxs)(K,{children:[`Yes, allow reading from `,Tx(s),` from this project`]})}if(l&&!u&&!d){if(o.length===1){let e=o[0];return(0,$.jsxs)(K,{children:[`Yes, and always allow access to `,(0,$.jsx)(K,{bold:!0,children:n_(e)||e}),s_,` from this project`]})}return(0,$.jsxs)(K,{children:[`Yes, and always allow access to `,Tx(o),` from this project`]})}if(d&&!l&&!u)return(0,$.jsxs)(K,{children:[`Yes, and don't ask again for `,wx(c),` commands in `,(0,$.jsx)(K,{bold:!0,children:Gu()})]});if((l||u)&&!d){let e=[...o,...s];if(l&&u)return(0,$.jsxs)(K,{children:[`Yes, and always allow access to `,Tx(e),` from this project`]})}if((l||u)&&d){let e=[...o,...s];return e.length===1&&c.length===1?(0,$.jsxs)(K,{children:[`Yes, and allow access to `,Tx(e),` and `,wx(c),` commands`]}):(0,$.jsxs)(K,{children:[`Yes, and allow `,Tx(e),` access and `,wx(c),` commands`]})}return null}_i();function Dx(e){let{commandWithoutRedirections:t,redirections:n}=Ei(e);return n.length>0?t:e}function Ox({suggestions:e=[],decisionReason:t,onRejectFeedbackChange:n,onAcceptFeedbackChange:r,onClassifierDescriptionChange:i,classifierDescription:a,initialClassifierDescriptionEmpty:o=!1,existingAllowDescriptions:s=[],yesInputMode:c=!1,noInputMode:l=!1,editablePrefix:u,onEditablePrefixChange:d}){let f=[];if(c?f.push({type:`input`,label:`Yes`,value:`yes`,placeholder:`and tell Claude what to do next`,onChange:r,allowEmptySubmitToCancel:!0}):f.push({label:`Yes`,value:`yes`}),nc()){let t=e.some(e=>e.type===`addDirectories`||e.type===`addRules`&&e.rules?.some(e=>e.toolName!==`Bash`));if(u!==void 0&&d&&!t&&e.length>0)f.push({type:`input`,label:`Yes, and don’t ask again for`,value:`yes-prefix-edited`,placeholder:`command prefix (e.g., npm run:*)`,initialValue:u,onChange:d,allowEmptySubmitToCancel:!0,showLabelWithValue:!0,labelValueSeparator:`: `,resetCursorOnUpdate:!0});else if(e.length>0){let t=Ex(e,Gp,Dx);t&&f.push({label:t,value:`yes-apply-suggestions`})}}return l?f.push({type:`input`,label:`No`,value:`no`,placeholder:`and tell Claude what to do differently`,onChange:n,allowEmptySubmitToCancel:!0}):f.push({label:`No`,value:`no`}),f}q(),O(),If(),Tm(),U(),ir(),Co(),dc(),R(),qa(),$n(),pg(),Vy();function kx(e){let{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,verbose:a}=e,{command:o,description:s}=Vi.inputSchema.parse(t.input),c=ra(o);return c?(0,$.jsx)(yx,{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,verbose:a,sedInfo:c}):(0,$.jsx)(Ax,{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,verbose:a,command:o,description:s})}function Ax({toolUseConfirm:e,toolUseContext:t,onDone:n,onReject:r,verbose:i,command:a,description:o}){let[s]=Dl(),c=W(e=>e.toolPermissionContext),l=Kb({toolName:e.tool.name,toolInput:e.input,toolDescription:e.description,messages:t.messages}),{yesInputMode:u,noInputMode:d,yesFeedbackModeEntered:f,noFeedbackModeEntered:p,acceptFeedback:m,rejectFeedback:h,setAcceptFeedback:g,setRejectFeedback:_,focusedOption:v,handleInputModeToggle:y,handleReject:b,handleFocus:x}=Sx({toolUseConfirm:e,onDone:n,onReject:r,explainerVisible:l.visible}),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(o||``),[E,D]=(0,Q.useState)(!o?.trim());(0,Q.useEffect)(()=>{if(!Os())return;let e=new AbortController;return Cc(a,o,e.signal).then(t=>{t&&!e.signal.aborted&&(T(t),D(!1))}).catch(()=>{}),()=>e.abort()},[a,o]);let O=e.permissionResult.decisionReason?.type===`subcommandResults`,[k,A]=(0,Q.useState)(()=>{if(O){let t=Fa(`suggestions`in e.permissionResult?e.permissionResult.suggestions:void 0).filter(e=>e.toolName===Vi.name&&e.ruleContent);return t.length===1?t[0].ruleContent:void 0}let t=ji(a);if(t)return`${t}:*`;let n=At(a);return n?`${n}:*`:a}),ee=(0,Q.useRef)(!1),j=(0,Q.useCallback)(e=>{ee.current=!0,A(e)},[]);(0,Q.useEffect)(()=>{if(O)return;let e=!1;return vb(a,e=>Vi.isReadOnly({command:e})).then(t=>{e||ee.current||t.length>0&&A(`${t[0]}:*`)}).catch(()=>{}),()=>{e=!0}},[a,O]);let[te]=(0,Q.useState)(!1),{destructiveWarning:ne,sandboxingEnabled:M,isSandboxed:N}=(0,Q.useMemo)(()=>{let t=pa.isSandboxingEnabled();return{destructiveWarning:null,sandboxingEnabled:t,isSandboxed:t&&Is(e.input)}},[a,e.input]);Sb(e,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let P=(0,Q.useMemo)(()=>Da(c),[c]),F=(0,Q.useMemo)(()=>Ox({suggestions:e.permissionResult.behavior===`ask`?e.permissionResult.suggestions:void 0,decisionReason:e.permissionResult.decisionReason,onRejectFeedbackChange:_,onAcceptFeedbackChange:g,onClassifierDescriptionChange:T,classifierDescription:w,initialClassifierDescriptionEmpty:E,existingAllowDescriptions:P,yesInputMode:u,noInputMode:d,editablePrefix:k,onEditablePrefixChange:j}),[e,w,E,P,u,d,k,j]);Il(`permission:toggleDebug`,(0,Q.useCallback)(()=>{C(e=>!e)},[]),{context:`Confirmation`}),Il(`confirm:no`,(0,Q.useCallback)(()=>{e.onDismissCheckmark?.()},[e]),{context:`Confirmation`,isActive:!1});function re(t){X(`tengu_permission_request_option_selected`,{option_index:{yes:1,"yes-apply-suggestions":2,"yes-prefix-edited":2,no:3}[t],explainer_visible:l.visible});let r=Em(e.tool.name);if(t===`yes-prefix-edited`){let t=(k??``).trim();if(xx(`tool_use_single`,e,`accept`),!t)e.onAllow(e.input,[]);else{let n=[{type:`addRules`,rules:[{toolName:Vi.name,ruleContent:t}],behavior:`allow`,destination:`localSettings`}];e.onAllow(e.input,n)}n();return}switch(t){case`yes`:{let t=m.trim();xx(`tool_use_single`,e,`accept`),X(`tengu_accept_submitted`,{toolName:r,isMcp:e.tool.isMcp??!1,has_instructions:!!t,instructions_length:t.length,entered_feedback_mode:f}),e.onAllow(e.input,[],t||void 0),n();break}case`yes-apply-suggestions`:{xx(`tool_use_single`,e,`accept`);let t=`suggestions`in e.permissionResult&&e.permissionResult.suggestions||[];e.onAllow(e.input,t),n();break}case`no`:{let t=h.trim();X(`tengu_reject_submitted`,{toolName:r,isMcp:e.tool.isMcp??!1,has_instructions:!!t,instructions_length:t.length,entered_feedback_mode:p}),b(t||void 0);break}}}return(0,$.jsxs)(hg,{title:M&&!N?`Bash command (unsandboxed)`:`Bash command`,subtitle:void 0,children:[(0,$.jsxs)(G,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(K,{dimColor:l.visible,children:Vi.renderToolUseMessage({command:a,description:o},{theme:s,verbose:!0})}),!l.visible&&(0,$.jsx)(K,{dimColor:!0,children:e.description}),(0,$.jsx)(Jb,{visible:l.visible,promise:l.promise})]}),S?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(kb,{permissionResult:e.permissionResult,toolName:`Bash`}),t.options.debug&&(0,$.jsx)(G,{justifyContent:`flex-end`,marginTop:1,children:(0,$.jsx)(K,{dimColor:!0,children:`Ctrl-D to hide debug info`})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(G,{flexDirection:`column`,children:[(0,$.jsx)(zy,{permissionResult:e.permissionResult,toolType:`command`}),ne&&(0,$.jsx)(G,{marginBottom:1,children:(0,$.jsx)(K,{color:`warning`,dimColor:!1,children:ne})}),(0,$.jsx)(K,{dimColor:!1,children:`Do you want to proceed?`}),(0,$.jsx)(Hi,{options:F,isDisabled:!1,inlineDescriptions:!0,onChange:re,onCancel:()=>b(),onFocus:x,onInputModeToggle:y})]}),(0,$.jsxs)(G,{justifyContent:`space-between`,marginTop:1,children:[(0,$.jsxs)(K,{dimColor:!0,children:[`Esc to reject`,(v===`yes`&&!u||v===`no`&&!d)&&` · Tab to add feedback`,l.enabled&&` · ctrl+e to ${l.visible?`hide`:`explain`}`]}),t.options.debug&&(0,$.jsx)(K,{dimColor:!0,children:`Ctrl+d to show debug info`})]})]})]})}Ru(),q(),If(),U(),He(),wi(),pg();function jx({toolUseConfirm:e,onDone:t,onReject:n}){let r=W(e=>e.toolPermissionContext.mode);function i(i){i===`yes`?(X(`tengu_plan_enter`,{interviewPhaseEnabled:yt(),entryMethod:`tool`}),od(r,`plan`),t(),e.onAllow({},[{type:`setMode`,mode:`plan`,destination:`session`}])):(t(),n(),e.onReject())}return(0,$.jsx)(hg,{color:`planMode`,title:`Enter plan mode?`,children:(0,$.jsxs)(G,{flexDirection:`column`,marginTop:1,paddingX:1,children:[(0,$.jsx)(K,{children:`Claude wants to enter plan mode to explore and design an implementation approach.`}),(0,$.jsxs)(G,{marginTop:1,flexDirection:`column`,children:[(0,$.jsx)(K,{dimColor:!0,children:`In plan mode, Claude will:`}),(0,$.jsx)(K,{dimColor:!0,children:` · Explore the codebase thoroughly`}),(0,$.jsx)(K,{dimColor:!0,children:` · Identify existing patterns`}),(0,$.jsx)(K,{dimColor:!0,children:` · Design an implementation strategy`}),(0,$.jsx)(K,{dimColor:!0,children:` · Present a plan for your approval`})]}),(0,$.jsx)(G,{marginTop:1,children:(0,$.jsx)(K,{dimColor:!0,children:`No code changes will be made until you approve the plan.`})}),(0,$.jsx)(G,{marginTop:1,children:(0,$.jsx)(Hi,{options:[{label:`Yes, enter plan mode`,value:`yes`},{label:`No, start implementing now`,value:`no`}],onChange:i,onCancel:()=>i(`no`)})})]})})}u(),If(),U(),Ru(),Tg(),q(),Ph(),Uc(),Ef(),vp(),Ka(),jd(),He(),Ki(),Rh(),he(),wi(),pg(),Vy(),Bc(),Eo();var Mx=(ci(),e(Rr));function Nx(e,t){let n=[{type:`setMode`,mode:of(e),destination:`session`}];return Os()&&t&&t.length>0&&n.push({type:`addRules`,rules:t.map(e=>({toolName:e.tool,ruleContent:Jo(e.prompt)})),behavior:`allow`,destination:`session`}),n}function Px(e,t,n){Au()||Hd()?.cleanupPeriodDays===0||!n&&ws($u())||Eg([Dr({content:e.slice(0,1e3)})],new AbortController().signal).then(async e=>{if(!e||ws($u()))return;let n=$u(),r=zc();await $o(n,e,r,`auto`),await Ss(n,e,r,`auto`),t(t=>t.standaloneAgentContext?.name===e?t:{...t,standaloneAgentContext:{...t.standaloneAgentContext,name:e}})}).catch(Y)}function Fx({toolUseConfirm:e,onDone:t,onReject:n,setStickyFooter:r}){let i=W(e=>e.toolPermissionContext),a=Qo();xa();let{addNotification:o}=ki(),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)({}),f=(0,Q.useRef)(0),p=W(e=>e.settings.showClearContextOnPlanAccept)??!1,m=e.assistantMessage.message.usage,{mode:h,isAutoModeAvailable:g,isBypassPermissionsModeAvailable:_}=i,v=(0,Q.useMemo)(()=>Ix({showClearContext:p,usedPercent:p?Lx(m,h):null,isAutoModeAvailable:g,isBypassPermissionsModeAvailable:_,onFeedbackChange:c}),[p,m,h,g,_]);function y(e,t,n,r,i){let a=f.current++,o={id:a,type:`image`,content:e,mediaType:t||`image/png`,filename:n||`Pasted image`,dimensions:r};_c(o),sa(o),u(e=>({...e,[a]:o}))}let b=(0,Q.useCallback)(e=>{u(t=>{let n={...t};return delete n[e],n})},[]),x=Object.values(l).filter(e=>e.type===`image`),S=x.length>0,C=e.tool.name===Hp,w=C?void 0:e.input.plan,T=C?as():void 0,E=e.input.allowedPrompts,D=w??Ds(),O=!D||D.trim()===``,[k]=(0,Q.useState)(()=>Yn()??void 0),[A,ee]=(0,Q.useState)(()=>w||(Ds()??`No plan found. Please write your plan to the plan file first.`)),[j,te]=(0,Q.useState)(!1),[ne,M]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{if(j){let e=setTimeout(te,5e3,!1);return()=>clearTimeout(e)}},[j]);let N=e=>{if(e.ctrl&&e.key===`g`){e.preventDefault(),X(`tengu_plan_external_editor_used`,{}),(async()=>{if(C&&T){let e=await zh(T);e.error&&o({key:`external-editor-error`,text:e.error,color:`warning`,priority:`high`}),e.content!==null&&(e.content!==A&&M(!0),ee(e.content),te(!0))}else{let e=await Ih(A);e.error&&o({key:`external-editor-error`,text:e.error,color:`warning`,priority:`high`}),e.content!==null&&e.content!==A&&(ee(e.content),te(!0))}})();return}if(e.shift&&e.key===`tab`){e.preventDefault(),P(p?`yes-accept-edits`:`yes-accept-edits-keep-context`);return}};async function P(r){let o=s.trim(),c=o||void 0,l=C&&!ne?{}:{plan:A};{let e=(r===`yes-resume-auto-mode`||r===`yes-auto-clear-context`)&&Oe(),t=Mx?.isAutoModeActive()??!1;r!==`no`&&!e&&t&&(Mx?.setAutoModeActive(!1),ju(!0),a(e=>({...e,toolPermissionContext:{...jo(e.toolPermissionContext),prePlanMode:void 0}})))}let u=r===`yes-accept-edits-keep-context`||r===`yes-default-keep-context`||r===`yes-resume-auto-mode`;if(r!==`no`&&Px(A,a,!u),r!==`no`&&!u){let i=`default`;r===`yes-bypass-permissions`?i=`bypassPermissions`:r===`yes-accept-edits`?i=`acceptEdits`:r===`yes-auto-clear-context`&&Oe()&&(i=`auto`,Mx?.setAutoModeActive(!0)),X(`tengu_plan_exit`,{planLengthChars:A.length,outcome:r,clearContext:!0,interviewPhaseEnabled:yt(),planStructureVariant:k,hasFeedback:!!c});let o=`\n\nIf you need specific details from before exiting plan mode (like exact code snippets, error messages, or content you generated), read the full transcript at: ${zc()}`,s=c?`\n\nUser feedback on this plan: ${c}`:``;a(e=>({...e,initialMessage:{message:{...Dr({content:`Implement the following plan:\n\n${A}${o}${s}`}),planContent:A},clearContext:!0,mode:i,allowedPrompts:E}})),Bu(!0),Nu(!0),t(),n(),e.onReject();return}if(r===`yes-resume-auto-mode`&&Oe()){X(`tengu_plan_exit`,{planLengthChars:A.length,outcome:r,clearContext:!1,interviewPhaseEnabled:yt(),planStructureVariant:k,hasFeedback:!!c}),Bu(!0),Nu(!0),Mx?.setAutoModeActive(!0),a(e=>({...e,toolPermissionContext:rn({...e.toolPermissionContext,mode:`auto`,prePlanMode:void 0})})),t(),e.onAllow(l,[],c);return}let d={"yes-accept-edits-keep-context":i.isBypassPermissionsModeAvailable?`bypassPermissions`:`acceptEdits`,"yes-default-keep-context":`default`,"yes-resume-auto-mode":`default`}[r];if(d){X(`tengu_plan_exit`,{planLengthChars:A.length,outcome:r,clearContext:!1,interviewPhaseEnabled:yt(),planStructureVariant:k,hasFeedback:!!c}),Bu(!0),Nu(!0),t(),e.onAllow(l,Nx(d,E),c);return}let f={"yes-bypass-permissions":`bypassPermissions`,"yes-accept-edits":`acceptEdits`}[r];if(f){X(`tengu_plan_exit`,{planLengthChars:A.length,outcome:r,interviewPhaseEnabled:yt(),planStructureVariant:k,hasFeedback:!!c}),Bu(!0),Nu(!0),t(),e.onAllow(l,Nx(f,E),c);return}if(r===`no`){if(!o&&!S)return;X(`tengu_plan_exit`,{planLengthChars:A.length,outcome:`no`,interviewPhaseEnabled:yt(),planStructureVariant:k});let r;S&&(r=await Promise.all(x.map(async e=>(await dl({type:`image`,source:{type:`base64`,media_type:e.mediaType||`image/png`,data:e.content}})).block))),t(),n(),e.onReject(o||(S?`(See attached image)`:void 0),r&&r.length>0?r:void 0)}}let F=Fh(),re=F?B(F):null,I=(0,Q.useRef)(P);I.current=P;let ie=(0,Q.useRef)(void 0);ie.current=()=>{X(`tengu_plan_exit`,{planLengthChars:A.length,outcome:`no`,interviewPhaseEnabled:yt(),planStructureVariant:k}),t(),n(),e.onReject()};let ae=!O&&!!r;if((0,Q.useLayoutEffect)(()=>{if(ae)return r((0,$.jsxs)(G,{flexDirection:`column`,borderStyle:`round`,borderColor:`planMode`,borderLeft:!1,borderRight:!1,borderBottom:!1,paddingX:1,children:[(0,$.jsx)(K,{dimColor:!0,children:`Would you like to proceed?`}),(0,$.jsx)(G,{marginTop:1,children:(0,$.jsx)(Hi,{options:v,onChange:e=>void I.current(e),onCancel:()=>ie.current?.(),onImagePaste:y,pastedContents:l,onRemoveImage:b})}),re&&(0,$.jsxs)(G,{flexDirection:`row`,gap:1,marginTop:1,children:[(0,$.jsx)(K,{dimColor:!0,children:`ctrl-g to edit in `}),(0,$.jsx)(K,{bold:!0,dimColor:!0,children:re}),C&&T&&(0,$.jsxs)(K,{dimColor:!0,children:[` · `,nf(T)]}),j&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(K,{dimColor:!0,children:` · `}),(0,$.jsxs)(K,{color:`success`,children:[d.tick,`Plan saved!`]})]})]})]})),()=>r(null)},[ae,r,v,l,re,C,T,j]),O){function r(r){r===`yes`?(X(`tengu_plan_exit`,{planLengthChars:0,outcome:`yes-default`,interviewPhaseEnabled:yt(),planStructureVariant:k}),(Mx?.isAutoModeActive()??!1)&&(Mx?.setAutoModeActive(!1),ju(!0),a(e=>({...e,toolPermissionContext:{...jo(e.toolPermissionContext),prePlanMode:void 0}}))),Bu(!0),Nu(!0),t(),e.onAllow({},[{type:`setMode`,mode:`default`,destination:`session`}])):(X(`tengu_plan_exit`,{planLengthChars:0,outcome:`no`,interviewPhaseEnabled:yt(),planStructureVariant:k}),t(),n(),e.onReject())}return(0,$.jsx)(hg,{color:`planMode`,title:`Exit plan mode?`,children:(0,$.jsxs)(G,{flexDirection:`column`,paddingX:1,marginTop:1,children:[(0,$.jsx)(K,{children:`Claude wants to exit plan mode`}),(0,$.jsx)(G,{marginTop:1,children:(0,$.jsx)(Hi,{options:[{label:`Yes`,value:`yes`},{label:`No`,value:`no`}],onChange:r,onCancel:()=>{X(`tengu_plan_exit`,{planLengthChars:0,outcome:`no`,interviewPhaseEnabled:yt(),planStructureVariant:k}),t(),n(),e.onReject()}})})]})})}return(0,$.jsxs)(G,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:N,children:[(0,$.jsx)(hg,{color:`planMode`,title:`Ready to code?`,innerPaddingX:0,children:(0,$.jsxs)(G,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(G,{paddingX:1,flexDirection:`column`,children:(0,$.jsx)(K,{children:`Here is Claude's plan:`})}),(0,$.jsx)(G,{borderColor:`subtle`,borderStyle:`dashed`,flexDirection:`column`,borderLeft:!1,borderRight:!1,paddingX:1,marginBottom:1,overflow:`hidden`,children:(0,$.jsx)(Ne,{children:A})}),(0,$.jsxs)(G,{flexDirection:`column`,paddingX:1,children:[(0,$.jsx)(zy,{permissionResult:e.permissionResult,toolType:`tool`}),Os()&&E&&E.length>0&&(0,$.jsxs)(G,{flexDirection:`column`,marginBottom:1,children:[(0,$.jsx)(K,{bold:!0,children:`Requested permissions:`}),E.map((e,t)=>(0,$.jsxs)(K,{dimColor:!0,children:[` `,`· `,e.tool,`(`,`prompt:`,` `,e.prompt,`)`]},t))]}),!ae&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(K,{dimColor:!0,children:`Claude has written up a plan and is ready to execute. Would you like to proceed?`}),(0,$.jsx)(G,{marginTop:1,children:(0,$.jsx)(Hi,{options:v,onChange:P,onCancel:()=>ie.current?.(),onImagePaste:y,pastedContents:l,onRemoveImage:b})})]})]})]})}),!ae&&re&&(0,$.jsxs)(G,{flexDirection:`row`,gap:1,paddingX:1,marginTop:1,children:[(0,$.jsxs)(G,{children:[(0,$.jsx)(K,{dimColor:!0,children:`ctrl-g to edit in `}),(0,$.jsx)(K,{bold:!0,dimColor:!0,children:re}),C&&T&&(0,$.jsxs)(K,{dimColor:!0,children:[` · `,nf(T)]})]}),j&&(0,$.jsxs)(G,{children:[(0,$.jsx)(K,{dimColor:!0,children:` · `}),(0,$.jsxs)(K,{color:`success`,children:[d.tick,`Plan saved!`]})]})]})]})}function Ix({showClearContext:e,usedPercent:t,isAutoModeAvailable:n,isBypassPermissionsModeAvailable:r,onFeedbackChange:i}){let a=[],o=t===null?``:` (${t}% used)`;return e&&(n?a.push({label:`Yes, clear context${o} and use auto mode`,value:`yes-auto-clear-context`}):r?a.push({label:`Yes, clear context${o} and bypass permissions`,value:`yes-bypass-permissions`}):a.push({label:`Yes, clear context${o} and auto-accept edits`,value:`yes-accept-edits`})),n?a.push({label:`Yes, and use auto mode`,value:`yes-resume-auto-mode`}):r?a.push({label:`Yes, and bypass permissions`,value:`yes-accept-edits-keep-context`}):a.push({label:`Yes, auto-accept edits`,value:`yes-accept-edits-keep-context`}),a.push({label:`Yes, manually approve edits`,value:`yes-default-keep-context`}),a.push({type:`input`,label:`No, keep planning`,value:`no`,placeholder:`Tell Claude what to change`,description:`shift+tab to approve with this feedback`,onChange:i}),a}function Lx(e,t){if(!e)return null;let n=hp(Dp({permissionMode:t,mainLoopModel:Lp(),exceeds200kTokens:!1}),Uu()),{used:r}=rp({input_tokens:e.input_tokens,cache_creation_input_tokens:e.cache_creation_input_tokens??0,cache_read_input_tokens:e.cache_read_input_tokens??0},n);return r}function Rx({options:e,onSelect:t,onCancel:n,question:r=`Do you want to proceed?`,toolAnalyticsContext:i}){let a=Qo(),[o,s]=(0,zx.useState)(``),[c,l]=(0,zx.useState)(``),[u,d]=(0,zx.useState)(!1),[f,p]=(0,zx.useState)(!1),[m,h]=(0,zx.useState)(null),[g,_]=(0,zx.useState)(!1),[v,y]=(0,zx.useState)(!1),b=e.find(e=>e.value===m)?.feedbackConfig?.type,x=b===`accept`&&!u||b===`reject`&&!f,S=(0,zx.useMemo)(()=>e.map(e=>{let{value:t,label:n,feedbackConfig:r}=e;if(!r)return{label:n,value:t};let{type:i,placeholder:a}=r,o=i===`accept`?u:f,c=i===`accept`?s:l,d=Vx[i];return o?{type:`input`,label:n,value:t,placeholder:a??d,onChange:c,allowEmptySubmitToCancel:!0}:{label:n,value:t}}),[e,u,f]),C=(0,zx.useCallback)(t=>{let n=e.find(e=>e.value===t);if(!n?.feedbackConfig)return;let{type:r}=n.feedbackConfig,a={toolName:i?.toolName,isMcp:i?.isMcp??!1};r===`accept`?u?(d(!1),X(`tengu_accept_feedback_mode_collapsed`,a)):(d(!0),_(!0),X(`tengu_accept_feedback_mode_entered`,a)):r===`reject`&&(f?(p(!1),X(`tengu_reject_feedback_mode_collapsed`,a)):(p(!0),y(!0),X(`tengu_reject_feedback_mode_entered`,a)))},[e,u,f,i]),w=(0,zx.useCallback)(n=>{let r=e.find(e=>e.value===n);if(!r)return;let a;if(r.feedbackConfig){let e=(r.feedbackConfig.type===`accept`?o:c).trim();e&&(a=e);let t={toolName:i?.toolName,isMcp:i?.isMcp??!1,has_instructions:!!e,instructions_length:e?.length??0,entered_feedback_mode:r.feedbackConfig.type===`accept`?g:v};r.feedbackConfig.type===`accept`?X(`tengu_accept_submitted`,t):r.feedbackConfig.type===`reject`&&X(`tengu_reject_submitted`,t)}t(n,a)},[e,o,c,t,i,g,v]);El((0,zx.useMemo)(()=>{let t={};for(let n of e)n.keybinding&&(t[n.keybinding]=()=>w(n.value));return t},[e,w]),{context:`Confirmation`});let T=(0,zx.useCallback)(()=>{X(`tengu_permission_request_escape`,{}),a(e=>({...e,attribution:{...e.attribution,escapeCount:e.attribution.escapeCount+1}})),n?.()},[n,a]);return(0,Bx.jsxs)(G,{flexDirection:`column`,children:[typeof r==`string`?(0,Bx.jsx)(K,{children:r}):r,(0,Bx.jsx)(Hi,{options:S,inlineDescriptions:!0,onChange:w,onCancel:T,onFocus:t=>{let n=e.find(e=>e.value===t);n?.feedbackConfig?.type!==`accept`&&u&&!o.trim()&&d(!1),n?.feedbackConfig?.type!==`reject`&&f&&!c.trim()&&p(!1),h(t)},onInputModeToggle:C}),(0,Bx.jsx)(G,{marginTop:1,children:(0,Bx.jsxs)(K,{dimColor:!0,children:[`Esc to cancel`,x&&` · Tab to amend`]})})]})}var zx,Bx,Vx,Hx=t((()=>{zx=n(Yl(),1),q(),O(),If(),U(),ar(),Bx=fu(),Vx={accept:`tell Claude what to do next`,reject:`tell Claude what to do differently`}}));Wm(),Ru(),q(),Tm(),Rd(),xs(),Qf(),xb(),pg(),Hx(),Vy();function Ux({toolUseConfirm:e,onDone:t,onReject:n,verbose:r}){let[i]=Dl(),a=e.tool.userFacingName(e.input),o=a.endsWith(` (MCP)`)?a.slice(0,-6):a;Sb(e,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let s=(0,Q.useCallback)((r,i)=>{switch(r){case`yes`:bb({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:Od.platform}}),e.onAllow(e.input,[],i),t();break;case`yes-dont-ask-again`:bb({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:Od.platform}}),e.onAllow(e.input,[{type:`addRules`,rules:[{toolName:e.tool.name}],behavior:`allow`,destination:`localSettings`}]),t();break;case`no`:bb({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:Od.platform}}),e.onReject(i),n(),t();break}},[e,t,n]),c=(0,Q.useCallback)(()=>{bb({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:Od.platform}}),e.onReject(),n(),t()},[e,t,n]),l=Gu(),u=nc(),d=(0,Q.useMemo)(()=>{let e=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}];return u&&e.push({label:(0,$.jsxs)(K,{children:[`Yes, and don't ask again for `,(0,$.jsx)(K,{bold:!0,children:o}),` commands in`,` `,(0,$.jsx)(K,{bold:!0,children:l})]}),value:`yes-dont-ask-again`}),e.push({label:`No`,value:`no`,feedbackConfig:{type:`reject`}}),e},[o,l,u]),f=(0,Q.useMemo)(()=>({toolName:Em(e.tool.name),isMcp:e.tool.isMcp??!1}),[e.tool.name,e.tool.isMcp]);return(0,$.jsxs)(hg,{title:`Tool use`,children:[(0,$.jsxs)(G,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsxs)(K,{children:[o,`(`,e.tool.renderToolUseMessage(e.input,{theme:i,verbose:!0}),`)`,a.endsWith(` (MCP)`)?(0,$.jsx)(K,{dimColor:!0,children:` (MCP)`}):``]}),(0,$.jsx)(K,{dimColor:!0,children:Xf(e.description,3)})]}),(0,$.jsxs)(G,{flexDirection:`column`,children:[(0,$.jsx)(zy,{permissionResult:e.permissionResult,toolType:`tool`}),(0,$.jsx)(Rx,{options:d,onSelect:s,onCancel:c,toolAnalyticsContext:f})]})]})}function Wx(e,t,n,r){return{filePath:e,edits:[{old_string:t,new_string:n,replace_all:r}],editMode:`single`}}sd(),q();var Gx={getConfig:e=>Wx(e.file_path,e.old_string,e.new_string,e.replace_all),applyChanges:(e,t)=>{let n=t[0];return n?{...e,old_string:n.old_string,new_string:n.new_string,replace_all:n.replace_all}:e}};function Kx(e){let t=e=>v.inputSchema.parse(e),{file_path:n,old_string:r,new_string:i,replace_all:a}=t(e.toolUseConfirm.input);return(0,$.jsx)(vx,{toolUseConfirm:e.toolUseConfirm,toolUseContext:e.toolUseContext,onDone:e.onDone,onReject:e.onReject,title:`Edit file`,subtitle:o_(cd(),n),question:(0,$.jsxs)(K,{children:[`Do you want to make this edit to `,(0,$.jsx)(K,{bold:!0,children:n_(n)}),`?`]}),content:(0,$.jsx)(Yb,{file_path:n,edits:[{old_string:r,new_string:i,replace_all:a||!1}]}),path:n,completionType:`str_replace_single`,parseInput:t,ideDiffSupport:Gx})}q();function qx(e){let t=e.tool;if(`getPath`in t&&typeof t.getPath==`function`)try{return t.getPath(e.input)}catch{return null}return null}function Jx({toolUseConfirm:e,onDone:t,onReject:n,verbose:r,toolUseContext:i}){let[a]=Dl(),o=qx(e),s=e.tool.userFacingName(e.input),c=e.tool.isReadOnly(e.input),l=`${c?`Read`:`Edit`} file`;return o?(0,$.jsx)(vx,{toolUseConfirm:e,toolUseContext:i,onDone:t,onReject:n,title:l,content:(0,$.jsx)(G,{flexDirection:`column`,paddingX:2,paddingY:1,children:(0,$.jsxs)(K,{children:[s,`(`,e.tool.renderToolUseMessage(e.input,{theme:a,verbose:r}),`)`]})}),path:o,parseInput:e=>e,operationType:c?`read`:`write`,completionType:`tool_use_single`}):(0,$.jsx)(Ux,{toolUseConfirm:e,toolUseContext:i,onDone:t,onReject:n,verbose:r})}ht(),q(),N(),zt();function Yx({file_path:e,content:t,fileExists:n,oldContent:r}){let{columns:i}=tu(),a=(0,Q.useMemo)(()=>n?Vn({filePath:e,fileContents:r,edits:[{old_string:r,new_string:t,replace_all:!1}]}):null,[n,e,r,t]),o=t.split(`
24
- `)[0]??null;return(0,$.jsx)(G,{flexDirection:`column`,children:(0,$.jsx)(G,{borderColor:`subtle`,borderStyle:`dashed`,flexDirection:`column`,borderLeft:!1,borderRight:!1,paddingX:1,children:a?af(a.map(t=>(0,$.jsx)(Lr,{patch:t,dim:!1,filePath:e,firstLine:o,fileContent:r,width:i-2},t.newStart)),e=>(0,$.jsx)(Pl,{fromLeftEdge:!0,children:(0,$.jsx)(K,{dimColor:!0,children:`...`})},`ellipsis-${e}`)):(0,$.jsx)(Ze,{code:t||`(No content)`,filePath:e})})})}q(),sd(),pd(),Dd();var Xx={getConfig:e=>{let t;try{t=Ld(e.file_path)}catch(e){if(!ld(e))throw e;t=``}return Wx(e.file_path,t,e.content,!1)},applyChanges:(e,t)=>{let n=t[0];return n?{...e,content:n.new_string}:e}};function Zx(e){let t=e=>ul.inputSchema.parse(e),{file_path:n,content:r}=t(e.toolUseConfirm.input),{fileExists:i,oldContent:a}=(0,Q.useMemo)(()=>{try{return{fileExists:!0,oldContent:Ld(n)}}catch(e){if(!ld(e))throw e;return{fileExists:!1,oldContent:``}}},[n]),o=i?`overwrite`:`create`;return(0,$.jsx)(vx,{toolUseConfirm:e.toolUseConfirm,toolUseContext:e.toolUseContext,onDone:e.onDone,onReject:e.onReject,title:i?`Overwrite file`:`Create file`,subtitle:o_(cd(),n),question:(0,$.jsxs)(K,{children:[`Do you want to `,o,` `,(0,$.jsx)(K,{bold:!0,children:n_(n)}),`?`]}),content:(0,$.jsx)(Yx,{file_path:n,content:r,fileExists:i,oldContent:a}),path:n,completionType:`write_file_single`,parseInput:t,ideDiffSupport:Xx})}q(),Nd(),sd(),N(),vd(),zt(),oi();function Qx(e){let t=(0,Q.useMemo)(()=>Cd().readFile(e.notebook_path,{encoding:`utf-8`}).then(e=>Ff(e)).catch(()=>null),[e.notebook_path]);return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)($x,{...e,promise:t})})}function $x({notebook_path:e,cell_id:t,new_source:n,cell_type:r,edit_mode:i=`replace`,verbose:a,width:o,promise:s}){let c=(0,Q.use)(s),l=(0,Q.useMemo)(()=>{if(!c||!t)return``;let e=Ls(t);if(e!==void 0){if(c.cells[e]){let t=c.cells[e].source;return Array.isArray(t)?t.join(``):t}return``}let n=c.cells.find(e=>e.id===t);return n?Array.isArray(n.source)?n.source.join(``):n.source:``},[c,t]),u=(0,Q.useMemo)(()=>!c||i===`insert`||i===`delete`?null:Vn({filePath:e,fileContents:l,edits:[{old_string:l,new_string:n,replace_all:!1}],ignoreWhitespace:!1}),[c,e,l,n,i]),d;switch(i){case`insert`:d=`Insert new cell`;break;case`delete`:d=`Delete cell`;break;default:d=`Replace cell contents`}return(0,$.jsx)(G,{flexDirection:`column`,children:(0,$.jsxs)(G,{borderStyle:`round`,flexDirection:`column`,paddingX:1,children:[(0,$.jsxs)(G,{paddingBottom:1,flexDirection:`column`,children:[(0,$.jsx)(K,{bold:!0,children:a?e:o_(cd(),e)}),(0,$.jsxs)(K,{dimColor:!0,children:[d,` for cell `,t,r?` (${r})`:``]})]}),i===`delete`?(0,$.jsx)(G,{flexDirection:`column`,paddingLeft:2,children:(0,$.jsx)(Ze,{code:l,filePath:e})}):i===`insert`?(0,$.jsx)(G,{flexDirection:`column`,paddingLeft:2,children:(0,$.jsx)(Ze,{code:n,filePath:r===`markdown`?`file.md`:e})}):u?af(u.map(t=>(0,$.jsx)(Lr,{patch:t,dim:!1,width:o,filePath:e,firstLine:n.split(`
25
- `)[0]??null,fileContent:l},t.newStart)),e=>(0,$.jsx)(Pl,{fromLeftEdge:!0,children:(0,$.jsx)(K,{dimColor:!0,children:`...`})},`ellipsis-${e}`)):(0,$.jsx)(Ze,{code:n,filePath:r===`markdown`?`file.md`:e})]})})}q(),Ef();function eS(e){let t=e=>{let t=zi.inputSchema.safeParse(e);return t.success?t.data:(Y(Error(`Failed to parse notebook edit input: ${t.error.message}`)),{notebook_path:``,new_source:``,cell_id:``})},n=t(e.toolUseConfirm.input),{notebook_path:r,edit_mode:i,cell_type:a}=n,o=a===`markdown`?`markdown`:`python`,s=i===`insert`?`insert this cell into`:i===`delete`?`delete this cell from`:`make this edit to`;return(0,$.jsx)(vx,{toolUseConfirm:e.toolUseConfirm,toolUseContext:e.toolUseContext,onDone:e.onDone,onReject:e.onReject,title:`Edit notebook`,question:(0,$.jsxs)(K,{children:[`Do you want to `,s,` `,(0,$.jsx)(K,{bold:!0,children:n_(r)}),`?`]}),content:(0,$.jsx)(Qx,{notebook_path:n.notebook_path,cell_id:n.cell_id,new_source:n.new_source,cell_type:n.cell_type,edit_mode:n.edit_mode,verbose:e.verbose,width:e.verbose?120:80}),path:r,completionType:`tool_use_single`,languageName:o,parseInput:t})}Qf(),Cs();async function tS(e){if(e.nameType===`application`)return null;let t=e.name;if(!t||aa.has(t.toLowerCase()))return null;if(e.nameType===`cmdlet`)return t;if(e.elementTypes?.[0]!==`StringConstant`)return null;for(let t=0;t<e.args.length;t++){let n=e.elementTypes[t+1];if(n!==`StringConstant`&&n!==`Parameter`)return null}let n=t.toLowerCase(),r=await ub(n),i=await ab(t,e.args,r),a=0;for(let t of i.split(` `).slice(1)){if(t.includes(`\\`))return null;for(;a<e.args.length;){let n=e.args[a];if(n===t)break;if(n.startsWith(`-`)){if(a++,r?.options&&a<e.args.length&&e.args[a]!==t&&!e.args[a].startsWith(`-`)){let e=n.toLowerCase();r.options.find(t=>Array.isArray(t.name)?t.name.includes(e):t.name===e)?.args&&a++}continue}return null}if(a>=e.args.length)return null;a++}return!i.includes(` `)&&(r?.subcommands?.length||eb[n])?null:i}async function nS(e,t){let n=await ka(e);if(!n.valid)return[];let r=es(n).filter(e=>e.elementType===`CommandAst`);if(r.length<=1){let e=r[0]?await tS(r[0]):null;return e?[e]:[]}let i=[];for(let e of r){if(t?.(e))continue;let n=await tS(e);n&&i.push(n)}if(i.length===0)return[];let a=new Map;for(let e of i){let t=e.split(` `)[0].toLowerCase(),n=a.get(t);n?n.push(e):a.set(t,[e])}let o=[];for(let[e,t]of a){let n=rS(t);(n===``?0:$f(n,` `)+1)<=1&&((await ub(e))?.subcommands?.length||eb[e])||o.push(n)}return o}function rS(e){if(e.length===0)return``;if(e.length===1)return e[0];let t=e[0].split(` `),n=t.length;for(let r=1;r<e.length;r++){let i=e[r].split(` `),a=0;for(;a<n&&a<i.length&&i[a].toLowerCase()===t[a].toLowerCase();)a++;if(n=a,n===0)break}return t.slice(0,n).join(` `)}xs();function iS({suggestions:e=[],onRejectFeedbackChange:t,onAcceptFeedbackChange:n,yesInputMode:r=!1,noInputMode:i=!1,editablePrefix:a,onEditablePrefixChange:o}){let s=[];if(r?s.push({type:`input`,label:`Yes`,value:`yes`,placeholder:`and tell Claude what to do next`,onChange:n,allowEmptySubmitToCancel:!0}):s.push({label:`Yes`,value:`yes`}),nc()&&e.length>0){let t=e.some(e=>e.type===`addDirectories`||e.type===`addRules`&&e.rules?.some(e=>e.toolName!==`PowerShell`));if(a!==void 0&&o&&!t)s.push({type:`input`,label:`Yes, and don’t ask again for`,value:`yes-prefix-edited`,placeholder:`command prefix (e.g., Get-Process:*)`,initialValue:a,onChange:o,allowEmptySubmitToCancel:!0,showLabelWithValue:!0,labelValueSeparator:`: `,resetCursorOnUpdate:!0});else{let t=Ex(e,Up);t&&s.push({label:t,value:`yes-apply-suggestions`})}}return i?s.push({type:`input`,label:`No`,value:`no`,placeholder:`and tell Claude what to do differently`,onChange:t,allowEmptySubmitToCancel:!0}):s.push({label:`No`,value:`no`}),s}q(),O(),If(),Tm(),ar(),pg(),Vy();function aS(e){let{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i}=e,{command:a,description:o}=_s.inputSchema.parse(t.input),[s]=Dl(),c=Kb({toolName:t.tool.name,toolInput:t.input,toolDescription:t.description,messages:n.messages}),{yesInputMode:l,noInputMode:u,yesFeedbackModeEntered:d,noFeedbackModeEntered:f,acceptFeedback:p,rejectFeedback:m,setAcceptFeedback:h,setRejectFeedback:g,focusedOption:_,handleInputModeToggle:v,handleReject:y,handleFocus:b}=Sx({toolUseConfirm:t,onDone:r,onReject:i,explainerVisible:c.visible}),[x,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(a.includes(`
26
- `)?void 0:a),T=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{let e=!1;return nS(a,e=>Sa(e,e.text)).then(t=>{e||T.current||t.length>0&&w(`${t[0]}:*`)}).catch(()=>{}),()=>{e=!0}},[a]);let E=(0,Q.useCallback)(e=>{T.current=!0,w(e)},[]);Sb(t,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let D=(0,Q.useMemo)(()=>iS({suggestions:t.permissionResult.behavior===`ask`?t.permissionResult.suggestions:void 0,onRejectFeedbackChange:g,onAcceptFeedbackChange:h,yesInputMode:l,noInputMode:u,editablePrefix:C,onEditablePrefixChange:E}),[t,l,u,C,E]);Il(`permission:toggleDebug`,(0,Q.useCallback)(()=>{S(e=>!e)},[]),{context:`Confirmation`});function O(e){X(`tengu_permission_request_option_selected`,{option_index:{yes:1,"yes-apply-suggestions":2,"yes-prefix-edited":2,no:3}[e],explainer_visible:c.visible});let n=Em(t.tool.name);if(e===`yes-prefix-edited`){let e=(C??``).trim();if(xx(`tool_use_single`,t,`accept`),!e)t.onAllow(t.input,[]);else{let n=[{type:`addRules`,rules:[{toolName:_s.name,ruleContent:e}],behavior:`allow`,destination:`localSettings`}];t.onAllow(t.input,n)}r();return}switch(e){case`yes`:{let e=p.trim();xx(`tool_use_single`,t,`accept`),X(`tengu_accept_submitted`,{toolName:n,isMcp:t.tool.isMcp??!1,has_instructions:!!e,instructions_length:e.length,entered_feedback_mode:d}),t.onAllow(t.input,[],e||void 0),r();break}case`yes-apply-suggestions`:{xx(`tool_use_single`,t,`accept`);let e=`suggestions`in t.permissionResult&&t.permissionResult.suggestions||[];t.onAllow(t.input,e),r();break}case`no`:{let e=m.trim();X(`tengu_reject_submitted`,{toolName:n,isMcp:t.tool.isMcp??!1,has_instructions:!!e,instructions_length:e.length,entered_feedback_mode:f}),y(e||void 0);break}}}return(0,$.jsxs)(hg,{title:`PowerShell command`,children:[(0,$.jsxs)(G,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(K,{dimColor:c.visible,children:_s.renderToolUseMessage({command:a,description:o},{theme:s,verbose:!0})}),!c.visible&&(0,$.jsx)(K,{dimColor:!0,children:t.description}),(0,$.jsx)(Jb,{visible:c.visible,promise:c.promise})]}),x?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(kb,{permissionResult:t.permissionResult,toolName:`PowerShell`}),n.options.debug&&(0,$.jsx)(G,{justifyContent:`flex-end`,marginTop:1,children:(0,$.jsx)(K,{dimColor:!0,children:`Ctrl-D to hide debug info`})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(G,{flexDirection:`column`,children:[(0,$.jsx)(zy,{permissionResult:t.permissionResult,toolType:`command`}),null,(0,$.jsx)(K,{children:`Do you want to proceed?`}),(0,$.jsx)(Hi,{options:D,inlineDescriptions:!0,onChange:O,onCancel:()=>y(),onFocus:b,onInputModeToggle:v})]}),(0,$.jsxs)(G,{justifyContent:`space-between`,marginTop:1,children:[(0,$.jsxs)(K,{dimColor:!0,children:[`Esc to cancel`,(_===`yes`&&!l||_===`no`&&!u)&&` · Tab to amend`,c.enabled&&` · ctrl+e to ${c.visible?`hide`:`explain`}`]}),n.options.debug&&(0,$.jsx)(K,{dimColor:!0,children:`Ctrl+d to show debug info`})]})]})]})}Ef(),Ru(),q(),Tm(),Rd(),xs(),xb(),pg(),Hx(),Vy();function oS(e){let{toolUseConfirm:t,onDone:n,onReject:r,verbose:i}=e,a=(e=>{let t=rl.inputSchema.safeParse(e);return t.success?t.data.skill:(Y(Error(`Failed to parse skill tool input: ${t.error.message}`)),``)})(t.input),o=t.permissionResult.behavior===`ask`&&t.permissionResult.metadata&&`command`in t.permissionResult.metadata?t.permissionResult.metadata.command:void 0;Sb(t,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let s=Gu(),c=nc(),l=(0,Q.useMemo)(()=>{let e=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}],t=[];if(c){t.push({label:(0,$.jsxs)(K,{children:[`Yes, and don't ask again for `,(0,$.jsx)(K,{bold:!0,children:a}),` in `,(0,$.jsx)(K,{bold:!0,children:s})]}),value:`yes-exact`});let e=a.indexOf(` `);if(e>0){let n=a.substring(0,e);t.push({label:(0,$.jsxs)(K,{children:[`Yes, and don't ask again for `,(0,$.jsx)(K,{bold:!0,children:n+`:*`}),` commands in`,` `,(0,$.jsx)(K,{bold:!0,children:s})]}),value:`yes-prefix`})}}let n={label:`No`,value:`no`,feedbackConfig:{type:`reject`}};return[...e,...t,n]},[a,s,c]),u=(0,Q.useMemo)(()=>({toolName:Em(t.tool.name),isMcp:t.tool.isMcp??!1}),[t.tool.name,t.tool.isMcp]),d=(0,Q.useCallback)((e,i)=>{switch(e){case`yes`:bb({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Od.platform}}),t.onAllow(t.input,[],i),n();break;case`yes-exact`:bb({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Od.platform}}),t.onAllow(t.input,[{type:`addRules`,rules:[{toolName:tm,ruleContent:a}],behavior:`allow`,destination:`localSettings`}]),n();break;case`yes-prefix`:{bb({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Od.platform}});let e=a.indexOf(` `),r=e>0?a.substring(0,e):a;t.onAllow(t.input,[{type:`addRules`,rules:[{toolName:tm,ruleContent:`${r}:*`}],behavior:`allow`,destination:`localSettings`}]),n();break}case`no`:bb({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Od.platform}}),t.onReject(i),r(),n();break}},[t,n,r,a]),f=(0,Q.useCallback)(()=>{bb({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Od.platform}}),t.onReject(),r(),n()},[t,n,r]);return(0,$.jsxs)(hg,{title:`Use skill "${a}"?`,children:[(0,$.jsx)(K,{children:`Claude may use instructions, code, or files from this Skill.`}),(0,$.jsx)(G,{flexDirection:`column`,paddingX:2,paddingY:1,children:(0,$.jsx)(K,{dimColor:!0,children:o?.description})}),(0,$.jsxs)(G,{flexDirection:`column`,children:[(0,$.jsx)(zy,{permissionResult:t.permissionResult,toolType:`tool`}),(0,$.jsx)(Rx,{options:l,onSelect:d,onCancel:f,toolAnalyticsContext:u})]})]})}var sS=r({WorkflowPermissionRequest:()=>cS});function cS({toolUseConfirm:e,onDone:t,onReject:n}){let[r]=Dl(),i=$r(r),a=e.input,o=(0,lS.useMemo)(()=>nc(),[]),s=(0,lS.useMemo)(()=>{let t=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}];return o&&t.push({label:(0,uS.jsxs)(K,{children:[`Yes, and don`,`’`,`t ask again for `,(0,uS.jsx)(K,{bold:!0,children:e.tool.name}),` commands`]}),value:`yes-dont-ask-again`}),t.push({label:`No`,value:`no`,feedbackConfig:{type:`reject`}}),t},[o,e.tool.name]),c=(0,lS.useCallback)((r,i)=>{switch(r){case`yes`:bb({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Od.platform}}),e.onAllow(e.input,[],i),t();break;case`yes-dont-ask-again`:bb({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Od.platform}}),e.onAllow(e.input,[{type:`addRules`,rules:[{toolName:e.tool.name}],behavior:`allow`,destination:`localSettings`}]),t();break;case`no`:bb({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Od.platform}}),e.onReject(i),n(),t();break}},[e,t,n]),l=(0,lS.useCallback)(()=>{bb({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Od.platform}}),e.onReject(),n(),t()},[e,t,n]);return(0,uS.jsx)(hg,{title:`Workflow`,children:(0,uS.jsxs)(G,{flexDirection:`column`,gap:1,children:[(0,uS.jsxs)(G,{flexDirection:`column`,children:[(0,uS.jsxs)(K,{bold:!0,color:i.permission,children:[`Execute workflow: `,a.workflow]}),a.args&&(0,uS.jsxs)(K,{dimColor:!0,children:[`Arguments: `,a.args]})]}),(0,uS.jsx)(zy,{permissionResult:e.permissionResult,toolType:`command`}),(0,uS.jsx)(Rx,{options:s,onSelect:c,onCancel:l})]})})}var lS,uS,dS=t((()=>{lS=n(Yl(),1),q(),Rd(),xs(),xb(),pg(),Hx(),Vy(),uS=fu()}));O(),oe(),ir(),Ba(),_a(),rr(),To(),_r();var fS=(Ya(),e(Ms)).createWorkflowToolCore(),pS=(dS(),e(sS)).WorkflowPermissionRequest;function mS(e){switch(e){case v:return Kx;case ul:return Zx;case Vi:return kx;case _s:return aS;case zi:return eS;case Yr:return Fx;case un:return jx;case rl:return oS;case vl:return Yy;case fS:return pS??Ux;case Ja:case ls:case is:return Jx;default:return Ux}}function hS(e){let t=e.tool.userFacingName(e.input);return e.tool===Yr?`Claude Code needs your approval for the plan`:e.tool===un?`Claude Code wants to enter plan mode`:!t||t.trim()===``?`Claude Code needs your attention`:`Claude needs your permission to use ${t}`}function gS({toolUseConfirm:e,toolUseContext:t,onDone:n,onReject:r,verbose:i,setStickyFooter:a}){return Il(`app:interrupt`,()=>{n(),r(),e.onReject()},{context:`Confirmation`}),Ay(hS(e),`permission_prompt`),(0,$.jsx)(mS(e.tool),{toolUseContext:t,toolUseConfirm:e,onDone:n,onReject:r,verbose:i,setStickyFooter:a})}fa(),fc(),Ef(),P();async function _S(e,t,n){let r=new Date,i=r.toISOString(),a=-r.getTimezoneOffset(),o=Math.floor(Math.abs(a)/60),s=Math.abs(a)%60,c=`${a>=0?`+`:`-`}${String(o).padStart(2,`0`)}:${String(s).padStart(2,`0`)}`,l=r.toLocaleDateString(`en-US`,{weekday:`long`}),u=dm([`You are a date/time parser that converts natural language into ISO 8601 format.`,`You MUST respond with ONLY the ISO 8601 formatted string, with no explanation or additional text.`,`If the input is ambiguous, prefer future dates over past dates.`,`For times without dates, use today's date.`,`For dates without times, do not include a time component.`,`If the input is incomplete or you cannot confidently parse it into a valid date, respond with exactly "INVALID" (nothing else).`,`Examples of INVALID input: partial dates like "2025-01-", lone numbers like "13", gibberish.`,`Examples of valid natural language: "tomorrow", "next Monday", "jan 1st 2025", "in 2 hours", "yesterday".`]),d=`Current context:
27
- - Current date and time: ${i} (UTC)
28
- - Local timezone: ${c}
29
- - Day of week: ${l}
30
-
31
- User input: "${e}"
32
-
33
- Output format: ${t===`date`?`YYYY-MM-DD (date only, no time)`:`YYYY-MM-DDTHH:MM:SS${c} (full date-time with timezone)`}
34
-
35
- Parse the user's input into ISO 8601 format. Return ONLY the formatted string, or "INVALID" if the input is incomplete or unparseable.`;try{let e=await Va({systemPrompt:u,userPrompt:d,signal:n,options:{querySource:`mcp_datetime_parse`,agents:[],isNonInteractiveSession:!1,hasAppendSystemPrompt:!1,mcpTools:[],enablePromptCaching:!1}}),t=jn(Array.isArray(e.message.content)?e.message.content:[]).trim();return!t||t===`INVALID`||!/^\d{4}/.test(t)?{success:!1,error:`Unable to parse date/time from input`}:{success:!0,value:t}}catch(e){return Y(e),{success:!1,error:`Unable to parse date/time. Please enter in ISO 8601 format manually.`}}}function vS(e){return/^\d{4}-\d{2}-\d{2}(T|$)/.test(e.trim())}Su(),wd(),Qf();var yS=e=>e.type===`string`&&(`enum`in e||`oneOf`in e);function bS(e){return e.type===`array`&&`items`in e&&typeof e.items==`object`&&e.items!==null&&(`enum`in e.items||`anyOf`in e.items)}function xS(e){return`anyOf`in e.items?e.items.anyOf.map(e=>e.const):`enum`in e.items?e.items.enum:[]}function SS(e){return`anyOf`in e.items?e.items.anyOf.map(e=>e.title):`enum`in e.items?e.items.enum:[]}function CS(e,t){let n=xS(e).indexOf(t);return n>=0?SS(e)[n]??t:t}function wS(e){return`oneOf`in e?e.oneOf.map(e=>e.const):`enum`in e?e.enum:[]}function TS(e){return`oneOf`in e?e.oneOf.map(e=>e.title):`enum`in e?(`enumNames`in e?e.enumNames:void 0)??e.enum:[]}function ES(e,t){let n=wS(e).indexOf(t);return n>=0?TS(e)[n]??t:t}function DS(e){if(yS(e)){let[t,...n]=wS(e);return t?vu([t,...n]):hu()}if(e.type===`string`){let t=pu();switch(e.minLength!==void 0&&(t=t.min(e.minLength,{message:`Must be at least ${e.minLength} ${Zf(e.minLength,`character`)}`})),e.maxLength!==void 0&&(t=t.max(e.maxLength,{message:`Must be at most ${e.maxLength} ${Zf(e.maxLength,`character`)}`})),e.format){case`email`:t=t.email({message:`Must be a valid email address, e.g. user@example.com`});break;case`uri`:t=t.url({message:`Must be a valid URI, e.g. https://example.com`});break;case`date`:t=t.date(`Must be a valid date, e.g. 2024-03-15, today, next Monday`);break;case`date-time`:t=t.datetime({offset:!0,message:`Must be a valid date-time, e.g. 2024-03-15T14:30:00Z, tomorrow at 3pm`});break;default:break}return t}if(e.type===`number`||e.type===`integer`){let t=e.type===`integer`?`an integer`:`a number`,n=e.type===`integer`,r=e=>Number.isInteger(e)&&!n?`${e}.0`:String(e),i=e.minimum!==void 0&&e.maximum!==void 0?`Must be ${t} between ${r(e.minimum)} and ${r(e.maximum)}`:e.minimum===void 0?e.maximum===void 0?`Must be ${t}`:`Must be ${t} <= ${r(e.maximum)}`:`Must be ${t} >= ${r(e.minimum)}`,a=gu({error:i});return e.type===`integer`&&(a=a.int({message:i})),e.minimum!==void 0&&(a=a.min(e.minimum,{message:i})),e.maximum!==void 0&&(a=a.max(e.maximum,{message:i})),a}if(e.type===`boolean`)return yu();throw Error(`Unsupported schema: ${ud(e)}`)}function OS(e,t){let n=DS(t).safeParse(e);return n.success?{value:n.data,isValid:!0}:{isValid:!1,error:n.error.issues.map(e=>e.message).join(`; `)}}function kS(e){return e.type===`string`&&`format`in e&&(e.format===`date`||e.format===`date-time`)}async function AS(e,t,n){let r=OS(e,t);if(r.isValid)return r;if(kS(t)&&!vS(e)){let r=await _S(e,t.format,n);if(r.success){let e=OS(r.value,t);if(e.isValid)return e}}return r}u(),ht(),q(),O(),Qf(),fn(),ba();var jS=e=>[`string`,`number`,`integer`].includes(e.type),MS=`⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏`,NS=e=>(e+1)%10;function PS(e){e.buffer=``,e.timer=void 0}function FS(){let[e,t]=(0,Q.useState)(0);return(0,Q.useEffect)(()=>{let e=setInterval(t,80,NS);return()=>clearInterval(e)},[]),(0,$.jsx)(K,{color:`warning`,children:MS[e]})}function IS(e,t){try{let n=new Date(e);if(Number.isNaN(n.getTime()))return e;if((`format`in t?t.format:void 0)===`date-time`)return n.toLocaleDateString(`en-US`,{weekday:`short`,year:`numeric`,month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`,timeZoneName:`short`});let r=e.split(`-`);return r.length===3?new Date(Number(r[0]),Number(r[1])-1,Number(r[2])).toLocaleDateString(`en-US`,{weekday:`short`,year:`numeric`,month:`short`,day:`numeric`}):e}catch{return e}}function LS({event:e,onResponse:t,onWaitingDismiss:n}){return e.params.mode===`url`?(0,$.jsx)(zS,{event:e,onResponse:t,onWaitingDismiss:n}):(0,$.jsx)(RS,{event:e,onResponse:t})}function RS({event:e,onResponse:t}){let{serverName:n,signal:r}=e,{message:i,requestedSchema:a}=e.params,o=Object.keys(a.properties).length>0,[s,c]=(0,Q.useState)(o?null:`accept`),[l,u]=(0,Q.useState)(()=>{let e={};if(a.properties)for(let[t,n]of Object.entries(a.properties))typeof n==`object`&&n&&n.default!==void 0&&(e[t]=n.default);return e}),[f,p]=(0,Q.useState)(()=>{let e={};for(let[t,n]of Object.entries(a.properties))if(jS(n)&&n?.default!==void 0){let r=OS(String(n.default),n);!r.isValid&&r.error&&(e[t]=r.error)}return e});(0,Q.useEffect)(()=>{if(!r)return;let e=()=>{t(`cancel`)};if(r.aborted){e();return}return r.addEventListener(`abort`,e),()=>{r.removeEventListener(`abort`,e)}},[r,t]);let m=(0,Q.useMemo)(()=>{let e=a.required??[];return Object.entries(a.properties).map(([t,n])=>({name:t,schema:n,isRequired:e.includes(t)}))},[a]),[h,g]=(0,Q.useState)(o?0:void 0),[_,v]=(0,Q.useState)(()=>{let e=m[0];if(e&&jS(e.schema)){let t=l[e.name];return t===void 0?``:String(t)}return``}),[y,b]=(0,Q.useState)(_.length),[x,S]=(0,Q.useState)(()=>new Set),[C,w]=(0,Q.useState)(),[T,E]=(0,Q.useState)(0),D=(0,Q.useRef)(void 0),O=(0,Q.useRef)(new Map),k=(0,Q.useRef)({buffer:``,timer:void 0});(0,Q.useEffect)(()=>()=>{D.current!==void 0&&clearTimeout(D.current);let e=k.current;e.timer!==void 0&&clearTimeout(e.timer);for(let e of O.current.values())e.abort();O.current.clear()},[]);let{columns:A,rows:ee}=tu(),j=h===void 0?void 0:m[h],te=j!==void 0&&jS(j.schema)&&!yS(j.schema)&&!s;xo(`elicitation`),Ay(`Claude Code needs your input`,`elicitation_dialog`);let ne=(0,Q.useCallback)(e=>{if(e===void 0){v(``),b(0);return}let t=m[e];if(t&&jS(t.schema)&&!yS(t.schema)){let e=l[t.name],n=e===void 0?``:String(e);v(n),b(n.length)}},[m,l]);function M(e,t){if(!bS(t))return;let n=l[e]??[],r=m.find(t=>t.name===e)?.isRequired??!1,i=t.minItems,a=t.maxItems;i!==void 0&&n.length<i&&(n.length>0||r)?F(e,`Select at least ${i} ${Zf(i,`item`)}`):a!==void 0&&n.length>a?F(e,`Select at most ${a} ${Zf(a,`item`)}`):F(e)}function N(e){j&&bS(j.schema)?(M(j.name,j.schema),w(void 0)):j&&yS(j.schema)&&w(void 0),te&&j&&(I(j.name,j.schema,_),D.current!==void 0&&(clearTimeout(D.current),D.current=void 0),kS(j.schema)&&_.trim()!==``&&f[j.name]&&ie(j.name,j.schema,_));let t=m.length+2,n=h??(s===`accept`?m.length:s===`decline`?m.length+1:void 0),r=n===void 0?0:(n+(e===`up`?t-1:1))%t;r<m.length?(g(r),c(null),ne(r)):(g(void 0),c(r===m.length?`accept`:`decline`),v(``))}function P(e,t){u(n=>{let r={...n};return t===void 0?delete r[e]:r[e]=t,r}),t!==void 0&&f[e]===`This field is required`&&F(e)}function F(e,t){p(n=>{let r={...n};return t?r[e]=t:delete r[e],r})}function re(e){e&&(P(e,void 0),F(e),v(``),b(0))}function I(e,t,n){let r=n.trim();if(r===``&&(t.type!==`string`||`format`in t&&t.format!==void 0)){re(e);return}if(r===``){l[e]!==void 0&&P(e,``);return}let i=OS(n,t);P(e,i.isValid?i.value:n),F(e,i.isValid?void 0:i.error)}function ie(e,t,n){if(!r)return;let i=O.current.get(e);i&&i.abort();let a=new AbortController;O.current.set(e,a),S(t=>new Set(t).add(e)),AS(n,t,a.signal).then(t=>{if(O.current.delete(e),S(t=>{let n=new Set(t);return n.delete(e),n}),!a.signal.aborted)if(t.isValid){P(e,t.value),F(e);let r=String(t.value);v(e=>e===n?(b(r.length),r):e)}else F(e,t.error)},()=>{O.current.delete(e),S(t=>{let n=new Set(t);return n.delete(e),n})})}function ae(e){if(v(e),j&&(I(j.name,j.schema,e),D.current!==void 0&&(clearTimeout(D.current),D.current=void 0),kS(j.schema)&&e.trim()!==``&&f[j.name])){let t=j.name,n=j.schema;D.current=setTimeout((e,t,n,r,i)=>{e.current=void 0,t(n,r,i)},2e3,D,ie,t,n,e)}}function oe(){N(`down`)}function se(e,t,n){let r=k.current;r.timer!==void 0&&clearTimeout(r.timer),r.buffer+=e.toLowerCase(),r.timer=setTimeout(PS,2e3,r);let i=t.findIndex(e=>e.startsWith(r.buffer));i!==-1&&n(i)}Il(`confirm:no`,()=>{if(te&&j){let e=l[j.name];v(e===void 0?``:String(e)),b(0)}t(`cancel`)},{context:`Settings`,isActive:!!j&&!s&&!C}),Xl((e,n)=>{if(te&&!n.upArrow&&!n.downArrow&&!n.return&&!n.backspace)return;if(C&&j&&bS(j.schema)){let t=j.schema,r=xS(t),i=l[j.name]??[];if(n.leftArrow||n.escape){w(void 0),M(j.name,t);return}if(n.upArrow){T===0?(w(void 0),M(j.name,t)):E(T-1);return}if(n.downArrow){T>=r.length-1?(w(void 0),N(`down`)):E(T+1);return}if(e===` `){let e=r[T];if(e!==void 0){let n=i.includes(e)?i.filter(t=>t!==e):[...i,e],r=n.length>0?n:void 0;P(j.name,r);let a=t.minItems,o=t.maxItems;a!==void 0&&n.length<a&&(n.length>0||j.isRequired)?F(j.name,`Select at least ${a} ${Zf(a,`item`)}`):o!==void 0&&n.length>o?F(j.name,`Select at most ${o} ${Zf(o,`item`)}`):F(j.name)}return}if(n.return){let e=r[T];e!==void 0&&!i.includes(e)&&P(j.name,[...i,e]),w(void 0),N(`down`);return}if(e){se(e,r.map(e=>CS(t,e).toLowerCase()),E);return}return}if(C&&j&&yS(j.schema)){let t=j.schema,r=wS(t);if(n.leftArrow||n.escape){w(void 0);return}if(n.upArrow){T===0?w(void 0):E(T-1);return}if(n.downArrow){T>=r.length-1?(w(void 0),N(`down`)):E(T+1);return}if(e===` `){let e=r[T];e!==void 0&&P(j.name,e),w(void 0);return}if(n.return){let e=r[T];e!==void 0&&P(j.name,e),w(void 0),N(`down`);return}if(e){se(e,r.map(e=>ES(t,e).toLowerCase()),E);return}return}if(n.return&&s===`accept`){if(ce()&&Object.keys(f).length===0)t(`accept`,l);else{let e=a.required||[];for(let t of e)l[t]===void 0&&F(t,`This field is required`);let t=m.findIndex(t=>e.includes(t.name)&&l[t.name]===void 0||f[t.name]!==void 0);t!==-1&&(g(t),c(null),ne(t))}return}if(n.return&&s===`decline`){t(`decline`);return}if(n.upArrow||n.downArrow){let e=k.current;e.buffer=``,e.timer!==void 0&&(clearTimeout(e.timer),e.timer=void 0),N(n.upArrow?`up`:`down`);return}if(s&&(n.leftArrow||n.rightArrow)){c(s===`accept`?`decline`:`accept`);return}if(!j)return;let{schema:r,name:i}=j,o=l[i];if(r.type===`boolean`){if(e===` `){P(i,o===void 0||!o);return}if(n.return){N(`down`);return}if(n.backspace&&o!==void 0){re(i);return}if(e&&!n.return){se(e,[`yes`,`no`],e=>P(i,e===0));return}return}if(yS(r)||bS(r)){if(n.return){N(`down`);return}if(n.backspace&&o!==void 0){re(i);return}let t,a=0;if(yS(r)){let e=wS(r);t=e.map(e=>ES(r,e).toLowerCase()),o!==void 0&&(a=Math.max(0,e.indexOf(o)))}else t=xS(r).map(e=>CS(r,e).toLowerCase());if(n.rightArrow){w(i),E(a);return}if(e&&!n.leftArrow){se(e,t,e=>{w(i),E(e)});return}return}if(n.backspace&&te&&_===``){re(i);return}},{isActive:!0});function ce(){let e=a.required||[];for(let t of e){let e=l[t];if(e==null||e===``||Array.isArray(e)&&e.length===0)return!1}return!0}let le=Math.max(2,Math.floor((ee-14)/3)),ue=(0,Q.useMemo)(()=>{let e=m.length;if(e<=le)return{start:0,end:e};let t=h??e-1,n=Math.max(0,t-Math.floor(le/2)),r=Math.min(n+le,e);return n=Math.max(0,r-le),{start:n,end:r}},[m.length,le,h]),L=ue.start>0,R=ue.end<m.length;function de(){return m.length?(0,$.jsxs)(G,{flexDirection:`column`,children:[L&&(0,$.jsx)(G,{marginLeft:2,children:(0,$.jsxs)(K,{dimColor:!0,children:[d.arrowUp,` `,ue.start,` more above`]})}),m.slice(ue.start,ue.end).map((e,t)=>{let n=ue.start+t,{name:r,schema:i,isRequired:a}=e,o=n===h&&!s,c=l[r],u=c!==void 0&&(!Array.isArray(c)||c.length>0),p=f[r],m=x.has(r)?(0,$.jsx)(FS,{}):p?(0,$.jsx)(K,{color:`error`,children:d.warning}):u?(0,$.jsx)(K,{color:`success`,dimColor:!o,children:d.tick}):a?(0,$.jsx)(K,{color:`error`,children:`*`}):(0,$.jsx)(K,{children:` `}),g=p?`error`:u?`success`:a?`error`:`suggestion`,v=o?g:void 0,S=(0,$.jsx)(K,{color:v,bold:o,children:i.title||r}),w,E=null;if(bS(i)){let e=xS(i),t=c??[];if(C===r&&o)w=(0,$.jsx)(K,{dimColor:!0,children:d.triangleDownSmall}),E=(0,$.jsx)(G,{flexDirection:`column`,marginLeft:6,children:e.map((e,n)=>{let r=CS(i,e),a=t.includes(e),o=n===T;return(0,$.jsxs)(G,{gap:1,children:[(0,$.jsx)(K,{color:`suggestion`,children:o?d.pointer:` `}),(0,$.jsx)(K,{color:a?`success`:void 0,children:a?d.checkboxOn:d.checkboxOff}),(0,$.jsx)(K,{color:o?`suggestion`:void 0,bold:o,children:r})]},e)})});else{let e=o?(0,$.jsxs)(K,{dimColor:!0,children:[d.triangleRightSmall,` `]}):null;w=t.length>0?(0,$.jsxs)(K,{children:[e,(0,$.jsx)(K,{color:v,bold:o,children:t.map(e=>CS(i,e)).join(`, `)})]}):(0,$.jsxs)(K,{children:[e,(0,$.jsx)(K,{dimColor:!0,italic:!0,children:`not set`})]})}}else if(yS(i)){let e=wS(i);if(C===r&&o)w=(0,$.jsx)(K,{dimColor:!0,children:d.triangleDownSmall}),E=(0,$.jsx)(G,{flexDirection:`column`,marginLeft:6,children:e.map((e,t)=>{let n=ES(i,e),r=c===e,a=t===T;return(0,$.jsxs)(G,{gap:1,children:[(0,$.jsx)(K,{color:`suggestion`,children:a?d.pointer:` `}),(0,$.jsx)(K,{color:r?`success`:void 0,children:r?d.radioOn:d.radioOff}),(0,$.jsx)(K,{color:a?`suggestion`:void 0,bold:a,children:n})]},e)})});else{let e=o?(0,$.jsxs)(K,{dimColor:!0,children:[d.triangleRightSmall,` `]}):null;w=u?(0,$.jsxs)(K,{children:[e,(0,$.jsx)(K,{color:v,bold:o,children:ES(i,c)})]}):(0,$.jsxs)(K,{children:[e,(0,$.jsx)(K,{dimColor:!0,italic:!0,children:`not set`})]})}}else if(i.type===`boolean`)w=o?u?(0,$.jsx)(K,{color:v,bold:!0,children:c?d.checkboxOn:d.checkboxOff}):(0,$.jsx)(K,{dimColor:!0,children:d.checkboxOff}):u?(0,$.jsx)(K,{children:c?d.checkboxOn:d.checkboxOff}):(0,$.jsx)(K,{dimColor:!0,italic:!0,children:`not set`});else if(jS(i))if(o)w=(0,$.jsx)(ac,{value:_,onChange:ae,onSubmit:oe,placeholder:`Type something…`,columns:Math.min(A-20,60),cursorOffset:y,onChangeCursorOffset:b,focus:!0,showCursor:!0});else{let e=u&&kS(i)?IS(String(c),i):String(c);w=u?(0,$.jsx)(K,{children:e}):(0,$.jsx)(K,{dimColor:!0,italic:!0,children:`not set`})}else w=u?(0,$.jsx)(K,{children:String(c)}):(0,$.jsx)(K,{dimColor:!0,italic:!0,children:`not set`});return(0,$.jsxs)(G,{flexDirection:`column`,children:[(0,$.jsxs)(G,{gap:1,children:[(0,$.jsx)(K,{color:g,children:o?d.pointer:` `}),m,(0,$.jsxs)(G,{children:[S,(0,$.jsx)(K,{color:v,children:`: `}),w]})]}),E,i.description&&(0,$.jsx)(G,{marginLeft:6,children:(0,$.jsx)(K,{dimColor:!0,children:i.description})}),(0,$.jsx)(G,{marginLeft:6,height:1,children:p?(0,$.jsx)(K,{color:`error`,italic:!0,children:p}):(0,$.jsx)(K,{children:` `})})]},r)}),R&&(0,$.jsx)(G,{marginLeft:2,children:(0,$.jsxs)(K,{dimColor:!0,children:[d.arrowDown,` `,m.length-ue.end,` more below`]})})]}):null}return(0,$.jsx)(lu,{title:`MCP server \u201c${n}\u201d requests your input`,subtitle:`\n${i}`,color:`permission`,onCancel:()=>t(`cancel`),isCancelActive:(!j||!!s)&&!C,inputGuide:e=>e.pending?(0,$.jsxs)(K,{children:[`Press `,e.keyName,` again to exit`]}):(0,$.jsxs)(Nl,{children:[(0,$.jsx)(Lo,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),(0,$.jsx)(Cl,{shortcut:`↑↓`,action:`navigate`}),j&&(0,$.jsx)(Cl,{shortcut:`Backspace`,action:`unset`}),j&&j.schema.type===`boolean`&&(0,$.jsx)(Cl,{shortcut:`Space`,action:`toggle`}),j&&yS(j.schema)&&(C?(0,$.jsx)(Cl,{shortcut:`Space`,action:`select`}):(0,$.jsx)(Cl,{shortcut:`→`,action:`expand`})),j&&bS(j.schema)&&(C?(0,$.jsx)(Cl,{shortcut:`Space`,action:`toggle`}):(0,$.jsx)(Cl,{shortcut:`→`,action:`expand`}))]}),children:(0,$.jsxs)(G,{flexDirection:`column`,children:[de(),(0,$.jsxs)(G,{children:[(0,$.jsx)(K,{color:`success`,children:s===`accept`?d.pointer:` `}),(0,$.jsx)(K,{bold:s===`accept`,color:s===`accept`?`success`:void 0,dimColor:s!==`accept`,children:` Accept `}),(0,$.jsx)(K,{color:`error`,children:s===`decline`?d.pointer:` `}),(0,$.jsx)(K,{bold:s===`decline`,color:s===`decline`?`error`:void 0,dimColor:s!==`decline`,children:` Decline`})]})]})})}function zS({event:e,onResponse:t,onWaitingDismiss:n}){let{serverName:r,signal:i,waitingState:a}=e,{message:o,url:s}=e.params,[c,l]=(0,Q.useState)(`prompt`),u=(0,Q.useRef)(`prompt`),[f,p]=(0,Q.useState)(`accept`),m=a?.showCancel??!1;Ay(`Claude Code needs your input`,`elicitation_url_dialog`),xo(`elicitation-url`),u.current=c;let h=(0,Q.useRef)(n);h.current=n,(0,Q.useEffect)(()=>{let e=()=>{u.current===`waiting`?h.current?.(`cancel`):t(`cancel`)};if(i.aborted){e();return}return i.addEventListener(`abort`,e),()=>i.removeEventListener(`abort`,e)},[i,t]);let g=``,_=``,v=``;try{g=new URL(s).hostname;let e=s.indexOf(g);_=s.slice(0,e),v=s.slice(e+g.length)}catch{g=s}(0,Q.useEffect)(()=>{c===`waiting`&&e.completed&&n?.(m?`retry`:`dismiss`)},[c,e.completed,n,m]);let y=(0,Q.useCallback)(()=>{$c(s),t(`accept`),l(`waiting`),u.current=`waiting`,p(`open`)},[t,s]);if(Xl((e,r)=>{if(c===`prompt`){if(r.leftArrow||r.rightArrow){p(e=>e===`accept`?`decline`:`accept`);return}r.return&&(f===`accept`?y():t(`decline`))}else{let e=m?[`open`,`action`,`cancel`]:[`open`,`action`];if(r.leftArrow||r.rightArrow){p(t=>{let n=e.indexOf(t),i=r.rightArrow?1:-1;return e[(n+i+e.length)%e.length]});return}r.return&&(f===`open`?$c(s):f===`cancel`?n?.(`cancel`):n?.(m?`retry`:`dismiss`))}}),c===`waiting`){let e=a?.actionLabel??`Continue without waiting`;return(0,$.jsx)(lu,{title:`MCP server \u201c${r}\u201d \u2014 waiting for completion`,subtitle:`\n${o}`,color:`permission`,onCancel:()=>n?.(`cancel`),isCancelActive:!0,inputGuide:e=>e.pending?(0,$.jsxs)(K,{children:[`Press `,e.keyName,` again to exit`]}):(0,$.jsxs)(Nl,{children:[(0,$.jsx)(Lo,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),(0,$.jsx)(Cl,{shortcut:`\\u2190\\u2192`,action:`switch`})]}),children:(0,$.jsxs)(G,{flexDirection:`column`,children:[(0,$.jsx)(G,{marginBottom:1,flexDirection:`column`,children:(0,$.jsxs)(K,{children:[_,(0,$.jsx)(K,{bold:!0,children:g}),v]})}),(0,$.jsx)(G,{marginBottom:1,children:(0,$.jsx)(K,{dimColor:!0,italic:!0,children:`Waiting for the server to confirm completion…`})}),(0,$.jsxs)(G,{children:[(0,$.jsx)(K,{color:`success`,children:f===`open`?d.pointer:` `}),(0,$.jsx)(K,{bold:f===`open`,color:f===`open`?`success`:void 0,dimColor:f!==`open`,children:` Reopen URL `}),(0,$.jsx)(K,{color:`success`,children:f===`action`?d.pointer:` `}),(0,$.jsx)(K,{bold:f===`action`,color:f===`action`?`success`:void 0,dimColor:f!==`action`,children:` ${e}`}),m&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(K,{children:` `}),(0,$.jsx)(K,{color:`error`,children:f===`cancel`?d.pointer:` `}),(0,$.jsx)(K,{bold:f===`cancel`,color:f===`cancel`?`error`:void 0,dimColor:f!==`cancel`,children:` Cancel`})]})]})]})})}return(0,$.jsx)(lu,{title:`MCP server \u201c${r}\u201d wants to open a URL`,subtitle:`\n${o}`,color:`permission`,onCancel:()=>t(`cancel`),isCancelActive:!0,inputGuide:e=>e.pending?(0,$.jsxs)(K,{children:[`Press `,e.keyName,` again to exit`]}):(0,$.jsxs)(Nl,{children:[(0,$.jsx)(Lo,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),(0,$.jsx)(Cl,{shortcut:`\\u2190\\u2192`,action:`switch`})]}),children:(0,$.jsxs)(G,{flexDirection:`column`,children:[(0,$.jsx)(G,{marginBottom:1,flexDirection:`column`,children:(0,$.jsxs)(K,{children:[_,(0,$.jsx)(K,{bold:!0,children:g}),v]})}),(0,$.jsxs)(G,{children:[(0,$.jsx)(K,{color:`success`,children:f===`accept`?d.pointer:` `}),(0,$.jsx)(K,{bold:f===`accept`,color:f===`accept`?`success`:void 0,dimColor:f!==`accept`,children:` Accept `}),(0,$.jsx)(K,{color:`error`,children:f===`decline`?d.pointer:` `}),(0,$.jsx)(K,{bold:f===`decline`,color:f===`decline`?`error`:void 0,dimColor:f!==`decline`,children:` Decline`})]})]})})}q(),O(),ar(),pg();function BS({title:e,toolInputSummary:t,request:n,onRespond:r,onAbort:i}){Il(`app:interrupt`,i,{isActive:!0});let a=n.options.map(e=>({label:e.label,value:e.key,description:e.description}));return(0,$.jsx)(hg,{title:e,subtitle:n.message,titleRight:t?(0,$.jsx)(K,{dimColor:!0,children:t}):void 0,children:(0,$.jsx)(G,{flexDirection:`column`,paddingY:1,children:(0,$.jsx)(Hi,{options:a,onChange:e=>{r(e)}})})})}function VS(){return(0,Q.useSyncExternalStore)(va,Na)}Ef(),Su(),Uc(),Cu();var HS=`at_mentioned`,US=xu(()=>bu({method:_u(HS),params:bu({filePath:pu(),lineStart:mu().optional(),lineEnd:mu().optional()})}));function WS(e,t){let n=(0,Q.useRef)(void 0);(0,Q.useEffect)(()=>{let r=ol(e);n.current!==r&&(n.current=r),r&&r.client.setNotificationHandler(US(),e=>{if(n.current===r)try{let n=e.params,r=n.lineStart===void 0?void 0:n.lineStart+1,i=n.lineEnd===void 0?void 0:n.lineEnd+1;t({filePath:n.filePath,lineStart:r,lineEnd:i})}catch(e){Y(e)}})},[e,t])}cg(),ug(),Pg();function GS(e){return(0,Q.useMemo)(()=>{let t=e?.find(e=>e.name===`ide`);if(!t)return{status:null,ideName:null};let n=t.config,r=n.type===`sse-ide`||n.type===`ws-ide`?n.ideName:null;return t.type===`connected`?{status:`connected`,ideName:r}:t.type===`pending`?{status:`pending`,ideName:r}:{status:`disconnected`,ideName:r}},[e])}Vh();function KS(){let[e,t]=(0,Q.useState)({...qt});return(0,Q.useEffect)(()=>{let e=e=>{t({...e})};return Fi.add(e),()=>{Fi.delete(e)}},[]),e}q();function qS({ideSelection:e,mcpClients:t}){let{status:n}=GS(t),r=n===`connected`&&(e?.filePath||e?.text&&e.lineCount>0);if(n===null||!r||!e)return null;if(e.text&&e.lineCount>0)return(0,$.jsxs)(K,{color:`ide`,wrap:`truncate`,children:[`⧉ `,e.lineCount,` `,e.lineCount===1?`line`:`lines`,` selected`]},`selection-indicator`);if(e.filePath)return(0,$.jsxs)(K,{color:`ide`,wrap:`truncate`,children:[`⧉ In `,n_(e.filePath)]},`selection-indicator`)}function JS(){return(0,Q.useSyncExternalStore)(Ps.subscribe,Ps.getState)}q(),br();function YS({tokenUsage:e,model:t}){let{percentLeft:n,isAboveWarningThreshold:r,isAboveErrorThreshold:i}=dn(e,t),a=JS();if(!r||a)return null;let o=Xn(),s=al(`warning`),c=`${n}% until auto-compact`;return(0,$.jsx)(G,{flexDirection:`row`,children:o?(0,$.jsx)(K,{dimColor:!0,wrap:`truncate`,children:s?`${c} \u00b7 ${s}`:c}):(0,$.jsx)(K,{color:i?`error`:`warning`,wrap:`truncate`,children:s?`Context low (${n}% remaining) \u00b7 ${s}`:`Context low (${n}% remaining) \u00b7 Run /compact to compact & continue`})})}q(),R();function XS(){let[e,t]=(0,Q.useState)(0),n=(0,Q.useRef)(null),r=an(`app:toggleTranscript`,`Global`,`ctrl+o`);return(0,Q.useEffect)(()=>{if(!pa.isSandboxingEnabled())return;let e=pa.getSandboxViolationStore(),r=e.getTotalCount(),i=e.subscribe(()=>{let i=e.getTotalCount(),a=i-r;a>0&&(t(a),r=i,n.current&&clearTimeout(n.current),n.current=setTimeout(t,5e3,0))});return()=>{i(),n.current&&clearTimeout(n.current)}},[]),!pa.isSandboxingEnabled()||e===0?null:(0,$.jsx)(G,{paddingX:0,paddingY:0,children:(0,$.jsxs)(K,{color:`inactive`,wrap:`truncate`,children:[`⧈ Sandbox blocked `,e,` `,e===1?`operation`:`operations`,` ·`,` `,r,` for details · /sandbox to disable`]})})}Ot(),If(),U(),q(),Tn(),Ph(),Kf(),Uc(),P(),fn();var ZS=5e3;function QS({apiKeyStatus:e,autoUpdaterResult:t,debug:n,isAutoUpdating:r,verbose:i,messages:a,onAutoUpdaterResult:o,onChangeIsUpdating:s,ideSelection:c,mcpClients:l,isInputWrapped:u=!1,isNarrow:d=!1}){let f=(0,Q.useMemo)(()=>xl(sn(a)),[a]),p=Bh(),m=dn(f,p).isAboveWarningThreshold,{status:h}=GS(l),g=W(e=>e.notifications),{addNotification:_,removeNotification:v}=ki(),y=KS();(0,Q.useEffect)(()=>(yc((e,t)=>{_({key:`env-hook`,text:e,color:t?`error`:void 0,priority:t?`medium`:`low`,timeoutMs:t?8e3:5e3})}),()=>yc(null)),[_]),h===`connected`&&(c?.filePath||c?.text&&c.lineCount);let b=y.isUsingOverage,x=cp(),S=x===`team`||x===`enterprise`,C=Fh(),w=u&&!m&&e!==`invalid`&&e!==`missing`&&C!==void 0;return(0,Q.useEffect)(()=>{w&&C?(X(`tengu_external_editor_hint_shown`,{}),_({key:`external-editor-hint`,jsx:(0,$.jsx)(K,{dimColor:!0,children:(0,$.jsx)(Lo,{action:`chat:externalEditor`,context:`Chat`,fallback:`ctrl+g`,description:`edit in ${B(C)}`})}),priority:`immediate`,timeoutMs:5e3})):v(`external-editor-hint`)},[w,C,_,v]),(0,$.jsx)(G,{flexDirection:`column`,alignItems:d?`flex-start`:`flex-end`,flexShrink:0,overflowX:`hidden`,children:(0,$.jsx)($S,{ideSelection:c,mcpClients:l,notifications:g,isInOverageMode:b??!1,isTeamOrEnterprise:S,apiKeyStatus:e,debug:n,verbose:i,tokenUsage:f,mainLoopModel:p})})}function $S({ideSelection:e,mcpClients:t,notifications:n,isInOverageMode:r,isTeamOrEnterprise:i,apiKeyStatus:a,debug:s,verbose:c,tokenUsage:l,mainLoopModel:u}){let[d,f]=(0,Q.useState)(null);return(0,Q.useEffect)(()=>{if(!np())return;let e=setInterval(e=>{let t=sp(),n=t>=1e4?Wf(t):null;e(e=>n===e?e:n)},1e3,f);return()=>clearInterval(e)},[]),(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(qS,{ideSelection:e,mcpClients:t}),n.current&&(`jsx`in n.current?(0,$.jsx)(K,{wrap:`truncate`,children:n.current.jsx},n.current.key):(0,$.jsx)(K,{color:n.current.color,dimColor:!n.current.color,wrap:`truncate`,children:n.current.text})),r&&!i&&(0,$.jsx)(G,{children:(0,$.jsx)(K,{dimColor:!0,wrap:`truncate`,children:`Now using extra usage`})}),d&&(0,$.jsxs)(G,{children:[(0,$.jsxs)(K,{color:`warning`,wrap:`truncate`,children:[`apiKeyHelper is taking a while`,` `]}),(0,$.jsxs)(K,{dimColor:!0,wrap:`truncate`,children:[`(`,d,`)`]})]}),(a===`invalid`||a===`missing`)&&(0,$.jsx)(G,{children:(0,$.jsx)(K,{color:`error`,wrap:`truncate`,children:o(process.env.CLAUDE_CODE_REMOTE)?`Authentication error · Try again`:`Not logged in`})}),s&&(0,$.jsx)(G,{children:(0,$.jsx)(K,{color:`warning`,wrap:`truncate`,children:`Debug mode`})}),a!==`invalid`&&a!==`missing`&&c&&(0,$.jsx)(G,{children:(0,$.jsxs)(K,{dimColor:!0,wrap:`truncate`,children:[l,` tokens`]})}),(0,$.jsx)(YS,{tokenUsage:l,model:u}),(0,$.jsx)(XS,{})]})}Ot(),fn(),q();var eC=10,tC=null,nC=0,rC;async function iC(e,t){let n=Math.ceil(e/eC)*eC;if(tC&&nC>=n&&rC===t)return tC;tC&&await tC,nC=n,rC=t,tC=(async()=>{let e=[],n=0;for await(let r of cn())if(!(t&&F(r.display)!==t)&&(e.push(r),n++,n>=nC))break;return e})();try{return await tC}finally{tC=null,nC=0,rC=void 0}}function aC(e,t,n,r,i){let[a,o]=(0,Q.useState)(0),[s,c]=(0,Q.useState)(void 0),l=(0,Q.useRef)(!1),{addNotification:u,removeNotification:d}=ki(),f=(0,Q.useRef)([]),p=(0,Q.useRef)(void 0),m=(0,Q.useRef)(0),h=(0,Q.useRef)(void 0),g=(0,Q.useRef)(t),_=(0,Q.useRef)(n),v=(0,Q.useRef)(i);g.current=t,_.current=n,v.current=i;let y=(0,Q.useCallback)((t,n,i,a=!1)=>{e(t,n,i),r?.(a?0:t.length)},[e,r]),b=(0,Q.useCallback)((e,t=!1)=>{if(!e||!e.display)return;let n=F(e.display),r=n===`bash`?e.display.slice(1):e.display;y(r,n,e.pastedContents??{},t)},[y]),x=(0,Q.useCallback)(()=>{u({key:`search-history-hint`,jsx:(0,$.jsx)(K,{dimColor:!0,children:(0,$.jsx)(Lo,{action:`history:search`,context:`Global`,fallback:`ctrl+r`,description:`search history`})}),priority:`immediate`,timeoutMs:ZS})},[u]);return{historyIndex:a,setHistoryIndex:o,onHistoryUp:(0,Q.useCallback)(()=>{let e=m.current;m.current++;let t=g.current,n=_.current,r=v.current;if(e===0){h.current=r===`bash`?r:void 0;let e=t.trim()!==``;c(e?{display:t,pastedContents:n,mode:r}:void 0)}let i=h.current;(async()=>{let t=e+1;if(p.current!==i&&(f.current=[],p.current=i,m.current=0),f.current.length<t){let e=await iC(t,i);e.length>f.current.length&&(f.current=e)}if(e>=f.current.length){m.current--;return}let n=e+1;o(n),b(f.current[e],!0),n>=2&&!l.current&&(l.current=!0,x())})()},[b,x]),onHistoryDown:(0,Q.useCallback)(()=>{let e=m.current;if(e>1)m.current--,o(e-1),b(f.current[e-2]);else if(e===1)if(m.current=0,o(0),s){let e=s.mode;e?y(s.display,e,s.pastedContents??{}):b(s)}else y(``,h.current??`prompt`,{});return e<=0},[s,b,y]),resetHistory:(0,Q.useCallback)(()=>{c(void 0),o(0),m.current=0,h.current=void 0,d(`search-history-hint`),f.current=[],p.current=void 0},[d]),dismissSearchHint:(0,Q.useCallback)(()=>{d(`search-history-hint`)},[d])}}U();function oC(){let e=W(e=>e.tasks);return(0,Q.useMemo)(()=>{let t=Date.now();return Object.values(e).filter(Qr).filter(e=>e.agentType!==`main-session`).filter(e=>e.isBackgrounded!==!1).filter(e=>e.evictAfter===void 0||e.evictAfter>t).sort((e,t)=>e.startTime-t.startTime)},[e])}at(),Wn(),q(),O();function sC(e,t,n,r,i,a,o,s,c,l,u){let[d,f]=(0,Q.useState)(``),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(``),[_,v]=(0,Q.useState)(0),[y,b]=(0,Q.useState)(`prompt`),[x,S]=(0,Q.useState)({}),[C,w]=(0,Q.useState)(void 0),T=(0,Q.useRef)(void 0),E=(0,Q.useRef)(new Set),D=(0,Q.useRef)(null),O=(0,Q.useCallback)(()=>{T.current&&(T.current.return(void 0),T.current=void 0)},[]),k=(0,Q.useCallback)(()=>{c(!1),f(``),m(!1),g(``),v(0),b(`prompt`),S({}),w(void 0),O(),E.current.clear()},[c,O]),A=(0,Q.useCallback)(async(e,t)=>{if(s){if(d.length===0){O(),E.current.clear(),w(void 0),m(!1),n(h),r(_),a(y),l(x);return}if(e||(O(),T.current=ze(),E.current.clear()),T.current)for(;;){if(t?.aborted)return;let e=await T.current.next();if(e.done){m(!0);return}let i=e.value.display,o=i.lastIndexOf(d);if(o!==-1&&!E.current.has(i)){E.current.add(i),w(e.value),m(!1),a(F(i)),n(i),l(e.value.pastedContents);let t=Kr(i).lastIndexOf(d);r(t===-1?o:t);return}}}},[s,d,O,n,r,a,l,h,_,y,x]),ee=(0,Q.useCallback)(()=>{c(!0),g(t),v(i),b(o),S(u),T.current=ze(),E.current.clear()},[c,t,i,o,u]),j=(0,Q.useCallback)(()=>{A(!0)},[A]),te=(0,Q.useCallback)(()=>{if(C){let e=F(C.display);n(Kr(C.display)),a(e),l(C.pastedContents)}else l(x);k()},[C,n,a,l,x,k]),ne=(0,Q.useCallback)(()=>{n(h),r(_),l(x),k()},[n,r,l,h,_,x,k]),M=(0,Q.useCallback)(()=>{if(d.length===0)e({display:h,pastedContents:x});else if(C){let t=F(C.display),n=Kr(C.display);a(t),e({display:n,pastedContents:C.pastedContents})}k()},[d,C,e,a,h,x,k]);Il(`history:search`,ee,{context:`Global`,isActive:!s}),El((0,Q.useMemo)(()=>({"historySearch:next":j,"historySearch:accept":te,"historySearch:cancel":ne,"historySearch:execute":M}),[j,te,ne,M]),{context:`HistorySearch`,isActive:s});let N=e=>{s&&e.key===`backspace`&&d===``&&(e.preventDefault(),ne())};Xl((e,t,n)=>{N(new Fl(n.keypress))},{isActive:s});let P=(0,Q.useRef)(A);return P.current=A,(0,Q.useEffect)(()=>{D.current?.abort();let e=new AbortController;return D.current=e,P.current(!1,e.signal),()=>{e.abort()}},[d]),{historyQuery:d,setHistoryQuery:f,historyMatch:C,historyFailedMatch:p,handleKeyDown:N}}function cC({maxBufferSize:e,debounceMs:t}){let[n,r]=(0,Q.useState)([]),[i,a]=(0,Q.useState)(-1),o=(0,Q.useRef)(0),s=(0,Q.useRef)(null),c=(0,Q.useCallback)((l,u,d={})=>{let f=Date.now();if(s.current&&(clearTimeout(s.current),s.current=null),f-o.current<t){s.current=setTimeout(c,t,l,u,d);return}o.current=f,r(t=>{let n=i>=0?t.slice(0,i+1):t,r=n[n.length-1];if(r&&r.text===l)return n;let a=[...n,{text:l,cursorOffset:u,pastedContents:d,timestamp:f}];return a.length>e?a.slice(-e):a}),a(t=>{let r=t>=0?t+1:n.length;return Math.min(r,e-1)})},[t,e,i,n.length]),l=(0,Q.useCallback)(()=>{if(i<0||n.length===0)return;let e=Math.max(0,i-1),t=n[e];if(t)return a(e),t},[n,i]),u=(0,Q.useCallback)(()=>{r([]),a(-1),o.current=0,s.current&&(clearTimeout(s.current),s.current=null)},[o,s]);return{pushToBuffer:c,undo:l,canUndo:i>0&&n.length>1,clearBuffer:u}}q(),If(),U();function lC({inputValue:e,isAssistantResponding:t}){let n=W(e=>e.promptSuggestion),r=Qo(),i=Ll(),{text:a,promptId:o,shownAt:s,acceptedAt:c,generationRequestId:l}=n,u=t||e.length>0?null:a,d=a&&s>0,f=(0,Q.useRef)(0),p=(0,Q.useRef)(!0),m=(0,Q.useRef)(0);s>0&&s!==m.current?(m.current=s,p.current=i,f.current=0):s===0&&(m.current=0),e.length>0&&f.current===0&&d&&(f.current=Date.now());let h=(0,Q.useCallback)(()=>{di(r),r(e=>({...e,promptSuggestion:{text:null,promptId:null,shownAt:0,acceptedAt:0,generationRequestId:null}}))},[r]);return{suggestion:u,markAccepted:(0,Q.useCallback)(()=>{d&&r(e=>({...e,promptSuggestion:{...e.promptSuggestion,acceptedAt:Date.now()}}))},[d,r]),markShown:(0,Q.useCallback)(()=>{r(e=>e.promptSuggestion.shownAt!==0||!e.promptSuggestion.text?e:{...e,promptSuggestion:{...e.promptSuggestion,shownAt:Date.now()}})},[r]),logOutcomeAtSubmission:(0,Q.useCallback)((e,t)=>{if(!d)return;let n=c>s,r=n||e===a,i=r&&c||Date.now();X(`tengu_prompt_suggestion`,{source:`cli`,outcome:r?`accepted`:`ignored`,prompt_id:o,...l&&{generationRequestId:l},...r&&{acceptMethod:n?`tab`:`enter`},...r&&{timeToAcceptMs:i-s},...!r&&{timeToIgnoreMs:i-s},...f.current>0&&{timeToFirstKeystrokeMs:f.current-s},wasFocusedWhenShown:p.current,similarity:Math.round(e.length/(a?.length||1)*100)/100}),t?.skipReset||h()},[d,c,s,a,o,l,h])}}ge(),bd(),Km();var uC=15,dC=1e3,fC=[`|`,`||`,`&&`,`;`];function pC(e){return typeof e==`object`&&!!e&&`op`in e&&fC.includes(e.op)}function mC(e){return e.startsWith(`$`)?`variable`:e.includes(`/`)||e.startsWith(`~`)||e.startsWith(`.`)?`file`:`command`}function hC(e){let t=e.findLastIndex(e=>typeof e==`string`);return t===-1?null:{token:e[t],index:t}}function gC(e,t){if(t===0)return!0;let n=e[t-1];return n!==void 0&&pC(n)}function _C(e,t){let n=e.slice(0,t),r=n.match(/\$[a-zA-Z_][a-zA-Z0-9_]*$/);if(r)return{prefix:r[0],completionType:`variable`};let i=bm(n);if(!i.success){let e=n.split(/\s+/),t=e[e.length-1]||``;return{prefix:t,completionType:e.length===1&&!n.includes(` `)?`command`:mC(t)}}let a=hC(i.tokens);if(!a){let e=i.tokens[i.tokens.length-1];return{prefix:``,completionType:(e&&pC(e),`command`)}}if(n.endsWith(` `))return{prefix:``,completionType:`file`};let o=mC(a.token);if(o===`variable`||o===`file`)return{prefix:a.token,completionType:o};let s=gC(i.tokens,a.index)?`command`:`file`;return{prefix:a.token,completionType:s}}function vC(e,t){return t===`variable`?`compgen -v ${xm([e.slice(1)])} 2>/dev/null`:t===`file`?`compgen -f ${xm([e])} 2>/dev/null | head -${uC} | while IFS= read -r f; do [ -d "$f" ] && echo "$f/" || echo "$f "; done`:`compgen -c ${xm([e])} 2>/dev/null`}function yC(e,t){return t===`variable`?`print -rl -- \${(k)parameters[(I)${xm([e.slice(1)])}*]} 2>/dev/null`:t===`file`?`for f in ${xm([e])}*(N[1,${uC}]); do [[ -d "$f" ]] && echo "$f/" || echo "$f "; done`:`print -rl -- \${(k)commands[(I)${xm([e])}*]} 2>/dev/null`}async function bC(e,t,n,r){let i;if(e===`bash`)i=vC(t,n);else if(e===`zsh`)i=yC(t,n);else return[];return(await(await Tt(i,r,`bash`,{timeout:dC})).result).stdout.split(`
36
- `).filter(e=>e.trim()).slice(0,uC).map(e=>({id:e,displayText:e,description:void 0,metadata:{completionType:n}}))}async function xC(e,t,n){let r=qm();if(r!==`bash`&&r!==`zsh`)return[];try{let{prefix:i,completionType:a}=_C(e,t);return i?(await bC(r,i,a,n)).map(t=>({...t,metadata:{...t.metadata,inputSnapshot:e}})):[]}catch(e){return J(`Shell completion failed: ${e}`),[]}}qv();var SC=/[:_-]/g,CC=null;function wC(e){if(CC?.commands===e)return CC.fuse;let t=new Kv(e.filter(e=>!e.isHidden).map(e=>{let t=ct(e),n=t.split(SC).filter(Boolean);return{descriptionKey:(e.description??``).split(` `).map(e=>IC(e)).filter(Boolean),partKey:n.length>1?n:void 0,commandName:t,command:e,aliasKey:e.aliases}}),{includeScore:!0,threshold:.3,location:0,distance:100,keys:[{name:`commandName`,weight:3},{name:`partKey`,weight:2},{name:`aliasKey`,weight:2},{name:`descriptionKey`,weight:.5}]});return CC={commands:e,fuse:t},t}function TC(e){return typeof e==`object`&&!!e&&`name`in e&&typeof e.name==`string`&&`type`in e}function EC(e,t){if(e.startsWith(`/`))return null;let n=e.slice(0,t).match(/\s\/([a-zA-Z0-9_:-]*)$/);if(!n||n.index===void 0)return null;let r=n.index+1,i=e.slice(r+1).match(/^[a-zA-Z0-9_:-]*/),a=i?i[0]:``;return t>r+1+a.length?null:{token:`/`+a,startPos:r,partialCommand:a}}function DC(e,t){if(!e)return null;let n=PC(`/`+e,t);if(n.length===0)return null;let r=e.toLowerCase();for(let t of n){if(!TC(t.metadata))continue;let n=ct(t.metadata);if(n.toLowerCase().startsWith(r)){let t=n.slice(e.length);if(t)return{suffix:t,fullCommand:n}}}return null}function OC(e){return e.startsWith(`/`)}function kC(e){return!(!OC(e)||!e.includes(` `)||e.endsWith(` `))}function AC(e){return`/${e} `}function jC(e){let t=ct(e);return e.type===`prompt`?e.source===`plugin`&&e.pluginInfo?.repository?`${t}:${e.source}:${e.pluginInfo.repository}`:`${t}:${e.source}`:`${t}:${e.type}`}function MC(e,t){if(!(!t||t.length===0||e===``))return t.find(t=>t.toLowerCase().startsWith(e))}function NC(e,t){let n=ct(e),r=t?` (${t})`:``,i=e.type===`prompt`&&e.kind===`workflow`,a=e.type===`prompt`&&!i&&(e.source===`projectSettings`||e.source===`localSettings`)?`local`:void 0,o=(i?e.description:Cn(e))+(e.type===`prompt`&&e.argNames?.length?` (arguments: ${e.argNames.join(`, `)})`:``);return{id:jC(e),displayText:`/${n}${r}`,tag:i?`workflow`:a,description:o,metadata:e}}function PC(e,t){if(!OC(e)||kC(e))return[];let n=e.slice(1).toLowerCase().trim();if(n===``){let e=t.filter(e=>!e.isHidden),n=[],r=e.filter(e=>e.type===`prompt`).map(e=>({cmd:e,score:z(ct(e))})).filter(e=>e.score>0).sort((e,t)=>t.score-e.score);for(let e of r.slice(0,5))n.push(e.cmd);let i=new Set(n.map(e=>jC(e))),a=[],o=[],s=[],c=[],l=[];e.forEach(e=>{i.has(jC(e))||(e.type===`local`||e.type===`local-jsx`?a.push(e):e.type===`prompt`&&(e.source===`userSettings`||e.source===`localSettings`)?o.push(e):e.type===`prompt`&&e.source===`projectSettings`?s.push(e):e.type===`prompt`&&e.source===`policySettings`?c.push(e):l.push(e))});let u=(e,t)=>ct(e).localeCompare(ct(t));return a.sort(u),o.sort(u),s.sort(u),c.sort(u),l.sort(u),[...n,...a,...o,...s,...c,...l].map(e=>NC(e))}let r=t.find(e=>e.isHidden&&ct(e).toLowerCase()===n);r&&t.some(e=>!e.isHidden&&ct(e).toLowerCase()===n)&&(r=void 0);let i=wC(t).search(n).map(e=>({r:e,name:e.item.commandName.toLowerCase(),aliases:e.item.aliasKey?.map(e=>e.toLowerCase())??[],usage:e.item.command.type===`prompt`?z(ct(e.item.command)):0})).sort((e,t)=>{let r=e.name,i=t.name,a=e.aliases,o=t.aliases,s=r===n,c=i===n;if(s&&!c)return-1;if(c&&!s)return 1;let l=a.some(e=>e===n),u=o.some(e=>e===n);if(l&&!u)return-1;if(u&&!l)return 1;let d=r.startsWith(n),f=i.startsWith(n);if(d&&!f)return-1;if(f&&!d)return 1;if(d&&f&&r.length!==i.length)return r.length-i.length;let p=a.find(e=>e.startsWith(n)),m=o.find(e=>e.startsWith(n));if(p&&!m)return-1;if(m&&!p)return 1;if(p&&m&&p.length!==m.length)return p.length-m.length;let h=(e.r.score??0)-(t.r.score??0);return Math.abs(h)>.1?h:t.usage-e.usage}).map(e=>{let t=e.r.item.command;return NC(t,MC(n,t.aliases))});if(r){let e=jC(r);if(!i.some(t=>t.id===e))return[NC(r),...i]}return i}function FC(e,t,n,r,i,a){let o,s;if(typeof e==`string`)o=e,s=t?Jn(o,n):void 0;else{if(!TC(e.metadata))return;o=ct(e.metadata),s=e.metadata}let c=AC(o);r(c),i(c.length),t&&s&&(s.type!==`prompt`||(s.argNames??[]).length===0)&&a(c,!0)}function IC(e){return e.toLowerCase().replace(/[^a-z0-9]/g,``)}function LC(e){let t=[],n=/(^|[\s])(\/[a-zA-Z][a-zA-Z0-9:\-_]*)/g,r=null;for(;(r=n.exec(e))!==null;){let e=r[1]??``,n=r[2]??``,i=r.index+e.length;t.push({start:i,end:i+n.length})}return t}Oh(),Wn(),bd();var RC=null,zC=0,BC=6e4;async function VC(){let e=Date.now();if(RC&&e-zC<BC)return RC;let t=[],n=new Set;try{for await(let e of cn()){if(e.display&&e.display.startsWith(`!`)){let r=e.display.slice(1).trim();r&&!n.has(r)&&(n.add(r),t.push(r))}if(t.length>=50)break}}catch(e){J(`Failed to read shell history: ${e}`)}return RC=t,zC=e,t}function HC(e){if(!RC)return;let t=RC.indexOf(e);t!==-1&&RC.splice(t,1),RC.unshift(e)}async function UC(e){if(!e||e.length<2||!e.trim())return null;let t=await VC();for(let n of t)if(n.startsWith(e)&&n!==e)return{fullCommand:n,suffix:n.slice(e.length)};return null}wm(),bd(),Cu(),id(),wd();var WC=`slack_search_channels`,GC=new Map,KC=new Set,qC=0,JC=Xu(),YC=JC.subscribe,XC=null,ZC=null;function QC(e){return e.find(e=>e.type===`connected`&&e.name.includes(`slack`))}async function $C(e,t){let n=QC(e);if(!n||n.type!==`connected`)return[];try{let e=(await n.client.callTool({name:WC,arguments:{query:t,limit:20,channel_types:`public_channel,private_channel`}},void 0,{timeout:5e3})).content;return Array.isArray(e)?nw(tw(e.filter(e=>e.type===`text`).map(e=>e.text).join(`
37
- `))):[]}catch(e){return J(`Failed to fetch Slack channels: ${e}`),[]}}var ew=xu(()=>bu({results:pu()}));function tw(e){let t=e.trim();if(!t.startsWith(`{`))return e;try{let e=ew().safeParse(md(t));if(e.success)return e.data.results}catch{}return e}function nw(e){let t=[],n=new Set;for(let r of e.split(`
38
- `)){let e=r.match(/^Name:\s*#?([a-z0-9][a-z0-9_-]{0,79})\s*$/);e&&!n.has(e[1])&&(n.add(e[1]),t.push(e[1]))}return t}function rw(e){return QC(e)!==void 0}function iw(){return qC}function aw(e){let t=[],n=/(^|\s)#([a-z0-9][a-z0-9_-]{0,79})(?=\s|$)/g,r;for(;(r=n.exec(e))!==null;){if(!KC.has(r[2]))continue;let e=r.index+r[1].length;t.push({start:e,end:e+1+r[2].length})}return t}function ow(e){let t=Math.max(e.lastIndexOf(`-`),e.lastIndexOf(`_`));return t>0?e.slice(0,t):e}function sw(e,t){let n,r=0;for(let[i,a]of GC)e.startsWith(i)&&i.length>r&&a.some(e=>e.startsWith(t))&&(n=a,r=i.length);return n}async function cw(e,t){if(!t)return[];let n=ow(t),r=t.toLowerCase(),i=GC.get(n)??sw(n,r);if(!i)if(XC===n&&ZC)i=await ZC;else{XC=n,ZC=$C(e,n),i=await ZC,GC.set(n,i);let t=KC.size;for(let e of i)KC.add(e);KC.size!==t&&(qC++,JC.emit()),GC.size>50&&GC.delete(GC.keys().next().value),XC===n&&(XC=null,ZC=null)}return i.filter(e=>e.startsWith(r)).sort().slice(0,10).map(e=>({id:`slack-channel-${e}`,displayText:`#${e}`}))}qv(),Hh(),za(),Kf(),Ef();function lw(e){switch(e.type){case`file`:return{id:`file-${e.path}`,displayText:e.displayText,description:e.description};case`mcp_resource`:return{id:`mcp-resource-${e.server}__${e.uri}`,displayText:e.displayText,description:e.description};case`agent`:return{id:`agent-${e.agentType}`,displayText:e.displayText,description:e.description,color:e.color}}}var uw=15,dw=60;function fw(e){return Vf(e,dw)}function pw(e,t,n=!1){if(!t&&!n)return[];try{let n=e.map(e=>({type:`agent`,displayText:`${e.agentType} (agent)`,description:fw(e.whenToUse),agentType:e.agentType,color:S(e.agentType)}));if(!t)return n;let r=t.toLowerCase();return n.filter(e=>e.agentType.toLowerCase().includes(r)||e.displayText.toLowerCase().includes(r))}catch(e){return Y(e),[]}}async function mw(e,t,n,r=!1){if(!e&&!r)return[];let[i,a]=await Promise.all([Uh(e,r),Promise.resolve(pw(n,e,r))]),o=i.map(e=>({type:`file`,displayText:e.displayText,description:e.description,path:e.displayText,filename:n_(e.displayText),score:e.metadata?.score})),s=Object.values(t).flat().map(e=>({type:`mcp_resource`,displayText:`${e.server}:${e.uri}`,description:fw(e.description||e.name||e.uri),server:e.server,uri:e.uri,name:e.name||e.uri}));if(!e)return[...o,...s,...a].slice(0,uw).map(lw);let c=[...s,...a],l=[];for(let e of o)l.push({source:e,score:e.score??.5});if(c.length>0){let t=new Kv(c,{includeScore:!0,threshold:.6,keys:[{name:`displayText`,weight:2},{name:`name`,weight:3},{name:`server`,weight:1},{name:`description`,weight:1},{name:`agentType`,weight:3}]}).search(e,{limit:uw});for(let e of t)l.push({source:e.item,score:e.score??.5})}return l.sort((e,t)=>e.score-t.score),l.slice(0,uw).map(e=>e.source).map(lw)}Ot(),q(),If(),ae(),at(),fc(),_n(),O(),Mo(),U(),Kf(),he(),Hh();var hw=/^@[\p{L}\p{N}\p{M}_\-./\\()[\]~:]*/u,gw=/^[\p{L}\p{N}\p{M}_\-./\\()[\]~:]+/u,_w=/(@[\p{L}\p{N}\p{M}_\-./\\()[\]~:]*|[\p{L}\p{N}\p{M}_\-./\\()[\]~:]+)$/u,vw=/[\p{L}\p{N}\p{M}_\-./\\()[\]~:]+$/u,yw=/(^|\s)@([\p{L}\p{N}\p{M}_\-./\\()[\]~:]*|"[^"]*"?)$/u,bw=/(^|\s)#([a-z0-9][a-z0-9_-]*)$/;function xw(e){return typeof e==`object`&&!!e&&`type`in e&&(e.type===`directory`||e.type===`file`)}function Sw(e,t,n){if(n.length===0)return-1;if(t<0)return 0;let r=e[t];if(!r)return 0;let i=n.findIndex(e=>e.id===r.id);return i>=0?i:0}function Cw(e){let t=e.metadata;return t?.sessionId?`/resume ${t.sessionId}`:`/resume ${e.displayText}`}function ww(e){return e.isQuoted?e.token.slice(2).replace(/"$/,``):e.token.startsWith(`@`)?e.token.substring(1):e.token}function Tw(e){let{displayText:t,mode:n,hasAtPrefix:r,needsQuotes:i,isQuoted:a,isComplete:o}=e,s=o?` `:``;return a||i?n===`bash`?`"${t}"${s}`:`@"${t}"${s}`:r?n===`bash`?`${t}${s}`:`@${t}${s}`:t}function Ew(e,t,n,r,i,a){let o=t.slice(0,n).lastIndexOf(` `)+1,s;s=a===`variable`?`$`+e.displayText+` `:a===`command`?e.displayText+` `:e.displayText,r(t.slice(0,o)+s+t.slice(n)),i(o+s.length)}var Dw=/(^|\s)@[\w-]*$/;function Ow(e,t,n,r,i,a){let o=t.slice(0,n).match(r);if(!o||o.index===void 0)return;let s=o.index+(o[1]?.length??0),c=t.slice(0,s);i(c+e.displayText+` `+t.slice(n)),a(c.length+e.displayText.length+1)}var kw=null;async function Aw(e,t){try{return kw&&kw.abort(),kw=new AbortController,await xC(e,t,kw.signal)}catch{return X(`tengu_shell_completion_failed`,{}),[]}}function jw(e,t,n,r,i){let a=i?`/`:` `,o=e.slice(0,n),s=e.slice(n+r),c=`@`+t+a;return{newInput:o+c+s,cursorPos:o.length+c.length}}function Mw(e,t,n=!1){if(!e)return null;let r=e.substring(0,t);if(n){let n=r.match(/@"([^"]*)"?$/);if(n&&n.index!==void 0){let r=e.substring(t).match(/^[^"]*"?/),i=r?r[0]:``;return{token:n[0]+i,startPos:n.index,isQuoted:!0}}}if(n){let n=r.lastIndexOf(`@`);if(n>=0&&(n===0||/\s/.test(r[n-1]))){let i=r.substring(n),a=i.match(hw);if(a&&a[0].length===i.length){let r=e.substring(t).match(gw),i=r?r[0]:``;return{token:a[0]+i,startPos:n,isQuoted:!1}}}}let i=n?_w:vw,a=r.match(i);if(!a||a.index===void 0)return null;let o=e.substring(t).match(gw),s=o?o[0]:``;return{token:a[0]+s,startPos:a.index,isQuoted:!1}}function Nw(e){if(OC(e)){let t=e.indexOf(` `);return t===-1?{commandName:e.slice(1),args:``}:{commandName:e.slice(1,t),args:e.slice(t+1)}}return null}function Pw(e,t){return!e&&t.includes(` `)&&!t.endsWith(` `)}function Fw({commands:e,onInputChange:t,onSubmit:n,setCursorOffset:r,input:i,cursorOffset:a,mode:o,agents:s,setSuggestionsState:c,suggestionsState:{suggestions:l,selectedSuggestion:u,commandArgumentHint:d},suppressSuggestions:f=!1,markAccepted:p,onModeChange:m}){let{addNotification:h}=ki(),g=an(`chat:thinkingToggle`,`Chat`,`alt+t`),[_,v]=(0,Q.useState)(`none`),y=(0,Q.useMemo)(()=>{let t=e.filter(e=>!e.isHidden);if(t.length!==0)return Math.max(...t.map(e=>{let t=ct(e);return t?t.length:0}))+6},[e]),[b,x]=(0,Q.useState)(void 0),S=W(e=>e.mcp.resources),C=xa(),w=W(e=>e.promptSuggestion),T=W(e=>!!e.viewingAgentTaskId),E=Bl(),[D,O]=(0,Q.useState)(void 0),k=(0,Q.useMemo)(()=>{if(o!==`prompt`||f)return;let t=EC(i,a);if(!t)return;let n=DC(t.partialCommand,e);if(n)return{text:n.suffix,fullCommand:n.fullCommand,insertPosition:t.startPos+1+t.partialCommand.length}},[i,a,o,e,f]),A=f?void 0:o===`prompt`?k:D,ee=(0,Q.useRef)(a);ee.current=a;let j=(0,Q.useRef)(null),te=(0,Q.useRef)(``),ne=(0,Q.useRef)(``),M=(0,Q.useRef)(``),N=(0,Q.useRef)(``),P=(0,Q.useRef)(l);P.current=l;let re=(0,Q.useRef)(null),I=(0,Q.useCallback)(()=>{c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),v(`none`),x(void 0),O(void 0)},[c]),ie=(0,Q.useCallback)(async(e,t=!1)=>{j.current=e;let n=await mw(e,S,s,t);if(j.current===e){if(n.length===0){c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),v(`none`),x(void 0);return}c(e=>({commandArgumentHint:void 0,suggestions:n,selectedSuggestion:Sw(e.suggestions,e.selectedSuggestion,n)})),v(n.length>0?`file`:`none`),x(void 0)}},[S,c,v,x,s]);(0,Q.useEffect)(()=>(Kh(),Wh(()=>{let e=j.current;e!==null&&(j.current=null,ie(e,e===``))})),[ie]);let ae=uu(ie,50),oe=uu((0,Q.useCallback)(async e=>{N.current=e;let t=await cw(C.getState().mcp.clients,e);N.current===e&&(c(e=>({commandArgumentHint:void 0,suggestions:t,selectedSuggestion:Sw(e.suggestions,e.selectedSuggestion,t)})),v(t.length>0?`slack-channel`:`none`),x(void 0))},[c]),150),se=(0,Q.useCallback)(async(t,n)=>{let r=n??ee.current;if(f){ae.cancel(),I();return}if(o===`prompt`){let n=EC(t,r);if(n&&DC(n.partialCommand,e)){c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),v(`none`),x(void 0);return}}if(o===`bash`&&t.trim()){M.current=t;let e=await UC(t);if(M.current!==t)return;if(e){O({text:e.suffix,fullCommand:e.fullCommand,insertPosition:t.length}),c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),v(`none`),x(void 0);return}else O(void 0)}let i=o===`bash`?null:t.substring(0,r).match(/(^|\s)@([\w-]*)$/);if(i){let e=(i[2]??``).toLowerCase(),t=C.getState(),n=[],r=new Set;for(let[i,a]of t.agentNameRegistry){if(r.has(i)||!i.toLowerCase().startsWith(e))continue;let o=t.tasks[a]?.status;n.push({id:`dm-${i}`,displayText:`@${i}`,description:o?`send message · ${o}`:`send message`})}if(n.length>0){ae.cancel(),c(e=>({commandArgumentHint:void 0,suggestions:n,selectedSuggestion:Sw(e.suggestions,e.selectedSuggestion,n)})),v(`agent`),x(void 0);return}}if(o===`prompt`){let e=t.substring(0,r).match(bw);if(e&&rw(C.getState().mcp.clients)){oe(e[2]);return}else _===`slack-channel`&&(oe.cancel(),I())}let a=t.substring(0,r).match(yw),s=r===t.length&&r>0&&t.length>0&&t[r-1]===` `;if(o===`prompt`&&OC(t)&&r>0){let e=Nw(t);if(e&&e.commandName===`add-dir`&&e.args){let{args:t}=e;if(t.match(/\s+$/)){ae.cancel(),I();return}let n=await kh(t);if(n.length>0){c(e=>({suggestions:n,selectedSuggestion:Sw(e.suggestions,e.selectedSuggestion,n),commandArgumentHint:void 0})),v(`directory`);return}ae.cancel(),I();return}if(e&&e.commandName===`resume`&&e.args!==void 0&&t.includes(` `)){let{args:t}=e,n=(await ho(t,{limit:10})).map(e=>{let t=_o(e);return{id:`resume-title-${t}`,displayText:e.customTitle,description:Uf(e),metadata:{sessionId:t}}});if(n.length>0){c(e=>({suggestions:n,selectedSuggestion:Sw(e.suggestions,e.selectedSuggestion,n),commandArgumentHint:void 0})),v(`custom-title`);return}I();return}}let l=t.substring(0,r);if(o===`prompt`&&OC(l)&&r>0&&!Pw(s,l)){let t;if(l.length>1){let n=l.indexOf(` `),r=n===-1?l.slice(1):l.slice(1,n),i=n!==-1&&l.slice(n+1).trim().length>0,a=n!==-1&&l.length===n+1;if(n!==-1){let o=e.find(e=>{let t=ct(e);return t&&t===r});if(o||i){if(o?.argumentHint&&a)t=o.argumentHint;else if(o?.type===`prompt`&&o.argNames?.length&&l.endsWith(` `)){let e=Xc(l.slice(n+1));t=xr(o.argNames,e)}c(()=>({commandArgumentHint:t,suggestions:[],selectedSuggestion:-1})),v(`none`),x(void 0);return}}}let n=PC(l,e);c(()=>({commandArgumentHint:t,suggestions:n,selectedSuggestion:n.length>0?0:-1})),v(n.length>0?`command`:`none`),n.length>0&&x(y);return}if(_===`command`?(ae.cancel(),I()):OC(l)&&Pw(s,l)&&c(e=>e.commandArgumentHint?{...e,commandArgumentHint:void 0}:e),_===`custom-title`&&I(),_===`agent`&&P.current.some(e=>e.id?.startsWith(`dm-`))&&(t.substring(0,r).match(/(^|\s)@([\w-]*)$/)||I()),a&&o!==`bash`){let e=Mw(t,r,!0);if(e&&e.token.startsWith(`@`)){let t=ww(e);if(Eh(t)){ne.current=t;let e=await Dh(t,{maxResults:10});if(ne.current!==t)return;if(e.length>0){c(t=>({suggestions:e,selectedSuggestion:Sw(t.suggestions,t.selectedSuggestion,e),commandArgumentHint:void 0})),v(`directory`);return}}if(j.current===t)return;ae(t,!0);return}}if(_===`file`){let e=Mw(t,r,!0);if(e){let t=ww(e);if(j.current===t)return;ae(t,!1)}else ae.cancel(),I()}if(_===`shell`){let e=P.current[0]?.metadata?.inputSnapshot;(o!==`bash`||t!==e)&&(ae.cancel(),I())}},[_,e,c,I,ae,oe,o,f,y]);(0,Q.useEffect)(()=>{re.current!==i&&(te.current!==i&&(te.current=i,j.current=null),re.current=null,se(i))},[i,se]);let ce=(0,Q.useCallback)(async()=>{if(A){if(o===`bash`){t(A.fullCommand),r(A.fullCommand.length),O(void 0);return}let e=EC(i,a);if(e){let n=i.slice(0,e.startPos),a=i.slice(e.startPos+e.token.length),o=n+`/`+A.fullCommand+` `+a,s=e.startPos+1+A.fullCommand.length+1;t(o),r(s);return}}if(l.length>0){ae.cancel(),oe.cancel();let e=u===-1?0:u,n=l[e];if(_===`command`&&e<l.length){if(n){let e=n.metadata;if(e&&typeof e==`object`&&`name`in e&&`type`in e){let n=`/${ct(e)} `;t(n+i.slice(a)),r(n.length)}I()}}else if(_===`custom-title`&&l.length>0){if(n){let e=Cw(n);t(e),r(e.length),I()}}else if(_===`directory`&&l.length>0){let n=l[e];if(n){let e=OC(i),o;if(e){let e=i.indexOf(` `),a=i.slice(0,e+1),s=xw(n.metadata)&&n.metadata.type===`directory`?`/`:` `;o=a+n.id+s,t(o),r(o.length),xw(n.metadata)&&n.metadata.type===`directory`?(c(e=>({...e,commandArgumentHint:void 0})),se(o,o.length)):I()}else{let e=Mw(i,a,!0)??Mw(i,a,!1);if(e){let a=xw(n.metadata)&&n.metadata.type===`directory`,s=jw(i,n.id,e.startPos,e.token.length,a);o=s.newInput,t(o),r(s.cursorPos),a?(c(e=>({...e,commandArgumentHint:void 0})),se(o,s.cursorPos)):I()}else I()}}}else if(_===`shell`&&l.length>0){let n=l[e];if(n){let e=n.metadata;Ew(n,i,a,t,r,e?.completionType),I()}}else if(_===`agent`&&l.length>0&&l[e]?.id?.startsWith(`dm-`)){let n=l[e];n&&(Ow(n,i,a,Dw,t,r),I())}else if(_===`slack-channel`&&l.length>0){let n=l[e];n&&(Ow(n,i,a,bw,t,r),I())}else if(_===`file`&&l.length>0){let n=Mw(i,a,!0);if(!n){I();return}let s=Gh(l),c=n.token.startsWith(`@`),u;if(u=n.isQuoted?n.token.slice(2).replace(/"$/,``).length:c?n.token.length-1:n.token.length,s.length>u){let e=Tw({displayText:s,mode:o,hasAtPrefix:c,needsQuotes:!1,isQuoted:n.isQuoted,isComplete:!1});qh(e,i,n.token,n.startPos,t,r),se(i.replace(n.token,e),a)}else if(e<l.length){let a=l[e];if(a){let e=a.displayText.includes(` `);qh(Tw({displayText:a.displayText,mode:o,hasAtPrefix:c,needsQuotes:e,isQuoted:n.isQuoted,isComplete:!0}),i,n.token,n.startPos,t,r),I()}}}}else if(i.trim()!==``){let e,n;if(o===`bash`){e=`shell`;let o=await Aw(i,a);if(o.length===1){let e=o[0];if(e){let n=e.metadata;Ew(e,i,a,t,r,n?.completionType)}n=[]}else n=o}else{e=`file`;let t=Mw(i,a,!0);if(t){let e=t.token.startsWith(`@`);n=await mw(e?t.token.substring(1):t.token,S,s,e)}else n=[]}n.length>0&&(c(e=>({commandArgumentHint:void 0,suggestions:n,selectedSuggestion:Sw(e.suggestions,e.selectedSuggestion,n)})),v(e),x(void 0))}},[l,u,i,_,e,o,t,r,n,I,a,se,S,c,s,ae,oe,A]),le=(0,Q.useCallback)(()=>{if(u<0||l.length===0)return;let s=l[u];if(_===`command`&&u<l.length)s&&(FC(s,!0,e,t,r,n),ae.cancel(),I());else if(_===`custom-title`&&u<l.length){if(s){let e=Cw(s);t(e),r(e.length),n(e,!0),ae.cancel(),I()}}else if(_===`shell`&&u<l.length){let e=l[u];if(e){let n=e.metadata;Ew(e,i,a,t,r,n?.completionType),ae.cancel(),I()}}else if(_===`agent`&&u<l.length&&s?.id?.startsWith(`dm-`))Ow(s,i,a,Dw,t,r),ae.cancel(),I();else if(_===`slack-channel`&&u<l.length)s&&(Ow(s,i,a,bw,t,r),oe.cancel(),I());else if(_===`file`&&u<l.length){let e=Mw(i,a,!0);if(e&&s){let n=e.token.startsWith(`@`),a=s.displayText.includes(` `);qh(Tw({displayText:s.displayText,mode:o,hasAtPrefix:n,needsQuotes:a,isQuoted:e.isQuoted,isComplete:!0}),i,e.token,e.startPos,t,r),ae.cancel(),I()}}else if(_===`directory`&&u<l.length&&s){if(OC(i)){ae.cancel(),I();return}let e=Mw(i,a,!0)??Mw(i,a,!1);if(e){let n=xw(s.metadata)&&s.metadata.type===`directory`,a=jw(i,s.id,e.startPos,e.token.length,n);t(a.newInput),r(a.cursorPos)}ae.cancel(),I()}},[l,u,_,e,i,a,o,t,r,n,I,ae,oe]),ue=(0,Q.useCallback)(()=>{ce()},[ce]),L=(0,Q.useCallback)(()=>{ae.cancel(),oe.cancel(),I(),re.current=i},[ae,oe,I,i]),R=(0,Q.useCallback)(()=>{c(e=>({...e,selectedSuggestion:e.selectedSuggestion<=0?l.length-1:e.selectedSuggestion-1}))},[l.length,c]),de=(0,Q.useCallback)(()=>{c(e=>({...e,selectedSuggestion:e.selectedSuggestion>=l.length-1?0:e.selectedSuggestion+1}))},[l.length,c]),fe=(0,Q.useMemo)(()=>({"autocomplete:accept":ue,"autocomplete:dismiss":L,"autocomplete:previous":R,"autocomplete:next":de}),[ue,L,R,de]),pe=l.length>0||!!A,z=hs();xo(`autocomplete`,pe),Rl(`Autocomplete`,pe),El(fe,{context:`Autocomplete`,isActive:pe&&!z});function me(e){let n=F(e);if(n!==`prompt`&&m){m(n);let i=Kr(e);t(i),r(i.length)}else t(e),r(e.length)}let he=e=>{if(e.key===`right`&&!T){let t=w.text,n=w.shownAt;if(t&&n>0&&i===``){p(),me(t),e.stopImmediatePropagation();return}}if(e.key===`tab`&&!e.shift){if(l.length>0||A)return;let t=w.text,n=w.shownAt;if(t&&n>0&&i===``&&!T){e.preventDefault(),p(),me(t);return}i.trim()===``&&(e.preventDefault(),h({key:`thinking-toggle-hint`,jsx:(0,$.jsxs)(K,{dimColor:!0,children:[`Use `,g,` to toggle thinking`]}),priority:`immediate`,timeoutMs:3e3}));return}if(l.length===0)return;let t=E?.pendingChord!=null;if(e.ctrl&&e.key===`n`&&!t){e.preventDefault(),de();return}if(e.ctrl&&e.key===`p`&&!t){e.preventDefault(),R();return}e.key===`return`&&!e.shift&&!e.meta&&(e.preventDefault(),le())};return Xl((e,t,n)=>{let r=new Fl(n.keypress);he(r),r.didStopImmediatePropagation()&&n.stopImmediatePropagation()}),{suggestions:l,selectedSuggestion:u,suggestionType:_,maxColumnWidth:b,commandArgumentHint:d,inlineGhostText:A,handleKeyDown:he}}Zh();var Iw={"†":`alt+t`,π:`alt+p`,ø:`alt+o`};function Lw(e){return e in Iw}ue();function Rw(e){switch(e.mode){case`default`:return`acceptEdits`;case`acceptEdits`:return`plan`;case`plan`:return`auto`;case`auto`:return e.isBypassPermissionsModeAvailable?`bypassPermissions`:`default`;case`bypassPermissions`:return`default`;case`dontAsk`:return`default`;default:return`default`}}function zw(e){let t=Rw(e);return{nextMode:t,context:gn(e.mode,t,e)}}mh();var Bw=Ig();Ru(),fc(),q(),O(),U(),lf();function Vw({onDone:e}){xo(`bridge-dialog`);let t=W(e=>e.replBridgeConnected),n=W(e=>e.replBridgeSessionActive),r=W(e=>e.replBridgeReconnecting),i=W(e=>e.replBridgeConnectUrl),a=W(e=>e.replBridgeSessionUrl),o=W(e=>e.replBridgeError),s=W(e=>e.replBridgeExplicit),c=W(e=>e.replBridgeEnvironmentId),l=W(e=>e.replBridgeSessionId),u=W(e=>e.verbose),d=Qo(),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(``),v=n_(Gu());(0,Q.useEffect)(()=>{mf().then(_).catch(()=>{})},[]);let y=n?a:i;(0,Q.useEffect)(()=>{if(!f||!y){h(``);return}(0,Bw.toString)(y,{type:`terminal`,errorCorrectionLevel:`L`,small:!0}).then(h).catch(()=>h(``))},[f,y]),El({"confirm:yes":e,"confirm:toggle":()=>{p(e=>!e)}},{context:`Confirmation`}),Xl(t=>{t===`d`&&(s&&df(e=>e.remoteControlAtStartup===!1?e:{...e,remoteControlAtStartup:!1}),d(e=>e.replBridgeEnabled?{...e,replBridgeEnabled:!1}:e),e())});let{label:b,color:x}=uh({error:o,connected:t,sessionActive:n,reconnecting:r}),S=o?`×`:Fd,C=m?m.split(`
39
- `).filter(e=>e.length>0):[],w=[];v&&w.push(v),g&&w.push(g);let T=w.length>0?` · `+w.join(` · `):``,E=o?ph:y?n?fh(y):dh(y):void 0;return(0,$.jsx)(lu,{title:`Remote Control`,onCancel:e,hideInputGuide:!0,children:(0,$.jsxs)(G,{flexDirection:`column`,gap:1,children:[(0,$.jsxs)(G,{flexDirection:`column`,children:[(0,$.jsxs)(K,{children:[(0,$.jsxs)(K,{color:x,children:[S,` `,b]}),(0,$.jsx)(K,{dimColor:!0,children:T})]}),o&&(0,$.jsx)(K,{color:`error`,children:o}),u&&c&&(0,$.jsxs)(K,{dimColor:!0,children:[`Environment: `,c]}),u&&l&&(0,$.jsxs)(K,{dimColor:!0,children:[`Session: `,l]})]}),f&&C.length>0&&(0,$.jsx)(G,{flexDirection:`column`,children:C.map((e,t)=>(0,$.jsx)(K,{children:e},t))}),E&&(0,$.jsx)(K,{dimColor:!0,children:E}),(0,$.jsx)(K,{dimColor:!0,children:`d to disconnect · space for QR code · Enter/Esc to close`})]})})}q(),fc(),ht(),q(),sd(),Ph(),Kf(),xt(),fc(),Wn(),ht(),q(),Kf(),Jh(),fc(),Hh(),ht(),q(),sd(),Ph(),Kf(),Yt(),q(),O(),fn(),wi();function Hw({currentValue:e,onSelect:t,onCancel:n,isMidConversation:r}){let i=ch(),[a,o]=(0,Q.useState)(null),s=[{value:`true`,label:`Enabled`,description:`Claude will think before responding`},{value:`false`,label:`Disabled`,description:`Claude will respond without extended thinking`}];Il(`confirm:no`,()=>{a===null?n?.():o(null)},{context:`Confirmation`}),Il(`confirm:yes`,()=>{a!==null&&t(a)},{context:`Confirmation`,isActive:a!==null});function c(n){let i=n===`true`;r&&i!==e?o(i):t(i)}return(0,$.jsxs)(cu,{color:`permission`,children:[(0,$.jsxs)(G,{flexDirection:`column`,children:[(0,$.jsxs)(G,{marginBottom:1,flexDirection:`column`,children:[(0,$.jsx)(K,{color:`remember`,bold:!0,children:`Toggle thinking mode`}),(0,$.jsx)(K,{dimColor:!0,children:`Enable or disable thinking for this session.`})]}),a===null?(0,$.jsx)(G,{flexDirection:`column`,marginBottom:1,children:(0,$.jsx)(Hi,{defaultValue:e?`true`:`false`,defaultFocusValue:e?`true`:`false`,options:s,onChange:c,onCancel:n??(()=>{}),visibleOptionCount:2})}):(0,$.jsxs)(G,{flexDirection:`column`,marginBottom:1,gap:1,children:[(0,$.jsx)(K,{color:`warning`,children:`Changing thinking mode mid-conversation will increase latency and may reduce quality. For best results, set this at the start of a session.`}),(0,$.jsx)(K,{color:`warning`,children:`Do you want to proceed?`})]})]}),(0,$.jsx)(K,{dimColor:!0,italic:!0,children:i.pending?(0,$.jsxs)($.Fragment,{children:[`Press `,i.keyName,` again to exit`]}):a===null?(0,$.jsxs)(Nl,{children:[(0,$.jsx)(Cl,{shortcut:`Enter`,action:`confirm`}),(0,$.jsx)(Lo,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`exit`})]}):(0,$.jsxs)(Nl,{children:[(0,$.jsx)(Cl,{shortcut:`Enter`,action:`confirm`}),(0,$.jsx)(Lo,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})]})}re(),Im(),Oo(),Vg(),zg();function Uw(e,t,n){let r=t;for(let t=0;t<n;t++){let t=Ww(e,r);if(t.equals(r))break;r=t}return r}function Ww(e,t){switch(e){case`h`:return t.left();case`l`:return t.right();case`j`:return t.downLogicalLine();case`k`:return t.upLogicalLine();case`gj`:return t.down();case`gk`:return t.up();case`w`:return t.nextVimWord();case`b`:return t.prevVimWord();case`e`:return t.endOfVimWord();case`W`:return t.nextWORD();case`B`:return t.prevWORD();case`E`:return t.endOfWORD();case`0`:return t.startOfLogicalLine();case`^`:return t.firstNonBlankInLogicalLine();case`$`:return t.endOfLogicalLine();case`G`:return t.startOfLastLine();default:return t}}function Gw(e){return`eE$`.includes(e)}function Kw(e){return`jkG`.includes(e)||e===`gg`}var qw={"(":[`(`,`)`],")":[`(`,`)`],b:[`(`,`)`],"[":[`[`,`]`],"]":[`[`,`]`],"{":[`{`,`}`],"}":[`{`,`}`],B:[`{`,`}`],"<":[`<`,`>`],">":[`<`,`>`],'"':[`"`,`"`],"'":[`'`,`'`],"`":["`","`"]};function Jw(e,t,n,r){if(n===`w`)return Yw(e,t,r,nl);if(n===`W`)return Yw(e,t,r,e=>!ga(e));let i=qw[n];if(i){let[n,a]=i;return n===a?Xw(e,t,n,r):Zw(e,t,n,a,r)}return null}function Yw(e,t,n,r){let i=[];for(let{segment:t,index:n}of Lf().segment(e))i.push({segment:t,index:n});let a=i.length-1;for(let n=0;n<i.length;n++){let r=i[n],o=n+1<i.length?i[n+1].index:e.length;if(t>=r.index&&t<o){a=n;break}}let o=e=>i[e]?.segment??``,s=t=>t<i.length?i[t].index:e.length,c=e=>ga(o(e)),l=e=>r(o(e)),u=e=>cl(o(e)),d=a,f=a;if(l(a)){for(;d>0&&l(d-1);)d--;for(;f<i.length&&l(f);)f++}else if(c(a)){for(;d>0&&c(d-1);)d--;for(;f<i.length&&c(f);)f++;return{start:s(d),end:s(f)}}else if(u(a)){for(;d>0&&u(d-1);)d--;for(;f<i.length&&u(f);)f++}if(!n){if(f<i.length&&c(f))for(;f<i.length&&c(f);)f++;else if(d>0&&c(d-1))for(;d>0&&c(d-1);)d--}return{start:s(d),end:s(f)}}function Xw(e,t,n,r){let i=e.lastIndexOf(`
40
- `,t-1)+1,a=e.indexOf(`
41
- `,t),o=a===-1?e.length:a,s=e.slice(i,o),c=t-i,l=[];for(let e=0;e<s.length;e++)s[e]===n&&l.push(e);for(let e=0;e<l.length-1;e+=2){let t=l[e],n=l[e+1];if(t<=c&&c<=n)return r?{start:i+t+1,end:i+n}:{start:i+t,end:i+n+1}}return null}function Zw(e,t,n,r,i){let a=0,o=-1;for(let i=t;i>=0;i--)if(e[i]===r&&i!==t)a++;else if(e[i]===n){if(a===0){o=i;break}a--}if(o===-1)return null;a=0;let s=-1;for(let t=o+1;t<e.length;t++)if(e[t]===n)a++;else if(e[t]===r){if(a===0){s=t;break}a--}return s===-1?null:i?{start:o+1,end:s}:{start:o,end:s+1}}Pc(),Rf(),Qf();function Qw(e,t,n,r){let i=Uw(t,r.cursor,n);if(i.equals(r.cursor))return;let a=uT(r.cursor,i,t,e,n);fT(e,a.from,a.to,r,a.linewise),r.recordChange({type:`operator`,op:e,motion:t,count:n})}function $w(e,t,n,r,i){let a=i.cursor.findCharacter(n,t,r);if(a===null)return;let o=new no(i.cursor.measuredText,a),s=dT(i.cursor,o,t);fT(e,s.from,s.to,i),i.setLastFind(t,n),i.recordChange({type:`operatorFind`,op:e,find:t,char:n,count:r})}function eT(e,t,n,r,i){let a=Jw(i.text,i.cursor.offset,n,t===`inner`);a&&(fT(e,a.start,a.end,i),i.recordChange({type:`operatorTextObj`,op:e,objType:n,scope:t,count:r}))}function tT(e,t,n){let r=n.text,i=r.split(`
42
- `),a=$f(r.slice(0,n.cursor.offset),`
43
- `),o=Math.min(t,i.length-a),s=n.cursor.startOfLogicalLine().offset,c=s;for(let e=0;e<o;e++){let e=r.indexOf(`
44
- `,c);c=e===-1?r.length:e+1}let l=r.slice(s,c);if(l.endsWith(`
45
- `)||(l+=`
46
- `),n.setRegister(l,!0),e===`yank`)n.setOffset(s);else if(e===`delete`){let e=s,t=c;t===r.length&&e>0&&r[e-1]===`
47
- `&&--e;let i=r.slice(0,e)+r.slice(t);n.setText(i||``);let a=Math.max(0,i.length-(zf(i).length||1));n.setOffset(Math.min(e,a))}else if(e===`change`)if(i.length===1)n.setText(``),n.enterInsert(0);else{let e=i.slice(0,a),t=i.slice(a+o),r=[...e,``,...t].join(`
48
- `);n.setText(r),n.enterInsert(s)}n.recordChange({type:`operator`,op:e,motion:e[0],count:t})}function nT(e,t){let n=t.cursor.offset;if(n>=t.text.length)return;let r=t.cursor;for(let t=0;t<e&&!r.isAtEnd();t++)r=r.right();let i=r.offset,a=t.text.slice(n,i),o=t.text.slice(0,n)+t.text.slice(i);t.setRegister(a,!1),t.setText(o);let s=Math.max(0,o.length-(zf(o).length||1));t.setOffset(Math.min(n,s)),t.recordChange({type:`x`,count:e})}function rT(e,t,n){let r=n.cursor.offset,i=n.text;for(let n=0;n<t&&r<i.length;n++){let t=Bf(i.slice(r)).length||1;i=i.slice(0,r)+e+i.slice(r+t),r+=e.length}n.setText(i),n.setOffset(Math.max(0,r-e.length)),n.recordChange({type:`replace`,char:e,count:t})}function iT(e,t){let n=t.cursor.offset;if(n>=t.text.length)return;let r=t.text,i=n,a=0;for(;i<r.length&&a<e;){let e=Bf(r.slice(i)),t=e.length,n=e===e.toUpperCase()?e.toLowerCase():e.toUpperCase();r=r.slice(0,i)+n+r.slice(i+t),i+=n.length,a++}t.setText(r),t.setOffset(i),t.recordChange({type:`toggleCase`,count:e})}function aT(e,t){let n=t.text.split(`
49
- `),{line:r}=t.cursor.getPosition();if(r>=n.length-1)return;let i=Math.min(e,n.length-r-1),a=n[r],o=a.length;for(let e=1;e<=i;e++){let t=(n[r+e]??``).trimStart();t.length>0&&(!a.endsWith(` `)&&a.length>0&&(a+=` `),a+=t)}let s=[...n.slice(0,r),a,...n.slice(r+i+1)],c=s.join(`
50
- `);t.setText(c),t.setOffset(lT(s,r)+o),t.recordChange({type:`join`,count:e})}function oT(e,t,n){let r=n.getRegister();if(!r)return;let i=r.endsWith(`
51
- `),a=i?r.slice(0,-1):r;if(i){let r=n.text.split(`
52
- `),{line:i}=n.cursor.getPosition(),o=e?i+1:i,s=a.split(`
53
- `),c=[];for(let e=0;e<t;e++)c.push(...s);let l=[...r.slice(0,o),...c,...r.slice(o)],u=l.join(`
54
- `);n.setText(u),n.setOffset(lT(l,o))}else{let r=a.repeat(t),i=e&&n.cursor.offset<n.text.length?n.cursor.measuredText.nextOffset(n.cursor.offset):n.cursor.offset,o=n.text.slice(0,i)+r+n.text.slice(i),s=zf(r),c=i+r.length-(s.length||1);n.setText(o),n.setOffset(Math.max(i,c))}}function sT(e,t,n){let r=n.text.split(`
55
- `),{line:i}=n.cursor.getPosition(),a=Math.min(t,r.length-i);for(let t=0;t<a;t++){let n=i+t,a=r[n]??``;if(e===`>`)r[n]=` `+a;else if(a.startsWith(` `))r[n]=a.slice(2);else if(a.startsWith(` `))r[n]=a.slice(1);else{let e=0,t=0;for(;t<a.length&&e<2&&/\s/.test(a[t]);)e++,t++;r[n]=a.slice(t)}}let o=r.join(`
56
- `),s=((r[i]??``).match(/^\s*/)?.[0]??``).length;n.setText(o),n.setOffset(lT(r,i)+s),n.recordChange({type:`indent`,dir:e,count:t})}function cT(e,t){let n=t.text.split(`
57
- `),{line:r}=t.cursor.getPosition(),i=e===`below`?r+1:r,a=[...n.slice(0,i),``,...n.slice(i)],o=a.join(`
58
- `);t.setText(o),t.enterInsert(lT(a,i)),t.recordChange({type:`openLine`,direction:e})}function lT(e,t){return e.slice(0,t).join(`
59
- `).length+ +(t>0)}function uT(e,t,n,r,i){let a=Math.min(e.offset,t.offset),o=Math.max(e.offset,t.offset),s=!1;if(r===`change`&&(n===`w`||n===`W`)){let t=e;for(let e=0;e<i-1;e++)t=n===`w`?t.nextVimWord():t.nextWORD();let r=n===`w`?t.endOfVimWord():t.endOfWORD();o=e.measuredText.nextOffset(r.offset)}else if(Kw(n)){s=!0;let t=e.text,n=t.indexOf(`
60
- `,o);n===-1?(o=t.length,a>0&&t[a-1]===`
61
- `&&--a):o=n+1}else Gw(n)&&e.offset<=t.offset&&(o=e.measuredText.nextOffset(o));return a=e.snapOutOfImageRef(a,`start`),o=e.snapOutOfImageRef(o,`end`),{from:a,to:o,linewise:s}}function dT(e,t,n){let r=Math.min(e.offset,t.offset),i=Math.max(e.offset,t.offset);return{from:r,to:e.measuredText.nextOffset(i)}}function fT(e,t,n,r,i=!1){let a=r.text.slice(t,n);if(i&&!a.endsWith(`
62
- `)&&(a+=`
63
- `),r.setRegister(a,i),e===`yank`)r.setOffset(t);else if(e===`delete`){let e=r.text.slice(0,t)+r.text.slice(n);r.setText(e);let i=Math.max(0,e.length-(zf(e).length||1));r.setOffset(Math.min(t,i))}else if(e===`change`){let e=r.text.slice(0,t)+r.text.slice(n);r.setText(e),r.enterInsert(t)}}function pT(e,t,n){let r=t===1?n.cursor.startOfLastLine():n.cursor.goToLine(t);if(r.equals(n.cursor))return;let i=uT(n.cursor,r,`G`,e,t);fT(e,i.from,i.to,n,i.linewise),n.recordChange({type:`operator`,op:e,motion:`G`,count:t})}function mT(e,t,n){let r=t===1?n.cursor.startOfFirstLine():n.cursor.goToLine(t);if(r.equals(n.cursor))return;let i=uT(n.cursor,r,`gg`,e,t);fT(e,i.from,i.to,n,i.linewise),n.recordChange({type:`operator`,op:e,motion:`gg`,count:t})}var hT={d:`delete`,c:`change`,y:`yank`};function gT(e){return e in hT}var _T=new Set([`h`,`l`,`j`,`k`,`w`,`b`,`e`,`W`,`B`,`E`,`0`,`^`,`$`]),vT=new Set([`f`,`F`,`t`,`T`]),yT={i:`inner`,a:`around`};function bT(e){return e in yT}var xT=new Set([`w`,`W`,`"`,`'`,"`",`(`,`)`,`b`,`[`,`]`,`{`,`}`,`B`,`<`,`>`]),ST=1e4;function CT(){return{mode:`INSERT`,insertedText:``}}function wT(){return{lastChange:null,lastFind:null,register:``,registerIsLinewise:!1}}function TT(e,t,n){switch(e.type){case`idle`:return OT(t,n);case`count`:return kT(e,t,n);case`operator`:return AT(e,t,n);case`operatorCount`:return jT(e,t,n);case`operatorFind`:return MT(e,t,n);case`operatorTextObj`:return NT(e,t,n);case`find`:return PT(e,t,n);case`g`:return FT(e,t,n);case`operatorG`:return IT(e,t,n);case`replace`:return LT(e,t,n);case`indent`:return RT(e,t,n)}}function ET(e,t,n){return gT(e)?{next:{type:`operator`,op:hT[e],count:t}}:_T.has(e)?{execute:()=>{let r=Uw(e,n.cursor,t);n.setOffset(r.offset)}}:vT.has(e)?{next:{type:`find`,find:e,count:t}}:e===`g`?{next:{type:`g`,count:t}}:e===`r`?{next:{type:`replace`,count:t}}:e===`>`||e===`<`?{next:{type:`indent`,dir:e,count:t}}:e===`~`?{execute:()=>iT(t,n)}:e===`x`?{execute:()=>nT(t,n)}:e===`J`?{execute:()=>aT(t,n)}:e===`p`||e===`P`?{execute:()=>oT(e===`p`,t,n)}:e===`D`?{execute:()=>Qw(`delete`,`$`,1,n)}:e===`C`?{execute:()=>Qw(`change`,`$`,1,n)}:e===`Y`?{execute:()=>tT(`yank`,t,n)}:e===`G`?{execute:()=>{t===1?n.setOffset(n.cursor.startOfLastLine().offset):n.setOffset(n.cursor.goToLine(t).offset)}}:e===`.`?{execute:()=>n.onDotRepeat?.()}:e===`;`||e===`,`?{execute:()=>zT(e===`,`,t,n)}:e===`u`?{execute:()=>n.onUndo?.()}:e===`i`?{execute:()=>n.enterInsert(n.cursor.offset)}:e===`I`?{execute:()=>n.enterInsert(n.cursor.firstNonBlankInLogicalLine().offset)}:e===`a`?{execute:()=>{let e=n.cursor.isAtEnd()?n.cursor.offset:n.cursor.right().offset;n.enterInsert(e)}}:e===`A`?{execute:()=>n.enterInsert(n.cursor.endOfLogicalLine().offset)}:e===`o`?{execute:()=>cT(`below`,n)}:e===`O`?{execute:()=>cT(`above`,n)}:null}function DT(e,t,n,r){return bT(n)?{next:{type:`operatorTextObj`,op:e,count:t,scope:yT[n]}}:vT.has(n)?{next:{type:`operatorFind`,op:e,count:t,find:n}}:_T.has(n)?{execute:()=>Qw(e,n,t,r)}:n===`G`?{execute:()=>pT(e,t,r)}:n===`g`?{next:{type:`operatorG`,op:e,count:t}}:null}function OT(e,t){return/[1-9]/.test(e)?{next:{type:`count`,digits:e}}:e===`0`?{execute:()=>t.setOffset(t.cursor.startOfLogicalLine().offset)}:ET(e,1,t)||{}}function kT(e,t,n){if(/[0-9]/.test(t)){let n=e.digits+t;return{next:{type:`count`,digits:String(Math.min(parseInt(n,10),ST))}}}return ET(t,parseInt(e.digits,10),n)||{next:{type:`idle`}}}function AT(e,t,n){return t===e.op[0]?{execute:()=>tT(e.op,e.count,n)}:/[0-9]/.test(t)?{next:{type:`operatorCount`,op:e.op,count:e.count,digits:t}}:DT(e.op,e.count,t,n)||{next:{type:`idle`}}}function jT(e,t,n){if(/[0-9]/.test(t)){let n=e.digits+t,r=Math.min(parseInt(n,10),ST);return{next:{...e,digits:String(r)}}}let r=parseInt(e.digits,10),i=e.count*r;return DT(e.op,i,t,n)||{next:{type:`idle`}}}function MT(e,t,n){return{execute:()=>$w(e.op,e.find,t,e.count,n)}}function NT(e,t,n){return xT.has(t)?{execute:()=>eT(e.op,e.scope,t,e.count,n)}:{next:{type:`idle`}}}function PT(e,t,n){return{execute:()=>{let r=n.cursor.findCharacter(t,e.find,e.count);r!==null&&(n.setOffset(r),n.setLastFind(e.find,t))}}}function FT(e,t,n){return t===`j`||t===`k`?{execute:()=>{let r=Uw(`g${t}`,n.cursor,e.count);n.setOffset(r.offset)}}:t===`g`?e.count>1?{execute:()=>{let t=n.text.split(`
64
- `),r=Math.min(e.count-1,t.length-1),i=0;for(let e=0;e<r;e++)i+=(t[e]?.length??0)+1;n.setOffset(i)}}:{execute:()=>n.setOffset(n.cursor.startOfFirstLine().offset)}:{next:{type:`idle`}}}function IT(e,t,n){return t===`j`||t===`k`?{execute:()=>Qw(e.op,`g${t}`,e.count,n)}:t===`g`?{execute:()=>mT(e.op,e.count,n)}:{next:{type:`idle`}}}function LT(e,t,n){return t===``?{next:{type:`idle`}}:{execute:()=>rT(t,e.count,n)}}function RT(e,t,n){return t===e.dir?{execute:()=>sT(e.dir,e.count,n)}:{next:{type:`idle`}}}function zT(e,t,n){let r=n.getLastFind();if(!r)return;let i=r.type;e&&(i={f:`F`,F:`f`,t:`T`,T:`t`}[i]);let a=n.cursor.findCharacter(r.char,i,t);a!==null&&n.setOffset(a)}Pc(),Rf();function BT(e){let t=Q.useRef(CT()),[n,r]=(0,Q.useState)(`INSERT`),i=Q.useRef(wT()),a=ss({...e,inputFilter:void 0}),{onModeChange:o,inputFilter:s}=e,c=(0,Q.useCallback)(e=>{e!==void 0&&a.setOffset(e),t.current={mode:`INSERT`,insertedText:``},r(`INSERT`),o?.(`INSERT`)},[a,o]),l=(0,Q.useCallback)(()=>{let n=t.current;n.mode===`INSERT`&&n.insertedText&&(i.current.lastChange={type:`insert`,text:n.insertedText});let s=a.offset;s>0&&e.value[s-1]!==`
65
- `&&a.setOffset(s-1),t.current={mode:`NORMAL`,command:{type:`idle`}},r(`NORMAL`),o?.(`NORMAL`)},[o,a,e.value]);function u(t,n=!1){return{cursor:t,text:e.value,setText:t=>e.onChange(t),setOffset:e=>a.setOffset(e),enterInsert:e=>c(e),getRegister:()=>i.current.register,setRegister:(e,t)=>{i.current.register=e,i.current.registerIsLinewise=t},getLastFind:()=>i.current.lastFind,setLastFind:(e,t)=>{i.current.lastFind={type:e,char:t}},recordChange:n?()=>{}:e=>{i.current.lastChange=e}}}function d(){let t=i.current.lastChange;if(!t)return;let n=no.fromText(e.value,e.columns,a.offset),r=u(n,!0);switch(t.type){case`insert`:if(t.text){let r=n.insert(t.text);e.onChange(r.text),a.setOffset(r.offset)}break;case`x`:nT(t.count,r);break;case`replace`:rT(t.char,t.count,r);break;case`toggleCase`:iT(t.count,r);break;case`indent`:sT(t.dir,t.count,r);break;case`join`:aT(t.count,r);break;case`openLine`:cT(t.direction,r);break;case`operator`:Qw(t.op,t.motion,t.count,r);break;case`operatorFind`:$w(t.op,t.find,t.char,t.count,r);break;case`operatorTextObj`:eT(t.op,t.scope,t.objType,t.count,r);break}}function f(n,r){let i=t.current,o=s?s(n,r):n,c=i.mode===`INSERT`?o:n,f=no.fromText(e.value,e.columns,a.offset);if(r.ctrl){a.onInput(c,r);return}if(r.escape&&i.mode===`INSERT`){l();return}if(r.escape&&i.mode===`NORMAL`){t.current={mode:`NORMAL`,command:{type:`idle`}};return}if(r.return){a.onInput(c,r);return}if(i.mode===`INSERT`){r.backspace||r.delete?i.insertedText.length>0&&(t.current={mode:`INSERT`,insertedText:i.insertedText.slice(0,-(zf(i.insertedText).length||1))}):t.current={mode:`INSERT`,insertedText:i.insertedText+c},a.onInput(c,r);return}if(i.mode!==`NORMAL`)return;if(i.command.type===`idle`&&(r.upArrow||r.downArrow||r.leftArrow||r.rightArrow)){a.onInput(c,r);return}let p={...u(f,!1),onUndo:e.onUndo,onDotRepeat:d},m=i.command.type===`idle`||i.command.type===`count`||i.command.type===`operator`||i.command.type===`operatorCount`,h=c;r.leftArrow?h=`h`:r.rightArrow?h=`l`:r.upArrow?h=`k`:r.downArrow?h=`j`:m&&r.backspace?h=`h`:m&&i.command.type!==`count`&&r.delete&&(h=`x`);let g=TT(i.command,h,p);g.execute&&g.execute(),t.current.mode===`NORMAL`&&(g.next?t.current={mode:`NORMAL`,command:g.next}:g.execute&&(t.current={mode:`NORMAL`,command:{type:`idle`}})),c===`?`&&i.mode===`NORMAL`&&i.command.type===`idle`&&e.onChange(`?`)}let p=(0,Q.useCallback)(e=>{e===`INSERT`?t.current={mode:`INSERT`,insertedText:``}:t.current={mode:`NORMAL`,command:{type:`idle`}},r(e),o?.(e)},[o]);return{...a,onInput:f,mode:n,setMode:p}}Kl(),q();function VT(e){let[t]=Dl(),n=Ll();Ye(n,!!e.onImagePaste);let r=BT({value:e.value,onChange:e.onChange,onSubmit:e.onSubmit,onExit:e.onExit,onExitMessage:e.onExitMessage,onHistoryReset:e.onHistoryReset,onHistoryUp:e.onHistoryUp,onHistoryDown:e.onHistoryDown,onClearInput:e.onClearInput,focus:e.focus,mask:e.mask,multiline:e.multiline,cursorChar:e.showCursor?` `:``,highlightPastedText:e.highlightPastedText,invert:n?ou.inverse:e=>e,themeText:Ql(`text`,t),columns:e.columns,maxVisibleLines:e.maxVisibleLines,onImagePaste:e.onImagePaste,disableCursorMovementForUpDownKeys:e.disableCursorMovementForUpDownKeys,disableEscapeDoublePress:e.disableEscapeDoublePress,externalOffset:e.cursorOffset,onOffsetChange:e.onChangeCursorOffset,inputFilter:e.inputFilter,onModeChange:e.onModeChange,onUndo:e.onUndo}),{mode:i,setMode:a}=r;return Q.useEffect(()=>{e.initialMode&&e.initialMode!==i&&a(e.initialMode)},[e.initialMode,i,a]),(0,$.jsx)(G,{flexDirection:`column`,children:(0,$.jsx)(Xo,{inputState:r,terminalFocus:n,highlights:e.highlights,...e})})}jr(),yg(),s();function HT(e){if(!e)return null;let t=e.input_tokens+e.cache_creation_input_tokens+e.cache_read_input_tokens;return t===0?null:Math.round(e.cache_read_input_tokens/t*100)}function UT(e){return`${e.input_tokens}|${e.cache_creation_input_tokens}|${e.cache_read_input_tokens}`}function WT(e){let t=u_(`sha256`).update(e).digest(`hex`).slice(0,16);return l_(a(),`cache-stats`,`${t}.json`)}var GT={version:1,signature:null,lastResetAt:null,lastHitRate:null};function KT(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.version===1&&(t.signature===null||typeof t.signature==`string`)&&(t.lastResetAt===null||typeof t.lastResetAt==`number`)&&(t.lastHitRate===null||typeof t.lastHitRate==`number`)}async function qT(e){try{let t=await y_(e,`utf8`),n=JSON.parse(t);return KT(n)?n:{...GT}}catch{return{...GT}}}async function JT(e,t){await v_(c_(e),{recursive:!0});let n=`${e}.${process.pid}.tmp`;try{await x_(n,JSON.stringify(t),`utf8`),await b_(n,e)}catch{}}var YT={signature:null,lastResetAt:null,lastHitRate:null},XT=null;async function ZT(e){XT=e;let t=await qT(WT(e));YT={signature:t.signature,lastResetAt:t.lastResetAt,lastHitRate:t.lastHitRate}}function QT(e){let t=UT(e),n=HT(e);return t!==YT.signature&&(YT={signature:t,lastResetAt:Date.now(),lastHitRate:n},XT!==null&&JT(WT(XT),{version:1,signature:t,lastResetAt:YT.lastResetAt,lastHitRate:n})),{...YT}}function $T(){return{...YT}}q(),Kf(),ht();function eE(e){let t=e-Date.now()/1e3;if(t<=0)return`now`;let n=Math.floor(t/86400),r=Math.floor(t%86400/3600),i=Math.floor(t%3600/60);return n>=1?`${n}d${r}h`:r>=1?`${r}h${i}m`:`${i}m`}function tE(){return(0,$.jsx)(K,{dimColor:!0,children:` │ `})}function nE({modelName:e,contextUsedPct:t,usedTokens:n,contextWindowSize:r,totalCostUsd:i,rateLimits:a}){let{columns:o}=tu(),[s,c]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{if(!((a.five_hour?.resets_at??0)||(a.seven_day?.resets_at??0)))return;let e=setInterval(()=>c(e=>e+1),6e4);return()=>clearInterval(e)},[a.five_hour?.resets_at,a.seven_day?.resets_at]);let l=e.split(` `),u=l.length>=2?`${l[0]} ${l[1]}`:e,d=o<60,f=a.five_hour!=null,p=a.seven_day!=null,m=f?Math.round(a.five_hour.utilization*100):0,h=p?Math.round(a.seven_day.utilization*100):0,g=`${Hf(n)}/${Hf(r)}`;return(0,$.jsxs)(G,{children:[(0,$.jsx)(K,{children:u}),(0,$.jsx)(tE,{}),(0,$.jsx)(K,{dimColor:!0,children:`Context `}),(0,$.jsxs)(K,{children:[t,`%`]}),!d&&(0,$.jsxs)(K,{dimColor:!0,children:[` (`,g,`)`]}),f&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(tE,{}),(0,$.jsx)(K,{dimColor:!0,children:`Session `}),(0,$.jsxs)(K,{children:[m,`%`]}),!d&&a.five_hour.resets_at>0&&(0,$.jsxs)(K,{dimColor:!0,children:[` `,eE(a.five_hour.resets_at)]})]}),p&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(tE,{}),(0,$.jsx)(K,{dimColor:!0,children:`Weekly `}),(0,$.jsxs)(K,{children:[h,`%`]}),!d&&a.seven_day.resets_at>0&&(0,$.jsxs)(K,{dimColor:!0,children:[` `,eE(a.seven_day.resets_at)]})]}),i>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(tE,{}),(0,$.jsx)(K,{children:hn(i)})]})]})}var rE=Q.memo(nE);If(),U(),Ru(),Ot(),Ke(),Vh(),Zs(),q(),Nt(),lf(),fp(),sd(),bd(),Lc(),P(),vp(),he(),mr(),Kf();var iE=3600*1e3;function aE(e){return String(Math.floor(e)).padStart(2,`0`)}function oE(e){if(e<=0)return`exp`;let t=Math.floor(e/6e4),n=Math.floor(e%6e4/1e3);return`${aE(t)}:${aE(n)}`}function sE({messages:e}){let[t,n]=(0,Q.useState)(()=>Date.now()),[r,i]=(0,Q.useState)(!0),a=Ct(e),o=(0,Q.useRef)(null);if(a!==null){let e=UT(a);e!==o.current&&(o.current=e,QT(a))}let{lastResetAt:s,lastHitRate:c}=$T(),l=s===null?null:t-s,u=l===null?null:iE-l,d=l===null?null:l/6e4,f=u!==null&&u<=0;(0,Q.useEffect)(()=>{let e=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(e)},[]);let p=d!==null&&d>=55&&!f;(0,Q.useEffect)(()=>{if(!p){i(!0);return}let e=setInterval(()=>i(e=>!e),500);return()=>clearInterval(e)},[p]);let m=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{m.current||(m.current=!0,ZT($u()))},[]);let h=a===null?c:HT(a);if(h===null&&s===null)return(0,$.jsx)(K,{dimColor:!0,children:` Cache --% --:--`});let g=u===null?`--:--`:oE(u),_=h===null?`--%`:`${h}%`,v;return v=f||d===null?`inactive`:d<20?`success`:d<40?`warning`:`error`,(0,$.jsxs)(K,{children:[(0,$.jsx)(K,{dimColor:!0,children:` Cache `}),(0,$.jsx)(K,{color:h!==null&&h>=50?`success`:`inactive`,children:_}),(0,$.jsxs)(K,{color:v,dimColor:p&&!r,children:[` `,g]})]})}function cE(){let{getGoal:t,formatGoalStatusLabel:n}=(Jt(),e(gi)),r=t();if(!r)return null;let i=r.objective.length>30?`${r.objective.slice(0,27)}…`:r.objective,a=r.tokenBudget===null?Hf(r.tokensUsed):`${Hf(r.tokensUsed)}/${Hf(r.tokenBudget)}`,o=n(r.status),s;switch(r.status){case`active`:s=(0,$.jsx)(K,{color:`ansi:green`,children:o});break;case`paused`:case`budget_limited`:case`usage_limited`:s=(0,$.jsx)(K,{color:`ansi:yellow`,children:o});break;case`blocked`:s=(0,$.jsx)(K,{color:`ansi:red`,children:o});break;case`complete`:s=(0,$.jsx)(K,{color:`ansi:cyan`,children:o});break;default:s=(0,$.jsx)(K,{children:o})}return(0,$.jsxs)(K,{children:[s,(0,$.jsx)(K,{dimColor:!0,children:` · `}),(0,$.jsx)(K,{dimColor:!0,children:i}),(0,$.jsx)(K,{dimColor:!0,children:` · `}),(0,$.jsx)(K,{children:a})]})}function lE(e){return e?.statusLineEnabled===!1?!1:e?.statusLineEnabled===!0||!!e?.statusLine?.command}function uE(e,t,n,r,i,a,o){let s=zu(),c=Sr(),l=Dp({permissionMode:e,mainLoopModel:a,exceeds200kTokens:t}),u=n?.outputStyle||`default`,d=Ct(r),f=hp(l,Uu()),p=rp(d,f),m=ws($u()),h=Gs(),g={...h.five_hour&&{five_hour:{used_percentage:h.five_hour.utilization*100,resets_at:h.five_hour.resets_at}},...h.seven_day&&{seven_day:{used_percentage:h.seven_day.utilization*100,resets_at:h.seven_day.resets_at}}};return{...Qn(),...m&&{session_name:m},model:{id:l,display_name:mp(l)},workspace:{current_dir:cd(),project_dir:Gu(),added_dirs:i},version:`0.0.12`,output_style:{name:u},cost:{total_cost_usd:Ou(),total_duration_ms:Du(),total_api_duration_ms:Pu(),total_lines_added:Yu(),total_lines_removed:wu()},context_window:{total_input_tokens:Mu(),total_output_tokens:Ju(),context_window_size:f,current_usage:d,used_percentage:p.used,remaining_percentage:p.remaining},exceeds_200k_tokens:t,...(g.five_hour||g.seven_day)&&{rate_limits:g},...gg()&&{vim:{mode:o??`INSERT`}},...s&&{agent:{name:s}},...Tu()&&{remote:{session_id:$u()}},...c&&{worktree:{name:c.worktreeName,path:c.worktreePath,branch:c.worktreeBranch,original_cwd:c.originalCwd,original_branch:c.originalBranch}}}}function dE(e){return No(e)?.uuid??null}function fE({messagesRef:e,lastAssistantMessageId:t,vimMode:n}){let r=(0,Q.useRef)(void 0),i=W(e=>e.toolPermissionContext.mode),a=W(e=>e.toolPermissionContext.additionalWorkingDirectories),o=W(e=>e.statusLineText),s=Qo(),c=So(),{addNotification:l}=ki(),u=Bh(),d=(0,Q.useRef)(c);d.current=c;let f=(0,Q.useRef)(n);f.current=n;let p=(0,Q.useRef)(i);p.current=i;let m=(0,Q.useRef)(a);m.current=a;let h=(0,Q.useRef)(u);h.current=u;let g=(0,Q.useRef)({messageId:null,exceeds200kTokens:!1,permissionMode:i,vimMode:n,mainLoopModel:u}),_=(0,Q.useRef)(void 0),v=(0,Q.useRef)(!0),y=(0,Q.useCallback)(async()=>{r.current?.abort();let t=new AbortController;r.current=t;let n=e.current,i=v.current;if(v.current=!1,d.current?.statusLine?.command)try{let e=g.current.exceeds200kTokens,r=dE(n);r!==g.current.messageId&&(e=V(n),g.current.messageId=r,g.current.exceeds200kTokens=e);let a=await w(uE(p.current,e,d.current,n,Array.from(m.current.keys()),h.current,f.current),t.signal,void 0,i);t.signal.aborted||s(e=>e.statusLineText===a?e:{...e,statusLineText:a})}catch{}},[e,s]),b=(0,Q.useCallback)(()=>{_.current!==void 0&&clearTimeout(_.current),_.current=setTimeout((e,t)=>{e.current=void 0,t()},300,_,y)},[y]);(0,Q.useEffect)(()=>{(t!==g.current.messageId||i!==g.current.permissionMode||n!==g.current.vimMode||u!==g.current.mainLoopModel)&&(g.current.permissionMode=i,g.current.vimMode=n,g.current.mainLoopModel=u,b())},[t,i,n,u,b]);let x=c?.statusLine?.command,S=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>{if(S.current){S.current=!1;return}v.current=!0,y()},[x,y]),(0,Q.useEffect)(()=>{let e=c?.statusLine;e&&(X(`tengu_status_line_mount`,{command_length:e.command.length,padding:e.padding}),c.disableAllHooks===!0&&J(`Status line is configured but disableAllHooks is true`,{level:`warn`}),uf()||(l({key:`statusline-trust-blocked`,text:`statusline skipped · restart to fix`,color:`warning`,priority:`low`}),J(`Status line command skipped: workspace trust not accepted`,{level:`warn`})))},[]),(0,Q.useEffect)(()=>(y(),()=>{r.current?.abort(),_.current!==void 0&&clearTimeout(_.current)}),[]);let C=c?.statusLine?.padding??0,T=Dp({permissionMode:i,mainLoopModel:u,exceeds200kTokens:g.current.exceeds200kTokens}),E=hp(T,Uu()),D=Ct(e.current),O=D?D.input_tokens+D.cache_creation_input_tokens+D.cache_read_input_tokens:0,k=D?Math.round(rp(D,E).used??0):0,A=Gs(),ee={...A.five_hour&&{five_hour:{utilization:A.five_hour.utilization,resets_at:A.five_hour.resets_at}},...A.seven_day&&{seven_day:{utilization:A.seven_day.utilization,resets_at:A.seven_day.resets_at}}},j=c?.statusLineEnabled===!0,te=!!c?.statusLine?.command;return(0,$.jsxs)(G,{flexDirection:`column`,paddingX:C,children:[j&&(0,$.jsxs)(G,{gap:2,children:[(0,$.jsx)(rE,{modelName:mp(T),contextUsedPct:k,usedTokens:O,contextWindowSize:E,totalCostUsd:Ou(),rateLimits:ee}),(0,$.jsx)(cE,{}),(0,$.jsx)(sE,{messages:e.current})]}),o?(0,$.jsx)(K,{dimColor:!0,wrap:`truncate`,children:(0,$.jsx)(wl,{children:o})}):te&&La()?(0,$.jsx)(K,{children:` `}):null]})}var pE=(0,Q.memo)(fE);u(),U(),lr(),q();function mE({tasksSelected:e,onOpenDialog:t}){let n=W(e=>e.tasks),r=(0,Q.useMemo)(()=>Object.values(n??{}).filter(e=>qr(e)),[n]);return Rg(n??{},!1)||r.length===0?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(hE,{selected:e,onClick:t,children:Qt(r)}),ml(r)&&(0,$.jsxs)(K,{dimColor:!0,children:[` · `,d.arrowDown,` to view`]})]})}function hE({selected:e,onClick:t,children:n}){let[r,i]=(0,Q.useState)(!1),a=(0,$.jsx)(K,{color:`background`,inverse:e||r,children:n});return t?(0,$.jsx)(G,{onClick:t,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:a}):a}q(),ba();function gE({value:e,onChange:t,historyFailedMatch:n}){return(0,$.jsxs)(G,{gap:1,children:[(0,$.jsx)(K,{dimColor:!0,children:n?`no matching prompt:`:`search prompts:`}),(0,$.jsx)(ac,{value:e,onChange:t,cursorOffset:e.length,onChangeCursorOffset:()=>{},columns:Tl(e)+1,focus:!0,showCursor:!0,multiline:!1,dimColor:!0})]})}vf(),_f(),wd();var _E=5e3;function vE(e,t){if(e)return`draft`;switch(t){case`APPROVED`:return`approved`;case`CHANGES_REQUESTED`:return`changes_requested`;default:return`pending`}}async function yE(){if(!await gf())return null;let[e,t]=await Promise.all([mf(),pf()]);if(e===t)return null;let{stdout:n,code:r}=await yf(`gh`,[`pr`,`view`,`--json`,`number,url,reviewDecision,isDraft,headRefName,state`],{timeout:_E,preserveOutputOnError:!1});if(r!==0||!n.trim())return null;try{let e=md(n);return e.headRefName===t||e.headRefName===`main`||e.headRefName===`master`||e.state===`MERGED`||e.state===`CLOSED`?null:{number:e.number,url:e.url,reviewState:vE(e.isDraft,e.reviewDecision)}}catch{return null}}Ru();var bE=6e4,xE=4e3,SE=60*6e4,CE={number:null,url:null,reviewState:null,lastUpdated:0};function wE(e,t=!0){let[n,r]=(0,Q.useState)(CE),i=(0,Q.useRef)(null),a=(0,Q.useRef)(!1),o=(0,Q.useRef)(0);return(0,Q.useEffect)(()=>{if(!t||a.current)return;let e=!1,n=-1,s=Date.now();async function c(){if(e)return;let t=Lu();if(n!==t)n=t,s=Date.now();else if(Date.now()-s>=SE)return;let l=Date.now(),u=await yE();if(!e){if(o.current=l,r(e=>{let t=u?.number??null,n=u?.reviewState??null;return e.number===t&&e.reviewState===n?e:{number:t,url:u?.url??null,reviewState:n,lastUpdated:Date.now()}}),Date.now()-l>xE){a.current=!0;return}e||(i.current=setTimeout(c,bE))}}let l=Date.now()-o.current;return l>=bE?c():i.current=setTimeout(c,bE-l),()=>{e=!0,i.current&&(clearTimeout(i.current),i.current=null)}},[e,t]),n}q(),u(),yg(),Mo(),jd(),re(),Nd(),Vg(),U(),Ru(),ht(),Kf(),b(),lf(),Nf(),ii();var TE=(um(),e(vm)),EE=e=>()=>{},DE=()=>null,OE=5e3,kE=1e3;function AE(){let[e,t]=(0,Q.useState)(null);return(0,Q.useEffect)(()=>{function e(){let e=process.memoryUsage().rss/(1024*1024),n=e>=1024?`error`:e>=512?`warning`:`normal`,r=Gf(e*1024*1024);t(e=>e?.text===r?e:{text:r,level:n})}e();let n=setInterval(e,OE);return()=>clearInterval(n)},[]),e}function jE(){let e=(0,Q.useSyncExternalStore)(TE?.subscribeToProactiveChanges??EE,TE?.getNextTickAt??DE,DE),[t,n]=(0,Q.useState)(null);return(0,Q.useEffect)(()=>{if(e===null){n(null);return}function t(){let t=Math.max(0,Math.ceil((e-Date.now())/1e3));n(t)}t();let r=setInterval(t,1e3);return()=>clearInterval(r)},[e]),t===null?null:(0,$.jsxs)(K,{dimColor:!0,children:[`waiting `,Wf(t*1e3,{mostSignificantOnly:!0})]})}function ME(){let[t,n]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{let e=setInterval(()=>n(e=>e+1),kE);return()=>clearInterval(e)},[]);let r=(Jt(),e(gi)),i=r.getGoal();if(!i)return null;let a=r.getActiveElapsedMs(i),o=Math.floor(a/1e3),s=Math.floor(o/3600),c=Math.floor(o%3600/60),l=o%60,u;u=s>=1?`${s}h${c}min`:c>=1?`${c}min`:`${l}s`;let d;switch(i.status){case`active`:d=`ansi:green`;break;case`paused`:case`budget_limited`:case`usage_limited`:d=`ansi:yellow`;break;case`blocked`:d=`ansi:red`;break;case`complete`:d=`ansi:cyan`;break}return(0,$.jsxs)(K,{color:d,children:[`goal (`,u,`)`]})}function NE({exitMessage:e,vimMode:t,mode:n,toolPermissionContext:r,suppressHint:i,isLoading:a,tasksSelected:o,tmuxSelected:s,isPasting:c,isSearching:l,historyQuery:u,setHistoryQuery:d,historyFailedMatch:f,onOpenTasksDialog:p}){if(e.show)return(0,$.jsxs)(K,{dimColor:!0,children:[`Press `,e.key,` again to exit`]},`exit-message`);if(c)return(0,$.jsx)(K,{dimColor:!0,children:`Pasting text…`},`pasting-message`);let m=gg()&&t===`INSERT`&&!l;return(0,$.jsxs)(G,{justifyContent:`flex-start`,gap:1,children:[l&&(0,$.jsx)(gE,{value:u,onChange:d,historyFailedMatch:f}),m?(0,$.jsx)(K,{dimColor:!0,children:`-- INSERT --`},`vim-insert`):null,(0,$.jsx)(PE,{mode:n,toolPermissionContext:r,showHint:!i&&!m,isLoading:a,tasksSelected:o,tmuxSelected:s,onOpenTasksDialog:p})]})}function PE({mode:t,toolPermissionContext:n,showHint:r,isLoading:i,tasksSelected:a,tmuxSelected:o,onOpenTasksDialog:s}){let{columns:c}=tu(),l=an(`chat:cycleMode`,`Chat`,`shift+tab`),u=W(e=>e.tasks),f=xa(),[p]=(0,Q.useState)(()=>f.getState().remoteSessionUrl),m=wE(i,IE()),h=(0,Q.useSyncExternalStore)(TE?.subscribeToProactiveChanges??EE,TE?.getNextTickAt??DE,DE),g=Gl(),_=eu().getState,v=h!==null,y=(0,Q.useMemo)(()=>kd(Object.values(u),e=>qr(e)),[u]),b=pi(),x=b!==void 0&&b.length>0,S=an(`chat:cancel`,`Chat`,`esc`).toLowerCase(),C=an(`app:toggleTodos`,`Global`,`ctrl+t`),w=an(`chat:killAgents`,`Chat`,`ctrl+x ctrl+k`),T=W(e=>e.notifications.current?.key===`kill-agents-confirm`),E=AE();if(t===`bash`)return(0,$.jsx)(K,{color:`bashBorder`,children:`! for bash mode`});let D=n?.mode,O=!Md(D),k=y>0,A=+!!O+ +!!k,ee=IE()&&m.number!==null&&m.reviewState!==null&&m.url!==null&&A<2&&(A===0||c>=80),j=A<2,te=D&&O&&!Tu()?(0,$.jsxs)(K,{color:Wd(D),children:[Ad(D),` `,Pd(D).toLowerCase(),` on`,j&&(0,$.jsxs)(K,{dimColor:!0,children:[` `,(0,$.jsx)(Cl,{shortcut:l,action:`cycle`,parens:!0})]})]},`mode`):null,ne=[...p?[(0,$.jsx)(Al,{url:p,children:(0,$.jsxs)(K,{color:`ide`,children:[d.circleDouble,` remote`]})},`remote`)]:[],...ee?[(0,$.jsx)(Fr,{number:m.number,url:m.url,reviewState:m.reviewState},`pr-status`)]:[],...E?[(0,$.jsxs)(K,{dimColor:E.level===`normal`,color:E.level===`error`?`error`:E.level===`warning`?`warning`:void 0,children:[E.text,` · pid:`,process.pid]},`rss`)]:[],...(Jt(),e(gi)).getGoal()?[(0,$.jsx)(ME,{},`goal-elapsed`)]:[]],M=Object.values(u).some(e=>e.type===`local_agent`&&e.status===`running`),N=r?FE(i,S,C,w,x,M,T):[];v?ne.push((0,$.jsx)(jE,{},`proactive`)):r&&ne.push(...N);let P=k&&!Rg(u,!1)?(0,$.jsx)(mE,{tasksSelected:a,onOpenDialog:s}):null;ne.length===0&&!P&&!te&&r&&ne.push((0,$.jsx)(K,{dimColor:!0,children:`? for shortcuts`},`shortcuts-hint`));let F=cf().copyOnSelect??!0,re=g&&(!F||Zl());if(La()&&re){let e=Mf()===`macos`,t=e&&(_()?.lastPressHadAlt??!1);ne.push((0,$.jsx)(K,{dimColor:!0,children:(0,$.jsxs)(Nl,{children:[!F&&(0,$.jsx)(Cl,{shortcut:`ctrl+c`,action:`copy`}),Zl()&&(t?(0,$.jsx)(K,{children:`set macOptionClickForcesSelection in VS Code settings`}):(0,$.jsx)(Cl,{shortcut:e?`option+click`:`shift+click`,action:`native select`}))]})},`selection-copy`))}return P&&r&&ne.push((0,$.jsx)(K,{dimColor:!0,children:a?(0,$.jsx)(Cl,{shortcut:`Enter`,action:`view tasks`}):(0,$.jsx)(Cl,{shortcut:`↓`,action:`manage`})},`manage-tasks`)),ne.length===0&&!P&&!te?La()?(0,$.jsx)(K,{children:` `}):null:(0,$.jsxs)(G,{height:1,overflow:`hidden`,children:[te&&(0,$.jsxs)(G,{flexShrink:0,children:[te,(P||ne.length>0)&&(0,$.jsx)(K,{dimColor:!0,children:` · `})]}),P&&(0,$.jsxs)(G,{flexShrink:0,children:[P,ne.length>0&&(0,$.jsx)(K,{dimColor:!0,children:` · `})]}),ne.length>0&&(0,$.jsx)(K,{wrap:`truncate`,children:(0,$.jsx)(Nl,{children:ne})})]})}function FE(e,t,n,r,i,a,o){let s=i;return[...e?[(0,$.jsx)(K,{dimColor:!0,children:(0,$.jsx)(Cl,{shortcut:t,action:`interrupt`})},`esc`)]:[],...!e&&a&&!o?[(0,$.jsx)(K,{dimColor:!0,children:(0,$.jsx)(Cl,{shortcut:r,action:`stop agents`})},`kill-agents`)]:[],...s?[(0,$.jsx)(K,{dimColor:!0,children:(0,$.jsx)(Cl,{shortcut:n,action:`show tasks`})},`toggle-tasks`)]:[]]}function IE(){return cf().prStatusFooterEnabled??!0}Zs(),ht(),q(),b(),Ah(),vg();function LE({apiKeyStatus:e,debug:t,exitMessage:n,vimMode:r,mode:i,autoUpdaterResult:a,isAutoUpdating:o,verbose:s,onAutoUpdaterResult:c,onChangeIsUpdating:l,suggestions:u,selectedSuggestion:d,maxColumnWidth:f,toolPermissionContext:p,helpOpen:m,suppressHint:h,isLoading:g,tasksSelected:_,bridgeSelected:v,tmuxSelected:y,ideSelection:b,mcpClients:x,isPasting:S=!1,isInputWrapped:C=!1,messages:w,isSearching:T,historyQuery:E,setHistoryQuery:D,historyFailedMatch:O,onOpenTasksDialog:k}){let A=So(),{columns:ee,rows:j}=tu(),te=(0,Q.useRef)(w);te.current=w;let ne=(0,Q.useMemo)(()=>dE(w),[w]),M=ee<80,N=La(),P=N&&j<24,F=_,re=h||lE(A)||T;return Og((0,Q.useMemo)(()=>N&&u.length?{suggestions:u,selectedSuggestion:d,maxColumnWidth:f}:null,[N,u,d,f])),u.length&&!N?(0,$.jsx)(G,{paddingX:2,paddingY:0,children:(0,$.jsx)(jh,{suggestions:u,selectedSuggestion:d,maxColumnWidth:f})}):m?(0,$.jsx)(bg,{dimColor:!0,fixedWidth:!0,paddingX:2}):(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(G,{flexDirection:M?`column`:`row`,justifyContent:M?`flex-start`:`space-between`,paddingX:2,gap:+!M,children:[(0,$.jsxs)(G,{flexDirection:`column`,flexShrink:+!M,children:[i===`prompt`&&!P&&!n.show&&!S&&lE(A)&&(0,$.jsx)(pE,{messagesRef:te,lastAssistantMessageId:ne,vimMode:r}),(0,$.jsx)(zE,{}),(0,$.jsx)(NE,{exitMessage:n,vimMode:r,mode:i,toolPermissionContext:p,suppressHint:re,isLoading:g,tasksSelected:F,tmuxSelected:y,isPasting:S,isSearching:T,historyQuery:E,setHistoryQuery:D,historyFailedMatch:O,onOpenTasksDialog:k})]}),(0,$.jsx)(G,{flexShrink:1,gap:1,children:N?null:(0,$.jsx)(QS,{apiKeyStatus:e,autoUpdaterResult:a,debug:t,isAutoUpdating:o,verbose:s,messages:w,onAutoUpdaterResult:c,onChangeIsUpdating:l,ideSelection:b,mcpClients:x,isInputWrapped:C,isNarrow:M})})]})})}var RE=(0,Q.memo)(LE);function zE(){return null}u(),q();function BE({isLoading:e}){return(0,$.jsxs)(K,{dimColor:e,children:[d.pointer,`\xA0`]})}function VE({mode:e,isLoading:t}){return(0,$.jsx)(G,{alignItems:`flex-start`,alignSelf:`flex-start`,flexWrap:`nowrap`,justifyContent:`flex-start`,children:e===`bash`?(0,$.jsx)(K,{color:`bashBorder`,dimColor:t,children:`!\xA0`}):(0,$.jsx)(BE,{isLoading:t})})}q();var HE=Q.createContext(void 0),UE=2;function WE({isFirst:e,children:t}){let n=UE,r=Q.useMemo(()=>({isQueued:!0,isFirst:e,paddingWidth:n*2}),[e,n]);return(0,$.jsx)(HE.Provider,{value:r,children:(0,$.jsx)(G,{paddingX:n,children:t})})}q(),U(),ps(),P(),wd(),vt();var GE=new Set;function KE(e){try{return md(e)?.type===`idle_notification`}catch{return!1}}var qE=3;function JE(e){return`<${bf}>
66
- <${wf}>+${e} more tasks completed</${wf}>
67
- <${Sf}>completed</${Sf}>
68
- </${bf}>`}function YE(e){let t=e.filter(e=>typeof e.value!=`string`||!KE(e.value)),n=t.filter(e=>e.mode===`task-notification`),r=t.filter(e=>e.mode!==`task-notification`);if(n.length<=qE)return[...r,...n];let i=n.slice(0,qE-1),a={value:JE(n.length-(qE-1)),mode:`task-notification`};return[...r,...i,a]}function XE(){let e=VS(),t=W(e=>!!e.viewingAgentTaskId),n=(0,Q.useMemo)(()=>{if(e.length===0)return null;let t=e.filter(ao);return t.length===0?null:Et(YE(t).map(e=>{let t=e.value;return e.mode===`bash`&&typeof t==`string`&&(t=`<bash-input>${t}</bash-input>`),Dr({content:t})}))},[e]);return t||n===null?null:(0,$.jsx)(G,{marginTop:1,flexDirection:`column`,children:n.map((e,t)=>(0,$.jsx)(WE,{isFirst:t===0,children:(0,$.jsx)(Gn,{message:e,lookups:Js,addMargin:!1,tools:[],commands:[],verbose:!1,inProgressToolUseIDs:GE,progressMessagesForMessage:[],shouldAnimate:!1,shouldShowDot:!1,isTranscriptMode:!1,isStatic:!0})},t))})}var ZE=Q.memo(XE);Ca(),u(),q();function QE({hasStash:e}){return e?(0,$.jsx)(G,{paddingLeft:2,children:(0,$.jsxs)(K,{dimColor:!0,children:[d.pointerSmall,` Stashed (auto-restores after submit)`]})}):null}Wn();var $E=1e4,eD=1e3;function tD(e,t){if(e.length<=$E)return{truncatedText:e,placeholderContent:``};let n=Math.floor(eD/2),r=e.slice(0,n),i=e.slice(-500),a=e.slice(n,-500);return{truncatedText:r+nD(t,bn(a))+i,placeholderContent:a}}function nD(e,t){return`[...Truncated text #${e} +${t} lines...]`}function rD(e,t){let n=Object.keys(t).map(Number),r=n.length>0?Math.max(...n)+1:1,{truncatedText:i,placeholderContent:a}=tD(e,r);return a?{newInput:i,newPastedContents:{...t,[r]:{id:r,type:`text`,content:a}}}:{newInput:e,newPastedContents:t}}function iD({input:e,pastedContents:t,onInputChange:n,setCursorOffset:r,setPastedContents:i}){let[a,o]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{if(a||e.length<=1e4)return;let{newInput:s,newPastedContents:c}=rD(e,t);n(s),r(s.length),i(c),o(!0)},[e,a,t,n,i,r]),(0,Q.useEffect)(()=>{e===``&&o(!1)},[e])}U(),lf(),ps();var aD=(um(),e(vm)),oD=3;function sD({input:e,submitCount:t}){let n=VS(),r=W(e=>e.promptSuggestionEnabled);return(0,Q.useMemo)(()=>{if(e===``){if(n.some(yo)&&(cf().queuedCommandUpHintCount||0)<oD)return`Press up to edit queued messages`;if(t<1&&r&&!aD?.isProactiveActive())return Yg()}},[e,n,t,r])}var cD=5e3,lD=!1;function uD(e){let[t,n]=(0,Q.useState)(!1);return(0,Q.useEffect)(()=>{if(lD||!e)return;lD=!0,n(!0);let t=setTimeout(n,cD,!1);return()=>{clearTimeout(t),n(!1)}},[e]),t}Kl(),Ot(),If(),U(),sd(),ps(),Ol(),ae(),fc(),Pg(),Wn(),Vh(),ht(),q(),_n(),Le(),O(),Gt(),Nd(),Pc(),lf(),bd(),Rd(),pd(),b(),Eo(),Ef(),vp(),Nf(),Rh(),fn(),ba(),Vg(),at(),yg();var dD=5,fD=3;function pD({debug:e,ideSelection:t,toolPermissionContext:n,setToolPermissionContext:r,apiKeyStatus:i,commands:a,agents:o,isLoading:s,verbose:c,messages:l,onAutoUpdaterResult:u,autoUpdaterResult:d,input:f,onInputChange:p,mode:m,onModeChange:h,stashedPrompt:g,setStashedPrompt:_,submitCount:v,onShowMessageSelector:y,onMessageActionsEnter:b,mcpClients:x,pastedContents:S,setPastedContents:C,vimMode:w,setVimMode:T,showBashesDialog:E,setShowBashesDialog:D,onExit:O,getToolUseContext:k,onSubmit:A,isSearchingHistory:j,setIsSearchingHistory:te,onDismissSideQuestion:ne,isSideQuestionVisible:M,helpOpen:N,setHelpOpen:P,hasSuppressedDialogs:re,isLocalJSXCommandActive:I=!1,insertTextRef:ie}){let ae=Bh(),oe=hs()||I,[se,ce]=(0,Q.useState)(!1),[le,ue]=(0,Q.useState)({show:!1}),[L,R]=(0,Q.useState)(f.length),de=Q.useRef(f);f!==de.current&&(R(f.length),de.current=f);let fe=Q.useCallback(e=>{de.current=e,p(e)},[p]);ie&&(ie.current={cursorOffset:L,insert:e=>{let t=L===f.length&&f.length>0&&!/\s$/.test(f)?` `+e:e,n=f.slice(0,L)+t+f.slice(L);de.current=n,p(n),R(L+t.length)},setInputWithCursor:(e,t)=>{de.current=e,p(e),R(t)}});let pe=xa(),z=Qo(),me=W(e=>e.tasks),he=W(e=>e.replBridgeConnected),ge=W(e=>e.replBridgeExplicit),_e=W(e=>e.replBridgeReconnecting),ve=he&&(ge||_e),ye=VS(),be=W(e=>e.promptSuggestion),xe=W(e=>e.speculation),Se=W(e=>e.speculationSessionTimeSavedMs),Ce=W(e=>e.mainLoopModel),we=W(e=>e.mainLoopModelForSession),Te=W(e=>e.thinkingEnabled),Ee=W(e=>Np()?e.fastMode:!1),De=W(e=>e.viewingAgentTaskId);W(e=>e.viewSelectionMode);let{historyQuery:Oe,setHistoryQuery:ke,historyMatch:Ae,historyFailedMatch:je}=sC(e=>{C(e.pastedContents),Xt(e.display)},f,fe,R,L,h,m,j,te,C,S),Me=(0,Q.useRef)(-1);Me.current===-1&&(Me.current=mD(l));let Ne=(0,Q.useRef)(!1),[Pe,Fe]=(0,Q.useState)(!1),Ie=W(e=>e.selectedBgAgentIndex),Le=(0,Q.useCallback)(e=>z(t=>{let n=typeof e==`function`?e(t.selectedBgAgentIndex):e;return n===t.selectedBgAgentIndex?t:{...t,selectedBgAgentIndex:n}}),[z]),[Re,ze]=(0,Q.useState)(!1),[Be,Ve]=(0,Q.useState)(!1),[He,Ue]=(0,Q.useState)(!1),[We,Ge]=(0,Q.useState)(!1),[Ke,qe]=(0,Q.useState)(!1),[Je,Ye]=(0,Q.useState)(!1),[Xe,Ze]=(0,Q.useState)(!1),[Qe,$e]=(0,Q.useState)(!1),et=(0,Q.useMemo)(()=>{let e=f.indexOf(`
69
- `);return e===-1||L<=e},[f,L]),tt=(0,Q.useMemo)(()=>{let e=f.lastIndexOf(`
70
- `);return e===-1||L>e},[f,L]),nt=(0,Q.useMemo)(()=>kd(Object.values(me),e=>e.status===`running`),[me])>0&&!Rg(me,!1),rt=oC(),it=rt.length>0,at=(0,Q.useMemo)(()=>[it&&`bg_agent`,nt&&`tasks`,ve&&`bridge`].filter(Boolean),[it,nt,ve]),ot=W(e=>e.footerSelection),st=ot&&at.includes(ot)?ot:null;(0,Q.useEffect)(()=>{ot&&!st&&z(e=>e.footerSelection===null?e:{...e,footerSelection:null})},[ot,st,z]);let ct=st===`tasks`,lt=st===`tmux`,ut=st===`bridge`,dt=st===`bg_agent`;function ft(e){z(t=>t.footerSelection===e?t:{...t,footerSelection:e}),e===`bg_agent`&&Le(-1)}function pt(e,t=!1){let n=st?at.indexOf(st):-1,r=at[n+e];return r?(ft(r),!0):e<0&&t?(ft(null),!0):!1}let{suggestion:mt,markAccepted:ht,logOutcomeAtSubmission:gt,markShown:vt}=lC({inputValue:f,isAssistantResponding:s}),yt=(0,Q.useMemo)(()=>j&&Ae?Kr(typeof Ae==`string`?Ae:Ae.display):f,[j,Ae,f]),bt=(0,Q.useMemo)(()=>ts(yt),[yt]),xt=(0,Q.useMemo)(()=>hh(yt),[yt]),St=(0,Q.useMemo)(()=>LC(yt).filter(e=>_l(yt.slice(e.start+1,e.end),a)),[yt,a]),Ct=(0,Q.useMemo)(()=>Nn(yt),[yt]),wt=(0,Q.useMemo)(()=>rw(pe.getState().mcp.clients)?aw(yt):[],[yt,(0,Q.useSyncExternalStore)(YC,iw)]),Tt=(0,Q.useMemo)(()=>_t(yt).filter(e=>e.match.startsWith(`[Image`)).map(e=>({start:e.index,end:e.index+e.match.length})),[yt]),Et=Tt.some(e=>e.start===L);(0,Q.useEffect)(()=>{let e=Tt.find(e=>L>e.start&&L<e.end);if(e){let t=(e.start+e.end)/2;R(L<t?e.start:e.end)}},[L,Tt,R]);let Dt=(0,Q.useMemo)(()=>{let e=[];for(let t of Tt)L===t.start&&e.push({start:t.start,end:t.end,color:void 0,inverse:!0,priority:8});j&&Ae&&!je&&e.push({start:L,end:L+Oe.length,color:`warning`,priority:20});for(let t of xt)e.push({start:t.start,end:t.end,color:`warning`,priority:15});for(let t of St)e.push({start:t.start,end:t.end,color:`suggestion`,priority:5});for(let t of Ct)e.push({start:t.start,end:t.end,color:`suggestion`,priority:5});for(let t of wt)e.push({start:t.start,end:t.end,color:`suggestion`,priority:5});if(Za())for(let t of bt)for(let n=t.start;n<t.end;n++)e.push({start:n,end:n+1,color:Oc(n-t.start),shimmerColor:Oc(n-t.start,!0),priority:10});return e},[j,Oe,Ae,je,L,xt,Tt,St,Ct,wt,yt,bt]),{addNotification:Ot,removeNotification:kt}=ki();(0,Q.useEffect)(()=>{bt.length&&Za()?Ot({key:`ultrathink-active`,text:`Ultrathink active for this turn`,priority:`immediate`,timeoutMs:5e3}):kt(`ultrathink-active`)},[Ot,kt,bt.length]);let At=(0,Q.useRef)(f.length),jt=(0,Q.useRef)(f.length),Mt=(0,Q.useCallback)(()=>{kt(`stash-hint`)},[kt]);(0,Q.useEffect)(()=>{let e=At.current,t=jt.current,n=f.length;if(At.current=n,n>t){jt.current=n;return}if(n===0){jt.current=0;return}t>=20&&n<=5&&!(e>=20&&n<=5)&&(cf().hasUsedStash||Ot({key:`stash-hint`,jsx:(0,$.jsxs)(K,{dimColor:!0,children:[`Tip: `,(0,$.jsx)(Lo,{action:`chat:stash`,context:`Chat`,fallback:`ctrl+s`,description:`stash`})]}),priority:`immediate`,timeoutMs:ZS}),jt.current=n)},[f.length,Ot]);let{pushToBuffer:Nt,undo:Pt,canUndo:Ft,clearBuffer:It}=cC({maxBufferSize:50,debounceMs:1e3});iD({input:f,pastedContents:S,onInputChange:fe,setCursorOffset:R,setPastedContents:C});let Rt=sD({input:f,submitCount:v}),zt=(0,Q.useCallback)(e=>{if(e===`?`){X(`tengu_help_toggled`,{}),P(e=>!e);return}P(!1),Mt(),ms(),di(z);let t=e.length===f.length+1,n=L===0,r=F(e);if(n&&r!==`prompt`){if(t){h(r);return}if(f.length===0){h(r);let t=Kr(e).replaceAll(` `,` `);Nt(f,L,S),fe(t),R(t.length);return}}let i=e.replaceAll(` `,` `);f!==i&&Nt(f,L,S),z(e=>e.footerSelection===null?e:{...e,footerSelection:null}),fe(i)},[fe,h,f,L,Nt,S,Mt,z]),{resetHistory:Bt,onHistoryUp:Vt,onHistoryDown:Ht,dismissSearchHint:Ut,historyIndex:Wt}=aC((e,t,n)=>{zt(e),h(t),C(n)},f,S,R,m);(0,Q.useEffect)(()=>{j&&Ut()},[j,Ut]);function Gt(){if(!(Zt.length>1)&&et){if(ye.some(yo)){cn();return}Vt()}}function Kt(){if(!(Zt.length>1)&&tt&&Ht()&&at.length>0){let e=at[0];ft(e),e===`tasks`&&!cf().hasSeenTasksHint&&df(e=>e.hasSeenTasksHint?e:{...e,hasSeenTasksHint:!0})}}let[qt,Jt]=(0,Q.useState)({suggestions:[],selectedSuggestion:-1,commandArgumentHint:void 0}),Yt=(0,Q.useCallback)(e=>{Jt(t=>typeof e==`function`?e(t):e)},[]),Xt=(0,Q.useCallback)(async(e,t=!1)=>{e=e.trimEnd();let n=pe.getState();if(n.footerSelection&&at.includes(n.footerSelection)||n.viewSelectionMode===`selecting-agent`)return;let r=Object.values(S).some(e=>e.type===`image`),i=be.text;if((e.trim()===``||e===i)&&i&&!r&&!n.viewingAgentTaskId){if(xe.status===`active`){ht(),gt(i,{skipReset:!0}),A(i,{setCursorOffset:R,clearBuffer:It,resetHistory:Bt},{state:xe,speculationSessionTimeSavedMs:Se,setAppState:z});return}be.shownAt>0&&(ht(),e=i)}if(e.trim()===``&&!r)return;let a=qt.suggestions.length>0&&qt.suggestions.every(e=>e.description===`directory`);if(qt.suggestions.length>0&&!t&&!a){J(`[onSubmit] early return: suggestions showing (count=${qt.suggestions.length})`);return}be.text&&be.shownAt>0&&gt(e),kt(`stash-hint`),await A(e,{setCursorOffset:R,clearBuffer:It,resetHistory:Bt})},[be,xe,Se,pe,at,qt.suggestions,A,It,Bt,gt,z,ht,S,kt]),{suggestions:Zt,selectedSuggestion:Qt,commandArgumentHint:$t,inlineGhostText:en,maxColumnWidth:tn}=Fw({commands:a,onInputChange:fe,onSubmit:Xt,setCursorOffset:R,input:f,cursorOffset:L,mode:m,agents:o,setSuggestionsState:Yt,suggestionsState:qt,suppressSuggestions:j||Wt>0,markAccepted:ht,onModeChange:h}),nn=m===`prompt`&&Zt.length===0&&mt&&!De;nn&&vt(),be.text&&!mt&&be.shownAt===0&&!De&&(ta(`timing`,be.text),z(e=>({...e,promptSuggestion:{text:null,promptId:null,shownAt:0,acceptedAt:0,generationRequestId:null}})));function rn(e,t,n,r,i){X(`tengu_paste_image`,{}),h(`prompt`);let a=Me.current++,o={id:a,type:`image`,content:e,mediaType:t||`image/png`,filename:n||`Pasted image`,dimensions:r,sourcePath:i};_c(o),sa(o),C(e=>({...e,[a]:o})),sn((Ne.current?` `:``)+ee(a)),Ne.current=!0}(0,Q.useEffect)(()=>{let e=new Set(_t(f).map(e=>e.id));C(t=>{let n=Object.values(t).filter(t=>t.type===`image`&&!e.has(t.id));if(n.length===0)return t;let r={...t};for(let e of n)delete r[e.id];return r})},[f,C]);function an(e){Ne.current=!1;let t=iu(e).replace(/\r/g,`
71
- `).replaceAll(` `,` `);if(f.length===0){let e=F(t);e!==`prompt`&&(h(e),t=Kr(t))}let n=bn(t),r=Math.min(wn-10,2);if(t.length>800||n>r){let e=Me.current++,r={id:e,type:`text`,content:t};C(t=>({...t,[e]:r})),sn(Po(e,n))}else sn(t)}let on=(0,Q.useCallback)((e,t)=>Ne.current?(Ne.current=!1,_g(e,t)?` `+e:e):e,[]);function sn(e){Nt(f,L,S);let t=f.slice(0,L)+e+f.slice(L);fe(t),R(L+e.length)}let B=Jl(()=>{},()=>y()),cn=(0,Q.useCallback)(()=>{let e=Vc(f,L);return e?(fe(e.text),h(`prompt`),R(e.cursorOffset),e.images.length>0&&C(t=>{let n={...t};for(let t of e.images)n[t.id]=t;return n}),!0):!1},[fe,h,f,L,C]);WS(x,function(e){X(`tengu_ext_at_mentioned`,{});let t,n=t_.relative(cd(),e.filePath);t=e.lineStart&&e.lineEnd?e.lineStart===e.lineEnd?`@${n}#L${e.lineStart} `:`@${n}#L${e.lineStart}-${e.lineEnd} `:`@${n} `;let r=f[L-1]??` `;/\s/.test(r)||(t=` ${t}`),sn(t)});let ln=(0,Q.useCallback)(()=>{if(Ft){let e=Pt();e&&(fe(e.text),R(e.cursorOffset),C(e.pastedContents))}},[Ft,Pt,fe,C]),un=(0,Q.useCallback)(()=>{Nt(f,L,S);let e=f.slice(0,L)+`
72
- `+f.slice(L);fe(e),R(L+1)},[f,L,fe,R,Nt,S]),dn=(0,Q.useCallback)(async()=>{X(`tengu_external_editor_used`,{}),Ve(!0);try{let e=await Ih(f,S);e.error&&Ot({key:`external-editor-error`,text:e.error,color:`warning`,priority:`high`}),e.content!==null&&e.content!==f&&(Nt(f,L,S),fe(e.content),R(e.content.length))}catch(e){e instanceof Error&&Y(e),Ot({key:`external-editor-error`,text:`External editor failed: ${fd(e)}`,color:`warning`,priority:`high`})}finally{Ve(!1)}},[f,L,S,Nt,fe,Ot]),fn=(0,Q.useCallback)(()=>{f.trim()===``&&g!==void 0?(fe(g.text),R(g.cursorOffset),C(g.pastedContents),_(void 0)):f.trim()!==``&&(_({text:f,cursorOffset:L,pastedContents:S}),fe(``),R(0),C({}),df(e=>e.hasUsedStash?e:{...e,hasUsedStash:!0}))},[f,L,g,fe,_,S,C]),pn=(0,Q.useCallback)(()=>{Ue(e=>!e),N&&P(!1)},[N]),mn=(0,Q.useCallback)(()=>{Ze(e=>!e),N&&P(!1)},[N]),hn=(0,Q.useCallback)(()=>{$e(e=>!e),N&&P(!1)},[N]),gn=(0,Q.useCallback)(()=>{J(`[auto-mode] handleCycleMode: currentMode=${n.mode}`);let e=Rw(n),{context:t}=zw(n);X(`tengu_mode_cycle`,{to:e}),e===`plan`&&df(e=>({...e,lastPlanModeUse:Date.now()})),z(n=>({...n,toolPermissionContext:{...t,mode:e}})),r({...t,mode:e}),N&&P(!1)},[n,z,r,N]),_n=(0,Q.useCallback)(()=>{Lt().then(e=>{if(e)rn(e.base64,e.mediaType);else{let e=Hn(`chat:imagePaste`,`Chat`,`ctrl+v`),t=Od.isSSH()?`No image found in clipboard. You're SSH'd; try scp?`:`No image found in clipboard. Use ${e} to paste images.`;Ot({key:`no-image-in-clipboard`,text:t,priority:`immediate`,timeoutMs:1e3})}})},[Ot,rn]),vn=Bl();(0,Q.useEffect)(()=>{if(!(!vn||oe))return vn.registerHandler({action:`chat:submit`,context:`Chat`,handler:()=>{Xt(f)}})},[vn,oe,Xt,f]),El((0,Q.useMemo)(()=>({"chat:undo":ln,"chat:newline":un,"chat:externalEditor":dn,"chat:stash":fn,"chat:modelPicker":pn,"chat:thinkingToggle":hn,"chat:cycleMode":gn,"chat:imagePaste":_n}),[ln,un,dn,fn,pn,hn,gn,_n]),{context:`Chat`,isActive:!oe}),Il(`chat:messageActions`,()=>b?.(),{context:`Chat`,isActive:!oe&&!j}),Il(`chat:fastMode`,mn,{context:`Chat`,isActive:!oe&&Np()&&Ip()}),Il(`help:dismiss`,()=>{P(!1)},{context:`Help`,isActive:N}),Il(`app:quickOpen`,()=>{},{context:`Global`,isActive:!1}),Il(`app:globalSearch`,()=>{},{context:`Global`,isActive:!1}),Il(`history:search`,()=>{},{context:`Global`,isActive:!1}),Il(`app:interrupt`,()=>{di(z)},{context:`Global`,isActive:!s&&xe.status===`active`}),El({"footer:up":()=>{if(dt){Ie>-1?Le(e=>e-1):ft(null);return}pt(-1,!0)},"footer:down":()=>{if(dt){Ie<rt.length-1&&Le(e=>e+1);return}if(ct){D(!0),ft(null);return}pt(1)},"footer:next":()=>{pt(1)},"footer:previous":()=>{pt(-1)},"footer:openSelected":()=>{switch(st){case`tasks`:D(!0),ft(null);break;case`tmux`:break;case`bridge`:Fe(!0),ft(null);break;case`bg_agent`:break}},"footer:clearSelection":()=>{ft(null)},"footer:close":()=>!1},{context:`Footer`,isActive:!!st&&!oe}),Xl((e,t)=>{if(!(We||Ke||Je)){if(Mf()===`macos`&&Lw(e)){let t=Iw[e],n=im();Ot({key:`option-meta-hint`,jsx:n?(0,$.jsxs)(K,{dimColor:!0,children:[`To enable `,t,`, set `,(0,$.jsx)(K,{bold:!0,children:`Option as Meta`}),` in `,n,` preferences (⌘,)`]}):(0,$.jsxs)(K,{dimColor:!0,children:[`To enable `,t,`, run /terminal-setup`]}),priority:`immediate`,timeoutMs:5e3})}if(st&&e&&!t.ctrl&&!t.meta&&!t.escape&&!t.return){zt(f.slice(0,L)+e+f.slice(L)),R(L+e.length);return}if(L===0&&(t.escape||t.backspace||t.delete||t.ctrl&&e===`u`)&&(h(`prompt`),P(!1)),N&&f===``&&(t.backspace||t.delete)&&P(!1),t.escape){if(xe.status===`active`){di(z);return}if(M&&ne){ne();return}if(N){P(!1);return}if(st)return;if(ye.some(yo)){cn();return}l.length>0&&!f&&!s&&B()}t.return&&N&&P(!1)}});let yn=Np()?Ap():!1,xn=Np()?Ee&&(Ip()||yn):!1,Sn=uD(xn??!1),{columns:Cn,rows:wn}=tu(),Tn=Cn-3,En=La()?Math.max(fD,Math.floor(wn/2)-dD):void 0,Dn=(0,Q.useCallback)(e=>{if(!f||j)return;let t=no.fromText(f,Tn,L),n=t.getViewportStartLine(En),r=t.measuredText.getOffsetFromPosition({line:e.localRow+n,column:e.localCol});R(r)},[f,Tn,j,L,En]),On=(0,Q.useCallback)(e=>D(e??!0),[D]),kn=nn&&mt?mt:Rt,An=(0,Q.useMemo)(()=>f.includes(`
73
- `),[f]),jn=(0,Q.useCallback)(e=>{let t=!1;z(n=>(t=Np()&&!Ep(e)&&!!n.fastMode,{...n,mainLoopModel:e,mainLoopModelForSession:null,...t&&{fastMode:!1}})),Ue(!1);let n=(Ee??!1)&&!t,r=`Model set to ${zp(e)}`;Yh(e,n,xp())&&(r+=` · Billed as extra usage`),t&&(r+=` · Fast mode OFF`),Ot({key:`model-switched`,jsx:(0,$.jsx)(K,{children:r}),priority:`immediate`,timeoutMs:3e3}),X(`tengu_model_picker_hotkey`,{model:e})},[z,Ot,Ee]),Mn=(0,Q.useCallback)(()=>{Ue(!1)},[]),Pn=(0,Q.useMemo)(()=>He?(0,$.jsx)(G,{flexDirection:`column`,marginTop:1,children:(0,$.jsx)(Xh,{initial:Ce,sessionModel:we,onSelect:jn,onCancel:Mn,isStandaloneCommand:!0,showFastModeNotice:Np()&&Ee&&Ep(Ce)&&Ip()})}):null,[He,Ce,we,jn,Mn]),Fn=(0,Q.useCallback)(e=>{Ze(!1),e&&Ot({key:`fast-mode-toggled`,jsx:(0,$.jsx)(K,{children:e}),priority:`immediate`,timeoutMs:3e3})},[Ot]),In=(0,Q.useMemo)(()=>Xe?(0,$.jsx)(G,{flexDirection:`column`,marginTop:1,children:(0,$.jsx)(dg,{onDone:Fn,unavailableReason:_p()})}):null,[Xe,Fn]),Ln=(0,Q.useCallback)(e=>{z(t=>({...t,thinkingEnabled:e})),$e(!1),X(`tengu_thinking_toggled_hotkey`,{enabled:e}),Ot({key:`thinking-toggled-hotkey`,jsx:(0,$.jsxs)(K,{color:e?`suggestion`:void 0,dimColor:!e,children:[`Thinking `,e?`on`:`off`]}),priority:`immediate`,timeoutMs:3e3})},[z,Ot]),Rn=(0,Q.useCallback)(()=>{$e(!1)},[]),zn=(0,Q.useMemo)(()=>Qe?(0,$.jsx)(G,{flexDirection:`column`,marginTop:1,children:(0,$.jsx)(Hw,{currentValue:Te??!0,onSelect:Ln,onCancel:Rn,isMidConversation:l.some(e=>e.type===`assistant`)})}):null,[Qe,Te,Ln,Rn,l.length]);if(Ag(null),E)return(0,$.jsx)(Hg,{onDone:()=>D(!1),toolUseContext:k(l,[],new AbortController,ae),initialDetailTaskId:typeof E==`string`?E:void 0});if(Pn)return Pn;if(In)return In;if(zn)return zn;if(Pe)return(0,$.jsx)(Vw,{onDone:()=>{Fe(!1),ft(null)}});let Bn={multiline:!0,onSubmit:Xt,onChange:zt,value:Ae?Kr(typeof Ae==`string`?Ae:Ae.display):f,onHistoryUp:Gt,onHistoryDown:Kt,onHistoryReset:Bt,placeholder:kn,onExit:O,onExitMessage:(e,t)=>ue({show:e,key:t}),onImagePaste:rn,columns:Tn,maxVisibleLines:En,disableCursorMovementForUpDownKeys:Zt.length>0||!!st,disableEscapeDoublePress:Zt.length>0,cursorOffset:L,onChangeCursorOffset:R,onPaste:an,onIsPastingChange:ze,focus:!j&&!oe&&!st,showCursor:!st&&!j&&!Et,argumentHint:$t,onUndo:Ft?()=>{let e=Pt();e&&(fe(e.text),R(e.cursorOffset),C(e.pastedContents))}:void 0,highlights:Dt,inlineGhostText:en,inputFilter:on},Vn=()=>{let e={bash:`bashBorder`};return e[m]?e[m]:`promptBorder`};if(Be)return(0,$.jsx)(G,{flexDirection:`row`,alignItems:`center`,justifyContent:`center`,borderColor:Vn(),borderStyle:`round`,borderLeft:!1,borderRight:!1,borderBottom:!0,width:`100%`,children:(0,$.jsx)(K,{dimColor:!0,italic:!0,children:`Save and close editor to continue...`})});let Un=gg()?(0,$.jsx)(VT,{...Bn,initialMode:w,onModeChange:T}):(0,$.jsx)(ac,{...Bn});return(0,$.jsxs)(G,{flexDirection:`column`,marginTop:1,children:[!La()&&(0,$.jsx)(ZE,{}),re&&(0,$.jsx)(G,{marginTop:1,marginLeft:2,children:(0,$.jsx)(K,{dimColor:!0,children:`Waiting for permission…`})}),(0,$.jsx)(QE,{hasStash:g!==void 0}),(0,$.jsxs)(G,{flexDirection:`row`,alignItems:`flex-start`,justifyContent:`flex-start`,borderColor:Vn(),borderStyle:`round`,borderLeft:!1,borderRight:!1,borderBottom:!0,width:`100%`,borderText:hD(xn??!1,Sn,yn),children:[(0,$.jsx)(VE,{mode:m,isLoading:s}),(0,$.jsx)(G,{flexGrow:1,flexShrink:1,onClick:Dn,children:Un})]}),(0,$.jsx)(RE,{apiKeyStatus:i,debug:e,exitMessage:le,vimMode:gg()?w:void 0,mode:m,autoUpdaterResult:d,isAutoUpdating:se,verbose:c,onAutoUpdaterResult:u,onChangeIsUpdating:ce,suggestions:Zt,selectedSuggestion:Qt,maxColumnWidth:tn,toolPermissionContext:n,helpOpen:N,suppressHint:f.length>0,isLoading:s,tasksSelected:ct,bridgeSelected:ut,tmuxSelected:lt,ideSelection:t,mcpClients:x,isPasting:Re,isInputWrapped:An,messages:l,isSearching:j,historyQuery:Oe,setHistoryQuery:ke,historyFailedMatch:je,onOpenTasksDialog:La()?On:void 0}),La()?(0,$.jsx)(G,{position:`absolute`,marginTop:-1,height:+(Zt.length===0),width:`100%`,paddingLeft:2,paddingRight:1,flexDirection:`column`,justifyContent:`flex-end`,overflow:`hidden`,children:(0,$.jsx)(QS,{apiKeyStatus:i,autoUpdaterResult:d,debug:e,isAutoUpdating:se,verbose:c,messages:l,onAutoUpdaterResult:u,onChangeIsUpdating:ce,ideSelection:t,mcpClients:x,isInputWrapped:An})}):null]})}function mD(e){let t=0;for(let n of e)if(n.type===`user`){if(n.imagePasteIds)for(let e of n.imagePasteIds)e>t&&(t=e);if(Array.isArray(n.message.content)){for(let e of n.message.content)if(e.type===`text`){let n=_t(e.text);for(let e of n)e.id>t&&(t=e.id)}}}return t+1}function hD(e,t,n){if(e)return{content:` ${t?`${lg(!0,n)} ${ou.dim(`/fast`)}`:lg(!0,n)} `,position:`top`,align:`end`,offset:0}}var gD=Q.memo(pD);wd();function _D(e,t){return{type:`assistant`,uuid:d_(),message:{id:`remote-${t}`,type:`message`,role:`assistant`,content:[{type:`tool_use`,id:e.tool_use_id,name:e.tool_name,input:e.input}],model:``,stop_reason:null,stop_sequence:null,container:null,context_management:null,usage:{input_tokens:0,output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:0}},requestId:void 0,timestamp:new Date().toISOString()}}function vD(e){return{name:e,inputSchema:{},isEnabled:()=>!0,userFacingName:()=>e,renderToolUseMessage:e=>{let t=Object.entries(e);return t.length===0?``:t.slice(0,3).map(([e,t])=>`${e}: ${typeof t==`string`?t:ud(t)}`).join(`, `)},call:async()=>({data:``}),description:async()=>``,prompt:()=>``,isReadOnly:()=>!1,isMcp:!1,needsPermissions:()=>!0}}bd(),Vm(),P();function yD(e){return{type:`assistant`,message:e.message,uuid:e.uuid,requestId:void 0,timestamp:new Date().toISOString(),error:e.error}}function bD(e){return{type:`stream_event`,event:e.event}}function xD(e){let t=e.subtype!==`success`;return{type:`system`,subtype:`informational`,content:t?e.errors?.join(`, `)||`Unknown error`:`Session completed successfully`,level:t?`warning`:`info`,uuid:e.uuid,timestamp:new Date().toISOString()}}function SD(e){return{type:`system`,subtype:`informational`,content:`Remote session initialized (model: ${e.model})`,level:`info`,uuid:e.uuid,timestamp:new Date().toISOString()}}function CD(e){return e.status?{type:`system`,subtype:`informational`,content:e.status===`compacting`?`Compacting conversation…`:`Status: ${e.status}`,level:`info`,uuid:e.uuid,timestamp:new Date().toISOString()}:null}function wD(e){return{type:`system`,subtype:`informational`,content:`Tool ${e.tool_name} running for ${e.elapsed_time_seconds}s…`,level:`info`,uuid:e.uuid,timestamp:new Date().toISOString(),toolUseID:e.tool_use_id}}function TD(e){return{type:`system`,subtype:`compact_boundary`,content:`Conversation compacted`,level:`info`,uuid:e.uuid,timestamp:new Date().toISOString(),compactMetadata:Hm(e.compact_metadata)}}function ED(e,t){switch(e.type){case`assistant`:return{type:`message`,message:yD(e)};case`user`:{let n=e,r=n.message?.content,i=Array.isArray(r)&&r.some(e=>e.type===`tool_result`);return t?.convertToolResults&&i||t?.convertUserTextMessages&&!i&&(typeof r==`string`||Array.isArray(r))?{type:`message`,message:Dr({content:r,toolUseResult:n.tool_use_result,uuid:n.uuid,timestamp:n.timestamp})}:{type:`ignored`}}case`stream_event`:return{type:`stream_event`,event:bD(e)};case`result`:return e.subtype===`success`?{type:`ignored`}:{type:`message`,message:xD(e)};case`system`:{let t=e;if(t.subtype===`init`)return{type:`message`,message:SD(t)};if(t.subtype===`status`){let t=CD(e);return t?{type:`message`,message:t}:{type:`ignored`}}return t.subtype===`compact_boundary`?{type:`message`,message:TD(e)}:(J(`[sdkMessageAdapter] Ignoring system message subtype: ${t.subtype}`),{type:`ignored`})}case`tool_progress`:return{type:`message`,message:wD(e)};case`auth_status`:return J(`[sdkMessageAdapter] Ignoring auth_status message`),{type:`ignored`};case`tool_use_summary`:return J(`[sdkMessageAdapter] Ignoring tool_use_summary message`),{type:`ignored`};case`rate_limit_event`:return J(`[sdkMessageAdapter] Ignoring rate_limit_event message`),{type:`ignored`};case`task_state`:return J(`[sdkMessageAdapter] Ignoring task_state message`),{type:`ignored`};default:return J(`[sdkMessageAdapter] Unknown message type: ${e.type}`),{type:`ignored`}}}function DD(e){return e.type===`result`}U(),bd(),Kf(),P();var OD=6e4,kD=18e4;function AD({config:e,setMessages:t,setIsLoading:n,onInit:r,setToolUseConfirmQueue:i,tools:a,setStreamingToolUses:o,setStreamMode:s,setInProgressToolUseIDs:c}){let l=!!e,u=Qo(),d=(0,Q.useCallback)(e=>u(t=>t.remoteConnectionStatus===e?t:{...t,remoteConnectionStatus:e}),[u]),f=(0,Q.useRef)(new Set),p=(0,Q.useCallback)(()=>{let e=f.current.size;u(t=>t.remoteBackgroundTaskCount===e?t:{...t,remoteBackgroundTaskCount:e})},[u]),m=(0,Q.useRef)(null),h=(0,Q.useRef)(!1),g=(0,Q.useRef)(null),_=(0,Q.useRef)(!1),v=(0,Q.useRef)(new Gm(50)),y=(0,Q.useRef)(a);(0,Q.useEffect)(()=>{y.current=a},[a]),(0,Q.useEffect)(()=>{if(!e)return;J(`[useRemoteSession] Initializing for session ${e.sessionId}`);let a=new Xg(e,{onMessage:i=>{let a=[`type=${i.type}`];if(`subtype`in i&&a.push(`subtype=${i.subtype}`),i.type===`user`){let e=i.message?.content;a.push(`content=${Array.isArray(e)?e.map(e=>e.type).join(`,`):typeof e}`)}if(J(`[useRemoteSession] Received ${a.join(` `)}`),m.current&&(clearTimeout(m.current),m.current=null),i.type===`user`&&i.uuid&&v.current.has(i.uuid)){J(`[useRemoteSession] Dropping echoed user message ${i.uuid}`);return}if(i.type===`system`&&i.subtype===`init`&&r){let e=i.slash_commands;J(`[useRemoteSession] Init received with ${e.length} slash commands`),r(e)}if(i.type===`system`){if(i.subtype===`task_started`){f.current.add(i.task_id),p();return}if(i.subtype===`task_notification`){f.current.delete(i.task_id),p();return}if(i.subtype===`task_progress`)return;if(i.subtype===`status`){let e=h.current;if(h.current=i.status===`compacting`,e&&h.current)return}i.subtype===`compact_boundary`&&(h.current=!1)}if(DD(i)&&(h.current=!1,n(!1)),c&&i.type===`user`){let e=i.message?.content;if(Array.isArray(e)){let t=[];for(let n of e)n.type===`tool_result`&&t.push(n.tool_use_id);t.length>0&&c(e=>{let n=new Set(e);for(let e of t)n.delete(e);return n.size===e.size?e:n})}}let l=ED(i,e.viewerOnly?{convertToolResults:!0,convertUserTextMessages:!0}:void 0);if(l.type===`message`){if(o?.(e=>e.length>0?[]:e),c&&l.message.type===`assistant`){let e=(Array.isArray(l.message.message?.content)?l.message.message.content:[]).filter(e=>e.type===`tool_use`).map(e=>e.id);e.length>0&&c(t=>{let n=new Set(t);for(let t of e)n.add(t);return n})}t(e=>[...e,l.message])}else l.type===`stream_event`&&(o&&s?Xt(l.event,e=>t(t=>[...t,e]),()=>{},s,o):J(`[useRemoteSession] Stream event received but streaming callbacks not provided`))},onPermissionRequest:(e,t)=>{J(`[useRemoteSession] Permission request for tool: ${e.tool_name}`);let r=em(y.current,e.tool_name)??vD(e.tool_name),o=_D(e,t),s={behavior:`ask`,message:e.description??`${e.tool_name} requires permission`,suggestions:e.permission_suggestions,blockedPath:e.blocked_path},c={assistantMessage:o,tool:r,description:e.description??`${e.tool_name} requires permission`,input:e.input,toolUseContext:{},toolUseID:e.tool_use_id,permissionResult:s,permissionPromptStartTimeMs:Date.now(),onUserInteraction(){},onAbort(){a.respondToPermissionRequest(t,{behavior:`deny`,message:`User aborted`}),i(t=>t.filter(t=>t.toolUseID!==e.tool_use_id))},onAllow(r,o,s){let c={behavior:`allow`,updatedInput:r};a.respondToPermissionRequest(t,c),i(t=>t.filter(t=>t.toolUseID!==e.tool_use_id)),n(!0)},onReject(n){let r={behavior:`deny`,message:n??`User denied permission`};a.respondToPermissionRequest(t,r),i(t=>t.filter(t=>t.toolUseID!==e.tool_use_id))},async recheckPermission(){}};i(e=>[...e,c]),n(!1)},onPermissionCancelled:(e,t)=>{J(`[useRemoteSession] Permission request cancelled: ${e}`);let r=t??e;i(e=>e.filter(e=>e.toolUseID!==r)),n(!0)},onConnected:()=>{J(`[useRemoteSession] Connected`),d(`connected`)},onReconnecting:()=>{J(`[useRemoteSession] Reconnecting`),d(`reconnecting`),f.current.clear(),p(),c?.(e=>e.size>0?new Set:e)},onDisconnected:()=>{J(`[useRemoteSession] Disconnected`),d(`disconnected`),n(!1),f.current.clear(),p(),c?.(e=>e.size>0?new Set:e)},onError:e=>{J(`[useRemoteSession] Error: ${e.message}`)}});return g.current=a,a.connect(),()=>{J(`[useRemoteSession] Cleanup - disconnecting`),m.current&&(clearTimeout(m.current),m.current=null),a.disconnect(),g.current=null}},[e,t,n,r,i,o,s,c,d,p]);let b=(0,Q.useCallback)(async(r,i)=>{let a=g.current;if(!a)return J(`[useRemoteSession] Cannot send - no manager`),!1;m.current&&clearTimeout(m.current),n(!0),i?.uuid&&v.current.add(i.uuid);let o=await a.sendMessage(r,i);if(!o)return n(!1),!1;if(!_.current&&e&&!e.hasInitialPrompt&&!e.viewerOnly){_.current=!0;let t=e.sessionId,n=typeof r==`string`?r:jn(r,` `);n&&Um(n,new AbortController().signal).then(e=>{Lm(t,e??Vf(n,75))})}if(!e?.viewerOnly){let e=h.current?kD:OD;m.current=setTimeout((e,t)=>{J(`[useRemoteSession] Response timeout - attempting reconnect`);let n=gr(`Remote session may be unresponsive. Attempting to reconnect…`,`warning`);e(e=>[...e,n]),t.reconnect()},e,t,a)}return o},[e,n,t]),x=(0,Q.useCallback)(()=>{m.current&&(clearTimeout(m.current),m.current=null),e?.viewerOnly||g.current?.cancelSession(),n(!1)},[e,n]),S=(0,Q.useCallback)(()=>{m.current&&(clearTimeout(m.current),m.current=null),g.current?.disconnect(),g.current=null},[]);return(0,Q.useMemo)(()=>({isRemoteMode:l,sendMessage:b,cancelRequest:x,disconnect:S}),[l,b,x,S])}bd(),wd(),c();function jD(e){return typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`}var MD=class{constructor(e,t){l(this,`ws`,null),l(this,`config`,void 0),l(this,`callbacks`,void 0),this.config=e,this.callbacks=t}connect(){let e={};this.config.authToken&&(e.authorization=`Bearer ${this.config.authToken}`),this.ws=new WebSocket(this.config.wsUrl,{headers:e}),this.ws.addEventListener(`open`,()=>{this.callbacks.onConnected?.()}),this.ws.addEventListener(`message`,e=>{let t=(typeof e.data==`string`?e.data:``).split(`
74
- `).filter(e=>e.trim());for(let e of t){let t;try{t=md(e)}catch{continue}if(!jD(t))continue;let n=t;if(n.type===`control_request`){n.request.subtype===`can_use_tool`?this.callbacks.onPermissionRequest(n.request,n.request_id):(J(`[DirectConnect] Unsupported control request subtype: ${n.request.subtype}`),this.sendErrorResponse(n.request_id,`Unsupported control request subtype: ${n.request.subtype}`));continue}n.type!==`control_response`&&n.type!==`keep_alive`&&n.type!==`control_cancel_request`&&n.type!==`streamlined_text`&&n.type!==`streamlined_tool_use_summary`&&!(n.type===`system`&&n.subtype===`post_turn_summary`)&&this.callbacks.onMessage(n)}}),this.ws.addEventListener(`close`,()=>{this.callbacks.onDisconnected?.()}),this.ws.addEventListener(`error`,()=>{this.callbacks.onError?.(Error(`WebSocket connection error`))})}sendMessage(e){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return!1;let t=ud({type:`user`,message:{role:`user`,content:e},parent_tool_use_id:null,session_id:``});return this.ws.send(t),!0}respondToPermissionRequest(e,t){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return;let n=ud({type:`control_response`,response:{subtype:`success`,request_id:e,response:{behavior:t.behavior,...t.behavior===`allow`?{updatedInput:t.updatedInput}:{message:t.message}}}});this.ws.send(n)}sendInterrupt(){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return;let e=ud({type:`control_request`,request_id:crypto.randomUUID(),request:{subtype:`interrupt`}});this.ws.send(e)}sendErrorResponse(e,t){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return;let n=ud({type:`control_response`,response:{subtype:`error`,request_id:e,error:t}});this.ws.send(n)}disconnect(){this.ws&&(this.ws.close(),this.ws=null)}isConnected(){return this.ws?.readyState===WebSocket.OPEN}};Kp(),bd();function ND({config:e,setMessages:t,setIsLoading:n,setToolUseConfirmQueue:r,tools:i}){let a=!!e,o=(0,Q.useRef)(null),s=(0,Q.useRef)(!1),c=(0,Q.useRef)(!1),l=(0,Q.useRef)(i);(0,Q.useEffect)(()=>{l.current=i},[i]),(0,Q.useEffect)(()=>{if(!e)return;s.current=!1,J(`[useDirectConnect] Connecting to ${e.wsUrl}`);let i=new MD(e,{onMessage:e=>{if(DD(e)&&n(!1),e.type===`system`&&e.subtype===`init`){if(s.current)return;s.current=!0}let r=ED(e,{convertToolResults:!0});r.type===`message`&&t(e=>[...e,r.message])},onPermissionRequest:(e,t)=>{J(`[useDirectConnect] Permission request for tool: ${e.tool_name}`);let a=em(l.current,e.tool_name)??vD(e.tool_name),o=_D(e,t),s={behavior:`ask`,message:e.description??`${e.tool_name} requires permission`,suggestions:e.permission_suggestions,blockedPath:e.blocked_path},c={assistantMessage:o,tool:a,description:e.description??`${e.tool_name} requires permission`,input:e.input,toolUseContext:{},toolUseID:e.tool_use_id,permissionResult:s,permissionPromptStartTimeMs:Date.now(),onUserInteraction(){},onAbort(){i.respondToPermissionRequest(t,{behavior:`deny`,message:`User aborted`}),r(t=>t.filter(t=>t.toolUseID!==e.tool_use_id))},onAllow(a,o,s){let c={behavior:`allow`,updatedInput:a};i.respondToPermissionRequest(t,c),r(t=>t.filter(t=>t.toolUseID!==e.tool_use_id)),n(!0)},onReject(n){let a={behavior:`deny`,message:n??`User denied permission`};i.respondToPermissionRequest(t,a),r(t=>t.filter(t=>t.toolUseID!==e.tool_use_id))},async recheckPermission(){}};r(e=>[...e,c]),n(!1)},onConnected:()=>{J(`[useDirectConnect] Connected`),c.current=!0},onDisconnected:()=>{J(`[useDirectConnect] Disconnected`),c.current?process.stderr.write(`
75
- Server disconnected.
76
- `):process.stderr.write(`\nFailed to connect to server at ${e.wsUrl}\n`),c.current=!1,vi(1),n(!1)},onError:e=>{J(`[useDirectConnect] Error: ${e.message}`)}});return o.current=i,i.connect(),()=>{J(`[useDirectConnect] Cleanup - disconnecting`),i.disconnect(),o.current=null}},[e,t,n,r]);let u=(0,Q.useCallback)(async e=>{let t=o.current;return t?(n(!0),t.sendMessage(e)):!1},[n]),d=(0,Q.useCallback)(()=>{o.current?.sendInterrupt(),n(!1)},[n]),f=(0,Q.useCallback)(()=>{o.current?.disconnect(),o.current=null,c.current=!1},[]);return(0,Q.useMemo)(()=>({isRemoteMode:a,sendMessage:u,cancelRequest:d,disconnect:f}),[a,u,d,f])}Kp(),bd(),nr();function PD({session:e,setMessages:t,setIsLoading:n,setToolUseConfirmQueue:r,tools:i}){let a=!!e,o=(0,Q.useRef)(null),s=(0,Q.useRef)(!1),c=(0,Q.useRef)(!1),l=(0,Q.useRef)(i);(0,Q.useEffect)(()=>{l.current=i},[i]),(0,Q.useEffect)(()=>{if(!e)return;s.current=!1,J(`[useSSHSession] wiring SSH session manager`);let i=e.createManager({onMessage:e=>{if(DD(e)&&n(!1),e.type===`system`&&e.subtype===`init`){if(s.current)return;s.current=!0}let r=ED(e,{convertToolResults:!0});r.type===`message`&&t(e=>[...e,r.message])},onPermissionRequest:(e,t)=>{J(`[useSSHSession] permission request: ${e.tool_name}`);let a=em(l.current,e.tool_name)??vD(e.tool_name),o=_D(e,t),s={behavior:`ask`,message:e.description??`${e.tool_name} requires permission`,suggestions:e.permission_suggestions,blockedPath:e.blocked_path},c={assistantMessage:o,tool:a,description:e.description??`${e.tool_name} requires permission`,input:e.input,toolUseContext:{},toolUseID:e.tool_use_id,permissionResult:s,permissionPromptStartTimeMs:Date.now(),onUserInteraction(){},onAbort(){i.respondToPermissionRequest(t,{behavior:`deny`,message:`User aborted`}),r(t=>t.filter(t=>t.toolUseID!==e.tool_use_id))},onAllow(a){i.respondToPermissionRequest(t,{behavior:`allow`,updatedInput:a}),r(t=>t.filter(t=>t.toolUseID!==e.tool_use_id)),n(!0)},onReject(n){i.respondToPermissionRequest(t,{behavior:`deny`,message:n??`User denied permission`}),r(t=>t.filter(t=>t.toolUseID!==e.tool_use_id))},async recheckPermission(){}};r(e=>[...e,c]),n(!1)},onConnected:()=>{J(`[useSSHSession] connected`),c.current=!0},onReconnecting:(e,r)=>{J(`[useSSHSession] ssh dropped, reconnecting (${e}/${r})`),c.current=!1,n(!1);let i={type:`system`,subtype:`informational`,content:`SSH connection dropped — reconnecting (attempt ${e}/${r})...`,timestamp:new Date().toISOString(),uuid:d_(),level:`warning`};t(e=>[...e,i])},onDisconnected:()=>{J(`[useSSHSession] ssh process exited (giving up)`);let t=e.getStderrTail().trim(),r=c.current,i=e.proc.exitCode;c.current=!1,n(!1);let a=r?`Remote session ended.`:`SSH session failed before connecting.`;t&&(!r||i!==0)&&(a+=`\nRemote stderr (exit ${i??`signal `+e.proc.signalCode}):\n${t}`),vi(1,`other`,{finalMessage:a})},onError:e=>{J(`[useSSHSession] error: ${e.message}`)}});return o.current=i,i.connect(),()=>{J(`[useSSHSession] cleanup`),i.disconnect(),e.proxy.stop(),o.current=null}},[e,t,n,r]);let u=(0,Q.useCallback)(async e=>{let t=o.current;return t?(n(!0),t.sendMessage(e)):!1},[n]),d=(0,Q.useCallback)(()=>{o.current?.sendInterrupt(),n(!1)},[n]),f=(0,Q.useCallback)(()=>{o.current?.disconnect(),o.current=null,c.current=!1},[]);return(0,Q.useMemo)(()=>({isRemoteMode:a,sendMessage:u,cancelRequest:d,disconnect:f}),[a,u,d,f])}Qf();var FD=400;function ID({inputValue:e,setInputValue:t,isValidDigit:n,onDigit:r,enabled:i=!0,once:a=!1,debounceMs:o=FD}){let s=(0,Q.useRef)(e),c=(0,Q.useRef)(!1),l=(0,Q.useRef)(null),u=(0,Q.useRef)({setInputValue:t,isValidDigit:n,onDigit:r});u.current={setInputValue:t,isValidDigit:n,onDigit:r},(0,Q.useEffect)(()=>{if(!(!i||a&&c.current)){if(l.current!==null&&(clearTimeout(l.current),l.current=null),e!==s.current){let t=ep(e.slice(-1));if(u.current.isValidDigit(t)){let n=e.slice(0,-1);l.current=setTimeout((e,t,n,r,i)=>{e.current=null,t.current=!0,n.current.setInputValue(r),n.current.onDigit(i)},o,l,c,u,n,t)}}return()=>{l.current!==null&&(clearTimeout(l.current),l.current=null)}}},[e,i,a,o])}q();var LD=[`0`,`1`,`2`,`3`],RD={0:`dismissed`,1:`bad`,2:`fine`,3:`good`},zD=e=>LD.includes(e),BD=`How is Claude doing this session? (optional)`;function VD({onSelect:e,inputValue:t,setInputValue:n,message:r=BD}){return ID({inputValue:t,setInputValue:n,isValidDigit:zD,onDigit:t=>e(RD[t])}),(0,$.jsxs)(G,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(G,{children:[(0,$.jsx)(K,{color:`ansi:cyan`,children:`● `}),(0,$.jsx)(K,{bold:!0,children:r})]}),(0,$.jsxs)(G,{marginLeft:2,children:[(0,$.jsx)(G,{width:10,children:(0,$.jsxs)(K,{children:[(0,$.jsx)(K,{color:`ansi:cyan`,children:`1`}),`: Bad`]})}),(0,$.jsx)(G,{width:10,children:(0,$.jsxs)(K,{children:[(0,$.jsx)(K,{color:`ansi:cyan`,children:`2`}),`: Fine`]})}),(0,$.jsx)(G,{width:10,children:(0,$.jsxs)(K,{children:[(0,$.jsx)(K,{color:`ansi:cyan`,children:`3`}),`: Good`]})}),(0,$.jsx)(G,{children:(0,$.jsxs)(K,{children:[(0,$.jsx)(K,{color:`ansi:cyan`,children:`0`}),`: Dismiss`]})})]})]})}Id(),q(),Qf();function HD({isOpen:e,skillName:t,updates:n,handleSelect:r,inputValue:i,setInputValue:a}){return!e||i&&!zD(i)?null:(0,$.jsx)(GD,{skillName:t,updates:n,onSelect:r,inputValue:i,setInputValue:a})}var UD=[`0`,`1`];function WD(e){return UD.includes(e)}function GD({skillName:e,updates:t,onSelect:n,inputValue:r,setInputValue:i}){let a=(0,Q.useRef)(r);return(0,Q.useEffect)(()=>{if(r!==a.current){let e=ep(r.slice(-1));WD(e)&&(i(r.slice(0,-1)),n(e===`1`?`good`:`dismissed`))}},[r,n,i]),(0,$.jsxs)(G,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(G,{children:[(0,$.jsxs)(K,{color:`ansi:cyan`,children:[Ed,` `]}),(0,$.jsxs)(K,{bold:!0,children:[`Skill improvement suggested for "`,e,`"`]})]}),(0,$.jsx)(G,{flexDirection:`column`,marginLeft:2,children:t.map((e,t)=>(0,$.jsxs)(K,{dimColor:!0,children:[`∙`,` `,e.change]},t))}),(0,$.jsxs)(G,{marginLeft:2,marginTop:1,children:[(0,$.jsx)(G,{width:12,children:(0,$.jsxs)(K,{children:[(0,$.jsx)(K,{color:`ansi:cyan`,children:`1`}),`: Apply`]})}),(0,$.jsx)(G,{width:14,children:(0,$.jsxs)(K,{children:[(0,$.jsx)(K,{color:`ansi:cyan`,children:`0`}),`: Dismiss`]})})]})]})}If(),U(),P();function KD(e){let t=W(e=>e.skillImprovement.suggestion),n=Qo(),[r,i]=(0,Q.useState)(!1),a=(0,Q.useRef)(t),o=(0,Q.useRef)(!1);t&&(a.current=t),t&&!r&&(i(!0),o.current||(o.current=!0,X(`tengu_skill_improvement_survey`,{event_type:`appeared`,_PROTO_skill_name:t.skillName??`unknown`})));let s=(0,Q.useCallback)(t=>{let r=a.current;if(!r)return;let s=t!==`dismissed`;X(`tengu_skill_improvement_survey`,{event_type:`responded`,response:s?`applied`:`dismissed`,_PROTO_skill_name:r.skillName}),s&&Zg(r.skillName,r.updates).then(()=>{e(e=>[...e,gr(`Skill "${r.skillName}" updated with improvements.`,`suggestion`)])}),i(!1),o.current=!1,n(e=>e.skillImprovement.suggestion?{...e,skillImprovement:{suggestion:null}}:e)},[n,e]);return{isOpen:r,suggestion:a.current,handleSelect:s}}function qD(e){return{onBeforeQuery:async()=>!0,onTurnComplete:async()=>{},render:()=>null}}wr(),vc(),ns(),Ke();function JD(e){(0,Q.useEffect)(()=>{let t=()=>{Wa()&&process.stdout.write(`
77
- `+An()+`
78
- `),nn(e?.())};return process.on(`exit`,t),()=>{process.off(`exit`,t)}},[])}function YD(){(0,Q.useEffect)(()=>{},[])}function XD(e,t){let n=(0,Q.useRef)(e??null),r=(0,Q.useRef)(!e);return(0,Q.useEffect)(()=>{let e=n.current;if(!e)return;let i=!1;return e.then(e=>{i||(r.current=!0,n.current=null,e.length>0&&t(t=>[...e,...t]))}),()=>{i=!0}},[t]),(0,Q.useCallback)(async()=>{if(r.current||!n.current)return;let e=await n.current;r.current||(r.current=!0,n.current=null,e.length>0&&t(t=>[...e,...t]))},[t])}Ru(),h(),ip();function ZD(){let[e,t]=(0,Q.useState)(()=>{if(!dp()||lp())return`valid`;let{key:e,source:t}=pp({skipRetrievingKeyFromApiKeyHelper:!0});return e||t===`apiKeyHelper`?`loading`:`missing`}),[n,r]=(0,Q.useState)(null);return{status:e,reverify:(0,Q.useCallback)(async()=>{if(!dp()||lp()){t(`valid`);return}await ap(ad());let{key:e,source:n}=pp();if(!e){if(n===`apiKeyHelper`){t(`error`),r(Error(`API key helper did not return a valid key`));return}t(`missing`);return}try{let n=await tc(e,!1)?`valid`:`invalid`;t(n);return}catch(e){r(e),t(`error`);return}},[]),error:n}}Ru(),q(),sd(),bd(),q(),O(),If(),U();function QD({screen:e,setScreen:t,showAllInTranscript:n,setShowAllInTranscript:r,messageCount:i,onEnterTranscript:a,onExitTranscript:o,virtualScrollActive:s,searchBarOpen:c=!1}){let l=W(e=>e.expandedView),u=Qo(),d=(0,Q.useCallback)(()=>{X(`tengu_toggle_todos`,{is_expanded:l===`tasks`}),u(e=>({...e,expandedView:e.expandedView===`tasks`?`none`:`tasks`}))},[l,u]),f=(0,Q.useCallback)(()=>{let s=e!==`transcript`;X(`tengu_toggle_transcript`,{is_entering:s,show_all:n,message_count:i}),t(e=>e===`transcript`?`prompt`:`transcript`),r(!1),s&&a&&a(),!s&&o&&o()},[e,t,n,r,i,u,a,o]),p=(0,Q.useCallback)(()=>{X(`tengu_transcript_toggle_show_all`,{is_expanding:!n,message_count:i}),r(e=>!e)},[n,r,i]),m=(0,Q.useCallback)(()=>{X(`tengu_transcript_exit`,{show_all:n,message_count:i}),t(`prompt`),r(!1),o&&o()},[t,n,r,i,o]);Il(`app:toggleTodos`,d,{context:`Global`}),Il(`app:toggleTranscript`,f,{context:`Global`}),Il(`app:toggleTerminal`,(0,Q.useCallback)(()=>{},[]),{context:`Global`}),Il(`app:redraw`,(0,Q.useCallback)(()=>{Ml.get(process.stdout)?.forceRedraw()},[]),{context:`Global`});let h=e===`transcript`;return Il(`transcript:toggleShowAll`,p,{context:`Transcript`,isActive:h&&!s}),Il(`transcript:exit`,m,{context:`Transcript`,isActive:h&&!c}),null}fc(),_n(),O();var $D={setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}};function eO({onSubmit:e,isActive:t=!0}){let n=Bl(),r=hs(),i=(0,Q.useMemo)(()=>{if(!n)return new Set;let e=new Set;for(let t of n.bindings)t.action?.startsWith(`command:`)&&e.add(t.action);return e},[n]);return El((0,Q.useMemo)(()=>{let t={};for(let n of i){let r=n.slice(8);t[n]=()=>{e(`/${r}`,$D,void 0,{fromKeybinding:!0})}}return t},[i,e]),{context:`Chat`,isActive:t&&!r}),null}Bn(),If(),U(),yg(),Ot(),fc(),Le(),O(),le(),ps();var tO=3e3;function nO(e){let{setToolUseConfirmQueue:t,onCancel:n,onAgentsKilled:r,isMessageSelectorVisible:i,screen:a,abortSignal:o,popCommandFromQueue:s,vimMode:c,isLocalJSXCommand:l,isSearchingHistory:u,isHelpOpen:d,inputMode:f,inputValue:p,streamMode:m}=e,h=xa(),g=Qo(),_=VS().length,{addNotification:v,removeNotification:y}=ki(),b=(0,Q.useRef)(0),x=(0,Q.useCallback)(()=>{let e={source:`escape`,streamMode:m};if(o!==void 0&&!o.aborted){X(`tengu_cancel`,e),t(()=>[]),n();return}if(Fs()&&s){s();return}X(`tengu_cancel`,e),t(()=>[]),n()},[o,s,t,n,m]),S=Xs(),C=o!==void 0&&!o.aborted,w=_>0,T=f!==void 0&&f!==`prompt`&&!p,E=a!==`transcript`&&!u&&!i&&!l&&!d&&!S&&!(gg()&&c===`INSERT`),D=E&&(C||w)&&!T,O=E&&(C||w);Il(`chat:cancel`,x,{context:`Chat`,isActive:D});let k=(0,Q.useCallback)(()=>{let e=h.getState().tasks,t=Object.entries(e).filter(([,e])=>e.type===`local_agent`&&e.status===`running`);if(t.length===0)return!1;dt(e,g);let n=[];for(let[e,r]of t)Br(e,g),n.push(r.description),lm(e,`stopped`,{toolUseId:r.toolUseId,summary:r.description});return Ta({value:n.length===1?`Background agent "${n[0]}" was stopped by the user.`:`${n.length} background agents were stopped by the user: ${n.map(e=>`"${e}"`).join(`, `)}.`,mode:`task-notification`}),r(),!0},[h,g,r]);return Il(`app:interrupt`,(0,Q.useCallback)(()=>{(C||w)&&x()},[C,w,x]),{context:`Global`,isActive:O}),Il(`chat:killAgents`,(0,Q.useCallback)(()=>{let e=h.getState().tasks;if(!Object.values(e).some(e=>e.type===`local_agent`&&e.status===`running`)){v({key:`kill-agents-none`,text:`No background agents running`,priority:`immediate`,timeoutMs:2e3});return}let t=Date.now();if(t-b.current<=tO){b.current=0,y(`kill-agents-confirm`),X(`tengu_cancel`,{source:`kill_agents`}),Ao(),k();return}b.current=t;let n=Hn(`chat:killAgents`,`Chat`,`ctrl+x ctrl+k`);v({key:`kill-agents-confirm`,text:`Press ${n} again to stop background agents`,priority:`immediate`,timeoutMs:tO})},[h,v,y,k]),{context:`Chat`}),null}q(),U(),re();function rO(e){let t=W(e=>e.tasks),n=W(e=>e.pipeIpc),r=Object.values(t).some(qr),i=t=>{if(t.shift&&(t.key===`up`||t.key===`down`)){t.preventDefault(),r?e?.onOpenBackgroundTasks?.():t.key===`down`&&n?.statusVisible&&e?.onTogglePipeSelector&&e.onTogglePipeSelector();return}};return Xl((e,t,n)=>{i(new Fl(n.keypress))}),{handleKeyDown:i}}xg(),Ef();async function iO(e){let{ctx:t,updatedInput:n,suggestions:r,permissionMode:i}=e;try{let e=await t.runHooks(i,r,n);if(e)return e}catch(e){e instanceof Error?Y(e):Y(Error(`Automated permission check failed: ${String(e)}`))}return null}var aO=new Map,oO=null;function sO(){return oO??null}function cO(e,t){let n=sO();if(!n)return null;let r=d_(),i={requestId:r,toolName:e.tool.name,toolUseID:e.toolUseID,description:e.description,input:e.input,permissionResult:e.permissionResult,permissionPromptStartTimeMs:e.permissionPromptStartTimeMs};return aO.set(r,{onResponse:t}),n({type:`permission_request`,data:JSON.stringify(i)}),r}function lO(e){e&&aO.delete(e)}function uO(e,t){if(!e)return;let n=sO();n&&n({type:`permission_cancel`,data:JSON.stringify({requestId:e,reason:t})})}If(),Tm(),bi(),bd(),Lc(),P(),dc(),Ns();function dO(e){let t=!1,n=!1;return{resolve(r){n||(n=!0,t=!0,e(r))},isResolved(){return t},claim(){return t?!1:(t=!0,!0)}}}function fO(e,t,n,r,i,a,o){let s=r.message.id;return Object.freeze({tool:e,input:t,toolUseContext:n,assistantMessage:r,messageId:s,toolUseID:i,logDecision(r,a){ds({tool:e,input:a?.input??t,toolUseContext:n,messageId:s,toolUseID:i},r,a?.permissionPromptStartTimeMs)},logCancelled(){X(`tengu_tool_use_cancelled`,{messageID:s,toolName:Em(e.name)})},async persistPermissions(e){return e.length===0?!1:(qs(e),a(y(n.getAppState().toolPermissionContext,e)),e.some(e=>bo(e.destination)))},resolveIfAborted(e){return n.abortController.signal.aborted?(this.logCancelled(),e(this.cancelAndAbort(void 0,!0)),!0):!1},cancelAndAbort(t,r,i){let a=!!n.agentId,o=t?`${a?wc:ya}${t}`:a?Yo:rc,s=a?o:gc(o);return(r||!t&&!i?.length&&!a)&&(J(`Aborting: tool=${e.name} isAbort=${r} hasFeedback=${!!t} isSubagent=${a}`),n.abortController.abort()),{behavior:`ask`,message:s,contentBlocks:i}},async runHooks(r,a,o,s){for await(let c of fi(e.name,i,t,n,r,a,n.abortController.signal))if(c.permissionRequestResult){let r=c.permissionRequestResult;if(r.behavior===`allow`){let e=r.updatedInput??o??t;return await this.handleHookAllow(e,r.updatedPermissions??[],s)}else if(r.behavior===`deny`)return this.logDecision({decision:`reject`,source:{type:`hook`}},{permissionPromptStartTimeMs:s}),r.interrupt&&(J(`Hook interrupt: tool=${e.name} hookMessage=${r.message}`),n.abortController.abort()),this.buildDeny(r.message||`Permission denied by hook`,{type:`hook`,hookName:`PermissionRequest`,reason:r.message})}return null},buildAllow(e,t){return{behavior:`allow`,updatedInput:e,userModified:t?.userModified??!1,...t?.decisionReason&&{decisionReason:t.decisionReason},...t?.acceptFeedback&&{acceptFeedback:t.acceptFeedback},...t?.contentBlocks&&t.contentBlocks.length>0&&{contentBlocks:t.contentBlocks}}},buildDeny(e,t){return{behavior:`deny`,message:e,decisionReason:t}},async handleUserAllow(n,r,i,a,o,s){let c=await this.persistPermissions(r);this.logDecision({decision:`accept`,source:{type:`user`,permanent:c}},{input:n,permissionPromptStartTimeMs:a});let l=e.inputsEquivalent?!e.inputsEquivalent(t,n):!1,u=i?.trim();return this.buildAllow(n,{userModified:l,decisionReason:s,acceptFeedback:u||void 0,contentBlocks:o})},async handleHookAllow(e,t,n){let r=await this.persistPermissions(t);return this.logDecision({decision:`accept`,source:{type:`hook`,permanent:r}},{input:e,permissionPromptStartTimeMs:n}),this.buildAllow(e,{decisionReason:{type:`hook`,hookName:`PermissionRequest`}})},pushToQueue(e){o?.push(e)},removeFromQueue(){o?.remove(i)},updateQueueItem(e){o?.update(i,e)}})}function pO(e){return{push(t){e(e=>[...e,t])},remove(t){e(e=>e.filter(e=>e.toolUseID!==t))},update(t,n){e(e=>e.map(e=>e.toolUseID===t?{...e,...n}:e))}}}bd(),q(),bi(),$e(),pd();function mO(e,t){let{ctx:n,description:r,result:i,awaitAutomatedChecksBeforeDialog:a,bridgeCallbacks:o}=e,{resolve:s,isResolved:c,claim:l}=dO(t),u,d,f=o?d_():void 0,p=Date.now(),m=i.updatedInput??n.input,h=null;function g(e){uO(h,e),lO(h),h=null}function _(){lO(h),h=null}let v={assistantMessage:n.assistantMessage,tool:n.tool,description:r,input:m,toolUseContext:n.toolUseContext,toolUseID:n.toolUseID,permissionResult:i,permissionPromptStartTimeMs:p,onUserInteraction(){Date.now()-p<200||li(n.toolUseID)},onDismissCheckmark(){u&&(clearTimeout(u),u=void 0,d&&(n.toolUseContext.abortController.signal.removeEventListener(`abort`,d),d=void 0),n.removeFromQueue())},onAbort(){l()&&(g(`Permission request was aborted locally in sub.`),o&&f&&(o.sendResponse(f,{behavior:`deny`,message:`User aborted`}),o.cancelRequest(f)),n.logCancelled(),n.logDecision({decision:`reject`,source:{type:`user_abort`}},{permissionPromptStartTimeMs:p}),s(n.cancelAndAbort(void 0,!0)))},async onAllow(e,t,r,a){l()&&(g(`Permission request was approved locally in sub.`),o&&f&&(o.sendResponse(f,{behavior:`allow`,updatedInput:e,updatedPermissions:t}),o.cancelRequest(f)),s(await n.handleUserAllow(e,t,r,p,a,i.decisionReason)))},onReject(e,t){l()&&(g(`Permission request was rejected locally in sub.`),o&&f&&(o.sendResponse(f,{behavior:`deny`,message:e??`User denied permission`}),o.cancelRequest(f)),n.logDecision({decision:`reject`,source:{type:`user_reject`,hasFeedback:!!e}},{permissionPromptStartTimeMs:p}),s(n.cancelAndAbort(e,void 0,t)))},async recheckPermission(){if(c())return;let e=await Nr(n.tool,n.input,n.toolUseContext,n.assistantMessage,n.toolUseID);if(e.behavior===`allow`){if(!l())return;g(`Permission request was resolved locally in sub.`),o&&f&&o.cancelRequest(f),n.removeFromQueue(),n.logDecision({decision:`accept`,source:`config`}),s(n.buildAllow(e.updatedInput??n.input))}}};if(n.pushToQueue(v),h=cO(v,e=>{l()&&(_(),li(n.toolUseID),n.removeFromQueue(),o&&f&&o.cancelRequest(f),e.behavior===`allow`?(async()=>{e.permissionUpdates?.length&&n.persistPermissions(e.permissionUpdates),n.logDecision({decision:`accept`,source:{type:`user`,permanent:!!e.permissionUpdates?.length}},{permissionPromptStartTimeMs:p}),s(n.buildAllow(e.updatedInput??m,{acceptFeedback:e.feedback,contentBlocks:e.contentBlocks}))})():(n.logDecision({decision:`reject`,source:{type:`user_reject`,hasFeedback:!!e.feedback}},{permissionPromptStartTimeMs:p}),s(n.cancelAndAbort(e.feedback,void 0,e.contentBlocks))))}),o&&f){o.sendRequest(f,n.tool.name,m,n.toolUseID,r,i.suggestions,i.blockedPath);let e=n.toolUseContext.abortController.signal,t=o.onResponse(f,r=>{l()&&(g(`Permission request was resolved by bridge before pipe response.`),e.removeEventListener(`abort`,t),li(n.toolUseID),n.removeFromQueue(),r.behavior===`allow`?(r.updatedPermissions?.length&&n.persistPermissions(r.updatedPermissions),n.logDecision({decision:`accept`,source:{type:`user`,permanent:!!r.updatedPermissions?.length}},{permissionPromptStartTimeMs:p}),s(n.buildAllow(r.updatedInput??m))):(n.logDecision({decision:`reject`,source:{type:`user_reject`,hasFeedback:!!r.message}},{permissionPromptStartTimeMs:p}),s(n.cancelAndAbort(r.message))))});e.addEventListener(`abort`,t,{once:!0})}a||(async()=>{if(c())return;let e=n.toolUseContext.getAppState(),t=await n.runHooks(e.toolPermissionContext.mode,i.suggestions,i.updatedInput,p);!t||!l()||(g(`Permission request was resolved by hook before pipe response.`),o&&f&&o.cancelRequest(f),n.removeFromQueue(),s(t))})()}q(),bi(),$e(),bd(),pd(),Ef(),ti(),Ns();function hO(e,t){return(0,Q.useCallback)(async(n,r,i,a,o,s)=>new Promise(c=>{let l=fO(n,r,i,a,o,t,pO(e));if(!l.resolveIfAborted(c))return(s===void 0?Nr(n,r,i,a,o):Promise.resolve(s)).then(async e=>{if(e.behavior===`allow`){if(l.resolveIfAborted(c))return;e.decisionReason?.type===`classifier`&&e.decisionReason.classifier===`auto-mode`&&Vt(o,e.decisionReason.reason),l.logDecision({decision:`accept`,source:`config`}),c(l.buildAllow(e.updatedInput??r,{decisionReason:e.decisionReason}));return}let t=i.getAppState(),a=await n.description(r,{isNonInteractiveSession:i.options.isNonInteractiveSession,toolPermissionContext:t.toolPermissionContext,tools:i.options.tools});if(!l.resolveIfAborted(c))switch(e.behavior){case`deny`:ds({tool:n,input:r,toolUseContext:i,messageId:l.messageId,toolUseID:o},{decision:`reject`,source:`config`}),e.decisionReason?.type===`classifier`&&e.decisionReason.classifier===`auto-mode`&&(Sg({toolName:n.name,display:a,reason:e.decisionReason.reason??``,timestamp:Date.now()}),i.addNotification?.({key:`auto-mode-denied`,priority:`immediate`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(K,{color:`error`,children:[n.userFacingName(r).toLowerCase(),` denied by auto mode`]}),(0,$.jsx)(K,{dimColor:!0,children:` · /permissions`})]})})),c(e);return;case`ask`:if(t.toolPermissionContext.awaitAutomatedChecksBeforeDialog){let n=await iO({ctx:l,updatedInput:e.updatedInput,suggestions:e.suggestions,permissionMode:t.toolPermissionContext.mode});if(n){c(n);return}}if(l.resolveIfAborted(c))return;mO({ctx:l,description:a,result:e,awaitAutomatedChecksBeforeDialog:t.toolPermissionContext.awaitAutomatedChecksBeforeDialog,bridgeCallbacks:void 0},c);return}}).catch(e=>{e instanceof dd||e instanceof _d?(J(`Permission check threw ${e.constructor.name} for tool=${n.name}: ${e.message}`),l.logCancelled(),c(l.cancelAndAbort(void 0,!0))):(Y(e),c(l.cancelAndAbort(void 0,!0)))}).finally(()=>{li(o)})}),[e,t])}mm(),If(),ae(),Wn(),sd(),bd(),nr(),pd(),Ef(),ps(),vp();function gO(){Ri(0)}async function _O(e){let{helpers:t,queryGuard:n,isExternalLoading:r=!1,commands:i,onInputChange:a,setPastedContents:o,setToolJSX:s,getToolUseContext:c,messages:l,mainLoopModel:u,ideSelection:d,setUserInputOnProcessing:f,setAbortController:p,onQuery:m,setAppState:h,onBeforeQuery:g,canUseTool:_,queuedCommands:v,uuid:y,skipSlashCommands:b,bridgeOrigin:x}=e,{setCursorOffset:S,clearBuffer:C,resetHistory:w}=t;if(v?.length){Dt(),await vO({queuedCommands:v,messages:l,mainLoopModel:u,ideSelection:d,querySource:e.querySource,commands:i,queryGuard:n,setToolJSX:s,getToolUseContext:c,setUserInputOnProcessing:f,setAbortController:p,onQuery:m,setAppState:h,onBeforeQuery:g,resetHistory:w,canUseTool:_,onInputChange:a});return}let T=e.input??``,E=e.mode??`prompt`,D=e.pastedContents??{},O=new Set(_t(T).map(e=>e.id)),k=Object.fromEntries(Object.entries(D).filter(([,e])=>e.type!==`image`||O.has(e.id))),A=Object.values(k).some(or);if(T.trim()===``)return;if(!b&&[`exit`,`quit`,`:q`,`:q!`,`:wq`,`:wq!`].includes(T.trim())){i.find(e=>e.name===`exit`)?_O({...e,input:`/exit`}):gO();return}let ee=Ho(T,k),j=_t(T).filter(e=>k[e.id]?.type===`text`),te=j.length;if(X(`tengu_paste_text`,{pastedTextCount:te,pastedTextBytes:j.reduce((e,t)=>e+(k[t.id]?.content.length??0),0)}),!b&&ee.trim().startsWith(`/`)){let t=ee.trim(),d=t.indexOf(` `),f=d===-1?t.slice(1):t.slice(1,d),p=d===-1?``:t.slice(d+1).trim(),m=i.find(e=>e.immediate&&si(e)&&(e.name===f||e.aliases?.includes(f)||ct(e)===f));if(m&&m.type===`local-jsx`&&(n.isActive||r)){X(`tengu_immediate_command_executed`,{commandName:m.name}),a(``),S(0),o({}),C();let t=c(l,[],Ua(),u),n=!1,r=await(await m.load()).call((t,r)=>{n=!0,s({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0}),t&&r?.display!==`skip`&&e.addNotification&&e.addNotification({key:`immediate-${m.name}`,text:t,priority:`immediate`}),r?.nextInput&&(r.submitNextInput?uc({value:r.nextInput,mode:`prompt`}):a(r.nextInput))},t,p);r&&!n&&s({jsx:r,shouldHidePromptInput:!1,isLocalJSXCommand:!0,isImmediate:!0});return}}if(n.isActive||r){if(E!==`prompt`&&E!==`bash`)return;e.hasInterruptibleToolInProgress&&(J(`[interrupt] Aborting current turn: streamMode=${e.streamMode}`),X(`tengu_cancel`,{source:`interrupt_on_submit`,streamMode:e.streamMode}),e.abortController?.abort(`interrupt`)),uc({value:ee.trim(),preExpansionValue:T.trim(),mode:E,pastedContents:A?k:void 0,skipSlashCommands:b,bridgeOrigin:x,uuid:y}),a(``),S(0),o({}),w(),C();return}Dt(),await vO({queuedCommands:[{value:ee,preExpansionValue:T,mode:E,pastedContents:A?k:void 0,skipSlashCommands:b,bridgeOrigin:x,uuid:y}],messages:l,mainLoopModel:u,ideSelection:d,querySource:e.querySource,commands:i,queryGuard:n,setToolJSX:s,getToolUseContext:c,setUserInputOnProcessing:f,setAbortController:p,onQuery:m,setAppState:h,onBeforeQuery:g,resetHistory:w,canUseTool:_,onInputChange:a})}async function vO(e){let{messages:t,mainLoopModel:n,ideSelection:r,querySource:i,queryGuard:a,setToolJSX:o,getToolUseContext:s,setUserInputOnProcessing:c,setAbortController:l,onQuery:u,setAppState:d,onBeforeQuery:f,resetHistory:p,canUseTool:m,queuedCommands:h}=e,g=Ua();l(g);function _(){return s(t,[],g,n)}try{a.reserve(),Rs(`query_process_user_input_start`);let s=[],v=!1,y,b,x,S,C=h??[],w=await Ar(C);C=w.attachmentCommands;let T=w.claimedCommands;if(C.length===0){l(null);return}let E=C[0]?.workload,D=E!==void 0&&C.every(e=>e.workload===E)?E:void 0,O=new Set,k;try{await Tp(D,async()=>{for(let e=0;e<C.length;e++){let n=C[e],a=e===0,l=n.autonomy?.runId,u=await ah({input:n.value,preExpansionInput:n.preExpansionValue,mode:n.mode,setToolJSX:o,context:_(),pastedContents:a?n.pastedContents:void 0,messages:t,setUserInputOnProcessing:a?c:void 0,isAlreadyProcessing:!a,querySource:i,canUseTool:m,uuid:n.uuid,ideSelection:a?r:void 0,skipSlashCommands:n.skipSlashCommands,bridgeOrigin:n.bridgeOrigin,isMeta:n.isMeta,skipAttachments:!a,autonomy:n.autonomy});l&&u.deferAutonomyCompletion&&O.add(l);let d=n.origin??(n.mode===`task-notification`?{kind:`task-notification`}:void 0);if(d)for(let e of u.messages)e.type===`user`&&(e.origin=d);s.push(...u.messages),a&&(v=u.shouldQuery,y=u.allowedTools,b=u.model,x=u.nextInput,S=u.submitNextInput)}if(Rs(`query_process_user_input_end`),Kc()&&(Rs(`query_file_history_snapshot_start`),s.filter(rh).forEach(e=>{Se(e=>{d(t=>({...t,fileHistory:e(t.fileHistory)}))},e.uuid)}),Rs(`query_file_history_snapshot_end`)),s.length){p(),o({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0});let e=C[0],t=e?.mode??`prompt`,r=e&&typeof e.value==`string`?e.value:void 0,i=t===`prompt`;await u(s,g,v,y??[],b?op(b,n):n,i?f:void 0,r)}else a.cancelReservation(),o({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0}),p(),l(null);x&&(S?uc({value:x,mode:`prompt`}):e.onInputChange(x))})}catch(e){k=e}if(T.length){let e=T.filter(e=>{let t=e.autonomy?.runId;return!t||!O.has(t)});if(k)try{await Me({commands:e,outcome:{type:`failed`,error:k},currentDir:cd(),priority:`later`,workload:D})}catch(e){Y(hd(e))}else try{let t=await Me({commands:e,outcome:{type:`completed`},currentDir:cd(),priority:`later`,workload:D});for(let e of t)uc(e)}catch(e){Y(hd(e))}}if(k)throw k}finally{a.cancelReservation(),c(void 0)}}ps();function yO(e){if(typeof e.value==`string`)return e.value.trim().startsWith(`/`)&&(!e.skipSlashCommands||e.bridgeOrigin===!0);for(let t of e.value)if(t.type===`text`)return t.text.trim().startsWith(`/`)&&(!e.skipSlashCommands||e.bridgeOrigin===!0);return!1}function bO({executeInput:e}){let t=e=>e.agentId===void 0,n=Qi(t);if(!n)return{processed:!1};if(yO(n)||n.mode===`bash`)return e([ua(t)]),{processed:!0};let r=n.mode,i=Es(e=>t(e)&&!yO(e)&&e.mode===r);return i.length===0?{processed:!1}:(e(i),{processed:!0})}ps();function xO({executeQueuedInput:e,hasActiveLocalJsxUI:t,queryGuard:n}){let r=(0,Q.useSyncExternalStore)(n.subscribe,n.getSnapshot),i=(0,Q.useSyncExternalStore)(va,Na);(0,Q.useEffect)(()=>{r||t||i.length!==0&&bO({executeInput:e})},[i,r,e,t,n])}function SO({isLoading:e,onSubmitMessage:t}){let n=po();(0,Q.useEffect)(()=>{if(e)return;let r=n.poll();r&&t(r.content)},[e,(0,Q.useSyncExternalStore)((0,Q.useMemo)(()=>n.subscribe.bind(n),[n]),(0,Q.useCallback)(()=>n.revision,[n])),n,t])}function CO(e,t){return e&&t&&t.length>0?vn([...e,...t],`name`):e||[]}function wO(e,t){return(0,Q.useMemo)(()=>CO(e,t),[e,t])}Xa(),nh(),Nh(),on();function TO(e,t){return(0,Q.useMemo)(()=>t.length>0?vn([...e,...t],`name`):e,[e,t])}ae(),Ef();function EO(e,t){let n=(0,Q.useCallback)(async()=>{if(e)try{te(),t(await Ve(e))}catch(e){e instanceof Error&&Y(e)}},[e,t]);(0,Q.useEffect)(()=>xh.subscribe(n),[n])}Ef(),Su(),Uc(),Cu();var DO=xu(()=>bu({method:_u(`selection_changed`),params:bu({selection:bu({start:bu({line:mu(),character:mu()}),end:bu({line:mu(),character:mu()})}).nullable().optional(),text:pu().optional(),filePath:pu().optional()})}));function OO(e,t){let n=(0,Q.useRef)(!1),r=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{let i=ol(e);if(r.current!==(i??null)&&(n.current=!1,r.current=i||null,t({lineCount:0,lineStart:void 0,text:void 0,filePath:void 0})),n.current||!i)return;let a=e=>{if(e.selection?.start&&e.selection?.end){let{start:n,end:r}=e.selection,i=r.line-n.line+1;r.character===0&&i--,t({lineCount:i,lineStart:n.line,text:e.text,filePath:e.filePath})}};i.client.setNotificationHandler(DO(),e=>{if(r.current===i)try{let t=e.params;t.selection&&t.selection.start&&t.selection.end?a(t):t.text!==void 0&&a({selection:null,text:t.text,filePath:t.filePath})}catch(e){Y(e)}}),n.current=!0},[e,t])}qn(),Ut(),_e(),q(),Lg(),U(),Kf();function kO({task:e,selected:t}){let n=Bg(e.startTime,e.status===`running`),r=e.progress?.tokenCount??0;return(0,$.jsxs)(G,{flexDirection:`row`,width:`100%`,justifyContent:`space-between`,children:[(0,$.jsxs)(G,{flexDirection:`row`,flexShrink:1,children:[(0,$.jsx)(K,{color:e.status===`running`?`success`:void 0,children:t?`● `:`○ `}),(0,$.jsxs)(K,{bold:t,wrap:`truncate-end`,children:[e.agentType,` `,(0,$.jsx)(K,{dimColor:!0,children:e.description})]})]}),(0,$.jsx)(G,{flexShrink:0,children:(0,$.jsxs)(K,{dimColor:!0,children:[n,` · ↓ `,Hf(r),` tokens`]})})]})}function AO(e,t){return e?`↑/↓ to select · Enter to view`:t?t.status===`running`?`shift+↓ to manage · x to stop`:`shift+↓ to manage · x to clear`:`shift+↓ to manage background agents`}function jO(){let e=oC(),t=W(e=>e.viewingAgentTaskId),n=W(e=>e.footerSelection),r=W(e=>e.selectedBgAgentIndex);if(e.length===0)return null;let i=n===`bg_agent`,a=i?r===-1?null:e[r]?.agentId??null:t??null,o=i?r===-1:t===void 0,s=t?e.find(e=>e.agentId===t)??null:null;return(0,$.jsxs)(G,{flexDirection:`column`,width:`100%`,children:[(0,$.jsxs)(G,{flexDirection:`row`,width:`100%`,justifyContent:`space-between`,children:[(0,$.jsxs)(K,{bold:o,children:[o?`● `:`○ `,`main`]}),(0,$.jsx)(K,{dimColor:!0,children:AO(i,s)})]}),e.map(e=>(0,$.jsx)(kO,{task:e,selected:e.agentId===a},e.agentId))]})}lf(),s(),Uc();function MO({autoConnectIdeFlag:e,ideToInstallExtension:t,setDynamicMcpConfig:n,setShowIdeOnboarding:r,setIDEInstallationState:a}){(0,Q.useEffect)(()=>{function s(r){r&&(cf().autoConnectIde||e||Mn()||process.env.CLAUDE_CODE_SSE_PORT||t||o(process.env.CLAUDE_CODE_AUTO_CONNECT_IDE))&&!i(process.env.CLAUDE_CODE_AUTO_CONNECT_IDE)&&n(e=>e?.ide?e:{...e,ide:{type:r.url.startsWith(`ws:`)?`ws-ide`:`sse-ide`,url:r.url,ideName:r.name,authToken:r.authToken,ideRunningInWindows:r.ideRunningInWindows,scope:`dynamic`}})}Or(s,t,()=>r(!0),e=>a(e))},[e,t,n,r,a])}og(),fo(),q(),O(),Mo(),U(),lf(),Rd(),s();function NO({onBackgroundSession:e,isLoading:t}){let n=Qo(),r=xa(),[i,a]=(0,Q.useState)(!1),s=Jl(a,e,()=>{}),c=(0,Q.useCallback)(()=>{o(process.env.CLAUDE_CODE_DISABLE_BACKGROUND_TASKS)||(hl(r.getState())?(ur(()=>r.getState(),n),cf().hasUsedBackgroundTask||df(e=>e.hasUsedBackgroundTask?e:{...e,hasUsedBackgroundTask:!0})):o(`false`)&&t&&s())},[n,r,t,s]),l=W(hl),u=o(`false`);Il(`task:background`,c,{context:`Task`,isActive:l||u&&t});let d=an(`task:background`,`Task`,`ctrl+b`),f=Od.terminal===`tmux`&&d===`ctrl+b`?`ctrl+b ctrl+b`:d;return!t||!i?null:(0,$.jsx)(G,{paddingLeft:2,children:(0,$.jsx)(K,{dimColor:!0,children:(0,$.jsx)(Cl,{shortcut:f,action:`background`})})})}U();function PO({setMessages:e,setIsLoading:t,resetLoadingState:n,setAbortController:r,onBackgroundQuery:i}){let a=W(e=>e.foregroundedTaskId),o=W(e=>e.foregroundedTaskId?e.tasks[e.foregroundedTaskId]:void 0),s=Qo(),c=(0,Q.useRef)(0),l=(0,Q.useCallback)(()=>{if(a){s(e=>{let t=e.foregroundedTaskId;if(!t)return e;let n=e.tasks[t];return n?{...e,foregroundedTaskId:void 0,tasks:{...e.tasks,[t]:{...n,isBackgrounded:!0}}}:{...e,foregroundedTaskId:void 0}}),e([]),n(),r(null);return}i()},[a,s,e,n,r,i]);return(0,Q.useEffect)(()=>{if(!a){c.current=0;return}if(!o||o.type!==`local_agent`){s(e=>({...e,foregroundedTaskId:void 0})),n(),c.current=0;return}let i=o.messages??[];if(i.length!==c.current&&(c.current=i.length,e([...i])),o.status===`running`){let e=o.abortController;if(e?.signal.aborted){s(e=>{if(!e.foregroundedTaskId)return e;let t=e.tasks[e.foregroundedTaskId];return t?{...e,foregroundedTaskId:void 0,tasks:{...e.tasks,[e.foregroundedTaskId]:{...t,isBackgrounded:!0}}}:{...e,foregroundedTaskId:void 0}}),n(),r(null),c.current=0;return}t(!0),e&&r(e)}else s(e=>{let t=e.foregroundedTaskId;if(!t)return e;let n=e.tasks[t];return n?{...e,foregroundedTaskId:void 0,tasks:{...e.tasks,[t]:{...n,isBackgrounded:!0}}}:{...e,foregroundedTaskId:void 0}}),n(),r(null),c.current=0},[a,o,s,e,t,n,r]),{handleBackgroundSession:l}}Un(),q(),ip(),lf(),ar(),pg();function FO({onDone:e}){let t=(0,Q.useRef)(e);t.current=e;let n=(0,Q.useCallback)(()=>{t.current(`dismiss`)},[]);(0,Q.useEffect)(()=>{df(e=>e.remoteDialogSeen?e:{...e,remoteDialogSeen:!0})},[]);let r=(0,Q.useCallback)(e=>{t.current(e)},[]);return(0,$.jsx)(hg,{title:`Remote Control`,children:(0,$.jsxs)(G,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsxs)(G,{marginBottom:1,flexDirection:`column`,children:[(0,$.jsx)(K,{children:`Remote Control lets you access this CLI session from the web (claude.ai/code) or the Claude app, so you can pick up where you left off on any device.`}),(0,$.jsx)(K,{children:` `}),(0,$.jsx)(K,{children:`You can disconnect remote access anytime by running /remote-control again.`})]}),(0,$.jsx)(G,{children:(0,$.jsx)(Hi,{options:[{label:`Enable Remote Control for this session`,description:`Opens a secure connection to claude.ai.`,value:`enable`},{label:`Never mind`,description:`You can always enable it later with /remote-control.`,value:`dismiss`}],onChange:r,onCancel:n})})]})})}$m();function IO(e,t){return t}oc(),Ru(),P(),ht(),q(),O(),h(),ip(),fa(),bd(),Rd(),_f(),Ef(),he(),wd(),ys(),fn(),ba();function LO(e){let t=e;return t=t.replace(/"(sk-ant[^\s"']{24,})"/g,`"[REDACTED_API_KEY]"`),t=t.replace(/(?<![A-Za-z0-9"'])(sk-ant-?[A-Za-z0-9_-]{10,})(?![A-Za-z0-9"'])/g,`[REDACTED_API_KEY]`),t=t.replace(/AWS key: "(AWS[A-Z0-9]{20,})"/g,`AWS key: "[REDACTED_AWS_KEY]"`),t=t.replace(/(AKIA[A-Z0-9]{16})/g,`[REDACTED_AWS_KEY]`),t=t.replace(/(?<![A-Za-z0-9])(AIza[A-Za-z0-9_-]{35})(?![A-Za-z0-9])/g,`[REDACTED_GCP_KEY]`),t=t.replace(/(?<![A-Za-z0-9])([a-z0-9-]+@[a-z0-9-]+\.iam\.gserviceaccount\.com)(?![A-Za-z0-9])/g,`[REDACTED_GCP_SERVICE_ACCOUNT]`),t=t.replace(/(["']?x-api-key["']?\s*[:=]\s*["']?)[^"',\s)}\]]+/gi,`$1[REDACTED_API_KEY]`),t=t.replace(/(["']?authorization["']?\s*[:=]\s*["']?(bearer\s+)?)[^"',\s)}\]]+/gi,`$1[REDACTED_TOKEN]`),t=t.replace(/(AWS[_-][A-Za-z0-9_]+\s*[=:]\s*)["']?[^"',\s)}\]]+["']?/gi,`$1[REDACTED_AWS_VALUE]`),t=t.replace(/(GOOGLE[_-][A-Za-z0-9_]+\s*[=:]\s*)["']?[^"',\s)}\]]+["']?/gi,`$1[REDACTED_GCP_VALUE]`),t=t.replace(/((API[-_]?KEY|TOKEN|SECRET|PASSWORD)\s*[=:]\s*)["']?[^"',\s)}\]]+["']?/gi,`$1[REDACTED]`),t}m(),ip(),bd(),pd(),kp(),P(),he(),wd();async function RO(e,t,n){try{J(`Collecting transcript for sharing`,{level:`info`});let r=Oi(e),i=await ce(x(e)),a;try{let e=zc(),{size:t}=await m_(e);t<=52428800?a=await f_(e,`utf-8`):J(`Skipping raw transcript read: file too large (${t} bytes)`,{level:`warn`})}catch{}let o=LO(ud({trigger:t,version:`0.0.12`,platform:process.platform,transcript:r,subagentTranscripts:Object.keys(i).length>0?i:void 0,rawTranscriptJsonl:a}));await Op();let s=tp();if(s.error)return{success:!1};let c={"Content-Type":`application/json`,"User-Agent":Fp(),...s.headers},l=await p.post(`https://api.anthropic.com/api/claude_code_shared_session_transcripts`,{content:o,appearance_id:n},{headers:c,timeout:3e4});if(l.status===200||l.status===201){let e=l.data;return J(`Transcript shared successfully`,{level:`info`}),{success:!0,transcriptId:e?.transcript_id}}return{success:!1}}catch(e){return J(fd(e),{level:`error`}),{success:!1}}}function zO({hideThanksAfterMs:e,onOpen:t,onSelect:n,shouldShowTranscriptPrompt:r,onTranscriptPromptShown:i,onTranscriptSelect:a}){let[o,s]=(0,Q.useState)(`closed`),[c,l]=(0,Q.useState)(null),u=(0,Q.useRef)(d_()),d=(0,Q.useRef)(null),f=(0,Q.useCallback)(()=>{s(`thanks`),setTimeout((e,t)=>{e(`closed`),t(null)},e,s,l)},[e]),p=(0,Q.useCallback)(()=>{s(`submitted`),setTimeout(s,e,`closed`)},[e]);return{state:o,lastResponse:c,open:(0,Q.useCallback)(()=>{o===`closed`&&(s(`open`),u.current=d_(),t(u.current))},[o,t]),handleSelect:(0,Q.useCallback)(e=>{if(l(e),d.current=e,n(u.current,e),e===`dismissed`)s(`closed`),l(null);else if(r?.(e))return s(`transcript_prompt`),i?.(u.current,e),!0;else f();return!1},[f,n,r,i]),handleTranscriptSelect:(0,Q.useCallback)(e=>{switch(e){case`yes`:s(`submitting`),(async()=>{try{await a?.(u.current,e,d.current)?p():f()}catch{f()}})();break;case`no`:case`dont_ask_again`:a?.(u.current,e,d.current),f();break}},[f,p,a])}}If(),lf(),s(),P(),vp(),Ud();var BO={minTimeBeforeFeedbackMs:6e5,minTimeBetweenFeedbackMs:36e5,minTimeBetweenGlobalFeedbackMs:1e8,minUserTurnsBeforeFeedback:5,minUserTurnsBetweenFeedback:10,hideThanksAfterMs:3e3,onForModels:[`*`],probability:.005},VO={probability:0};function HO(e,t,n,r=`session`,i=!1){let a=(0,Q.useRef)(`unknown`);a.current=No(e)?.message?.id||`unknown`;let[s,c]=(0,Q.useState)(()=>({timeLastShown:null,submitCountAtLastAppearance:null})),l=IO(`tengu_feedback_survey_config`,BO),u=IO(`tengu_bad_survey_transcript_ask_config`,VO),d=IO(`tengu_good_survey_transcript_ask_config`,VO),f=qd().feedbackSurveyRate,p=(0,Q.useRef)(Date.now()),m=(0,Q.useRef)(n),h=(0,Q.useRef)(n);h.current=n;let g=(0,Q.useRef)(e);g.current=e;let _=(0,Q.useRef)(!1),v=(0,Q.useRef)(null),y=(0,Q.useCallback)((e,t)=>{c(n=>n.timeLastShown===e&&n.submitCountAtLastAppearance===t?n:{timeLastShown:e,submitCountAtLastAppearance:t}),cf().feedbackSurveyState?.lastShownTime!==e&&df(t=>({...t,feedbackSurveyState:{lastShownTime:e}}))},[]),b=(0,Q.useCallback)(e=>{y(Date.now(),h.current),X(`tengu_feedback_survey_event`,{event_type:`appeared`,appearance_id:e,last_assistant_message_id:a.current,survey_type:r}),Am(`feedback_survey`,{event_type:`appeared`,appearance_id:e,survey_type:r})},[y,r]),x=(0,Q.useCallback)((e,t)=>{y(Date.now(),h.current),X(`tengu_feedback_survey_event`,{event_type:`responded`,appearance_id:e,response:t,last_assistant_message_id:a.current,survey_type:r}),Am(`feedback_survey`,{event_type:`responded`,appearance_id:e,response:t,survey_type:r})},[y,r]),S=(0,Q.useCallback)(e=>{if(e!==`bad`&&e!==`good`||cf().transcriptShareDismissed||!Zo(`allow_product_feedback`))return!1;let t=e===`bad`?u.probability:d.probability;return Math.random()<=t},[u.probability,d.probability]),C=(0,Q.useCallback)((e,t)=>{let n=t===`good`?`good_feedback_survey`:`bad_feedback_survey`;X(`tengu_feedback_survey_event`,{event_type:`transcript_prompt_appeared`,appearance_id:e,last_assistant_message_id:a.current,survey_type:r,trigger:n}),Am(`feedback_survey`,{event_type:`transcript_prompt_appeared`,appearance_id:e,survey_type:r})},[r]),w=(0,Q.useCallback)(async(e,t,n)=>{let i=n===`good`?`good_feedback_survey`:`bad_feedback_survey`;if(X(`tengu_feedback_survey_event`,{event_type:`transcript_share_${t}`,appearance_id:e,last_assistant_message_id:a.current,survey_type:r,trigger:i}),t===`dont_ask_again`&&df(e=>({...e,transcriptShareDismissed:!0})),t===`yes`){let t=await RO(g.current,i,e);return X(`tengu_feedback_survey_event`,{event_type:t.success?`transcript_share_submitted`:`transcript_share_failed`,appearance_id:e,trigger:i}),t.success}return!1},[r]),{state:T,lastResponse:E,open:D,handleSelect:O,handleTranscriptSelect:k}=zO({hideThanksAfterMs:l.hideThanksAfterMs,onOpen:b,onSelect:x,shouldShowTranscriptPrompt:S,onTranscriptPromptShown:C,onTranscriptSelect:w}),A=Lp(),ee=(0,Q.useMemo)(()=>l.onForModels.length===0?!1:l.onForModels.includes(`*`)?!0:l.onForModels.includes(A),[l.onForModels,A]),j=(0,Q.useMemo)(()=>{if(T!==`closed`||t||i)return!1;if(process.env.CLAUDE_FORCE_DISPLAY_SURVEY&&!s.timeLastShown)return!0;if(!ee||o(process.env.CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY)||zm()||!Zo(`allow_product_feedback`))return!1;if(s.timeLastShown){if(Date.now()-s.timeLastShown<l.minTimeBetweenFeedbackMs||s.submitCountAtLastAppearance!==null&&n<s.submitCountAtLastAppearance+l.minUserTurnsBetweenFeedback)return!1}else if(Date.now()-p.current<l.minTimeBeforeFeedbackMs||n<m.current+l.minUserTurnsBeforeFeedback)return!1;if(v.current!==n&&(v.current=n,_.current=Math.random()<=(f??l.probability)),!_.current)return!1;let e=cf().feedbackSurveyState;return!(e?.lastShownTime&&Date.now()-e.lastShownTime<l.minTimeBetweenGlobalFeedbackMs)},[T,t,i,ee,s.timeLastShown,s.submitCountAtLastAppearance,n,l.minTimeBetweenFeedbackMs,l.minTimeBetweenGlobalFeedbackMs,l.minUserTurnsBetweenFeedback,l.minTimeBeforeFeedbackMs,l.minUserTurnsBeforeFeedback,l.probability,f]);return(0,Q.useEffect)(()=>{j&&D()},[j,D]),{state:T,lastResponse:E,handleSelect:O,handleTranscriptSelect:k}}Rm(),If(),lf(),s(),P(),Nm();var UO=3e3,WO=`tengu_memory_survey_event`,GO=`memory_survey`;function KO(e,t,n=!1,{enabled:r=!0}={}){let i=(0,Q.useRef)(new Set),a=(0,Q.useRef)(!1),o=(0,Q.useRef)(e);o.current=e;let{state:s,lastResponse:c,open:l,handleSelect:u,handleTranscriptSelect:d}=zO({hideThanksAfterMs:UO,onOpen:(0,Q.useCallback)(e=>{X(WO,{event_type:`appeared`,appearance_id:e}),Am(`feedback_survey`,{event_type:`appeared`,appearance_id:e,survey_type:`memory`})},[]),onSelect:(0,Q.useCallback)((e,t)=>{X(WO,{event_type:`responded`,appearance_id:e,response:t}),Am(`feedback_survey`,{event_type:`responded`,appearance_id:e,response:t,survey_type:`memory`})},[]),shouldShowTranscriptPrompt:(0,Q.useCallback)(e=>!1,[]),onTranscriptPromptShown:(0,Q.useCallback)(e=>{X(WO,{event_type:`transcript_prompt_appeared`,appearance_id:e,trigger:GO}),Am(`feedback_survey`,{event_type:`transcript_prompt_appeared`,appearance_id:e,survey_type:`memory`})},[]),onTranscriptSelect:(0,Q.useCallback)(async(e,t)=>{if(X(WO,{event_type:`transcript_share_${t}`,appearance_id:e,trigger:GO}),t===`dont_ask_again`&&df(e=>({...e,transcriptShareDismissed:!0})),t===`yes`){let t=await RO(o.current,GO,e);return X(WO,{event_type:t.success?`transcript_share_submitted`:`transcript_share_failed`,appearance_id:e,trigger:GO}),t.success}return!1},[])});return(0,Q.useEffect)(()=>{if(r&&e.length===0){a.current=!1,i.current.clear();return}},[r,s,t,n,(0,Q.useMemo)(()=>No(e),[e]),e,l]),{state:s,lastResponse:c,handleSelect:u,handleTranscriptSelect:d}}Rm(),If(),s(),P(),Nm();var qO=3e3,JO=.2;function YO(e,t){let n=e.findIndex(e=>e.uuid===t);if(n===-1)return!1;for(let t=n+1;t<e.length;t++){let n=e[t];if(n&&(n.type===`user`||n.type===`assistant`))return!0}return!1}function XO(e,t,n=!1,{enabled:r=!0}={}){let[i,a]=(0,Q.useState)(null),s=(0,Q.useRef)(new Set),c=(0,Q.useRef)(null),{state:l,lastResponse:u,open:d,handleSelect:f}=zO({hideThanksAfterMs:qO,onOpen:(0,Q.useCallback)(e=>{X(`tengu_post_compact_survey_event`,{event_type:`appeared`,appearance_id:e,session_memory_compaction_enabled:bt()}),Am(`feedback_survey`,{event_type:`appeared`,appearance_id:e,survey_type:`post_compact`})},[]),onSelect:(0,Q.useCallback)((e,t)=>{X(`tengu_post_compact_survey_event`,{event_type:`responded`,appearance_id:e,response:t,session_memory_compaction_enabled:bt()}),Am(`feedback_survey`,{event_type:`responded`,appearance_id:e,response:t,survey_type:`post_compact`})},[])});(0,Q.useEffect)(()=>{r&&a(!1)},[r]);let p=(0,Q.useMemo)(()=>new Set(e.filter(e=>Gr(e)).map(e=>e.uuid)),[e]);return(0,Q.useEffect)(()=>{if(!r||l!==`closed`||t||n||i!==!0||zm()||o(process.env.CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY))return;if(c.current!==null&&YO(e,c.current)){c.current=null,Math.random()<JO&&d();return}let a=Array.from(p).filter(e=>!s.current.has(e));a.length>0&&(s.current=new Set(p),c.current=a[a.length-1])},[r,p,l,t,n,i,e,d]),{state:l,lastResponse:u,handleSelect:f}}Id(),q();var ZO=[`1`,`2`,`3`],QO={1:`yes`,2:`no`,3:`dont_ask_again`},$O=e=>ZO.includes(e);function ek({onSelect:e,inputValue:t,setInputValue:n}){return ID({inputValue:t,setInputValue:n,isValidDigit:$O,onDigit:t=>e(QO[t])}),(0,$.jsxs)(G,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(G,{children:[(0,$.jsxs)(K,{color:`ansi:cyan`,children:[Ed,` `]}),(0,$.jsx)(K,{bold:!0,children:`Can we look at your session transcript to help us improve Claude Code?`})]}),(0,$.jsx)(G,{marginLeft:2,children:(0,$.jsx)(K,{dimColor:!0,children:`Learn more: https://code.workmate.com/docs/en/data-usage#session-quality-surveys`})}),(0,$.jsxs)(G,{marginLeft:2,children:[(0,$.jsx)(G,{width:10,children:(0,$.jsxs)(K,{children:[(0,$.jsx)(K,{color:`ansi:cyan`,children:`1`}),`: Yes`]})}),(0,$.jsx)(G,{width:10,children:(0,$.jsxs)(K,{children:[(0,$.jsx)(K,{color:`ansi:cyan`,children:`2`}),`: No`]})}),(0,$.jsx)(G,{children:(0,$.jsxs)(K,{children:[(0,$.jsx)(K,{color:`ansi:cyan`,children:`3`}),`: Don't ask again`]})})]})]})}If(),q();function tk({state:e,lastResponse:t,handleSelect:n,handleTranscriptSelect:r,inputValue:i,setInputValue:a,onRequestFeedback:o,message:s}){return e===`closed`?null:e===`thanks`?(0,$.jsx)(rk,{lastResponse:t,inputValue:i,setInputValue:a,onRequestFeedback:o}):e===`submitted`?(0,$.jsx)(G,{marginTop:1,children:(0,$.jsxs)(K,{color:`success`,children:[`✓`,` Thanks for sharing your transcript!`]})}):e===`submitting`?(0,$.jsx)(G,{marginTop:1,children:(0,$.jsxs)(K,{dimColor:!0,children:[`Sharing transcript`,`…`]})}):e===`transcript_prompt`?!r||i&&![`1`,`2`,`3`].includes(i)?null:(0,$.jsx)(ek,{onSelect:r,inputValue:i,setInputValue:a}):i&&!zD(i)?null:(0,$.jsx)(VD,{onSelect:n,inputValue:i,setInputValue:a,message:s})}var nk=e=>e===`1`;function rk({lastResponse:e,inputValue:t,setInputValue:n,onRequestFeedback:r}){let i=r&&e===`good`;return ID({inputValue:t,setInputValue:n,isValidDigit:nk,enabled:!!i,once:!0,onDigit:()=>{X(`tengu_feedback_survey_event`,{event_type:`followup_accepted`,response:e}),r?.()}}),(0,$.jsxs)(G,{marginTop:1,flexDirection:`column`,children:[(0,$.jsx)(K,{color:`success`,children:`Thanks for the feedback!`}),i?(0,$.jsxs)(K,{dimColor:!0,children:[`(Optional) Press [`,(0,$.jsx)(K,{color:`ansi:cyan`,children:`1`}),`] to tell us what went well `,` · `,`/issue`]}):e===`bad`?(0,$.jsx)(K,{dimColor:!0,children:`Use /issue to report model behavior issues.`}):(0,$.jsx)(K,{dimColor:!0,children:`Use /issue to share detailed feedback anytime.`})]})}Jm(),Zm(),Ru(),Ot(),Ef();function ik(e){let{addNotification:t}=ki(),n=(0,Q.useRef)(!1),r=(0,Q.useRef)(e);r.current=e,(0,Q.useEffect)(()=>{Tu()||n.current||(n.current=!0,Promise.resolve().then(()=>r.current()).then(e=>{if(e)for(let n of Array.isArray(e)?e:[e])t(n)}).catch(Y))},[t])}function ak(){ik(async()=>(await Xm()).map((e,t)=>{let n=`low`;return e.type===`error`||e.userActionRequired?n=`high`:(e.type===`path`||e.type===`alias`)&&(n=`medium`),{key:`install-message-${t}-${e.type}`,text:e.message,priority:n,color:e.type===`error`?`error`:`warning`}}))}lf(),gd(),bd(),P(),vp(),ys(),h(),q(),P();function ok(e,t,n){(0,Q.useRef)(null),(0,Q.useRef)(null);let r=(0,Q.useRef)(e),i=(0,Q.useRef)(n),a=(0,Q.useRef)(!1),o=(0,Q.useRef)(null);r.current=e,i.current=n,(0,Q.useEffect)(()=>{},[!1,t]),(0,Q.useEffect)(()=>{if(n||!a.current)return;let e=Hl();e!==`blurred`&&e!==`unknown`||o.current?.()},[n]),(0,Q.useEffect)(()=>{Hl()},[n,!1])}If(),lf(),bd(),s(),pd(),Ef();function sk(){return o(process.env.CLAUDE_CODE_DISABLE_OFFICIAL_MARKETPLACE_AUTOINSTALL)}var ck={MAX_ATTEMPTS:10,INITIAL_DELAY_MS:3600*1e3,BACKOFF_MULTIPLIER:2,MAX_DELAY_MS:10080*60*1e3};function lk(e){let t=ck.INITIAL_DELAY_MS*ck.BACKOFF_MULTIPLIER**e;return Math.min(t,ck.MAX_DELAY_MS)}function uk(e){if(!e.officialMarketplaceAutoInstallAttempted)return!0;if(e.officialMarketplaceAutoInstalled)return!1;let t=e.officialMarketplaceAutoInstallFailReason,n=e.officialMarketplaceAutoInstallRetryCount||0,r=e.officialMarketplaceAutoInstallNextRetryTime,i=Date.now();return n>=ck.MAX_ATTEMPTS||t===`policy_blocked`||r&&i<r?!1:t===`unknown`||t===`git_unavailable`||t===`gcs_unavailable`||t===void 0}async function dk(){let e=cf();if(!uk(e)){let t=e.officialMarketplaceAutoInstallFailReason??`already_attempted`;return J(`Official marketplace auto-install skipped: ${t}`),{installed:!1,skipped:!0,reason:t}}try{if(sk())return J(`Official marketplace auto-install disabled via env var, skipping`),df(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`policy_blocked`})),X(`tengu_official_marketplace_auto_install`,{installed:!1,skipped:!0,policy_blocked:!0}),{installed:!1,skipped:!0,reason:`policy_blocked`};if((await se())[`claude-plugins-official`])return J(`Official marketplace '${mt}' already installed, skipping`),df(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!0})),{installed:!1,skipped:!0,reason:`already_installed`};if(!Do(Hr))return J(`Official marketplace blocked by enterprise policy, skipping`),df(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`policy_blocked`})),X(`tengu_official_marketplace_auto_install`,{installed:!1,skipped:!0,policy_blocked:!0}),{installed:!1,skipped:!0,reason:`policy_blocked`};let t=en(),n=a_(t,mt);if(await Ni(n,t)!==null){let e=await se();return e[mt]={source:Hr,installLocation:n,lastUpdated:new Date().toISOString()},await Ht(e),df(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!0,officialMarketplaceAutoInstallFailReason:void 0,officialMarketplaceAutoInstallRetryCount:void 0,officialMarketplaceAutoInstallLastAttemptTime:void 0,officialMarketplaceAutoInstallNextRetryTime:void 0})),X(`tengu_official_marketplace_auto_install`,{installed:!0,skipped:!1,via_gcs:!0}),{installed:!0,skipped:!1}}if(!await wt()){J(`Git not available, skipping official marketplace auto-install`);let t=(e.officialMarketplaceAutoInstallRetryCount||0)+1,n=Date.now(),r=n+lk(t),i=!1;try{df(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`git_unavailable`,officialMarketplaceAutoInstallRetryCount:t,officialMarketplaceAutoInstallLastAttemptTime:n,officialMarketplaceAutoInstallNextRetryTime:r}))}catch(e){i=!0,Y(hd(e)),J(`Failed to save marketplace auto-install git_unavailable state: ${e}`,{level:`error`})}return X(`tengu_official_marketplace_auto_install`,{installed:!1,skipped:!0,git_unavailable:!0,retry_count:t}),{installed:!1,skipped:!0,reason:`git_unavailable`,configSaveFailed:i}}J(`Attempting to auto-install official marketplace`),await Dn(Hr),J(`Successfully auto-installed official marketplace`);let r=e.officialMarketplaceAutoInstallRetryCount||0;return df(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!0,officialMarketplaceAutoInstallFailReason:void 0,officialMarketplaceAutoInstallRetryCount:void 0,officialMarketplaceAutoInstallLastAttemptTime:void 0,officialMarketplaceAutoInstallNextRetryTime:void 0})),X(`tengu_official_marketplace_auto_install`,{installed:!0,skipped:!1,retry_count:r}),{installed:!0,skipped:!1}}catch(t){let n=t instanceof Error?t.message:String(t);if(n.includes(`xcrun: error:`))return hr(),J(`Official marketplace auto-install: git is a non-functional macOS xcrun shim, treating as git_unavailable`),X(`tengu_official_marketplace_auto_install`,{installed:!1,skipped:!0,git_unavailable:!0,macos_xcrun_shim:!0}),{installed:!1,skipped:!0,reason:`git_unavailable`};J(`Failed to auto-install official marketplace: ${n}`,{level:`error`}),Y(hd(t));let r=(e.officialMarketplaceAutoInstallRetryCount||0)+1,i=Date.now(),a=i+lk(r),o=!1;try{df(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`unknown`,officialMarketplaceAutoInstallRetryCount:r,officialMarketplaceAutoInstallLastAttemptTime:i,officialMarketplaceAutoInstallNextRetryTime:a}))}catch(e){o=!0,Y(hd(e)),J(`Failed to save marketplace auto-install failure state: ${e}`,{level:`error`})}return X(`tengu_official_marketplace_auto_install`,{installed:!1,skipped:!0,failed:!0,retry_count:r}),{installed:!1,skipped:!0,reason:`unknown`,configSaveFailed:o}}}q(),bd();function fk(){ik(async()=>{let e=await dk(),t=[];return e.configSaveFailed&&(J(`Showing marketplace config save failure notification`),t.push({key:`marketplace-config-save-failed`,jsx:(0,$.jsx)(K,{color:`error`,children:`Failed to save marketplace retry info · Check ~/.workmate.json permissions`}),priority:`immediate`,timeoutMs:1e4})),e.installed?(J(`Showing marketplace installation success notification`),t.push({key:`marketplace-installed`,jsx:(0,$.jsx)(K,{color:`success`,children:`✓ Official marketplace installed · /plugin to see available plugins`}),priority:`immediate`,timeoutMs:7e3})):e.skipped&&e.reason===`unknown`&&(J(`Showing marketplace installation failure notification`),t.push({key:`marketplace-install-failed`,jsx:(0,$.jsx)(K,{color:`warning`,children:`Failed to install official marketplace · Will retry on next startup`}),priority:`immediate`,timeoutMs:8e3})),t})}Ud(),If();function pk(e){if(e.length===0)return;if(e.length===1)return e[0];let t=e.map(e=>({tip:e,sessions:Kg(e.id)}));return t.sort((e,t)=>t.sessions-e.sessions),t[0]?.tip}async function mk(e){if(Hd().spinnerTipsEnabled===!1)return;let t=await Jg(e);if(t.length!==0)return pk(t)}function hk(e){Gg(e.id),X(`tengu_tip_shown`,{tipIdLength:e.id,cooldownSessions:e.cooldownSessions})}pd(),Ef(),Ru(),U(),ue();var gk=!1;async function _k(e,t,n){{if(gk)return;gk=!0;let{updateContext:r,notification:i}=await Ie(e,n);t(e=>{let t=r(e.toolPermissionContext),n=t===e.toolPermissionContext?e:{...e,toolPermissionContext:t};return i?{...n,notifications:{...n.notifications,queue:[...n.notifications.queue,{key:`auto-mode-gate-notification`,text:i,color:`warning`,priority:`high`}]}}:n})}}function vk(){gk=!1}function yk(){let e=W(e=>e.mainLoopModel),t=W(e=>e.mainLoopModelForSession),n=W(e=>e.fastMode),r=Qo(),i=xa(),a=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>{Tu()||(a.current?a.current=!1:vk(),_k(i.getState().toolPermissionContext,r,n).catch(e=>{Y(Error(`Auto mode gate check failed`,{cause:hd(e)}))}))},[e,t,n])}j();function bk(e,t,n){let r=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{!Kc()||r.current||(r.current=!0,e&&Fn(e,n))},[t,e,n])}q(),R(),ar(),pg();function xk({hostPattern:{host:e},onUserResponse:t}){function n(e){switch(e){case`yes`:t({allow:!0,persistToSettings:!1});break;case`yes-dont-ask-again`:t({allow:!0,persistToSettings:!0});break;case`no`:t({allow:!1,persistToSettings:!1});break}}let r=[{label:`Yes`,value:`yes`},...ke()?[]:[{label:(0,$.jsxs)(K,{children:[`Yes, and don't ask again for `,(0,$.jsx)(K,{bold:!0,children:e})]}),value:`yes-dont-ask-again`}],{label:(0,$.jsxs)(K,{children:[`No, and tell Claude what to do differently `,(0,$.jsx)(K,{bold:!0,children:`(esc)`})]}),value:`no`}];return(0,$.jsx)(hg,{title:`Network request outside of sandbox`,children:(0,$.jsxs)(G,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsxs)(G,{children:[(0,$.jsx)(K,{dimColor:!0,children:`Host:`}),(0,$.jsxs)(K,{children:[` `,e]})]}),(0,$.jsx)(G,{marginTop:1,children:(0,$.jsx)(K,{children:`Do you want to allow this connection?`})}),(0,$.jsx)(G,{children:(0,$.jsx)(Hi,{options:r,onChange:n,onCancel:()=>{t({allow:!1,persistToSettings:!1})}})})]})})}q(),R(),Nf();function Sk(e){return`${e.getHours()%12||12}:${String(e.getMinutes()).padStart(2,`0`)}:${String(e.getSeconds()).padStart(2,`0`)}${e.getHours()<12?`am`:`pm`}`}function Ck(){let[e,t]=(0,Q.useState)([]),[n,r]=(0,Q.useState)(0);return(0,Q.useEffect)(()=>{let e=pa.getSandboxViolationStore();return e.subscribe(n=>{t(n.slice(-10)),r(e.getTotalCount())})},[]),!pa.isSandboxingEnabled()||Mf()===`linux`||n===0?null:(0,$.jsxs)(G,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(G,{marginLeft:0,children:(0,$.jsxs)(K,{color:`permission`,children:[`⧈ Sandbox blocked `,n,` total `,n===1?`operation`:`operations`]})}),e.map((e,t)=>(0,$.jsx)(G,{paddingLeft:2,children:(0,$.jsxs)(K,{dimColor:!0,children:[Sk(e.timestamp),e.command?` ${e.command}:`:``,` `,e.line]})},`${e.timestamp.getTime()}-${t}`)),(0,$.jsx)(G,{paddingLeft:2,children:(0,$.jsxs)(K,{dimColor:!0,children:[`… showing last `,Math.min(10,e.length),` of `,n]})})]})}rg(),Ot(),Ru(),q();var wk=[];function Tk({mcpClients:e=wk}){let{addNotification:t}=ki();(0,Q.useEffect)(()=>{if(Tu())return;let n=e.filter(e=>e.type===`failed`&&e.config.type!==`sse-ide`&&e.config.type!==`ws-ide`&&e.config.type!==`claudeai-proxy`),r=e.filter(e=>e.type===`failed`&&e.config.type===`claudeai-proxy`&&$i(e.name)),i=e.filter(e=>e.type===`needs-auth`&&e.config.type!==`claudeai-proxy`),a=e.filter(e=>e.type===`needs-auth`&&e.config.type===`claudeai-proxy`&&$i(e.name));n.length===0&&r.length===0&&i.length===0&&a.length===0||(n.length>0&&t({key:`mcp-failed`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(K,{color:`error`,children:[n.length,` MCP `,n.length===1?`server`:`servers`,` failed`]}),(0,$.jsx)(K,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}),r.length>0&&t({key:`mcp-claudeai-failed`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(K,{color:`error`,children:[r.length,` claude.ai `,r.length===1?`connector`:`connectors`,` `,`unavailable`]}),(0,$.jsx)(K,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}),i.length>0&&t({key:`mcp-needs-auth`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(K,{color:`warning`,children:[i.length,` MCP `,i.length===1?`server needs`:`servers need`,` `,`auth`]}),(0,$.jsx)(K,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}),a.length>0&&t({key:`mcp-claudeai-needs-auth`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(K,{color:`warning`,children:[a.length,` claude.ai`,` `,a.length===1?`connector needs`:`connectors need`,` auth`]}),(0,$.jsx)(K,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}))},[t,e])}q(),Ud(),wi();var Ek=`Auto mode lets Claude handle permission prompts automatically — Claude checks each tool call for risky actions and prompt injection before executing. Actions Claude identifies as safe are executed, while actions Claude identifies as risky are blocked and Claude may try a different approach. Ideal for long-running tasks. Sessions are slightly more expensive. Claude can make mistakes that allow harmful commands to run, it's recommended to only use in isolated environments. Shift+Tab to change mode.`;su(),Ru(),Ot(),q(),U(),bd(),s();var Dk=5e3;function Ok(){let{addNotification:e}=ki(),t=Qo(),[n,r]=Q.useState(()=>o(`true`)),i=Q.useRef(new Set),a=Q.useCallback((n,r)=>{let a=`${n}:${r}`;if(i.current.has(a))return;i.current.add(a),J(`LSP error: ${n} - ${r}`),t(e=>{let t=new Set(e.plugins.errors.map(e=>e.type===`generic-error`?`generic-error:${e.source}:${e.error}`:`${e.type}:${e.source}`)),i=`generic-error:${n}:${r}`;return t.has(i)?e:{...e,plugins:{...e.plugins,errors:[...e.plugins.errors,{type:`generic-error`,source:n,error:r}]}}});let o=n.startsWith(`plugin:`)?n.split(`:`)[1]??n:n;e({key:`lsp-error-${n}`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(K,{color:`error`,children:[`LSP for `,o,` failed`]}),(0,$.jsx)(K,{dimColor:!0,children:` · /plugin for details`})]}),priority:`medium`,timeoutMs:8e3})},[e,t]),s=Q.useCallback(()=>{if(Tu()||Fu())return;let e=il();if(e.status===`failed`){a(`lsp-manager`,e.error.message),r(!1);return}if(e.status===`pending`||e.status===`not-started`)return;let t=yr();if(t){let e=t.getAllServers();for(let[t,n]of e)n.state===`error`&&n.lastError&&a(t,n.lastError.message)}},[a]);Wl(s,n?Dk:null),Q.useEffect(()=>{Tu()||!n||s()},[s,n])}bd();var kk=new Map;async function Ak(e){if(!e||!e.trim())return J(`[binaryCheck] Empty command provided, returning false`),!1;let t=e.trim(),n=kk.get(t);if(n!==void 0)return J(`[binaryCheck] Cache hit for '${t}': ${n}`),n;let r=!1;return await Af(t).catch(()=>null)&&(r=!0),kk.set(t,r),J(`[binaryCheck] Binary '${t}' ${r?`found`:`not found`}`),r}lf(),bd(),bl();var jk=5;function Mk(e){return Vd.has(e.toLowerCase())}function Nk(e){if(!e)return null;if(typeof e==`string`)return J(`[lspRecommendation] Skipping string path lspServers (not readable from marketplace)`),null;if(Array.isArray(e)){for(let t of e){if(typeof t==`string`)continue;let e=Fk(t);if(e)return e}return null}return Fk(e)}function Pk(e){return typeof e==`object`&&!!e}function Fk(e){let t=new Set,n=null;for(let[r,i]of Object.entries(e)){if(!Pk(i))continue;!n&&typeof i.command==`string`&&(n=i.command);let e=i.extensionToLanguage;if(Pk(e))for(let n of Object.keys(e))t.add(n.toLowerCase())}return!n||t.size===0?null:{extensions:t,command:n}}async function Ik(){let e=new Map;try{let t=await se();for(let n of Object.keys(t))try{let t=await St(n),r=Mk(n);for(let i of t.plugins){if(!i.lspServers)continue;let t=Nk(i.lspServers);if(!t)continue;let a=`${i.name}@${n}`;e.set(a,{entry:i,marketplaceName:n,extensions:t.extensions,command:t.command,isOfficial:r})}}catch(e){J(`[lspRecommendation] Failed to load marketplace ${n}: ${e}`)}}catch(e){J(`[lspRecommendation] Failed to load marketplaces config: ${e}`)}return e}async function Lk(e){if(Bk())return J(`[lspRecommendation] Recommendations are disabled`),[];let t=i_(e).toLowerCase();if(!t)return J(`[lspRecommendation] No file extension found`),[];J(`[lspRecommendation] Looking for LSP plugins for ${t}`);let n=await Ik(),r=cf().lspRecommendationNeverPlugins??[],i=[];for(let[e,a]of n)if(a.extensions.has(t)){if(r.includes(e)){J(`[lspRecommendation] Skipping ${e} (in never suggest list)`);continue}if(Ln(e)){J(`[lspRecommendation] Skipping ${e} (already installed)`);continue}i.push({info:a,pluginId:e})}let a=[];for(let{info:e,pluginId:t}of i)await Ak(e.command)?(a.push({info:e,pluginId:t}),J(`[lspRecommendation] Binary '${e.command}' found for ${t}`)):J(`[lspRecommendation] Skipping ${t} (binary '${e.command}' not found)`);return a.sort((e,t)=>e.info.isOfficial&&!t.info.isOfficial?-1:!e.info.isOfficial&&t.info.isOfficial?1:0),a.map(({info:e,pluginId:t})=>({pluginId:t,pluginName:e.entry.name,marketplaceName:e.marketplaceName,description:e.entry.description,isOfficial:e.isOfficial,extensions:Array.from(e.extensions),command:e.command}))}function Rk(e){df(t=>{let n=t.lspRecommendationNeverPlugins??[];return n.includes(e)?t:{...t,lspRecommendationNeverPlugins:[...n,e]}}),J(`[lspRecommendation] Added ${e} to never suggest`)}function zk(){df(e=>{let t=(e.lspRecommendationIgnoredCount??0)+1;return{...e,lspRecommendationIgnoredCount:t}}),J(`[lspRecommendation] Incremented ignored count`)}function Bk(){let e=cf();return e.lspRecommendationDisabled===!0||(e.lspRecommendationIgnoredCount??0)>=jk}u(),Ru(),q(),Ef(),bl();function Vk(){let[e,t]=Q.useState(null),n=Q.useRef(!1),r=Q.useCallback(r=>{Tu()||e||n.current||(n.current=!0,r().then(e=>{e&&t(e)}).catch(Y).finally(()=>{n.current=!1}))},[e]);return{recommendation:e,clearRecommendation:Q.useCallback(()=>t(null),[]),tryResolve:r}}async function Hk(e,t,n,r,i){try{let a=await pr(e);if(!a)throw Error(`Plugin ${e} not found in marketplace`);await i(a),r({key:`${n}-installed`,jsx:(0,$.jsxs)(K,{color:`success`,children:[d.tick,` `,t,` installed · restart to apply`]}),priority:`immediate`,timeoutMs:5e3})}catch(e){Y(e),r({key:`${n}-install-failed`,jsx:(0,$.jsxs)(K,{color:`error`,children:[`Failed to install `,t]}),priority:`immediate`,timeoutMs:5e3})}}Ru(),Ot(),U(),lf(),bd(),Ef(),Ud();var Uk=28e3;function Wk(){let e=W(e=>e.fileHistory.trackedFiles),{addNotification:t}=ki(),n=Q.useRef(new Set),{recommendation:r,clearRecommendation:i,tryResolve:a}=Vk();return Q.useEffect(()=>{a(async()=>{if(Iu())return null;let t=[];for(let r of e)n.current.has(r)||(n.current.add(r),t.push(r));for(let e of t)try{let t=(await Lk(e))[0];if(t)return J(`[useLspPluginRecommendation] Found match: ${t.pluginName} for ${e}`),qu(!0),{pluginId:t.pluginId,pluginName:t.pluginName,pluginDescription:t.description,fileExtension:i_(e),shownAt:Date.now()}}catch(e){Y(e)}return null})},[e,a]),{recommendation:r,handleResponse:Q.useCallback(e=>{if(!r)return;let{pluginId:n,pluginName:a,shownAt:o}=r;switch(J(`[useLspPluginRecommendation] User response: ${e} for ${a}`),e){case`yes`:Hk(n,a,`lsp-plugin`,t,async e=>{J(`[useLspPluginRecommendation] Installing plugin: ${n}`);let t=typeof e.entry.source==`string`?a_(e.marketplaceInstallLocation,e.entry.source):void 0;await go(n,e.entry,`user`,void 0,t),tf(`userSettings`,{enabledPlugins:{...zd(`userSettings`)?.enabledPlugins,[n]:!0}}),J(`[useLspPluginRecommendation] Plugin installed: ${n}`)});break;case`no`:{let e=Date.now()-o;e>=Uk&&(J(`[useLspPluginRecommendation] Timeout detected (${e}ms), incrementing ignored count`),zk());break}case`never`:Rk(n);break;case`disable`:df(e=>e.lspRecommendationDisabled?e:{...e,lspRecommendationDisabled:!0});break}i()},[r,t,i])}}q(),ar(),pg();var Gk=3e4;function Kk({pluginName:e,pluginDescription:t,fileExtension:n,onResponse:r}){let i=Q.useRef(r);i.current=r,Q.useEffect(()=>{let e=setTimeout(e=>e.current(`no`),Gk,i);return()=>clearTimeout(e)},[]);function a(e){switch(e){case`yes`:r(`yes`);break;case`no`:r(`no`);break;case`never`:r(`never`);break;case`disable`:r(`disable`);break}}return(0,$.jsx)(hg,{title:`LSP Plugin Recommendation`,children:(0,$.jsxs)(G,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(G,{marginBottom:1,children:(0,$.jsx)(K,{dimColor:!0,children:`LSP provides code intelligence like go-to-definition and error checking`})}),(0,$.jsxs)(G,{children:[(0,$.jsx)(K,{dimColor:!0,children:`Plugin:`}),(0,$.jsxs)(K,{children:[` `,e]})]}),t&&(0,$.jsx)(G,{children:(0,$.jsx)(K,{dimColor:!0,children:t})}),(0,$.jsxs)(G,{children:[(0,$.jsx)(K,{dimColor:!0,children:`Triggered by:`}),(0,$.jsxs)(K,{children:[` `,n,` files`]})]}),(0,$.jsx)(G,{marginTop:1,children:(0,$.jsx)(K,{children:`Would you like to install this LSP plugin?`})}),(0,$.jsx)(G,{children:(0,$.jsx)(Hi,{options:[{label:(0,$.jsxs)(K,{children:[`Yes, install `,(0,$.jsx)(K,{bold:!0,children:e})]}),value:`yes`},{label:`No, not now`,value:`no`},{label:(0,$.jsxs)(K,{children:[`Never for `,(0,$.jsx)(K,{bold:!0,children:e})]}),value:`never`},{label:`Disable all LSP recommendations`,value:`disable`}],onChange:a,onCancel:()=>r(`no`)})})]})})}Ot(),If(),bd(),Zi();function qk(){let e=Q.useSyncExternalStore(Be,ln),{addNotification:t}=ki(),{recommendation:n,clearRecommendation:r,tryResolve:i}=Vk();return Q.useEffect(()=>{e&&i(async()=>{let t=await ll(e);return t&&(J(`[useClaudeCodeHintRecommendation] surfacing ${t.pluginId} from ${t.sourceCommand}`),Kn()),ln()===e&&Fo(),t})},[e,i]),{recommendation:n,handleResponse:Q.useCallback(e=>{if(n){switch(Fc(n.pluginId),X(`tengu_plugin_hint_response`,{_PROTO_plugin_name:n.pluginName,_PROTO_marketplace_name:n.marketplaceName,response:e}),e){case`yes`:{let{pluginId:e,pluginName:r,marketplaceName:i}=n;Hk(e,r,`hint-plugin`,t,async t=>{let n=await Rc({pluginId:e,entry:t.entry,marketplaceName:i,scope:`user`,trigger:`hint`});if(!n.success)throw Error(n.success?`Unknown error`:n.error)});break}case`disable`:ro();break;case`no`:break}r()}},[n,t,r])}}q(),ar(),pg();var Jk=3e4;function Yk({pluginName:e,pluginDescription:t,marketplaceName:n,sourceCommand:r,onResponse:i}){let a=Q.useRef(i);a.current=i,Q.useEffect(()=>{let e=setTimeout(e=>e.current(`no`),Jk,a);return()=>clearTimeout(e)},[]);function o(e){switch(e){case`yes`:i(`yes`);break;case`disable`:i(`disable`);break;default:i(`no`)}}return(0,$.jsx)(hg,{title:`Plugin Recommendation`,children:(0,$.jsxs)(G,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(G,{marginBottom:1,children:(0,$.jsxs)(K,{dimColor:!0,children:[`The `,(0,$.jsx)(K,{bold:!0,children:r}),` command suggests installing a plugin.`]})}),(0,$.jsxs)(G,{children:[(0,$.jsx)(K,{dimColor:!0,children:`Plugin:`}),(0,$.jsxs)(K,{children:[` `,e]})]}),(0,$.jsxs)(G,{children:[(0,$.jsx)(K,{dimColor:!0,children:`Marketplace:`}),(0,$.jsxs)(K,{children:[` `,n]})]}),t&&(0,$.jsx)(G,{children:(0,$.jsx)(K,{dimColor:!0,children:t})}),(0,$.jsx)(G,{marginTop:1,children:(0,$.jsx)(K,{children:`Would you like to install it?`})}),(0,$.jsx)(G,{children:(0,$.jsx)(Hi,{options:[{label:(0,$.jsxs)(K,{children:[`Yes, install `,(0,$.jsx)(K,{bold:!0,children:e})]}),value:`yes`},{label:`No`,value:`no`},{label:`No, and don't show plugin installation hints again`,value:`disable`}],onChange:o,onCancel:()=>i(`no`)})})]})})}ar(),pg();var Xk=3e4;function Zk({tools:e,onSelect:t,onDismiss:n}){let r=Q.useRef(t),i=Q.useRef(n);r.current=t,i.current=n,Q.useEffect(()=>{let e=setTimeout(e=>e.current(),Xk,i);return()=>clearTimeout(e)},[]);let a=e.map(e=>({label:`${e.name} — ${e.description.slice(0,60)} (score: ${e.score.toFixed(2)})`,value:e.name}));return a.push({label:`Dismiss`,value:`__dismiss__`}),(0,$.jsx)(hg,{title:`Tool Recommendation`,children:(0,$.jsx)(Hi,{options:a,onChange:e=>{e===`__dismiss__`?i.current():(i.current(),r.current(e))}})})}Ae();var Qk=.15,$k=3;function eA(){let e=Q.useSyncExternalStore(xe,kr),t=Q.useMemo(()=>e.length===0?[]:e.slice(0,$k).map(e=>({name:e.name,description:e.description.slice(0,60),score:e.score})),[e]);return{tools:t,visible:t.length>0&&(t[0]?.score??0)>=Qk,handleSelect:Q.useCallback(e=>{Wc()},[]),handleDismiss:Q.useCallback(()=>{Wc()},[])}}Ru(),sd(),bd(),vf(),ef();var tA=`1.1.2396`;function nA(){let e=[process.argv[1]||``,process.execPath||``],t=[`/build-ant/`,`/build-ant-native/`,`/build-external/`,`/build-external-native/`];return e.some(e=>t.some(t=>e.includes(t)))}function rA(e){let t=nA()?`claude-dev`:`claude`,n=new URL(`${t}://resume`);return n.searchParams.set(`session`,e),n.searchParams.set(`cwd`,cd()),n.toString()}async function iA(){if(nA())return!0;let e=process.platform;if(e===`darwin`)return Gd(`/Applications/Claude.app`);if(e===`linux`){let{code:e,stdout:t}=await yf(`xdg-mime`,[`query`,`default`,`x-scheme-handler/claude`]);return e===0&&t.trim().length>0}else if(e===`win32`){let{code:e}=await yf(`reg`,[`query`,`HKEY_CLASSES_ROOT\\claude`,`/ve`]);return e===0}return!1}async function aA(){let e=process.platform;if(e===`darwin`){let{code:e,stdout:t}=await yf(`defaults`,[`read`,`/Applications/Claude.app/Contents/Info.plist`,`CFBundleShortVersionString`]);if(e!==0)return null;let n=t.trim();return n.length>0?n:null}else if(e===`win32`){let e=process.env.LOCALAPPDATA;if(!e)return null;let t=a_(e,`AnthropicClaude`);try{let e=(await p_(t)).filter(e=>e.startsWith(`app-`)).map(e=>e.slice(4)).filter(e=>(0,Jv.coerce)(e)!==null).sort((e,t)=>{let n=(0,Jv.coerce)(e),r=(0,Jv.coerce)(t);return n.compare(r)});return e.length>0?e[e.length-1]:null}catch{return null}}return null}async function oA(){if(!await iA())return{status:`not-installed`};let e;try{e=await aA()}catch{return{status:`ready`,version:`unknown`}}if(!e)return{status:`ready`,version:`unknown`};let t=(0,Jv.coerce)(e);return!t||!gm(t.version,tA)?{status:`version-too-old`,version:e}:{status:`ready`,version:e}}async function sA(e){let t=process.platform;if(J(`Opening deep link: ${e}`),t===`darwin`){if(nA()){let{code:t}=await yf(`osascript`,[`-e`,`tell application "Electron" to open location "${e}"`]);return t===0}let{code:t}=await yf(`open`,[e]);return t===0}else if(t===`linux`){let{code:t}=await yf(`xdg-open`,[e]);return t===0}else if(t===`win32`){let{code:t}=await yf(`cmd`,[`/c`,`start`,``,e]);return t===0}return!1}async function cA(){let e=$u();if(!await iA())return{success:!1,error:`Claude Desktop is not installed. Install it from https://claude.ai/download`};let t=rA(e);return await sA(t)?{success:!0,deepLinkUrl:t}:{success:!1,error:`Failed to open Claude Desktop. Please try opening it manually.`,deepLinkUrl:t}}q(),fa(),pd(),nr(),he();var lA=`https://clau.de/desktop`;function uA(){switch(process.platform){case`win32`:return`https://claude.ai/api/desktop/win32/x64/exe/latest/redirect`;default:return`https://claude.ai/api/desktop/darwin/universal/dmg/latest/redirect`}}function dA({onDone:e}){let[t,n]=(0,Q.useState)(`checking`),[r,i]=(0,Q.useState)(null),[a,o]=(0,Q.useState)(``);return Xl(n=>{if(t===`error`){e(r??`Unknown error`,{display:`system`});return}t===`prompt-download`&&(n===`y`||n===`Y`?($c(uA()).catch(()=>{}),e(`Starting download. Re-run /desktop once you\u2019ve installed the app.\nLearn more at ${lA}`,{display:`system`})):(n===`n`||n===`N`)&&e(`The desktop app is required for /desktop. Learn more at ${lA}`,{display:`system`}))}),(0,Q.useEffect)(()=>{async function t(){n(`checking`);let t=await oA();if(t.status===`not-installed`){o(`Claude Desktop is not installed.`),n(`prompt-download`);return}if(t.status===`version-too-old`){o(`Claude Desktop needs to be updated (found v${t.version}, need v1.1.2396+).`),n(`prompt-download`);return}n(`flushing`),await vs(),n(`opening`);let r=await cA();if(!r.success){i(r.error??`Failed to open Claude Desktop`),n(`error`);return}n(`success`),setTimeout(async e=>{e(`Session transferred to Claude Desktop`,{display:`system`}),await vi(0,`other`)},500,e)}t().catch(e=>{i(fd(e)),n(`error`)})},[e]),t===`error`?(0,$.jsxs)(G,{flexDirection:`column`,paddingX:2,children:[(0,$.jsxs)(K,{color:`error`,children:[`Error: `,r]}),(0,$.jsx)(K,{dimColor:!0,children:`Press any key to continue…`})]}):t===`prompt-download`?(0,$.jsxs)(G,{flexDirection:`column`,paddingX:2,children:[(0,$.jsx)(K,{children:a}),(0,$.jsx)(K,{children:`Download now? (y/n)`})]}):(0,$.jsx)(nu,{message:{checking:`Checking for Claude Desktop…`,flushing:`Saving session…`,opening:`Opening Claude Desktop…`,success:`Opening in Claude Desktop…`}[t]})}q(),If(),lf(),ar(),pg();var fA={enable_shortcut_tip:!1,enable_startup_dialog:!1};function pA(){return fA}function mA(){return process.platform===`darwin`||process.platform===`win32`&&process.arch===`x64`}function hA(){if(!mA()||!pA().enable_startup_dialog)return!1;let e=cf();return!(e.desktopUpsellDismissed||(e.desktopUpsellSeenCount??0)>=3)}function gA({onDone:e}){let[t,n]=(0,Q.useState)(!1);if((0,Q.useEffect)(()=>{let e=(cf().desktopUpsellSeenCount??0)+1;df(t=>(t.desktopUpsellSeenCount??0)>=e?t:{...t,desktopUpsellSeenCount:e}),X(`tengu_desktop_upsell_shown`,{seen_count:e})},[]),t)return(0,$.jsx)(dA,{onDone:()=>e()});function r(t){switch(t){case`try`:n(!0);return;case`never`:df(e=>e.desktopUpsellDismissed?e:{...e,desktopUpsellDismissed:!0}),e();return;case`not-now`:e();return}}return(0,$.jsx)(hg,{title:`Try Claude Code Desktop`,children:(0,$.jsxs)(G,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(G,{marginBottom:1,children:(0,$.jsx)(K,{children:`Same Claude Code with visual diffs, live app preview, parallel sessions, and more.`})}),(0,$.jsx)(Hi,{options:[{label:`Open in Claude Code Desktop`,value:`try`},{label:`Not now`,value:`not-now`},{label:`Don't ask again`,value:`never`}],onChange:r,onCancel:()=>r(`not-now`)})]})})}Ru(),Ot(),q(),U(),bd(),Qf();function _A(){let{addNotification:e}=ki(),t=W(e=>e.plugins.installationStatus),{totalFailed:n,failedMarketplacesCount:r,failedPluginsCount:i}=(0,Q.useMemo)(()=>{if(!t)return{totalFailed:0,failedMarketplacesCount:0,failedPluginsCount:0};let e=t.marketplaces.filter(e=>e.status===`failed`),n=t.plugins.filter(e=>e.status===`failed`);return{totalFailed:e.length+n.length,failedMarketplacesCount:e.length,failedPluginsCount:n.length}},[t]);(0,Q.useEffect)(()=>{if(!Tu()){if(!t){J(`No installation status to monitor`);return}n!==0&&(J(`Plugin installation status: ${r} failed marketplaces, ${i} failed plugins`),n!==0&&(J(`Adding notification for ${n} failed installations`),e({key:`plugin-install-failed`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(K,{color:`error`,children:[n,` `,Zf(n,`plugin`),` failed to install`]}),(0,$.jsx)(K,{dimColor:!0,children:` · /plugin for details`})]}),priority:`medium`})))}},[e,n,r,i])}Ru(),Ot(),q(),bd(),Cg();function vA(){let{addNotification:e}=ki(),[t,n]=(0,Q.useState)([]);(0,Q.useEffect)(()=>{if(!Tu())return wg(e=>{J(`Plugin autoupdate notification: ${e.length} plugin(s) updated`),n(e)})},[]),(0,Q.useEffect)(()=>{if(Tu()||t.length===0)return;let n=t.map(e=>{let t=e.indexOf(`@`);return t>0?e.substring(0,t):e}),r=n.length<=2?n.join(` and `):`${n.length} plugins`;e({key:`plugin-autoupdate-restart`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(K,{color:`success`,children:[n.length===1?`Plugin`:`Plugins`,` updated: `,r]}),(0,$.jsx)(K,{dimColor:!0,children:` · Run /reload-plugins to apply`})]}),priority:`low`,timeoutMs:1e4}),J(`Showing plugin autoupdate notification for: ${n.join(`, `)}`)},[t,e])}bd(),Ef(),bl(),Th(),If();function yA(e,t,n,r){e(e=>({...e,plugins:{...e.plugins,installationStatus:{...e.plugins.installationStatus,marketplaces:e.plugins.installationStatus.marketplaces.map(e=>e.name===t?{...e,status:n,error:r}:e)}}}))}async function bA(e){J(`performBackgroundPluginInstallations called`);try{let t=Ch(We(),await se().catch(()=>({}))),n=[...t.missing,...t.sourceChanged.map(e=>e.name)];if(e(e=>({...e,plugins:{...e.plugins,installationStatus:{marketplaces:n.map(e=>({name:e,status:`pending`})),plugins:[]}}})),n.length===0)return;J(`Installing ${n.length} marketplace(s) in background`);let r=await Sh({onProgress:t=>{switch(t.type){case`installing`:yA(e,t.name,`installing`);break;case`installed`:yA(e,t.name,`installed`);break;case`failed`:yA(e,t.name,`failed`,t.error);break}}}),i={installed_count:r.installed.length,updated_count:r.updated.length,failed_count:r.failed.length,up_to_date_count:r.upToDate.length};if(X(`tengu_marketplace_background_install`,i),hf(`info`,`tengu_marketplace_background_install`,i),r.installed.length>0){Zn(),J(`Auto-refreshing plugins after ${r.installed.length} new marketplace(s) installed`);try{await wh(e)}catch(t){Y(t),J(`Auto-refresh failed, falling back to needsRefresh: ${t}`,{level:`warn`}),cc(`performBackgroundPluginInstallations: auto-refresh failed`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}})}}else r.updated.length>0&&(Zn(),cc(`performBackgroundPluginInstallations: marketplaces reconciled`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}}))}catch(e){Y(e)}}lf(),bd(),bl(),ja();async function xA(e){if(J(`performStartupChecks called`),!uf()){J(`Trust not accepted for current directory - skipping plugin installations`);return}try{J(`Starting background plugin installations`),await ui()&&(Zn(),cc(`performStartupChecks: seed marketplaces changed`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}})),await bA(e)}catch(e){J(`Error initiating background plugin installations: ${e}`)}}q();var SA=/https?:\/\/\S+/;function CA(){let[e,t]=(0,Q.useState)(yp.getInstance().getStatus());return(0,Q.useEffect)(()=>yp.getInstance().subscribe(t),[]),!e.isAuthenticating&&!e.error&&e.output.length===0||!e.isAuthenticating&&!e.error?null:(0,$.jsxs)(G,{flexDirection:`column`,borderStyle:`round`,borderColor:`permission`,paddingX:1,marginY:1,children:[(0,$.jsx)(K,{bold:!0,color:`permission`,children:`Cloud Authentication`}),e.output.length>0&&(0,$.jsx)(G,{flexDirection:`column`,marginTop:1,children:e.output.slice(-5).map((e,t)=>{let n=e.match(SA);if(!n)return(0,$.jsx)(K,{dimColor:!0,children:e},t);let r=n[0],i=n.index??0,a=e.slice(0,i),o=e.slice(i+r.length);return(0,$.jsxs)(K,{dimColor:!0,children:[a,(0,$.jsx)(Al,{url:r,children:r}),o]},t)})}),e.error&&(0,$.jsx)(G,{marginTop:1,children:(0,$.jsx)(K,{color:`error`,children:e.error})})]})}Ot(),q(),Nt(),ip(),xc(),Ru();function wA(e){let{addNotification:t}=ki(),n=KS(),r=(0,Q.useMemo)(()=>Ti(n,e),[n,e]),i=(0,Q.useMemo)(()=>Ui(n),[n]),a=(0,Q.useRef)(null),o=cp(),s=E(),c=o===`team`||o===`enterprise`,[l,u]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{Tu()||(n.isUsingOverage&&!l&&(!c||s)?(t({key:`limit-reached`,text:i,priority:`immediate`}),u(!0)):!n.isUsingOverage&&l&&u(!1))},[n.isUsingOverage,i,l,t,s,c]),(0,Q.useEffect)(()=>{Tu()||r&&r!==a.current&&(a.current=r,t({key:`rate-limit-warning`,jsx:(0,$.jsx)(K,{children:(0,$.jsx)(K,{color:`warning`,children:r})}),priority:`high`}))},[r,t])}Ot(),Ru();function TA(e){let{addNotification:t}=ki(),n=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(Tu())return;let r=qg(e);r&&r!==n.current&&(n.current=r,t({key:`model-deprecation-warning`,text:r,color:`warning`,priority:`high`})),r||(n.current=null)},[e,t])}s();var EA=``;function DA(){ik(async()=>qf()||o(process.env.DISABLE_INSTALLATION_CHECKS)||await Ym()===`development`?null:{timeoutMs:15e3,key:`npm-deprecation-warning`,text:EA,color:`warning`,priority:`high`})}Ot(),q(),lf(),Uc(),Ru();var OA=5;function kA({ideSelection:e,mcpClients:t,ideInstallationStatus:n}){let{addNotification:r,removeNotification:i}=ki(),{status:a,ideName:o}=GS(t),s=(0,Q.useRef)(!1),c=n?be(n?.ideType):!1,l=n?.error||c,u=a===`connected`&&(e?.filePath||e?.text&&e.lineCount>0),d=a===`connected`&&!u,f=l&&!c&&!d&&!u,p=l&&c&&!d&&!u;(0,Q.useEffect)(()=>{if(Tu())return;if(Mn()||a!==null||p){i(`ide-status-hint`);return}if(s.current||(cf().ideHintShownCount??0)>=OA)return;let e=setTimeout((e,t)=>{Ji(!0).then(n=>{let r=n[0]?.name;r&&!e.current&&(e.current=!0,df(e=>({...e,ideHintShownCount:(e.ideHintShownCount??0)+1})),t({key:`ide-status-hint`,jsx:(0,$.jsxs)(K,{dimColor:!0,children:[`/ide for `,(0,$.jsx)(K,{color:`ide`,children:r})]}),priority:`low`}))})},3e3,s,r);return()=>clearTimeout(e)},[r,i,a,p]),(0,Q.useEffect)(()=>{if(!Tu()){if(f||p||a!==`disconnected`||!o){i(`ide-status-disconnected`);return}r({key:`ide-status-disconnected`,text:`${o} disconnected`,color:`error`,priority:`medium`})}},[r,i,a,o,f,p]),(0,Q.useEffect)(()=>{if(!Tu()){if(!p){i(`ide-status-jetbrains-disconnected`);return}r({key:`ide-status-jetbrains-disconnected`,text:`IDE plugin not connected · /status for info`,priority:`medium`})}},[r,i,p]),(0,Q.useEffect)(()=>{if(!Tu()){if(!f){i(`ide-status-install-error`);return}r({key:`ide-status-install-error`,text:`IDE extension install failed (see /status for info)`,color:`error`,priority:`medium`})}},[r,i,f])}lf();var AA=[e=>{if(MA(e.sonnet45To46MigrationTimestamp))return{key:`sonnet-46-update`,text:`Model updated to Sonnet 4.6`,color:`suggestion`,priority:`high`,timeoutMs:3e3}},e=>{let t=!!e.legacyOpusMigrationTimestamp;if(MA(e.legacyOpusMigrationTimestamp??e.opusProMigrationTimestamp))return{key:`opus-pro-update`,text:t?`Model updated to Opus 4.7 · Set CLAUDE_CODE_DISABLE_LEGACY_MODEL_REMAP=1 to opt out`:`Model updated to Opus 4.7`,color:`suggestion`,priority:`high`,timeoutMs:t?8e3:3e3}}];function jA(){ik(()=>{let e=cf(),t=[];for(let n of AA){let r=n(e);r&&t.push(r)}return t.length>0?t:null})}function MA(e){return e!==void 0&&Date.now()-e<3e3}ip(),q(),If(),lf();var NA=3;function PA(){ik(async()=>{if((cf().subscriptionNoticeCount??0)>=NA)return null;let e=await FA();return e===null?null:(df(e=>({...e,subscriptionNoticeCount:(e.subscriptionNoticeCount??0)+1})),X(`tengu_switch_to_subscription_notice_shown`,{}),{key:`switch-to-subscription`,jsx:(0,$.jsxs)(K,{color:`suggestion`,children:[`Use your existing Claude `,e,` plan with Claude Code`]}),priority:`low`})})}async function FA(){if(lp())return null;let e=await up();return e?e.account.has_claude_max?`Max`:e.account.has_claude_pro?`Pro`:null:null}Ot(),U(),Cp(),Kf(),Ru();var IA=`fast-mode-cooldown-started`,LA=`fast-mode-cooldown-expired`,RA=`fast-mode-org-changed`,zA=`fast-mode-overage-rejected`;function BA(){let{addNotification:e}=ki(),t=W(e=>e.fastMode),n=Qo();(0,Q.useEffect)(()=>{if(!Tu()&&Np())return Sp(r=>{r?e({key:RA,color:`fastMode`,priority:`immediate`,text:`Fast mode is now available · /fast to turn on`}):t&&(n(e=>({...e,fastMode:!1})),e({key:RA,color:`warning`,priority:`immediate`,text:`Fast mode has been disabled by your organization`}))})},[e,t,n]),(0,Q.useEffect)(()=>{if(!Tu()&&Np())return Pp(t=>{n(e=>({...e,fastMode:!1})),e({key:zA,color:`warning`,priority:`immediate`,text:t})})},[e,n]),(0,Q.useEffect)(()=>{if(Tu()||!t)return;let n=jp((t,n)=>{let r=VA(n,Wf(t-Date.now(),{hideTrailingZeros:!0}));e({key:IA,invalidates:[LA],text:r,color:`warning`,priority:`immediate`})}),r=bp(()=>{e({key:LA,invalidates:[IA],color:`fastMode`,text:`Fast limit reset · now using fast mode`,priority:`immediate`})});return()=>{n(),r()}},[e,t])}function VA(e,t){switch(e){case`overloaded`:return`Fast mode overloaded and is temporarily unavailable · resets in ${t}`;case`rate_limit`:return`Fast limit reached and temporarily disabled · resets in ${t}`}}q(),O();function HA({onRun:e,onCancel:t,reason:n}){let r=(0,Q.useRef)(!1);return Il(`confirm:no`,t,{context:`Confirmation`}),(0,Q.useEffect)(()=>{r.current||(r.current=!0,e())},[e]),(0,$.jsxs)(G,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(G,{children:(0,$.jsx)(K,{bold:!0,children:`Running feedback capture...`})}),(0,$.jsx)(G,{children:(0,$.jsxs)(K,{dimColor:!0,children:[`Press `,(0,$.jsx)(Cl,{shortcut:`Esc`,action:`cancel`}),` anytime`]})}),(0,$.jsx)(G,{children:(0,$.jsxs)(K,{dimColor:!0,children:[`Reason: `,n]})})]})}function UA(e){switch(e){case`feedback_survey_bad`:return!1;case`feedback_survey_good`:return!1;default:return!1}}function WA(e){return`/issue`}function GA(e){switch(e){case`feedback_survey_bad`:return`You responded "Bad" to the feedback survey`;case`feedback_survey_good`:return`You responded "Good" to the feedback survey`;default:return`Unknown reason`}}function KA(){return null}function qA(e,t){return!1}Dg(),q(),lf(),pt();function JA(e,t,n){let r=(0,Q.useRef)(!1),i=(0,Q.useRef)(n);i.current=n,(0,Q.useEffect)(()=>{if(t)return e.subscribe(()=>{let t=e.getState(),n=e.hasSelection();if(t?.isDragging){r.current=!1;return}if(!n){r.current=!1;return}if(r.current||!(cf().copyOnSelect??!0))return;let a=e.copySelectionNoClear();if(!a||!a.trim()){r.current=!0;return}r.current=!0,i.current?.(a)})},[t,e])}function YA(e){let[t]=Dl();(0,Q.useEffect)(()=>{e.setSelectionBgColor($r(t).selectionBg)},[e,t])}Ot(),q(),O(),bd();var XA=40,ZA=.3,QA=6,$A=200,ej=15,tj=15,nj=3,rj=1500,ij=150,aj=5,oj=5,sj=80,cj=3,lj=6,uj=500;function dj(e){return!(e.wheelUp||e.wheelDown||(e.leftArrow||e.rightArrow||e.upArrow||e.downArrow||e.home||e.end||e.pageUp||e.pageDown)&&(e.shift||e.meta||e.super))}function fj(e){return!e.shift||e.meta?null:e.leftArrow?`left`:e.rightArrow?`right`:e.upArrow?`up`:e.downArrow?`down`:e.home?`lineStart`:e.end?`lineEnd`:null}function pj(e,t,n){if(!e.xtermJs){if(e.wheelMode&&n-e.time>rj&&(e.wheelMode=!1,e.burstCount=0,e.mult=e.base),e.pendingFlip){if(e.pendingFlip=!1,t!==e.dir||n-e.time>$A)return e.dir=t,e.time=n,e.mult=e.base,Math.floor(e.mult);e.wheelMode=!0}let r=n-e.time;if(t!==e.dir&&e.dir!==0)return e.pendingFlip=!0,e.time=n,0;if(e.dir=t,e.time=n,e.wheelMode)if(r<oj)if(++e.burstCount>=5)e.wheelMode=!1,e.burstCount=0,e.mult=e.base;else return 1;else e.burstCount=0;if(e.wheelMode){let t=.5**(r/ij),n=Math.max(tj,e.base*2),i=1+(e.mult-1)*t+ej*t;return e.mult=Math.min(n,i,e.mult+nj),Math.floor(e.mult)}if(r>XA)e.mult=e.base;else{let t=Math.max(QA,e.base*2);e.mult=Math.min(t,e.mult+ZA)}return Math.floor(e.mult)}let r=n-e.time,i=t===e.dir;if(e.time=n,e.dir=t,i&&r<oj)return 1;if(!i||r>uj)e.mult=2,e.frac=0;else{let t=.5**(r/ij);e.mult=Math.min(r>=sj?cj:lj,1+(e.mult-1)*t+aj*t)}let a=e.mult+e.frac,o=Math.floor(a);return e.frac=a-o,o}function mj(){let e=process.env.CLAUDE_CODE_SCROLL_SPEED;if(!e)return 1;let t=parseFloat(e);return Number.isNaN(t)||t<=0?1:Math.min(t,20)}function hj(e=!1,t=1){return{time:0,mult:t,dir:0,xtermJs:e,frac:0,base:t,pendingFlip:!1,wheelMode:!1,burstCount:0}}function gj(){let e=Zl(),t=mj();return J(`wheel accel: ${e?`decay (xterm.js)`:`window (native)`} · base=${t} · TERM_PROGRAM=${process.env.TERM_PROGRAM??`unset`}`),hj(e,t)}var _j=2,vj=50,yj=200;function bj({scrollRef:e,isActive:t,onScroll:n,isModal:r=!1}){let i=eu(),{addNotification:a}=ki(),o=(0,Q.useRef)(null);function s(e){let t=$l(),n=e.length,r;switch(t){case`native`:r=`copied ${n} chars to clipboard`;break;case`tmux-buffer`:r=`copied ${n} chars to tmux buffer · paste with prefix + ]`;break;case`osc52`:r=`sent ${n} chars via OSC 52 · check terminal clipboard settings if paste fails`;break}a({key:`selection-copied`,text:r,color:`suggestion`,priority:`immediate`,timeoutMs:t===`native`?2e3:4e3})}function c(){let e=i.copySelection();e&&s(e)}function l(e,t){let n=i.getState();if(!n?.anchor||!n.focus)return;let r=e.getViewportTop(),a=r+e.getViewportHeight()-1;if(n.anchor.row<r||n.anchor.row>a||n.focus.row<r||n.focus.row>a)return;let o=Math.max(0,e.getScrollHeight()-e.getViewportHeight()),s=e.getScrollTop()+e.getPendingDelta(),c=Math.max(0,Math.min(o,s+t))-s;if(c!==0)if(c>0)i.captureScrolledRows(r,r+c-1,`above`),i.shiftSelection(-c,r,a);else{let e=-c;i.captureScrolledRows(a-e+1,a,`below`),i.shiftSelection(e,r,a)}}return El({"scroll:pageUp":()=>{let t=e.current;if(!t)return;let r=-Math.max(1,Math.floor(t.getViewportHeight()/2));l(t,r);let i=Cj(t,r);n?.(i,t)},"scroll:pageDown":()=>{let t=e.current;if(!t)return;let r=Math.max(1,Math.floor(t.getViewportHeight()/2));l(t,r);let i=Cj(t,r);n?.(i,t)},"scroll:lineUp":()=>{i.clearSelection();let t=e.current;if(!t||t.getScrollHeight()<=t.getViewportHeight())return!1;o.current??(o.current=gj()),Tj(t,pj(o.current,-1,performance.now())),n?.(!1,t)},"scroll:lineDown":()=>{i.clearSelection();let t=e.current;if(!t||t.getScrollHeight()<=t.getViewportHeight())return!1;o.current??(o.current=gj());let r=wj(t,pj(o.current,1,performance.now()));n?.(r,t)},"scroll:top":()=>{let t=e.current;t&&(l(t,-(t.getScrollTop()+t.getPendingDelta())),t.scrollTo(0),n?.(!1,t))},"scroll:bottom":()=>{let t=e.current;if(!t)return;let r=Math.max(0,t.getScrollHeight()-t.getViewportHeight());l(t,r-(t.getScrollTop()+t.getPendingDelta())),t.scrollTo(r),t.scrollToBottom(),n?.(!0,t)},"selection:copy":c},{context:`Scroll`,isActive:t}),El({"scroll:halfPageUp":()=>{let t=e.current;if(!t)return;let r=-Math.max(1,Math.floor(t.getViewportHeight()/2));l(t,r);let i=Cj(t,r);n?.(i,t)},"scroll:halfPageDown":()=>{let t=e.current;if(!t)return;let r=Math.max(1,Math.floor(t.getViewportHeight()/2));l(t,r);let i=Cj(t,r);n?.(i,t)},"scroll:fullPageUp":()=>{let t=e.current;if(!t)return;let r=-Math.max(1,t.getViewportHeight());l(t,r);let i=Cj(t,r);n?.(i,t)},"scroll:fullPageDown":()=>{let t=e.current;if(!t)return;let r=Math.max(1,t.getViewportHeight());l(t,r);let i=Cj(t,r);n?.(i,t)}},{context:`Scroll`,isActive:t}),Xl((t,r,i)=>{let a=e.current;if(!a)return;let o=Dj(a,Ej(t,r),e=>l(a,e));o!==null&&(n?.(o,a),i.stopImmediatePropagation())},{isActive:t&&r}),Xl((e,t,n)=>{if(!i.hasSelection())return;if(t.escape){i.clearSelection(),n.stopImmediatePropagation();return}if(t.ctrl&&!t.shift&&!t.meta&&e===`c`){c(),n.stopImmediatePropagation();return}let r=fj(t);if(r){i.moveFocus(r),n.stopImmediatePropagation();return}dj(t)&&i.clearSelection()},{isActive:t}),xj(e,i,t,n),JA(i,t,s),YA(i),null}function xj(e,t,n,r){let i=(0,Q.useRef)(null),a=(0,Q.useRef)(0),o=(0,Q.useRef)(0),s=(0,Q.useRef)(0),c=(0,Q.useRef)(r);c.current=r,(0,Q.useEffect)(()=>{if(!n)return;function r(){a.current=0,i.current&&(clearInterval(i.current),i.current=null)}function l(){let n=t.getState(),i=e.current,o=a.current;if(!n?.isDragging||!n.focus||!i||o===0||++s.current>yj){r();return}if(i.getPendingDelta()!==0)return;let l=i.getViewportTop(),u=l+i.getViewportHeight()-1;if(o<0){if(i.getScrollTop()<=0){r();return}let e=Math.min(_j,i.getScrollTop());t.captureScrolledRows(u-e+1,u,`below`),t.shiftAnchor(e,0,u),i.scrollBy(-2)}else{let e=Math.max(0,i.getScrollHeight()-i.getViewportHeight());if(i.getScrollTop()>=e){r();return}let n=Math.min(_j,e-i.getScrollTop());t.captureScrolledRows(l,l+n-1,`above`),t.shiftAnchor(-n,l,u),i.scrollBy(_j)}c.current?.(!1,i)}function u(e){o.current=e,a.current!==e&&(r(),a.current=e,s.current=0,l(),a.current===e&&(i.current=setInterval(l,vj)))}function d(){let n=e.current;if(!n){r();return}let i=n.getViewportTop(),a=i+n.getViewportHeight()-1,s=t.getState();(!s?.isDragging||s.scrolledOffAbove.length===0&&s.scrolledOffBelow.length===0)&&(o.current=0);let c=Sj(s,i,a,o.current);if(c===0){if(o.current!==0&&s?.focus){let e=s.focus.row<i?-1:+(s.focus.row>a);e!==0&&e!==o.current&&(s.scrolledOffAbove=[],s.scrolledOffBelow=[],s.scrolledOffAboveSW=[],s.scrolledOffBelowSW=[],o.current=0)}r()}else u(c)}let f=t.subscribe(d);return()=>{f(),r(),o.current=0}},[n,e,t])}function Sj(e,t,n,r=0){if(!e?.isDragging||!e.anchor||!e.focus)return 0;let i=e.focus.row,a=i<t?-1:+(i>n);return r===0?e.anchor.row<t||e.anchor.row>n?0:a:a===r?a:0}function Cj(e,t){let n=Math.max(0,e.getScrollHeight()-e.getViewportHeight()),r=e.getScrollTop()+e.getPendingDelta()+t;return r>=n?(e.scrollTo(n),e.scrollToBottom(),!0):(e.scrollTo(Math.max(0,r)),!1)}function wj(e,t){let n=Math.max(0,e.getScrollHeight()-e.getViewportHeight());return e.getScrollTop()+e.getPendingDelta()+t>=n?(e.scrollToBottom(),!0):(e.scrollBy(t),!1)}function Tj(e,t){if(e.getScrollTop()+e.getPendingDelta()-t<=0){e.scrollTo(0);return}e.scrollBy(-t)}function Ej(e,t){if(t.meta)return null;if(!t.ctrl&&!t.shift){if(t.upArrow)return`lineUp`;if(t.downArrow)return`lineDown`;if(t.home)return`top`;if(t.end)return`bottom`}if(t.ctrl){if(t.shift)return null;switch(e){case`u`:return`halfPageUp`;case`d`:return`halfPageDown`;case`b`:return`fullPageUp`;case`f`:return`fullPageDown`;case`n`:return`lineDown`;case`p`:return`lineUp`;default:return null}}let n=e[0];if(!n||e!==n.repeat(e.length))return null;if(n===`G`||n===`g`&&t.shift)return`bottom`;if(t.shift)return null;switch(n){case`g`:return`top`;case`j`:return`lineDown`;case`k`:return`lineUp`;case` `:return`fullPageDown`;case`b`:return`fullPageUp`;default:return null}}function Dj(e,t,n){switch(t){case null:return null;case`lineUp`:case`lineDown`:{let r=t===`lineDown`?1:-1;return n(r),Cj(e,r)}case`halfPageUp`:case`halfPageDown`:{let r=Math.max(1,Math.floor(e.getViewportHeight()/2)),i=t===`halfPageDown`?r:-r;return n(i),Cj(e,i)}case`fullPageUp`:case`fullPageDown`:{let r=Math.max(1,e.getViewportHeight()),i=t===`fullPageDown`?r:-r;return n(i),Cj(e,i)}case`top`:return n(-(e.getScrollTop()+e.getPendingDelta())),e.scrollTo(0),!1;case`bottom`:{let t=Math.max(0,e.getScrollHeight()-e.getViewportHeight());return n(t-(e.getScrollTop()+e.getPendingDelta())),e.scrollTo(t),e.scrollToBottom(),!0}}}var Oj=r({useProactive:()=>kj});function kj(e){let t=(0,Aj.useRef)(e);t.current=e,(0,Aj.useEffect)(()=>{if(!ym())return;let e=null,n=!1,r=!1;function i(){cm(Date.now()+jj),e=setTimeout(()=>{if(e=null,!om()){i();return}let{isLoading:a,queuedCommandsLength:o,hasActiveLocalJsxUI:s,isInPlanMode:c}=t.current;if(a||c||s||o>0||r){i();return}r=!0,(async()=>{let e=await In({basePrompt:`<${xf}>${new Date().toLocaleTimeString()}</${xf}>`,currentDir:cd(),shouldCreate:()=>!n});if(n){await qc({commands:e});return}let r=[];try{for(let n of e)t.current.onQueueTick(n),r.push(n)}catch(t){throw await qc({commands:e.filter(e=>!r.includes(e))}),t}})().catch(e=>J(`[Proactive] failed to create tick: ${e}`,{level:`error`})).finally(()=>{r=!1}),i()},jj)}return i(),()=>{n=!0,e!==null&&(clearTimeout(e),e=null),cm(null)}},[ym(),fm(),_m()])}var Aj,jj,Mj=t((()=>{Aj=n(Yl(),1),Df(),sd(),we(),bd(),jj=3e4}));function Nj(e){if(e.tokenBudget!==null){let t=Math.max(0,e.tokenBudget-e.tokensUsed);return`Tokens used: ${e.tokensUsed} / ${e.tokenBudget} (${t} remaining)`}return`Tokens used: ${e.tokensUsed}`}function Pj(e){let t=ei(e),n=Nj(e),r=`Continuation turns executed: ${e.turnsExecuted}`;return`<goal-steering type="continuation">
79
- You have an active goal to work on. Continue making progress.
80
-
81
- ## Active Goal
82
- ${e.objective}
83
-
84
- ## Status
85
- - Elapsed active time: ${t}
86
- - ${n}
87
- - ${r}
88
-
89
- ## Instructions
90
-
91
- Continue working towards the goal. Do NOT narrow the scope of the goal — even if you cannot complete everything in one turn, maintain the full objective and make as much progress as possible.
92
-
93
- When you believe the goal is fully achieved, use the GoalTool to mark it complete. Before doing so, perform a strict Completion Audit:
94
-
95
- ### Completion Audit
96
- 1. Derive concrete requirements from the objective and any referenced files.
97
- 2. Preserve the original scope — do not redefine success around what is already done.
98
- 3. For every explicit requirement, identify authoritative evidence (test output, file content, command result).
99
- 4. Treat tests, manifests, and verifiers as evidence only after confirming they actually cover the requirement.
100
- 5. Treat uncertain or indirect evidence as "not achieved".
101
- 6. The audit must PROVE completion, not merely fail to find remaining work.
102
-
103
- ### Blocked Audit
104
- If you encounter an obstacle you genuinely cannot overcome:
105
- - Do NOT mark blocked on the first encounter.
106
- - The same blocking condition must persist for at least 3 consecutive continuation turns before you may mark blocked.
107
- - "Difficult", "slow", or "partially incomplete" is NOT blocked.
108
- - If blocked, use the GoalTool with status "blocked" and a clear reason.
109
-
110
- Resume working now.
111
- </goal-steering>`}function Fj(e){return`<goal-steering type="budget_limit">
112
- ## Token Budget Reached
113
-
114
- Your token budget for this goal has been exhausted.
115
-
116
- - Goal: ${e.objective}
117
- - Tokens used: ${e.tokensUsed}${e.tokenBudget===null?``:` / ${e.tokenBudget}`}
118
- - Active time: ${ei(e)}
119
-
120
- **Stop all substantive work immediately.** Do NOT start new file edits, tool calls, or explorations.
121
-
122
- Instead, provide a brief summary:
123
- 1. What has been accomplished so far.
124
- 2. What remains to be done.
125
- 3. Any blockers or issues encountered.
126
-
127
- Then use the GoalTool to mark the goal as complete (if truly done) or leave it in its current state for the user to decide.
128
- </goal-steering>`}var Ij=t((()=>{})),Lj=r({useGoalContinuation:()=>zj});function Rj(e){J(`[goal] hook: ${e}`)}function zj(e){let t=(0,Bj.useRef)(e);t.current=e;let n=(0,Bj.useRef)(!1),r=(0,Bj.useRef)(!1);(0,Bj.useLayoutEffect)(()=>{if(e.isLoading){n.current=!1;return}if(e.isQueryActiveNow?.()){Rj(`skip: queryActiveNow=true`);return}if(e.wasAborted){Rj(`skip: wasAborted=true`);return}if(n.current)return;if(Na().length>0){Rj(`skip: yielding to queued user messages`);return}if(e.hasActiveLocalJsxUI){Rj(`skip: activeLocalJsxUI`);return}if(e.isInPlanMode){Rj(`skip: planMode`);return}let t=Ur();if(!t){r.current=!1;return}if(t.status===`active`&&(r.current=!1),t.status===`budget_limited`&&!r.current){r.current=!0,n.current=!0;let e=Fj(t);J(`[goal] hook: budget limit reached, injecting wrap-up prompt`),uc({value:e,mode:`prompt`,priority:`now`,isMeta:!0,origin:`goal-budget-limit`,skipSlashCommands:!0});return}if(t.status!==`active`){Rj(`skip: status="${t.status}" (not active)`);return}if(t.turnsExecuted>=150){Ks()&&(Ic(),e.onMaxTurnsReached?.()),J(`[goal] hook: MAX_GOAL_TURNS (150) reached, stopping`);return}n.current=!0;let i=rt();Ic();let a=Pj(t);J(`[goal] hook: enqueuing turn ${i} for "${t.objective.slice(0,60)}"`),uc({value:a,mode:`prompt`,priority:`now`,isMeta:!0,origin:`goal-continuation`,skipSlashCommands:!0}),e.onContinuationEnqueued?.({turn:i,objective:t.objective})},[e.isLoading,e.wasAborted,e.queuedCommandsLength,e.hasActiveLocalJsxUI,e.isInPlanMode])}var Bj,Vj=t((()=>{Bj=n(Yl(),1),bd(),Jt(),Ij(),ps()}));Ru(),Vo(),Nd(),u(),q(),ht(),Ph(),Ot(),bd(),s(),Kf(),we(),le(),ae(),oh(),Ke(),Wn(),at(),Mo(),Le(),pd(),Ef(),sd(),dc(),ue(),bi(),lf(),xc(),If(),P(),Wm(),Df(),nr(),Je(),jg(),Vr(),Lc(),Vh(),U(),Ki(),he(),j(),Uc(),jr(),ps(),Gt(),bc(),R(),b();var Hj=(um(),e(vm)),Uj=e=>()=>{},Wj=()=>!1,Gj=()=>null,Kj=(e,t)=>!1,qj=(Mj(),e(Oj)).useProactive,Jj=(Vj(),e(Lj)).useGoalContinuation,Yj=[],Xj=3e3;function Zj({showAllInTranscript:e,virtualScroll:t,searchBadge:n,suppressShowAll:r=!1,status:i}){let a=an(`app:toggleTranscript`,`Global`,`ctrl+o`),o=an(`transcript:toggleShowAll`,`Transcript`,`ctrl+e`);return(0,$.jsxs)(G,{noSelect:!0,alignItems:`center`,alignSelf:`center`,borderTopDimColor:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,borderStyle:`single`,marginTop:1,paddingLeft:2,width:`100%`,children:[(0,$.jsxs)(K,{dimColor:!0,children:[`Showing detailed transcript · `,a,` to toggle`,n?` · n/N to navigate`:t?` · ${d.arrowUp}${d.arrowDown} scroll · home/end top/bottom`:r?``:` · ${o} to ${e?`collapse`:`show all`}`]}),i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(G,{flexGrow:1}),(0,$.jsxs)(K,{children:[i,` `]})]}):n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(G,{flexGrow:1}),(0,$.jsxs)(K,{dimColor:!0,children:[n.current,`/`,n.count,` `]})]}):null]})}function Qj({jumpRef:e,count:t,current:n,onClose:r,onCancel:i,setHighlight:a,initialQuery:o}){let{query:s,cursorOffset:c}=Qh({isActive:!0,initialQuery:o,onExit:()=>r(s),onCancel:i}),[l,u]=Q.useState(`building`);Q.useEffect(()=>{let t=!0,n,r=e.current?.warmSearchIndex;if(!r){u(null);return}return u(`building`),r().then(e=>{t&&(e<20?u(null):(u({ms:e}),n=setTimeout(()=>t&&u(null),2e3)))}),()=>{t=!1,n&&clearTimeout(n)}},[e]);let d=l!==`building`;(0,Q.useEffect)(()=>{d&&(e.current?.setSearchQuery(s),a(s))},[e,s,a,d]);let f=c,p=f<s.length?s[f]:` `;return(0,$.jsxs)(G,{borderTopDimColor:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,borderStyle:`single`,marginTop:1,paddingLeft:2,width:`100%`,noSelect:!0,children:[(0,$.jsx)(K,{children:`/`}),(0,$.jsx)(K,{children:s.slice(0,f)}),(0,$.jsx)(K,{inverse:!0,children:p}),f<s.length&&(0,$.jsx)(K,{children:s.slice(f+1)}),(0,$.jsx)(G,{flexGrow:1}),l===`building`?(0,$.jsx)(K,{dimColor:!0,children:`indexing… `}):l?(0,$.jsxs)(K,{dimColor:!0,children:[`indexed in `,l.ms,`ms `]}):t===0&&s?(0,$.jsx)(K,{color:`error`,children:`no matches `}):t>0?(0,$.jsxs)(K,{dimColor:!0,children:[n,`/`,t,` `]}):null]})}var $j=[`⠂`,`⠐`],eM=`✳`,tM=960;function nM({isAnimating:e,title:t,disabled:n,noPrefix:r}){let i=Ll(),[a,o]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{if(n||r||!e||!i)return;let t=setInterval(e=>e(e=>(e+1)%$j.length),tM,o);return()=>clearInterval(t)},[n,r,e,i]);let s=e?$j[a]??eM:eM;return zl(n?null:r?t:`${s} ${t}`),null}var rM=`<${Tf}>`;function iM(e){return e.type===`text`&&typeof e.text==`string`&&e.text.includes(rM)}function aM({commands:t,debug:n,initialTools:r,initialMessages:i,pendingHookMessages:a,initialFileHistorySnapshots:s,initialContentReplacements:c,initialAgentName:l,initialAgentColor:u,mcpClients:d,dynamicMcpConfig:f,autoConnectIdeFlag:p,strictMcpConfig:m=!1,systemPrompt:h,appendSystemPrompt:g,onBeforeQuery:v,onTurnComplete:b,disabled:x=!1,mainThreadAgentDefinition:S,disableSlashCommands:C=!1,taskListId:w,remoteSessionConfig:T,directConnectConfig:E,sshSession:O,thinkingConfig:ee}){let j=!!T,te=(0,Q.useMemo)(()=>o(process.env.CLAUDE_CODE_DISABLE_TERMINAL_TITLE),[]),ne=(0,Q.useMemo)(()=>o(process.env.CLAUDE_CODE_DISABLE_VIRTUAL_SCROLL),[]);(0,Q.useMemo)(()=>o(process.env.CLAUDE_CODE_DISABLE_MESSAGE_ACTIONS),[]),(0,Q.useEffect)(()=>(J(`[REPL:mount] REPL mounted, disabled=${x}`),()=>J(`[REPL:unmount] REPL unmounting`)),[x]);let[M,N]=(0,Q.useState)(S),P=W(e=>e.toolPermissionContext),F=W(e=>e.verbose),re=W(e=>e.mcp),I=W(e=>e.plugins),ie=W(e=>e.agentDefinitions),ae=W(e=>e.fileHistory),oe=W(e=>e.initialMessage),se=VS(),ce=W(e=>e.spinnerTip),le=W(e=>e.expandedView)===`tasks`,ue=W(e=>e.tasks),R=W(e=>e.elicitation),fe=W(e=>e.viewingAgentTaskId),z=Qo(),me=fe?ue[fe]:void 0,he=Qr(me)&&me.retain&&!me.diskLoaded;(0,Q.useEffect)(()=>{if(!fe||!he)return;let e=fe;$s(Xe(e)).then(t=>{z(n=>{let r=n.tasks[e];if(!Qr(r)||r.diskLoaded||!r.retain)return n;let i=r.messages??[],a=new Set(i.map(e=>e.uuid)),o=t?t.messages.filter(e=>!a.has(e.uuid)):[];return{...n,tasks:{...n.tasks,[e]:{...r,messages:[...o,...i],diskLoaded:!0}}}})})},[fe,he,z]);let ge=xa(),_e=jl(),ve=Bh(),[ye,be]=(0,Q.useState)(t);EO(j?void 0:Ku(),be);let xe=Q.useSyncExternalStore(Hj?.subscribeToProactiveChanges??Uj,Hj?.isProactiveActive??Wj),we=Q.useSyncExternalStore(Hj?.subscribeToProactiveChanges??Uj,Hj?.getNextTickAt??Gj),De=(0,Q.useMemo)(()=>Ra(P),[P,xe]);yk();let[Oe,ke]=(0,Q.useState)(f),Ae=(0,Q.useCallback)(e=>{ke(e)},[ke]),[Ne,Fe]=(0,Q.useState)(`prompt`),[Ie,Le]=(0,Q.useState)(!1),[Re,ze]=(0,Q.useState)(!1),[Be,Ve]=(0,Q.useState)(``),He=(0,Q.useRef)(0),Ue=(0,Q.useRef)(void 0),We=(0,Q.useRef)(!1),{addNotification:Ge,removeNotification:Ke}=ki(),Je=Kj,Ye=wO(d,re.clients),[Ze,$e]=(0,Q.useState)(void 0),[et,rt]=(0,Q.useState)(null),[it,at]=(0,Q.useState)(null),[ot,st]=(0,Q.useState)(!1),lt=W(e=>e.showRemoteCallout),[dt,ft]=(0,Q.useState)(()=>hA());jA(),PA(),kA({ideSelection:Ze,mcpClients:Ye,ideInstallationStatus:it}),Tk({mcpClients:Ye}),_A(),vA(),ng(),wA(ve),BA(),TA(ve),DA(),ak(),fk(),Ok();let{recommendation:pt,handleResponse:mt}=Wk(),{recommendation:ht,handleResponse:gt}=qk(),vt=eA(),yt=(0,Q.useMemo)(()=>[...De,...r],[De,r]);Qm({enabled:!j});let bt=nt();(0,Q.useEffect)(()=>{j||xA(z)},[z,j]);let xt=Mh(yt,re.tools,P),{tools:St,allowedAgentTypes:Ct}=(0,Q.useMemo)(()=>{if(!M)return{tools:xt,allowedAgentTypes:void 0};let e=Hs(M,xt,!1,!0);return{tools:e.resolvedTools,allowedAgentTypes:e.allowedAgentTypes}},[M,xt]),wt=TO(TO(ye,I.commands),re.commands),Tt=(0,Q.useMemo)(()=>C?[]:wt,[C,wt]);Ty(j?Yj:re.clients),OO(j?Yj:re.clients,$e);let[Et,Dt]=(0,Q.useState)(`responding`),Ot=(0,Q.useRef)(Et);Ot.current=Et;let[At,Nt]=(0,Q.useState)([]),[Pt,Ft]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{if(Pt&&!Pt.isStreaming&&Pt.streamingEndedAt){let e=3e4-(Date.now()-Pt.streamingEndedAt);if(e>0){let t=setTimeout(Ft,e,null);return()=>clearTimeout(t)}else Ft(null)}},[Pt]);let[Lt,zt]=(0,Q.useState)(null),Bt=(0,Q.useRef)(null);Bt.current=Lt;let Vt=(0,Q.useRef)(0),[Ht,Ut]=(0,Q.useState)(!1),Gt=(0,Q.useRef)(()=>{}),qt=(0,Q.useRef)(()=>{}),Yt=(0,Q.useRef)(null),Qt=(0,Q.useRef)(null),$t=(0,Q.useRef)(0),en=Q.useRef(new xy).current,tn=Q.useSyncExternalStore(en.subscribe,en.getSnapshot),[an,on]=Q.useState(T?.hasInitialPrompt??!1),B=tn||an,[cn,ln]=Q.useState(void 0),un=Q.useRef(0),dn=Q.useRef(!1),fn=Q.useRef(0),pn=Q.useRef(0),hn=Q.useRef(null),gn=Q.useCallback(()=>{fn.current=Date.now(),pn.current=0,hn.current=null},[]),_n=Q.useRef(!1);tn&&!_n.current&&gn(),_n.current=tn;let vn=Q.useCallback(e=>{on(e),e&&gn()},[gn]),bn=Q.useRef(void 0),[xn,Cn]=Q.useState(!1),[wn,Tn]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{wn?.notifications&&wn.notifications.forEach(e=>{Ge({key:`auto-updater-notification`,text:e,priority:`low`})})},[wn,Ge]),(0,Q.useEffect)(()=>{La()&&gs().then(e=>{e&&Ge({key:`tmux-mouse-hint`,text:e,priority:`low`})})},[]);let[En,Dn]=(0,Q.useState)(null),kn=(0,Q.useRef)(null),An=(0,Q.useCallback)(e=>{if(e?.isLocalJSXCommand){let{clearLocalJSX:t,...n}=e;kn.current={...n,isLocalJSXCommand:!0},Dn(n);return}if(kn.current){if(e?.clearLocalJSX){kn.current=null,Dn(null),Vt.current=Date.now();return}return}if(e?.clearLocalJSX){Dn(null);return}Dn(e)},[]),[jn,Mn]=(0,Q.useState)([]),[Nn,Fn]=(0,Q.useState)(null),[In,Ln]=(0,Q.useState)([]),[Rn,Bn]=(0,Q.useState)([]),Vn=(0,Q.useRef)(new Map),Un=W(e=>e.settings.terminalTitleFromRename)===!1?void 0:ws($u()),[Wn,Gn]=(0,Q.useState)(),Kn=(0,Q.useRef)((i?.length??0)>0),qn=M?.agentType,Jn=Un??qn??Wn??`Work Mate`,Yn=jn.length>0||Rn.length>0,Xn=En?.isLocalJSXCommand===!0&&En?.jsx!=null,Zn=B&&!Yn&&!Xn;(0,Q.useEffect)(()=>{if(B&&!Yn&&!Xn)return my(),()=>hy()},[B,Yn,Xn]);let Qn=Yn||Xn?`waiting`:B?`busy`:`idle`,$n=Qn===`waiting`?jn.length>0?`approve ${jn[0].tool.name}`:Xn?`dialog open`:`input needed`:void 0;(0,Q.useEffect)(()=>{tl({status:Qn,waitingFor:$n})},[Qn,$n]),Vl(null);let[V,tr]=(0,Q.useState)(i??[]),nr=(0,Q.useRef)(V),rr=(0,Q.useRef)(!1),H=(0,Q.useCallback)(e=>{let t=nr.current,n=typeof e==`function`?e(nr.current):e;if(nr.current=n,n.length<un.current)un.current=0;else if(n.length>t.length&&dn.current){let e=n.length-t.length;(t.length===0||n[0]===t[0]?n.slice(-e):n.slice(0,e)).some(On)?dn.current=!1:un.current=n.length}tr(n)},[]),ir=(0,Q.useCallback)(e=>{e===void 0?dn.current=!1:(un.current=nr.current.length,dn.current=!0),ln(e)},[]),{dividerIndex:ar,dividerYRef:or,onScrollAway:sr,onRepin:cr,jumpToNew:lr,shiftDivider:ur}=Mg(V.length);ok(V,H,B);let[dr,fr]=(0,Q.useState)(null),pr=(0,Q.useRef)(null),mr=(0,Q.useMemo)(()=>kg(V,ar),[ar,V.length]),hr=(0,Q.useCallback)(()=>{Yt.current?.scrollToBottom(),cr(),fr(null)},[cr,fr]),_r=V.at(-1),yr=_r!=null&&On(_r);(0,Q.useEffect)(()=>{yr&&hr()},[yr,_r,hr]);let br=(0,Q.useCallback)((e,t)=>{$t.current=Date.now(),e?cr():sr(t)},[cr,sr,z]),xr=XD(a,H),wr=(0,Q.useDeferredValue)(Q.useMemo(()=>V.length>500?V.slice(-500):V,[V])),Tr=V.length-wr.length;Tr>0&&J(`[useDeferredValue] Messages deferred by ${Tr} (${wr.length}→${V.length})`);let[Or,kr]=(0,Q.useState)(null),[jr,Mr]=(0,Q.useState)(()=>Wg()),Nr=(0,Q.useRef)(jr);Nr.current=jr;let Fr=(0,Q.useRef)(null),Ir=(0,Q.useCallback)(e=>{Je(Nr.current,e)||(Nr.current===``&&e!==``&&Date.now()-$t.current>=Xj&&hr(),Nr.current=e,Mr(e),Cn(e.trim().length>0))},[Cn,hr,Je]);(0,Q.useEffect)(()=>{if(jr.trim().length===0)return;let e=setTimeout(Cn,1500,!1);return()=>clearTimeout(e)},[jr]);let[Lr,Rr]=(0,Q.useState)(`prompt`),[Br,Vr]=(0,Q.useState)(),Hr=(0,Q.useCallback)(e=>{let t=new Set(e);be(e=>e.filter(e=>t.has(e.name)||Ce.has(e)))},[be]),[Ur,Kr]=(0,Q.useState)(new Set),qr=(0,Q.useRef)(!1),Jr=AD({config:T,setMessages:H,setIsLoading:vn,onInit:Hr,setToolUseConfirmQueue:Mn,tools:yt,setStreamingToolUses:Nt,setStreamMode:Dt,setInProgressToolUseIDs:Kr}),Yr=ND({config:E,setMessages:H,setIsLoading:vn,setToolUseConfirmQueue:Mn,tools:yt}),Xr=PD({session:O,setMessages:H,setIsLoading:vn,setToolUseConfirmQueue:Mn,tools:yt}),$r=Xr.isRemoteMode?Xr:Yr.isRemoteMode?Yr:Jr,[ei,ti]=(0,Q.useState)({}),[ri,ii]=(0,Q.useState)(0),oi=(0,Q.useRef)(0),ci=(0,Q.useRef)([]),li=(0,Q.useCallback)(e=>{let t=oi.current;if(oi.current=e(t),oi.current>t){let e=ci.current;if(e.length>0){let t=e.at(-1);t.lastTokenTime=Date.now(),t.endResponseLength=oi.current}}},[]),[ui,di]=(0,Q.useState)(null),fi=!(W(e=>e.settings.prefersReducedMotion)??!1)&&!au(),pi=(0,Q.useCallback)(e=>{fi&&di(e)},[fi]),mi=ui&&fi&&ui.substring(0,ui.lastIndexOf(`
129
- `)+1)||null,[hi,_i]=(0,Q.useState)(0),[vi,yi]=(0,Q.useState)(null),[bi,xi]=(0,Q.useState)(null),[Si,wi]=(0,Q.useState)(null),[Ti,Ei]=(0,Q.useState)(!1),[Di,Oi]=(0,Q.useState)(void 0),[Ai,ji]=(0,Q.useState)(!1),[Ni,Pi]=(0,Q.useState)(d_()),[Fi,Ii]=(0,Q.useState)(null),zi=(0,Q.useRef)(!1),Bi=(0,Q.useRef)(hi);Bi.current=hi;let[Vi]=(0,Q.useState)(()=>({current:ni(i,c)}));ut(()=>{Vi.current=Wr()});let[Hi,Ui]=(0,Q.useState)(cf().hasAcknowledgedCostThreshold),[Wi,Gi]=(0,Q.useState)(`INSERT`),[Ki,Ji]=(0,Q.useState)(!1),[Yi,Zi]=(0,Q.useState)(!1),[Qi,$i]=(0,Q.useState)(!1),ta=Ll(),na=(0,Q.useRef)(ta);na.current=ta;let[ra]=Dl(),aa=Q.useRef(!1),oa=(0,Q.useCallback)(()=>{if(aa.current)return;aa.current=!0;let e=nr.current.slice(Na.current);for(let t of Us(e))Ma.current.add(t);Na.current=nr.current.length,mk({theme:ra,readFileState:ja.current,bashTools:Ma.current}).then(async e=>{if(e){let t=await e.content({theme:ra});z(e=>({...e,spinnerTip:t})),hk(e)}else z(e=>e.spinnerTip===void 0?e:{...e,spinnerTip:void 0})})},[z,ra]),sa=(0,Q.useCallback)(()=>{vn(!1),ir(void 0),oi.current=0,ci.current=[],di(null),Nt([]),yi(null),xi(null),wi(null),oa(),Mm(),Vs()},[oa]),ua=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{{if(P.mode!==`auto`){ua.current=!1;return}if(ua.current||(cf().autoPermissionsNotificationCount??0)>=3)return;let e=setTimeout((e,t)=>{e.current=!0,df(e=>{let t=e.autoPermissionsNotificationCount??0;return t>=3?e:{...e,autoPermissionsNotificationCount:t+1}}),t(e=>[...e,gr(Ek,`warning`)])},800,ua,H);return()=>clearTimeout(e)}},[P.mode,H]);let da=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(da.current)return;let e=Sr();if(!e?.creationDurationMs||e.usedSparsePaths||e.creationDurationMs<15e3)return;da.current=!0;let t=Math.round(e.creationDurationMs/1e3);H(e=>[...e,gr(`Worktree creation took ${t}s. For large repos, set \`worktree.sparsePaths\` in .workmate/settings.json to check out only the directories you need — e.g. \`{"worktree": {"sparsePaths": ["src", "packages/foo"]}}\`.`,`info`)])},[H]);let fa=(0,Q.useMemo)(()=>{let e=V.findLast(e=>e.type===`assistant`);if(e?.type!==`assistant`)return!1;let t=e.message?.content,n=(Array.isArray(t)?t:[]).filter(e=>e.type===`tool_use`&&Ur.has(e.id));return n.length>0&&n.every(e=>e.type===`tool_use`&&e.name===`Sleep`)},[V,Ur]),{onBeforeQuery:ma,onTurnComplete:ha,render:ga}=qD({enabled:!1,setMessages:H,inputValue:jr,setInputValue:Ir,setToolJSX:An}),_a=(!En||En.showSpinner===!0)&&jn.length===0&&Rn.length===0&&(B||cn||Ac()>0)&&!fa&&!mi,va=jn.length>0||Rn.length>0||In.length>0||R.queue.length>0,ya=HO(V,B,ri,`session`,va),ba=KD(H),Sa=qA(V,ri),Ca=(0,Q.useMemo)(()=>({...ya,handleSelect:e=>{qa.current=!1;let t=ya.handleSelect(e);e===`bad`&&!t&&UA(`feedback_survey_bad`)&&(Ka(`feedback_survey_bad`),qa.current=!0)}}),[ya]),Ta=XO(V,B,va,{enabled:!j}),Da=KO(V,B,va,{enabled:!j});MO({autoConnectIdeFlag:p,ideToInstallExtension:et,setDynamicMcpConfig:ke,setShowIdeOnboarding:st,setIDEInstallationState:at}),bk(s,ae,e=>z(t=>({...t,fileHistory:e})));let Oa=(0,Q.useCallback)(async(t,n,r)=>{let i=performance.now();try{let a=Cr(n.messages),o=Dc();await Ci(`resume`,{getAppState:()=>ge.getState(),setAppState:z,signal:AbortSignal.timeout(o),timeoutMs:o});let s=await Er(`resume`,{sessionId:t,agentType:M?.agentType,model:ve});a.push(...s),r===`fork`?Ea(n,Rt(t)):Ga(n,Rt(t)),vh(n,z),n.fileHistorySnapshots&&vr(n);let{agentDefinition:c}=gh(n.agentSetting,S,ie);N(c),z(e=>({...e,agent:c?.agentType})),z(e=>({...e,standaloneAgentContext:_h(n.agentName,n.agentColor)})),pe(n.agentName),Ia(a,n.projectPath??Gu()),sa(),zt(null),Pi(t);let l=er(t);if(nn(),Wu(),Qu(Rt(t),n.fullPath?r_(n.fullPath):null),await wo(),Mi(),ia(n),n.goal){let{hydrateGoalFromTranscript:r}=(Xi(),e(io)),i=new Map;i.set(t,n.goal),r(i,t)}if(Kn.current=!0,Gn(void 0),r!==`fork`)yh(),bh(n.worktreeSession),Zr(),ca({abortController:new AbortController,getAppState:()=>ge.getState(),setAppState:z});else{let e=Sr();e&&us(e)}l&&rd(l),Vi.current&&r!==`fork`&&(Vi.current=qe(a,n.contentReplacements??[])),H(()=>a),An(null),Ir(``),X(`tengu_session_resumed`,{entrypoint:r,success:!0,resume_duration_ms:Math.round(performance.now()-i)})}catch(e){throw X(`tengu_session_resumed`,{entrypoint:r,success:!1}),e}},[sa,z]),[ka]=(0,Q.useState)(()=>ks(100)),ja=(0,Q.useRef)(ka),Ma=(0,Q.useRef)(new Set),Na=(0,Q.useRef)(0),Pa=(0,Q.useRef)(new Set),Fa=(0,Q.useRef)(new Set),Ia=(0,Q.useCallback)((e,t)=>{let n=jt(e,t,100);ja.current=lo(ja.current,n);for(let t of Us(e))Ma.current.add(t)},[]);(0,Q.useEffect)(()=>{i&&i.length>0&&(Ia(i,Gu()),ca({abortController:new AbortController,getAppState:()=>ge.getState(),setAppState:z}))},[]);let{status:za,reverify:Ba}=ZD(),[Va,Ka]=(0,Q.useState)(null),qa=(0,Q.useRef)(!1),[Ja,Ya]=(0,Q.useState)(null),[Xa,Za]=(0,Q.useState)(!1),$a=!B&&Ai;function no(){if(Xa||Ja)return;if(Ti)return`message-selector`;if(xn)return;if(In[0])return`sandbox-permission`;let e=!En||En.shouldContinueAnimation;if(e&&jn[0])return`tool-permission`;if(e&&Rn[0])return`prompt`;if(e&&R.queue[0])return`elicitation`;if(e&&$a)return`cost`;if(e&&Fi)return`idle-return`;if(e&&ot)return`ide-onboarding`;if(e&&lt)return`remote-callout`;if(e&&pt)return`lsp-recommendation`;if(e&&ht)return`plugin-hint`;if(e&&vt.visible)return`search-extra-tools-hint`;if(e&&dt)return`desktop-upsell`}let ro=no(),ao=xn&&(In[0]||jn[0]||Rn[0]||R.queue[0]||$a);bn.current=ro,(0,Q.useEffect)(()=>{if(!B)return;let e=ro===`tool-permission`,t=Date.now();e&&hn.current===null?hn.current=t:!e&&hn.current!==null&&(pn.current+=t-hn.current,hn.current=null)},[ro,B]);let oo=(0,Q.useRef)(ro);(0,Q.useLayoutEffect)(()=>{oo.current===`tool-permission`!=(ro===`tool-permission`)&&hr(),oo.current=ro},[ro,hr]);function uo(){if(ro!==`elicitation`){if(Vt.current!==0&&Date.now()-Vt.current<500){Vt.current=0,J(`[onCancel] suppressed: local-jsx panel just dismissed`);return}if(Vt.current=0,J(`[onCancel] focusedInputDialog=${ro} streamMode=${Et}`),Hj?.pauseProactive(),en.getSnapshot()){let{getGoal:t,pauseGoal:n}=(Jt(),e(gi)),{persistCurrentGoal:r}=(Xi(),e(io));t()?.status===`active`&&(n(),r())}if(Ut(!0),en.forceEnd(),zi.current=!1,ui?.trim()&&H(e=>[...e,qi({content:ui})]),sa(),Vu(null),ro===`tool-permission`)jn[0]?.onAbort(),Mn([]);else if(ro===`prompt`){for(let e of Rn)e.reject(Error(`Prompt cancelled by user`));Bn([]),Lt?.abort(`user-cancel`)}else $r.isRemoteMode?$r.cancelRequest():Lt?.abort(`user-cancel`);zt(null),ha(nr.current,!0)}}let fo=(0,Q.useCallback)(()=>{let e=Vc(jr,0);e&&(Ir(e.text),Rr(`prompt`),e.images.length>0&&ti(t=>{let n={...t};for(let t of e.images)n[t.id]=t;return n}))},[Ir,Rr,jr,ti]),po={setToolUseConfirmQueue:Mn,onCancel:uo,onAgentsKilled:()=>H(e=>[...e,co()]),isMessageSelectorVisible:Ti||!!Ki,screen:Ne,abortSignal:Lt?.signal,popCommandFromQueue:fo,vimMode:Wi,isLocalJSXCommand:En?.isLocalJSXCommand,isSearchingHistory:Yi,isHelpOpen:Qi,inputMode:Lr,inputValue:jr,streamMode:Et};(0,Q.useEffect)(()=>{Ou()>=5&&!Ai&&!Hi&&(X(`tengu_cost_threshold_reached`,{}),Ui(!0),Wa()&&ji(!0))},[V,Ai,Hi]);let mo=(0,Q.useCallback)(async e=>new Promise(t=>{let n=!1;function r(e){n||(n=!0,t(e))}Ln(t=>[...t,{hostPattern:e,resolvePromise:r}])}),[z,ge]);(0,Q.useEffect)(()=>{let e=pa.getSandboxUnavailableReason();if(e){if(pa.isSandboxRequired()){process.stderr.write(`\nError: sandbox required but unavailable: ${e}\n sandbox.failIfUnavailable is set — refusing to start without a working sandbox.\n\n`),Ri(1,`other`);return}J(`sandbox disabled: ${e}`,{level:`warn`}),Ge({key:`sandbox-unavailable`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(K,{color:`warning`,children:`sandbox disabled`}),(0,$.jsx)(K,{dimColor:!0,children:` · /sandbox`})]}),priority:`medium`})}},[Ge]),pa.isSandboxingEnabled()&&pa.initialize(mo).catch(e=>{process.stderr.write(`\n❌ Sandbox Error: ${fd(e)}\n`),Ri(1,`other`)});let ho=(0,Q.useCallback)((e,t)=>{z(n=>({...n,toolPermissionContext:{...e,mode:t?.preserveMode?n.toolPermissionContext.mode:e.mode}})),setImmediate(e=>{e(e=>(e.forEach(e=>{e.recheckPermission()}),e))},Mn)},[z,Mn]),go=hO(Mn,ho),_o=(0,Q.useCallback)((e,t,r,i)=>{let a=ge.getState(),o=()=>{let e=ge.getState(),t=Li(e.toolPermissionContext,e.mcp.tools),n=th(yt,t,e.toolPermissionContext.mode);return M?Hs(M,n,!1,!0).resolvedTools:n};return{abortController:r,options:{commands:Tt,tools:o(),debug:n,verbose:a.verbose,mainLoopModel:i,thinkingConfig:a.thinkingEnabled===!1?{type:`disabled`}:ee,mcpClients:CO(d,a.mcp.clients),mcpResources:a.mcp.resources,ideInstallationStatus:it,isNonInteractiveSession:!1,dynamicMcpConfig:Oe,theme:ra,agentDefinitions:Ct?{...a.agentDefinitions,allowedAgentTypes:Ct}:a.agentDefinitions,customSystemPrompt:h,appendSystemPrompt:g,refreshTools:o},getAppState:()=>ge.getState(),setAppState:z,messages:e,setMessages:H,updateFileHistoryState(e){z(t=>{let n=e(t.fileHistory);return n===t.fileHistory?t:{...t,fileHistory:n}})},updateAttributionState(e){z(t=>{let n=e(t.attribution);return n===t.attribution?t:{...t,attribution:n}})},openMessageSelector:()=>{x||Ei(!0)},onChangeAPIKey:Ba,readFileState:ja.current,setToolJSX:An,addNotification:Ge,appendSystemMessage:e=>H(t=>[...t,e]),sendOSNotification:e=>{ny(e,_e)},onChangeDynamicMcpConfig:Ae,onInstallIDEExtension:rt,nestedMemoryAttachmentTriggers:new Set,loadedNestedMemoryPaths:Fa.current,dynamicSkillDirTriggers:new Set,discoveredSkillNames:Pa.current,setResponseLength:li,pushApiMetricsEntry:void 0,setStreamMode:Dt,onCompactProgress:e=>{switch(e.type){case`hooks_start`:xi(`claudeBlue_FOR_SYSTEM_SPINNER`),wi(`claudeBlueShimmer_FOR_SYSTEM_SPINNER`),yi(e.hookType===`pre_compact`?`Running PreCompact hooks…`:e.hookType===`post_compact`?`Running PostCompact hooks…`:`Running SessionStart hooks…`);break;case`compact_start`:yi(`Compacting conversation`);break;case`compact_end`:yi(null),xi(null),wi(null);break}},setInProgressToolUseIDs:Kr,setHasInterruptibleToolInProgress:e=>{qr.current=e},resume:Oa,setConversationId:Pi,requestPrompt:void 0,contentReplacementState:Vi.current}},[Tt,yt,M,n,d,it,Oe,ra,Ct,ge,z,Ba,Ge,H,Ae,Oa,(0,Q.useCallback)((e,t)=>n=>new Promise((r,i)=>{Bn(a=>[...a,{request:n,title:e,toolInputSummary:t,resolve:r,reject:i}])}),[]),x,h,g,Pi]),{handleBackgroundSession:vo}=PO({setMessages:H,setIsLoading:vn,resetLoadingState:sa,setAbortController:zt,onBackgroundQuery:(0,Q.useCallback)(()=>{Lt?.abort(`background`);let e=fl(e=>e.mode===`task-notification`);(async()=>{let t=_o(nr.current,[],new AbortController,ve),[n,r,i]=await Promise.all([wa(t.options.tools,ve,Array.from(P.additionalWorkingDirectories.keys()),t.options.mcpClients),la(),ko()]),a=Ha({mainThreadAgentDefinition:M,toolUseContext:t,customSystemPrompt:h,defaultSystemPrompt:n,appendSystemPrompt:g});t.renderedSystemPrompt=a;let o=(await Go(e).catch(()=>[])).map(Te),s=new Set;for(let e of nr.current)e.type===`attachment`&&e.attachment.type===`queued_command`&&e.attachment.commandMode===`task-notification`&&typeof e.attachment.prompt==`string`&&s.add(e.attachment.prompt);let c=o.filter(e=>e.attachment.type===`queued_command`&&(typeof e.attachment.prompt!=`string`||!s.has(e.attachment.prompt)));ai({messages:[...nr.current,...c],queryParams:{systemPrompt:a,userContext:r,systemContext:i,canUseTool:go,toolUseContext:t,querySource:Aa()},description:Jn,setAppState:z,agentDefinition:M})})()},[Lt,ve,P,M,_o,h,g,go,z])}),yo=(0,Q.useCallback)(t=>{Xt(t,t=>{if(Gr(t)?(La()?H(e=>{let n=sn(e,{includeSnipped:!0});return[...n.length>500?n.slice(-500):n,t]}):H(()=>[t]),Pi(d_()),Hj?.setContextBlocked(!1)):t.type===`progress`&&Pe(t.data?.type)?H(e=>{let n=t.data;for(let r=e.length-1;r>=0;r--){let i=e[r];if(i.type!==`progress`)break;let a=i.data;if(i.parentToolUseID===t.parentToolUseID&&a?.type===n.type){let n=e.slice();return n[r]=t,n}}return[...e,t]}):H(e=>[...e,t]),t.type===`assistant`&&`isApiErrorMessage`in t&&t.isApiErrorMessage?Hj?.setContextBlocked(!0):t.type===`assistant`&&Hj?.setContextBlocked(!1),t.type===`assistant`&&`isApiErrorMessage`in t&&t.isApiErrorMessage){let n=(k(t.message?.content??``)??``).toLowerCase();if(n.includes(`connection error`)||n.includes(`fetch failed`)||n.includes(`network error`)||n.includes(`enotfound`)||n.includes(`econnreset`)||n.includes(`etimedout`)){let{getGoal:t,pauseGoal:n}=(Jt(),e(gi)),{persistCurrentGoal:r}=(Xi(),e(io));t()?.status===`active`&&(n(),r(),Ge({key:`goal-auto-paused-connectivity-error`,text:`Detected connection error. Active goal was auto-paused. Run /goal resume after network recovers.`,priority:`immediate`}))}}},e=>{li(t=>t+e.length)},Dt,Nt,e=>{H(t=>t.filter(t=>t!==e)),mc(e.uuid)},Ft,e=>{let t=Date.now(),n=oi.current;ci.current.push({...e,firstTokenTime:t,lastTokenTime:t,responseLengthBaseline:n,endResponseLength:n})},pi)},[H,li,Dt,Nt,Ft,pi]),bo=(0,Q.useCallback)(async(e,t,n,r,i,a)=>{if(r){let e=CO(d,ge.getState().mcp.clients);D.handleQueryStart(e);let t=ol(e);t&&eo(t)}if(rm(),!te&&!Un&&!qn&&!Kn.current){let e=t.find(e=>e.type===`user`&&!e.isMeta),n=e?.type===`user`?k(e.message.content):null;n&&!n.startsWith(`<local-command-stdout>`)&&!n.startsWith(`<command-message>`)&&!n.startsWith(`<command-name>`)&&!n.startsWith(`<bash-input>`)&&(Kn.current=!0,Um(n,new AbortController().signal).then(e=>{e?Gn(e):Kn.current=!1},()=>{Kn.current=!1}))}if(ge.setState(e=>{let t=e.toolPermissionContext.alwaysAllowRules.command;return t===i||t?.length===i.length&&t.every((e,t)=>e===i[t])?e:{...e,toolPermissionContext:{...e.toolPermissionContext,alwaysAllowRules:{...e.toolPermissionContext.alwaysAllowRules,command:i}}}}),!r){t.some(Gr)&&(Pi(d_()),Hj?.setContextBlocked(!1)),sa(),zt(null);return}let o=_o(e,t,n,a),{tools:s,mcpClients:c}=o.options;Rs(`query_context_loading_start`);let[,,l,u,f]=await Promise.all([void 0,_k(P,z,ge.getState().fastMode),wa(s,a,Array.from(P.additionalWorkingDirectories.keys()),c),la(),ko()]),p={...u,...Hj?.isProactiveActive()&&!na.current?{terminalFocus:`The terminal is unfocused — the user is not actively watching.`}:{}};Rs(`query_context_loading_end`);let m=Ha({mainThreadAgentDefinition:M,toolUseContext:o,customSystemPrompt:h,defaultSystemPrompt:l,appendSystemPrompt:g});o.renderedSystemPrompt=m,Rs(`query_query_start`),Zu(),ed(),nd();for await(let t of to({messages:e,systemPrompt:m,userContext:p,systemContext:f,canUseTool:go,toolUseContext:o,querySource:Aa()}))yo(t);Rs(`query_end`),sa(),It(),await b?.(nr.current)},[d,sa,_o,P,z,h,b,g,go,M,yo,Un,te]),xo=(0,Q.useCallback)(async(e,t,n,r,i,a,o)=>{let s=en.tryStart();if(s===null)return X(`tengu_concurrent_onquery_detected`,{}),e.filter(e=>e.type===`user`&&!e.isMeta).map(e=>k(e.message.content)).filter(e=>e!==null).forEach((e,t)=>{uc({value:e,mode:`prompt`}),t===0&&X(`tengu_concurrent_onquery_enqueued`,{})}),!1;try{Ut(!1),gn(),H(t=>[...t,...e]),oi.current=0,Vu((o?A(o):null)??Eu()),ci.current=[],Nt([]),di(null);let s=nr.current;if(o&&await ma(o,s,e.length),a&&o&&!await a(o,s))return!0;await bo(s,e,t,n,r,i)}finally{if(en.end(s)){Ut(t.signal.aborted),_i(Date.now()),zi.current=!1,sa(),await ha(nr.current,t.signal.aborted),Gt.current();let e;Eu()!==null&&Eu()>0&&!t.signal.aborted&&(e={tokens:ku(),limit:Eu(),nudges:Hu()}),Vu(null);let n=Date.now()-fn.current-pn.current;(n>3e4||e!==void 0)&&!t.signal.aborted&&!xe&&H(t=>[...t,de(n,e,kd(t,zn))]),zt(null)}if(t.signal.reason===`user-cancel`&&!en.isActive&&Nr.current===``&&Ac()===0&&!ge.getState().viewingAgentTaskId){let e=nr.current,t=e.findLast(rh);t&&ih(e,e.lastIndexOf(t))&&(Zt(),qt.current(t))}}return!0},[bo,z,sa,en,ma,ha]),So=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{let e=oe;if(!e||B||So.current)return;So.current=!0;async function t(e){if(e.clearContext){let t=e.message.planContent?so():void 0,{clearConversation:n}=await import(`./conversation-CFIn-KsW.js`);await n({setMessages:H,readFileState:ja.current,discoveredSkillNames:Pa.current,loadedNestedMemoryPaths:Fa.current,getAppState:()=>ge.getState(),setAppState:z,setConversationId:Pi}),Kn.current=!1,Gn(void 0),Ma.current.clear(),Na.current=0,t&&jc($u(),t)}z(t=>{let n=e.mode?y(t.toolPermissionContext,Nx(e.mode,e.allowedPrompts)):t.toolPermissionContext;return e.mode===`auto`&&(n=rn({...n,mode:`auto`,prePlanMode:void 0})),{...t,initialMessage:null,toolPermissionContext:n}}),Kc()&&Se(e=>{z(t=>({...t,fileHistory:e(t.fileHistory)}))},e.message.uuid),await xr();let t=e.message.message.content;if(typeof t==`string`&&!e.message.planContent)Co(t,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}});else{let t=Ua();zt(t),xo([e.message],t,!0,[],ve)}setTimeout(e=>{e.current=!1},100,So)}t(e)},[oe,B,H,z,xo,ve,St]);let Co=(0,Q.useCallback)(async(e,t,n,r)=>{if(hr(),Hj?.resumeProactive(),!n&&e.trim().startsWith(`/`)){let n=Ho(e,ei).trim(),i=n.indexOf(` `),a=i===-1?n.slice(1):n.slice(1,i),o=i===-1?``:n.slice(i+1).trim(),s=Tt.find(e=>si(e)&&(e.name===a||e.aliases?.includes(a)||ct(e)===a));s?.name===`clear`&&rr.current&&(X(`tengu_idle_return_action`,{action:`hint_converted`,variant:rr.current,idleMinutes:Math.round((Date.now()-Bi.current)/6e4),messageCount:nr.current.length,totalInputTokens:Mu()}),rr.current=!1);let c=en.isActive&&(s?.immediate||r?.fromKeybinding);if(s&&c&&s.type===`local-jsx`){e.trim()===Nr.current.trim()&&(Ir(``),t.setCursorOffset(0),t.clearBuffer(),ti({}));let n=_t(e).filter(e=>ei[e.id]?.type===`text`),i=n.length;X(`tengu_paste_text`,{pastedTextCount:i,pastedTextBytes:n.reduce((e,t)=>e+(ei[t.id]?.content.length??0),0)}),X(`tengu_immediate_command_executed`,{commandName:s.name,fromKeybinding:r?.fromKeybinding??!1}),(async()=>{let e=!1,n=(n,r)=>{e=!0,An({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0});let i=[];if(n&&r?.display!==`skip`&&(Ge({key:`immediate-${s.name}`,text:n,priority:`immediate`}),!La())){let e=r?.displayArgs??o;i.push(Mc(zo(ct(s),e)),Mc(`<${Cf}>${kt(n)}</${Cf}>`))}r?.metaMessages?.length&&i.push(...r.metaMessages.map(e=>Dr({content:e,isMeta:!0}))),i.length&&H(e=>[...e,...i]),Br!==void 0&&(Ir(Br.text),t.setCursorOffset(Br.cursorOffset),ti(Br.pastedContents),Vr(void 0))},r=_o(nr.current,[],Ua(),ve),i=await(await s.load()).call(n,r,o);i&&!e&&An({jsx:i,shouldHidePromptInput:!1,isLocalJSXCommand:!0})})();return}}if($r.isRemoteMode&&!e.trim())return;Number(process.env.CLAUDE_CODE_IDLE_THRESHOLD_MINUTES??75),Number(process.env.CLAUDE_CODE_IDLE_TOKEN_THRESHOLD??1e5),r?.fromKeybinding||(Pn({display:n?e:Pr(e,Lr),pastedContents:n?{}:ei}),Lr===`bash`&&HC(e.trim()));let i=!n&&e.trim().startsWith(`/`),a=!B||n||$r.isRemoteMode;if(Br!==void 0&&!i&&a?(Ir(Br.text),t.setCursorOffset(Br.cursorOffset),ti(Br.pastedContents),Vr(void 0)):a&&(r?.fromKeybinding||(Ir(``),t.setCursorOffset(0)),ti({})),a&&(Rr(`prompt`),$e(void 0),ii(e=>e+1),t.clearBuffer(),aa.current=!1,!i&&Lr===`prompt`&&!n&&!$r.isRemoteMode&&(ir(e),gn()),z(e=>({...e,attribution:Sn(e.attribution,e=>{Wt(e).catch(e=>{J(`Attribution: Failed to save snapshot: ${e}`)})})}))),n){let{queryRequired:t}=await tt(n.state,n.speculationSessionTimeSavedMs,n.setAppState,e,{setMessages:H,readFileState:ja,cwd:Gu()});if(t){let e=Ua();zt(e),xo([],e,!0,[],ve)}return}if($r.isRemoteMode&&!(i&&Tt.find(t=>{let n=e.trim().slice(1).split(/\s/)[0];return si(t)&&(t.name===n||t.aliases?.includes(n)||ct(t)===n)})?.type===`local-jsx`)){let t=Object.values(ei),n=t.filter(e=>e.type===`image`),r=n.length>0?n.map(e=>e.id):void 0,i=e.trim(),a=e.trim();if(t.length>0){let n=[],r=[],o=e.trim();o&&(n.push({type:`text`,text:o}),r.push({type:`text`,text:o}));for(let e of t)if(e.type===`image`){let t={type:`base64`,media_type:e.mediaType??`image/png`,data:e.content};n.push({type:`image`,source:t}),r.push({type:`image`,source:t})}else n.push({type:`text`,text:e.content}),r.push({type:`text`,text:e.content});i=n,a=r}let o=Dr({content:i,imagePasteIds:r});H(e=>[...e,o]),await $r.sendMessage(a,{uuid:o.uuid});return}await xr(),await _O({input:e,helpers:t,queryGuard:en,isExternalLoading:an,mode:Lr,commands:Tt,onInputChange:Ir,setPastedContents:ti,setToolJSX:An,getToolUseContext:_o,messages:nr.current,mainLoopModel:ve,pastedContents:ei,ideSelection:Ze,setUserInputOnProcessing:ir,setAbortController:zt,abortController:Lt,onQuery:xo,setAppState:z,querySource:Aa(),onBeforeQuery:v,canUseTool:go,addNotification:Ge,setMessages:H,streamMode:Ot.current,hasInterruptibleToolInProgress:qr.current}),(i||B)&&Br!==void 0&&(Ir(Br.text),t.setCursorOffset(Br.cursorOffset),ti(Br.pastedContents),Vr(void 0))},[en,B,an,Lr,Tt,Ir,Rr,ti,ii,$e,An,_o,ve,ei,Ze,ir,zt,Ge,xo,Br,Vr,z,v,go,Jr,H,xr,hr]),To=(0,Q.useCallback)(()=>{let e=Va?WA(Va):`/issue`;Ka(null),Co(e,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}}).catch(t=>{J(`Auto-run ${e} failed: ${fd(t)}`)})},[Co,Va]),Eo=(0,Q.useCallback)(()=>{Ka(null)},[]),Do=(0,Q.useCallback)(()=>{Co(`/issue`,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}}).catch(e=>{J(`Survey feedback request failed: ${e instanceof Error?e.message:String(e)}`)})},[Co]),Oo=(0,Q.useRef)(Co);Oo.current=Co;let Ao=(0,Q.useCallback)(async()=>{if(Za(!0),sl()){__(`tmux`,[`detach-client`],{stdio:`ignore`}),Za(!1);return}if(Sr()!==null){Ya((0,$.jsx)(sg,{showWorktree:!0,onDone:()=>{},onCancel:()=>{Ya(null),Za(!1)}}));return}let e=await(await Qe.load()).call(()=>{});Ya(e),e===null&&Za(!1)},[]),jo=(0,Q.useCallback)(()=>{Ei(e=>!e)},[]),Mo=(0,Q.useCallback)(e=>{let t=nr.current,n=t.lastIndexOf(e);if(n===-1)return;X(`tengu_conversation_rewind`,{preRewindMessageCount:t.length,postRewindMessageCount:n,messagesRemoved:t.length-n,rewindToMessageIndex:n}),H(t.slice(0,n)),Pi(d_()),Qa();let r=e.permissionMode;z(e=>({...e,toolPermissionContext:r&&e.toolPermissionContext.mode!==r?{...e.toolPermissionContext,mode:r}:e.toolPermissionContext,promptSuggestion:{text:null,promptId:null,shownAt:0,acceptedAt:0,generationRequestId:null}}))},[H,z]),No=(0,Q.useCallback)(e=>{Mo(e);let t=_(e);if(t&&(Ir(t.text),Rr(t.mode)),Array.isArray(e.message.content)&&e.message.content.some(e=>e.type===`image`)){let t=e.message.content.filter(e=>e.type===`image`);if(t.length>0){let n={};t.forEach((t,r)=>{if(t.source.type===`base64`){let i=e.imagePasteIds?.[r]??r+1;n[i]={id:i,type:`image`,content:t.source.data,mediaType:t.source.media_type}}}),ti(n)}}},[Mo,Ir]);qt.current=No;let Po=(0,Q.useCallback)(async e=>{setImmediate((e,t)=>e(t),No,e)},[No]),Fo=e=>{let t=e.slice(0,24);return V.findIndex(e=>e.uuid.slice(0,24)===t)},{enter:Io,handlers:Lo}=Ro(dr,fr,pr,{copy:e=>void ql(e).then(e=>{e&&process.stdout.write(e),Ge({key:`selection-copied`,text:`copied`,color:`success`,priority:`immediate`,timeoutMs:2e3})}),edit:async e=>{let t=Fo(e.uuid),n=t>=0?V[t]:void 0;if(!n||!rh(n))return;let r=!await je(ae,n.uuid),i=ih(V,t);r&&i?(uo(),Po(n)):(Oi(n),Ei(!0))}});async function Bo(){Ba();let e=await ea();if(e.length>0){let t=e.map(e=>` [${e.type}] ${e.path} (${e.content.length} chars)${e.parent?` (included by ${e.parent})`:``}`).join(`
130
- `);J(`Loaded ${e.length} AGENTS.md/rules files:\n${t}`)}else J(`No AGENTS.md/rules files found`);for(let t of e)ja.current.set(t.path,{content:t.contentDiffersFromDisk?t.rawContent??t.content:t.content,timestamp:Date.now(),offset:void 0,limit:void 0,isPartialView:t.contentDiffersFromDisk})}JD(Ug()),Sy(V,V.length===i?.length);let{sendBridgeResult:Vo}=Cy(V,H,Bt,Tt,ve);Gt.current=Vo,YD();let Wo=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(se.length<1){Wo.current=!1;return}Wo.current||(Wo.current=!0,df(e=>({...e,promptQueueUseCount:(e.promptQueueUseCount??0)+1})))},[se.length]),xO({executeQueuedInput:(0,Q.useCallback)(async e=>{await _O({helpers:{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}},queryGuard:en,commands:Tt,onInputChange:()=>{},setPastedContents:()=>{},setToolJSX:An,getToolUseContext:_o,messages:V,mainLoopModel:ve,ideSelection:Ze,setUserInputOnProcessing:ir,setAbortController:zt,onQuery:xo,setAppState:z,querySource:Aa(),onBeforeQuery:v,canUseTool:go,addNotification:Ge,setMessages:H,queuedCommands:e})},[en,Tt,An,_o,V,ve,Ze,ir,go,zt,xo,Ge,z,v]),hasActiveLocalJsxUI:Xn,queryGuard:en}),(0,Q.useEffect)(()=>{Mt.recordUserActivity(),td(!0)},[jr,ri]),(0,Q.useEffect)(()=>{ri===1&&Qg()},[ri]),(0,Q.useEffect)(()=>{if(B||ri===0||hi===0)return;let e=setTimeout((e,t,n,r,i)=>{if(Lu()>e)return;let a=Date.now()-e;!t&&!n&&r.current===void 0&&a>=cf().messageIdleNotifThresholdMs&&ny({message:`Claude is waiting for your input`,notificationType:`idle_prompt`},i)},cf().messageIdleNotifThresholdMs,hi,B,En,bn,_e);return()=>clearTimeout(e)},[B,En,ri,hi,_e]),(0,Q.useEffect)(()=>{},[hi,B,Ge,Ke]),SO({isLoading:B,onSubmitMessage:(0,Q.useCallback)((e,t)=>{if(en.isActive||rs().some(e=>e.mode===`prompt`||e.mode===`bash`))return!1;let n=typeof e==`string`?{value:e,mode:`prompt`,isMeta:t?.isMeta?!0:void 0}:e;return(async()=>{let e=await Ar([n]),t=e.attachmentCommands[0];if(!t)return;let r=Ua();zt(r);let i=Dr({content:t.value,isMeta:t.isMeta?!0:void 0,origin:t.origin}),a=!1;try{a=await xo([i],r,!0,[],ve)!==!1}catch(t){try{await Me({commands:e.claimedCommands,outcome:{type:`failed`,error:t},currentDir:cd(),priority:`later`})}catch(e){Y(hd(e))}Y(hd(t));return}if(a)try{let t=await Me({commands:e.claimedCommands,outcome:{type:`completed`},currentDir:cd(),priority:`later`});for(let e of t)uc(e)}catch(e){Y(hd(e))}})().catch(e=>{Y(hd(e))}),!0},[xo,ve,ge])}),qj?.({isLoading:B||oe!==null,queuedCommandsLength:se.length,hasActiveLocalJsxUI:Xn,isInPlanMode:P.mode===`plan`,onQueueTick:e=>uc(e)}),Jj?.({isLoading:B||oe!==null,wasAborted:Ht,queuedCommandsLength:se.length,hasActiveLocalJsxUI:Xn,isInPlanMode:P.mode===`plan`,isQueryActiveNow:en.getSnapshot,onContinuationEnqueued:({turn:e,objective:t})=>{let n=`Goal auto-continue (${e}/1): continue advancing "${t}".`;H(e=>[...e,Dr({content:n,isVisibleInTranscriptOnly:!0})])},onMaxTurnsReached:()=>{Ge({key:`goal-max-turns-reached`,text:`Goal reached max continuation turns (1). Run /goal continue to reset turn counter and continue.`,priority:`immediate`})}}),(0,Q.useEffect)(()=>{if(!xe){hm(null);return}if(!B){if(we!==null&&se.length===0&&!Xn&&P.mode!==`plan`&&oe===null){hm({enabled:!0,phase:`standby`,next_tick_at:we,sleep_until:null});return}hm({enabled:!0,phase:null,next_tick_at:null,sleep_until:null})}},[oe,B,Xn,xe,we,se.length,P.mode]),(0,Q.useEffect)(()=>{se.some(e=>e.priority===`now`)&&Bt.current?.abort(`interrupt`)},[se]);let Ko=(0,Q.useRef)(Bo);Ko.current=Bo;let qo=(0,Q.useRef)(D);qo.current=D,(0,Q.useEffect)(()=>(Ko.current(),()=>{qo.current.shutdown()}),[]);let{internal_eventEmitter:Jo}=Ul(),[Yo,Xo]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{let e=()=>{process.stdout.write(`
131
- Claude Code has been suspended. Run \`fg\` to bring Claude Code back.
132
- Note: ctrl + z now suspends Claude Code, ctrl + _ undoes input.
133
- `)},t=()=>{Xo(e=>e+1)};return Jo?.on(`suspend`,e),Jo?.on(`resume`,t),()=>{Jo?.off(`suspend`,e),Jo?.off(`resume`,t)}},[Jo]);let Zo=(0,Q.useMemo)(()=>{if(!B)return null;let e=V.filter(e=>{if(e.type!==`progress`)return!1;let t=e.data;return t.type===`hook_progress`&&(t.hookEvent===`Stop`||t.hookEvent===`SubagentStop`)});if(e.length===0)return null;let t=e.at(-1)?.toolUseID;if(!t||V.some(e=>e.type===`system`&&e.subtype===`stop_hook_summary`&&e.toolUseID===t))return null;let n=e.filter(e=>e.toolUseID===t),r=n.length,i=kd(V,e=>{if(e.type!==`attachment`)return!1;let n=e.attachment;return`hookEvent`in n&&(n.hookEvent===`Stop`||n.hookEvent===`SubagentStop`)&&`toolUseID`in n&&n.toolUseID===t}),a=n.find(e=>e.data.statusMessage)?.data.statusMessage;if(a)return r===1?`${a}…`:`${a}… ${i}/${r}`;let o=n[0]?.data.hookEvent===`SubagentStop`?`subagent stop`:`stop`;return r===1?`running ${o} hook`:`running stop hooks… ${i}/${r}`},[V,B]),$o=(0,Q.useCallback)(()=>{kr({messagesLength:V.length,streamingToolUsesLength:At.length})},[V.length,At.length]),es=(0,Q.useCallback)(()=>{kr(null)},[]),ts=La()&&!ne,ns=(0,Q.useRef)(null),[is,as]=(0,Q.useState)(!1),[os,ss]=(0,Q.useState)(``),[cs,ls]=(0,Q.useState)(0),[ds,fs]=(0,Q.useState)(0),ps=(0,Q.useCallback)((e,t)=>{ls(e),fs(t)},[]);Xl((e,t,n)=>{if(t.ctrl||t.meta)return;if(e===`/`){ns.current?.setAnchor(),as(!0),n.stopImmediatePropagation();return}let r=e[0];if((r===`n`||r===`N`)&&e===r.repeat(e.length)&&cs>0){let t=r===`n`?ns.current?.nextMatch:ns.current?.prevMatch;if(t)for(let n=0;n<e.length;n++)t();n.stopImmediatePropagation()}},{isActive:Ne===`transcript`&&ts&&!is&&!Re});let{setQuery:ms,scanElement:hs,setPositions:_s}=ru(),vs=tu().columns,ys=Q.useRef(vs);Q.useEffect(()=>{ys.current!==vs&&(ys.current=vs,(os||is)&&(as(!1),ss(``),ls(0),fs(0),ns.current?.disarmSearch(),ms(``)))},[vs,os,is,ms]),Xl((e,t,n)=>{if(!(t.ctrl||t.meta)){if(e===`q`){es(),n.stopImmediatePropagation();return}if(e===`[`&&!Re)ze(!0),Le(!0),n.stopImmediatePropagation();else if(e===`v`){if(n.stopImmediatePropagation(),We.current)return;We.current=!0;let e=He.current,t=t=>{e===He.current&&(clearTimeout(Ue.current),Ve(t))};t(`rendering ${wr.length} messages…`),(async()=>{try{let e=Math.max(80,(process.stdout.columns??80)-6),n=(await Qv(wr,St,e)).replace(/[ \t]+$/gm,``),r=a_(e_(),`cc-transcript-${Date.now()}.txt`);await h_(r,n);let i=Lh(r);t(i?`opening ${r}`:`wrote ${r} · no $VISUAL/$EDITOR set`)}catch(e){t(`render failed: ${e instanceof Error?e.message:String(e)}`)}We.current=!1,e===He.current&&(Ue.current=setTimeout(e=>e(``),4e3,Ve))})()}}},{isActive:Ne===`transcript`&&ts&&!is});let bs=Ne===`transcript`&&ts;(0,Q.useEffect)(()=>{bs||(ss(``),ls(0),fs(0),as(!1),He.current++,clearTimeout(Ue.current),ze(!1),Ve(``))},[bs]),(0,Q.useEffect)(()=>{ms(bs?os:``),bs||_s(null)},[bs,os,ms,_s]);let xs={screen:Ne,setScreen:Fe,showAllInTranscript:Ie,setShowAllInTranscript:Le,messageCount:V.length,onEnterTranscript:$o,onExitTranscript:es,virtualScrollActive:ts,searchBarOpen:is},U=Or?wr.slice(0,Or.messagesLength):wr,Ss=Or?At.slice(0,Or.streamingToolUsesLength):At;rO({onOpenBackgroundTasks:Xn?void 0:()=>Ji(!0),onTogglePipeSelector:()=>{z(e=>{let t=e.pipeIpc??{};return{...e,pipeIpc:{...t,selectorOpen:!t.selectorOpen}}})}});let Cs=fe?ue[fe]:void 0,Ts=Cs&&Qr(Cs)?Cs:void 0,Es=fi||!B,Ds=Ts?.messages,Os=(0,Q.useMemo)(()=>{if(!Ts)return;let e=Ds??[];if(!Qr(Ts)||Ts.agentType!==`fork`||!Ts.prompt)return e;let t=Ts.prompt.trim(),n=-1,r=-1,i=!1;for(let a=0;a<e.length;a++){let o=e[a];if(o.type===`user`&&Array.isArray(o.message?.content)){if(o.message.content.some(iM))n=a;else if(!i){let e=o.message.content.find(e=>e.type===`text`&&typeof e.text==`string`);e&&e.text.trim()===t&&(i=!0)}continue}o.type===`assistant`&&Array.isArray(o.message?.content)&&o.message.content.some(e=>e.type===`tool_use`)&&(r=a)}let a=n===-1?e:e.map((e,t)=>t!==n||!Array.isArray(e.message?.content)?e:{...e,message:{...e.message,content:e.message.content.filter(e=>!iM(e))}});if(i)return a;let o=n===-1?r+1:n+1,s=Dr({content:Ts.prompt,timestamp:new Date(Ts.startTime).toISOString()});return[...a.slice(0,o),s,...a.slice(o)]},[Ts,Ds]),As=Ts?Os??[]:Es?V:wr;if(Ne===`transcript`){let e=La()&&!ne&&!Re?Yt:void 0,t=(0,$.jsx)(Fg,{messages:U,tools:St,commands:Tt,verbose:!0,toolJSX:null,toolUseConfirmQueue:[],inProgressToolUseIDs:Ur,isMessageSelectorVisible:!1,conversationId:Ni,screen:Ne,agentDefinitions:ie,streamingToolUses:Ss,showAllInTranscript:Ie,isLoading:B,hidePastThinking:!0,streamingThinking:Pt,scrollRef:e,jumpRef:ns,onSearchMatchesChange:ps,scanElement:hs,setPositions:_s,disableRenderCap:Re}),n=En&&(0,$.jsx)(G,{flexDirection:`column`,width:`100%`,children:En.jsx}),r=(0,$.jsxs)(Ee,{children:[(0,$.jsx)(nM,{isAnimating:Zn,title:Jn,disabled:te,noPrefix:!1}),(0,$.jsx)(QD,{...xs}),(0,$.jsx)(eO,{onSubmit:Co,isActive:!En?.isLocalJSXCommand}),e?(0,$.jsx)(bj,{scrollRef:Yt,isActive:!0,isModal:!is,onScroll:()=>ns.current?.disarmSearch()}):null,(0,$.jsx)(nO,{...po}),e?(0,$.jsx)(Ng,{scrollRef:Yt,scrollable:(0,$.jsxs)($.Fragment,{children:[t,n,(0,$.jsx)(Ck,{})]}),bottom:is?(0,$.jsx)(Qj,{jumpRef:ns,initialQuery:``,count:cs,current:ds,onClose:e=>{ss(cs>0?e:``),as(!1),e||(ls(0),fs(0),ns.current?.setSearchQuery(``))},onCancel:()=>{as(!1),ns.current?.setSearchQuery(``),ns.current?.setSearchQuery(os),ms(os)},setHighlight:ms}):(0,$.jsx)(Zj,{showAllInTranscript:Ie,virtualScroll:!0,status:Be||void 0,searchBadge:os&&cs>0?{current:ds,count:cs}:void 0})}):(0,$.jsxs)($.Fragment,{children:[t,n,(0,$.jsx)(Ck,{}),(0,$.jsx)(Zj,{showAllInTranscript:Ie,virtualScroll:!1,suppressShowAll:Re,status:Be||void 0})]})]});return e?(0,$.jsx)(du,{mouseTracking:pc(),children:r}):r}let js=cn&&!Ts&&As.length<=un.current?cn:void 0,Ms=ro===`tool-permission`?(0,$.jsx)(gS,{onDone:()=>Mn(([e,...t])=>t),onReject:fo,toolUseConfirm:jn[0],toolUseContext:_o(V,V,Lt??Ua(),ve),verbose:F,setStickyFooter:La()?Fn:void 0},jn[0]?.toolUseID):null,Ns=La()&&En?.isLocalJSXCommand===!0,Ps=Ns?En.jsx:null,Fs=(0,$.jsxs)(Ee,{children:[(0,$.jsx)(nM,{isAnimating:Zn,title:Jn,disabled:te,noPrefix:!1}),(0,$.jsx)(QD,{...xs}),(0,$.jsx)(eO,{onSubmit:Co,isActive:!En?.isLocalJSXCommand}),(0,$.jsx)(bj,{scrollRef:Yt,isActive:La()&&(Ps!=null||!ro||ro===`tool-permission`),onScroll:br}),null,(0,$.jsx)(nO,{...po}),(0,$.jsx)(eh,{dynamicMcpConfig:Oe,isStrictMcpConfig:m,children:(0,$.jsx)(Ng,{scrollRef:Yt,overlay:Ms,modal:Ps,modalScrollRef:Qt,dividerYRef:or,hidePill:!!Ts,newMessageCount:mr?.count??0,onPillClick:()=>{fr(null),lr(Yt.current)},scrollable:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Fg,{messages:As,tools:St,commands:Tt,verbose:F,toolJSX:En,toolUseConfirmQueue:jn,inProgressToolUseIDs:Ur,isMessageSelectorVisible:Ti,conversationId:Ni,screen:Ne,streamingToolUses:At,showAllInTranscript:Ie,agentDefinitions:ie,isLoading:B,streamingText:B&&!Ts?mi:null,unseenDivider:Ts?void 0:mr,scrollRef:La()?Yt:void 0,trackStickyPrompt:La()?!0:void 0,cursor:dr,setCursor:fr,cursorNavRef:pr}),(0,$.jsx)(CA,{}),!x&&js&&!Ps&&(0,$.jsx)(lc,{param:{text:js,type:`text`},addMargin:!0,verbose:F}),En&&!(En.isLocalJSXCommand&&En.isImmediate)&&!Ns&&(0,$.jsx)(G,{flexDirection:`column`,width:`100%`,children:En.jsx}),(0,$.jsx)(G,{flexGrow:1}),_a&&(0,$.jsx)(mn,{mode:Et,spinnerTip:ce,responseLengthRef:oi,apiMetricsRef:ci,overrideMessage:vi,spinnerSuffix:Zo,verbose:F,loadingStartTimeRef:fn,totalPausedMsRef:pn,pauseStartTimeRef:hn,overrideColor:bi,overrideShimmerColor:Si,hasActiveTools:Ur.size>0,leaderIsIdle:!B})]}),bottom:(0,$.jsx)(G,{flexDirection:`row`,width:`100%`,alignItems:`flex-end`,children:(0,$.jsxs)(G,{flexDirection:`column`,flexGrow:1,children:[La()&&(0,$.jsx)(ZE,{}),Nn,En?.isLocalJSXCommand&&En.isImmediate&&!Ns&&(0,$.jsx)(G,{flexDirection:`column`,width:`100%`,children:En.jsx}),!_a&&!En?.isLocalJSXCommand&&le&&bt&&bt.length>0&&(0,$.jsx)(G,{width:`100%`,flexDirection:`column`,children:(0,$.jsx)(Kt,{tasks:bt,isStandalone:!0})}),ro===`sandbox-permission`&&(0,$.jsx)(xk,{hostPattern:In[0].hostPattern,onUserResponse:e=>{let{allow:t,persistToSettings:n}=e,r=In[0];if(!r)return;let i=r.hostPattern.host;Ln(e=>(e.filter(e=>e.hostPattern.host===i).forEach(e=>e.resolvePromise(t)),e.filter(e=>e.hostPattern.host!==i)));let a=Vn.current.get(i);if(a){for(let e of a)e();Vn.current.delete(i)}}},In[0].hostPattern.host),ro===`prompt`&&(0,$.jsx)(BS,{title:Rn[0].title,toolInputSummary:Rn[0].toolInputSummary,request:Rn[0].request,onRespond:e=>{let t=Rn[0];t&&(t.resolve({prompt_response:t.request.prompt,selected:e}),Bn(([,...e])=>e))},onAbort:()=>{let e=Rn[0];e&&(e.reject(Error(`Prompt cancelled by user`)),Bn(([,...e])=>e))}},Rn[0].request.prompt),ro===`elicitation`&&(0,$.jsx)(LS,{event:R.queue[0],onResponse:(e,t)=>{let n=R.queue[0];n&&(n.respond({action:e,content:t}),n.params.mode===`url`&&e===`accept`||z(e=>({...e,elicitation:{queue:e.elicitation.queue.slice(1)}})))},onWaitingDismiss:e=>{let t=R.queue[0];z(e=>({...e,elicitation:{queue:e.elicitation.queue.slice(1)}})),t?.onWaitingDismiss?.(e)}},R.queue[0].serverName+`:`+String(R.queue[0].requestId)),ro===`cost`&&(0,$.jsx)($v,{onDone:()=>{ji(!1),Ui(!0),df(e=>({...e,hasAcknowledgedCostThreshold:!0})),X(`tengu_cost_threshold_acknowledged`,{})}}),ro===`idle-return`&&Fi&&(0,$.jsx)(ey,{idleMinutes:Fi.idleMinutes,totalInputTokens:Mu(),onDone:async e=>{let t=Fi;if(Ii(null),X(`tengu_idle_return_action`,{action:e,idleMinutes:Math.round(t.idleMinutes),messageCount:nr.current.length,totalInputTokens:Mu()}),e===`dismiss`){Ir(t.input);return}if(e===`never`&&df(e=>e.idleReturnDismissed?e:{...e,idleReturnDismissed:!0}),e===`clear`){let{clearConversation:e}=await import(`./conversation-CFIn-KsW.js`);await e({setMessages:H,readFileState:ja.current,discoveredSkillNames:Pa.current,loadedNestedMemoryPaths:Fa.current,getAppState:()=>ge.getState(),setAppState:z,setConversationId:Pi}),Kn.current=!1,Gn(void 0),Ma.current.clear(),Na.current=0}zi.current=!0,Oo.current(t.input,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}})}}),ro===`ide-onboarding`&&(0,$.jsx)(yn,{onDone:()=>st(!1),installationStatus:it}),ro===`remote-callout`&&(0,$.jsx)(FO,{onDone:e=>{z(t=>t.showRemoteCallout?{...t,showRemoteCallout:!1,...e===`enable`&&{replBridgeEnabled:!0,replBridgeExplicit:!0,replBridgeOutboundOnly:!1}}:t)}}),Ja,ro===`plugin-hint`&&ht&&(0,$.jsx)(Yk,{pluginName:ht.pluginName,pluginDescription:ht.pluginDescription,marketplaceName:ht.marketplaceName,sourceCommand:ht.sourceCommand,onResponse:gt}),ro===`search-extra-tools-hint`&&vt.visible&&(0,$.jsx)(Zk,{tools:vt.tools,onSelect:vt.handleSelect,onDismiss:vt.handleDismiss}),ro===`lsp-recommendation`&&pt&&(0,$.jsx)(Kk,{pluginName:pt.pluginName,pluginDescription:pt.pluginDescription,fileExtension:pt.fileExtension,onResponse:mt}),ro===`desktop-upsell`&&(0,$.jsx)(gA,{onDone:()=>ft(!1)}),ga(),!En?.shouldHidePromptInput&&!ro&&!Xa&&!x&&!dr&&(0,$.jsxs)($.Fragment,{children:[Va&&(0,$.jsx)(HA,{onRun:To,onCancel:Eo,reason:GA(Va)}),Ta.state===`closed`?Da.state===`closed`?(0,$.jsx)(tk,{state:Ca.state,lastResponse:Ca.lastResponse,handleSelect:Ca.handleSelect,handleTranscriptSelect:Ca.handleTranscriptSelect,inputValue:jr,setInputValue:Ir,onRequestFeedback:qa.current?void 0:Do}):(0,$.jsx)(tk,{state:Da.state,lastResponse:Da.lastResponse,handleSelect:Da.handleSelect,handleTranscriptSelect:Da.handleTranscriptSelect,inputValue:jr,setInputValue:Ir,onRequestFeedback:Do,message:`How well did Claude use its memory? (optional)`}):(0,$.jsx)(tk,{state:Ta.state,lastResponse:Ta.lastResponse,handleSelect:Ta.handleSelect,inputValue:jr,setInputValue:Ir,onRequestFeedback:Do}),ba.suggestion&&(0,$.jsx)(HD,{isOpen:ba.isOpen,skillName:ba.suggestion.skillName,updates:ba.suggestion.updates,handleSelect:ba.handleSelect,inputValue:jr,setInputValue:Ir}),Sa&&(0,$.jsx)(KA,{}),(0,$.jsx)(gD,{debug:n,ideSelection:Ze,hasSuppressedDialogs:!!ao,isLocalJSXCommandActive:Xn,getToolUseContext:_o,toolPermissionContext:P,setToolPermissionContext:ho,apiKeyStatus:za,commands:Tt,agents:ie.activeAgents,isLoading:B,onExit:Ao,verbose:F,messages:V,onAutoUpdaterResult:Tn,autoUpdaterResult:wn,input:jr,onInputChange:Ir,mode:Lr,onModeChange:Rr,stashedPrompt:Br,setStashedPrompt:Vr,submitCount:ri,onShowMessageSelector:jo,onMessageActionsEnter:void 0,mcpClients:Ye,pastedContents:ei,setPastedContents:ti,vimMode:Wi,setVimMode:Gi,showBashesDialog:Ki,setShowBashesDialog:Ji,onSubmit:Co,isSearchingHistory:Yi,setIsSearchingHistory:Zi,helpOpen:Qi,setHelpOpen:$i,insertTextRef:Fr}),(0,$.jsx)(NO,{onBackgroundSession:vo,isLoading:B}),(0,$.jsx)(jO,{})]}),dr&&(0,$.jsx)(L,{cursor:dr}),ro===`message-selector`&&(0,$.jsx)(sh,{messages:V,preselectedMessage:Di,onPreRestore:uo,onRestoreCode:async e=>{await Uo(e=>{z(t=>({...t,fileHistory:e(t.fileHistory)}))},e.uuid)},onSummarize:async(e,t,n=`from`)=>{let r=sn(V),i=r.indexOf(e);if(i===-1){H(e=>[...e,gr(`That message is no longer in the active context (snipped or pre-compact). Choose a more recent message.`,`warning`)]);return}let a=Ua(),o=_o(r,[],a,ve),s=o.getAppState(),c=await wa(o.options.tools,o.options.mainLoopModel,Array.from(s.toolPermissionContext.additionalWorkingDirectories.keys()),o.options.mcpClients),l=Ha({mainThreadAgentDefinition:void 0,toolUseContext:o,customSystemPrompt:o.options.customSystemPrompt,defaultSystemPrompt:c,appendSystemPrompt:o.options.appendSystemPrompt}),[u,d]=await Promise.all([la(),ko()]),f=await el(r,i,o,{systemPrompt:l,userContext:u,systemContext:d,toolUseContext:o,forkContextMessages:r},t,n),p=f.messagesToKeep??[],m=n===`up_to`?[...f.summaryMessages,...p]:[...p,...f.summaryMessages],h=[f.boundaryMarker,...m,...f.attachments,...f.hookResults];if(La()&&n===`from`?H(t=>{let n=t.findIndex(t=>t.uuid===e.uuid);return[...t.slice(0,n===-1?0:n),...h]}):H(h),Hj?.setContextBlocked(!1),Pi(d_()),zr(o.options.querySource),n===`from`){let t=_(e);t&&(Ir(t.text),Rr(t.mode))}let g=Hn(`app:toggleTranscript`,`Global`,`ctrl+o`);Ge({key:`summarize-ctrl-o-hint`,text:`Conversation summarized (${g} for history)`,priority:`medium`,timeoutMs:8e3})},onRestoreMessage:Po,onClose:()=>{Ei(!1),Oi(void 0)}})]})})})},Yo)]});return La()?(0,$.jsx)(du,{mouseTracking:pc(),children:Fs}):Fs}export{aM as t};