@readmagic/workmate 0.0.24 → 0.0.26

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 (436) hide show
  1. package/dist/chunks/AddWorkspaceDirectory-mS8iUoWY.js +1 -0
  2. package/dist/chunks/AgentsMdExternalIncludesDialog-BHBkysy0.js +1 -0
  3. package/dist/chunks/AgentsMdExternalIncludesDialog-DuStmCjj.js +1 -0
  4. package/dist/chunks/App-D--vtCyq.js +1 -0
  5. package/dist/chunks/BackgroundTasksDialog-mcDuiNGs.js +2 -0
  6. package/dist/chunks/BypassPermissionsModeDialog-DyqI98d2.js +1 -0
  7. package/dist/chunks/CustomSelect-CpMbxYbt.js +1 -0
  8. package/dist/chunks/DiffDialog-BQAU2pJx.js +6 -0
  9. package/dist/chunks/Doctor-BU69VQzw.js +1 -0
  10. package/dist/chunks/Doctor-DJOMbSDE.js +3 -0
  11. package/dist/chunks/ExitFlow-xBOnvhiW.js +2 -0
  12. package/dist/chunks/InvalidConfigDialog-NiuhcaG5.js +1 -0
  13. package/dist/chunks/{InvalidSettingsDialog-iwh8H52b.js → InvalidSettingsDialog-DrromC1I.js} +1 -1
  14. package/dist/chunks/KeybindingProviderSetup-CSUkJHTT.js +1 -0
  15. package/dist/chunks/MCPConnectionManager-Bn1PDn3R.js +1 -0
  16. package/dist/chunks/MCPToolListView-BRxjOaOL.js +1 -0
  17. package/dist/chunks/McpParsingWarnings-BYG2yqjO.js +1 -0
  18. package/dist/chunks/MessageSelector-B7xAQqZI.js +3 -0
  19. package/dist/chunks/Messages-CxMsfjOa.js +10 -0
  20. package/dist/chunks/Onboarding-CkATe87e.js +1 -0
  21. package/dist/chunks/{PermissionDialog-BaibiQae.js → PermissionDialog-tEMMa5-a.js} +1 -1
  22. package/dist/chunks/{PressEnterToContinue-DZc_s_pE.js → PressEnterToContinue-CPOaYnym.js} +1 -1
  23. package/dist/chunks/PromptInputFooterSuggestions-CwqAsTI2.js +1 -0
  24. package/dist/chunks/PromptInputHelpMenu-krq-hiFO.js +1 -0
  25. package/dist/chunks/{ProviderSetup-BCSPsvfv.js → ProviderSetup-J6Ty-Wj8.js} +1 -1
  26. package/dist/chunks/QueryEngine-Mdi_kUaL.js +1 -0
  27. package/dist/chunks/REPL-BgzQtSFF.js +1 -0
  28. package/dist/chunks/REPL-rirm6s_7.js +124 -0
  29. package/dist/chunks/ResumeConversation-Cmsbo5m7.js +1 -0
  30. package/dist/chunks/{SearchBox-C9xxQzh1.js → SearchBox-DQBLKyzJ.js} +1 -1
  31. package/dist/chunks/SearchExtraToolsTool-D1-7C04z.js +1 -0
  32. package/dist/chunks/{SelectMulti-BQRHed-d.js → SelectMulti-BpAjjhsn.js} +1 -1
  33. package/dist/chunks/Settings-B6DImvca.js +2 -0
  34. package/dist/chunks/Spinner-DhhSOFcN.js +1 -0
  35. package/dist/chunks/{SpinnerGlyph-CmkRUvHe.js → SpinnerGlyph-CmVXC-_9.js} +1 -1
  36. package/dist/chunks/TextInput-BboKIug2.js +22 -0
  37. package/dist/chunks/ThemePicker-DTpXbEY0.js +1 -0
  38. package/dist/chunks/TrustDialog-CZ8JpySm.js +1 -0
  39. package/dist/chunks/{ValidationErrorsList-DgNzJQUP.js → ValidationErrorsList-C_gDQfm1.js} +1 -1
  40. package/dist/chunks/_baseEach-DGbaIpJA.js +1 -0
  41. package/dist/chunks/_baseSlice-D67_NpZ1.js +1 -0
  42. package/dist/chunks/add-dir-B576wzi9.js +1 -0
  43. package/dist/chunks/{agentDisplay-M4pfwbMC.js → agentDisplay-ZuFoBZYu.js} +1 -1
  44. package/dist/chunks/{agents-DddX7lLX.js → agents-Dy4_hDic.js} +1 -1
  45. package/dist/chunks/agents-HIOBiw4w.js +101 -0
  46. package/dist/chunks/allErrors-CxPNR2WN.js +1 -0
  47. package/dist/chunks/analytics-COpjZpvd.js +1 -0
  48. package/dist/chunks/appleTerminalBackup-C9kjzdM9.js +1 -0
  49. package/dist/chunks/backgroundHousekeeping-PyLNnGdw.js +1 -0
  50. package/dist/chunks/backgroundHousekeeping-ZCMPmQuU.js +1 -0
  51. package/dist/chunks/banner-DqFectPg.js +2 -0
  52. package/dist/chunks/branch-B_BL5N9N.js +2 -0
  53. package/dist/chunks/{break-cache-BMXqFTeS.js → break-cache-DL95nKZl.js} +2 -2
  54. package/dist/chunks/btw-Y44ctueB.js +1 -0
  55. package/dist/chunks/bundledMode-BxyD5cqq.js +1 -0
  56. package/dist/chunks/caches-5xZ4dSXt.js +1 -0
  57. package/dist/chunks/caches-Be9saXxV.js +1 -0
  58. package/dist/chunks/{claudeDesktop-D8ml2767.js → claudeDesktop-g8eUUY2E.js} +1 -1
  59. package/dist/chunks/{clear-B8ZtFPOK.js → clear-DtTkA707.js} +1 -1
  60. package/dist/chunks/{client-CpTCeWba.js → client-Bw_L3lSc.js} +1 -1
  61. package/dist/chunks/{client-4iqhC8xq.js → client-aJ2Nr_sh.js} +1 -1
  62. package/dist/chunks/client-mnUISv_N.js +1 -0
  63. package/dist/chunks/client-wPqIdEVm.js +1 -0
  64. package/dist/chunks/commands-wfE12a4L.js +1 -0
  65. package/dist/chunks/compact-CvNOtu7J.js +2 -0
  66. package/dist/chunks/config-D3K87Mm1.js +3 -0
  67. package/dist/chunks/config-DTga6Ku8.js +1 -0
  68. package/dist/chunks/config-DtmqWusU.js +1 -0
  69. package/dist/chunks/context-Opu4E8dL.js +1 -0
  70. package/dist/chunks/{context-noninteractive-C7wrRZnM.js → context-noninteractive-B1V2Mp26.js} +5 -5
  71. package/dist/chunks/context-noninteractive-eIlneYiL.js +1 -0
  72. package/dist/chunks/conversation-CG_z7TLE.js +1 -0
  73. package/dist/chunks/conversation-CHesBfFZ.js +1 -0
  74. package/dist/chunks/conversationRecovery-OhitW-7g.js +1 -0
  75. package/dist/chunks/crossProjectResume-mmYx8PrZ.js +40 -0
  76. package/dist/chunks/cwd-BH2f3u0o.js +1 -0
  77. package/dist/chunks/cwd-DrEEb4f5.js +1 -0
  78. package/dist/chunks/debug-kBjDaVkQ.js +39 -0
  79. package/dist/chunks/{detectRepository-CfX8Lc0A.js → detectRepository-M6K2wc7h.js} +1 -1
  80. package/dist/chunks/{diff-DdpHThJ7.js → diff-Cv7tX2-P.js} +1 -1
  81. package/dist/chunks/{directoryCompletion-D_Rtg-4j.js → directoryCompletion-BHyjyKAM.js} +1 -1
  82. package/dist/chunks/doctor-DeBG5SL5.js +1 -0
  83. package/dist/chunks/entry-CbhyIWgj.js +13 -0
  84. package/dist/chunks/envUtils-DZ_SvEVz.js +1 -0
  85. package/dist/chunks/{esm-CGx9qY3q.js → esm-DUH16IqH.js} +1 -1
  86. package/dist/chunks/execAsync-D6SA-YsV.js +1 -0
  87. package/dist/chunks/execFileNoThrow-BfZFnCGa.js +1 -0
  88. package/dist/chunks/execa-CBhG1doD.js +34 -0
  89. package/dist/chunks/exit-OKEV_ddw.js +1 -0
  90. package/dist/chunks/extraUsage-BlRL3yeb.js +1 -0
  91. package/dist/chunks/extractMemories-jnsv-_n_.js +1 -0
  92. package/dist/chunks/fast-4I_qPJCd.js +1 -0
  93. package/dist/chunks/fast-DiolM1M7.js +1 -0
  94. package/dist/chunks/fetchModelList-BRFTQim4.js +1 -0
  95. package/dist/chunks/fetchModelList-qPKAuu4m.js +1 -0
  96. package/dist/chunks/fileSuggestions-iWVXvvLB.js +3 -0
  97. package/dist/chunks/firstPartyEventLogger-CN9UOmEC.js +1 -0
  98. package/dist/chunks/firstPartyEventLogger-RR5rvDtk.js +1 -0
  99. package/dist/chunks/{fpsMetrics-wxj9GAsd.js → fpsMetrics-Ixd0J4CH.js} +1 -1
  100. package/dist/chunks/{gemini-C_ApXgwc.js → gemini-BfVyavwQ.js} +2 -2
  101. package/dist/chunks/generateSessionName-CGaTTXCA.js +1 -0
  102. package/dist/chunks/genericProcessUtils-CVtQOTO2.js +12 -0
  103. package/dist/chunks/getMachineId-bsd-DTYGimUN.js +1 -0
  104. package/dist/chunks/getMachineId-darwin-DqIFUVvd.js +2 -0
  105. package/dist/chunks/getMachineId-linux-CnCTmdzd.js +1 -0
  106. package/dist/chunks/getMachineId-unsupported-Cx21ssu1.js +1 -0
  107. package/dist/chunks/getMachineId-win-vZhex7KX.js +1 -0
  108. package/dist/chunks/goal-BidR-GFa.js +3 -0
  109. package/dist/chunks/grok-DLcuI-U7.js +1 -0
  110. package/dist/chunks/help-CZuvYhXj.js +1 -0
  111. package/dist/chunks/history-BxPGftQw.js +1 -0
  112. package/dist/chunks/hooks-Bg9WIjZQ.js +1 -0
  113. package/dist/chunks/{hooks-DR3IYPJ3.js → hooks-ehqfAM5F.js} +2 -2
  114. package/dist/chunks/install-ACGY0vhM.js +1 -0
  115. package/dist/chunks/instrumentation-B9bfF2mA.js +21 -0
  116. package/dist/chunks/{job-YhJQWgE0.js → job-Coztdn6A.js} +1 -1
  117. package/dist/chunks/keybindings-DwSdLpaE.js +1 -0
  118. package/dist/chunks/launchLocalMemory-DRzfpIOB.js +3 -0
  119. package/dist/chunks/launchOnboarding-D2zFCJf-.js +8 -0
  120. package/dist/chunks/{loadAgentsDir-B0Anodo0.js → loadAgentsDir-DR5PVAc3.js} +590 -594
  121. package/dist/chunks/loadAgentsDir-DqAbnpB-.js +1 -0
  122. package/dist/chunks/{loadPluginHooks-BSwCtQ6T.js → loadPluginHooks-BiQgGfUJ.js} +1 -1
  123. package/dist/chunks/{loader-CICGtLp2.js → loader-6MqzNGmV.js} +1 -1
  124. package/dist/chunks/{localSearch-BxLYi6w_.js → localSearch-CzkxDuOR.js} +1 -1
  125. package/dist/chunks/localSearch-DW3JT2MA.js +1 -0
  126. package/dist/chunks/lockfile-D_9vif6E.js +1 -0
  127. package/dist/chunks/{log-D2TIwHBV.js → log-DWZny1vM.js} +1 -1
  128. package/dist/chunks/logoUtils-DR5T0pr3.js +1 -0
  129. package/dist/chunks/{magicDocs-Bkz7ZcmL.js → magicDocs-BwBxjfLo.js} +2 -2
  130. package/dist/chunks/main-Ryi27wYq.js +345 -0
  131. package/dist/chunks/managedEnv-DCEJh3z3.js +1 -0
  132. package/dist/chunks/managedEnv-Do9fgLpk.js +1 -0
  133. package/dist/chunks/managedEnvConstants-CWcT7nYr.js +1 -0
  134. package/dist/chunks/mcp-BCpnF6wD.js +1 -0
  135. package/dist/chunks/mcp-CJ6SDJEK.js +6 -0
  136. package/dist/chunks/mcp-CZBTxbhu.js +2 -0
  137. package/dist/chunks/memory-BQO6Y0ak.js +1 -0
  138. package/dist/chunks/{modalContext-DDZdU1J8.js → modalContext-CBE8xuck.js} +1 -1
  139. package/dist/chunks/mode-wq70cR44.js +2 -0
  140. package/dist/chunks/model-D42epddJ.js +1 -0
  141. package/dist/chunks/model-DVk9-2dk.js +1 -0
  142. package/dist/chunks/modelOptions-beLgXORr.js +1 -0
  143. package/dist/chunks/nativeInstaller-ChGSz1lb.js +1 -0
  144. package/dist/chunks/{notifications-Bc6k-Ozy.js → notifications-dGBuNvFj.js} +1 -1
  145. package/dist/chunks/onChangeAppState-B4K-rSaF.js +1 -0
  146. package/dist/chunks/open-Cyrr4E5x.js +1 -0
  147. package/dist/chunks/openai-DAwnAV9K.js +2 -0
  148. package/dist/chunks/overlayContext-B6i_6y_0.js +1 -0
  149. package/dist/chunks/{panel-CVS4SK_E.js → panel-C0CF3noE.js} +1 -1
  150. package/dist/chunks/parser-BZt0VFd_.js +1 -0
  151. package/dist/chunks/{parser-Cg6hSCmn.js → parser-DThLwgdM.js} +1 -1
  152. package/dist/chunks/partition-BRQHofxD.js +1 -0
  153. package/dist/chunks/{pasteStore-P0zP-ch0.js → pasteStore-BmehVo5j.js} +1 -1
  154. package/dist/chunks/permissions-DkfWKN-B.js +3 -0
  155. package/dist/chunks/pidLock-YvAaIrIY.js +3 -0
  156. package/dist/chunks/plan-B6U3ioer.js +1 -0
  157. package/dist/chunks/platform-Vl9IynC3.js +2 -0
  158. package/dist/chunks/plugin-CTA2_-F7.js +17 -0
  159. package/dist/chunks/{pluginAutoupdate-ennb9k8_.js → pluginAutoupdate-Dy5W3HWE.js} +1 -1
  160. package/dist/chunks/{pluginBlocklist-9OrNEh--.js → pluginBlocklist-DAoUENwc.js} +1 -1
  161. package/dist/chunks/pluginCliCommands-CaHnj0C_.js +1 -0
  162. package/dist/chunks/{pluginFlagging-js_-WmYj.js → pluginFlagging-BCj9LJP3.js} +1 -1
  163. package/dist/chunks/pluginOperations-ClXNOOG6.js +2 -0
  164. package/dist/chunks/pluginStartupCheck-CiwMKGjx.js +1 -0
  165. package/dist/chunks/{pluginStartupCheck-SRXOyqr7.js → pluginStartupCheck-U8_xk25t.js} +1 -1
  166. package/dist/chunks/plugins-D7zyI9c4.js +4 -0
  167. package/dist/chunks/{poller-CpLBoB-N.js → poller-BeyVwHAf.js} +1 -1
  168. package/dist/chunks/poorMode-DtzWNhsY.js +1 -0
  169. package/dist/chunks/poorMode-Ocff_UT1.js +1 -0
  170. package/dist/chunks/print-BzljdXem.js +13 -0
  171. package/dist/chunks/processBashCommand-RUkmyAl4.js +1 -0
  172. package/dist/chunks/processSlashCommand-DRLO-jNV.js +5 -0
  173. package/dist/chunks/{projectContext-5fmRr6Sd.js → projectContext-COeHKDrk.js} +1 -1
  174. package/dist/chunks/{projectContext-DhtjLv3k.js → projectContext-QN5U3Ggr.js} +1 -1
  175. package/dist/chunks/{projectOnboardingState-B5YATuc6.js → projectOnboardingState-KqcpRXls.js} +1 -1
  176. package/dist/chunks/{prompt-CJ1l3XXk.js → prompt-CTByhpUI.js} +21 -21
  177. package/dist/chunks/prompt-DTpfW6yP.js +1 -0
  178. package/dist/chunks/prompt-D__eHY_5.js +1 -0
  179. package/dist/chunks/promptEditor-CpUFgGzc.js +4 -0
  180. package/dist/chunks/protocolHandler-BQSLVGnG.js +13 -0
  181. package/dist/chunks/{proxy-CDBfZjO7.js → proxy-BtWuysHM.js} +2 -2
  182. package/dist/chunks/reconciler-D6BUq8WB.js +1 -0
  183. package/dist/chunks/refresh-B4pqFp12.js +1 -0
  184. package/dist/chunks/reject-C6IvUvBt.js +1 -0
  185. package/dist/chunks/{reload-plugins-CQZFQLWP.js → reload-plugins-DXQqk7q6.js} +1 -1
  186. package/dist/chunks/rename-D4XBmTBI.js +1 -0
  187. package/dist/chunks/{renderOptions-DV0dn0IW.js → renderOptions-DkP98P_d.js} +1 -1
  188. package/dist/chunks/resume-DzIev0JI.js +2 -0
  189. package/dist/chunks/ripgrep-CYP26Fhg.js +1 -0
  190. package/dist/chunks/ripgrep-D1f1pbCz.js +5 -0
  191. package/dist/chunks/{runtimeObserver-PJ1o8GRA.js → runtimeObserver-BPqlbu0B.js} +4 -4
  192. package/dist/chunks/{runtimeObserver-DEuR8z0f.js → runtimeObserver-BUHs3qjs.js} +1 -1
  193. package/dist/chunks/sandbox-adapter-CumL75tU.js +1 -0
  194. package/dist/chunks/sandbox-toggle-CTtET6Xq.js +1 -0
  195. package/dist/chunks/searchExtraTools-BMCU2zEf.js +1 -0
  196. package/dist/chunks/select-FrwoTzuc.js +1 -0
  197. package/dist/chunks/sessionFileAccessHooks-WO8WTdT9.js +1 -0
  198. package/dist/chunks/{sessionObserver-BtKjvteq.js → sessionObserver-B6xzxckA.js} +2 -2
  199. package/dist/chunks/sessionObserver-CBrM4opL.js +1 -0
  200. package/dist/chunks/sessionStorage-C1EAxDWG.js +1 -0
  201. package/dist/chunks/sessionTracing-UFK96PxT.js +11 -0
  202. package/dist/chunks/settings-BK6gCko-.js +1 -0
  203. package/dist/chunks/settings-YIDksG5Z.js +24 -0
  204. package/dist/chunks/setup-BBvZyrfz.js +3 -0
  205. package/dist/chunks/{shadowedRuleDetection-Bg_aIc5Z.js → shadowedRuleDetection-D6R2OeoH.js} +1 -1
  206. package/dist/chunks/{sideQuestion-D49GsfH7.js → sideQuestion-5jcbOMsR.js} +3 -3
  207. package/dist/chunks/sinks-B-kFqjjd.js +1 -0
  208. package/dist/chunks/sinks-DB_D4lmu.js +1 -0
  209. package/dist/chunks/skillChangeDetector-103-nEle.js +1 -0
  210. package/dist/chunks/{skillGapStore-CcFoHNLl.js → skillGapStore-DOz1KCqo.js} +2 -2
  211. package/dist/chunks/{skillLifecycle-Bnz_4wE5.js → skillLifecycle-D9NkIwFQ.js} +2 -2
  212. package/dist/chunks/{skillSearchPanel-C_5yUhqn.js → skillSearchPanel-DFiSZaJ4.js} +4 -4
  213. package/dist/chunks/skills-DgeLr52a.js +1 -0
  214. package/dist/chunks/sleep-BbWr_FL1.js +1 -0
  215. package/dist/chunks/{src-CiJCsqUl.js → src-C8gyNm5a.js} +1 -1
  216. package/dist/chunks/{src-9vmGsuSI.js → src-Cy5_qH26.js} +1 -1
  217. package/dist/chunks/src-Db7K3F_i.js +3 -0
  218. package/dist/chunks/{src-DL3w8VPk.js → src-WZ94ZKI3.js} +4 -4
  219. package/dist/chunks/startupProfiler-DIM_Ihyp.js +3 -0
  220. package/dist/chunks/startupProfiler-FpGsKWYk.js +1 -0
  221. package/dist/chunks/{state-B4jiUise.js → state-CXY-q5gr.js} +1 -1
  222. package/dist/chunks/state-DXt6rahM.js +1 -0
  223. package/dist/chunks/{staticRender-BVWx0IM1.js → staticRender-RHUIg5ln.js} +1 -1
  224. package/dist/chunks/status-CKLecQZV.js +1 -0
  225. package/dist/chunks/statusNoticeHelpers-DI45AH-c.js +1 -0
  226. package/dist/chunks/stringUtils-D_xPrwGQ.js +4 -0
  227. package/dist/chunks/switcher-D2Z2ZNQ0.js +1 -0
  228. package/dist/chunks/switcher-DhZCaAun.js +1 -0
  229. package/dist/chunks/{tasks-DdcUQEeD.js → tasks-6suPhqsK.js} +1 -1
  230. package/dist/chunks/{templateJobs-C8qsPrLj.js → templateJobs-BKVEWCsb.js} +1 -1
  231. package/dist/chunks/{terminalSetup-qc2PlvOm.js → terminalSetup-7PUR4hfo.js} +1 -1
  232. package/dist/chunks/{terminalSetup-B_10N_gE.js → terminalSetup-Cqy5_PhJ.js} +4 -4
  233. package/dist/chunks/{theme-f1h2QI8J.js → theme-B-HG2PUs.js} +1 -1
  234. package/dist/chunks/tipRegistry-BR_lSGRw.js +2 -0
  235. package/dist/chunks/{toolEventObserver-7QP38x4t.js → toolEventObserver-BY3QVnr6.js} +1 -1
  236. package/dist/chunks/toolPool-BcwIF8Q_.js +1 -0
  237. package/dist/chunks/{types-Dx7P7JLQ.js → types-CD25a50S.js} +16 -16
  238. package/dist/chunks/udsClient-CCxgLiZy.js +1 -0
  239. package/dist/chunks/urlHandler-BNsQKqba.js +1 -0
  240. package/dist/chunks/{use-select-navigation-hWL5VHnL.js → use-select-navigation-CW5alA9r.js} +1 -1
  241. package/dist/chunks/{useDoublePress-C9xxQzh1.js → useDoublePress-DQBLKyzJ.js} +1 -1
  242. package/dist/chunks/useExitOnCtrlCDWithKeybindings-BgJrnuDl.js +1 -0
  243. package/dist/chunks/useMainLoopModel-BVgJo4hN.js +1 -0
  244. package/dist/chunks/useManagePlugins-CrWjzESW.js +1 -0
  245. package/dist/chunks/useMergedTools-r6GQq5mI.js +1 -0
  246. package/dist/chunks/useSearchInput-BITV_Txn.js +1 -0
  247. package/dist/chunks/useSettingsErrors-CO0fTNzn.js +1 -0
  248. package/dist/chunks/util-_zo3I1y8.js +1 -0
  249. package/dist/chunks/validatePlugin-DFGdRhA-.js +1 -0
  250. package/dist/chunks/vim-qgMS88ss.js +1 -0
  251. package/dist/chunks/worktree-CR_M6Qfy.js +1 -0
  252. package/dist/cli.js +1 -1
  253. package/package.json +1 -12
  254. package/scripts/postinstall.cjs +16 -16
  255. package/dist/chunks/AddWorkspaceDirectory-Ch8IcWXO.js +0 -1
  256. package/dist/chunks/AgentsMdExternalIncludesDialog-Cyia0s4g.js +0 -1
  257. package/dist/chunks/AgentsMdExternalIncludesDialog-LjI_H_Au.js +0 -1
  258. package/dist/chunks/App-BOqh_1tN.js +0 -1
  259. package/dist/chunks/BackgroundTasksDialog-CSEuuoq9.js +0 -2
  260. package/dist/chunks/BypassPermissionsModeDialog-CwfCwUr9.js +0 -1
  261. package/dist/chunks/CustomSelect-wmZ9jz0W.js +0 -1
  262. package/dist/chunks/DiffDialog-BpXIEWiE.js +0 -6
  263. package/dist/chunks/Doctor-CMpr7tdf.js +0 -1
  264. package/dist/chunks/Doctor-DqW6j3_B.js +0 -3
  265. package/dist/chunks/ExitFlow-DacaBTlk.js +0 -2
  266. package/dist/chunks/Grove-CNqYPWI6.js +0 -11
  267. package/dist/chunks/InvalidConfigDialog-0TMJItCC.js +0 -1
  268. package/dist/chunks/KeybindingProviderSetup-D49HHTXD.js +0 -1
  269. package/dist/chunks/MCPConnectionManager-Cie77ZAK.js +0 -1
  270. package/dist/chunks/MCPToolListView-B4ehtkXd.js +0 -1
  271. package/dist/chunks/McpParsingWarnings-Bff66RtJ.js +0 -1
  272. package/dist/chunks/MessageSelector-Dpd6Iywp.js +0 -3
  273. package/dist/chunks/Messages-DN7M3oS_.js +0 -10
  274. package/dist/chunks/Onboarding-CQmE3rUf.js +0 -1
  275. package/dist/chunks/PromptInputFooterSuggestions-HI6HH3TP.js +0 -1
  276. package/dist/chunks/PromptInputHelpMenu-3QNUC2Cg.js +0 -1
  277. package/dist/chunks/QueryEngine-DdLWvJv6.js +0 -1
  278. package/dist/chunks/REPL-BqO9KcK_.js +0 -124
  279. package/dist/chunks/REPL-CmZmypfF.js +0 -1
  280. package/dist/chunks/ResumeConversation-DBqX7gva.js +0 -1
  281. package/dist/chunks/SearchExtraToolsTool-BsSoILFj.js +0 -1
  282. package/dist/chunks/Settings-B-7yBewS.js +0 -3
  283. package/dist/chunks/Spinner-ByQXTvAA.js +0 -1
  284. package/dist/chunks/TextInput-B8ruWRf2.js +0 -22
  285. package/dist/chunks/ThemePicker-BQErFFW1.js +0 -1
  286. package/dist/chunks/TrustDialog-BIhz6AZE.js +0 -1
  287. package/dist/chunks/_baseEach-CsIRoaTH.js +0 -1
  288. package/dist/chunks/add-dir-CrUDs19x.js +0 -1
  289. package/dist/chunks/agents-CGaCQeLw.js +0 -101
  290. package/dist/chunks/allErrors-BF73lon8.js +0 -1
  291. package/dist/chunks/analytics-DJobLaWP.js +0 -1
  292. package/dist/chunks/appleTerminalBackup-BArZWB21.js +0 -1
  293. package/dist/chunks/backgroundHousekeeping-Bq3LMsVR.js +0 -17
  294. package/dist/chunks/backgroundHousekeeping-Cl3Ox7Qh.js +0 -1
  295. package/dist/chunks/banner-Cu2-XUek.js +0 -2
  296. package/dist/chunks/branch-Yg_taNlT.js +0 -2
  297. package/dist/chunks/btw-udbprVvu.js +0 -1
  298. package/dist/chunks/caches-ChjIEcdd.js +0 -1
  299. package/dist/chunks/caches-DLJ6urv-.js +0 -1
  300. package/dist/chunks/client-BiqbIkwr.js +0 -1
  301. package/dist/chunks/client-CZ8nyVh5.js +0 -1
  302. package/dist/chunks/commands-CVCpJo7M.js +0 -1
  303. package/dist/chunks/compact-izk6RKHQ.js +0 -2
  304. package/dist/chunks/config-C-Y2qtB2.js +0 -3
  305. package/dist/chunks/config-CFqpXMFX.js +0 -1
  306. package/dist/chunks/config-DD8fCYXn.js +0 -1
  307. package/dist/chunks/context-BbVm4SWK.js +0 -1
  308. package/dist/chunks/context-noninteractive-x0HAzWhc.js +0 -1
  309. package/dist/chunks/conversation-DouVzO0K.js +0 -1
  310. package/dist/chunks/conversation-DrVkifKy.js +0 -1
  311. package/dist/chunks/conversationRecovery-DliPBo_z.js +0 -1
  312. package/dist/chunks/crossProjectResume-DxMy05_P.js +0 -40
  313. package/dist/chunks/cwd-Dc3NV7s8.js +0 -1
  314. package/dist/chunks/cwd-Pa83R95t.js +0 -1
  315. package/dist/chunks/datadog-Cu3s7P48.js +0 -1
  316. package/dist/chunks/debug-Bglx1aTu.js +0 -39
  317. package/dist/chunks/doctor-D_kV_D_l.js +0 -1
  318. package/dist/chunks/entry-Bxseqbi_.js +0 -13
  319. package/dist/chunks/envUtils-DfkgIdYf.js +0 -1
  320. package/dist/chunks/esm-BXTZz3av.js +0 -1
  321. package/dist/chunks/execAsync-Bv2yxuGe.js +0 -1
  322. package/dist/chunks/execFileNoThrow-BTachNBI.js +0 -34
  323. package/dist/chunks/exit-C_R_FgzR.js +0 -1
  324. package/dist/chunks/extraUsage-xMuDiNKh.js +0 -1
  325. package/dist/chunks/extractMemories-D4Dl1itt.js +0 -1
  326. package/dist/chunks/fast-DH-C5IZs.js +0 -1
  327. package/dist/chunks/fast-bopOPrtf.js +0 -1
  328. package/dist/chunks/fetchModelList-DC4VQpqa.js +0 -1
  329. package/dist/chunks/fetchModelList-FE8tzTDc.js +0 -1
  330. package/dist/chunks/fileSuggestions-C-9unnoJ.js +0 -3
  331. package/dist/chunks/firstPartyEventLogger-QmjjQmgt.js +0 -3
  332. package/dist/chunks/firstPartyEventLogger-lFeqhtfh.js +0 -1
  333. package/dist/chunks/generateSessionName-CQ03xlYI.js +0 -1
  334. package/dist/chunks/genericProcessUtils-DwQFuna9.js +0 -23
  335. package/dist/chunks/getMachineId-bsd-Cut1kHoA.js +0 -1
  336. package/dist/chunks/getMachineId-darwin-CsRhaP3y.js +0 -2
  337. package/dist/chunks/getMachineId-linux-Bd7UBNRQ.js +0 -1
  338. package/dist/chunks/getMachineId-unsupported-vFGP8E_8.js +0 -1
  339. package/dist/chunks/getMachineId-win-DamF2CH_.js +0 -1
  340. package/dist/chunks/goal-CdL29Y8C.js +0 -3
  341. package/dist/chunks/grok-C6WAslUT.js +0 -1
  342. package/dist/chunks/grove-O6qp7ITR.js +0 -1
  343. package/dist/chunks/help-DxanITNN.js +0 -1
  344. package/dist/chunks/history-BMycjPTT.js +0 -1
  345. package/dist/chunks/hooks-D9ApLkBp.js +0 -1
  346. package/dist/chunks/install-0D9u2dZw.js +0 -1
  347. package/dist/chunks/instrumentation-BFiGwntt.js +0 -21
  348. package/dist/chunks/keybindings-DZrF9iNd.js +0 -1
  349. package/dist/chunks/launchLocalMemory-DhJ56KDc.js +0 -3
  350. package/dist/chunks/launchOnboarding-DmMoZwv5.js +0 -8
  351. package/dist/chunks/loadAgentsDir-BbUR6pqH.js +0 -1
  352. package/dist/chunks/localSearch-zfn7jgrh.js +0 -1
  353. package/dist/chunks/logoUtils-CRxTutvr.js +0 -1
  354. package/dist/chunks/main-9ksgUUY_.js +0 -345
  355. package/dist/chunks/managedEnv-BEqrGqn1.js +0 -1
  356. package/dist/chunks/managedEnv-OPlzUPbJ.js +0 -1
  357. package/dist/chunks/managedEnvConstants-BPwL2aWI.js +0 -1
  358. package/dist/chunks/mcp-ChF12reQ.js +0 -1
  359. package/dist/chunks/mcp-DoEl5uah.js +0 -2
  360. package/dist/chunks/mcp-hp9qqjAy.js +0 -6
  361. package/dist/chunks/memory-Qv-wGNQ5.js +0 -1
  362. package/dist/chunks/mode-bFXPCR2P.js +0 -2
  363. package/dist/chunks/model-6lkW4o2c.js +0 -1
  364. package/dist/chunks/model-BvQFFOf8.js +0 -1
  365. package/dist/chunks/modelOptions-BBvF3wHK.js +0 -1
  366. package/dist/chunks/nativeInstaller-CdjmE9Zy.js +0 -1
  367. package/dist/chunks/onChangeAppState-DLjZ1x95.js +0 -1
  368. package/dist/chunks/open-BtQHzzL9.js +0 -1
  369. package/dist/chunks/openai-D46QvESE.js +0 -2
  370. package/dist/chunks/overlayContext-8--_fbvY.js +0 -1
  371. package/dist/chunks/parser-CG5RuOCK.js +0 -1
  372. package/dist/chunks/partition-DznN4XZH.js +0 -1
  373. package/dist/chunks/permissions-DmGFViHI.js +0 -3
  374. package/dist/chunks/pidLock-Cm4sW35f.js +0 -3
  375. package/dist/chunks/plan-CzGBz_87.js +0 -1
  376. package/dist/chunks/platform-BacQ6ACS.js +0 -2
  377. package/dist/chunks/plugin-CluR79xX.js +0 -17
  378. package/dist/chunks/pluginCliCommands-CJv5uhOG.js +0 -1
  379. package/dist/chunks/pluginOperations-CcUSHAIa.js +0 -2
  380. package/dist/chunks/pluginStartupCheck-CRBUO9gP.js +0 -1
  381. package/dist/chunks/plugins-IwwaCDba.js +0 -4
  382. package/dist/chunks/poorMode-B0QGV6Ci.js +0 -1
  383. package/dist/chunks/poorMode-G-pnu6NM.js +0 -1
  384. package/dist/chunks/print-CgszM1ea.js +0 -13
  385. package/dist/chunks/processBashCommand-D098WsqY.js +0 -1
  386. package/dist/chunks/processSlashCommand-DOQFjJ88.js +0 -5
  387. package/dist/chunks/prompt-BKPmDAuL.js +0 -1
  388. package/dist/chunks/prompt-CgOklk7z.js +0 -1
  389. package/dist/chunks/promptEditor-DoGHJN_W.js +0 -4
  390. package/dist/chunks/protocolHandler-DjQALaU2.js +0 -13
  391. package/dist/chunks/reconciler-ykkSPR-i.js +0 -1
  392. package/dist/chunks/refresh-Dn_I1R4v.js +0 -1
  393. package/dist/chunks/registerProtocol-CAsDme_E.js +0 -1
  394. package/dist/chunks/reject-DtcCfuZV.js +0 -1
  395. package/dist/chunks/rename-DyEfsZiq.js +0 -1
  396. package/dist/chunks/resume-BcXEDUqZ.js +0 -2
  397. package/dist/chunks/ripgrep-DLs8MraF.js +0 -1
  398. package/dist/chunks/ripgrep-Dl3y5r4m.js +0 -5
  399. package/dist/chunks/sandbox-adapter-DfB9kgQD.js +0 -1
  400. package/dist/chunks/sandbox-toggle-D9GDUsTl.js +0 -1
  401. package/dist/chunks/searchExtraTools-D4gMMQv0.js +0 -1
  402. package/dist/chunks/select-DIxfl_VN.js +0 -1
  403. package/dist/chunks/sessionFileAccessHooks-lbgHnVvi.js +0 -1
  404. package/dist/chunks/sessionObserver-D6qzEdGJ.js +0 -1
  405. package/dist/chunks/sessionStorage-C_7gow_z.js +0 -1
  406. package/dist/chunks/sessionTracing-CtbeAD0s.js +0 -11
  407. package/dist/chunks/settings-B2jvL8Dp.js +0 -24
  408. package/dist/chunks/settings-CisDe8DB.js +0 -1
  409. package/dist/chunks/setup-qecdf-ES.js +0 -3
  410. package/dist/chunks/sinks-C-lP7uyO.js +0 -1
  411. package/dist/chunks/sinks-De-B1lPQ.js +0 -1
  412. package/dist/chunks/skillChangeDetector-DkOJoNhT.js +0 -1
  413. package/dist/chunks/skills-BE5scC-g.js +0 -1
  414. package/dist/chunks/src-CHw1lvBc.js +0 -3
  415. package/dist/chunks/startupProfiler-BH0FoI66.js +0 -1
  416. package/dist/chunks/startupProfiler-CJdr3SxP.js +0 -3
  417. package/dist/chunks/state-BhOKSFi5.js +0 -1
  418. package/dist/chunks/status-Dw09WZLd.js +0 -1
  419. package/dist/chunks/statusNoticeHelpers-BRQpUIlH.js +0 -1
  420. package/dist/chunks/stringUtils-C718f5ey.js +0 -4
  421. package/dist/chunks/switcher-CgZVah7U.js +0 -1
  422. package/dist/chunks/switcher-DZwUo5Ed.js +0 -1
  423. package/dist/chunks/tipRegistry-B71o4qWr.js +0 -2
  424. package/dist/chunks/toolPool-V-7Yv0GA.js +0 -1
  425. package/dist/chunks/udsClient-cQz6nJ_T.js +0 -1
  426. package/dist/chunks/urlHandler-DLz3FZm1.js +0 -1
  427. package/dist/chunks/useExitOnCtrlCDWithKeybindings-BKwzUpgb.js +0 -1
  428. package/dist/chunks/useMainLoopModel-DxvV70Ru.js +0 -1
  429. package/dist/chunks/useManagePlugins-BXLXazrR.js +0 -1
  430. package/dist/chunks/useMergedTools-CCgnBJzO.js +0 -1
  431. package/dist/chunks/useSearchInput-CzopttqC.js +0 -1
  432. package/dist/chunks/useSettingsErrors-SFPWfxsA.js +0 -1
  433. package/dist/chunks/util-Cbb3S6SX.js +0 -1
  434. package/dist/chunks/validatePlugin-BMSoeb_b.js +0 -1
  435. package/dist/chunks/vim-CoRp9lY1.js +0 -1
  436. package/dist/chunks/worktree-Vm-SNY5x.js +0 -1
@@ -0,0 +1,124 @@
1
+ import{a as e,n as t,o as n}from"./rolldown-runtime-DaDcL9Zw.js";import{i as r,l as i,o as a}from"./envUtils-DZ_SvEVz.js";import{n as o,t as s}from"./defineProperty-C-QyHrDq.js";import{n as c,t as l}from"./figures-5ThXQEtq.js";import{C as u,D as d,Ft as f,Gr as p,Gt as m,H as h,I as g,Kr as _,Kt as v,Lt as y,P as b,Pn as x,Rn as S,T as C,Tt as w,Vn as T,Wt as E,Xn as D,Xt as O,Y as k,Yt as A,Z as j,Zn as M,_n as N,ai as P,bn as F,ct as ee,di as I,dr as L,et as te,fi as R,hn as ne,ir as z,j as re,lr as ie,lt as B,ot as ae,q as oe,qr as se,t as V,tr as ce,vn as le,x as H,y as ue,yn as U,yt as W}from"./src-WZ94ZKI3.js";import{t as de}from"./jsx-runtime-Bb4Xn-E0.js";import{C as fe,H as pe,T as me,W as he,X as ge,b as _e,d as ve,g as ye,h as be,k as xe,l as Se,o as Ce,s as we}from"./types-CD25a50S.js";import{Cn as Te,Ft as Ee,Gn as De,Gt as Oe,Hn as ke,I as Ae,Kn as je,Kt as Me,Pt as Ne,Qt as Pe,Tt as Fe,Un as Ie,Ut as Le,Vn as Re,W as ze,Wt as Be,X as Ve,_n as He,_t as Ue,at as We,bt as Ge,ft as Ke,gt as qe,in as Je,jt as Ye,kt as Xe,q as Ze,rt as Qe,vt as $e,w as et,wn as tt,xt as nt,y as rt,yt as it,z as at}from"./state-CXY-q5gr.js";import{$C as ot,$_ as st,$a as ct,$c as lt,$h as ut,$l as dt,$p as ft,$s as pt,$v as mt,$x as ht,A as gt,AC as _t,Aa as vt,Ac as yt,Ag as bt,Ah as xt,As as St,Au as Ct,Av as wt,B as Tt,B_ as Et,Ba as Dt,Bg as Ot,Bh as G,Bm as kt,Bn as At,Bt as jt,Bv as Mt,By as Nt,C as Pt,Cc as Ft,Cg as It,Ch as Lt,Ci as Rt,Cl as K,Cm as zt,Cs as Bt,Cu as Vt,Cv as Ht,Db as Ut,Dc as Wt,Di as Gt,Dv as Kt,Dy as qt,Eb as Jt,Ec as Yt,Eg as Xt,Ei as Zt,Ev as Qt,FC as $t,F_ as en,Fc as tn,Fg as nn,Fh as rn,Fi as an,Fp as on,Fv as sn,Fx as cn,GC as ln,GS as un,Gp as dn,Gu as fn,Gv as pn,Gx as mn,Gy as hn,H_ as gn,Hg as _n,Hh as vn,Hm as yn,Hu as bn,Hx as xn,Hy as Sn,IC as Cn,I_ as wn,Ic as Tn,Ih as En,Ii as Dn,In as On,Ip as kn,Is as An,Iv as jn,Ix as Mn,J as Nn,JC as Pn,Jh as Fn,Ji as In,Jo as Ln,Jp as q,Js as Rn,Jv as zn,Jy as Bn,K as Vn,KC as Hn,Kp as Un,Kr as Wn,Ku as J,Kv as Gn,Kx as Kn,Ky as qn,LC as Jn,Lc as Yn,Lg as Xn,Lh as Zn,Li as Qn,Lr as $n,Ls as er,Lx as tr,MC as nr,M_ as rr,Mc as ir,Mg as ar,Mh as or,Mi as sr,Ml as cr,Mm as lr,Ms as ur,Mt as dr,Mu as fr,Mv as pr,NC as mr,Nc as hr,Nh as gr,Ni as _r,Nl as vr,Nm as yr,Nn as br,Np as xr,Nu as Sr,Nv as Cr,O as wr,OC as Tr,Oa as Er,Oc as Dr,Oh as Or,On as kr,Oo as Ar,PC as jr,P_ as Mr,Pa as Nr,Pc as Pr,Pg as Fr,Ph as Ir,Pm as Lr,Pn as Rr,Pp as zr,Pu as Br,Pv as Vr,QC as Hr,Qc as Ur,Qg as Wr,Ql as Gr,Qo as Kr,Qp as qr,Qv as Jr,RC as Yr,Ra as Xr,Rc as Zr,Rg as Qr,Rm as $r,Rs as ei,Ru as ti,Rv as ni,Rx as ri,Sg as ii,Sh as ai,Sl as oi,Sm as si,Sp as ci,St as li,Su as ui,Sv as di,Sy as fi,Tb as pi,Tg as mi,Ti as hi,Tl as gi,Tv as _i,U as vi,UC as yi,U_ as bi,Ub as xi,Ug as Si,Uu as Ci,Ux as wi,V as Ti,Va as Ei,Vg as Di,Vh as Oi,Vm as ki,Vt as Ai,Vu as ji,Vx as Mi,Vy as Ni,W as Pi,WC as Fi,W_ as Ii,Wb as Li,Wg as Ri,Wn as zi,Wr as Bi,Wu as Vi,Wv as Hi,X as Ui,XC as Wi,Xh as Gi,Xr as Ki,Xs as qi,Xt as Ji,Xx as Yi,Xy as Xi,Ya as Zi,Yh as Qi,Yi as $i,Yo as ea,Yp as ta,Yr as na,Yv as ra,Z as ia,ZC as aa,Zg as oa,Zh as sa,Zi as ca,Zl as la,Zn as ua,Zr as da,Zs as fa,Zv as pa,Zx as ma,_b as ha,_c as ga,_h as _a,_l as va,_m as ya,_o as ba,_p as xa,_r as Sa,_s as Ca,_u as wa,_x as Ta,aC as Ea,ab as Da,ag as Oa,ai as ka,al as Aa,ao as ja,as as Ma,aw as Na,ay as Pa,b as Fa,bb as Ia,bc as La,bh as Ra,bo as za,bs as Ba,bu as Va,bv as Ha,by as Ua,cC as Wa,cb as Ga,cg as Ka,cl as qa,cm as Ja,co as Ya,cw as Xa,cy as Za,dC as Qa,dS as $a,dd as eo,dl as to,dm as no,do as ro,dv as io,dx as ao,dy as oo,eS as so,eb as co,ec as lo,ei as uo,el as fo,em as po,er as mo,es as ho,eu as go,ew as _o,ey as vo,fC as yo,fS as bo,fb as xo,fd as So,fh as Co,fm as wo,fr as To,fu as Eo,fv as Do,fx as Oo,ga as ko,gb as Ao,gh as jo,gi as Mo,gl as No,gm as Po,gr as Fo,gs as Io,gu as Lo,hb as Ro,hd as zo,hg as Bo,hh as Vo,hi as Ho,hl as Uo,hm as Wo,ho as Go,hs as Ko,hu as qo,ib as Jo,ig as Yo,io as Xo,iw as Zo,iy as Qo,jC as $o,j_ as es,jc as ts,jg as ns,jh as rs,ji as is,jm as as,jn as os,ju as ss,jv as cs,k as ls,kb as us,kh as ds,ko as fs,ks as ps,kv as ms,ky as hs,lS as gs,la as _s,lb as vs,ld as ys,lg as bs,ll as xs,lm as Ss,lo as Cs,lr as ws,lv as Ts,lw as Es,ly as Ds,md as Os,mg as ks,mm as As,mn as js,ms as Ms,mu as Ns,n_ as Ps,nb as Fs,nc as Is,nd as Ls,ng as Rs,nw as zs,ny as Bs,ob as Vs,od as Hs,og as Us,oi as Ws,on as Gs,oo as Ks,os as qs,ot as Js,ow as Ys,oy as Xs,pb as Zs,pd as Qs,pg as $s,ph as ec,pm as tc,ps as nc,pu as rc,px as ic,py as ac,q as oc,qC as sc,qh as cc,qo as lc,qp as uc,qs as dc,qt as fc,qv as pc,rb as mc,rg as hc,rw as gc,ry as _c,sC as vc,sb as yc,sd as bc,sg as xc,sl as Sc,sm as Cc,so as wc,st as Tc,sv as Ec,t_ as Dc,tb as Oc,tc as kc,td as Ac,tg as jc,tm as Mc,ts as Nc,ty as Pc,uS as Fc,ub as Ic,ug as Lc,ul as Rc,uo as zc,uu as Bc,uy as Vc,vS as Hc,vb as Uc,vc as Wc,vg as Gc,vh as Kc,vl as qc,vp as Jc,vs as Yc,vu as Xc,vx as Zc,wb as Qc,wg as $c,wh as el,wl as tl,wm as nl,wv as rl,xh as il,xo as al,xp as ol,xr as sl,xs as cl,xv as ll,xy as ul,yS as dl,yb as fl,yc as pl,yg as ml,yh as hl,yl as gl,yr as _l,ys as vl,yt as yl,yu as bl,yv as xl,yx as Sl,yy as Cl,zc as wl,zh as Y,zm as Tl,zs as El,zu as Dl,zv as Ol,zy as kl}from"./loadAgentsDir-DR5PVAc3.js";import{n as Al,t as jl}from"./cwd-DrEEb4f5.js";import{$ as Ml,C as Nl,E as Pl,H as Fl,I as Il,M as Ll,R as Rl,S as zl,V as Bl,Y as Vl,c as X,et as Hl,f as Ul,g as Wl,i as Gl,u as Kl,x as ql}from"./debug-kBjDaVkQ.js";import{$n as Jl,Ar as Yl,At as Xl,B as Zl,Bn as Ql,Cn as $l,Dr as eu,Fn as tu,Ft as nu,In as ru,It as iu,Kr as au,Kt as ou,L as su,Ln as cu,Lt as lu,Or as uu,Pr as du,Qn as fu,Ut as pu,Vn as mu,Wt as hu,an as gu,bn as _u,cn as vu,d as yu,er as bu,gt as xu,jt as Su,kt as Cu,m as wu,ot as Tu,qr as Eu,s as Du,y as Ou,zn as ku}from"./settings-YIDksG5Z.js";import{d as Au,h as ju,o as Mu,t as Nu}from"./config-D3K87Mm1.js";import{B as Pu,F as Fu,H as Iu,L as Lu,R as Ru,j as zu,o as Bu,q as Vu,s as Hu}from"./log-DWZny1vM.js";import{i as Uu,t as Wu}from"./execFileNoThrow-BfZFnCGa.js";import{a as Gu,i as Ku,n as qu,t as Ju}from"./bundledMode-BxyD5cqq.js";import{i as Yu,n as Xu}from"./platform-Vl9IynC3.js";import{n as Zu}from"./analytics-COpjZpvd.js";import{n as Qu,o as $u,s as ed,t as td}from"./intl-D2kgJmX7.js";import{S as nd,_ as rd,d as id,g as ad,l as od,u as sd}from"./startupProfiler-DIM_Ihyp.js";import{a as cd,d as ld,l as ud,o as dd,r as fd}from"./stringUtils-D_xPrwGQ.js";import{$ as pd,At as md,S as hd,at as gd,b as _d,et as vd,f as yd,g as bd,h as xd,jt as Sd,l as Cd,s as wd,u as Td}from"./model-D42epddJ.js";import{Ct as Ed,Rt as Dd,fn as Od,in as kd,ln as Ad,pn as jd,rn as Md,tt as Nd,un as Pd,wt as Fd,zt as Id}from"./prompt-CTByhpUI.js";import{i as Ld,r as Rd}from"./projectOnboardingState-KqcpRXls.js";import{a as zd,l as Bd}from"./sleep-BbWr_FL1.js";import{a as Vd}from"./ripgrep-D1f1pbCz.js";import{a as Hd}from"./loader-6MqzNGmV.js";import{n as Ud,r as Wd}from"./switcher-DhZCaAun.js";import{B as Gd,L as Kd,c as qd,r as Jd}from"./sessionTracing-UFK96PxT.js";import{i as Yd,n as Xd,r as Zd}from"./parser-DThLwgdM.js";import{n as Qd,t as $d}from"./poorMode-Ocff_UT1.js";import{C as ef,D as tf,E as nf,O as rf,S as af,T as of,a as sf,c as cf,d as lf,f as uf,i as df,l as ff,m as pf,n as mf,o as hf,p as gf,r as _f,s as vf,t as yf,w as bf,x as xf}from"./TextInput-BboKIug2.js";import{n as Sf,t as Cf}from"./notifications-dGBuNvFj.js";import{i as wf,n as Tf}from"./terminalSetup-Cqy5_PhJ.js";import{a as Ef,c as Df,i as Of,l as kf,n as Af,o as jf,r as Mf,s as Nf,t as Pf,u as Ff}from"./history-BxPGftQw.js";import{t as If}from"./useDoublePress-DQBLKyzJ.js";import{i as Lf,n as Rf,r as zf,t as Bf}from"./overlayContext-B6i_6y_0.js";import{t as Vf}from"./SelectMulti-BpAjjhsn.js";import{t as Hf}from"./KeybindingProviderSetup-CSUkJHTT.js";import{t as Uf}from"./useManagePlugins-CrWjzESW.js";import{n as Wf,t as Gf}from"./MCPConnectionManager-Bn1PDn3R.js";import{n as Kf,t as qf}from"./toolPool-BcwIF8Q_.js";import{t as Jf}from"./conversationRecovery-OhitW-7g.js";import{a as Yf,i as Xf,o as Zf,r as Qf,t as $f}from"./MessageSelector-B7xAQqZI.js";import{n as ep,t as tp}from"./useExitOnCtrlCDWithKeybindings-BgJrnuDl.js";import{n as np,t as rp}from"./select-FrwoTzuc.js";import{a as ip,c as ap,d as op,f as sp,i as cp,l as lp,n as up,o as dp,r as fp,s as pp,u as mp}from"./Spinner-DhhSOFcN.js";import{l as hp,u as gp}from"./SpinnerGlyph-CmVXC-_9.js";import{n as _p,r as vp}from"./sessionTitle-k4wpUS5l.js";import{n as yp,t as bp}from"./sideQuestion-5jcbOMsR.js";import{a as xp,n as Sp,o as Cp,r as wp,s as Tp,t as Ep}from"./skillChangeDetector-103-nEle.js";import{n as Dp,t as Op}from"./reconciler-D6BUq8WB.js";import{n as kp,t as Ap}from"./refresh-B4pqFp12.js";import{i as jp,n as Mp,r as Np,t as Pp}from"./directoryCompletion-BHyjyKAM.js";import{r as Fp,t as Ip}from"./PromptInputFooterSuggestions-CwqAsTI2.js";import{n as Lp,t as Rp}from"./useMergedTools-r6GQq5mI.js";import{a as zp,i as Bp,n as Vp,o as Hp,r as Up,t as Wp}from"./promptEditor-CpUFgGzc.js";import{n as Gp,t as Kp}from"./useMainLoopModel-BVgJo4hN.js";import{a as qp,i as Jp,o as Yp,r as Xp,s as Zp,t as Qp}from"./fileSuggestions-iWVXvvLB.js";import{E as $p,T as em,g as tm,m as nm}from"./pidLock-YvAaIrIY.js";import{n as rm,t as im}from"./nativeInstaller-ChGSz1lb.js";import{t as am}from"./CustomSelect-CpMbxYbt.js";import{i as om,n as sm,r as cm,t as lm}from"./extraUsage-BlRL3yeb.js";import{n as um,t as dm}from"./useSearchInput-BITV_Txn.js";import{n as fm,t as pm}from"./staticRender-RHUIg5ln.js";import{n as mm,t as hm}from"./useSettingsErrors-CO0fTNzn.js";import{n as gm,t as _m}from"./shadowedRuleDetection-D6R2OeoH.js";import{n as vm,t as ym}from"./ExitFlow-xBOnvhiW.js";import{a as bm,i as xm,r as Sm,t as Cm}from"./fast-DiolM1M7.js";import{i as wm,n as Tm,r as Em,t as Dm}from"./PermissionDialog-tEMMa5-a.js";import{a as Om,i as km,n as Am,r as jm,t as Mm}from"./PromptInputHelpMenu-krq-hiFO.js";import{n as Nm,r as Pm}from"./pluginAutoupdate-Dy5W3HWE.js";import{n as Fm,t as Im}from"./generateSessionName-CGaTTXCA.js";import{a as Lm,c as Rm,i as zm,l as Bm,n as Vm,o as Hm,r as Um,s as Wm,t as Gm}from"./Messages-CxMsfjOa.js";import{a as Km,i as qm,n as Jm,o as Ym,r as Xm,t as Zm}from"./BackgroundTasksDialog-mcDuiNGs.js";import{n as Qm}from"./fpsMetrics-Ixd0J4CH.js";import{a as $m,i as eh,n as th,r as nh,t as rh}from"./tipRegistry-BR_lSGRw.js";import{t as ih}from"./earlyInput-IghoCjG5.js";import{t as ah}from"./backgroundHousekeeping-PyLNnGdw.js";import{homedir as oh,tmpdir as sh}from"os";import{basename as ch,dirname as lh,extname as uh,join as dh,relative as fh,sep as ph}from"path";import{dirname as mh,join as hh}from"node:path";import{createHash as gh}from"node:crypto";import{randomUUID as _h}from"crypto";import{writeFile as vh}from"fs/promises";import{spawn as yh,spawnSync as bh}from"child_process";import{mkdir as xh,readFile as Sh,rename as Ch,writeFile as wh}from"node:fs/promises";function Th(e){return Array.isArray?Array.isArray(e):Fh(e)===`[object Array]`}function Eh(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 Dh(e){return e==null?``:Eh(e)}function Oh(e){return typeof e==`string`}function kh(e){return typeof e==`number`}function Ah(e){return e===!0||e===!1||Mh(e)&&Fh(e)==`[object Boolean]`}function jh(e){return typeof e==`object`}function Mh(e){return jh(e)&&e!==null}function Nh(e){return e!=null}function Ph(e){return!e.trim().length}function Fh(e){return e==null?e===void 0?`[object Undefined]`:`[object Null]`:Object.prototype.toString.call(e)}function Ih(e){let t=null,n=null,r=null,i=1,a=null;if(Oh(e)||Th(e))r=e,t=Lh(e),n=Rh(e);else{if(!bg.call(e,`name`))throw Error(_g(`name`));let o=e.name;if(r=o,bg.call(e,`weight`)&&e.weight!==void 0&&(i=e.weight,i<=0))throw Error(vg(Rh(o)));t=Lh(o),n=Rh(o),a=e.getFn??null}return{path:t,id:n,weight:i,src:r,getFn:a}}function Lh(e){return Th(e)?e:e.split(`.`)}function Rh(e){return Th(e)?e.join(`.`):e}function zh(e,t){let n=[],r=!1,i=(e,t,a,o)=>{if(Nh(e))if(!t[a])n.push(o===void 0?e:{v:e,i:o});else{let s=e[t[a]];if(!Nh(s))return;if(a===t.length-1&&(Oh(s)||kh(s)||Ah(s)||typeof s==`bigint`))n.push(o===void 0?Dh(s):{v:Dh(s),i:o});else if(Th(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,Oh(t)?t.split(`.`):t,0),r?n:n[0]}function Bh(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 Vh(e,t,{getFn:n=Z.getFn,fieldNormWeight:r=Z.fieldNormWeight}={}){let i=new Eg({getFn:n,fieldNormWeight:r});return i.setKeys(e.map(Ih)),i.setSources(t),i.create(),i}function Hh(e,{getFn:t=Z.getFn,fieldNormWeight:n=Z.fieldNormWeight}={}){let{keys:r,records:i}=e,a=new Eg({getFn:t,fieldNormWeight:n});return a.setKeys(r),a.setIndexRecords(i),a}function Uh(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 Wh(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(gg(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=Uh(_,s);e.length?c&&(w.indices=e):w.isMatch=!1}return w}function Gh(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 Kh(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 qh(e){return e.startsWith(`inverse`)}function Jh(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 Yh(e,t){let n=e.match(t);return n?n[1]:null}function Xh(e,t={}){return e.replace(/\\\|/g,Pg).split(Fg).map(e=>{let n=Jh(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<Ng;){let e=Mg[o],n=Yh(i,e.multiRegex);n&&(r.push(e.create(n,t)),a=!0)}if(!a)for(o=-1;++o<Ng;){let e=Mg[o],n=Yh(i,e.singleRegex);if(n){r.push(e.create(n,t));break}}}return r})}function Zh(...e){Lg.push(...e)}function Qh(e,t){for(let n=0,r=Lg.length;n<r;n+=1){let r=Lg[n];if(r.condition(e,t))return new r(e,t)}return new Ag(e,t)}function $h(e,t,{auto:n=!0}={}){let r=e=>{if(Oh(e)){let r={keyId:null,pattern:e};return n&&(r.searcher=Qh(e,t)),r}let i=Object.keys(e),a=Vg(e);if(!a&&i.length>1&&!Bg(e))return r(Ug(e));if(Hg(e)){let r=a?e[zg.PATH]:i[0],o=a?e[zg.PATTERN]:e[r];if(!Oh(o))throw Error(hg(r));let s={keyId:Rh(r),pattern:o};return n&&(s.searcher=Qh(o,t)),s}let o={children:[],operator:i[0]};return i.forEach(t=>{let n=e[t];Th(n)&&n.forEach(e=>{o.children.push(r(e))})}),o};return Bg(e)||(e=Ug(e)),r(e)}function eg(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 tg(e,{ignoreFieldNorm:t=Z.ignoreFieldNorm}){e.forEach(e=>{e.score=eg(e.matches,{ignoreFieldNorm:t})})}function ng(e){let t=[];return e.matches.forEach(e=>{if(!Nh(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 rg(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=ng(e)),r&&(a.score=e.score),a})}function ig(e){Kg.has(e)||(Kg.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 ag(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||ig(e),t=>t.match(e)||[]):e=>e.match(Gg)||[]}function og({isCaseSensitive:e=!1,ignoreDiacritics:t=!1,tokenize:n}={}){let r=ag(n);return{tokenize(n){return e||(n=n.toLowerCase()),t&&(n=kg(n)),r(n)}}}function sg(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 cg(e,t,n,r){let{i,v:a,$:o}=t;if(a!==void 0){sg(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)sg(e,t.v,i,r);else sg(e,n.v,i,r)}}function lg(e,t,n){let r={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(let i of e)cg(r,i,t,n);return r}function ug(e,t,n,r){cg(e,t,n,r)}function dg(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 fg(e,t){if(t.length===0)return;let n=Array.from(new Set(t)).sort((e,t)=>e-t);for(let t of n)dg(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 pg,mg,hg,gg,_g,vg,yg,bg,xg,Sg,Cg,wg,Tg,Z,Eg,Dg,Og,kg,Ag,jg,Mg,Ng,Pg,Fg,Ig,Lg,Rg,zg,Bg,Vg,Hg,Ug,Wg,Gg,Kg,qg,Jg,Yg,Xg=t((()=>{pg=`Incorrect 'index' type`,mg=`Invalid doc index: must be a non-negative integer within the bounds of the docs array`,hg=e=>`Invalid value for key ${e}`,gg=e=>`Pattern length exceeds max of ${e}.`,_g=e=>`Missing ${e} property in key`,vg=e=>`Property 'weight' in key '${e}' must be a positive integer`,yg=`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.`,bg=Object.prototype.hasOwnProperty,xg=class{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach(e=>{let n=Ih(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)}},Sg={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},Cg={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},wg={location:0,threshold:.6,distance:100},Tg={useExtendedSearch:!1,useTokenSearch:!1,tokenize:void 0,tokenMatch:`any`,getFn:zh,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1},Z=Object.freeze({...Cg,...Sg,...wg,...Tg}),Eg=class{constructor({getFn:e=Z.getFn,fieldNormWeight:t=Z.fieldNormWeight}={}){this.norm=Bh(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(Oh(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(mg);if(Oh(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(mg);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!Nh(e)||Ph(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(Nh(i)){if(Th(i)){let e=[];for(let t=0,n=i.length;t<n;t+=1){let n=i[t];if(Nh(n)){if(Oh(n)){if(!Ph(n)){let r={v:n,i:t,n:this.norm.get(n)};e.push(r)}}else if(Nh(n.v)){let t=Oh(n.v)?n.v:Dh(n.v);if(!Ph(t)){let r={v:t,i:n.i,n:this.norm.get(t)};e.push(r)}}}}n.$[t]=e}else if(Oh(i)&&!Ph(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}}},Dg={ł:`l`,Ł:`L`,đ:`d`,Đ:`D`,ø:`o`,Ø:`O`,ħ:`h`,Ħ:`H`,ŧ:`t`,Ŧ:`T`,ı:`i`,ß:`ss`},Og=RegExp(`[`+Object.keys(Dg).join(``)+`]`,`g`),kg=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(Og,e=>Dg[e]):e=>e,Ag=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?kg(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;let u=(e,t)=>{this.chunks.push({pattern:e,alphabet:Gh(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?kg(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}=Wh(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=Kh(u)),p}},jg=new Set([`fuzzy`,`include`]),Mg=[{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 Ag(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)}}}}],Ng=Mg.length,Pg=`\0`,Fg=`|`,Ig=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?kg(e):e,this.pattern=e,this.query=Xh(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?kg(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,qh(r.type)&&(c=!0),n&&(jg.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=Kh(o)),e}}return{isMatch:!1,score:1}}},Lg=[],Rg={AND:`$and`,OR:`$or`},zg={PATH:`$path`,PATTERN:`$val`},Bg=e=>!!(e[Rg.AND]||e[Rg.OR]),Vg=e=>!!e[zg.PATH],Hg=e=>!Th(e)&&jh(e)&&!Bg(e),Ug=e=>({[Rg.AND]:Object.keys(e).map(t=>({[t]:e[t]}))}),Wg=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)}},Gg=/[\p{L}\p{M}\p{N}_]+/gu,Kg=new WeakSet,qg=class{static condition(e,t){return t.useTokenSearch}constructor(e,t){this.options=t,this.analyzer=og({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 Ag(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=Kh(t)),this.combineAll&&(this.useMask?c.matchedMask=a:c.matchedTerms=o,c.termCount=this.numTerms),c}},Jg=class{constructor(e,t,n){this.options={...Z,...t},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new xg(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=Qh(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 Eg))throw Error(pg);if(this._myIndex=t||Vh(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){let e=og({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=lg(this._myIndex.records,this._myIndex.keys.length,e)}this._invalidateSearcherCache()}add(e){if(!Nh(e))return;this._docs.push(e);let t=this._myIndex.add(e,this._docs.length-1);if(this._invertedIndex&&t){let e=og({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});ug(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&&fg(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(mg);this._invertedIndex&&fg(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(Oh(e)&&!e.trim()){let e=this._docs.map((e,t)=>({item:e,refIndex:t}));return kh(n)&&n>-1&&(e=e.slice(0,n)),e}let c=kh(n)&&n>0&&Oh(e),l;if(c){let t=new Wg(n);Oh(this._docs[0])?this._searchStringList(e,{heap:t,ignoreFieldNorm:s}):this._searchObjectList(e,{heap:t,ignoreFieldNorm:s}),l=t.extractSorted(o)}else l=Oh(e)?Oh(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e),tg(l,{ignoreFieldNorm:s}),a&&l.sort(o),kh(n)&&n>-1&&(l=l.slice(0,n));return rg(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(!Nh(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=eg(r.matches,{ignoreFieldNorm:n}),t.shouldInsert(r.score)&&t.insert(r)):o.push(r)}}}),o}_searchLogical(e){let t=$h(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===Rg.AND)return[]}return o},r=this._myIndex.records,i=new Map,a=[];return r.forEach(({$:e,i:r})=>{if(Nh(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(!Nh(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=eg(r.matches,{ignoreFieldNorm:n}),t.shouldInsert(r.score)&&t.insert(r)):s.push(r)}}),s}_findMatches({key:e,value:t,searcher:n}){if(!Nh(t))return[];let r=[];if(Th(t))t.forEach(({v:t,i,n:a})=>{if(!Nh(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}},Jg.version=`7.4.2`,Jg.createIndex=Vh,Jg.parseIndex=Hh,Jg.config=Z,Jg.match=function(e,t,n){if(n&&n.useTokenSearch)throw Error(yg);return Qh(e,{...Z,...n}).searchIn(t)},Jg.parseQuery=$h,Zh(Ig),Zh(qg),Jg.use=function(...e){e.forEach(e=>Zh(e))},Yg=Jg}));o(),le(),c(),V(),je(),Ne(),Ql(),$u(),yc(),kc(),lf(),dm();var Q=n(P(),1);_(),Vm(),Jo(),zd(),Y(),pm();var $=de();function Zg({children:e}){let{bindings:t}=Bd(),n=(0,Q.useRef)(null),r=(0,Q.useRef)(new Map),i=(0,Q.useRef)(new Set).current;return(0,$.jsx)(v,{bindings:t,pendingChordRef:n,pendingChord:null,setPendingChord:()=>{},activeContexts:i,registerActiveContext:()=>{},unregisterActiveContext:()=>{},handlerRegistryRef:r,children:e})}function Qg(e){if(!(`message`in e))return 1;let t=e.message.content;return Array.isArray(t)?t.length:1}async function $g(e,t,n,{columns:r,verbose:i=!1,chunkSize:a=40,onProgress:o}={}){let s=n=>fm((0,$.jsx)(Zn,{children:(0,$.jsx)(Zg,{children:(0,$.jsx)(Gm,{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+=Qg(t);for(let e=0;e<c;e+=a){let t=await s([e,e+a]);if(se(t).trim()===``)break;await n(t),o?.(e+a)}}async function e_(e,t=[],n){let r=[];return await $g(e,t,e=>void r.push(se(e)),{columns:n}),r.join(``)}a(),R(),_e(),Al(),Ml(),Fl(),Il(),ql(),Ul(),Gl(),au(),Vu(),Bu(),Uu(),be(),Ku(),du(),Yu(),bu(),Zu(),ru(),$l(),Se(),rd(),vu(),Ce(),Ju(),ou(),Xl(),xu(),su(),dd(),wu(),Au(),jd(),gd(),yd(),kd(),Xa(),Fi(),_t(),Qa(),Vd(),vc(),Kd(),Sl(),Oo(),xi(),Ut(),Qc(),Ia(),ha(),Zs(),vs(),Ga(),Fs(),Oc(),Xi(),Nt(),Id(),hs(),fi(),Cl(),oo(),Xs(),_c(),Pc(),Fd(),Nd(),mt(),pc(),pn(),Mt(),wt(),Ha(),io(),st(),Ii(),Et(),wn(),Dc(),oa(),Zd(),Si(),Xn(),ar(),Xt(),$c(),Gc(),Bo(),Ka(),Oa(),Fn(),rn(),rs(),xt(),yn(),Tl(),Lr(),lr(),zt(),ya(),Wo(),no(),Cc(),po(),qr(),q(),Qs(),eo(),fn(),Sr(),ss(),go(),Gr(),gi(),K(),qc(),No(),wl(),Wt(),qd(),ga(),qi(),dc(),ei(),St(),Bt(),vl(),nc(),Ma(),Nc(),Ar(),al(),zc(),Zi(),Dt(),Nr(),Er(),In(),Qn(),sr(),Mo(),Fo(),os(),js(),Ui(),oc(),vi(),Ti(),Fa(),zp(),am();function t_({onDone:e}){return(0,$.jsxs)(ue,{title:`You've spent $5 on the API this session.`,onCancel:e,children:[(0,$.jsxs)(g,{flexDirection:`column`,children:[(0,$.jsx)(b,{children:`Learn more about how to monitor your spending:`}),(0,$.jsx)(y,{url:`https://code.workmate.com/docs/en/costs`})]}),(0,$.jsx)(rp,{options:[{value:`ok`,label:`Got it, thanks!`}],onChange:e})]})}np(),V(),am();function n_({idleMinutes:e,totalInputTokens:t,onDone:n}){return(0,$.jsxs)(ue,{title:`You've been away ${r_(e)} and this conversation is ${ad(t)} tokens.`,onCancel:()=>n(`dismiss`),children:[(0,$.jsx)(g,{flexDirection:`column`,children:(0,$.jsx)(b,{children:`If this is a new task, clearing context will save usage and be faster.`})}),(0,$.jsx)(rp,{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 r_(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`}Cf();async function i_(e,t){let n=Mu().preferredNotifChannel;await jt(e),await o_(n,e,t),pu.terminal}var a_=`Work Mate`;async function o_(e,t,n){let r=t.title||a_;try{switch(e){case`auto`:return s_(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:c_()}),`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 s_(e,t){let n=e.title||a_;switch(pu.terminal){case`Apple_Terminal`:return await l_()?(t.notifyBell(),`terminal_bell`):`no_method_available`;case`iTerm.app`:return t.notifyITerm2(e),`iterm2`;case`kitty`:return t.notifyKitty({...e,title:n,id:c_()}),`kitty`;case`ghostty`:return t.notifyGhostty({...e,title:n}),`ghostty`;default:return`no_method_available`}}function c_(){return Math.floor(Math.random()*1e4)}async function l_(){try{if(pu.terminal!==`Apple_Terminal`)return!1;let e=(await Wu(`osascript`,[`-e`,`tell application "Terminal" to name of current settings of front window`])).stdout.trim();if(!e)return!1;let t=await Wu(`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 Hu(e),!1}}var u_=300,d_=240*1e3,f_=null,p_=null,m_=0,h_=!1;function g_(){m_++,m_===1&&(x_(),y_())}function __(){m_>0&&m_--,m_===0&&(b_(),S_())}function v_(){m_=0,b_(),S_()}function y_(){process.platform===`darwin`&&p_===null&&(p_=setInterval(()=>{m_>0&&(X(`Restarting caffeinate to maintain sleep prevention`),S_(),x_())},d_),p_.unref())}function b_(){p_!==null&&(clearInterval(p_),p_=null)}function x_(){if(process.platform===`darwin`&&f_===null){h_||(h_=!0,Hl(async()=>{v_()}));try{f_=yh(`caffeinate`,[`-i`,`-t`,String(u_)],{stdio:`ignore`}),f_.unref();let e=f_;f_.on(`error`,t=>{X(`caffeinate spawn error: ${t.message}`),f_===e&&(f_=null)}),f_.on(`exit`,()=>{f_===e&&(f_=null)}),X(`Started caffeinate to prevent sleep`)}catch{f_=null}}}function S_(){if(f_!==null){let e=f_;f_=null;try{e.kill(`SIGKILL`),X(`Stopped caffeinate, allowing sleep`)}catch{}}}var C_=class{constructor(){s(this,`_status`,`idle`),s(this,`_generation`,0),s(this,`_changed`,De()),s(this,`subscribe`,this._changed.subscribe),s(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 w_(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(Bi(f,{},p,e).then(e=>{m===a.current&&e&&!l&&(r.current=e)}),l||c||u){let t=At(f,e).findLast(Sa);t&&(r.current=t.uuid)}n.current=e.length,i.current=o},[e,t])}tp(),sp(),mp(),dp(),fp(),Qf(),V();var T_=6e3;function E_(){return Date.now()-at()}function D_(e){return E_()<e}function O_(e){return!D_(e)}function k_(e,t){let n=x();(0,Q.useEffect)(()=>{Ie(!0)},[]),(0,Q.useEffect)(()=>{let r=!1,i=setInterval(()=>{O_(6e3)&&!r&&(r=!0,clearInterval(i),i_({message:e,notificationType:t},n))},T_);return()=>clearInterval(i)},[e,t,n])}Rd(),Vs(),Sn(),ti(),Tn(),hr(),yt(),rf(),of(),ef(),wf(),Nf(),If(),vf(),df(),mf(),Up(),wm(),V(),hn();var A_={topLeft:`┌`,topRight:`┐`,bottomLeft:`└`,bottomRight:`┘`,horizontal:`─`,vertical:`│`,teeLeft:`├`,teeRight:`┤`};function j_(e){return En().syntaxHighlightingDisabled?(0,$.jsx)(N_,{...e,highlight:null}):(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(N_,{...e,highlight:null}),children:(0,$.jsx)(M_,{...e})})}function M_(e){let t=(0,Q.use)(Or());return(0,$.jsx)(N_,{...e,highlight:t})}function N_({content:e,maxLines:t,minHeight:n,minWidth:r=40,maxWidth:i,highlight:a}){let{columns:o}=ae(),[s]=h(),c=i??o-4,l=t??20,u=(0,Q.useMemo)(()=>So(e,s,a),[e,s,a]).split(`
2
+ `),d=u.length>l,m=d?u.slice(0,l):u,_=Math.max(0,Math.min(n??0,l)-m.length-+!!d),v=_>0?[...m,...Array(_).fill(``)]:m,y=Math.max(r,...v.map(e=>p(e))),x=Math.min(y+4,c),S=x-4,C=`${A_.topLeft}${A_.horizontal.repeat(x-2)}${A_.topRight}`,w=`${A_.bottomLeft}${A_.horizontal.repeat(x-2)}${A_.bottomRight}`,T=d?(()=>{let e=u.length-l,t=`${A_.horizontal.repeat(3)} \u2702 ${A_.horizontal.repeat(3)} ${e} lines hidden `,n=p(t),r=Math.max(0,x-2-n);return`${A_.teeLeft}${t}${A_.horizontal.repeat(r)}${A_.teeRight}`})():null;return(0,$.jsxs)(g,{flexDirection:`column`,children:[(0,$.jsx)(b,{dimColor:!0,children:C}),v.map((e,t)=>{let n=p(e)>S?qn(e,0,S):e,r=` `.repeat(Math.max(0,S-p(n)));return(0,$.jsxs)(g,{flexDirection:`row`,children:[(0,$.jsxs)(b,{dimColor:!0,children:[A_.vertical,` `]}),(0,$.jsx)(f,{children:n}),(0,$.jsxs)(b,{dimColor:!0,children:[r,` `,A_.vertical]})]},t)}),T&&(0,$.jsx)(b,{color:`warning`,children:T}),(0,$.jsx)(b,{dimColor:!0,children:w})]})}yc(),V(),rd();function P_({questions:e,currentQuestionIndex:t,answers:n,hideSubmitTab:r=!1}){let{columns:i}=ae(),a=(0,Q.useMemo)(()=>{let n=r?``:` ${l.tick} Submit `,a=p(`← `)+p(` →`)+p(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+p(e)).reduce((e,t)=>e+t,0)<=o)return s;let c=4+p(s[t]||``),u=Math.min(c,o/2),d=o-u,f=e.length-1,m=Math.max(6,Math.floor(d/Math.max(f,1)));return s.map((e,n)=>n===t?nd(e,u-2-2):nd(e,m-2-2))},[e,t,i,r]),o=e.length===1&&r;return(0,$.jsxs)(g,{flexDirection:`row`,marginBottom:1,children:[!o&&(0,$.jsx)(b,{color:t===0?`inactive`:void 0,children:`← `}),e.map((e,r)=>{let i=r===t,o=e?.question&&n[e.question]?l.checkboxOn:l.checkboxOff,s=a[r]||e?.header||`Q${r+1}`;return(0,$.jsx)(g,{children:i?(0,$.jsxs)(b,{backgroundColor:`permission`,color:`inverseText`,children:[` `,o,` `,s,` `]}):(0,$.jsxs)(b,{children:[` `,o,` `,s,` `]})},e?.question||`question-${r}`)}),!r&&(0,$.jsx)(g,{children:t===e.length?(0,$.jsxs)(b,{backgroundColor:`permission`,color:`inverseText`,children:[` `,l.tick,` Submit`,` `]}):(0,$.jsxs)(b,{children:[` `,l.tick,` Submit `]})},`submit`),!o&&(0,$.jsx)(b,{color:t===e.length?`inactive`:void 0,children:` →`})]})}c(),yc(),V(),Y();function F_({question:e,questions:t,currentQuestionIndex:n,answers:r,questionStates:i,hideSubmitTab:a=!1,minContentHeight:o,minContentWidth:s,onUpdateQuestionState:c,onAnswer:d,onTextInputFocus:f,onCancel:p,onTabPrev:h,onTabNext:_,onRespondToClaude:v,onFinishPlanInterview:y}){let x=G(e=>e.toolPermissionContext.mode)===`plan`,[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(0),[D,O]=(0,Q.useState)(!1),[k,A]=(0,Q.useState)(0),j=Bp(),M=j??null,N=e.question,P=i[N],F=e.options,[ee,I]=(0,Q.useState)(0),L=(0,Q.useRef)(N);if(L.current!==N){L.current=N;let e=P?.selectedValue,t=e?F.findIndex(t=>t.label===e):-1;I(t>=0?t:0)}let te=F[ee],R=P?.selectedValue,ne=P?.textInputValue||``,z=(0,Q.useCallback)(e=>{let t=F[e];t&&(I(e),c(N,{selectedValue:t.label},!1),d(N,t.label))},[F,N,c,d]),re=(0,Q.useCallback)(e=>{if(D)return;let t;t=typeof e==`number`?e:e===`up`?ee>0?ee-1:ee:ee<F.length-1?ee+1:ee,t>=0&&t<F.length&&I(t)},[ee,F.length,D]);E(`chat:externalEditor`,async()=>{let e=P?.textInputValue||``,t=await Vp(e);t.content!==null&&t.content!==e&&c(N,{textInputValue:t.content},!1)},{context:`Chat`,isActive:D&&!!j}),m({"tabs:previous":()=>h?.(),"tabs:next":()=>_?.()},{context:`Tabs`,isActive:!D&&!S});let ie=(0,Q.useCallback)(()=>{O(!1),f(!1),R&&d(N,R)},[R,N,d,f]),B=(0,Q.useCallback)(()=>{C(!0)},[]),oe=(0,Q.useCallback)(()=>{C(!1)},[]),se=(0,Q.useCallback)(e=>{if(S){if(e.key===`up`||e.ctrl&&e.key===`p`){e.preventDefault(),w===0?oe():T(0);return}if(e.key===`down`||e.ctrl&&e.key===`n`){e.preventDefault(),x&&w===0&&T(1);return}if(e.key===`return`){e.preventDefault(),w===0?v():y();return}e.key===`escape`&&(e.preventDefault(),p());return}if(D){e.key===`escape`&&(e.preventDefault(),ie());return}if(e.key===`up`||e.ctrl&&e.key===`p`)e.preventDefault(),ee>0&&re(`up`);else if(e.key===`down`||e.ctrl&&e.key===`n`)e.preventDefault(),ee===F.length-1?B():re(`down`);else if(e.key===`return`)e.preventDefault(),z(ee);else if(e.key===`n`&&!e.ctrl&&!e.meta)e.preventDefault(),O(!0),f(!0);else if(e.key===`escape`)e.preventDefault(),p();else if(e.key.length===1&&e.key>=`1`&&e.key<=`9`){e.preventDefault();let t=parseInt(e.key,10)-1;t<F.length&&re(t)}},[S,w,x,D,ee,F.length,oe,B,re,z,ie,v,y,p,f]),V=te?.preview||null,{columns:ce}=ae(),le=ce-30-4,H=(0,Q.useMemo)(()=>o?Math.max(1,o-11):void 0,[o]);return(0,$.jsxs)(g,{flexDirection:`column`,marginTop:1,tabIndex:0,autoFocus:!0,onKeyDown:se,children:[(0,$.jsx)(u,{color:`inactive`}),(0,$.jsxs)(g,{flexDirection:`column`,paddingTop:0,children:[(0,$.jsx)(P_,{questions:t,currentQuestionIndex:n,answers:r,hideSubmitTab:a}),(0,$.jsx)(Em,{title:e.question,color:`text`}),(0,$.jsxs)(g,{flexDirection:`column`,minHeight:o,children:[(0,$.jsxs)(g,{marginTop:1,flexDirection:`row`,gap:4,children:[(0,$.jsx)(g,{flexDirection:`column`,width:30,children:F.map((e,t)=>{let n=ee===t,r=R===e.label;return(0,$.jsxs)(g,{flexDirection:`row`,children:[n?(0,$.jsx)(b,{color:`suggestion`,children:l.pointer}):(0,$.jsx)(b,{children:` `}),(0,$.jsxs)(b,{dimColor:!0,children:[` `,t+1,`.`]}),(0,$.jsxs)(b,{color:r?`success`:n?`suggestion`:void 0,bold:n,children:[` `,e.label]}),r&&(0,$.jsxs)(b,{color:`success`,children:[` `,l.tick]})]},e.label)})}),(0,$.jsxs)(g,{flexDirection:`column`,flexGrow:1,children:[(0,$.jsx)(j_,{content:V||`No preview available`,maxLines:H,minWidth:s,maxWidth:le}),(0,$.jsxs)(g,{marginTop:1,flexDirection:`row`,gap:1,children:[(0,$.jsx)(b,{color:`suggestion`,children:`Notes:`}),D?(0,$.jsx)(yf,{value:ne,placeholder:`Add notes on this design…`,onChange:e=>{c(N,{textInputValue:e},!1)},onSubmit:ie,onExit:ie,focus:!0,showCursor:!0,columns:60,cursorOffset:k,onChangeCursorOffset:A}):(0,$.jsx)(b,{dimColor:!0,italic:!0,children:ne||`press n to add notes`})]})]})]}),(0,$.jsxs)(g,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(u,{color:`inactive`}),(0,$.jsxs)(g,{flexDirection:`row`,gap:1,children:[S&&w===0?(0,$.jsx)(b,{color:`suggestion`,children:l.pointer}):(0,$.jsx)(b,{children:` `}),(0,$.jsx)(b,{color:S&&w===0?`suggestion`:void 0,children:`Chat about this`})]}),x&&(0,$.jsxs)(g,{flexDirection:`row`,gap:1,children:[S&&w===1?(0,$.jsx)(b,{color:`suggestion`,children:l.pointer}):(0,$.jsx)(b,{children:` `}),(0,$.jsx)(b,{color:S&&w===1?`suggestion`:void 0,children:`Skip interview and plan immediately`})]})]}),(0,$.jsx)(g,{marginTop:1,children:(0,$.jsxs)(b,{color:`inactive`,dimColor:!0,children:[`Enter to select · `,l.arrowUp,`/`,l.arrowDown,` to navigate · n to add notes`,t.length>1&&(0,$.jsx)($.Fragment,{children:` · Tab to switch questions`}),D&&M&&(0,$.jsxs)($.Fragment,{children:[` · ctrl+g to edit in `,M]}),` · Esc to cancel`]})})]})]})]})}c(),V(),Y(),zp(),Up(),am(),wm();function I_({question:e,questions:t,currentQuestionIndex:n,answers:r,questionStates:i,hideSubmitTab:a=!1,planFilePath:o,minContentHeight:s,minContentWidth:c,onUpdateQuestionState:d,onAnswer:f,onTextInputFocus:p,onCancel:m,onSubmit:h,onTabPrev:_,onTabNext:v,onRespondToClaude:y,onFinishPlanInterview:x,onImagePaste:S,pastedContents:C,onRemoveImage:w}){let T=G(e=>e.toolPermissionContext.mode)===`plan`,[E,D]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(0),[A,j]=(0,Q.useState)(!1),M=Bp()??null,N=(0,Q.useCallback)(e=>{let t=e===`__other__`;j(t),p(t)},[p]),P=(0,Q.useCallback)(()=>{D(!0)},[]),F=(0,Q.useCallback)(()=>{D(!1)},[]),ee=(0,Q.useCallback)(e=>{if(E){if(e.key===`up`||e.ctrl&&e.key===`p`){e.preventDefault(),O===0?F():k(0);return}if(e.key===`down`||e.ctrl&&e.key===`n`){e.preventDefault(),T&&O===0&&k(1);return}if(e.key===`return`){e.preventDefault(),O===0?y():x();return}e.key===`escape`&&(e.preventDefault(),m())}},[E,O,T,F,y,x,m]),I=e.options.map(e=>({type:`text`,value:e.label,label:e.label,description:e.description})),L=e.question,te=i[L],R=(0,Q.useCallback)(async(t,n)=>{let r=await Vp(t);r.content!==null&&r.content!==t&&(n(r.content),d(L,{textInputValue:r.content},e.multiSelect??!1))},[L,d,e.multiSelect]),ne={type:`input`,value:`__other__`,label:`Other`,placeholder:e.multiSelect?`Type something`:`Type something.`,initialValue:te?.textInputValue??``,onChange:t=>{d(L,{textInputValue:t},e.multiSelect??!1)}},z=[...I,ne];return!e.multiSelect&&e.options.some(e=>e.preview)?(0,$.jsx)(F_,{question:e,questions:t,currentQuestionIndex:n,answers:r,questionStates:i,hideSubmitTab:a,minContentHeight:s,minContentWidth:c,onUpdateQuestionState:d,onAnswer:f,onTextInputFocus:p,onCancel:m,onTabPrev:_,onTabNext:v,onRespondToClaude:y,onFinishPlanInterview:x}):(0,$.jsxs)(g,{flexDirection:`column`,marginTop:0,tabIndex:0,autoFocus:!0,onKeyDown:ee,children:[T&&o&&(0,$.jsxs)(g,{flexDirection:`column`,gap:0,children:[(0,$.jsx)(u,{color:`inactive`}),(0,$.jsxs)(b,{color:`inactive`,children:[`Planning: `,(0,$.jsx)(Ni,{filePath:o})]})]}),(0,$.jsx)(g,{marginTop:-1,children:(0,$.jsx)(u,{color:`inactive`})}),(0,$.jsxs)(g,{flexDirection:`column`,paddingTop:0,children:[(0,$.jsx)(P_,{questions:t,currentQuestionIndex:n,answers:r,hideSubmitTab:a}),(0,$.jsx)(Em,{title:e.question,color:`text`}),(0,$.jsxs)(g,{flexDirection:`column`,minHeight:s,children:[(0,$.jsx)(g,{marginTop:1,children:e.multiSelect?(0,$.jsx)(Vf,{options:z,defaultValue:i[e.question]?.selectedValue,onChange:e=>{d(L,{selectedValue:e},!0);let t=e.includes(`__other__`)?i[L]?.textInputValue:void 0,n=e.filter(e=>e!==`__other__`).concat(t?[t]:[]);f(L,n,void 0,!1)},onFocus:N,onCancel:m,submitButtonText:n===t.length-1?`Submit`:`Next`,onSubmit:h,onDownFromLastItem:P,isDisabled:E,onOpenEditor:R,onImagePaste:S,pastedContents:C,onRemoveImage:w},e.question):(0,$.jsx)(rp,{options:z,defaultValue:i[e.question]?.selectedValue,onChange:e=>{d(L,{selectedValue:e},!1);let t=e===`__other__`?i[L]?.textInputValue:void 0;f(L,e,t)},onFocus:N,onCancel:m,onDownFromLastItem:P,isDisabled:E,layout:`compact-vertical`,onOpenEditor:R,onImagePaste:S,pastedContents:C,onRemoveImage:w},e.question)}),(0,$.jsxs)(g,{flexDirection:`column`,children:[(0,$.jsx)(u,{color:`inactive`}),(0,$.jsxs)(g,{flexDirection:`row`,gap:1,children:[E&&O===0?(0,$.jsx)(b,{color:`suggestion`,children:l.pointer}):(0,$.jsx)(b,{children:` `}),(0,$.jsxs)(b,{color:E&&O===0?`suggestion`:void 0,children:[z.length+1,`. Chat about this`]})]}),T&&(0,$.jsxs)(g,{flexDirection:`row`,gap:1,children:[E&&O===1?(0,$.jsx)(b,{color:`suggestion`,children:l.pointer}):(0,$.jsx)(b,{children:` `}),(0,$.jsxs)(b,{color:E&&O===1?`suggestion`:void 0,children:[z.length+2,`. Skip interview and plan immediately`]})]})]}),(0,$.jsx)(g,{marginTop:1,children:(0,$.jsxs)(b,{color:`inactive`,dimColor:!0,children:[`Enter to select ·`,` `,t.length===1?(0,$.jsxs)($.Fragment,{children:[l.arrowUp,`/`,l.arrowDown,` to navigate`]}):`Tab/Arrow keys to navigate`,A&&M&&(0,$.jsxs)($.Fragment,{children:[` · ctrl+g to edit in `,M]}),` · Esc to cancel`]})})]})]})]})}V(),Xc(),Y();function L_(e,t){if(!e)return null;switch(e.type){case`rule`:return{reasonString:`Permission rule ${I.bold(Zl(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?` ${I.dim(`[${e.hookSource}]`)}`:``;return{reasonString:`Hook ${I.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 R_({permissionResult:e,toolType:t}){let n=G(e=>e.toolPermissionContext.mode),r=L_(e?.decisionReason,t);if(!r)return null;let i=r.themeColor??(e?.decisionReason?.type===`hook`&&n===`auto`?`warning`:void 0);return(0,$.jsxs)(g,{marginBottom:1,flexDirection:`column`,children:[i?(0,$.jsx)(b,{color:i,children:r.reasonString}):(0,$.jsx)(b,{children:(0,$.jsx)(f,{children:r.reasonString})}),r.configString&&(0,$.jsx)(b,{dimColor:!0,children:r.configString})]})}c(),V(),am(),wm();function z_({questions:e,currentQuestionIndex:t,answers:n,allQuestionsAnswered:r,permissionResult:i,minContentHeight:a,onFinalResponse:o}){return(0,$.jsxs)(g,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(u,{color:`inactive`}),(0,$.jsxs)(g,{flexDirection:`column`,borderTop:!0,borderColor:`inactive`,paddingTop:0,children:[(0,$.jsx)(P_,{questions:e,currentQuestionIndex:t,answers:n}),(0,$.jsx)(Em,{title:`Review your answers`,color:`text`}),(0,$.jsxs)(g,{flexDirection:`column`,marginTop:1,minHeight:a,children:[!r&&(0,$.jsx)(g,{marginBottom:1,children:(0,$.jsxs)(b,{color:`warning`,children:[l.warning,` You have not answered all questions`]})}),Object.keys(n).length>0&&(0,$.jsx)(g,{flexDirection:`column`,marginBottom:1,children:e.filter(e=>e?.question&&n[e.question]).map(e=>{let t=n[e?.question];return(0,$.jsxs)(g,{flexDirection:`column`,marginLeft:1,children:[(0,$.jsxs)(b,{children:[l.bullet,` `,e?.question||`Question`]}),(0,$.jsx)(g,{marginLeft:2,children:(0,$.jsxs)(b,{color:`success`,children:[l.arrowRight,` `,t]})})]},e?.question||`answer`)})}),(0,$.jsx)(R_,{permissionResult:i,toolType:`tool`}),(0,$.jsx)(b,{color:`inactive`,children:`Ready to submit your answers?`}),(0,$.jsx)(g,{marginTop:1,children:(0,$.jsx)(rp,{options:[{type:`text`,label:`Submit answers`,value:`submit`},{type:`text`,label:`Cancel`,value:`cancel`}],onChange:e=>o(e),onCancel:()=>o(`cancel`)})})]})]})]})}function B_(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 V_={currentQuestionIndex:0,answers:{},questionStates:{},isInTextInput:!1};function H_(){let[e,t]=(0,Q.useReducer)(B_,V_),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}}rn(),yc(),V(),Oc(),Zu(),Y(),xt(),Bu(),Qs();var U_=12,W_=40,G_=15;function K_(e){return En().syntaxHighlightingDisabled?(0,$.jsx)(J_,{...e,highlight:null}):(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(J_,{...e,highlight:null}),children:(0,$.jsx)(q_,{...e})})}function q_(e){let t=(0,Q.use)(Or());return(0,$.jsx)(J_,{...e,highlight:t})}function J_({toolUseConfirm:e,onDone:t,onReject:n,highlight:r}){let i=(0,Q.useMemo)(()=>oi.inputSchema.safeParse(e.input),[e.input]),a=i.success&&i.data.questions||[],{rows:o}=ae(),[s]=h(),{globalContentHeight:c,globalContentWidth:l}=(0,Q.useMemo)(()=>{let e=0,t=0,n=Math.max(U_,o-G_);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=So(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,p(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,U_),n),globalContentWidth:Math.max(t,W_)}},[a,o,s,r]),u=i.success?i.data.metadata?.source:void 0,[d,f]=(0,Q.useState)({}),g=(0,Q.useRef)(0);function _(e,t,n,r,i,a){let o=g.current++,s={id:o,type:`image`,content:t,mediaType:n||`image/png`,filename:r||`Pasted image`,dimensions:i};Br(s),Dl(s),f(t=>({...t,[e]:{...t[e]??{},[o]:s}}))}let v=(0,Q.useCallback)((e,t)=>{f(n=>{let r={...n[e]??{}};return delete r[t],{...n,[e]:r}})},[]),y=Object.values(d).flatMap(e=>Object.values(e)).filter(e=>e.type===`image`),b=G(e=>e.toolPermissionContext.mode)===`plan`,x=b?Na():void 0,{currentQuestionIndex:S,answers:C,questionStates:w,isInTextInput:T,nextQuestion:E,prevQuestion:D,updateQuestionState:O,setAnswer:k,setTextInputMode:A}=H_(),j=S<(a?.length||0)?a?.[S]:null,M=S===(a?.length||0),N=a?.every(e=>e?.question&&!!C[e.question])??!1,P=a.length===1&&!a[0]?.multiSelect,F=(0,Q.useCallback)(()=>{u&&(a.length,b&&gl()),t(),n(),e.onReject()},[t,n,e,u,a.length,b]),ee=(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=C[e.question];return t?`- "${e.question}"\n Answer: ${t}`:`- "${e.question}"\n (No answer provided)`}).join(`
9
+ `)}`;u&&(a.length,b&&gl());let r=await Y_(y);t(),e.onReject(n,r&&r.length>0?r:void 0)},[a,C,t,e,u,b,y]),I=(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=C[e.question];return t?`- "${e.question}"\n Answer: ${t}`:`- "${e.question}"\n (No answer provided)`}).join(`
13
+ `)}`;u&&(a.length,b&&gl());let r=await Y_(y);t(),e.onReject(n,r&&r.length>0?r:void 0)},[a,C,t,e,u,b,y]),L=(0,Q.useCallback)(async n=>{u&&(a.length,Object.keys(n).length,b&&gl());let r={};for(let e of a){let t=n[e.question],i=w[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 Y_(y);t(),e.onAllow(i,[],void 0,o&&o.length>0?o:void 0)},[e,t,u,a,w,b,y]),te=(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={...C,[e]:i};L(t).catch(Hu);return}k(e,i,r)},[k,a.length,C,L,d]);function R(e){if(e===`cancel`){F();return}e===`submit`&&L(C).catch(Hu)}let ne=P?(a?.length||1)-1:a?.length||0,z=(0,Q.useCallback)(()=>{S>0&&D()},[S,D]),re=(0,Q.useCallback)(()=>{S<ne&&E()},[S,ne,E]);return m({"tabs:previous":z,"tabs:next":re},{context:`Tabs`,isActive:!(T&&!M)}),j?(0,$.jsx)(I_,{question:j,questions:a,currentQuestionIndex:S,answers:C,questionStates:w,hideSubmitTab:P,minContentHeight:c,minContentWidth:l,planFilePath:x,onUpdateQuestionState:O,onAnswer:te,onTextInputFocus:A,onCancel:F,onSubmit:E,onTabPrev:z,onTabNext:re,onRespondToClaude:ee,onFinishPlanInterview:I,onImagePaste:(e,t,n,r,i)=>_(j.question,e,t,n,r,i),pastedContents:d[j.question]??{},onRemoveImage:e=>v(j.question,e)}):M?(0,$.jsx)(z_,{questions:a,currentQuestionIndex:S,answers:C,allQuestionsAnswered:N,permissionResult:e.permissionResult,minContentHeight:c,onFinalResponse:R}):null}async function Y_(e){if(e.length!==0)return Promise.all(e.map(async e=>(await Li({type:`image`,source:{type:`base64`,media_type:e.mediaType||`image/png`,data:e.content}})).block))}var X_=[`http://`,`https://`,`ftp://`],Z_={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},Q_=e=>Array.isArray(e)?e:[e];function $_(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 ev(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(`-`)?!$_(t,n):!1}function tv(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(r){if(r.startsWith(`-`)){ev(r,e[n+1],t)&&n++;continue}if(!t?.subcommands?.length||$_(r,t))return r}}}async function nv(e,t,n){let r=await rv(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&&Q_(e.args).some(e=>e?.isCommand||e?.isModule)){i.push(c);continue}}if(a&&!o){ev(c,t[s+1],n)&&s++;continue}break}if(await iv(c,t.slice(0,s),n))break;a&&!o&&(o=$_(c,n)),i.push(c)}return i.join(` `)}async function rv(e,t,n){let r=tv(t,n),i=e.toLowerCase(),a=r?`${i} ${r.toLowerCase()}`:i;if(Z_[a])return Z_[a];if(Z_[i])return Z_[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&&Q_(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=Q_(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=Q_(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&&Q_(n.args).some(e=>e?.isDangerous)?3:2}async function iv(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=X_.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&&Q_(e.args).some(e=>e?.isModule))return!1}return!0}var av=[{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 ov(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 sv=ye(async e=>av.find(t=>t.name===e)||await ov(e)||null,e=>e),cv=/^\d+$/,lv=/^[A-Za-z_][A-Za-z0-9_]*=/,uv=new Set([`nice`]),dv=e=>Array.isArray(e)?e:[e];function fv(e,t){return t?.subcommands?.length?t.subcommands.some(t=>Array.isArray(t.name)?t.name.includes(e):t.name===e):!1}async function pv(e,t=0,n=0){if(n>2||t>10)return null;let r=await Yd(e);if(!r)return null;if(!r.commandNode)return{commandPrefix:null};let{envVars:i,commandNode:a}=r,[o,...s]=Xd(a);if(!o)return{commandPrefix:null};let c=await sv(o),l=uv.has(o)||c?.args&&dv(c.args).some(e=>e?.isCommand);l&&s[0]&&fv(s[0],c)&&(l=!1);let u=l?await mv(o,s,t,n):await nv(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 mv(e,t,n,r){let i=await sv(e);if(i?.args){let a=dv(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 pv(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(`-`)&&!lv.test(t[e])&&i.push(t[e])}}let a=t.find(e=>!e.startsWith(`-`)&&!cv.test(e)&&!lv.test(e));if(!a)return e;let o=await pv(t.slice(t.indexOf(a)).join(` `),n+1,r+1);return o?.commandPrefix?`${e} ${o.commandPrefix}`:null}async function hv(e,t){let n=Nn(e);if(n.length<=1){let t=await pv(e);return t?.commandPrefix?[t.commandPrefix]:[]}let r=[];for(let e of n){let n=e.trim();if(t?.(n))continue;let i=await pv(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(gv(e));return a}function gv(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(` `)}Zu();async function _v(e){e.event,e.completion_type,await e.metadata.language_name,e.metadata.message_id,e.metadata.platform,{...e.metadata.hasFeedback!==void 0&&{hasFeedback:e.metadata.hasFeedback}}}Zu(),Y(),ou();function vv(e,t){let n=vn(),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}})),e.assistantMessage.message.id,Gd(e.tool.name),e.tool.isMcp,e.permissionResult.decisionReason?.type,Ea.isSandboxingEnabled(),_v({completion_type:t.completion_type,event:`response`,metadata:{language_name:t.language_name,message_id:e.assistantMessage.message.id,platform:pu.platform}}))},[e,t,n])}R(),c(),V(),Y(),su(),gm(),vc();function yv(e){switch(e.type){case`rule`:return`${I.bold(Zl(e.rule.ruleValue))} rule from ${gu(e.rule.source)}`;case`mode`:return`${iu(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`${I.bold(e.permissionPromptToolName)} permission prompt tool`;case`hook`:return e.reason?`${I.bold(e.hookName)} hook: ${e.reason}`:`${I.bold(e.hookName)} hook`;case`asyncAgent`:return e.reason;default:return``}}function bv({title:e,decisionReason:t}){let[n]=h();function r(){switch(t.type){case`subcommandResults`:return(0,$.jsx)(g,{flexDirection:`column`,children:Array.from(t.reasons.entries()).map(([e,t])=>(0,$.jsxs)(g,{flexDirection:`column`,children:[(0,$.jsxs)(b,{children:[t.behavior===`allow`?re(`success`,n)(l.tick):re(`error`,n)(l.cross),` `,e]}),t.decisionReason!==void 0&&t.decisionReason.type!==`subcommandResults`&&(0,$.jsxs)(b,{children:[(0,$.jsxs)(b,{dimColor:!0,children:[` `,`⎿`,` `]}),(0,$.jsx)(f,{children:yv(t.decisionReason)})]}),t.behavior===`ask`&&(0,$.jsx)(xv,{suggestions:t.suggestions})]},e))});default:return(0,$.jsx)(b,{children:(0,$.jsx)(f,{children:yv(t)})})}}return(0,$.jsxs)(g,{flexDirection:`column`,children:[e&&(0,$.jsx)(b,{children:e}),r()]})}function xv({suggestions:e}){let t=ns(e);return t.length===0?null:(0,$.jsxs)(b,{children:[(0,$.jsxs)(b,{dimColor:!0,children:[` `,`⎿`,` `]}),`Suggested rules: `,(0,$.jsx)(f,{children:t.map(e=>I.bold(Zl(e))).join(`, `)})]})}function Sv(e){return e?e.flatMap(e=>{switch(e.type){case`addDirectories`:return e.directories;default:return[]}}):[]}function Cv(e){if(!e)return;let t=e.findLast(e=>e.type===`setMode`);return t?.type===`setMode`?t.mode:void 0}function wv({suggestions:e,width:t}){if(!e||e.length===0)return(0,$.jsxs)(g,{flexDirection:`row`,children:[(0,$.jsx)(g,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(b,{dimColor:!0,children:`Suggestions `})}),(0,$.jsx)(b,{children:`None`})]});let n=ns(e),r=Sv(e),i=Cv(e);return n.length===0&&r.length===0&&!i?(0,$.jsxs)(g,{flexDirection:`row`,children:[(0,$.jsx)(g,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(b,{dimColor:!0,children:`Suggestion `})}),(0,$.jsx)(b,{children:`None`})]}):(0,$.jsxs)(g,{flexDirection:`column`,children:[(0,$.jsxs)(g,{flexDirection:`row`,children:[(0,$.jsx)(g,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(b,{dimColor:!0,children:`Suggestions `})}),(0,$.jsx)(b,{children:` `})]}),n.length>0&&(0,$.jsxs)(g,{flexDirection:`row`,children:[(0,$.jsx)(g,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(b,{dimColor:!0,children:` Rules `})}),(0,$.jsx)(g,{flexDirection:`column`,children:n.map((e,t)=>(0,$.jsxs)(b,{children:[l.bullet,` `,Zl(e)]},t))})]}),r.length>0&&(0,$.jsxs)(g,{flexDirection:`row`,children:[(0,$.jsx)(g,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(b,{dimColor:!0,children:` Directories `})}),(0,$.jsx)(g,{flexDirection:`column`,children:r.map((e,t)=>(0,$.jsxs)(b,{children:[l.bullet,` `,e]},t))})]}),i&&(0,$.jsxs)(g,{flexDirection:`row`,children:[(0,$.jsx)(g,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(b,{dimColor:!0,children:` Mode `})}),(0,$.jsx)(b,{children:iu(i)})]})]})}function Tv({permissionResult:e,toolName:t}){let n=G(e=>e.toolPermissionContext),r=e.decisionReason,i=`suggestions`in e?e.suggestions:void 0,a=(0,Q.useMemo)(()=>{let e=Ea.isSandboxingEnabled()&&Ea.isAutoAllowBashIfSandboxedEnabled(),r=_m(n,{sandboxAutoAllowEnabled:e}),a=ns(i);return a.length>0?r.filter(e=>a.some(t=>t.toolName===e.rule.ruleValue.toolName&&t.ruleContent===e.rule.ruleValue.ruleContent)):t?r.filter(e=>e.rule.ruleValue.toolName===t):r},[n,t,i]);return(0,$.jsxs)(g,{flexDirection:`column`,children:[(0,$.jsxs)(g,{flexDirection:`row`,children:[(0,$.jsx)(g,{justifyContent:`flex-end`,minWidth:10,children:(0,$.jsx)(b,{dimColor:!0,children:`Behavior `})}),(0,$.jsx)(b,{children:e.behavior})]}),e.behavior!==`allow`&&(0,$.jsxs)(g,{flexDirection:`row`,children:[(0,$.jsx)(g,{justifyContent:`flex-end`,minWidth:10,children:(0,$.jsx)(b,{dimColor:!0,children:`Message `})}),(0,$.jsx)(b,{children:e.message})]}),(0,$.jsxs)(g,{flexDirection:`row`,children:[(0,$.jsx)(g,{justifyContent:`flex-end`,minWidth:10,children:(0,$.jsx)(b,{dimColor:!0,children:`Reason `})}),r===void 0?(0,$.jsx)(b,{children:`undefined`}):(0,$.jsx)(bv,{decisionReason:r})]}),(0,$.jsx)(wv,{suggestions:i,width:10}),a.length>0&&(0,$.jsxs)(g,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(b,{color:`warning`,children:[l.warning,` Unreachable Rules (`,a.length,`)`]}),a.map((e,t)=>(0,$.jsxs)(g,{flexDirection:`column`,marginLeft:2,children:[(0,$.jsx)(b,{color:`warning`,children:Zl(e.rule.ruleValue)}),(0,$.jsxs)(b,{dimColor:!0,children:[` `,e.reason]}),(0,$.jsxs)(b,{dimColor:!0,children:[` `,`Fix: `,e.fix]})]},t))]})]})}Tm(),Zu(),Kd(),Au(),Gl(),Bu(),$d(),Hc();var Ev={LOW:1,MEDIUM:2,HIGH:3},Dv=`Analyze shell commands and explain what they do, why you're running them, and potential risks.`,Ov={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`]}},kv=we(()=>he({riskLevel:xe([`LOW`,`MEDIUM`,`HIGH`]),explanation:ge(),reasoning:ge(),risk:ge()}));function Av(e){if(typeof e==`string`)return e;try{return Nl(e,null,2)}catch{return String(e)}}function jv(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 Mv(){return Mu().permissionExplainerEnabled!==!1}async function Nv({toolName:e,toolInput:t,toolDescription:n,messages:r,signal:i}){if(!Mv())return null;let a=Date.now();try{let o=Av(t),s=r?.length?jv(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 dl({model:Qd()?Td():wd(),system:Dv,messages:[{role:`user`,content:c}],tools:[Ov],tool_choice:{type:`tool`,name:`explain_command`},signal:i,querySource:`permission_explainer`}),u=Date.now()-a;X(`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`){X(`Permission explainer: tool input: ${Nl(d.input).slice(0,500)}`);let t=kv().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 Gd(e),Ev[n.riskLevel],X(`Permission explainer: ${n.riskLevel} risk for ${e} (${u}ms)`),n}}return Gd(e),X(`Permission explainer: no parsed output in response`),null}catch(t){return Date.now()-a,i.aborted?(X(`Permission explainer: request aborted for ${e}`),null):(X(`Permission explainer error: ${Ll(t)}`),Hu(t),Gd(e),t instanceof Error&&t.name,null)}}V(),Oc(),Zu(),hf(),cp();var Pv=`Loading explanation…`;function Fv(){let[e,t]=ip(`responding`,Pv,!1);return(0,$.jsx)(g,{ref:e,children:(0,$.jsx)(b,{children:Pv.split(``).map((e,n)=>(0,$.jsx)(sf,{char:e,index:n,glimmerIndex:t,messageColor:`inactive`,shimmerColor:`text`},n))})})}function Iv(e){switch(e){case`LOW`:return`success`;case`MEDIUM`:return`warning`;case`HIGH`:return`error`}}function Lv(e){switch(e){case`LOW`:return`Low risk`;case`MEDIUM`:return`Med risk`;case`HIGH`:return`High risk`}}function Rv(e){return Nv({toolName:e.toolName,toolInput:e.toolInput,toolDescription:e.toolDescription,messages:e.messages,signal:new AbortController().signal}).catch(()=>null)}function zv(e){let t=Mv(),[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(null);return E(`confirm:toggleExplanation`,()=>{n||i||a(Rv(e)),r(e=>!e)},{context:`Confirmation`,isActive:t}),{visible:n,enabled:t,promise:i}}function Bv({promise:e}){let t=(0,Q.use)(e);return t?(0,$.jsxs)(g,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(b,{children:t.explanation}),(0,$.jsx)(g,{marginTop:1,children:(0,$.jsx)(b,{children:t.reasoning})}),(0,$.jsx)(g,{marginTop:1,children:(0,$.jsxs)(b,{children:[(0,$.jsxs)(b,{color:Iv(t.riskLevel),children:[Lv(t.riskLevel),`:`]}),(0,$.jsxs)(b,{children:[` `,t.risk]})]})})]}):(0,$.jsx)(g,{marginTop:1,children:(0,$.jsx)(b,{dimColor:!0,children:`Explanation unavailable`})})}function Vv({visible:e,promise:t}){return!e||!t?null:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(g,{marginTop:1,children:(0,$.jsx)(Fv,{})}),children:(0,$.jsx)(Bv,{promise:t})})}yc(),V(),Bu(),Vo(),Ra();function Hv(e){let[t]=(0,Q.useState)(()=>Gv(e.file_path,e.edits));return(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(Wv,{placeholder:!0}),children:(0,$.jsx)(Uv,{promise:t,file_path:e.file_path})})}function Uv({promise:e,file_path:t}){let{patch:n,firstLine:r,fileContent:i}=(0,Q.use)(e),{columns:a}=ae();return(0,$.jsx)(Wv,{children:(0,$.jsx)(hl,{hunks:n,dim:!1,width:a,filePath:t,firstLine:r,fileContent:i})})}function Wv({children:e,placeholder:t}){return(0,$.jsx)(g,{flexDirection:`column`,children:(0,$.jsx)(g,{borderColor:`subtle`,borderStyle:`dashed`,flexDirection:`column`,borderLeft:!1,borderRight:!1,children:t?(0,$.jsx)(b,{dimColor:!0,children:`…`}):e})})}async function Gv(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 Kv(e,[r]);try{let t=await jo(e);if(t===null)return Kv(e,n);try{if(!r||r.old_string===``){let r=await _a(t);return r===null?Kv(e,n):{patch:Pa({filePath:e,fileContents:r,edits:n.map(e=>qv(r,e))}),firstLine:cd(r),fileContent:r}}let i=await Kc(t,r.old_string,3);if(i.truncated||i.content===``)return Kv(e,[r]);let a=qv(i.content,r);return{patch:Qo(Pa({filePath:e,fileContents:i.content,edits:[a]}),i.lineOffset-1),firstLine:i.lineOffset===1?cd(i.content):null,fileContent:i.content}}finally{await t.close()}}catch(t){return Hu(t),Kv(e,n)}}function Kv(e,t){return{patch:t.flatMap(t=>Pa({filePath:e,fileContents:t.old_string,edits:[t]})),firstLine:null,fileContent:void 0}}function qv(e,t){let n=Bs(e,t.old_string)||t.old_string;return{...t,old_string:n}}ai(),Ne(),V();function Jv(e){let t=fu(e),n=fu(`${Ze()}/.workmate`),r=br(t),i=br(n);return r.startsWith(i+ph.toLowerCase())||r.startsWith(`${i}/`)}function Yv(e){let t=fu(e),n=dh(oh(),`.workmate`),r=br(t),i=br(n);return r.startsWith(i+ph.toLowerCase())||r.startsWith(`${i}/`)}function Xv({filePath:e,toolPermissionContext:t,operationType:n=`write`,onRejectFeedbackChange:r,onAcceptFeedbackChange:i,yesInputMode:a=!1,noInputMode:o=!1}){let s=[],c=Da(`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=Rr(e,t),u=Jv(e),d=Yv(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)(b,{children:[`Yes, allow all edits during this session `,(0,$.jsxs)(b,{bold:!0,children:[`(`,c,`)`]})]});else{let r=ch(Jl(e))||`this directory`;t=n===`read`?(0,$.jsxs)(b,{children:[`Yes, allow reading from `,(0,$.jsxs)(b,{bold:!0,children:[r,`/`]}),` during this session`]}):(0,$.jsxs)(b,{children:[`Yes, allow all edits in `,(0,$.jsxs)(b,{bold:!0,children:[r,`/`]}),` during this session`,` `,(0,$.jsxs)(b,{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}Zu(),Kd(),ou(),os();function Zv(e,t,n,r,i){_v({completion_type:t,event:e,metadata:{language_name:n,message_id:r,platform:pu.platform,hasFeedback:i??!1}})}function Qv(e,t){let{messageId:n,toolUseConfirm:r,onDone:i,completionType:a,languageName:o}=e;Zv(`accept`,a,o,n),Gd(r.tool.name),r.tool.isMcp,t?.feedback,t?.feedback?.length,t?.enteredFeedbackMode,i(),r.onAllow(r.input,[],t?.feedback)}function $v(e,t){let{messageId:n,path:r,toolUseConfirm:i,toolPermissionContext:a,onDone:o,completionType:s,languageName:c,operationType:l}=e;if(Zv(`accept`,s,c,n),t?.scope===`claude-folder`||t?.scope===`global-claude-folder`){let e=[{type:`addRules`,rules:[{toolName:Pd,ruleContent:t.scope===`global-claude-folder`?Od:Ad}],behavior:`allow`,destination:`session`}];o(),i.onAllow(i.input,e);return}let u=r?kr(r,l,a):[];o(),i.onAllow(i.input,u)}function ey(e,t){let{messageId:n,toolUseConfirm:r,onDone:i,onReject:a,completionType:o,languageName:s}=e;Zv(`reject`,o,s,n,t?.hasFeedback),Gd(r.tool.name),r.tool.isMcp,t?.feedback,t?.feedback?.length,t?.enteredFeedbackMode,i(),a(),r.onReject(t?.feedback)}var ty={"accept-once":Qv,"accept-session":$v,reject:ey};Y(),Oc(),Zu(),Kd();function ny({filePath:e,completionType:t,languageName:n,toolUseConfirm:r,onDone:i,onReject:a,parseInput:o,operationType:s=`write`}){let c=G(e=>e.toolPermissionContext),[l,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)(``),[p,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)(()=>Xv({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=ty[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 m({"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:p,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=>{Gd(r.tool.name),r.tool.isMcp,e===`yes`?g?_(!1):(_(!0),x(!0)):e===`no`&&(v?y(!1):(y(!0),C(!0)))},[g,v,r]),yesInputMode:g,noInputMode:v}}V(),xt(),bu(),am();function ry({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`,languageName:f}){let p=(0,Q.useMemo)(()=>f??(l?ds(l):`none`),[f,l]);vv(e,(0,Q.useMemo)(()=>({completion_type:c,language_name:p}),[c,p]));let m=(0,Q.useMemo)(()=>{if(!l||d===`read`)return null;let e=fu(l),{resolvedPath:t,isSymlink:n}=Wl(Kl(),e);return n?t:null},[l,d]),h=ny({filePath:l||``,completionType:c,languageName:p,toolUseConfirm:e,onDone:n,onReject:r,parseInput:u,operationType:d}),{options:_,acceptFeedback:v,rejectFeedback:y,setFocusedOption:x,handleInputModeToggle:S,focusedOption:C,yesInputMode:w,noInputMode:T}=h,E=u(e.input),D=(e,t)=>{h.onChange(e,E,t?.trim())},O=m!=null&&fh(jl(),m).startsWith(`..`);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Dm,{title:i,subtitle:a,innerPaddingX:0,children:[m?(0,$.jsx)(g,{paddingX:1,marginBottom:1,children:(0,$.jsx)(b,{color:`warning`,children:O?`This will modify ${m} (outside working directory) via a symlink`:`Symlink target: ${m}`})}):null,s,(0,$.jsxs)(g,{flexDirection:`column`,paddingX:1,children:[typeof o==`string`?(0,$.jsx)(b,{children:o}):o,(0,$.jsx)(rp,{options:_,inlineDescriptions:!0,onChange:e=>{let t=_.find(t=>t.value===e);if(t){if(t.option.type===`reject`){let e=y.trim();D(t.option,e||void 0);return}if(t.option.type===`accept-once`){let e=v.trim();D(t.option,e||void 0);return}D(t.option)}},onCancel:()=>D({type:`reject`}),onFocus:e=>x(e),onInputModeToggle:S})]})]}),(0,$.jsx)(g,{paddingX:1,marginTop:1,children:(0,$.jsxs)(b,{dimColor:!0,children:[`Esc to reject`,(C===`yes`&&!w||C===`no`&&!T)&&` · Tab to add feedback`]})})]})}Al(),Il(),Ul(),V();function iy({sedInfo:e,...t}){let{filePath:n}=e;return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(ay,{sedInfo:e,contentPromise:(0,Q.useMemo)(()=>(async()=>{let e=tu(n);return{oldContent:(await Kl().readFile(n,{encoding:e})).replaceAll(`\r
22
+ `,`
23
+ `),fileExists:!0}})().catch(e=>{if(!Rl(e))throw e;return{oldContent:``,fileExists:!1}}),[n]),...t})})}function ay({sedInfo:e,contentPromise:t,...n}){let{filePath:r}=e,{oldContent:i,fileExists:a}=(0,Q.use)(t),o=(0,Q.useMemo)(()=>si(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)(ry,{toolUseConfirm:n.toolUseConfirm,toolUseContext:n.toolUseContext,onDone:n.onDone,onReject:n.onReject,title:`Edit file`,subtitle:fh(jl(),r),question:(0,$.jsxs)(b,{children:[`Do you want to make this edit to `,(0,$.jsx)(b,{bold:!0,children:ch(r)}),`?`]}),content:s.length>0?(0,$.jsx)(Hv,{file_path:r,edits:s}):(0,$.jsx)(b,{dimColor:!0,children:c}),path:r,completionType:`str_replace_single`,parseInput:e=>({...Po.inputSchema.parse(e),_simulatedSedEdit:{filePath:r,newContent:o}})})}ou();function oy(e,{assistantMessage:{message:{id:t}}},n,r){_v({completion_type:e,event:n,metadata:{language_name:`none`,message_id:t,platform:hu(),hasFeedback:r??!1}})}Zu(),Kd(),Y();function sy({toolUseConfirm:e,onDone:t,onReject:n,explainerVisible:r}){let i=vn(),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(`yes`),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(!1);function y(t){e.onUserInteraction(),Gd(e.tool.name),e.tool.isMcp,t===`yes`?l?u(!1):(u(!0),g(!0)):t===`no`&&(d?f(!1):(f(!0),v(!0)))}function b(r){let a=r?.trim(),o=!!a;o||i(e=>({...e,attribution:{...e.attribution,escapeCount:e.attribution.escapeCount+1}})),oy(`tool_use_single`,e,`reject`,o),a?e.onReject(a):e.onReject(),n(),t()}function x(t){t!==p&&e.onUserInteraction(),t!==`yes`&&l&&!s.trim()&&u(!1),t!==`no`&&d&&!a.trim()&&f(!1),m(t)}return{yesInputMode:l,noInputMode:d,yesFeedbackModeEntered:h,noFeedbackModeEntered:_,acceptFeedback:s,rejectFeedback:a,setAcceptFeedback:c,setRejectFeedback:o,focusedOption:p,handleInputModeToggle:y,handleReject:b,handleFocus:x}}Ne(),V();function cy(e){switch(e.length){case 0:return``;case 1:return(0,$.jsx)(b,{bold:!0,children:e[0]});case 2:return(0,$.jsxs)(b,{children:[(0,$.jsx)(b,{bold:!0,children:e[0]}),` and `,(0,$.jsx)(b,{bold:!0,children:e[1]})]});default:return(0,$.jsxs)(b,{children:[(0,$.jsx)(b,{bold:!0,children:e.slice(0,-1).join(`, `)}),`, and `,(0,$.jsx)(b,{bold:!0,children:e.slice(-1)[0]})]})}}function ly(e){return e.join(`, `).length>50?`similar`:cy(e)}function uy(e){if(e.length===0)return``;let t=e.map(e=>ch(e)||e);return t.length===1?(0,$.jsxs)(b,{children:[(0,$.jsx)(b,{bold:!0,children:t[0]}),ph]}):t.length===2?(0,$.jsxs)(b,{children:[(0,$.jsx)(b,{bold:!0,children:t[0]}),ph,` and `,(0,$.jsx)(b,{bold:!0,children:t[1]}),ph]}):(0,$.jsxs)(b,{children:[(0,$.jsx)(b,{bold:!0,children:t[0]}),ph,`, `,(0,$.jsx)(b,{bold:!0,children:t[1]}),ph,` and `,e.length-2,` more`]})}function dy(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=Ic(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)(b,{children:[`Yes, allow reading from `,(0,$.jsx)(b,{bold:!0,children:ch(e)||e}),ph,` from this project`]})}return(0,$.jsxs)(b,{children:[`Yes, allow reading from `,uy(s),` from this project`]})}if(l&&!u&&!d){if(o.length===1){let e=o[0];return(0,$.jsxs)(b,{children:[`Yes, and always allow access to `,(0,$.jsx)(b,{bold:!0,children:ch(e)||e}),ph,` from this project`]})}return(0,$.jsxs)(b,{children:[`Yes, and always allow access to `,uy(o),` from this project`]})}if(d&&!l&&!u)return(0,$.jsxs)(b,{children:[`Yes, and don't ask again for `,ly(c),` commands in `,(0,$.jsx)(b,{bold:!0,children:Ze()})]});if((l||u)&&!d){let e=[...o,...s];if(l&&u)return(0,$.jsxs)(b,{children:[`Yes, and always allow access to `,uy(e),` from this project`]})}if((l||u)&&d){let e=[...o,...s];return e.length===1&&c.length===1?(0,$.jsxs)(b,{children:[`Yes, and allow access to `,uy(e),` and `,ly(c),` commands`]}):(0,$.jsxs)(b,{children:[`Yes, and allow `,uy(e),` access and `,ly(c),` commands`]})}return null}oc();function fy(e){let{commandWithoutRedirections:t,redirections:n}=Vn(e);return n.length>0?t:e}function py({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`}),Qr()){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=dy(e,Md,fy);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}V(),Oc(),Zu(),Kd(),Y(),ya(),zt(),ar(),vc(),Tm();function my(e){let{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,verbose:a}=e,{command:o,description:s}=Po.inputSchema.parse(t.input),c=nl(o);return c?(0,$.jsx)(iy,{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,verbose:a,sedInfo:c}):(0,$.jsx)(hy,{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,verbose:a,command:o,description:s})}function hy({toolUseConfirm:e,toolUseContext:t,onDone:n,onReject:r,verbose:i,command:a,description:o}){let[s]=h(),c=G(e=>e.toolPermissionContext),l=zv({toolName:e.tool.name,toolInput:e.input,toolDescription:e.description,messages:t.messages}),{yesInputMode:u,noInputMode:d,yesFeedbackModeEntered:f,noFeedbackModeEntered:p,acceptFeedback:m,rejectFeedback:_,setAcceptFeedback:v,setRejectFeedback:y,focusedOption:x,handleInputModeToggle:S,handleReject:C,handleFocus:w}=sy({toolUseConfirm:e,onDone:n,onReject:r,explainerVisible:l.visible}),[T,D]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(o||``),[A,j]=(0,Q.useState)(!o?.trim());(0,Q.useEffect)(()=>{if(!Ri())return;let e=new AbortController;return Di(a,o,e.signal).then(t=>{t&&!e.signal.aborted&&(k(t),j(!1))}).catch(()=>{}),()=>e.abort()},[a,o]);let M=e.permissionResult.decisionReason?.type===`subcommandResults`,[N,P]=(0,Q.useState)(()=>{if(M){let t=ns(`suggestions`in e.permissionResult?e.permissionResult.suggestions:void 0).filter(e=>e.toolName===Po.name&&e.ruleContent);return t.length===1?t[0].ruleContent:void 0}let t=As(a);if(t)return`${t}:*`;let n=tc(a);return n?`${n}:*`:a}),F=(0,Q.useRef)(!1),ee=(0,Q.useCallback)(e=>{F.current=!0,P(e)},[]);(0,Q.useEffect)(()=>{if(M)return;let e=!1;return hv(a,e=>Po.isReadOnly({command:e})).then(t=>{e||F.current||t.length>0&&P(`${t[0]}:*`)}).catch(()=>{}),()=>{e=!0}},[a,M]);let{destructiveWarning:I,sandboxingEnabled:L,isSandboxed:te}=(0,Q.useMemo)(()=>{let t=Ea.isSandboxingEnabled();return{destructiveWarning:null,sandboxingEnabled:t,isSandboxed:t&&Pi(e.input)}},[a,e.input]);vv(e,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let R=(0,Q.useMemo)(()=>_n(c),[c]),ne=(0,Q.useMemo)(()=>py({suggestions:e.permissionResult.behavior===`ask`?e.permissionResult.suggestions:void 0,decisionReason:e.permissionResult.decisionReason,onRejectFeedbackChange:y,onAcceptFeedbackChange:v,onClassifierDescriptionChange:k,classifierDescription:O,initialClassifierDescriptionEmpty:A,existingAllowDescriptions:R,yesInputMode:u,noInputMode:d,editablePrefix:N,onEditablePrefixChange:ee}),[e,O,A,R,u,d,N,ee]);E(`permission:toggleDebug`,(0,Q.useCallback)(()=>{D(e=>!e)},[]),{context:`Confirmation`}),E(`confirm:no`,(0,Q.useCallback)(()=>{e.onDismissCheckmark?.()},[e]),{context:`Confirmation`,isActive:!1});function z(t){if({yes:1,"yes-apply-suggestions":2,"yes-prefix-edited":2,no:3}[t],l.visible,Gd(e.tool.name),t===`yes-prefix-edited`){let t=(N??``).trim();if(oy(`tool_use_single`,e,`accept`),!t)e.onAllow(e.input,[]);else{let n=[{type:`addRules`,rules:[{toolName:Po.name,ruleContent:t}],behavior:`allow`,destination:`localSettings`}];e.onAllow(e.input,n)}n();return}switch(t){case`yes`:{let t=m.trim();oy(`tool_use_single`,e,`accept`),e.tool.isMcp,t.length,e.onAllow(e.input,[],t||void 0),n();break}case`yes-apply-suggestions`:{oy(`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=_.trim();e.tool.isMcp,t.length,C(t||void 0);break}}}return(0,$.jsxs)(Dm,{title:L&&!te?`Bash command (unsandboxed)`:`Bash command`,children:[(0,$.jsxs)(g,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(b,{dimColor:l.visible,children:Po.renderToolUseMessage({command:a,description:o},{theme:s,verbose:!0})}),!l.visible&&(0,$.jsx)(b,{dimColor:!0,children:e.description}),(0,$.jsx)(Vv,{visible:l.visible,promise:l.promise})]}),T?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Tv,{permissionResult:e.permissionResult,toolName:`Bash`}),t.options.debug&&(0,$.jsx)(g,{justifyContent:`flex-end`,marginTop:1,children:(0,$.jsx)(b,{dimColor:!0,children:`Ctrl-D to hide debug info`})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(g,{flexDirection:`column`,children:[(0,$.jsx)(R_,{permissionResult:e.permissionResult,toolType:`command`}),I&&(0,$.jsx)(g,{marginBottom:1,children:(0,$.jsx)(b,{color:`warning`,dimColor:!1,children:I})}),(0,$.jsx)(b,{dimColor:!1,children:`Do you want to proceed?`}),(0,$.jsx)(rp,{options:ne,isDisabled:!1,inlineDescriptions:!0,onChange:z,onCancel:()=>C(),onFocus:w,onInputModeToggle:S})]}),(0,$.jsxs)(g,{justifyContent:`space-between`,marginTop:1,children:[(0,$.jsxs)(b,{dimColor:!0,children:[`Esc to reject`,(x===`yes`&&!u||x===`no`&&!d)&&` · Tab to add feedback`,l.enabled&&` · ctrl+e to ${l.visible?`hide`:`explain`}`]}),t.options.debug&&(0,$.jsx)(b,{dimColor:!0,children:`Ctrl+d to show debug info`})]})]})]})}Ne(),V(),Zu(),Y(),qc(),am(),Tm();function gy({toolUseConfirm:e,onDone:t,onReject:n}){let r=G(e=>e.toolPermissionContext.mode);function i(i){i===`yes`?(gl(),Xe(r,`plan`),t(),e.onAllow({},[{type:`setMode`,mode:`plan`,destination:`session`}])):(t(),n(),e.onReject())}return(0,$.jsx)(Dm,{color:`planMode`,title:`Enter plan mode?`,children:(0,$.jsxs)(g,{flexDirection:`column`,marginTop:1,paddingX:1,children:[(0,$.jsx)(b,{children:`Work Mate wants to enter plan mode to explore and design an implementation approach.`}),(0,$.jsxs)(g,{marginTop:1,flexDirection:`column`,children:[(0,$.jsx)(b,{dimColor:!0,children:`In plan mode, Work Mate will:`}),(0,$.jsx)(b,{dimColor:!0,children:` · Explore the codebase thoroughly`}),(0,$.jsx)(b,{dimColor:!0,children:` · Identify existing patterns`}),(0,$.jsx)(b,{dimColor:!0,children:` · Design an implementation strategy`}),(0,$.jsx)(b,{dimColor:!0,children:` · Present a plan for your approval`})]}),(0,$.jsx)(g,{marginTop:1,children:(0,$.jsx)(b,{dimColor:!0,children:`No code changes will be made until you approve the plan.`})}),(0,$.jsx)(g,{marginTop:1,children:(0,$.jsx)(rp,{options:[{label:`Yes, enter plan mode`,value:`yes`},{label:`No, start implementing now`,value:`no`}],onChange:i,onCancel:()=>i(`no`)})})]})})}c(),Zu(),Y(),Ne(),Fm(),V(),zp(),Bu(),yd(),Si(),Xl(),qc(),Xa(),Up(),Fo(),am(),Tm(),xi(),ti();function _y(e,t){let n=[{type:`setMode`,mode:lu(e),destination:`session`}];return Ri()&&t&&t.length>0&&n.push({type:`addRules`,rules:t.map(e=>({toolName:e.tool,ruleContent:Ot(e.prompt)})),behavior:`allow`,destination:`session`}),n}function vy(e,t,n){Ee()||yu()?.cleanupPeriodDays===0||!n&&mo(We())||Im([ht({content:e.slice(0,1e3)})],new AbortController().signal).then(async e=>{if(!e||mo(We()))return;let n=We(),r=To();await uo(n,e,r,`auto`),await da(n,e,r,`auto`),t(t=>t.standaloneAgentContext?.name===e?t:{...t,standaloneAgentContext:{...t.standaloneAgentContext,name:e}})}).catch(Hu)}function yy({toolUseConfirm:e,onDone:t,onReject:n,setStickyFooter:r}){let i=G(e=>e.toolPermissionContext),a=vn();Oi();let{addNotification:o}=Sf(),[s,c]=(0,Q.useState)(``),[u,d]=(0,Q.useState)({}),f=(0,Q.useRef)(0),p=G(e=>e.settings.showClearContextOnPlanAccept)??!1,m=e.assistantMessage.message.usage,{mode:h,isAutoModeAvailable:_,isBypassPermissionsModeAvailable:v}=i,y=(0,Q.useMemo)(()=>by({showClearContext:p,usedPercent:p?xy(m,h):null,isAutoModeAvailable:_,isBypassPermissionsModeAvailable:v,onFeedbackChange:c}),[p,m,h,_,v]);function x(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};Br(o),Dl(o),d(e=>({...e,[a]:o}))}let S=(0,Q.useCallback)(e=>{d(t=>{let n={...t};return delete n[e],n})},[]),C=Object.values(u).filter(e=>e.type===`image`),w=C.length>0,T=Na(),E=e.input.allowedPrompts,D=Zo(),O=!D||D.trim()===``,[k]=(0,Q.useState)(()=>va()??void 0),[A,j]=(0,Q.useState)(()=>Zo()??`No plan found. Please write your plan to the plan file first.`),[M,N]=(0,Q.useState)(!1),[P,F]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{if(M){let e=setTimeout(N,5e3,!1);return()=>clearTimeout(e)}},[M]);let ee=e=>{if(e.ctrl&&e.key===`g`){e.preventDefault(),(async()=>{let e=await Wp(T);e.error&&o({key:`external-editor-error`,text:e.error,color:`warning`,priority:`high`}),e.content!==null&&(e.content!==A&&F(!0),j(e.content),N(!0))})();return}if(e.shift&&e.key===`tab`){e.preventDefault(),I(p?`yes-accept-edits`:`yes-accept-edits-keep-context`);return}};async function I(r){let o=s.trim(),c=o||void 0,l=P?{plan:A}:{};{let e=(r===`yes-resume-auto-mode`||r===`yes-auto-clear-context`)&&Pt(),t=zn();r!==`no`&&!e&&t&&(ra(!1),Te(!0),a(e=>({...e,toolPermissionContext:{...wr(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`&&vy(A,a,!u),r!==`no`&&!u){let i=`default`;r===`yes-bypass-permissions`?i=`bypassPermissions`:r===`yes-accept-edits`?i=`acceptEdits`:r===`yes-auto-clear-context`&&Pt()&&(i=`auto`,ra(!0)),A.length,gl();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: ${To()}`,s=c?`\n\nUser feedback on this plan: ${c}`:``;a(e=>({...e,initialMessage:{message:{...ht({content:`Implement the following plan:\n\n${A}${o}${s}`}),planContent:A},clearContext:!0,mode:i,allowedPrompts:E}})),Je(!0),tt(!0),t(),n(),e.onReject();return}if(r===`yes-resume-auto-mode`&&Pt()){A.length,gl(),Je(!0),tt(!0),ra(!0),a(e=>({...e,toolPermissionContext:ls({...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){A.length,gl(),Je(!0),tt(!0),t(),e.onAllow(l,_y(d,E),c);return}let f={"yes-bypass-permissions":`bypassPermissions`,"yes-accept-edits":`acceptEdits`}[r];if(f){A.length,gl(),Je(!0),tt(!0),t(),e.onAllow(l,_y(f,E),c);return}if(r===`no`){if(!o&&!w)return;A.length,gl();let r;w&&(r=await Promise.all(C.map(async e=>(await Li({type:`image`,source:{type:`base64`,media_type:e.mediaType||`image/png`,data:e.content}})).block))),t(),n(),e.onReject(o||(w?`(See attached image)`:void 0),r&&r.length>0?r:void 0)}}let L=Bp()??null,te=(0,Q.useRef)(I);te.current=I;let R=(0,Q.useRef)(void 0);R.current=()=>{A.length,gl(),t(),n(),e.onReject()};let ne=!O&&!!r;if((0,Q.useLayoutEffect)(()=>{if(ne)return r((0,$.jsxs)(g,{flexDirection:`column`,borderStyle:`round`,borderColor:`planMode`,borderLeft:!1,borderRight:!1,borderBottom:!1,paddingX:1,children:[(0,$.jsx)(b,{dimColor:!0,children:`Would you like to proceed?`}),(0,$.jsx)(g,{marginTop:1,children:(0,$.jsx)(rp,{options:y,onChange:e=>void te.current(e),onCancel:()=>R.current?.(),onImagePaste:x,pastedContents:u,onRemoveImage:S})}),L&&(0,$.jsxs)(g,{flexDirection:`row`,gap:1,marginTop:1,children:[(0,$.jsx)(b,{dimColor:!0,children:`ctrl-g to edit in `}),(0,$.jsx)(b,{bold:!0,dimColor:!0,children:L}),(0,$.jsxs)(b,{dimColor:!0,children:[` · `,_u(T)]}),M&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(b,{dimColor:!0,children:` · `}),(0,$.jsxs)(b,{color:`success`,children:[l.tick,`Plan saved!`]})]})]})]})),()=>r(null)},[ne,r,y,u,L,T,M]),O){function r(r){r===`yes`?(gl(),zn()&&(ra(!1),Te(!0),a(e=>({...e,toolPermissionContext:{...wr(e.toolPermissionContext),prePlanMode:void 0}}))),Je(!0),tt(!0),t(),e.onAllow({},[{type:`setMode`,mode:`default`,destination:`session`}])):(gl(),t(),n(),e.onReject())}return(0,$.jsx)(Dm,{color:`planMode`,title:`Exit plan mode?`,children:(0,$.jsxs)(g,{flexDirection:`column`,paddingX:1,marginTop:1,children:[(0,$.jsx)(b,{children:`Work Mate wants to exit plan mode`}),(0,$.jsx)(g,{marginTop:1,children:(0,$.jsx)(rp,{options:[{label:`Yes`,value:`yes`},{label:`No`,value:`no`}],onChange:r,onCancel:()=>{gl(),t(),n(),e.onReject()}})})]})})}return(0,$.jsxs)(g,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:ee,children:[(0,$.jsx)(Dm,{color:`planMode`,title:`Ready to code?`,innerPaddingX:0,children:(0,$.jsxs)(g,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(g,{paddingX:1,flexDirection:`column`,children:(0,$.jsx)(b,{children:`Here is Work Mate's plan:`})}),(0,$.jsx)(g,{borderColor:`subtle`,borderStyle:`dashed`,flexDirection:`column`,borderLeft:!1,borderRight:!1,paddingX:1,marginBottom:1,overflow:`hidden`,children:(0,$.jsx)(ys,{children:A})}),(0,$.jsxs)(g,{flexDirection:`column`,paddingX:1,children:[(0,$.jsx)(R_,{permissionResult:e.permissionResult,toolType:`tool`}),Ri()&&E&&E.length>0&&(0,$.jsxs)(g,{flexDirection:`column`,marginBottom:1,children:[(0,$.jsx)(b,{bold:!0,children:`Requested permissions:`}),E.map((e,t)=>(0,$.jsxs)(b,{dimColor:!0,children:[` `,`· `,e.tool,`(`,`prompt:`,` `,e.prompt,`)`]},t))]}),!ne&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(b,{dimColor:!0,children:`Work Mate has written up a plan and is ready to execute. Would you like to proceed?`}),(0,$.jsx)(g,{marginTop:1,children:(0,$.jsx)(rp,{options:y,onChange:I,onCancel:()=>R.current?.(),onImagePaste:x,pastedContents:u,onRemoveImage:S})})]})]})]})}),!ne&&L&&(0,$.jsxs)(g,{flexDirection:`row`,gap:1,paddingX:1,marginTop:1,children:[(0,$.jsxs)(g,{children:[(0,$.jsx)(b,{dimColor:!0,children:`ctrl-g to edit in `}),(0,$.jsx)(b,{bold:!0,dimColor:!0,children:L}),(0,$.jsxs)(b,{dimColor:!0,children:[` · `,_u(T)]})]}),M&&(0,$.jsxs)(g,{children:[(0,$.jsx)(b,{dimColor:!0,children:` · `}),(0,$.jsxs)(b,{color:`success`,children:[l.tick,`Plan saved!`]})]})]})]})}function by({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 xy(e,t){if(!e)return null;let n=vd(Cd({permissionMode:t,mainLoopModel:wd(),exceeds200kTokens:!1}),Qe()),{used:r}=pd({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}vp(),V(),Oc(),Zu(),Y(),np();var Sy={accept:`tell Work Mate what to do next`,reject:`tell Work Mate what to do differently`};function Cy({options:e,onSelect:t,onCancel:n,question:r=`Do you want to proceed?`,toolAnalyticsContext:i}){let a=vn(),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(!1),[h,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(!1),C=e.find(e=>e.value===h)?.feedbackConfig?.type,w=C===`accept`&&!u||C===`reject`&&!f,T=(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=Sy[i];return o?{type:`input`,label:n,value:t,placeholder:a??d,onChange:c,allowEmptySubmitToCancel:!0}:{label:n,value:t}}),[e,u,f]),E=(0,Q.useCallback)(t=>{let n=e.find(e=>e.value===t);if(!n?.feedbackConfig)return;let{type:r}=n.feedbackConfig;i?.toolName,i?.isMcp,r===`accept`?u?d(!1):(d(!0),y(!0)):r===`reject`&&(f?p(!1):(p(!0),S(!0)))},[e,u,f,i]),D=(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),i?.toolName,i?.isMcp,e?.length,r.feedbackConfig.type,r.feedbackConfig.type===`accept`||r.feedbackConfig.type}t(n,a)},[e,o,c,t,i,v,x]);m((0,Q.useMemo)(()=>{let t={};for(let n of e)n.keybinding&&(t[n.keybinding]=()=>D(n.value));return t},[e,D]),{context:`Confirmation`});let O=(0,Q.useCallback)(()=>{a(e=>({...e,attribution:{...e.attribution,escapeCount:e.attribution.escapeCount+1}})),n?.()},[n,a]);return(0,$.jsxs)(g,{flexDirection:`column`,children:[typeof r==`string`?(0,$.jsx)(b,{children:r}):r,(0,$.jsx)(rp,{options:T,inlineDescriptions:!0,onChange:D,onCancel:O,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),_(t)},onInputModeToggle:E}),(0,$.jsx)(g,{marginTop:1,children:(0,$.jsxs)(b,{dimColor:!0,children:[`Esc to cancel`,w&&` · Tab to amend`]})})]})}Ne(),V(),Kd(),ou(),Xn(),dd(),Tm();function wy({toolUseConfirm:e,onDone:t,onReject:n,verbose:r}){let[i]=h(),a=e.tool.userFacingName(e.input),o=a.endsWith(` (MCP)`)?a.slice(0,-6):a;vv(e,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let s=(0,Q.useCallback)((r,i)=>{switch(r){case`yes`:_v({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:pu.platform}}),e.onAllow(e.input,[],i),t();break;case`yes-dont-ask-again`:_v({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:pu.platform}}),e.onAllow(e.input,[{type:`addRules`,rules:[{toolName:e.tool.name}],behavior:`allow`,destination:`localSettings`}]),t();break;case`no`:_v({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:pu.platform}}),e.onReject(i),n(),t();break}},[e,t,n]),c=(0,Q.useCallback)(()=>{_v({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:pu.platform}}),e.onReject(),n(),t()},[e,t,n]),l=Ze(),u=Qr(),d=(0,Q.useMemo)(()=>{let e=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}];return u&&e.push({label:(0,$.jsxs)(b,{children:[`Yes, and don't ask again for `,(0,$.jsx)(b,{bold:!0,children:o}),` commands in`,` `,(0,$.jsx)(b,{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:Gd(e.tool.name),isMcp:e.tool.isMcp??!1}),[e.tool.name,e.tool.isMcp]);return(0,$.jsxs)(Dm,{title:`Tool use`,children:[(0,$.jsxs)(g,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsxs)(b,{children:[o,`(`,e.tool.renderToolUseMessage(e.input,{theme:i,verbose:!0}),`)`,a.endsWith(` (MCP)`)?(0,$.jsx)(b,{dimColor:!0,children:` (MCP)`}):``]}),(0,$.jsx)(b,{dimColor:!0,children:ld(e.description,3)})]}),(0,$.jsxs)(g,{flexDirection:`column`,children:[(0,$.jsx)(R_,{permissionResult:e.permissionResult,toolType:`tool`}),(0,$.jsx)(Cy,{options:d,onSelect:s,onCancel:c,toolAnalyticsContext:f})]})]})}Al(),V();function Ty(e){let t=e=>fr.inputSchema.parse(e),{file_path:n,old_string:r,new_string:i,replace_all:a}=t(e.toolUseConfirm.input);return(0,$.jsx)(ry,{toolUseConfirm:e.toolUseConfirm,toolUseContext:e.toolUseContext,onDone:e.onDone,onReject:e.onReject,title:`Edit file`,subtitle:fh(jl(),n),question:(0,$.jsxs)(b,{children:[`Do you want to make this edit to `,(0,$.jsx)(b,{bold:!0,children:ch(n)}),`?`]}),content:(0,$.jsx)(Hv,{file_path:n,edits:[{old_string:r,new_string:i,replace_all:a||!1}]}),path:n,completionType:`str_replace_single`,parseInput:t})}V();function Ey(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 Dy({toolUseConfirm:e,onDone:t,onReject:n,verbose:r,toolUseContext:i}){let[a]=h(),o=Ey(e),s=e.tool.userFacingName(e.input),c=e.tool.isReadOnly(e.input),l=`${c?`Read`:`Edit`} file`;return o?(0,$.jsx)(ry,{toolUseConfirm:e,toolUseContext:i,onDone:t,onReject:n,title:l,content:(0,$.jsx)(g,{flexDirection:`column`,paddingX:2,paddingY:1,children:(0,$.jsxs)(b,{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)(wy,{toolUseConfirm:e,toolUseContext:i,onDone:t,onReject:n,verbose:r})}yc(),V(),Xs(),el();function Oy({file_path:e,content:t,fileExists:n,oldContent:r}){let{columns:i}=ae(),a=(0,Q.useMemo)(()=>n?Pa({filePath:e,fileContents:r,edits:[{old_string:r,new_string:t,replace_all:!1}]}):null,[n,e,r,t]),o=t.split(`
24
+ `)[0]??null;return(0,$.jsx)(g,{flexDirection:`column`,children:(0,$.jsx)(g,{borderColor:`subtle`,borderStyle:`dashed`,flexDirection:`column`,borderLeft:!1,borderRight:!1,paddingX:1,children:a?mu(a.map(t=>(0,$.jsx)(il,{patch:t,dim:!1,filePath:e,firstLine:o,fileContent:r,width:i-2},t.newStart)),e=>(0,$.jsx)(w,{fromLeftEdge:!0,children:(0,$.jsx)(b,{dimColor:!0,children:`...`})},`ellipsis-${e}`)):(0,$.jsx)(Lt,{code:t||`(No content)`,filePath:e})})})}V(),Al(),Il(),ru();function ky(e){let t=e=>$r.inputSchema.parse(e),{file_path:n,content:r}=t(e.toolUseConfirm.input),{fileExists:i,oldContent:a}=(0,Q.useMemo)(()=>{try{return{fileExists:!0,oldContent:cu(n)}}catch(e){if(!Rl(e))throw e;return{fileExists:!1,oldContent:``}}},[n]),o=i?`overwrite`:`create`;return(0,$.jsx)(ry,{toolUseConfirm:e.toolUseConfirm,toolUseContext:e.toolUseContext,onDone:e.onDone,onReject:e.onReject,title:i?`Overwrite file`:`Create file`,subtitle:fh(jl(),n),question:(0,$.jsxs)(b,{children:[`Do you want to `,o,` `,(0,$.jsx)(b,{bold:!0,children:ch(n)}),`?`]}),content:(0,$.jsx)(Oy,{file_path:n,content:r,fileExists:i,oldContent:a}),path:n,completionType:`write_file_single`,parseInput:t})}V(),Ql(),Al(),Xs(),Ul(),el(),ai();function Ay(e){let t=(0,Q.useMemo)(()=>Kl().readFile(e.notebook_path,{encoding:`utf-8`}).then(e=>ve(e)).catch(()=>null),[e.notebook_path]);return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(jy,{...e,promise:t})})}function jy({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=Uc(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:Pa({filePath:e,fileContents:l,edits:[{old_string:l,new_string:n,replace_all:!1}],ignoreWhitespace:!1}),[c,e,l,n,i]),d;switch(i){case`insert`:d=`Insert new cell`;break;case`delete`:d=`Delete cell`;break;default:d=`Replace cell contents`}return(0,$.jsx)(g,{flexDirection:`column`,children:(0,$.jsxs)(g,{borderStyle:`round`,flexDirection:`column`,paddingX:1,children:[(0,$.jsxs)(g,{paddingBottom:1,flexDirection:`column`,children:[(0,$.jsx)(b,{bold:!0,children:a?e:fh(jl(),e)}),(0,$.jsxs)(b,{dimColor:!0,children:[d,` for cell `,t,r?` (${r})`:``]})]}),i===`delete`?(0,$.jsx)(g,{flexDirection:`column`,paddingLeft:2,children:(0,$.jsx)(Lt,{code:l,filePath:e})}):i===`insert`?(0,$.jsx)(g,{flexDirection:`column`,paddingLeft:2,children:(0,$.jsx)(Lt,{code:n,filePath:r===`markdown`?`file.md`:e})}):u?mu(u.map(t=>(0,$.jsx)(il,{patch:t,dim:!1,width:o,filePath:e,firstLine:n.split(`
25
+ `)[0]??null,fileContent:l},t.newStart)),e=>(0,$.jsx)(w,{fromLeftEdge:!0,children:(0,$.jsx)(b,{dimColor:!0,children:`...`})},`ellipsis-${e}`)):(0,$.jsx)(Lt,{code:n,filePath:r===`markdown`?`file.md`:e})]})})}V(),Bu();function My(e){let t=e=>{let t=Ct.inputSchema.safeParse(e);return t.success?t.data:(Hu(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)(ry,{toolUseConfirm:e.toolUseConfirm,toolUseContext:e.toolUseContext,onDone:e.onDone,onReject:e.onReject,title:`Edit notebook`,question:(0,$.jsxs)(b,{children:[`Do you want to `,s,` `,(0,$.jsx)(b,{bold:!0,children:ch(r)}),`?`]}),content:(0,$.jsx)(Ay,{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})}dd(),ir();async function Ny(e){if(e.nameType===`application`)return null;let t=e.name;if(!t||ts.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 sv(n),i=await nv(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||Z_[n])?null:i}async function Py(e,t){let n=await Yn(e);if(!n.valid)return[];let r=tn(n).filter(e=>e.elementType===`CommandAst`);if(r.length<=1){let e=r[0]?await Ny(r[0]):null;return e?[e]:[]}let i=[];for(let e of r){if(t?.(e))continue;let n=await Ny(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=Fy(t);(n===``?0:fd(n,` `)+1)<=1&&((await sv(e))?.subcommands?.length||Z_[e])||o.push(n)}return o}function Fy(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(` `)}Xn();function Iy({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`}),Qr()&&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=dy(e,Ed);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}V(),Oc(),Zu(),Kd(),np(),Tm();function Ly(e){let{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i}=e,{command:a,description:o}=Dr.inputSchema.parse(t.input),[s]=h(),c=zv({toolName:t.tool.name,toolInput:t.input,toolDescription:t.description,messages:n.messages}),{yesInputMode:l,noInputMode:u,yesFeedbackModeEntered:d,noFeedbackModeEntered:f,acceptFeedback:p,rejectFeedback:m,setAcceptFeedback:_,setRejectFeedback:v,focusedOption:y,handleInputModeToggle:x,handleReject:S,handleFocus:C}=sy({toolUseConfirm:t,onDone:r,onReject:i,explainerVisible:c.visible}),[w,T]=(0,Q.useState)(!1),[D,O]=(0,Q.useState)(a.includes(`
26
+ `)?void 0:a),k=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{let e=!1;return Py(a,e=>Pr(e,e.text)).then(t=>{e||k.current||t.length>0&&O(`${t[0]}:*`)}).catch(()=>{}),()=>{e=!0}},[a]);let A=(0,Q.useCallback)(e=>{k.current=!0,O(e)},[]);vv(t,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let j=(0,Q.useMemo)(()=>Iy({suggestions:t.permissionResult.behavior===`ask`?t.permissionResult.suggestions:void 0,onRejectFeedbackChange:v,onAcceptFeedbackChange:_,yesInputMode:l,noInputMode:u,editablePrefix:D,onEditablePrefixChange:A}),[t,l,u,D,A]);E(`permission:toggleDebug`,(0,Q.useCallback)(()=>{T(e=>!e)},[]),{context:`Confirmation`});function M(e){if({yes:1,"yes-apply-suggestions":2,"yes-prefix-edited":2,no:3}[e],c.visible,Gd(t.tool.name),e===`yes-prefix-edited`){let e=(D??``).trim();if(oy(`tool_use_single`,t,`accept`),!e)t.onAllow(t.input,[]);else{let n=[{type:`addRules`,rules:[{toolName:Dr.name,ruleContent:e}],behavior:`allow`,destination:`localSettings`}];t.onAllow(t.input,n)}r();return}switch(e){case`yes`:{let e=p.trim();oy(`tool_use_single`,t,`accept`),t.tool.isMcp,e.length,t.onAllow(t.input,[],e||void 0),r();break}case`yes-apply-suggestions`:{oy(`tool_use_single`,t,`accept`);let e=`suggestions`in t.permissionResult&&t.permissionResult.suggestions||[];t.onAllow(t.input,e),r();break}case`no`:{let e=m.trim();t.tool.isMcp,e.length,S(e||void 0);break}}}return(0,$.jsxs)(Dm,{title:`PowerShell command`,children:[(0,$.jsxs)(g,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(b,{dimColor:c.visible,children:Dr.renderToolUseMessage({command:a,description:o},{theme:s,verbose:!0})}),!c.visible&&(0,$.jsx)(b,{dimColor:!0,children:t.description}),(0,$.jsx)(Vv,{visible:c.visible,promise:c.promise})]}),w?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Tv,{permissionResult:t.permissionResult,toolName:`PowerShell`}),n.options.debug&&(0,$.jsx)(g,{justifyContent:`flex-end`,marginTop:1,children:(0,$.jsx)(b,{dimColor:!0,children:`Ctrl-D to hide debug info`})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(g,{flexDirection:`column`,children:[(0,$.jsx)(R_,{permissionResult:t.permissionResult,toolType:`command`}),null,(0,$.jsx)(b,{children:`Do you want to proceed?`}),(0,$.jsx)(rp,{options:j,inlineDescriptions:!0,onChange:M,onCancel:()=>S(),onFocus:C,onInputModeToggle:x})]}),(0,$.jsxs)(g,{justifyContent:`space-between`,marginTop:1,children:[(0,$.jsxs)(b,{dimColor:!0,children:[`Esc to cancel`,(y===`yes`&&!l||y===`no`&&!u)&&` · Tab to amend`,c.enabled&&` · ctrl+e to ${c.visible?`hide`:`explain`}`]}),n.options.debug&&(0,$.jsx)(b,{dimColor:!0,children:`Ctrl+d to show debug info`})]})]})]})}Bu(),Ne(),V(),Kd(),ou(),Xn(),Tm();function Ry(e){let{toolUseConfirm:t,onDone:n,onReject:r,verbose:i}=e,a=(e=>{let t=la.inputSchema.safeParse(e);return t.success?t.data.skill:(Hu(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;vv(t,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let s=Ze(),c=Qr(),l=(0,Q.useMemo)(()=>{let e=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}],t=[];if(c){t.push({label:(0,$.jsxs)(b,{children:[`Yes, and don't ask again for `,(0,$.jsx)(b,{bold:!0,children:a}),` in `,(0,$.jsx)(b,{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)(b,{children:[`Yes, and don't ask again for `,(0,$.jsx)(b,{bold:!0,children:`${n}:*`}),` commands in`,` `,(0,$.jsx)(b,{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:Gd(t.tool.name),isMcp:t.tool.isMcp??!1}),[t.tool.name,t.tool.isMcp]),d=(0,Q.useCallback)((e,i)=>{switch(e){case`yes`:_v({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:pu.platform}}),t.onAllow(t.input,[],i),n();break;case`yes-exact`:_v({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:pu.platform}}),t.onAllow(t.input,[{type:`addRules`,rules:[{toolName:Dd,ruleContent:a}],behavior:`allow`,destination:`localSettings`}]),n();break;case`yes-prefix`:{_v({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:pu.platform}});let e=a.indexOf(` `),r=e>0?a.substring(0,e):a;t.onAllow(t.input,[{type:`addRules`,rules:[{toolName:Dd,ruleContent:`${r}:*`}],behavior:`allow`,destination:`localSettings`}]),n();break}case`no`:_v({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:pu.platform}}),t.onReject(i),r(),n();break}},[t,n,r,a]),f=(0,Q.useCallback)(()=>{_v({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:pu.platform}}),t.onReject(),r(),n()},[t,n,r]);return(0,$.jsxs)(Dm,{title:`Use skill "${a}"?`,children:[(0,$.jsx)(b,{children:`Work Mate may use instructions, code, or files from this Skill.`}),(0,$.jsx)(g,{flexDirection:`column`,paddingX:2,paddingY:1,children:(0,$.jsx)(b,{dimColor:!0,children:o?.description})}),(0,$.jsxs)(g,{flexDirection:`column`,children:[(0,$.jsx)(R_,{permissionResult:t.permissionResult,toolType:`tool`}),(0,$.jsx)(Cy,{options:l,onSelect:d,onCancel:f,toolAnalyticsContext:u})]})]})}V(),gp(),ou(),Xn(),Tm();function zy({toolUseConfirm:e,onDone:t,onReject:n}){let[r]=h(),i=hp(r),a=e.input,o=(0,Q.useMemo)(()=>Qr(),[]),s=(0,Q.useMemo)(()=>{let t=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}];return o&&t.push({label:(0,$.jsxs)(b,{children:[`Yes, and don`,`’`,`t ask again for `,(0,$.jsx)(b,{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`:_v({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:pu.platform}}),e.onAllow(e.input,[],i),t();break;case`yes-dont-ask-again`:_v({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:pu.platform}}),e.onAllow(e.input,[{type:`addRules`,rules:[{toolName:e.tool.name}],behavior:`allow`,destination:`localSettings`}]),t();break;case`no`:_v({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:pu.platform}}),e.onReject(i),n(),t();break}},[e,t,n]),l=(0,Q.useCallback)(()=>{_v({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:pu.platform}}),e.onReject(),n(),t()},[e,t,n]);return(0,$.jsx)(Dm,{title:`Workflow`,children:(0,$.jsxs)(g,{flexDirection:`column`,gap:1,children:[(0,$.jsxs)(g,{flexDirection:`column`,children:[(0,$.jsxs)(b,{bold:!0,color:i.permission,children:[`Execute workflow: `,a.workflow]}),a.args&&(0,$.jsxs)(b,{dimColor:!0,children:[`Arguments: `,a.args]})]}),(0,$.jsx)(R_,{permissionResult:e.permissionResult,toolType:`command`}),(0,$.jsx)(Cy,{options:s,onSelect:c,onCancel:l})]})})}Oc(),K(),ya(),Sr(),Tl(),ss(),yt(),Gr();var By=Zr();function Vy(e){switch(e){case fr:return Ty;case $r:return ky;case Po:return my;case Dr:return Ly;case Ct:return My;case tl:return yy;case Uo:return gy;case la:return Ry;case oi:return K_;case By:return zy??wy;case as:case yr:case kl:return Dy;default:return wy}}function Hy(e){let t=e.tool.userFacingName(e.input);return e.tool===tl?`Work Mate needs your approval for the plan`:e.tool===Uo?`Work Mate wants to enter plan mode`:!t||t.trim()===``?`Work Mate needs your attention`:`Work Mate needs your permission to use ${t}`}function Uy({toolUseConfirm:e,toolUseContext:t,onDone:n,onReject:r,verbose:i,setStickyFooter:a}){return E(`app:interrupt`,()=>{n(),r(),e.onReject()},{context:`Confirmation`}),k_(Hy(e),`permission_prompt`),(0,$.jsx)(Vy(e.tool),{toolUseContext:t,toolUseConfirm:e,onDone:n,onReject:r,verbose:i,setStickyFooter:a})}bl(),Bf(),Bu(),In();async function Wy(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=un([`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 ia({systemPrompt:u,userPrompt:d,signal:n,options:{querySource:`mcp_datetime_parse`,agents:[],isNonInteractiveSession:!1,hasAppendSystemPrompt:!1,mcpTools:[],enablePromptCaching:!1}}),t=cn(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 Hu(e),{success:!1,error:`Unable to parse date/time. Please enter in ISO 8601 format manually.`}}}function Gy(e){return/^\d{4}-\d{2}-\d{2}(T|$)/.test(e.trim())}_e(),ql(),dd();var Ky=e=>e.type===`string`&&(`enum`in e||`oneOf`in e);function qy(e){return e.type===`array`&&`items`in e&&typeof e.items==`object`&&e.items!==null&&(`enum`in e.items||`anyOf`in e.items)}function Jy(e){return`anyOf`in e.items?e.items.anyOf.map(e=>e.const):`enum`in e.items?e.items.enum:[]}function Yy(e){return`anyOf`in e.items?e.items.anyOf.map(e=>e.title):`enum`in e.items?e.items.enum:[]}function Xy(e,t){let n=Jy(e).indexOf(t);return n>=0?Yy(e)[n]??t:t}function Zy(e){return`oneOf`in e?e.oneOf.map(e=>e.const):`enum`in e?e.enum:[]}function Qy(e){return`oneOf`in e?e.oneOf.map(e=>e.title):`enum`in e?(`enumNames`in e?e.enumNames:void 0)??e.enum:[]}function $y(e,t){let n=Zy(e).indexOf(t);return n>=0?Qy(e)[n]??t:t}function eb(e){if(Ky(e)){let[t,...n]=Zy(e);return t?xe([t,...n]):pe()}if(e.type===`string`){let t=ge();switch(e.minLength!==void 0&&(t=t.min(e.minLength,{message:`Must be at least ${e.minLength} ${ud(e.minLength,`character`)}`})),e.maxLength!==void 0&&(t=t.max(e.maxLength,{message:`Must be at most ${e.maxLength} ${ud(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=me({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 fe();throw Error(`Unsupported schema: ${Nl(e)}`)}function tb(e,t){let n=eb(t).safeParse(e);return n.success?{value:n.data,isValid:!0}:{isValid:!1,error:n.error.issues.map(e=>e.message).join(`; `)}}function nb(e){return e.type===`string`&&`format`in e&&(e.format===`date`||e.format===`date-time`)}async function rb(e,t,n){let r=tb(e,t);if(r.isValid)return r;if(nb(t)&&!Gy(e)){let r=await Wy(e,t.format,n);if(r.success){let e=tb(r.value,t);if(e.isValid)return e}}return r}c(),yc(),V(),Oc(),dd(),zo(),mf();var ib=e=>[`string`,`number`,`integer`].includes(e.type),ab=`⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏`,ob=e=>(e+1)%10;function sb(e){e.buffer=``,e.timer=void 0}function cb(){let[e,t]=(0,Q.useState)(0);return(0,Q.useEffect)(()=>{let e=setInterval(t,80,ob);return()=>clearInterval(e)},[]),(0,$.jsx)(b,{color:`warning`,children:ab[e]})}function lb(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 ub({event:e,onResponse:t,onWaitingDismiss:n}){return e.params.mode===`url`?(0,$.jsx)(fb,{event:e,onResponse:t,onWaitingDismiss:n}):(0,$.jsx)(db,{event:e,onResponse:t})}function db({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`),[u,f]=(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}),[p,m]=(0,Q.useState)(()=>{let e={};for(let[t,n]of Object.entries(a.properties))if(ib(n)&&n?.default!==void 0){let r=tb(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 h=(0,Q.useMemo)(()=>{let e=a.required??[];return Object.entries(a.properties).map(([t,n])=>({name:t,schema:n,isRequired:e.includes(t)}))},[a]),[_,v]=(0,Q.useState)(o?0:void 0),[y,x]=(0,Q.useState)(()=>{let e=h[0];if(e&&ib(e.schema)){let t=u[e.name];return t===void 0?``:String(t)}return``}),[S,w]=(0,Q.useState)(y.length),[T,D]=(0,Q.useState)(()=>new Set),[O,k]=(0,Q.useState)(),[A,j]=(0,Q.useState)(0),M=(0,Q.useRef)(void 0),N=(0,Q.useRef)(new Map),P=(0,Q.useRef)({buffer:``,timer:void 0});(0,Q.useEffect)(()=>()=>{M.current!==void 0&&clearTimeout(M.current);let e=P.current;e.timer!==void 0&&clearTimeout(e.timer);for(let e of N.current.values())e.abort();N.current.clear()},[]);let{columns:F,rows:ee}=ae(),I=_===void 0?void 0:h[_],L=I!==void 0&&ib(I.schema)&&!Ky(I.schema)&&!s;Lf(`elicitation`),k_(`Work Mate needs your input`,`elicitation_dialog`);let te=(0,Q.useCallback)(e=>{if(e===void 0){x(``),w(0);return}let t=h[e];if(t&&ib(t.schema)&&!Ky(t.schema)){let e=u[t.name],n=e===void 0?``:String(e);x(n),w(n.length)}},[h,u]);function R(e,t){if(!qy(t))return;let n=u[e]??[],r=h.find(t=>t.name===e)?.isRequired??!1,i=t.minItems,a=t.maxItems;i!==void 0&&n.length<i&&(n.length>0||r)?ie(e,`Select at least ${i} ${ud(i,`item`)}`):a!==void 0&&n.length>a?ie(e,`Select at most ${a} ${ud(a,`item`)}`):ie(e)}function z(e){I&&qy(I.schema)?(R(I.name,I.schema),k(void 0)):I&&Ky(I.schema)&&k(void 0),L&&I&&(oe(I.name,I.schema,y),M.current!==void 0&&(clearTimeout(M.current),M.current=void 0),nb(I.schema)&&y.trim()!==``&&p[I.name]&&se(I.name,I.schema,y));let t=h.length+2,n=_??(s===`accept`?h.length:s===`decline`?h.length+1:void 0),r=n===void 0?0:(n+(e===`up`?t-1:1))%t;r<h.length?(v(r),c(null),te(r)):(v(void 0),c(r===h.length?`accept`:`decline`),x(``))}function re(e,t){f(n=>{let r={...n};return t===void 0?delete r[e]:r[e]=t,r}),t!==void 0&&p[e]===`This field is required`&&ie(e)}function ie(e,t){m(n=>{let r={...n};return t?r[e]=t:delete r[e],r})}function B(e){e&&(re(e,void 0),ie(e),x(``),w(0))}function oe(e,t,n){let r=n.trim();if(r===``&&(t.type!==`string`||`format`in t&&t.format!==void 0)){B(e);return}if(r===``){u[e]!==void 0&&re(e,``);return}let i=tb(n,t);re(e,i.isValid?i.value:n),ie(e,i.isValid?void 0:i.error)}function se(e,t,n){if(!r)return;let i=N.current.get(e);i&&i.abort();let a=new AbortController;N.current.set(e,a),D(t=>new Set(t).add(e)),rb(n,t,a.signal).then(t=>{if(N.current.delete(e),D(t=>{let n=new Set(t);return n.delete(e),n}),!a.signal.aborted)if(t.isValid){re(e,t.value),ie(e);let r=String(t.value);x(e=>e===n?(w(r.length),r):e)}else ie(e,t.error)},()=>{N.current.delete(e),D(t=>{let n=new Set(t);return n.delete(e),n})})}function V(e){if(x(e),I&&(oe(I.name,I.schema,e),M.current!==void 0&&(clearTimeout(M.current),M.current=void 0),nb(I.schema)&&e.trim()!==``&&p[I.name])){let t=I.name,n=I.schema;M.current=setTimeout((e,t,n,r,i)=>{e.current=void 0,t(n,r,i)},2e3,M,se,t,n,e)}}function ce(){z(`down`)}function le(e,t,n){let r=P.current;r.timer!==void 0&&clearTimeout(r.timer),r.buffer+=e.toLowerCase(),r.timer=setTimeout(sb,2e3,r);let i=t.findIndex(e=>e.startsWith(r.buffer));i!==-1&&n(i)}E(`confirm:no`,()=>{if(L&&I){let e=u[I.name];x(e===void 0?``:String(e)),w(0)}t(`cancel`)},{context:`Settings`,isActive:!!I&&!s&&!O}),ne((e,n)=>{if(L&&!n.upArrow&&!n.downArrow&&!n.return&&!n.backspace)return;if(O&&I&&qy(I.schema)){let t=I.schema,r=Jy(t),i=u[I.name]??[];if(n.leftArrow||n.escape){k(void 0),R(I.name,t);return}if(n.upArrow){A===0?(k(void 0),R(I.name,t)):j(A-1);return}if(n.downArrow){A>=r.length-1?(k(void 0),z(`down`)):j(A+1);return}if(e===` `){let e=r[A];if(e!==void 0){let n=i.includes(e)?i.filter(t=>t!==e):[...i,e],r=n.length>0?n:void 0;re(I.name,r);let a=t.minItems,o=t.maxItems;a!==void 0&&n.length<a&&(n.length>0||I.isRequired)?ie(I.name,`Select at least ${a} ${ud(a,`item`)}`):o!==void 0&&n.length>o?ie(I.name,`Select at most ${o} ${ud(o,`item`)}`):ie(I.name)}return}if(n.return){let e=r[A];e!==void 0&&!i.includes(e)&&re(I.name,[...i,e]),k(void 0),z(`down`);return}if(e){le(e,r.map(e=>Xy(t,e).toLowerCase()),j);return}return}if(O&&I&&Ky(I.schema)){let t=I.schema,r=Zy(t);if(n.leftArrow||n.escape){k(void 0);return}if(n.upArrow){A===0?k(void 0):j(A-1);return}if(n.downArrow){A>=r.length-1?(k(void 0),z(`down`)):j(A+1);return}if(e===` `){let e=r[A];e!==void 0&&re(I.name,e),k(void 0);return}if(n.return){let e=r[A];e!==void 0&&re(I.name,e),k(void 0),z(`down`);return}if(e){le(e,r.map(e=>$y(t,e).toLowerCase()),j);return}return}if(n.return&&s===`accept`){if(H()&&Object.keys(p).length===0)t(`accept`,u);else{let e=a.required||[];for(let t of e)u[t]===void 0&&ie(t,`This field is required`);let t=h.findIndex(t=>e.includes(t.name)&&u[t.name]===void 0||p[t.name]!==void 0);t!==-1&&(v(t),c(null),te(t))}return}if(n.return&&s===`decline`){t(`decline`);return}if(n.upArrow||n.downArrow){let e=P.current;e.buffer=``,e.timer!==void 0&&(clearTimeout(e.timer),e.timer=void 0),z(n.upArrow?`up`:`down`);return}if(s&&(n.leftArrow||n.rightArrow)){c(s===`accept`?`decline`:`accept`);return}if(!I)return;let{schema:r,name:i}=I,o=u[i];if(r.type===`boolean`){if(e===` `){re(i,o===void 0||!o);return}if(n.return){z(`down`);return}if(n.backspace&&o!==void 0){B(i);return}if(e&&!n.return){le(e,[`yes`,`no`],e=>re(i,e===0));return}return}if(Ky(r)||qy(r)){if(n.return){z(`down`);return}if(n.backspace&&o!==void 0){B(i);return}let t,a=0;if(Ky(r)){let e=Zy(r);t=e.map(e=>$y(r,e).toLowerCase()),o!==void 0&&(a=Math.max(0,e.indexOf(o)))}else t=Jy(r).map(e=>Xy(r,e).toLowerCase());if(n.rightArrow){k(i),j(a);return}if(e&&!n.leftArrow){le(e,t,e=>{k(i),j(e)});return}return}if(n.backspace&&L&&y===``){B(i);return}},{isActive:!0});function H(){let e=a.required||[];for(let t of e){let e=u[t];if(e==null||e===``||Array.isArray(e)&&e.length===0)return!1}return!0}let U=Math.max(2,Math.floor((ee-14)/3)),W=(0,Q.useMemo)(()=>{let e=h.length;if(e<=U)return{start:0,end:e};let t=_??e-1,n=Math.max(0,t-Math.floor(U/2)),r=Math.min(n+U,e);return n=Math.max(0,r-U),{start:n,end:r}},[h.length,U,_]),de=W.start>0,fe=W.end<h.length;function pe(){return h.length?(0,$.jsxs)(g,{flexDirection:`column`,children:[de&&(0,$.jsx)(g,{marginLeft:2,children:(0,$.jsxs)(b,{dimColor:!0,children:[l.arrowUp,` `,W.start,` more above`]})}),h.slice(W.start,W.end).map((e,t)=>{let n=W.start+t,{name:r,schema:i,isRequired:a}=e,o=n===_&&!s,c=u[r],d=c!==void 0&&(!Array.isArray(c)||c.length>0),f=p[r],m=T.has(r)?(0,$.jsx)(cb,{}):f?(0,$.jsx)(b,{color:`error`,children:l.warning}):d?(0,$.jsx)(b,{color:`success`,dimColor:!o,children:l.tick}):a?(0,$.jsx)(b,{color:`error`,children:`*`}):(0,$.jsx)(b,{children:` `}),h=f?`error`:d?`success`:a?`error`:`suggestion`,v=o?h:void 0,x=(0,$.jsx)(b,{color:v,bold:o,children:i.title||r}),C,E=null;if(qy(i)){let e=Jy(i),t=c??[];if(O===r&&o)C=(0,$.jsx)(b,{dimColor:!0,children:l.triangleDownSmall}),E=(0,$.jsx)(g,{flexDirection:`column`,marginLeft:6,children:e.map((e,n)=>{let r=Xy(i,e),a=t.includes(e),o=n===A;return(0,$.jsxs)(g,{gap:1,children:[(0,$.jsx)(b,{color:`suggestion`,children:o?l.pointer:` `}),(0,$.jsx)(b,{color:a?`success`:void 0,children:a?l.checkboxOn:l.checkboxOff}),(0,$.jsx)(b,{color:o?`suggestion`:void 0,bold:o,children:r})]},e)})});else{let e=o?(0,$.jsxs)(b,{dimColor:!0,children:[l.triangleRightSmall,` `]}):null;C=t.length>0?(0,$.jsxs)(b,{children:[e,(0,$.jsx)(b,{color:v,bold:o,children:t.map(e=>Xy(i,e)).join(`, `)})]}):(0,$.jsxs)(b,{children:[e,(0,$.jsx)(b,{dimColor:!0,italic:!0,children:`not set`})]})}}else if(Ky(i)){let e=Zy(i);if(O===r&&o)C=(0,$.jsx)(b,{dimColor:!0,children:l.triangleDownSmall}),E=(0,$.jsx)(g,{flexDirection:`column`,marginLeft:6,children:e.map((e,t)=>{let n=$y(i,e),r=c===e,a=t===A;return(0,$.jsxs)(g,{gap:1,children:[(0,$.jsx)(b,{color:`suggestion`,children:a?l.pointer:` `}),(0,$.jsx)(b,{color:r?`success`:void 0,children:r?l.radioOn:l.radioOff}),(0,$.jsx)(b,{color:a?`suggestion`:void 0,bold:a,children:n})]},e)})});else{let e=o?(0,$.jsxs)(b,{dimColor:!0,children:[l.triangleRightSmall,` `]}):null;C=d?(0,$.jsxs)(b,{children:[e,(0,$.jsx)(b,{color:v,bold:o,children:$y(i,c)})]}):(0,$.jsxs)(b,{children:[e,(0,$.jsx)(b,{dimColor:!0,italic:!0,children:`not set`})]})}}else if(i.type===`boolean`)C=o?d?(0,$.jsx)(b,{color:v,bold:!0,children:c?l.checkboxOn:l.checkboxOff}):(0,$.jsx)(b,{dimColor:!0,children:l.checkboxOff}):d?(0,$.jsx)(b,{children:c?l.checkboxOn:l.checkboxOff}):(0,$.jsx)(b,{dimColor:!0,italic:!0,children:`not set`});else if(ib(i))if(o)C=(0,$.jsx)(yf,{value:y,onChange:V,onSubmit:ce,placeholder:`Type something…`,columns:Math.min(F-20,60),cursorOffset:S,onChangeCursorOffset:w,focus:!0,showCursor:!0});else{let e=d&&nb(i)?lb(String(c),i):String(c);C=d?(0,$.jsx)(b,{children:e}):(0,$.jsx)(b,{dimColor:!0,italic:!0,children:`not set`})}else C=d?(0,$.jsx)(b,{children:String(c)}):(0,$.jsx)(b,{dimColor:!0,italic:!0,children:`not set`});return(0,$.jsxs)(g,{flexDirection:`column`,children:[(0,$.jsxs)(g,{gap:1,children:[(0,$.jsx)(b,{color:h,children:o?l.pointer:` `}),m,(0,$.jsxs)(g,{children:[x,(0,$.jsx)(b,{color:v,children:`: `}),C]})]}),E,i.description&&(0,$.jsx)(g,{marginLeft:6,children:(0,$.jsx)(b,{dimColor:!0,children:i.description})}),(0,$.jsx)(g,{marginLeft:6,height:1,children:f?(0,$.jsx)(b,{color:`error`,italic:!0,children:f}):(0,$.jsx)(b,{children:` `})})]},r)}),fe&&(0,$.jsx)(g,{marginLeft:2,children:(0,$.jsxs)(b,{dimColor:!0,children:[l.arrowDown,` `,h.length-W.end,` more below`]})})]}):null}return(0,$.jsx)(ue,{title:`MCP server \u201c${n}\u201d requests your input`,subtitle:`\n${i}`,color:`permission`,onCancel:()=>t(`cancel`),isCancelActive:(!I||!!s)&&!O,inputGuide:e=>e.pending?(0,$.jsxs)(b,{children:[`Press `,e.keyName,` again to exit`]}):(0,$.jsxs)(C,{children:[(0,$.jsx)(Os,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),(0,$.jsx)(d,{shortcut:`↑↓`,action:`navigate`}),I&&(0,$.jsx)(d,{shortcut:`Backspace`,action:`unset`}),I&&I.schema.type===`boolean`&&(0,$.jsx)(d,{shortcut:`Space`,action:`toggle`}),I&&Ky(I.schema)&&(O?(0,$.jsx)(d,{shortcut:`Space`,action:`select`}):(0,$.jsx)(d,{shortcut:`→`,action:`expand`})),I&&qy(I.schema)&&(O?(0,$.jsx)(d,{shortcut:`Space`,action:`toggle`}):(0,$.jsx)(d,{shortcut:`→`,action:`expand`}))]}),children:(0,$.jsxs)(g,{flexDirection:`column`,children:[pe(),(0,$.jsxs)(g,{children:[(0,$.jsx)(b,{color:`success`,children:s===`accept`?l.pointer:` `}),(0,$.jsx)(b,{bold:s===`accept`,color:s===`accept`?`success`:void 0,dimColor:s!==`accept`,children:` Accept `}),(0,$.jsx)(b,{color:`error`,children:s===`decline`?l.pointer:` `}),(0,$.jsx)(b,{bold:s===`decline`,color:s===`decline`?`error`:void 0,dimColor:s!==`decline`,children:` Decline`})]})]})})}function fb({event:e,onResponse:t,onWaitingDismiss:n}){let{serverName:r,signal:i,waitingState:a}=e,{message:o,url:s}=e.params,[c,u]=(0,Q.useState)(`prompt`),f=(0,Q.useRef)(`prompt`),[p,m]=(0,Q.useState)(`accept`),h=a?.showCancel??!1;k_(`Work Mate needs your input`,`elicitation_url_dialog`),Lf(`elicitation-url`),f.current=c;let _=(0,Q.useRef)(n);_.current=n,(0,Q.useEffect)(()=>{let e=()=>{f.current===`waiting`?_.current?.(`cancel`):t(`cancel`)};if(i.aborted){e();return}return i.addEventListener(`abort`,e),()=>i.removeEventListener(`abort`,e)},[i,t]);let v=``,y=``,x=``;try{v=new URL(s).hostname;let e=s.indexOf(v);y=s.slice(0,e),x=s.slice(e+v.length)}catch{v=s}(0,Q.useEffect)(()=>{c===`waiting`&&e.completed&&n?.(h?`retry`:`dismiss`)},[c,e.completed,n,h]);let S=(0,Q.useCallback)(()=>{Va(s),t(`accept`),u(`waiting`),f.current=`waiting`,m(`open`)},[t,s]);if(ne((e,r)=>{if(c===`prompt`){if(r.leftArrow||r.rightArrow){m(e=>e===`accept`?`decline`:`accept`);return}r.return&&(p===`accept`?S():t(`decline`))}else{let e=h?[`open`,`action`,`cancel`]:[`open`,`action`];if(r.leftArrow||r.rightArrow){m(t=>{let n=e.indexOf(t),i=r.rightArrow?1:-1;return e[(n+i+e.length)%e.length]});return}r.return&&(p===`open`?Va(s):p===`cancel`?n?.(`cancel`):n?.(h?`retry`:`dismiss`))}}),c===`waiting`){let e=a?.actionLabel??`Continue without waiting`;return(0,$.jsx)(ue,{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)(b,{children:[`Press `,e.keyName,` again to exit`]}):(0,$.jsxs)(C,{children:[(0,$.jsx)(Os,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),(0,$.jsx)(d,{shortcut:`\\u2190\\u2192`,action:`switch`})]}),children:(0,$.jsxs)(g,{flexDirection:`column`,children:[(0,$.jsx)(g,{marginBottom:1,flexDirection:`column`,children:(0,$.jsxs)(b,{children:[y,(0,$.jsx)(b,{bold:!0,children:v}),x]})}),(0,$.jsx)(g,{marginBottom:1,children:(0,$.jsx)(b,{dimColor:!0,italic:!0,children:`Waiting for the server to confirm completion…`})}),(0,$.jsxs)(g,{children:[(0,$.jsx)(b,{color:`success`,children:p===`open`?l.pointer:` `}),(0,$.jsx)(b,{bold:p===`open`,color:p===`open`?`success`:void 0,dimColor:p!==`open`,children:` Reopen URL `}),(0,$.jsx)(b,{color:`success`,children:p===`action`?l.pointer:` `}),(0,$.jsx)(b,{bold:p===`action`,color:p===`action`?`success`:void 0,dimColor:p!==`action`,children:` ${e}`}),h&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(b,{children:` `}),(0,$.jsx)(b,{color:`error`,children:p===`cancel`?l.pointer:` `}),(0,$.jsx)(b,{bold:p===`cancel`,color:p===`cancel`?`error`:void 0,dimColor:p!==`cancel`,children:` Cancel`})]})]})]})})}return(0,$.jsx)(ue,{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)(b,{children:[`Press `,e.keyName,` again to exit`]}):(0,$.jsxs)(C,{children:[(0,$.jsx)(Os,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),(0,$.jsx)(d,{shortcut:`\\u2190\\u2192`,action:`switch`})]}),children:(0,$.jsxs)(g,{flexDirection:`column`,children:[(0,$.jsx)(g,{marginBottom:1,flexDirection:`column`,children:(0,$.jsxs)(b,{children:[y,(0,$.jsx)(b,{bold:!0,children:v}),x]})}),(0,$.jsxs)(g,{children:[(0,$.jsx)(b,{color:`success`,children:p===`accept`?l.pointer:` `}),(0,$.jsx)(b,{bold:p===`accept`,color:p===`accept`?`success`:void 0,dimColor:p!==`accept`,children:` Accept `}),(0,$.jsx)(b,{color:`error`,children:p===`decline`?l.pointer:` `}),(0,$.jsx)(b,{bold:p===`decline`,color:p===`decline`?`error`:void 0,dimColor:p!==`decline`,children:` Decline`})]})]})})}V(),Oc(),np(),Tm();function pb({title:e,toolInputSummary:t,request:n,onRespond:r,onAbort:i}){E(`app:interrupt`,i,{isActive:!0});let a=n.options.map(e=>({label:e.label,value:e.key,description:e.description}));return(0,$.jsx)(Dm,{title:e,subtitle:n.message,titleRight:t?(0,$.jsx)(b,{dimColor:!0,children:t}):void 0,children:(0,$.jsx)(g,{flexDirection:`column`,paddingY:1,children:(0,$.jsx)(rp,{options:a,onChange:e=>{r(e)}})})})}function mb(){return(0,Q.useSyncExternalStore)(jn,Kt)}Kp(),bm(),Sm(),Wm();function hb(){let[e,t]=(0,Q.useState)({...An});return(0,Q.useEffect)(()=>{let e=e=>{t({...e})};return El.add(e),()=>{El.delete(e)}},[]),e}function gb(){return(0,Q.useSyncExternalStore)(bi.subscribe,bi.getState)}V(),Ls();function _b({tokenUsage:e,model:t}){let{percentLeft:n,isAboveWarningThreshold:r,isAboveErrorThreshold:i}=ft(e,t),a=gb();if(!r||a)return null;let o=Mc(),s=Ac(`warning`),c=`${n}% until auto-compact`;return(0,$.jsx)(g,{flexDirection:`row`,children:o?(0,$.jsx)(b,{dimColor:!0,wrap:`truncate`,children:s?`${c} \u00b7 ${s}`:c}):(0,$.jsx)(b,{color:i?`error`:`warning`,wrap:`truncate`,children:s?`Context low (${n}% remaining) \u00b7 ${s}`:`Context low (${n}% remaining) \u00b7 Run /compact to compact & continue`})})}V(),vc();function vb(){let[e,t]=(0,Q.useState)(0),n=(0,Q.useRef)(null),r=mc(`app:toggleTranscript`,`Global`,`ctrl+o`);return(0,Q.useEffect)(()=>{if(!Ea.isSandboxingEnabled())return;let e=Ea.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)}},[]),!Ea.isSandboxingEnabled()||e===0?null:(0,$.jsx)(g,{paddingX:0,paddingY:0,children:(0,$.jsxs)(b,{color:`inactive`,wrap:`truncate`,children:[`⧈ Sandbox blocked `,e,` `,e===1?`operation`:`operations`,` ·`,` `,r,` for details · /sandbox to disable`]})})}Cf(),Zu(),Y(),V(),po(),zp(),In(),zo();var yb=5e3;function bb({apiKeyStatus:e,autoUpdaterResult:t,debug:n,isAutoUpdating:r,verbose:i,messages:a,onAutoUpdaterResult:o,onChangeIsUpdating:s,mcpClients:c,isInputWrapped:l=!1,isNarrow:u=!1}){let d=(0,Q.useMemo)(()=>Do(ri(a)),[a]),f=Gp(),p=ft(d,f).isAboveWarningThreshold,m=G(e=>e.notifications),{addNotification:h,removeNotification:_}=Sf(),v=hb();(0,Q.useEffect)(()=>(us((e,t)=>{h({key:`env-hook`,text:e,color:t?`error`:void 0,priority:t?`medium`:`low`,timeoutMs:t?8e3:5e3})}),()=>us(null)),[h]);let y=v.isUsingOverage,x=Bp(),S=l&&!p&&e!==`invalid`&&e!==`missing`&&x!==void 0;return(0,Q.useEffect)(()=>{S&&x?h({key:`external-editor-hint`,jsx:(0,$.jsx)(b,{dimColor:!0,children:(0,$.jsx)(Os,{action:`chat:externalEditor`,context:`Chat`,fallback:`ctrl+g`,description:`edit in ${x}`})}),priority:`immediate`,timeoutMs:5e3}):_(`external-editor-hint`)},[S,x,h,_]),(0,$.jsx)(g,{flexDirection:`column`,alignItems:u?`flex-start`:`flex-end`,flexShrink:0,overflowX:`hidden`,children:(0,$.jsx)(xb,{notifications:m,isInOverageMode:y??!1,apiKeyStatus:e,debug:n,verbose:i,tokenUsage:d,mainLoopModel:f})})}function xb({notifications:e,isInOverageMode:t,apiKeyStatus:n,debug:r,verbose:a,tokenUsage:o,mainLoopModel:s}){return(0,$.jsxs)($.Fragment,{children:[e.current&&(`jsx`in e.current?(0,$.jsx)(b,{wrap:`truncate`,children:e.current.jsx},e.current.key):(0,$.jsx)(b,{color:e.current.color,dimColor:!e.current.color,wrap:`truncate`,children:e.current.text})),t&&(0,$.jsx)(g,{children:(0,$.jsx)(b,{dimColor:!0,wrap:`truncate`,children:`Now using extra usage`})}),(n===`invalid`||n===`missing`)&&(0,$.jsx)(g,{children:(0,$.jsx)(b,{color:`error`,wrap:`truncate`,children:i(process.env.WORKMATE_REMOTE)?`Authentication error · Try again`:`Not logged in`})}),r&&(0,$.jsx)(g,{children:(0,$.jsx)(b,{color:`warning`,wrap:`truncate`,children:`Debug mode`})}),n!==`invalid`&&n!==`missing`&&a&&(0,$.jsx)(g,{children:(0,$.jsxs)(b,{dimColor:!0,wrap:`truncate`,children:[o,` tokens`]})}),(0,$.jsx)(_b,{tokenUsage:o,model:s}),(0,$.jsx)(vb,{})]})}Cf(),zo(),V();var Sb=10,Cb=null,wb=0,Tb;async function Eb(e,t){let n=Math.ceil(e/Sb)*Sb;if(Cb&&wb>=n&&Tb===t)return Cb;Cb&&await Cb,wb=n,Tb=t,Cb=(async()=>{let e=[],n=0;for await(let r of Ef())if(!(t&&xf(r.display)!==t)&&(e.push(r),n++,n>=wb))break;return e})();try{return await Cb}finally{Cb=null,wb=0,Tb=void 0}}function Db(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}=Sf(),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]),x=(0,Q.useCallback)((e,t=!1)=>{if(!e?.display)return;let n=xf(e.display),r=n===`bash`?e.display.slice(1):e.display;y(r,n,e.pastedContents??{},t)},[y]),S=(0,Q.useCallback)(()=>{u({key:`search-history-hint`,jsx:(0,$.jsx)(b,{dimColor:!0,children:(0,$.jsx)(Os,{action:`history:search`,context:`Global`,fallback:`ctrl+r`,description:`search history`})}),priority:`immediate`,timeoutMs:yb})},[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 Eb(t,i);e.length>f.current.length&&(f.current=e)}if(e>=f.current.length){m.current--;return}let n=e+1;o(n),x(f.current[e],!0),n>=2&&!l.current&&(l.current=!0,S())})()},[x,S]),onHistoryDown:(0,Q.useCallback)(()=>{let e=m.current;if(e>1)m.current--,o(e-1),x(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??{}):x(s)}else y(``,h.current??`prompt`,{});return e<=0},[s,x,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])}}Y();function Ob(){let e=G(e=>e.tasks);return(0,Q.useMemo)(()=>{let t=Date.now();return Object.values(e).filter(Ms).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])}ef(),Nf(),V(),Oc();function kb(e,t,n,r,i,a,o,s,c,l,u){let[d,f]=(0,Q.useState)(``),[p,h]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(``),[v,y]=(0,Q.useState)(0),[b,x]=(0,Q.useState)(`prompt`),[S,C]=(0,Q.useState)({}),[w,D]=(0,Q.useState)(void 0),O=(0,Q.useRef)(void 0),k=(0,Q.useRef)(new Set),A=(0,Q.useRef)(null),j=(0,Q.useCallback)(()=>{O.current&&(O.current.return(void 0),O.current=void 0)},[]),M=(0,Q.useCallback)(()=>{c(!1),f(``),h(!1),_(``),y(0),x(`prompt`),C({}),D(void 0),j(),k.current.clear()},[c,j]),N=(0,Q.useCallback)(async(e,t)=>{if(s){if(d.length===0){j(),k.current.clear(),D(void 0),h(!1),n(g),r(v),a(b),l(S);return}if(e||(j(),O.current=Df(),k.current.clear()),O.current)for(;;){if(t?.aborted)return;let e=await O.current.next();if(e.done){h(!0);return}let i=e.value.display,o=i.lastIndexOf(d);if(o!==-1&&!k.current.has(i)){k.current.add(i),D(e.value),h(!1),a(xf(i)),n(i),l(e.value.pastedContents);let t=af(i).lastIndexOf(d);r(t===-1?o:t);return}}}},[s,d,j,n,r,a,l,g,v,b,S]),P=(0,Q.useCallback)(()=>{c(!0),_(t),y(i),x(o),C(u),O.current=Df(),k.current.clear()},[c,t,i,o,u]),F=(0,Q.useCallback)(()=>{N(!0)},[N]),ee=(0,Q.useCallback)(()=>{if(w){let e=xf(w.display);n(af(w.display)),a(e),l(w.pastedContents)}else l(S);M()},[w,n,a,l,S,M]),I=(0,Q.useCallback)(()=>{n(g),r(v),l(S),M()},[n,r,l,g,v,S,M]),L=(0,Q.useCallback)(()=>{if(d.length===0)e({display:g,pastedContents:S});else if(w){let t=xf(w.display),n=af(w.display);a(t),e({display:n,pastedContents:w.pastedContents})}M()},[d,w,e,a,g,S,M]);E(`history:search`,P,{context:`Global`,isActive:!s}),m((0,Q.useMemo)(()=>({"historySearch:next":F,"historySearch:accept":ee,"historySearch:cancel":I,"historySearch:execute":L}),[F,ee,I,L]),{context:`HistorySearch`,isActive:s});let te=e=>{s&&e.key===`backspace`&&d===``&&(e.preventDefault(),I())};ne((e,t,n)=>{te(new T(n.keypress))},{isActive:s});let R=(0,Q.useRef)(N);return R.current=N,(0,Q.useEffect)(()=>{A.current?.abort();let e=new AbortController;return A.current=e,R.current(!1,e.signal),()=>{e.abort()}},[d]),{historyQuery:d,setHistoryQuery:f,historyMatch:w,historyFailedMatch:p,handleKeyDown:te}}function Ab({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}}V(),Zu(),Y();function jb({inputValue:e,isAssistantResponding:t}){let n=G(e=>e.promptSuggestion),r=vn(),i=D(),{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)(()=>{Ca(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();({...l&&{generationRequestId:l},...r&&{acceptMethod:n?`tab`:`enter`},...r&&{timeToAcceptMs:i-s},...!r&&{timeToIgnoreMs:i-s},...f.current>0&&{timeToFirstKeystrokeMs:f.current-s}}),p.current,Math.round(e.length/(a?.length||1)*100)/100,t?.skipReset||h()},[d,c,s,a,o,l,h])}}Ln(),Gl(),$p();var Mb=15,Nb=1e3,Pb=[`|`,`||`,`&&`,`;`];function Fb(e){return typeof e==`object`&&!!e&&`op`in e&&Pb.includes(e.op)}function Ib(e){return e.startsWith(`$`)?`variable`:e.includes(`/`)||e.startsWith(`~`)||e.startsWith(`.`)?`file`:`command`}function Lb(e){let t=e.findLastIndex(e=>typeof e==`string`);return t===-1?null:{token:e[t],index:t}}function Rb(e,t){if(t===0)return!0;let n=e[t-1];return n!==void 0&&Fb(n)}function zb(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=Jt(n);if(!i.success){let e=n.split(/\s+/),t=e[e.length-1]||``;return{prefix:t,completionType:e.length===1&&!n.includes(` `)?`command`:Ib(t)}}let a=Lb(i.tokens);if(!a){let e=i.tokens[i.tokens.length-1];return{prefix:``,completionType:(e&&Fb(e),`command`)}}if(n.endsWith(` `))return{prefix:``,completionType:`file`};let o=Ib(a.token);if(o===`variable`||o===`file`)return{prefix:a.token,completionType:o};let s=Rb(i.tokens,a.index)?`command`:`file`;return{prefix:a.token,completionType:s}}function Bb(e,t){return t===`variable`?`compgen -v ${pi([e.slice(1)])} 2>/dev/null`:t===`file`?`compgen -f ${pi([e])} 2>/dev/null | head -${Mb} | while IFS= read -r f; do [ -d "$f" ] && echo "$f/" || echo "$f "; done`:`compgen -c ${pi([e])} 2>/dev/null`}function Vb(e,t){return t===`variable`?`print -rl -- \${(k)parameters[(I)${pi([e.slice(1)])}*]} 2>/dev/null`:t===`file`?`for f in ${pi([e])}*(N[1,${Mb}]); do [[ -d "$f" ]] && echo "$f/" || echo "$f "; done`:`print -rl -- \${(k)commands[(I)${pi([e])}*]} 2>/dev/null`}async function Hb(e,t,n,r){let i;if(e===`bash`)i=Bb(t,n);else if(e===`zsh`)i=Vb(t,n);else return[];return(await(await fl(i,r,`bash`,{timeout:Nb})).result).stdout.split(`
36
+ `).filter(e=>e.trim()).slice(0,Mb).map(e=>({id:e,displayText:e,description:void 0,metadata:{completionType:n}}))}async function Ub(e,t,n){let r=em();if(r!==`bash`&&r!==`zsh`)return[];try{let{prefix:i,completionType:a}=zb(e,t);return i?(await Hb(r,i,a,n)).map(t=>({...t,metadata:{...t.metadata,inputSnapshot:e}})):[]}catch(e){return X(`Shell completion failed: ${e}`),[]}}Xg();var Wb=/[:_-]/g,Gb=null;function Kb(e){if(Gb?.commands===e)return Gb.fuse;let t=new Yg(e.filter(e=>!e.isHidden).map(e=>{let t=_r(e),n=t.split(Wb).filter(Boolean);return{descriptionKey:(e.description??``).split(` `).map(e=>ix(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 Gb={commands:e,fuse:t},t}function qb(e){return typeof e==`object`&&!!e&&`name`in e&&typeof e.name==`string`&&`type`in e}function Jb(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 Yb(e,t){if(!e)return null;let n=nx(`/${e}`,t);if(n.length===0)return null;let r=e.toLowerCase();for(let t of n){if(!qb(t.metadata))continue;let n=_r(t.metadata);if(n.toLowerCase().startsWith(r)){let t=n.slice(e.length);if(t)return{suffix:t,fullCommand:n}}}return null}function Xb(e){return e.startsWith(`/`)}function Zb(e){return!(!Xb(e)||!e.includes(` `)||e.endsWith(` `))}function Qb(e){return`/${e} `}function $b(e){let t=_r(e);return e.type===`prompt`?e.source===`plugin`&&e.pluginInfo?.repository?`${t}:${e.source}:${e.pluginInfo.repository}`:`${t}:${e.source}`:`${t}:${e.type}`}function ex(e,t){if(!(!t||t.length===0||e===``))return t.find(t=>t.toLowerCase().startsWith(e))}function tx(e,t){let n=_r(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:hi(e))+(e.type===`prompt`&&e.argNames?.length?` (arguments: ${e.argNames.join(`, `)})`:``);return{id:$b(e),displayText:`/${n}${r}`,tag:i?`workflow`:a,description:o,metadata:e}}function nx(e,t){if(!Xb(e)||Zb(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:dt(_r(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=>$b(e))),a=[],o=[],s=[],c=[],l=[];e.forEach(e=>{i.has($b(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)=>_r(e).localeCompare(_r(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=>tx(e))}let r=t.find(e=>e.isHidden&&_r(e).toLowerCase()===n);r&&t.some(e=>!e.isHidden&&_r(e).toLowerCase()===n)&&(r=void 0);let i=Kb(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`?dt(_r(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 tx(t,ex(n,t.aliases))});if(r){let e=$b(r);if(!i.some(t=>t.id===e))return[tx(r),...i]}return i}function rx(e,t,n,r,i,a){let o,s;if(typeof e==`string`)o=e,s=t?Zt(o,n):void 0;else{if(!qb(e.metadata))return;o=_r(e.metadata),s=e.metadata}let c=Qb(o);r(c),i(c.length),t&&s&&(s.type!==`prompt`||(s.argNames??[]).length===0)&&a(c,!0)}function ix(e){return e.toLowerCase().replace(/[^a-z0-9]/g,``)}function ax(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}Np(),Nf(),Gl();var ox=null,sx=0,cx=6e4;async function lx(){let e=Date.now();if(ox&&e-sx<cx)return ox;let t=[],n=new Set;try{for await(let e of Ef()){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){X(`Failed to read shell history: ${e}`)}return ox=t,sx=e,t}function ux(e){if(!ox)return;let t=ox.indexOf(e);t!==-1&&ox.splice(t,1),ox.unshift(e)}async function dx(e){if(!e||e.length<2||!e.trim())return null;let t=await lx();for(let n of t)if(n.startsWith(e)&&n!==e)return{fullCommand:n,suffix:n.slice(e.length)};return null}Hd(),Gl(),Ce(),je(),ql();var fx=`slack_search_channels`,px=new Map,mx=new Set,hx=0,gx=De(),_x=gx.subscribe,vx=null,yx=null;function bx(e){return e.find(e=>e.type===`connected`&&e.name.includes(`slack`))}async function xx(e,t){let n=bx(e);if(n?.type!==`connected`)return[];try{let e=(await n.client.callTool({name:fx,arguments:{query:t,limit:20,channel_types:`public_channel,private_channel`}},void 0,{timeout:5e3})).content;return Array.isArray(e)?wx(Cx(e.filter(e=>e.type===`text`).map(e=>e.text).join(`
37
+ `))):[]}catch(e){return X(`Failed to fetch Slack channels: ${e}`),[]}}var Sx=we(()=>he({results:ge()}));function Cx(e){let t=e.trim();if(!t.startsWith(`{`))return e;try{let e=Sx().safeParse(zl(t));if(e.success)return e.data.results}catch{}return e}function wx(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 Tx(e){return bx(e)!==void 0}function Ex(){return hx}function Dx(e){let t=[],n=/(^|\s)#([a-z0-9][a-z0-9_-]{0,79})(?=\s|$)/g,r;for(;(r=n.exec(e))!==null;){if(!mx.has(r[2]))continue;let e=r.index+r[1].length;t.push({start:e,end:e+1+r[2].length})}return t}function Ox(e){let t=Math.max(e.lastIndexOf(`-`),e.lastIndexOf(`_`));return t>0?e.slice(0,t):e}function kx(e,t){let n,r=0;for(let[i,a]of px)e.startsWith(i)&&i.length>r&&a.some(e=>e.startsWith(t))&&(n=a,r=i.length);return n}async function Ax(e,t){if(!t)return[];let n=Ox(t),r=t.toLowerCase(),i=px.get(n)??kx(n,r);if(!i)if(vx===n&&yx)i=await yx;else{vx=n,yx=xx(e,n),i=await yx,px.set(n,i);let t=mx.size;for(let e of i)mx.add(e);mx.size!==t&&(hx++,gx.emit()),px.size>50&&px.delete(px.keys().next().value),vx===n&&(vx=null,yx=null)}return i.filter(e=>e.startsWith(r)).sort().slice(0,10).map(e=>({id:`slack-channel-${e}`,displayText:`#${e}`}))}Xg(),qp(),ci(),rd(),Bu();function jx(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 Mx=15,Nx=60;function Px(e){return nd(e,Nx)}function Fx(e,t,n=!1){if(!t&&!n)return[];try{let n=e.map(e=>({type:`agent`,displayText:`${e.agentType} (agent)`,description:Px(e.whenToUse),agentType:e.agentType,color:ol(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 Hu(e),[]}}async function Ix(e,t,n,r=!1){if(!e&&!r)return[];let[i,a]=await Promise.all([Jp(e,r),Promise.resolve(Fx(n,e,r))]),o=i.map(e=>({type:`file`,displayText:e.displayText,description:e.description,path:e.displayText,filename:ch(e.displayText),score:e.metadata?.score})),s=Object.values(t).flat().map(e=>({type:`mcp_resource`,displayText:`${e.server}:${e.uri}`,description:Px(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,Mx).map(jx);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 Yg(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:Mx});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,Mx).map(e=>e.source).map(jx)}Cf(),V(),Zu(),sr(),ef(),Bf(),Jo(),Oc(),Fs(),Y(),rd(),Fo(),qp();var Lx=/^@[\p{L}\p{N}\p{M}_\-./\\()[\]~:]*/u,Rx=/^[\p{L}\p{N}\p{M}_\-./\\()[\]~:]+/u,zx=/(@[\p{L}\p{N}\p{M}_\-./\\()[\]~:]*|[\p{L}\p{N}\p{M}_\-./\\()[\]~:]+)$/u,Bx=/[\p{L}\p{N}\p{M}_\-./\\()[\]~:]+$/u,Vx=/(^|\s)@([\p{L}\p{N}\p{M}_\-./\\()[\]~:]*|"[^"]*"?)$/u,Hx=/(^|\s)#([a-z0-9][a-z0-9_-]*)$/;function Ux(e){return typeof e==`object`&&!!e&&`type`in e&&(e.type===`directory`||e.type===`file`)}function Wx(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 Gx(e){let t=e.metadata;return t?.sessionId?`/resume ${t.sessionId}`:`/resume ${e.displayText}`}function Kx(e){return e.isQuoted?e.token.slice(2).replace(/"$/,``):e.token.startsWith(`@`)?e.token.substring(1):e.token}function qx(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 Jx(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 Yx=/(^|\s)@[\w-]*$/;function Xx(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 Zx=null;async function Qx(e,t){try{return Zx&&Zx.abort(),Zx=new AbortController,await Ub(e,t,Zx.signal)}catch{return[]}}function $x(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 eS(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(Lx);if(a&&a[0].length===i.length){let r=e.substring(t).match(Rx),i=r?r[0]:``;return{token:a[0]+i,startPos:n,isQuoted:!1}}}}let i=n?zx:Bx,a=r.match(i);if(!a||a.index===void 0)return null;let o=e.substring(t).match(Rx),s=o?o[0]:``;return{token:a[0]+s,startPos:a.index,isQuoted:!1}}function tS(e){if(Xb(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 nS(e,t){return!e&&t.includes(` `)&&!t.endsWith(` `)}function rS({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:h}){let{addNotification:g}=Sf(),_=mc(`chat:thinkingToggle`,`Chat`,`alt+t`),[v,y]=(0,Q.useState)(`none`),x=(0,Q.useMemo)(()=>{let t=e.filter(e=>!e.isHidden);if(t.length!==0)return Math.max(...t.map(e=>{let t=_r(e);return t?t.length:0}))+6},[e]),[S,C]=(0,Q.useState)(void 0),w=G(e=>e.mcp.resources),E=Oi(),D=G(e=>e.promptSuggestion),k=G(e=>!!e.viewingAgentTaskId),j=A(),[M,N]=(0,Q.useState)(void 0),P=(0,Q.useMemo)(()=>{if(o!==`prompt`||f)return;let t=Jb(i,a);if(!t)return;let n=Yb(t.partialCommand,e);if(n)return{text:n.suffix,fullCommand:n.fullCommand,insertPosition:t.startPos+1+t.partialCommand.length}},[i,a,o,e,f]),F=f?void 0:o===`prompt`?P:M,ee=(0,Q.useRef)(a);ee.current=a;let I=(0,Q.useRef)(null),L=(0,Q.useRef)(``),te=(0,Q.useRef)(``),R=(0,Q.useRef)(``),z=(0,Q.useRef)(``),re=(0,Q.useRef)(l);re.current=l;let ie=(0,Q.useRef)(null),B=(0,Q.useCallback)(()=>{c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),y(`none`),C(void 0),N(void 0)},[c]),ae=(0,Q.useCallback)(async(e,t=!1)=>{I.current=e;let n=await Ix(e,w,s,t);if(I.current===e){if(n.length===0){c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),y(`none`),C(void 0);return}c(e=>({commandArgumentHint:void 0,suggestions:n,selectedSuggestion:Wx(e.suggestions,e.selectedSuggestion,n)})),y(n.length>0?`file`:`none`),C(void 0)}},[w,c,y,C,s]);(0,Q.useEffect)(()=>(Zp(),Yp(()=>{let e=I.current;e!==null&&(I.current=null,ae(e,e===``))})),[ae]);let oe=U(ae,50),se=U((0,Q.useCallback)(async e=>{z.current=e;let t=await Ax(E.getState().mcp.clients,e);z.current===e&&(c(e=>({commandArgumentHint:void 0,suggestions:t,selectedSuggestion:Wx(e.suggestions,e.selectedSuggestion,t)})),y(t.length>0?`slack-channel`:`none`),C(void 0))},[c]),150),V=(0,Q.useCallback)(async(t,n)=>{let r=n??ee.current;if(f){oe.cancel(),B();return}if(o===`prompt`){let n=Jb(t,r);if(n&&Yb(n.partialCommand,e)){c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),y(`none`),C(void 0);return}}if(o===`bash`&&t.trim()){R.current=t;let e=await dx(t);if(R.current!==t)return;if(e){N({text:e.suffix,fullCommand:e.fullCommand,insertPosition:t.length}),c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),y(`none`),C(void 0);return}else N(void 0)}let i=o===`bash`?null:t.substring(0,r).match(/(^|\s)@([\w-]*)$/);if(i){let e=(i[2]??``).toLowerCase(),t=E.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){oe.cancel(),c(e=>({commandArgumentHint:void 0,suggestions:n,selectedSuggestion:Wx(e.suggestions,e.selectedSuggestion,n)})),y(`agent`),C(void 0);return}}if(o===`prompt`){let e=t.substring(0,r).match(Hx);if(e&&Tx(E.getState().mcp.clients)){se(e[2]);return}else v===`slack-channel`&&(se.cancel(),B())}let a=t.substring(0,r).match(Vx),s=r===t.length&&r>0&&t.length>0&&t[r-1]===` `;if(o===`prompt`&&Xb(t)&&r>0){let e=tS(t);if(e&&e.commandName===`add-dir`&&e.args){let{args:t}=e;if(t.match(/\s+$/)){oe.cancel(),B();return}let n=await Pp(t);if(n.length>0){c(e=>({suggestions:n,selectedSuggestion:Wx(e.suggestions,e.selectedSuggestion,n),commandArgumentHint:void 0})),y(`directory`);return}oe.cancel(),B();return}if(e&&e.commandName===`resume`&&e.args!==void 0&&t.includes(` `)){let{args:t}=e,n=(await Ws(t,{limit:10})).map(e=>{let t=ws(e);return{id:`resume-title-${t}`,displayText:e.customTitle,description:id(e),metadata:{sessionId:t}}});if(n.length>0){c(e=>({suggestions:n,selectedSuggestion:Wx(e.suggestions,e.selectedSuggestion,n),commandArgumentHint:void 0})),y(`custom-title`);return}B();return}}let l=t.substring(0,r);if(o===`prompt`&&Xb(l)&&r>0&&!nS(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=_r(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=ea(l.slice(n+1));t=lc(o.argNames,e)}c(()=>({commandArgumentHint:t,suggestions:[],selectedSuggestion:-1})),y(`none`),C(void 0);return}}}let n=nx(l,e);c(()=>({commandArgumentHint:t,suggestions:n,selectedSuggestion:n.length>0?0:-1})),y(n.length>0?`command`:`none`),n.length>0&&C(x);return}if(v===`command`?(oe.cancel(),B()):Xb(l)&&nS(s,l)&&c(e=>e.commandArgumentHint?{...e,commandArgumentHint:void 0}:e),v===`custom-title`&&B(),v===`agent`&&re.current.some(e=>e.id?.startsWith(`dm-`))&&(t.substring(0,r).match(/(^|\s)@([\w-]*)$/)||B()),a&&o!==`bash`){let e=eS(t,r,!0);if(e?.token.startsWith(`@`)){let t=Kx(e);if(jp(t)){te.current=t;let e=await Mp(t,{maxResults:10});if(te.current!==t)return;if(e.length>0){c(t=>({suggestions:e,selectedSuggestion:Wx(t.suggestions,t.selectedSuggestion,e),commandArgumentHint:void 0})),y(`directory`);return}}if(I.current===t)return;oe(t,!0);return}}if(v===`file`){let e=eS(t,r,!0);if(e){let t=Kx(e);if(I.current===t)return;oe(t,!1)}else oe.cancel(),B()}if(v===`shell`){let e=re.current[0]?.metadata?.inputSnapshot;(o!==`bash`||t!==e)&&(oe.cancel(),B())}},[v,e,c,B,oe,se,o,f,x]);(0,Q.useEffect)(()=>{ie.current!==i&&(L.current!==i&&(L.current=i,I.current=null),ie.current=null,V(i))},[i,V]);let ce=(0,Q.useCallback)(async()=>{if(F){if(o===`bash`){t(F.fullCommand),r(F.fullCommand.length),N(void 0);return}let e=Jb(i,a);if(e){let n=i.slice(0,e.startPos),a=i.slice(e.startPos+e.token.length),o=`${n}/${F.fullCommand} ${a}`,s=e.startPos+1+F.fullCommand.length+1;t(o),r(s);return}}if(l.length>0){oe.cancel(),se.cancel();let e=u===-1?0:u,n=l[e];if(v===`command`&&e<l.length){if(n){let e=n.metadata;if(e&&typeof e==`object`&&`name`in e&&`type`in e){let n=`/${_r(e)} `;t(n+i.slice(a)),r(n.length)}B()}}else if(v===`custom-title`&&l.length>0){if(n){let e=Gx(n);t(e),r(e.length),B()}}else if(v===`directory`&&l.length>0){let n=l[e];if(n){let e=Xb(i),o;if(e){let e=i.indexOf(` `),a=i.slice(0,e+1),s=Ux(n.metadata)&&n.metadata.type===`directory`?`/`:` `;o=a+n.id+s,t(o),r(o.length),Ux(n.metadata)&&n.metadata.type===`directory`?(c(e=>({...e,commandArgumentHint:void 0})),V(o,o.length)):B()}else{let e=eS(i,a,!0)??eS(i,a,!1);if(e){let a=Ux(n.metadata)&&n.metadata.type===`directory`,s=$x(i,n.id,e.startPos,e.token.length,a);o=s.newInput,t(o),r(s.cursorPos),a?(c(e=>({...e,commandArgumentHint:void 0})),V(o,s.cursorPos)):B()}else B()}}}else if(v===`shell`&&l.length>0){let n=l[e];if(n){let e=n.metadata;Jx(n,i,a,t,r,e?.completionType),B()}}else if(v===`agent`&&l.length>0&&l[e]?.id?.startsWith(`dm-`)){let n=l[e];n&&(Xx(n,i,a,Yx,t,r),B())}else if(v===`slack-channel`&&l.length>0){let n=l[e];n&&(Xx(n,i,a,Hx,t,r),B())}else if(v===`file`&&l.length>0){let n=eS(i,a,!0);if(!n){B();return}let s=Xp(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=qx({displayText:s,mode:o,hasAtPrefix:c,needsQuotes:!1,isQuoted:n.isQuoted,isComplete:!1});Qp(e,i,n.token,n.startPos,t,r),V(i.replace(n.token,e),a)}else if(e<l.length){let a=l[e];if(a){let e=a.displayText.includes(` `);Qp(qx({displayText:a.displayText,mode:o,hasAtPrefix:c,needsQuotes:e,isQuoted:n.isQuoted,isComplete:!0}),i,n.token,n.startPos,t,r),B()}}}}else if(i.trim()!==``){let e,n;if(o===`bash`){e=`shell`;let o=await Qx(i,a);if(o.length===1){let e=o[0];if(e){let n=e.metadata;Jx(e,i,a,t,r,n?.completionType)}n=[]}else n=o}else{e=`file`;let t=eS(i,a,!0);if(t){let e=t.token.startsWith(`@`);n=await Ix(e?t.token.substring(1):t.token,w,s,e)}else n=[]}n.length>0&&(c(e=>({commandArgumentHint:void 0,suggestions:n,selectedSuggestion:Wx(e.suggestions,e.selectedSuggestion,n)})),y(e),C(void 0))}},[l,u,i,v,e,o,t,r,n,B,a,V,w,c,s,oe,se,F]),le=(0,Q.useCallback)(()=>{if(u<0||l.length===0)return;let s=l[u];if(v===`command`&&u<l.length)s&&(rx(s,!0,e,t,r,n),oe.cancel(),B());else if(v===`custom-title`&&u<l.length){if(s){let e=Gx(s);t(e),r(e.length),n(e,!0),oe.cancel(),B()}}else if(v===`shell`&&u<l.length){let e=l[u];if(e){let n=e.metadata;Jx(e,i,a,t,r,n?.completionType),oe.cancel(),B()}}else if(v===`agent`&&u<l.length&&s?.id?.startsWith(`dm-`))Xx(s,i,a,Yx,t,r),oe.cancel(),B();else if(v===`slack-channel`&&u<l.length)s&&(Xx(s,i,a,Hx,t,r),se.cancel(),B());else if(v===`file`&&u<l.length){let e=eS(i,a,!0);if(e&&s){let n=e.token.startsWith(`@`),a=s.displayText.includes(` `);Qp(qx({displayText:s.displayText,mode:o,hasAtPrefix:n,needsQuotes:a,isQuoted:e.isQuoted,isComplete:!0}),i,e.token,e.startPos,t,r),oe.cancel(),B()}}else if(v===`directory`&&u<l.length&&s){if(Xb(i)){oe.cancel(),B();return}let e=eS(i,a,!0)??eS(i,a,!1);if(e){let n=Ux(s.metadata)&&s.metadata.type===`directory`,a=$x(i,s.id,e.startPos,e.token.length,n);t(a.newInput),r(a.cursorPos)}oe.cancel(),B()}},[l,u,v,e,i,a,o,t,r,n,B,oe,se]),H=(0,Q.useCallback)(()=>{ce()},[ce]),ue=(0,Q.useCallback)(()=>{oe.cancel(),se.cancel(),B(),ie.current=i},[oe,se,B,i]),W=(0,Q.useCallback)(()=>{c(e=>({...e,selectedSuggestion:e.selectedSuggestion<=0?l.length-1:e.selectedSuggestion-1}))},[l.length,c]),de=(0,Q.useCallback)(()=>{c(e=>({...e,selectedSuggestion:e.selectedSuggestion>=l.length-1?0:e.selectedSuggestion+1}))},[l.length,c]),fe=(0,Q.useMemo)(()=>({"autocomplete:accept":H,"autocomplete:dismiss":ue,"autocomplete:previous":W,"autocomplete:next":de}),[H,ue,W,de]),pe=l.length>0||!!F,me=Rf();Lf(`autocomplete`,pe),O(`Autocomplete`,pe),m(fe,{context:`Autocomplete`,isActive:pe&&!me});function he(e){let n=xf(e);if(n!==`prompt`&&h){h(n);let i=af(e);t(i),r(i.length)}else t(e),r(e.length)}let ge=e=>{if(e.key===`right`&&!k){let t=D.text,n=D.shownAt;if(t&&n>0&&i===``){p(),he(t),e.stopImmediatePropagation();return}}if(e.key===`tab`&&!e.shift){if(l.length>0||F)return;let t=D.text,n=D.shownAt;if(t&&n>0&&i===``&&!k){e.preventDefault(),p(),he(t);return}i.trim()===``&&(e.preventDefault(),g({key:`thinking-toggle-hint`,jsx:(0,$.jsxs)(b,{dimColor:!0,children:[`Use `,_,` to toggle thinking`]}),priority:`immediate`,timeoutMs:3e3}));return}if(l.length===0)return;let t=j?.pendingChord!=null;if(e.ctrl&&e.key===`n`&&!t){e.preventDefault(),de();return}if(e.ctrl&&e.key===`p`&&!t){e.preventDefault(),W();return}e.key===`return`&&!e.shift&&!e.meta&&(e.preventDefault(),le())};return ne((e,t,n)=>{let r=new T(n.keypress);ge(r),r.didStopImmediatePropagation()&&n.stopImmediatePropagation()}),{suggestions:l,selectedSuggestion:u,suggestionType:v,maxColumnWidth:S,commandArgumentHint:d,inlineGhostText:F,handleKeyDown:ge}}lm();var iS={"†":`alt+t`,π:`alt+p`,ø:`alt+o`};function aS(e){return e in iS}Fa();function oS(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 sS(e){let t=oS(e);return{nextMode:t,context:gt(e.mode,t,e)}}yp(),V(),Bf(),yc(),V(),Al(),zp(),rd(),os(),Bf(),Nf(),yc(),V(),rd(),om(),Bf(),qp(),yc(),V(),Al(),zp(),rd(),Ga(),V(),Oc(),zo(),am();function cS({currentValue:e,onSelect:t,onCancel:n,isMidConversation:r}){let i=ep(),[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`}];E(`confirm:no`,()=>{a===null?n?.():o(null)},{context:`Confirmation`}),E(`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)(H,{color:`permission`,children:[(0,$.jsxs)(g,{flexDirection:`column`,children:[(0,$.jsxs)(g,{marginBottom:1,flexDirection:`column`,children:[(0,$.jsx)(b,{color:`remember`,bold:!0,children:`Toggle thinking mode`}),(0,$.jsx)(b,{dimColor:!0,children:`Enable or disable thinking for this session.`})]}),a===null?(0,$.jsx)(g,{flexDirection:`column`,marginBottom:1,children:(0,$.jsx)(rp,{defaultValue:e?`true`:`false`,defaultFocusValue:e?`true`:`false`,options:s,onChange:c,onCancel:n??(()=>{}),visibleOptionCount:2})}):(0,$.jsxs)(g,{flexDirection:`column`,marginBottom:1,gap:1,children:[(0,$.jsx)(b,{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)(b,{color:`warning`,children:`Do you want to proceed?`})]})]}),(0,$.jsx)(b,{dimColor:!0,italic:!0,children:i.pending?(0,$.jsxs)($.Fragment,{children:[`Press `,i.keyName,` again to exit`]}):a===null?(0,$.jsxs)(C,{children:[(0,$.jsx)(d,{shortcut:`Enter`,action:`confirm`}),(0,$.jsx)(Os,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`exit`})]}):(0,$.jsxs)(C,{children:[(0,$.jsx)(d,{shortcut:`Enter`,action:`confirm`}),(0,$.jsx)(Os,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})]})}Lo(),Xm(),Jm();function lS(e,t,n){let r=t;for(let t=0;t<n;t++){let t=uS(e,r);if(t.equals(r))break;r=t}return r}function uS(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 dS(e){return`eE$`.includes(e)}function fS(e){return`jkG`.includes(e)||e===`gg`}var pS={"(":[`(`,`)`],")":[`(`,`)`],b:[`(`,`)`],"[":[`[`,`]`],"]":[`[`,`]`],"{":[`{`,`}`],"}":[`{`,`}`],B:[`{`,`}`],"<":[`<`,`>`],">":[`<`,`>`],'"':[`"`,`"`],"'":[`'`,`'`],"`":["`","`"]};function mS(e,t,n,r){if(n===`w`)return hS(e,t,r,pf);if(n===`W`)return hS(e,t,r,e=>!gf(e));let i=pS[n];if(i){let[n,a]=i;return n===a?gS(e,t,n,r):_S(e,t,n,a,r)}return null}function hS(e,t,n,r){let i=[];for(let{segment:t,index:n}of Qu().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=>gf(o(e)),l=e=>r(o(e)),u=e=>uf(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 gS(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 _S(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}}lf(),$u(),dd();function vS(e,t,n,r){let i=lS(t,r.cursor,n);if(i.equals(r.cursor))return;let a=AS(r.cursor,i,t,e,n);MS(e,a.from,a.to,r,a.linewise),r.recordChange({type:`operator`,op:e,motion:t,count:n})}function yS(e,t,n,r,i){let a=i.cursor.findCharacter(n,t,r);if(a===null)return;let o=new ff(i.cursor.measuredText,a),s=jS(i.cursor,o,t);MS(e,s.from,s.to,i),i.setLastFind(t,n),i.recordChange({type:`operatorFind`,op:e,find:t,char:n,count:r})}function bS(e,t,n,r,i){let a=mS(i.text,i.cursor.offset,n,t===`inner`);a&&(MS(e,a.start,a.end,i),i.recordChange({type:`operatorTextObj`,op:e,objType:n,scope:t,count:r}))}function xS(e,t,n){let r=n.text,i=r.split(`
41
+ `),a=fd(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-(ed(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 SS(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-(ed(o).length||1));t.setOffset(Math.min(n,s)),t.recordChange({type:`x`,count:e})}function CS(e,t,n){let r=n.cursor.offset,i=n.text;for(let n=0;n<t&&r<i.length;n++){let t=td(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 wS(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=td(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 TS(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(kS(s,r)+o),t.recordChange({type:`join`,count:e})}function ES(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(kS(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=ed(r),c=i+r.length-(s.length||1);n.setText(o),n.setOffset(Math.max(i,c))}}function DS(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(kS(r,i)+s),n.recordChange({type:`indent`,dir:e,count:t})}function OS(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(kS(a,i)),t.recordChange({type:`openLine`,direction:e})}function kS(e,t){return e.slice(0,t).join(`
57
+ `).length+ +(t>0)}function AS(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(fS(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 dS(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 jS(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 MS(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-(ed(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 NS(e,t,n){let r=t===1?n.cursor.startOfLastLine():n.cursor.goToLine(t);if(r.equals(n.cursor))return;let i=AS(n.cursor,r,`G`,e,t);MS(e,i.from,i.to,n,i.linewise),n.recordChange({type:`operator`,op:e,motion:`G`,count:t})}function PS(e,t,n){let r=t===1?n.cursor.startOfFirstLine():n.cursor.goToLine(t);if(r.equals(n.cursor))return;let i=AS(n.cursor,r,`gg`,e,t);MS(e,i.from,i.to,n,i.linewise),n.recordChange({type:`operator`,op:e,motion:`gg`,count:t})}var FS={d:`delete`,c:`change`,y:`yank`};function IS(e){return e in FS}var LS=new Set([`h`,`l`,`j`,`k`,`w`,`b`,`e`,`W`,`B`,`E`,`0`,`^`,`$`]),RS=new Set([`f`,`F`,`t`,`T`]),zS={i:`inner`,a:`around`};function BS(e){return e in zS}var VS=new Set([`w`,`W`,`"`,`'`,"`",`(`,`)`,`b`,`[`,`]`,`{`,`}`,`B`,`<`,`>`]),HS=1e4;function US(){return{mode:`INSERT`,insertedText:``}}function WS(){return{lastChange:null,lastFind:null,register:``,registerIsLinewise:!1}}function GS(e,t,n){switch(e.type){case`idle`:return JS(t,n);case`count`:return YS(e,t,n);case`operator`:return XS(e,t,n);case`operatorCount`:return ZS(e,t,n);case`operatorFind`:return QS(e,t,n);case`operatorTextObj`:return $S(e,t,n);case`find`:return eC(e,t,n);case`g`:return tC(e,t,n);case`operatorG`:return nC(e,t,n);case`replace`:return rC(e,t,n);case`indent`:return iC(e,t,n)}}function KS(e,t,n){return IS(e)?{next:{type:`operator`,op:FS[e],count:t}}:LS.has(e)?{execute:()=>{let r=lS(e,n.cursor,t);n.setOffset(r.offset)}}:RS.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:()=>wS(t,n)}:e===`x`?{execute:()=>SS(t,n)}:e===`J`?{execute:()=>TS(t,n)}:e===`p`||e===`P`?{execute:()=>ES(e===`p`,t,n)}:e===`D`?{execute:()=>vS(`delete`,`$`,1,n)}:e===`C`?{execute:()=>vS(`change`,`$`,1,n)}:e===`Y`?{execute:()=>xS(`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:()=>aC(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:()=>OS(`below`,n)}:e===`O`?{execute:()=>OS(`above`,n)}:null}function qS(e,t,n,r){return BS(n)?{next:{type:`operatorTextObj`,op:e,count:t,scope:zS[n]}}:RS.has(n)?{next:{type:`operatorFind`,op:e,count:t,find:n}}:LS.has(n)?{execute:()=>vS(e,n,t,r)}:n===`G`?{execute:()=>NS(e,t,r)}:n===`g`?{next:{type:`operatorG`,op:e,count:t}}:null}function JS(e,t){return/[1-9]/.test(e)?{next:{type:`count`,digits:e}}:e===`0`?{execute:()=>t.setOffset(t.cursor.startOfLogicalLine().offset)}:KS(e,1,t)||{}}function YS(e,t,n){if(/[0-9]/.test(t)){let n=e.digits+t;return{next:{type:`count`,digits:String(Math.min(parseInt(n,10),HS))}}}return KS(t,parseInt(e.digits,10),n)||{next:{type:`idle`}}}function XS(e,t,n){return t===e.op[0]?{execute:()=>xS(e.op,e.count,n)}:/[0-9]/.test(t)?{next:{type:`operatorCount`,op:e.op,count:e.count,digits:t}}:qS(e.op,e.count,t,n)||{next:{type:`idle`}}}function ZS(e,t,n){if(/[0-9]/.test(t)){let n=e.digits+t,r=Math.min(parseInt(n,10),HS);return{next:{...e,digits:String(r)}}}let r=parseInt(e.digits,10),i=e.count*r;return qS(e.op,i,t,n)||{next:{type:`idle`}}}function QS(e,t,n){return{execute:()=>yS(e.op,e.find,t,e.count,n)}}function $S(e,t,n){return VS.has(t)?{execute:()=>bS(e.op,e.scope,t,e.count,n)}:{next:{type:`idle`}}}function eC(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 tC(e,t,n){return t===`j`||t===`k`?{execute:()=>{let r=lS(`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 nC(e,t,n){return t===`j`||t===`k`?{execute:()=>vS(e.op,`g${t}`,e.count,n)}:t===`g`?{execute:()=>PS(e.op,e.count,n)}:{next:{type:`idle`}}}function rC(e,t,n){return t===``?{next:{type:`idle`}}:{execute:()=>CS(t,e.count,n)}}function iC(e,t,n){return t===e.dir?{execute:()=>DS(e.dir,e.count,n)}:{next:{type:`idle`}}}function aC(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)}lf(),$u();function oC(e){let t=Q.useRef(US()),[n,r]=(0,Q.useState)(`INSERT`),i=Q.useRef(WS()),a=cf({...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=ff.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`:SS(t.count,r);break;case`replace`:CS(t.char,t.count,r);break;case`toggleCase`:wS(t.count,r);break;case`indent`:DS(t.dir,t.count,r);break;case`join`:TS(t.count,r);break;case`openLine`:OS(t.direction,r);break;case`operator`:vS(t.op,t.motion,t.count,r);break;case`operatorFind`:yS(t.op,t.find,t.char,t.count,r);break;case`operatorTextObj`:bS(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=ff.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,-(ed(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=GS(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}}R(),V();function sC(e){let[t]=h(),n=D();nf(n,!!e.onImagePaste);let r=oC({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?I.inverse:e=>e,themeText:re(`text`,t),columns:e.columns,maxVisibleLines:e.maxVisibleLines,onImagePaste:e.onImagePaste,disableCursorMovementForUpDownKeys:e.disableCursorMovementForUpDownKeys,disableEscapeDoublePress:e.disableEscapeDoublePress,externalOffset:e.cursorOffset,onOffsetChange:e.onChangeCursorOffset,inputFilter:e.inputFilter,onModeChange:e.onModeChange,onUndo:e.onUndo}),{mode:i,setMode:a}=r;return Q.useEffect(()=>{e.initialMode&&e.initialMode!==i&&a(e.initialMode)},[e.initialMode,i,a]),(0,$.jsx)(g,{flexDirection:`column`,children:(0,$.jsx)(_f,{inputState:r,terminalFocus:n,highlights:e.highlights,...e})})}li(),jm(),a();function cC(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 lC(e){return`${e.input_tokens}|${e.cache_creation_input_tokens}|${e.cache_read_input_tokens}`}function uC(e){let t=gh(`sha256`).update(e).digest(`hex`).slice(0,16);return hh(r(),`cache-stats`,`${t}.json`)}var dC={version:1,signature:null,lastResetAt:null,lastHitRate:null};function fC(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 pC(e){try{let t=await Sh(e,`utf8`),n=JSON.parse(t);return fC(n)?n:{...dC}}catch{return{...dC}}}async function mC(e,t){await xh(mh(e),{recursive:!0});let n=`${e}.${process.pid}.tmp`;try{await wh(n,JSON.stringify(t),`utf8`),await Ch(n,e)}catch{}}var hC={signature:null,lastResetAt:null,lastHitRate:null},gC=null;async function _C(e){gC=e;let t=await pC(uC(e));hC={signature:t.signature,lastResetAt:t.lastResetAt,lastHitRate:t.lastHitRate}}function vC(e){let t=lC(e),n=cC(e);return t!==hC.signature&&(hC={signature:t,lastResetAt:Date.now(),lastHitRate:n},gC!==null&&mC(uC(gC),{version:1,signature:t,lastResetAt:hC.lastResetAt,lastHitRate:n})),{...hC}}function yC(){return{...hC}}V(),rd(),yc();function bC(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 xC(){return(0,$.jsx)(b,{dimColor:!0,children:` │ `})}function SC({modelName:e,contextUsedPct:t,usedTokens:n,contextWindowSize:r,totalCostUsd:i,rateLimits:a}){let{columns:o}=ae(),[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,_=`${ad(n)}/${ad(r)}`;return(0,$.jsxs)(g,{children:[(0,$.jsx)(b,{children:u}),(0,$.jsx)(xC,{}),(0,$.jsx)(b,{dimColor:!0,children:`Context `}),(0,$.jsxs)(b,{children:[t,`%`]}),!d&&(0,$.jsxs)(b,{dimColor:!0,children:[` (`,_,`)`]}),f&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(xC,{}),(0,$.jsx)(b,{dimColor:!0,children:`Session `}),(0,$.jsxs)(b,{children:[m,`%`]}),!d&&a.five_hour.resets_at>0&&(0,$.jsxs)(b,{dimColor:!0,children:[` `,bC(a.five_hour.resets_at)]})]}),p&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(xC,{}),(0,$.jsx)(b,{dimColor:!0,children:`Weekly `}),(0,$.jsxs)(b,{children:[h,`%`]}),!d&&a.seven_day.resets_at>0&&(0,$.jsxs)(b,{dimColor:!0,children:[` `,bC(a.seven_day.resets_at)]})]}),i>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(xC,{}),(0,$.jsx)(b,{children:Za(i)})]})]})}var CC=Q.memo(SC);Zu(),Y(),Ne(),Cf(),oo(),Kp(),rn(),V(),ei(),Au(),gd(),Al(),Gl(),js(),In(),yd(),Fo(),io(),rd();var wC=3600*1e3;function TC(e){return String(Math.floor(e)).padStart(2,`0`)}function EC(e){if(e<=0)return`exp`;let t=Math.floor(e/6e4),n=Math.floor(e%6e4/1e3);return`${TC(t)}:${TC(n)}`}function DC({messages:e}){let[t,n]=(0,Q.useState)(()=>Date.now()),[r,i]=(0,Q.useState)(!0),a=Ts(e),o=(0,Q.useRef)(null);if(a!==null){let e=lC(a);e!==o.current&&(o.current=e,vC(a))}let{lastResetAt:s,lastHitRate:c}=yC(),l=s===null?null:t-s,u=l===null?null:wC-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,_C(We()))},[]);let h=a===null?c:cC(a);if(h===null&&s===null)return(0,$.jsx)(b,{dimColor:!0,children:` Cache --% --:--`});let g=u===null?`--:--`:EC(u),_=h===null?`--%`:`${h}%`,v;return v=f||d===null?`inactive`:d<20?`success`:d<40?`warning`:`error`,(0,$.jsxs)(b,{children:[(0,$.jsx)(b,{dimColor:!0,children:` Cache `}),(0,$.jsx)(b,{color:h!==null&&h>=50?`success`:`inactive`,children:_}),(0,$.jsxs)(b,{color:v,dimColor:p&&!r,children:[` `,g]})]})}function OC(){return null}function kC(e){return e?.statusLineEnabled===!1?!1:e?.statusLineEnabled===!0||!!e?.statusLine?.command}function AC(e,t,n,r,i,a,o){let s=ze(),c=yl(),l=Cd({permissionMode:e,mainLoopModel:a,exceeds200kTokens:t}),u=n?.outputStyle||`default`,d=Ts(r),f=vd(l,Qe()),p=pd(d,f),m=mo(We()),h=er(),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{...dr(),...m&&{session_name:m},model:{id:l,display_name:_d(l)},workspace:{current_dir:jl(),project_dir:Ze(),added_dirs:i},version:`0.0.26`,output_style:{name:u},cost:{total_cost_usd:qe(),total_duration_ms:Ue(),total_api_duration_ms:Ke(),total_lines_added:it(),total_lines_removed:Ge()},context_window:{total_input_tokens:$e(),total_output_tokens:nt(),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},...Om()&&{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 jC(e){return tr(e)?.uuid??null}function MC({messagesRef:e,lastAssistantMessageId:t,vimMode:n}){let r=(0,Q.useRef)(void 0),i=G(e=>e.toolPermissionContext.mode),a=G(e=>e.toolPermissionContext.additionalWorkingDirectories),o=G(e=>e.statusLineText),s=vn(),c=En(),{addNotification:l}=Sf(),u=Gp(),d=(0,Q.useRef)(c);d.current=c;let p=(0,Q.useRef)(n);p.current=n;let m=(0,Q.useRef)(i);m.current=i;let h=(0,Q.useRef)(a);h.current=a;let _=(0,Q.useRef)(u);_.current=u;let v=(0,Q.useRef)({messageId:null,exceeds200kTokens:!1,permissionMode:i,vimMode:n,mainLoopModel:u}),y=(0,Q.useRef)(void 0),x=(0,Q.useRef)(!0),S=(0,Q.useCallback)(async()=>{r.current?.abort();let t=new AbortController;r.current=t;let n=e.current,i=x.current;if(x.current=!1,d.current?.statusLine?.command)try{let e=v.current.exceeds200kTokens,r=jC(n);r!==v.current.messageId&&(e=Ec(n),v.current.messageId=r,v.current.exceeds200kTokens=e);let a=await Ji(AC(m.current,e,d.current,n,Array.from(h.current.keys()),_.current,p.current),t.signal,void 0,i);t.signal.aborted||s(e=>e.statusLineText===a?e:{...e,statusLineText:a})}catch{}},[e,s]),C=(0,Q.useCallback)(()=>{y.current!==void 0&&clearTimeout(y.current),y.current=setTimeout((e,t)=>{e.current=void 0,t()},300,y,S)},[S]);(0,Q.useEffect)(()=>{(t!==v.current.messageId||i!==v.current.permissionMode||n!==v.current.vimMode||u!==v.current.mainLoopModel)&&(v.current.permissionMode=i,v.current.vimMode=n,v.current.mainLoopModel=u,C())},[t,i,n,u,C]);let w=c?.statusLine?.command,T=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>{if(T.current){T.current=!1;return}x.current=!0,S()},[w,S]),(0,Q.useEffect)(()=>{let e=c?.statusLine;e&&(e.command.length,e.padding,c.disableAllHooks===!0&&X(`Status line is configured but disableAllHooks is true`,{level:`warn`}),Nu()||(l({key:`statusline-trust-blocked`,text:`statusline skipped · restart to fix`,color:`warning`,priority:`low`}),X(`Status line command skipped: workspace trust not accepted`,{level:`warn`})))},[]),(0,Q.useEffect)(()=>(S(),()=>{r.current?.abort(),y.current!==void 0&&clearTimeout(y.current)}),[]);let E=c?.statusLine?.padding??0,D=Cd({permissionMode:i,mainLoopModel:u,exceeds200kTokens:v.current.exceeds200kTokens}),O=vd(D,Qe()),k=Ts(e.current),A=k?k.input_tokens+k.cache_creation_input_tokens+k.cache_read_input_tokens:0,j=k?Math.round(pd(k,O).used??0):0,M=er(),N={...M.five_hour&&{five_hour:{utilization:M.five_hour.utilization,resets_at:M.five_hour.resets_at}},...M.seven_day&&{seven_day:{utilization:M.seven_day.utilization,resets_at:M.seven_day.resets_at}}},P=c?.statusLineEnabled===!0,F=!!c?.statusLine?.command;return(0,$.jsxs)(g,{flexDirection:`column`,paddingX:E,children:[P&&(0,$.jsxs)(g,{gap:2,children:[(0,$.jsx)(CC,{modelName:_d(D),contextUsedPct:j,usedTokens:A,contextWindowSize:O,totalCostUsd:qe(),rateLimits:N}),(0,$.jsx)(OC,{}),(0,$.jsx)(DC,{messages:e.current})]}),o?(0,$.jsx)(b,{dimColor:!0,wrap:`truncate`,children:(0,$.jsx)(f,{children:o})}):F&&or()?(0,$.jsx)(b,{children:` `}):null]})}var NC=(0,Q.memo)(MC);c(),Y(),Ns(),V();function PC({tasksSelected:e,onOpenDialog:t}){let n=G(e=>e.tasks),r=(0,Q.useMemo)(()=>Object.values(n??{}).filter(e=>wa(e)),[n]);return qm(n??{},!1)||r.length===0?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(FC,{selected:e,onClick:t,children:rc(r)}),qo(r)&&(0,$.jsxs)(b,{dimColor:!0,children:[` · `,l.arrowDown,` to view`]})]})}function FC({selected:e,onClick:t,children:n}){let[r,i]=(0,Q.useState)(!1),a=(0,$.jsx)(b,{color:`background`,inverse:e||r,children:n});return t?(0,$.jsx)(g,{onClick:t,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:a}):a}V(),mf();function IC({value:e,onChange:t,historyFailedMatch:n}){return(0,$.jsxs)(g,{gap:1,children:[(0,$.jsx)(b,{dimColor:!0,children:n?`no matching prompt:`:`search prompts:`}),(0,$.jsx)(yf,{value:e,onChange:t,cursorOffset:e.length,onChangeCursorOffset:()=>{},columns:p(e)+1,focus:!0,showCursor:!0,multiline:!1,dimColor:!0})]})}Uu(),ql();var LC=5e3;function RC(e,t){if(e)return`draft`;switch(t){case`APPROVED`:return`approved`;case`CHANGES_REQUESTED`:return`changes_requested`;default:return`pending`}}async function zC(){if(!await Yl())return null;let[e,t]=await Promise.all([eu(),uu()]);if(e===t)return null;let{stdout:n,code:r}=await Wu(`gh`,[`pr`,`view`,`--json`,`number,url,reviewDecision,isDraft,headRefName,state`],{timeout:LC,preserveOutputOnError:!1});if(r!==0||!n.trim())return null;try{let e=zl(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:RC(e.isDraft,e.reviewDecision)}}catch{return null}}Ne();var BC=6e4,VC=4e3,HC=60*6e4,UC={number:null,url:null,reviewState:null,lastUpdated:0};function WC(e,t=!0){let[n,r]=(0,Q.useState)(UC),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=at();if(n!==t)n=t,s=Date.now();else if(Date.now()-s>=HC)return;let l=Date.now(),u=await zC();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>VC){a.current=!0;return}e||(i.current=setTimeout(c,BC))}}let l=Date.now()-o.current;return l>=BC?c():i.current=setTimeout(c,BC-l),()=>{e=!0,i.current&&(clearTimeout(i.current),i.current=null)}},[e,t]),n}V(),jm(),Fs(),Xl(),Lo(),Ql(),Xm(),Y(),yc(),rd(),rs(),yd(),Wd(),Au(),Vt();var GC=()=>null,KC=5e3,qC=1e3;function JC(){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=sd(e*1024*1024);t(e=>e?.text===r?e:{text:r,level:n})}e();let n=setInterval(e,KC);return()=>clearInterval(n)},[]),e}function YC(){let e=(0,Q.useSyncExternalStore)(_o,yi,GC),[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)(b,{dimColor:!0,children:[`waiting `,od(t*1e3,{mostSignificantOnly:!0})]})}function XC(){let[t,n]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{let e=setInterval(()=>n(e=>e+1),qC);return()=>clearInterval(e)},[]);let r=(Rc(),e(qa)),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)(b,{color:d,children:[`goal (`,u,`)`]})}function ZC({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)(b,{dimColor:!0,children:[`Press `,e.key,` again to exit`]},`exit-message`);if(c)return(0,$.jsx)(b,{dimColor:!0,children:`Pasting text…`},`pasting-message`);let m=Om()&&t===`INSERT`&&!l;return(0,$.jsxs)(g,{justifyContent:`flex-start`,gap:1,children:[l&&(0,$.jsx)(IC,{value:u,onChange:d,historyFailedMatch:f}),m?(0,$.jsx)(b,{dimColor:!0,children:`-- INSERT --`},`vim-insert`):null,(0,$.jsx)(QC,{mode:n,toolPermissionContext:r,showHint:!i&&!m,isLoading:a,tasksSelected:o,tmuxSelected:s,onOpenTasksDialog:p})]})}function QC({mode:t,toolPermissionContext:n,showHint:r,isLoading:i,tasksSelected:a,tmuxSelected:o,onOpenTasksDialog:s}){let{columns:c}=ae(),l=mc(`chat:cycleMode`,`Chat`,`shift+tab`),u=G(e=>e.tasks);Oi();let f=WC(i,ew()),p=(0,Q.useSyncExternalStore)(_o,yi,GC),m=ee(),h=B().getState,_=p!==null,v=(0,Q.useMemo)(()=>ku(Object.values(u),e=>wa(e)),[u]),y=pp(),x=y!==void 0&&y.length>0,S=mc(`chat:cancel`,`Chat`,`esc`).toLowerCase(),w=mc(`app:toggleTodos`,`Global`,`ctrl+t`),T=mc(`chat:killAgents`,`Chat`,`ctrl+x ctrl+k`),E=G(e=>e.notifications.current?.key===`kill-agents-confirm`),D=JC(),O=(0,Q.useMemo)(()=>_d(wd()),[G(e=>e.mainLoopModel)]),k=Ud();if(t===`bash`)return(0,$.jsx)(b,{color:`bashBorder`,children:`! for bash mode`});let A=n?.mode,j=!Su(A),M=v>0,N=+!!j+ +!!M,P=ew()&&f.number!==null&&f.reviewState!==null&&f.url!==null&&N<2&&(N===0||c>=80),F=N<2,I=A&&j?(0,$.jsxs)(b,{color:Cu(A),children:[nu(A),` `,iu(A).toLowerCase(),` on`,F&&(0,$.jsxs)(b,{dimColor:!0,children:[` `,(0,$.jsx)(d,{shortcut:l,action:`cycle`,parens:!0})]})]},`mode`):null,L=[...P?[(0,$.jsx)(ui,{number:f.number,url:f.url,reviewState:f.reviewState},`pr-status`)]:[],...D?[(0,$.jsxs)(b,{dimColor:D.level===`normal`,color:D.level===`error`?`error`:D.level===`warning`?`warning`:void 0,children:[D.text,` · pid:`,process.pid,` · `,O,k?` · ${k}`:``]},`rss`)]:[],...(Rc(),e(qa)).getGoal()?[(0,$.jsx)(XC,{},`goal-elapsed`)]:[]],te=Object.values(u).some(e=>e.type===`local_agent`&&e.status===`running`),R=r?$C(i,S,w,T,x,te,E):[];_?L.push((0,$.jsx)(YC,{},`proactive`)):r&&L.push(...R);let ne=M&&!qm(u,!1)?(0,$.jsx)(PC,{tasksSelected:a,onOpenDialog:s}):null;L.length===0&&!ne&&!I&&r&&L.push((0,$.jsx)(b,{dimColor:!0,children:`? for shortcuts`},`shortcuts-hint`));let re=Mu().copyOnSelect??!0,ie=m&&(!re||z());if(or()&&ie){let e=Xu()===`macos`,t=e&&(h()?.lastPressHadAlt??!1);L.push((0,$.jsx)(b,{dimColor:!0,children:(0,$.jsxs)(C,{children:[!re&&(0,$.jsx)(d,{shortcut:`ctrl+c`,action:`copy`}),z()&&(t?(0,$.jsx)(b,{children:`set macOptionClickForcesSelection in VS Code settings`}):(0,$.jsx)(d,{shortcut:e?`option+click`:`shift+click`,action:`native select`}))]})},`selection-copy`))}return ne&&r&&L.push((0,$.jsx)(b,{dimColor:!0,children:a?(0,$.jsx)(d,{shortcut:`Enter`,action:`view tasks`}):(0,$.jsx)(d,{shortcut:`↓`,action:`manage`})},`manage-tasks`)),L.length===0&&!ne&&!I?or()?(0,$.jsx)(b,{children:` `}):null:(0,$.jsxs)(g,{height:1,overflow:`hidden`,children:[I&&(0,$.jsxs)(g,{flexShrink:0,children:[I,(ne||L.length>0)&&(0,$.jsx)(b,{dimColor:!0,children:` · `})]}),ne&&(0,$.jsxs)(g,{flexShrink:0,children:[ne,L.length>0&&(0,$.jsx)(b,{dimColor:!0,children:` · `})]}),L.length>0&&(0,$.jsx)(b,{wrap:`truncate`,children:(0,$.jsx)(C,{children:L})})]})}function $C(e,t,n,r,i,a,o){let s=i;return[...e?[(0,$.jsx)(b,{dimColor:!0,children:(0,$.jsx)(d,{shortcut:t,action:`interrupt`})},`esc`)]:[],...!e&&a&&!o?[(0,$.jsx)(b,{dimColor:!0,children:(0,$.jsx)(d,{shortcut:r,action:`stop agents`})},`kill-agents`)]:[],...s?[(0,$.jsx)(b,{dimColor:!0,children:(0,$.jsx)(d,{shortcut:n,action:`show tasks`})},`toggle-tasks`)]:[]]}function ew(){return Mu().prStatusFooterEnabled??!0}rn(),yc(),V(),rs(),Fp(),Am();function tw({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:_,tasksSelected:v,tmuxSelected:y,mcpClients:b,isPasting:x=!1,isInputWrapped:S=!1,messages:C,isSearching:w,historyQuery:T,setHistoryQuery:E,historyFailedMatch:D,onOpenTasksDialog:O}){let k=En(),{columns:A,rows:j}=ae(),M=(0,Q.useRef)(C);M.current=C;let N=(0,Q.useMemo)(()=>jC(C),[C]),P=A<80,F=or(),ee=F&&j<24,I=v,L=h||kC(k)||w;return Rm((0,Q.useMemo)(()=>F&&u.length?{suggestions:u,selectedSuggestion:d,maxColumnWidth:f}:null,[F,u,d,f])),u.length&&!F?(0,$.jsx)(g,{paddingX:2,paddingY:0,children:(0,$.jsx)(Ip,{suggestions:u,selectedSuggestion:d,maxColumnWidth:f})}):m?(0,$.jsx)(Mm,{dimColor:!0,fixedWidth:!0,paddingX:2}):(0,$.jsxs)(g,{flexDirection:P?`column`:`row`,justifyContent:P?`flex-start`:`space-between`,paddingX:2,gap:+!P,children:[(0,$.jsxs)(g,{flexDirection:`column`,flexShrink:+!P,children:[i===`prompt`&&!ee&&!n.show&&!x&&kC(k)&&(0,$.jsx)(NC,{messagesRef:M,lastAssistantMessageId:N,vimMode:r}),(0,$.jsx)(rw,{}),(0,$.jsx)(ZC,{exitMessage:n,vimMode:r,mode:i,toolPermissionContext:p,suppressHint:L,isLoading:_,tasksSelected:I,tmuxSelected:y,isPasting:x,isSearching:w,historyQuery:T,setHistoryQuery:E,historyFailedMatch:D,onOpenTasksDialog:O})]}),(0,$.jsx)(g,{flexShrink:1,gap:1,children:F?null:(0,$.jsx)(bb,{apiKeyStatus:e,autoUpdaterResult:a,debug:t,isAutoUpdating:o,verbose:s,messages:C,onAutoUpdaterResult:c,onChangeIsUpdating:l,mcpClients:b,isInputWrapped:S,isNarrow:P})})]})}var nw=(0,Q.memo)(tw);function rw(){return null}c(),V();function iw({isLoading:e}){return(0,$.jsxs)(b,{dimColor:e,children:[l.pointer,`\xA0`]})}function aw({mode:e,isLoading:t}){return(0,$.jsx)(g,{alignItems:`flex-start`,alignSelf:`flex-start`,flexWrap:`nowrap`,justifyContent:`flex-start`,children:e===`bash`?(0,$.jsx)(b,{color:`bashBorder`,dimColor:t,children:`!\xA0`}):(0,$.jsx)(iw,{isLoading:t})})}V();var ow=Q.createContext(void 0),sw=2;function cw({isFirst:e,children:t}){let n=sw,r=Q.useMemo(()=>({isQueued:!0,isFirst:e,paddingWidth:n*2}),[e,n]);return(0,$.jsx)(ow.Provider,{value:r,children:(0,$.jsx)(g,{paddingX:n,children:t})})}V(),Y(),wt(),In(),ql(),Eo();var lw=new Set;function uw(e){try{return zl(e)?.type===`idle_notification`}catch{return!1}}var dw=3;function fw(e){return`<${Pu}>
63
+ <${Ru}>+${e} more tasks completed</${Ru}>
64
+ <${Lu}>completed</${Lu}>
65
+ </${Pu}>`}function pw(e){let t=e.filter(e=>typeof e.value!=`string`||!uw(e.value)),n=t.filter(e=>e.mode===`task-notification`),r=t.filter(e=>e.mode!==`task-notification`);if(n.length<=dw)return[...r,...n];let i=n.slice(0,dw-1),a={value:fw(n.length-(dw-1)),mode:`task-notification`};return[...r,...i,a]}function mw(){let e=mb(),t=G(e=>!!e.viewingAgentTaskId),n=(0,Q.useMemo)(()=>{if(e.length===0)return null;let t=e.filter(pr);return t.length===0?null:_s(pw(t).map(e=>{let t=e.value;return e.mode===`bash`&&typeof t==`string`&&(t=`<bash-input>${t}</bash-input>`),ht({content:t})}))},[e]);return t||n===null?null:(0,$.jsx)(g,{marginTop:1,flexDirection:`column`,children:n.map((e,t)=>(0,$.jsx)(cw,{isFirst:t===0,children:(0,$.jsx)(Bc,{message:e,lookups:ca,addMargin:!1,tools:[],commands:[],verbose:!1,inProgressToolUseIDs:lw,progressMessagesForMessage:[],shouldAnimate:!1,shouldShowDot:!1,isTranscriptMode:!1,isStatic:!0})},t))})}var hw=Q.memo(mw);bn(),c(),V();function gw({hasStash:e}){return e?(0,$.jsx)(g,{paddingLeft:2,children:(0,$.jsxs)(b,{dimColor:!0,children:[l.pointerSmall,` Stashed (auto-restores after submit)`]})}):null}Nf();var _w=1e4,vw=1e3;function yw(e,t){if(e.length<=_w)return{truncatedText:e,placeholderContent:``};let n=Math.floor(vw/2),r=e.slice(0,n),i=e.slice(-500),a=e.slice(n,-500);return{truncatedText:r+bw(t,jf(a))+i,placeholderContent:a}}function bw(e,t){return`[...Truncated text #${e} +${t} lines...]`}function xw(e,t){let n=Object.keys(t).map(Number),r=n.length>0?Math.max(...n)+1:1,{truncatedText:i,placeholderContent:a}=yw(e,r);return a?{newInput:i,newPastedContents:{...t,[r]:{id:r,type:`text`,content:a}}}:{newInput:e,newPastedContents:t}}function Sw({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}=xw(e,t);n(s),r(s.length),i(c),o(!0)},[e,a,t,n,i,r]),(0,Q.useEffect)(()=>{e===``&&o(!1)},[e])}Y(),Au(),wt(),Fi();var Cw=3;function ww({input:e,submitCount:t}){let n=mb(),r=G(e=>e.promptSuggestionEnabled);return(0,Q.useMemo)(()=>{if(e===``){if(n.some(cs)&&(Mu().queuedCommandUpHintCount||0)<Cw)return`Press up to edit queued messages`;if(t<1&&r&&!Hn())return $m()}},[e,n,t,r])}var Tw=5e3,Ew=!1;function Dw(e){let[t,n]=(0,Q.useState)(!1);return(0,Q.useEffect)(()=>{if(Ew||!e)return;Ew=!0,n(!0);let t=setTimeout(n,Tw,!1);return()=>{clearTimeout(t),n(!1)}},[e]),t}R(),Cf(),Zu(),Y(),wt(),_(),sr(),Bf(),Wm(),Nf(),Kp(),yc(),V(),Jo(),Vs(),Oc(),vl(),Ql(),lf(),Au(),Gl(),ou(),Il(),rs(),ti(),Bu(),yd(),Yu(),Up(),zo(),mf(),Xm(),ef(),jm();var Ow=5,kw=3;function Aw({debug:e,toolPermissionContext:t,setToolPermissionContext:n,apiKeyStatus:r,commands:i,agents:a,isLoading:o,verbose:s,messages:c,onAutoUpdaterResult:l,autoUpdaterResult:u,input:d,onInputChange:f,mode:p,onModeChange:h,stashedPrompt:_,setStashedPrompt:v,submitCount:y,onShowMessageSelector:x,onMessageActionsEnter:S,mcpClients:C,pastedContents:w,setPastedContents:T,vimMode:D,setVimMode:O,showBashesDialog:k,setShowBashesDialog:j,onExit:M,getToolUseContext:N,onSubmit:P,isSearchingHistory:F,setIsSearchingHistory:ee,onDismissSideQuestion:I,isSideQuestionVisible:L,helpOpen:R,setHelpOpen:z,hasSuppressedDialogs:re,isLocalJSXCommandActive:ie=!1,insertTextRef:B}){let oe=Gp(),V=Rf()||ie,[ce,le]=(0,Q.useState)(!1),[H,ue]=(0,Q.useState)({show:!1}),[U,W]=(0,Q.useState)(d.length),de=Q.useRef(d);d!==de.current&&(W(d.length),de.current=d);let fe=Q.useCallback(e=>{de.current=e,f(e)},[f]);B&&(B.current={cursorOffset:U,insert:e=>{let t=U===d.length&&d.length>0&&!/\s$/.test(d)?` ${e}`:e,n=d.slice(0,U)+t+d.slice(U);de.current=n,f(n),W(U+t.length)},setInputWithCursor:(e,t)=>{de.current=e,f(e),W(t)}});let pe=Oi(),me=vn(),he=G(e=>e.tasks),ge=mb(),_e=G(e=>e.promptSuggestion),ve=G(e=>e.speculation),ye=G(e=>e.speculationSessionTimeSavedMs),be=G(e=>e.mainLoopModel),xe=G(e=>e.mainLoopModelForSession),Se=G(e=>e.thinkingEnabled),Ce=G(e=>mr()?e.fastMode:!1),we=G(e=>e.viewingAgentTaskId);G(e=>e.viewSelectionMode);let{historyQuery:Te,setHistoryQuery:Ee,historyMatch:De,historyFailedMatch:Oe}=kb(e=>{T(e.pastedContents),Vt(e.display)},d,fe,W,U,h,p,F,ee,T,w),ke=(0,Q.useRef)(-1);ke.current===-1&&(ke.current=jw(c));let Ae=(0,Q.useRef)(!1),je=G(e=>e.selectedBgAgentIndex),Me=(0,Q.useCallback)(e=>me(t=>{let n=typeof e==`function`?e(t.selectedBgAgentIndex):e;return n===t.selectedBgAgentIndex?t:{...t,selectedBgAgentIndex:n}}),[me]),[Ne,Pe]=(0,Q.useState)(!1),[Fe,Ie]=(0,Q.useState)(!1),[Le,Re]=(0,Q.useState)(!1),[ze,Be]=(0,Q.useState)(!1),[Ve,He]=(0,Q.useState)(!1),[Ue,We]=(0,Q.useState)(!1),[Ge,Ke]=(0,Q.useState)(!1),[qe,Je]=(0,Q.useState)(!1),Ye=(0,Q.useMemo)(()=>{let e=d.indexOf(`
66
+ `);return e===-1||U<=e},[d,U]),Xe=(0,Q.useMemo)(()=>{let e=d.lastIndexOf(`
67
+ `);return e===-1||U>e},[d,U]),Ze=(0,Q.useMemo)(()=>ku(Object.values(he),e=>e.status===`running`),[he])>0&&!qm(he,!1),Qe=Ob(),$e=Qe.length>0,et=(0,Q.useMemo)(()=>[$e&&`bg_agent`,Ze&&`tasks`].filter(Boolean),[$e,Ze]),tt=G(e=>e.footerSelection),nt=tt&&et.includes(tt)?tt:null;(0,Q.useEffect)(()=>{tt&&!nt&&me(e=>e.footerSelection===null?e:{...e,footerSelection:null})},[tt,nt,me]);let rt=nt===`tasks`,it=nt===`tmux`,at=nt===`bg_agent`;function ot(e){me(t=>t.footerSelection===e?t:{...t,footerSelection:e}),e===`bg_agent`&&Me(-1)}function st(e,t=!1){let n=nt?et.indexOf(nt):-1,r=et[n+e];return r?(ot(r),!0):e<0&&t?(ot(null),!0):!1}let{suggestion:ct,markAccepted:lt,logOutcomeAtSubmission:ut,markShown:dt}=jb({inputValue:d,isAssistantResponding:o}),ft=(0,Q.useMemo)(()=>F&&De?af(typeof De==`string`?De:De.display):d,[F,De,d]),pt=(0,Q.useMemo)(()=>Ci(ft),[ft]),mt=(0,Q.useMemo)(()=>bp(ft),[ft]),ht=(0,Q.useMemo)(()=>ax(ft).filter(e=>is(ft.slice(e.start+1,e.end),i)),[ft,i]),gt=(0,Q.useMemo)(()=>[],[ft]),_t=(0,Q.useMemo)(()=>Tx(pe.getState().mcp.clients)?Dx(ft):[],[ft,(0,Q.useSyncExternalStore)(_x,Ex)]),vt=(0,Q.useMemo)(()=>kf(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===U);(0,Q.useEffect)(()=>{let e=vt.find(e=>U>e.start&&U<e.end);if(e){let t=(e.start+e.end)/2;W(U<t?e.start:e.end)}},[U,vt,W]);let bt=(0,Q.useMemo)(()=>{let e=[];for(let t of vt)U===t.start&&e.push({start:t.start,end:t.end,color:void 0,inverse:!0,priority:8});F&&De&&!Oe&&e.push({start:U,end:U+Te.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(J())for(let t of pt)for(let n=t.start;n<t.end;n++)e.push({start:n,end:n+1,color:Vi(n-t.start),shimmerColor:Vi(n-t.start,!0),priority:10});return e},[F,Te,De,Oe,U,mt,vt,ht,gt,_t,ft,pt]),{addNotification:xt,removeNotification:St}=Sf();(0,Q.useEffect)(()=>{pt.length&&J()?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)(d.length),wt=(0,Q.useRef)(d.length),Tt=(0,Q.useCallback)(()=>{St(`stash-hint`)},[St]);(0,Q.useEffect)(()=>{let e=Ct.current,t=wt.current,n=d.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)&&(Mu().hasUsedStash||xt({key:`stash-hint`,jsx:(0,$.jsxs)(b,{dimColor:!0,children:[`Tip: `,(0,$.jsx)(Os,{action:`chat:stash`,context:`Chat`,fallback:`ctrl+s`,description:`stash`})]}),priority:`immediate`,timeoutMs:yb}),wt.current=n)},[d.length,xt]);let{pushToBuffer:Et,undo:Dt,canUndo:Ot,clearBuffer:kt}=Ab({maxBufferSize:50,debounceMs:1e3});Sw({input:d,pastedContents:w,onInputChange:fe,setCursorOffset:W,setPastedContents:T});let At=ww({input:d,submitCount:y}),jt=(0,Q.useCallback)(e=>{if(e===`?`){z(e=>!e);return}z(!1),Tt(),ps(),Ca(me);let t=e.length===d.length+1,n=U===0,r=xf(e);if(n&&r!==`prompt`){if(t){h(r);return}if(d.length===0){h(r);let t=af(e).replaceAll(` `,` `);Et(d,U,w),fe(t),W(t.length);return}}let i=e.replaceAll(` `,` `);d!==i&&Et(d,U,w),me(e=>e.footerSelection===null?e:{...e,footerSelection:null}),fe(i)},[fe,h,d,U,Et,w,Tt,me]),{resetHistory:Mt,onHistoryUp:Nt,onHistoryDown:Pt,dismissSearchHint:Ft,historyIndex:It}=Db((e,t,n)=>{jt(e),h(t),T(n)},d,w,W,p);(0,Q.useEffect)(()=>{F&&Ft()},[F,Ft]);function Lt(){if(!(Ht.length>1)&&Ye){if(ge.some(cs)){$t();return}Nt()}}function Rt(){if(!(Ht.length>1)&&Xe&&Pt()&&et.length>0){let e=et[0];ot(e),e===`tasks`&&!Mu().hasSeenTasksHint&&ju(e=>e.hasSeenTasksHint?e:{...e,hasSeenTasksHint:!0})}}let[K,zt]=(0,Q.useState)({suggestions:[],selectedSuggestion:-1,commandArgumentHint:void 0}),Bt=(0,Q.useCallback)(e=>{zt(t=>typeof e==`function`?e(t):e)},[]),Vt=(0,Q.useCallback)(async(e,t=!1)=>{e=e.trimEnd();let n=pe.getState();if(n.footerSelection&&et.includes(n.footerSelection)||n.viewSelectionMode===`selecting-agent`)return;let r=Object.values(w).some(e=>e.type===`image`),i=_e.text;if((e.trim()===``||e===i)&&i&&!r&&!n.viewingAgentTaskId){if(ve.status===`active`){lt(),ut(i,{skipReset:!0}),P(i,{setCursorOffset:W,clearBuffer:kt,resetHistory:Mt},{state:ve,speculationSessionTimeSavedMs:ye,setAppState:me});return}_e.shownAt>0&&(lt(),e=i)}if(e.trim()===``&&!r)return;let a=K.suggestions.length>0&&K.suggestions.every(e=>e.description===`directory`);if(K.suggestions.length>0&&!t&&!a){X(`[onSubmit] early return: suggestions showing (count=${K.suggestions.length})`);return}_e.text&&_e.shownAt>0&&ut(e),St(`stash-hint`),await P(e,{setCursorOffset:W,clearBuffer:kt,resetHistory:Mt})},[_e,ve,ye,pe,et,K.suggestions,P,kt,Mt,ut,me,lt,w,St]),{suggestions:Ht,selectedSuggestion:Ut,commandArgumentHint:Wt,inlineGhostText:Gt,maxColumnWidth:Kt}=rS({commands:i,onInputChange:fe,onSubmit:Vt,setCursorOffset:W,input:d,cursorOffset:U,mode:p,agents:a,setSuggestionsState:Bt,suggestionsState:K,suppressSuggestions:F||It>0,markAccepted:lt,onModeChange:h}),qt=p===`prompt`&&Ht.length===0&&ct&&!we;qt&&dt(),_e.text&&!ct&&_e.shownAt===0&&!we&&(ur(`timing`,_e.text),me(e=>({...e,promptSuggestion:{text:null,promptId:null,shownAt:0,acceptedAt:0,generationRequestId:null}})));function Jt(e,t,n,r,i){h(`prompt`);let a=ke.current++,o={id:a,type:`image`,content:e,mediaType:t||`image/png`,filename:n||`Pasted image`,dimensions:r,sourcePath:i};Br(o),Dl(o),T(e=>({...e,[a]:o})),Zt((Ae.current?` `:``)+Mf(a)),Ae.current=!0}(0,Q.useEffect)(()=>{let e=new Set(kf(d).map(e=>e.id));T(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})},[d,T]);function Yt(e){Ae.current=!1;let t=se(e).replace(/\r/g,`
68
+ `).replaceAll(` `,` `);if(d.length===0){let e=xf(t);e!==`prompt`&&(h(e),t=af(t))}let n=jf(t),r=Math.min(hn-10,2);if(t.length>800||n>r){let e=ke.current++,r={id:e,type:`text`,content:t};T(t=>({...t,[e]:r})),Zt(Of(e,n))}else Zt(t)}let Xt=(0,Q.useCallback)((e,t)=>Ae.current?(Ae.current=!1,km(e,t)?` ${e}`:e):e,[]);function Zt(e){Et(d,U,w);let t=d.slice(0,U)+e+d.slice(U);fe(t),W(U+e.length)}let Qt=te(()=>{},()=>x()),$t=(0,Q.useCallback)(()=>{let e=Vr(d,U);return e?(fe(e.text),h(`prompt`),W(e.cursorOffset),e.images.length>0&&T(t=>{let n={...t};for(let t of e.images)n[t.id]=t;return n}),!0):!1},[fe,h,d,U,T]),en=(0,Q.useCallback)(()=>{if(Ot){let e=Dt();e&&(fe(e.text),W(e.cursorOffset),T(e.pastedContents))}},[Ot,Dt,fe,T]),tn=(0,Q.useCallback)(()=>{Et(d,U,w);let e=`${d.slice(0,U)}\n${d.slice(U)}`;fe(e),W(U+1)},[d,U,fe,W,Et,w]),nn=(0,Q.useCallback)(async()=>{Ie(!0);try{let e=await Vp(d,w);e.error&&xt({key:`external-editor-error`,text:e.error,color:`warning`,priority:`high`}),e.content!==null&&e.content!==d&&(Et(d,U,w),fe(e.content),W(e.content.length))}catch(e){e instanceof Error&&Hu(e),xt({key:`external-editor-error`,text:`External editor failed: ${Ll(e)}`,color:`warning`,priority:`high`})}finally{Ie(!1)}},[d,U,w,Et,fe,xt]),rn=(0,Q.useCallback)(()=>{d.trim()===``&&_!==void 0?(fe(_.text),W(_.cursorOffset),T(_.pastedContents),v(void 0)):d.trim()!==``&&(v({text:d,cursorOffset:U,pastedContents:w}),fe(``),W(0),T({}),ju(e=>e.hasUsedStash?e:{...e,hasUsedStash:!0}))},[d,U,_,fe,v,w,T]),an=(0,Q.useCallback)(()=>{Re(e=>!e),R&&z(!1)},[R]),on=(0,Q.useCallback)(()=>{Ke(e=>!e),R&&z(!1)},[R]),sn=(0,Q.useCallback)(()=>{Je(e=>!e),R&&z(!1)},[R]),cn=(0,Q.useCallback)(()=>{X(`[auto-mode] handleCycleMode: currentMode=${t.mode}`);let e=oS(t),{context:r}=sS(t);e===`plan`&&ju(e=>({...e,lastPlanModeUse:Date.now()})),me(t=>({...t,toolPermissionContext:{...r,mode:e}})),n({...r,mode:e}),R&&z(!1)},[t,me,n,R]),ln=(0,Q.useCallback)(()=>{tf().then(e=>{if(e)Jt(e.base64,e.mediaType);else{let e=Da(`chat:imagePaste`,`Chat`,`ctrl+v`),t=pu.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,Jt]),un=A();(0,Q.useEffect)(()=>{if(!(!un||V))return un.registerHandler({action:`chat:submit`,context:`Chat`,handler:()=>{Vt(d)}})},[un,V,Vt,d]),m((0,Q.useMemo)(()=>({"chat:undo":en,"chat:newline":tn,"chat:externalEditor":nn,"chat:stash":rn,"chat:modelPicker":an,"chat:thinkingToggle":sn,"chat:cycleMode":cn,"chat:imagePaste":ln}),[en,tn,nn,rn,an,sn,cn,ln]),{context:`Chat`,isActive:!V}),E(`chat:messageActions`,()=>S?.(),{context:`Chat`,isActive:!V&&!F}),E(`chat:fastMode`,on,{context:`Chat`,isActive:!V&&mr()&&$o()}),E(`help:dismiss`,()=>{z(!1)},{context:`Help`,isActive:R}),E(`app:quickOpen`,()=>{},{context:`Global`,isActive:!1}),E(`app:globalSearch`,()=>{},{context:`Global`,isActive:!1}),E(`history:search`,()=>{},{context:`Global`,isActive:!1}),E(`app:interrupt`,()=>{Ca(me)},{context:`Global`,isActive:!o&&ve.status===`active`}),m({"footer:up":()=>{if(at){je>-1?Me(e=>e-1):ot(null);return}st(-1,!0)},"footer:down":()=>{if(at){je<Qe.length-1&&Me(e=>e+1);return}if(rt){j(!0),ot(null);return}st(1)},"footer:next":()=>{st(1)},"footer:previous":()=>{st(-1)},"footer:openSelected":()=>{switch(nt){case`tasks`:j(!0),ot(null);break;case`tmux`:break;case`bg_agent`:break}},"footer:clearSelection":()=>{ot(null)},"footer:close":()=>!1},{context:`Footer`,isActive:!!nt&&!V}),ne((e,t)=>{if(!(ze||Ve||Ue)){if(Xu()===`macos`&&aS(e)){let t=iS[e],n=Tf();xt({key:`option-meta-hint`,jsx:n?(0,$.jsxs)(b,{dimColor:!0,children:[`To enable `,t,`, set `,(0,$.jsx)(b,{bold:!0,children:`Option as Meta`}),` in `,n,` preferences (⌘,)`]}):(0,$.jsxs)(b,{dimColor:!0,children:[`To enable `,t,`, run /terminal-setup`]}),priority:`immediate`,timeoutMs:5e3})}if(nt&&e&&!t.ctrl&&!t.meta&&!t.escape&&!t.return){jt(d.slice(0,U)+e+d.slice(U)),W(U+e.length);return}if(U===0&&(t.escape||t.backspace||t.delete||t.ctrl&&e===`u`)&&(h(`prompt`),z(!1)),R&&d===``&&(t.backspace||t.delete)&&z(!1),t.escape){if(ve.status===`active`){Ca(me);return}if(L&&I){I();return}if(R){z(!1);return}if(nt)return;if(ge.some(cs)){$t();return}c.length>0&&!d&&!o&&Qt()}t.return&&R&&z(!1)}});let dn=mr()?nr():!1,fn=mr()?Ce&&($o()||dn):!1,pn=Dw(fn??!1),{columns:mn,rows:hn}=ae(),gn=mn-3,_n=or()?Math.max(kw,Math.floor(hn/2)-Ow):void 0,yn=(0,Q.useCallback)(e=>{if(!d||F)return;let t=ff.fromText(d,gn,U),n=t.getViewportStartLine(_n),r=t.measuredText.getOffsetFromPosition({line:e.localRow+n,column:e.localCol});W(r)},[d,gn,F,U,_n]),bn=(0,Q.useCallback)(e=>j(e??!0),[j]),xn=qt&&ct?ct:At,Sn=(0,Q.useMemo)(()=>d.includes(`
69
+ `),[d]),Cn=(0,Q.useCallback)(e=>{let t=!1;me(n=>(t=mr()&&!jr(e)&&!!n.fastMode,{...n,mainLoopModel:e,mainLoopModelForSession:null,...t&&{fastMode:!1}})),Re(!1);let n=(Ce??!1)&&!t,r=`Model set to ${bd(e)}`;sm(e,n,xd())&&(r+=` · Billed as extra usage`),t&&(r+=` · Fast mode OFF`),xt({key:`model-switched`,jsx:(0,$.jsx)(b,{children:r}),priority:`immediate`,timeoutMs:3e3})},[me,xt,Ce]),wn=(0,Q.useCallback)(()=>{Re(!1)},[]),Tn=(0,Q.useMemo)(()=>Le?(0,$.jsx)(g,{flexDirection:`column`,marginTop:1,children:(0,$.jsx)(cm,{initial:be,sessionModel:xe,onSelect:Cn,onCancel:wn,isStandaloneCommand:!0,showFastModeNotice:mr()&&Ce&&jr(be)&&$o()})}):null,[Le,be,xe,Cn,wn]),En=(0,Q.useCallback)(e=>{Ke(!1),e&&xt({key:`fast-mode-toggled`,jsx:(0,$.jsx)(b,{children:e}),priority:`immediate`,timeoutMs:3e3})},[xt]),Dn=(0,Q.useMemo)(()=>Ge?(0,$.jsx)(g,{flexDirection:`column`,marginTop:1,children:(0,$.jsx)(Cm,{onDone:En,unavailableReason:Tr()})}):null,[Ge,En]),On=(0,Q.useCallback)(e=>{me(t=>({...t,thinkingEnabled:e})),Je(!1),xt({key:`thinking-toggled-hotkey`,jsx:(0,$.jsxs)(b,{color:e?`suggestion`:void 0,dimColor:!e,children:[`Thinking `,e?`on`:`off`]}),priority:`immediate`,timeoutMs:3e3})},[me,xt]),kn=(0,Q.useCallback)(()=>{Je(!1)},[]),An=(0,Q.useMemo)(()=>qe?(0,$.jsx)(g,{flexDirection:`column`,marginTop:1,children:(0,$.jsx)(cS,{currentValue:Se??!0,onSelect:On,onCancel:kn,isMidConversation:c.some(e=>e.type===`assistant`)})}):null,[qe,Se,On,kn,c.length]);if(Bm(null),k)return(0,$.jsx)(Zm,{onDone:()=>j(!1),toolUseContext:N(c,[],new AbortController,oe),initialDetailTaskId:typeof k==`string`?k:void 0});if(Tn)return Tn;if(Dn)return Dn;if(An)return An;let jn={multiline:!0,onSubmit:Vt,onChange:jt,value:De?af(typeof De==`string`?De:De.display):d,onHistoryUp:Lt,onHistoryDown:Rt,onHistoryReset:Mt,placeholder:xn,onExit:M,onExitMessage:(e,t)=>ue({show:e,key:t}),onImagePaste:Jt,columns:gn,maxVisibleLines:_n,disableCursorMovementForUpDownKeys:Ht.length>0||!!nt,disableEscapeDoublePress:Ht.length>0,cursorOffset:U,onChangeCursorOffset:W,onPaste:Yt,onIsPastingChange:Pe,focus:!F&&!V&&!nt,showCursor:!nt&&!F&&!yt,argumentHint:Wt,onUndo:Ot?()=>{let e=Dt();e&&(fe(e.text),W(e.cursorOffset),T(e.pastedContents))}:void 0,highlights:bt,inlineGhostText:Gt,inputFilter:Xt},Mn=()=>{let e={bash:`bashBorder`};return e[p]?e[p]:`promptBorder`};if(Fe)return(0,$.jsx)(g,{flexDirection:`row`,alignItems:`center`,justifyContent:`center`,borderColor:Mn(),borderStyle:`round`,borderLeft:!1,borderRight:!1,borderBottom:!0,width:`100%`,children:(0,$.jsx)(b,{dimColor:!0,italic:!0,children:`Save and close editor to continue...`})});let Nn=Om()?(0,$.jsx)(sC,{...jn,initialMode:D,onModeChange:O}):(0,$.jsx)(yf,{...jn});return(0,$.jsxs)(g,{flexDirection:`column`,marginTop:1,children:[!or()&&(0,$.jsx)(hw,{}),re&&(0,$.jsx)(g,{marginTop:1,marginLeft:2,children:(0,$.jsx)(b,{dimColor:!0,children:`Waiting for permission…`})}),(0,$.jsx)(gw,{hasStash:_!==void 0}),(0,$.jsxs)(g,{flexDirection:`row`,alignItems:`flex-start`,justifyContent:`flex-start`,borderColor:Mn(),borderStyle:`round`,borderLeft:!1,borderRight:!1,borderBottom:!0,width:`100%`,borderText:Mw(fn??!1,pn,dn),children:[(0,$.jsx)(aw,{mode:p,isLoading:o}),(0,$.jsx)(g,{flexGrow:1,flexShrink:1,onClick:yn,children:Nn})]}),(0,$.jsx)(nw,{apiKeyStatus:r,debug:e,exitMessage:H,vimMode:Om()?D:void 0,mode:p,autoUpdaterResult:u,isAutoUpdating:ce,verbose:s,onAutoUpdaterResult:l,onChangeIsUpdating:le,suggestions:Ht,selectedSuggestion:Ut,maxColumnWidth:Kt,toolPermissionContext:t,helpOpen:R,suppressHint:d.length>0,isLoading:o,tasksSelected:rt,tmuxSelected:it,mcpClients:C,isPasting:Ne,isInputWrapped:Sn,messages:c,isSearching:F,historyQuery:Te,setHistoryQuery:Ee,historyFailedMatch:Oe,onOpenTasksDialog:or()?bn:void 0}),or()?(0,$.jsx)(g,{position:`absolute`,marginTop:-1,height:+(Ht.length===0),width:`100%`,paddingLeft:2,paddingRight:1,flexDirection:`column`,justifyContent:`flex-end`,overflow:`hidden`,children:(0,$.jsx)(bb,{apiKeyStatus:r,autoUpdaterResult:u,debug:e,isAutoUpdating:ce,verbose:s,messages:c,onAutoUpdaterResult:l,onChangeIsUpdating:le,mcpClients:C,isInputWrapped:Sn})}):null]})}function jw(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=kf(e.text);for(let e of n)e.id>t&&(t=e.id)}}}return t+1}function Mw(e,t,n){if(e)return{content:` ${t?`${xm(!0,n)} ${I.dim(`/fast`)}`:xm(!0,n)} `,position:`top`,align:`end`,offset:0}}var Nw=Q.memo(Aw);function Pw(e){return{onBeforeQuery:async()=>!0,onTurnComplete:async()=>{},render:()=>null}}ni(),rr(),Tc();function Fw(){return!1}function Iw(){return!1}oo();function Lw(e){(0,Q.useEffect)(()=>{let t=()=>{Fw()&&process.stdout.write(`\n${Ds()}\n`),ac(e?.())};return process.on(`exit`,t),()=>{process.off(`exit`,t)}},[])}function Rw(){(0,Q.useEffect)(()=>{},[])}function zw(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])}function Bw(){let[e]=(0,Q.useState)(`valid`),[t]=(0,Q.useState)(null);return{status:e,reverify:(0,Q.useCallback)(async()=>{},[]),error:t}}V(),Oc(),Zu(),Y();function Vw({screen:e,setScreen:t,showAllInTranscript:n,setShowAllInTranscript:r,messageCount:i,onEnterTranscript:a,onExitTranscript:o,virtualScrollActive:s,searchBarOpen:c=!1}){let l=G(e=>e.expandedView),u=vn(),d=(0,Q.useCallback)(()=>{u(e=>({...e,expandedView:e.expandedView===`tasks`?`none`:`tasks`}))},[l,u]),f=(0,Q.useCallback)(()=>{let n=e!==`transcript`;t(e=>e===`transcript`?`prompt`:`transcript`),r(!1),n&&a&&a(),!n&&o&&o()},[e,t,n,r,i,u,a,o]),p=(0,Q.useCallback)(()=>{r(e=>!e)},[n,r,i]),m=(0,Q.useCallback)(()=>{t(`prompt`),r(!1),o&&o()},[t,n,r,i,o]);E(`app:toggleTodos`,d,{context:`Global`}),E(`app:toggleTranscript`,f,{context:`Global`}),E(`app:toggleTerminal`,(0,Q.useCallback)(()=>{},[]),{context:`Global`}),E(`app:redraw`,(0,Q.useCallback)(()=>{S.get(process.stdout)?.forceRedraw()},[]),{context:`Global`});let h=e===`transcript`;return E(`transcript:toggleShowAll`,p,{context:`Transcript`,isActive:h&&!s}),E(`transcript:exit`,m,{context:`Transcript`,isActive:h&&!c}),null}Bf(),Jo(),Oc();var Hw={setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}};function Uw({onSubmit:e,isActive:t=!0}){let n=A(),r=Rf(),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 m((0,Q.useMemo)(()=>{let t={};for(let n of i){let r=n.slice(8);t[n]=()=>{e(`/${r}`,Hw,void 0,{fromKeybinding:!0})}}return t},[i,e]),{context:`Chat`,isActive:t&&!r}),null}Zu(),Y(),jm(),Cf(),Bf(),Vs(),Oc(),nc(),wt();var Ww=3e3;function Gw(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=Oi(),g=vn(),_=mb().length,{addNotification:v,removeNotification:y}=Sf(),b=(0,Q.useRef)(0),x=(0,Q.useCallback)(()=>{if(o!==void 0&&!o.aborted){t(()=>[]),n();return}if(ms()&&s){s();return}t(()=>[]),n()},[o,s,t,n,m]),S=zf(),C=o!==void 0&&!o.aborted,w=_>0,T=f!==void 0&&f!==`prompt`&&!p,D=a!==`transcript`&&!u&&!i&&!l&&!d&&!S&&!(Om()&&c===`INSERT`),O=D&&(C||w)&&!T,k=D&&(C||w);E(`chat:cancel`,x,{context:`Chat`,isActive:O});let A=(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;Ko(e,g);let n=[];for(let[e,r]of t)Io(e,g),n.push(r.description),xl(e,`stopped`,{toolUseId:r.toolUseId,summary:r.description});return _i({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 E(`app:interrupt`,(0,Q.useCallback)(()=>{(C||w)&&x()},[C,w,x]),{context:`Global`,isActive:k}),E(`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<=Ww){b.current=0,y(`kill-agents-confirm`),ll(),A();return}b.current=t;let n=Da(`chat:killAgents`,`Chat`,`ctrl+x ctrl+k`);v({key:`kill-agents-confirm`,text:`Press ${n} again to stop background agents`,priority:`immediate`,timeoutMs:Ww})},[h,v,y,A]),{context:`Chat`}),null}V(),Y(),Lo();function Kw(e){let t=G(e=>e.tasks),n=Object.values(t).some(wa),r=t=>{if(t.shift&&(t.key===`up`||t.key===`down`)){t.preventDefault(),n&&e?.onOpenBackgroundTasks?.();return}};return ne((e,t,n)=>{r(new T(n.keypress))}),{handleKeyDown:r}}Bu();async function qw(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?Hu(e):Hu(Error(`Automated permission check failed: ${String(e)}`))}return null}Zu(),Kd(),Gl(),js(),In(),ar(),on();function Jw(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 Yw(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){kn({tool:e,input:a?.input??t,toolUseContext:n,messageId:s,toolUseID:i},r,a?.permissionPromptStartTimeMs)},logCancelled(){Gd(e.name)},async persistPermissions(e){return e.length===0?!1:(Fr(e),a(bt(n.getAppState().toolPermissionContext,e)),e.some(e=>nn(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?bo:Fc}${t}`:a?$a:gs,s=a?o:ko(o);return(r||!t&&!i?.length&&!a)&&(X(`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 Ai(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&&(X(`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 Xw(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))}}}function Zw(e,t){let{ctx:n,description:r,result:i,awaitAutomatedChecksBeforeDialog:a}=e,{resolve:o,isResolved:s,claim:c}=Jw(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 Tt(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))})()}no(),Gl(),Il(),Bu(),Ti(),on();function Qw(e,t){return(0,Q.useCallback)(async(n,r,i,a,o,s)=>new Promise(c=>{let l=Yw(n,r,i,a,o,t,Xw(e));if(!l.resolveIfAborted(c))return(s===void 0?Tt(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`:kn({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 qw({ctx:l,updatedInput:e.updatedInput,suggestions:e.suggestions,permissionMode:t.toolPermissionContext.mode});if(n){c(n);return}}if(l.resolveIfAborted(c))return;Zw({ctx:l,description:a,result:e,awaitAutomatedChecksBeforeDialog:t.toolPermissionContext.awaitAutomatedChecksBeforeDialog},c);return}}).catch(e=>{e instanceof Pl||e instanceof Vl?(X(`Permission check threw ${e.constructor.name} for tool=${n.name}: ${e.message}`),l.logCancelled(),c(l.cancelAndAbort(void 0,!0))):(Hu(e),c(l.cancelAndAbort(void 0,!0)))}).finally(()=>{})}),[e,t])}cr(),Zu(),sr(),Nf(),Al(),Gl(),Il(),Bu(),wt(),yd(),md();function $w(){Ho(0)}async function eT(e){let{helpers:t,queryGuard:n,isExternalLoading:r=!1,commands:i,onInputChange:a,setPastedContents:o,setToolJSX:s,getToolUseContext:c,messages:l,mainLoopModel:u,setUserInputOnProcessing:d,setAbortController:f,onQuery:p,setAppState:m,onBeforeQuery:h,canUseTool:g,queuedCommands:_,uuid:v,skipSlashCommands:y,bridgeOrigin:b}=e,{setCursorOffset:x,clearBuffer:S,resetHistory:C}=t;if(_?.length){La(),await tT({queuedCommands:_,messages:l,mainLoopModel:u,querySource:e.querySource,commands:i,queryGuard:n,setToolJSX:s,getToolUseContext:c,setUserInputOnProcessing:d,setAbortController:f,onQuery:p,setAppState:m,onBeforeQuery:h,resetHistory:C,canUseTool:g,onInputChange:a});return}let w=e.input??``,T=e.mode??`prompt`,E=e.pastedContents??{},D=new Set(kf(w).map(e=>e.id)),O=Object.fromEntries(Object.entries(E).filter(([,e])=>e.type!==`image`||D.has(e.id))),k=Object.values(O).some(Ua);if(w.trim()===``)return;if(!y&&[`exit`,`quit`,`:q`,`:q!`,`:wq`,`:wq!`].includes(w.trim())){i.find(e=>e.name===`exit`)?eT({...e,input:`/exit`}):$w();return}let A=Af(w,O),j=kf(w).filter(e=>O[e.id]?.type===`text`);if(j.length,j.reduce((e,t)=>e+(O[t.id]?.content.length??0),0),!y&&A.trim().startsWith(`/`)){let t=A.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&&an(e)&&(e.name===f||e.aliases?.includes(f)||_r(e)===f));if(m&&m.type===`local-jsx`&&(n.isActive||r)){m.name,a(``),x(0),o({}),S();let t=c(l,[],Ol(),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?rl({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(T!==`prompt`&&T!==`bash`)return;e.hasInterruptibleToolInProgress&&(X(`[interrupt] Aborting current turn: streamMode=${e.streamMode}`),e.streamMode,e.abortController?.abort(`interrupt`)),rl({value:A.trim(),preExpansionValue:w.trim(),mode:T,pastedContents:k?O:void 0,skipSlashCommands:y,bridgeOrigin:b,uuid:v}),a(``),x(0),o({}),C(),S();return}La(),await tT({queuedCommands:[{value:A,preExpansionValue:w,mode:T,pastedContents:k?O:void 0,skipSlashCommands:y,bridgeOrigin:b,uuid:v}],messages:l,mainLoopModel:u,querySource:e.querySource,commands:i,queryGuard:n,setToolJSX:s,getToolUseContext:c,setUserInputOnProcessing:d,setAbortController:f,onQuery:p,setAppState:m,onBeforeQuery:h,resetHistory:C,canUseTool:g,onInputChange:a})}async function tT(e){let{messages:t,mainLoopModel:n,querySource:r,queryGuard:i,setToolJSX:a,getToolUseContext:o,setUserInputOnProcessing:s,setAbortController:c,onQuery:l,setAppState:u,onBeforeQuery:d,resetHistory:f,canUseTool:p,queuedCommands:m}=e,h=Ol();c(h);function g(){return o(t,[],h,n)}try{i.reserve(),pl(`query_process_user_input_start`);let o=[],_=!1,v,y,b,x,S=m??[],C=await Un(S);S=C.attachmentCommands;let w=C.claimedCommands;if(S.length===0){c(null);return}let T=S[0]?.workload,E=T!==void 0&&S.every(e=>e.workload===T)?T:void 0,D=new Set,O;try{await Sd(E,async()=>{for(let e=0;e<S.length;e++){let n=S[e],i=e===0,c=n.autonomy?.runId,l=await Zf({input:n.value,preExpansionInput:n.preExpansionValue,mode:n.mode,setToolJSX:a,context:g(),pastedContents:i?n.pastedContents:void 0,messages:t,setUserInputOnProcessing:i?s:void 0,isAlreadyProcessing:!i,querySource:r,canUseTool:p,uuid:n.uuid,skipSlashCommands:n.skipSlashCommands,bridgeOrigin:n.bridgeOrigin,isMeta:n.isMeta,skipAttachments:!i,autonomy:n.autonomy});c&&l.deferAutonomyCompletion&&D.add(c);let u=n.origin??(n.mode===`task-notification`?{kind:`task-notification`}:void 0);if(u)for(let e of l.messages)e.type===`user`&&(e.origin=u);o.push(...l.messages),i&&(_=l.shouldQuery,v=l.allowedTools,y=l.model,b=l.nextInput,x=l.submitNextInput)}if(pl(`query_process_user_input_end`),ut()&&(pl(`query_file_history_snapshot_start`),o.filter(Yf).forEach(e=>{Rs(e=>{u(t=>({...t,fileHistory:e(t.fileHistory)}))},e.uuid)}),pl(`query_file_history_snapshot_end`)),o.length){f(),a({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0});let e=S[0],t=e?.mode??`prompt`,r=e&&typeof e.value==`string`?e.value:void 0,i=t===`prompt`;await l(o,h,_,v??[],y?hd(y,n):n,i?d:void 0,r)}else i.cancelReservation(),a({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0}),f(),c(null);b&&(x?rl({value:b,mode:`prompt`}):e.onInputChange(b))})}catch(e){O=e}if(w.length){let e=w.filter(e=>{let t=e.autonomy?.runId;return!t||!D.has(t)});if(O)try{await uc({commands:e,outcome:{type:`failed`,error:O},currentDir:jl(),priority:`later`,workload:E})}catch(e){Hu(Bl(e))}else try{let t=await uc({commands:e,outcome:{type:`completed`},currentDir:jl(),priority:`later`,workload:E});for(let e of t)rl(e)}catch(e){Hu(Bl(e))}}if(O)throw O}finally{i.cancelReservation(),s(void 0)}}wt();function nT(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 rT({executeInput:e}){let t=e=>e.agentId===void 0,n=Cr(t);if(!n)return{processed:!1};if(nT(n)||n.mode===`bash`)return e([di(t)]),{processed:!0};let r=n.mode,i=Ht(e=>t(e)&&!nT(e)&&e.mode===r);return i.length===0?{processed:!1}:(e(i),{processed:!0})}wt();function iT({executeQueuedInput:e,hasActiveLocalJsxUI:t,queryGuard:n}){let r=(0,Q.useSyncExternalStore)(n.subscribe,n.getSnapshot),i=(0,Q.useSyncExternalStore)(jn,Kt);(0,Q.useEffect)(()=>{r||t||i.length!==0&&rT({executeInput:e})},[i,r,e,t,n])}function aT(e,t){return e&&t&&t.length>0?yo([...e,...t],`name`):e||[]}function oT(e,t){return(0,Q.useMemo)(()=>aT(e,t),[e,t])}zr(),qf(),Rp(),Qa();function sT(e,t){return(0,Q.useMemo)(()=>t.length>0?yo([...e,...t],`name`):e,[e,t])}sr(),Bu();function cT(e,t){let n=(0,Q.useCallback)(async()=>{if(e)try{Rt(),t(await Gt(e))}catch(e){e instanceof Error&&Hu(e)}},[e,t]);(0,Q.useEffect)(()=>Ep.subscribe(n),[n])}ec(),xa(),V(),Km(),Y(),rd();function lT({task:e,selected:t}){let n=Ym(e.startTime,e.status===`running`),r=e.progress?.tokenCount??0;return(0,$.jsxs)(g,{flexDirection:`row`,width:`100%`,justifyContent:`space-between`,children:[(0,$.jsxs)(g,{flexDirection:`row`,flexShrink:1,children:[(0,$.jsx)(b,{color:e.status===`running`?`success`:void 0,children:t?`● `:`○ `}),(0,$.jsxs)(b,{bold:t,wrap:`truncate-end`,children:[e.agentType,` `,(0,$.jsx)(b,{dimColor:!0,children:e.description})]})]}),(0,$.jsx)(g,{flexShrink:0,children:(0,$.jsxs)(b,{dimColor:!0,children:[n,` · ↓ `,ad(r),` tokens`]})})]})}function uT(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 dT(){let e=Ob(),t=G(e=>e.viewingAgentTaskId),n=G(e=>e.footerSelection),r=G(e=>e.selectedBgAgentIndex);if(e.length===0)return null;let i=n===`bg_agent`,a=i?r===-1?null:e[r]?.agentId??null:t??null,o=i?r===-1:t===void 0,s=t?e.find(e=>e.agentId===t)??null:null;return(0,$.jsxs)(g,{flexDirection:`column`,width:`100%`,children:[(0,$.jsxs)(g,{flexDirection:`row`,width:`100%`,justifyContent:`space-between`,children:[(0,$.jsxs)(b,{bold:o,children:[o?`● `:`○ `,`main`]}),(0,$.jsx)(b,{dimColor:!0,children:uT(i,s)})]}),e.map(e=>(0,$.jsx)(lT,{task:e,selected:e.agentId===a},e.agentId))]})}Vu(),Al(),q(),Gl(),Fi();var fT=3e4;function pT(e){let t=(0,Q.useRef)(e);t.current=e,(0,Q.useEffect)(()=>{if(!Hn())return;let e=null,n=!1,r=!1;function i(){Hr(Date.now()+fT),e=setTimeout(()=>{if(e=null,!ot()){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 ta({basePrompt:`<${Iu}>${new Date().toLocaleTimeString()}</${Iu}>`,currentDir:jl(),shouldCreate:()=>!n});if(n){await dn({commands:e});return}let r=[];try{for(let n of e)t.current.onQueueTick(n),r.push(n)}catch(t){throw await dn({commands:e.filter(e=>!r.includes(e))}),t}})().catch(e=>X(`[Proactive] failed to create tick: ${e}`,{level:`error`})).finally(()=>{r=!1}),i()},fT)}return i(),()=>{n=!0,e!==null&&(clearTimeout(e),e=null),Hr(null)}},[Hn(),sc(),ln()])}lt(),Rc();function mT(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 hT(e){let t=Aa(e),n=mT(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 gT(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: ${Aa(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>`}Gl(),Rc(),wt();function _T(e){X(`[goal] hook: ${e}`)}function vT(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?.()){_T(`skip: queryActiveNow=true`);return}if(e.wasAborted){_T(`skip: wasAborted=true`);return}if(n.current)return;if(Kt().length>0){_T(`skip: yielding to queued user messages`);return}if(e.hasActiveLocalJsxUI){_T(`skip: activeLocalJsxUI`);return}if(e.isInPlanMode){_T(`skip: planMode`);return}let t=Sc();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=gT(t);X(`[goal] hook: budget limit reached, injecting wrap-up prompt`),rl({value:e,mode:`prompt`,priority:`now`,isMeta:!0,origin:`goal-budget-limit`,skipSlashCommands:!0});return}if(t.status!==`active`){_T(`skip: status="${t.status}" (not active)`);return}if(t.turnsExecuted>=150){to()&&(fo(),e.onMaxTurnsReached?.()),X(`[goal] hook: MAX_GOAL_TURNS (150) reached, stopping`);return}n.current=!0;let i=xs();fo();let a=hT(t);X(`[goal] hook: enqueuing turn ${i} for "${t.objective.slice(0,60)}"`),rl({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])}vm(),If(),V(),Oc(),Fs(),Y(),Au(),ou(),a();function yT({onBackgroundSession:e,isLoading:t}){let n=vn(),r=Oi(),[a,o]=(0,Q.useState)(!1),s=te(o,e,()=>{}),c=(0,Q.useCallback)(()=>{i(process.env.WORKMATE_DISABLE_BACKGROUND_TASKS)||(ks(r.getState())?($s(()=>r.getState(),n),Mu().hasUsedBackgroundTask||ju(e=>e.hasUsedBackgroundTask?e:{...e,hasUsedBackgroundTask:!0})):i(`false`)&&t&&s())},[n,r,t,s]),l=G(ks),u=i(`false`);E(`task:background`,c,{context:`Task`,isActive:l||u&&t});let f=mc(`task:background`,`Task`,`ctrl+b`),p=pu.terminal===`tmux`&&f===`ctrl+b`?`ctrl+b ctrl+b`:f;return!t||!a?null:(0,$.jsx)(g,{paddingLeft:2,children:(0,$.jsx)(b,{dimColor:!0,children:(0,$.jsx)(d,{shortcut:p,action:`background`})})})}Y();function bT({setMessages:e,setIsLoading:t,resetLoadingState:n,setAbortController:r,onBackgroundQuery:i}){let a=G(e=>e.foregroundedTaskId),o=G(e=>e.foregroundedTaskId?e.tasks[e.foregroundedTaskId]:void 0),s=vn(),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}}Wf(),tm(),im(),Cf(),Bu();function xT(e){let{addNotification:t}=Sf(),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(Hu))},[t])}function ST(){xT(async()=>(await rm()).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`}}))}Au(),Fl(),Gl(),In(),yd(),Pc(),Ui(),V(),In();function CT(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=M();e!==`blurred`&&e!==`unknown`||o.current?.()},[n]),(0,Q.useEffect)(()=>{M()},[n,!1])}Zu(),Au(),Gl(),a(),Il(),Bu();function wT(){return i(process.env.WORKMATE_DISABLE_OFFICIAL_MARKETPLACE_AUTOINSTALL)}var TT={MAX_ATTEMPTS:10,INITIAL_DELAY_MS:3600*1e3,BACKOFF_MULTIPLIER:2,MAX_DELAY_MS:10080*60*1e3};function ET(e){let t=TT.INITIAL_DELAY_MS*TT.BACKOFF_MULTIPLIER**e;return Math.min(t,TT.MAX_DELAY_MS)}function DT(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>=TT.MAX_ATTEMPTS||t===`policy_blocked`||r&&i<r?!1:t===`unknown`||t===`git_unavailable`||t===`gcs_unavailable`||t===void 0}async function OT(){let e=Mu();if(!DT(e)){let t=e.officialMarketplaceAutoInstallFailReason??`already_attempted`;return X(`Official marketplace auto-install skipped: ${t}`),{installed:!1,skipped:!0,reason:t}}try{if(wT())return X(`Official marketplace auto-install disabled via env var, skipping`),ju(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`policy_blocked`})),{installed:!1,skipped:!0,reason:`policy_blocked`};if((await ro())[`claude-plugins-official`])return X(`Official marketplace '${Ta}' already installed, skipping`),ju(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!0})),{installed:!1,skipped:!0,reason:`already_installed`};if(!fs(Zc))return X(`Official marketplace blocked by enterprise policy, skipping`),ju(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`policy_blocked`})),{installed:!1,skipped:!0,reason:`policy_blocked`};let t=Ya(),n=dh(t,Ta);if(await za(n,t)!==null){let e=await ro();return e[Ta]={source:Zc,installLocation:n,lastUpdated:new Date().toISOString()},await ba(e),ju(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!0,officialMarketplaceAutoInstallFailReason:void 0,officialMarketplaceAutoInstallRetryCount:void 0,officialMarketplaceAutoInstallLastAttemptTime:void 0,officialMarketplaceAutoInstallNextRetryTime:void 0})),{installed:!0,skipped:!1}}if(!await ao()){X(`Git not available, skipping official marketplace auto-install`);let t=(e.officialMarketplaceAutoInstallRetryCount||0)+1,n=Date.now(),r=n+ET(t),i=!1;try{ju(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`git_unavailable`,officialMarketplaceAutoInstallRetryCount:t,officialMarketplaceAutoInstallLastAttemptTime:n,officialMarketplaceAutoInstallNextRetryTime:r}))}catch(e){i=!0,Hu(Bl(e)),X(`Failed to save marketplace auto-install git_unavailable state: ${e}`,{level:`error`})}return{installed:!1,skipped:!0,reason:`git_unavailable`,configSaveFailed:i}}return X(`Attempting to auto-install official marketplace`),await Xo(Zc),X(`Successfully auto-installed official marketplace`),e.officialMarketplaceAutoInstallRetryCount,ju(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!0,officialMarketplaceAutoInstallFailReason:void 0,officialMarketplaceAutoInstallRetryCount:void 0,officialMarketplaceAutoInstallLastAttemptTime:void 0,officialMarketplaceAutoInstallNextRetryTime:void 0})),{installed:!0,skipped:!1}}catch(t){let n=t instanceof Error?t.message:String(t);if(n.includes(`xcrun: error:`))return ic(),X(`Official marketplace auto-install: git is a non-functional macOS xcrun shim, treating as git_unavailable`),{installed:!1,skipped:!0,reason:`git_unavailable`};X(`Failed to auto-install official marketplace: ${n}`,{level:`error`}),Hu(Bl(t));let r=(e.officialMarketplaceAutoInstallRetryCount||0)+1,i=Date.now(),a=i+ET(r),o=!1;try{ju(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`unknown`,officialMarketplaceAutoInstallRetryCount:r,officialMarketplaceAutoInstallLastAttemptTime:i,officialMarketplaceAutoInstallNextRetryTime:a}))}catch(e){o=!0,Hu(Bl(e)),X(`Failed to save marketplace auto-install failure state: ${e}`,{level:`error`})}return{installed:!1,skipped:!0,reason:`unknown`,configSaveFailed:o}}}V(),Gl();function kT(){xT(async()=>{let e=await OT(),t=[];return e.configSaveFailed&&(X(`Showing marketplace config save failure notification`),t.push({key:`marketplace-config-save-failed`,jsx:(0,$.jsx)(b,{color:`error`,children:`Failed to save marketplace retry info · Check ~/.workmate.json permissions`}),priority:`immediate`,timeoutMs:1e4})),e.installed?(X(`Showing marketplace installation success notification`),t.push({key:`marketplace-installed`,jsx:(0,$.jsx)(b,{color:`success`,children:`✓ Official marketplace installed · /plugin to see available plugins`}),priority:`immediate`,timeoutMs:7e3})):e.skipped&&e.reason===`unknown`&&(X(`Showing marketplace installation failure notification`),t.push({key:`marketplace-install-failed`,jsx:(0,$.jsx)(b,{color:`warning`,children:`Failed to install official marketplace · Will retry on next startup`}),priority:`immediate`,timeoutMs:8e3})),t})}wu(),Zu();function AT(e){if(e.length===0)return;if(e.length===1)return e[0];let t=e.map(e=>({tip:e,sessions:th(e.id)}));return t.sort((e,t)=>t.sessions-e.sessions),t[0]?.tip}async function jT(e){if(yu().spinnerTipsEnabled===!1)return;let t=await rh(e);if(t.length!==0)return AT(t)}function MT(e){nh(e.id),e.id,e.cooldownSessions}Il(),Bu(),Y();async function NT(e,t,n){}function PT(){let e=G(e=>e.mainLoopModel),t=G(e=>e.mainLoopModelForSession),n=G(e=>e.fastMode),r=vn(),i=Oi(),a=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>{a.current&&(a.current=!1),NT(i.getState().toolPermissionContext,r,n).catch(e=>{Hu(Error(`Auto mode gate check failed`,{cause:Bl(e)}))})},[e,t,n])}Oa();function FT(e,t,n){let r=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{!ut()||r.current||(r.current=!0,e&&hc(e,n))},[t,e,n])}V(),vc(),np(),Tm();function IT({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`},...Wa()?[]:[{label:(0,$.jsxs)(b,{children:[`Yes, and don't ask again for `,(0,$.jsx)(b,{bold:!0,children:e})]}),value:`yes-dont-ask-again`}],{label:(0,$.jsxs)(b,{children:[`No, and tell Work Mate what to do differently `,(0,$.jsx)(b,{bold:!0,children:`(esc)`})]}),value:`no`}];return(0,$.jsx)(Dm,{title:`Network request outside of sandbox`,children:(0,$.jsxs)(g,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsxs)(g,{children:[(0,$.jsx)(b,{dimColor:!0,children:`Host:`}),(0,$.jsxs)(b,{children:[` `,e]})]}),(0,$.jsx)(g,{marginTop:1,children:(0,$.jsx)(b,{children:`Do you want to allow this connection?`})}),(0,$.jsx)(g,{children:(0,$.jsx)(rp,{options:r,onChange:n,onCancel:()=>{t({allow:!1,persistToSettings:!1})}})})]})})}V(),vc(),Yu();function LT(e){return`${e.getHours()%12||12}:${String(e.getMinutes()).padStart(2,`0`)}:${String(e.getSeconds()).padStart(2,`0`)}${e.getHours()<12?`am`:`pm`}`}function RT(){let[e,t]=(0,Q.useState)([]),[n,r]=(0,Q.useState)(0);return(0,Q.useEffect)(()=>{let e=Ea.getSandboxViolationStore();return e.subscribe(n=>{t(n.slice(-10)),r(e.getTotalCount())})},[]),!Ea.isSandboxingEnabled()||Xu()===`linux`||n===0?null:(0,$.jsxs)(g,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(g,{marginLeft:0,children:(0,$.jsxs)(b,{color:`permission`,children:[`⧈ Sandbox blocked `,n,` total `,n===1?`operation`:`operations`]})}),e.map((e,t)=>(0,$.jsx)(g,{paddingLeft:2,children:(0,$.jsxs)(b,{dimColor:!0,children:[LT(e.timestamp),e.command?` ${e.command}:`:``,` `,e.line]})},`${e.timestamp.getTime()}-${t}`)),(0,$.jsx)(g,{paddingLeft:2,children:(0,$.jsxs)(b,{dimColor:!0,children:[`… showing last `,Math.min(10,e.length),` of `,n]})})]})}hm(),Cf(),V();var zT=[];function BT({mcpClients:e=zT}){let{addNotification:t}=Sf();(0,Q.useEffect)(()=>{let n=e.filter(e=>e.type===`failed`&&e.config.type!==`sse-ide`&&e.config.type!==`ws-ide`),r=e.filter(e=>e.type===`needs-auth`);n.length===0&&r.length===0||(n.length>0&&t({key:`mcp-failed`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(b,{color:`error`,children:[n.length,` MCP `,n.length===1?`server`:`servers`,` failed`]}),(0,$.jsx)(b,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}),r.length>0&&t({key:`mcp-needs-auth`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(b,{color:`warning`,children:[r.length,` MCP `,r.length===1?`server needs`:`servers need`,` `,`auth`]}),(0,$.jsx)(b,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}))},[t,e])}V(),wu(),am();var VT=`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.`;le(),Ne(),Cf(),V(),Y(),Gl(),a();var HT=5e3;function UT(){let{addNotification:e}=Sf(),t=vn(),[n,r]=Q.useState(()=>i(`true`)),a=Q.useRef(new Set),o=Q.useCallback((n,r)=>{let i=`${n}:${r}`;if(a.current.has(i))return;a.current.add(i),X(`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)(b,{color:`error`,children:[`LSP for `,o,` failed`]}),(0,$.jsx)(b,{dimColor:!0,children:` · /plugin for details`})]}),priority:`medium`,timeoutMs:8e3})},[e,t]),s=Q.useCallback(()=>{if(Ae())return;let e=kt();if(e.status===`failed`){o(`lsp-manager`,e.error.message),r(!1);return}if(e.status===`pending`||e.status===`not-started`)return;let t=ki();if(t){let e=t.getAllServers();for(let[t,n]of e)n.state===`error`&&n.lastError&&o(t,n.lastError.message)}},[o]);F(s,n?HT:null),Q.useEffect(()=>{n&&s()},[s,n])}Gl();var WT=new Map;async function GT(e){if(!e?.trim())return X(`[binaryCheck] Empty command provided, returning false`),!1;let t=e.trim(),n=WT.get(t);if(n!==void 0)return X(`[binaryCheck] Cache hit for '${t}': ${n}`),n;let r=!1;return await Gu(t).catch(()=>null)&&(r=!0),WT.set(t,r),X(`[binaryCheck] Binary '${t}' ${r?`found`:`not found`}`),r}Au(),Gl(),zc();var KT=5;function qT(e){return Tu.has(e.toLowerCase())}function JT(e){if(!e)return null;if(typeof e==`string`)return X(`[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=XT(t);if(e)return e}return null}return XT(e)}function YT(e){return typeof e==`object`&&!!e}function XT(e){let t=new Set,n=null;for(let[r,i]of Object.entries(e)){if(!YT(i))continue;!n&&typeof i.command==`string`&&(n=i.command);let e=i.extensionToLanguage;if(YT(e))for(let n of Object.keys(e))t.add(n.toLowerCase())}return!n||t.size===0?null:{extensions:t,command:n}}async function ZT(){let e=new Map;try{let t=await ro();for(let n of Object.keys(t))try{let t=await wc(n),r=qT(n);for(let i of t.plugins){if(!i.lspServers)continue;let t=JT(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){X(`[lspRecommendation] Failed to load marketplace ${n}: ${e}`)}}catch(e){X(`[lspRecommendation] Failed to load marketplaces config: ${e}`)}return e}async function QT(e){if(tE())return X(`[lspRecommendation] Recommendations are disabled`),[];let t=uh(e).toLowerCase();if(!t)return X(`[lspRecommendation] No file extension found`),[];X(`[lspRecommendation] Looking for LSP plugins for ${t}`);let n=await ZT(),r=Mu().lspRecommendationNeverPlugins??[],i=[];for(let[e,a]of n)if(a.extensions.has(t)){if(r.includes(e)){X(`[lspRecommendation] Skipping ${e} (in never suggest list)`);continue}if(ct(e)){X(`[lspRecommendation] Skipping ${e} (already installed)`);continue}i.push({info:a,pluginId:e})}let a=[];for(let{info:e,pluginId:t}of i)await GT(e.command)?(a.push({info:e,pluginId:t}),X(`[lspRecommendation] Binary '${e.command}' found for ${t}`)):X(`[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 $T(e){ju(t=>{let n=t.lspRecommendationNeverPlugins??[];return n.includes(e)?t:{...t,lspRecommendationNeverPlugins:[...n,e]}}),X(`[lspRecommendation] Added ${e} to never suggest`)}function eE(){ju(e=>{let t=(e.lspRecommendationIgnoredCount??0)+1;return{...e,lspRecommendationIgnoredCount:t}}),X(`[lspRecommendation] Incremented ignored count`)}function tE(){let e=Mu();return e.lspRecommendationDisabled===!0||(e.lspRecommendationIgnoredCount??0)>=KT}c(),V(),Bu(),zc();function nE(){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(Hu).finally(()=>{n.current=!1}))},[e]);return{recommendation:e,clearRecommendation:Q.useCallback(()=>t(null),[]),tryResolve:r}}async function rE(e,t,n,r,i){try{let a=await Cs(e);if(!a)throw Error(`Plugin ${e} not found in marketplace`);await i(a),r({key:`${n}-installed`,jsx:(0,$.jsxs)(b,{color:`success`,children:[l.tick,` `,t,` installed · restart to apply`]}),priority:`immediate`,timeoutMs:5e3})}catch(e){Hu(e),r({key:`${n}-install-failed`,jsx:(0,$.jsxs)(b,{color:`error`,children:[`Failed to install `,t]}),priority:`immediate`,timeoutMs:5e3})}}Ne(),Cf(),Y(),Au(),Gl(),Bu(),wu();var iE=28e3;function aE(){let e=G(e=>e.fileHistory.trackedFiles),{addNotification:t}=Sf(),n=Q.useRef(new Set),{recommendation:r,clearRecommendation:i,tryResolve:a}=nE();return Q.useEffect(()=>{a(async()=>{if(Ye())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 QT(e))[0];if(t)return X(`[useLspPluginRecommendation] Found match: ${t.pluginName} for ${e}`),He(!0),{pluginId:t.pluginId,pluginName:t.pluginName,pluginDescription:t.description,fileExtension:uh(e),shownAt:Date.now()}}catch(e){Hu(e)}return null})},[e,a]),{recommendation:r,handleResponse:Q.useCallback(e=>{if(!r)return;let{pluginId:n,pluginName:a,shownAt:o}=r;switch(X(`[useLspPluginRecommendation] User response: ${e} for ${a}`),e){case`yes`:rE(n,a,`lsp-plugin`,t,async e=>{X(`[useLspPluginRecommendation] Installing plugin: ${n}`);let t=typeof e.entry.source==`string`?dh(e.marketplaceInstallLocation,e.entry.source):void 0;await Xr(n,e.entry,`user`,void 0,t),Ou(`userSettings`,{enabledPlugins:{...Du(`userSettings`)?.enabledPlugins,[n]:!0}}),X(`[useLspPluginRecommendation] Plugin installed: ${n}`)});break;case`no`:{let e=Date.now()-o;e>=iE&&(X(`[useLspPluginRecommendation] Timeout detected (${e}ms), incrementing ignored count`),eE());break}case`never`:$T(n);break;case`disable`:ju(e=>e.lspRecommendationDisabled?e:{...e,lspRecommendationDisabled:!0});break}i()},[r,t,i])}}V(),np(),Tm();var oE=3e4;function sE({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`),oE,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)(Dm,{title:`LSP Plugin Recommendation`,children:(0,$.jsxs)(g,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(g,{marginBottom:1,children:(0,$.jsx)(b,{dimColor:!0,children:`LSP provides code intelligence like go-to-definition and error checking`})}),(0,$.jsxs)(g,{children:[(0,$.jsx)(b,{dimColor:!0,children:`Plugin:`}),(0,$.jsxs)(b,{children:[` `,e]})]}),t&&(0,$.jsx)(g,{children:(0,$.jsx)(b,{dimColor:!0,children:t})}),(0,$.jsxs)(g,{children:[(0,$.jsx)(b,{dimColor:!0,children:`Triggered by:`}),(0,$.jsxs)(b,{children:[` `,n,` files`]})]}),(0,$.jsx)(g,{marginTop:1,children:(0,$.jsx)(b,{children:`Would you like to install this LSP plugin?`})}),(0,$.jsx)(g,{children:(0,$.jsx)(rp,{options:[{label:(0,$.jsxs)(b,{children:[`Yes, install `,(0,$.jsx)(b,{bold:!0,children:e})]}),value:`yes`},{label:`No, not now`,value:`no`},{label:(0,$.jsxs)(b,{children:[`Never for `,(0,$.jsx)(b,{bold:!0,children:e})]}),value:`never`},{label:`Disable all LSP recommendations`,value:`disable`}],onChange:a,onCancel:()=>r(`no`)})})]})})}Cf(),Zu(),Gl(),Dt();function cE(){let e=Q.useSyncExternalStore(Lc,xc),{addNotification:t}=Sf(),{recommendation:n,clearRecommendation:r,tryResolve:i}=nE();return Q.useEffect(()=>{e&&i(async()=>{let t=await Gi(e);return t&&(X(`[useWorkMateHintRecommendation] surfacing ${t.pluginId} from ${t.sourceCommand}`),bs()),xc()===e&&Us(),t})},[e,i]),{recommendation:n,handleResponse:Q.useCallback(e=>{if(n){switch(Qi(n.pluginId),n.pluginName,n.marketplaceName,e){case`yes`:{let{pluginId:e,pluginName:r,marketplaceName:i}=n;rE(e,r,`hint-plugin`,t,async t=>{let n=await Ei({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`:cc();break;case`no`:break}r()}},[n,t,r])}}V(),np(),Tm();var lE=3e4;function uE({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`),lE,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)(Dm,{title:`Plugin Recommendation`,children:(0,$.jsxs)(g,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(g,{marginBottom:1,children:(0,$.jsxs)(b,{dimColor:!0,children:[`The `,(0,$.jsx)(b,{bold:!0,children:r}),` command suggests installing a plugin.`]})}),(0,$.jsxs)(g,{children:[(0,$.jsx)(b,{dimColor:!0,children:`Plugin:`}),(0,$.jsxs)(b,{children:[` `,e]})]}),(0,$.jsxs)(g,{children:[(0,$.jsx)(b,{dimColor:!0,children:`Marketplace:`}),(0,$.jsxs)(b,{children:[` `,n]})]}),t&&(0,$.jsx)(g,{children:(0,$.jsx)(b,{dimColor:!0,children:t})}),(0,$.jsx)(g,{marginTop:1,children:(0,$.jsx)(b,{children:`Would you like to install it?`})}),(0,$.jsx)(g,{children:(0,$.jsx)(rp,{options:[{label:(0,$.jsxs)(b,{children:[`Yes, install `,(0,$.jsx)(b,{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`)})})]})})}np(),Tm();var dE=3e4;function fE({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(),dE,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)(Dm,{title:`Tool Recommendation`,children:(0,$.jsx)(rp,{options:a,onChange:e=>{e===`__dismiss__`?i.current():(i.current(),r.current(e))}})})}var pE=.15,mE=3;function hE(){let e=Q.useSyncExternalStore(vo,Jr),t=Q.useMemo(()=>e.length===0?[]:e.slice(0,mE).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)>=pE,handleSelect:Q.useCallback(e=>{pa()},[]),handleDismiss:Q.useCallback(()=>{pa()},[])}}Cf(),V(),Y(),Gl(),dd();function gE(){let{addNotification:e}=Sf(),t=G(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){X(`No installation status to monitor`);return}n!==0&&(X(`Plugin installation status: ${r} failed marketplaces, ${i} failed plugins`),n!==0&&(X(`Adding notification for ${n} failed installations`),e({key:`plugin-install-failed`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(b,{color:`error`,children:[n,` `,ud(n,`plugin`),` failed to install`]}),(0,$.jsx)(b,{dimColor:!0,children:` · /plugin for details`})]}),priority:`medium`})))},[e,n,r,i])}Cf(),V(),Gl(),Nm();function _E(){let{addNotification:e}=Sf(),[t,n]=(0,Q.useState)([]);(0,Q.useEffect)(()=>Pm(e=>{X(`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)(b,{color:`success`,children:[n.length===1?`Plugin`:`Plugins`,` updated: `,r]}),(0,$.jsx)(b,{dimColor:!0,children:` · Run /reload-plugins to apply`})]}),priority:`low`,timeoutMs:1e4}),X(`Showing plugin autoupdate notification for: ${n.join(`, `)}`)},[t,e])}Gl(),Bu(),zc(),Ap(),Zu();function vE(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 yE(e){X(`performBackgroundPluginInstallations called`);try{let t=Op(Ks(),await ro().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;X(`Installing ${n.length} marketplace(s) in background`);let r=await Dp({onProgress:t=>{switch(t.type){case`installing`:vE(e,t.name,`installing`);break;case`installed`:vE(e,t.name,`installed`);break;case`failed`:vE(e,t.name,`failed`,t.error);break}}});if(Eu(`info`,`tengu_marketplace_background_install`,{installed_count:r.installed.length,updated_count:r.updated.length,failed_count:r.failed.length,up_to_date_count:r.upToDate.length}),r.installed.length>0){ja(),X(`Auto-refreshing plugins after ${r.installed.length} new marketplace(s) installed`);try{await kp(e)}catch(t){Hu(t),X(`Auto-refresh failed, falling back to needsRefresh: ${t}`,{level:`warn`}),vt(`performBackgroundPluginInstallations: auto-refresh failed`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}})}}else r.updated.length>0&&(ja(),vt(`performBackgroundPluginInstallations: marketplaces reconciled`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}}))}catch(e){Hu(e)}}Au(),Gl(),zc(),Nr();async function bE(e){if(X(`performStartupChecks called`),!Nu()){X(`Trust not accepted for current directory - skipping plugin installations`);return}try{X(`Starting background plugin installations`),await Go()&&(ja(),vt(`performStartupChecks: seed marketplaces changed`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}})),await yE(e)}catch(e){X(`Error initiating background plugin installations: ${e}`)}}Cf(),V(),ei();function xE(e){let{addNotification:t}=Sf(),n=hb(),r=(0,Q.useMemo)(()=>Hs(n,e),[n,e]),i=(0,Q.useMemo)(()=>bc(n),[n]),a=(0,Q.useRef)(null),o=Iw(),[s,c]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{n.isUsingOverage&&!s&&o?(t({key:`limit-reached`,text:i,priority:`immediate`}),c(!0)):!n.isUsingOverage&&s&&c(!1)},[n.isUsingOverage,i,s,t,o]),(0,Q.useEffect)(()=>{r&&r!==a.current&&(a.current=r,t({key:`rate-limit-warning`,jsx:(0,$.jsx)(b,{children:(0,$.jsx)(b,{color:`warning`,children:r})}),priority:`high`}))},[r,t])}Cf();function SE(e){let{addNotification:t}=Sf(),n=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{let r=eh(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])}a();var CE=``;function wE(){xT(async()=>qu()||i(process.env.DISABLE_INSTALLATION_CHECKS)||await nm()===`development`?null:{timeoutMs:15e3,key:`npm-deprecation-warning`,text:CE,color:`warning`,priority:`high`})}Au();var TE=[e=>{if(DE(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(DE(e.legacyOpusMigrationTimestamp??e.opusProMigrationTimestamp))return{key:`opus-pro-update`,text:t?`Model updated to Opus 4.7 · Set WORKMATE_DISABLE_LEGACY_MODEL_REMAP=1 to opt out`:`Model updated to Opus 4.7`,color:`suggestion`,priority:`high`,timeoutMs:t?8e3:3e3}}];function EE(){xT(()=>{let e=Mu(),t=[];for(let n of TE){let r=n(e);r&&t.push(r)}return t.length>0?t:null})}function DE(e){return e!==void 0&&Date.now()-e<3e3}Cf(),Y(),_t(),rd();var OE=`fast-mode-cooldown-started`,kE=`fast-mode-cooldown-expired`,AE=`fast-mode-org-changed`,jE=`fast-mode-overage-rejected`;function ME(){let{addNotification:e}=Sf(),t=G(e=>e.fastMode),n=vn();(0,Q.useEffect)(()=>{if(mr())return Yr(r=>{r?e({key:AE,color:`fastMode`,priority:`immediate`,text:`Fast mode is now available · /fast to turn on`}):t&&(n(e=>({...e,fastMode:!1})),e({key:AE,color:`warning`,priority:`immediate`,text:`Fast mode has been disabled by your organization`}))})},[e,t,n]),(0,Q.useEffect)(()=>{if(mr())return Jn(t=>{n(e=>({...e,fastMode:!1})),e({key:jE,color:`warning`,priority:`immediate`,text:t})})},[e,n]),(0,Q.useEffect)(()=>{if(!t)return;let n=Cn((t,n)=>{let r=NE(n,od(t-Date.now(),{hideTrailingZeros:!0}));e({key:OE,invalidates:[kE],text:r,color:`warning`,priority:`immediate`})}),r=$t(()=>{e({key:kE,invalidates:[OE],color:`fastMode`,text:`Fast limit reset · now using fast mode`,priority:`immediate`})});return()=>{n(),r()}},[e,t])}function NE(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}`}}Lm(),V(),Au(),gp();function PE(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||!(Mu().copyOnSelect??!0))return;let a=e.copySelectionNoClear();if(!a?.trim()){r.current=!0;return}r.current=!0,i.current?.(a)})},[t,e])}function FE(e){let[t]=h();(0,Q.useEffect)(()=>{e.setSelectionBgColor(hp(t).selectionBg)},[e,t])}Cf(),V(),Oc(),Gl();var IE=40,LE=.3,RE=6,zE=200,BE=15,VE=15,HE=3,UE=1500,WE=150,GE=5,KE=5,qE=80,JE=3,YE=6,XE=500;function ZE(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 QE(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 $E(e,t,n){if(!e.xtermJs){if(e.wheelMode&&n-e.time>UE&&(e.wheelMode=!1,e.burstCount=0,e.mult=e.base),e.pendingFlip){if(e.pendingFlip=!1,t!==e.dir||n-e.time>zE)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<KE)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/WE),n=Math.max(VE,e.base*2),i=1+(e.mult-1)*t+BE*t;return e.mult=Math.min(n,i,e.mult+HE),Math.floor(e.mult)}if(r>IE)e.mult=e.base;else{let t=Math.max(RE,e.base*2);e.mult=Math.min(t,e.mult+LE)}return Math.floor(e.mult)}let r=n-e.time,i=t===e.dir;if(e.time=n,e.dir=t,i&&r<KE)return 1;if(!i||r>XE)e.mult=2,e.frac=0;else{let t=.5**(r/WE);e.mult=Math.min(r>=qE?JE:YE,1+(e.mult-1)*t+GE*t)}let a=e.mult+e.frac,o=Math.floor(a);return e.frac=a-o,o}function eD(){let e=process.env.WORKMATE_SCROLL_SPEED;if(!e)return 1;let t=parseFloat(e);return Number.isNaN(t)||t<=0?1:Math.min(t,20)}function tD(e=!1,t=1){return{time:0,mult:t,dir:0,xtermJs:e,frac:0,base:t,pendingFlip:!1,wheelMode:!1,burstCount:0}}function nD(){let e=z(),t=eD();return X(`wheel accel: ${e?`decay (xterm.js)`:`window (native)`} · base=${t} · TERM_PROGRAM=${process.env.TERM_PROGRAM??`unset`}`),tD(e,t)}var rD=2,iD=50,aD=200;function oD({scrollRef:e,isActive:t,onScroll:n,isModal:r=!1}){let i=B(),{addNotification:a}=Sf(),o=(0,Q.useRef)(null);function s(e){let t=ie(),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 m({"scroll:pageUp":()=>{let t=e.current;if(!t)return;let r=-Math.max(1,Math.floor(t.getViewportHeight()/2));l(t,r);let i=lD(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=lD(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=nD()),dD(t,$E(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=nD());let r=uD(t,$E(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}),m({"scroll:halfPageUp":()=>{let t=e.current;if(!t)return;let r=-Math.max(1,Math.floor(t.getViewportHeight()/2));l(t,r);let i=lD(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=lD(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=lD(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=lD(t,r);n?.(i,t)}},{context:`Scroll`,isActive:t}),ne((t,r,i)=>{let a=e.current;if(!a)return;let o=pD(a,fD(t,r),e=>l(a,e));o!==null&&(n?.(o,a),i.stopImmediatePropagation())},{isActive:t&&r}),ne((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=QE(t);if(r){i.moveFocus(r),n.stopImmediatePropagation();return}ZE(t)&&i.clearSelection()},{isActive:t}),sD(e,i,t,n),PE(i,t,s),FE(i),null}function sD(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>aD){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(rD,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(rD,e-i.getScrollTop());t.captureScrolledRows(l,l+n-1,`above`),t.shiftAnchor(-n,l,u),i.scrollBy(rD)}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,iD)))}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=cD(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 cD(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 lD(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 uD(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 dD(e,t){if(e.getScrollTop()+e.getPendingDelta()-t<=0){e.scrollTo(0);return}e.scrollBy(-t)}function fD(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 pD(e,t,n){switch(t){case null:return null;case`lineUp`:case`lineDown`:{let r=t===`lineDown`?1:-1;return n(r),lD(e,r)}case`halfPageUp`:case`halfPageDown`:{let r=Math.max(1,Math.floor(e.getViewportHeight()/2)),i=t===`halfPageDown`?r:-r;return n(i),lD(e,i)}case`fullPageUp`:case`fullPageDown`:{let r=Math.max(1,e.getViewportHeight()),i=t===`fullPageDown`?r:-r;return n(i),lD(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}}}Ne(),kc(),Ql(),c(),V(),yc(),zp(),Cf(),Gl(),a(),rd(),nc(),sr(),Qf(),oo(),Nf(),ef(),Fs(),Vs(),Il(),ar(),Fa(),Wo(),Au(),Zu(),In(),Vu(),Mo(),ga(),Vm(),dp(),js(),Kp(),Y(),Xa(),Fo(),Oa(),Fi(),li(),wt(),vl(),Mt(),vc(),rs();var mD=3e3;function hD({showAllInTranscript:e,virtualScroll:t,searchBadge:n,suppressShowAll:r=!1,status:i}){let a=mc(`app:toggleTranscript`,`Global`,`ctrl+o`),o=mc(`transcript:toggleShowAll`,`Transcript`,`ctrl+e`);return(0,$.jsxs)(g,{noSelect:!0,alignItems:`center`,alignSelf:`center`,borderTopDimColor:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,borderStyle:`single`,marginTop:1,paddingLeft:2,width:`100%`,children:[(0,$.jsxs)(b,{dimColor:!0,children:[`Showing detailed transcript · `,a,` to toggle`,n?` · n/N to navigate`:t?` · ${l.arrowUp}${l.arrowDown} scroll · home/end top/bottom`:r?``:` · ${o} to ${e?`collapse`:`show all`}`]}),i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(g,{flexGrow:1}),(0,$.jsxs)(b,{children:[i,` `]})]}):n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(g,{flexGrow:1}),(0,$.jsxs)(b,{dimColor:!0,children:[n.current,`/`,n.count,` `]})]}):null]})}function gD({jumpRef:e,count:t,current:n,onClose:r,onCancel:i,setHighlight:a,initialQuery:o}){let{query:s,cursorOffset:c}=um({isActive:!0,initialQuery:o,onExit:()=>r(s),onCancel:i}),[l,u]=Q.useState(`building`);Q.useEffect(()=>{let t=!0,n,r=e.current?.warmSearchIndex;if(!r){u(null);return}return u(`building`),r().then(e=>{t&&(e<20?u(null):(u({ms:e}),n=setTimeout(()=>t&&u(null),2e3)))}),()=>{t=!1,n&&clearTimeout(n)}},[e]);let d=l!==`building`;(0,Q.useEffect)(()=>{d&&(e.current?.setSearchQuery(s),a(s))},[e,s,a,d]);let f=c,p=f<s.length?s[f]:` `;return(0,$.jsxs)(g,{borderTopDimColor:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,borderStyle:`single`,marginTop:1,paddingLeft:2,width:`100%`,noSelect:!0,children:[(0,$.jsx)(b,{children:`/`}),(0,$.jsx)(b,{children:s.slice(0,f)}),(0,$.jsx)(b,{inverse:!0,children:p}),f<s.length&&(0,$.jsx)(b,{children:s.slice(f+1)}),(0,$.jsx)(g,{flexGrow:1}),l===`building`?(0,$.jsx)(b,{dimColor:!0,children:`indexing… `}):l?(0,$.jsxs)(b,{dimColor:!0,children:[`indexed in `,l.ms,`ms `]}):t===0&&s?(0,$.jsx)(b,{color:`error`,children:`no matches `}):t>0?(0,$.jsxs)(b,{dimColor:!0,children:[n,`/`,t,` `]}):null]})}var _D=[`⠂`,`⠐`],vD=`✳`,yD=960;function bD({isAnimating:e,title:t,disabled:n,noPrefix:r}){let i=D(),[a,o]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{if(n||r||!e||!i)return;let t=setInterval(e=>e(e=>(e+1)%_D.length),yD,o);return()=>clearInterval(t)},[n,r,e,i]);let s=e?_D[a]??vD:vD;return k(n?null:r?t:`${s} ${t}`),null}var xD=`<${zu}>`;function SD(e){return e.type===`text`&&typeof e.text==`string`&&e.text.includes(xD)}function CD({commands:t,debug:n,initialTools:r,initialMessages:a,pendingHookMessages:o,initialFileHistorySnapshots:s,initialContentReplacements:c,initialAgentName:l,initialAgentColor:u,mcpClients:d,dynamicMcpConfig:f,strictMcpConfig:p=!1,systemPrompt:m,appendSystemPrompt:_,onBeforeQuery:v,onTurnComplete:y,disabled:S=!1,mainThreadAgentDefinition:C,disableSlashCommands:w=!1,taskListId:T,thinkingConfig:E}){let O=(0,Q.useMemo)(()=>i(process.env.WORKMATE_DISABLE_TERMINAL_TITLE),[]),k=(0,Q.useMemo)(()=>i(process.env.WORKMATE_DISABLE_VIRTUAL_SCROLL),[]);(0,Q.useMemo)(()=>i(process.env.WORKMATE_DISABLE_MESSAGE_ACTIONS),[]),(0,Q.useEffect)(()=>(X(`[REPL:mount] REPL mounted, disabled=${S}`),()=>X(`[REPL:unmount] REPL unmounting`)),[S]);let[A,M]=(0,Q.useState)(C),P=G(e=>e.toolPermissionContext),F=G(e=>e.verbose),ee=G(e=>e.mcp),I=G(e=>e.plugins),te=G(e=>e.agentDefinitions),R=G(e=>e.fileHistory),z=G(e=>e.initialMessage),re=mb(),ie=G(e=>e.spinnerTip),B=G(e=>e.expandedView)===`tasks`,se=G(e=>e.tasks),V=G(e=>e.elicitation),le=G(e=>e.viewingAgentTaskId),H=vn(),ue=le?se[le]:void 0,U=Ms(ue)&&ue.retain&&!ue.diskLoaded;(0,Q.useEffect)(()=>{if(!le||!U)return;let e=le;ua(ii(e)).then(t=>{H(n=>{let r=n.tasks[e];if(!Ms(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}}}})})},[le,U,H]);let de=Oi(),fe=x(),pe=Gp(),[me,he]=(0,Q.useState)(t);cT(Ve(),he);let ge=Q.useSyncExternalStore(_o,Hn),_e=Q.useSyncExternalStore(_o,yi),ve=(0,Q.useMemo)(()=>Yt(P),[P,ge]);PT();let[ye,be]=(0,Q.useState)(f),xe=(0,Q.useCallback)(e=>{be(e)},[be]),[Se,Ce]=(0,Q.useState)(`prompt`),[we,Te]=(0,Q.useState)(!1),[Ee,De]=(0,Q.useState)(!1),[Ae,je]=(0,Q.useState)(``),Ne=(0,Q.useRef)(0),ze=(0,Q.useRef)(void 0),He=(0,Q.useRef)(!1),{addNotification:Ue,removeNotification:Ge}=Sf(),Ke=oT(d,ee.clients);EE(),BT({mcpClients:Ke}),gE(),_E(),mm(),xE(pe),ME(),SE(pe),wE(),ST(),kT(),UT();let{recommendation:Je,handleResponse:Ye}=aE(),{recommendation:Xe,handleResponse:Qe}=cE(),tt=hE(),nt=(0,Q.useMemo)(()=>[...ve,...r],[ve,r]);Uf({enabled:!0});let it=ap();(0,Q.useEffect)(()=>{bE(H)},[H]);let ot=Lp(nt,ee.tools,P),{tools:st,allowedAgentTypes:ct}=(0,Q.useMemo)(()=>{if(!A)return{tools:ot,allowedAgentTypes:void 0};let e=Jc(A,ot,!1,!0);return{tools:e.resolvedTools,allowedAgentTypes:e.allowedAgentTypes}},[A,ot]),dt=sT(sT(me,I.commands),ee.commands),ft=(0,Q.useMemo)(()=>w?[]:dt,[w,dt]),[mt,gt]=(0,Q.useState)(`responding`),_t=(0,Q.useRef)(mt);_t.current=mt;let[vt,yt]=(0,Q.useState)([]),[xt,St]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{if(xt&&!xt.isStreaming&&xt.streamingEndedAt){let e=3e4-(Date.now()-xt.streamingEndedAt);if(e>0){let t=setTimeout(St,e,null);return()=>clearTimeout(t)}else St(null)}},[xt]);let[Ct,wt]=(0,Q.useState)(null),Tt=(0,Q.useRef)(null);Tt.current=Ct;let Et=(0,Q.useRef)(0),[Dt,Ot]=(0,Q.useState)(!1),kt=(0,Q.useRef)(()=>{}),At=(0,Q.useRef)(null),jt=(0,Q.useRef)(null),Mt=(0,Q.useRef)(0),Nt=Q.useRef(new C_).current,Pt=Q.useSyncExternalStore(Nt.subscribe,Nt.getSnapshot),[Lt,Rt]=Q.useState(!1),K=Pt||Lt,[zt,Bt]=Q.useState(void 0),Vt=Q.useRef(0),Ht=Q.useRef(!1),Ut=Q.useRef(0),Wt=Q.useRef(0),Gt=Q.useRef(null),Kt=Q.useCallback(()=>{Ut.current=Date.now(),Wt.current=0,Gt.current=null},[]),Jt=Q.useRef(!1);Pt&&!Jt.current&&Kt(),Jt.current=Pt;let Xt=Q.useCallback(e=>{Rt(e),e&&Kt()},[Kt]),Zt=Q.useRef(void 0),[$t,tn]=Q.useState(!1),[nn,rn]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{nn?.notifications&&nn.notifications.forEach(e=>{Ue({key:`auto-updater-notification`,text:e,priority:`low`})})},[nn,Ue]),(0,Q.useEffect)(()=>{or()&&Ir().then(e=>{e&&Ue({key:`tmux-mouse-hint`,text:e,priority:`low`})})},[]);let[on,cn]=(0,Q.useState)(null),ln=(0,Q.useRef)(null),un=(0,Q.useCallback)(e=>{if(e?.isLocalJSXCommand){let{clearLocalJSX:t,...n}=e;ln.current={...n,isLocalJSXCommand:!0},cn(n);return}if(ln.current){if(e?.clearLocalJSX){ln.current=null,cn(null),Et.current=Date.now();return}return}if(e?.clearLocalJSX){cn(null);return}cn(e)},[]),[dn,fn]=(0,Q.useState)([]),[pn,hn]=(0,Q.useState)(null),[_n,yn]=(0,Q.useState)([]),[bn,Sn]=(0,Q.useState)([]),Cn=G(e=>e.settings.terminalTitleFromRename)===!1?void 0:mo(We()),[wn,Tn]=(0,Q.useState)(),En=(0,Q.useRef)((a?.length??0)>0),kn=A?.agentType,An=Cn??kn??wn??`Work Mate`,jn=dn.length>0||bn.length>0,Nn=on?.isLocalJSXCommand===!0&&on?.jsx!=null,Fn=K&&!jn&&!Nn;(0,Q.useEffect)(()=>{if(K&&!jn&&!Nn)return g_(),()=>__()},[K,jn,Nn]);let In=jn||Nn?`waiting`:K?`busy`:`idle`,Ln=In===`waiting`?dn.length>0?`approve ${dn[0].tool.name}`:Nn?`dialog open`:`input needed`:void 0;(0,Q.useEffect)(()=>{pt({status:In,waitingFor:Ln})},[In,Ln]),j(null);let[q,zn]=(0,Q.useState)(a??[]),Vn=(0,Q.useRef)(q),Un=(0,Q.useRef)(!1),J=(0,Q.useCallback)(e=>{let t=Vn.current,n=typeof e==`function`?e(Vn.current):e;if(Vn.current=n,n.length<Vt.current)Vt.current=0;else if(n.length>t.length&&Ht.current){let e=n.length-t.length;(t.length===0||n[0]===t[0]?n.slice(-e):n.slice(0,e)).some(qs)?Ht.current=!1:Vt.current=n.length}zn(n)},[]),qn=(0,Q.useCallback)(e=>{e===void 0?Ht.current=!1:(Vt.current=Vn.current.length,Ht.current=!0),Bt(e)},[]),{dividerIndex:Jn,dividerYRef:Yn,onScrollAway:Xn,onRepin:Zn,jumpToNew:Qn,shiftDivider:er}=Hm(q.length);CT(q,J,K);let[tr,nr]=(0,Q.useState)(null),rr=(0,Q.useRef)(null),ir=(0,Q.useMemo)(()=>zm(q,Jn),[Jn,q.length]),ar=(0,Q.useCallback)(()=>{At.current?.scrollToBottom(),Zn(),nr(null)},[Zn,nr]),sr=q.at(-1),cr=sr!=null&&qs(sr);(0,Q.useEffect)(()=>{cr&&ar()},[cr,sr,ar]);let lr=(0,Q.useCallback)((e,t)=>{Mt.current=Date.now(),e?Zn():Xn(t)},[Zn,Xn,H]),ur=zw(o,J),dr=(0,Q.useDeferredValue)(Q.useMemo(()=>q.length>500?q.slice(-500):q,[q])),fr=q.length-dr.length;fr>0&&X(`[useDeferredValue] Messages deferred by ${fr} (${dr.length}→${q.length})`);let[pr,mr]=(0,Q.useState)(null),[hr,yr]=(0,Q.useState)(()=>ih()),br=(0,Q.useRef)(hr);br.current=hr;let Sr=(0,Q.useRef)(null),Cr=(0,Q.useCallback)(e=>{br.current===``&&e!==``&&Date.now()-Mt.current>=mD&&ar(),br.current=e,yr(e),tn(e.trim().length>0)},[tn,ar]);(0,Q.useEffect)(()=>{if(hr.trim().length===0)return;let e=setTimeout(tn,1500,!1);return()=>clearTimeout(e)},[hr]);let[wr,Tr]=(0,Q.useState)(`prompt`),[Er,Dr]=(0,Q.useState)(),[Or,kr]=(0,Q.useState)(new Set),Ar=(0,Q.useRef)(!1),[jr,Nr]=(0,Q.useState)({}),[Pr,Fr]=(0,Q.useState)(0),Lr=(0,Q.useRef)(0),Rr=(0,Q.useRef)([]),zr=(0,Q.useCallback)(e=>{let t=Lr.current;if(Lr.current=e(t),Lr.current>t){let e=Rr.current;if(e.length>0){let t=e.at(-1);t.lastTokenTime=Date.now(),t.endResponseLength=Lr.current}}},[]),[Br,Hr]=(0,Q.useState)(null),Gr=!(G(e=>e.settings.prefersReducedMotion)??!1)&&!ce(),qr=(0,Q.useCallback)(e=>{Gr&&Hr(e)},[Gr]),Jr=Br&&Gr&&Br.substring(0,Br.lastIndexOf(`
120
+ `)+1)||null,[Yr,Xr]=(0,Q.useState)(0),[Zr,Qr]=(0,Q.useState)(null),[$r,ei]=(0,Q.useState)(null),[ti,ni]=(0,Q.useState)(null),[ai,oi]=(0,Q.useState)(!1),[si,ci]=(0,Q.useState)(void 0),[li,ui]=(0,Q.useState)(!1),[di,fi]=(0,Q.useState)(_h()),[pi,hi]=(0,Q.useState)(null),gi=(0,Q.useRef)(!1),_i=(0,Q.useRef)(Yr);_i.current=Yr;let[vi]=(0,Q.useState)(()=>({current:Ro(a,c)}));Ja(()=>{vi.current=xo()});let[bi,xi]=(0,Q.useState)(Mu().hasAcknowledgedCostThreshold),[Si,Ci]=(0,Q.useState)(`INSERT`),[Ti,Ei]=(0,Q.useState)(!1),[Di,ki]=(0,Q.useState)(!1),[Ai,Ni]=(0,Q.useState)(!1),Pi=D(),Fi=(0,Q.useRef)(Pi);Fi.current=Pi;let[Ii]=h(),Li=Q.useRef(!1),Ri=(0,Q.useCallback)(()=>{if(Li.current)return;Li.current=!0;let e=Vn.current.slice(ia.current);for(let t of Ba(e))ra.current.add(t);ia.current=Vn.current.length,jT({theme:Ii,readFileState:ta.current,bashTools:ra.current}).then(async e=>{if(e){let t=await e.content({theme:Ii});H(e=>({...e,spinnerTip:t})),MT(e)}else H(e=>e.spinnerTip===void 0?e:{...e,spinnerTip:void 0})})},[H,Ii]),Bi=(0,Q.useCallback)(()=>{Xt(!1),qn(void 0),Lr.current=0,Rr.current=[],Hr(null),yt([]),Qr(null),ei(null),ni(null),Ri(),Jd(),wo()},[Ri]),Vi=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(P.mode!==`auto`){Vi.current=!1;return}if(Vi.current||(Mu().autoPermissionsNotificationCount??0)>=3)return;let e=setTimeout((e,t)=>{e.current=!0,ju(e=>{let t=e.autoPermissionsNotificationCount??0;return t>=3?e:{...e,autoPermissionsNotificationCount:t+1}}),t(e=>[...e,Yi(VT,`warning`)])},800,Vi,J);return()=>clearTimeout(e)},[P.mode,J]);let Ui=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(Ui.current)return;let e=yl();if(!e?.creationDurationMs||e.usedSparsePaths||e.creationDurationMs<15e3)return;Ui.current=!0;let t=Math.round(e.creationDurationMs/1e3);J(e=>[...e,Yi(`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`)])},[J]);let Gi=(0,Q.useMemo)(()=>{let e=q.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`&&Or.has(e.id));return n.length>0&&n.every(e=>e.type===`tool_use`&&e.name===`Sleep`)},[q,Or]),{onBeforeQuery:qi,onTurnComplete:Ji,render:Xi}=Pw({enabled:!1,setMessages:J,inputValue:hr,setInputValue:Cr,setToolJSX:un}),Zi=(!on||on.showSpinner===!0)&&dn.length===0&&bn.length===0&&(K||zt||Qt()>0)&&!Gi&&!Jr;dn.length>0||bn.length>0||_n.length>0||V.queue.length,FT(s,R,e=>H(t=>({...t,fileHistory:e})));let Qi=(0,Q.useCallback)(async(t,n,r)=>{let i=performance.now();try{let a=Jf(n.messages),o=Gs();await fc(`resume`,{getAppState:()=>de.getState(),setAppState:H,signal:AbortSignal.timeout(o),timeoutMs:o});let s=await Ps(`resume`,{sessionId:t,agentType:A?.agentType,model:pe});a.push(...s),r===`fork`?zs(n,It(t)):gc(n,It(t)),Cp(n,H),n.fileHistorySnapshots&&sa(n);let{agentDefinition:c}=xp(n.agentSetting,C,te);M(c),H(e=>({...e,agent:c?.agentType})),H(e=>({...e,standaloneAgentContext:Sp(n.agentName,n.agentColor)})),lo(n.agentName),la(a,n.projectPath??Ze()),Bi(),wt(null),fi(t);let l=Vc(t);if(ac(),Le(),ke(It(t),n.fullPath?lh(n.fullPath):null),await na(),zi(),Ki(n),n.goal){let{hydrateGoalFromTranscript:r}=(lt(),e(Ur)),i=new Map;i.set(t,n.goal),r(i,t)}if(En.current=!0,Tn(void 0),r!==`fork`)wp(),Tp(n.worktreeSession),On();else{let e=yl();e&&ka(e)}l&&Pe(l),vi.current&&r!==`fork`&&(vi.current=Ao(a,n.contentReplacements??[])),J(()=>a),un(null),Cr(``),Math.round(performance.now()-i)}catch(e){throw e}},[Bi,H]),[ea]=(0,Q.useState)(()=>Hi(100)),ta=(0,Q.useRef)(ea),ra=(0,Q.useRef)(new Set),ia=(0,Q.useRef)(0),oa=(0,Q.useRef)(new Set),ca=(0,Q.useRef)(new Set),la=(0,Q.useCallback)((e,t)=>{let n=cl(e,t,100);ta.current=Gn(ta.current,n);for(let t of Ba(e))ra.current.add(t)},[]);(0,Q.useEffect)(()=>{a&&a.length>0&&la(a,Ze())},[]);let{status:da,reverify:pa}=Bw(),[ha,ga]=(0,Q.useState)(null),[_a,va]=(0,Q.useState)(!1),ya=!K&&li;function ba(){if(_a||ha)return;if(ai)return`message-selector`;if($t)return;if(_n[0])return`sandbox-permission`;let e=!on||on.shouldContinueAnimation;if(e&&dn[0])return`tool-permission`;if(e&&bn[0])return`prompt`;if(e&&V.queue[0])return`elicitation`;if(e&&ya)return`cost`;if(e&&pi)return`idle-return`;if(e&&Je)return`lsp-recommendation`;if(e&&Xe)return`plugin-hint`;if(e&&tt.visible)return`search-extra-tools-hint`}let xa=ba(),Sa=$t&&(_n[0]||dn[0]||bn[0]||V.queue[0]||ya);Zt.current=xa,(0,Q.useEffect)(()=>{if(!K)return;let e=xa===`tool-permission`,t=Date.now();e&&Gt.current===null?Gt.current=t:!e&&Gt.current!==null&&(Wt.current+=t-Gt.current,Gt.current=null)},[xa,K]);let Ca=(0,Q.useRef)(xa);(0,Q.useLayoutEffect)(()=>{Ca.current===`tool-permission`!=(xa===`tool-permission`)&&ar(),Ca.current=xa},[xa,ar]);function wa(){if(xa!==`elicitation`){if(Et.current!==0&&Date.now()-Et.current<500){Et.current=0,X(`[onCancel] suppressed: local-jsx panel just dismissed`);return}if(Et.current=0,X(`[onCancel] focusedInputDialog=${xa} streamMode=${mt}`),Pn(),Nt.getSnapshot()){let{getGoal:t,pauseGoal:n}=(Rc(),e(qa)),{persistCurrentGoal:r}=(lt(),e(Ur));t()?.status===`active`&&(n(),r())}if(Ot(!0),Nt.forceEnd(),gi.current=!1,Br?.trim()&&J(e=>[...e,mn({content:Br})]),Bi(),Re(null),xa===`tool-permission`)dn[0]?.onAbort(),fn([]);else if(xa===`prompt`){for(let e of bn)e.reject(Error(`Prompt cancelled by user`));Sn([]),Ct?.abort(`user-cancel`)}else Ct?.abort(`user-cancel`);wt(null),Ji(Vn.current,!0)}}let Ta=(0,Q.useCallback)(()=>{let e=Vr(hr,0);e&&(Cr(e.text),Tr(`prompt`),e.images.length>0&&Nr(t=>{let n={...t};for(let t of e.images)n[t.id]=t;return n}))},[Cr,Tr,hr,Nr]),Oa={setToolUseConfirmQueue:fn,onCancel:wa,onAgentsKilled:()=>J(e=>[...e,wi()]),isMessageSelectorVisible:ai||!!Ti,screen:Se,abortSignal:Ct?.signal,popCommandFromQueue:Ta,vimMode:Si,isLocalJSXCommand:on?.isLocalJSXCommand,isSearchingHistory:Di,isHelpOpen:Ai,inputMode:wr,inputValue:hr,streamMode:mt};(0,Q.useEffect)(()=>{qe()>=5&&!li&&!bi&&(xi(!0),Fw()&&ui(!0))},[q,li,bi]);let Aa=(0,Q.useCallback)(async e=>new Promise(t=>{let n=!1;function r(e){n||(n=!0,t(e))}yn(t=>[...t,{hostPattern:e,resolvePromise:r}])}),[H,de]);(0,Q.useEffect)(()=>{let e=Ea.getSandboxUnavailableReason();if(e){if(Ea.isSandboxRequired()){process.stderr.write(`\nError: sandbox required but unavailable: ${e}\n sandbox.failIfUnavailable is set — refusing to start without a working sandbox.\n\n`),Ho(1,`other`);return}X(`sandbox disabled: ${e}`,{level:`warn`}),Ue({key:`sandbox-unavailable`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(b,{color:`warning`,children:`sandbox disabled`}),(0,$.jsx)(b,{dimColor:!0,children:` · /sandbox`})]}),priority:`medium`})}},[Ue]),Ea.isSandboxingEnabled()&&Ea.initialize(Aa).catch(e=>{process.stderr.write(`\n❌ Sandbox Error: ${Ll(e)}\n`),Ho(1,`other`)});let ja=(0,Q.useCallback)((e,t)=>{H(n=>({...n,toolPermissionContext:{...e,mode:t?.preserveMode?n.toolPermissionContext.mode:e.mode}})),setImmediate(e=>{e(e=>(e.forEach(e=>{e.recheckPermission()}),e))},fn)},[H,fn]),Ma=Qw(fn,ja),Na=(0,Q.useCallback)((e,t,r,i)=>{let a=de.getState(),o=()=>{let e=de.getState(),t=Ft(e.toolPermissionContext,e.mcp.tools),n=Kf(nt,t,e.toolPermissionContext.mode);return A?Jc(A,n,!1,!0).resolvedTools:n};return{abortController:r,options:{commands:ft,tools:o(),debug:n,verbose:a.verbose,mainLoopModel:i,thinkingConfig:a.thinkingEnabled===!1?{type:`disabled`}:E,mcpClients:aT(d,a.mcp.clients),mcpResources:a.mcp.resources,isNonInteractiveSession:!1,dynamicMcpConfig:ye,theme:Ii,agentDefinitions:ct?{...a.agentDefinitions,allowedAgentTypes:ct}:a.agentDefinitions,customSystemPrompt:m,appendSystemPrompt:_,refreshTools:o},getAppState:()=>de.getState(),setAppState:H,messages:e,setMessages:J,updateFileHistoryState(e){H(t=>{let n=e(t.fileHistory);return n===t.fileHistory?t:{...t,fileHistory:n}})},updateAttributionState(e){H(t=>{let n=e(t.attribution);return n===t.attribution?t:{...t,attribution:n}})},openMessageSelector:()=>{S||oi(!0)},onChangeAPIKey:pa,readFileState:ta.current,setToolJSX:un,addNotification:Ue,appendSystemMessage:e=>J(t=>[...t,e]),sendOSNotification:e=>{i_(e,fe)},onChangeDynamicMcpConfig:xe,nestedMemoryAttachmentTriggers:new Set,loadedNestedMemoryPaths:ca.current,dynamicSkillDirTriggers:new Set,discoveredSkillNames:oa.current,setResponseLength:zr,pushApiMetricsEntry:void 0,setStreamMode:gt,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:kr,setHasInterruptibleToolInProgress:e=>{Ar.current=e},resume:Qi,setConversationId:fi,requestPrompt:void 0,contentReplacementState:vi.current}},[ft,nt,A,n,d,ye,Ii,ct,de,H,pa,Ue,J,xe,Qi,(0,Q.useCallback)((e,t)=>n=>new Promise((r,i)=>{Sn(a=>[...a,{request:n,title:e,toolInputSummary:t,resolve:r,reject:i}])}),[]),S,m,_,fi]),{handleBackgroundSession:Pa}=bT({setMessages:J,setIsLoading:Xt,resetLoadingState:Bi,setAbortController:wt,onBackgroundQuery:(0,Q.useCallback)(()=>{Ct?.abort(`background`);let e=sn(e=>e.mode===`task-notification`);(async()=>{let t=Na(Vn.current,[],new AbortController,pe),[n,r,i]=await Promise.all([Js(t.options.tools,pe,Array.from(P.additionalWorkingDirectories.keys()),t.options.mcpClients),en(),Mr()]),a=es({mainThreadAgentDefinition:A,toolUseContext:t,customSystemPrompt:m,defaultSystemPrompt:n,appendSystemPrompt:_});t.renderedSystemPrompt=a;let o=(await ho(e).catch(()=>[])).map(Kr),s=new Set;for(let e of Vn.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)));ml({messages:[...Vn.current,...c],queryParams:{systemPrompt:a,userContext:r,systemContext:i,canUseTool:Ma,toolUseContext:t,querySource:xr()},description:An,setAppState:H,agentDefinition:A})})()},[Ct,pe,P,A,Na,m,_,Ma,H])}),Fa=(0,Q.useCallback)(t=>{$i(t,t=>{if(Mi(t)?(or()?J(e=>{let n=ri(e,{includeSnipped:!0});return[...n.length>500?n.slice(-500):n,t]}):J(()=>[t]),fi(_h()),aa(!1)):t.type===`progress`&&_l(t.data?.type)?J(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]}):J(e=>[...e,t]),t.type===`assistant`&&`isApiErrorMessage`in t&&t.isApiErrorMessage?aa(!0):t.type===`assistant`&&aa(!1),t.type===`assistant`&&`isApiErrorMessage`in t&&t.isApiErrorMessage){let n=(Mn(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}=(Rc(),e(qa)),{persistCurrentGoal:r}=(lt(),e(Ur));t()?.status===`active`&&(n(),r(),Ue({key:`goal-auto-paused-connectivity-error`,text:`Detected connection error. Active goal was auto-paused. Run /goal resume after network recovers.`,priority:`immediate`}))}}},e=>{zr(t=>t+e.length)},gt,yt,e=>{J(t=>t.filter(t=>t!==e)),Wn(e.uuid)},St,e=>{let t=Date.now(),n=Lr.current;Rr.current.push({...e,firstTokenTime:t,lastTokenTime:t,responseLengthBaseline:n,endResponseLength:n})},qr)},[J,zr,gt,yt,St,qr]),Ia=(0,Q.useCallback)(async(e,t,n,r,i,a)=>{if(r){let e=aT(d,de.getState().mcp.clients);ul.handleQueryStart(e)}if(Ld(),!O&&!Cn&&!kn&&!En.current){let e=t.find(e=>e.type===`user`&&!e.isMeta),n=e?.type===`user`?Mn(e.message.content):null;n&&!n.startsWith(`<local-command-stdout>`)&&!n.startsWith(`<command-message>`)&&!n.startsWith(`<command-name>`)&&!n.startsWith(`<bash-input>`)&&(En.current=!0,_p(n,new AbortController().signal).then(e=>{e?Tn(e):En.current=!1},()=>{En.current=!1}))}if(de.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(Mi)&&(fi(_h()),aa(!1)),Bi(),wt(null);return}let o=Na(e,t,n,a),{tools:s,mcpClients:c}=o.options;pl(`query_context_loading_start`);let[,,l,u,f]=await Promise.all([void 0,NT(P,H,de.getState().fastMode),Js(s,a,Array.from(P.additionalWorkingDirectories.keys()),c),en(),Mr()]),p={...u,...Hn()&&!Fi.current?{terminalFocus:`The terminal is unfocused — the user is not actively watching.`}:{}};pl(`query_context_loading_end`);let h=es({mainThreadAgentDefinition:A,toolUseContext:o,customSystemPrompt:m,defaultSystemPrompt:l,appendSystemPrompt:_});o.renderedSystemPrompt=h,pl(`query_query_start`),Oe(),Me(),Be();for await(let t of Rn({messages:e,systemPrompt:h,userContext:p,systemContext:f,canUseTool:Ma,toolUseContext:o,querySource:xr()}))Fa(t);pl(`query_end`),Bi(),Wc(),await y?.(Vn.current)},[d,Bi,Na,P,H,m,y,_,Ma,A,Fa,Cn,O]),La=(0,Q.useCallback)(async(e,t,n,r,i,a,o)=>{let s=Nt.tryStart();if(s===null)return e.filter(e=>e.type===`user`&&!e.isMeta).map(e=>Mn(e.message.content)).filter(e=>e!==null).forEach((e,t)=>{rl({value:e,mode:`prompt`})}),!1;try{Ot(!1),Kt(),J(t=>[...t,...e]),Lr.current=0,Re((o?Is(o):null)??et()),Rr.current=[],yt([]),Hr(null);let s=Vn.current;if(o&&await qi(o,s,e.length),a&&o&&!await a(o,s))return!0;await Ia(s,e,t,n,r,i)}finally{if(Nt.end(s)){Ot(t.signal.aborted),Xr(Date.now()),gi.current=!1,Bi(),await Ji(Vn.current,t.signal.aborted);let e;et()!==null&&et()>0&&!t.signal.aborted&&(e={tokens:Fe(),limit:et(),nudges:rt()}),Re(null);let n=Date.now()-Ut.current-Wt.current;(n>3e4||e!==void 0)&&!t.signal.aborted&&!ge&&J(t=>[...t,ma(n,e,ku(t,sl))]),wt(null)}if(t.signal.reason===`user-cancel`&&!Nt.isActive&&br.current===``&&Qt()===0&&!de.getState().viewingAgentTaskId){let e=Vn.current,t=e.findLast(Yf);t&&Xf(e,e.lastIndexOf(t))&&(Ff(),kt.current(t))}}return!0},[Ia,H,Bi,Nt,qi,Ji]),Ra=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{let e=z;if(!e||K||Ra.current)return;Ra.current=!0;async function t(e){if(e.clearContext){let t=e.message.planContent?Ys():void 0,{clearConversation:n}=await import(`./conversation-CHesBfFZ.js`);await n({setMessages:J,readFileState:ta.current,discoveredSkillNames:oa.current,loadedNestedMemoryPaths:ca.current,getAppState:()=>de.getState(),setAppState:H,setConversationId:fi}),En.current=!1,Tn(void 0),ra.current.clear(),ia.current=0,t&&Es(We(),t)}H(t=>{let n=e.mode?bt(t.toolPermissionContext,_y(e.mode,e.allowedPrompts)):t.toolPermissionContext;return e.mode===`auto`&&(n=ls({...n,mode:`auto`,prePlanMode:void 0})),{...t,initialMessage:null,toolPermissionContext:n}}),ut()&&Rs(e=>{H(t=>({...t,fileHistory:e(t.fileHistory)}))},e.message.uuid),await ur();let t=e.message.message.content;if(typeof t==`string`&&!e.message.planContent)za(t,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}});else{let t=Ol();wt(t),La([e.message],t,!0,[],pe)}setTimeout(e=>{e.current=!1},100,Ra)}t(e)},[z,K,J,H,La,pe,st]);let za=(0,Q.useCallback)(async(e,t,n,r)=>{if(ar(),Wi(),!n&&e.trim().startsWith(`/`)){let n=Af(e,jr).trim(),i=n.indexOf(` `),a=i===-1?n.slice(1):n.slice(1,i),o=i===-1?``:n.slice(i+1).trim(),s=ft.find(e=>an(e)&&(e.name===a||e.aliases?.includes(a)||_r(e)===a));s?.name===`clear`&&Un.current&&(Un.current,Math.round((Date.now()-_i.current)/6e4),Vn.current.length,$e(),Un.current=!1);let c=Nt.isActive&&(s?.immediate||r?.fromKeybinding);if(s&&c&&s.type===`local-jsx`){e.trim()===br.current.trim()&&(Cr(``),t.setCursorOffset(0),t.clearBuffer(),Nr({}));let n=kf(e).filter(e=>jr[e.id]?.type===`text`);n.length,n.reduce((e,t)=>e+(jr[t.id]?.content.length??0),0),s.name,r?.fromKeybinding,(async()=>{let e=!1,n=(n,r)=>{e=!0,un({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0});let i=[];if(n&&r?.display!==`skip`&&(Ue({key:`immediate-${s.name}`,text:n,priority:`immediate`}),!or())){let e=r?.displayArgs??o;i.push(Kn(so(_r(s),e)),Kn(`<${Fu}>${mi(n)}</${Fu}>`))}r?.metaMessages?.length&&i.push(...r.metaMessages.map(e=>ht({content:e,isMeta:!0}))),i.length&&J(e=>[...e,...i]),Er!==void 0&&(Cr(Er.text),t.setCursorOffset(Er.cursorOffset),Nr(Er.pastedContents),Dr(void 0))},r=Na(Vn.current,[],Ol(),pe),i=await(await s.load()).call(n,r,o);i&&!e&&un({jsx:i,shouldHidePromptInput:!1,isLocalJSXCommand:!0})})();return}}Number(process.env.WORKMATE_IDLE_THRESHOLD_MINUTES??75),Number(process.env.WORKMATE_IDLE_TOKEN_THRESHOLD??1e5),r?.fromKeybinding||(Pf({display:n?e:bf(e,wr),pastedContents:n?{}:jr}),wr===`bash`&&ux(e.trim()));let i=!n&&e.trim().startsWith(`/`),a=!K||n;if(Er!==void 0&&!i&&a?(Cr(Er.text),t.setCursorOffset(Er.cursorOffset),Nr(Er.pastedContents),Dr(void 0)):a&&(r?.fromKeybinding||(Cr(``),t.setCursorOffset(0)),Nr({})),a&&(Tr(`prompt`),Fr(e=>e+1),t.clearBuffer(),Li.current=!1,!i&&wr===`prompt`&&!n&&(qn(e),Kt()),H(e=>({...e,attribution:Co(e.attribution,e=>{$n(e).catch(e=>{X(`Attribution: Failed to save snapshot: ${e}`)})})}))),n){let{queryRequired:t}=await Yc(n.state,n.speculationSessionTimeSavedMs,n.setAppState,e,{setMessages:J,readFileState:ta,cwd:Ze()});if(t){let e=Ol();wt(e),La([],e,!0,[],pe)}return}await ur(),await eT({input:e,helpers:t,queryGuard:Nt,isExternalLoading:Lt,mode:wr,commands:ft,onInputChange:Cr,setPastedContents:Nr,setToolJSX:un,getToolUseContext:Na,messages:Vn.current,mainLoopModel:pe,pastedContents:jr,setUserInputOnProcessing:qn,setAbortController:wt,abortController:Ct,onQuery:La,setAppState:H,querySource:xr(),onBeforeQuery:v,canUseTool:Ma,addNotification:Ue,setMessages:J,streamMode:_t.current,hasInterruptibleToolInProgress:Ar.current}),(i||K)&&Er!==void 0&&(Cr(Er.text),t.setCursorOffset(Er.cursorOffset),Nr(Er.pastedContents),Dr(void 0))},[Nt,K,Lt,wr,ft,Cr,Tr,Nr,Fr,un,Na,pe,jr,qn,wt,Ue,La,Er,Dr,H,v,Ma,J,ur,ar]),Va=(0,Q.useRef)(za);Va.current=za;let Ha=(0,Q.useCallback)(async()=>{if(va(!0),fa()){bh(`tmux`,[`detach-client`],{stdio:`ignore`}),va(!1);return}if(yl()!==null){ga((0,$.jsx)(ym,{showWorktree:!0,onDone:()=>{},onCancel:()=>{ga(null),va(!1)}}));return}let e=await(await Dn.load()).call(()=>{});ga(e),e===null&&va(!1)},[]),Ua=(0,Q.useCallback)(()=>{oi(e=>!e)},[]),Wa=(0,Q.useCallback)(e=>{let t=Vn.current,n=t.lastIndexOf(e);if(n===-1)return;t.length,t.length-n,J(t.slice(0,n)),fi(_h()),gn();let r=e.permissionMode;H(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}}))},[J,H]),Ga=(0,Q.useCallback)(e=>{Wa(e);let t=xn(e);if(t&&(Cr(t.text),Tr(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}}}),Nr(n)}}},[Wa,Cr]);kt.current=Ga;let Ka=(0,Q.useCallback)(async e=>{setImmediate((e,t)=>e(t),Ga,e)},[Ga]),Ya=e=>{let t=e.slice(0,24);return q.findIndex(e=>e.uuid.slice(0,24)===t)},{enter:Xa,handlers:Za}=co(tr,nr,rr,{copy:e=>void L(e).then(e=>{e&&process.stdout.write(e),Ue({key:`selection-copied`,text:`copied`,color:`success`,priority:`immediate`,timeoutMs:2e3})}),edit:async e=>{let t=Ya(e.uuid),n=t>=0?q[t]:void 0;if(!n||!Yf(n))return;let r=!await jc(R,n.uuid),i=Xf(q,t);r&&i?(wa(),Ka(n)):(ci(n),oi(!0))}});async function Qa(){pa();let e=await qt();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
+ `);X(`Loaded ${e.length} AGENTS.md/rules files:\n${t}`)}else X(`No AGENTS.md/rules files found`);for(let t of e)ta.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})}Lw(Qm()),w_(q,q.length===a?.length),Rw();let $a=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(re.length<1){$a.current=!1;return}$a.current||($a.current=!0,ju(e=>({...e,promptQueueUseCount:(e.promptQueueUseCount??0)+1})))},[re.length]),iT({executeQueuedInput:(0,Q.useCallback)(async e=>{await eT({helpers:{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}},queryGuard:Nt,commands:ft,onInputChange:()=>{},setPastedContents:()=>{},setToolJSX:un,getToolUseContext:Na,messages:q,mainLoopModel:pe,setUserInputOnProcessing:qn,setAbortController:wt,onQuery:La,setAppState:H,querySource:xr(),onBeforeQuery:v,canUseTool:Ma,addNotification:Ue,setMessages:J,queuedCommands:e})},[Nt,ft,un,Na,q,pe,qn,Ma,wt,La,Ue,H,v]),hasActiveLocalJsxUI:Nn,queryGuard:Nt}),(0,Q.useEffect)(()=>{op.recordUserActivity(),Ie(!0)},[hr,Pr]),(0,Q.useEffect)(()=>{Pr===1&&ah()},[Pr]),(0,Q.useEffect)(()=>{if(K||Pr===0||Yr===0)return;let e=setTimeout((e,t,n,r,i)=>{if(at()>e)return;let a=Date.now()-e;!t&&!n&&r.current===void 0&&a>=Mu().messageIdleNotifThresholdMs&&i_({message:`Work Mate is waiting for your input`,notificationType:`idle_prompt`},i)},Mu().messageIdleNotifThresholdMs,Yr,K,on,Zt,fe);return()=>clearTimeout(e)},[K,on,Pr,Yr,fe]),(0,Q.useEffect)(()=>{},[Yr,K,Ue,Ge]),pT({isLoading:K||z!==null,queuedCommandsLength:re.length,hasActiveLocalJsxUI:Nn,isInPlanMode:P.mode===`plan`,onQueueTick:e=>rl(e)}),vT({isLoading:K||z!==null,wasAborted:Dt,queuedCommandsLength:re.length,hasActiveLocalJsxUI:Nn,isInPlanMode:P.mode===`plan`,isQueryActiveNow:Nt.getSnapshot,onContinuationEnqueued:({turn:e,objective:t})=>{let n=`Goal auto-continue (${e}/1): continue advancing "${t}".`;J(e=>[...e,ht({content:n,isVisibleInTranscriptOnly:!0})])},onMaxTurnsReached:()=>{Ue({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(!ge){vr(null);return}if(!K){if(_e!==null&&re.length===0&&!Nn&&P.mode!==`plan`&&z===null){vr({enabled:!0,phase:`standby`,next_tick_at:_e,sleep_until:null});return}vr({enabled:!0,phase:null,next_tick_at:null,sleep_until:null})}},[z,K,Nn,ge,_e,re.length,P.mode]),(0,Q.useEffect)(()=>{re.some(e=>e.priority===`now`)&&Tt.current?.abort(`interrupt`)},[re]);let eo=(0,Q.useRef)(Qa);eo.current=Qa;let to=(0,Q.useRef)(ul);to.current=ul,(0,Q.useEffect)(()=>(eo.current(),()=>{to.current.shutdown()}),[]);let{internal_eventEmitter:no}=N(),[ro,io]=(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=()=>{io(e=>e+1)};return no?.on(`suspend`,e),no?.on(`resume`,t),()=>{no?.off(`suspend`,e),no?.off(`resume`,t)}},[no]);let ao=(0,Q.useMemo)(()=>{if(!K)return null;let e=q.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||q.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=ku(q,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}`},[q,K]),oo=(0,Q.useCallback)(()=>{mr({messagesLength:q.length,streamingToolUsesLength:vt.length})},[q.length,vt.length]),uo=(0,Q.useCallback)(()=>{mr(null)},[]),fo=or()&&!k,po=(0,Q.useRef)(null),[go,vo]=(0,Q.useState)(!1),[yo,bo]=(0,Q.useState)(``),[So,To]=(0,Q.useState)(0),[Eo,Do]=(0,Q.useState)(0),Oo=(0,Q.useCallback)((e,t)=>{To(e),Do(t)},[]);ne((e,t,n)=>{if(t.ctrl||t.meta)return;if(e===`/`){po.current?.setAnchor(),vo(!0),n.stopImmediatePropagation();return}let r=e[0];if((r===`n`||r===`N`)&&e===r.repeat(e.length)&&So>0){let t=r===`n`?po.current?.nextMatch:po.current?.prevMatch;if(t)for(let n=0;n<e.length;n++)t();n.stopImmediatePropagation()}},{isActive:Se===`transcript`&&fo&&!go&&!Ee});let{setQuery:ko,scanElement:jo,setPositions:Mo}=oe(),No=ae().columns,Po=Q.useRef(No);Q.useEffect(()=>{Po.current!==No&&(Po.current=No,(yo||go)&&(vo(!1),bo(``),To(0),Do(0),po.current?.disarmSearch(),ko(``)))},[No,yo,go,ko]),ne((e,t,n)=>{if(!(t.ctrl||t.meta)){if(e===`q`){uo(),n.stopImmediatePropagation();return}if(e===`[`&&!Ee)De(!0),Te(!0),n.stopImmediatePropagation();else if(e===`v`){if(n.stopImmediatePropagation(),He.current)return;He.current=!0;let e=Ne.current,t=t=>{e===Ne.current&&(clearTimeout(ze.current),je(t))};t(`rendering ${dr.length} messages…`),(async()=>{try{let e=Math.max(80,(process.stdout.columns??80)-6),n=(await e_(dr,st,e)).replace(/[ \t]+$/gm,``),r=dh(sh(),`cc-transcript-${Date.now()}.txt`);await vh(r,n);let i=Hp(r);t(i?`opening ${r}`:`wrote ${r} · no $VISUAL/$EDITOR set`)}catch(e){t(`render failed: ${e instanceof Error?e.message:String(e)}`)}He.current=!1,e===Ne.current&&(ze.current=setTimeout(e=>e(``),4e3,je))})()}}},{isActive:Se===`transcript`&&fo&&!go});let Fo=Se===`transcript`&&fo;(0,Q.useEffect)(()=>{Fo||(bo(``),To(0),Do(0),vo(!1),Ne.current++,clearTimeout(ze.current),De(!1),je(``))},[Fo]),(0,Q.useEffect)(()=>{ko(Fo?yo:``),Fo||Mo(null)},[Fo,yo,ko,Mo]);let Io={screen:Se,setScreen:Ce,showAllInTranscript:we,setShowAllInTranscript:Te,messageCount:q.length,onEnterTranscript:oo,onExitTranscript:uo,virtualScrollActive:fo,searchBarOpen:go},Lo=pr?dr.slice(0,pr.messagesLength):dr,zo=pr?vt.slice(0,pr.streamingToolUsesLength):vt;Kw({onOpenBackgroundTasks:Nn?void 0:()=>Ei(!0)});let Bo=le?se[le]:void 0,Vo=Bo&&Ms(Bo)?Bo:void 0,Uo=Gr||!K,Wo=Vo?.messages,Go=(0,Q.useMemo)(()=>{if(!Vo)return;let e=Wo??[];if(!Ms(Vo)||Vo.agentType!==`fork`||!Vo.prompt)return e;let t=Vo.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(SD))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=>!SD(e))}});if(i)return a;let o=n===-1?r+1:n+1,s=ht({content:Vo.prompt,timestamp:new Date(Vo.startTime).toISOString()});return[...a.slice(0,o),s,...a.slice(o)]},[Vo,Wo]),Ko=Vo?Go??[]:Uo?q:dr;if(Se===`transcript`){let e=or()&&!k&&!Ee?At:void 0,t=(0,$.jsx)(Gm,{messages:Lo,tools:st,commands:ft,verbose:!0,toolJSX:null,toolUseConfirmQueue:[],inProgressToolUseIDs:Or,isMessageSelectorVisible:!1,conversationId:di,screen:Se,agentDefinitions:te,streamingToolUses:zo,showAllInTranscript:we,isLoading:K,hidePastThinking:!0,streamingThinking:xt,scrollRef:e,jumpRef:po,onSearchMatchesChange:Oo,scanElement:jo,setPositions:Mo,disableRenderCap:Ee}),n=on&&(0,$.jsx)(g,{flexDirection:`column`,width:`100%`,children:on.jsx}),r=(0,$.jsxs)(Hf,{children:[(0,$.jsx)(bD,{isAnimating:Fn,title:An,disabled:O,noPrefix:!1}),(0,$.jsx)(Vw,{...Io}),(0,$.jsx)(Uw,{onSubmit:za,isActive:!on?.isLocalJSXCommand}),e?(0,$.jsx)(oD,{scrollRef:At,isActive:!0,isModal:!go,onScroll:()=>po.current?.disarmSearch()}):null,(0,$.jsx)(Gw,{...Oa}),e?(0,$.jsx)(Um,{scrollRef:At,scrollable:(0,$.jsxs)($.Fragment,{children:[t,n,(0,$.jsx)(RT,{})]}),bottom:go?(0,$.jsx)(gD,{jumpRef:po,initialQuery:``,count:So,current:Eo,onClose:e=>{bo(So>0?e:``),vo(!1),e||(To(0),Do(0),po.current?.setSearchQuery(``))},onCancel:()=>{vo(!1),po.current?.setSearchQuery(``),po.current?.setSearchQuery(yo),ko(yo)},setHighlight:ko}):(0,$.jsx)(hD,{showAllInTranscript:we,virtualScroll:!0,status:Ae||void 0,searchBadge:yo&&So>0?{current:Eo,count:So}:void 0})}):(0,$.jsxs)($.Fragment,{children:[t,n,(0,$.jsx)(RT,{}),(0,$.jsx)(hD,{showAllInTranscript:we,virtualScroll:!1,suppressShowAll:Ee,status:Ae||void 0})]})]});return e?(0,$.jsx)(W,{mouseTracking:gr(),children:r}):r}let qo=zt&&!Vo&&Ko.length<=Vt.current?zt:void 0,Jo=xa===`tool-permission`?(0,$.jsx)(Uy,{onDone:()=>fn(([e,...t])=>t),onReject:Ta,toolUseConfirm:dn[0],toolUseContext:Na(q,q,Ct??Ol(),pe),verbose:F,setStickyFooter:or()?hn:void 0},dn[0]?.toolUseID):null,Xo=or()&&on?.isLocalJSXCommand===!0,Zo=Xo?on.jsx:null,Qo=(0,$.jsxs)(Hf,{children:[(0,$.jsx)(bD,{isAnimating:Fn,title:An,disabled:O,noPrefix:!1}),(0,$.jsx)(Vw,{...Io}),(0,$.jsx)(Uw,{onSubmit:za,isActive:!on?.isLocalJSXCommand}),(0,$.jsx)(oD,{scrollRef:At,isActive:or()&&(Zo!=null||!xa||xa===`tool-permission`),onScroll:lr}),null,(0,$.jsx)(Gw,{...Oa}),(0,$.jsx)(Gf,{dynamicMcpConfig:ye,isStrictMcpConfig:p,children:(0,$.jsx)(Um,{scrollRef:At,overlay:Jo,modal:Zo,modalScrollRef:jt,dividerYRef:Yn,hidePill:!!Vo,newMessageCount:ir?.count??0,onPillClick:()=>{nr(null),Qn(At.current)},scrollable:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Gm,{messages:Ko,tools:st,commands:ft,verbose:F,toolJSX:on,toolUseConfirmQueue:dn,inProgressToolUseIDs:Or,isMessageSelectorVisible:ai,conversationId:di,screen:Se,streamingToolUses:vt,showAllInTranscript:we,agentDefinitions:te,isLoading:K,streamingText:K&&!Vo?Jr:null,unseenDivider:Vo?void 0:ir,scrollRef:or()?At:void 0,trackStickyPrompt:or()?!0:void 0,cursor:tr,setCursor:nr,cursorNavRef:rr}),!S&&qo&&!Zo&&(0,$.jsx)(ji,{param:{text:qo,type:`text`},addMargin:!0,verbose:F}),on&&!(on.isLocalJSXCommand&&on.isImmediate)&&!Xo&&(0,$.jsx)(g,{flexDirection:`column`,width:`100%`,children:on.jsx}),(0,$.jsx)(g,{flexGrow:1}),Zi&&(0,$.jsx)(up,{mode:mt,spinnerTip:ie,responseLengthRef:Lr,apiMetricsRef:Rr,overrideMessage:Zr,spinnerSuffix:ao,verbose:F,loadingStartTimeRef:Ut,totalPausedMsRef:Wt,pauseStartTimeRef:Gt,overrideColor:$r,overrideShimmerColor:ti,hasActiveTools:Or.size>0,leaderIsIdle:!K})]}),bottom:(0,$.jsx)(g,{flexDirection:`row`,width:`100%`,alignItems:`flex-end`,children:(0,$.jsxs)(g,{flexDirection:`column`,flexGrow:1,children:[or()&&(0,$.jsx)(hw,{}),pn,on?.isLocalJSXCommand&&on.isImmediate&&!Xo&&(0,$.jsx)(g,{flexDirection:`column`,width:`100%`,children:on.jsx}),!Zi&&!on?.isLocalJSXCommand&&B&&it&&it.length>0&&(0,$.jsx)(g,{width:`100%`,flexDirection:`column`,children:(0,$.jsx)(lp,{tasks:it,isStandalone:!0})}),xa===`sandbox-permission`&&(0,$.jsx)(IT,{hostPattern:_n[0].hostPattern,onUserResponse:e=>{let{allow:t,persistToSettings:n}=e,r=_n[0];if(!r)return;let i=r.hostPattern.host;yn(e=>(e.filter(e=>e.hostPattern.host===i).forEach(e=>e.resolvePromise(t)),e.filter(e=>e.hostPattern.host!==i)))}},_n[0].hostPattern.host),xa===`prompt`&&(0,$.jsx)(pb,{title:bn[0].title,toolInputSummary:bn[0].toolInputSummary,request:bn[0].request,onRespond:e=>{let t=bn[0];t&&(t.resolve({prompt_response:t.request.prompt,selected:e}),Sn(([,...e])=>e))},onAbort:()=>{let e=bn[0];e&&(e.reject(Error(`Prompt cancelled by user`)),Sn(([,...e])=>e))}},bn[0].request.prompt),xa===`elicitation`&&(0,$.jsx)(ub,{event:V.queue[0],onResponse:(e,t)=>{let n=V.queue[0];n&&(n.respond({action:e,content:t}),n.params.mode===`url`&&e===`accept`||H(e=>({...e,elicitation:{queue:e.elicitation.queue.slice(1)}})))},onWaitingDismiss:e=>{let t=V.queue[0];H(e=>({...e,elicitation:{queue:e.elicitation.queue.slice(1)}})),t?.onWaitingDismiss?.(e)}},`${V.queue[0].serverName}:${String(V.queue[0].requestId)}`),xa===`cost`&&(0,$.jsx)(t_,{onDone:()=>{ui(!1),xi(!0),ju(e=>({...e,hasAcknowledgedCostThreshold:!0}))}}),xa===`idle-return`&&pi&&(0,$.jsx)(n_,{idleMinutes:pi.idleMinutes,totalInputTokens:$e(),onDone:async e=>{let t=pi;if(hi(null),Math.round(t.idleMinutes),Vn.current.length,$e(),e===`dismiss`){Cr(t.input);return}if(e===`never`&&ju(e=>e.idleReturnDismissed?e:{...e,idleReturnDismissed:!0}),e===`clear`){let{clearConversation:e}=await import(`./conversation-CHesBfFZ.js`);await e({setMessages:J,readFileState:ta.current,discoveredSkillNames:oa.current,loadedNestedMemoryPaths:ca.current,getAppState:()=>de.getState(),setAppState:H,setConversationId:fi}),En.current=!1,Tn(void 0),ra.current.clear(),ia.current=0}gi.current=!0,Va.current(t.input,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}})}}),ha,xa===`plugin-hint`&&Xe&&(0,$.jsx)(uE,{pluginName:Xe.pluginName,pluginDescription:Xe.pluginDescription,marketplaceName:Xe.marketplaceName,sourceCommand:Xe.sourceCommand,onResponse:Qe}),xa===`search-extra-tools-hint`&&tt.visible&&(0,$.jsx)(fE,{tools:tt.tools,onSelect:tt.handleSelect,onDismiss:tt.handleDismiss}),xa===`lsp-recommendation`&&Je&&(0,$.jsx)(sE,{pluginName:Je.pluginName,pluginDescription:Je.pluginDescription,fileExtension:Je.fileExtension,onResponse:Ye}),Xi(),!on?.shouldHidePromptInput&&!xa&&!_a&&!S&&!tr&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Nw,{debug:n,hasSuppressedDialogs:!!Sa,isLocalJSXCommandActive:Nn,getToolUseContext:Na,toolPermissionContext:P,setToolPermissionContext:ja,apiKeyStatus:da,commands:ft,agents:te.activeAgents,isLoading:K,onExit:Ha,verbose:F,messages:q,onAutoUpdaterResult:rn,autoUpdaterResult:nn,input:hr,onInputChange:Cr,mode:wr,onModeChange:Tr,stashedPrompt:Er,setStashedPrompt:Dr,submitCount:Pr,onShowMessageSelector:Ua,onMessageActionsEnter:void 0,mcpClients:Ke,pastedContents:jr,setPastedContents:Nr,vimMode:Si,setVimMode:Ci,showBashesDialog:Ti,setShowBashesDialog:Ei,onSubmit:za,isSearchingHistory:Di,setIsSearchingHistory:ki,helpOpen:Ai,setHelpOpen:Ni,insertTextRef:Sr}),(0,$.jsx)(yT,{onBackgroundSession:Pa,isLoading:K}),(0,$.jsx)(dT,{})]}),tr&&(0,$.jsx)(Bn,{cursor:tr}),xa===`message-selector`&&(0,$.jsx)($f,{messages:q,preselectedMessage:si,onPreRestore:wa,onRestoreCode:async e=>{await Yo(e=>{H(t=>({...t,fileHistory:e(t.fileHistory)}))},e.uuid)},onSummarize:async(e,t,n=`from`)=>{let r=ri(q),i=r.indexOf(e);if(i===-1){J(e=>[...e,Yi(`That message is no longer in the active context (snipped or pre-compact). Choose a more recent message.`,`warning`)]);return}let a=Ol(),o=Na(r,[],a,pe),s=o.getAppState(),c=await Js(o.options.tools,o.options.mainLoopModel,Array.from(s.toolPermissionContext.additionalWorkingDirectories.keys()),o.options.mcpClients),l=es({mainThreadAgentDefinition:void 0,toolUseContext:o,customSystemPrompt:o.options.customSystemPrompt,defaultSystemPrompt:c,appendSystemPrompt:o.options.appendSystemPrompt}),[u,d]=await Promise.all([en(),Mr()]),f=await Wr(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(or()&&n===`from`?J(t=>{let n=t.findIndex(t=>t.uuid===e.uuid);return[...t.slice(0,n===-1?0:n),...h]}):J(h),aa(!1),fi(_h()),Ss(o.options.querySource),n===`from`){let t=xn(e);t&&(Cr(t.text),Tr(t.mode))}let g=Da(`app:toggleTranscript`,`Global`,`ctrl+o`);Ue({key:`summarize-ctrl-o-hint`,text:`Conversation summarized (${g} for history)`,priority:`medium`,timeoutMs:8e3})},onRestoreMessage:Ka,onClose:()=>{oi(!1),ci(void 0)}})]})})})},ro)]});return or()?(0,$.jsx)(W,{mouseTracking:gr(),children:Qo}):Qo}export{CD as t};