@readmagic/workmate 0.0.20 → 0.0.22

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 (509) hide show
  1. package/dist/chunks/AddWorkspaceDirectory-DWgTWJ7R.js +1 -0
  2. package/dist/chunks/AgentsMdExternalIncludesDialog-DCvgQ6n3.js +1 -0
  3. package/dist/chunks/AgentsMdExternalIncludesDialog-s0Orgord.js +1 -0
  4. package/dist/chunks/App-BcEI6U5j.js +1 -0
  5. package/dist/chunks/ApproveApiKey-DegdTXZl.js +1 -0
  6. package/dist/chunks/ApproveApiKey-_VXIMSwY.js +1 -0
  7. package/dist/chunks/BackgroundTasksDialog-CjBt1L0p.js +2 -0
  8. package/dist/chunks/BypassPermissionsModeDialog-D2Gesf-u.js +1 -0
  9. package/dist/chunks/CustomSelect-B46Eh0gU.js +1 -0
  10. package/dist/chunks/DiffDialog-v2IiYyi3.js +6 -0
  11. package/dist/chunks/Doctor-BP0Rqraa.js +1 -0
  12. package/dist/chunks/Doctor-By_y3C2V.js +3 -0
  13. package/dist/chunks/ExitFlow-BasHk1mk.js +2 -0
  14. package/dist/chunks/Grove-C3mhgshv.js +11 -0
  15. package/dist/chunks/InvalidConfigDialog-DYVQK5js.js +1 -0
  16. package/dist/chunks/InvalidSettingsDialog-Dg6OiStR.js +1 -0
  17. package/dist/chunks/KeybindingProviderSetup-Bn1jzN5F.js +1 -0
  18. package/dist/chunks/MCPConnectionManager-ChN4Ayjk.js +1 -0
  19. package/dist/chunks/MCPToolListView-DLSrQHDc.js +1 -0
  20. package/dist/chunks/McpParsingWarnings-DZejAh8b.js +1 -0
  21. package/dist/chunks/MessageSelector-CdDlJE48.js +3 -0
  22. package/dist/chunks/Messages-DuL_r1Or.js +10 -0
  23. package/dist/chunks/Onboarding-CE2GNA-h.js +1 -0
  24. package/dist/chunks/PermissionDialog-BaibiQae.js +1 -0
  25. package/dist/chunks/PressEnterToContinue-DZc_s_pE.js +1 -0
  26. package/dist/chunks/PromptInputFooterSuggestions-lkr_A5jQ.js +1 -0
  27. package/dist/chunks/PromptInputHelpMenu-DaQKKyM5.js +1 -0
  28. package/dist/chunks/QueryEngine-DNNy1UCD.js +1 -0
  29. package/dist/chunks/REPL-CEhW-C41.js +1 -0
  30. package/dist/chunks/REPL-CkSL4C_8.js +124 -0
  31. package/dist/chunks/ResumeConversation-BMCO_3X7.js +1 -0
  32. package/dist/chunks/{SearchBox-CwwV0W-w.js → SearchBox-C9xxQzh1.js} +1 -1
  33. package/dist/chunks/SearchExtraToolsTool-DSy_jDhf.js +1 -0
  34. package/dist/chunks/SelectMulti-CNE06VAN.js +1 -0
  35. package/dist/chunks/Settings-mDykHLok.js +2 -0
  36. package/dist/chunks/Spinner-DwsJJUtn.js +1 -0
  37. package/dist/chunks/SpinnerGlyph-A6G-gloN.js +1 -0
  38. package/dist/chunks/TextInput-7uqPhq9T.js +22 -0
  39. package/dist/chunks/ThemePicker-DT9zVy-0.js +1 -0
  40. package/dist/chunks/TrustDialog-G4jM9IfM.js +1 -0
  41. package/dist/chunks/{ValidationErrorsList-BfZ5gcIv.js → ValidationErrorsList-BLtP647v.js} +1 -1
  42. package/dist/chunks/add-dir-7RfQAC3h.js +1 -0
  43. package/dist/chunks/{agentDisplay-BM4QG_RX.js → agentDisplay-vLQHFrmq.js} +1 -1
  44. package/dist/chunks/agents-BNg_skSm.js +101 -0
  45. package/dist/chunks/{agents-BbDBN5l9.js → agents-DLz0kfsr.js} +1 -1
  46. package/dist/chunks/allErrors-DaztSMrw.js +1 -0
  47. package/dist/chunks/appleTerminalBackup-BYKdf3of.js +1 -0
  48. package/dist/chunks/auth-BTB00dq5.js +10 -0
  49. package/dist/chunks/auth-Bbc0Ny8i.js +1 -0
  50. package/dist/chunks/backgroundHousekeeping-DYz83_8C.js +1 -0
  51. package/dist/chunks/backgroundHousekeeping-bEZtlJSf.js +17 -0
  52. package/dist/chunks/banner-mqZEluky.js +2 -0
  53. package/dist/chunks/branch-exFKkymg.js +2 -0
  54. package/dist/chunks/{break-cache-CcwOjTKt.js → break-cache-BL2gnDLX.js} +2 -2
  55. package/dist/chunks/btw-3l78DYET.js +1 -0
  56. package/dist/chunks/caches-6Nx6tsk9.js +1 -0
  57. package/dist/chunks/caches-ouaWB9bY.js +1 -0
  58. package/dist/chunks/claudeDesktop-D3PEgx3U.js +1 -0
  59. package/dist/chunks/{clear-DmqQBNKg.js → clear-CXfhVRp8.js} +1 -1
  60. package/dist/chunks/client-C01Bnxxv.js +1 -0
  61. package/dist/chunks/client-DYRgRQsr.js +1 -0
  62. package/dist/chunks/{client-C_jBL1yC.js → client-DdenNfkQ.js} +1 -1
  63. package/dist/chunks/client-DvhWKIOx.js +1 -0
  64. package/dist/chunks/commands-BoxOw75F.js +1 -0
  65. package/dist/chunks/compact-BOYr105K.js +2 -0
  66. package/dist/chunks/config-BddEvZZl.js +3 -0
  67. package/dist/chunks/config-GEv9hUzz.js +1 -0
  68. package/dist/chunks/config-kw4xg7Nk.js +1 -0
  69. package/dist/chunks/context-3s9wtn4L.js +1 -0
  70. package/dist/chunks/{context-noninteractive-BzDVMnWC.js → context-noninteractive-CJhUu_4y.js} +9 -9
  71. package/dist/chunks/context-noninteractive-DFvoZ2L9.js +1 -0
  72. package/dist/chunks/conversation-CoGharlH.js +1 -0
  73. package/dist/chunks/conversation-MxEVm54C.js +1 -0
  74. package/dist/chunks/conversationRecovery-Da_8uldZ.js +1 -0
  75. package/dist/chunks/convert-legacy-node-http-options-BZnGSjx2.js +1 -0
  76. package/dist/chunks/crossProjectResume-CzPCHq_K.js +40 -0
  77. package/dist/chunks/cwd-BcO6WHKo.js +1 -0
  78. package/dist/chunks/cwd-CDUelriw.js +1 -0
  79. package/dist/chunks/{datadog-Bc6wkPne.js → datadog-v_mXWncN.js} +1 -1
  80. package/dist/chunks/{debug-D58GQBDG.js → debug-8DCufdSp.js} +4 -4
  81. package/dist/chunks/detectRepository-DfX8xXw2.js +1 -0
  82. package/dist/chunks/{diff-DIg66U_d.js → diff-DJSt7QO6.js} +1 -1
  83. package/dist/chunks/directoryCompletion-CT6YVeg7.js +1 -0
  84. package/dist/chunks/doctor-DWvioSU9.js +1 -0
  85. package/dist/chunks/entry-ex0-RyYV.js +13 -0
  86. package/dist/chunks/esm-0CwQE5CJ.js +10 -0
  87. package/dist/chunks/esm-BCmY8V0C.js +1 -0
  88. package/dist/chunks/esm-BQY8jJNR.js +1 -0
  89. package/dist/chunks/esm-BUJtY-Rb.js +1 -0
  90. package/dist/chunks/esm-BadZVa27.js +1 -0
  91. package/dist/chunks/esm-BbMeEYcz.js +1 -0
  92. package/dist/chunks/esm-sVMjGuep.js +1 -0
  93. package/dist/chunks/execFileNoThrow-BsfuytkN.js +34 -0
  94. package/dist/chunks/exit-BxC_ZEtO.js +1 -0
  95. package/dist/chunks/extraUsage-DYm33Occ.js +1 -0
  96. package/dist/chunks/extractMemories-CzN3Ax2B.js +1 -0
  97. package/dist/chunks/fast-DqUpl_Lr.js +1 -0
  98. package/dist/chunks/fast-NUdUyAaM.js +1 -0
  99. package/dist/chunks/fetchModelList-CqsTAWEN.js +1 -0
  100. package/dist/chunks/fetchModelList-DBMHE6Ng.js +1 -0
  101. package/dist/chunks/fileSuggestions-B-SLfb-o.js +3 -0
  102. package/dist/chunks/firstPartyEventLogger-C0q45h_4.js +3 -0
  103. package/dist/chunks/firstPartyEventLogger-CP8hCBDj.js +1 -0
  104. package/dist/chunks/fpsMetrics-wxj9GAsd.js +1 -0
  105. package/dist/chunks/gemini-BC9kHhwe.js +2 -0
  106. package/dist/chunks/generateSessionName-ChvKBVxB.js +1 -0
  107. package/dist/chunks/{genericProcessUtils-6E7fB1dI.js → genericProcessUtils-BYi0OefF.js} +3 -3
  108. package/dist/chunks/goal-ByyimpVU.js +3 -0
  109. package/dist/chunks/grok-DenjixMl.js +1 -0
  110. package/dist/chunks/grove-Dq8QbQ9o.js +7 -0
  111. package/dist/chunks/help-CK90i4hE.js +1 -0
  112. package/dist/chunks/history-CNQNd6hT.js +1 -0
  113. package/dist/chunks/{hooks-7iyENdDG.js → hooks-BRFDg9DV.js} +2 -2
  114. package/dist/chunks/hooks-BaYwmkxD.js +1 -0
  115. package/dist/chunks/install-ZMll-dAa.js +1 -0
  116. package/dist/chunks/instrumentation-BwVyvRfY.js +21 -0
  117. package/dist/chunks/{job-CXz7SLZp.js → job-G_ukhLc4.js} +1 -1
  118. package/dist/chunks/keybindings-wNxBzDVQ.js +1 -0
  119. package/dist/chunks/launchLocalMemory-BcRlXLm6.js +3 -0
  120. package/dist/chunks/launchOnboarding-CDjQ64RO.js +8 -0
  121. package/dist/chunks/{loadAgentsDir-DaNpxaO-.js → loadAgentsDir-C1LkW7gl.js} +571 -641
  122. package/dist/chunks/loadAgentsDir-DKXap_Om.js +1 -0
  123. package/dist/chunks/loadPluginHooks-DtmHtEiS.js +1 -0
  124. package/dist/chunks/{loader-C33o_5kS.js → loader-C61fB6vU.js} +1 -1
  125. package/dist/chunks/localSearch-BB9x5C2N.js +1 -0
  126. package/dist/chunks/{localSearch-C2SZ9bGW.js → localSearch-DFo_WTMm.js} +1 -1
  127. package/dist/chunks/log-DaILwWJa.js +1 -0
  128. package/dist/chunks/logoUtils-Dj_2SWmO.js +1 -0
  129. package/dist/chunks/{magicDocs-CrTwULyJ.js → magicDocs-DYc9TFmI.js} +2 -2
  130. package/dist/chunks/main-BRg8L_aw.js +346 -0
  131. package/dist/chunks/managedEnv-DsqAYOJ4.js +1 -0
  132. package/dist/chunks/managedEnv-lybrMred.js +1 -0
  133. package/dist/chunks/mcp-Bsw3cMiJ.js +6 -0
  134. package/dist/chunks/mcp-DDdud6Y7.js +1 -0
  135. package/dist/chunks/mcp-DbgTDUt7.js +2 -0
  136. package/dist/chunks/memory-CzwTzihf.js +1 -0
  137. package/dist/chunks/modalContext-DDZdU1J8.js +1 -0
  138. package/dist/chunks/mode-Pan-Q2c4.js +2 -0
  139. package/dist/chunks/model-BYfmXKHf.js +1 -0
  140. package/dist/chunks/model-BwBE0Pt5.js +1 -0
  141. package/dist/chunks/modelOptions-DvNBapgG.js +1 -0
  142. package/dist/chunks/nativeInstaller-DnSNJWIi.js +1 -0
  143. package/dist/chunks/notifications-B0DTaYoy.js +1 -0
  144. package/dist/chunks/omit-Dl1Us_PY.js +1 -0
  145. package/dist/chunks/onChangeAppState-4KOJMN82.js +1 -0
  146. package/dist/chunks/openai-C_6C1_0N.js +10 -0
  147. package/dist/chunks/overlayContext-CMV7nYR9.js +1 -0
  148. package/dist/chunks/panel-D9fGQgln.js +1 -0
  149. package/dist/chunks/parser-BKAVMTyD.js +1 -0
  150. package/dist/chunks/{parser-eVu-cTRs.js → parser-D8slvrJP.js} +1 -1
  151. package/dist/chunks/partition-B504IgAa.js +1 -0
  152. package/dist/chunks/pasteStore-DNV1M5Xd.js +1 -0
  153. package/dist/chunks/permissions-CLFMhdRk.js +3 -0
  154. package/dist/chunks/pidLock-D9do1Afy.js +3 -0
  155. package/dist/chunks/plan-CQLnPLuE.js +1 -0
  156. package/dist/chunks/{platform-DMQxcm4K.js → platform-Dzff1WWw.js} +1 -1
  157. package/dist/chunks/plugin-BYdF7uob.js +17 -0
  158. package/dist/chunks/pluginAutoupdate-BJaAqwTH.js +1 -0
  159. package/dist/chunks/pluginBlocklist-DKKmOnWM.js +1 -0
  160. package/dist/chunks/pluginCliCommands-z8TtJMKH.js +1 -0
  161. package/dist/chunks/{pluginFlagging-DRA0m76J.js → pluginFlagging-DQP8tBi2.js} +1 -1
  162. package/dist/chunks/pluginOperations-BcfJCDco.js +2 -0
  163. package/dist/chunks/{pluginStartupCheck-BF1N4Lih.js → pluginStartupCheck-CfRvCrFg.js} +1 -1
  164. package/dist/chunks/pluginStartupCheck-Cq4PvULa.js +1 -0
  165. package/dist/chunks/plugins-CTM8jpOw.js +4 -0
  166. package/dist/chunks/policyLimits-a7ix6GnU.js +1 -0
  167. package/dist/chunks/poorMode-C11JEH3d.js +1 -0
  168. package/dist/chunks/{poorMode-CKQfWf3S.js → poorMode-J5SYJvoY.js} +1 -1
  169. package/dist/chunks/print-u6MzL5Cr.js +13 -0
  170. package/dist/chunks/processBashCommand-DIwrI2QC.js +1 -0
  171. package/dist/chunks/processSlashCommand-B-Gujpxm.js +5 -0
  172. package/dist/chunks/projectOnboardingState-CJycxw5P.js +1 -0
  173. package/dist/chunks/{prompt-8u06WVES.js → prompt-BGqgPgCU.js} +3 -3
  174. package/dist/chunks/prompt-BPJDGlx5.js +1 -0
  175. package/dist/chunks/prompt-DEdZzkEz.js +1 -0
  176. package/dist/chunks/promptEditor-CmQ9p4oe.js +4 -0
  177. package/dist/chunks/{protocolHandler-DzHVaPl3.js → protocolHandler-CJo9-PfZ.js} +2 -2
  178. package/dist/chunks/{proxy-BhIc7-mj.js → proxy-CB17QimU.js} +2 -2
  179. package/dist/chunks/reconciler-DSKLuOS7.js +1 -0
  180. package/dist/chunks/refresh-BbZFCNpn.js +1 -0
  181. package/dist/chunks/registerProtocol-CLIpzVwF.js +1 -0
  182. package/dist/chunks/reload-plugins-DjugL8jH.js +1 -0
  183. package/dist/chunks/rename-DOtCOtEr.js +1 -0
  184. package/dist/chunks/{renderOptions-D-aQZbzS.js → renderOptions-Zqfm2U1y.js} +1 -1
  185. package/dist/chunks/resume-BB4T4WIV.js +2 -0
  186. package/dist/chunks/ripgrep-BuzOTf1S.js +5 -0
  187. package/dist/chunks/ripgrep-CZ2CqaHb.js +1 -0
  188. package/dist/chunks/{runtimeObserver-DzesbvgI.js → runtimeObserver-CK_iZ6OB.js} +1 -1
  189. package/dist/chunks/{runtimeObserver-L6041elO.js → runtimeObserver-CpP0L9T9.js} +4 -4
  190. package/dist/chunks/sandbox-adapter-DhJJ6WOV.js +1 -0
  191. package/dist/chunks/sandbox-toggle-KOHYvbQT.js +1 -0
  192. package/dist/chunks/searchExtraTools-CdJghGkj.js +1 -0
  193. package/dist/chunks/select-C_KXmqbI.js +1 -0
  194. package/dist/chunks/sessionFileAccessHooks-D7KbWFp7.js +1 -0
  195. package/dist/chunks/sessionObserver-DB-sLv-X.js +1 -0
  196. package/dist/chunks/{sessionObserver-0D8xFoRK.js → sessionObserver-WOYv2n7C.js} +2 -2
  197. package/dist/chunks/sessionStorage-sgOAbDn7.js +1 -0
  198. package/dist/chunks/sessionTracing-yBre24PH.js +11 -0
  199. package/dist/chunks/settings-C-KNkvsM.js +1 -0
  200. package/dist/chunks/settings-DKN4xSpQ.js +24 -0
  201. package/dist/chunks/setup-CN_Pk7AR.js +3 -0
  202. package/dist/chunks/{shadowedRuleDetection-Cy9tsuKc.js → shadowedRuleDetection-Df-kZ_pK.js} +1 -1
  203. package/dist/chunks/{sideQuestion-Ds7Elgs4.js → sideQuestion-CMB8hfgX.js} +3 -3
  204. package/dist/chunks/sinks-BS17vtN0.js +1 -0
  205. package/dist/chunks/sinks-D1EjkHb4.js +1 -0
  206. package/dist/chunks/skillChangeDetector-CBKuGuEi.js +1 -0
  207. package/dist/chunks/{skillGapStore-BxCxKPev.js → skillGapStore-CfmlO6pb.js} +2 -2
  208. package/dist/chunks/{skillLifecycle-CfyNC3sW.js → skillLifecycle-BQ2LMfMx.js} +2 -2
  209. package/dist/chunks/{skillSearchPanel-CMNJFIEC.js → skillSearchPanel-BwYuwLFs.js} +4 -4
  210. package/dist/chunks/skills-BVHPQma0.js +1 -0
  211. package/dist/chunks/src-9vmGsuSI.js +1 -0
  212. package/dist/chunks/{src-CgZmCiiH.js → src-BacxF9BD.js} +2 -2
  213. package/dist/chunks/startupProfiler-B_U4QDtf.js +1 -0
  214. package/dist/chunks/startupProfiler-DTs9w9EN.js +3 -0
  215. package/dist/chunks/{state-D5D6QpTX.js → state-BowF111d.js} +1 -1
  216. package/dist/chunks/state-CGuyDES7.js +1 -0
  217. package/dist/chunks/staticRender-BVWx0IM1.js +1 -0
  218. package/dist/chunks/status-BurdTfyz.js +2 -0
  219. package/dist/chunks/status-DMq1An5h.js +1 -0
  220. package/dist/chunks/statusNoticeHelpers-X75JNlx5.js +1 -0
  221. package/dist/chunks/stringUtils-BQm3OfeJ.js +4 -0
  222. package/dist/chunks/{switcher-DQF5ZNal.js → switcher-Bq1Ct_Sn.js} +1 -1
  223. package/dist/chunks/switcher-DGD4ORVf.js +1 -0
  224. package/dist/chunks/{tasks-C8pb6ftc.js → tasks-0c8Uy04D.js} +1 -1
  225. package/dist/chunks/tempfile-CHO5wXsV.js +1 -0
  226. package/dist/chunks/{templateJobs-DJ4dcfcL.js → templateJobs-BdFzE9XG.js} +1 -1
  227. package/dist/chunks/terminalSetup-Cf_r6pwK.js +32 -0
  228. package/dist/chunks/{terminalSetup-7PdC4fV5.js → terminalSetup-D7J6bxcn.js} +1 -1
  229. package/dist/chunks/theme-Bby4fssR.js +1 -0
  230. package/dist/chunks/tipRegistry-CyRXWWTz.js +2 -0
  231. package/dist/chunks/{toolEventObserver-D2nk8ZbW.js → toolEventObserver-CzFZUIsM.js} +1 -1
  232. package/dist/chunks/toolPool-CnrZcprA.js +1 -0
  233. package/dist/chunks/types-zk5Ltv5q.js +81 -0
  234. package/dist/chunks/udsClient-ftP0yIpe.js +1 -0
  235. package/dist/chunks/use-select-navigation-DMaC_3iw.js +1 -0
  236. package/dist/chunks/useDoublePress-C9xxQzh1.js +1 -0
  237. package/dist/chunks/useExitOnCtrlCDWithKeybindings-CjW3gUOt.js +1 -0
  238. package/dist/chunks/useMainLoopModel-DWscpA9I.js +1 -0
  239. package/dist/chunks/useManagePlugins-CYXVcql2.js +1 -0
  240. package/dist/chunks/useMergedTools-DarmnCEw.js +1 -0
  241. package/dist/chunks/useSearchInput-C2JuUW3g.js +1 -0
  242. package/dist/chunks/useSettingsErrors-DutJBiKZ.js +1 -0
  243. package/dist/chunks/util-Bq5l7FF5.js +1 -0
  244. package/dist/chunks/validatePlugin-DIdEydz_.js +1 -0
  245. package/dist/chunks/{vim-BagKUX4j.js → vim-D8prM2IH.js} +1 -1
  246. package/dist/chunks/worktree-Caqt2WRZ.js +1 -0
  247. package/dist/cli.js +1 -1
  248. package/package.json +3 -21
  249. package/dist/chunks/AddWorkspaceDirectory-BYNvxNrD.js +0 -1
  250. package/dist/chunks/AgentsMdExternalIncludesDialog-BSSz86ER.js +0 -1
  251. package/dist/chunks/AgentsMdExternalIncludesDialog-CMEGV4Md.js +0 -1
  252. package/dist/chunks/App-W_9d1DjK.js +0 -1
  253. package/dist/chunks/ApproveApiKey-Bf1Rb8Ql.js +0 -1
  254. package/dist/chunks/ApproveApiKey-wpdvXpFr.js +0 -1
  255. package/dist/chunks/BackgroundTasksDialog-lGn1Wj1k.js +0 -2
  256. package/dist/chunks/BypassPermissionsModeDialog-CjVjyNf8.js +0 -1
  257. package/dist/chunks/DiffDialog-DCpchgp5.js +0 -6
  258. package/dist/chunks/Doctor-6SjW91rd.js +0 -1
  259. package/dist/chunks/Doctor-FPYTivHw.js +0 -3
  260. package/dist/chunks/ExitFlow-Dy8_1D8J.js +0 -2
  261. package/dist/chunks/Grove-Dd6rjs5P.js +0 -11
  262. package/dist/chunks/HybridTransport-CJVkWa2u.js +0 -2
  263. package/dist/chunks/InvalidConfigDialog-Bisj9ic_.js +0 -1
  264. package/dist/chunks/InvalidSettingsDialog-DyTPNRQR.js +0 -1
  265. package/dist/chunks/MCPConnectionManager-DfyoZaiu.js +0 -1
  266. package/dist/chunks/MCPToolListView-Dioupv8F.js +0 -1
  267. package/dist/chunks/McpParsingWarnings-BUlgpZAF.js +0 -1
  268. package/dist/chunks/MessageSelector-D8fylxPg.js +0 -3
  269. package/dist/chunks/Messages-BZDFMYBT.js +0 -10
  270. package/dist/chunks/Onboarding-BKLomZYo.js +0 -1
  271. package/dist/chunks/PermissionDialog-BPhvs5xH.js +0 -1
  272. package/dist/chunks/PressEnterToContinue-Dwoh6CaW.js +0 -1
  273. package/dist/chunks/PromptInputFooterSuggestions-DCum89fF.js +0 -1
  274. package/dist/chunks/PromptInputHelpMenu-DG2lRqis.js +0 -1
  275. package/dist/chunks/QueryEngine-CyGHpX7M.js +0 -1
  276. package/dist/chunks/REPL-BDsz8KIx.js +0 -1
  277. package/dist/chunks/REPL-CCBNfZfs.js +0 -128
  278. package/dist/chunks/RemoteSessionManager-BfsOv4K6.js +0 -2
  279. package/dist/chunks/ResumeConversation-pC8NLq0F.js +0 -1
  280. package/dist/chunks/SSETransport-B3K6eH9I.js +0 -2
  281. package/dist/chunks/SearchExtraToolsTool-DYoxHo9T.js +0 -1
  282. package/dist/chunks/Settings-CKaGmKg2.js +0 -2
  283. package/dist/chunks/TeleportProgress-CkgSp1cs.js +0 -1
  284. package/dist/chunks/TeleportRepoMismatchDialog-DdO_rECq.js +0 -1
  285. package/dist/chunks/TeleportResumeWrapper-BeG4N-2z.js +0 -1
  286. package/dist/chunks/ThemePicker-iD9ufy99.js +0 -1
  287. package/dist/chunks/TrustDialog-qO5OdQt8.js +0 -1
  288. package/dist/chunks/add-dir-C4eSVlZ6.js +0 -1
  289. package/dist/chunks/agents-D3APE_8d.js +0 -101
  290. package/dist/chunks/allErrors-BkgB7JNK.js +0 -1
  291. package/dist/chunks/api-BHBK9axp.js +0 -1
  292. package/dist/chunks/api-DyUWfg3a.js +0 -1
  293. package/dist/chunks/auth-0rn1U4Eq.js +0 -10
  294. package/dist/chunks/auth-BEoTPSgC.js +0 -1
  295. package/dist/chunks/auth-BPug7U_u.js +0 -1
  296. package/dist/chunks/backgroundHousekeeping-D7xAhUaE.js +0 -1
  297. package/dist/chunks/backgroundHousekeeping-km82qEh0.js +0 -17
  298. package/dist/chunks/banner-BkUdig-T.js +0 -2
  299. package/dist/chunks/bg-tGgpwpYx.js +0 -9
  300. package/dist/chunks/branch-CQ38cx5n.js +0 -2
  301. package/dist/chunks/bridgeConfig-C5L-7KaP.js +0 -1
  302. package/dist/chunks/bridgeConfig-CJMjDoaP.js +0 -1
  303. package/dist/chunks/bridgeMessaging-DVC3qj-C.js +0 -1
  304. package/dist/chunks/bridgePointer-DfTOjgtX.js +0 -1
  305. package/dist/chunks/bridgeStatusUtil-Cex6VowM.js +0 -1
  306. package/dist/chunks/btw-_P96ffHR.js +0 -1
  307. package/dist/chunks/bundledMode--fG1S62b.js +0 -1
  308. package/dist/chunks/caches-DH-q8Fjf.js +0 -1
  309. package/dist/chunks/caches-Dq0pJFDP.js +0 -1
  310. package/dist/chunks/capacityWake-BpP6c7x3.js +0 -3
  311. package/dist/chunks/ccrClient-DO563xlf.js +0 -1
  312. package/dist/chunks/claudeDesktop-DPc_SaVn.js +0 -1
  313. package/dist/chunks/cliLaunch-DDtwAolw.js +0 -1
  314. package/dist/chunks/client-9uHzAmFH.js +0 -1
  315. package/dist/chunks/client-BVal_QII.js +0 -1
  316. package/dist/chunks/client-C19cqYQS.js +0 -1
  317. package/dist/chunks/client-Dd7CKMRX.js +0 -1
  318. package/dist/chunks/commands-BkpqHY9F.js +0 -1
  319. package/dist/chunks/compact-DuVIvqMu.js +0 -2
  320. package/dist/chunks/config-DMP6-Ccr.js +0 -1
  321. package/dist/chunks/config-DRy1I12M.js +0 -3
  322. package/dist/chunks/config-e0Goy478.js +0 -1
  323. package/dist/chunks/context-DjgMzIfe.js +0 -1
  324. package/dist/chunks/context-noninteractive-DV7bIJCm.js +0 -1
  325. package/dist/chunks/controlMessageCompat-IFu4Gc1y.js +0 -1
  326. package/dist/chunks/conversation-BBOE_EoE.js +0 -1
  327. package/dist/chunks/conversation-WxH5pb2z.js +0 -1
  328. package/dist/chunks/createSSHSession-LVGVXHXL.js +0 -5
  329. package/dist/chunks/createSession-BUzna9-E.js +0 -1
  330. package/dist/chunks/createSession-Dgwxk1WA.js +0 -1
  331. package/dist/chunks/crossProjectResume-6B2NYy8a.js +0 -40
  332. package/dist/chunks/cwd-DLK3znO7.js +0 -1
  333. package/dist/chunks/cwd-Nh5IZNKO.js +0 -1
  334. package/dist/chunks/debugUtils-DXBRbwCE.js +0 -1
  335. package/dist/chunks/detached-Biz-xhu0.js +0 -4
  336. package/dist/chunks/detectRepository-CDOJ-M7h.js +0 -1
  337. package/dist/chunks/detectRepository-Cv9-k6dg.js +0 -1
  338. package/dist/chunks/directoryCompletion-BDGcGDuv.js +0 -1
  339. package/dist/chunks/doctor-BhUmhHQU.js +0 -1
  340. package/dist/chunks/entry-B-Y-AYeK.js +0 -13
  341. package/dist/chunks/esm-BYnFh4pG.js +0 -1
  342. package/dist/chunks/esm-Bx6rTxIs.js +0 -1
  343. package/dist/chunks/esm-C367Cyo-.js +0 -1
  344. package/dist/chunks/esm-CXM9jqO_.js +0 -1
  345. package/dist/chunks/esm-CXczu_-W.js +0 -1
  346. package/dist/chunks/esm-CXt5K8Xt.js +0 -1
  347. package/dist/chunks/esm-Cb-L4oAk.js +0 -1
  348. package/dist/chunks/esm-CvHtYRrr.js +0 -1
  349. package/dist/chunks/esm-DhRjocaU.js +0 -1
  350. package/dist/chunks/esm-DklLYEuz.js +0 -1
  351. package/dist/chunks/esm-IYgGg4wR.js +0 -1
  352. package/dist/chunks/esm-lyfry1WB.js +0 -10
  353. package/dist/chunks/execFileNoThrow-Bmb5HEFz.js +0 -34
  354. package/dist/chunks/execSyncWrapper-C3ZFV9od.js +0 -1
  355. package/dist/chunks/exit-CW2eqUrR.js +0 -1
  356. package/dist/chunks/extraUsage-CkTon7ib.js +0 -1
  357. package/dist/chunks/extractMemories-CfmbvayQ.js +0 -1
  358. package/dist/chunks/fast-ByahC7Gw.js +0 -1
  359. package/dist/chunks/fast-xtIP4u4y.js +0 -1
  360. package/dist/chunks/fetchModelList-D9aePIPW.js +0 -1
  361. package/dist/chunks/fetchModelList-Dy-x4h3G.js +0 -1
  362. package/dist/chunks/fileSuggestions-CFkJktgc.js +0 -3
  363. package/dist/chunks/firstPartyEventLogger-Bt9iG9xk.js +0 -1
  364. package/dist/chunks/firstPartyEventLogger-DqGSujCz.js +0 -3
  365. package/dist/chunks/flushGate-BjKW7PFC.js +0 -1
  366. package/dist/chunks/fpsMetrics-Dk_pnSHJ.js +0 -1
  367. package/dist/chunks/gemini-NnmxBoEp.js +0 -1
  368. package/dist/chunks/generateSessionName-EpqGW-T2.js +0 -1
  369. package/dist/chunks/git-By_J4XJL.js +0 -5
  370. package/dist/chunks/git-zJCasBa6.js +0 -1
  371. package/dist/chunks/githubRepoPathMapping-CzgPGOHQ.js +0 -1
  372. package/dist/chunks/goal-DbS8yJfB.js +0 -3
  373. package/dist/chunks/grok-BxZ4vTDw.js +0 -1
  374. package/dist/chunks/grove-CYE1Cfcz.js +0 -7
  375. package/dist/chunks/hash-Tu-My5Vp.js +0 -1
  376. package/dist/chunks/help-DatnwM25.js +0 -1
  377. package/dist/chunks/hooks-DjbqtbUV.js +0 -1
  378. package/dist/chunks/initReplBridge-BEZW5PEY.js +0 -1
  379. package/dist/chunks/install-DJukI-kL.js +0 -1
  380. package/dist/chunks/instrumentation-2HH15DPu.js +0 -21
  381. package/dist/chunks/jwtUtils-C_LG1txt.js +0 -1
  382. package/dist/chunks/keybindings-C9l5il16.js +0 -1
  383. package/dist/chunks/launchLocalMemory-BfGenqj1.js +0 -3
  384. package/dist/chunks/launchOnboarding-DjMmXeQE.js +0 -8
  385. package/dist/chunks/lazySchema-DULtBUCI.js +0 -65
  386. package/dist/chunks/lib-BlVGipXx.js +0 -14
  387. package/dist/chunks/loadAgentsDir-DcI-8FQF.js +0 -1
  388. package/dist/chunks/loadPluginHooks-CGgpcyEC.js +0 -1
  389. package/dist/chunks/localSearch-CTTwYTU1.js +0 -1
  390. package/dist/chunks/log-CZ7ploQm.js +0 -1
  391. package/dist/chunks/logoUtils-CbIqOFrX.js +0 -1
  392. package/dist/chunks/main-Blm02_Js.js +0 -31
  393. package/dist/chunks/main-bJXadFi0.js +0 -356
  394. package/dist/chunks/managedEnv-CUsdYhAI.js +0 -1
  395. package/dist/chunks/managedEnv-DXeaUDSK.js +0 -1
  396. package/dist/chunks/mappers-_B-s9fNz.js +0 -1
  397. package/dist/chunks/mcp-BbbYzWpy.js +0 -6
  398. package/dist/chunks/mcp-D91sH9a8.js +0 -1
  399. package/dist/chunks/mcp-Dx-zgUgu.js +0 -2
  400. package/dist/chunks/memoize-CumjjK2Q.js +0 -1
  401. package/dist/chunks/memory-BeL7ui9m.js +0 -1
  402. package/dist/chunks/modalContext-wY9CeN4G.js +0 -1
  403. package/dist/chunks/mode-D695kgLI.js +0 -2
  404. package/dist/chunks/model-DX0TtzqX.js +0 -1
  405. package/dist/chunks/model-Do0f476p.js +0 -1
  406. package/dist/chunks/model-DpcM8dz5.js +0 -1
  407. package/dist/chunks/modelOptions-B3nis9cC.js +0 -1
  408. package/dist/chunks/nativeInstaller-CymO8TNe.js +0 -1
  409. package/dist/chunks/oauth-D38aRTUb.js +0 -1
  410. package/dist/chunks/oauth-U649LV5H.js +0 -1
  411. package/dist/chunks/omit-DO61BHZu.js +0 -1
  412. package/dist/chunks/onChangeAppState-vKml_lit.js +0 -1
  413. package/dist/chunks/openai-DdupGVdC.js +0 -10
  414. package/dist/chunks/panel-CVd1dzYl.js +0 -1
  415. package/dist/chunks/parser-Cq9X7HMP.js +0 -1
  416. package/dist/chunks/partition-BivH9MBJ.js +0 -1
  417. package/dist/chunks/permissions-C9iqR4_N.js +0 -3
  418. package/dist/chunks/pidLock-DiKz5Tza.js +0 -3
  419. package/dist/chunks/plan-KDN5IGWY.js +0 -1
  420. package/dist/chunks/plugin-D0rzUb8E.js +0 -17
  421. package/dist/chunks/pluginAutoupdate-C2xTKLR_.js +0 -1
  422. package/dist/chunks/pluginBlocklist-xdiUmUpt.js +0 -1
  423. package/dist/chunks/pluginCliCommands-CIDDvVN7.js +0 -1
  424. package/dist/chunks/pluginOperations-BEYsarAn.js +0 -2
  425. package/dist/chunks/pluginStartupCheck-DVkI4pqo.js +0 -1
  426. package/dist/chunks/plugins-CWWU4BKs.js +0 -4
  427. package/dist/chunks/pollConfig-2nFzv6Hy.js +0 -1
  428. package/dist/chunks/poorMode-BTIe8W_H.js +0 -1
  429. package/dist/chunks/print-B5H2xbBS.js +0 -14
  430. package/dist/chunks/processBashCommand-EQ9EWaRV.js +0 -1
  431. package/dist/chunks/processSlashCommand-C4PKNyFT.js +0 -5
  432. package/dist/chunks/prompt-B9sDzLPK.js +0 -1
  433. package/dist/chunks/prompt-WsoTRhoh.js +0 -1
  434. package/dist/chunks/promptEditor-Cr4w-4Bz.js +0 -4
  435. package/dist/chunks/rcDebugLog-DSchf3Hs.js +0 -1
  436. package/dist/chunks/reconciler-RIKmaPg7.js +0 -1
  437. package/dist/chunks/refresh-CCSCAjgz.js +0 -1
  438. package/dist/chunks/registerProtocol-C0IlPEoa.js +0 -1
  439. package/dist/chunks/reload-plugins-DC-tbXVv.js +0 -1
  440. package/dist/chunks/remoteBridgeCore-NGTnhQgw.js +0 -1
  441. package/dist/chunks/remoteManagedSettings-BoOYHzYP.js +0 -1
  442. package/dist/chunks/rename-DS1AmW-F.js +0 -1
  443. package/dist/chunks/resume-Cf5PSoPw.js +0 -2
  444. package/dist/chunks/ripgrep-C3jtZL7k.js +0 -5
  445. package/dist/chunks/ripgrep-CBUbn6Po.js +0 -1
  446. package/dist/chunks/sandbox-adapter-Z4Phj31K.js +0 -1
  447. package/dist/chunks/sandbox-toggle-COZE8Lo4.js +0 -1
  448. package/dist/chunks/searchExtraTools-CvkRbL2m.js +0 -1
  449. package/dist/chunks/session-BvA99K4j.js +0 -2
  450. package/dist/chunks/sessionFileAccessHooks-6XfAf6ke.js +0 -1
  451. package/dist/chunks/sessionIdCompat-Dgp6PW_1.js +0 -1
  452. package/dist/chunks/sessionObserver-CRWUBJEY.js +0 -1
  453. package/dist/chunks/sessionState-CQhbGfmh.js +0 -11
  454. package/dist/chunks/sessionStorage-DqEuxDlb.js +0 -1
  455. package/dist/chunks/sessionStoragePortable-x0Yn02-G.js +0 -3
  456. package/dist/chunks/sessionTracing-BoOZsXU2.js +0 -11
  457. package/dist/chunks/settings-3xZ0fsvE.js +0 -19
  458. package/dist/chunks/settings-Crx1cI1u.js +0 -1
  459. package/dist/chunks/settingsSync-rkWmClKS.js +0 -1
  460. package/dist/chunks/setup-D8L275fT.js +0 -3
  461. package/dist/chunks/shellQuote-Ddgr1vif.js +0 -4
  462. package/dist/chunks/sinks-BXX72cbf.js +0 -1
  463. package/dist/chunks/sinks-DMp6uEzM.js +0 -1
  464. package/dist/chunks/skillChangeDetector-CtithJ4a.js +0 -1
  465. package/dist/chunks/skills-DXMk-498.js +0 -1
  466. package/dist/chunks/src-D3yIF9I42.js +0 -1
  467. package/dist/chunks/src-DQOX_xI1.js +0 -1
  468. package/dist/chunks/src-Dt5IJd3C.js +0 -1
  469. package/dist/chunks/src-Dvp6-vB7.js +0 -19
  470. package/dist/chunks/src-PM8NIIu_.js +0 -1
  471. package/dist/chunks/startupProfiler-CbzxVmbv.js +0 -3
  472. package/dist/chunks/startupProfiler-uHetQush.js +0 -1
  473. package/dist/chunks/state-BStOuCh4.js +0 -1
  474. package/dist/chunks/staticRender-D9AbnQFr.js +0 -1
  475. package/dist/chunks/stats-Ce15gc3E.js +0 -1
  476. package/dist/chunks/status-CFrLuGbf.js +0 -2
  477. package/dist/chunks/status-D5OCkMZG.js +0 -1
  478. package/dist/chunks/statusNoticeHelpers-CZoOse-_.js +0 -1
  479. package/dist/chunks/stringUtils-CKD8qDqx.js +0 -4
  480. package/dist/chunks/subprocessEnv-CNBOhlDV.js +0 -1
  481. package/dist/chunks/subprocessEnv-DtBCqQIo.js +0 -1
  482. package/dist/chunks/switcher-AiMcRzoi.js +0 -1
  483. package/dist/chunks/syncCache-qWJ_VfBo.js +0 -1
  484. package/dist/chunks/teleport-Bi_1VFIZ.js +0 -1
  485. package/dist/chunks/terminalSetup-kWdZRKWq.js +0 -32
  486. package/dist/chunks/theme-CEKOCSLw.js +0 -1
  487. package/dist/chunks/tmux-CpGd0Aca.js +0 -1
  488. package/dist/chunks/toolPool-Df5iUqJ-.js +0 -1
  489. package/dist/chunks/trustedDevice-CB6rNzl-.js +0 -1
  490. package/dist/chunks/trustedDevice-DXGePUAC.js +0 -1
  491. package/dist/chunks/types-APu4OCXJ.js +0 -17
  492. package/dist/chunks/udsClient-U7MEfYj7.js +0 -1
  493. package/dist/chunks/upstreamproxy-CTOuotLO.js +0 -10
  494. package/dist/chunks/useExitOnCtrlCDWithKeybindings-Bw0mlTT9.js +0 -1
  495. package/dist/chunks/useMainLoopModel-CIG2cjS2.js +0 -1
  496. package/dist/chunks/useManagePlugins-MSHw-qHx.js +0 -1
  497. package/dist/chunks/useMergedTools-Bb-INJa2.js +0 -1
  498. package/dist/chunks/useSearchInput-QL_VtdJD.js +0 -1
  499. package/dist/chunks/useSettingsErrors-Dvi6zLCr.js +0 -1
  500. package/dist/chunks/userAgent-i-oGzf40.js +0 -1
  501. package/dist/chunks/util-CLQvtXuD.js +0 -1
  502. package/dist/chunks/validatePlugin-1mTZ3TJR.js +0 -1
  503. package/dist/chunks/which-BxQ1hpjp.js +0 -1
  504. package/dist/chunks/windowsPaths-BdhjMYTm.js +0 -1
  505. package/dist/chunks/windowsPaths-DtGZ83kH.js +0 -1
  506. package/dist/chunks/workSecret-CaM2yIJD.js +0 -1
  507. package/dist/chunks/workerRegistry-BjxoZ12l.js +0 -2
  508. package/dist/chunks/worktree-DpksgxdF.js +0 -1
  509. /package/dist/chunks/{src-DL3w8VPk2.js → src-DL3w8VPk.js} +0 -0
@@ -0,0 +1,124 @@
1
+ import{a as e,n as t,o as n}from"./rolldown-runtime-DaDcL9Zw.js";import{c as r,i,l as a,o}from"./envUtils-DcaKZlRU.js";import{n as s,t as c}from"./defineProperty-C-QyHrDq.js";import{n as l,t as u}from"./figures-5ThXQEtq.js";import{t as d}from"./semver-DQo45qGo.js";import{et as f,rt as p}from"./esm-BQY8jJNR.js";import{n as m,t as h}from"./axios-DaWTGg7G.js";import{$S as g,$g as _,$n as v,$o as y,$p as b,$r as x,$u as S,A as C,AS as w,A_ as T,Ab as E,Ac as D,Ag as O,Ah as k,Am as A,An as j,Ao as M,Ap as N,As as ee,B as te,BS as P,B_ as F,Bg as I,Bi as L,Bm as ne,Bt as re,C as ie,C_ as ae,Cc as oe,Cd as se,Cg as ce,Ch as le,Cm as R,Cp as z,Cr as ue,Cu as B,DS as de,Db as fe,Dc as pe,Df as me,Dg as he,Di as ge,Dp as V,Du as _e,Dw as ve,ES as ye,Ec as be,Ef as xe,Eg as Se,Em as Ce,Eu as we,Ew as Te,FC as Ee,FS as De,F_ as Oe,Fc as ke,Fd as Ae,Ff as je,Fg as Me,Fn as Ne,Fp as Pe,Fu as Fe,Fw as Ie,G_ as Le,Gb as Re,Gf as ze,Gg as Be,Gp as Ve,HS as He,H_ as Ue,Hb as We,Hf as Ge,Hg as Ke,Hn as qe,Ib as Je,Id as Ye,If as Xe,Ig as Ze,Ii as Qe,In as $e,Ip as et,Iu as tt,J as nt,Jb as rt,Jc as it,Jd as at,Jg as ot,Jl as st,Jo as ct,Jp as lt,Jr as ut,Ju as dt,K as ft,KC as pt,K_ as mt,Kb as ht,Kn as gt,Kp as _t,Kr as vt,Ks as yt,L_ as bt,La as xt,Ld as St,Lf as Ct,Lg as wt,Lp as Tt,Lu as Et,MS as Dt,M_ as Ot,Mc as kt,Mh as At,Mm as jt,Mt,Mu as Nt,Mw as Pt,Mx as Ft,My as It,N_ as Lt,Na as Rt,Nb as zt,Nc as Bt,Ng as Vt,Ni as Ht,Nn as Ut,Ns as Wt,Nw as H,Nx as Gt,O as Kt,Ob as qt,Oc as Jt,Og as Yt,Oh as Xt,Oi as Zt,Ol as Qt,Om as $t,Op as U,Ow as en,PS as tn,P_ as nn,Pb as rn,Pc as an,Pf as on,Pg as sn,Pi as cn,Pr as ln,Pu as un,Pw as dn,QC as fn,QS as pn,Qb as mn,Qg as hn,Qh as gn,Qi as _n,Qn as vn,Qp as yn,Qr as bn,Qs as xn,Qw as Sn,R_ as Cn,Rb as wn,Rd as Tn,Rg as En,Ri as Dn,Rn as On,Rp as kn,Ru as An,Rw as jn,Sc as Mn,Sh as Nn,Sm as Pn,So as Fn,Sp as In,Ss as Ln,St as Rn,TS as zn,Tf as Bn,Tg as Vn,Ti as Hn,Tm as Un,Tp as Wn,Tu as W,Tw as Gn,U as Kn,US as qn,U_ as Jn,Ua as G,Ub as Yn,Uf as Xn,Ug as Zn,Um as Qn,Up as $n,Us as er,V as tr,V_ as nr,Va as rr,Vf as ir,Vh as ar,Vp as or,Vt as sr,Vw as cr,W as lr,W_ as ur,Wa as dr,Wb as fr,Wf as pr,Wg as mr,Wm as hr,Ws as gr,X as _r,Xa as vr,Xb as yr,Xc as br,Xd as xr,Xg as Sr,Xl as Cr,Xo as wr,Xp as Tr,Xs as Er,Xt as Dr,YC as Or,Y_ as kr,Yb as Ar,Yc as jr,Yd as Mr,Yg as Nr,Yl as Pr,Yn as Fr,Yo as Ir,Yp as Lr,Ys as Rr,Yu as zr,Z as Br,Zb as Vr,Zd as Hr,Zg as Ur,Zi as Wr,Zp as Gr,Zr as Kr,Zs as qr,Zw as Jr,_f as Yr,_g as Xr,_i as Zr,_p as Qr,_s as $r,_x as ei,_y as ti,aT as ni,a_ as ri,ad as ii,af as ai,al as oi,am as si,ao as ci,ap as li,at as ui,aw as di,ax as fi,b as pi,bd as mi,bf as hi,bh as gi,bl as _i,bm as vi,bp as yi,bs as bi,cC as xi,cS as Si,cT as Ci,c_ as wi,cg as Ti,ci as Ei,cm as Di,co as Oi,cp as ki,cu as Ai,cx as ji,df as Mi,dg as Ni,dl as Pi,dm as Fi,do as Ii,dp as Li,dr as Ri,du as zi,dv as Bi,eC as Vi,eS as Hi,e_ as Ui,ea as Wi,ef as Gi,eg as Ki,em as qi,eo as Ji,ep as Yi,et as Xi,ex as Zi,f_ as Qi,fa as $i,ff as ea,fg as ta,fl as na,fm as ra,fo as ia,fp as aa,fu as oa,fv as sa,fx as ca,g_ as la,gc as ua,gf as da,gi as fa,go as pa,gp as ma,gs as ha,gu as ga,gy as _a,h_ as va,hc as ya,hf as ba,hg as xa,hl as Sa,hn as Ca,hs as wa,hu as Ta,hx as Ea,iT as Da,i_ as Oa,id as ka,if as Aa,il as ja,im as Ma,ip as Na,iw as Pa,ix as Fa,jS as Ia,j_ as La,ja as Ra,jc as za,jg as Ba,jh as Va,jm as Ha,js as Ua,ju as Wa,jw as Ga,jy as Ka,k as qa,k_ as Ja,kb as Ya,kc as Xa,kg as Za,ki as Qa,kl as $a,km as eo,ko as to,kp as no,kw as ro,kx as io,lT as ao,l_ as oo,lm as so,lo as co,lp as lo,lu as uo,m_ as fo,mc as po,mf as mo,mg as ho,ml as go,mm as _o,mr as vo,ms as yo,mu as bo,mx as xo,nS as So,nT as Co,n_ as wo,nd as To,nf as Eo,ng as Do,ni as Oo,nr as ko,ns as Ao,oS as jo,oT as Mo,ol as No,oo as Po,op as Fo,os as Io,ot as Lo,ou as Ro,ox as zo,p_ as Bo,pa as Vo,pc as Ho,pg as Uo,pl as Wo,pm as Go,pu as Ko,px as qo,q as Jo,q_ as Yo,qb as Xo,qd as Zo,qg as Qo,ql as $o,qp as es,qs as ts,qt as ns,rT as rs,r_ as is,rd as as,rf as os,rg as ss,rl as cs,rm as ls,rp as us,rx as ds,sC as fs,sS as ps,s_ as ms,si as hs,sl as gs,sn as _s,so as vs,sp as ys,ss as bs,sx as xs,tC as Ss,tS as Cs,t_ as ws,td as Ts,tf as Es,tl as Ds,tp as Os,ts as ks,tx as As,u_ as js,uf as Ms,ug as Ns,um as Ps,uo as Fs,up as Is,uu as Ls,vf as Rs,vg as zs,vi as Bs,vl as Vs,vm as Hs,vo as Us,vp as Ws,vr as Gs,vs as Ks,wS as qs,wc as Js,wd as Ys,wg as Xs,wh as Zs,wp as Qs,ws as $s,wu as ec,ww as tc,x_ as nc,xl as rc,xo as ic,xp as ac,xr as oc,xs as sc,ya as cc,yc as lc,yd as uc,yf as dc,yg as fc,yh as pc,yl as mc,ym as hc,yp as gc,yr as _c,ys as vc,yt as yc,zS as bc,z_ as xc,zg as Sc,zi as Cc,zm as wc,zr as Tc,zu as Ec}from"./loadAgentsDir-C1LkW7gl.js";import{C as Dc,D as Oc,Ft as kc,Gr as Ac,Gt as jc,H as Mc,I as K,Kr as Nc,Kt as Pc,Lt as Fc,P as q,Pn as Ic,Rn as Lc,T as Rc,Tt as zc,Vn as Bc,Wt as Vc,Xn as Hc,Xt as Uc,Y as Wc,Yt as Gc,Z as Kc,Zn as qc,_n as Jc,ai as Yc,bn as Xc,ct as Zc,di as Qc,dr as $c,et as el,fi as tl,hn as nl,ir as rl,j as il,lr as al,lt as ol,ot as sl,p as cl,q as ll,qr as ul,t as J,tr as dl,vn as fl,x as pl,y as ml,yn as hl,yt as gl}from"./src-DL3w8VPk.js";import{t as _l}from"./jsx-runtime-Bb4Xn-E0.js";import{A as vl,E as yl,G as bl,U as xl,V as Sl,W as Cl,Z as wl,_ as Tl,f as El,g as Dl,l as Ol,o as kl,s as Al,w as jl,x as Ml}from"./types-zk5Ltv5q.js";import{$n as Nl,An as Pl,At as Fl,Bt as Il,Cn as Ll,Ct as Rl,E as zl,Et as Bl,It as Vl,Jn as Hl,Jt as Ul,K as Wl,L as Gl,Pt as Kl,Qn as ql,R as Jl,St as Yl,Tt as Xl,V as Zl,Xn as Ql,Xt as $l,Yn as eu,Yt as tu,Z as nu,Zt as ru,_t as iu,b as au,ct as ou,in as su,kn as cu,tt as lu,un as uu,ut as du,wt as fu,xt as pu,zt as mu}from"./state-BowF111d.js";import{n as hu,t as gu}from"./cwd-BcO6WHKo.js";import{C as _u,E as vu,H as yu,L as bu,N as xu,S as Su,U as Cu,X as wu,c as Y,et as Tu,f as Eu,g as Du,i as Ou,tt as ku,u as Au,x as ju,z as Mu}from"./debug-8DCufdSp.js";import{An as Nu,At as Pu,Dn as Fu,Fn as Iu,Fr as Lu,Gn as Ru,Gt as zu,Ht as Bu,Ir as Vu,It as Hu,Jn as Uu,Lt as Wu,Mt as Gu,R as Ku,Rr as qu,Rt as Ju,Un as Yu,Ur as Xu,V as Zu,Vt as Qu,Wn as $u,Wt as ed,Yn as td,_t as nd,b as rd,cr as id,d as ad,fn as od,h as sd,hn as cd,jt as ld,ni as ud,or as dd,qn as fd,qt as pd,s as md,sr as hd,st as gd,t as _d,ti as vd}from"./settings-DKN4xSpQ.js";import{c as yd,j as bd,m as xd,n as Sd,v as Cd}from"./config-BddEvZZl.js";import{i as wd,t as Td}from"./execFileNoThrow-BsfuytkN.js";import{B as Ed,F as Dd,H as Od,L as kd,R as Ad,j as jd,o as Md,q as Nd,s as Pd}from"./log-DaILwWJa.js";import{_ as Fd,a as Id,d as Ld,h as Rd,l as zd,m as Bd,o as Vd,r as Hd,s as Ud,v as Wd}from"./stringUtils-BQm3OfeJ.js";import{i as Gd,o as Kd}from"./platform-Dzff1WWw.js";import{n as qd,r as X}from"./analytics-DJobLaWP.js";import{n as Jd,o as Yd,s as Xd,t as Zd}from"./intl-D2kgJmX7.js";import{S as Qd,_ as $d,d as ef,g as tf,l as nf,u as rf}from"./startupProfiler-DTs9w9EN.js";import{Bn as af,Cn as of,Cr as sf,En as cf,G as lf,J as uf,K as df,S as ff,Sr as pf,St as mf,Tn as hf,Tt as gf,U as _f,Vn as vf,W as yf,X as bf,Y as xf,Z as Sf,b as Cf,cr as wf,ct as Tf,dn as Ef,dt as Df,f as Of,g as kf,gn as Af,h as jf,l as Mf,lt as Nf,mt as Pf,or as Ff,q as If,s as Lf,tt as Rf,u as zf,un as Bf,wt as Vf,yt as Hf,z as Uf}from"./model-BwBE0Pt5.js";import{Rt as Wf,St as Gf,fn as Kf,in as qf,ln as Jf,pn as Yf,rn as Xf,tn as Zf,tt as Qf,un as $f,xt as ep,zt as tp}from"./prompt-BGqgPgCU.js";import{i as np,r as rp}from"./projectOnboardingState-CJycxw5P.js";import{a as ip}from"./ripgrep-BuzOTf1S.js";import{a as ap}from"./loader-C61fB6vU.js";import{n as op,r as sp}from"./switcher-Bq1Ct_Sn.js";import{i as cp,n as lp,r as up}from"./parser-D8slvrJP.js";import{T as dp,c as fp,r as pp,w as mp}from"./sessionTracing-yBre24PH.js";import{n as hp,t as gp}from"./poorMode-J5SYJvoY.js";import{f as _p,m as vp,n as yp}from"./firstPartyEventLogger-C0q45h_4.js";import{r as bp}from"./policyLimits-a7ix6GnU.js";import{E as xp,T as Sp,g as Cp,m as wp}from"./pidLock-D9do1Afy.js";import{n as Tp,t as Ep}from"./nativeInstaller-DnSNJWIi.js";import{C as Dp,D as Op,E as kp,O as Ap,S as jp,T as Mp,a as Np,c as Pp,d as Fp,f as Ip,i as Lp,l as Rp,m as zp,n as Bp,o as Vp,p as Hp,r as Up,s as Wp,t as Gp,w as Kp,x as qp}from"./TextInput-7uqPhq9T.js";import{n as Jp,t as Yp}from"./notifications-B0DTaYoy.js";import{i as Xp,n as Zp}from"./terminalSetup-Cf_r6pwK.js";import{a as Qp,c as $p,i as em,l as tm,n as nm,o as rm,r as im,s as am,t as om,u as sm}from"./history-CNQNd6hT.js";import{t as cm}from"./useDoublePress-C9xxQzh1.js";import{i as lm,n as um,r as dm,t as fm}from"./overlayContext-CMV7nYR9.js";import{t as pm}from"./SelectMulti-CNE06VAN.js";import{t as mm}from"./KeybindingProviderSetup-Bn1jzN5F.js";import{t as hm}from"./useManagePlugins-CYXVcql2.js";import{n as gm,t as _m}from"./MCPConnectionManager-ChN4Ayjk.js";import{n as vm,t as ym}from"./toolPool-CnrZcprA.js";import{t as bm}from"./conversationRecovery-Da_8uldZ.js";import{a as xm,i as Sm,o as Cm,r as wm,t as Tm}from"./MessageSelector-CdDlJE48.js";import{n as Em,t as Dm}from"./useExitOnCtrlCDWithKeybindings-CjW3gUOt.js";import{n as Om,t as km}from"./select-C_KXmqbI.js";import{a as Am,c as jm,d as Mm,f as Nm,i as Pm,l as Fm,n as Im,o as Lm,r as Rm,s as zm,u as Bm}from"./Spinner-DwsJJUtn.js";import{l as Vm,u as Hm}from"./SpinnerGlyph-A6G-gloN.js";import{n as Um,r as Wm}from"./sessionTitle-k4wpUS5l.js";import{n as Gm,t as Km}from"./sideQuestion-CMB8hfgX.js";import{a as qm,n as Jm,o as Ym,r as Xm,s as Zm,t as Qm}from"./skillChangeDetector-CBKuGuEi.js";import{n as $m,t as eh}from"./reconciler-DSKLuOS7.js";import{n as th,t as nh}from"./refresh-BbZFCNpn.js";import{i as rh,n as ih,r as ah,t as oh}from"./directoryCompletion-CT6YVeg7.js";import{r as sh,t as ch}from"./PromptInputFooterSuggestions-lkr_A5jQ.js";import{n as lh,t as uh}from"./useMergedTools-DarmnCEw.js";import{a as dh,i as fh,n as ph,o as mh,r as hh,t as gh}from"./promptEditor-CmQ9p4oe.js";import{n as _h,t as vh}from"./useMainLoopModel-DWscpA9I.js";import{a as yh,i as bh,o as xh,r as Sh,s as Ch,t as wh}from"./fileSuggestions-B-SLfb-o.js";import{t as Th}from"./CustomSelect-B46Eh0gU.js";import{i as Eh,n as Dh,r as Oh,t as kh}from"./extraUsage-DYm33Occ.js";import{n as Ah,t as jh}from"./useSearchInput-C2JuUW3g.js";import{n as Mh,t as Nh}from"./staticRender-BVWx0IM1.js";import{n as Ph,t as Fh}from"./useSettingsErrors-DutJBiKZ.js";import{n as Ih,t as Lh}from"./shadowedRuleDetection-Df-kZ_pK.js";import{n as Rh,t as zh}from"./ExitFlow-BasHk1mk.js";import{a as Bh,i as Vh,r as Hh,t as Uh}from"./fast-DqUpl_Lr.js";import{i as Wh,n as Gh,r as Kh,t as qh}from"./PermissionDialog-BaibiQae.js";import{a as Jh,i as Yh,n as Xh,r as Zh,t as Qh}from"./PromptInputHelpMenu-DaQKKyM5.js";import{n as $h,r as eg}from"./pluginAutoupdate-BJaAqwTH.js";import{n as tg,t as ng}from"./generateSessionName-ChvKBVxB.js";import{a as rg,c as ig,i as ag,l as og,n as sg,o as cg,r as lg,s as ug,t as dg}from"./Messages-DuL_r1Or.js";import{a as fg,i as pg,n as mg,o as hg,r as gg,t as _g}from"./BackgroundTasksDialog-CjBt1L0p.js";import{n as vg}from"./fpsMetrics-wxj9GAsd.js";import{t as yg}from"./earlyInput-IghoCjG5.js";import{a as bg,i as xg,n as Sg,r as Cg,t as wg}from"./tipRegistry-CyRXWWTz.js";import{n as Tg,t as Eg}from"./backgroundHousekeeping-bEZtlJSf.js";import{homedir as Dg,tmpdir as Og}from"os";import*as kg from"path";import{basename as Ag,dirname as jg,extname as Mg,join as Ng,relative as Pg,sep as Fg}from"path";import{dirname as Ig,join as Lg}from"node:path";import{createHash as Rg}from"node:crypto";import{randomUUID as zg}from"crypto";import{readFile as Bg,readdir as Vg,stat as Hg,writeFile as Ug}from"fs/promises";import{spawn as Wg,spawnSync as Gg}from"child_process";import{mkdir as Kg,readFile as qg,rename as Jg,writeFile as Yg}from"node:fs/promises";function Xg(e){return Array.isArray?Array.isArray(e):o_(e)===`[object Array]`}function Zg(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 Qg(e){return e==null?``:Zg(e)}function $g(e){return typeof e==`string`}function e_(e){return typeof e==`number`}function t_(e){return e===!0||e===!1||r_(e)&&o_(e)==`[object Boolean]`}function n_(e){return typeof e==`object`}function r_(e){return n_(e)&&e!==null}function i_(e){return e!=null}function a_(e){return!e.trim().length}function o_(e){return e==null?e===void 0?`[object Undefined]`:`[object Null]`:Object.prototype.toString.call(e)}function s_(e){let t=null,n=null,r=null,i=1,a=null;if($g(e)||Xg(e))r=e,t=c_(e),n=l_(e);else{if(!G_.call(e,`name`))throw Error(H_(`name`));let o=e.name;if(r=o,G_.call(e,`weight`)&&e.weight!==void 0&&(i=e.weight,i<=0))throw Error(U_(l_(o)));t=c_(o),n=l_(o),a=e.getFn??null}return{path:t,id:n,weight:i,src:r,getFn:a}}function c_(e){return Xg(e)?e:e.split(`.`)}function l_(e){return Xg(e)?e.join(`.`):e}function u_(e,t){let n=[],r=!1,i=(e,t,a,o)=>{if(i_(e))if(!t[a])n.push(o===void 0?e:{v:e,i:o});else{let s=e[t[a]];if(!i_(s))return;if(a===t.length-1&&($g(s)||e_(s)||t_(s)||typeof s==`bigint`))n.push(o===void 0?Qg(s):{v:Qg(s),i:o});else if(Xg(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,$g(t)?t.split(`.`):t,0),r?n:n[0]}function d_(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 f_(e,t,{getFn:n=Z.getFn,fieldNormWeight:r=Z.fieldNormWeight}={}){let i=new Z_({getFn:n,fieldNormWeight:r});return i.setKeys(e.map(s_)),i.setSources(t),i.create(),i}function p_(e,{getFn:t=Z.getFn,fieldNormWeight:n=Z.fieldNormWeight}={}){let{keys:r,records:i}=e,a=new Z_({getFn:t,fieldNormWeight:n});return a.setKeys(r),a.setIndexRecords(i),a}function m_(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 h_(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(V_(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=m_(_,s);e.length?c&&(w.indices=e):w.isMatch=!1}return w}function g_(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 __(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 v_(e){return e.startsWith(`inverse`)}function y_(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 b_(e,t){let n=e.match(t);return n?n[1]:null}function x_(e,t={}){return e.replace(/\\\|/g,av).split(ov).map(e=>{let n=y_(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<iv;){let e=rv[o],n=b_(i,e.multiRegex);n&&(r.push(e.create(n,t)),a=!0)}if(!a)for(o=-1;++o<iv;){let e=rv[o],n=b_(i,e.singleRegex);if(n){r.push(e.create(n,t));break}}}return r})}function S_(...e){cv.push(...e)}function C_(e,t){for(let n=0,r=cv.length;n<r;n+=1){let r=cv[n];if(r.condition(e,t))return new r(e,t)}return new tv(e,t)}function w_(e,t,{auto:n=!0}={}){let r=e=>{if($g(e)){let r={keyId:null,pattern:e};return n&&(r.searcher=C_(e,t)),r}let i=Object.keys(e),a=fv(e);if(!a&&i.length>1&&!dv(e))return r(mv(e));if(pv(e)){let r=a?e[uv.PATH]:i[0],o=a?e[uv.PATTERN]:e[r];if(!$g(o))throw Error(B_(r));let s={keyId:l_(r),pattern:o};return n&&(s.searcher=C_(o,t)),s}let o={children:[],operator:i[0]};return i.forEach(t=>{let n=e[t];Xg(n)&&n.forEach(e=>{o.children.push(r(e))})}),o};return dv(e)||(e=mv(e)),r(e)}function T_(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 E_(e,{ignoreFieldNorm:t=Z.ignoreFieldNorm}){e.forEach(e=>{e.score=T_(e.matches,{ignoreFieldNorm:t})})}function D_(e){let t=[];return e.matches.forEach(e=>{if(!i_(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 O_(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=D_(e)),r&&(a.score=e.score),a})}function k_(e){_v.has(e)||(_v.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 A_(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||k_(e),t=>t.match(e)||[]):e=>e.match(gv)||[]}function j_({isCaseSensitive:e=!1,ignoreDiacritics:t=!1,tokenize:n}={}){let r=A_(n);return{tokenize(n){return e||(n=n.toLowerCase()),t&&(n=ev(n)),r(n)}}}function M_(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 N_(e,t,n,r){let{i,v:a,$:o}=t;if(a!==void 0){M_(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)M_(e,t.v,i,r);else M_(e,n.v,i,r)}}function P_(e,t,n){let r={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(let i of e)N_(r,i,t,n);return r}function F_(e,t,n,r){N_(e,t,n,r)}function I_(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 L_(e,t){if(t.length===0)return;let n=Array.from(new Set(t)).sort((e,t)=>e-t);for(let t of n)I_(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 R_,z_,B_,V_,H_,U_,W_,G_,K_,q_,J_,Y_,X_,Z,Z_,Q_,$_,ev,tv,nv,rv,iv,av,ov,sv,cv,lv,uv,dv,fv,pv,mv,hv,gv,_v,vv,yv,bv,xv=t((()=>{R_=`Incorrect 'index' type`,z_=`Invalid doc index: must be a non-negative integer within the bounds of the docs array`,B_=e=>`Invalid value for key ${e}`,V_=e=>`Pattern length exceeds max of ${e}.`,H_=e=>`Missing ${e} property in key`,U_=e=>`Property 'weight' in key '${e}' must be a positive integer`,W_=`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.`,G_=Object.prototype.hasOwnProperty,K_=class{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach(e=>{let n=s_(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)}},q_={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},J_={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},Y_={location:0,threshold:.6,distance:100},X_={useExtendedSearch:!1,useTokenSearch:!1,tokenize:void 0,tokenMatch:`any`,getFn:u_,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1},Z=Object.freeze({...J_,...q_,...Y_,...X_}),Z_=class{constructor({getFn:e=Z.getFn,fieldNormWeight:t=Z.fieldNormWeight}={}){this.norm=d_(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($g(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(z_);if($g(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(z_);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!i_(e)||a_(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(i_(i)){if(Xg(i)){let e=[];for(let t=0,n=i.length;t<n;t+=1){let n=i[t];if(i_(n)){if($g(n)){if(!a_(n)){let r={v:n,i:t,n:this.norm.get(n)};e.push(r)}}else if(i_(n.v)){let t=$g(n.v)?n.v:Qg(n.v);if(!a_(t)){let r={v:t,i:n.i,n:this.norm.get(t)};e.push(r)}}}}n.$[t]=e}else if($g(i)&&!a_(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}}},Q_={ł:`l`,Ł:`L`,đ:`d`,Đ:`D`,ø:`o`,Ø:`O`,ħ:`h`,Ħ:`H`,ŧ:`t`,Ŧ:`T`,ı:`i`,ß:`ss`},$_=RegExp(`[`+Object.keys(Q_).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($_,e=>Q_[e]):e=>e,tv=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:g_(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}=h_(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)),p}},nv=new Set([`fuzzy`,`include`]),rv=[{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 tv(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)}}}}],iv=rv.length,av=`\0`,ov=`|`,sv=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=x_(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,v_(r.type)&&(c=!0),n&&(nv.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=__(o)),e}}return{isMatch:!1,score:1}}},cv=[],lv={AND:`$and`,OR:`$or`},uv={PATH:`$path`,PATTERN:`$val`},dv=e=>!!(e[lv.AND]||e[lv.OR]),fv=e=>!!e[uv.PATH],pv=e=>!Xg(e)&&n_(e)&&!dv(e),mv=e=>({[lv.AND]:Object.keys(e).map(t=>({[t]:e[t]}))}),hv=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)}},gv=/[\p{L}\p{M}\p{N}_]+/gu,_v=new WeakSet,vv=class{static condition(e,t){return t.useTokenSearch}constructor(e,t){this.options=t,this.analyzer=j_({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 tv(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=__(t)),this.combineAll&&(this.useMask?c.matchedMask=a:c.matchedTerms=o,c.termCount=this.numTerms),c}},yv=class{constructor(e,t,n){this.options={...Z,...t},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new K_(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=C_(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 Z_))throw Error(R_);if(this._myIndex=t||f_(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){let e=j_({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=P_(this._myIndex.records,this._myIndex.keys.length,e)}this._invalidateSearcherCache()}add(e){if(!i_(e))return;this._docs.push(e);let t=this._myIndex.add(e,this._docs.length-1);if(this._invertedIndex&&t){let e=j_({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});F_(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&&L_(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(z_);this._invertedIndex&&L_(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($g(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&&$g(e),l;if(c){let t=new hv(n);$g(this._docs[0])?this._searchStringList(e,{heap:t,ignoreFieldNorm:s}):this._searchObjectList(e,{heap:t,ignoreFieldNorm:s}),l=t.extractSorted(o)}else l=$g(e)?$g(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e),E_(l,{ignoreFieldNorm:s}),a&&l.sort(o),e_(n)&&n>-1&&(l=l.slice(0,n));return O_(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(!i_(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=T_(r.matches,{ignoreFieldNorm:n}),t.shouldInsert(r.score)&&t.insert(r)):o.push(r)}}}),o}_searchLogical(e){let t=w_(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===lv.AND)return[]}return o},r=this._myIndex.records,i=new Map,a=[];return r.forEach(({$:e,i:r})=>{if(i_(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(!i_(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=T_(r.matches,{ignoreFieldNorm:n}),t.shouldInsert(r.score)&&t.insert(r)):s.push(r)}}),s}_findMatches({key:e,value:t,searcher:n}){if(!i_(t))return[];let r=[];if(Xg(t))t.forEach(({v:t,i,n:a})=>{if(!i_(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}},yv.version=`7.4.2`,yv.createIndex=f_,yv.parseIndex=p_,yv.config=Z,yv.match=function(e,t,n){if(n&&n.useTokenSearch)throw Error(W_);return C_(e,{...Z,...n}).searchIn(t)},yv.parseQuery=w_,S_(sv),S_(vv),yv.use=function(...e){e.forEach(e=>S_(e))},bv=yv}));s();var Sv=d();fl(),l(),J(),Nl(),mu(),Uu(),Yd(),Ar(),qr(),Fp(),jh();var Q=n(Yc(),1);Nc(),sg(),ht(),jn(),V(),Nh();var $=_l();function Cv({children:e}){let{bindings:t}=cr(),n=(0,Q.useRef)(null),r=(0,Q.useRef)(new Map),i=(0,Q.useRef)(new Set).current;return(0,$.jsx)(Pc,{bindings:t,pendingChordRef:n,pendingChord:null,setPendingChord:()=>{},activeContexts:i,registerActiveContext:()=>{},unregisterActiveContext:()=>{},handlerRegistryRef:r,children:e})}function wv(e){if(!(`message`in e))return 1;let t=e.message.content;return Array.isArray(t)?t.length:1}async function Tv(e,t,n,{columns:r,verbose:i=!1,chunkSize:a=40,onProgress:o}={}){let s=n=>Mh((0,$.jsx)(Wn,{children:(0,$.jsx)(Cv,{children:(0,$.jsx)(dg,{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+=wv(t);for(let e=0;e<c;e+=a){let t=await s([e,e+a]);if(ul(t).trim()===``)break;await n(t),o?.(e+a)}}async function Ev(e,t=[],n){let r=[];return await Tv(e,t,e=>void r.push(ul(e)),{columns:n}),r.join(``)}o(),tl(),Ml(),hu(),Tu(),Cu(),bu(),ju(),Eu(),Ou(),vd(),Nd(),Md(),wd(),Dl(),Fd(),Xu(),Kd(),id(),qd(),$u(),Nu(),Ol(),$d(),cd(),kl(),Bd(),pd(),Bu(),ld(),nd(),Ku(),Vd(),sd(),bd(),pf(),xd(),Yf(),wf(),vf(),cf(),Af(),mf(),_f(),Of(),qf(),Zf(),Ci(),Sn(),Gn(),Pa(),ip(),Or(),f(),Si(),Cs(),Ft(),io(),Ea(),ca(),ji(),fi(),As(),Vr(),yr(),fr(),Yn(),wn(),qt(),tp(),ti(),sa(),Yo(),Cn(),T(),ae(),la(),Bo(),js(),ri(),ws(),Ur(),Gf(),Qf(),Nr(),Zn(),sn(),Xs(),fc(),ta(),Ti(),Do(),ar(),At(),Xt(),Zs(),Qn(),wc(),up(),Ha(),Un(),vi(),_o(),ra(),Di(),si(),yn(),Lr(),et(),z(),gc(),Ws(),ze(),Ge(),Ct(),je(),xe(),hi(),Rs(),mo(),mp(),Ms(),Aa(),Eo(),Gi(),xr(),as(),Ts(),An(),we(),ec(),Cr(),st(),rc(),mc(),go(),na(),ke(),oe(),fp(),Ho(),yt(),er(),Ua(),$s(),bi(),yo(),Io(),Ao(),to(),Fn(),Ii(),vr(),G(),xt(),Ra(),Wr(),L(),cn(),_p(),yp(),Bs(),Gs(),Ut(),Ca(),_r(),Jo(),Kn(),tr(),pi(),dh(),Th();function Dv({onDone:e}){return(0,$.jsxs)(ml,{title:`You've spent $5 on the API this session.`,onCancel:e,children:[(0,$.jsxs)(K,{flexDirection:`column`,children:[(0,$.jsx)(q,{children:`Learn more about how to monitor your spending:`}),(0,$.jsx)(Fc,{url:`https://code.workmate.com/docs/en/costs`})]}),(0,$.jsx)(km,{options:[{value:`ok`,label:`Got it, thanks!`}],onChange:e})]})}Om(),J(),Th();function Ov({idleMinutes:e,totalInputTokens:t,onDone:n}){return(0,$.jsxs)(ml,{title:`You've been away ${kv(e)} and this conversation is ${tf(t)} tokens.`,onCancel:()=>n(`dismiss`),children:[(0,$.jsx)(K,{flexDirection:`column`,children:(0,$.jsx)(q,{children:`If this is a new task, clearing context will save usage and be faster.`})}),(0,$.jsx)(km,{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 kv(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`}Yp();async function Av(e,t){let n=yd().preferredNotifChannel;await re(e),X(`tengu_notification_method_used`,{configured_channel:n,method_used:await Mv(n,e,t),term:ed.terminal})}var jv=`Work Mate`;async function Mv(e,t,n){let r=t.title||jv;try{switch(e){case`auto`:return Nv(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:Pv()}),`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 Nv(e,t){let n=e.title||jv;switch(ed.terminal){case`Apple_Terminal`:return await Fv()?(t.notifyBell(),`terminal_bell`):`no_method_available`;case`iTerm.app`:return t.notifyITerm2(e),`iterm2`;case`kitty`:return t.notifyKitty({...e,title:n,id:Pv()}),`kitty`;case`ghostty`:return t.notifyGhostty({...e,title:n}),`ghostty`;default:return`no_method_available`}}function Pv(){return Math.floor(Math.random()*1e4)}async function Fv(){try{if(ed.terminal!==`Apple_Terminal`)return!1;let e=(await Td(`osascript`,[`-e`,`tell application "Terminal" to name of current settings of front window`])).stdout.trim();if(!e)return!1;let t=await Td(`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 Pd(e),!1}}var Iv=300,Lv=240*1e3,Rv=null,zv=null,Bv=0,Vv=!1;function Hv(){Bv++,Bv===1&&(qv(),Gv())}function Uv(){Bv>0&&Bv--,Bv===0&&(Kv(),Jv())}function Wv(){Bv=0,Kv(),Jv()}function Gv(){process.platform===`darwin`&&zv===null&&(zv=setInterval(()=>{Bv>0&&(Y(`Restarting caffeinate to maintain sleep prevention`),Jv(),qv())},Lv),zv.unref())}function Kv(){zv!==null&&(clearInterval(zv),zv=null)}function qv(){if(process.platform===`darwin`&&Rv===null){Vv||(Vv=!0,ku(async()=>{Wv()}));try{Rv=Wg(`caffeinate`,[`-i`,`-t`,String(Iv)],{stdio:`ignore`}),Rv.unref();let e=Rv;Rv.on(`error`,t=>{Y(`caffeinate spawn error: ${t.message}`),Rv===e&&(Rv=null)}),Rv.on(`exit`,()=>{Rv===e&&(Rv=null)}),Y(`Started caffeinate to prevent sleep`)}catch{Rv=null}}}function Jv(){if(Rv!==null){let e=Rv;Rv=null;try{e.kill(`SIGKILL`),Y(`Stopped caffeinate, allowing sleep`)}catch{}}}var Yv=class{constructor(){c(this,`_status`,`idle`),c(this,`_generation`,0),c(this,`_changed`,ql()),c(this,`subscribe`,this._changed.subscribe),c(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 Xv(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(vt(f,{},p,e).then(e=>{m===a.current&&e&&!l&&(r.current=e)}),l||c||u){let t=qe(f,e).findLast(_c);t&&(r.current=t.uuid)}n.current=e.length,i.current=o},[e,t])}Dm(),Nm(),Bm(),Lm(),Rm(),wm(),qd();var Zv=Al(()=>bl({method:Sl(`log_event`),params:bl({eventName:wl(),eventData:bl({}).passthrough()})}));function Qv(e){(0,Q.useEffect)(()=>{if(!e.length)return;let t=nn(e);t&&t.client.setNotificationHandler(Zv(),e=>{let{eventName:t,eventData:n}=e.params;X(`tengu_ide_${t}`,n)})},[e])}J();var $v=6e3;function ey(){return Date.now()-Zl()}function ty(e){return ey()<e}function ny(e){return!ty(e)}function ry(e,t){let n=Ic();(0,Q.useEffect)(()=>{Ql(!0)},[]),(0,Q.useEffect)(()=>{let r=!1,i=setInterval(()=>{ny(6e3)&&!r&&(r=!0,clearInterval(i),Av({message:e,notificationType:t},n))},$v);return()=>clearInterval(i)},[e,t,n])}rp(),rt(),E(),Wa(),kt(),Xa(),be(),Ap(),Mp(),Dp(),Xp(),am(),cm(),Wp(),Lp(),Bp(),hh(),Wh(),J(),zt();var iy={topLeft:`┌`,topRight:`┐`,bottomLeft:`└`,bottomRight:`┘`,horizontal:`─`,vertical:`│`,teeLeft:`├`,teeRight:`┤`};function ay(e){return Qs().syntaxHighlightingDisabled?(0,$.jsx)(sy,{...e,highlight:null}):(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(sy,{...e,highlight:null}),children:(0,$.jsx)(oy,{...e})})}function oy(e){let t=(0,Q.use)(ma());return(0,$.jsx)(sy,{...e,highlight:t})}function sy({content:e,maxLines:t,minHeight:n,minWidth:r=40,maxWidth:i,highlight:a}){let{columns:o}=sl(),[s]=Mc(),c=i??o-4,l=t??20,u=(0,Q.useMemo)(()=>To(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=>Ac(e))),g=Math.min(h+4,c),_=g-4,v=`${iy.topLeft}${iy.horizontal.repeat(g-2)}${iy.topRight}`,y=`${iy.bottomLeft}${iy.horizontal.repeat(g-2)}${iy.bottomRight}`,b=d?(()=>{let e=u.length-l,t=`${iy.horizontal.repeat(3)} \u2702 ${iy.horizontal.repeat(3)} ${e} lines hidden `,n=Ac(t),r=Math.max(0,g-2-n);return`${iy.teeLeft}${t}${iy.horizontal.repeat(r)}${iy.teeRight}`})():null;return(0,$.jsxs)(K,{flexDirection:`column`,children:[(0,$.jsx)(q,{dimColor:!0,children:v}),m.map((e,t)=>{let n=Ac(e)>_?rn(e,0,_):e,r=` `.repeat(Math.max(0,_-Ac(n)));return(0,$.jsxs)(K,{flexDirection:`row`,children:[(0,$.jsxs)(q,{dimColor:!0,children:[iy.vertical,` `]}),(0,$.jsx)(kc,{children:n}),(0,$.jsxs)(q,{dimColor:!0,children:[r,` `,iy.vertical]})]},t)}),b&&(0,$.jsx)(q,{color:`warning`,children:b}),(0,$.jsx)(q,{dimColor:!0,children:y})]})}Ar(),J(),$d();function cy({questions:e,currentQuestionIndex:t,answers:n,hideSubmitTab:r=!1}){let{columns:i}=sl(),a=(0,Q.useMemo)(()=>{let n=r?``:` ${u.tick} Submit `,a=Ac(`← `)+Ac(` →`)+Ac(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+Ac(e)).reduce((e,t)=>e+t,0)<=o)return s;let c=4+Ac(s[t]||``),l=Math.min(c,o/2),d=o-l,f=e.length-1,p=Math.max(6,Math.floor(d/Math.max(f,1)));return s.map((e,n)=>n===t?Qd(e,l-2-2):Qd(e,p-2-2))},[e,t,i,r]),o=e.length===1&&r;return(0,$.jsxs)(K,{flexDirection:`row`,marginBottom:1,children:[!o&&(0,$.jsx)(q,{color:t===0?`inactive`:void 0,children:`← `}),e.map((e,r)=>{let i=r===t,o=e?.question&&n[e.question]?u.checkboxOn:u.checkboxOff,s=a[r]||e?.header||`Q${r+1}`;return(0,$.jsx)(K,{children:i?(0,$.jsxs)(q,{backgroundColor:`permission`,color:`inverseText`,children:[` `,o,` `,s,` `]}):(0,$.jsxs)(q,{children:[` `,o,` `,s,` `]})},e?.question||`question-${r}`)}),!r&&(0,$.jsx)(K,{children:t===e.length?(0,$.jsxs)(q,{backgroundColor:`permission`,color:`inverseText`,children:[` `,u.tick,` Submit`,` `]}):(0,$.jsxs)(q,{children:[` `,u.tick,` Submit `]})},`submit`),!o&&(0,$.jsx)(q,{color:t===e.length?`inactive`:void 0,children:` →`})]})}l(),Ar(),J(),V(),Cn();function ly({question:e,questions:t,currentQuestionIndex:n,answers:r,questionStates:i,hideSubmitTab:a=!1,minContentHeight:o,minContentWidth:s,onUpdateQuestionState:c,onAnswer:l,onTextInputFocus:d,onCancel:f,onTabPrev:p,onTabNext:m,onRespondToClaude:h,onFinishPlanInterview:g}){let _=U(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?Jn(E):null,O=e.question,k=i[O],A=e.options,[j,M]=(0,Q.useState)(0),N=(0,Q.useRef)(O);if(N.current!==O){N.current=O;let e=k?.selectedValue,t=e?A.findIndex(t=>t.label===e):-1;M(t>=0?t:0)}let ee=A[j],te=k?.selectedValue,P=k?.textInputValue||``,F=(0,Q.useCallback)(e=>{let t=A[e];t&&(M(e),c(O,{selectedValue:t.label},!1),l(O,t.label))},[A,O,c,l]),I=(0,Q.useCallback)(e=>{if(S)return;let t;t=typeof e==`number`?e:e===`up`?j>0?j-1:j:j<A.length-1?j+1:j,t>=0&&t<A.length&&M(t)},[j,A.length,S]);Vc(`chat:externalEditor`,async()=>{let e=k?.textInputValue||``,t=await ph(e);t.content!==null&&t.content!==e&&c(O,{textInputValue:t.content},!1)},{context:`Chat`,isActive:S&&!!E}),jc({"tabs:previous":()=>p?.(),"tabs:next":()=>m?.()},{context:`Tabs`,isActive:!S&&!v});let L=(0,Q.useCallback)(()=>{C(!1),d(!1),te&&l(O,te)},[te,O,l,d]),ne=(0,Q.useCallback)(()=>{y(!0)},[]),re=(0,Q.useCallback)(()=>{y(!1)},[]),ie=(0,Q.useCallback)(e=>{if(v){if(e.key===`up`||e.ctrl&&e.key===`p`){e.preventDefault(),b===0?re():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(),L());return}if(e.key===`up`||e.ctrl&&e.key===`p`)e.preventDefault(),j>0&&I(`up`);else if(e.key===`down`||e.ctrl&&e.key===`n`)e.preventDefault(),j===A.length-1?ne():I(`down`);else if(e.key===`return`)e.preventDefault(),F(j);else if(e.key===`n`&&!e.ctrl&&!e.meta)e.preventDefault(),C(!0),d(!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&&I(t)}},[v,b,_,S,j,A.length,re,ne,I,F,L,h,g,f,d]),ae=ee?.preview||null,{columns:oe}=sl(),se=oe-30-4,ce=(0,Q.useMemo)(()=>o?Math.max(1,o-11):void 0,[o]);return(0,$.jsxs)(K,{flexDirection:`column`,marginTop:1,tabIndex:0,autoFocus:!0,onKeyDown:ie,children:[(0,$.jsx)(Dc,{color:`inactive`}),(0,$.jsxs)(K,{flexDirection:`column`,paddingTop:0,children:[(0,$.jsx)(cy,{questions:t,currentQuestionIndex:n,answers:r,hideSubmitTab:a}),(0,$.jsx)(Kh,{title:e.question,color:`text`}),(0,$.jsxs)(K,{flexDirection:`column`,minHeight:o,children:[(0,$.jsxs)(K,{marginTop:1,flexDirection:`row`,gap:4,children:[(0,$.jsx)(K,{flexDirection:`column`,width:30,children:A.map((e,t)=>{let n=j===t,r=te===e.label;return(0,$.jsxs)(K,{flexDirection:`row`,children:[n?(0,$.jsx)(q,{color:`suggestion`,children:u.pointer}):(0,$.jsx)(q,{children:` `}),(0,$.jsxs)(q,{dimColor:!0,children:[` `,t+1,`.`]}),(0,$.jsxs)(q,{color:r?`success`:n?`suggestion`:void 0,bold:n,children:[` `,e.label]}),r&&(0,$.jsxs)(q,{color:`success`,children:[` `,u.tick]})]},e.label)})}),(0,$.jsxs)(K,{flexDirection:`column`,flexGrow:1,children:[(0,$.jsx)(ay,{content:ae||`No preview available`,maxLines:ce,minWidth:s,maxWidth:se}),(0,$.jsxs)(K,{marginTop:1,flexDirection:`row`,gap:1,children:[(0,$.jsx)(q,{color:`suggestion`,children:`Notes:`}),S?(0,$.jsx)(Gp,{value:P,placeholder:`Add notes on this design…`,onChange:e=>{c(O,{textInputValue:e},!1)},onSubmit:L,onExit:L,focus:!0,showCursor:!0,columns:60,cursorOffset:w,onChangeCursorOffset:T}):(0,$.jsx)(q,{dimColor:!0,italic:!0,children:P||`press n to add notes`})]})]})]}),(0,$.jsxs)(K,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(Dc,{color:`inactive`}),(0,$.jsxs)(K,{flexDirection:`row`,gap:1,children:[v&&b===0?(0,$.jsx)(q,{color:`suggestion`,children:u.pointer}):(0,$.jsx)(q,{children:` `}),(0,$.jsx)(q,{color:v&&b===0?`suggestion`:void 0,children:`Chat about this`})]}),_&&(0,$.jsxs)(K,{flexDirection:`row`,gap:1,children:[v&&b===1?(0,$.jsx)(q,{color:`suggestion`,children:u.pointer}):(0,$.jsx)(q,{children:` `}),(0,$.jsx)(q,{color:v&&b===1?`suggestion`:void 0,children:`Skip interview and plan immediately`})]})]}),(0,$.jsx)(K,{marginTop:1,children:(0,$.jsxs)(q,{color:`inactive`,dimColor:!0,children:[`Enter to select · `,u.arrowUp,`/`,u.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`]})})]})]})]})}l(),J(),V(),dh(),Cn(),hh(),Th(),Wh();function uy({question:e,questions:t,currentQuestionIndex:n,answers:r,questionStates:i,hideSubmitTab:a=!1,planFilePath:o,minContentHeight:s,minContentWidth:c,onUpdateQuestionState:l,onAnswer:d,onTextInputFocus:f,onCancel:p,onSubmit:m,onTabPrev:h,onTabNext:g,onRespondToClaude:_,onFinishPlanInterview:v,onImagePaste:y,pastedContents:b,onRemoveImage:x}){let S=U(e=>e.toolPermissionContext.mode)===`plan`,[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(0),[D,O]=(0,Q.useState)(!1),k=fh(),A=k?Jn(k):null,j=(0,Q.useCallback)(e=>{let t=e===`__other__`;O(t),f(t)},[f]),M=(0,Q.useCallback)(()=>{w(!0)},[]),N=(0,Q.useCallback)(()=>{w(!1)},[]),ee=(0,Q.useCallback)(e=>{if(C){if(e.key===`up`||e.ctrl&&e.key===`p`){e.preventDefault(),T===0?N():E(0);return}if(e.key===`down`||e.ctrl&&e.key===`n`){e.preventDefault(),S&&T===0&&E(1);return}if(e.key===`return`){e.preventDefault(),T===0?_():v();return}e.key===`escape`&&(e.preventDefault(),p())}},[C,T,S,N,_,v,p]),te=e.options.map(e=>({type:`text`,value:e.label,label:e.label,description:e.description})),P=e.question,F=i[P],I=(0,Q.useCallback)(async(t,n)=>{let r=await ph(t);r.content!==null&&r.content!==t&&(n(r.content),l(P,{textInputValue:r.content},e.multiSelect??!1))},[P,l,e.multiSelect]),L={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)}},ne=[...te,L];return!e.multiSelect&&e.options.some(e=>e.preview)?(0,$.jsx)(ly,{question:e,questions:t,currentQuestionIndex:n,answers:r,questionStates:i,hideSubmitTab:a,minContentHeight:s,minContentWidth:c,onUpdateQuestionState:l,onAnswer:d,onTextInputFocus:f,onCancel:p,onTabPrev:h,onTabNext:g,onRespondToClaude:_,onFinishPlanInterview:v}):(0,$.jsxs)(K,{flexDirection:`column`,marginTop:0,tabIndex:0,autoFocus:!0,onKeyDown:ee,children:[S&&o&&(0,$.jsxs)(K,{flexDirection:`column`,gap:0,children:[(0,$.jsx)(Dc,{color:`inactive`}),(0,$.jsxs)(q,{color:`inactive`,children:[`Planning: `,(0,$.jsx)(Ya,{filePath:o})]})]}),(0,$.jsx)(K,{marginTop:-1,children:(0,$.jsx)(Dc,{color:`inactive`})}),(0,$.jsxs)(K,{flexDirection:`column`,paddingTop:0,children:[(0,$.jsx)(cy,{questions:t,currentQuestionIndex:n,answers:r,hideSubmitTab:a}),(0,$.jsx)(Kh,{title:e.question,color:`text`}),(0,$.jsxs)(K,{flexDirection:`column`,minHeight:s,children:[(0,$.jsx)(K,{marginTop:1,children:e.multiSelect?(0,$.jsx)(pm,{options:ne,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]:[]);d(P,n,void 0,!1)},onFocus:j,onCancel:p,submitButtonText:n===t.length-1?`Submit`:`Next`,onSubmit:m,onDownFromLastItem:M,isDisabled:C,onOpenEditor:I,onImagePaste:y,pastedContents:b,onRemoveImage:x},e.question):(0,$.jsx)(km,{options:ne,defaultValue:i[e.question]?.selectedValue,onChange:e=>{l(P,{selectedValue:e},!1);let t=e===`__other__`?i[P]?.textInputValue:void 0;d(P,e,t)},onFocus:j,onCancel:p,onDownFromLastItem:M,isDisabled:C,layout:`compact-vertical`,onOpenEditor:I,onImagePaste:y,pastedContents:b,onRemoveImage:x},e.question)}),(0,$.jsxs)(K,{flexDirection:`column`,children:[(0,$.jsx)(Dc,{color:`inactive`}),(0,$.jsxs)(K,{flexDirection:`row`,gap:1,children:[C&&T===0?(0,$.jsx)(q,{color:`suggestion`,children:u.pointer}):(0,$.jsx)(q,{children:` `}),(0,$.jsxs)(q,{color:C&&T===0?`suggestion`:void 0,children:[ne.length+1,`. Chat about this`]})]}),S&&(0,$.jsxs)(K,{flexDirection:`row`,gap:1,children:[C&&T===1?(0,$.jsx)(q,{color:`suggestion`,children:u.pointer}):(0,$.jsx)(q,{children:` `}),(0,$.jsxs)(q,{color:C&&T===1?`suggestion`:void 0,children:[ne.length+2,`. Skip interview and plan immediately`]})]})]}),(0,$.jsx)(K,{marginTop:1,children:(0,$.jsxs)(q,{color:`inactive`,dimColor:!0,children:[`Enter to select ·`,` `,t.length===1?(0,$.jsxs)($.Fragment,{children:[u.arrowUp,`/`,u.arrowDown,` to navigate`]}):`Tab/Arrow keys to navigate`,D&&A&&(0,$.jsxs)($.Fragment,{children:[` · ctrl+g to edit in `,A]}),` · Esc to cancel`]})})]})]})]})}J(),bo(),V();function dy(e,t){if(!e)return null;switch(e.type){case`rule`:return{reasonString:`Permission rule ${Qc.bold(Zu(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?` ${Qc.dim(`[${e.hookSource}]`)}`:``;return{reasonString:`Hook ${Qc.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 fy({permissionResult:e,toolType:t}){let n=U(e=>e.toolPermissionContext.mode),r=dy(e?.decisionReason,t);if(!r)return null;let i=r.themeColor??(e?.decisionReason?.type===`hook`&&n===`auto`?`warning`:void 0);return(0,$.jsxs)(K,{marginBottom:1,flexDirection:`column`,children:[i?(0,$.jsx)(q,{color:i,children:r.reasonString}):(0,$.jsx)(q,{children:(0,$.jsx)(kc,{children:r.reasonString})}),r.configString&&(0,$.jsx)(q,{dimColor:!0,children:r.configString})]})}l(),J(),Th(),Wh();function py({questions:e,currentQuestionIndex:t,answers:n,allQuestionsAnswered:r,permissionResult:i,minContentHeight:a,onFinalResponse:o}){return(0,$.jsxs)(K,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(Dc,{color:`inactive`}),(0,$.jsxs)(K,{flexDirection:`column`,borderTop:!0,borderColor:`inactive`,paddingTop:0,children:[(0,$.jsx)(cy,{questions:e,currentQuestionIndex:t,answers:n}),(0,$.jsx)(Kh,{title:`Review your answers`,color:`text`}),(0,$.jsxs)(K,{flexDirection:`column`,marginTop:1,minHeight:a,children:[!r&&(0,$.jsx)(K,{marginBottom:1,children:(0,$.jsxs)(q,{color:`warning`,children:[u.warning,` You have not answered all questions`]})}),Object.keys(n).length>0&&(0,$.jsx)(K,{flexDirection:`column`,marginBottom:1,children:e.filter(e=>e?.question&&n[e.question]).map(e=>{let t=n[e?.question];return(0,$.jsxs)(K,{flexDirection:`column`,marginLeft:1,children:[(0,$.jsxs)(q,{children:[u.bullet,` `,e?.question||`Question`]}),(0,$.jsx)(K,{marginLeft:2,children:(0,$.jsxs)(q,{color:`success`,children:[u.arrowRight,` `,t]})})]},e?.question||`answer`)})}),(0,$.jsx)(fy,{permissionResult:i,toolType:`tool`}),(0,$.jsx)(q,{color:`inactive`,children:`Ready to submit your answers?`}),(0,$.jsx)(K,{marginTop:1,children:(0,$.jsx)(km,{options:[{type:`text`,label:`Submit answers`,value:`submit`},{type:`text`,label:`Cancel`,value:`cancel`}],onChange:e=>o(e),onCancel:()=>o(`cancel`)})})]})]})]})}function my(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 hy={currentQuestionIndex:0,answers:{},questionStates:{},isInTextInput:!1};function gy(){let[e,t]=(0,Q.useReducer)(my,hy),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}}z(),Ar(),J(),Yn(),qd(),V(),Ws(),Md(),as();var _y=12,vy=40,yy=15;function by(e){return Qs().syntaxHighlightingDisabled?(0,$.jsx)(Sy,{...e,highlight:null}):(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(Sy,{...e,highlight:null}),children:(0,$.jsx)(xy,{...e})})}function xy(e){let t=(0,Q.use)(ma());return(0,$.jsx)(Sy,{...e,highlight:t})}function Sy({toolUseConfirm:e,onDone:t,onReject:n,highlight:r}){let i=(0,Q.useMemo)(()=>Vs.inputSchema.safeParse(e.input),[e.input]),a=i.success&&i.data.questions||[],{rows:o}=sl(),[s]=Mc(),{globalContentHeight:c,globalContentWidth:l}=(0,Q.useMemo)(()=>{let e=0,t=0,n=Math.max(_y,o-yy);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=To(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,Ac(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,_y),n),globalContentWidth:Math.max(t,vy)}},[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};_e(s),Nt(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`),_=U(e=>e.toolPermissionContext.mode)===`plan`,v=_?ni():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,j=a.length===1&&!a[0]?.multiSelect,M=(0,Q.useCallback)(()=>{u&&X(`tengu_ask_user_question_rejected`,{source:u,questionCount:a.length,isInPlanMode:_,interviewPhaseEnabled:_&&Sa()}),t(),n(),e.onReject()},[t,n,e,u,a.length,_]),N=(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:_&&Sa()});let r=await Cy(g);t(),e.onReject(n,r&&r.length>0?r:void 0)},[a,b,t,e,u,_,g]),ee=(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:_&&Sa()});let r=await Cy(g);t(),e.onReject(n,r&&r.length>0?r:void 0)},[a,b,t,e,u,_,g]),te=(0,Q.useCallback)(async n=>{u&&X(`tengu_ask_user_question_accepted`,{source:u,questionCount:a.length,answerCount:Object.keys(n).length,isInPlanMode:_,interviewPhaseEnabled:_&&Sa()});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 Cy(g);t(),e.onAllow(i,[],void 0,o&&o.length>0?o:void 0)},[e,t,u,a,x,_,g]),P=(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};te(t).catch(Pd);return}E(e,i,r)},[E,a.length,b,te,d]);function F(e){if(e===`cancel`){M();return}e===`submit`&&te(b).catch(Pd)}let I=j?(a?.length||1)-1:a?.length||0,L=(0,Q.useCallback)(()=>{y>0&&w()},[y,w]),ne=(0,Q.useCallback)(()=>{y<I&&C()},[y,I,C]);return jc({"tabs:previous":L,"tabs:next":ne},{context:`Tabs`,isActive:!(S&&!k)}),O?(0,$.jsx)(uy,{question:O,questions:a,currentQuestionIndex:y,answers:b,questionStates:x,hideSubmitTab:j,minContentHeight:c,minContentWidth:l,planFilePath:v,onUpdateQuestionState:T,onAnswer:P,onTextInputFocus:D,onCancel:M,onSubmit:C,onTabPrev:L,onTabNext:ne,onRespondToClaude:N,onFinishPlanInterview:ee,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)(py,{questions:a,currentQuestionIndex:y,answers:b,allQuestionsAnswered:A,permissionResult:e.permissionResult,minContentHeight:c,onFinalResponse:F}):null}async function Cy(e){if(e.length!==0)return Promise.all(e.map(async e=>(await Gt({type:`image`,source:{type:`base64`,media_type:e.mediaType||`image/png`,data:e.content}})).block))}var wy=[`http://`,`https://`,`ftp://`],Ty={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},Ey=e=>Array.isArray(e)?e:[e];function Dy(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 Oy(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(`-`)?!Dy(t,n):!1}function ky(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(r){if(r.startsWith(`-`)){Oy(r,e[n+1],t)&&n++;continue}if(!t?.subcommands?.length||Dy(r,t))return r}}}async function Ay(e,t,n){let r=await jy(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&&Ey(e.args).some(e=>e?.isCommand||e?.isModule)){i.push(c);continue}}if(a&&!o){Oy(c,t[s+1],n)&&s++;continue}break}if(await My(c,t.slice(0,s),n))break;a&&!o&&(o=Dy(c,n)),i.push(c)}return i.join(` `)}async function jy(e,t,n){let r=ky(t,n),i=e.toLowerCase(),a=r?`${i} ${r.toLowerCase()}`:i;if(Ty[a])return Ty[a];if(Ty[i])return Ty[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&&Ey(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=Ey(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=Ey(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&&Ey(n.args).some(e=>e?.isDangerous)?3:2}async function My(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=wy.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&&Ey(e.args).some(e=>e?.isModule))return!1}return!0}var Ny=[{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 Py(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 Fy=Tl(async e=>Ny.find(t=>t.name===e)||await Py(e)||null,e=>e),Iy=/^\d+$/,Ly=/^[A-Za-z_][A-Za-z0-9_]*=/,Ry=new Set([`nice`]),zy=e=>Array.isArray(e)?e:[e];function By(e,t){return t?.subcommands?.length?t.subcommands.some(t=>Array.isArray(t.name)?t.name.includes(e):t.name===e):!1}async function Vy(e,t=0,n=0){if(n>2||t>10)return null;let r=await cp(e);if(!r)return null;if(!r.commandNode)return{commandPrefix:null};let{envVars:i,commandNode:a}=r,[o,...s]=lp(a);if(!o)return{commandPrefix:null};let c=await Fy(o),l=Ry.has(o)||c?.args&&zy(c.args).some(e=>e?.isCommand);l&&s[0]&&By(s[0],c)&&(l=!1);let u=l?await Hy(o,s,t,n):await Ay(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 Hy(e,t,n,r){let i=await Fy(e);if(i?.args){let a=zy(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 Vy(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(`-`)&&!Ly.test(t[e])&&i.push(t[e])}}let a=t.find(e=>!e.startsWith(`-`)&&!Iy.test(e)&&!Ly.test(e));if(!a)return e;let o=await Vy(t.slice(t.indexOf(a)).join(` `),n+1,r+1);return o?.commandPrefix?`${e} ${o.commandPrefix}`:null}async function Uy(e,t){let n=nt(e);if(n.length<=1){let t=await Vy(e);return t?.commandPrefix?[t.commandPrefix]:[]}let r=[];for(let e of n){let n=e.trim();if(t?.(n))continue;let i=await Vy(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(Wy(e));return a}function Wy(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(` `)}Vp(),Pm(),qd();async function Gy(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}})}qd(),V(),pd();function Ky(e,t){let n=N(),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:p(e.tool.name),isMcp:e.tool.isMcp??!1,decisionReasonType:e.permissionResult.decisionReason?.type,sandboxEnabled:pt.isSandboxingEnabled()}),Gy({completion_type:t.completion_type,event:`response`,metadata:{language_name:t.language_name,message_id:e.assistantMessage.message.id,platform:ed.platform}}))},[e,t,n])}tl(),l(),J(),V(),Ku(),Ih(),Or();function qy(e){switch(e.type){case`rule`:return`${Qc.bold(Zu(e.rule.ruleValue))} rule from ${od(e.rule.source)}`;case`mode`:return`${Wu(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`${Qc.bold(e.permissionPromptToolName)} permission prompt tool`;case`hook`:return e.reason?`${Qc.bold(e.hookName)} hook: ${e.reason}`:`${Qc.bold(e.hookName)} hook`;case`asyncAgent`:return e.reason;default:return``}}function Jy({title:e,decisionReason:t}){let[n]=Mc();function r(){switch(t.type){case`subcommandResults`:return(0,$.jsx)(K,{flexDirection:`column`,children:Array.from(t.reasons.entries()).map(([e,t])=>(0,$.jsxs)(K,{flexDirection:`column`,children:[(0,$.jsxs)(q,{children:[t.behavior===`allow`?il(`success`,n)(u.tick):il(`error`,n)(u.cross),` `,e]}),t.decisionReason!==void 0&&t.decisionReason.type!==`subcommandResults`&&(0,$.jsxs)(q,{children:[(0,$.jsxs)(q,{dimColor:!0,children:[` `,`⎿`,` `]}),(0,$.jsx)(kc,{children:qy(t.decisionReason)})]}),t.behavior===`ask`&&(0,$.jsx)(Yy,{suggestions:t.suggestions})]},e))});default:return(0,$.jsx)(q,{children:(0,$.jsx)(kc,{children:qy(t)})})}}return(0,$.jsxs)(K,{flexDirection:`column`,children:[e&&(0,$.jsx)(q,{children:e}),r()]})}function Yy({suggestions:e}){let t=hc(e);return t.length===0?null:(0,$.jsxs)(q,{children:[(0,$.jsxs)(q,{dimColor:!0,children:[` `,`⎿`,` `]}),`Suggested rules: `,(0,$.jsx)(kc,{children:t.map(e=>Qc.bold(Zu(e))).join(`, `)})]})}function Xy(e){return e?e.flatMap(e=>{switch(e.type){case`addDirectories`:return e.directories;default:return[]}}):[]}function Zy(e){if(!e)return;let t=e.findLast(e=>e.type===`setMode`);return t?.type===`setMode`?t.mode:void 0}function Qy({suggestions:e,width:t}){if(!e||e.length===0)return(0,$.jsxs)(K,{flexDirection:`row`,children:[(0,$.jsx)(K,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(q,{dimColor:!0,children:`Suggestions `})}),(0,$.jsx)(q,{children:`None`})]});let n=hc(e),r=Xy(e),i=Zy(e);return n.length===0&&r.length===0&&!i?(0,$.jsxs)(K,{flexDirection:`row`,children:[(0,$.jsx)(K,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(q,{dimColor:!0,children:`Suggestion `})}),(0,$.jsx)(q,{children:`None`})]}):(0,$.jsxs)(K,{flexDirection:`column`,children:[(0,$.jsxs)(K,{flexDirection:`row`,children:[(0,$.jsx)(K,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(q,{dimColor:!0,children:`Suggestions `})}),(0,$.jsx)(q,{children:` `})]}),n.length>0&&(0,$.jsxs)(K,{flexDirection:`row`,children:[(0,$.jsx)(K,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(q,{dimColor:!0,children:` Rules `})}),(0,$.jsx)(K,{flexDirection:`column`,children:n.map((e,t)=>(0,$.jsxs)(q,{children:[u.bullet,` `,Zu(e)]},t))})]}),r.length>0&&(0,$.jsxs)(K,{flexDirection:`row`,children:[(0,$.jsx)(K,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(q,{dimColor:!0,children:` Directories `})}),(0,$.jsx)(K,{flexDirection:`column`,children:r.map((e,t)=>(0,$.jsxs)(q,{children:[u.bullet,` `,e]},t))})]}),i&&(0,$.jsxs)(K,{flexDirection:`row`,children:[(0,$.jsx)(K,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(q,{dimColor:!0,children:` Mode `})}),(0,$.jsx)(q,{children:Wu(i)})]})]})}function $y({permissionResult:e,toolName:t}){let n=U(e=>e.toolPermissionContext),r=e.decisionReason,i=`suggestions`in e?e.suggestions:void 0,a=(0,Q.useMemo)(()=>{let e=pt.isSandboxingEnabled()&&pt.isAutoAllowBashIfSandboxedEnabled(),r=Lh(n,{sandboxAutoAllowEnabled:e}),a=hc(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)(K,{flexDirection:`column`,children:[(0,$.jsxs)(K,{flexDirection:`row`,children:[(0,$.jsx)(K,{justifyContent:`flex-end`,minWidth:10,children:(0,$.jsx)(q,{dimColor:!0,children:`Behavior `})}),(0,$.jsx)(q,{children:e.behavior})]}),e.behavior!==`allow`&&(0,$.jsxs)(K,{flexDirection:`row`,children:[(0,$.jsx)(K,{justifyContent:`flex-end`,minWidth:10,children:(0,$.jsx)(q,{dimColor:!0,children:`Message `})}),(0,$.jsx)(q,{children:e.message})]}),(0,$.jsxs)(K,{flexDirection:`row`,children:[(0,$.jsx)(K,{justifyContent:`flex-end`,minWidth:10,children:(0,$.jsx)(q,{dimColor:!0,children:`Reason `})}),r===void 0?(0,$.jsx)(q,{children:`undefined`}):(0,$.jsx)(Jy,{decisionReason:r})]}),(0,$.jsx)(Qy,{suggestions:i,width:10}),a.length>0&&(0,$.jsxs)(K,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(q,{color:`warning`,children:[u.warning,` Unreachable Rules (`,a.length,`)`]}),a.map((e,t)=>(0,$.jsxs)(K,{flexDirection:`column`,marginLeft:2,children:[(0,$.jsx)(q,{color:`warning`,children:Zu(e.rule.ruleValue)}),(0,$.jsxs)(q,{dimColor:!0,children:[` `,e.reason]}),(0,$.jsxs)(q,{dimColor:!0,children:[` `,`Fix: `,e.fix]})]},t))]})]})}Gh(),Ml(),qd(),f(),xd(),Ou(),kl(),Md(),gp(),fs();var eb={LOW:1,MEDIUM:2,HIGH:3},tb=1,nb=2,rb=3,ib=`Analyze shell commands and explain what they do, why you're running them, and potential risks.`,ab={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`]}},ob=Al(()=>bl({riskLevel:vl([`LOW`,`MEDIUM`,`HIGH`]),explanation:wl(),reasoning:wl(),risk:wl()}));function sb(e){if(typeof e==`string`)return e;try{return _u(e,null,2)}catch{return String(e)}}function cb(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 lb(){return yd().permissionExplainerEnabled!==!1}async function ub({toolName:e,toolInput:t,toolDescription:n,messages:r,signal:i}){if(!lb())return null;let a=Date.now();try{let o=sb(t),s=r?.length?cb(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 xi({model:hp()?zf():Lf(),system:ib,messages:[{role:`user`,content:c}],tools:[ab],tool_choice:{type:`tool`,name:`explain_command`},signal:i,querySource:`permission_explainer`}),u=Date.now()-a;Y(`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`){Y(`Permission explainer: tool input: ${_u(d.input).slice(0,500)}`);let t=ob().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:p(e),risk_level:eb[n.riskLevel],latency_ms:u}),Y(`Permission explainer: ${n.riskLevel} risk for ${e} (${u}ms)`),n}}return X(`tengu_permission_explainer_error`,{tool_name:p(e),error_type:tb,latency_ms:u}),Y(`Permission explainer: no parsed output in response`),null}catch(t){let n=Date.now()-a;return i.aborted?(Y(`Permission explainer: request aborted for ${e}`),null):(Y(`Permission explainer error: ${xu(t)}`),Pd(t),X(`tengu_permission_explainer_error`,{tool_name:p(e),error_type:t instanceof Error&&t.name===`AbortError`?nb:rb,latency_ms:n}),null)}}J(),Yn(),qd();var db=`Loading explanation…`;function fb(){let[e,t]=Am(`responding`,db,!1);return(0,$.jsx)(K,{ref:e,children:(0,$.jsx)(q,{children:db.split(``).map((e,n)=>(0,$.jsx)(Np,{char:e,index:n,glimmerIndex:t,messageColor:`inactive`,shimmerColor:`text`},n))})})}function pb(e){switch(e){case`LOW`:return`success`;case`MEDIUM`:return`warning`;case`HIGH`:return`error`}}function mb(e){switch(e){case`LOW`:return`Low risk`;case`MEDIUM`:return`Med risk`;case`HIGH`:return`High risk`}}function hb(e){return ub({toolName:e.toolName,toolInput:e.toolInput,toolDescription:e.toolDescription,messages:e.messages,signal:new AbortController().signal}).catch(()=>null)}function gb(e){let t=lb(),[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(null);return Vc(`confirm:toggleExplanation`,()=>{n||(X(`tengu_permission_explainer_shortcut_used`,{}),i||a(hb(e))),r(e=>!e)},{context:`Confirmation`,isActive:t}),{visible:n,enabled:t,promise:i}}function _b({promise:e}){let t=(0,Q.use)(e);return t?(0,$.jsxs)(K,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(q,{children:t.explanation}),(0,$.jsx)(K,{marginTop:1,children:(0,$.jsx)(q,{children:t.reasoning})}),(0,$.jsx)(K,{marginTop:1,children:(0,$.jsxs)(q,{children:[(0,$.jsxs)(q,{color:pb(t.riskLevel),children:[mb(t.riskLevel),`:`]}),(0,$.jsxs)(q,{children:[` `,t.risk]})]})})]}):(0,$.jsx)(K,{marginTop:1,children:(0,$.jsx)(q,{dimColor:!0,children:`Explanation unavailable`})})}function vb({visible:e,promise:t}){return!e||!t?null:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(K,{marginTop:1,children:(0,$.jsx)(fb,{})}),children:(0,$.jsx)(_b,{promise:t})})}Ar(),J(),Md(),us(),ki();function yb(e){let[t]=(0,Q.useState)(()=>Sb(e.file_path,e.edits));return(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(xb,{placeholder:!0}),children:(0,$.jsx)(bb,{promise:t,file_path:e.file_path})})}function bb({promise:e,file_path:t}){let{patch:n,firstLine:r,fileContent:i}=(0,Q.use)(e),{columns:a}=sl();return(0,$.jsx)(xb,{children:(0,$.jsx)(ys,{hunks:n,dim:!1,width:a,filePath:t,firstLine:r,fileContent:i})})}function xb({children:e,placeholder:t}){return(0,$.jsx)(K,{flexDirection:`column`,children:(0,$.jsx)(K,{borderColor:`subtle`,borderStyle:`dashed`,flexDirection:`column`,borderLeft:!1,borderRight:!1,children:t?(0,$.jsx)(q,{dimColor:!0,children:`…`}):e})})}async function Sb(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 Cb(e,[r]);try{let t=await Na(e);if(t===null)return Cb(e,n);try{if(!r||r.old_string===``){let r=await li(t);return r===null?Cb(e,n):{patch:is({filePath:e,fileContents:r,edits:n.map(e=>wb(r,e))}),firstLine:Id(r),fileContent:r}}let i=await Fo(t,r.old_string,3);if(i.truncated||i.content===``)return Cb(e,[r]);let a=wb(i.content,r);return{patch:wo(is({filePath:e,fileContents:i.content,edits:[a]}),i.lineOffset-1),firstLine:i.lineOffset===1?Id(i.content):null,fileContent:i.content}}finally{await t.close()}}catch(t){return Pd(t),Cb(e,n)}}function Cb(e,t){return{patch:t.flatMap(t=>is({filePath:e,fileContents:t.old_string,edits:[t]})),firstLine:null,fileContent:void 0}}function wb(e,t){let n=hn(e,t.old_string)||t.old_string;return{...t,old_string:n}}Is(),qd(),ws(),xd(),ri(),bu(),Cn(),Md();function Tb({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)(()=>zg().slice(0,6),[]),l=(0,Q.useMemo)(()=>`✻ [Work Mate] ${Ag(n)} (${c}) ⧉`,[n,c]),u=bt(t.options.mcpClients)&&yd().diffTool===`auto`&&!n.endsWith(`.ipynb`),d=Oe(t.options.mcpClients)??`IDE`;async function f(){if(u)try{X(`tengu_ext_will_show_diff`,{});let{oldContent:o,newContent:s}=await Db(n,r,t,l);if(a.current)return;X(`tengu_ext_diff_accepted`,{});let c=Eb(n,o,s,i);if(c.length===0){X(`tengu_ext_diff_rejected`,{});let i=nn(t.options.mcpClients);i&&await Ob(l,i),e({type:`reject`},{file_path:n,edits:r});return}e({type:`accept-once`},{file_path:n,edits:c})}catch(e){Pd(e),s(!0)}}return(0,Q.useEffect)(()=>(f(),()=>{a.current=!0}),[]),{closeTabInIDE(){let e=nn(t.options.mcpClients);return e?Ob(l,e):Promise.resolve()},showingDiffInIDE:u&&!o,ideName:d,hasError:o}}function Eb(e,t,n,r){let i=r===`single`,a=Oa({filePath:e,oldContent:t,newContent:n,singleHunk:i});return a.length===0?[]:(i&&a.length>1&&Pd(Error(`Unexpected number of hunks: ${a.length}. Expected 1 hunk.`)),_(a))}async function Db(e,t,n,r){let i=!1,a=dd(e),o=``;try{o=Ru(a)}catch(e){if(!Mu(e))throw e}async function s(){if(!i){i=!0;try{await Ob(r,c)}catch(e){Pd(e)}process.off(`beforeExit`,s),n.abortController.signal.removeEventListener(`abort`,s)}}n.abortController.signal.addEventListener(`abort`,s),process.on(`beforeExit`,s);let c=nn(n.options.mcpClients);try{let{updatedFile:e}=Ui({filePath:a,fileContents:o,edits:t});if(c?.type!==`connected`)throw Error(`IDE client not available`);let n=a,i=c.config.ideRunningInWindows===!0;Gd()===`wsl`&&i&&process.env.WSL_DISTRO_NAME&&(n=new mt(process.env.WSL_DISTRO_NAME).toIDEPath(a));let l=await kr(`openDiff`,{old_file_path:n,new_file_path:n,new_file_contents:e,tab_name:r},c),u=Array.isArray(l)?l:[l];if(jb(u))return s(),{oldContent:o,newContent:u[1].text};if(kb(u))return s(),{oldContent:o,newContent:e};if(Ab(u))return s(),{oldContent:o,newContent:o};throw Error(`Not accepted`)}catch(e){throw Pd(e),s(),e}}async function Ob(e,t){try{if(t?.type!==`connected`)throw Error(`IDE client not available`);await kr(`close_tab`,{tab_name:e},t)}catch(e){Pd(e)}}function kb(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 Ab(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 jb(e){return Array.isArray(e)&&e[0]?.type===`text`&&e[0].text===`FILE_SAVED`&&typeof e[1].text==`string`}J(),Cn(),Th();function Mb({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)(pl,{color:`permission`,children:(0,$.jsxs)(K,{flexDirection:`column`,gap:1,children:[(0,$.jsxs)(q,{bold:!0,color:`permission`,children:[`Opened changes in `,i,` ⧉`]}),a&&(0,$.jsx)(q,{color:`warning`,children:Pg(gu(),a).startsWith(`..`)?`This will modify ${a} (outside working directory) via a symlink`:`Symlink target: ${a}`}),Ue()&&(0,$.jsx)(q,{dimColor:!0,children:`Save file to continue…`}),(0,$.jsxs)(K,{flexDirection:`column`,children:[(0,$.jsxs)(q,{children:[`Do you want to make this edit to `,(0,$.jsx)(q,{bold:!0,children:Ag(r)}),`?`]}),(0,$.jsx)(km,{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)(K,{marginTop:1,children:(0,$.jsxs)(q,{dimColor:!0,children:[`Esc to cancel`,(u===`yes`&&!d||u===`no`&&!f)&&` · Tab to amend`]})})]})})}mu(),J(),id();function Nb(e){let t=dd(e),n=dd(`${nu()}/.workmate`),r=Ne(t),i=Ne(n);return r.startsWith(i+Fg.toLowerCase())||r.startsWith(`${i}/`)}function Pb(e){let t=dd(e),n=Ng(Dg(),`.workmate`),r=Ne(t),i=Ne(n);return r.startsWith(i+Fg.toLowerCase())||r.startsWith(`${i}/`)}function Fb({filePath:e,toolPermissionContext:t,operationType:n=`write`,onRejectFeedbackChange:r,onAcceptFeedbackChange:i,yesInputMode:a=!1,noInputMode:o=!1}){let s=[],c=Xo(`chat:cycleMode`,`Chat`,`shift+tab`);a&&i?s.push({type:`input`,label:`Yes`,value:`yes`,placeholder:`and tell Work Mate what to do next`,onChange:i,allowEmptySubmitToCancel:!0,option:{type:`accept-once`}}):s.push({label:`Yes`,value:`yes`,option:{type:`accept-once`}});let l=$e(e,t),u=Nb(e),d=Pb(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)(q,{children:[`Yes, allow all edits during this session `,(0,$.jsxs)(q,{bold:!0,children:[`(`,c,`)`]})]});else{let r=Ag(hd(e))||`this directory`;t=n===`read`?(0,$.jsxs)(q,{children:[`Yes, allow reading from `,(0,$.jsxs)(q,{bold:!0,children:[r,`/`]}),` during this session`]}):(0,$.jsxs)(q,{children:[`Yes, allow all edits in `,(0,$.jsxs)(q,{bold:!0,children:[r,`/`]}),` during this session`,` `,(0,$.jsxs)(q,{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 Work Mate what to do differently`,onChange:r,allowEmptySubmitToCancel:!0,option:{type:`reject`}}):s.push({label:`No`,value:`no`,option:{type:`reject`}}),s}qd(),f(),pd(),Ut();function Ib(e,t,n,r,i){Gy({completion_type:t,event:e,metadata:{language_name:n,message_id:r,platform:ed.platform,hasFeedback:i??!1}})}function Lb(e,t){let{messageId:n,toolUseConfirm:r,onDone:i,completionType:a,languageName:o}=e;Ib(`accept`,a,o,n),X(`tengu_accept_submitted`,{toolName:p(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 Rb(e,t){let{messageId:n,path:r,toolUseConfirm:i,toolPermissionContext:a,onDone:o,completionType:s,languageName:c,operationType:l}=e;if(Ib(`accept`,s,c,n),t?.scope===`claude-folder`||t?.scope===`global-claude-folder`){let e=[{type:`addRules`,rules:[{toolName:$f,ruleContent:t.scope===`global-claude-folder`?Kf:Jf}],behavior:`allow`,destination:`session`}];o(),i.onAllow(i.input,e);return}let u=r?j(r,l,a):[];o(),i.onAllow(i.input,u)}function zb(e,t){let{messageId:n,toolUseConfirm:r,onDone:i,onReject:a,completionType:o,languageName:s}=e;Ib(`reject`,o,s,n,t?.hasFeedback),X(`tengu_reject_submitted`,{toolName:p(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 Bb={"accept-once":Lb,"accept-session":Rb,reject:zb};V(),Yn(),qd(),f();function Vb({filePath:e,completionType:t,languageName:n,toolUseConfirm:r,onDone:i,onReject:a,parseInput:o,operationType:s=`write`}){let c=U(e=>e.toolPermissionContext),[l,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)(``),[m,h]=(0,Q.useState)(`yes`),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(!1),w=(0,Q.useMemo)(()=>Fb({filePath:e,toolPermissionContext:c,operationType:s,onRejectFeedbackChange:f,onAcceptFeedbackChange:u,yesInputMode:g,noInputMode:v}),[e,c,s,g,v]),T=(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=Bb[o.type];p(d,{feedback:u,hasFeedback:!!u,enteredFeedbackMode:o.type===`accept-once`?b:S,scope:o.type===`accept-session`?o.scope:void 0})},[e,t,n,r,c,i,a,s,b,S]);return jc({"confirm:cycleMode":(0,Q.useCallback)(()=>{let e=w.find(e=>e.option.type===`accept-session`);if(e){let t=o(r.input);T(e.option,t)}},[w,o,r.input,T])},{context:`Confirmation`}),{options:w,onChange:T,acceptFeedback:l,rejectFeedback:d,focusedOption:m,setFocusedOption:(0,Q.useCallback)(e=>{e!==`yes`&&g&&!l.trim()&&_(!1),e!==`no`&&v&&!d.trim()&&y(!1),h(e)},[g,v,l,d]),handleInputModeToggle:(0,Q.useCallback)(e=>{let t={toolName:p(r.tool.name),isMcp:r.tool.isMcp??!1};e===`yes`?g?(_(!1),X(`tengu_accept_feedback_mode_collapsed`,t)):(_(!0),x(!0),X(`tengu_accept_feedback_mode_entered`,t)):e===`no`&&(v?(y(!1),X(`tengu_reject_feedback_mode_collapsed`,t)):(y(!0),C(!0),X(`tengu_reject_feedback_mode_entered`,t)))},[g,v,r]),yesInputMode:g,noInputMode:v}}J(),Ws(),hu(),id(),Th();function Hb({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?Qr(l):`none`),[p,l]);Ky(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=dd(l),{resolvedPath:t,isSymlink:n}=Du(Au(),e);return n?t:null},[l,d]),g=Vb({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}=Tb(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)(Mb,{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 j=h!=null&&Pg(gu(),h).startsWith(`..`);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(qh,{title:i,subtitle:a,innerPaddingX:0,children:[h?(0,$.jsx)(K,{paddingX:1,marginBottom:1,children:(0,$.jsx)(q,{color:`warning`,children:j?`This will modify ${h} (outside working directory) via a symlink`:`Symlink target: ${h}`})}):null,s,(0,$.jsxs)(K,{flexDirection:`column`,paddingX:1,children:[typeof o==`string`?(0,$.jsx)(q,{children:o}):o,(0,$.jsx)(km,{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)(K,{paddingX:1,marginTop:1,children:(0,$.jsxs)(q,{dimColor:!0,children:[`Esc to reject`,(S===`yes`&&!C||S===`no`&&!w)&&` · Tab to add feedback`]})})]})}hu(),bu(),$u(),Eu(),J();function Ub({sedInfo:e,...t}){let{filePath:n}=e;return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Wb,{sedInfo:e,contentPromise:(0,Q.useMemo)(()=>(async()=>{let e=Yu(n);return{oldContent:(await Au().readFile(n,{encoding:e})).replaceAll(`\r
22
+ `,`
23
+ `),fileExists:!0}})().catch(e=>{if(!Mu(e))throw e;return{oldContent:``,fileExists:!1}}),[n]),...t})})}function Wb({sedInfo:e,contentPromise:t,...n}){let{filePath:r}=e,{oldContent:i,fileExists:a}=(0,Q.use)(t),o=(0,Q.useMemo)(()=>Bn(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)(Hb,{toolUseConfirm:n.toolUseConfirm,toolUseContext:n.toolUseContext,onDone:n.onDone,onReject:n.onReject,title:`Edit file`,subtitle:Pg(gu(),r),question:(0,$.jsxs)(q,{children:[`Do you want to make this edit to `,(0,$.jsx)(q,{bold:!0,children:Ag(r)}),`?`]}),content:s.length>0?(0,$.jsx)(yb,{file_path:r,edits:s}):(0,$.jsx)(q,{dimColor:!0,children:c}),path:r,completionType:`str_replace_single`,parseInput:e=>({...dc.inputSchema.parse(e),_simulatedSedEdit:{filePath:r,newContent:o}})})}pd();function Gb(e,{assistantMessage:{message:{id:t}}},n,r){Gy({completion_type:e,event:n,metadata:{language_name:`none`,message_id:t,platform:zu(),hasFeedback:r??!1}})}qd(),f(),V();function Kb({toolUseConfirm:e,onDone:t,onReject:n,explainerVisible:r}){let i=N(),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(`yes`),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(!1);function b(t){e.onUserInteraction();let n={toolName:p(e.tool.name),isMcp:e.tool.isMcp??!1};t===`yes`?l?(u(!1),X(`tengu_accept_feedback_mode_collapsed`,n)):(u(!0),_(!0),X(`tengu_accept_feedback_mode_entered`,n)):t===`no`&&(d?(f(!1),X(`tengu_reject_feedback_mode_collapsed`,n)):(f(!0),y(!0),X(`tengu_reject_feedback_mode_entered`,n)))}function x(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}}))),Gb(`tool_use_single`,e,`reject`,s),o?e.onReject(o):e.onReject(),n(),t()}function S(t){t!==m&&e.onUserInteraction(),t!==`yes`&&l&&!s.trim()&&u(!1),t!==`no`&&d&&!a.trim()&&f(!1),h(t)}return{yesInputMode:l,noInputMode:d,yesFeedbackModeEntered:g,noFeedbackModeEntered:v,acceptFeedback:s,rejectFeedback:a,setAcceptFeedback:c,setRejectFeedback:o,focusedOption:m,handleInputModeToggle:b,handleReject:x,handleFocus:S}}mu(),J();function qb(e){switch(e.length){case 0:return``;case 1:return(0,$.jsx)(q,{bold:!0,children:e[0]});case 2:return(0,$.jsxs)(q,{children:[(0,$.jsx)(q,{bold:!0,children:e[0]}),` and `,(0,$.jsx)(q,{bold:!0,children:e[1]})]});default:return(0,$.jsxs)(q,{children:[(0,$.jsx)(q,{bold:!0,children:e.slice(0,-1).join(`, `)}),`, and `,(0,$.jsx)(q,{bold:!0,children:e.slice(-1)[0]})]})}}function Jb(e){return e.join(`, `).length>50?`similar`:qb(e)}function Yb(e){if(e.length===0)return``;let t=e.map(e=>Ag(e)||e);return t.length===1?(0,$.jsxs)(q,{children:[(0,$.jsx)(q,{bold:!0,children:t[0]}),Fg]}):t.length===2?(0,$.jsxs)(q,{children:[(0,$.jsx)(q,{bold:!0,children:t[0]}),Fg,` and `,(0,$.jsx)(q,{bold:!0,children:t[1]}),Fg]}):(0,$.jsxs)(q,{children:[(0,$.jsx)(q,{bold:!0,children:t[0]}),Fg,`, `,(0,$.jsx)(q,{bold:!0,children:t[1]}),Fg,` and `,e.length-2,` more`]})}function Xb(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=mn(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)(q,{children:[`Yes, allow reading from `,(0,$.jsx)(q,{bold:!0,children:Ag(e)||e}),Fg,` from this project`]})}return(0,$.jsxs)(q,{children:[`Yes, allow reading from `,Yb(s),` from this project`]})}if(l&&!u&&!d){if(o.length===1){let e=o[0];return(0,$.jsxs)(q,{children:[`Yes, and always allow access to `,(0,$.jsx)(q,{bold:!0,children:Ag(e)||e}),Fg,` from this project`]})}return(0,$.jsxs)(q,{children:[`Yes, and always allow access to `,Yb(o),` from this project`]})}if(d&&!l&&!u)return(0,$.jsxs)(q,{children:[`Yes, and don't ask again for `,Jb(c),` commands in `,(0,$.jsx)(q,{bold:!0,children:nu()})]});if((l||u)&&!d){let e=[...o,...s];if(l&&u)return(0,$.jsxs)(q,{children:[`Yes, and always allow access to `,Yb(e),` from this project`]})}if((l||u)&&d){let e=[...o,...s];return e.length===1&&c.length===1?(0,$.jsxs)(q,{children:[`Yes, and allow access to `,Yb(e),` and `,Jb(c),` commands`]}):(0,$.jsxs)(q,{children:[`Yes, and allow `,Yb(e),` access and `,Jb(c),` commands`]})}return null}Jo();function Zb(e){let{commandWithoutRedirections:t,redirections:n}=ft(e);return n.length>0?t:e}function Qb({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 Work Mate what to do next`,onChange:r,allowEmptySubmitToCancel:!0}):f.push({label:`Yes`,value:`yes`}),Ce()){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=Xb(e,Xf,Zb);t&&f.push({label:t,value:`yes-apply-suggestions`})}}return l?f.push({type:`input`,label:`No`,value:`no`,placeholder:`and tell Work Mate what to do differently`,onChange:n,allowEmptySubmitToCancel:!0}):f.push({label:`No`,value:`no`}),f}J(),Yn(),qd(),f(),V(),hi(),xe(),vi(),Or(),Vp(),Pm(),Gh();function $b(e){let{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,verbose:a}=e,{command:o,description:s}=dc.inputSchema.parse(t.input),c=me(o);return c?(0,$.jsx)(Ub,{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,verbose:a,sedInfo:c}):(0,$.jsx)(ex,{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,verbose:a,command:o,description:s})}function ex({toolUseConfirm:e,toolUseContext:t,onDone:n,onReject:r,verbose:i,command:a,description:o}){let[s]=Mc(),c=U(e=>e.toolPermissionContext),l=gb({toolName:e.tool.name,toolInput:e.input,toolDescription:e.description,messages:t.messages}),{yesInputMode:u,noInputMode:d,yesFeedbackModeEntered:f,noFeedbackModeEntered:m,acceptFeedback:h,rejectFeedback:g,setAcceptFeedback:_,setRejectFeedback:v,focusedOption:y,handleInputModeToggle:b,handleReject:x,handleFocus:S}=Kb({toolUseConfirm:e,onDone:n,onReject:r,explainerVisible:l.visible}),[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(o||``),[D,O]=(0,Q.useState)(!o?.trim());(0,Q.useEffect)(()=>{if(!jt())return;let e=new AbortController;return eo(a,o,e.signal).then(t=>{t&&!e.signal.aborted&&(E(t),O(!1))}).catch(()=>{}),()=>e.abort()},[a,o]);let k=e.permissionResult.decisionReason?.type===`subcommandResults`,[j,M]=(0,Q.useState)(()=>{if(k){let t=hc(`suggestions`in e.permissionResult?e.permissionResult.suggestions:void 0).filter(e=>e.toolName===dc.name&&e.ruleContent);return t.length===1?t[0].ruleContent:void 0}let t=Yr(a);if(t)return`${t}:*`;let n=da(a);return n?`${n}:*`:a}),N=(0,Q.useRef)(!1),ee=(0,Q.useCallback)(e=>{N.current=!0,M(e)},[]);(0,Q.useEffect)(()=>{if(k)return;let e=!1;return Uy(a,e=>dc.isReadOnly({command:e})).then(t=>{e||N.current||t.length>0&&M(`${t[0]}:*`)}).catch(()=>{}),()=>{e=!0}},[a,k]);let[te]=(0,Q.useState)(!1),{destructiveWarning:P,sandboxingEnabled:F,isSandboxed:I}=(0,Q.useMemo)(()=>{let t=pt.isSandboxingEnabled();return{destructiveWarning:null,sandboxingEnabled:t,isSandboxed:t&&lr(e.input)}},[a,e.input]);Ky(e,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let L=(0,Q.useMemo)(()=>A(c),[c]),ne=(0,Q.useMemo)(()=>Qb({suggestions:e.permissionResult.behavior===`ask`?e.permissionResult.suggestions:void 0,decisionReason:e.permissionResult.decisionReason,onRejectFeedbackChange:v,onAcceptFeedbackChange:_,onClassifierDescriptionChange:E,classifierDescription:T,initialClassifierDescriptionEmpty:D,existingAllowDescriptions:L,yesInputMode:u,noInputMode:d,editablePrefix:j,onEditablePrefixChange:ee}),[e,T,D,L,u,d,j,ee]);Vc(`permission:toggleDebug`,(0,Q.useCallback)(()=>{w(e=>!e)},[]),{context:`Confirmation`}),Vc(`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=p(e.tool.name);if(t===`yes-prefix-edited`){let t=(j??``).trim();if(Gb(`tool_use_single`,e,`accept`),!t)e.onAllow(e.input,[]);else{let n=[{type:`addRules`,rules:[{toolName:dc.name,ruleContent:t}],behavior:`allow`,destination:`localSettings`}];e.onAllow(e.input,n)}n();return}switch(t){case`yes`:{let t=h.trim();Gb(`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`:{Gb(`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=g.trim();X(`tengu_reject_submitted`,{toolName:r,isMcp:e.tool.isMcp??!1,has_instructions:!!t,instructions_length:t.length,entered_feedback_mode:m}),x(t||void 0);break}}}return(0,$.jsxs)(qh,{title:F&&!I?`Bash command (unsandboxed)`:`Bash command`,subtitle:void 0,children:[(0,$.jsxs)(K,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(q,{dimColor:l.visible,children:dc.renderToolUseMessage({command:a,description:o},{theme:s,verbose:!0})}),!l.visible&&(0,$.jsx)(q,{dimColor:!0,children:e.description}),(0,$.jsx)(vb,{visible:l.visible,promise:l.promise})]}),C?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)($y,{permissionResult:e.permissionResult,toolName:`Bash`}),t.options.debug&&(0,$.jsx)(K,{justifyContent:`flex-end`,marginTop:1,children:(0,$.jsx)(q,{dimColor:!0,children:`Ctrl-D to hide debug info`})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(K,{flexDirection:`column`,children:[(0,$.jsx)(fy,{permissionResult:e.permissionResult,toolType:`command`}),P&&(0,$.jsx)(K,{marginBottom:1,children:(0,$.jsx)(q,{color:`warning`,dimColor:!1,children:P})}),(0,$.jsx)(q,{dimColor:!1,children:`Do you want to proceed?`}),(0,$.jsx)(km,{options:ne,isDisabled:!1,inlineDescriptions:!0,onChange:re,onCancel:()=>x(),onFocus:S,onInputModeToggle:b})]}),(0,$.jsxs)(K,{justifyContent:`space-between`,marginTop:1,children:[(0,$.jsxs)(q,{dimColor:!0,children:[`Esc to reject`,(y===`yes`&&!u||y===`no`&&!d)&&` · Tab to add feedback`,l.enabled&&` · ctrl+e to ${l.visible?`hide`:`explain`}`]}),t.options.debug&&(0,$.jsx)(q,{dimColor:!0,children:`Ctrl+d to show debug info`})]})]})]})}mu(),J(),qd(),V(),go(),Th(),Gh();function tx({toolUseConfirm:e,onDone:t,onReject:n}){let r=U(e=>e.toolPermissionContext.mode);function i(i){i===`yes`?(X(`tengu_plan_enter`,{interviewPhaseEnabled:Sa(),entryMethod:`tool`}),Kl(r,`plan`),t(),e.onAllow({},[{type:`setMode`,mode:`plan`,destination:`session`}])):(t(),n(),e.onReject())}return(0,$.jsx)(qh,{color:`planMode`,title:`Enter plan mode?`,children:(0,$.jsxs)(K,{flexDirection:`column`,marginTop:1,paddingX:1,children:[(0,$.jsx)(q,{children:`Work Mate wants to enter plan mode to explore and design an implementation approach.`}),(0,$.jsxs)(K,{marginTop:1,flexDirection:`column`,children:[(0,$.jsx)(q,{dimColor:!0,children:`In plan mode, Work Mate will:`}),(0,$.jsx)(q,{dimColor:!0,children:` · Explore the codebase thoroughly`}),(0,$.jsx)(q,{dimColor:!0,children:` · Identify existing patterns`}),(0,$.jsx)(q,{dimColor:!0,children:` · Design an implementation strategy`}),(0,$.jsx)(q,{dimColor:!0,children:` · Present a plan for your approval`})]}),(0,$.jsx)(K,{marginTop:1,children:(0,$.jsx)(q,{dimColor:!0,children:`No code changes will be made until you approve the plan.`})}),(0,$.jsx)(K,{marginTop:1,children:(0,$.jsx)(km,{options:[{label:`Yes, enter plan mode`,value:`yes`},{label:`No, start implementing now`,value:`no`}],onChange:i,onCancel:()=>i(`no`)})})]})})}l(),qd(),V(),mu(),tg(),J(),dh(),Cn(),Md(),Of(),Ha(),ld(),go(),Ci(),hh(),Gs(),Th(),Gh(),Ft(),Wa();function nx(e,t){let n=[{type:`setMode`,mode:Ju(e),destination:`session`}];return jt()&&t&&t.length>0&&n.push({type:`addRules`,rules:t.map(e=>({toolName:e.tool,ruleContent:$t(e.prompt)})),behavior:`allow`,destination:`session`}),n}function rx(e,t,n){Il()||ad()?.cleanupPeriodDays===0||!n&&ko(du())||ng([He({content:e.slice(0,1e3)})],new AbortController().signal).then(async e=>{if(!e||ko(du()))return;let n=du(),r=vo();await Oo(n,e,r,`auto`),await x(n,e,r,`auto`),t(t=>t.standaloneAgentContext?.name===e?t:{...t,standaloneAgentContext:{...t.standaloneAgentContext,name:e}})}).catch(Pd)}function ix({toolUseConfirm:e,onDone:t,onReject:n,setStickyFooter:r}){let i=U(e=>e.toolPermissionContext),a=N();no();let{addNotification:o}=Jp(),[s,c]=(0,Q.useState)(``),[l,d]=(0,Q.useState)({}),f=(0,Q.useRef)(0),p=U(e=>e.settings.showClearContextOnPlanAccept)??!1,m=e.assistantMessage.message.usage,{mode:h,isAutoModeAvailable:g,isBypassPermissionsModeAvailable:_}=i,v=(0,Q.useMemo)(()=>ax({showClearContext:p,usedPercent:p?ox(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};_e(o),Nt(o),d(e=>({...e,[a]:o}))}let b=(0,Q.useCallback)(e=>{d(t=>{let n={...t};return delete n[e],n})},[]),x=Object.values(l).filter(e=>e.type===`image`),C=x.length>0,w=ni(),T=e.input.allowedPrompts,E=Da(),D=!E||E.trim()===``,[O]=(0,Q.useState)(()=>Wo()??void 0),[k,A]=(0,Q.useState)(()=>Da()??`No plan found. Please write your plan to the plan file first.`),[j,M]=(0,Q.useState)(!1),[ee,te]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{if(j){let e=setTimeout(M,5e3,!1);return()=>clearTimeout(e)}},[j]);let P=e=>{if(e.ctrl&&e.key===`g`){e.preventDefault(),X(`tengu_plan_external_editor_used`,{}),(async()=>{let e=await gh(w);e.error&&o({key:`external-editor-error`,text:e.error,color:`warning`,priority:`high`}),e.content!==null&&(e.content!==k&&te(!0),A(e.content),M(!0))})();return}if(e.shift&&e.key===`tab`){e.preventDefault(),F(p?`yes-accept-edits`:`yes-accept-edits-keep-context`);return}};async function F(r){let o=s.trim(),c=o||void 0,l=ee?{plan:k}:{};{let e=(r===`yes-resume-auto-mode`||r===`yes-auto-clear-context`)&&ie(),t=mr();r!==`no`&&!e&&t&&(Be(!1),cu(!0),a(e=>({...e,toolPermissionContext:{...Kt(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`&&rx(k,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`&&ie()&&(i=`auto`,Be(!0)),X(`tengu_plan_exit`,{planLengthChars:k.length,outcome:r,clearContext:!0,interviewPhaseEnabled:Sa(),planStructureVariant:O,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: ${vo()}`,s=c?`\n\nUser feedback on this plan: ${c}`:``;a(e=>({...e,initialMessage:{message:{...He({content:`Implement the following plan:\n\n${k}${o}${s}`}),planContent:k},clearContext:!0,mode:i,allowedPrompts:T}})),uu(!0),Pl(!0),t(),n(),e.onReject();return}if(r===`yes-resume-auto-mode`&&ie()){X(`tengu_plan_exit`,{planLengthChars:k.length,outcome:r,clearContext:!1,interviewPhaseEnabled:Sa(),planStructureVariant:O,hasFeedback:!!c}),uu(!0),Pl(!0),Be(!0),a(e=>({...e,toolPermissionContext:qa({...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:k.length,outcome:r,clearContext:!1,interviewPhaseEnabled:Sa(),planStructureVariant:O,hasFeedback:!!c}),uu(!0),Pl(!0),t(),e.onAllow(l,nx(d,T),c);return}let f={"yes-bypass-permissions":`bypassPermissions`,"yes-accept-edits":`acceptEdits`}[r];if(f){X(`tengu_plan_exit`,{planLengthChars:k.length,outcome:r,interviewPhaseEnabled:Sa(),planStructureVariant:O,hasFeedback:!!c}),uu(!0),Pl(!0),t(),e.onAllow(l,nx(f,T),c);return}if(r===`no`){if(!o&&!C)return;X(`tengu_plan_exit`,{planLengthChars:k.length,outcome:`no`,interviewPhaseEnabled:Sa(),planStructureVariant:O});let r;C&&(r=await Promise.all(x.map(async e=>(await Gt({type:`image`,source:{type:`base64`,media_type:e.mediaType||`image/png`,data:e.content}})).block))),t(),n(),e.onReject(o||(C?`(See attached image)`:void 0),r&&r.length>0?r:void 0)}}let I=fh(),L=I?Jn(I):null,ne=(0,Q.useRef)(F);ne.current=F;let re=(0,Q.useRef)(void 0);re.current=()=>{X(`tengu_plan_exit`,{planLengthChars:k.length,outcome:`no`,interviewPhaseEnabled:Sa(),planStructureVariant:O}),t(),n(),e.onReject()};let ae=!D&&!!r;if((0,Q.useLayoutEffect)(()=>{if(ae)return r((0,$.jsxs)(K,{flexDirection:`column`,borderStyle:`round`,borderColor:`planMode`,borderLeft:!1,borderRight:!1,borderBottom:!1,paddingX:1,children:[(0,$.jsx)(q,{dimColor:!0,children:`Would you like to proceed?`}),(0,$.jsx)(K,{marginTop:1,children:(0,$.jsx)(km,{options:v,onChange:e=>void ne.current(e),onCancel:()=>re.current?.(),onImagePaste:y,pastedContents:l,onRemoveImage:b})}),L&&(0,$.jsxs)(K,{flexDirection:`row`,gap:1,marginTop:1,children:[(0,$.jsx)(q,{dimColor:!0,children:`ctrl-g to edit in `}),(0,$.jsx)(q,{bold:!0,dimColor:!0,children:L}),(0,$.jsxs)(q,{dimColor:!0,children:[` · `,Fu(w)]}),j&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{dimColor:!0,children:` · `}),(0,$.jsxs)(q,{color:`success`,children:[u.tick,`Plan saved!`]})]})]})]})),()=>r(null)},[ae,r,v,l,L,w,j]),D){function r(r){r===`yes`?(X(`tengu_plan_exit`,{planLengthChars:0,outcome:`yes-default`,interviewPhaseEnabled:Sa(),planStructureVariant:O}),mr()&&(Be(!1),cu(!0),a(e=>({...e,toolPermissionContext:{...Kt(e.toolPermissionContext),prePlanMode:void 0}}))),uu(!0),Pl(!0),t(),e.onAllow({},[{type:`setMode`,mode:`default`,destination:`session`}])):(X(`tengu_plan_exit`,{planLengthChars:0,outcome:`no`,interviewPhaseEnabled:Sa(),planStructureVariant:O}),t(),n(),e.onReject())}return(0,$.jsx)(qh,{color:`planMode`,title:`Exit plan mode?`,children:(0,$.jsxs)(K,{flexDirection:`column`,paddingX:1,marginTop:1,children:[(0,$.jsx)(q,{children:`Work Mate wants to exit plan mode`}),(0,$.jsx)(K,{marginTop:1,children:(0,$.jsx)(km,{options:[{label:`Yes`,value:`yes`},{label:`No`,value:`no`}],onChange:r,onCancel:()=>{X(`tengu_plan_exit`,{planLengthChars:0,outcome:`no`,interviewPhaseEnabled:Sa(),planStructureVariant:O}),t(),n(),e.onReject()}})})]})})}return(0,$.jsxs)(K,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:P,children:[(0,$.jsx)(qh,{color:`planMode`,title:`Ready to code?`,innerPaddingX:0,children:(0,$.jsxs)(K,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(K,{paddingX:1,flexDirection:`column`,children:(0,$.jsx)(q,{children:`Here is Work Mate's plan:`})}),(0,$.jsx)(K,{borderColor:`subtle`,borderStyle:`dashed`,flexDirection:`column`,borderLeft:!1,borderRight:!1,paddingX:1,marginBottom:1,overflow:`hidden`,children:(0,$.jsx)(S,{children:k})}),(0,$.jsxs)(K,{flexDirection:`column`,paddingX:1,children:[(0,$.jsx)(fy,{permissionResult:e.permissionResult,toolType:`tool`}),jt()&&T&&T.length>0&&(0,$.jsxs)(K,{flexDirection:`column`,marginBottom:1,children:[(0,$.jsx)(q,{bold:!0,children:`Requested permissions:`}),T.map((e,t)=>(0,$.jsxs)(q,{dimColor:!0,children:[` `,`· `,e.tool,`(`,`prompt:`,` `,e.prompt,`)`]},t))]}),!ae&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{dimColor:!0,children:`Work Mate has written up a plan and is ready to execute. Would you like to proceed?`}),(0,$.jsx)(K,{marginTop:1,children:(0,$.jsx)(km,{options:v,onChange:F,onCancel:()=>re.current?.(),onImagePaste:y,pastedContents:l,onRemoveImage:b})})]})]})]})}),!ae&&L&&(0,$.jsxs)(K,{flexDirection:`row`,gap:1,paddingX:1,marginTop:1,children:[(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{dimColor:!0,children:`ctrl-g to edit in `}),(0,$.jsx)(q,{bold:!0,dimColor:!0,children:L}),(0,$.jsxs)(q,{dimColor:!0,children:[` · `,Fu(w)]})]}),j&&(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{dimColor:!0,children:` · `}),(0,$.jsxs)(q,{color:`success`,children:[u.tick,`Plan saved!`]})]})]})]})}function ax({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 Work Mate what to change`,description:`shift+tab to approve with this feedback`,onChange:i}),a}function ox(e,t){if(!e)return null;let n=Ef(Mf({permissionMode:t,mainLoopModel:Lf(),exceeds200kTokens:!1}),ou()),{used:r}=Bf({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}Wm(),J(),Yn(),qd(),V(),Om();var sx={accept:`tell Work Mate what to do next`,reject:`tell Work Mate what to do differently`};function cx({options:e,onSelect:t,onCancel:n,question:r=`Do you want to proceed?`,toolAnalyticsContext:i}){let a=N(),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(!1),b=e.find(e=>e.value===m)?.feedbackConfig?.type,x=b===`accept`&&!u||b===`reject`&&!f,S=(0,Q.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=sx[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,Q.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,Q.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]);jc((0,Q.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,Q.useCallback)(()=>{X(`tengu_permission_request_escape`,{}),a(e=>({...e,attribution:{...e.attribution,escapeCount:e.attribution.escapeCount+1}})),n?.()},[n,a]);return(0,$.jsxs)(K,{flexDirection:`column`,children:[typeof r==`string`?(0,$.jsx)(q,{children:r}):r,(0,$.jsx)(km,{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,$.jsx)(K,{marginTop:1,children:(0,$.jsxs)(q,{dimColor:!0,children:[`Esc to cancel`,x&&` · Tab to amend`]})})]})}mu(),J(),f(),pd(),Un(),Vd(),Gh();function lx({toolUseConfirm:e,onDone:t,onReject:n,verbose:r}){let[i]=Mc(),a=e.tool.userFacingName(e.input),o=a.endsWith(` (MCP)`)?a.slice(0,-6):a;Ky(e,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let s=(0,Q.useCallback)((r,i)=>{switch(r){case`yes`:Gy({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:ed.platform}}),e.onAllow(e.input,[],i),t();break;case`yes-dont-ask-again`:Gy({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:ed.platform}}),e.onAllow(e.input,[{type:`addRules`,rules:[{toolName:e.tool.name}],behavior:`allow`,destination:`localSettings`}]),t();break;case`no`:Gy({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:ed.platform}}),e.onReject(i),n(),t();break}},[e,t,n]),c=(0,Q.useCallback)(()=>{Gy({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:ed.platform}}),e.onReject(),n(),t()},[e,t,n]),l=nu(),u=Ce(),d=(0,Q.useMemo)(()=>{let e=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}];return u&&e.push({label:(0,$.jsxs)(q,{children:[`Yes, and don't ask again for `,(0,$.jsx)(q,{bold:!0,children:o}),` commands in`,` `,(0,$.jsx)(q,{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:p(e.tool.name),isMcp:e.tool.isMcp??!1}),[e.tool.name,e.tool.isMcp]);return(0,$.jsxs)(qh,{title:`Tool use`,children:[(0,$.jsxs)(K,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsxs)(q,{children:[o,`(`,e.tool.renderToolUseMessage(e.input,{theme:i,verbose:!0}),`)`,a.endsWith(` (MCP)`)?(0,$.jsx)(q,{dimColor:!0,children:` (MCP)`}):``]}),(0,$.jsx)(q,{dimColor:!0,children:Ld(e.description,3)})]}),(0,$.jsxs)(K,{flexDirection:`column`,children:[(0,$.jsx)(fy,{permissionResult:e.permissionResult,toolType:`tool`}),(0,$.jsx)(cx,{options:d,onSelect:s,onCancel:c,toolAnalyticsContext:f})]})]})}function ux(e,t,n,r){return{filePath:e,edits:[{old_string:t,new_string:n,replace_all:r}],editMode:`single`}}hu(),J();var dx={getConfig:e=>ux(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 fx(e){let t=e=>W.inputSchema.parse(e),{file_path:n,old_string:r,new_string:i,replace_all:a}=t(e.toolUseConfirm.input);return(0,$.jsx)(Hb,{toolUseConfirm:e.toolUseConfirm,toolUseContext:e.toolUseContext,onDone:e.onDone,onReject:e.onReject,title:`Edit file`,subtitle:Pg(gu(),n),question:(0,$.jsxs)(q,{children:[`Do you want to make this edit to `,(0,$.jsx)(q,{bold:!0,children:Ag(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:dx})}J();function px(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 mx({toolUseConfirm:e,onDone:t,onReject:n,verbose:r,toolUseContext:i}){let[a]=Mc(),o=px(e),s=e.tool.userFacingName(e.input),c=e.tool.isReadOnly(e.input),l=`${c?`Read`:`Edit`} file`;return o?(0,$.jsx)(Hb,{toolUseConfirm:e,toolUseContext:i,onDone:t,onReject:n,title:l,content:(0,$.jsx)(K,{flexDirection:`column`,paddingX:2,paddingY:1,children:(0,$.jsxs)(q,{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)(lx,{toolUseConfirm:e,toolUseContext:i,onDone:t,onReject:n,verbose:r})}Ar(),J(),ri(),aa();function hx({file_path:e,content:t,fileExists:n,oldContent:r}){let{columns:i}=sl(),a=(0,Q.useMemo)(()=>n?is({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)(K,{flexDirection:`column`,children:(0,$.jsx)(K,{borderColor:`subtle`,borderStyle:`dashed`,flexDirection:`column`,borderLeft:!1,borderRight:!1,paddingX:1,children:a?td(a.map(t=>(0,$.jsx)(lo,{patch:t,dim:!1,filePath:e,firstLine:o,fileContent:r,width:i-2},t.newStart)),e=>(0,$.jsx)(zc,{fromLeftEdge:!0,children:(0,$.jsx)(q,{dimColor:!0,children:`...`})},`ellipsis-${e}`)):(0,$.jsx)(Li,{code:t||`(No content)`,filePath:e})})})}J(),hu(),bu(),$u();var gx={getConfig:e=>{let t;try{t=Ru(e.file_path)}catch(e){if(!Mu(e))throw e;t=``}return ux(e.file_path,t,e.content,!1)},applyChanges:(e,t)=>{let n=t[0];return n?{...e,content:n.new_string}:e}};function _x(e){let t=e=>ir.inputSchema.parse(e),{file_path:n,content:r}=t(e.toolUseConfirm.input),{fileExists:i,oldContent:a}=(0,Q.useMemo)(()=>{try{return{fileExists:!0,oldContent:Ru(n)}}catch(e){if(!Mu(e))throw e;return{fileExists:!1,oldContent:``}}},[n]),o=i?`overwrite`:`create`;return(0,$.jsx)(Hb,{toolUseConfirm:e.toolUseConfirm,toolUseContext:e.toolUseContext,onDone:e.onDone,onReject:e.onReject,title:i?`Overwrite file`:`Create file`,subtitle:Pg(gu(),n),question:(0,$.jsxs)(q,{children:[`Do you want to `,o,` `,(0,$.jsx)(q,{bold:!0,children:Ag(n)}),`?`]}),content:(0,$.jsx)(hx,{file_path:n,content:r,fileExists:i,oldContent:a}),path:n,completionType:`write_file_single`,parseInput:t,ideDiffSupport:gx})}J(),Uu(),hu(),ri(),Eu(),aa(),Is();function vx(e){let t=(0,Q.useMemo)(()=>Au().readFile(e.notebook_path,{encoding:`utf-8`}).then(e=>El(e)).catch(()=>null),[e.notebook_path]);return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(yx,{...e,promise:t})})}function yx({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=zo(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:is({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)(K,{flexDirection:`column`,children:(0,$.jsxs)(K,{borderStyle:`round`,flexDirection:`column`,paddingX:1,children:[(0,$.jsxs)(K,{paddingBottom:1,flexDirection:`column`,children:[(0,$.jsx)(q,{bold:!0,children:a?e:Pg(gu(),e)}),(0,$.jsxs)(q,{dimColor:!0,children:[d,` for cell `,t,r?` (${r})`:``]})]}),i===`delete`?(0,$.jsx)(K,{flexDirection:`column`,paddingLeft:2,children:(0,$.jsx)(Li,{code:l,filePath:e})}):i===`insert`?(0,$.jsx)(K,{flexDirection:`column`,paddingLeft:2,children:(0,$.jsx)(Li,{code:n,filePath:r===`markdown`?`file.md`:e})}):u?td(u.map(t=>(0,$.jsx)(lo,{patch:t,dim:!1,width:o,filePath:e,firstLine:n.split(`
25
+ `)[0]??null,fileContent:l},t.newStart)),e=>(0,$.jsx)(zc,{fromLeftEdge:!0,children:(0,$.jsx)(q,{dimColor:!0,children:`...`})},`ellipsis-${e}`)):(0,$.jsx)(Li,{code:n,filePath:r===`markdown`?`file.md`:e})]})})}J(),Md();function bx(e){let t=e=>{let t=B.inputSchema.safeParse(e);return t.success?t.data:(Pd(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)(Hb,{toolUseConfirm:e.toolUseConfirm,toolUseContext:e.toolUseContext,onDone:e.onDone,onReject:e.onReject,title:`Edit notebook`,question:(0,$.jsxs)(q,{children:[`Do you want to `,s,` `,(0,$.jsx)(q,{bold:!0,children:Ag(r)}),`?`]}),content:(0,$.jsx)(vx,{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})}Vd(),Jt();async function xx(e){if(e.nameType===`application`)return null;let t=e.name;if(!t||pe.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 Fy(n),i=await Ay(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||Ty[n])?null:i}async function Sx(e,t){let n=await Bt(e);if(!n.valid)return[];let r=za(n).filter(e=>e.elementType===`CommandAst`);if(r.length<=1){let e=r[0]?await xx(r[0]):null;return e?[e]:[]}let i=[];for(let e of r){if(t?.(e))continue;let n=await xx(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=Cx(t);(n===``?0:Hd(n,` `)+1)<=1&&((await Fy(e))?.subcommands?.length||Ty[e])||o.push(n)}return o}function Cx(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(` `)}Un();function wx({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 Work Mate what to do next`,onChange:n,allowEmptySubmitToCancel:!0}):s.push({label:`Yes`,value:`yes`}),Ce()&&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=Xb(e,ep);t&&s.push({label:t,value:`yes-apply-suggestions`})}}return i?s.push({type:`input`,label:`No`,value:`no`,placeholder:`and tell Work Mate what to do differently`,onChange:t,allowEmptySubmitToCancel:!0}):s.push({label:`No`,value:`no`}),s}J(),Yn(),qd(),f(),Om(),Gh();function Tx(e){let{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i}=e,{command:a,description:o}=Js.inputSchema.parse(t.input),[s]=Mc(),c=gb({toolName:t.tool.name,toolInput:t.input,toolDescription:t.description,messages:n.messages}),{yesInputMode:l,noInputMode:u,yesFeedbackModeEntered:d,noFeedbackModeEntered:f,acceptFeedback:m,rejectFeedback:h,setAcceptFeedback:g,setRejectFeedback:_,focusedOption:v,handleInputModeToggle:y,handleReject:b,handleFocus:x}=Kb({toolUseConfirm:t,onDone:r,onReject:i,explainerVisible:c.visible}),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(a.includes(`
26
+ `)?void 0:a),E=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{let e=!1;return Sx(a,e=>D(e,e.text)).then(t=>{e||E.current||t.length>0&&T(`${t[0]}:*`)}).catch(()=>{}),()=>{e=!0}},[a]);let O=(0,Q.useCallback)(e=>{E.current=!0,T(e)},[]);Ky(t,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let k=(0,Q.useMemo)(()=>wx({suggestions:t.permissionResult.behavior===`ask`?t.permissionResult.suggestions:void 0,onRejectFeedbackChange:_,onAcceptFeedbackChange:g,yesInputMode:l,noInputMode:u,editablePrefix:w,onEditablePrefixChange:O}),[t,l,u,w,O]);Vc(`permission:toggleDebug`,(0,Q.useCallback)(()=>{C(e=>!e)},[]),{context:`Confirmation`});function A(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=p(t.tool.name);if(e===`yes-prefix-edited`){let e=(w??``).trim();if(Gb(`tool_use_single`,t,`accept`),!e)t.onAllow(t.input,[]);else{let n=[{type:`addRules`,rules:[{toolName:Js.name,ruleContent:e}],behavior:`allow`,destination:`localSettings`}];t.onAllow(t.input,n)}r();return}switch(e){case`yes`:{let e=m.trim();Gb(`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`:{Gb(`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=h.trim();X(`tengu_reject_submitted`,{toolName:n,isMcp:t.tool.isMcp??!1,has_instructions:!!e,instructions_length:e.length,entered_feedback_mode:f}),b(e||void 0);break}}}return(0,$.jsxs)(qh,{title:`PowerShell command`,children:[(0,$.jsxs)(K,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(q,{dimColor:c.visible,children:Js.renderToolUseMessage({command:a,description:o},{theme:s,verbose:!0})}),!c.visible&&(0,$.jsx)(q,{dimColor:!0,children:t.description}),(0,$.jsx)(vb,{visible:c.visible,promise:c.promise})]}),S?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)($y,{permissionResult:t.permissionResult,toolName:`PowerShell`}),n.options.debug&&(0,$.jsx)(K,{justifyContent:`flex-end`,marginTop:1,children:(0,$.jsx)(q,{dimColor:!0,children:`Ctrl-D to hide debug info`})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(K,{flexDirection:`column`,children:[(0,$.jsx)(fy,{permissionResult:t.permissionResult,toolType:`command`}),null,(0,$.jsx)(q,{children:`Do you want to proceed?`}),(0,$.jsx)(km,{options:k,inlineDescriptions:!0,onChange:A,onCancel:()=>b(),onFocus:x,onInputModeToggle:y})]}),(0,$.jsxs)(K,{justifyContent:`space-between`,marginTop:1,children:[(0,$.jsxs)(q,{dimColor:!0,children:[`Esc to cancel`,(v===`yes`&&!l||v===`no`&&!u)&&` · Tab to amend`,c.enabled&&` · ctrl+e to ${c.visible?`hide`:`explain`}`]}),n.options.debug&&(0,$.jsx)(q,{dimColor:!0,children:`Ctrl+d to show debug info`})]})]})]})}Md(),mu(),J(),f(),pd(),Un(),Gh();function Ex(e){let{toolUseConfirm:t,onDone:n,onReject:r,verbose:i}=e,a=(e=>{let t=$o.inputSchema.safeParse(e);return t.success?t.data.skill:(Pd(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;Ky(t,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let s=nu(),c=Ce(),l=(0,Q.useMemo)(()=>{let e=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}],t=[];if(c){t.push({label:(0,$.jsxs)(q,{children:[`Yes, and don't ask again for `,(0,$.jsx)(q,{bold:!0,children:a}),` in `,(0,$.jsx)(q,{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)(q,{children:[`Yes, and don't ask again for `,(0,$.jsx)(q,{bold:!0,children:`${n}:*`}),` commands in`,` `,(0,$.jsx)(q,{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:p(t.tool.name),isMcp:t.tool.isMcp??!1}),[t.tool.name,t.tool.isMcp]),d=(0,Q.useCallback)((e,i)=>{switch(e){case`yes`:Gy({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:ed.platform}}),t.onAllow(t.input,[],i),n();break;case`yes-exact`:Gy({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:ed.platform}}),t.onAllow(t.input,[{type:`addRules`,rules:[{toolName:Wf,ruleContent:a}],behavior:`allow`,destination:`localSettings`}]),n();break;case`yes-prefix`:{Gy({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:ed.platform}});let e=a.indexOf(` `),r=e>0?a.substring(0,e):a;t.onAllow(t.input,[{type:`addRules`,rules:[{toolName:Wf,ruleContent:`${r}:*`}],behavior:`allow`,destination:`localSettings`}]),n();break}case`no`:Gy({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:ed.platform}}),t.onReject(i),r(),n();break}},[t,n,r,a]),f=(0,Q.useCallback)(()=>{Gy({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:ed.platform}}),t.onReject(),r(),n()},[t,n,r]);return(0,$.jsxs)(qh,{title:`Use skill "${a}"?`,children:[(0,$.jsx)(q,{children:`Work Mate may use instructions, code, or files from this Skill.`}),(0,$.jsx)(K,{flexDirection:`column`,paddingX:2,paddingY:1,children:(0,$.jsx)(q,{dimColor:!0,children:o?.description})}),(0,$.jsxs)(K,{flexDirection:`column`,children:[(0,$.jsx)(fy,{permissionResult:t.permissionResult,toolType:`tool`}),(0,$.jsx)(cx,{options:l,onSelect:d,onCancel:f,toolAnalyticsContext:u})]})]})}J(),Hm(),pd(),Un(),Gh();function Dx({toolUseConfirm:e,onDone:t,onReject:n}){let[r]=Mc(),i=Vm(r),a=e.input,o=(0,Q.useMemo)(()=>Ce(),[]),s=(0,Q.useMemo)(()=>{let t=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}];return o&&t.push({label:(0,$.jsxs)(q,{children:[`Yes, and don`,`’`,`t ask again for `,(0,$.jsx)(q,{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,Q.useCallback)((r,i)=>{switch(r){case`yes`:Gy({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:ed.platform}}),e.onAllow(e.input,[],i),t();break;case`yes-dont-ask-again`:Gy({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:ed.platform}}),e.onAllow(e.input,[{type:`addRules`,rules:[{toolName:e.tool.name}],behavior:`allow`,destination:`localSettings`}]),t();break;case`no`:Gy({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:ed.platform}}),e.onReject(i),n(),t();break}},[e,t,n]),l=(0,Q.useCallback)(()=>{Gy({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:ed.platform}}),e.onReject(),n(),t()},[e,t,n]);return(0,$.jsx)(qh,{title:`Workflow`,children:(0,$.jsxs)(K,{flexDirection:`column`,gap:1,children:[(0,$.jsxs)(K,{flexDirection:`column`,children:[(0,$.jsxs)(q,{bold:!0,color:i.permission,children:[`Execute workflow: `,a.workflow]}),a.args&&(0,$.jsxs)(q,{dimColor:!0,children:[`Arguments: `,a.args]})]}),(0,$.jsx)(fy,{permissionResult:e.permissionResult,toolType:`command`}),(0,$.jsx)(cx,{options:s,onSelect:c,onCancel:l})]})})}Yn(),mc(),hi(),we(),Ge(),ec(),be(),st();var Ox=an();function kx(e){switch(e){case W:return fx;case ir:return _x;case dc:return $b;case Js:return Tx;case B:return bx;case _i:return ix;case Pi:return tx;case $o:return Ex;case Vs:return by;case Ox:return Dx??lx;case on:case Xe:case fe:return mx;default:return lx}}function Ax(e){let t=e.tool.userFacingName(e.input);return e.tool===_i?`Work Mate needs your approval for the plan`:e.tool===Pi?`Work Mate wants to enter plan mode`:!t||t.trim()===``?`Work Mate needs your attention`:`Work Mate needs your permission to use ${t}`}function jx({toolUseConfirm:e,toolUseContext:t,onDone:n,onReject:r,verbose:i,setStickyFooter:a}){return Vc(`app:interrupt`,()=>{n(),r(),e.onReject()},{context:`Confirmation`}),ry(Ax(e),`permission_prompt`),(0,$.jsx)(kx(e.tool),{toolUseContext:t,toolUseConfirm:e,onDone:n,onReject:r,verbose:i,setStickyFooter:a})}Ka(),fm(),Md(),Wr();async function Mx(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=Ee([`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 Br({systemPrompt:u,userPrompt:d,signal:n,options:{querySource:`mcp_datetime_parse`,agents:[],isNonInteractiveSession:!1,hasAppendSystemPrompt:!1,mcpTools:[],enablePromptCaching:!1}}),t=qs(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 Pd(e),{success:!1,error:`Unable to parse date/time. Please enter in ISO 8601 format manually.`}}}function Nx(e){return/^\d{4}-\d{2}-\d{2}(T|$)/.test(e.trim())}Ml(),ju(),Vd();var Px=e=>e.type===`string`&&(`enum`in e||`oneOf`in e);function Fx(e){return e.type===`array`&&`items`in e&&typeof e.items==`object`&&e.items!==null&&(`enum`in e.items||`anyOf`in e.items)}function Ix(e){return`anyOf`in e.items?e.items.anyOf.map(e=>e.const):`enum`in e.items?e.items.enum:[]}function Lx(e){return`anyOf`in e.items?e.items.anyOf.map(e=>e.title):`enum`in e.items?e.items.enum:[]}function Rx(e,t){let n=Ix(e).indexOf(t);return n>=0?Lx(e)[n]??t:t}function zx(e){return`oneOf`in e?e.oneOf.map(e=>e.const):`enum`in e?e.enum:[]}function Bx(e){return`oneOf`in e?e.oneOf.map(e=>e.title):`enum`in e?(`enumNames`in e?e.enumNames:void 0)??e.enum:[]}function Vx(e,t){let n=zx(e).indexOf(t);return n>=0?Bx(e)[n]??t:t}function Hx(e){if(Px(e)){let[t,...n]=zx(e);return t?vl([t,...n]):xl()}if(e.type===`string`){let t=wl();switch(e.minLength!==void 0&&(t=t.min(e.minLength,{message:`Must be at least ${e.minLength} ${zd(e.minLength,`character`)}`})),e.maxLength!==void 0&&(t=t.max(e.maxLength,{message:`Must be at most ${e.maxLength} ${zd(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=yl({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 jl();throw Error(`Unsupported schema: ${_u(e)}`)}function Ux(e,t){let n=Hx(t).safeParse(e);return n.success?{value:n.data,isValid:!0}:{isValid:!1,error:n.error.issues.map(e=>e.message).join(`; `)}}function Wx(e){return e.type===`string`&&`format`in e&&(e.format===`date`||e.format===`date-time`)}async function Gx(e,t,n){let r=Ux(e,t);if(r.isValid)return r;if(Wx(t)&&!Nx(e)){let r=await Mx(e,t.format,n);if(r.success){let e=Ux(r.value,t);if(e.isValid)return e}}return r}l(),Ar(),J(),Yn(),Vd(),ii(),Bp();var Kx=e=>[`string`,`number`,`integer`].includes(e.type),qx=`⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏`,Jx=e=>(e+1)%10;function Yx(e){e.buffer=``,e.timer=void 0}function Xx(){let[e,t]=(0,Q.useState)(0);return(0,Q.useEffect)(()=>{let e=setInterval(t,80,Jx);return()=>clearInterval(e)},[]),(0,$.jsx)(q,{color:`warning`,children:qx[e]})}function Zx(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 Qx({event:e,onResponse:t,onWaitingDismiss:n}){return e.params.mode===`url`?(0,$.jsx)(eS,{event:e,onResponse:t,onWaitingDismiss:n}):(0,$.jsx)($x,{event:e,onResponse:t})}function $x({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,d]=(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(Kx(n)&&n?.default!==void 0){let r=Ux(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&&Kx(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:j}=sl(),M=h===void 0?void 0:m[h],N=M!==void 0&&Kx(M.schema)&&!Px(M.schema)&&!s;lm(`elicitation`),ry(`Work Mate needs your input`,`elicitation_dialog`);let ee=(0,Q.useCallback)(e=>{if(e===void 0){v(``),b(0);return}let t=m[e];if(t&&Kx(t.schema)&&!Px(t.schema)){let e=l[t.name],n=e===void 0?``:String(e);v(n),b(n.length)}},[m,l]);function te(e,t){if(!Fx(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)?I(e,`Select at least ${i} ${zd(i,`item`)}`):a!==void 0&&n.length>a?I(e,`Select at most ${a} ${zd(a,`item`)}`):I(e)}function P(e){M&&Fx(M.schema)?(te(M.name,M.schema),w(void 0)):M&&Px(M.schema)&&w(void 0),N&&M&&(ne(M.name,M.schema,_),D.current!==void 0&&(clearTimeout(D.current),D.current=void 0),Wx(M.schema)&&_.trim()!==``&&f[M.name]&&re(M.name,M.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),ee(r)):(g(void 0),c(r===m.length?`accept`:`decline`),v(``))}function F(e,t){d(n=>{let r={...n};return t===void 0?delete r[e]:r[e]=t,r}),t!==void 0&&f[e]===`This field is required`&&I(e)}function I(e,t){p(n=>{let r={...n};return t?r[e]=t:delete r[e],r})}function L(e){e&&(F(e,void 0),I(e),v(``),b(0))}function ne(e,t,n){let r=n.trim();if(r===``&&(t.type!==`string`||`format`in t&&t.format!==void 0)){L(e);return}if(r===``){l[e]!==void 0&&F(e,``);return}let i=Ux(n,t);F(e,i.isValid?i.value:n),I(e,i.isValid?void 0:i.error)}function re(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)),Gx(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){F(e,t.value),I(e);let r=String(t.value);v(e=>e===n?(b(r.length),r):e)}else I(e,t.error)},()=>{O.current.delete(e),S(t=>{let n=new Set(t);return n.delete(e),n})})}function ie(e){if(v(e),M&&(ne(M.name,M.schema,e),D.current!==void 0&&(clearTimeout(D.current),D.current=void 0),Wx(M.schema)&&e.trim()!==``&&f[M.name])){let t=M.name,n=M.schema;D.current=setTimeout((e,t,n,r,i)=>{e.current=void 0,t(n,r,i)},2e3,D,re,t,n,e)}}function ae(){P(`down`)}function oe(e,t,n){let r=k.current;r.timer!==void 0&&clearTimeout(r.timer),r.buffer+=e.toLowerCase(),r.timer=setTimeout(Yx,2e3,r);let i=t.findIndex(e=>e.startsWith(r.buffer));i!==-1&&n(i)}Vc(`confirm:no`,()=>{if(N&&M){let e=l[M.name];v(e===void 0?``:String(e)),b(0)}t(`cancel`)},{context:`Settings`,isActive:!!M&&!s&&!C}),nl((e,n)=>{if(N&&!n.upArrow&&!n.downArrow&&!n.return&&!n.backspace)return;if(C&&M&&Fx(M.schema)){let t=M.schema,r=Ix(t),i=l[M.name]??[];if(n.leftArrow||n.escape){w(void 0),te(M.name,t);return}if(n.upArrow){T===0?(w(void 0),te(M.name,t)):E(T-1);return}if(n.downArrow){T>=r.length-1?(w(void 0),P(`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;F(M.name,r);let a=t.minItems,o=t.maxItems;a!==void 0&&n.length<a&&(n.length>0||M.isRequired)?I(M.name,`Select at least ${a} ${zd(a,`item`)}`):o!==void 0&&n.length>o?I(M.name,`Select at most ${o} ${zd(o,`item`)}`):I(M.name)}return}if(n.return){let e=r[T];e!==void 0&&!i.includes(e)&&F(M.name,[...i,e]),w(void 0),P(`down`);return}if(e){oe(e,r.map(e=>Rx(t,e).toLowerCase()),E);return}return}if(C&&M&&Px(M.schema)){let t=M.schema,r=zx(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),P(`down`)):E(T+1);return}if(e===` `){let e=r[T];e!==void 0&&F(M.name,e),w(void 0);return}if(n.return){let e=r[T];e!==void 0&&F(M.name,e),w(void 0),P(`down`);return}if(e){oe(e,r.map(e=>Vx(t,e).toLowerCase()),E);return}return}if(n.return&&s===`accept`){if(se()&&Object.keys(f).length===0)t(`accept`,l);else{let e=a.required||[];for(let t of e)l[t]===void 0&&I(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),ee(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),P(n.upArrow?`up`:`down`);return}if(s&&(n.leftArrow||n.rightArrow)){c(s===`accept`?`decline`:`accept`);return}if(!M)return;let{schema:r,name:i}=M,o=l[i];if(r.type===`boolean`){if(e===` `){F(i,o===void 0||!o);return}if(n.return){P(`down`);return}if(n.backspace&&o!==void 0){L(i);return}if(e&&!n.return){oe(e,[`yes`,`no`],e=>F(i,e===0));return}return}if(Px(r)||Fx(r)){if(n.return){P(`down`);return}if(n.backspace&&o!==void 0){L(i);return}let t,a=0;if(Px(r)){let e=zx(r);t=e.map(e=>Vx(r,e).toLowerCase()),o!==void 0&&(a=Math.max(0,e.indexOf(o)))}else t=Ix(r).map(e=>Rx(r,e).toLowerCase());if(n.rightArrow){w(i),E(a);return}if(e&&!n.leftArrow){oe(e,t,e=>{w(i),E(e)});return}return}if(n.backspace&&N&&_===``){L(i);return}},{isActive:!0});function se(){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 ce=Math.max(2,Math.floor((j-14)/3)),le=(0,Q.useMemo)(()=>{let e=m.length;if(e<=ce)return{start:0,end:e};let t=h??e-1,n=Math.max(0,t-Math.floor(ce/2)),r=Math.min(n+ce,e);return n=Math.max(0,r-ce),{start:n,end:r}},[m.length,ce,h]),R=le.start>0,z=le.end<m.length;function ue(){return m.length?(0,$.jsxs)(K,{flexDirection:`column`,children:[R&&(0,$.jsx)(K,{marginLeft:2,children:(0,$.jsxs)(q,{dimColor:!0,children:[u.arrowUp,` `,le.start,` more above`]})}),m.slice(le.start,le.end).map((e,t)=>{let n=le.start+t,{name:r,schema:i,isRequired:a}=e,o=n===h&&!s,c=l[r],d=c!==void 0&&(!Array.isArray(c)||c.length>0),p=f[r],m=x.has(r)?(0,$.jsx)(Xx,{}):p?(0,$.jsx)(q,{color:`error`,children:u.warning}):d?(0,$.jsx)(q,{color:`success`,dimColor:!o,children:u.tick}):a?(0,$.jsx)(q,{color:`error`,children:`*`}):(0,$.jsx)(q,{children:` `}),g=p?`error`:d?`success`:a?`error`:`suggestion`,v=o?g:void 0,S=(0,$.jsx)(q,{color:v,bold:o,children:i.title||r}),w,E=null;if(Fx(i)){let e=Ix(i),t=c??[];if(C===r&&o)w=(0,$.jsx)(q,{dimColor:!0,children:u.triangleDownSmall}),E=(0,$.jsx)(K,{flexDirection:`column`,marginLeft:6,children:e.map((e,n)=>{let r=Rx(i,e),a=t.includes(e),o=n===T;return(0,$.jsxs)(K,{gap:1,children:[(0,$.jsx)(q,{color:`suggestion`,children:o?u.pointer:` `}),(0,$.jsx)(q,{color:a?`success`:void 0,children:a?u.checkboxOn:u.checkboxOff}),(0,$.jsx)(q,{color:o?`suggestion`:void 0,bold:o,children:r})]},e)})});else{let e=o?(0,$.jsxs)(q,{dimColor:!0,children:[u.triangleRightSmall,` `]}):null;w=t.length>0?(0,$.jsxs)(q,{children:[e,(0,$.jsx)(q,{color:v,bold:o,children:t.map(e=>Rx(i,e)).join(`, `)})]}):(0,$.jsxs)(q,{children:[e,(0,$.jsx)(q,{dimColor:!0,italic:!0,children:`not set`})]})}}else if(Px(i)){let e=zx(i);if(C===r&&o)w=(0,$.jsx)(q,{dimColor:!0,children:u.triangleDownSmall}),E=(0,$.jsx)(K,{flexDirection:`column`,marginLeft:6,children:e.map((e,t)=>{let n=Vx(i,e),r=c===e,a=t===T;return(0,$.jsxs)(K,{gap:1,children:[(0,$.jsx)(q,{color:`suggestion`,children:a?u.pointer:` `}),(0,$.jsx)(q,{color:r?`success`:void 0,children:r?u.radioOn:u.radioOff}),(0,$.jsx)(q,{color:a?`suggestion`:void 0,bold:a,children:n})]},e)})});else{let e=o?(0,$.jsxs)(q,{dimColor:!0,children:[u.triangleRightSmall,` `]}):null;w=d?(0,$.jsxs)(q,{children:[e,(0,$.jsx)(q,{color:v,bold:o,children:Vx(i,c)})]}):(0,$.jsxs)(q,{children:[e,(0,$.jsx)(q,{dimColor:!0,italic:!0,children:`not set`})]})}}else if(i.type===`boolean`)w=o?d?(0,$.jsx)(q,{color:v,bold:!0,children:c?u.checkboxOn:u.checkboxOff}):(0,$.jsx)(q,{dimColor:!0,children:u.checkboxOff}):d?(0,$.jsx)(q,{children:c?u.checkboxOn:u.checkboxOff}):(0,$.jsx)(q,{dimColor:!0,italic:!0,children:`not set`});else if(Kx(i))if(o)w=(0,$.jsx)(Gp,{value:_,onChange:ie,onSubmit:ae,placeholder:`Type something…`,columns:Math.min(A-20,60),cursorOffset:y,onChangeCursorOffset:b,focus:!0,showCursor:!0});else{let e=d&&Wx(i)?Zx(String(c),i):String(c);w=d?(0,$.jsx)(q,{children:e}):(0,$.jsx)(q,{dimColor:!0,italic:!0,children:`not set`})}else w=d?(0,$.jsx)(q,{children:String(c)}):(0,$.jsx)(q,{dimColor:!0,italic:!0,children:`not set`});return(0,$.jsxs)(K,{flexDirection:`column`,children:[(0,$.jsxs)(K,{gap:1,children:[(0,$.jsx)(q,{color:g,children:o?u.pointer:` `}),m,(0,$.jsxs)(K,{children:[S,(0,$.jsx)(q,{color:v,children:`: `}),w]})]}),E,i.description&&(0,$.jsx)(K,{marginLeft:6,children:(0,$.jsx)(q,{dimColor:!0,children:i.description})}),(0,$.jsx)(K,{marginLeft:6,height:1,children:p?(0,$.jsx)(q,{color:`error`,italic:!0,children:p}):(0,$.jsx)(q,{children:` `})})]},r)}),z&&(0,$.jsx)(K,{marginLeft:2,children:(0,$.jsxs)(q,{dimColor:!0,children:[u.arrowDown,` `,m.length-le.end,` more below`]})})]}):null}return(0,$.jsx)(ml,{title:`MCP server \u201c${n}\u201d requests your input`,subtitle:`\n${i}`,color:`permission`,onCancel:()=>t(`cancel`),isCancelActive:(!M||!!s)&&!C,inputGuide:e=>e.pending?(0,$.jsxs)(q,{children:[`Press `,e.keyName,` again to exit`]}):(0,$.jsxs)(Rc,{children:[(0,$.jsx)(ka,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),(0,$.jsx)(Oc,{shortcut:`↑↓`,action:`navigate`}),M&&(0,$.jsx)(Oc,{shortcut:`Backspace`,action:`unset`}),M&&M.schema.type===`boolean`&&(0,$.jsx)(Oc,{shortcut:`Space`,action:`toggle`}),M&&Px(M.schema)&&(C?(0,$.jsx)(Oc,{shortcut:`Space`,action:`select`}):(0,$.jsx)(Oc,{shortcut:`→`,action:`expand`})),M&&Fx(M.schema)&&(C?(0,$.jsx)(Oc,{shortcut:`Space`,action:`toggle`}):(0,$.jsx)(Oc,{shortcut:`→`,action:`expand`}))]}),children:(0,$.jsxs)(K,{flexDirection:`column`,children:[ue(),(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{color:`success`,children:s===`accept`?u.pointer:` `}),(0,$.jsx)(q,{bold:s===`accept`,color:s===`accept`?`success`:void 0,dimColor:s!==`accept`,children:` Accept `}),(0,$.jsx)(q,{color:`error`,children:s===`decline`?u.pointer:` `}),(0,$.jsx)(q,{bold:s===`decline`,color:s===`decline`?`error`:void 0,dimColor:s!==`decline`,children:` Decline`})]})]})})}function eS({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`),d=(0,Q.useRef)(`prompt`),[f,p]=(0,Q.useState)(`accept`),m=a?.showCancel??!1;ry(`Work Mate needs your input`,`elicitation_url_dialog`),lm(`elicitation-url`),d.current=c;let h=(0,Q.useRef)(n);h.current=n,(0,Q.useEffect)(()=>{let e=()=>{d.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)(()=>{It(s),t(`accept`),l(`waiting`),d.current=`waiting`,p(`open`)},[t,s]);if(nl((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`?It(s):f===`cancel`?n?.(`cancel`):n?.(m?`retry`:`dismiss`))}}),c===`waiting`){let e=a?.actionLabel??`Continue without waiting`;return(0,$.jsx)(ml,{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)(q,{children:[`Press `,e.keyName,` again to exit`]}):(0,$.jsxs)(Rc,{children:[(0,$.jsx)(ka,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),(0,$.jsx)(Oc,{shortcut:`\\u2190\\u2192`,action:`switch`})]}),children:(0,$.jsxs)(K,{flexDirection:`column`,children:[(0,$.jsx)(K,{marginBottom:1,flexDirection:`column`,children:(0,$.jsxs)(q,{children:[_,(0,$.jsx)(q,{bold:!0,children:g}),v]})}),(0,$.jsx)(K,{marginBottom:1,children:(0,$.jsx)(q,{dimColor:!0,italic:!0,children:`Waiting for the server to confirm completion…`})}),(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{color:`success`,children:f===`open`?u.pointer:` `}),(0,$.jsx)(q,{bold:f===`open`,color:f===`open`?`success`:void 0,dimColor:f!==`open`,children:` Reopen URL `}),(0,$.jsx)(q,{color:`success`,children:f===`action`?u.pointer:` `}),(0,$.jsx)(q,{bold:f===`action`,color:f===`action`?`success`:void 0,dimColor:f!==`action`,children:` ${e}`}),m&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{children:` `}),(0,$.jsx)(q,{color:`error`,children:f===`cancel`?u.pointer:` `}),(0,$.jsx)(q,{bold:f===`cancel`,color:f===`cancel`?`error`:void 0,dimColor:f!==`cancel`,children:` Cancel`})]})]})]})})}return(0,$.jsx)(ml,{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)(q,{children:[`Press `,e.keyName,` again to exit`]}):(0,$.jsxs)(Rc,{children:[(0,$.jsx)(ka,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),(0,$.jsx)(Oc,{shortcut:`\\u2190\\u2192`,action:`switch`})]}),children:(0,$.jsxs)(K,{flexDirection:`column`,children:[(0,$.jsx)(K,{marginBottom:1,flexDirection:`column`,children:(0,$.jsxs)(q,{children:[_,(0,$.jsx)(q,{bold:!0,children:g}),v]})}),(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{color:`success`,children:f===`accept`?u.pointer:` `}),(0,$.jsx)(q,{bold:f===`accept`,color:f===`accept`?`success`:void 0,dimColor:f!==`accept`,children:` Accept `}),(0,$.jsx)(q,{color:`error`,children:f===`decline`?u.pointer:` `}),(0,$.jsx)(q,{bold:f===`decline`,color:f===`decline`?`error`:void 0,dimColor:f!==`decline`,children:` Decline`})]})]})})}J(),Yn(),Om(),Gh();function tS({title:e,toolInputSummary:t,request:n,onRespond:r,onAbort:i}){Vc(`app:interrupt`,i,{isActive:!0});let a=n.options.map(e=>({label:e.label,value:e.key,description:e.description}));return(0,$.jsx)(qh,{title:e,subtitle:n.message,titleRight:t?(0,$.jsx)(q,{dimColor:!0,children:t}):void 0,children:(0,$.jsx)(K,{flexDirection:`column`,paddingY:1,children:(0,$.jsx)(km,{options:a,onChange:e=>{r(e)}})})})}function nS(){return(0,Q.useSyncExternalStore)(I,Ba)}Md(),Ml(),Cn(),kl();var rS=`at_mentioned`,iS=Al(()=>bl({method:Sl(rS),params:bl({filePath:wl(),lineStart:Cl().optional(),lineEnd:Cl().optional()})}));function aS(e,t){let n=(0,Q.useRef)(void 0);(0,Q.useEffect)(()=>{let r=nn(e);n.current!==r&&(n.current=r),r&&r.client.setNotificationHandler(iS(),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){Pd(e)}})},[e,t])}Bh(),Hh(),ug();function oS(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 sS(){let[e,t]=(0,Q.useState)({...Ns});return(0,Q.useEffect)(()=>{let e=e=>{t({...e})};return Uo.add(e),()=>{Uo.delete(e)}},[]),e}J();function cS({ideSelection:e,mcpClients:t}){let{status:n}=oS(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)(q,{color:`ide`,wrap:`truncate`,children:[`⧉ `,e.lineCount,` `,e.lineCount===1?`line`:`lines`,` selected`]},`selection-indicator`);if(e.filePath)return(0,$.jsxs)(q,{color:`ide`,wrap:`truncate`,children:[`⧉ In `,Ag(e.filePath)]},`selection-indicator`)}function lS(){return(0,Q.useSyncExternalStore)(Va.subscribe,Va.getState)}J(),zr();function uS({tokenUsage:e,model:t}){let{percentLeft:n,isAboveWarningThreshold:r,isAboveErrorThreshold:i}=Es(e,t),a=lS();if(!r||a)return null;let o=os(),s=dt(`warning`),c=`${n}% until auto-compact`;return(0,$.jsx)(K,{flexDirection:`row`,children:o?(0,$.jsx)(q,{dimColor:!0,wrap:`truncate`,children:s?`${c} \u00b7 ${s}`:c}):(0,$.jsx)(q,{color:i?`error`:`warning`,wrap:`truncate`,children:s?`Context low (${n}% remaining) \u00b7 ${s}`:`Context low (${n}% remaining) \u00b7 Run /compact to compact & continue`})})}J(),Or();function dS(){let[e,t]=(0,Q.useState)(0),n=(0,Q.useRef)(null),r=Re(`app:toggleTranscript`,`Global`,`ctrl+o`);return(0,Q.useEffect)(()=>{if(!pt.isSandboxingEnabled())return;let e=pt.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)}},[]),!pt.isSandboxingEnabled()||e===0?null:(0,$.jsx)(K,{paddingX:0,paddingY:0,children:(0,$.jsxs)(q,{color:`inactive`,wrap:`truncate`,children:[`⧈ Sandbox blocked `,e,` `,e===1?`operation`:`operations`,` ·`,` `,r,` for details · /sandbox to disable`]})})}Yp(),qd(),V(),J(),Eo(),dh(),$d(),Cn(),Wr(),ii();var fS=5e3;function pS({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)(()=>ss(de(a)),[a]),p=_h(),m=Es(f,p).isAboveWarningThreshold,{status:h}=oS(l),g=U(e=>e.notifications),{addNotification:_,removeNotification:v}=Jp(),y=sS();(0,Q.useEffect)(()=>(ei((e,t)=>{_({key:`env-hook`,text:e,color:t?`error`:void 0,priority:t?`medium`:`low`,timeoutMs:t?8e3:5e3})}),()=>ei(null)),[_]),h===`connected`&&(c?.filePath||c?.text&&c.lineCount);let b=y.isUsingOverage,x=Hf(),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)(q,{dimColor:!0,children:(0,$.jsx)(ka,{action:`chat:externalEditor`,context:`Chat`,fallback:`ctrl+g`,description:`edit in ${Jn(C)}`})}),priority:`immediate`,timeoutMs:5e3})):v(`external-editor-hint`)},[w,C,_,v]),(0,$.jsx)(K,{flexDirection:`column`,alignItems:d?`flex-start`:`flex-end`,flexShrink:0,overflowX:`hidden`,children:(0,$.jsx)(mS,{ideSelection:c,mcpClients:l,notifications:g,isInOverageMode:b??!1,isTeamOrEnterprise:S,apiKeyStatus:e,debug:n,verbose:i,tokenUsage:f,mainLoopModel:p})})}function mS({ideSelection:e,mcpClients:t,notifications:n,isInOverageMode:r,isTeamOrEnterprise:i,apiKeyStatus:o,debug:s,verbose:c,tokenUsage:l,mainLoopModel:u}){let[d,f]=(0,Q.useState)(null);return(0,Q.useEffect)(()=>{if(!Pf())return;let e=setInterval(e=>{let t=Df(),n=t>=1e4?nf(t):null;e(e=>n===e?e:n)},1e3,f);return()=>clearInterval(e)},[]),(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(cS,{ideSelection:e,mcpClients:t}),n.current&&(`jsx`in n.current?(0,$.jsx)(q,{wrap:`truncate`,children:n.current.jsx},n.current.key):(0,$.jsx)(q,{color:n.current.color,dimColor:!n.current.color,wrap:`truncate`,children:n.current.text})),r&&!i&&(0,$.jsx)(K,{children:(0,$.jsx)(q,{dimColor:!0,wrap:`truncate`,children:`Now using extra usage`})}),d&&(0,$.jsxs)(K,{children:[(0,$.jsxs)(q,{color:`warning`,wrap:`truncate`,children:[`apiKeyHelper is taking a while`,` `]}),(0,$.jsxs)(q,{dimColor:!0,wrap:`truncate`,children:[`(`,d,`)`]})]}),(o===`invalid`||o===`missing`)&&(0,$.jsx)(K,{children:(0,$.jsx)(q,{color:`error`,wrap:`truncate`,children:a(process.env.CLAUDE_CODE_REMOTE)?`Authentication error · Try again`:`Not logged in`})}),s&&(0,$.jsx)(K,{children:(0,$.jsx)(q,{color:`warning`,wrap:`truncate`,children:`Debug mode`})}),o!==`invalid`&&o!==`missing`&&c&&(0,$.jsx)(K,{children:(0,$.jsxs)(q,{dimColor:!0,wrap:`truncate`,children:[l,` tokens`]})}),(0,$.jsx)(uS,{tokenUsage:l,model:u}),(0,$.jsx)(dS,{})]})}Yp(),ii(),J();var hS=10,gS=null,_S=0,vS;async function yS(e,t){let n=Math.ceil(e/hS)*hS;if(gS&&_S>=n&&vS===t)return gS;gS&&await gS,_S=n,vS=t,gS=(async()=>{let e=[],n=0;for await(let r of Qp())if(!(t&&qp(r.display)!==t)&&(e.push(r),n++,n>=_S))break;return e})();try{return await gS}finally{gS=null,_S=0,vS=void 0}}function bS(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}=Jp(),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?.display)return;let n=qp(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)(q,{dimColor:!0,children:(0,$.jsx)(ka,{action:`history:search`,context:`Global`,fallback:`ctrl+r`,description:`search history`})}),priority:`immediate`,timeoutMs:fS})},[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 yS(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])}}V();function xS(){let e=U(e=>e.tasks);return(0,Q.useMemo)(()=>{let t=Date.now();return Object.values(e).filter(wa).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])}Dp(),am(),J(),Yn();function SS(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=$p(),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(qp(i)),n(i),l(e.value.pastedContents);let t=jp(i).lastIndexOf(d);r(t===-1?o:t);return}}}},[s,d,O,n,r,a,l,h,_,y,x]),j=(0,Q.useCallback)(()=>{c(!0),g(t),v(i),b(o),S(u),T.current=$p(),E.current.clear()},[c,t,i,o,u]),M=(0,Q.useCallback)(()=>{A(!0)},[A]),N=(0,Q.useCallback)(()=>{if(C){let e=qp(C.display);n(jp(C.display)),a(e),l(C.pastedContents)}else l(x);k()},[C,n,a,l,x,k]),ee=(0,Q.useCallback)(()=>{n(h),r(_),l(x),k()},[n,r,l,h,_,x,k]),te=(0,Q.useCallback)(()=>{if(d.length===0)e({display:h,pastedContents:x});else if(C){let t=qp(C.display),n=jp(C.display);a(t),e({display:n,pastedContents:C.pastedContents})}k()},[d,C,e,a,h,x,k]);Vc(`history:search`,j,{context:`Global`,isActive:!s}),jc((0,Q.useMemo)(()=>({"historySearch:next":M,"historySearch:accept":N,"historySearch:cancel":ee,"historySearch:execute":te}),[M,N,ee,te]),{context:`HistorySearch`,isActive:s});let P=e=>{s&&e.key===`backspace`&&d===``&&(e.preventDefault(),ee())};nl((e,t,n)=>{P(new Bc(n.keypress))},{isActive:s});let F=(0,Q.useRef)(A);return F.current=A,(0,Q.useEffect)(()=>{D.current?.abort();let e=new AbortController;return D.current=e,F.current(!1,e.signal),()=>{e.abort()}},[d]),{historyQuery:d,setHistoryQuery:f,historyMatch:C,historyFailedMatch:p,handleKeyDown:P}}function CS({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}}J(),qd(),V();function wS({inputValue:e,isAssistantResponding:t}){let n=U(e=>e.promptSuggestion),r=N(),i=Hc(),{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)(()=>{Ks(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])}}Ir(),Ou(),xp();var TS=15,ES=1e3,DS=[`|`,`||`,`&&`,`;`];function OS(e){return typeof e==`object`&&!!e&&`op`in e&&DS.includes(e.op)}function kS(e){return e.startsWith(`$`)?`variable`:e.includes(`/`)||e.startsWith(`~`)||e.startsWith(`.`)?`file`:`command`}function AS(e){let t=e.findLastIndex(e=>typeof e==`string`);return t===-1?null:{token:e[t],index:t}}function jS(e,t){if(t===0)return!0;let n=e[t-1];return n!==void 0&&OS(n)}function MS(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=xo(n);if(!i.success){let e=n.split(/\s+/),t=e[e.length-1]||``;return{prefix:t,completionType:e.length===1&&!n.includes(` `)?`command`:kS(t)}}let a=AS(i.tokens);if(!a){let e=i.tokens[i.tokens.length-1];return{prefix:``,completionType:(e&&OS(e),`command`)}}if(n.endsWith(` `))return{prefix:``,completionType:`file`};let o=kS(a.token);if(o===`variable`||o===`file`)return{prefix:a.token,completionType:o};let s=jS(i.tokens,a.index)?`command`:`file`;return{prefix:a.token,completionType:s}}function NS(e,t){return t===`variable`?`compgen -v ${qo([e.slice(1)])} 2>/dev/null`:t===`file`?`compgen -f ${qo([e])} 2>/dev/null | head -${TS} | while IFS= read -r f; do [ -d "$f" ] && echo "$f/" || echo "$f "; done`:`compgen -c ${qo([e])} 2>/dev/null`}function PS(e,t){return t===`variable`?`print -rl -- \${(k)parameters[(I)${qo([e.slice(1)])}*]} 2>/dev/null`:t===`file`?`for f in ${qo([e])}*(N[1,${TS}]); do [[ -d "$f" ]] && echo "$f/" || echo "$f "; done`:`print -rl -- \${(k)commands[(I)${qo([e])}*]} 2>/dev/null`}async function FS(e,t,n,r){let i;if(e===`bash`)i=NS(t,n);else if(e===`zsh`)i=PS(t,n);else return[];return(await(await xs(i,r,`bash`,{timeout:ES})).result).stdout.split(`
36
+ `).filter(e=>e.trim()).slice(0,TS).map(e=>({id:e,displayText:e,description:void 0,metadata:{completionType:n}}))}async function IS(e,t,n){let r=Sp();if(r!==`bash`&&r!==`zsh`)return[];try{let{prefix:i,completionType:a}=MS(e,t);return i?(await FS(r,i,a,n)).map(t=>({...t,metadata:{...t.metadata,inputSnapshot:e}})):[]}catch(e){return Y(`Shell completion failed: ${e}`),[]}}xv();var LS=/[:_-]/g,RS=null;function zS(e){if(RS?.commands===e)return RS.fuse;let t=new bv(e.filter(e=>!e.isHidden).map(e=>{let t=Qe(e),n=t.split(LS).filter(Boolean);return{descriptionKey:(e.description??``).split(` `).map(e=>ZS(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 RS={commands:e,fuse:t},t}function BS(e){return typeof e==`object`&&!!e&&`name`in e&&typeof e.name==`string`&&`type`in e}function VS(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 HS(e,t){if(!e)return null;let n=YS(`/${e}`,t);if(n.length===0)return null;let r=e.toLowerCase();for(let t of n){if(!BS(t.metadata))continue;let n=Qe(t.metadata);if(n.toLowerCase().startsWith(r)){let t=n.slice(e.length);if(t)return{suffix:t,fullCommand:n}}}return null}function US(e){return e.startsWith(`/`)}function WS(e){return!(!US(e)||!e.includes(` `)||e.endsWith(` `))}function GS(e){return`/${e} `}function KS(e){let t=Qe(e);return e.type===`prompt`?e.source===`plugin`&&e.pluginInfo?.repository?`${t}:${e.source}:${e.pluginInfo.repository}`:`${t}:${e.source}`:`${t}:${e.type}`}function qS(e,t){if(!(!t||t.length===0||e===``))return t.find(t=>t.toLowerCase().startsWith(e))}function JS(e,t){let n=Qe(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:ge(e))+(e.type===`prompt`&&e.argNames?.length?` (arguments: ${e.argNames.join(`, `)})`:``);return{id:KS(e),displayText:`/${n}${r}`,tag:i?`workflow`:a,description:o,metadata:e}}function YS(e,t){if(!US(e)||WS(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:Pr(Qe(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=>KS(e))),a=[],o=[],s=[],c=[],l=[];e.forEach(e=>{i.has(KS(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)=>Qe(e).localeCompare(Qe(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=>JS(e))}let r=t.find(e=>e.isHidden&&Qe(e).toLowerCase()===n);r&&t.some(e=>!e.isHidden&&Qe(e).toLowerCase()===n)&&(r=void 0);let i=zS(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`?Pr(Qe(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 JS(t,qS(n,t.aliases))});if(r){let e=KS(r);if(!i.some(t=>t.id===e))return[JS(r),...i]}return i}function XS(e,t,n,r,i,a){let o,s;if(typeof e==`string`)o=e,s=t?Zt(o,n):void 0;else{if(!BS(e.metadata))return;o=Qe(e.metadata),s=e.metadata}let c=GS(o);r(c),i(c.length),t&&s&&(s.type!==`prompt`||(s.argNames??[]).length===0)&&a(c,!0)}function ZS(e){return e.toLowerCase().replace(/[^a-z0-9]/g,``)}function QS(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}ah(),am(),Ou();var $S=null,eC=0,tC=6e4;async function nC(){let e=Date.now();if($S&&e-eC<tC)return $S;let t=[],n=new Set;try{for await(let e of Qp()){if(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){Y(`Failed to read shell history: ${e}`)}return $S=t,eC=e,t}function rC(e){if(!$S)return;let t=$S.indexOf(e);t!==-1&&$S.splice(t,1),$S.unshift(e)}async function iC(e){if(!e||e.length<2||!e.trim())return null;let t=await nC();for(let n of t)if(n.startsWith(e)&&n!==e)return{fullCommand:n,suffix:n.slice(e.length)};return null}ap(),Ou(),kl(),Nl(),ju();var aC=`slack_search_channels`,oC=new Map,sC=new Set,cC=0,lC=ql(),uC=lC.subscribe,dC=null,fC=null;function pC(e){return e.find(e=>e.type===`connected`&&e.name.includes(`slack`))}async function mC(e,t){let n=pC(e);if(n?.type!==`connected`)return[];try{let e=(await n.client.callTool({name:aC,arguments:{query:t,limit:20,channel_types:`public_channel,private_channel`}},void 0,{timeout:5e3})).content;return Array.isArray(e)?_C(gC(e.filter(e=>e.type===`text`).map(e=>e.text).join(`
37
+ `))):[]}catch(e){return Y(`Failed to fetch Slack channels: ${e}`),[]}}var hC=Al(()=>bl({results:wl()}));function gC(e){let t=e.trim();if(!t.startsWith(`{`))return e;try{let e=hC().safeParse(Su(t));if(e.success)return e.data.results}catch{}return e}function _C(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 vC(e){return pC(e)!==void 0}function yC(){return cC}function bC(e){let t=[],n=/(^|\s)#([a-z0-9][a-z0-9_-]{0,79})(?=\s|$)/g,r;for(;(r=n.exec(e))!==null;){if(!sC.has(r[2]))continue;let e=r.index+r[1].length;t.push({start:e,end:e+1+r[2].length})}return t}function xC(e){let t=Math.max(e.lastIndexOf(`-`),e.lastIndexOf(`_`));return t>0?e.slice(0,t):e}function SC(e,t){let n,r=0;for(let[i,a]of oC)e.startsWith(i)&&i.length>r&&a.some(e=>e.startsWith(t))&&(n=a,r=i.length);return n}async function CC(e,t){if(!t)return[];let n=xC(t),r=t.toLowerCase(),i=oC.get(n)??SC(n,r);if(!i)if(dC===n&&fC)i=await fC;else{dC=n,fC=mC(e,n),i=await fC,oC.set(n,i);let t=sC.size;for(let e of i)sC.add(e);sC.size!==t&&(cC++,lC.emit()),oC.size>50&&oC.delete(oC.keys().next().value),dC===n&&(dC=null,fC=null)}return i.filter(e=>e.startsWith(r)).sort().slice(0,10).map(e=>({id:`slack-channel-${e}`,displayText:`#${e}`}))}xv(),yh(),Ys(),$d(),Md();function wC(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 TC=15,EC=60;function DC(e){return Qd(e,EC)}function OC(e,t,n=!1){if(!t&&!n)return[];try{let n=e.map(e=>({type:`agent`,displayText:`${e.agentType} (agent)`,description:DC(e.whenToUse),agentType:e.agentType,color:se(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 Pd(e),[]}}async function kC(e,t,n,r=!1){if(!e&&!r)return[];let[i,a]=await Promise.all([bh(e,r),Promise.resolve(OC(n,e,r))]),o=i.map(e=>({type:`file`,displayText:e.displayText,description:e.description,path:e.displayText,filename:Ag(e.displayText),score:e.metadata?.score})),s=Object.values(t).flat().map(e=>({type:`mcp_resource`,displayText:`${e.server}:${e.uri}`,description:DC(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,TC).map(wC);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 bv(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:TC});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,TC).map(e=>e.source).map(wC)}Yp(),J(),qd(),cn(),Dp(),fm(),ht(),Yn(),fr(),V(),$d(),Gs(),yh();var AC=/^@[\p{L}\p{N}\p{M}_\-./\\()[\]~:]*/u,jC=/^[\p{L}\p{N}\p{M}_\-./\\()[\]~:]+/u,MC=/(@[\p{L}\p{N}\p{M}_\-./\\()[\]~:]*|[\p{L}\p{N}\p{M}_\-./\\()[\]~:]+)$/u,NC=/[\p{L}\p{N}\p{M}_\-./\\()[\]~:]+$/u,PC=/(^|\s)@([\p{L}\p{N}\p{M}_\-./\\()[\]~:]*|"[^"]*"?)$/u,FC=/(^|\s)#([a-z0-9][a-z0-9_-]*)$/;function IC(e){return typeof e==`object`&&!!e&&`type`in e&&(e.type===`directory`||e.type===`file`)}function LC(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 RC(e){let t=e.metadata;return t?.sessionId?`/resume ${t.sessionId}`:`/resume ${e.displayText}`}function zC(e){return e.isQuoted?e.token.slice(2).replace(/"$/,``):e.token.startsWith(`@`)?e.token.substring(1):e.token}function BC(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 VC(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 HC=/(^|\s)@[\w-]*$/;function UC(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 WC=null;async function GC(e,t){try{return WC&&WC.abort(),WC=new AbortController,await IS(e,t,WC.signal)}catch{return X(`tengu_shell_completion_failed`,{}),[]}}function KC(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 qC(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(AC);if(a&&a[0].length===i.length){let r=e.substring(t).match(jC),i=r?r[0]:``;return{token:a[0]+i,startPos:n,isQuoted:!1}}}}let i=n?MC:NC,a=r.match(i);if(!a||a.index===void 0)return null;let o=e.substring(t).match(jC),s=o?o[0]:``;return{token:a[0]+s,startPos:a.index,isQuoted:!1}}function JC(e){if(US(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 YC(e,t){return!e&&t.includes(` `)&&!t.endsWith(` `)}function XC({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}=Jp(),g=Re(`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=Qe(e);return t?t.length:0}))+6},[e]),[b,x]=(0,Q.useState)(void 0),S=U(e=>e.mcp.resources),C=no(),w=U(e=>e.promptSuggestion),T=U(e=>!!e.viewingAgentTaskId),E=Gc(),[D,O]=(0,Q.useState)(void 0),k=(0,Q.useMemo)(()=>{if(o!==`prompt`||f)return;let t=VS(i,a);if(!t)return;let n=HS(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,j=(0,Q.useRef)(a);j.current=a;let M=(0,Q.useRef)(null),N=(0,Q.useRef)(``),ee=(0,Q.useRef)(``),te=(0,Q.useRef)(``),P=(0,Q.useRef)(``),F=(0,Q.useRef)(l);F.current=l;let I=(0,Q.useRef)(null),L=(0,Q.useCallback)(()=>{c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),v(`none`),x(void 0),O(void 0)},[c]),ne=(0,Q.useCallback)(async(e,t=!1)=>{M.current=e;let n=await kC(e,S,s,t);if(M.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:LC(e.suggestions,e.selectedSuggestion,n)})),v(n.length>0?`file`:`none`),x(void 0)}},[S,c,v,x,s]);(0,Q.useEffect)(()=>(Ch(),xh(()=>{let e=M.current;e!==null&&(M.current=null,ne(e,e===``))})),[ne]);let re=hl(ne,50),ie=hl((0,Q.useCallback)(async e=>{P.current=e;let t=await CC(C.getState().mcp.clients,e);P.current===e&&(c(e=>({commandArgumentHint:void 0,suggestions:t,selectedSuggestion:LC(e.suggestions,e.selectedSuggestion,t)})),v(t.length>0?`slack-channel`:`none`),x(void 0))},[c]),150),ae=(0,Q.useCallback)(async(t,n)=>{let r=n??j.current;if(f){re.cancel(),L();return}if(o===`prompt`){let n=VS(t,r);if(n&&HS(n.partialCommand,e)){c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),v(`none`),x(void 0);return}}if(o===`bash`&&t.trim()){te.current=t;let e=await iC(t);if(te.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){re.cancel(),c(e=>({commandArgumentHint:void 0,suggestions:n,selectedSuggestion:LC(e.suggestions,e.selectedSuggestion,n)})),v(`agent`),x(void 0);return}}if(o===`prompt`){let e=t.substring(0,r).match(FC);if(e&&vC(C.getState().mcp.clients)){ie(e[2]);return}else _===`slack-channel`&&(ie.cancel(),L())}let a=t.substring(0,r).match(PC),s=r===t.length&&r>0&&t.length>0&&t[r-1]===` `;if(o===`prompt`&&US(t)&&r>0){let e=JC(t);if(e&&e.commandName===`add-dir`&&e.args){let{args:t}=e;if(t.match(/\s+$/)){re.cancel(),L();return}let n=await oh(t);if(n.length>0){c(e=>({suggestions:n,selectedSuggestion:LC(e.suggestions,e.selectedSuggestion,n),commandArgumentHint:void 0})),v(`directory`);return}re.cancel(),L();return}if(e&&e.commandName===`resume`&&e.args!==void 0&&t.includes(` `)){let{args:t}=e,n=(await Ei(t,{limit:10})).map(e=>{let t=Ri(e);return{id:`resume-title-${t}`,displayText:e.customTitle,description:ef(e),metadata:{sessionId:t}}});if(n.length>0){c(e=>({suggestions:n,selectedSuggestion:LC(e.suggestions,e.selectedSuggestion,n),commandArgumentHint:void 0})),v(`custom-title`);return}L();return}}let l=t.substring(0,r);if(o===`prompt`&&US(l)&&r>0&&!YC(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=Qe(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=wr(l.slice(n+1));t=ct(o.argNames,e)}c(()=>({commandArgumentHint:t,suggestions:[],selectedSuggestion:-1})),v(`none`),x(void 0);return}}}let n=YS(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`?(re.cancel(),L()):US(l)&&YC(s,l)&&c(e=>e.commandArgumentHint?{...e,commandArgumentHint:void 0}:e),_===`custom-title`&&L(),_===`agent`&&F.current.some(e=>e.id?.startsWith(`dm-`))&&(t.substring(0,r).match(/(^|\s)@([\w-]*)$/)||L()),a&&o!==`bash`){let e=qC(t,r,!0);if(e?.token.startsWith(`@`)){let t=zC(e);if(rh(t)){ee.current=t;let e=await ih(t,{maxResults:10});if(ee.current!==t)return;if(e.length>0){c(t=>({suggestions:e,selectedSuggestion:LC(t.suggestions,t.selectedSuggestion,e),commandArgumentHint:void 0})),v(`directory`);return}}if(M.current===t)return;re(t,!0);return}}if(_===`file`){let e=qC(t,r,!0);if(e){let t=zC(e);if(M.current===t)return;re(t,!1)}else re.cancel(),L()}if(_===`shell`){let e=F.current[0]?.metadata?.inputSnapshot;(o!==`bash`||t!==e)&&(re.cancel(),L())}},[_,e,c,L,re,ie,o,f,y]);(0,Q.useEffect)(()=>{I.current!==i&&(N.current!==i&&(N.current=i,M.current=null),I.current=null,ae(i))},[i,ae]);let oe=(0,Q.useCallback)(async()=>{if(A){if(o===`bash`){t(A.fullCommand),r(A.fullCommand.length),O(void 0);return}let e=VS(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){re.cancel(),ie.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=`/${Qe(e)} `;t(n+i.slice(a)),r(n.length)}L()}}else if(_===`custom-title`&&l.length>0){if(n){let e=RC(n);t(e),r(e.length),L()}}else if(_===`directory`&&l.length>0){let n=l[e];if(n){let e=US(i),o;if(e){let e=i.indexOf(` `),a=i.slice(0,e+1),s=IC(n.metadata)&&n.metadata.type===`directory`?`/`:` `;o=a+n.id+s,t(o),r(o.length),IC(n.metadata)&&n.metadata.type===`directory`?(c(e=>({...e,commandArgumentHint:void 0})),ae(o,o.length)):L()}else{let e=qC(i,a,!0)??qC(i,a,!1);if(e){let a=IC(n.metadata)&&n.metadata.type===`directory`,s=KC(i,n.id,e.startPos,e.token.length,a);o=s.newInput,t(o),r(s.cursorPos),a?(c(e=>({...e,commandArgumentHint:void 0})),ae(o,s.cursorPos)):L()}else L()}}}else if(_===`shell`&&l.length>0){let n=l[e];if(n){let e=n.metadata;VC(n,i,a,t,r,e?.completionType),L()}}else if(_===`agent`&&l.length>0&&l[e]?.id?.startsWith(`dm-`)){let n=l[e];n&&(UC(n,i,a,HC,t,r),L())}else if(_===`slack-channel`&&l.length>0){let n=l[e];n&&(UC(n,i,a,FC,t,r),L())}else if(_===`file`&&l.length>0){let n=qC(i,a,!0);if(!n){L();return}let s=Sh(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=BC({displayText:s,mode:o,hasAtPrefix:c,needsQuotes:!1,isQuoted:n.isQuoted,isComplete:!1});wh(e,i,n.token,n.startPos,t,r),ae(i.replace(n.token,e),a)}else if(e<l.length){let a=l[e];if(a){let e=a.displayText.includes(` `);wh(BC({displayText:a.displayText,mode:o,hasAtPrefix:c,needsQuotes:e,isQuoted:n.isQuoted,isComplete:!0}),i,n.token,n.startPos,t,r),L()}}}}else if(i.trim()!==``){let e,n;if(o===`bash`){e=`shell`;let o=await GC(i,a);if(o.length===1){let e=o[0];if(e){let n=e.metadata;VC(e,i,a,t,r,n?.completionType)}n=[]}else n=o}else{e=`file`;let t=qC(i,a,!0);if(t){let e=t.token.startsWith(`@`);n=await kC(e?t.token.substring(1):t.token,S,s,e)}else n=[]}n.length>0&&(c(e=>({commandArgumentHint:void 0,suggestions:n,selectedSuggestion:LC(e.suggestions,e.selectedSuggestion,n)})),v(e),x(void 0))}},[l,u,i,_,e,o,t,r,n,L,a,ae,S,c,s,re,ie,A]),se=(0,Q.useCallback)(()=>{if(u<0||l.length===0)return;let s=l[u];if(_===`command`&&u<l.length)s&&(XS(s,!0,e,t,r,n),re.cancel(),L());else if(_===`custom-title`&&u<l.length){if(s){let e=RC(s);t(e),r(e.length),n(e,!0),re.cancel(),L()}}else if(_===`shell`&&u<l.length){let e=l[u];if(e){let n=e.metadata;VC(e,i,a,t,r,n?.completionType),re.cancel(),L()}}else if(_===`agent`&&u<l.length&&s?.id?.startsWith(`dm-`))UC(s,i,a,HC,t,r),re.cancel(),L();else if(_===`slack-channel`&&u<l.length)s&&(UC(s,i,a,FC,t,r),ie.cancel(),L());else if(_===`file`&&u<l.length){let e=qC(i,a,!0);if(e&&s){let n=e.token.startsWith(`@`),a=s.displayText.includes(` `);wh(BC({displayText:s.displayText,mode:o,hasAtPrefix:n,needsQuotes:a,isQuoted:e.isQuoted,isComplete:!0}),i,e.token,e.startPos,t,r),re.cancel(),L()}}else if(_===`directory`&&u<l.length&&s){if(US(i)){re.cancel(),L();return}let e=qC(i,a,!0)??qC(i,a,!1);if(e){let n=IC(s.metadata)&&s.metadata.type===`directory`,a=KC(i,s.id,e.startPos,e.token.length,n);t(a.newInput),r(a.cursorPos)}re.cancel(),L()}},[l,u,_,e,i,a,o,t,r,n,L,re,ie]),ce=(0,Q.useCallback)(()=>{oe()},[oe]),le=(0,Q.useCallback)(()=>{re.cancel(),ie.cancel(),L(),I.current=i},[re,ie,L,i]),R=(0,Q.useCallback)(()=>{c(e=>({...e,selectedSuggestion:e.selectedSuggestion<=0?l.length-1:e.selectedSuggestion-1}))},[l.length,c]),z=(0,Q.useCallback)(()=>{c(e=>({...e,selectedSuggestion:e.selectedSuggestion>=l.length-1?0:e.selectedSuggestion+1}))},[l.length,c]),ue=(0,Q.useMemo)(()=>({"autocomplete:accept":ce,"autocomplete:dismiss":le,"autocomplete:previous":R,"autocomplete:next":z}),[ce,le,R,z]),B=l.length>0||!!A,de=um();lm(`autocomplete`,B),Uc(`Autocomplete`,B),jc(ue,{context:`Autocomplete`,isActive:B&&!de});function fe(e){let n=qp(e);if(n!==`prompt`&&m){m(n);let i=jp(e);t(i),r(i.length)}else t(e),r(e.length)}let pe=e=>{if(e.key===`right`&&!T){let t=w.text,n=w.shownAt;if(t&&n>0&&i===``){p(),fe(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(),fe(t);return}i.trim()===``&&(e.preventDefault(),h({key:`thinking-toggle-hint`,jsx:(0,$.jsxs)(q,{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(),z();return}if(e.ctrl&&e.key===`p`&&!t){e.preventDefault(),R();return}e.key===`return`&&!e.shift&&!e.meta&&(e.preventDefault(),se())};return nl((e,t,n)=>{let r=new Bc(n.keypress);pe(r),r.didStopImmediatePropagation()&&n.stopImmediatePropagation()}),{suggestions:l,selectedSuggestion:u,suggestionType:_,maxColumnWidth:b,commandArgumentHint:d,inlineGhostText:A,handleKeyDown:pe}}kh();var ZC={"†":`alt+t`,π:`alt+p`,ø:`alt+o`};function QC(e){return e in ZC}pi();function $C(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 ew(e){let t=$C(e);return{nextMode:t,context:C(e.mode,t,e)}}Gm(),J(),fm(),Ar(),J(),hu(),dh(),$d(),Ut(),fm(),am(),Ar(),J(),$d(),Eh(),fm(),yh(),Ar(),J(),hu(),dh(),$d(),yr(),J(),Yn(),ii(),Th();function tw({currentValue:e,onSelect:t,onCancel:n,isMidConversation:r}){let i=Em(),[a,o]=(0,Q.useState)(null),s=[{value:`true`,label:`Enabled`,description:`Work Mate will think before responding`},{value:`false`,label:`Disabled`,description:`Work Mate will respond without extended thinking`}];Vc(`confirm:no`,()=>{a===null?n?.():o(null)},{context:`Confirmation`}),Vc(`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)(pl,{color:`permission`,children:[(0,$.jsxs)(K,{flexDirection:`column`,children:[(0,$.jsxs)(K,{marginBottom:1,flexDirection:`column`,children:[(0,$.jsx)(q,{color:`remember`,bold:!0,children:`Toggle thinking mode`}),(0,$.jsx)(q,{dimColor:!0,children:`Enable or disable thinking for this session.`})]}),a===null?(0,$.jsx)(K,{flexDirection:`column`,marginBottom:1,children:(0,$.jsx)(km,{defaultValue:e?`true`:`false`,defaultFocusValue:e?`true`:`false`,options:s,onChange:c,onCancel:n??(()=>{}),visibleOptionCount:2})}):(0,$.jsxs)(K,{flexDirection:`column`,marginBottom:1,gap:1,children:[(0,$.jsx)(q,{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)(q,{color:`warning`,children:`Do you want to proceed?`})]})]}),(0,$.jsx)(q,{dimColor:!0,italic:!0,children:i.pending?(0,$.jsxs)($.Fragment,{children:[`Press `,i.keyName,` again to exit`]}):a===null?(0,$.jsxs)(Rc,{children:[(0,$.jsx)(Oc,{shortcut:`Enter`,action:`confirm`}),(0,$.jsx)(ka,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`exit`})]}):(0,$.jsxs)(Rc,{children:[(0,$.jsx)(Oc,{shortcut:`Enter`,action:`confirm`}),(0,$.jsx)(ka,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})]})}oa(),gg(),mg();function nw(e,t,n){let r=t;for(let t=0;t<n;t++){let t=rw(e,r);if(t.equals(r))break;r=t}return r}function rw(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 iw(e){return`eE$`.includes(e)}function aw(e){return`jkG`.includes(e)||e===`gg`}var ow={"(":[`(`,`)`],")":[`(`,`)`],b:[`(`,`)`],"[":[`[`,`]`],"]":[`[`,`]`],"{":[`{`,`}`],"}":[`{`,`}`],B:[`{`,`}`],"<":[`<`,`>`],">":[`<`,`>`],'"':[`"`,`"`],"'":[`'`,`'`],"`":["`","`"]};function sw(e,t,n,r){if(n===`w`)return cw(e,t,r,zp);if(n===`W`)return cw(e,t,r,e=>!Hp(e));let i=ow[n];if(i){let[n,a]=i;return n===a?lw(e,t,n,r):uw(e,t,n,a,r)}return null}function cw(e,t,n,r){let i=[];for(let{segment:t,index:n}of Jd().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=>Hp(o(e)),l=e=>r(o(e)),u=e=>Ip(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 lw(e,t,n,r){let i=e.lastIndexOf(`
39
+ `,t-1)+1,a=e.indexOf(`
40
+ `,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 uw(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}}Fp(),Yd(),Vd();function dw(e,t,n,r){let i=nw(t,r.cursor,n);if(i.equals(r.cursor))return;let a=Cw(r.cursor,i,t,e,n);Tw(e,a.from,a.to,r,a.linewise),r.recordChange({type:`operator`,op:e,motion:t,count:n})}function fw(e,t,n,r,i){let a=i.cursor.findCharacter(n,t,r);if(a===null)return;let o=new Rp(i.cursor.measuredText,a),s=ww(i.cursor,o,t);Tw(e,s.from,s.to,i),i.setLastFind(t,n),i.recordChange({type:`operatorFind`,op:e,find:t,char:n,count:r})}function pw(e,t,n,r,i){let a=sw(i.text,i.cursor.offset,n,t===`inner`);a&&(Tw(e,a.start,a.end,i),i.recordChange({type:`operatorTextObj`,op:e,objType:n,scope:t,count:r}))}function mw(e,t,n){let r=n.text,i=r.split(`
41
+ `),a=Hd(r.slice(0,n.cursor.offset),`
42
+ `),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(`
43
+ `,c);c=e===-1?r.length:e+1}let l=r.slice(s,c);if(l.endsWith(`
44
+ `)||(l=`${l}\n`),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]===`
45
+ `&&--e;let i=r.slice(0,e)+r.slice(t);n.setText(i||``);let a=Math.max(0,i.length-(Xd(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(`
46
+ `);n.setText(r),n.enterInsert(s)}n.recordChange({type:`operator`,op:e,motion:e[0],count:t})}function hw(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-(Xd(o).length||1));t.setOffset(Math.min(n,s)),t.recordChange({type:`x`,count:e})}function gw(e,t,n){let r=n.cursor.offset,i=n.text;for(let n=0;n<t&&r<i.length;n++){let t=Zd(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 _w(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=Zd(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 vw(e,t){let n=t.text.split(`
47
+ `),{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(`
48
+ `);t.setText(c),t.setOffset(Sw(s,r)+o),t.recordChange({type:`join`,count:e})}function yw(e,t,n){let r=n.getRegister();if(!r)return;let i=r.endsWith(`
49
+ `),a=i?r.slice(0,-1):r;if(i){let r=n.text.split(`
50
+ `),{line:i}=n.cursor.getPosition(),o=e?i+1:i,s=a.split(`
51
+ `),c=[];for(let e=0;e<t;e++)c.push(...s);let l=[...r.slice(0,o),...c,...r.slice(o)],u=l.join(`
52
+ `);n.setText(u),n.setOffset(Sw(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=Xd(r),c=i+r.length-(s.length||1);n.setText(o),n.setOffset(Math.max(i,c))}}function bw(e,t,n){let r=n.text.split(`
53
+ `),{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(`
54
+ `),s=((r[i]??``).match(/^\s*/)?.[0]??``).length;n.setText(o),n.setOffset(Sw(r,i)+s),n.recordChange({type:`indent`,dir:e,count:t})}function xw(e,t){let n=t.text.split(`
55
+ `),{line:r}=t.cursor.getPosition(),i=e===`below`?r+1:r,a=[...n.slice(0,i),``,...n.slice(i)],o=a.join(`
56
+ `);t.setText(o),t.enterInsert(Sw(a,i)),t.recordChange({type:`openLine`,direction:e})}function Sw(e,t){return e.slice(0,t).join(`
57
+ `).length+ +(t>0)}function Cw(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(aw(n)){s=!0;let t=e.text,n=t.indexOf(`
58
+ `,o);n===-1?(o=t.length,a>0&&t[a-1]===`
59
+ `&&--a):o=n+1}else iw(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 ww(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 Tw(e,t,n,r,i=!1){let a=r.text.slice(t,n);if(i&&!a.endsWith(`
60
+ `)&&(a=`${a}\n`),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-(Xd(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 Ew(e,t,n){let r=t===1?n.cursor.startOfLastLine():n.cursor.goToLine(t);if(r.equals(n.cursor))return;let i=Cw(n.cursor,r,`G`,e,t);Tw(e,i.from,i.to,n,i.linewise),n.recordChange({type:`operator`,op:e,motion:`G`,count:t})}function Dw(e,t,n){let r=t===1?n.cursor.startOfFirstLine():n.cursor.goToLine(t);if(r.equals(n.cursor))return;let i=Cw(n.cursor,r,`gg`,e,t);Tw(e,i.from,i.to,n,i.linewise),n.recordChange({type:`operator`,op:e,motion:`gg`,count:t})}var Ow={d:`delete`,c:`change`,y:`yank`};function kw(e){return e in Ow}var Aw=new Set([`h`,`l`,`j`,`k`,`w`,`b`,`e`,`W`,`B`,`E`,`0`,`^`,`$`]),jw=new Set([`f`,`F`,`t`,`T`]),Mw={i:`inner`,a:`around`};function Nw(e){return e in Mw}var Pw=new Set([`w`,`W`,`"`,`'`,"`",`(`,`)`,`b`,`[`,`]`,`{`,`}`,`B`,`<`,`>`]),Fw=1e4;function Iw(){return{mode:`INSERT`,insertedText:``}}function Lw(){return{lastChange:null,lastFind:null,register:``,registerIsLinewise:!1}}function Rw(e,t,n){switch(e.type){case`idle`:return Vw(t,n);case`count`:return Hw(e,t,n);case`operator`:return Uw(e,t,n);case`operatorCount`:return Ww(e,t,n);case`operatorFind`:return Gw(e,t,n);case`operatorTextObj`:return Kw(e,t,n);case`find`:return qw(e,t,n);case`g`:return Jw(e,t,n);case`operatorG`:return Yw(e,t,n);case`replace`:return Xw(e,t,n);case`indent`:return Zw(e,t,n)}}function zw(e,t,n){return kw(e)?{next:{type:`operator`,op:Ow[e],count:t}}:Aw.has(e)?{execute:()=>{let r=nw(e,n.cursor,t);n.setOffset(r.offset)}}:jw.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:()=>_w(t,n)}:e===`x`?{execute:()=>hw(t,n)}:e===`J`?{execute:()=>vw(t,n)}:e===`p`||e===`P`?{execute:()=>yw(e===`p`,t,n)}:e===`D`?{execute:()=>dw(`delete`,`$`,1,n)}:e===`C`?{execute:()=>dw(`change`,`$`,1,n)}:e===`Y`?{execute:()=>mw(`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:()=>Qw(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:()=>xw(`below`,n)}:e===`O`?{execute:()=>xw(`above`,n)}:null}function Bw(e,t,n,r){return Nw(n)?{next:{type:`operatorTextObj`,op:e,count:t,scope:Mw[n]}}:jw.has(n)?{next:{type:`operatorFind`,op:e,count:t,find:n}}:Aw.has(n)?{execute:()=>dw(e,n,t,r)}:n===`G`?{execute:()=>Ew(e,t,r)}:n===`g`?{next:{type:`operatorG`,op:e,count:t}}:null}function Vw(e,t){return/[1-9]/.test(e)?{next:{type:`count`,digits:e}}:e===`0`?{execute:()=>t.setOffset(t.cursor.startOfLogicalLine().offset)}:zw(e,1,t)||{}}function Hw(e,t,n){if(/[0-9]/.test(t)){let n=e.digits+t;return{next:{type:`count`,digits:String(Math.min(parseInt(n,10),Fw))}}}return zw(t,parseInt(e.digits,10),n)||{next:{type:`idle`}}}function Uw(e,t,n){return t===e.op[0]?{execute:()=>mw(e.op,e.count,n)}:/[0-9]/.test(t)?{next:{type:`operatorCount`,op:e.op,count:e.count,digits:t}}:Bw(e.op,e.count,t,n)||{next:{type:`idle`}}}function Ww(e,t,n){if(/[0-9]/.test(t)){let n=e.digits+t,r=Math.min(parseInt(n,10),Fw);return{next:{...e,digits:String(r)}}}let r=parseInt(e.digits,10),i=e.count*r;return Bw(e.op,i,t,n)||{next:{type:`idle`}}}function Gw(e,t,n){return{execute:()=>fw(e.op,e.find,t,e.count,n)}}function Kw(e,t,n){return Pw.has(t)?{execute:()=>pw(e.op,e.scope,t,e.count,n)}:{next:{type:`idle`}}}function qw(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 Jw(e,t,n){return t===`j`||t===`k`?{execute:()=>{let r=nw(`g${t}`,n.cursor,e.count);n.setOffset(r.offset)}}:t===`g`?e.count>1?{execute:()=>{let t=n.text.split(`
61
+ `),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 Yw(e,t,n){return t===`j`||t===`k`?{execute:()=>dw(e.op,`g${t}`,e.count,n)}:t===`g`?{execute:()=>Dw(e.op,e.count,n)}:{next:{type:`idle`}}}function Xw(e,t,n){return t===``?{next:{type:`idle`}}:{execute:()=>gw(t,e.count,n)}}function Zw(e,t,n){return t===e.dir?{execute:()=>bw(e.dir,e.count,n)}:{next:{type:`idle`}}}function Qw(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)}Fp(),Yd();function $w(e){let t=Q.useRef(Iw()),[n,r]=(0,Q.useState)(`INSERT`),i=Q.useRef(Lw()),a=Pp({...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]!==`
62
+ `&&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=Rp.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`:hw(t.count,r);break;case`replace`:gw(t.char,t.count,r);break;case`toggleCase`:_w(t.count,r);break;case`indent`:bw(t.dir,t.count,r);break;case`join`:vw(t.count,r);break;case`openLine`:xw(t.direction,r);break;case`operator`:dw(t.op,t.motion,t.count,r);break;case`operatorFind`:fw(t.op,t.find,t.char,t.count,r);break;case`operatorTextObj`:pw(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=Rp.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,-(Xd(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=Rw(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}}tl(),J();function eT(e){let[t]=Mc(),n=Hc();kp(n,!!e.onImagePaste);let r=$w({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?Qc.inverse:e=>e,themeText:il(`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)(K,{flexDirection:`column`,children:(0,$.jsx)(Up,{inputState:r,terminalFocus:n,highlights:e.highlights,...e})})}Rn(),Zh(),o();function tT(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 nT(e){return`${e.input_tokens}|${e.cache_creation_input_tokens}|${e.cache_read_input_tokens}`}function rT(e){let t=Rg(`sha256`).update(e).digest(`hex`).slice(0,16);return Lg(i(),`cache-stats`,`${t}.json`)}var iT={version:1,signature:null,lastResetAt:null,lastHitRate:null};function aT(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 oT(e){try{let t=await qg(e,`utf8`),n=JSON.parse(t);return aT(n)?n:{...iT}}catch{return{...iT}}}async function sT(e,t){await Kg(Ig(e),{recursive:!0});let n=`${e}.${process.pid}.tmp`;try{await Yg(n,JSON.stringify(t),`utf8`),await Jg(n,e)}catch{}}var cT={signature:null,lastResetAt:null,lastHitRate:null},lT=null;async function uT(e){lT=e;let t=await oT(rT(e));cT={signature:t.signature,lastResetAt:t.lastResetAt,lastHitRate:t.lastHitRate}}function dT(e){let t=nT(e),n=tT(e);return t!==cT.signature&&(cT={signature:t,lastResetAt:Date.now(),lastHitRate:n},lT!==null&&sT(rT(lT),{version:1,signature:t,lastResetAt:cT.lastResetAt,lastHitRate:n})),{...cT}}function fT(){return{...cT}}J(),$d(),Ar();function pT(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 mT(){return(0,$.jsx)(q,{dimColor:!0,children:` │ `})}function hT({modelName:e,contextUsedPct:t,usedTokens:n,contextWindowSize:r,totalCostUsd:i,rateLimits:a}){let{columns:o}=sl(),[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=`${tf(n)}/${tf(r)}`;return(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{children:u}),(0,$.jsx)(mT,{}),(0,$.jsx)(q,{dimColor:!0,children:`Context `}),(0,$.jsxs)(q,{children:[t,`%`]}),!d&&(0,$.jsxs)(q,{dimColor:!0,children:[` (`,g,`)`]}),f&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(mT,{}),(0,$.jsx)(q,{dimColor:!0,children:`Session `}),(0,$.jsxs)(q,{children:[m,`%`]}),!d&&a.five_hour.resets_at>0&&(0,$.jsxs)(q,{dimColor:!0,children:[` `,pT(a.five_hour.resets_at)]})]}),p&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(mT,{}),(0,$.jsx)(q,{dimColor:!0,children:`Weekly `}),(0,$.jsxs)(q,{children:[h,`%`]}),!d&&a.seven_day.resets_at>0&&(0,$.jsxs)(q,{dimColor:!0,children:[` `,pT(a.seven_day.resets_at)]})]}),i>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(mT,{}),(0,$.jsx)(q,{children:ms(i)})]})]})}var gT=Q.memo(hT);qd(),V(),mu(),Yp(),js(),vh(),z(),J(),ta(),xd(),Af(),hu(),Ou(),Ca(),Wr(),Of(),Gs(),Do(),$d();var _T=3600*1e3;function vT(e){return String(Math.floor(e)).padStart(2,`0`)}function yT(e){if(e<=0)return`exp`;let t=Math.floor(e/6e4),n=Math.floor(e%6e4/1e3);return`${vT(t)}:${vT(n)}`}function bT({messages:e}){let[t,n]=(0,Q.useState)(()=>Date.now()),[r,i]=(0,Q.useState)(!0),a=Ki(e),o=(0,Q.useRef)(null);if(a!==null){let e=nT(a);e!==o.current&&(o.current=e,dT(a))}let{lastResetAt:s,lastHitRate:c}=fT(),l=s===null?null:t-s,u=l===null?null:_T-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,uT(du()))},[]);let h=a===null?c:tT(a);if(h===null&&s===null)return(0,$.jsx)(q,{dimColor:!0,children:` Cache --% --:--`});let g=u===null?`--:--`:yT(u),_=h===null?`--%`:`${h}%`,v;return v=f||d===null?`inactive`:d<20?`success`:d<40?`warning`:`error`,(0,$.jsxs)(q,{children:[(0,$.jsx)(q,{dimColor:!0,children:` Cache `}),(0,$.jsx)(q,{color:h!==null&&h>=50?`success`:`inactive`,children:_}),(0,$.jsxs)(q,{color:v,dimColor:p&&!r,children:[` `,g]})]})}function xT(){return null}function ST(e){return e?.statusLineEnabled===!1?!1:e?.statusLineEnabled===!0||!!e?.statusLine?.command}function CT(e,t,n,r,i,a,o){let s=Wl(),c=yc(),l=Mf({permissionMode:e,mainLoopModel:a,exceeds200kTokens:t}),u=n?.outputStyle||`default`,d=Ki(r),f=Ef(l,ou()),p=Bf(d,f),m=ko(du()),h=Ni(),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{...Mt(),...m&&{session_name:m},model:{id:l,display_name:Cf(l)},workspace:{current_dir:gu(),project_dir:nu(),added_dirs:i},version:`0.0.22`,output_style:{name:u},cost:{total_cost_usd:pu(),total_duration_ms:Yl(),total_api_duration_ms:iu(),total_lines_added:fu(),total_lines_removed:Xl()},context_window:{total_input_tokens:Rl(),total_output_tokens:Bl(),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},...Jh()&&{vim:{mode:o??`INSERT`}},...s&&{agent:{name:s}},...c&&{worktree:{name:c.worktreeName,path:c.worktreePath,branch:c.worktreeBranch,original_cwd:c.originalCwd,original_branch:c.originalBranch}}}}function wT(e){return ye(e)?.uuid??null}function TT({messagesRef:e,lastAssistantMessageId:t,vimMode:n}){let r=(0,Q.useRef)(void 0),i=U(e=>e.toolPermissionContext.mode),a=U(e=>e.toolPermissionContext.additionalWorkingDirectories),o=U(e=>e.statusLineText),s=N(),c=Qs(),{addNotification:l}=Jp(),u=_h(),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=wT(n);r!==g.current.messageId&&(e=gn(n),g.current.messageId=r,g.current.exceeds200kTokens=e);let a=await Dr(CT(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&&Y(`Status line is configured but disableAllHooks is true`,{level:`warn`}),Sd()||(l({key:`statusline-trust-blocked`,text:`statusline skipped · restart to fix`,color:`warning`,priority:`low`}),Y(`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,w=Mf({permissionMode:i,mainLoopModel:u,exceeds200kTokens:g.current.exceeds200kTokens}),T=Ef(w,ou()),E=Ki(e.current),D=E?E.input_tokens+E.cache_creation_input_tokens+E.cache_read_input_tokens:0,O=E?Math.round(Bf(E,T).used??0):0,k=Ni(),A={...k.five_hour&&{five_hour:{utilization:k.five_hour.utilization,resets_at:k.five_hour.resets_at}},...k.seven_day&&{seven_day:{utilization:k.seven_day.utilization,resets_at:k.seven_day.resets_at}}},j=c?.statusLineEnabled===!0,M=!!c?.statusLine?.command;return(0,$.jsxs)(K,{flexDirection:`column`,paddingX:C,children:[j&&(0,$.jsxs)(K,{gap:2,children:[(0,$.jsx)(gT,{modelName:Cf(w),contextUsedPct:O,usedTokens:D,contextWindowSize:T,totalCostUsd:pu(),rateLimits:A}),(0,$.jsx)(xT,{}),(0,$.jsx)(bT,{messages:e.current})]}),o?(0,$.jsx)(q,{dimColor:!0,wrap:`truncate`,children:(0,$.jsx)(kc,{children:o})}):M&&yi()?(0,$.jsx)(q,{children:` `}):null]})}var ET=(0,Q.memo)(TT);l(),V(),Ls(),J();function DT({tasksSelected:e,onOpenDialog:t}){let n=U(e=>e.tasks),r=(0,Q.useMemo)(()=>Object.values(n??{}).filter(e=>Ko(e)),[n]);return pg(n??{},!1)||r.length===0?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(OT,{selected:e,onClick:t,children:uo(r)}),zi(r)&&(0,$.jsxs)(q,{dimColor:!0,children:[` · `,u.arrowDown,` to view`]})]})}function OT({selected:e,onClick:t,children:n}){let[r,i]=(0,Q.useState)(!1),a=(0,$.jsx)(q,{color:`background`,inverse:e||r,children:n});return t?(0,$.jsx)(K,{onClick:t,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:a}):a}J(),Bp();function kT({value:e,onChange:t,historyFailedMatch:n}){return(0,$.jsxs)(K,{gap:1,children:[(0,$.jsx)(q,{dimColor:!0,children:n?`no matching prompt:`:`search prompts:`}),(0,$.jsx)(Gp,{value:e,onChange:t,cursorOffset:e.length,onChangeCursorOffset:()=>{},columns:Ac(e)+1,focus:!0,showCursor:!0,multiline:!1,dimColor:!0})]})}wd(),ju();var AT=5e3;function jT(e,t){if(e)return`draft`;switch(t){case`APPROVED`:return`approved`;case`CHANGES_REQUESTED`:return`changes_requested`;default:return`pending`}}async function MT(){if(!await qu())return null;let[e,t]=await Promise.all([Lu(),Vu()]);if(e===t)return null;let{stdout:n,code:r}=await Td(`gh`,[`pr`,`view`,`--json`,`number,url,reviewDecision,isDraft,headRefName,state`],{timeout:AT,preserveOutputOnError:!1});if(r!==0||!n.trim())return null;try{let e=Su(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:jT(e.isDraft,e.reviewDecision)}}catch{return null}}mu();var NT=6e4,PT=4e3,FT=60*6e4,IT={number:null,url:null,reviewState:null,lastUpdated:0};function LT(e,t=!0){let[n,r]=(0,Q.useState)(IT),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=Zl();if(n!==t)n=t,s=Date.now();else if(Date.now()-s>=FT)return;let l=Date.now(),u=await MT();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>PT){a.current=!0;return}e||(i.current=setTimeout(c,NT))}}let l=Date.now()-o.current;return l>=NT?c():i.current=setTimeout(c,NT-l),()=>{e=!0,i.current&&(clearTimeout(i.current),i.current=null)}},[e,t]),n}J(),Zh(),fr(),ld(),oa(),Uu(),gg(),V(),Ar(),$d(),gc(),Of(),sp(),xd(),Kd(),ga();var RT=()=>null,zT=5e3,BT=1e3;function VT(){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=rf(e*1024*1024);t(e=>e?.text===r?e:{text:r,level:n})}e();let n=setInterval(e,zT);return()=>clearInterval(n)},[]),e}function HT(){let e=(0,Q.useSyncExternalStore)(Ie,tc,RT),[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)(q,{dimColor:!0,children:[`waiting `,nf(t*1e3,{mostSignificantOnly:!0})]})}function UT(){let[t,n]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{let e=setInterval(()=>n(e=>e+1),BT);return()=>clearInterval(e)},[]);let r=(No(),e(ja)),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)(q,{color:d,children:[`goal (`,u,`)`]})}function WT({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)(q,{dimColor:!0,children:[`Press `,e.key,` again to exit`]},`exit-message`);if(c)return(0,$.jsx)(q,{dimColor:!0,children:`Pasting text…`},`pasting-message`);let m=Jh()&&t===`INSERT`&&!l;return(0,$.jsxs)(K,{justifyContent:`flex-start`,gap:1,children:[l&&(0,$.jsx)(kT,{value:u,onChange:d,historyFailedMatch:f}),m?(0,$.jsx)(q,{dimColor:!0,children:`-- INSERT --`},`vim-insert`):null,(0,$.jsx)(GT,{mode:n,toolPermissionContext:r,showHint:!i&&!m,isLoading:a,tasksSelected:o,tmuxSelected:s,onOpenTasksDialog:p})]})}function GT({mode:t,toolPermissionContext:n,showHint:r,isLoading:i,tasksSelected:a,tmuxSelected:o,onOpenTasksDialog:s}){let{columns:c}=sl(),l=Re(`chat:cycleMode`,`Chat`,`shift+tab`),u=U(e=>e.tasks);no();let d=LT(i,qT()),f=(0,Q.useSyncExternalStore)(Ie,tc,RT),p=Zc(),m=ol().getState,h=f!==null,g=(0,Q.useMemo)(()=>fd(Object.values(u),e=>Ko(e)),[u]),_=zm(),v=_!==void 0&&_.length>0,y=Re(`chat:cancel`,`Chat`,`esc`).toLowerCase(),b=Re(`app:toggleTodos`,`Global`,`ctrl+t`),x=Re(`chat:killAgents`,`Chat`,`ctrl+x ctrl+k`),S=U(e=>e.notifications.current?.key===`kill-agents-confirm`),C=VT(),w=(0,Q.useMemo)(()=>Cf(Lf()),[U(e=>e.mainLoopModel)]),T=op();if(t===`bash`)return(0,$.jsx)(q,{color:`bashBorder`,children:`! for bash mode`});let E=n?.mode,D=!Gu(E),O=g>0,k=+!!D+ +!!O,A=qT()&&d.number!==null&&d.reviewState!==null&&d.url!==null&&k<2&&(k===0||c>=80),j=k<2,M=E&&D?(0,$.jsxs)(q,{color:Pu(E),children:[Hu(E),` `,Wu(E).toLowerCase(),` on`,j&&(0,$.jsxs)(q,{dimColor:!0,children:[` `,(0,$.jsx)(Oc,{shortcut:l,action:`cycle`,parens:!0})]})]},`mode`):null,N=[...A?[(0,$.jsx)(Ta,{number:d.number,url:d.url,reviewState:d.reviewState},`pr-status`)]:[],...C?[(0,$.jsxs)(q,{dimColor:C.level===`normal`,color:C.level===`error`?`error`:C.level===`warning`?`warning`:void 0,children:[C.text,` · pid:`,process.pid,` · `,w,T?` · ${T}`:``]},`rss`)]:[],...(No(),e(ja)).getGoal()?[(0,$.jsx)(UT,{},`goal-elapsed`)]:[]],ee=Object.values(u).some(e=>e.type===`local_agent`&&e.status===`running`),te=r?KT(i,y,b,x,v,ee,S):[];h?N.push((0,$.jsx)(HT,{},`proactive`)):r&&N.push(...te);let P=O&&!pg(u,!1)?(0,$.jsx)(DT,{tasksSelected:a,onOpenDialog:s}):null;N.length===0&&!P&&!M&&r&&N.push((0,$.jsx)(q,{dimColor:!0,children:`? for shortcuts`},`shortcuts-hint`));let F=yd().copyOnSelect??!0,I=p&&(!F||rl());if(yi()&&I){let e=Gd()===`macos`,t=e&&(m()?.lastPressHadAlt??!1);N.push((0,$.jsx)(q,{dimColor:!0,children:(0,$.jsxs)(Rc,{children:[!F&&(0,$.jsx)(Oc,{shortcut:`ctrl+c`,action:`copy`}),rl()&&(t?(0,$.jsx)(q,{children:`set macOptionClickForcesSelection in VS Code settings`}):(0,$.jsx)(Oc,{shortcut:e?`option+click`:`shift+click`,action:`native select`}))]})},`selection-copy`))}return P&&r&&N.push((0,$.jsx)(q,{dimColor:!0,children:a?(0,$.jsx)(Oc,{shortcut:`Enter`,action:`view tasks`}):(0,$.jsx)(Oc,{shortcut:`↓`,action:`manage`})},`manage-tasks`)),N.length===0&&!P&&!M?yi()?(0,$.jsx)(q,{children:` `}):null:(0,$.jsxs)(K,{height:1,overflow:`hidden`,children:[M&&(0,$.jsxs)(K,{flexShrink:0,children:[M,(P||N.length>0)&&(0,$.jsx)(q,{dimColor:!0,children:` · `})]}),P&&(0,$.jsxs)(K,{flexShrink:0,children:[P,N.length>0&&(0,$.jsx)(q,{dimColor:!0,children:` · `})]}),N.length>0&&(0,$.jsx)(q,{wrap:`truncate`,children:(0,$.jsx)(Rc,{children:N})})]})}function KT(e,t,n,r,i,a,o){let s=i;return[...e?[(0,$.jsx)(q,{dimColor:!0,children:(0,$.jsx)(Oc,{shortcut:t,action:`interrupt`})},`esc`)]:[],...!e&&a&&!o?[(0,$.jsx)(q,{dimColor:!0,children:(0,$.jsx)(Oc,{shortcut:r,action:`stop agents`})},`kill-agents`)]:[],...s?[(0,$.jsx)(q,{dimColor:!0,children:(0,$.jsx)(Oc,{shortcut:n,action:`show tasks`})},`toggle-tasks`)]:[]]}function qT(){return yd().prStatusFooterEnabled??!0}z(),Ar(),J(),gc(),sh(),Xh();function JT({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:_,tmuxSelected:v,ideSelection:y,mcpClients:b,isPasting:x=!1,isInputWrapped:S=!1,messages:C,isSearching:w,historyQuery:T,setHistoryQuery:E,historyFailedMatch:D,onOpenTasksDialog:O}){let k=Qs(),{columns:A,rows:j}=sl(),M=(0,Q.useRef)(C);M.current=C;let N=(0,Q.useMemo)(()=>wT(C),[C]),ee=A<80,te=yi(),P=te&&j<24,F=_,I=h||ST(k)||w;return ig((0,Q.useMemo)(()=>te&&u.length?{suggestions:u,selectedSuggestion:d,maxColumnWidth:f}:null,[te,u,d,f])),u.length&&!te?(0,$.jsx)(K,{paddingX:2,paddingY:0,children:(0,$.jsx)(ch,{suggestions:u,selectedSuggestion:d,maxColumnWidth:f})}):m?(0,$.jsx)(Qh,{dimColor:!0,fixedWidth:!0,paddingX:2}):(0,$.jsxs)(K,{flexDirection:ee?`column`:`row`,justifyContent:ee?`flex-start`:`space-between`,paddingX:2,gap:+!ee,children:[(0,$.jsxs)(K,{flexDirection:`column`,flexShrink:+!ee,children:[i===`prompt`&&!P&&!n.show&&!x&&ST(k)&&(0,$.jsx)(ET,{messagesRef:M,lastAssistantMessageId:N,vimMode:r}),(0,$.jsx)(XT,{}),(0,$.jsx)(WT,{exitMessage:n,vimMode:r,mode:i,toolPermissionContext:p,suppressHint:I,isLoading:g,tasksSelected:F,tmuxSelected:v,isPasting:x,isSearching:w,historyQuery:T,setHistoryQuery:E,historyFailedMatch:D,onOpenTasksDialog:O})]}),(0,$.jsx)(K,{flexShrink:1,gap:1,children:te?null:(0,$.jsx)(pS,{apiKeyStatus:e,autoUpdaterResult:a,debug:t,isAutoUpdating:o,verbose:s,messages:C,onAutoUpdaterResult:c,onChangeIsUpdating:l,ideSelection:y,mcpClients:b,isInputWrapped:S,isNarrow:ee})})]})}var YT=(0,Q.memo)(JT);function XT(){return null}l(),J();function ZT({isLoading:e}){return(0,$.jsxs)(q,{dimColor:e,children:[u.pointer,`\xA0`]})}function QT({mode:e,isLoading:t}){return(0,$.jsx)(K,{alignItems:`flex-start`,alignSelf:`flex-start`,flexWrap:`nowrap`,justifyContent:`flex-start`,children:e===`bash`?(0,$.jsx)(q,{color:`bashBorder`,dimColor:t,children:`!\xA0`}):(0,$.jsx)(ZT,{isLoading:t})})}J();var $T=Q.createContext(void 0),eE=2;function tE({isFirst:e,children:t}){let n=eE,r=Q.useMemo(()=>({isQueued:!0,isFirst:e,paddingWidth:n*2}),[e,n]);return(0,$.jsx)($T.Provider,{value:r,children:(0,$.jsx)(K,{paddingX:n,children:t})})}J(),V(),sn(),Wr(),ju(),Ai();var nE=new Set;function rE(e){try{return Su(e)?.type===`idle_notification`}catch{return!1}}var iE=3;function aE(e){return`<${Ed}>
63
+ <${Ad}>+${e} more tasks completed</${Ad}>
64
+ <${kd}>completed</${kd}>
65
+ </${Ed}>`}function oE(e){let t=e.filter(e=>typeof e.value!=`string`||!rE(e.value)),n=t.filter(e=>e.mode===`task-notification`),r=t.filter(e=>e.mode!==`task-notification`);if(n.length<=iE)return[...r,...n];let i=n.slice(0,iE-1),a={value:aE(n.length-(iE-1)),mode:`task-notification`};return[...r,...i,a]}function sE(){let e=nS(),t=U(e=>!!e.viewingAgentTaskId),n=(0,Q.useMemo)(()=>{if(e.length===0)return null;let t=e.filter(Ze);return t.length===0?null:$i(oE(t).map(e=>{let t=e.value;return e.mode===`bash`&&typeof t==`string`&&(t=`<bash-input>${t}</bash-input>`),He({content:t})}))},[e]);return t||n===null?null:(0,$.jsx)(K,{marginTop:1,flexDirection:`column`,children:n.map((e,t)=>(0,$.jsx)(tE,{isFirst:t===0,children:(0,$.jsx)(Ro,{message:e,lookups:Wi,addMargin:!1,tools:[],commands:[],verbose:!1,inProgressToolUseIDs:nE,progressMessagesForMessage:[],shouldAnimate:!1,shouldShowDot:!1,isTranscriptMode:!1,isStatic:!0})},t))})}var cE=Q.memo(sE);Fe(),l(),J();function lE({hasStash:e}){return e?(0,$.jsx)(K,{paddingLeft:2,children:(0,$.jsxs)(q,{dimColor:!0,children:[u.pointerSmall,` Stashed (auto-restores after submit)`]})}):null}am();var uE=1e4,dE=1e3;function fE(e,t){if(e.length<=uE)return{truncatedText:e,placeholderContent:``};let n=Math.floor(dE/2),r=e.slice(0,n),i=e.slice(-500),a=e.slice(n,-500);return{truncatedText:r+pE(t,rm(a))+i,placeholderContent:a}}function pE(e,t){return`[...Truncated text #${e} +${t} lines...]`}function mE(e,t){let n=Object.keys(t).map(Number),r=n.length>0?Math.max(...n)+1:1,{truncatedText:i,placeholderContent:a}=fE(e,r);return a?{newInput:i,newPastedContents:{...t,[r]:{id:r,type:`text`,content:a}}}:{newInput:e,newPastedContents:t}}function hE({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}=mE(e,t);n(s),r(s.length),i(c),o(!0)},[e,a,t,n,i,r]),(0,Q.useEffect)(()=>{e===``&&o(!1)},[e])}V(),xd(),sn(),Gn();var gE=3;function _E({input:e,submitCount:t}){let n=nS(),r=U(e=>e.promptSuggestionEnabled);return(0,Q.useMemo)(()=>{if(e===``){if(n.some(Me)&&(yd().queuedCommandUpHintCount||0)<gE)return`Press up to edit queued messages`;if(t<1&&r&&!ve())return bg()}},[e,n,t,r])}var vE=5e3,yE=!1;function bE(e){let[t,n]=(0,Q.useState)(!1);return(0,Q.useEffect)(()=>{if(yE||!e)return;yE=!0,n(!0);let t=setTimeout(n,vE,!1);return()=>{clearTimeout(t),n(!1)}},[e]),t}tl(),Yp(),qd(),V(),hu(),sn(),Nc(),cn(),fm(),ug(),am(),vh(),Ar(),J(),ht(),rt(),Yn(),bi(),Uu(),Fp(),xd(),Ou(),pd(),bu(),gc(),Wa(),Md(),Of(),Kd(),hh(),ii(),Bp(),gg(),Dp(),Zh();var xE=5,SE=3;function CE({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:M,onDismissSideQuestion:te,isSideQuestionVisible:P,helpOpen:F,setHelpOpen:I,hasSuppressedDialogs:L,isLocalJSXCommandActive:ne=!1,insertTextRef:re}){let ie=_h(),ae=um()||ne,[oe,se]=(0,Q.useState)(!1),[ce,le]=(0,Q.useState)({show:!1}),[R,z]=(0,Q.useState)(f.length),ue=Q.useRef(f);f!==ue.current&&(z(f.length),ue.current=f);let B=Q.useCallback(e=>{ue.current=e,p(e)},[p]);re&&(re.current={cursorOffset:R,insert:e=>{let t=R===f.length&&f.length>0&&!/\s$/.test(f)?` ${e}`:e,n=f.slice(0,R)+t+f.slice(R);ue.current=n,p(n),z(R+t.length)},setInputWithCursor:(e,t)=>{ue.current=e,p(e),z(t)}});let de=no(),fe=N(),pe=U(e=>e.tasks),me=nS(),he=U(e=>e.promptSuggestion),ge=U(e=>e.speculation),V=U(e=>e.speculationSessionTimeSavedMs),ve=U(e=>e.mainLoopModel),ye=U(e=>e.mainLoopModelForSession),be=U(e=>e.thinkingEnabled),xe=U(e=>df()?e.fastMode:!1),Se=U(e=>e.viewingAgentTaskId);U(e=>e.viewSelectionMode);let{historyQuery:Ce,setHistoryQuery:we,historyMatch:Te,historyFailedMatch:Ee}=SS(e=>{C(e.pastedContents),Gt(e.display)},f,B,z,R,h,m,j,M,C,S),De=(0,Q.useRef)(-1);De.current===-1&&(De.current=wE(l));let Oe=(0,Q.useRef)(!1),ke=U(e=>e.selectedBgAgentIndex),Ae=(0,Q.useCallback)(e=>fe(t=>{let n=typeof e==`function`?e(t.selectedBgAgentIndex):e;return n===t.selectedBgAgentIndex?t:{...t,selectedBgAgentIndex:n}}),[fe]),[je,Ne]=(0,Q.useState)(!1),[Pe,Fe]=(0,Q.useState)(!1),[Ie,Le]=(0,Q.useState)(!1),[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=(0,Q.useMemo)(()=>{let e=f.indexOf(`
66
+ `);return e===-1||R<=e},[f,R]),Ye=(0,Q.useMemo)(()=>{let e=f.lastIndexOf(`
67
+ `);return e===-1||R>e},[f,R]),Xe=(0,Q.useMemo)(()=>fd(Object.values(pe),e=>e.status===`running`),[pe])>0&&!pg(pe,!1),Ze=xS(),Qe=Ze.length>0,$e=(0,Q.useMemo)(()=>[Qe&&`bg_agent`,Xe&&`tasks`].filter(Boolean),[Qe,Xe]),et=U(e=>e.footerSelection),nt=et&&$e.includes(et)?et:null;(0,Q.useEffect)(()=>{et&&!nt&&fe(e=>e.footerSelection===null?e:{...e,footerSelection:null})},[et,nt,fe]);let rt=nt===`tasks`,it=nt===`tmux`,at=nt===`bg_agent`;function ot(e){fe(t=>t.footerSelection===e?t:{...t,footerSelection:e}),e===`bg_agent`&&Ae(-1)}function st(e,t=!1){let n=nt?$e.indexOf(nt):-1,r=$e[n+e];return r?(ot(r),!0):e<0&&t?(ot(null),!0):!1}let{suggestion:ct,markAccepted:lt,logOutcomeAtSubmission:ut,markShown:dt}=wS({inputValue:f,isAssistantResponding:s}),ft=(0,Q.useMemo)(()=>j&&Te?jp(typeof Te==`string`?Te:Te.display):f,[j,Te,f]),pt=(0,Q.useMemo)(()=>tt(ft),[ft]),mt=(0,Q.useMemo)(()=>Km(ft),[ft]),ht=(0,Q.useMemo)(()=>QS(ft).filter(e=>Ht(ft.slice(e.start+1,e.end),a)),[ft,a]),gt=(0,Q.useMemo)(()=>[],[ft]),_t=(0,Q.useMemo)(()=>vC(de.getState().mcp.clients)?bC(ft):[],[ft,(0,Q.useSyncExternalStore)(uC,yC)]),vt=(0,Q.useMemo)(()=>tm(ft).filter(e=>e.match.startsWith(`[Image`)).map(e=>({start:e.index,end:e.index+e.match.length})),[ft]),yt=vt.some(e=>e.start===R);(0,Q.useEffect)(()=>{let e=vt.find(e=>R>e.start&&R<e.end);if(e){let t=(e.start+e.end)/2;z(R<t?e.start:e.end)}},[R,vt,z]);let bt=(0,Q.useMemo)(()=>{let e=[];for(let t of vt)R===t.start&&e.push({start:t.start,end:t.end,color:void 0,inverse:!0,priority:8});j&&Te&&!Ee&&e.push({start:R,end:R+Ce.length,color:`warning`,priority:20});for(let t of mt)e.push({start:t.start,end:t.end,color:`warning`,priority:15});for(let t of ht)e.push({start:t.start,end:t.end,color:`suggestion`,priority:5});for(let t of gt)e.push({start:t.start,end:t.end,color:`suggestion`,priority:5});for(let t of _t)e.push({start:t.start,end:t.end,color:`suggestion`,priority:5});if(Ec())for(let t of pt)for(let n=t.start;n<t.end;n++)e.push({start:n,end:n+1,color:Et(n-t.start),shimmerColor:Et(n-t.start,!0),priority:10});return e},[j,Ce,Te,Ee,R,mt,vt,ht,gt,_t,ft,pt]),{addNotification:xt,removeNotification:St}=Jp();(0,Q.useEffect)(()=>{pt.length&&Ec()?xt({key:`ultrathink-active`,text:`Ultrathink active for this turn`,priority:`immediate`,timeoutMs:5e3}):St(`ultrathink-active`)},[xt,St,pt.length]);let Ct=(0,Q.useRef)(f.length),wt=(0,Q.useRef)(f.length),Tt=(0,Q.useCallback)(()=>{St(`stash-hint`)},[St]);(0,Q.useEffect)(()=>{let e=Ct.current,t=wt.current,n=f.length;if(Ct.current=n,n>t){wt.current=n;return}if(n===0){wt.current=0;return}t>=20&&n<=5&&!(e>=20&&n<=5)&&(yd().hasUsedStash||xt({key:`stash-hint`,jsx:(0,$.jsxs)(q,{dimColor:!0,children:[`Tip: `,(0,$.jsx)(ka,{action:`chat:stash`,context:`Chat`,fallback:`ctrl+s`,description:`stash`})]}),priority:`immediate`,timeoutMs:fS}),wt.current=n)},[f.length,xt]);let{pushToBuffer:Dt,undo:Ot,canUndo:kt,clearBuffer:At}=CS({maxBufferSize:50,debounceMs:1e3});hE({input:f,pastedContents:S,onInputChange:B,setCursorOffset:z,setPastedContents:C});let jt=_E({input:f,submitCount:v}),Mt=(0,Q.useCallback)(e=>{if(e===`?`){X(`tengu_help_toggled`,{}),I(e=>!e);return}I(!1),Tt(),ee(),Ks(fe);let t=e.length===f.length+1,n=R===0,r=qp(e);if(n&&r!==`prompt`){if(t){h(r);return}if(f.length===0){h(r);let t=jp(e).replaceAll(` `,` `);Dt(f,R,S),B(t),z(t.length);return}}let i=e.replaceAll(` `,` `);f!==i&&Dt(f,R,S),fe(e=>e.footerSelection===null?e:{...e,footerSelection:null}),B(i)},[B,h,f,R,Dt,S,Tt,fe]),{resetHistory:Pt,onHistoryUp:Ft,onHistoryDown:It,dismissSearchHint:Lt,historyIndex:Rt}=bS((e,t,n)=>{Mt(e),h(t),C(n)},f,S,z,m);(0,Q.useEffect)(()=>{j&&Lt()},[j,Lt]);function zt(){if(!(Kt.length>1)&&Je){if(me.some(Me)){rn();return}Ft()}}function Bt(){if(!(Kt.length>1)&&Ye&&It()&&$e.length>0){let e=$e[0];ot(e),e===`tasks`&&!yd().hasSeenTasksHint&&Cd(e=>e.hasSeenTasksHint?e:{...e,hasSeenTasksHint:!0})}}let[Vt,Ut]=(0,Q.useState)({suggestions:[],selectedSuggestion:-1,commandArgumentHint:void 0}),H=(0,Q.useCallback)(e=>{Ut(t=>typeof e==`function`?e(t):e)},[]),Gt=(0,Q.useCallback)(async(e,t=!1)=>{e=e.trimEnd();let n=de.getState();if(n.footerSelection&&$e.includes(n.footerSelection)||n.viewSelectionMode===`selecting-agent`)return;let r=Object.values(S).some(e=>e.type===`image`),i=he.text;if((e.trim()===``||e===i)&&i&&!r&&!n.viewingAgentTaskId){if(ge.status===`active`){lt(),ut(i,{skipReset:!0}),A(i,{setCursorOffset:z,clearBuffer:At,resetHistory:Pt},{state:ge,speculationSessionTimeSavedMs:V,setAppState:fe});return}he.shownAt>0&&(lt(),e=i)}if(e.trim()===``&&!r)return;let a=Vt.suggestions.length>0&&Vt.suggestions.every(e=>e.description===`directory`);if(Vt.suggestions.length>0&&!t&&!a){Y(`[onSubmit] early return: suggestions showing (count=${Vt.suggestions.length})`);return}he.text&&he.shownAt>0&&ut(e),St(`stash-hint`),await A(e,{setCursorOffset:z,clearBuffer:At,resetHistory:Pt})},[he,ge,V,de,$e,Vt.suggestions,A,At,Pt,ut,fe,lt,S,St]),{suggestions:Kt,selectedSuggestion:qt,commandArgumentHint:Jt,inlineGhostText:Yt,maxColumnWidth:Xt}=XC({commands:a,onInputChange:B,onSubmit:Gt,setCursorOffset:z,input:f,cursorOffset:R,mode:m,agents:o,setSuggestionsState:H,suggestionsState:Vt,suppressSuggestions:j||Rt>0,markAccepted:lt,onModeChange:h}),Zt=m===`prompt`&&Kt.length===0&&ct&&!Se;Zt&&dt(),he.text&&!ct&&he.shownAt===0&&!Se&&(Wt(`timing`,he.text),fe(e=>({...e,promptSuggestion:{text:null,promptId:null,shownAt:0,acceptedAt:0,generationRequestId:null}})));function Qt(e,t,n,r,i){X(`tengu_paste_image`,{}),h(`prompt`);let a=De.current++,o={id:a,type:`image`,content:e,mediaType:t||`image/png`,filename:n||`Pasted image`,dimensions:r,sourcePath:i};_e(o),Nt(o),C(e=>({...e,[a]:o})),tn((Oe.current?` `:``)+im(a)),Oe.current=!0}(0,Q.useEffect)(()=>{let e=new Set(tm(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 $t(e){Oe.current=!1;let t=ul(e).replace(/\r/g,`
68
+ `).replaceAll(` `,` `);if(f.length===0){let e=qp(t);e!==`prompt`&&(h(e),t=jp(t))}let n=rm(t),r=Math.min(yn-10,2);if(t.length>800||n>r){let e=De.current++,r={id:e,type:`text`,content:t};C(t=>({...t,[e]:r})),tn(em(e,n))}else tn(t)}let en=(0,Q.useCallback)((e,t)=>Oe.current?(Oe.current=!1,Yh(e,t)?` ${e}`:e):e,[]);function tn(e){Dt(f,R,S);let t=f.slice(0,R)+e+f.slice(R);B(t),z(R+e.length)}let nn=el(()=>{},()=>y()),rn=(0,Q.useCallback)(()=>{let e=En(f,R);return e?(B(e.text),h(`prompt`),z(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},[B,h,f,R,C]);aS(x,e=>{X(`tengu_ext_at_mentioned`,{});let t,n=kg.relative(gu(),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[R-1]??` `;/\s/.test(r)||(t=` ${t}`),tn(t)});let an=(0,Q.useCallback)(()=>{if(kt){let e=Ot();e&&(B(e.text),z(e.cursorOffset),C(e.pastedContents))}},[kt,Ot,B,C]),on=(0,Q.useCallback)(()=>{Dt(f,R,S);let e=`${f.slice(0,R)}\n${f.slice(R)}`;B(e),z(R+1)},[f,R,B,z,Dt,S]),sn=(0,Q.useCallback)(async()=>{X(`tengu_external_editor_used`,{}),Fe(!0);try{let e=await ph(f,S);e.error&&xt({key:`external-editor-error`,text:e.error,color:`warning`,priority:`high`}),e.content!==null&&e.content!==f&&(Dt(f,R,S),B(e.content),z(e.content.length))}catch(e){e instanceof Error&&Pd(e),xt({key:`external-editor-error`,text:`External editor failed: ${xu(e)}`,color:`warning`,priority:`high`})}finally{Fe(!1)}},[f,R,S,Dt,B,xt]),cn=(0,Q.useCallback)(()=>{f.trim()===``&&g!==void 0?(B(g.text),z(g.cursorOffset),C(g.pastedContents),_(void 0)):f.trim()!==``&&(_({text:f,cursorOffset:R,pastedContents:S}),B(``),z(0),C({}),Cd(e=>e.hasUsedStash?e:{...e,hasUsedStash:!0}))},[f,R,g,B,_,S,C]),ln=(0,Q.useCallback)(()=>{Le(e=>!e),F&&I(!1)},[F]),un=(0,Q.useCallback)(()=>{Ge(e=>!e),F&&I(!1)},[F]),dn=(0,Q.useCallback)(()=>{qe(e=>!e),F&&I(!1)},[F]),fn=(0,Q.useCallback)(()=>{Y(`[auto-mode] handleCycleMode: currentMode=${n.mode}`);let e=$C(n),{context:t}=ew(n);X(`tengu_mode_cycle`,{to:e}),e===`plan`&&Cd(e=>({...e,lastPlanModeUse:Date.now()})),fe(n=>({...n,toolPermissionContext:{...t,mode:e}})),r({...t,mode:e}),F&&I(!1)},[n,fe,r,F]),pn=(0,Q.useCallback)(()=>{Op().then(e=>{if(e)Qt(e.base64,e.mediaType);else{let e=Xo(`chat:imagePaste`,`Chat`,`ctrl+v`),t=ed.isSSH()?`No image found in clipboard. You're SSH'd; try scp?`:`No image found in clipboard. Use ${e} to paste images.`;xt({key:`no-image-in-clipboard`,text:t,priority:`immediate`,timeoutMs:1e3})}})},[xt,Qt]),mn=Gc();(0,Q.useEffect)(()=>{if(!(!mn||ae))return mn.registerHandler({action:`chat:submit`,context:`Chat`,handler:()=>{Gt(f)}})},[mn,ae,Gt,f]),jc((0,Q.useMemo)(()=>({"chat:undo":an,"chat:newline":on,"chat:externalEditor":sn,"chat:stash":cn,"chat:modelPicker":ln,"chat:thinkingToggle":dn,"chat:cycleMode":fn,"chat:imagePaste":pn}),[an,on,sn,cn,ln,dn,fn,pn]),{context:`Chat`,isActive:!ae}),Vc(`chat:messageActions`,()=>b?.(),{context:`Chat`,isActive:!ae&&!j}),Vc(`chat:fastMode`,un,{context:`Chat`,isActive:!ae&&df()&&yf()}),Vc(`help:dismiss`,()=>{I(!1)},{context:`Help`,isActive:F}),Vc(`app:quickOpen`,()=>{},{context:`Global`,isActive:!1}),Vc(`app:globalSearch`,()=>{},{context:`Global`,isActive:!1}),Vc(`history:search`,()=>{},{context:`Global`,isActive:!1}),Vc(`app:interrupt`,()=>{Ks(fe)},{context:`Global`,isActive:!s&&ge.status===`active`}),jc({"footer:up":()=>{if(at){ke>-1?Ae(e=>e-1):ot(null);return}st(-1,!0)},"footer:down":()=>{if(at){ke<Ze.length-1&&Ae(e=>e+1);return}if(rt){D(!0),ot(null);return}st(1)},"footer:next":()=>{st(1)},"footer:previous":()=>{st(-1)},"footer:openSelected":()=>{switch(nt){case`tasks`:D(!0),ot(null);break;case`tmux`:break;case`bg_agent`:break}},"footer:clearSelection":()=>{ot(null)},"footer:close":()=>!1},{context:`Footer`,isActive:!!nt&&!ae}),nl((e,t)=>{if(!(Re||Be||He)){if(Gd()===`macos`&&QC(e)){let t=ZC[e],n=Zp();xt({key:`option-meta-hint`,jsx:n?(0,$.jsxs)(q,{dimColor:!0,children:[`To enable `,t,`, set `,(0,$.jsx)(q,{bold:!0,children:`Option as Meta`}),` in `,n,` preferences (⌘,)`]}):(0,$.jsxs)(q,{dimColor:!0,children:[`To enable `,t,`, run /terminal-setup`]}),priority:`immediate`,timeoutMs:5e3})}if(nt&&e&&!t.ctrl&&!t.meta&&!t.escape&&!t.return){Mt(f.slice(0,R)+e+f.slice(R)),z(R+e.length);return}if(R===0&&(t.escape||t.backspace||t.delete||t.ctrl&&e===`u`)&&(h(`prompt`),I(!1)),F&&f===``&&(t.backspace||t.delete)&&I(!1),t.escape){if(ge.status===`active`){Ks(fe);return}if(P&&te){te();return}if(F){I(!1);return}if(nt)return;if(me.some(Me)){rn();return}l.length>0&&!f&&!s&&nn()}t.return&&F&&I(!1)}});let hn=df()?lf():!1,gn=df()?xe&&(yf()||hn):!1,_n=bE(gn??!1),{columns:vn,rows:yn}=sl(),bn=vn-3,xn=yi()?Math.max(SE,Math.floor(yn/2)-xE):void 0,Sn=(0,Q.useCallback)(e=>{if(!f||j)return;let t=Rp.fromText(f,bn,R),n=t.getViewportStartLine(xn),r=t.measuredText.getOffsetFromPosition({line:e.localRow+n,column:e.localCol});z(r)},[f,bn,j,R,xn]),Cn=(0,Q.useCallback)(e=>D(e??!0),[D]),wn=Zt&&ct?ct:jt,Tn=(0,Q.useMemo)(()=>f.includes(`
69
+ `),[f]),Dn=(0,Q.useCallback)(e=>{let t=!1;fe(n=>(t=df()&&!If(e)&&!!n.fastMode,{...n,mainLoopModel:e,mainLoopModelForSession:null,...t&&{fastMode:!1}})),Le(!1);let n=(xe??!1)&&!t,r=`Model set to ${kf(e)}`;Dh(e,n,jf())&&(r+=` · Billed as extra usage`),t&&(r+=` · Fast mode OFF`),xt({key:`model-switched`,jsx:(0,$.jsx)(q,{children:r}),priority:`immediate`,timeoutMs:3e3}),X(`tengu_model_picker_hotkey`,{model:e})},[fe,xt,xe]),On=(0,Q.useCallback)(()=>{Le(!1)},[]),kn=(0,Q.useMemo)(()=>Ie?(0,$.jsx)(K,{flexDirection:`column`,marginTop:1,children:(0,$.jsx)(Oh,{initial:ve,sessionModel:ye,onSelect:Dn,onCancel:On,isStandaloneCommand:!0,showFastModeNotice:df()&&xe&&If(ve)&&yf()})}):null,[Ie,ve,ye,Dn,On]),An=(0,Q.useCallback)(e=>{Ge(!1),e&&xt({key:`fast-mode-toggled`,jsx:(0,$.jsx)(q,{children:e}),priority:`immediate`,timeoutMs:3e3})},[xt]),jn=(0,Q.useMemo)(()=>We?(0,$.jsx)(K,{flexDirection:`column`,marginTop:1,children:(0,$.jsx)(Uh,{onDone:An,unavailableReason:Uf()})}):null,[We,An]),Mn=(0,Q.useCallback)(e=>{fe(t=>({...t,thinkingEnabled:e})),qe(!1),X(`tengu_thinking_toggled_hotkey`,{enabled:e}),xt({key:`thinking-toggled-hotkey`,jsx:(0,$.jsxs)(q,{color:e?`suggestion`:void 0,dimColor:!e,children:[`Thinking `,e?`on`:`off`]}),priority:`immediate`,timeoutMs:3e3})},[fe,xt]),Nn=(0,Q.useCallback)(()=>{qe(!1)},[]),Pn=(0,Q.useMemo)(()=>Ke?(0,$.jsx)(K,{flexDirection:`column`,marginTop:1,children:(0,$.jsx)(tw,{currentValue:be??!0,onSelect:Mn,onCancel:Nn,isMidConversation:l.some(e=>e.type===`assistant`)})}):null,[Ke,be,Mn,Nn,l.length]);if(og(null),E)return(0,$.jsx)(_g,{onDone:()=>D(!1),toolUseContext:k(l,[],new AbortController,ie),initialDetailTaskId:typeof E==`string`?E:void 0});if(kn)return kn;if(jn)return jn;if(Pn)return Pn;let Fn={multiline:!0,onSubmit:Gt,onChange:Mt,value:Te?jp(typeof Te==`string`?Te:Te.display):f,onHistoryUp:zt,onHistoryDown:Bt,onHistoryReset:Pt,placeholder:wn,onExit:O,onExitMessage:(e,t)=>le({show:e,key:t}),onImagePaste:Qt,columns:bn,maxVisibleLines:xn,disableCursorMovementForUpDownKeys:Kt.length>0||!!nt,disableEscapeDoublePress:Kt.length>0,cursorOffset:R,onChangeCursorOffset:z,onPaste:$t,onIsPastingChange:Ne,focus:!j&&!ae&&!nt,showCursor:!nt&&!j&&!yt,argumentHint:Jt,onUndo:kt?()=>{let e=Ot();e&&(B(e.text),z(e.cursorOffset),C(e.pastedContents))}:void 0,highlights:bt,inlineGhostText:Yt,inputFilter:en},In=()=>{let e={bash:`bashBorder`};return e[m]?e[m]:`promptBorder`};if(Pe)return(0,$.jsx)(K,{flexDirection:`row`,alignItems:`center`,justifyContent:`center`,borderColor:In(),borderStyle:`round`,borderLeft:!1,borderRight:!1,borderBottom:!0,width:`100%`,children:(0,$.jsx)(q,{dimColor:!0,italic:!0,children:`Save and close editor to continue...`})});let Ln=Jh()?(0,$.jsx)(eT,{...Fn,initialMode:w,onModeChange:T}):(0,$.jsx)(Gp,{...Fn});return(0,$.jsxs)(K,{flexDirection:`column`,marginTop:1,children:[!yi()&&(0,$.jsx)(cE,{}),L&&(0,$.jsx)(K,{marginTop:1,marginLeft:2,children:(0,$.jsx)(q,{dimColor:!0,children:`Waiting for permission…`})}),(0,$.jsx)(lE,{hasStash:g!==void 0}),(0,$.jsxs)(K,{flexDirection:`row`,alignItems:`flex-start`,justifyContent:`flex-start`,borderColor:In(),borderStyle:`round`,borderLeft:!1,borderRight:!1,borderBottom:!0,width:`100%`,borderText:TE(gn??!1,_n,hn),children:[(0,$.jsx)(QT,{mode:m,isLoading:s}),(0,$.jsx)(K,{flexGrow:1,flexShrink:1,onClick:Sn,children:Ln})]}),(0,$.jsx)(YT,{apiKeyStatus:i,debug:e,exitMessage:ce,vimMode:Jh()?w:void 0,mode:m,autoUpdaterResult:d,isAutoUpdating:oe,verbose:c,onAutoUpdaterResult:u,onChangeIsUpdating:se,suggestions:Kt,selectedSuggestion:qt,maxColumnWidth:Xt,toolPermissionContext:n,helpOpen:F,suppressHint:f.length>0,isLoading:s,tasksSelected:rt,tmuxSelected:it,ideSelection:t,mcpClients:x,isPasting:je,isInputWrapped:Tn,messages:l,isSearching:j,historyQuery:Ce,setHistoryQuery:we,historyFailedMatch:Ee,onOpenTasksDialog:yi()?Cn:void 0}),yi()?(0,$.jsx)(K,{position:`absolute`,marginTop:-1,height:+(Kt.length===0),width:`100%`,paddingLeft:2,paddingRight:1,flexDirection:`column`,justifyContent:`flex-end`,overflow:`hidden`,children:(0,$.jsx)(pS,{apiKeyStatus:i,autoUpdaterResult:d,debug:e,isAutoUpdating:oe,verbose:c,messages:l,onAutoUpdaterResult:u,onChangeIsUpdating:se,ideSelection:t,mcpClients:x,isInputWrapped:Tn})}):null]})}function wE(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=tm(e.text);for(let e of n)e.id>t&&(t=e.id)}}}return t+1}function TE(e,t,n){if(e)return{content:` ${t?`${Vh(!0,n)} ${Qc.dim(`/fast`)}`:Vh(!0,n)} `,position:`top`,align:`end`,offset:0}}var EE=Q.memo(CE);Vd();var DE=400;function OE({inputValue:e,setInputValue:t,isValidDigit:n,onDigit:r,enabled:i=!0,once:a=!1,debounceMs:o=DE}){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=Ud(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])}J();var kE=[`0`,`1`,`2`,`3`],AE={0:`dismissed`,1:`bad`,2:`fine`,3:`good`},jE=e=>kE.includes(e),ME=`How is Work Mate doing this session? (optional)`;function NE({onSelect:e,inputValue:t,setInputValue:n,message:r=ME}){return OE({inputValue:t,setInputValue:n,isValidDigit:jE,onDigit:t=>e(AE[t])}),(0,$.jsxs)(K,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{color:`ansi:cyan`,children:`● `}),(0,$.jsx)(q,{bold:!0,children:r})]}),(0,$.jsxs)(K,{marginLeft:2,children:[(0,$.jsx)(K,{width:10,children:(0,$.jsxs)(q,{children:[(0,$.jsx)(q,{color:`ansi:cyan`,children:`1`}),`: Bad`]})}),(0,$.jsx)(K,{width:10,children:(0,$.jsxs)(q,{children:[(0,$.jsx)(q,{color:`ansi:cyan`,children:`2`}),`: Fine`]})}),(0,$.jsx)(K,{width:10,children:(0,$.jsxs)(q,{children:[(0,$.jsx)(q,{color:`ansi:cyan`,children:`3`}),`: Good`]})}),(0,$.jsx)(K,{children:(0,$.jsxs)(q,{children:[(0,$.jsx)(q,{color:`ansi:cyan`,children:`0`}),`: Dismiss`]})})]})]})}J(),Vd();function PE({isOpen:e,skillName:t,updates:n,handleSelect:r,inputValue:i,setInputValue:a}){return!e||i&&!jE(i)?null:(0,$.jsx)(LE,{skillName:t,updates:n,onSelect:r,inputValue:i,setInputValue:a})}var FE=[`0`,`1`];function IE(e){return FE.includes(e)}function LE({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=Ud(r.slice(-1));IE(e)&&(i(r.slice(0,-1)),n(e===`1`?`good`:`dismissed`))}},[r,n,i]),(0,$.jsxs)(K,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(K,{children:[(0,$.jsxs)(q,{color:`ansi:cyan`,children:[Qu,` `]}),(0,$.jsxs)(q,{bold:!0,children:[`Skill improvement suggested for "`,e,`"`]})]}),(0,$.jsx)(K,{flexDirection:`column`,marginLeft:2,children:t.map((e,t)=>(0,$.jsxs)(q,{dimColor:!0,children:[`∙`,` `,e.change]},t))}),(0,$.jsxs)(K,{marginLeft:2,marginTop:1,children:[(0,$.jsx)(K,{width:12,children:(0,$.jsxs)(q,{children:[(0,$.jsx)(q,{color:`ansi:cyan`,children:`1`}),`: Apply`]})}),(0,$.jsx)(K,{width:14,children:(0,$.jsxs)(q,{children:[(0,$.jsx)(q,{color:`ansi:cyan`,children:`0`}),`: Dismiss`]})})]})]})}qd(),V(),Wr();function RE(e){let t=U(e=>e.skillImprovement.suggestion),n=N(),[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&&Tg(r.skillName,r.updates).then(()=>{e(e=>[...e,bc(`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 zE(e){return{onBeforeQuery:async()=>!0,onTurnComplete:async()=>{},render:()=>null}}Ke(),gi(),Lo(),js();function BE(e){(0,Q.useEffect)(()=>{let t=()=>{zs()&&process.stdout.write(`\n${wi()}\n`),Qi(e?.())};return process.on(`exit`,t),()=>{process.off(`exit`,t)}},[])}function VE(){(0,Q.useEffect)(()=>{},[])}function HE(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])}mu(),_r(),mf();function UE(){let[e,t]=(0,Q.useState)(()=>{if(!Vf()||gf())return`valid`;let{key:e,source:t}=Tf({skipRetrievingKeyFromApiKeyHelper:!0});return e||t===`apiKeyHelper`?`loading`:`missing`}),[n,r]=(0,Q.useState)(null);return{status:e,reverify:(0,Q.useCallback)(async()=>{if(!Vf()||gf()){t(`valid`);return}await Nf(Gl());let{key:e,source:n}=Tf();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 Xi(e,!1)?`valid`:`invalid`;t(n);return}catch(e){r(e),t(`error`);return}},[]),error:n}}mu(),J(),hu(),Ou(),J(),Yn(),qd(),V();function WE({screen:e,setScreen:t,showAllInTranscript:n,setShowAllInTranscript:r,messageCount:i,onEnterTranscript:a,onExitTranscript:o,virtualScrollActive:s,searchBarOpen:c=!1}){let l=U(e=>e.expandedView),u=N(),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]);Vc(`app:toggleTodos`,d,{context:`Global`}),Vc(`app:toggleTranscript`,f,{context:`Global`}),Vc(`app:toggleTerminal`,(0,Q.useCallback)(()=>{},[]),{context:`Global`}),Vc(`app:redraw`,(0,Q.useCallback)(()=>{Lc.get(process.stdout)?.forceRedraw()},[]),{context:`Global`});let h=e===`transcript`;return Vc(`transcript:toggleShowAll`,p,{context:`Transcript`,isActive:h&&!s}),Vc(`transcript:exit`,m,{context:`Transcript`,isActive:h&&!c}),null}fm(),ht(),Yn();var GE={setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}};function KE({onSubmit:e,isActive:t=!0}){let n=Gc(),r=um(),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 jc((0,Q.useMemo)(()=>{let t={};for(let n of i){let r=n.slice(8);t[n]=()=>{e(`/${r}`,GE,void 0,{fromKeybinding:!0})}}return t},[i,e]),{context:`Chat`,isActive:t&&!r}),null}qd(),V(),Zh(),Yp(),fm(),rt(),Yn(),yo(),sn();var qE=3e3;function JE(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=no(),g=N(),_=nS().length,{addNotification:v,removeNotification:y}=Jp(),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(Vt()&&s){s();return}X(`tengu_cancel`,e),t(()=>[]),n()},[o,s,t,n,m]),S=dm(),C=o!==void 0&&!o.aborted,w=_>0,T=f!==void 0&&f!==`prompt`&&!p,E=a!==`transcript`&&!u&&!i&&!l&&!d&&!S&&!(Jh()&&c===`INSERT`),D=E&&(C||w)&&!T,O=E&&(C||w);Vc(`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;ha(e,g);let n=[];for(let[e,r]of t)$r(e,g),n.push(r.description),ce(e,`stopped`,{toolUseId:r.toolUseId,summary:r.description});return Za({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 Vc(`app:interrupt`,(0,Q.useCallback)(()=>{(C||w)&&x()},[C,w,x]),{context:`Global`,isActive:O}),Vc(`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<=qE){b.current=0,y(`kill-agents-confirm`),X(`tengu_cancel`,{source:`kill_agents`}),Vn(),k();return}b.current=t;let n=Xo(`chat:killAgents`,`Chat`,`ctrl+x ctrl+k`);v({key:`kill-agents-confirm`,text:`Press ${n} again to stop background agents`,priority:`immediate`,timeoutMs:qE})},[h,v,y,k]),{context:`Chat`}),null}J(),V(),oa();function YE(e){let t=U(e=>e.tasks),n=Object.values(t).some(Ko),r=t=>{if(t.shift&&(t.key===`up`||t.key===`down`)){t.preventDefault(),n&&e?.onOpenBackgroundTasks?.();return}};return nl((e,t,n)=>{r(new Bc(n.keypress))}),{handleKeyDown:r}}Md();async function XE(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?Pd(e):Pd(Error(`Automated permission check failed: ${String(e)}`))}return null}qd(),f(),Rs(),Ou(),Ca(),Wr(),vi(),St();function ZE(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 QE(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){Tn({tool:e,input:a?.input??t,toolUseContext:n,messageId:s,toolUseID:i},r,a?.permissionPromptStartTimeMs)},logCancelled(){X(`tengu_tool_use_cancelled`,{messageID:s,toolName:p(e.name)})},async persistPermissions(e){return e.length===0?!1:(Pn(e),a(Hs(n.getAppState().toolPermissionContext,e)),e.some(e=>R(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?Ss:g}${t}`:a?Vi:pn,s=a?o:cc(o);return(r||!t&&!i?.length&&!a)&&(Y(`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 sr(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&&(Y(`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 $E(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))}}}Ou(),J(),Rs(),mo(),bu();function eD(e,t){let{ctx:n,description:r,result:i,awaitAutomatedChecksBeforeDialog:a}=e,{resolve:o,isResolved:s,claim:c}=ZE(t),l,u,d=Date.now(),f=i.updatedInput??n.input,p={assistantMessage:n.assistantMessage,tool:n.tool,description:r,input:f,toolUseContext:n.toolUseContext,toolUseID:n.toolUseID,permissionResult:i,permissionPromptStartTimeMs:d,onUserInteraction(){Date.now()-d<200||n.toolUseID},onDismissCheckmark(){l&&(clearTimeout(l),l=void 0,u&&(n.toolUseContext.abortController.signal.removeEventListener(`abort`,u),u=void 0),n.removeFromQueue())},onAbort(){c()&&(n.logCancelled(),n.logDecision({decision:`reject`,source:{type:`user_abort`}},{permissionPromptStartTimeMs:d}),o(n.cancelAndAbort(void 0,!0)))},async onAllow(e,t,r,a){c()&&o(await n.handleUserAllow(e,t,r,d,a,i.decisionReason))},onReject(e,t){c()&&(n.logDecision({decision:`reject`,source:{type:`user_reject`,hasFeedback:!!e}},{permissionPromptStartTimeMs:d}),o(n.cancelAndAbort(e,void 0,t)))},async recheckPermission(){if(s())return;let e=await te(n.tool,n.input,n.toolUseContext,n.assistantMessage,n.toolUseID);if(e.behavior===`allow`){if(!c())return;n.removeFromQueue(),n.logDecision({decision:`accept`,source:`config`}),o(n.buildAllow(e.updatedInput??n.input))}}};n.pushToQueue(p),a||(async()=>{if(s())return;let e=n.toolUseContext.getAppState(),t=await n.runHooks(e.toolPermissionContext.mode,i.suggestions,i.updatedInput,d);!t||!c()||(n.removeFromQueue(),o(t))})()}J(),Rs(),mo(),Ou(),bu(),Md(),tr(),St();function tD(e,t){return(0,Q.useCallback)(async(n,r,i,a,o,s)=>new Promise(c=>{let l=QE(n,r,i,a,o,t,$E(e));if(!l.resolveIfAborted(c))return(s===void 0?te(n,r,i,a,o):Promise.resolve(s)).then(async e=>{if(e.behavior===`allow`){if(l.resolveIfAborted(c))return;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`:Tn({tool:n,input:r,toolUseContext:i,messageId:l.messageId,toolUseID:o},{decision:`reject`,source:`config`}),c(e);return;case`ask`:if(t.toolPermissionContext.awaitAutomatedChecksBeforeDialog){let n=await XE({ctx:l,updatedInput:e.updatedInput,suggestions:e.suggestions,permissionMode:t.toolPermissionContext.mode});if(n){c(n);return}}if(l.resolveIfAborted(c))return;eD({ctx:l,description:a,result:e,awaitAutomatedChecksBeforeDialog:t.toolPermissionContext.awaitAutomatedChecksBeforeDialog},c);return}}).catch(e=>{e instanceof vu||e instanceof wu?(Y(`Permission check threw ${e.constructor.name} for tool=${n.name}: ${e.message}`),l.logCancelled(),c(l.cancelAndAbort(void 0,!0))):(Pd(e),c(l.cancelAndAbort(void 0,!0)))}).finally(()=>{})}),[e,t])}Qt(),qd(),cn(),am(),hu(),Ou(),bu(),Md(),sn(),Of();function nD(){Zr(0)}async function rD(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){ua(),await iD({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(tm(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(fo);if(T.trim()===``)return;if(!b&&[`exit`,`quit`,`:q`,`:q!`,`:wq`,`:wq!`].includes(T.trim())){i.find(e=>e.name===`exit`)?rD({...e,input:`/exit`}):nD();return}let j=nm(T,k),M=tm(T).filter(e=>k[e.id]?.type===`text`),N=M.length;if(X(`tengu_paste_text`,{pastedTextCount:N,pastedTextBytes:M.reduce((e,t)=>e+(k[t.id]?.content.length??0),0)}),!b&&j.trim().startsWith(`/`)){let t=j.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&&Dn(e)&&(e.name===f||e.aliases?.includes(f)||Qe(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,[],Bi(),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?Yt({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&&(Y(`[interrupt] Aborting current turn: streamMode=${e.streamMode}`),X(`tengu_cancel`,{source:`interrupt_on_submit`,streamMode:e.streamMode}),e.abortController?.abort(`interrupt`)),Yt({value:j.trim(),preExpansionValue:T.trim(),mode:E,pastedContents:A?k:void 0,skipSlashCommands:b,bridgeOrigin:x,uuid:y}),a(``),S(0),o({}),w(),C();return}ua(),await iD({queuedCommands:[{value:j,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 iD(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=Bi();l(g);function _(){return s(t,[],g,n)}try{a.reserve(),ya(`query_process_user_input_start`);let s=[],v=!1,y,b,x,S,C=h??[],w=await at(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 sf(D,async()=>{for(let e=0;e<C.length;e++){let n=C[e],a=e===0,l=n.autonomy?.runId,u=await Cm({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(ya(`query_process_user_input_end`),$n()&&(ya(`query_file_history_snapshot_start`),s.filter(xm).forEach(e=>{_t(e=>{d(t=>({...t,fileHistory:e(t.fileHistory)}))},e.uuid)}),ya(`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?ff(b,n):n,i?f:void 0,r)}else a.cancelReservation(),o({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0}),p(),l(null);x&&(S?Yt({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 Mr({commands:e,outcome:{type:`failed`,error:k},currentDir:gu(),priority:`later`,workload:D})}catch(e){Pd(yu(e))}else try{let t=await Mr({commands:e,outcome:{type:`completed`},currentDir:gu(),priority:`later`,workload:D});for(let e of t)Yt(e)}catch(e){Pd(yu(e))}}if(k)throw k}finally{a.cancelReservation(),c(void 0)}}sn();function aD(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 oD({executeInput:e}){let t=e=>e.agentId===void 0,n=wt(t);if(!n)return{processed:!1};if(aD(n)||n.mode===`bash`)return e([Se(t)]),{processed:!0};let r=n.mode,i=he(e=>t(e)&&!aD(e)&&e.mode===r);return i.length===0?{processed:!1}:(e(i),{processed:!0})}sn();function sD({executeQueuedInput:e,hasActiveLocalJsxUI:t,queryGuard:n}){let r=(0,Q.useSyncExternalStore)(n.subscribe,n.getSnapshot),i=(0,Q.useSyncExternalStore)(I,Ba);(0,Q.useEffect)(()=>{r||t||i.length!==0&&oD({executeInput:e})},[i,r,e,t,n])}function cD(e,t){return e&&t&&t.length>0?di([...e,...t],`name`):e||[]}function lD(e,t){return(0,Q.useMemo)(()=>cD(e,t),[e,t])}Ye(),ym(),uh(),Pa();function uD(e,t){return(0,Q.useMemo)(()=>t.length>0?di([...e,...t],`name`):e,[e,t])}cn(),Md();function dD(e,t){let n=(0,Q.useCallback)(async()=>{if(e)try{Hn(),t(await Qa(e))}catch(e){e instanceof Error&&Pd(e)}},[e,t]);(0,Q.useEffect)(()=>Qm.subscribe(n),[n])}Md(),Ml(),Cn(),kl();var fD=Al(()=>bl({method:Sl(`selection_changed`),params:bl({selection:bl({start:bl({line:Cl(),character:Cl()}),end:bl({line:Cl(),character:Cl()})}).nullable().optional(),text:wl().optional(),filePath:wl().optional()})}));function pD(e,t){let n=(0,Q.useRef)(!1),r=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{let i=nn(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(fD(),e=>{if(r.current===i)try{let t=e.params;t.selection?.start&&t.selection.end?a(t):t.text!==void 0&&a({selection:null,text:t.text,filePath:t.filePath})}catch(e){Pd(e)}}),n.current=!0},[e,t])}Os(),uc(),J(),fg(),V(),$d();function mD({task:e,selected:t}){let n=hg(e.startTime,e.status===`running`),r=e.progress?.tokenCount??0;return(0,$.jsxs)(K,{flexDirection:`row`,width:`100%`,justifyContent:`space-between`,children:[(0,$.jsxs)(K,{flexDirection:`row`,flexShrink:1,children:[(0,$.jsx)(q,{color:e.status===`running`?`success`:void 0,children:t?`● `:`○ `}),(0,$.jsxs)(q,{bold:t,wrap:`truncate-end`,children:[e.agentType,` `,(0,$.jsx)(q,{dimColor:!0,children:e.description})]})]}),(0,$.jsx)(K,{flexShrink:0,children:(0,$.jsxs)(q,{dimColor:!0,children:[n,` · ↓ `,tf(r),` tokens`]})})]})}function hD(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 gD(){let e=xS(),t=U(e=>e.viewingAgentTaskId),n=U(e=>e.footerSelection),r=U(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)(K,{flexDirection:`column`,width:`100%`,children:[(0,$.jsxs)(K,{flexDirection:`row`,width:`100%`,justifyContent:`space-between`,children:[(0,$.jsxs)(q,{bold:o,children:[o?`● `:`○ `,`main`]}),(0,$.jsx)(q,{dimColor:!0,children:hD(i,s)})]}),e.map(e=>(0,$.jsx)(mD,{task:e,selected:e.agentId===a},e.agentId))]})}Nd(),hu(),xr(),Ou(),Gn();var _D=3e4;function vD(e){let t=(0,Q.useRef)(e);t.current=e,(0,Q.useEffect)(()=>{if(!ve())return;let e=null,n=!1,r=!1;function i(){H(Date.now()+_D),e=setTimeout(()=>{if(e=null,!dn()){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 Hr({basePrompt:`<${Od}>${new Date().toLocaleTimeString()}</${Od}>`,currentDir:gu(),shouldCreate:()=>!n});if(n){await Zo({commands:e});return}let r=[];try{for(let n of e)t.current.onQueueTick(n),r.push(n)}catch(t){throw await Zo({commands:e.filter(e=>!r.includes(e))}),t}})().catch(e=>Y(`[Proactive] failed to create tick: ${e}`,{level:`error`})).finally(()=>{r=!1}),i()},_D)}return i(),()=>{n=!0,e!==null&&(clearTimeout(e),e=null),H(null)}},[ve(),en(),Te()])}jr(),No();function yD(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 bD(e){let t=Ds(e),n=yD(e),r=`Continuation turns executed: ${e.turnsExecuted}`;return`<goal-steering type="continuation">
70
+ You have an active goal to work on. Continue making progress.
71
+
72
+ ## Active Goal
73
+ ${e.objective}
74
+
75
+ ## Status
76
+ - Elapsed active time: ${t}
77
+ - ${n}
78
+ - ${r}
79
+
80
+ ## Instructions
81
+
82
+ 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.
83
+
84
+ When you believe the goal is fully achieved, use the GoalTool to mark it complete. Before doing so, perform a strict Completion Audit:
85
+
86
+ ### Completion Audit
87
+ 1. Derive concrete requirements from the objective and any referenced files.
88
+ 2. Preserve the original scope — do not redefine success around what is already done.
89
+ 3. For every explicit requirement, identify authoritative evidence (test output, file content, command result).
90
+ 4. Treat tests, manifests, and verifiers as evidence only after confirming they actually cover the requirement.
91
+ 5. Treat uncertain or indirect evidence as "not achieved".
92
+ 6. The audit must PROVE completion, not merely fail to find remaining work.
93
+
94
+ ### Blocked Audit
95
+ If you encounter an obstacle you genuinely cannot overcome:
96
+ - Do NOT mark blocked on the first encounter.
97
+ - The same blocking condition must persist for at least 3 consecutive continuation turns before you may mark blocked.
98
+ - "Difficult", "slow", or "partially incomplete" is NOT blocked.
99
+ - If blocked, use the GoalTool with status "blocked" and a clear reason.
100
+
101
+ Resume working now.
102
+ </goal-steering>`}function xD(e){return`<goal-steering type="budget_limit">
103
+ ## Token Budget Reached
104
+
105
+ Your token budget for this goal has been exhausted.
106
+
107
+ - Goal: ${e.objective}
108
+ - Tokens used: ${e.tokensUsed}${e.tokenBudget===null?``:` / ${e.tokenBudget}`}
109
+ - Active time: ${Ds(e)}
110
+
111
+ **Stop all substantive work immediately.** Do NOT start new file edits, tool calls, or explorations.
112
+
113
+ Instead, provide a brief summary:
114
+ 1. What has been accomplished so far.
115
+ 2. What remains to be done.
116
+ 3. Any blockers or issues encountered.
117
+
118
+ 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.
119
+ </goal-steering>`}Ou(),No(),sn();function SD(e){Y(`[goal] hook: ${e}`)}function CD(e){let t=(0,Q.useRef)(e);t.current=e;let n=(0,Q.useRef)(!1),r=(0,Q.useRef)(!1);(0,Q.useLayoutEffect)(()=>{if(e.isLoading){n.current=!1;return}if(e.isQueryActiveNow?.()){SD(`skip: queryActiveNow=true`);return}if(e.wasAborted){SD(`skip: wasAborted=true`);return}if(n.current)return;if(Ba().length>0){SD(`skip: yielding to queued user messages`);return}if(e.hasActiveLocalJsxUI){SD(`skip: activeLocalJsxUI`);return}if(e.isInPlanMode){SD(`skip: planMode`);return}let t=cs();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=xD(t);Y(`[goal] hook: budget limit reached, injecting wrap-up prompt`),Yt({value:e,mode:`prompt`,priority:`now`,isMeta:!0,origin:`goal-budget-limit`,skipSlashCommands:!0});return}if(t.status!==`active`){SD(`skip: status="${t.status}" (not active)`);return}if(t.turnsExecuted>=150){gs()&&(br(),e.onMaxTurnsReached?.()),Y(`[goal] hook: MAX_GOAL_TURNS (150) reached, stopping`);return}n.current=!0;let i=oi();br();let a=bD(t);Y(`[goal] hook: enqueuing turn ${i} for "${t.objective.slice(0,60)}"`),Yt({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])}xd(),o(),Cn();function wD({autoConnectIdeFlag:e,ideToInstallExtension:t,setDynamicMcpConfig:n,setShowIdeOnboarding:i,setIDEInstallationState:o}){(0,Q.useEffect)(()=>{function s(i){i&&(yd().autoConnectIde||e||nr()||process.env.CLAUDE_CODE_SSE_PORT||t||a(process.env.CLAUDE_CODE_AUTO_CONNECT_IDE))&&!r(process.env.CLAUDE_CODE_AUTO_CONNECT_IDE)&&n(e=>e?.ide?e:{...e,ide:{type:i.url.startsWith(`ws:`)?`ws-ide`:`sse-ide`,url:i.url,ideName:i.name,authToken:i.authToken,ideRunningInWindows:i.ideRunningInWindows,scope:`dynamic`}})}xc(s,t,()=>i(!0),e=>o(e))},[e,t,n,i,o])}Rh(),cm(),J(),Yn(),fr(),V(),xd(),pd(),o();function TD({onBackgroundSession:e,isLoading:t}){let n=N(),r=no(),[i,o]=(0,Q.useState)(!1),s=el(o,e,()=>{}),c=(0,Q.useCallback)(()=>{a(process.env.CLAUDE_CODE_DISABLE_BACKGROUND_TASKS)||(Ma(r.getState())?(ls(()=>r.getState(),n),yd().hasUsedBackgroundTask||Cd(e=>e.hasUsedBackgroundTask?e:{...e,hasUsedBackgroundTask:!0})):a(`false`)&&t&&s())},[n,r,t,s]),l=U(Ma),u=a(`false`);Vc(`task:background`,c,{context:`Task`,isActive:l||u&&t});let d=Re(`task:background`,`Task`,`ctrl+b`),f=ed.terminal===`tmux`&&d===`ctrl+b`?`ctrl+b ctrl+b`:d;return!t||!i?null:(0,$.jsx)(K,{paddingLeft:2,children:(0,$.jsx)(q,{dimColor:!0,children:(0,$.jsx)(Oc,{shortcut:f,action:`background`})})})}V();function ED({setMessages:e,setIsLoading:t,resetLoadingState:n,setAbortController:r,onBackgroundQuery:i}){let a=U(e=>e.foregroundedTaskId),o=U(e=>e.foregroundedTaskId?e.tasks[e.foregroundedTaskId]:void 0),s=N(),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?.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}}Le(),gm();function DD(e,t){return t}mu(),Wr(),Ar(),J(),Yn(),_r(),mf(),Ka(),Ou(),pd(),Xu(),Md(),Gs(),ju(),Ur(),ii(),Bp();function OD(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}h(),mf(),Ou(),bu(),cf(),Wr(),Gs(),ju();async function kD(e,t,n){try{Y(`Collecting transcript for sharing`,{level:`info`});let r=Vo(e),i=await ln(Fr(e)),a;try{let e=vo(),{size:t}=await Hg(e);t<=52428800?a=await Bg(e,`utf-8`):Y(`Skipping raw transcript read: file too large (${t} bytes)`,{level:`warn`})}catch{}let o=OD(_u({trigger:t,version:`0.0.22`,platform:process.platform,transcript:r,subagentTranscripts:Object.keys(i).length>0?i:void 0,rawTranscriptJsonl:a}));await Rf();let s=of();if(s.error)return{success:!1};let c={"Content-Type":`application/json`,"User-Agent":hf(),...s.headers},l=await m.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 Y(`Transcript shared successfully`,{level:`info`}),{success:!0,transcriptId:e?.transcript_id}}return{success:!1}}catch(e){return Y(xu(e),{level:`error`}),{success:!1}}}function AD({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)(zg()),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=zg(),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])}}qd(),xd(),o(),Wr(),Of(),sd();var jD={minTimeBeforeFeedbackMs:6e5,minTimeBetweenFeedbackMs:36e5,minTimeBetweenGlobalFeedbackMs:1e8,minUserTurnsBeforeFeedback:5,minUserTurnsBetweenFeedback:10,hideThanksAfterMs:3e3,onForModels:[`*`],probability:.005},MD={probability:0};function ND(e,t,n,r=`session`,i=!1){let o=(0,Q.useRef)(`unknown`);o.current=ye(e)?.message?.id||`unknown`;let[s,c]=(0,Q.useState)(()=>({timeLastShown:null,submitCountAtLastAppearance:null})),l=DD(`tengu_feedback_survey_config`,jD),u=DD(`tengu_bad_survey_transcript_ask_config`,MD),d=DD(`tengu_good_survey_transcript_ask_config`,MD),f=_d().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}),yd().feedbackSurveyState?.lastShownTime!==e&&Cd(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:o.current,survey_type:r}),dp(`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:o.current,survey_type:r}),dp(`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`||yd().transcriptShareDismissed||!bp(`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:o.current,survey_type:r,trigger:n}),dp(`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:o.current,survey_type:r,trigger:i}),t===`dont_ask_again`&&Cd(e=>({...e,transcriptShareDismissed:!0})),t===`yes`){let t=await kD(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}=AD({hideThanksAfterMs:l.hideThanksAfterMs,onOpen:b,onSelect:x,shouldShowTranscriptPrompt:S,onTranscriptPromptShown:C,onTranscriptSelect:w}),A=Lf(),j=(0,Q.useMemo)(()=>l.onForModels.length===0?!1:l.onForModels.includes(`*`)?!0:l.onForModels.includes(A),[l.onForModels,A]),M=(0,Q.useMemo)(()=>{if(T!==`closed`||t||i)return!1;if(process.env.CLAUDE_FORCE_DISPLAY_SURVEY&&!s.timeLastShown)return!0;if(!j||a(process.env.CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY)||vp()||!bp(`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=yd().feedbackSurveyState;return!(e?.lastShownTime&&Date.now()-e.lastShownTime<l.minTimeBetweenGlobalFeedbackMs)},[T,t,i,j,s.timeLastShown,s.submitCountAtLastAppearance,n,l.minTimeBetweenFeedbackMs,l.minTimeBetweenGlobalFeedbackMs,l.minUserTurnsBetweenFeedback,l.minTimeBeforeFeedbackMs,l.minUserTurnsBeforeFeedback,l.probability,f]);return(0,Q.useEffect)(()=>{M&&D()},[M,D]),{state:T,lastResponse:E,handleSelect:O,handleTranscriptSelect:k}}_p(),qd(),xd(),o(),Wr(),mp();var PD=3e3,FD=`tengu_memory_survey_event`,ID=`memory_survey`;function LD(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}=AD({hideThanksAfterMs:PD,onOpen:(0,Q.useCallback)(e=>{X(FD,{event_type:`appeared`,appearance_id:e}),dp(`feedback_survey`,{event_type:`appeared`,appearance_id:e,survey_type:`memory`})},[]),onSelect:(0,Q.useCallback)((e,t)=>{X(FD,{event_type:`responded`,appearance_id:e,response:t}),dp(`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(FD,{event_type:`transcript_prompt_appeared`,appearance_id:e,trigger:ID}),dp(`feedback_survey`,{event_type:`transcript_prompt_appeared`,appearance_id:e,survey_type:`memory`})},[]),onTranscriptSelect:(0,Q.useCallback)(async(e,t)=>{if(X(FD,{event_type:`transcript_share_${t}`,appearance_id:e,trigger:ID}),t===`dont_ask_again`&&Cd(e=>({...e,transcriptShareDismissed:!0})),t===`yes`){let t=await kD(o.current,ID,e);return X(FD,{event_type:t.success?`transcript_share_submitted`:`transcript_share_failed`,appearance_id:e,trigger:ID}),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)(()=>ye(e),[e]),e,l]),{state:s,lastResponse:c,handleSelect:u,handleTranscriptSelect:d}}_p(),qd(),o(),Wr(),mp();var RD=3e3,zD=.2;function BD(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 VD(e,t,n=!1,{enabled:r=!0}={}){let[i,o]=(0,Q.useState)(null),s=(0,Q.useRef)(new Set),c=(0,Q.useRef)(null),{state:l,lastResponse:u,open:d,handleSelect:f}=AD({hideThanksAfterMs:RD,onOpen:(0,Q.useCallback)(e=>{X(`tengu_post_compact_survey_event`,{event_type:`appeared`,appearance_id:e,session_memory_compaction_enabled:ai()}),dp(`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:ai()}),dp(`feedback_survey`,{event_type:`responded`,appearance_id:e,response:t,survey_type:`post_compact`})},[])});(0,Q.useEffect)(()=>{r&&o(!1)},[r]);let p=(0,Q.useMemo)(()=>new Set(e.filter(e=>w(e)).map(e=>e.uuid)),[e]);return(0,Q.useEffect)(()=>{if(!r||l!==`closed`||t||n||i!==!0||vp()||a(process.env.CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY))return;if(c.current!==null&&BD(e,c.current)){c.current=null,Math.random()<zD&&d();return}let o=Array.from(p).filter(e=>!s.current.has(e));o.length>0&&(s.current=new Set(p),c.current=o[o.length-1])},[r,p,l,t,n,i,e,d]),{state:l,lastResponse:u,handleSelect:f}}Bu(),J();var HD=[`1`,`2`,`3`],UD={1:`yes`,2:`no`,3:`dont_ask_again`},WD=e=>HD.includes(e);function GD({onSelect:e,inputValue:t,setInputValue:n}){return OE({inputValue:t,setInputValue:n,isValidDigit:WD,onDigit:t=>e(UD[t])}),(0,$.jsxs)(K,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(K,{children:[(0,$.jsxs)(q,{color:`ansi:cyan`,children:[Qu,` `]}),(0,$.jsx)(q,{bold:!0,children:`Can we look at your session transcript to help us improve Work Mate?`})]}),(0,$.jsx)(K,{marginLeft:2,children:(0,$.jsx)(q,{dimColor:!0,children:`Learn more: https://code.workmate.com/docs/en/data-usage#session-quality-surveys`})}),(0,$.jsxs)(K,{marginLeft:2,children:[(0,$.jsx)(K,{width:10,children:(0,$.jsxs)(q,{children:[(0,$.jsx)(q,{color:`ansi:cyan`,children:`1`}),`: Yes`]})}),(0,$.jsx)(K,{width:10,children:(0,$.jsxs)(q,{children:[(0,$.jsx)(q,{color:`ansi:cyan`,children:`2`}),`: No`]})}),(0,$.jsx)(K,{children:(0,$.jsxs)(q,{children:[(0,$.jsx)(q,{color:`ansi:cyan`,children:`3`}),`: Don't ask again`]})})]})]})}qd(),J();function KD({state:e,lastResponse:t,handleSelect:n,handleTranscriptSelect:r,inputValue:i,setInputValue:a,onRequestFeedback:o,message:s}){return e===`closed`?null:e===`thanks`?(0,$.jsx)(JD,{lastResponse:t,inputValue:i,setInputValue:a,onRequestFeedback:o}):e===`submitted`?(0,$.jsx)(K,{marginTop:1,children:(0,$.jsxs)(q,{color:`success`,children:[`✓`,` Thanks for sharing your transcript!`]})}):e===`submitting`?(0,$.jsx)(K,{marginTop:1,children:(0,$.jsxs)(q,{dimColor:!0,children:[`Sharing transcript`,`…`]})}):e===`transcript_prompt`?!r||i&&![`1`,`2`,`3`].includes(i)?null:(0,$.jsx)(GD,{onSelect:r,inputValue:i,setInputValue:a}):i&&!jE(i)?null:(0,$.jsx)(NE,{onSelect:n,inputValue:i,setInputValue:a,message:s})}var qD=e=>e===`1`;function JD({lastResponse:e,inputValue:t,setInputValue:n,onRequestFeedback:r}){let i=r&&e===`good`;return OE({inputValue:t,setInputValue:n,isValidDigit:qD,enabled:!!i,once:!0,onDigit:()=>{X(`tengu_feedback_survey_event`,{event_type:`followup_accepted`,response:e}),r?.()}}),(0,$.jsxs)(K,{marginTop:1,flexDirection:`column`,children:[(0,$.jsx)(q,{color:`success`,children:`Thanks for the feedback!`}),i?(0,$.jsxs)(q,{dimColor:!0,children:[`(Optional) Press [`,(0,$.jsx)(q,{color:`ansi:cyan`,children:`1`}),`] to tell us what went well `,` · `,`/issue`]}):e===`bad`?(0,$.jsx)(q,{dimColor:!0,children:`Use /issue to report model behavior issues.`}):(0,$.jsx)(q,{dimColor:!0,children:`Use /issue to share detailed feedback anytime.`})]})}Cp(),Ep(),Yp(),Md();function YD(e){let{addNotification:t}=Jp(),n=(0,Q.useRef)(!1),r=(0,Q.useRef)(e);r.current=e,(0,Q.useEffect)(()=>{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(Pd))},[t])}function XD(){YD(async()=>(await Tp()).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`}}))}xd(),Cu(),Ou(),Wr(),Of(),Ur(),_r(),J(),Wr();function ZD(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=qc();e!==`blurred`&&e!==`unknown`||o.current?.()},[n]),(0,Q.useEffect)(()=>{qc()},[n,!1])}qd(),xd(),Ou(),o(),bu(),Md();function QD(){return a(process.env.CLAUDE_CODE_DISABLE_OFFICIAL_MARKETPLACE_AUTOINSTALL)}var $D={MAX_ATTEMPTS:10,INITIAL_DELAY_MS:3600*1e3,BACKOFF_MULTIPLIER:2,MAX_DELAY_MS:10080*60*1e3};function eO(e){let t=$D.INITIAL_DELAY_MS*$D.BACKOFF_MULTIPLIER**e;return Math.min(t,$D.MAX_DELAY_MS)}function tO(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>=$D.MAX_ATTEMPTS||t===`policy_blocked`||r&&i<r?!1:t===`unknown`||t===`git_unavailable`||t===`gcs_unavailable`||t===void 0}async function nO(){let e=yd();if(!tO(e)){let t=e.officialMarketplaceAutoInstallFailReason??`already_attempted`;return Y(`Official marketplace auto-install skipped: ${t}`),{installed:!1,skipped:!0,reason:t}}try{if(QD())return Y(`Official marketplace auto-install disabled via env var, skipping`),Cd(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 ia())[`claude-plugins-official`])return Y(`Official marketplace '${jo}' already installed, skipping`),Cd(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!0})),{installed:!1,skipped:!0,reason:`already_installed`};if(!M(ps))return Y(`Official marketplace blocked by enterprise policy, skipping`),Cd(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=co(),n=Ng(t,jo);if(await ic(n,t)!==null){let e=await ia();return e[jo]={source:ps,installLocation:n,lastUpdated:new Date().toISOString()},await Us(e),Cd(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 Hi()){Y(`Git not available, skipping official marketplace auto-install`);let t=(e.officialMarketplaceAutoInstallRetryCount||0)+1,n=Date.now(),r=n+eO(t),i=!1;try{Cd(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`git_unavailable`,officialMarketplaceAutoInstallRetryCount:t,officialMarketplaceAutoInstallLastAttemptTime:n,officialMarketplaceAutoInstallNextRetryTime:r}))}catch(e){i=!0,Pd(yu(e)),Y(`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}}Y(`Attempting to auto-install official marketplace`),await ci(ps),Y(`Successfully auto-installed official marketplace`);let r=e.officialMarketplaceAutoInstallRetryCount||0;return Cd(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 So(),Y(`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`};Y(`Failed to auto-install official marketplace: ${n}`,{level:`error`}),Pd(yu(t));let r=(e.officialMarketplaceAutoInstallRetryCount||0)+1,i=Date.now(),a=i+eO(r),o=!1;try{Cd(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`unknown`,officialMarketplaceAutoInstallRetryCount:r,officialMarketplaceAutoInstallLastAttemptTime:i,officialMarketplaceAutoInstallNextRetryTime:a}))}catch(e){o=!0,Pd(yu(e)),Y(`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}}}J(),Ou();function rO(){YD(async()=>{let e=await nO(),t=[];return e.configSaveFailed&&(Y(`Showing marketplace config save failure notification`),t.push({key:`marketplace-config-save-failed`,jsx:(0,$.jsx)(q,{color:`error`,children:`Failed to save marketplace retry info · Check ~/.workmate.json permissions`}),priority:`immediate`,timeoutMs:1e4})),e.installed?(Y(`Showing marketplace installation success notification`),t.push({key:`marketplace-installed`,jsx:(0,$.jsx)(q,{color:`success`,children:`✓ Official marketplace installed · /plugin to see available plugins`}),priority:`immediate`,timeoutMs:7e3})):e.skipped&&e.reason===`unknown`&&(Y(`Showing marketplace installation failure notification`),t.push({key:`marketplace-install-failed`,jsx:(0,$.jsx)(q,{color:`warning`,children:`Failed to install official marketplace · Will retry on next startup`}),priority:`immediate`,timeoutMs:8e3})),t})}sd(),qd();function iO(e){if(e.length===0)return;if(e.length===1)return e[0];let t=e.map(e=>({tip:e,sessions:Sg(e.id)}));return t.sort((e,t)=>t.sessions-e.sessions),t[0]?.tip}async function aO(e){if(ad().spinnerTipsEnabled===!1)return;let t=await wg(e);if(t.length!==0)return iO(t)}function oO(e){Cg(e.id),X(`tengu_tip_shown`,{tipIdLength:e.id,cooldownSessions:e.cooldownSessions})}bu(),Md(),V(),pi();async function sO(e,t,n){}function cO(){let e=U(e=>e.mainLoopModel),t=U(e=>e.mainLoopModelForSession),n=U(e=>e.fastMode),r=N(),i=no(),a=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>{a.current&&(a.current=!1),sO(i.getState().toolPermissionContext,r,n).catch(e=>{Pd(Error(`Auto mode gate check failed`,{cause:yu(e)}))})},[e,t,n])}Lr();function lO(e,t,n){let r=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{!$n()||r.current||(r.current=!0,e&&es(e,n))},[t,e,n])}J(),Or(),Om(),Gh();function uO({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`},...fn()?[]:[{label:(0,$.jsxs)(q,{children:[`Yes, and don't ask again for `,(0,$.jsx)(q,{bold:!0,children:e})]}),value:`yes-dont-ask-again`}],{label:(0,$.jsxs)(q,{children:[`No, and tell Work Mate what to do differently `,(0,$.jsx)(q,{bold:!0,children:`(esc)`})]}),value:`no`}];return(0,$.jsx)(qh,{title:`Network request outside of sandbox`,children:(0,$.jsxs)(K,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{dimColor:!0,children:`Host:`}),(0,$.jsxs)(q,{children:[` `,e]})]}),(0,$.jsx)(K,{marginTop:1,children:(0,$.jsx)(q,{children:`Do you want to allow this connection?`})}),(0,$.jsx)(K,{children:(0,$.jsx)(km,{options:r,onChange:n,onCancel:()=>{t({allow:!1,persistToSettings:!1})}})})]})})}J(),Or(),Kd();function dO(e){return`${e.getHours()%12||12}:${String(e.getMinutes()).padStart(2,`0`)}:${String(e.getSeconds()).padStart(2,`0`)}${e.getHours()<12?`am`:`pm`}`}function fO(){let[e,t]=(0,Q.useState)([]),[n,r]=(0,Q.useState)(0);return(0,Q.useEffect)(()=>{let e=pt.getSandboxViolationStore();return e.subscribe(n=>{t(n.slice(-10)),r(e.getTotalCount())})},[]),!pt.isSandboxingEnabled()||Gd()===`linux`||n===0?null:(0,$.jsxs)(K,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(K,{marginLeft:0,children:(0,$.jsxs)(q,{color:`permission`,children:[`⧈ Sandbox blocked `,n,` total `,n===1?`operation`:`operations`]})}),e.map((e,t)=>(0,$.jsx)(K,{paddingLeft:2,children:(0,$.jsxs)(q,{dimColor:!0,children:[dO(e.timestamp),e.command?` ${e.command}:`:``,` `,e.line]})},`${e.timestamp.getTime()}-${t}`)),(0,$.jsx)(K,{paddingLeft:2,children:(0,$.jsxs)(q,{dimColor:!0,children:[`… showing last `,Math.min(10,e.length),` of `,n]})})]})}Fh(),Yp(),J();var pO=[];function mO({mcpClients:e=pO}){let{addNotification:t}=Jp();(0,Q.useEffect)(()=>{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`&&_a(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`&&_a(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)(q,{color:`error`,children:[n.length,` MCP `,n.length===1?`server`:`servers`,` failed`]}),(0,$.jsx)(q,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}),r.length>0&&t({key:`mcp-claudeai-failed`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(q,{color:`error`,children:[r.length,` claude.ai `,r.length===1?`connector`:`connectors`,` `,`unavailable`]}),(0,$.jsx)(q,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}),i.length>0&&t({key:`mcp-needs-auth`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(q,{color:`warning`,children:[i.length,` MCP `,i.length===1?`server needs`:`servers need`,` `,`auth`]}),(0,$.jsx)(q,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}),a.length>0&&t({key:`mcp-claudeai-needs-auth`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(q,{color:`warning`,children:[a.length,` claude.ai`,` `,a.length===1?`connector needs`:`connectors need`,` auth`]}),(0,$.jsx)(q,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}))},[t,e])}J(),sd(),Th();var hO=`Auto mode lets Work Mate handle permission prompts automatically — Work Mate checks each tool call for risky actions and prompt injection before executing. Actions Work Mate identifies as safe are executed, while actions Work Mate identifies as risky are blocked and Work Mate may try a different approach. Ideal for long-running tasks. Sessions are slightly more expensive. Work Mate can make mistakes that allow harmful commands to run, it's recommended to only use in isolated environments. Shift+Tab to change mode.`;fl(),mu(),Yp(),J(),V(),Ou(),o();var gO=5e3;function _O(){let{addNotification:e}=Jp(),t=N(),[n,r]=Q.useState(()=>a(`true`)),i=Q.useRef(new Set),o=Q.useCallback((n,r)=>{let a=`${n}:${r}`;if(i.current.has(a))return;i.current.add(a),Y(`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)(q,{color:`error`,children:[`LSP for `,o,` failed`]}),(0,$.jsx)(q,{dimColor:!0,children:` · /plugin for details`})]}),priority:`medium`,timeoutMs:8e3})},[e,t]),s=Q.useCallback(()=>{if(Jl())return;let e=Xn();if(e.status===`failed`){o(`lsp-manager`,e.error.message),r(!1);return}if(e.status===`pending`||e.status===`not-started`)return;let t=pr();if(t){let e=t.getAllServers();for(let[t,n]of e)n.state===`error`&&n.lastError&&o(t,n.lastError.message)}},[o]);Xc(s,n?gO:null),Q.useEffect(()=>{n&&s()},[s,n])}Ou();var vO=new Map;async function yO(e){if(!e?.trim())return Y(`[binaryCheck] Empty command provided, returning false`),!1;let t=e.trim(),n=vO.get(t);if(n!==void 0)return Y(`[binaryCheck] Cache hit for '${t}': ${n}`),n;let r=!1;return await Wd(t).catch(()=>null)&&(r=!0),vO.set(t,r),Y(`[binaryCheck] Binary '${t}' ${r?`found`:`not found`}`),r}xd(),Ou(),Ii();var bO=5;function xO(e){return gd.has(e.toLowerCase())}function SO(e){if(!e)return null;if(typeof e==`string`)return Y(`[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=wO(t);if(e)return e}return null}return wO(e)}function CO(e){return typeof e==`object`&&!!e}function wO(e){let t=new Set,n=null;for(let[r,i]of Object.entries(e)){if(!CO(i))continue;!n&&typeof i.command==`string`&&(n=i.command);let e=i.extensionToLanguage;if(CO(e))for(let n of Object.keys(e))t.add(n.toLowerCase())}return!n||t.size===0?null:{extensions:t,command:n}}async function TO(){let e=new Map;try{let t=await ia();for(let n of Object.keys(t))try{let t=await Oi(n),r=xO(n);for(let i of t.plugins){if(!i.lspServers)continue;let t=SO(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){Y(`[lspRecommendation] Failed to load marketplace ${n}: ${e}`)}}catch(e){Y(`[lspRecommendation] Failed to load marketplaces config: ${e}`)}return e}async function EO(e){if(kO())return Y(`[lspRecommendation] Recommendations are disabled`),[];let t=Mg(e).toLowerCase();if(!t)return Y(`[lspRecommendation] No file extension found`),[];Y(`[lspRecommendation] Looking for LSP plugins for ${t}`);let n=await TO(),r=yd().lspRecommendationNeverPlugins??[],i=[];for(let[e,a]of n)if(a.extensions.has(t)){if(r.includes(e)){Y(`[lspRecommendation] Skipping ${e} (in never suggest list)`);continue}if(Ji(e)){Y(`[lspRecommendation] Skipping ${e} (already installed)`);continue}i.push({info:a,pluginId:e})}let a=[];for(let{info:e,pluginId:t}of i)await yO(e.command)?(a.push({info:e,pluginId:t}),Y(`[lspRecommendation] Binary '${e.command}' found for ${t}`)):Y(`[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 DO(e){Cd(t=>{let n=t.lspRecommendationNeverPlugins??[];return n.includes(e)?t:{...t,lspRecommendationNeverPlugins:[...n,e]}}),Y(`[lspRecommendation] Added ${e} to never suggest`)}function OO(){Cd(e=>{let t=(e.lspRecommendationIgnoredCount??0)+1;return{...e,lspRecommendationIgnoredCount:t}}),Y(`[lspRecommendation] Incremented ignored count`)}function kO(){let e=yd();return e.lspRecommendationDisabled===!0||(e.lspRecommendationIgnoredCount??0)>=bO}l(),J(),Md(),Ii();function AO(){let[e,t]=Q.useState(null),n=Q.useRef(!1),r=Q.useCallback(r=>{e||n.current||(n.current=!0,r().then(e=>{e&&t(e)}).catch(Pd).finally(()=>{n.current=!1}))},[e]);return{recommendation:e,clearRecommendation:Q.useCallback(()=>t(null),[]),tryResolve:r}}async function jO(e,t,n,r,i){try{let a=await Fs(e);if(!a)throw Error(`Plugin ${e} not found in marketplace`);await i(a),r({key:`${n}-installed`,jsx:(0,$.jsxs)(q,{color:`success`,children:[u.tick,` `,t,` installed · restart to apply`]}),priority:`immediate`,timeoutMs:5e3})}catch(e){Pd(e),r({key:`${n}-install-failed`,jsx:(0,$.jsxs)(q,{color:`error`,children:[`Failed to install `,t]}),priority:`immediate`,timeoutMs:5e3})}}mu(),Yp(),V(),xd(),Ou(),Md(),sd();var MO=28e3;function NO(){let e=U(e=>e.fileHistory.trackedFiles),{addNotification:t}=Jp(),n=Q.useRef(new Set),{recommendation:r,clearRecommendation:i,tryResolve:a}=AO();return Q.useEffect(()=>{a(async()=>{if(Vl())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 EO(e))[0];if(t)return Y(`[useLspPluginRecommendation] Found match: ${t.pluginName} for ${e}`),Ll(!0),{pluginId:t.pluginId,pluginName:t.pluginName,pluginDescription:t.description,fileExtension:Mg(e),shownAt:Date.now()}}catch(e){Pd(e)}return null})},[e,a]),{recommendation:r,handleResponse:Q.useCallback(e=>{if(!r)return;let{pluginId:n,pluginName:a,shownAt:o}=r;switch(Y(`[useLspPluginRecommendation] User response: ${e} for ${a}`),e){case`yes`:jO(n,a,`lsp-plugin`,t,async e=>{Y(`[useLspPluginRecommendation] Installing plugin: ${n}`);let t=typeof e.entry.source==`string`?Ng(e.marketplaceInstallLocation,e.entry.source):void 0;await rr(n,e.entry,`user`,void 0,t),rd(`userSettings`,{enabledPlugins:{...md(`userSettings`)?.enabledPlugins,[n]:!0}}),Y(`[useLspPluginRecommendation] Plugin installed: ${n}`)});break;case`no`:{let e=Date.now()-o;e>=MO&&(Y(`[useLspPluginRecommendation] Timeout detected (${e}ms), incrementing ignored count`),OO());break}case`never`:DO(n);break;case`disable`:Cd(e=>e.lspRecommendationDisabled?e:{...e,lspRecommendationDisabled:!0});break}i()},[r,t,i])}}J(),Om(),Gh();var PO=3e4;function FO({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`),PO,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)(qh,{title:`LSP Plugin Recommendation`,children:(0,$.jsxs)(K,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(K,{marginBottom:1,children:(0,$.jsx)(q,{dimColor:!0,children:`LSP provides code intelligence like go-to-definition and error checking`})}),(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{dimColor:!0,children:`Plugin:`}),(0,$.jsxs)(q,{children:[` `,e]})]}),t&&(0,$.jsx)(K,{children:(0,$.jsx)(q,{dimColor:!0,children:t})}),(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{dimColor:!0,children:`Triggered by:`}),(0,$.jsxs)(q,{children:[` `,n,` files`]})]}),(0,$.jsx)(K,{marginTop:1,children:(0,$.jsx)(q,{children:`Would you like to install this LSP plugin?`})}),(0,$.jsx)(K,{children:(0,$.jsx)(km,{options:[{label:(0,$.jsxs)(q,{children:[`Yes, install `,(0,$.jsx)(q,{bold:!0,children:e})]}),value:`yes`},{label:`No, not now`,value:`no`},{label:(0,$.jsxs)(q,{children:[`Never for `,(0,$.jsx)(q,{bold:!0,children:e})]}),value:`never`},{label:`Disable all LSP recommendations`,value:`disable`}],onChange:a,onCancel:()=>r(`no`)})})]})})}Yp(),qd(),Ou(),G();function IO(){let e=Q.useSyncExternalStore(qi,Gr),{addNotification:t}=Jp(),{recommendation:n,clearRecommendation:r,tryResolve:i}=AO();return Q.useEffect(()=>{e&&i(async()=>{let t=await kn(e);return t&&(Y(`[useClaudeCodeHintRecommendation] surfacing ${t.pluginId} from ${t.sourceCommand}`),b()),Gr()===e&&Tr(),t})},[e,i]),{recommendation:n,handleResponse:Q.useCallback(e=>{if(n){switch(Tt(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;jO(e,r,`hint-plugin`,t,async t=>{let n=await dr({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`:Pe();break;case`no`:break}r()}},[n,t,r])}}J(),Om(),Gh();var LO=3e4;function RO({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`),LO,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)(qh,{title:`Plugin Recommendation`,children:(0,$.jsxs)(K,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(K,{marginBottom:1,children:(0,$.jsxs)(q,{dimColor:!0,children:[`The `,(0,$.jsx)(q,{bold:!0,children:r}),` command suggests installing a plugin.`]})}),(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{dimColor:!0,children:`Plugin:`}),(0,$.jsxs)(q,{children:[` `,e]})]}),(0,$.jsxs)(K,{children:[(0,$.jsx)(q,{dimColor:!0,children:`Marketplace:`}),(0,$.jsxs)(q,{children:[` `,n]})]}),t&&(0,$.jsx)(K,{children:(0,$.jsx)(q,{dimColor:!0,children:t})}),(0,$.jsx)(K,{marginTop:1,children:(0,$.jsx)(q,{children:`Would you like to install it?`})}),(0,$.jsx)(K,{children:(0,$.jsx)(km,{options:[{label:(0,$.jsxs)(q,{children:[`Yes, install `,(0,$.jsx)(q,{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`)})})]})})}Om(),Gh();var zO=3e4;function BO({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(),zO,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)(qh,{title:`Tool Recommendation`,children:(0,$.jsx)(km,{options:a,onChange:e=>{e===`__dismiss__`?i.current():(i.current(),r.current(e))}})})}var VO=.15,HO=3;function UO(){let e=Q.useSyncExternalStore(Sr,ot),t=Q.useMemo(()=>e.length===0?[]:e.slice(0,HO).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)>=VO,handleSelect:Q.useCallback(e=>{Qo()},[]),handleDismiss:Q.useCallback(()=>{Qo()},[])}}mu(),hu(),Ou(),wd(),Nu();var WO=`1.1.2396`;function GO(){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 KO(e){let t=GO()?`claude-dev`:`claude`,n=new URL(`${t}://resume`);return n.searchParams.set(`session`,e),n.searchParams.set(`cwd`,gu()),n.toString()}async function qO(){if(GO())return!0;let e=process.platform;if(e===`darwin`)return Iu(`/Applications/Work Mate.app`);if(e===`linux`){let{code:e,stdout:t}=await Td(`xdg-mime`,[`query`,`default`,`x-scheme-handler/claude`]);return e===0&&t.trim().length>0}else if(e===`win32`){let{code:e}=await Td(`reg`,[`query`,`HKEY_CLASSES_ROOT\\claude`,`/ve`]);return e===0}return!1}async function JO(){let e=process.platform;if(e===`darwin`){let{code:e,stdout:t}=await Td(`defaults`,[`read`,`/Applications/Work Mate.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=Ng(e,`AnthropicClaude`);try{let e=(await Vg(t)).filter(e=>e.startsWith(`app-`)).map(e=>e.slice(4)).filter(e=>(0,Sv.coerce)(e)!==null).sort((e,t)=>{let n=(0,Sv.coerce)(e),r=(0,Sv.coerce)(t);return n.compare(r)});return e.length>0?e[e.length-1]:null}catch{return null}}return null}async function YO(){if(!await qO())return{status:`not-installed`};let e;try{e=await JO()}catch{return{status:`ready`,version:`unknown`}}if(!e)return{status:`ready`,version:`unknown`};let t=(0,Sv.coerce)(e);return!t||!Jr(t.version,WO)?{status:`version-too-old`,version:e}:{status:`ready`,version:e}}async function XO(e){let t=process.platform;if(Y(`Opening deep link: ${e}`),t===`darwin`){if(GO()){let{code:t}=await Td(`osascript`,[`-e`,`tell application "Electron" to open location "${e}"`]);return t===0}let{code:t}=await Td(`open`,[e]);return t===0}else if(t===`linux`){let{code:t}=await Td(`xdg-open`,[e]);return t===0}else if(t===`win32`){let{code:t}=await Td(`cmd`,[`/c`,`start`,``,e]);return t===0}return!1}async function ZO(){let e=du();if(!await qO())return{success:!1,error:`Work Mate Desktop is not installed. Install it from https://claude.ai/download`};let t=KO(e);return await XO(t)?{success:!0,deepLinkUrl:t}:{success:!1,error:`Failed to open Work Mate Desktop. Please try opening it manually.`,deepLinkUrl:t}}J(),Ka(),bu(),Bs(),Gs();var QO=`https://clau.de/desktop`;function $O(){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 ek({onDone:e}){let[t,n]=(0,Q.useState)(`checking`),[r,i]=(0,Q.useState)(null),[a,o]=(0,Q.useState)(``);return nl(n=>{if(t===`error`){e(r??`Unknown error`,{display:`system`});return}t===`prompt-download`&&(n===`y`||n===`Y`?(It($O()).catch(()=>{}),e(`Starting download. Re-run /desktop once you\u2019ve installed the app.\nLearn more at ${QO}`,{display:`system`})):(n===`n`||n===`N`)&&e(`The desktop app is required for /desktop. Learn more at ${QO}`,{display:`system`}))}),(0,Q.useEffect)(()=>{async function t(){n(`checking`);let t=await YO();if(t.status===`not-installed`){o(`Work Mate Desktop is not installed.`),n(`prompt-download`);return}if(t.status===`version-too-old`){o(`Work Mate Desktop needs to be updated (found v${t.version}, need v1.1.2396+).`),n(`prompt-download`);return}n(`flushing`),await vn(),n(`opening`);let r=await ZO();if(!r.success){i(r.error??`Failed to open Work Mate Desktop`),n(`error`);return}n(`success`),setTimeout(async e=>{e(`Session transferred to Work Mate Desktop`,{display:`system`}),await fa(0,`other`)},500,e)}t().catch(e=>{i(xu(e)),n(`error`)})},[e]),t===`error`?(0,$.jsxs)(K,{flexDirection:`column`,paddingX:2,children:[(0,$.jsxs)(q,{color:`error`,children:[`Error: `,r]}),(0,$.jsx)(q,{dimColor:!0,children:`Press any key to continue…`})]}):t===`prompt-download`?(0,$.jsxs)(K,{flexDirection:`column`,paddingX:2,children:[(0,$.jsx)(q,{children:a}),(0,$.jsx)(q,{children:`Download now? (y/n)`})]}):(0,$.jsx)(cl,{message:{checking:`Checking for Work Mate Desktop…`,flushing:`Saving session…`,opening:`Opening Work Mate Desktop…`,success:`Opening in Work Mate Desktop…`}[t]})}J(),qd(),xd(),Om(),Gh();var tk={enable_shortcut_tip:!1,enable_startup_dialog:!1};function nk(){return tk}function rk(){return process.platform===`darwin`||process.platform===`win32`&&process.arch===`x64`}function ik(){if(!rk()||!nk().enable_startup_dialog)return!1;let e=yd();return!(e.desktopUpsellDismissed||(e.desktopUpsellSeenCount??0)>=3)}function ak({onDone:e}){let[t,n]=(0,Q.useState)(!1);if((0,Q.useEffect)(()=>{let e=(yd().desktopUpsellSeenCount??0)+1;Cd(t=>(t.desktopUpsellSeenCount??0)>=e?t:{...t,desktopUpsellSeenCount:e}),X(`tengu_desktop_upsell_shown`,{seen_count:e})},[]),t)return(0,$.jsx)(ek,{onDone:()=>e()});function r(t){switch(t){case`try`:n(!0);return;case`never`:Cd(e=>e.desktopUpsellDismissed?e:{...e,desktopUpsellDismissed:!0}),e();return;case`not-now`:e();return}}return(0,$.jsx)(qh,{title:`Try Work Mate Desktop`,children:(0,$.jsxs)(K,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(K,{marginBottom:1,children:(0,$.jsx)(q,{children:`Same Work Mate with visual diffs, live app preview, parallel sessions, and more.`})}),(0,$.jsx)(km,{options:[{label:`Open in Work Mate Desktop`,value:`try`},{label:`Not now`,value:`not-now`},{label:`Don't ask again`,value:`never`}],onChange:r,onCancel:()=>r(`not-now`)})]})})}Yp(),J(),V(),Ou(),Vd();function ok(){let{addNotification:e}=Jp(),t=U(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(!t){Y(`No installation status to monitor`);return}n!==0&&(Y(`Plugin installation status: ${r} failed marketplaces, ${i} failed plugins`),n!==0&&(Y(`Adding notification for ${n} failed installations`),e({key:`plugin-install-failed`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(q,{color:`error`,children:[n,` `,zd(n,`plugin`),` failed to install`]}),(0,$.jsx)(q,{dimColor:!0,children:` · /plugin for details`})]}),priority:`medium`})))},[e,n,r,i])}Yp(),J(),Ou(),$h();function sk(){let{addNotification:e}=Jp(),[t,n]=(0,Q.useState)([]);(0,Q.useEffect)(()=>eg(e=>{Y(`Plugin autoupdate notification: ${e.length} plugin(s) updated`),n(e)}),[]),(0,Q.useEffect)(()=>{if(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)(q,{color:`success`,children:[n.length===1?`Plugin`:`Plugins`,` updated: `,r]}),(0,$.jsx)(q,{dimColor:!0,children:` · Run /reload-plugins to apply`})]}),priority:`low`,timeoutMs:1e4}),Y(`Showing plugin autoupdate notification for: ${n.join(`, `)}`)},[t,e])}Ou(),Md(),Ii(),nh(),qd();function ck(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 lk(e){Y(`performBackgroundPluginInstallations called`);try{let t=eh(vs(),await ia().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;Y(`Installing ${n.length} marketplace(s) in background`);let r=await $m({onProgress:t=>{switch(t.type){case`installing`:ck(e,t.name,`installing`);break;case`installed`:ck(e,t.name,`installed`);break;case`failed`:ck(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),ud(`info`,`tengu_marketplace_background_install`,i),r.installed.length>0){Po(),Y(`Auto-refreshing plugins after ${r.installed.length} new marketplace(s) installed`);try{await th(e)}catch(t){Pd(t),Y(`Auto-refresh failed, falling back to needsRefresh: ${t}`,{level:`warn`}),Rt(`performBackgroundPluginInstallations: auto-refresh failed`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}})}}else r.updated.length>0&&(Po(),Rt(`performBackgroundPluginInstallations: marketplaces reconciled`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}}))}catch(e){Pd(e)}}xd(),Ou(),Ii(),xt();async function uk(e){if(Y(`performStartupChecks called`),!Sd()){Y(`Trust not accepted for current directory - skipping plugin installations`);return}try{Y(`Starting background plugin installations`),await pa()&&(Po(),Rt(`performStartupChecks: seed marketplaces changed`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}})),await lk(e)}catch(e){Y(`Error initiating background plugin installations: ${e}`)}}J();var dk=/https?:\/\/\S+/;function fk(){let[e,t]=(0,Q.useState)(af.getInstance().getStatus());return(0,Q.useEffect)(()=>af.getInstance().subscribe(t),[]),!e.isAuthenticating&&!e.error&&e.output.length===0||!e.isAuthenticating&&!e.error?null:(0,$.jsxs)(K,{flexDirection:`column`,borderStyle:`round`,borderColor:`permission`,paddingX:1,marginY:1,children:[(0,$.jsx)(q,{bold:!0,color:`permission`,children:`Cloud Authentication`}),e.output.length>0&&(0,$.jsx)(K,{flexDirection:`column`,marginTop:1,children:e.output.slice(-5).map((e,t)=>{let n=e.match(dk);if(!n)return(0,$.jsx)(q,{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)(q,{dimColor:!0,children:[a,(0,$.jsx)(Fc,{url:r,children:r}),o]},t)})}),e.error&&(0,$.jsx)(K,{marginTop:1,children:(0,$.jsx)(q,{color:`error`,children:e.error})})]})}Yp(),J(),ta(),mf(),fc();function pk(e){let{addNotification:t}=Jp(),n=sS(),r=(0,Q.useMemo)(()=>ho(n,e),[n,e]),i=(0,Q.useMemo)(()=>xa(n),[n]),a=(0,Q.useRef)(null),o=Hf(),s=Xr(),c=o===`team`||o===`enterprise`,[l,u]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{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)(()=>{r&&r!==a.current&&(a.current=r,t({key:`rate-limit-warning`,jsx:(0,$.jsx)(q,{children:(0,$.jsx)(q,{color:`warning`,children:r})}),priority:`high`}))},[r,t])}Yp();function mk(e){let{addNotification:t}=Jp(),n=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{let r=xg(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])}o();var hk=``;function gk(){YD(async()=>Rd()||a(process.env.DISABLE_INSTALLATION_CHECKS)||await wp()===`development`?null:{timeoutMs:15e3,key:`npm-deprecation-warning`,text:hk,color:`warning`,priority:`high`})}Yp(),J(),xd(),Cn();var _k=5;function vk({ideSelection:e,mcpClients:t,ideInstallationStatus:n}){let{addNotification:r,removeNotification:i}=Jp(),{status:a,ideName:o}=oS(t),s=(0,Q.useRef)(!1),c=n?F(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(nr()||a!==null||p){i(`ide-status-hint`);return}if(s.current||(yd().ideHintShownCount??0)>=_k)return;let e=setTimeout((e,t)=>{Lt(!0).then(n=>{let r=n[0]?.name;r&&!e.current&&(e.current=!0,Cd(e=>({...e,ideHintShownCount:(e.ideHintShownCount??0)+1})),t({key:`ide-status-hint`,jsx:(0,$.jsxs)(q,{dimColor:!0,children:[`/ide for `,(0,$.jsx)(q,{color:`ide`,children:r})]}),priority:`low`}))})},3e3,s,r);return()=>clearTimeout(e)},[r,i,a,p]),(0,Q.useEffect)(()=>{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(!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(!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])}xd();var yk=[e=>{if(xk(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(xk(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 bk(){YD(()=>{let e=yd(),t=[];for(let n of yk){let r=n(e);r&&t.push(r)}return t.length>0?t:null})}function xk(e){return e!==void 0&&Date.now()-e<3e3}mf(),J(),qd(),xd();var Sk=3;function Ck(){YD(async()=>{if((yd().subscriptionNoticeCount??0)>=Sk)return null;let e=await wk();return e===null?null:(Cd(e=>({...e,subscriptionNoticeCount:(e.subscriptionNoticeCount??0)+1})),X(`tengu_switch_to_subscription_notice_shown`,{}),{key:`switch-to-subscription`,jsx:(0,$.jsxs)(q,{color:`suggestion`,children:[`Use your existing Work Mate `,e,` plan with Work Mate`]}),priority:`low`})})}async function wk(){if(gf())return null;let e=await Ff();return e?e.account.has_claude_max?`Max`:e.account.has_claude_pro?`Pro`:null:null}Yp(),V(),_f(),$d();var Tk=`fast-mode-cooldown-started`,Ek=`fast-mode-cooldown-expired`,Dk=`fast-mode-org-changed`,Ok=`fast-mode-overage-rejected`;function kk(){let{addNotification:e}=Jp(),t=U(e=>e.fastMode),n=N();(0,Q.useEffect)(()=>{if(df())return Sf(r=>{r?e({key:Dk,color:`fastMode`,priority:`immediate`,text:`Fast mode is now available · /fast to turn on`}):t&&(n(e=>({...e,fastMode:!1})),e({key:Dk,color:`warning`,priority:`immediate`,text:`Fast mode has been disabled by your organization`}))})},[e,t,n]),(0,Q.useEffect)(()=>{if(df())return bf(t=>{n(e=>({...e,fastMode:!1})),e({key:Ok,color:`warning`,priority:`immediate`,text:t})})},[e,n]),(0,Q.useEffect)(()=>{if(!t)return;let n=xf((t,n)=>{let r=Ak(n,nf(t-Date.now(),{hideTrailingZeros:!0}));e({key:Tk,invalidates:[Ek],text:r,color:`warning`,priority:`immediate`})}),r=uf(()=>{e({key:Ek,invalidates:[Tk],color:`fastMode`,text:`Fast limit reset · now using fast mode`,priority:`immediate`})});return()=>{n(),r()}},[e,t])}function Ak(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}`}}J(),Yn();function jk({onRun:e,onCancel:t,reason:n}){let r=(0,Q.useRef)(!1);return Vc(`confirm:no`,t,{context:`Confirmation`}),(0,Q.useEffect)(()=>{r.current||(r.current=!0,e())},[e]),(0,$.jsxs)(K,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(K,{children:(0,$.jsx)(q,{bold:!0,children:`Running feedback capture...`})}),(0,$.jsx)(K,{children:(0,$.jsxs)(q,{dimColor:!0,children:[`Press `,(0,$.jsx)(Oc,{shortcut:`Esc`,action:`cancel`}),` anytime`]})}),(0,$.jsx)(K,{children:(0,$.jsxs)(q,{dimColor:!0,children:[`Reason: `,n]})})]})}function Mk(e){switch(e){case`feedback_survey_bad`:return!1;case`feedback_survey_good`:return!1;default:return!1}}function Nk(e){return`/issue`}function Pk(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 Fk(){return null}function Ik(e,t){return!1}rg(),J(),xd(),Hm();function Lk(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||!(yd().copyOnSelect??!0))return;let a=e.copySelectionNoClear();if(!a?.trim()){r.current=!0;return}r.current=!0,i.current?.(a)})},[t,e])}function Rk(e){let[t]=Mc();(0,Q.useEffect)(()=>{e.setSelectionBgColor(Vm(t).selectionBg)},[e,t])}Yp(),J(),Yn(),Ou();var zk=40,Bk=.3,Vk=6,Hk=200,Uk=15,Wk=15,Gk=3,Kk=1500,qk=150,Jk=5,Yk=5,Xk=80,Zk=3,Qk=6,$k=500;function eA(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 tA(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 nA(e,t,n){if(!e.xtermJs){if(e.wheelMode&&n-e.time>Kk&&(e.wheelMode=!1,e.burstCount=0,e.mult=e.base),e.pendingFlip){if(e.pendingFlip=!1,t!==e.dir||n-e.time>Hk)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<Yk)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/qk),n=Math.max(Wk,e.base*2),i=1+(e.mult-1)*t+Uk*t;return e.mult=Math.min(n,i,e.mult+Gk),Math.floor(e.mult)}if(r>zk)e.mult=e.base;else{let t=Math.max(Vk,e.base*2);e.mult=Math.min(t,e.mult+Bk)}return Math.floor(e.mult)}let r=n-e.time,i=t===e.dir;if(e.time=n,e.dir=t,i&&r<Yk)return 1;if(!i||r>$k)e.mult=2,e.frac=0;else{let t=.5**(r/qk);e.mult=Math.min(r>=Xk?Zk:Qk,1+(e.mult-1)*t+Jk*t)}let a=e.mult+e.frac,o=Math.floor(a);return e.frac=a-o,o}function rA(){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 iA(e=!1,t=1){return{time:0,mult:t,dir:0,xtermJs:e,frac:0,base:t,pendingFlip:!1,wheelMode:!1,burstCount:0}}function aA(){let e=rl(),t=rA();return Y(`wheel accel: ${e?`decay (xterm.js)`:`window (native)`} · base=${t} · TERM_PROGRAM=${process.env.TERM_PROGRAM??`unset`}`),iA(e,t)}var oA=2,sA=50,cA=200;function lA({scrollRef:e,isActive:t,onScroll:n,isModal:r=!1}){let i=ol(),{addNotification:a}=Jp(),o=(0,Q.useRef)(null);function s(e){let t=al(),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 jc({"scroll:pageUp":()=>{let t=e.current;if(!t)return;let r=-Math.max(1,Math.floor(t.getViewportHeight()/2));l(t,r);let i=fA(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=fA(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=aA()),mA(t,nA(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=aA());let r=pA(t,nA(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}),jc({"scroll:halfPageUp":()=>{let t=e.current;if(!t)return;let r=-Math.max(1,Math.floor(t.getViewportHeight()/2));l(t,r);let i=fA(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=fA(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=fA(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=fA(t,r);n?.(i,t)}},{context:`Scroll`,isActive:t}),nl((t,r,i)=>{let a=e.current;if(!a)return;let o=gA(a,hA(t,r),e=>l(a,e));o!==null&&(n?.(o,a),i.stopImmediatePropagation())},{isActive:t&&r}),nl((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=tA(t);if(r){i.moveFocus(r),n.stopImmediatePropagation();return}eA(t)&&i.clearSelection()},{isActive:t}),uA(e,i,t,n),Lk(i,t,s),Rk(i),null}function uA(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>cA){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(oA,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(oA,e-i.getScrollTop());t.captureScrolledRows(l,l+n-1,`above`),t.shiftAnchor(-n,l,u),i.scrollBy(oA)}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,sA)))}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=dA(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 dA(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 fA(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 pA(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 mA(e,t){if(e.getScrollTop()+e.getPendingDelta()-t<=0){e.scrollTo(0);return}e.scrollBy(-t)}function hA(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 gA(e,t,n){switch(t){case null:return null;case`lineUp`:case`lineDown`:{let r=t===`lineDown`?1:-1;return n(r),fA(e,r)}case`halfPageUp`:case`halfPageDown`:{let r=Math.max(1,Math.floor(e.getViewportHeight()/2)),i=t===`halfPageDown`?r:-r;return n(i),fA(e,i)}case`fullPageUp`:case`fullPageDown`:{let r=Math.max(1,e.getViewportHeight()),i=t===`fullPageDown`?r:-r;return n(i),fA(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}}}mu(),qr(),Uu(),l(),J(),Ar(),dh(),Yp(),Ou(),o(),$d(),yo(),cn(),wm(),js(),am(),Dp(),fr(),rt(),bu(),vi(),pi(),Rs(),xd(),fc(),qd(),Wr(),Nd(),Bs(),Ho(),sg(),Lm(),Ca(),vh(),V(),Ci(),Gs(),Lr(),Gn(),Cn(),Rn(),sn(),bi(),sa(),Or(),gc();var _A=3e3;function vA({showAllInTranscript:e,virtualScroll:t,searchBadge:n,suppressShowAll:r=!1,status:i}){let a=Re(`app:toggleTranscript`,`Global`,`ctrl+o`),o=Re(`transcript:toggleShowAll`,`Transcript`,`ctrl+e`);return(0,$.jsxs)(K,{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)(q,{dimColor:!0,children:[`Showing detailed transcript · `,a,` to toggle`,n?` · n/N to navigate`:t?` · ${u.arrowUp}${u.arrowDown} scroll · home/end top/bottom`:r?``:` · ${o} to ${e?`collapse`:`show all`}`]}),i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(K,{flexGrow:1}),(0,$.jsxs)(q,{children:[i,` `]})]}):n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(K,{flexGrow:1}),(0,$.jsxs)(q,{dimColor:!0,children:[n.current,`/`,n.count,` `]})]}):null]})}function yA({jumpRef:e,count:t,current:n,onClose:r,onCancel:i,setHighlight:a,initialQuery:o}){let{query:s,cursorOffset:c}=Ah({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)(K,{borderTopDimColor:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,borderStyle:`single`,marginTop:1,paddingLeft:2,width:`100%`,noSelect:!0,children:[(0,$.jsx)(q,{children:`/`}),(0,$.jsx)(q,{children:s.slice(0,f)}),(0,$.jsx)(q,{inverse:!0,children:p}),f<s.length&&(0,$.jsx)(q,{children:s.slice(f+1)}),(0,$.jsx)(K,{flexGrow:1}),l===`building`?(0,$.jsx)(q,{dimColor:!0,children:`indexing… `}):l?(0,$.jsxs)(q,{dimColor:!0,children:[`indexed in `,l.ms,`ms `]}):t===0&&s?(0,$.jsx)(q,{color:`error`,children:`no matches `}):t>0?(0,$.jsxs)(q,{dimColor:!0,children:[n,`/`,t,` `]}):null]})}var bA=[`⠂`,`⠐`],xA=`✳`,SA=960;function CA({isAnimating:e,title:t,disabled:n,noPrefix:r}){let i=Hc(),[a,o]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{if(n||r||!e||!i)return;let t=setInterval(e=>e(e=>(e+1)%bA.length),SA,o);return()=>clearInterval(t)},[n,r,e,i]);let s=e?bA[a]??xA:xA;return Wc(n?null:r?t:`${s} ${t}`),null}var wA=`<${jd}>`;function TA(e){return e.type===`text`&&typeof e.text==`string`&&e.text.includes(wA)}function EA({commands:t,debug:n,initialTools:r,initialMessages:i,pendingHookMessages:o,initialFileHistorySnapshots:s,initialContentReplacements:c,initialAgentName:l,initialAgentColor:u,mcpClients:d,dynamicMcpConfig:f,autoConnectIdeFlag:p,strictMcpConfig:m=!1,systemPrompt:h,appendSystemPrompt:g,onBeforeQuery:_,onTurnComplete:b,disabled:x=!1,mainThreadAgentDefinition:S,disableSlashCommands:C=!1,taskListId:T,thinkingConfig:E}){let D=(0,Q.useMemo)(()=>a(process.env.CLAUDE_CODE_DISABLE_TERMINAL_TITLE),[]),A=(0,Q.useMemo)(()=>a(process.env.CLAUDE_CODE_DISABLE_VIRTUAL_SCROLL),[]);(0,Q.useMemo)(()=>a(process.env.CLAUDE_CODE_DISABLE_MESSAGE_ACTIONS),[]),(0,Q.useEffect)(()=>(Y(`[REPL:mount] REPL mounted, disabled=${x}`),()=>Y(`[REPL:unmount] REPL unmounting`)),[x]);let[j,M]=(0,Q.useState)(S),ee=U(e=>e.toolPermissionContext),te=U(e=>e.verbose),F=U(e=>e.mcp),I=U(e=>e.plugins),L=U(e=>e.agentDefinitions),re=U(e=>e.fileHistory),ie=U(e=>e.initialMessage),ae=nS(),oe=U(e=>e.spinnerTip),se=U(e=>e.expandedView)===`tasks`,ce=U(e=>e.tasks),R=U(e=>e.elicitation),z=U(e=>e.viewingAgentTaskId),B=N(),fe=z?ce[z]:void 0,pe=wa(fe)&&fe.retain&&!fe.diskLoaded;(0,Q.useEffect)(()=>{if(!z||!pe)return;let e=z;v(Ps(e)).then(t=>{B(n=>{let r=n.tasks[e];if(!wa(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}}}})})},[z,pe,B]);let me=no(),he=Ic(),ge=_h(),[V,_e]=(0,Q.useState)(t);dD(lu(),_e);let ye=Q.useSyncExternalStore(Ie,ve),be=Q.useSyncExternalStore(Ie,tc),xe=(0,Q.useMemo)(()=>Mn(ee),[ee,ye]);cO();let[Se,Ce]=(0,Q.useState)(f),we=(0,Q.useCallback)(e=>{Ce(e)},[Ce]),[Te,Ee]=(0,Q.useState)(`prompt`),[Oe,ke]=(0,Q.useState)(!1),[je,Me]=(0,Q.useState)(!1),[Ne,Pe]=(0,Q.useState)(``),Fe=(0,Q.useRef)(0),Le=(0,Q.useRef)(void 0),Re=(0,Q.useRef)(!1),{addNotification:ze,removeNotification:Be}=Jp(),Ue=lD(d,F.clients),[Ge,Ke]=(0,Q.useState)(void 0),[qe,Ye]=(0,Q.useState)(null),[Xe,Ze]=(0,Q.useState)(null),[$e,et]=(0,Q.useState)(!1),[tt,nt]=(0,Q.useState)(()=>ik());bk(),Ck(),vk({ideSelection:Ge,mcpClients:Ue,ideInstallationStatus:Xe}),mO({mcpClients:Ue}),ok(),sk(),Ph(),pk(ge),kk(),mk(ge),gk(),XD(),rO(),_O();let{recommendation:rt,handleResponse:at}=NO(),{recommendation:ot,handleResponse:st}=IO(),ct=UO(),dt=(0,Q.useMemo)(()=>[...xe,...r],[xe,r]);hm({enabled:!0});let ft=jm();(0,Q.useEffect)(()=>{uk(B)},[B]);let mt=lh(dt,F.tools,ee),{tools:ht,allowedAgentTypes:vt}=(0,Q.useMemo)(()=>{if(!j)return{tools:mt,allowedAgentTypes:void 0};let e=mi(j,mt,!1,!0);return{tools:e.resolvedTools,allowedAgentTypes:e.allowedAgentTypes}},[j,mt]),yt=uD(uD(V,I.commands),F.commands),bt=(0,Q.useMemo)(()=>C?[]:yt,[C,yt]);Qv(F.clients),pD(F.clients,Ke);let[xt,St]=(0,Q.useState)(`responding`),Ct=(0,Q.useRef)(xt);Ct.current=xt;let[wt,Tt]=(0,Q.useState)([]),[Et,kt]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{if(Et&&!Et.isStreaming&&Et.streamingEndedAt){let e=3e4-(Date.now()-Et.streamingEndedAt);if(e>0){let t=setTimeout(kt,e,null);return()=>clearTimeout(t)}else kt(null)}},[Et]);let[At,jt]=(0,Q.useState)(null),Mt=(0,Q.useRef)(null);Mt.current=At;let Nt=(0,Q.useRef)(0),[Ft,It]=(0,Q.useState)(!1),Lt=(0,Q.useRef)(()=>{}),Rt=(0,Q.useRef)(null),zt=(0,Q.useRef)(null),Bt=(0,Q.useRef)(0),Vt=Q.useRef(new Yv).current,Ht=Q.useSyncExternalStore(Vt.subscribe,Vt.getSnapshot),[Ut,Wt]=Q.useState(!1),H=Ht||Ut,[Gt,Kt]=Q.useState(void 0),qt=Q.useRef(0),Jt=Q.useRef(!1),Xt=Q.useRef(0),Zt=Q.useRef(0),Qt=Q.useRef(null),$t=Q.useCallback(()=>{Xt.current=Date.now(),Zt.current=0,Qt.current=null},[]),en=Q.useRef(!1);Ht&&!en.current&&$t(),en.current=Ht;let rn=Q.useCallback(e=>{Wt(e),e&&$t()},[$t]),an=Q.useRef(void 0),[on,sn]=Q.useState(!1),[cn,ln]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{cn?.notifications&&cn.notifications.forEach(e=>{ze({key:`auto-updater-notification`,text:e,priority:`low`})})},[cn,ze]),(0,Q.useEffect)(()=>{yi()&&In().then(e=>{e&&ze({key:`tmux-mouse-hint`,text:e,priority:`low`})})},[]);let[dn,fn]=(0,Q.useState)(null),pn=(0,Q.useRef)(null),mn=(0,Q.useCallback)(e=>{if(e?.isLocalJSXCommand){let{clearLocalJSX:t,...n}=e;pn.current={...n,isLocalJSXCommand:!0},fn(n);return}if(pn.current){if(e?.clearLocalJSX){pn.current=null,fn(null),Nt.current=Date.now();return}return}if(e?.clearLocalJSX){fn(null);return}fn(e)},[]),[hn,gn]=(0,Q.useState)([]),[vn,yn]=(0,Q.useState)(null),[Sn,Cn]=(0,Q.useState)([]),[wn,Tn]=(0,Q.useState)([]),kn=U(e=>e.settings.terminalTitleFromRename)===!1?void 0:ko(du()),[An,jn]=(0,Q.useState)(),Pn=(0,Q.useRef)((i?.length??0)>0),Fn=j?.agentType,Rn=kn??Fn??An??`Work Mate`,Bn=hn.length>0||wn.length>0,Vn=dn?.isLocalJSXCommand===!0&&dn?.jsx!=null,Hn=H&&!Bn&&!Vn;(0,Q.useEffect)(()=>{if(H&&!Bn&&!Vn)return Hv(),()=>Uv()},[H,Bn,Vn]);let Un=Bn||Vn?`waiting`:H?`busy`:`idle`,Wn=Un===`waiting`?hn.length>0?`approve ${hn[0].tool.name}`:Vn?`dialog open`:`input needed`:void 0;(0,Q.useEffect)(()=>{Rr({status:Un,waitingFor:Wn})},[Un,Wn]),Kc(null);let[W,Gn]=(0,Q.useState)(i??[]),Kn=(0,Q.useRef)(W),Jn=(0,Q.useRef)(!1),G=(0,Q.useCallback)(e=>{let t=Kn.current,n=typeof e==`function`?e(Kn.current):e;if(Kn.current=n,n.length<qt.current)qt.current=0;else if(n.length>t.length&&Jt.current){let e=n.length-t.length;(t.length===0||n[0]===t[0]?n.slice(-e):n.slice(0,e)).some(bs)?Jt.current=!1:qt.current=n.length}Gn(n)},[]),Yn=(0,Q.useCallback)(e=>{e===void 0?Jt.current=!1:(qt.current=Kn.current.length,Jt.current=!0),Kt(e)},[]),{dividerIndex:Xn,dividerYRef:Zn,onScrollAway:Qn,onRepin:er,jumpToNew:tr,shiftDivider:nr}=cg(W.length);ZD(W,G,H);let[rr,ir]=(0,Q.useState)(null),ar=(0,Q.useRef)(null),sr=(0,Q.useMemo)(()=>ag(W,Xn),[Xn,W.length]),cr=(0,Q.useCallback)(()=>{Rt.current?.scrollToBottom(),er(),ir(null)},[er,ir]),lr=W.at(-1),dr=lr!=null&&bs(lr);(0,Q.useEffect)(()=>{dr&&cr()},[dr,lr,cr]);let fr=(0,Q.useCallback)((e,t)=>{Bt.current=Date.now(),e?er():Qn(t)},[er,Qn,B]),pr=HE(o,G),mr=(0,Q.useDeferredValue)(Q.useMemo(()=>W.length>500?W.slice(-500):W,[W])),_r=W.length-mr.length;_r>0&&Y(`[useDeferredValue] Messages deferred by ${_r} (${mr.length}→${W.length})`);let[vr,yr]=(0,Q.useState)(null),[br,xr]=(0,Q.useState)(()=>yg()),Sr=(0,Q.useRef)(br);Sr.current=br;let Cr=(0,Q.useRef)(null),wr=(0,Q.useCallback)(e=>{Sr.current===``&&e!==``&&Date.now()-Bt.current>=_A&&cr(),Sr.current=e,xr(e),sn(e.trim().length>0)},[sn,cr]);(0,Q.useEffect)(()=>{if(br.trim().length===0)return;let e=setTimeout(sn,1500,!1);return()=>clearTimeout(e)},[br]);let[Tr,Dr]=(0,Q.useState)(`prompt`),[Or,kr]=(0,Q.useState)(),[Ar,Mr]=(0,Q.useState)(new Set),Nr=(0,Q.useRef)(!1),[Pr,Fr]=(0,Q.useState)({}),[Ir,Lr]=(0,Q.useState)(0),zr=(0,Q.useRef)(0),Br=(0,Q.useRef)([]),Vr=(0,Q.useCallback)(e=>{let t=zr.current;if(zr.current=e(t),zr.current>t){let e=Br.current;if(e.length>0){let t=e.at(-1);t.lastTokenTime=Date.now(),t.endResponseLength=zr.current}}},[]),[Hr,Ur]=(0,Q.useState)(null),Wr=!(U(e=>e.settings.prefersReducedMotion)??!1)&&!dl(),Gr=(0,Q.useCallback)(e=>{Wr&&Ur(e)},[Wr]),qr=Hr&&Wr&&Hr.substring(0,Hr.lastIndexOf(`
120
+ `)+1)||null,[Jr,Yr]=(0,Q.useState)(0),[Xr,Qr]=(0,Q.useState)(null),[$r,ei]=(0,Q.useState)(null),[ti,ni]=(0,Q.useState)(null),[ri,ii]=(0,Q.useState)(!1),[ai,oi]=(0,Q.useState)(void 0),[si,ci]=(0,Q.useState)(!1),[li,di]=(0,Q.useState)(zg()),[fi,pi]=(0,Q.useState)(null),hi=(0,Q.useRef)(!1),gi=(0,Q.useRef)(Jr);gi.current=Jr;let[_i]=(0,Q.useState)(()=>({current:ds(i,c)}));Mi(()=>{_i.current=Zi()});let[vi,bi]=(0,Q.useState)(yd().hasAcknowledgedCostThreshold),[xi,Si]=(0,Q.useState)(`INSERT`),[Ci,wi]=(0,Q.useState)(!1),[Ti,Ei]=(0,Q.useState)(!1),[Di,Oi]=(0,Q.useState)(!1),ki=Hc(),Ai=(0,Q.useRef)(ki);Ai.current=ki;let[ji]=Mc(),Ni=Q.useRef(!1),Pi=(0,Q.useCallback)(()=>{if(Ni.current)return;Ni.current=!0;let e=Kn.current.slice(oa.current);for(let t of sc(e))aa.current.add(t);oa.current=Kn.current.length,aO({theme:ji,readFileState:ia.current,bashTools:aa.current}).then(async e=>{if(e){let t=await e.content({theme:ji});B(e=>({...e,spinnerTip:t})),oO(e)}else B(e=>e.spinnerTip===void 0?e:{...e,spinnerTip:void 0})})},[B,ji]),Ii=(0,Q.useCallback)(()=>{rn(!1),Yn(void 0),zr.current=0,Br.current=[],Ur(null),Tt([]),Qr(null),ei(null),ni(null),Pi(),pp(),ba()},[Pi]),Li=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(ee.mode!==`auto`){Li.current=!1;return}if(Li.current||(yd().autoPermissionsNotificationCount??0)>=3)return;let e=setTimeout((e,t)=>{e.current=!0,Cd(e=>{let t=e.autoPermissionsNotificationCount??0;return t>=3?e:{...e,autoPermissionsNotificationCount:t+1}}),t(e=>[...e,bc(hO,`warning`)])},800,Li,G);return()=>clearTimeout(e)},[ee.mode,G]);let Ri=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(Ri.current)return;let e=yc();if(!e?.creationDurationMs||e.usedSparsePaths||e.creationDurationMs<15e3)return;Ri.current=!0;let t=Math.round(e.creationDurationMs/1e3);G(e=>[...e,bc(`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`)])},[G]);let zi=(0,Q.useMemo)(()=>{let e=W.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`&&Ar.has(e.id));return n.length>0&&n.every(e=>e.type===`tool_use`&&e.name===`Sleep`)},[W,Ar]),{onBeforeQuery:Vi,onTurnComplete:Hi,render:Ui}=zE({enabled:!1,setMessages:G,inputValue:br,setInputValue:wr,setToolJSX:mn}),Wi=(!dn||dn.showSpinner===!0)&&hn.length===0&&wn.length===0&&(H||Gt||O()>0)&&!zi&&!qr,Gi=hn.length>0||wn.length>0||Sn.length>0||R.queue.length>0,Ki=ND(W,H,Ir,`session`,Gi),qi=RE(G),Ji=Ik(W,Ir),Xi=(0,Q.useMemo)(()=>({...Ki,handleSelect:e=>{ma.current=!1;let t=Ki.handleSelect(e);e===`bad`&&!t&&Mk(`feedback_survey_bad`)&&(pa(`feedback_survey_bad`),ma.current=!0)}}),[Ki]),$i=VD(W,H,Gi,{enabled:!0}),ta=LD(W,H,Gi,{enabled:!0});wD({autoConnectIdeFlag:p,ideToInstallExtension:qe,setDynamicMcpConfig:Ce,setShowIdeOnboarding:et,setIDEInstallationState:Ze}),lO(s,re,e=>B(t=>({...t,fileHistory:e})));let na=(0,Q.useCallback)(async(t,n,r)=>{let i=performance.now();try{let a=bm(n.messages),o=_s();await ns(`resume`,{getAppState:()=>me.getState(),setAppState:B,signal:AbortSignal.timeout(o),timeoutMs:o});let s=await hr(`resume`,{sessionId:t,agentType:j?.agentType,model:ge});a.push(...s),r===`fork`?Co(n,Fi(t)):rs(n,Fi(t)),Ym(n,B),n.fileHistorySnapshots&&or(n);let{agentDefinition:c}=qm(n.agentSetting,S,L);M(c),B(e=>({...e,agent:c?.agentType})),B(e=>({...e,standaloneAgentContext:Jm(n.agentName,n.agentColor)})),Er(n.agentName),la(a,n.projectPath??nu()),Ii(),jt(null),di(t);let l=oo(t);if(Qi(),Ul(),eu(Fi(t),n.fullPath?jg(n.fullPath):null),await Kr(),gt(),bn(n),n.goal){let{hydrateGoalFromTranscript:r}=(jr(),e(it)),i=new Map;i.set(t,n.goal),r(i,t)}if(Pn.current=!0,jn(void 0),r!==`fork`)Xm(),Zm(n.worktreeSession),On();else{let e=yc();e&&hs(e)}l&&su(l),_i.current&&r!==`fork`&&(_i.current=Fa(a,n.contentReplacements??[])),G(()=>a),mn(null),wr(``),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}},[Ii,B]),[ra]=(0,Q.useState)(()=>Ja(100)),ia=(0,Q.useRef)(ra),aa=(0,Q.useRef)(new Set),oa=(0,Q.useRef)(0),sa=(0,Q.useRef)(new Set),ca=(0,Q.useRef)(new Set),la=(0,Q.useCallback)((e,t)=>{let n=Ln(e,t,100);ia.current=La(ia.current,n);for(let t of sc(e))aa.current.add(t)},[]);(0,Q.useEffect)(()=>{i&&i.length>0&&la(i,nu())},[]);let{status:ua,reverify:da}=UE(),[fa,pa]=(0,Q.useState)(null),ma=(0,Q.useRef)(!1),[ha,ga]=(0,Q.useState)(null),[_a,xa]=(0,Q.useState)(!1),Sa=!H&&si;function Ca(){if(_a||ha)return;if(ri)return`message-selector`;if(on)return;if(Sn[0])return`sandbox-permission`;let e=!dn||dn.shouldContinueAnimation;if(e&&hn[0])return`tool-permission`;if(e&&wn[0])return`prompt`;if(e&&R.queue[0])return`elicitation`;if(e&&Sa)return`cost`;if(e&&fi)return`idle-return`;if(e&&$e)return`ide-onboarding`;if(e&&rt)return`lsp-recommendation`;if(e&&ot)return`plugin-hint`;if(e&&ct.visible)return`search-extra-tools-hint`;if(e&&tt)return`desktop-upsell`}let Ta=Ca(),Ea=on&&(Sn[0]||hn[0]||wn[0]||R.queue[0]||Sa);an.current=Ta,(0,Q.useEffect)(()=>{if(!H)return;let e=Ta===`tool-permission`,t=Date.now();e&&Qt.current===null?Qt.current=t:!e&&Qt.current!==null&&(Zt.current+=t-Qt.current,Qt.current=null)},[Ta,H]);let Da=(0,Q.useRef)(Ta);(0,Q.useLayoutEffect)(()=>{Da.current===`tool-permission`!=(Ta===`tool-permission`)&&cr(),Da.current=Ta},[Ta,cr]);function Oa(){if(Ta!==`elicitation`){if(Nt.current!==0&&Date.now()-Nt.current<500){Nt.current=0,Y(`[onCancel] suppressed: local-jsx panel just dismissed`);return}if(Nt.current=0,Y(`[onCancel] focusedInputDialog=${Ta} streamMode=${xt}`),ro(),Vt.getSnapshot()){let{getGoal:t,pauseGoal:n}=(No(),e(ja)),{persistCurrentGoal:r}=(jr(),e(it));t()?.status===`active`&&(n(),r())}if(It(!0),Vt.forceEnd(),hi.current=!1,Hr?.trim()&&G(e=>[...e,tn({content:Hr})]),Ii(),Hl(null),Ta===`tool-permission`)hn[0]?.onAbort(),gn([]);else if(Ta===`prompt`){for(let e of wn)e.reject(Error(`Prompt cancelled by user`));Tn([]),At?.abort(`user-cancel`)}else At?.abort(`user-cancel`);jt(null),Hi(Kn.current,!0)}}let ka=(0,Q.useCallback)(()=>{let e=En(br,0);e&&(wr(e.text),Dr(`prompt`),e.images.length>0&&Fr(t=>{let n={...t};for(let t of e.images)n[t.id]=t;return n}))},[wr,Dr,br,Fr]),Aa={setToolUseConfirmQueue:gn,onCancel:Oa,onAgentsKilled:()=>G(e=>[...e,Dt()]),isMessageSelectorVisible:ri||!!Ci,screen:Te,abortSignal:At?.signal,popCommandFromQueue:ka,vimMode:xi,isLocalJSXCommand:dn?.isLocalJSXCommand,isSearchingHistory:Ti,isHelpOpen:Di,inputMode:Tr,inputValue:br,streamMode:xt};(0,Q.useEffect)(()=>{pu()>=5&&!si&&!vi&&(X(`tengu_cost_threshold_reached`,{}),bi(!0),zs()&&ci(!0))},[W,si,vi]);let Ma=(0,Q.useCallback)(async e=>new Promise(t=>{let n=!1;function r(e){n||(n=!0,t(e))}Cn(t=>[...t,{hostPattern:e,resolvePromise:r}])}),[B,me]);(0,Q.useEffect)(()=>{let e=pt.getSandboxUnavailableReason();if(e){if(pt.isSandboxRequired()){process.stderr.write(`\nError: sandbox required but unavailable: ${e}\n sandbox.failIfUnavailable is set — refusing to start without a working sandbox.\n\n`),Zr(1,`other`);return}Y(`sandbox disabled: ${e}`,{level:`warn`}),ze({key:`sandbox-unavailable`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{color:`warning`,children:`sandbox disabled`}),(0,$.jsx)(q,{dimColor:!0,children:` · /sandbox`})]}),priority:`medium`})}},[ze]),pt.isSandboxingEnabled()&&pt.initialize(Ma).catch(e=>{process.stderr.write(`\n❌ Sandbox Error: ${xu(e)}\n`),Zr(1,`other`)});let Na=(0,Q.useCallback)((e,t)=>{B(n=>({...n,toolPermissionContext:{...e,mode:t?.preserveMode?n.toolPermissionContext.mode:e.mode}})),setImmediate(e=>{e(e=>(e.forEach(e=>{e.recheckPermission()}),e))},gn)},[B,gn]),Pa=tD(gn,Na),Ra=(0,Q.useCallback)((e,t,r,i)=>{let a=me.getState(),o=()=>{let e=me.getState(),t=lc(e.toolPermissionContext,e.mcp.tools),n=vm(dt,t,e.toolPermissionContext.mode);return j?mi(j,n,!1,!0).resolvedTools:n};return{abortController:r,options:{commands:bt,tools:o(),debug:n,verbose:a.verbose,mainLoopModel:i,thinkingConfig:a.thinkingEnabled===!1?{type:`disabled`}:E,mcpClients:cD(d,a.mcp.clients),mcpResources:a.mcp.resources,ideInstallationStatus:Xe,isNonInteractiveSession:!1,dynamicMcpConfig:Se,theme:ji,agentDefinitions:vt?{...a.agentDefinitions,allowedAgentTypes:vt}:a.agentDefinitions,customSystemPrompt:h,appendSystemPrompt:g,refreshTools:o},getAppState:()=>me.getState(),setAppState:B,messages:e,setMessages:G,updateFileHistoryState(e){B(t=>{let n=e(t.fileHistory);return n===t.fileHistory?t:{...t,fileHistory:n}})},updateAttributionState(e){B(t=>{let n=e(t.attribution);return n===t.attribution?t:{...t,attribution:n}})},openMessageSelector:()=>{x||ii(!0)},onChangeAPIKey:da,readFileState:ia.current,setToolJSX:mn,addNotification:ze,appendSystemMessage:e=>G(t=>[...t,e]),sendOSNotification:e=>{Av(e,he)},onChangeDynamicMcpConfig:we,onInstallIDEExtension:Ye,nestedMemoryAttachmentTriggers:new Set,loadedNestedMemoryPaths:ca.current,dynamicSkillDirTriggers:new Set,discoveredSkillNames:sa.current,setResponseLength:Vr,pushApiMetricsEntry:void 0,setStreamMode:St,onCompactProgress:e=>{switch(e.type){case`hooks_start`:ei(`claudeBlue_FOR_SYSTEM_SPINNER`),ni(`claudeBlueShimmer_FOR_SYSTEM_SPINNER`),Qr(e.hookType===`pre_compact`?`Running PreCompact hooks…`:e.hookType===`post_compact`?`Running PostCompact hooks…`:`Running SessionStart hooks…`);break;case`compact_start`:Qr(`Compacting conversation`);break;case`compact_end`:Qr(null),ei(null),ni(null);break}},setInProgressToolUseIDs:Mr,setHasInterruptibleToolInProgress:e=>{Nr.current=e},resume:na,setConversationId:di,requestPrompt:void 0,contentReplacementState:_i.current}},[bt,dt,j,n,d,Xe,Se,ji,vt,me,B,da,ze,G,we,na,(0,Q.useCallback)((e,t)=>n=>new Promise((r,i)=>{Tn(a=>[...a,{request:n,title:e,toolInputSummary:t,resolve:r,reject:i}])}),[]),x,h,g,di]),{handleBackgroundSession:za}=ED({setMessages:G,setIsLoading:rn,resetLoadingState:Ii,setAbortController:jt,onBackgroundQuery:(0,Q.useCallback)(()=>{At?.abort(`background`);let e=Sc(e=>e.mode===`task-notification`);(async()=>{let t=Ra(Kn.current,[],new AbortController,ge),[n,r,i]=await Promise.all([ui(t.options.tools,ge,Array.from(ee.additionalWorkingDirectories.keys()),t.options.mcpClients),le(),Nn()]),a=pc({mainThreadAgentDefinition:j,toolUseContext:t,customSystemPrompt:h,defaultSystemPrompt:n,appendSystemPrompt:g});t.renderedSystemPrompt=a;let o=(await ks(e).catch(()=>[])).map(y),s=new Set;for(let e of Kn.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)));so({messages:[...Kn.current,...c],queryParams:{systemPrompt:a,userContext:r,systemContext:i,canUseTool:Pa,toolUseContext:t,querySource:Ae()},description:Rn,setAppState:B,agentDefinition:j})})()},[At,ge,ee,j,Ra,h,g,Pa,B])}),Ba=(0,Q.useCallback)(t=>{_n(t,t=>{if(w(t)?(yi()?G(e=>{let n=de(e,{includeSnipped:!0});return[...n.length>500?n.slice(-500):n,t]}):G(()=>[t]),di(zg()),Pt(!1)):t.type===`progress`&&oc(t.data?.type)?G(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]}):G(e=>[...e,t]),t.type===`assistant`&&`isApiErrorMessage`in t&&t.isApiErrorMessage?Pt(!0):t.type===`assistant`&&Pt(!1),t.type===`assistant`&&`isApiErrorMessage`in t&&t.isApiErrorMessage){let n=(zn(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}=(No(),e(ja)),{persistCurrentGoal:r}=(jr(),e(it));t()?.status===`active`&&(n(),r(),ze({key:`goal-auto-paused-connectivity-error`,text:`Detected connection error. Active goal was auto-paused. Run /goal resume after network recovers.`,priority:`immediate`}))}}},e=>{Vr(t=>t+e.length)},St,Tt,e=>{G(t=>t.filter(t=>t!==e)),ut(e.uuid)},kt,e=>{let t=Date.now(),n=zr.current;Br.current.push({...e,firstTokenTime:t,lastTokenTime:t,responseLengthBaseline:n,endResponseLength:n})},Gr)},[G,Vr,St,Tt,kt,Gr]),Va=(0,Q.useCallback)(async(e,t,n,r,i,a)=>{if(r){let e=cD(d,me.getState().mcp.clients);va.handleQueryStart(e);let t=nn(e);t&&Ot(t)}if(np(),!D&&!kn&&!Fn&&!Pn.current){let e=t.find(e=>e.type===`user`&&!e.isMeta),n=e?.type===`user`?zn(e.message.content):null;n&&!n.startsWith(`<local-command-stdout>`)&&!n.startsWith(`<command-message>`)&&!n.startsWith(`<command-name>`)&&!n.startsWith(`<bash-input>`)&&(Pn.current=!0,Um(n,new AbortController().signal).then(e=>{e?jn(e):Pn.current=!1},()=>{Pn.current=!1}))}if(me.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(w)&&(di(zg()),Pt(!1)),Ii(),jt(null);return}let o=Ra(e,t,n,a),{tools:s,mcpClients:c}=o.options;ya(`query_context_loading_start`);let[,,l,u,f]=await Promise.all([void 0,sO(ee,B,me.getState().fastMode),ui(s,a,Array.from(ee.additionalWorkingDirectories.keys()),c),le(),Nn()]),p={...u,...ve()&&!Ai.current?{terminalFocus:`The terminal is unfocused — the user is not actively watching.`}:{}};ya(`query_context_loading_end`);let m=pc({mainThreadAgentDefinition:j,toolUseContext:o,customSystemPrompt:h,defaultSystemPrompt:l,appendSystemPrompt:g});o.renderedSystemPrompt=m,ya(`query_query_start`),$l(),ru(),tu();for await(let t of gr({messages:e,systemPrompt:m,userContext:p,systemContext:f,canUseTool:Pa,toolUseContext:o,querySource:Ae()}))Ba(t);ya(`query_end`),Ii(),po(),await b?.(Kn.current)},[d,Ii,Ra,ee,B,h,b,g,Pa,j,Ba,kn,D]),Ha=(0,Q.useCallback)(async(e,t,n,r,i,a,o)=>{let s=Vt.tryStart();if(s===null)return X(`tengu_concurrent_onquery_detected`,{}),e.filter(e=>e.type===`user`&&!e.isMeta).map(e=>zn(e.message.content)).filter(e=>e!==null).forEach((e,t)=>{Yt({value:e,mode:`prompt`}),t===0&&X(`tengu_concurrent_onquery_enqueued`,{})}),!1;try{It(!1),$t(),G(t=>[...t,...e]),zr.current=0,Hl((o?xn(o):null)??zl()),Br.current=[],Tt([]),Ur(null);let s=Kn.current;if(o&&await Vi(o,s,e.length),a&&o&&!await a(o,s))return!0;await Va(s,e,t,n,r,i)}finally{if(Vt.end(s)){It(t.signal.aborted),Yr(Date.now()),hi.current=!1,Ii(),await Hi(Kn.current,t.signal.aborted);let e;zl()!==null&&zl()>0&&!t.signal.aborted&&(e={tokens:Fl(),limit:zl(),nudges:au()}),Hl(null);let n=Date.now()-Xt.current-Zt.current;(n>3e4||e!==void 0)&&!t.signal.aborted&&!ye&&G(t=>[...t,P(n,e,fd(t,ue))]),jt(null)}if(t.signal.reason===`user-cancel`&&!Vt.isActive&&Sr.current===``&&O()===0&&!me.getState().viewingAgentTaskId){let e=Kn.current,t=e.findLast(xm);t&&Sm(e,e.lastIndexOf(t))&&(sm(),Lt.current(t))}}return!0},[Va,B,Ii,Vt,Vi,Hi]),Ua=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{let e=ie;if(!e||H||Ua.current)return;Ua.current=!0;async function t(e){if(e.clearContext){let t=e.message.planContent?Mo():void 0,{clearConversation:n}=await import(`./conversation-CoGharlH.js`);await n({setMessages:G,readFileState:ia.current,discoveredSkillNames:sa.current,loadedNestedMemoryPaths:ca.current,getAppState:()=>me.getState(),setAppState:B,setConversationId:di}),Pn.current=!1,jn(void 0),aa.current.clear(),oa.current=0,t&&ao(du(),t)}B(t=>{let n=e.mode?Hs(t.toolPermissionContext,nx(e.mode,e.allowedPrompts)):t.toolPermissionContext;return e.mode===`auto`&&(n=qa({...n,mode:`auto`,prePlanMode:void 0})),{...t,initialMessage:null,toolPermissionContext:n}}),$n()&&_t(e=>{B(t=>({...t,fileHistory:e(t.fileHistory)}))},e.message.uuid),await pr();let t=e.message.message.content;if(typeof t==`string`&&!e.message.planContent)Wa(t,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}});else{let t=Bi();jt(t),Ha([e.message],t,!0,[],ge)}setTimeout(e=>{e.current=!1},100,Ua)}t(e)},[ie,H,G,B,Ha,ge,ht]);let Wa=(0,Q.useCallback)(async(e,t,n,r)=>{if(cr(),Ga(),!n&&e.trim().startsWith(`/`)){let n=nm(e,Pr).trim(),i=n.indexOf(` `),a=i===-1?n.slice(1):n.slice(1,i),o=i===-1?``:n.slice(i+1).trim(),s=bt.find(e=>Dn(e)&&(e.name===a||e.aliases?.includes(a)||Qe(e)===a));s?.name===`clear`&&Jn.current&&(X(`tengu_idle_return_action`,{action:`hint_converted`,variant:Jn.current,idleMinutes:Math.round((Date.now()-gi.current)/6e4),messageCount:Kn.current.length,totalInputTokens:Rl()}),Jn.current=!1);let c=Vt.isActive&&(s?.immediate||r?.fromKeybinding);if(s&&c&&s.type===`local-jsx`){e.trim()===Sr.current.trim()&&(wr(``),t.setCursorOffset(0),t.clearBuffer(),Fr({}));let n=tm(e).filter(e=>Pr[e.id]?.type===`text`),i=n.length;X(`tengu_paste_text`,{pastedTextCount:i,pastedTextBytes:n.reduce((e,t)=>e+(Pr[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,mn({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0});let i=[];if(n&&r?.display!==`skip`&&(ze({key:`immediate-${s.name}`,text:n,priority:`immediate`}),!yi())){let e=r?.displayArgs??o;i.push(De(qn(Qe(s),e)),De(`<${Dd}>${Go(n)}</${Dd}>`))}r?.metaMessages?.length&&i.push(...r.metaMessages.map(e=>He({content:e,isMeta:!0}))),i.length&&G(e=>[...e,...i]),Or!==void 0&&(wr(Or.text),t.setCursorOffset(Or.cursorOffset),Fr(Or.pastedContents),kr(void 0))},r=Ra(Kn.current,[],Bi(),ge),i=await(await s.load()).call(n,r,o);i&&!e&&mn({jsx:i,shouldHidePromptInput:!1,isLocalJSXCommand:!0})})();return}}Number(process.env.CLAUDE_CODE_IDLE_THRESHOLD_MINUTES??75),Number(process.env.CLAUDE_CODE_IDLE_TOKEN_THRESHOLD??1e5),r?.fromKeybinding||(om({display:n?e:Kp(e,Tr),pastedContents:n?{}:Pr}),Tr===`bash`&&rC(e.trim()));let i=!n&&e.trim().startsWith(`/`),a=!H||n;if(Or!==void 0&&!i&&a?(wr(Or.text),t.setCursorOffset(Or.cursorOffset),Fr(Or.pastedContents),kr(void 0)):a&&(r?.fromKeybinding||(wr(``),t.setCursorOffset(0)),Fr({})),a&&(Dr(`prompt`),Ke(void 0),Lr(e=>e+1),t.clearBuffer(),Ni.current=!1,!i&&Tr===`prompt`&&!n&&(Yn(e),$t()),B(e=>({...e,attribution:Yi(e.attribution,e=>{Tc(e).catch(e=>{Y(`Attribution: Failed to save snapshot: ${e}`)})})}))),n){let{queryRequired:t}=await vc(n.state,n.speculationSessionTimeSavedMs,n.setAppState,e,{setMessages:G,readFileState:ia,cwd:nu()});if(t){let e=Bi();jt(e),Ha([],e,!0,[],ge)}return}await pr(),await rD({input:e,helpers:t,queryGuard:Vt,isExternalLoading:Ut,mode:Tr,commands:bt,onInputChange:wr,setPastedContents:Fr,setToolJSX:mn,getToolUseContext:Ra,messages:Kn.current,mainLoopModel:ge,pastedContents:Pr,ideSelection:Ge,setUserInputOnProcessing:Yn,setAbortController:jt,abortController:At,onQuery:Ha,setAppState:B,querySource:Ae(),onBeforeQuery:_,canUseTool:Pa,addNotification:ze,setMessages:G,streamMode:Ct.current,hasInterruptibleToolInProgress:Nr.current}),(i||H)&&Or!==void 0&&(wr(Or.text),t.setCursorOffset(Or.cursorOffset),Fr(Or.pastedContents),kr(void 0))},[Vt,H,Ut,Tr,bt,wr,Dr,Fr,Lr,Ke,mn,Ra,ge,Pr,Ge,Yn,jt,ze,Ha,Or,kr,B,_,Pa,G,pr,cr]),Ka=(0,Q.useCallback)(()=>{let e=fa?Nk(fa):`/issue`;pa(null),Wa(e,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}}).catch(t=>{Y(`Auto-run ${e} failed: ${xu(t)}`)})},[Wa,fa]),Ya=(0,Q.useCallback)(()=>{pa(null)},[]),Xa=(0,Q.useCallback)(()=>{Wa(`/issue`,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}}).catch(e=>{Y(`Survey feedback request failed: ${e instanceof Error?e.message:String(e)}`)})},[Wa]),Za=(0,Q.useRef)(Wa);Za.current=Wa;let Qa=(0,Q.useCallback)(async()=>{if(xa(!0),ts()){Gg(`tmux`,[`detach-client`],{stdio:`ignore`}),xa(!1);return}if(yc()!==null){ga((0,$.jsx)(zh,{showWorktree:!0,onDone:()=>{},onCancel:()=>{ga(null),xa(!1)}}));return}let e=await(await Cc.load()).call(()=>{});ga(e),e===null&&xa(!1)},[]),eo=(0,Q.useCallback)(()=>{ii(e=>!e)},[]),to=(0,Q.useCallback)(e=>{let t=Kn.current,n=t.lastIndexOf(e);if(n===-1)return;X(`tengu_conversation_rewind`,{preRewindMessageCount:t.length,postRewindMessageCount:n,messagesRemoved:t.length-n,rewindToMessageIndex:n}),G(t.slice(0,n)),di(zg()),k();let r=e.permissionMode;B(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}}))},[G,B]),io=(0,Q.useCallback)(e=>{to(e);let t=Ia(e);if(t&&(wr(t.text),Dr(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}}}),Fr(n)}}},[to,wr]);Lt.current=io;let co=(0,Q.useCallback)(async e=>{setImmediate((e,t)=>e(t),io,e)},[io]),lo=e=>{let t=e.slice(0,24);return W.findIndex(e=>e.uuid.slice(0,24)===t)},{enter:uo,handlers:fo}=We(rr,ir,ar,{copy:e=>void $c(e).then(e=>{e&&process.stdout.write(e),ze({key:`selection-copied`,text:`copied`,color:`success`,priority:`immediate`,timeoutMs:2e3})}),edit:async e=>{let t=lo(e.uuid),n=t>=0?W[t]:void 0;if(!n||!xm(n))return;let r=!await Ve(re,n.uuid),i=Sm(W,t);r&&i?(Oa(),co(n)):(oi(n),ii(!0))}});async function mo(){da();let e=await nc();if(e.length>0){let t=e.map(e=>` [${e.type}] ${e.path} (${e.content.length} chars)${e.parent?` (included by ${e.parent})`:``}`).join(`
121
+ `);Y(`Loaded ${e.length} AGENTS.md/rules files:\n${t}`)}else Y(`No AGENTS.md/rules files found`);for(let t of e)ia.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})}BE(vg()),Xv(W,W.length===i?.length),VE();let ho=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(ae.length<1){ho.current=!1;return}ho.current||(ho.current=!0,Cd(e=>({...e,promptQueueUseCount:(e.promptQueueUseCount??0)+1})))},[ae.length]),sD({executeQueuedInput:(0,Q.useCallback)(async e=>{await rD({helpers:{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}},queryGuard:Vt,commands:bt,onInputChange:()=>{},setPastedContents:()=>{},setToolJSX:mn,getToolUseContext:Ra,messages:W,mainLoopModel:ge,ideSelection:Ge,setUserInputOnProcessing:Yn,setAbortController:jt,onQuery:Ha,setAppState:B,querySource:Ae(),onBeforeQuery:_,canUseTool:Pa,addNotification:ze,setMessages:G,queuedCommands:e})},[Vt,bt,mn,Ra,W,ge,Ge,Yn,Pa,jt,Ha,ze,B,_]),hasActiveLocalJsxUI:Vn,queryGuard:Vt}),(0,Q.useEffect)(()=>{Mm.recordUserActivity(),Ql(!0)},[br,Ir]),(0,Q.useEffect)(()=>{Ir===1&&Eg()},[Ir]),(0,Q.useEffect)(()=>{if(H||Ir===0||Jr===0)return;let e=setTimeout((e,t,n,r,i)=>{if(Zl()>e)return;let a=Date.now()-e;!t&&!n&&r.current===void 0&&a>=yd().messageIdleNotifThresholdMs&&Av({message:`Work Mate is waiting for your input`,notificationType:`idle_prompt`},i)},yd().messageIdleNotifThresholdMs,Jr,H,dn,an,he);return()=>clearTimeout(e)},[H,dn,Ir,Jr,he]),(0,Q.useEffect)(()=>{},[Jr,H,ze,Be]),vD({isLoading:H||ie!==null,queuedCommandsLength:ae.length,hasActiveLocalJsxUI:Vn,isInPlanMode:ee.mode===`plan`,onQueueTick:e=>Yt(e)}),CD({isLoading:H||ie!==null,wasAborted:Ft,queuedCommandsLength:ae.length,hasActiveLocalJsxUI:Vn,isInPlanMode:ee.mode===`plan`,isQueryActiveNow:Vt.getSnapshot,onContinuationEnqueued:({turn:e,objective:t})=>{let n=`Goal auto-continue (${e}/1): continue advancing "${t}".`;G(e=>[...e,He({content:n,isVisibleInTranscriptOnly:!0})])},onMaxTurnsReached:()=>{ze({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(!ye){$a(null);return}if(!H){if(be!==null&&ae.length===0&&!Vn&&ee.mode!==`plan`&&ie===null){$a({enabled:!0,phase:`standby`,next_tick_at:be,sleep_until:null});return}$a({enabled:!0,phase:null,next_tick_at:null,sleep_until:null})}},[ie,H,Vn,ye,be,ae.length,ee.mode]),(0,Q.useEffect)(()=>{ae.some(e=>e.priority===`now`)&&Mt.current?.abort(`interrupt`)},[ae]);let go=(0,Q.useRef)(mo);go.current=mo;let _o=(0,Q.useRef)(va);_o.current=va,(0,Q.useEffect)(()=>(go.current(),()=>{_o.current.shutdown()}),[]);let{internal_eventEmitter:vo}=Jc(),[yo,bo]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{let e=()=>{process.stdout.write(`
122
+ Work Mate has been suspended. Run \`fg\` to bring Work Mate back.
123
+ Note: ctrl + z now suspends Work Mate, ctrl + _ undoes input.
124
+ `)},t=()=>{bo(e=>e+1)};return vo?.on(`suspend`,e),vo?.on(`resume`,t),()=>{vo?.off(`suspend`,e),vo?.off(`resume`,t)}},[vo]);let xo=(0,Q.useMemo)(()=>{if(!H)return null;let e=W.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||W.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=fd(W,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}`},[W,H]),So=(0,Q.useCallback)(()=>{yr({messagesLength:W.length,streamingToolUsesLength:wt.length})},[W.length,wt.length]),wo=(0,Q.useCallback)(()=>{yr(null)},[]),To=yi()&&!A,Eo=(0,Q.useRef)(null),[Do,Oo]=(0,Q.useState)(!1),[Ao,jo]=(0,Q.useState)(``),[Po,Fo]=(0,Q.useState)(0),[Io,Lo]=(0,Q.useState)(0),Ro=(0,Q.useCallback)((e,t)=>{Fo(e),Lo(t)},[]);nl((e,t,n)=>{if(t.ctrl||t.meta)return;if(e===`/`){Eo.current?.setAnchor(),Oo(!0),n.stopImmediatePropagation();return}let r=e[0];if((r===`n`||r===`N`)&&e===r.repeat(e.length)&&Po>0){let t=r===`n`?Eo.current?.nextMatch:Eo.current?.prevMatch;if(t)for(let n=0;n<e.length;n++)t();n.stopImmediatePropagation()}},{isActive:Te===`transcript`&&To&&!Do&&!je});let{setQuery:zo,scanElement:Bo,setPositions:Vo}=ll(),Ho=sl().columns,Uo=Q.useRef(Ho);Q.useEffect(()=>{Uo.current!==Ho&&(Uo.current=Ho,(Ao||Do)&&(Oo(!1),jo(``),Fo(0),Lo(0),Eo.current?.disarmSearch(),zo(``)))},[Ho,Ao,Do,zo]),nl((e,t,n)=>{if(!(t.ctrl||t.meta)){if(e===`q`){wo(),n.stopImmediatePropagation();return}if(e===`[`&&!je)Me(!0),ke(!0),n.stopImmediatePropagation();else if(e===`v`){if(n.stopImmediatePropagation(),Re.current)return;Re.current=!0;let e=Fe.current,t=t=>{e===Fe.current&&(clearTimeout(Le.current),Pe(t))};t(`rendering ${mr.length} messages…`),(async()=>{try{let e=Math.max(80,(process.stdout.columns??80)-6),n=(await Ev(mr,ht,e)).replace(/[ \t]+$/gm,``),r=Ng(Og(),`cc-transcript-${Date.now()}.txt`);await Ug(r,n);let i=mh(r);t(i?`opening ${r}`:`wrote ${r} · no $VISUAL/$EDITOR set`)}catch(e){t(`render failed: ${e instanceof Error?e.message:String(e)}`)}Re.current=!1,e===Fe.current&&(Le.current=setTimeout(e=>e(``),4e3,Pe))})()}}},{isActive:Te===`transcript`&&To&&!Do});let Wo=Te===`transcript`&&To;(0,Q.useEffect)(()=>{Wo||(jo(``),Fo(0),Lo(0),Oo(!1),Fe.current++,clearTimeout(Le.current),Me(!1),Pe(``))},[Wo]),(0,Q.useEffect)(()=>{zo(Wo?Ao:``),Wo||Vo(null)},[Wo,Ao,zo,Vo]);let Ko={screen:Te,setScreen:Ee,showAllInTranscript:Oe,setShowAllInTranscript:ke,messageCount:W.length,onEnterTranscript:So,onExitTranscript:wo,virtualScrollActive:To,searchBarOpen:Do},qo=vr?mr.slice(0,vr.messagesLength):mr,Jo=vr?wt.slice(0,vr.streamingToolUsesLength):wt;YE({onOpenBackgroundTasks:Vn?void 0:()=>wi(!0)});let Yo=z?ce[z]:void 0,Zo=Yo&&wa(Yo)?Yo:void 0,Qo=Wr||!H,$o=Zo?.messages,es=(0,Q.useMemo)(()=>{if(!Zo)return;let e=$o??[];if(!wa(Zo)||Zo.agentType!==`fork`||!Zo.prompt)return e;let t=Zo.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(TA))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=>!TA(e))}});if(i)return a;let o=n===-1?r+1:n+1,s=He({content:Zo.prompt,timestamp:new Date(Zo.startTime).toISOString()});return[...a.slice(0,o),s,...a.slice(o)]},[Zo,$o]),is=Zo?es??[]:Qo?W:mr;if(Te===`transcript`){let e=yi()&&!A&&!je?Rt:void 0,t=(0,$.jsx)(dg,{messages:qo,tools:ht,commands:bt,verbose:!0,toolJSX:null,toolUseConfirmQueue:[],inProgressToolUseIDs:Ar,isMessageSelectorVisible:!1,conversationId:li,screen:Te,agentDefinitions:L,streamingToolUses:Jo,showAllInTranscript:Oe,isLoading:H,hidePastThinking:!0,streamingThinking:Et,scrollRef:e,jumpRef:Eo,onSearchMatchesChange:Ro,scanElement:Bo,setPositions:Vo,disableRenderCap:je}),n=dn&&(0,$.jsx)(K,{flexDirection:`column`,width:`100%`,children:dn.jsx}),r=(0,$.jsxs)(mm,{children:[(0,$.jsx)(CA,{isAnimating:Hn,title:Rn,disabled:D,noPrefix:!1}),(0,$.jsx)(WE,{...Ko}),(0,$.jsx)(KE,{onSubmit:Wa,isActive:!dn?.isLocalJSXCommand}),e?(0,$.jsx)(lA,{scrollRef:Rt,isActive:!0,isModal:!Do,onScroll:()=>Eo.current?.disarmSearch()}):null,(0,$.jsx)(JE,{...Aa}),e?(0,$.jsx)(lg,{scrollRef:Rt,scrollable:(0,$.jsxs)($.Fragment,{children:[t,n,(0,$.jsx)(fO,{})]}),bottom:Do?(0,$.jsx)(yA,{jumpRef:Eo,initialQuery:``,count:Po,current:Io,onClose:e=>{jo(Po>0?e:``),Oo(!1),e||(Fo(0),Lo(0),Eo.current?.setSearchQuery(``))},onCancel:()=>{Oo(!1),Eo.current?.setSearchQuery(``),Eo.current?.setSearchQuery(Ao),zo(Ao)},setHighlight:zo}):(0,$.jsx)(vA,{showAllInTranscript:Oe,virtualScroll:!0,status:Ne||void 0,searchBadge:Ao&&Po>0?{current:Io,count:Po}:void 0})}):(0,$.jsxs)($.Fragment,{children:[t,n,(0,$.jsx)(fO,{}),(0,$.jsx)(vA,{showAllInTranscript:Oe,virtualScroll:!1,suppressShowAll:je,status:Ne||void 0})]})]});return e?(0,$.jsx)(gl,{mouseTracking:ac(),children:r}):r}let as=Gt&&!Zo&&is.length<=qt.current?Gt:void 0,os=Ta===`tool-permission`?(0,$.jsx)(jx,{onDone:()=>gn(([e,...t])=>t),onReject:ka,toolUseConfirm:hn[0],toolUseContext:Ra(W,W,At??Bi(),ge),verbose:te,setStickyFooter:yi()?yn:void 0},hn[0]?.toolUseID):null,ss=yi()&&dn?.isLocalJSXCommand===!0,cs=ss?dn.jsx:null,ls=(0,$.jsxs)(mm,{children:[(0,$.jsx)(CA,{isAnimating:Hn,title:Rn,disabled:D,noPrefix:!1}),(0,$.jsx)(WE,{...Ko}),(0,$.jsx)(KE,{onSubmit:Wa,isActive:!dn?.isLocalJSXCommand}),(0,$.jsx)(lA,{scrollRef:Rt,isActive:yi()&&(cs!=null||!Ta||Ta===`tool-permission`),onScroll:fr}),null,(0,$.jsx)(JE,{...Aa}),(0,$.jsx)(_m,{dynamicMcpConfig:Se,isStrictMcpConfig:m,children:(0,$.jsx)(lg,{scrollRef:Rt,overlay:os,modal:cs,modalScrollRef:zt,dividerYRef:Zn,hidePill:!!Zo,newMessageCount:sr?.count??0,onPillClick:()=>{ir(null),tr(Rt.current)},scrollable:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(dg,{messages:is,tools:ht,commands:bt,verbose:te,toolJSX:dn,toolUseConfirmQueue:hn,inProgressToolUseIDs:Ar,isMessageSelectorVisible:ri,conversationId:li,screen:Te,streamingToolUses:wt,showAllInTranscript:Oe,agentDefinitions:L,isLoading:H,streamingText:H&&!Zo?qr:null,unseenDivider:Zo?void 0:sr,scrollRef:yi()?Rt:void 0,trackStickyPrompt:yi()?!0:void 0,cursor:rr,setCursor:ir,cursorNavRef:ar}),(0,$.jsx)(fk,{}),!x&&as&&!cs&&(0,$.jsx)(un,{param:{text:as,type:`text`},addMargin:!0,verbose:te}),dn&&!(dn.isLocalJSXCommand&&dn.isImmediate)&&!ss&&(0,$.jsx)(K,{flexDirection:`column`,width:`100%`,children:dn.jsx}),(0,$.jsx)(K,{flexGrow:1}),Wi&&(0,$.jsx)(Im,{mode:xt,spinnerTip:oe,responseLengthRef:zr,apiMetricsRef:Br,overrideMessage:Xr,spinnerSuffix:xo,verbose:te,loadingStartTimeRef:Xt,totalPausedMsRef:Zt,pauseStartTimeRef:Qt,overrideColor:$r,overrideShimmerColor:ti,hasActiveTools:Ar.size>0,leaderIsIdle:!H})]}),bottom:(0,$.jsx)(K,{flexDirection:`row`,width:`100%`,alignItems:`flex-end`,children:(0,$.jsxs)(K,{flexDirection:`column`,flexGrow:1,children:[yi()&&(0,$.jsx)(cE,{}),vn,dn?.isLocalJSXCommand&&dn.isImmediate&&!ss&&(0,$.jsx)(K,{flexDirection:`column`,width:`100%`,children:dn.jsx}),!Wi&&!dn?.isLocalJSXCommand&&se&&ft&&ft.length>0&&(0,$.jsx)(K,{width:`100%`,flexDirection:`column`,children:(0,$.jsx)(Fm,{tasks:ft,isStandalone:!0})}),Ta===`sandbox-permission`&&(0,$.jsx)(uO,{hostPattern:Sn[0].hostPattern,onUserResponse:e=>{let{allow:t,persistToSettings:n}=e,r=Sn[0];if(!r)return;let i=r.hostPattern.host;Cn(e=>(e.filter(e=>e.hostPattern.host===i).forEach(e=>e.resolvePromise(t)),e.filter(e=>e.hostPattern.host!==i)))}},Sn[0].hostPattern.host),Ta===`prompt`&&(0,$.jsx)(tS,{title:wn[0].title,toolInputSummary:wn[0].toolInputSummary,request:wn[0].request,onRespond:e=>{let t=wn[0];t&&(t.resolve({prompt_response:t.request.prompt,selected:e}),Tn(([,...e])=>e))},onAbort:()=>{let e=wn[0];e&&(e.reject(Error(`Prompt cancelled by user`)),Tn(([,...e])=>e))}},wn[0].request.prompt),Ta===`elicitation`&&(0,$.jsx)(Qx,{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`||B(e=>({...e,elicitation:{queue:e.elicitation.queue.slice(1)}})))},onWaitingDismiss:e=>{let t=R.queue[0];B(e=>({...e,elicitation:{queue:e.elicitation.queue.slice(1)}})),t?.onWaitingDismiss?.(e)}},`${R.queue[0].serverName}:${String(R.queue[0].requestId)}`),Ta===`cost`&&(0,$.jsx)(Dv,{onDone:()=>{ci(!1),bi(!0),Cd(e=>({...e,hasAcknowledgedCostThreshold:!0})),X(`tengu_cost_threshold_acknowledged`,{})}}),Ta===`idle-return`&&fi&&(0,$.jsx)(Ov,{idleMinutes:fi.idleMinutes,totalInputTokens:Rl(),onDone:async e=>{let t=fi;if(pi(null),X(`tengu_idle_return_action`,{action:e,idleMinutes:Math.round(t.idleMinutes),messageCount:Kn.current.length,totalInputTokens:Rl()}),e===`dismiss`){wr(t.input);return}if(e===`never`&&Cd(e=>e.idleReturnDismissed?e:{...e,idleReturnDismissed:!0}),e===`clear`){let{clearConversation:e}=await import(`./conversation-CoGharlH.js`);await e({setMessages:G,readFileState:ia.current,discoveredSkillNames:sa.current,loadedNestedMemoryPaths:ca.current,getAppState:()=>me.getState(),setAppState:B,setConversationId:di}),Pn.current=!1,jn(void 0),aa.current.clear(),oa.current=0}hi.current=!0,Za.current(t.input,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}})}}),Ta===`ide-onboarding`&&(0,$.jsx)(ur,{onDone:()=>et(!1),installationStatus:Xe}),ha,Ta===`plugin-hint`&&ot&&(0,$.jsx)(RO,{pluginName:ot.pluginName,pluginDescription:ot.pluginDescription,marketplaceName:ot.marketplaceName,sourceCommand:ot.sourceCommand,onResponse:st}),Ta===`search-extra-tools-hint`&&ct.visible&&(0,$.jsx)(BO,{tools:ct.tools,onSelect:ct.handleSelect,onDismiss:ct.handleDismiss}),Ta===`lsp-recommendation`&&rt&&(0,$.jsx)(FO,{pluginName:rt.pluginName,pluginDescription:rt.pluginDescription,fileExtension:rt.fileExtension,onResponse:at}),Ta===`desktop-upsell`&&(0,$.jsx)(ak,{onDone:()=>nt(!1)}),Ui(),!dn?.shouldHidePromptInput&&!Ta&&!_a&&!x&&!rr&&(0,$.jsxs)($.Fragment,{children:[fa&&(0,$.jsx)(jk,{onRun:Ka,onCancel:Ya,reason:Pk(fa)}),$i.state===`closed`?ta.state===`closed`?(0,$.jsx)(KD,{state:Xi.state,lastResponse:Xi.lastResponse,handleSelect:Xi.handleSelect,handleTranscriptSelect:Xi.handleTranscriptSelect,inputValue:br,setInputValue:wr,onRequestFeedback:ma.current?void 0:Xa}):(0,$.jsx)(KD,{state:ta.state,lastResponse:ta.lastResponse,handleSelect:ta.handleSelect,handleTranscriptSelect:ta.handleTranscriptSelect,inputValue:br,setInputValue:wr,onRequestFeedback:Xa,message:`How well did Work Mate use its memory? (optional)`}):(0,$.jsx)(KD,{state:$i.state,lastResponse:$i.lastResponse,handleSelect:$i.handleSelect,inputValue:br,setInputValue:wr,onRequestFeedback:Xa}),qi.suggestion&&(0,$.jsx)(PE,{isOpen:qi.isOpen,skillName:qi.suggestion.skillName,updates:qi.suggestion.updates,handleSelect:qi.handleSelect,inputValue:br,setInputValue:wr}),Ji&&(0,$.jsx)(Fk,{}),(0,$.jsx)(EE,{debug:n,ideSelection:Ge,hasSuppressedDialogs:!!Ea,isLocalJSXCommandActive:Vn,getToolUseContext:Ra,toolPermissionContext:ee,setToolPermissionContext:Na,apiKeyStatus:ua,commands:bt,agents:L.activeAgents,isLoading:H,onExit:Qa,verbose:te,messages:W,onAutoUpdaterResult:ln,autoUpdaterResult:cn,input:br,onInputChange:wr,mode:Tr,onModeChange:Dr,stashedPrompt:Or,setStashedPrompt:kr,submitCount:Ir,onShowMessageSelector:eo,onMessageActionsEnter:void 0,mcpClients:Ue,pastedContents:Pr,setPastedContents:Fr,vimMode:xi,setVimMode:Si,showBashesDialog:Ci,setShowBashesDialog:wi,onSubmit:Wa,isSearchingHistory:Ti,setIsSearchingHistory:Ei,helpOpen:Di,setHelpOpen:Oi,insertTextRef:Cr}),(0,$.jsx)(TD,{onBackgroundSession:za,isLoading:H}),(0,$.jsx)(gD,{})]}),rr&&(0,$.jsx)(Je,{cursor:rr}),Ta===`message-selector`&&(0,$.jsx)(Tm,{messages:W,preselectedMessage:ai,onPreRestore:Oa,onRestoreCode:async e=>{await lt(e=>{B(t=>({...t,fileHistory:e(t.fileHistory)}))},e.uuid)},onSummarize:async(e,t,n=`from`)=>{let r=de(W),i=r.indexOf(e);if(i===-1){G(e=>[...e,bc(`That message is no longer in the active context (snipped or pre-compact). Choose a more recent message.`,`warning`)]);return}let a=Bi(),o=Ra(r,[],a,ge),s=o.getAppState(),c=await ui(o.options.tools,o.options.mainLoopModel,Array.from(s.toolPermissionContext.additionalWorkingDirectories.keys()),o.options.mcpClients),l=pc({mainThreadAgentDefinition:void 0,toolUseContext:o,customSystemPrompt:o.options.customSystemPrompt,defaultSystemPrompt:c,appendSystemPrompt:o.options.appendSystemPrompt}),[u,d]=await Promise.all([le(),Nn()]),f=await ne(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(yi()&&n===`from`?G(t=>{let n=t.findIndex(t=>t.uuid===e.uuid);return[...t.slice(0,n===-1?0:n),...h]}):G(h),Pt(!1),di(zg()),ea(o.options.querySource),n===`from`){let t=Ia(e);t&&(wr(t.text),Dr(t.mode))}let g=Xo(`app:toggleTranscript`,`Global`,`ctrl+o`);ze({key:`summarize-ctrl-o-hint`,text:`Conversation summarized (${g} for history)`,priority:`medium`,timeoutMs:8e3})},onRestoreMessage:co,onClose:()=>{ii(!1),oi(void 0)}})]})})})},yo)]});return yi()?(0,$.jsx)(gl,{mouseTracking:ac(),children:ls}):ls}export{EA as t};