@readmagic/workmate 0.0.18 → 0.0.20

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 (384) hide show
  1. package/dist/chunks/{AddWorkspaceDirectory-Wa6Q24nu.js → AddWorkspaceDirectory-BYNvxNrD.js} +1 -1
  2. package/dist/chunks/AgentsMdExternalIncludesDialog-BSSz86ER.js +1 -0
  3. package/dist/chunks/{AgentsMdExternalIncludesDialog-3I_KlOLv.js → AgentsMdExternalIncludesDialog-CMEGV4Md.js} +1 -1
  4. package/dist/chunks/{App-BgPs1Bu8.js → App-W_9d1DjK.js} +1 -1
  5. package/dist/chunks/{ApproveApiKey-BxpapUq0.js → ApproveApiKey-Bf1Rb8Ql.js} +1 -1
  6. package/dist/chunks/ApproveApiKey-wpdvXpFr.js +1 -0
  7. package/dist/chunks/BackgroundTasksDialog-lGn1Wj1k.js +2 -0
  8. package/dist/chunks/{BypassPermissionsModeDialog-8Cq982M0.js → BypassPermissionsModeDialog-CjVjyNf8.js} +1 -1
  9. package/dist/chunks/{DiffDialog-DwQTDWYh.js → DiffDialog-DCpchgp5.js} +2 -2
  10. package/dist/chunks/Doctor-6SjW91rd.js +1 -0
  11. package/dist/chunks/Doctor-FPYTivHw.js +3 -0
  12. package/dist/chunks/ExitFlow-Dy8_1D8J.js +2 -0
  13. package/dist/chunks/{Grove-_QX_wR9C.js → Grove-Dd6rjs5P.js} +1 -1
  14. package/dist/chunks/{HybridTransport-BG2VIIBC.js → HybridTransport-CJVkWa2u.js} +1 -1
  15. package/dist/chunks/{InvalidConfigDialog-BDdMkuaL.js → InvalidConfigDialog-Bisj9ic_.js} +1 -1
  16. package/dist/chunks/{InvalidSettingsDialog-DSCqbVER.js → InvalidSettingsDialog-DyTPNRQR.js} +1 -1
  17. package/dist/chunks/MCPConnectionManager-DfyoZaiu.js +1 -0
  18. package/dist/chunks/MCPToolListView-Dioupv8F.js +1 -0
  19. package/dist/chunks/{McpParsingWarnings-Cr_n2QR6.js → McpParsingWarnings-BUlgpZAF.js} +1 -1
  20. package/dist/chunks/MessageSelector-D8fylxPg.js +3 -0
  21. package/dist/chunks/Messages-BZDFMYBT.js +10 -0
  22. package/dist/chunks/{Onboarding-Cz3CfOTl.js → Onboarding-BKLomZYo.js} +1 -1
  23. package/dist/chunks/{PromptInputFooterSuggestions-GhA5Qa1I.js → PromptInputFooterSuggestions-DCum89fF.js} +1 -1
  24. package/dist/chunks/{PromptInputHelpMenu-sX_yHORM.js → PromptInputHelpMenu-DG2lRqis.js} +1 -1
  25. package/dist/chunks/QueryEngine-CyGHpX7M.js +1 -0
  26. package/dist/chunks/REPL-BDsz8KIx.js +1 -0
  27. package/dist/chunks/REPL-CCBNfZfs.js +128 -0
  28. package/dist/chunks/RemoteSessionManager-BfsOv4K6.js +2 -0
  29. package/dist/chunks/{ResumeConversation-e5sISbWn.js → ResumeConversation-pC8NLq0F.js} +1 -1
  30. package/dist/chunks/{SSETransport-BuDKErlN.js → SSETransport-B3K6eH9I.js} +1 -1
  31. package/dist/chunks/SearchExtraToolsTool-DYoxHo9T.js +1 -0
  32. package/dist/chunks/Settings-CKaGmKg2.js +2 -0
  33. package/dist/chunks/{TeleportProgress-BUtze4qa.js → TeleportProgress-CkgSp1cs.js} +1 -1
  34. package/dist/chunks/{TeleportRepoMismatchDialog-Dp7rzrrz.js → TeleportRepoMismatchDialog-DdO_rECq.js} +1 -1
  35. package/dist/chunks/{TeleportResumeWrapper-Ch2osY21.js → TeleportResumeWrapper-BeG4N-2z.js} +1 -1
  36. package/dist/chunks/{ThemePicker-AA-0hjpq.js → ThemePicker-iD9ufy99.js} +1 -1
  37. package/dist/chunks/{TrustDialog-rO5dZ8G-.js → TrustDialog-qO5OdQt8.js} +1 -1
  38. package/dist/chunks/{ValidationErrorsList-DayOwxq9.js → ValidationErrorsList-BfZ5gcIv.js} +1 -1
  39. package/dist/chunks/add-dir-C4eSVlZ6.js +1 -0
  40. package/dist/chunks/{agentDisplay-nVTmC7tL.js → agentDisplay-BM4QG_RX.js} +1 -1
  41. package/dist/chunks/{agents-BQwi-6GV.js → agents-BbDBN5l9.js} +1 -1
  42. package/dist/chunks/agents-D3APE_8d.js +101 -0
  43. package/dist/chunks/allErrors-BkgB7JNK.js +1 -0
  44. package/dist/chunks/api-BHBK9axp.js +1 -0
  45. package/dist/chunks/{api-DAyhTxgY.js → api-DyUWfg3a.js} +1 -1
  46. package/dist/chunks/{auth-BzrroWLq.js → auth-0rn1U4Eq.js} +1 -1
  47. package/dist/chunks/auth-BEoTPSgC.js +1 -0
  48. package/dist/chunks/auth-BPug7U_u.js +1 -0
  49. package/dist/chunks/backgroundHousekeeping-D7xAhUaE.js +1 -0
  50. package/dist/chunks/backgroundHousekeeping-km82qEh0.js +17 -0
  51. package/dist/chunks/{banner-BfIcVEUU.js → banner-BkUdig-T.js} +1 -1
  52. package/dist/chunks/{bg-C15c_rMK.js → bg-tGgpwpYx.js} +2 -2
  53. package/dist/chunks/branch-CQ38cx5n.js +2 -0
  54. package/dist/chunks/{break-cache-XKbOAw-u.js → break-cache-CcwOjTKt.js} +3 -3
  55. package/dist/chunks/{bridgeConfig-Bxkrv8ZL.js → bridgeConfig-C5L-7KaP.js} +1 -1
  56. package/dist/chunks/bridgeConfig-CJMjDoaP.js +1 -0
  57. package/dist/chunks/{bridgeMessaging-BcSjIPCZ.js → bridgeMessaging-DVC3qj-C.js} +1 -1
  58. package/dist/chunks/{bridgePointer-CGhOBNMg.js → bridgePointer-DfTOjgtX.js} +1 -1
  59. package/dist/chunks/{bridgeStatusUtil-DBWBTU31.js → bridgeStatusUtil-Cex6VowM.js} +1 -1
  60. package/dist/chunks/btw-_P96ffHR.js +1 -0
  61. package/dist/chunks/caches-DH-q8Fjf.js +1 -0
  62. package/dist/chunks/caches-Dq0pJFDP.js +1 -0
  63. package/dist/chunks/{capacityWake-C24_KT1x.js → capacityWake-BpP6c7x3.js} +1 -1
  64. package/dist/chunks/{ccrClient-CH6PsxJJ.js → ccrClient-DO563xlf.js} +1 -1
  65. package/dist/chunks/{claudeDesktop-CovdLe-b.js → claudeDesktop-DPc_SaVn.js} +1 -1
  66. package/dist/chunks/{clear-D72LxXA6.js → clear-DmqQBNKg.js} +1 -1
  67. package/dist/chunks/{cliLaunch-DDA65zeR.js → cliLaunch-DDtwAolw.js} +1 -1
  68. package/dist/chunks/{client-o5_awagP.js → client-9uHzAmFH.js} +1 -1
  69. package/dist/chunks/client-BVal_QII.js +1 -0
  70. package/dist/chunks/client-C19cqYQS.js +1 -0
  71. package/dist/chunks/{client-eLOYyeES.js → client-C_jBL1yC.js} +1 -1
  72. package/dist/chunks/client-Dd7CKMRX.js +1 -0
  73. package/dist/chunks/commands-BkpqHY9F.js +1 -0
  74. package/dist/chunks/{compact--fnu8Zd-.js → compact-DuVIvqMu.js} +2 -2
  75. package/dist/chunks/config-DMP6-Ccr.js +1 -0
  76. package/dist/chunks/{config-BybjRr09.js → config-DRy1I12M.js} +2 -2
  77. package/dist/chunks/{config-BlQhL9Bh.js → config-e0Goy478.js} +1 -1
  78. package/dist/chunks/{context-D6PaqwrR.js → context-DjgMzIfe.js} +1 -1
  79. package/dist/chunks/{context-noninteractive-CxoMCfR4.js → context-noninteractive-BzDVMnWC.js} +5 -5
  80. package/dist/chunks/context-noninteractive-DV7bIJCm.js +1 -0
  81. package/dist/chunks/conversation-BBOE_EoE.js +1 -0
  82. package/dist/chunks/conversation-WxH5pb2z.js +1 -0
  83. package/dist/chunks/{createSSHSession-B3FdForb.js → createSSHSession-LVGVXHXL.js} +1 -1
  84. package/dist/chunks/createSession-BUzna9-E.js +1 -0
  85. package/dist/chunks/{createSession-C0e_DHsW.js → createSession-Dgwxk1WA.js} +1 -1
  86. package/dist/chunks/crossProjectResume-6B2NYy8a.js +40 -0
  87. package/dist/chunks/cwd-DLK3znO7.js +1 -0
  88. package/dist/chunks/cwd-Nh5IZNKO.js +1 -0
  89. package/dist/chunks/{datadog-ZxeaKwKd.js → datadog-Bc6wkPne.js} +1 -1
  90. package/dist/chunks/{debug-D7OBvqC2.js → debug-D58GQBDG.js} +1 -1
  91. package/dist/chunks/{debugUtils-B-GMBTBk.js → debugUtils-DXBRbwCE.js} +1 -1
  92. package/dist/chunks/{detached-uMuMcLsV.js → detached-Biz-xhu0.js} +1 -1
  93. package/dist/chunks/{detectRepository-AVEUw4lk.js → detectRepository-CDOJ-M7h.js} +1 -1
  94. package/dist/chunks/detectRepository-Cv9-k6dg.js +1 -0
  95. package/dist/chunks/{diff-BA2vN7sD.js → diff-DIg66U_d.js} +1 -1
  96. package/dist/chunks/{directoryCompletion-CLcmLin8.js → directoryCompletion-BDGcGDuv.js} +1 -1
  97. package/dist/chunks/doctor-BhUmhHQU.js +1 -0
  98. package/dist/chunks/{entry-cou5DS53.js → entry-B-Y-AYeK.js} +4 -4
  99. package/dist/chunks/{esm-D9-9wS1F.js → esm-CvHtYRrr.js} +1 -1
  100. package/dist/chunks/{execFileNoThrow-BHDSgTpZ.js → execFileNoThrow-Bmb5HEFz.js} +1 -1
  101. package/dist/chunks/{execSyncWrapper-pYxQXqb-.js → execSyncWrapper-C3ZFV9od.js} +1 -1
  102. package/dist/chunks/{exit-DdZJHhy2.js → exit-CW2eqUrR.js} +1 -1
  103. package/dist/chunks/{extraUsage-CHnG6JNH.js → extraUsage-CkTon7ib.js} +1 -1
  104. package/dist/chunks/extractMemories-CfmbvayQ.js +1 -0
  105. package/dist/chunks/fast-ByahC7Gw.js +1 -0
  106. package/dist/chunks/{fast-Bl_0cs9e.js → fast-xtIP4u4y.js} +1 -1
  107. package/dist/chunks/fetchModelList-D9aePIPW.js +1 -0
  108. package/dist/chunks/{fetchModelList-CheIBH5f.js → fetchModelList-Dy-x4h3G.js} +1 -1
  109. package/dist/chunks/{fileSuggestions-Dl87JhBr.js → fileSuggestions-CFkJktgc.js} +2 -2
  110. package/dist/chunks/firstPartyEventLogger-Bt9iG9xk.js +1 -0
  111. package/dist/chunks/{firstPartyEventLogger-Cw9Bc3on.js → firstPartyEventLogger-DqGSujCz.js} +2 -2
  112. package/dist/chunks/{flushGate-BD3Tk3_k.js → flushGate-BjKW7PFC.js} +1 -1
  113. package/dist/chunks/{gemini-BARUjH_t.js → gemini-NnmxBoEp.js} +1 -1
  114. package/dist/chunks/{generateSessionName-CHaK44K-.js → generateSessionName-EpqGW-T2.js} +1 -1
  115. package/dist/chunks/{genericProcessUtils-D5hCZ2ho.js → genericProcessUtils-6E7fB1dI.js} +1 -1
  116. package/dist/chunks/{git-CNhyfMtb.js → git-By_J4XJL.js} +1 -1
  117. package/dist/chunks/git-zJCasBa6.js +1 -0
  118. package/dist/chunks/githubRepoPathMapping-CzgPGOHQ.js +1 -0
  119. package/dist/chunks/{goal-fTQFogdl.js → goal-DbS8yJfB.js} +1 -1
  120. package/dist/chunks/{grok-D0J4IiCe.js → grok-BxZ4vTDw.js} +1 -1
  121. package/dist/chunks/{grove-mDH4wkhM.js → grove-CYE1Cfcz.js} +1 -1
  122. package/dist/chunks/{help-Dr7st1Yv.js → help-DatnwM25.js} +1 -1
  123. package/dist/chunks/{hooks-DCfpFhl2.js → hooks-7iyENdDG.js} +2 -2
  124. package/dist/chunks/hooks-DjbqtbUV.js +1 -0
  125. package/dist/chunks/initReplBridge-BEZW5PEY.js +1 -0
  126. package/dist/chunks/install-DJukI-kL.js +1 -0
  127. package/dist/chunks/{instrumentation-DS2S1m1a.js → instrumentation-2HH15DPu.js} +4 -4
  128. package/dist/chunks/{job-Dry-GMc5.js → job-CXz7SLZp.js} +1 -1
  129. package/dist/chunks/{jwtUtils-ClCcC8lO.js → jwtUtils-C_LG1txt.js} +1 -1
  130. package/dist/chunks/keybindings-C9l5il16.js +1 -0
  131. package/dist/chunks/{launchLocalMemory-_T0oHfh9.js → launchLocalMemory-BfGenqj1.js} +1 -1
  132. package/dist/chunks/{launchOnboarding-D4fS6pLc.js → launchOnboarding-DjMmXeQE.js} +1 -1
  133. package/dist/chunks/{loadAgentsDir-DnsldjYU.js → loadAgentsDir-DaNpxaO-.js} +588 -623
  134. package/dist/chunks/loadAgentsDir-DcI-8FQF.js +1 -0
  135. package/dist/chunks/{loadPluginHooks-CRoYa_il.js → loadPluginHooks-CGgpcyEC.js} +1 -1
  136. package/dist/chunks/{loader-C-PQ3onD.js → loader-C33o_5kS.js} +1 -1
  137. package/dist/chunks/{localSearch-nuNjYVKq.js → localSearch-C2SZ9bGW.js} +1 -1
  138. package/dist/chunks/localSearch-CTTwYTU1.js +1 -0
  139. package/dist/chunks/{log-CR0v5KUR.js → log-CZ7ploQm.js} +1 -1
  140. package/dist/chunks/{logoV2Utils-CZwL_VX1.js → logoUtils-CbIqOFrX.js} +1 -1
  141. package/dist/chunks/{magicDocs-D0rjtxup.js → magicDocs-CrTwULyJ.js} +2 -2
  142. package/dist/chunks/{main-DKqCPH3G.js → main-Blm02_Js.js} +2 -2
  143. package/dist/chunks/{main-C8n_p7yX.js → main-bJXadFi0.js} +30 -30
  144. package/dist/chunks/managedEnv-CUsdYhAI.js +1 -0
  145. package/dist/chunks/managedEnv-DXeaUDSK.js +1 -0
  146. package/dist/chunks/{mappers-BIDALdjB.js → mappers-_B-s9fNz.js} +1 -1
  147. package/dist/chunks/mcp-BbbYzWpy.js +6 -0
  148. package/dist/chunks/mcp-D91sH9a8.js +1 -0
  149. package/dist/chunks/mcp-Dx-zgUgu.js +2 -0
  150. package/dist/chunks/{memoize-C7xmvAQ0.js → memoize-CumjjK2Q.js} +1 -1
  151. package/dist/chunks/memory-BeL7ui9m.js +1 -0
  152. package/dist/chunks/{mode-CajUX4Uz.js → mode-D695kgLI.js} +1 -1
  153. package/dist/chunks/model-DX0TtzqX.js +1 -0
  154. package/dist/chunks/{model-xI2MbgRj.js → model-Do0f476p.js} +1 -1
  155. package/dist/chunks/model-DpcM8dz5.js +1 -0
  156. package/dist/chunks/{modelOptions-Ct80yABl.js → modelOptions-B3nis9cC.js} +1 -1
  157. package/dist/chunks/{src-l6_O0K-a.js → modifiersNative-BYHdmWw1.js} +1 -1
  158. package/dist/chunks/modifiersNative-D7nm70eq.js +1 -0
  159. package/dist/chunks/{nativeInstaller-C6aWHxve.js → nativeInstaller-CymO8TNe.js} +1 -1
  160. package/dist/chunks/omit-DO61BHZu.js +1 -0
  161. package/dist/chunks/onChangeAppState-vKml_lit.js +1 -0
  162. package/dist/chunks/{openai-wsPCDwGL.js → openai-DdupGVdC.js} +2 -2
  163. package/dist/chunks/{panel-BKMLX5AR.js → panel-CVd1dzYl.js} +1 -1
  164. package/dist/chunks/parser-Cq9X7HMP.js +1 -0
  165. package/dist/chunks/{parser-Dy-RMf4a.js → parser-eVu-cTRs.js} +1 -1
  166. package/dist/chunks/partition-BivH9MBJ.js +1 -0
  167. package/dist/chunks/permissions-C9iqR4_N.js +3 -0
  168. package/dist/chunks/pidLock-DiKz5Tza.js +3 -0
  169. package/dist/chunks/{plan-CTiLy_c4.js → plan-KDN5IGWY.js} +1 -1
  170. package/dist/chunks/{platform-BZm4WVLM.js → platform-DMQxcm4K.js} +1 -1
  171. package/dist/chunks/plugin-D0rzUb8E.js +17 -0
  172. package/dist/chunks/{pluginAutoupdate-DzK-fXJC.js → pluginAutoupdate-C2xTKLR_.js} +1 -1
  173. package/dist/chunks/{pluginBlocklist-B3JVl1h2.js → pluginBlocklist-xdiUmUpt.js} +1 -1
  174. package/dist/chunks/{pluginCliCommands-CubOvlhc.js → pluginCliCommands-CIDDvVN7.js} +1 -1
  175. package/dist/chunks/{pluginFlagging-Dp7W2eL8.js → pluginFlagging-DRA0m76J.js} +1 -1
  176. package/dist/chunks/pluginOperations-BEYsarAn.js +2 -0
  177. package/dist/chunks/{pluginStartupCheck-CL24_zVV.js → pluginStartupCheck-BF1N4Lih.js} +1 -1
  178. package/dist/chunks/pluginStartupCheck-DVkI4pqo.js +1 -0
  179. package/dist/chunks/{plugins-DA3lpRU4.js → plugins-CWWU4BKs.js} +4 -4
  180. package/dist/chunks/poorMode-BTIe8W_H.js +1 -0
  181. package/dist/chunks/poorMode-CKQfWf3S.js +1 -0
  182. package/dist/chunks/print-B5H2xbBS.js +14 -0
  183. package/dist/chunks/processBashCommand-EQ9EWaRV.js +1 -0
  184. package/dist/chunks/processSlashCommand-C4PKNyFT.js +5 -0
  185. package/dist/chunks/{prompt-CzQkcxfg.js → prompt-8u06WVES.js} +17 -17
  186. package/dist/chunks/prompt-B9sDzLPK.js +1 -0
  187. package/dist/chunks/prompt-WsoTRhoh.js +1 -0
  188. package/dist/chunks/{promptEditor-C6w1vT5E.js → promptEditor-Cr4w-4Bz.js} +1 -1
  189. package/dist/chunks/{protocolHandler-B3bQyB6W.js → protocolHandler-DzHVaPl3.js} +2 -2
  190. package/dist/chunks/{proxy-DFIxRT0i.js → proxy-BhIc7-mj.js} +1 -1
  191. package/dist/chunks/reconciler-RIKmaPg7.js +1 -0
  192. package/dist/chunks/refresh-CCSCAjgz.js +1 -0
  193. package/dist/chunks/registerProtocol-C0IlPEoa.js +1 -0
  194. package/dist/chunks/{reload-plugins-BnZzcRcd.js → reload-plugins-DC-tbXVv.js} +1 -1
  195. package/dist/chunks/{remoteBridgeCore-DAK9KSWp.js → remoteBridgeCore-NGTnhQgw.js} +1 -1
  196. package/dist/chunks/remoteManagedSettings-BoOYHzYP.js +1 -0
  197. package/dist/chunks/{rename-OSN3Ua2J.js → rename-DS1AmW-F.js} +1 -1
  198. package/dist/chunks/{renderOptions-XgkOdKCJ.js → renderOptions-D-aQZbzS.js} +1 -1
  199. package/dist/chunks/resume-Cf5PSoPw.js +2 -0
  200. package/dist/chunks/{ripgrep-C_XuTqp3.js → ripgrep-C3jtZL7k.js} +1 -1
  201. package/dist/chunks/ripgrep-CBUbn6Po.js +1 -0
  202. package/dist/chunks/{runtimeObserver-CuTsWhhF.js → runtimeObserver-DzesbvgI.js} +1 -1
  203. package/dist/chunks/{runtimeObserver-D9sujsqj.js → runtimeObserver-L6041elO.js} +2 -2
  204. package/dist/chunks/sandbox-adapter-Z4Phj31K.js +1 -0
  205. package/dist/chunks/{sandbox-toggle-oasrWfbj.js → sandbox-toggle-COZE8Lo4.js} +1 -1
  206. package/dist/chunks/sanitization-DV-94a9Z.js +1 -0
  207. package/dist/chunks/searchExtraTools-CvkRbL2m.js +1 -0
  208. package/dist/chunks/{session-c46jULDV.js → session-BvA99K4j.js} +1 -1
  209. package/dist/chunks/sessionFileAccessHooks-6XfAf6ke.js +1 -0
  210. package/dist/chunks/{sessionObserver-Cu7vykWp.js → sessionObserver-0D8xFoRK.js} +1 -1
  211. package/dist/chunks/sessionObserver-CRWUBJEY.js +1 -0
  212. package/dist/chunks/{sessionState-B3tFm9SC.js → sessionState-CQhbGfmh.js} +2 -2
  213. package/dist/chunks/sessionStorage-DqEuxDlb.js +1 -0
  214. package/dist/chunks/{sessionTracing-BRp_Ej-e.js → sessionTracing-BoOZsXU2.js} +1 -1
  215. package/dist/chunks/{settings-DUyIag_5.js → settings-3xZ0fsvE.js} +4 -4
  216. package/dist/chunks/settings-Crx1cI1u.js +1 -0
  217. package/dist/chunks/settingsSync-rkWmClKS.js +1 -0
  218. package/dist/chunks/setup-D8L275fT.js +3 -0
  219. package/dist/chunks/{shadowedRuleDetection-ChoqK1Iq.js → shadowedRuleDetection-Cy9tsuKc.js} +1 -1
  220. package/dist/chunks/{shellQuote-C-7PluUY.js → shellQuote-Ddgr1vif.js} +1 -1
  221. package/dist/chunks/{sideQuestion-CkC27Pf3.js → sideQuestion-Ds7Elgs4.js} +1 -1
  222. package/dist/chunks/{sinks-C9qCsi94.js → sinks-BXX72cbf.js} +1 -1
  223. package/dist/chunks/sinks-DMp6uEzM.js +1 -0
  224. package/dist/chunks/skillChangeDetector-CtithJ4a.js +1 -0
  225. package/dist/chunks/{skillGapStore-DC8s2Whn.js → skillGapStore-BxCxKPev.js} +2 -2
  226. package/dist/chunks/{skillLifecycle-BaqH5lw_.js → skillLifecycle-CfyNC3sW.js} +2 -2
  227. package/dist/chunks/{skillSearchPanel-Dtvyo2Dk.js → skillSearchPanel-CMNJFIEC.js} +3 -3
  228. package/dist/chunks/{skills-DXW57WeY.js → skills-DXMk-498.js} +1 -1
  229. package/dist/chunks/{startupProfiler-BqUlQEaV.js → startupProfiler-CbzxVmbv.js} +1 -1
  230. package/dist/chunks/startupProfiler-uHetQush.js +1 -0
  231. package/dist/chunks/state-BStOuCh4.js +1 -0
  232. package/dist/chunks/{state-B3zvBu4R.js → state-D5D6QpTX.js} +1 -1
  233. package/dist/chunks/{stats-vvwEVnon.js → stats-Ce15gc3E.js} +1 -1
  234. package/dist/chunks/{status-g_dhM6Ep.js → status-CFrLuGbf.js} +2 -2
  235. package/dist/chunks/status-D5OCkMZG.js +1 -0
  236. package/dist/chunks/{statusNoticeHelpers-B235FWru.js → statusNoticeHelpers-CZoOse-_.js} +1 -1
  237. package/dist/chunks/{stringUtils-CGZoOfer.js → stringUtils-CKD8qDqx.js} +1 -1
  238. package/dist/chunks/switcher-AiMcRzoi.js +1 -0
  239. package/dist/chunks/{switcher-OAeeTHHt.js → switcher-DQF5ZNal.js} +1 -1
  240. package/dist/chunks/syncCache-qWJ_VfBo.js +1 -0
  241. package/dist/chunks/{tasks--7yJk7MD.js → tasks-C8pb6ftc.js} +1 -1
  242. package/dist/chunks/{teleport-ja50aVy3.js → teleport-Bi_1VFIZ.js} +1 -1
  243. package/dist/chunks/{templateJobs-DSM3tNDS.js → templateJobs-DJ4dcfcL.js} +1 -1
  244. package/dist/chunks/{terminalSetup-C735-5lZ.js → terminalSetup-7PdC4fV5.js} +1 -1
  245. package/dist/chunks/{terminalSetup-BpZXqE_G.js → terminalSetup-kWdZRKWq.js} +1 -1
  246. package/dist/chunks/{theme-BX54e0r7.js → theme-CEKOCSLw.js} +1 -1
  247. package/dist/chunks/{tmux-BIdWN33b.js → tmux-CpGd0Aca.js} +1 -1
  248. package/dist/chunks/{toolEventObserver-O6ljakS9.js → toolEventObserver-D2nk8ZbW.js} +1 -1
  249. package/dist/chunks/toolPool-Df5iUqJ-.js +1 -0
  250. package/dist/chunks/{trustedDevice-Kyid5Fuy.js → trustedDevice-CB6rNzl-.js} +1 -1
  251. package/dist/chunks/trustedDevice-DXGePUAC.js +1 -0
  252. package/dist/chunks/{types-DDku8UKF.js → types-APu4OCXJ.js} +1 -1
  253. package/dist/chunks/{udsClient-B2yCKNgT.js → udsClient-U7MEfYj7.js} +1 -1
  254. package/dist/chunks/{upstreamproxy--RTAcgrE.js → upstreamproxy-CTOuotLO.js} +1 -1
  255. package/dist/chunks/{useExitOnCtrlCDWithKeybindings-BnmDpMkm.js → useExitOnCtrlCDWithKeybindings-Bw0mlTT9.js} +1 -1
  256. package/dist/chunks/useMainLoopModel-CIG2cjS2.js +1 -0
  257. package/dist/chunks/useManagePlugins-MSHw-qHx.js +1 -0
  258. package/dist/chunks/{useMergedTools-ChLA8dsy.js → useMergedTools-Bb-INJa2.js} +1 -1
  259. package/dist/chunks/{useSearchInput-DqymtQhH.js → useSearchInput-QL_VtdJD.js} +1 -1
  260. package/dist/chunks/useSettingsErrors-Dvi6zLCr.js +1 -0
  261. package/dist/chunks/{userAgent-D8vvjitA.js → userAgent-i-oGzf40.js} +1 -1
  262. package/dist/chunks/{util-CC-NRn16.js → util-CLQvtXuD.js} +1 -1
  263. package/dist/chunks/validatePlugin-1mTZ3TJR.js +1 -0
  264. package/dist/chunks/{vim-CIK2DjfK.js → vim-BagKUX4j.js} +1 -1
  265. package/dist/chunks/{which-3MmqfsNV.js → which-BxQ1hpjp.js} +1 -1
  266. package/dist/chunks/{windowsPaths-x-CxdtFP.js → windowsPaths-BdhjMYTm.js} +1 -1
  267. package/dist/chunks/windowsPaths-DtGZ83kH.js +1 -0
  268. package/dist/chunks/{workSecret-BsolC5S7.js → workSecret-CaM2yIJD.js} +1 -1
  269. package/dist/chunks/{workerRegistry-DE4Ghp-n.js → workerRegistry-BjxoZ12l.js} +2 -2
  270. package/dist/chunks/worktree-DpksgxdF.js +1 -0
  271. package/dist/cli.js +1 -1
  272. package/package.json +1 -5
  273. package/dist/chunks/AgentsMdExternalIncludesDialog-h150UBir.js +0 -1
  274. package/dist/chunks/ApproveApiKey-DIIIi6U8.js +0 -1
  275. package/dist/chunks/BackgroundTasksDialog-nfRmiGl3.js +0 -2
  276. package/dist/chunks/Doctor-Beo5yEMD.js +0 -1
  277. package/dist/chunks/Doctor-BxXAGr-Z.js +0 -3
  278. package/dist/chunks/ExitFlow-CVIuvrHT.js +0 -2
  279. package/dist/chunks/MCPConnectionManager-Cer1UawR.js +0 -1
  280. package/dist/chunks/MCPToolListView-DndNWDr1.js +0 -1
  281. package/dist/chunks/MessageSelector-BfmbAG8E.js +0 -3
  282. package/dist/chunks/Messages-CUJJ6nHV.js +0 -10
  283. package/dist/chunks/QueryEngine-C6Dx_-U8.js +0 -1
  284. package/dist/chunks/REPL-BPig-OIh.js +0 -128
  285. package/dist/chunks/REPL-e5wWV2Sl.js +0 -1
  286. package/dist/chunks/RemoteSessionManager-Cax4g0GH.js +0 -2
  287. package/dist/chunks/SearchExtraToolsTool-B_z74zwG.js +0 -1
  288. package/dist/chunks/Settings-B9rxF2wR.js +0 -2
  289. package/dist/chunks/add-dir-Cz33IGht.js +0 -1
  290. package/dist/chunks/agents-rfuJUSSc.js +0 -101
  291. package/dist/chunks/allErrors-YIRWFBD9.js +0 -1
  292. package/dist/chunks/api-CGk-0H2x.js +0 -1
  293. package/dist/chunks/attributionHooks-C0aXyx9L.js +0 -1
  294. package/dist/chunks/auth-DWWb8STf.js +0 -1
  295. package/dist/chunks/auth-DsqlBO-Q.js +0 -1
  296. package/dist/chunks/backgroundHousekeeping-CXv_Pm5h.js +0 -17
  297. package/dist/chunks/backgroundHousekeeping-Crx3oXIu.js +0 -1
  298. package/dist/chunks/branch-BEaujq-M.js +0 -2
  299. package/dist/chunks/bridgeConfig-Ctl7I_RR.js +0 -1
  300. package/dist/chunks/btw-8JqSG3o7.js +0 -1
  301. package/dist/chunks/caches-dnO4Ae_m.js +0 -1
  302. package/dist/chunks/caches-lPzD_yGv.js +0 -1
  303. package/dist/chunks/client-BFjMSlp7.js +0 -1
  304. package/dist/chunks/client-Byat5HpG.js +0 -1
  305. package/dist/chunks/client-Dzx24jGZ.js +0 -1
  306. package/dist/chunks/commands-D3lQbt9p.js +0 -1
  307. package/dist/chunks/config-CPGSP_1Z.js +0 -1
  308. package/dist/chunks/context-noninteractive-CwlOID3q.js +0 -1
  309. package/dist/chunks/conversation-BLEWB1BE.js +0 -1
  310. package/dist/chunks/conversation-Bos7yTIv.js +0 -1
  311. package/dist/chunks/createSession-B4wkDNam.js +0 -1
  312. package/dist/chunks/crossProjectResume-C5QtstD6.js +0 -40
  313. package/dist/chunks/cwd-BfiQQAqr.js +0 -1
  314. package/dist/chunks/cwd-Dj2ynhWd.js +0 -1
  315. package/dist/chunks/detectRepository-CWI2xcdR.js +0 -1
  316. package/dist/chunks/doctor-BV6zhneX.js +0 -1
  317. package/dist/chunks/extractMemories-DxGHxoNO.js +0 -1
  318. package/dist/chunks/fast-Bf-g-wR6.js +0 -1
  319. package/dist/chunks/fetchModelList-vk-RMDfG.js +0 -1
  320. package/dist/chunks/firstPartyEventLogger-DvsZdBy2.js +0 -1
  321. package/dist/chunks/git-Bujlb5tq.js +0 -1
  322. package/dist/chunks/githubRepoPathMapping-Dhz4cvw2.js +0 -1
  323. package/dist/chunks/hooks-C5YSYzSl.js +0 -1
  324. package/dist/chunks/initReplBridge-BFYTAFlT.js +0 -1
  325. package/dist/chunks/install-CjacxFXg.js +0 -1
  326. package/dist/chunks/keybindings-D01jzjKu.js +0 -1
  327. package/dist/chunks/loadAgentsDir-xG1HswS_.js +0 -1
  328. package/dist/chunks/localSearch-B17Mzd84.js +0 -1
  329. package/dist/chunks/managedEnv-C7bVtcgA.js +0 -1
  330. package/dist/chunks/managedEnv-d7HliQYg.js +0 -1
  331. package/dist/chunks/mcp-BcEApfqn.js +0 -1
  332. package/dist/chunks/mcp-CBbVcOTy.js +0 -2
  333. package/dist/chunks/mcp-DYtfHeRa.js +0 -6
  334. package/dist/chunks/memory-CijapyZk.js +0 -1
  335. package/dist/chunks/model-CyF5u3zH.js +0 -1
  336. package/dist/chunks/model-DaYZWYJe.js +0 -1
  337. package/dist/chunks/omit-BhPlISSj.js +0 -1
  338. package/dist/chunks/onChangeAppState-BOJd4Yce.js +0 -1
  339. package/dist/chunks/parser-B-QFQfSO.js +0 -1
  340. package/dist/chunks/partition-_qZZlGjS.js +0 -1
  341. package/dist/chunks/permissions-CcjGscyg.js +0 -3
  342. package/dist/chunks/pidLock-Cm9FWa4w.js +0 -3
  343. package/dist/chunks/plugin-D7vjs6Hu.js +0 -17
  344. package/dist/chunks/pluginOperations-BxHoy0pC.js +0 -2
  345. package/dist/chunks/pluginStartupCheck-CtX6QkdO.js +0 -1
  346. package/dist/chunks/poorMode-DyAWNRRM.js +0 -1
  347. package/dist/chunks/poorMode-aMzKXz6G.js +0 -1
  348. package/dist/chunks/postCommitAttribution-DoSP9wZD.js +0 -1
  349. package/dist/chunks/print-BrqZ3AgP.js +0 -14
  350. package/dist/chunks/processBashCommand-C6mBgRVz.js +0 -1
  351. package/dist/chunks/processSlashCommand-t0-BVku8.js +0 -5
  352. package/dist/chunks/prompt-BJ3xYAvE.js +0 -1
  353. package/dist/chunks/prompt-Di2lNwYp.js +0 -1
  354. package/dist/chunks/reconciler-p4lAu9ft.js +0 -1
  355. package/dist/chunks/refresh-DCQChX5A.js +0 -1
  356. package/dist/chunks/registerProtocol-CrzdmgCD.js +0 -1
  357. package/dist/chunks/remoteManagedSettings-DkLfclxa.js +0 -1
  358. package/dist/chunks/resume-K9q5B1li.js +0 -2
  359. package/dist/chunks/ripgrep-DLPH9MP9.js +0 -1
  360. package/dist/chunks/sandbox-adapter-CRxZBMAP.js +0 -1
  361. package/dist/chunks/searchExtraTools-BAYzzTE8.js +0 -1
  362. package/dist/chunks/sessionFileAccessHooks-CwnjOk6S.js +0 -1
  363. package/dist/chunks/sessionObserver-DNjDoJmy.js +0 -1
  364. package/dist/chunks/sessionStorage-CVZ0MUSE.js +0 -1
  365. package/dist/chunks/settings-DsqFBv6J.js +0 -1
  366. package/dist/chunks/settingsSync-yE43qjMS.js +0 -1
  367. package/dist/chunks/setup-CFOc-hPM.js +0 -3
  368. package/dist/chunks/sinks-B64r_OBE.js +0 -1
  369. package/dist/chunks/skillChangeDetector-CLnn22Jo.js +0 -1
  370. package/dist/chunks/src-DPUAq5Ty.js +0 -1
  371. package/dist/chunks/startupProfiler-yBU6FaAV.js +0 -1
  372. package/dist/chunks/state-mHtumqEo.js +0 -1
  373. package/dist/chunks/status--Ql7l0VG.js +0 -1
  374. package/dist/chunks/switcher-Cb9R9247.js +0 -1
  375. package/dist/chunks/syncCache-BiqQEess.js +0 -1
  376. package/dist/chunks/toolPool-H_kXc8vo.js +0 -1
  377. package/dist/chunks/trustedDevice-Dm_SY3Ko.js +0 -1
  378. package/dist/chunks/useMainLoopModel-DG8pghH7.js +0 -1
  379. package/dist/chunks/useManagePlugins-HMHtjIY-.js +0 -1
  380. package/dist/chunks/useSettingsErrors-Bs9uyzW4.js +0 -1
  381. package/dist/chunks/validatePlugin-yCb8gsVF.js +0 -1
  382. package/dist/chunks/windowsPaths-Dd_S96Bq.js +0 -1
  383. package/dist/chunks/worktree-D-CgffvU.js +0 -1
  384. /package/dist/chunks/{src-DLz3FZm1.js → urlHandler-DLz3FZm1.js} +0 -0
@@ -0,0 +1,128 @@
1
+ import{a as e,n as t,o as n}from"./rolldown-runtime-DaDcL9Zw.js";import{c as r,i,l as a,o}from"./envUtils-DcaKZlRU.js";import{n as s,t as c}from"./defineProperty-C-QyHrDq.js";import{n as l,t as u}from"./figures-5ThXQEtq.js";import{t as d}from"./semver-DQo45qGo.js";import{n as f,t as p}from"./axios-DaWTGg7G.js";import{$C as m,$_ as h,$c as g,$d as _,$g as v,$h as y,$n as b,$s as x,$u as S,$v as C,$y as w,A as T,AT as E,Ad as D,Af as O,Ag as k,Ah as A,Ai as j,Al as M,An as N,Ao as ee,As as te,Ay as P,B as F,Bc as I,Bf as L,Bh as ne,Bm as re,Bs as ie,Bt as ae,Bv as oe,Bx as se,C as ce,Cg as le,Cr as R,Cu as ue,Cv as de,Cw as fe,Cy as z,DC as pe,Da as me,Dh as he,Di as ge,Dl as _e,Dm as ve,Dp as ye,Ds as be,Dv as xe,Dy as Se,EC as Ce,Ea as we,Em as Te,Ep as Ee,Es as De,Ey as Oe,FC as ke,Fb as Ae,Fd as je,Ff as Me,Fg as Ne,Fh as Pe,Fl as Fe,Fm as Ie,Fn as Le,Fo as Re,Fu as ze,Fv as Be,Fy as Ve,GT as He,G_ as Ue,Ga as We,Gd as Ge,Gg as Ke,Gh as qe,Gl as Je,Gs as Ye,Gu as Xe,Hd as Ze,Hh as Qe,Hi as $e,Hl as et,Hm as tt,Hn as nt,Hp as rt,Hs as it,Hu as at,Hv as ot,Id as st,If as ct,Ig as lt,Ih as ut,Ii as dt,Il as ft,Im as pt,In as mt,Io as ht,Iu as gt,Iv as _t,Iy as vt,J as yt,JS as bt,J_ as xt,Jc as St,Jd as Ct,Jf as wt,Jg as Tt,Jh as Et,Ju as Dt,Jv as Ot,K as kt,KT as At,Ka as jt,Kc as Mt,Kd as Nt,Kh as Pt,Kn as Ft,Ko as It,Kp as Lt,Ku as Rt,Ky as zt,La as Bt,Lc as Vt,Ld as Ht,Lf as Ut,Lg as Wt,Li as Gt,Ll as Kt,Lo as qt,Lr as Jt,Ls as B,Lv as Yt,Ly as Xt,MT as Zt,Md as Qt,Mf as $t,Mh as en,Mi as tn,Mo as nn,Mt as rn,My as an,NC as on,Nd as sn,Nf as cn,Ng as ln,Nh as un,Nn as dn,No as fn,Nu as pn,Nv as mn,Ny as hn,O as gn,OC as _n,Oa as vn,Og as yn,Oh as bn,Ol as xn,Om as Sn,Op as Cn,Ou as wn,Ov as Tn,Oy as En,Pa as Dn,Pb as On,Pd as kn,Pf as An,Pg as jn,Ph as Mn,Pm as Nn,Po as Pn,Pu as Fn,QC as In,Qa as Ln,Qc as Rn,Qd as zn,Qh as Bn,Qr as Vn,Qu as Hn,Qv as Un,Qw as Wn,Qy as Gn,Ra as Kn,Rc as qn,Rd as Jn,Rf as Yn,Rg as Xn,Rl as Zn,Rm as V,Rn as Qn,Rs as $n,Rv as er,Ry as tr,SC as nr,Sa as rr,Sc as ir,Sd as ar,Sg as H,Sp as or,St as sr,Sw as cr,Sy as lr,TC as ur,Ta as dr,Tg as fr,Th as pr,Tl as mr,Tm as hr,To as gr,Tp as _r,Tr as vr,Tv as yr,Ty as br,U as xr,UT as Sr,Uc as Cr,Ud as wr,Ug as Tr,Uh as Er,Ui as Dr,Ul as Or,Um as kr,Uo as Ar,Up as jr,Ur as Mr,Us as Nr,Uu as Pr,Uv as Fr,Uw as Ir,V as Lr,Vd as Rr,Vh as zr,Vi as Br,Vm as Vr,Vo as Hr,Vs as Ur,Vt as Wr,W as Gr,WT as Kr,W_ as qr,Wd as Jr,Wg as Yr,Wh as Xr,Wl as Zr,Wm as Qr,Ws as $r,Wu as ei,Wv as ti,Ww as ni,Wy as ri,X as ii,XS as ai,XT as oi,Xa as si,Xc as ci,Xd as li,Xf as ui,Xg as di,Xh as U,Xm as fi,Xn as pi,Xr as mi,Xt as hi,Xu as gi,Xv as _i,YC as vi,YS as yi,YT as bi,Y_ as xi,Yd as Si,Yf as Ci,Yh as wi,Ym as Ti,Yu as Ei,Yv as Di,Z as Oi,ZS as ki,Zc as Ai,Zd as ji,Zf as Mi,Zg as Ni,Zh as W,Zm as Pi,Zu as Fi,Zv as Ii,_C as Li,_d as Ri,_f as zi,_g as Bi,_m as Vi,_p as Hi,_w as Ui,_y as Wi,aC as Gi,aa as Ki,ad as qi,af as Ji,ag as Yi,ah as Xi,al as Zi,am as Qi,ap as $i,at as ea,au as ta,ay as na,b as ra,ba as ia,bc as aa,bd as oa,bf as sa,bg as ca,bl as la,bm as ua,br as da,bs as fa,by as pa,cb as ma,cd as ha,cg as ga,co as _a,cp as va,cy as ya,dC as ba,dT as xa,d_ as Sa,db as Ca,dd as wa,dh as Ta,di as Ea,dy as Da,eC as Oa,eS as ka,e_ as Aa,ea as ja,eb as Ma,ec as Na,ed as Pa,el as Fa,ep as Ia,er as La,es as Ra,et as za,ey as Ba,fC as Va,fa as Ha,fb as Ua,fc as Wa,fd as Ga,fg as Ka,fh as qa,fi as Ja,fo as Ya,fr as Xa,fv as Za,fy as Qa,gC as $a,gb as eo,gc as to,gd as no,gg as ro,gw as io,gy as ao,hC as oo,h_ as so,ha as co,hb as lo,hc as uo,hd as fo,hh as po,hn as mo,ho,hr as go,iT as _o,ia as vo,ib as yo,id as bo,ig as xo,ih as So,il as Co,im as wo,io as To,ip as Eo,iy as Do,jd as Oo,jh as ko,ji as Ao,jl as jo,jo as Mo,jy as No,k as Po,kC as Fo,ka as Io,kd as Lo,kg as Ro,kh as zo,kl as Bo,km as Vo,ks as Ho,ku as Uo,lC as Wo,lb as Go,ld as Ko,lg as qo,ly as Jo,mC as Yo,m_ as Xo,ma as Zo,mb as Qo,md as $o,mg as es,mh as ts,mo as ns,my as rs,n_ as is,nb as as,nc as os,nd as ss,ni as cs,nl as ls,no as us,nv as ds,ny as fs,oa as ps,ob as ms,og as hs,oh as gs,oi as _s,om as vs,op as ys,ot as bs,ou as xs,oy as Ss,pC as Cs,pb as ws,pc as Ts,pd as Es,ph as Ds,py as Os,q as ks,qT as As,q_ as js,qc as Ms,qd as Ns,qf as Ps,qg as Fs,qh as Is,qo as Ls,qp as Rs,qs as zs,qt as Bs,qu as Vs,qv as Hs,rC as Us,r_ as Ws,rb as Gs,rd as Ks,rf as qs,ri as Js,rl as Ys,rp as Xs,rr as Zs,rv as Qs,ry as $s,sa as ec,sb as tc,sg as nc,sh as rc,sm as ic,sn as ac,sp as oc,sy as sc,tC as cc,tS as lc,tT as uc,t_ as dc,tb as fc,ti as pc,tl as mc,tp as hc,ts as gc,tv as _c,uC as vc,uT as yc,u_ as bc,ub as xc,ud as Sc,vC as Cc,vb as wc,vc as Tc,vf as Ec,vg as Dc,vl as Oc,vm as kc,vp as Ac,vw as jc,vy as Mc,wC as Nc,wg as Pc,wh as Fc,wi as Ic,wm as Lc,wp as Rc,ws as zc,wu as Bc,ww as Vc,wy as Hc,xC as Uc,xc as Wc,xd as Gc,xg as Kc,xm as qc,xo as Jc,xr as Yc,xs as Xc,xy as Zc,yC as Qc,ya as $c,yd as el,yf as tl,yg as nl,yl as rl,ym as il,ys as al,yt as ol,yy as sl,zc as cl,zf as ll,zg as ul,zi as dl,zl as fl,zm as pl,zs as ml,zv as hl,zx as gl,zy as _l}from"./loadAgentsDir-DaNpxaO-.js";import{C as vl,D as yl,Ft as bl,Gr as xl,Gt as Sl,H as Cl,I as G,Kr as wl,Kt as Tl,Lt as El,P as K,Pn as Dl,Rn as Ol,T as kl,Tt as Al,Vn as jl,Wt as Ml,Xn as Nl,Xt as Pl,Y as Fl,Yt as Il,Z as Ll,Zn as Rl,_n as zl,ai as Bl,bn as Vl,ct as Hl,di as Ul,dr as Wl,et as Gl,fi as Kl,hn as ql,ir as Jl,j as Yl,lr as Xl,lt as Zl,ot as Ql,p as $l,q as eu,qr as tu,t as q,tr as nu,vn as ru,x as iu,y as au,yn as ou,yt as su}from"./src-DL3w8VPk2.js";import{t as cu}from"./jsx-runtime-Bb4Xn-E0.js";import{C as lu,D as uu,E as du,N as fu,T as pu,c as mu,f as hu,n as gu,o as _u,r as vu,t as yu}from"./lazySchema-DULtBUCI.js";import{$ as bu,$t as xu,An as Su,At as Cu,B as wu,Bt as Tu,Dt as Eu,E as Du,Et as Ou,In as ku,J as Au,Ln as ju,Ot as Mu,Pt as Nu,R as Pu,Rt as Fu,Tt as Iu,U as Lu,Ut as Ru,Wt as zu,ar as Bu,b as Vu,cr as Hu,en as Uu,ft as Wu,gn as Gu,ir as Ku,kt as qu,ln as Ju,lr as Yu,nn as Xu,or as Zu,rt as Qu,tn as $u,ut as ed,xt as td,z as nd}from"./state-D5D6QpTX.js";import{n as rd,t as id}from"./cwd-Nh5IZNKO.js";import{B as ad,C as od,E as sd,P as cd,R as ld,S as ud,U as dd,W as fd,Z as pd,c as J,f as md,g as hd,i as gd,nt as _d,tt as vd,u as yd,x as bd}from"./debug-D58GQBDG.js";import{At as xd,Cn as Sd,Gt as Cd,Ht as wd,In as Td,It as Ed,Jn as Dd,Jt as Od,Kn as kd,Kt as Ad,Ln as jd,Lt as Md,Mt as Nd,On as Pd,R as Fd,Rn as Id,Rt as Ld,Ut as Rd,V as zd,Vt as Bd,_t as Vd,an as Hd,ar as Ud,b as Wd,bn as Gd,cn as Kd,d as qd,h as Jd,jt as Yd,or as Xd,qn as Zd,s as Qd,sr as $d,st as ef,t as tf}from"./settings-3xZ0fsvE.js";import{M as nf,c as rf,h as af,n as of,y as sf}from"./config-DRy1I12M.js";import{O as cf,a as lf,i as uf,k as df,l as ff,m as pf}from"./git-By_J4XJL.js";import{r as mf,t as hf}from"./execFileNoThrow-Bmb5HEFz.js";import{B as gf,H as _f,L as vf,N as yf,R as bf,k as xf,o as Sf,q as Cf,s as Y}from"./log-CZ7ploQm.js";import{n as wf,t as Tf}from"./memoize-CumjjK2Q.js";import{n as Ef,t as Df}from"./which-BxQ1hpjp.js";import{i as Of,o as kf}from"./platform-DMQxcm4K.js";import{s as Af,u as jf}from"./types-APu4OCXJ.js";import{n as Mf,r as X}from"./analytics-DJobLaWP.js";import{n as Nf,o as Pf,s as Ff,t as If}from"./intl-D2kgJmX7.js";import{C as Lf,_ as Rf,d as zf,l as Bf,u as Vf,v as Hf}from"./startupProfiler-CbzxVmbv.js";import{n as Uf,t as Wf}from"./bundledMode--fG1S62b.js";import{a as Gf,d as Kf,l as qf,o as Jf,r as Yf,s as Xf}from"./stringUtils-CKD8qDqx.js";import{$ as Zf,Bn as Qf,D as $f,Fn as ep,Fr as tp,It as np,J as rp,Lr as ip,Pn as ap,Pt as op,Q as sp,Qr as cp,T as lp,W as up,X as dp,Xn as fp,Y as pp,Yn as mp,Z as hp,Zr as gp,_ as _p,_t as vp,b as yp,bt as bp,ct as xp,dr as Sp,et as Cp,gt as wp,h as Tp,kt as Ep,m as Dp,nt as Op,qn as kp,tt as Ap,u as jp,ur as Mp,wt as Np,x as Pp,zt as Fp}from"./model-Do0f476p.js";import{Rt as Ip,St as Lp,fn as Rp,gn as zp,in as Bp,ln as Vp,pn as Hp,rn as Up,tn as Wp,tt as Gp,un as Kp,vn as qp,xt as Jp,zt as Yp}from"./prompt-8u06WVES.js";import{i as Xp,m as Zp,n as Qp,p as $p}from"./terminalSetup-kWdZRKWq.js";import{Q as em,_t as tm,at as nm,b as rm,ct as im,dt as am,ft as om,ht as sm,it as cm,lt as lm,mt as um,n as dm,ot as fm,pt as pm,r as mm,st as hm,v as gm,vt as _m}from"./sessionState-CQhbGfmh.js";import{a as vm,i as ym,r as bm}from"./shellQuote-Ddgr1vif.js";import{a as xm}from"./ripgrep-C3jtZL7k.js";import{a as Sm}from"./loader-C33o_5kS.js";import{n as Cm,r as wm}from"./switcher-DQF5ZNal.js";import{et as Tm,rt as Em}from"./esm-CvHtYRrr.js";import{i as Dm,n as Om,r as km}from"./parser-eVu-cTRs.js";import{T as Am,c as jm,r as Mm,w as Nm}from"./sessionTracing-BoOZsXU2.js";import{n as Pm,t as Fm}from"./poorMode-CKQfWf3S.js";import{o as Im,u as Lm}from"./api-DyUWfg3a.js";import{f as Rm,m as zm,n as Bm}from"./firstPartyEventLogger-DqGSujCz.js";import{n as Vm,t as Hm}from"./mappers-_B-s9fNz.js";import{n as Um,r as Wm}from"./sessionTitle-k4wpUS5l.js";import{t as Gm}from"./bridgeMessaging-DVC3qj-C.js";import{E as Km,T as qm,g as Jm,m as Ym}from"./pidLock-DiKz5Tza.js";import{n as Xm,t as Zm}from"./nativeInstaller-CymO8TNe.js";import{t as Qm}from"./useManagePlugins-MSHw-qHx.js";import{n as $m,t as eh}from"./MCPConnectionManager-DfyoZaiu.js";import{n as th,t as nh}from"./toolPool-Df5iUqJ-.js";import{a as rh,i as ih,o as ah,r as oh,t as sh}from"./MessageSelector-D8fylxPg.js";import{n as ch,t as lh}from"./useExitOnCtrlCDWithKeybindings-Bw0mlTT9.js";import{a as uh,i as dh,n as fh,t as ph}from"./bridgeStatusUtil-Cex6VowM.js";import{n as mh,t as hh}from"./sideQuestion-Ds7Elgs4.js";import{a as gh,n as _h,o as vh,r as yh,s as bh,t as xh}from"./skillChangeDetector-CtithJ4a.js";import{n as Sh,t as Ch}from"./reconciler-RIKmaPg7.js";import{n as wh,t as Th}from"./refresh-CCSCAjgz.js";import{i as Eh,n as Dh,r as Oh,t as kh}from"./directoryCompletion-BDGcGDuv.js";import{r as Ah,t as jh}from"./PromptInputFooterSuggestions-DCum89fF.js";import{n as Mh,t as Nh}from"./useMergedTools-Bb-INJa2.js";import{a as Ph,i as Fh,n as Ih,o as Lh,r as Rh,t as zh}from"./promptEditor-Cr4w-4Bz.js";import{n as Bh,t as Vh}from"./useMainLoopModel-CIG2cjS2.js";import{a as Hh,i as Uh,o as Wh,r as Gh,s as Kh,t as qh}from"./fileSuggestions-CFkJktgc.js";import{i as Jh,n as Yh,r as Xh,t as Zh}from"./extraUsage-CkTon7ib.js";import{n as Qh,t as $h}from"./useSearchInput-QL_VtdJD.js";import{n as eg,t as tg}from"./staticRender-D9AbnQFr.js";import{n as ng,t as rg}from"./useSettingsErrors-Dvi6zLCr.js";import{n as ig,t as ag}from"./shadowedRuleDetection-Cy9tsuKc.js";import{n as og,t as sg}from"./ExitFlow-Dy8_1D8J.js";import{a as cg,i as lg,r as ug,t as dg}from"./fast-xtIP4u4y.js";import{i as fg,n as pg,r as mg,t as hg}from"./PermissionDialog-BPhvs5xH.js";import{a as gg,i as _g,n as vg,r as yg,t as bg}from"./PromptInputHelpMenu-DG2lRqis.js";import{n as xg,r as Sg}from"./pluginAutoupdate-C2xTKLR_.js";import{n as Cg,t as wg}from"./generateSessionName-EpqGW-T2.js";import{a as Tg,c as Eg,i as Dg,l as Og,n as kg,o as Ag,r as jg,s as Mg,t as Ng}from"./Messages-BZDFMYBT.js";import{t as Pg}from"./lib-BlVGipXx.js";import{a as Fg,i as Ig,n as Lg,o as Rg,r as zg,t as Bg}from"./BackgroundTasksDialog-lGn1Wj1k.js";import{n as Vg}from"./fpsMetrics-Dk_pnSHJ.js";import{t as Hg}from"./earlyInput-IghoCjG5.js";import{a as Ug,i as Wg,o as Gg,r as Kg,s as qg,t as Jg}from"./RemoteSessionManager-BfsOv4K6.js";import{n as Yg,t as Xg}from"./backgroundHousekeeping-km82qEh0.js";import{homedir as Zg,tmpdir as Qg}from"os";import*as $g from"path";import{basename as e_,dirname as t_,extname as n_,join as r_,relative as i_,sep as a_}from"path";import{dirname as o_,join as s_}from"node:path";import{createHash as c_}from"node:crypto";import{randomUUID as l_}from"crypto";import{readFile as u_,readdir as d_,stat as f_,writeFile as p_}from"fs/promises";import{spawn as m_,spawnSync as h_}from"child_process";import{mkdir as g_,readFile as __,rename as v_,writeFile as y_}from"node:fs/promises";function b_(e){return Array.isArray?Array.isArray(e):A_(e)===`[object Array]`}function x_(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 S_(e){return e==null?``:x_(e)}function C_(e){return typeof e==`string`}function w_(e){return typeof e==`number`}function T_(e){return e===!0||e===!1||D_(e)&&A_(e)==`[object Boolean]`}function E_(e){return typeof e==`object`}function D_(e){return E_(e)&&e!==null}function O_(e){return e!=null}function k_(e){return!e.trim().length}function A_(e){return e==null?e===void 0?`[object Undefined]`:`[object Null]`:Object.prototype.toString.call(e)}function j_(e){let t=null,n=null,r=null,i=1,a=null;if(C_(e)||b_(e))r=e,t=M_(e),n=N_(e);else{if(!hv.call(e,`name`))throw Error(fv(`name`));let o=e.name;if(r=o,hv.call(e,`weight`)&&e.weight!==void 0&&(i=e.weight,i<=0))throw Error(pv(N_(o)));t=M_(o),n=N_(o),a=e.getFn??null}return{path:t,id:n,weight:i,src:r,getFn:a}}function M_(e){return b_(e)?e:e.split(`.`)}function N_(e){return b_(e)?e.join(`.`):e}function P_(e,t){let n=[],r=!1,i=(e,t,a,o)=>{if(O_(e))if(!t[a])n.push(o===void 0?e:{v:e,i:o});else{let s=e[t[a]];if(!O_(s))return;if(a===t.length-1&&(C_(s)||w_(s)||T_(s)||typeof s==`bigint`))n.push(o===void 0?S_(s):{v:S_(s),i:o});else if(b_(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,C_(t)?t.split(`.`):t,0),r?n:n[0]}function F_(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 I_(e,t,{getFn:n=Z.getFn,fieldNormWeight:r=Z.fieldNormWeight}={}){let i=new xv({getFn:n,fieldNormWeight:r});return i.setKeys(e.map(j_)),i.setSources(t),i.create(),i}function L_(e,{getFn:t=Z.getFn,fieldNormWeight:n=Z.fieldNormWeight}={}){let{keys:r,records:i}=e,a=new xv({getFn:t,fieldNormWeight:n});return a.setKeys(r),a.setIndexRecords(i),a}function R_(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 z_(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(dv(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=R_(_,s);e.length?c&&(w.indices=e):w.isMatch=!1}return w}function B_(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 V_(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 H_(e){return e.startsWith(`inverse`)}function U_(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 W_(e,t){let n=e.match(t);return n?n[1]:null}function G_(e,t={}){return e.replace(/\\\|/g,kv).split(Av).map(e=>{let n=U_(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<Ov;){let e=Dv[o],n=W_(i,e.multiRegex);n&&(r.push(e.create(n,t)),a=!0)}if(!a)for(o=-1;++o<Ov;){let e=Dv[o],n=W_(i,e.singleRegex);if(n){r.push(e.create(n,t));break}}}return r})}function K_(...e){Mv.push(...e)}function q_(e,t){for(let n=0,r=Mv.length;n<r;n+=1){let r=Mv[n];if(r.condition(e,t))return new r(e,t)}return new Tv(e,t)}function J_(e,t,{auto:n=!0}={}){let r=e=>{if(C_(e)){let r={keyId:null,pattern:e};return n&&(r.searcher=q_(e,t)),r}let i=Object.keys(e),a=Iv(e);if(!a&&i.length>1&&!Fv(e))return r(Rv(e));if(Lv(e)){let r=a?e[Pv.PATH]:i[0],o=a?e[Pv.PATTERN]:e[r];if(!C_(o))throw Error(uv(r));let s={keyId:N_(r),pattern:o};return n&&(s.searcher=q_(o,t)),s}let o={children:[],operator:i[0]};return i.forEach(t=>{let n=e[t];b_(n)&&n.forEach(e=>{o.children.push(r(e))})}),o};return Fv(e)||(e=Rv(e)),r(e)}function Y_(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 X_(e,{ignoreFieldNorm:t=Z.ignoreFieldNorm}){e.forEach(e=>{e.score=Y_(e.matches,{ignoreFieldNorm:t})})}function Z_(e){let t=[];return e.matches.forEach(e=>{if(!O_(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 Q_(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=Z_(e)),r&&(a.score=e.score),a})}function $_(e){Vv.has(e)||(Vv.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 ev(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||$_(e),t=>t.match(e)||[]):e=>e.match(Bv)||[]}function tv({isCaseSensitive:e=!1,ignoreDiacritics:t=!1,tokenize:n}={}){let r=ev(n);return{tokenize(n){return e||(n=n.toLowerCase()),t&&(n=wv(n)),r(n)}}}function nv(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 rv(e,t,n,r){let{i,v:a,$:o}=t;if(a!==void 0){nv(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)nv(e,t.v,i,r);else nv(e,n.v,i,r)}}function iv(e,t,n){let r={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(let i of e)rv(r,i,t,n);return r}function av(e,t,n,r){rv(e,t,n,r)}function ov(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 sv(e,t){if(t.length===0)return;let n=Array.from(new Set(t)).sort((e,t)=>e-t);for(let t of n)ov(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 cv,lv,uv,dv,fv,pv,mv,hv,gv,_v,vv,yv,bv,Z,xv,Sv,Cv,wv,Tv,Ev,Dv,Ov,kv,Av,jv,Mv,Nv,Pv,Fv,Iv,Lv,Rv,zv,Bv,Vv,Hv,Uv,Wv,Gv=t((()=>{cv=`Incorrect 'index' type`,lv=`Invalid doc index: must be a non-negative integer within the bounds of the docs array`,uv=e=>`Invalid value for key ${e}`,dv=e=>`Pattern length exceeds max of ${e}.`,fv=e=>`Missing ${e} property in key`,pv=e=>`Property 'weight' in key '${e}' must be a positive integer`,mv=`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.`,hv=Object.prototype.hasOwnProperty,gv=class{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach(e=>{let n=j_(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)}},_v={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},vv={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},yv={location:0,threshold:.6,distance:100},bv={useExtendedSearch:!1,useTokenSearch:!1,tokenize:void 0,tokenMatch:`any`,getFn:P_,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1},Z=Object.freeze({...vv,..._v,...yv,...bv}),xv=class{constructor({getFn:e=Z.getFn,fieldNormWeight:t=Z.fieldNormWeight}={}){this.norm=F_(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(C_(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(lv);if(C_(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(lv);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!O_(e)||k_(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(O_(i)){if(b_(i)){let e=[];for(let t=0,n=i.length;t<n;t+=1){let n=i[t];if(O_(n)){if(C_(n)){if(!k_(n)){let r={v:n,i:t,n:this.norm.get(n)};e.push(r)}}else if(O_(n.v)){let t=C_(n.v)?n.v:S_(n.v);if(!k_(t)){let r={v:t,i:n.i,n:this.norm.get(t)};e.push(r)}}}}n.$[t]=e}else if(C_(i)&&!k_(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}}},Sv={ł:`l`,Ł:`L`,đ:`d`,Đ:`D`,ø:`o`,Ø:`O`,ħ:`h`,Ħ:`H`,ŧ:`t`,Ŧ:`T`,ı:`i`,ß:`ss`},Cv=RegExp(`[`+Object.keys(Sv).join(``)+`]`,`g`),wv=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(Cv,e=>Sv[e]):e=>e,Tv=class{constructor(e,{location:t=Z.location,threshold:n=Z.threshold,distance:r=Z.distance,includeMatches:i=Z.includeMatches,findAllMatches:a=Z.findAllMatches,minMatchCharLength:o=Z.minMatchCharLength,isCaseSensitive:s=Z.isCaseSensitive,ignoreDiacritics:c=Z.ignoreDiacritics,ignoreLocation:l=Z.ignoreLocation}={}){if(this.options={location:t,threshold:n,distance:r,includeMatches:i,findAllMatches:a,minMatchCharLength:o,isCaseSensitive:s,ignoreDiacritics:c,ignoreLocation:l},e=s?e:e.toLowerCase(),e=c?wv(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;let u=(e,t)=>{this.chunks.push({pattern:e,alphabet:B_(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?wv(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}=z_(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=V_(u)),p}},Ev=new Set([`fuzzy`,`include`]),Dv=[{type:`exact`,multiRegex:/^="(.*)"$/,singleRegex:/^=(.*)$/,create:e=>({type:`exact`,search(t){let n=t===e;return{isMatch:n,score:+!n,indices:[0,e.length-1]}}})},{type:`include`,multiRegex:/^'"(.*)"$/,singleRegex:/^'(.*)$/,create:e=>({type:`include`,search(t){let n=0,r,i=[],a=e.length;for(;(r=t.indexOf(e,n))>-1;)n=r+a,i.push([r,n-1]);let o=!!i.length;return{isMatch:o,score:+!o,indices:i}}})},{type:`prefix-exact`,multiRegex:/^\^"(.*)"$/,singleRegex:/^\^(.*)$/,create:e=>({type:`prefix-exact`,search(t){let n=t.startsWith(e);return{isMatch:n,score:+!n,indices:[0,e.length-1]}}})},{type:`inverse-prefix-exact`,multiRegex:/^!\^"(.*)"$/,singleRegex:/^!\^(.*)$/,create:e=>({type:`inverse-prefix-exact`,search(t){let n=!t.startsWith(e);return{isMatch:n,score:+!n,indices:[0,t.length-1]}}})},{type:`inverse-suffix-exact`,multiRegex:/^!"(.*)"\$$/,singleRegex:/^!(.*)\$$/,create:e=>({type:`inverse-suffix-exact`,search(t){let n=!t.endsWith(e);return{isMatch:n,score:+!n,indices:[0,t.length-1]}}})},{type:`suffix-exact`,multiRegex:/^"(.*)"\$$/,singleRegex:/^(.*)\$$/,create:e=>({type:`suffix-exact`,search(t){let n=t.endsWith(e);return{isMatch:n,score:+!n,indices:[t.length-e.length,t.length-1]}}})},{type:`inverse-exact`,multiRegex:/^!"(.*)"$/,singleRegex:/^!(.*)$/,create:e=>({type:`inverse-exact`,search(t){let n=t.indexOf(e)===-1;return{isMatch:n,score:+!n,indices:[0,t.length-1]}}})},{type:`fuzzy`,multiRegex:/^"(.*)"$/,singleRegex:/^(.*)$/,create:(e,t={})=>{let n=new Tv(e,{location:t.location??Z.location,threshold:t.threshold??Z.threshold,distance:t.distance??Z.distance,includeMatches:t.includeMatches??Z.includeMatches,findAllMatches:t.findAllMatches??Z.findAllMatches,minMatchCharLength:t.minMatchCharLength??Z.minMatchCharLength,isCaseSensitive:t.isCaseSensitive??Z.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics??Z.ignoreDiacritics,ignoreLocation:t.ignoreLocation??Z.ignoreLocation});return{type:`fuzzy`,search(e){return n.searchIn(e)}}}}],Ov=Dv.length,kv=`\0`,Av=`|`,jv=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?wv(e):e,this.pattern=e,this.query=G_(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?wv(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,H_(r.type)&&(c=!0),n&&(Ev.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=V_(o)),e}}return{isMatch:!1,score:1}}},Mv=[],Nv={AND:`$and`,OR:`$or`},Pv={PATH:`$path`,PATTERN:`$val`},Fv=e=>!!(e[Nv.AND]||e[Nv.OR]),Iv=e=>!!e[Pv.PATH],Lv=e=>!b_(e)&&E_(e)&&!Fv(e),Rv=e=>({[Nv.AND]:Object.keys(e).map(t=>({[t]:e[t]}))}),zv=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)}},Bv=/[\p{L}\p{M}\p{N}_]+/gu,Vv=new WeakSet,Hv=class{static condition(e,t){return t.useTokenSearch}constructor(e,t){this.options=t,this.analyzer=tv({isCaseSensitive:t.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics,tokenize:t.tokenize});let n=this.analyzer.tokenize(e),{df:r,fieldCount:i}=t._invertedIndex;this.termSearchers=[],this.idfWeights=[];for(let e of n){this.termSearchers.push(new Tv(e,{location:t.location,threshold:t.threshold,distance:t.distance,includeMatches:t.includeMatches,findAllMatches:t.findAllMatches,minMatchCharLength:t.minMatchCharLength,isCaseSensitive:t.isCaseSensitive,ignoreDiacritics:t.ignoreDiacritics,ignoreLocation:!0}));let n=r.get(e)||0,a=Math.log(1+(i-n+.5)/(n+.5));this.idfWeights.push(a)}this.combineAll=t.tokenMatch===`all`,this.numTerms=this.termSearchers.length,this.useMask=this.numTerms<=31}searchIn(e){if(!this.termSearchers.length)return{isMatch:!1,score:1};let t=[],n=0,r=0,i=0,a=0,o=this.combineAll&&!this.useMask?new Set:null;for(let s=0;s<this.termSearchers.length;s++){let c=this.termSearchers[s].searchIn(e),l=this.idfWeights[s];r+=l,c.isMatch&&(i++,n+=l*(1-c.score),c.indices&&t.push(...c.indices),this.combineAll&&(this.useMask?a|=1<<s:o.add(s)))}if(i===0)return{isMatch:!1,score:1};let s=r>0?1-n/r:0,c={isMatch:!0,score:Math.max(.001,s)};return this.options.includeMatches&&t.length&&(c.indices=V_(t)),this.combineAll&&(this.useMask?c.matchedMask=a:c.matchedTerms=o,c.termCount=this.numTerms),c}},Uv=class{constructor(e,t,n){this.options={...Z,...t},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new gv(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=q_(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 xv))throw Error(cv);if(this._myIndex=t||I_(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){let e=tv({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=iv(this._myIndex.records,this._myIndex.keys.length,e)}this._invalidateSearcherCache()}add(e){if(!O_(e))return;this._docs.push(e);let t=this._myIndex.add(e,this._docs.length-1);if(this._invertedIndex&&t){let e=tv({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});av(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&&sv(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(lv);this._invertedIndex&&sv(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(C_(e)&&!e.trim()){let e=this._docs.map((e,t)=>({item:e,refIndex:t}));return w_(n)&&n>-1&&(e=e.slice(0,n)),e}let c=w_(n)&&n>0&&C_(e),l;if(c){let t=new zv(n);C_(this._docs[0])?this._searchStringList(e,{heap:t,ignoreFieldNorm:s}):this._searchObjectList(e,{heap:t,ignoreFieldNorm:s}),l=t.extractSorted(o)}else l=C_(e)?C_(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e),X_(l,{ignoreFieldNorm:s}),a&&l.sort(o),w_(n)&&n>-1&&(l=l.slice(0,n));return Q_(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(!O_(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=Y_(r.matches,{ignoreFieldNorm:n}),t.shouldInsert(r.score)&&t.insert(r)):o.push(r)}}}),o}_searchLogical(e){let t=J_(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===Nv.AND)return[]}return o},r=this._myIndex.records,i=new Map,a=[];return r.forEach(({$:e,i:r})=>{if(O_(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(!O_(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=Y_(r.matches,{ignoreFieldNorm:n}),t.shouldInsert(r.score)&&t.insert(r)):s.push(r)}}),s}_findMatches({key:e,value:t,searcher:n}){if(!O_(t))return[];let r=[];if(b_(t))t.forEach(({v:t,i,n:a})=>{if(!O_(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}},Uv.version=`7.4.2`,Uv.createIndex=I_,Uv.parseIndex=L_,Uv.config=Z,Uv.match=function(e,t,n){if(n&&n.useTokenSearch)throw Error(mv);return q_(e,{...Z,...n}).searchIn(t)},Uv.parseQuery=J_,K_(jv),K_(Hv),Uv.use=function(...e){e.forEach(e=>K_(e))},Wv=Uv}));s();var Kv=d();ru(),l(),q(),Yu(),Ru(),jd(),Pf(),$a(),el(),Wc(),$h();var Q=n(Bl(),1);wl(),kg(),Cs(),E(),U(),tg();var $=cu();function qv({children:e}){let{bindings:t}=Zt(),n=(0,Q.useRef)(null),r=(0,Q.useRef)(new Map),i=(0,Q.useRef)(new Set).current;return(0,$.jsx)(Tl,{bindings:t,pendingChordRef:n,pendingChord:null,setPendingChord:()=>{},activeContexts:i,registerActiveContext:()=>{},unregisterActiveContext:()=>{},handlerRegistryRef:r,children:e})}function Jv(e){if(!(`message`in e))return 1;let t=e.message.content;return Array.isArray(t)?t.length:1}async function Yv(e,t,n,{columns:r,verbose:i=!1,chunkSize:a=40,onProgress:o}={}){let s=n=>eg((0,$.jsx)(wi,{children:(0,$.jsx)(qv,{children:(0,$.jsx)(Ng,{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+=Jv(t);for(let e=0;e<c;e+=a){let t=await s([e,e+a]);if(tu(t).trim()===``)break;await n(t),o?.(e+a)}}async function Xv(e,t=[],n){let r=[];return await Yv(e,t,e=>void r.push(tu(e)),{columns:n}),r.join(``)}o(),Kl(),vu(),rd(),vd(),fd(),ld(),bd(),md(),gd(),cf(),Cf(),Sf(),mf(),Tf(),Df(),pf(),kf(),$d(),Zd(),Mf(),Sd(),Af(),Hf(),Kd(),yu(),Wf(),Od(),Rd(),Yd(),Vd(),Fd(),Jf(),Jd(),nf(),gp(),qp(),af(),Hp(),ip(),Sp(),fp(),Qf(),op(),rp(),_p(),Bp(),Wp(),bi(),_m(),nm(),yc(),xm(),uc(),Tm(),Vc(),Ui(),In(),vi(),on(),bm(),Fo(),Ce(),nr(),Cc(),Li(),ba(),vc(),Gi(),yi(),Yp(),se(),Ae(),eo(),tc(),w(),zt(),_l(),vt(),hn(),En(),Hc(),pa(),Lp(),Gp(),Mc(),Qa(),$s(),rm(),ti(),Yt(),mn(),xe(),Za(),Qs(),h(),xi(),Xo(),bc(),km(),is(),di(),Ke(),ul(),Wt(),ln(),k(),le(),ca(),nc(),xo(),Is(),Er(),Qe(),po(),qa(),rc(),Xi(),fi(),Qr(),tt(),V(),Nm(),Nn(),Sn(),Te(),Lc(),ua(),Ee(),Rc(),oc(),ui(),wt(),sa(),Ec(),Rm(),Bm(),_(),Je(),Or(),Zn(),ft(),Zi(),Ms(),jm(),Vt(),uo(),Wa(),Na(),zs(),Nr(),B(),Ho(),be(),Ra(),Ls(),ht(),Jc(),ns(),_a(),us(),Bt(),Dr(),Gt(),da(),dn(),mo(),ii(),ks(),xr(),Lr(),ra(),Ph(),Fi();function Zv({onDone:e}){return(0,$.jsxs)(au,{title:`You've spent $5 on the API this session.`,onCancel:e,children:[(0,$.jsxs)(G,{flexDirection:`column`,children:[(0,$.jsx)(K,{children:`Learn more about how to monitor your spending:`}),(0,$.jsx)(El,{url:`https://code.workmate.com/docs/en/costs`})]}),(0,$.jsx)(Hn,{options:[{value:`ok`,label:`Got it, thanks!`}],onChange:e})]})}S(),q(),Fi();function Qv({idleMinutes:e,totalInputTokens:t,onDone:n}){return(0,$.jsxs)(au,{title:`You've been away ${$v(e)} and this conversation is ${Rf(t)} tokens.`,onCancel:()=>n(`dismiss`),children:[(0,$.jsx)(G,{flexDirection:`column`,children:(0,$.jsx)(K,{children:`If this is a new task, clearing context will save usage and be faster.`})}),(0,$.jsx)(Hn,{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 $v(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`}Si();async function ey(e,t){let n=rf().preferredNotifChannel;await ae(e),X(`tengu_notification_method_used`,{configured_channel:n,method_used:await ny(n,e,t),term:Cd.terminal})}var ty=`Work Mate`;async function ny(e,t,n){let r=t.title||ty;try{switch(e){case`auto`:return ry(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:iy()}),`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 ry(e,t){let n=e.title||ty;switch(Cd.terminal){case`Apple_Terminal`:return await ay()?(t.notifyBell(),`terminal_bell`):`no_method_available`;case`iTerm.app`:return t.notifyITerm2(e),`iterm2`;case`kitty`:return t.notifyKitty({...e,title:n,id:iy()}),`kitty`;case`ghostty`:return t.notifyGhostty({...e,title:n}),`ghostty`;default:return`no_method_available`}}function iy(){return Math.floor(Math.random()*1e4)}async function ay(){try{if(Cd.terminal!==`Apple_Terminal`)return!1;let e=(await hf(`osascript`,[`-e`,`tell application "Terminal" to name of current settings of front window`])).stdout.trim();if(!e)return!1;let t=await hf(`defaults`,[`export`,`com.apple.Terminal`,`-`]);if(t.code!==0)return!1;let r=(await import(`./plist-Bzo2VMe9.js`).then(e=>n(e.default,1))).parse(t.stdout)?.[`Window Settings`]?.[e];return r?r.Bell===!1:!1}catch(e){return Y(e),!1}}var oy=300,sy=240*1e3,cy=null,ly=null,uy=0,dy=!1;function fy(){uy++,uy===1&&(_y(),hy())}function py(){uy>0&&uy--,uy===0&&(gy(),vy())}function my(){uy=0,gy(),vy()}function hy(){process.platform===`darwin`&&ly===null&&(ly=setInterval(()=>{uy>0&&(J(`Restarting caffeinate to maintain sleep prevention`),vy(),_y())},sy),ly.unref())}function gy(){ly!==null&&(clearInterval(ly),ly=null)}function _y(){if(process.platform===`darwin`&&cy===null){dy||(dy=!0,_d(async()=>{my()}));try{cy=m_(`caffeinate`,[`-i`,`-t`,String(oy)],{stdio:`ignore`}),cy.unref();let e=cy;cy.on(`error`,t=>{J(`caffeinate spawn error: ${t.message}`),cy===e&&(cy=null)}),cy.on(`exit`,()=>{cy===e&&(cy=null)}),J(`Started caffeinate to prevent sleep`)}catch{cy=null}}}function vy(){if(cy!==null){let e=cy;cy=null;try{e.kill(`SIGKILL`),J(`Stopped caffeinate, allowing sleep`)}catch{}}}var yy=class{constructor(){c(this,`_status`,`idle`),c(this,`_generation`,0),c(this,`_changed`,Hu()),c(this,`subscribe`,this._changed.subscribe),c(this,`getSnapshot`,()=>this._status!==`idle`)}reserve(){return this._status===`idle`?(this._status=`dispatching`,this._notify(),!0):!1}cancelReservation(){this._status===`dispatching`&&(this._status=`idle`,this._notify())}tryStart(){return this._status===`running`?null:(this._status=`running`,++this._generation,this._notify(),this._generation)}end(e){return this._generation!==e||this._status!==`running`?!1:(this._status=`idle`,this._notify(),!0)}forceEnd(){this._status!==`idle`&&(this._status=`idle`,++this._generation,this._notify())}get isActive(){return this._status!==`idle`}get generation(){return this._generation}_notify(){this._changed.emit()}};function by(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(mi(f,{},p,e).then(e=>{m===a.current&&e&&!l&&(r.current=e)}),l||c||u){let t=nt(f,e).findLast(Yc);t&&(r.current=t.uuid)}n.current=e.length,i.current=o},[e,t])}function xy(e,t,n,r,i){return{sendBridgeResult:(0,Q.useCallback)(()=>{},[])}}gi(),Dt(),ei(),Fn(),lh(),oh(),Mf();var Sy=gu(()=>uu({method:lu(`log_event`),params:uu({eventName:fu(),eventData:uu({}).passthrough()})}));function Cy(e){(0,Q.useEffect)(()=>{if(!e.length)return;let t=Gs(e);t&&t.client.setNotificationHandler(Sy(),e=>{let{eventName:t,eventData:n}=e.params;X(`tengu_ide_${t}`,n)})},[e])}q();var wy=6e3;function Ty(){return Date.now()-Lu()}function Ey(e){return Ty()<e}function Dy(e){return!Ey(e)}function Oy(e,t){let n=Dl();(0,Q.useEffect)(()=>{Zu(!0)},[]),(0,Q.useEffect)(()=>{let r=!1,i=setInterval(()=>{Dy(6e3)&&!r&&(r=!0,clearInterval(i),ey({message:e,notificationType:t},n))},wy);return()=>clearInterval(i)},[e,t,n])}$p(),oo(),ki(),Ia(),Ct(),Ge(),wr(),Xp(),je(),no(),$o(),wa(),Ko(),ls(),g(),ci(),Rh(),fg(),q(),Oa();var ky={topLeft:`┌`,topRight:`┐`,bottomLeft:`└`,bottomRight:`┘`,horizontal:`─`,vertical:`│`,teeLeft:`├`,teeRight:`┤`};function Ay(e){return Et().syntaxHighlightingDisabled?(0,$.jsx)(My,{...e,highlight:null}):(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(My,{...e,highlight:null}),children:(0,$.jsx)(jy,{...e})})}function jy(e){let t=(0,Q.use)(ne());return(0,$.jsx)(My,{...e,highlight:t})}function My({content:e,maxLines:t,minHeight:n,minWidth:r=40,maxWidth:i,highlight:a}){let{columns:o}=Ql(),[s]=Cl(),c=i??o-4,l=t??20,u=(0,Q.useMemo)(()=>_r(e,s,a),[e,s,a]).split(`
2
+ `),d=u.length>l,f=d?u.slice(0,l):u,p=Math.max(0,Math.min(n??0,l)-f.length-+!!d),m=p>0?[...f,...Array(p).fill(``)]:f,h=Math.max(r,...m.map(e=>xl(e))),g=Math.min(h+4,c),_=g-4,v=`${ky.topLeft}${ky.horizontal.repeat(g-2)}${ky.topRight}`,y=`${ky.bottomLeft}${ky.horizontal.repeat(g-2)}${ky.bottomRight}`,b=d?(()=>{let e=u.length-l,t=`${ky.horizontal.repeat(3)} \u2702 ${ky.horizontal.repeat(3)} ${e} lines hidden `,n=xl(t),r=Math.max(0,g-2-n);return`${ky.teeLeft}${t}${ky.horizontal.repeat(r)}${ky.teeRight}`})():null;return(0,$.jsxs)(G,{flexDirection:`column`,children:[(0,$.jsx)(K,{dimColor:!0,children:v}),m.map((e,t)=>{let n=xl(e)>_?cc(e,0,_):e,r=` `.repeat(Math.max(0,_-xl(n)));return(0,$.jsxs)(G,{flexDirection:`row`,children:[(0,$.jsxs)(K,{dimColor:!0,children:[ky.vertical,` `]}),(0,$.jsx)(bl,{children:n}),(0,$.jsxs)(K,{dimColor:!0,children:[r,` `,ky.vertical]})]},t)}),b&&(0,$.jsx)(K,{color:`warning`,children:b}),(0,$.jsx)(K,{dimColor:!0,children:y})]})}$a(),q(),Hf();function Ny({questions:e,currentQuestionIndex:t,answers:n,hideSubmitTab:r=!1}){let{columns:i}=Ql(),a=(0,Q.useMemo)(()=>{let n=r?``:` ${u.tick} Submit `,a=xl(`← `)+xl(` →`)+xl(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+xl(e)).reduce((e,t)=>e+t,0)<=o)return s;let c=4+xl(s[t]||``),l=Math.min(c,o/2),d=o-l,f=e.length-1,p=Math.max(6,Math.floor(d/Math.max(f,1)));return s.map((e,n)=>n===t?Lf(e,l-2-2):Lf(e,p-2-2))},[e,t,i,r]),o=e.length===1&&r;return(0,$.jsxs)(G,{flexDirection:`row`,marginBottom:1,children:[!o&&(0,$.jsx)(K,{color:t===0?`inactive`:void 0,children:`← `}),e.map((e,r)=>{let i=r===t,o=e?.question&&n[e.question]?u.checkboxOn:u.checkboxOff,s=a[r]||e?.header||`Q${r+1}`;return(0,$.jsx)(G,{children:i?(0,$.jsxs)(K,{backgroundColor:`permission`,color:`inverseText`,children:[` `,o,` `,s,` `]}):(0,$.jsxs)(K,{children:[` `,o,` `,s,` `]})},e?.question||`question-${r}`)}),!r&&(0,$.jsx)(G,{children:t===e.length?(0,$.jsxs)(K,{backgroundColor:`permission`,color:`inverseText`,children:[` `,u.tick,` Submit`,` `]}):(0,$.jsxs)(K,{children:[` `,u.tick,` Submit `]})},`submit`),!o&&(0,$.jsx)(K,{color:t===e.length?`inactive`:void 0,children:` →`})]})}l(),$a(),q(),U(),tc();function Py({question:e,questions:t,currentQuestionIndex:n,answers:r,questionStates:i,hideSubmitTab:a=!1,minContentHeight:o,minContentWidth:s,onUpdateQuestionState:c,onAnswer:l,onTextInputFocus:d,onCancel:f,onTabPrev:p,onTabNext:m,onRespondToClaude:h,onFinishPlanInterview:g}){let _=W(e=>e.toolPermissionContext.mode)===`plan`,[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(0),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(0),E=Fh(),D=E?Ua(E):null,O=e.question,k=i[O],A=e.options,[j,M]=(0,Q.useState)(0),N=(0,Q.useRef)(O);if(N.current!==O){N.current=O;let e=k?.selectedValue,t=e?A.findIndex(t=>t.label===e):-1;M(t>=0?t:0)}let ee=A[j],te=k?.selectedValue,P=k?.textInputValue||``,F=(0,Q.useCallback)(e=>{let t=A[e];t&&(M(e),c(O,{selectedValue:t.label},!1),l(O,t.label))},[A,O,c,l]),I=(0,Q.useCallback)(e=>{if(S)return;let t;t=typeof e==`number`?e:e===`up`?j>0?j-1:j:j<A.length-1?j+1:j,t>=0&&t<A.length&&M(t)},[j,A.length,S]);Ml(`chat:externalEditor`,async()=>{let e=k?.textInputValue||``,t=await Ih(e);t.content!==null&&t.content!==e&&c(O,{textInputValue:t.content},!1)},{context:`Chat`,isActive:S&&!!E}),Sl({"tabs:previous":()=>p?.(),"tabs:next":()=>m?.()},{context:`Tabs`,isActive:!S&&!v});let L=(0,Q.useCallback)(()=>{C(!1),d(!1),te&&l(O,te)},[te,O,l,d]),ne=(0,Q.useCallback)(()=>{y(!0)},[]),re=(0,Q.useCallback)(()=>{y(!1)},[]),ie=(0,Q.useCallback)(e=>{if(v){if(e.key===`up`||e.ctrl&&e.key===`p`){e.preventDefault(),b===0?re():x(0);return}if(e.key===`down`||e.ctrl&&e.key===`n`){e.preventDefault(),_&&b===0&&x(1);return}if(e.key===`return`){e.preventDefault(),b===0?h():g();return}e.key===`escape`&&(e.preventDefault(),f());return}if(S){e.key===`escape`&&(e.preventDefault(),L());return}if(e.key===`up`||e.ctrl&&e.key===`p`)e.preventDefault(),j>0&&I(`up`);else if(e.key===`down`||e.ctrl&&e.key===`n`)e.preventDefault(),j===A.length-1?ne():I(`down`);else if(e.key===`return`)e.preventDefault(),F(j);else if(e.key===`n`&&!e.ctrl&&!e.meta)e.preventDefault(),C(!0),d(!0);else if(e.key===`escape`)e.preventDefault(),f();else if(e.key.length===1&&e.key>=`1`&&e.key<=`9`){e.preventDefault();let t=parseInt(e.key,10)-1;t<A.length&&I(t)}},[v,b,_,S,j,A.length,re,ne,I,F,L,h,g,f,d]),ae=ee?.preview||null,{columns:oe}=Ql(),se=oe-30-4,ce=(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:ie,children:[(0,$.jsx)(vl,{color:`inactive`}),(0,$.jsxs)(G,{flexDirection:`column`,paddingTop:0,children:[(0,$.jsx)(Ny,{questions:t,currentQuestionIndex:n,answers:r,hideSubmitTab:a}),(0,$.jsx)(mg,{title:e.question,color:`text`}),(0,$.jsxs)(G,{flexDirection:`column`,minHeight:o,children:[(0,$.jsxs)(G,{marginTop:1,flexDirection:`row`,gap:4,children:[(0,$.jsx)(G,{flexDirection:`column`,width:30,children:A.map((e,t)=>{let n=j===t,r=te===e.label;return(0,$.jsxs)(G,{flexDirection:`row`,children:[n?(0,$.jsx)(K,{color:`suggestion`,children:u.pointer}):(0,$.jsx)(K,{children:` `}),(0,$.jsxs)(K,{dimColor:!0,children:[` `,t+1,`.`]}),(0,$.jsxs)(K,{color:r?`success`:n?`suggestion`:void 0,bold:n,children:[` `,e.label]}),r&&(0,$.jsxs)(K,{color:`success`,children:[` `,u.tick]})]},e.label)})}),(0,$.jsxs)(G,{flexDirection:`column`,flexGrow:1,children:[(0,$.jsx)(Ay,{content:ae||`No preview available`,maxLines:ce,minWidth:s,maxWidth:se}),(0,$.jsxs)(G,{marginTop:1,flexDirection:`row`,gap:1,children:[(0,$.jsx)(K,{color:`suggestion`,children:`Notes:`}),S?(0,$.jsx)(ha,{value:P,placeholder:`Add notes on this design…`,onChange:e=>{c(O,{textInputValue:e},!1)},onSubmit:L,onExit:L,focus:!0,showCursor:!0,columns:60,cursorOffset:w,onChangeCursorOffset:T}):(0,$.jsx)(K,{dimColor:!0,italic:!0,children:P||`press n to add notes`})]})]})]}),(0,$.jsxs)(G,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(vl,{color:`inactive`}),(0,$.jsxs)(G,{flexDirection:`row`,gap:1,children:[v&&b===0?(0,$.jsx)(K,{color:`suggestion`,children:u.pointer}):(0,$.jsx)(K,{children:` `}),(0,$.jsx)(K,{color:v&&b===0?`suggestion`:void 0,children:`Chat about this`})]}),_&&(0,$.jsxs)(G,{flexDirection:`row`,gap:1,children:[v&&b===1?(0,$.jsx)(K,{color:`suggestion`,children:u.pointer}):(0,$.jsx)(K,{children:` `}),(0,$.jsx)(K,{color:v&&b===1?`suggestion`:void 0,children:`Skip interview and plan immediately`})]})]}),(0,$.jsx)(G,{marginTop:1,children:(0,$.jsxs)(K,{color:`inactive`,dimColor:!0,children:[`Enter to select · `,u.arrowUp,`/`,u.arrowDown,` to navigate · n to add notes`,t.length>1&&(0,$.jsx)($.Fragment,{children:` · Tab to switch questions`}),S&&D&&(0,$.jsxs)($.Fragment,{children:[` · ctrl+g to edit in `,D]}),` · Esc to cancel`]})})]})]})]})}l(),q(),U(),Ph(),tc(),Rh(),Fi(),fg();function Fy({question:e,questions:t,currentQuestionIndex:n,answers:r,questionStates:i,hideSubmitTab:a=!1,planFilePath:o,minContentHeight:s,minContentWidth:c,onUpdateQuestionState:l,onAnswer:d,onTextInputFocus:f,onCancel:p,onSubmit:m,onTabPrev:h,onTabNext:g,onRespondToClaude:_,onFinishPlanInterview:v,onImagePaste:y,pastedContents:b,onRemoveImage:x}){let S=W(e=>e.toolPermissionContext.mode)===`plan`,[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(0),[D,O]=(0,Q.useState)(!1),k=Fh(),A=k?Ua(k):null,j=(0,Q.useCallback)(e=>{let t=e===`__other__`;O(t),f(t)},[f]),M=(0,Q.useCallback)(()=>{w(!0)},[]),N=(0,Q.useCallback)(()=>{w(!1)},[]),ee=(0,Q.useCallback)(e=>{if(C){if(e.key===`up`||e.ctrl&&e.key===`p`){e.preventDefault(),T===0?N():E(0);return}if(e.key===`down`||e.ctrl&&e.key===`n`){e.preventDefault(),S&&T===0&&E(1);return}if(e.key===`return`){e.preventDefault(),T===0?_():v();return}e.key===`escape`&&(e.preventDefault(),p())}},[C,T,S,N,_,v,p]),te=e.options.map(e=>({type:`text`,value:e.label,label:e.label,description:e.description})),P=e.question,F=i[P],I=(0,Q.useCallback)(async(t,n)=>{let r=await Ih(t);r.content!==null&&r.content!==t&&(n(r.content),l(P,{textInputValue:r.content},e.multiSelect??!1))},[P,l,e.multiSelect]),L={type:`input`,value:`__other__`,label:`Other`,placeholder:e.multiSelect?`Type something`:`Type something.`,initialValue:F?.textInputValue??``,onChange:t=>{l(P,{textInputValue:t},e.multiSelect??!1)}},ne=[...te,L];return!e.multiSelect&&e.options.some(e=>e.preview)?(0,$.jsx)(Py,{question:e,questions:t,currentQuestionIndex:n,answers:r,questionStates:i,hideSubmitTab:a,minContentHeight:s,minContentWidth:c,onUpdateQuestionState:l,onAnswer:d,onTextInputFocus:f,onCancel:p,onTabPrev:h,onTabNext:g,onRespondToClaude:_,onFinishPlanInterview:v}):(0,$.jsxs)(G,{flexDirection:`column`,marginTop:0,tabIndex:0,autoFocus:!0,onKeyDown:ee,children:[S&&o&&(0,$.jsxs)(G,{flexDirection:`column`,gap:0,children:[(0,$.jsx)(vl,{color:`inactive`}),(0,$.jsxs)(K,{color:`inactive`,children:[`Planning: `,(0,$.jsx)(ai,{filePath:o})]})]}),(0,$.jsx)(G,{marginTop:-1,children:(0,$.jsx)(vl,{color:`inactive`})}),(0,$.jsxs)(G,{flexDirection:`column`,paddingTop:0,children:[(0,$.jsx)(Ny,{questions:t,currentQuestionIndex:n,answers:r,hideSubmitTab:a}),(0,$.jsx)(mg,{title:e.question,color:`text`}),(0,$.jsxs)(G,{flexDirection:`column`,minHeight:s,children:[(0,$.jsx)(G,{marginTop:1,children:e.multiSelect?(0,$.jsx)(Pa,{options:ne,defaultValue:i[e.question]?.selectedValue,onChange:e=>{l(P,{selectedValue:e},!0);let t=e.includes(`__other__`)?i[P]?.textInputValue:void 0,n=e.filter(e=>e!==`__other__`).concat(t?[t]:[]);d(P,n,void 0,!1)},onFocus:j,onCancel:p,submitButtonText:n===t.length-1?`Submit`:`Next`,onSubmit:m,onDownFromLastItem:M,isDisabled:C,onOpenEditor:I,onImagePaste:y,pastedContents:b,onRemoveImage:x},e.question):(0,$.jsx)(Hn,{options:ne,defaultValue:i[e.question]?.selectedValue,onChange:e=>{l(P,{selectedValue:e},!1);let t=e===`__other__`?i[P]?.textInputValue:void 0;d(P,e,t)},onFocus:j,onCancel:p,onDownFromLastItem:M,isDisabled:C,layout:`compact-vertical`,onOpenEditor:I,onImagePaste:y,pastedContents:b,onRemoveImage:x},e.question)}),(0,$.jsxs)(G,{flexDirection:`column`,children:[(0,$.jsx)(vl,{color:`inactive`}),(0,$.jsxs)(G,{flexDirection:`row`,gap:1,children:[C&&T===0?(0,$.jsx)(K,{color:`suggestion`,children:u.pointer}):(0,$.jsx)(K,{children:` `}),(0,$.jsxs)(K,{color:C&&T===0?`suggestion`:void 0,children:[ne.length+1,`. Chat about this`]})]}),S&&(0,$.jsxs)(G,{flexDirection:`row`,gap:1,children:[C&&T===1?(0,$.jsx)(K,{color:`suggestion`,children:u.pointer}):(0,$.jsx)(K,{children:` `}),(0,$.jsxs)(K,{color:C&&T===1?`suggestion`:void 0,children:[ne.length+2,`. Skip interview and plan immediately`]})]})]}),(0,$.jsx)(G,{marginTop:1,children:(0,$.jsxs)(K,{color:`inactive`,dimColor:!0,children:[`Enter to select ·`,` `,t.length===1?(0,$.jsxs)($.Fragment,{children:[u.arrowUp,`/`,u.arrowDown,` to navigate`]}):`Tab/Arrow keys to navigate`,D&&A&&(0,$.jsxs)($.Fragment,{children:[` · ctrl+g to edit in `,A]}),` · Esc to cancel`]})})]})]})]})}q(),Yn(),U();function Iy(e,t){if(!e)return null;switch(e.type){case`rule`:return{reasonString:`Permission rule ${Ul.bold(zd(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?` ${Ul.dim(`[${e.hookSource}]`)}`:``;return{reasonString:`Hook ${Ul.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 Ly({permissionResult:e,toolType:t}){let n=W(e=>e.toolPermissionContext.mode),r=Iy(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)(K,{color:i,children:r.reasonString}):(0,$.jsx)(K,{children:(0,$.jsx)(bl,{children:r.reasonString})}),r.configString&&(0,$.jsx)(K,{dimColor:!0,children:r.configString})]})}l(),q(),Fi(),fg();function Ry({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)(vl,{color:`inactive`}),(0,$.jsxs)(G,{flexDirection:`column`,borderTop:!0,borderColor:`inactive`,paddingTop:0,children:[(0,$.jsx)(Ny,{questions:e,currentQuestionIndex:t,answers:n}),(0,$.jsx)(mg,{title:`Review your answers`,color:`text`}),(0,$.jsxs)(G,{flexDirection:`column`,marginTop:1,minHeight:a,children:[!r&&(0,$.jsx)(G,{marginBottom:1,children:(0,$.jsxs)(K,{color:`warning`,children:[u.warning,` You have not answered all questions`]})}),Object.keys(n).length>0&&(0,$.jsx)(G,{flexDirection:`column`,marginBottom:1,children:e.filter(e=>e?.question&&n[e.question]).map(e=>{let t=n[e?.question];return(0,$.jsxs)(G,{flexDirection:`column`,marginLeft:1,children:[(0,$.jsxs)(K,{children:[u.bullet,` `,e?.question||`Question`]}),(0,$.jsx)(G,{marginLeft:2,children:(0,$.jsxs)(K,{color:`success`,children:[u.arrowRight,` `,t]})})]},e?.question||`answer`)})}),(0,$.jsx)(Ly,{permissionResult:i,toolType:`tool`}),(0,$.jsx)(K,{color:`inactive`,children:`Ready to submit your answers?`}),(0,$.jsx)(G,{marginTop:1,children:(0,$.jsx)(Hn,{options:[{type:`text`,label:`Submit answers`,value:`submit`},{type:`text`,label:`Cancel`,value:`cancel`}],onChange:e=>o(e),onCancel:()=>o(`cancel`)})})]})]})]})}function zy(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 By={currentQuestionIndex:0,answers:{},questionStates:{},isInTextInput:!1};function Vy(){let[e,t]=(0,Q.useReducer)(zy,By),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}}Is(),$a(),q(),vc(),Mf(),U(),Qe(),Sf(),Ee();var Hy=12,Uy=40,Wy=15;function Gy(e){return Et().syntaxHighlightingDisabled?(0,$.jsx)(qy,{...e,highlight:null}):(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(qy,{...e,highlight:null}),children:(0,$.jsx)(Ky,{...e})})}function Ky(e){let t=(0,Q.use)(ne());return(0,$.jsx)(qy,{...e,highlight:t})}function qy({toolUseConfirm:e,onDone:t,onReject:n,highlight:r}){let i=(0,Q.useMemo)(()=>et.inputSchema.safeParse(e.input),[e.input]),a=i.success&&i.data.questions||[],{rows:o}=Ql(),[s]=Cl(),{globalContentHeight:c,globalContentWidth:l}=(0,Q.useMemo)(()=>{let e=0,t=0,n=Math.max(Hy,o-Wy);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=_r(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,xl(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,Hy),n),globalContentWidth:Math.max(t,Uy)}},[a,o,s,r]),u=i.success?i.data.metadata?.source:void 0,[d,f]=(0,Q.useState)({}),p=(0,Q.useRef)(0);function m(e,t,n,r,i,a){let o=p.current++,s={id:o,type:`image`,content:t,mediaType:n||`image/png`,filename:r||`Pasted image`,dimensions:i};Mi(s),hc(s),f(t=>({...t,[e]:{...t[e]??{},[o]:s}}))}let h=(0,Q.useCallback)((e,t)=>{f(n=>{let r={...n[e]??{}};return delete r[t],{...n,[e]:r}})},[]),g=Object.values(d).flatMap(e=>Object.values(e)).filter(e=>e.type===`image`),_=W(e=>e.toolPermissionContext.mode)===`plan`,v=_?At():void 0,{currentQuestionIndex:y,answers:b,questionStates:x,isInTextInput:S,nextQuestion:C,prevQuestion:w,updateQuestionState:T,setAnswer:E,setTextInputMode:D}=Vy(),O=y<(a?.length||0)?a?.[y]:null,k=y===(a?.length||0),A=a?.every(e=>e?.question&&!!b[e.question])??!1,j=a.length===1&&!a[0]?.multiSelect,M=(0,Q.useCallback)(()=>{u&&X(`tengu_ask_user_question_rejected`,{source:u,questionCount:a.length,isInPlanMode:_,interviewPhaseEnabled:_&&fl()}),t(),n(),e.onReject()},[t,n,e,u,a.length,_]),N=(0,Q.useCallback)(async()=>{let n=`The user wants to clarify these questions.
4
+ This means they may have additional information, context or questions for you.
5
+ Take their response into account and then reformulate the questions if appropriate.
6
+ Start by asking them what they would like to clarify.
7
+
8
+ Questions asked:\n${a.map(e=>{let t=b[e.question];return t?`- "${e.question}"\n Answer: ${t}`:`- "${e.question}"\n (No answer provided)`}).join(`
9
+ `)}`;u&&X(`tengu_ask_user_question_respond_to_claude`,{source:u,questionCount:a.length,isInPlanMode:_,interviewPhaseEnabled:_&&fl()});let r=await Jy(g);t(),e.onReject(n,r&&r.length>0?r:void 0)},[a,b,t,e,u,_,g]),ee=(0,Q.useCallback)(async()=>{let n=`The user has indicated they have provided enough answers for the plan interview.
10
+ Stop asking clarifying questions and proceed to finish the plan with the information you have.
11
+
12
+ Questions asked and answers provided:\n${a.map(e=>{let t=b[e.question];return t?`- "${e.question}"\n Answer: ${t}`:`- "${e.question}"\n (No answer provided)`}).join(`
13
+ `)}`;u&&X(`tengu_ask_user_question_finish_plan_interview`,{source:u,questionCount:a.length,isInPlanMode:_,interviewPhaseEnabled:_&&fl()});let r=await Jy(g);t(),e.onReject(n,r&&r.length>0?r:void 0)},[a,b,t,e,u,_,g]),te=(0,Q.useCallback)(async n=>{u&&X(`tengu_ask_user_question_accepted`,{source:u,questionCount:a.length,answerCount:Object.keys(n).length,isInPlanMode:_,interviewPhaseEnabled:_&&fl()});let r={};for(let e of a){let t=n[e.question],i=x[e.question]?.textInputValue,a=(t?e.options.find(e=>e.label===t):void 0)?.preview;(a||i?.trim())&&(r[e.question]={...a&&{preview:a},...i?.trim()&&{notes:i.trim()}})}let i={...e.input,answers:n,...Object.keys(r).length>0&&{annotations:r}},o=await Jy(g);t(),e.onAllow(i,[],void 0,o&&o.length>0?o:void 0)},[e,t,u,a,x,_,g]),P=(0,Q.useCallback)((e,t,n,r=!0)=>{let i,o=Array.isArray(t);i=o?t.join(`, `):n?Object.values(d[e]??{}).filter(e=>e.type===`image`).length>0?`${n} (Image attached)`:n:t===`__other__`&&Object.values(d[e]??{}).filter(e=>e.type===`image`).length>0?`(Image attached)`:t;let s=a.length===1;if(!o&&s&&r){let t={...b,[e]:i};te(t).catch(Y);return}E(e,i,r)},[E,a.length,b,te,d]);function F(e){if(e===`cancel`){M();return}e===`submit`&&te(b).catch(Y)}let I=j?(a?.length||1)-1:a?.length||0,L=(0,Q.useCallback)(()=>{y>0&&w()},[y,w]),ne=(0,Q.useCallback)(()=>{y<I&&C()},[y,I,C]);return Sl({"tabs:previous":L,"tabs:next":ne},{context:`Tabs`,isActive:!(S&&!k)}),O?(0,$.jsx)(Fy,{question:O,questions:a,currentQuestionIndex:y,answers:b,questionStates:x,hideSubmitTab:j,minContentHeight:c,minContentWidth:l,planFilePath:v,onUpdateQuestionState:T,onAnswer:P,onTextInputFocus:D,onCancel:M,onSubmit:C,onTabPrev:L,onTabNext:ne,onRespondToClaude:N,onFinishPlanInterview:ee,onImagePaste:(e,t,n,r,i)=>m(O.question,e,t,n,r,i),pastedContents:d[O.question]??{},onRemoveImage:e=>h(O.question,e)}):k?(0,$.jsx)(Ry,{questions:a,currentQuestionIndex:y,answers:b,allQuestionsAnswered:A,permissionResult:e.permissionResult,minContentHeight:c,onFinalResponse:F}):null}async function Jy(e){if(e.length!==0)return Promise.all(e.map(async e=>(await m({type:`image`,source:{type:`base64`,media_type:e.mediaType||`image/png`,data:e.content}})).block))}var Yy=[`http://`,`https://`,`ftp://`],Xy={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},Zy=e=>Array.isArray(e)?e:[e];function Qy(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 $y(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(`-`)?!Qy(t,n):!1}function eb(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(r){if(r.startsWith(`-`)){$y(r,e[n+1],t)&&n++;continue}if(!t?.subcommands?.length||Qy(r,t))return r}}}async function tb(e,t,n){let r=await nb(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&&Zy(e.args).some(e=>e?.isCommand||e?.isModule)){i.push(c);continue}}if(a&&!o){$y(c,t[s+1],n)&&s++;continue}break}if(await rb(c,t.slice(0,s),n))break;a&&!o&&(o=Qy(c,n)),i.push(c)}return i.join(` `)}async function nb(e,t,n){let r=eb(t,n),i=e.toLowerCase(),a=r?`${i} ${r.toLowerCase()}`:i;if(Xy[a])return Xy[a];if(Xy[i])return Xy[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&&Zy(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=Zy(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=Zy(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&&Zy(n.args).some(e=>e?.isDangerous)?3:2}async function rb(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=Yy.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&&Zy(e.args).some(e=>e?.isModule))return!1}return!0}var ib=[{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 ab(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 ob=wf(async e=>ib.find(t=>t.name===e)||await ab(e)||null,e=>e),sb=/^\d+$/,cb=/^[A-Za-z_][A-Za-z0-9_]*=/,lb=new Set([`nice`]),ub=e=>Array.isArray(e)?e:[e];function db(e,t){return t?.subcommands?.length?t.subcommands.some(t=>Array.isArray(t.name)?t.name.includes(e):t.name===e):!1}async function fb(e,t=0,n=0){if(n>2||t>10)return null;let r=await Dm(e);if(!r)return null;if(!r.commandNode)return{commandPrefix:null};let{envVars:i,commandNode:a}=r,[o,...s]=Om(a);if(!o)return{commandPrefix:null};let c=await ob(o),l=lb.has(o)||c?.args&&ub(c.args).some(e=>e?.isCommand);l&&s[0]&&db(s[0],c)&&(l=!1);let u=l?await pb(o,s,t,n):await tb(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 pb(e,t,n,r){let i=await ob(e);if(i?.args){let a=ub(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 fb(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(`-`)&&!cb.test(t[e])&&i.push(t[e])}}let a=t.find(e=>!e.startsWith(`-`)&&!sb.test(e)&&!cb.test(e));if(!a)return e;let o=await fb(t.slice(t.indexOf(a)).join(` `),n+1,r+1);return o?.commandPrefix?`${e} ${o.commandPrefix}`:null}async function mb(e,t){let n=yt(e);if(n.length<=1){let t=await fb(e);return t?.commandPrefix?[t.commandPrefix]:[]}let r=[];for(let e of n){let n=e.trim();if(t?.(n))continue;let i=await fb(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(hb(e));return a}function hb(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(` `)}Es(),ze(),Mf();async function gb(e){X(`tengu_unary_event`,{event:e.event,completion_type:e.completion_type,language_name:await e.metadata.language_name,message_id:e.metadata.message_id,platform:e.metadata.platform,...e.metadata.hasFeedback!==void 0&&{hasFeedback:e.metadata.hasFeedback}})}Mf(),U(),Od();function _b(e,t){let n=y(),r=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{r.current!==e.toolUseID&&(r.current=e.toolUseID,n(e=>({...e,attribution:{...e.attribution,permissionPromptCount:e.attribution.permissionPromptCount+1}})),X(`tengu_tool_use_show_permission_request`,{messageID:e.assistantMessage.message.id,toolName:Em(e.tool.name),isMcp:e.tool.isMcp??!1,decisionReasonType:e.permissionResult.decisionReason?.type,sandboxEnabled:Wn.isSandboxingEnabled()}),gb({completion_type:t.completion_type,event:`response`,metadata:{language_name:t.language_name,message_id:e.assistantMessage.message.id,platform:Cd.platform}}))},[e,t,n])}Kl(),l(),q(),U(),Fd(),ig(),uc();function vb(e){switch(e.type){case`rule`:return`${Ul.bold(zd(e.rule.ruleValue))} rule from ${Hd(e.rule.source)}`;case`mode`:return`${Md(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`${Ul.bold(e.permissionPromptToolName)} permission prompt tool`;case`hook`:return e.reason?`${Ul.bold(e.hookName)} hook: ${e.reason}`:`${Ul.bold(e.hookName)} hook`;case`asyncAgent`:return e.reason;default:return``}}function yb({title:e,decisionReason:t}){let[n]=Cl();function r(){switch(t.type){case`subcommandResults`:return(0,$.jsx)(G,{flexDirection:`column`,children:Array.from(t.reasons.entries()).map(([e,t])=>(0,$.jsxs)(G,{flexDirection:`column`,children:[(0,$.jsxs)(K,{children:[t.behavior===`allow`?Yl(`success`,n)(u.tick):Yl(`error`,n)(u.cross),` `,e]}),t.decisionReason!==void 0&&t.decisionReason.type!==`subcommandResults`&&(0,$.jsxs)(K,{children:[(0,$.jsxs)(K,{dimColor:!0,children:[` `,`⎿`,` `]}),(0,$.jsx)(bl,{children:vb(t.decisionReason)})]}),t.behavior===`ask`&&(0,$.jsx)(bb,{suggestions:t.suggestions})]},e))});default:return(0,$.jsx)(K,{children:(0,$.jsx)(bl,{children:vb(t)})})}}return(0,$.jsxs)(G,{flexDirection:`column`,children:[e&&(0,$.jsx)(K,{children:e}),r()]})}function bb({suggestions:e}){let t=Yr(e);return t.length===0?null:(0,$.jsxs)(K,{children:[(0,$.jsxs)(K,{dimColor:!0,children:[` `,`⎿`,` `]}),`Suggested rules: `,(0,$.jsx)(bl,{children:t.map(e=>Ul.bold(zd(e))).join(`, `)})]})}function xb(e){return e?e.flatMap(e=>{switch(e.type){case`addDirectories`:return e.directories;default:return[]}}):[]}function Sb(e){if(!e)return;let t=e.findLast(e=>e.type===`setMode`);return t?.type===`setMode`?t.mode:void 0}function Cb({suggestions:e,width:t}){if(!e||e.length===0)return(0,$.jsxs)(G,{flexDirection:`row`,children:[(0,$.jsx)(G,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(K,{dimColor:!0,children:`Suggestions `})}),(0,$.jsx)(K,{children:`None`})]});let n=Yr(e),r=xb(e),i=Sb(e);return n.length===0&&r.length===0&&!i?(0,$.jsxs)(G,{flexDirection:`row`,children:[(0,$.jsx)(G,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(K,{dimColor:!0,children:`Suggestion `})}),(0,$.jsx)(K,{children:`None`})]}):(0,$.jsxs)(G,{flexDirection:`column`,children:[(0,$.jsxs)(G,{flexDirection:`row`,children:[(0,$.jsx)(G,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(K,{dimColor:!0,children:`Suggestions `})}),(0,$.jsx)(K,{children:` `})]}),n.length>0&&(0,$.jsxs)(G,{flexDirection:`row`,children:[(0,$.jsx)(G,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(K,{dimColor:!0,children:` Rules `})}),(0,$.jsx)(G,{flexDirection:`column`,children:n.map((e,t)=>(0,$.jsxs)(K,{children:[u.bullet,` `,zd(e)]},t))})]}),r.length>0&&(0,$.jsxs)(G,{flexDirection:`row`,children:[(0,$.jsx)(G,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(K,{dimColor:!0,children:` Directories `})}),(0,$.jsx)(G,{flexDirection:`column`,children:r.map((e,t)=>(0,$.jsxs)(K,{children:[u.bullet,` `,e]},t))})]}),i&&(0,$.jsxs)(G,{flexDirection:`row`,children:[(0,$.jsx)(G,{justifyContent:`flex-end`,minWidth:t,children:(0,$.jsx)(K,{dimColor:!0,children:` Mode `})}),(0,$.jsx)(K,{children:Md(i)})]})]})}function wb({permissionResult:e,toolName:t}){let n=W(e=>e.toolPermissionContext),r=e.decisionReason,i=`suggestions`in e?e.suggestions:void 0,a=(0,Q.useMemo)(()=>{let e=Wn.isSandboxingEnabled()&&Wn.isAutoAllowBashIfSandboxedEnabled(),r=ag(n,{sandboxAutoAllowEnabled:e}),a=Yr(i);return a.length>0?r.filter(e=>a.some(t=>t.toolName===e.rule.ruleValue.toolName&&t.ruleContent===e.rule.ruleValue.ruleContent)):t?r.filter(e=>e.rule.ruleValue.toolName===t):r},[n,t,i]);return(0,$.jsxs)(G,{flexDirection:`column`,children:[(0,$.jsxs)(G,{flexDirection:`row`,children:[(0,$.jsx)(G,{justifyContent:`flex-end`,minWidth:10,children:(0,$.jsx)(K,{dimColor:!0,children:`Behavior `})}),(0,$.jsx)(K,{children:e.behavior})]}),e.behavior!==`allow`&&(0,$.jsxs)(G,{flexDirection:`row`,children:[(0,$.jsx)(G,{justifyContent:`flex-end`,minWidth:10,children:(0,$.jsx)(K,{dimColor:!0,children:`Message `})}),(0,$.jsx)(K,{children:e.message})]}),(0,$.jsxs)(G,{flexDirection:`row`,children:[(0,$.jsx)(G,{justifyContent:`flex-end`,minWidth:10,children:(0,$.jsx)(K,{dimColor:!0,children:`Reason `})}),r===void 0?(0,$.jsx)(K,{children:`undefined`}):(0,$.jsx)(yb,{decisionReason:r})]}),(0,$.jsx)(Cb,{suggestions:i,width:10}),a.length>0&&(0,$.jsxs)(G,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(K,{color:`warning`,children:[u.warning,` Unreachable Rules (`,a.length,`)`]}),a.map((e,t)=>(0,$.jsxs)(G,{flexDirection:`column`,marginLeft:2,children:[(0,$.jsx)(K,{color:`warning`,children:zd(e.rule.ruleValue)}),(0,$.jsxs)(K,{dimColor:!0,children:[` `,e.reason]}),(0,$.jsxs)(K,{dimColor:!0,children:[` `,`Fix: `,e.fix]})]},t))]})]})}pg(),vu(),Mf(),Tm(),af(),gd(),yu(),Sf(),Fm(),Ir();var Tb={LOW:1,MEDIUM:2,HIGH:3},Eb=1,Db=2,Ob=3,kb=`Analyze shell commands and explain what they do, why you're running them, and potential risks.`,Ab={name:`explain_command`,description:`Provide an explanation of a shell command`,input_schema:{type:`object`,properties:{explanation:{type:`string`,description:`What this command does (1-2 sentences)`},reasoning:{type:`string`,description:`Why YOU are running this command. Start with "I" - e.g. "I need to check the file contents"`},risk:{type:`string`,description:`What could go wrong, under 15 words`},riskLevel:{type:`string`,enum:[`LOW`,`MEDIUM`,`HIGH`],description:`LOW (safe dev workflows), MEDIUM (recoverable changes), HIGH (dangerous/irreversible)`}},required:[`explanation`,`reasoning`,`risk`,`riskLevel`]}},jb=gu(()=>uu({riskLevel:hu([`LOW`,`MEDIUM`,`HIGH`]),explanation:fu(),reasoning:fu(),risk:fu()}));function Mb(e){if(typeof e==`string`)return e;try{return od(e,null,2)}catch{return String(e)}}function Nb(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 Pb(){return rf().permissionExplainerEnabled!==!1}async function Fb({toolName:e,toolInput:t,toolDescription:n,messages:r,signal:i}){if(!Pb())return null;let a=Date.now();try{let o=Mb(t),s=r?.length?Nb(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 ni({model:Pm()?Tp():jp(),system:kb,messages:[{role:`user`,content:c}],tools:[Ab],tool_choice:{type:`tool`,name:`explain_command`},signal:i,querySource:`permission_explainer`}),u=Date.now()-a;J(`Permission explainer: API returned in ${u}ms, stop_reason=${l.stop_reason}`);let d=l.content.find(e=>e.type===`tool_use`);if(d&&d.type===`tool_use`){J(`Permission explainer: tool input: ${od(d.input).slice(0,500)}`);let t=jb().safeParse(d.input);if(t.success){let n={riskLevel:t.data.riskLevel,explanation:t.data.explanation,reasoning:t.data.reasoning,risk:t.data.risk};return X(`tengu_permission_explainer_generated`,{tool_name:Em(e),risk_level:Tb[n.riskLevel],latency_ms:u}),J(`Permission explainer: ${n.riskLevel} risk for ${e} (${u}ms)`),n}}return X(`tengu_permission_explainer_error`,{tool_name:Em(e),error_type:Eb,latency_ms:u}),J(`Permission explainer: no parsed output in response`),null}catch(t){let n=Date.now()-a;return i.aborted?(J(`Permission explainer: request aborted for ${e}`),null):(J(`Permission explainer error: ${cd(t)}`),Y(t),X(`tengu_permission_explainer_error`,{tool_name:Em(e),error_type:t instanceof Error&&t.name===`AbortError`?Db:Ob,latency_ms:n}),null)}}q(),vc(),Mf();var Ib=`Loading explanation…`;function Lb(){let[e,t]=gt(`responding`,Ib,!1);return(0,$.jsx)(G,{ref:e,children:(0,$.jsx)(K,{children:Ib.split(``).map((e,n)=>(0,$.jsx)(Ga,{char:e,index:n,glimmerIndex:t,messageColor:`inactive`,shimmerColor:`text`},n))})})}function Rb(e){switch(e){case`LOW`:return`success`;case`MEDIUM`:return`warning`;case`HIGH`:return`error`}}function zb(e){switch(e){case`LOW`:return`Low risk`;case`MEDIUM`:return`Med risk`;case`HIGH`:return`High risk`}}function Bb(e){return Fb({toolName:e.toolName,toolInput:e.toolInput,toolDescription:e.toolDescription,messages:e.messages,signal:new AbortController().signal}).catch(()=>null)}function Vb(e){let t=Pb(),[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(null);return Ml(`confirm:toggleExplanation`,()=>{n||(X(`tengu_permission_explainer_shortcut_used`,{}),i||a(Bb(e))),r(e=>!e)},{context:`Confirmation`,isActive:t}),{visible:n,enabled:t,promise:i}}function Hb({promise:e}){let t=(0,Q.use)(e);return t?(0,$.jsxs)(G,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(K,{children:t.explanation}),(0,$.jsx)(G,{marginTop:1,children:(0,$.jsx)(K,{children:t.reasoning})}),(0,$.jsx)(G,{marginTop:1,children:(0,$.jsxs)(K,{children:[(0,$.jsxs)(K,{color:Rb(t.riskLevel),children:[zb(t.riskLevel),`:`]}),(0,$.jsxs)(K,{children:[` `,t.risk]})]})})]}):(0,$.jsx)(G,{marginTop:1,children:(0,$.jsx)(K,{dimColor:!0,children:`Explanation unavailable`})})}function Ub({visible:e,promise:t}){return!e||!t?null:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(G,{marginTop:1,children:(0,$.jsx)(Lb,{})}),children:(0,$.jsx)(Hb,{promise:t})})}$a(),q(),Sf(),he(),en();function Wb(e){let[t]=(0,Q.useState)(()=>qb(e.file_path,e.edits));return(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(Kb,{placeholder:!0}),children:(0,$.jsx)(Gb,{promise:t,file_path:e.file_path})})}function Gb({promise:e,file_path:t}){let{patch:n,firstLine:r,fileContent:i}=(0,Q.use)(e),{columns:a}=Ql();return(0,$.jsx)(Kb,{children:(0,$.jsx)(ko,{hunks:n,dim:!1,width:a,filePath:t,firstLine:r,fileContent:i})})}function Kb({children:e,placeholder:t}){return(0,$.jsx)(G,{flexDirection:`column`,children:(0,$.jsx)(G,{borderColor:`subtle`,borderStyle:`dashed`,flexDirection:`column`,borderLeft:!1,borderRight:!1,children:t?(0,$.jsx)(K,{dimColor:!0,children:`…`}):e})})}async function qb(e,t){let n=t.filter(e=>e.old_string!=null&&e.new_string!=null),r=n.length===1?n[0]:void 0;if(r&&r.old_string.length>=8192)return Jb(e,[r]);try{let t=await bn(e);if(t===null)return Jb(e,n);try{if(!r||r.old_string===``){let r=await zo(t);return r===null?Jb(e,n):{patch:Oe({filePath:e,fileContents:r,edits:n.map(e=>Yb(r,e))}),firstLine:Gf(r),fileContent:r}}let i=await A(t,r.old_string,3);if(i.truncated||i.content===``)return Jb(e,[r]);let a=Yb(i.content,r);return{patch:br(Oe({filePath:e,fileContents:i.content,edits:[a]}),i.lineOffset-1),firstLine:i.lineOffset===1?Gf(i.content):null,fileContent:i.content}}finally{await t.close()}}catch(t){return Y(t),Jb(e,n)}}function Jb(e,t){return{patch:t.flatMap(t=>Oe({filePath:e,fileContents:t.old_string,edits:[t]})),firstLine:null,fileContent:void 0}}function Yb(e,t){let n=Zc(e,t.old_string)||t.old_string;return{...t,old_string:n}}Mn(),Mf(),Hc(),af(),En(),ld(),tc(),Sf();function Xb({onChange:e,toolUseContext:t,filePath:n,edits:r,editMode:i}){let a=(0,Q.useRef)(!1),[o,s]=(0,Q.useState)(!1),c=(0,Q.useMemo)(()=>l_().slice(0,6),[]),l=(0,Q.useMemo)(()=>`✻ [Work Mate] ${e_(n)} (${c}) ⧉`,[n,c]),u=ms(t.options.mcpClients)&&rf().diffTool===`auto`&&!n.endsWith(`.ipynb`),d=yo(t.options.mcpClients)??`IDE`;async function f(){if(u)try{X(`tengu_ext_will_show_diff`,{});let{oldContent:o,newContent:s}=await Qb(n,r,t,l);if(a.current)return;X(`tengu_ext_diff_accepted`,{});let c=Zb(n,o,s,i);if(c.length===0){X(`tengu_ext_diff_rejected`,{});let i=Gs(t.options.mcpClients);i&&await $b(l,i),e({type:`reject`},{file_path:n,edits:r});return}e({type:`accept-once`},{file_path:n,edits:c})}catch(e){Y(e),s(!0)}}return(0,Q.useEffect)(()=>(f(),()=>{a.current=!0}),[]),{closeTabInIDE(){let e=Gs(t.options.mcpClients);return e?$b(l,e):Promise.resolve()},showingDiffInIDE:u&&!o,ideName:d,hasError:o}}function Zb(e,t,n,r){let i=r===`single`,a=Se({filePath:e,oldContent:t,newContent:n,singleHunk:i});return a.length===0?[]:(i&&a.length>1&&Y(Error(`Unexpected number of hunks: ${a.length}. Expected 1 hunk.`)),lr(a))}async function Qb(e,t,n,r){let i=!1,a=Ud(e),o=``;try{o=Dd(a)}catch(e){if(!ad(e))throw e}async function s(){if(!i){i=!0;try{await $b(r,c)}catch(e){Y(e)}process.off(`beforeExit`,s),n.abortController.signal.removeEventListener(`abort`,s)}}n.abortController.signal.addEventListener(`abort`,s),process.on(`beforeExit`,s);let c=Gs(n.options.mcpClients);try{let{updatedFile:e}=z({filePath:a,fileContents:o,edits:t});if(c?.type!==`connected`)throw Error(`IDE client not available`);let n=a,i=c.config.ideRunningInWindows===!0;Of()===`wsl`&&i&&process.env.WSL_DISTRO_NAME&&(n=new lo(process.env.WSL_DISTRO_NAME).toIDEPath(a));let l=await wc(`openDiff`,{old_file_path:n,new_file_path:n,new_file_contents:e,tab_name:r},c),u=Array.isArray(l)?l:[l];if(nx(u))return s(),{oldContent:o,newContent:u[1].text};if(ex(u))return s(),{oldContent:o,newContent:e};if(tx(u))return s(),{oldContent:o,newContent:o};throw Error(`Not accepted`)}catch(e){throw Y(e),s(),e}}async function $b(e,t){try{if(t?.type!==`connected`)throw Error(`IDE client not available`);await wc(`close_tab`,{tab_name:e},t)}catch(e){Y(e)}}function ex(e){return Array.isArray(e)&&typeof e[0]==`object`&&e[0]!==null&&`type`in e[0]&&e[0].type===`text`&&`text`in e[0]&&e[0].text===`TAB_CLOSED`}function tx(e){return Array.isArray(e)&&typeof e[0]==`object`&&e[0]!==null&&`type`in e[0]&&e[0].type===`text`&&`text`in e[0]&&e[0].text===`DIFF_REJECTED`}function nx(e){return Array.isArray(e)&&e[0]?.type===`text`&&e[0].text===`FILE_SAVED`&&typeof e[1].text==`string`}q(),tc(),Fi();function rx({onChange:e,options:t,input:n,filePath:r,ideName:i,symlinkTarget:a,rejectFeedback:o,acceptFeedback:s,setFocusedOption:c,onInputModeToggle:l,focusedOption:u,yesInputMode:d,noInputMode:f}){return(0,$.jsx)(iu,{color:`permission`,children:(0,$.jsxs)(G,{flexDirection:`column`,gap:1,children:[(0,$.jsxs)(K,{bold:!0,color:`permission`,children:[`Opened changes in `,i,` ⧉`]}),a&&(0,$.jsx)(K,{color:`warning`,children:i_(id(),a).startsWith(`..`)?`This will modify ${a} (outside working directory) via a symlink`:`Symlink target: ${a}`}),Ca()&&(0,$.jsx)(K,{dimColor:!0,children:`Save file to continue…`}),(0,$.jsxs)(G,{flexDirection:`column`,children:[(0,$.jsxs)(K,{children:[`Do you want to make this edit to `,(0,$.jsx)(K,{bold:!0,children:e_(r)}),`?`]}),(0,$.jsx)(Hn,{options:t,inlineDescriptions:!0,onChange:r=>{let i=t.find(e=>e.value===r);if(i){if(i.option.type===`reject`){let t=o.trim();e(i.option,n,t||void 0);return}if(i.option.type===`accept-once`){let t=s.trim();e(i.option,n,t||void 0);return}e(i.option,n)}},onCancel:()=>e({type:`reject`},n),onFocus:e=>c(e),onInputModeToggle:l})]}),(0,$.jsx)(G,{marginTop:1,children:(0,$.jsxs)(K,{dimColor:!0,children:[`Esc to cancel`,(u===`yes`&&!d||u===`no`&&!f)&&` · Tab to amend`]})})]})})}Ru(),q(),$d();function ix(e){let t=Ud(e),n=Ud(`${bu()}/.workmate`),r=Le(t),i=Le(n);return r.startsWith(i+a_.toLowerCase())||r.startsWith(`${i}/`)}function ax(e){let t=Ud(e),n=r_(Zg(),`.workmate`),r=Le(t),i=Le(n);return r.startsWith(i+a_.toLowerCase())||r.startsWith(`${i}/`)}function ox({filePath:e,toolPermissionContext:t,operationType:n=`write`,onRejectFeedbackChange:r,onAcceptFeedbackChange:i,yesInputMode:a=!1,noInputMode:o=!1}){let s=[],c=Yo(`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=mt(e,t),u=ix(e),d=ax(e);if((u||d)&&n!==`read`)s.push({label:`Yes, allow edits to .workmate/ config for this session`,value:`yes-claude-folder`,option:{type:`accept-session`,scope:d?`global-claude-folder`:`claude-folder`}});else{let t;if(l)t=n===`read`?`Yes, during this session`:(0,$.jsxs)(K,{children:[`Yes, allow all edits during this session `,(0,$.jsxs)(K,{bold:!0,children:[`(`,c,`)`]})]});else{let r=e_(Xd(e))||`this directory`;t=n===`read`?(0,$.jsxs)(K,{children:[`Yes, allow reading from `,(0,$.jsxs)(K,{bold:!0,children:[r,`/`]}),` during this session`]}):(0,$.jsxs)(K,{children:[`Yes, allow all edits in `,(0,$.jsxs)(K,{bold:!0,children:[r,`/`]}),` during this session`,` `,(0,$.jsxs)(K,{bold:!0,children:[`(`,c,`)`]})]})}s.push({label:t,value:`yes-session`,option:{type:`accept-session`}})}return o&&r?s.push({type:`input`,label:`No`,value:`no`,placeholder:`and tell Work Mate what to do differently`,onChange:r,allowEmptySubmitToCancel:!0,option:{type:`reject`}}):s.push({label:`No`,value:`no`,option:{type:`reject`}}),s}Mf(),Tm(),Od(),dn();function sx(e,t,n,r,i){gb({completion_type:t,event:e,metadata:{language_name:n,message_id:r,platform:Cd.platform,hasFeedback:i??!1}})}function cx(e,t){let{messageId:n,toolUseConfirm:r,onDone:i,completionType:a,languageName:o}=e;sx(`accept`,a,o,n),X(`tengu_accept_submitted`,{toolName:Em(r.tool.name),isMcp:r.tool.isMcp??!1,has_instructions:!!t?.feedback,instructions_length:t?.feedback?.length??0,entered_feedback_mode:t?.enteredFeedbackMode??!1}),i(),r.onAllow(r.input,[],t?.feedback)}function lx(e,t){let{messageId:n,path:r,toolUseConfirm:i,toolPermissionContext:a,onDone:o,completionType:s,languageName:c,operationType:l}=e;if(sx(`accept`,s,c,n),t?.scope===`claude-folder`||t?.scope===`global-claude-folder`){let e=[{type:`addRules`,rules:[{toolName:Kp,ruleContent:t.scope===`global-claude-folder`?Rp:Vp}],behavior:`allow`,destination:`session`}];o(),i.onAllow(i.input,e);return}let u=r?N(r,l,a):[];o(),i.onAllow(i.input,u)}function ux(e,t){let{messageId:n,toolUseConfirm:r,onDone:i,onReject:a,completionType:o,languageName:s}=e;sx(`reject`,o,s,n,t?.hasFeedback),X(`tengu_reject_submitted`,{toolName:Em(r.tool.name),isMcp:r.tool.isMcp??!1,has_instructions:!!t?.feedback,instructions_length:t?.feedback?.length??0,entered_feedback_mode:t?.enteredFeedbackMode??!1}),i(),a(),r.onReject(t?.feedback)}var dx={"accept-once":cx,"accept-session":lx,reject:ux};U(),vc(),Mf(),Tm();function fx({filePath:e,completionType:t,languageName:n,toolUseConfirm:r,onDone:i,onReject:a,parseInput:o,operationType:s=`write`}){let c=W(e=>e.toolPermissionContext),[l,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)(``),[p,m]=(0,Q.useState)(`yes`),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(!1),C=(0,Q.useMemo)(()=>ox({filePath:e,toolPermissionContext:c,operationType:s,onRejectFeedbackChange:f,onAcceptFeedbackChange:u,yesInputMode:h,noInputMode:_}),[e,c,s,h,_]),w=(0,Q.useCallback)((o,l,u)=>{let d={messageId:r.assistantMessage.message.id,path:e,toolUseConfirm:r,toolPermissionContext:c,onDone:i,onReject:a,completionType:t,languageName:n,operationType:s},f=r.onAllow;r.onAllow=(e,t,n)=>{f(l,t,n)};let p=dx[o.type];p(d,{feedback:u,hasFeedback:!!u,enteredFeedbackMode:o.type===`accept-once`?y:x,scope:o.type===`accept-session`?o.scope:void 0})},[e,t,n,r,c,i,a,s,y,x]);return Sl({"confirm:cycleMode":(0,Q.useCallback)(()=>{let e=C.find(e=>e.option.type===`accept-session`);if(e){let t=o(r.input);w(e.option,t)}},[C,o,r.input,w])},{context:`Confirmation`}),{options:C,onChange:w,acceptFeedback:l,rejectFeedback:d,focusedOption:p,setFocusedOption:(0,Q.useCallback)(e=>{e!==`yes`&&h&&!l.trim()&&g(!1),e!==`no`&&_&&!d.trim()&&v(!1),m(e)},[h,_,l,d]),handleInputModeToggle:(0,Q.useCallback)(e=>{let t={toolName:Em(r.tool.name),isMcp:r.tool.isMcp??!1};e===`yes`?h?(g(!1),X(`tengu_accept_feedback_mode_collapsed`,t)):(g(!0),b(!0),X(`tengu_accept_feedback_mode_entered`,t)):e===`no`&&(_?(v(!1),X(`tengu_reject_feedback_mode_collapsed`,t)):(v(!0),S(!0),X(`tengu_reject_feedback_mode_entered`,t)))},[h,_,r]),yesInputMode:h,noInputMode:_}}q(),Qe(),rd(),$d(),Fi();function px({toolUseConfirm:e,toolUseContext:t,onDone:n,onReject:r,title:i,subtitle:a,question:o=`Do you want to proceed?`,content:s,completionType:c=`tool_use_single`,path:l,parseInput:u,operationType:d=`write`,ideDiffSupport:f,languageName:p}){let m=(0,Q.useMemo)(()=>p??(l?zr(l):`none`),[p,l]);_b(e,(0,Q.useMemo)(()=>({completion_type:c,language_name:m}),[c,m]));let h=(0,Q.useMemo)(()=>{if(!l||d===`read`)return null;let e=Ud(l),{resolvedPath:t,isSymlink:n}=hd(yd(),e);return n?t:null},[l,d]),g=fx({filePath:l||``,completionType:c,languageName:m,toolUseConfirm:e,onDone:n,onReject:r,parseInput:u,operationType:d}),{options:_,acceptFeedback:v,rejectFeedback:y,setFocusedOption:b,handleInputModeToggle:x,focusedOption:S,yesInputMode:C,noInputMode:w}=g,T=u(e.input),E=(0,Q.useMemo)(()=>f?f.getConfig(u(e.input)):null,[f,e.input]),{closeTabInIDE:D,showingDiffInIDE:O,ideName:k}=Xb(E?{onChange:(e,t)=>{let n=f.applyChanges(T,t.edits);g.onChange(e,n)},toolUseContext:t,filePath:E.filePath,edits:(E.edits||[]).map(e=>({old_string:e.old_string,new_string:e.new_string,replace_all:e.replace_all||!1})),editMode:E.editMode||`single`}:{onChange:()=>{},toolUseContext:t,filePath:``,edits:[],editMode:`single`}),A=(e,t)=>{D?.(),g.onChange(e,T,t?.trim())};if(O&&E&&l)return(0,$.jsx)(rx,{onChange:(e,t,n)=>A(e,n),options:_,filePath:l,input:T,ideName:k,symlinkTarget:h,rejectFeedback:y,acceptFeedback:v,setFocusedOption:b,onInputModeToggle:x,focusedOption:S,yesInputMode:C,noInputMode:w});let j=h!=null&&i_(id(),h).startsWith(`..`);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(hg,{title:i,subtitle:a,innerPaddingX:0,children:[h?(0,$.jsx)(G,{paddingX:1,marginBottom:1,children:(0,$.jsx)(K,{color:`warning`,children:j?`This will modify ${h} (outside working directory) via a symlink`:`Symlink target: ${h}`})}):null,s,(0,$.jsxs)(G,{flexDirection:`column`,paddingX:1,children:[typeof o==`string`?(0,$.jsx)(K,{children:o}):o,(0,$.jsx)(Hn,{options:_,inlineDescriptions:!0,onChange:e=>{let t=_.find(t=>t.value===e);if(t){if(t.option.type===`reject`){let e=y.trim();A(t.option,e||void 0);return}if(t.option.type===`accept-once`){let e=v.trim();A(t.option,e||void 0);return}A(t.option)}},onCancel:()=>A({type:`reject`}),onFocus:e=>b(e),onInputModeToggle:x})]})]}),(0,$.jsx)(G,{paddingX:1,marginTop:1,children:(0,$.jsxs)(K,{dimColor:!0,children:[`Esc to reject`,(S===`yes`&&!C||S===`no`&&!w)&&` · Tab to add feedback`]})})]})}rd(),ld(),Zd(),md(),q();function mx({sedInfo:e,...t}){let{filePath:n}=e;return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(hx,{sedInfo:e,contentPromise:(0,Q.useMemo)(()=>(async()=>{let e=kd(n);return{oldContent:(await yd().readFile(n,{encoding:e})).replaceAll(`\r
22
+ `,`
23
+ `),fileExists:!0}})().catch(e=>{if(!ad(e))throw e;return{oldContent:``,fileExists:!1}}),[n]),...t})})}function hx({sedInfo:e,contentPromise:t,...n}){let{filePath:r}=e,{oldContent:i,fileExists:a}=(0,Q.use)(t),o=(0,Q.useMemo)(()=>Ti(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)(px,{toolUseConfirm:n.toolUseConfirm,toolUseContext:n.toolUseContext,onDone:n.onDone,onReject:n.onReject,title:`Edit file`,subtitle:i_(id(),r),question:(0,$.jsxs)(K,{children:[`Do you want to make this edit to `,(0,$.jsx)(K,{bold:!0,children:e_(r)}),`?`]}),content:s.length>0?(0,$.jsx)(Wb,{file_path:r,edits:s}):(0,$.jsx)(K,{dimColor:!0,children:c}),path:r,completionType:`str_replace_single`,parseInput:e=>({...kr.inputSchema.parse(e),_simulatedSedEdit:{filePath:r,newContent:o}})})}Od();function gx(e,{assistantMessage:{message:{id:t}}},n,r){gb({completion_type:e,event:n,metadata:{language_name:`none`,message_id:t,platform:Ad(),hasFeedback:r??!1}})}Mf(),Tm(),U();function _x({toolUseConfirm:e,onDone:t,onReject:n,explainerVisible:r}){let i=y(),[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 b(t){e.onUserInteraction();let n={toolName:Em(e.tool.name),isMcp:e.tool.isMcp??!1};t===`yes`?l?(u(!1),X(`tengu_accept_feedback_mode_collapsed`,n)):(u(!0),g(!0),X(`tengu_accept_feedback_mode_entered`,n)):t===`no`&&(d?(f(!1),X(`tengu_reject_feedback_mode_collapsed`,n)):(f(!0),v(!0),X(`tengu_reject_feedback_mode_entered`,n)))}function x(a){let o=a?.trim(),s=!!o;s||(X(`tengu_permission_request_escape`,{explainer_visible:r}),i(e=>({...e,attribution:{...e.attribution,escapeCount:e.attribution.escapeCount+1}}))),gx(`tool_use_single`,e,`reject`,s),o?e.onReject(o):e.onReject(),n(),t()}function S(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:b,handleReject:x,handleFocus:S}}Ru(),q();function vx(e){switch(e.length){case 0:return``;case 1:return(0,$.jsx)(K,{bold:!0,children:e[0]});case 2:return(0,$.jsxs)(K,{children:[(0,$.jsx)(K,{bold:!0,children:e[0]}),` and `,(0,$.jsx)(K,{bold:!0,children:e[1]})]});default:return(0,$.jsxs)(K,{children:[(0,$.jsx)(K,{bold:!0,children:e.slice(0,-1).join(`, `)}),`, and `,(0,$.jsx)(K,{bold:!0,children:e.slice(-1)[0]})]})}}function yx(e){return e.join(`, `).length>50?`similar`:vx(e)}function bx(e){if(e.length===0)return``;let t=e.map(e=>e_(e)||e);return t.length===1?(0,$.jsxs)(K,{children:[(0,$.jsx)(K,{bold:!0,children:t[0]}),a_]}):t.length===2?(0,$.jsxs)(K,{children:[(0,$.jsx)(K,{bold:!0,children:t[0]}),a_,` and `,(0,$.jsx)(K,{bold:!0,children:t[1]}),a_]}):(0,$.jsxs)(K,{children:[(0,$.jsx)(K,{bold:!0,children:t[0]}),a_,`, `,(0,$.jsx)(K,{bold:!0,children:t[1]}),a_,` and `,e.length-2,` more`]})}function xx(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=Qc(e.ruleContent)??e.ruleContent;return n?n(t):t}))],l=o.length>0,u=s.length>0,d=c.length>0;if(u&&!l&&!d){if(s.length===1){let e=s[0];return(0,$.jsxs)(K,{children:[`Yes, allow reading from `,(0,$.jsx)(K,{bold:!0,children:e_(e)||e}),a_,` from this project`]})}return(0,$.jsxs)(K,{children:[`Yes, allow reading from `,bx(s),` from this project`]})}if(l&&!u&&!d){if(o.length===1){let e=o[0];return(0,$.jsxs)(K,{children:[`Yes, and always allow access to `,(0,$.jsx)(K,{bold:!0,children:e_(e)||e}),a_,` from this project`]})}return(0,$.jsxs)(K,{children:[`Yes, and always allow access to `,bx(o),` from this project`]})}if(d&&!l&&!u)return(0,$.jsxs)(K,{children:[`Yes, and don't ask again for `,yx(c),` commands in `,(0,$.jsx)(K,{bold:!0,children:bu()})]});if((l||u)&&!d){let e=[...o,...s];if(l&&u)return(0,$.jsxs)(K,{children:[`Yes, and always allow access to `,bx(e),` from this project`]})}if((l||u)&&d){let e=[...o,...s];return e.length===1&&c.length===1?(0,$.jsxs)(K,{children:[`Yes, and allow access to `,bx(e),` and `,yx(c),` commands`]}):(0,$.jsxs)(K,{children:[`Yes, and allow `,bx(e),` access and `,yx(c),` commands`]})}return null}ks();function Sx(e){let{commandWithoutRedirections:t,redirections:n}=kt(e);return n.length>0?t:e}function Cx({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`}),Ni()){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=xx(e,Up,Sx);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}q(),vc(),Mf(),Tm(),U(),Qr(),fi(),Ke(),uc(),Es(),ze(),pg();function wx(e){let{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,verbose:a}=e,{command:o,description:s}=kr.inputSchema.parse(t.input),c=Pi(o);return c?(0,$.jsx)(mx,{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,verbose:a,sedInfo:c}):(0,$.jsx)(Tx,{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i,verbose:a,command:o,description:s})}function Tx({toolUseConfirm:e,toolUseContext:t,onDone:n,onReject:r,verbose:i,command:a,description:o}){let[s]=Cl(),c=W(e=>e.toolPermissionContext),l=Vb({toolName:e.tool.name,toolInput:e.input,toolDescription:e.description,messages:t.messages}),{yesInputMode:u,noInputMode:d,yesFeedbackModeEntered:f,noFeedbackModeEntered:p,acceptFeedback:m,rejectFeedback:h,setAcceptFeedback:g,setRejectFeedback:_,focusedOption:v,handleInputModeToggle:y,handleReject:b,handleFocus:x}=_x({toolUseConfirm:e,onDone:n,onReject:r,explainerVisible:l.visible}),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(o||``),[E,D]=(0,Q.useState)(!o?.trim());(0,Q.useEffect)(()=>{if(!Ws())return;let e=new AbortController;return Aa(a,o,e.signal).then(t=>{t&&!e.signal.aborted&&(T(t),D(!1))}).catch(()=>{}),()=>e.abort()},[a,o]);let O=e.permissionResult.decisionReason?.type===`subcommandResults`,[k,A]=(0,Q.useState)(()=>{if(O){let t=Yr(`suggestions`in e.permissionResult?e.permissionResult.suggestions:void 0).filter(e=>e.toolName===kr.name&&e.ruleContent);return t.length===1?t[0].ruleContent:void 0}let t=Vr(a);if(t)return`${t}:*`;let n=re(a);return n?`${n}:*`:a}),j=(0,Q.useRef)(!1),M=(0,Q.useCallback)(e=>{j.current=!0,A(e)},[]);(0,Q.useEffect)(()=>{if(O)return;let e=!1;return mb(a,e=>kr.isReadOnly({command:e})).then(t=>{e||j.current||t.length>0&&A(`${t[0]}:*`)}).catch(()=>{}),()=>{e=!0}},[a,O]);let[N]=(0,Q.useState)(!1),{destructiveWarning:ee,sandboxingEnabled:te,isSandboxed:P}=(0,Q.useMemo)(()=>{let t=Wn.isSandboxingEnabled();return{destructiveWarning:null,sandboxingEnabled:t,isSandboxed:t&&Gr(e.input)}},[a,e.input]);_b(e,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let F=(0,Q.useMemo)(()=>dc(c),[c]),I=(0,Q.useMemo)(()=>Cx({suggestions:e.permissionResult.behavior===`ask`?e.permissionResult.suggestions:void 0,decisionReason:e.permissionResult.decisionReason,onRejectFeedbackChange:_,onAcceptFeedbackChange:g,onClassifierDescriptionChange:T,classifierDescription:w,initialClassifierDescriptionEmpty:E,existingAllowDescriptions:F,yesInputMode:u,noInputMode:d,editablePrefix:k,onEditablePrefixChange:M}),[e,w,E,F,u,d,k,M]);Ml(`permission:toggleDebug`,(0,Q.useCallback)(()=>{C(e=>!e)},[]),{context:`Confirmation`}),Ml(`confirm:no`,(0,Q.useCallback)(()=>{e.onDismissCheckmark?.()},[e]),{context:`Confirmation`,isActive:!1});function L(t){X(`tengu_permission_request_option_selected`,{option_index:{yes:1,"yes-apply-suggestions":2,"yes-prefix-edited":2,no:3}[t],explainer_visible:l.visible});let r=Em(e.tool.name);if(t===`yes-prefix-edited`){let t=(k??``).trim();if(gx(`tool_use_single`,e,`accept`),!t)e.onAllow(e.input,[]);else{let n=[{type:`addRules`,rules:[{toolName:kr.name,ruleContent:t}],behavior:`allow`,destination:`localSettings`}];e.onAllow(e.input,n)}n();return}switch(t){case`yes`:{let t=m.trim();gx(`tool_use_single`,e,`accept`),X(`tengu_accept_submitted`,{toolName:r,isMcp:e.tool.isMcp??!1,has_instructions:!!t,instructions_length:t.length,entered_feedback_mode:f}),e.onAllow(e.input,[],t||void 0),n();break}case`yes-apply-suggestions`:{gx(`tool_use_single`,e,`accept`);let t=`suggestions`in e.permissionResult&&e.permissionResult.suggestions||[];e.onAllow(e.input,t),n();break}case`no`:{let t=h.trim();X(`tengu_reject_submitted`,{toolName:r,isMcp:e.tool.isMcp??!1,has_instructions:!!t,instructions_length:t.length,entered_feedback_mode:p}),b(t||void 0);break}}}return(0,$.jsxs)(hg,{title:te&&!P?`Bash command (unsandboxed)`:`Bash command`,subtitle:void 0,children:[(0,$.jsxs)(G,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(K,{dimColor:l.visible,children:kr.renderToolUseMessage({command:a,description:o},{theme:s,verbose:!0})}),!l.visible&&(0,$.jsx)(K,{dimColor:!0,children:e.description}),(0,$.jsx)(Ub,{visible:l.visible,promise:l.promise})]}),S?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(wb,{permissionResult:e.permissionResult,toolName:`Bash`}),t.options.debug&&(0,$.jsx)(G,{justifyContent:`flex-end`,marginTop:1,children:(0,$.jsx)(K,{dimColor:!0,children:`Ctrl-D to hide debug info`})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(G,{flexDirection:`column`,children:[(0,$.jsx)(Ly,{permissionResult:e.permissionResult,toolType:`command`}),ee&&(0,$.jsx)(G,{marginBottom:1,children:(0,$.jsx)(K,{color:`warning`,dimColor:!1,children:ee})}),(0,$.jsx)(K,{dimColor:!1,children:`Do you want to proceed?`}),(0,$.jsx)(Hn,{options:I,isDisabled:!1,inlineDescriptions:!0,onChange:L,onCancel:()=>b(),onFocus:x,onInputModeToggle:y})]}),(0,$.jsxs)(G,{justifyContent:`space-between`,marginTop:1,children:[(0,$.jsxs)(K,{dimColor:!0,children:[`Esc to reject`,(v===`yes`&&!u||v===`no`&&!d)&&` · Tab to add feedback`,l.enabled&&` · ctrl+e to ${l.visible?`hide`:`explain`}`]}),t.options.debug&&(0,$.jsx)(K,{dimColor:!0,children:`Ctrl+d to show debug info`})]})]})]})}Ru(),q(),Mf(),U(),Zn(),Fi(),pg();function Ex({toolUseConfirm:e,onDone:t,onReject:n}){let r=W(e=>e.toolPermissionContext.mode);function i(i){i===`yes`?(X(`tengu_plan_enter`,{interviewPhaseEnabled:fl(),entryMethod:`tool`}),Fu(r,`plan`),t(),e.onAllow({},[{type:`setMode`,mode:`plan`,destination:`session`}])):(t(),n(),e.onReject())}return(0,$.jsx)(hg,{color:`planMode`,title:`Enter plan mode?`,children:(0,$.jsxs)(G,{flexDirection:`column`,marginTop:1,paddingX:1,children:[(0,$.jsx)(K,{children:`Work Mate wants to enter plan mode to explore and design an implementation approach.`}),(0,$.jsxs)(G,{marginTop:1,flexDirection:`column`,children:[(0,$.jsx)(K,{dimColor:!0,children:`In plan mode, Work Mate will:`}),(0,$.jsx)(K,{dimColor:!0,children:` · Explore the codebase thoroughly`}),(0,$.jsx)(K,{dimColor:!0,children:` · Identify existing patterns`}),(0,$.jsx)(K,{dimColor:!0,children:` · Design an implementation strategy`}),(0,$.jsx)(K,{dimColor:!0,children:` · Present a plan for your approval`})]}),(0,$.jsx)(G,{marginTop:1,children:(0,$.jsx)(K,{dimColor:!0,children:`No code changes will be made until you approve the plan.`})}),(0,$.jsx)(G,{marginTop:1,children:(0,$.jsx)(Hn,{options:[{label:`Yes, enter plan mode`,value:`yes`},{label:`No, start implementing now`,value:`no`}],onChange:i,onCancel:()=>i(`no`)})})]})})}l(),Mf(),U(),Ru(),Cg(),q(),Ph(),tc(),Sf(),_p(),is(),Yd(),Zn(),bi(),Rh(),da(),Fi(),pg(),In(),Ia();function Dx(e,t){let n=[{type:`setMode`,mode:Ld(e),destination:`session`}];return Ws()&&t&&t.length>0&&n.push({type:`addRules`,rules:t.map(e=>({toolName:e.tool,ruleContent:v(e.prompt)})),behavior:`allow`,destination:`session`}),n}function Ox(e,t,n){zu()||qd()?.cleanupPeriodDays===0||!n&&Zs(Wu())||wg([rr({content:e.slice(0,1e3)})],new AbortController().signal).then(async e=>{if(!e||Zs(Wu()))return;let n=Wu(),r=go();await _s(n,e,r,`auto`),await Js(n,e,r,`auto`),t(t=>t.standaloneAgentContext?.name===e?t:{...t,standaloneAgentContext:{...t.standaloneAgentContext,name:e}})}).catch(Y)}function kx({toolUseConfirm:e,onDone:t,onReject:n,setStickyFooter:r}){let i=W(e=>e.toolPermissionContext),a=y();Bn();let{addNotification:o}=li(),[s,c]=(0,Q.useState)(``),[l,d]=(0,Q.useState)({}),f=(0,Q.useRef)(0),p=W(e=>e.settings.showClearContextOnPlanAccept)??!1,h=e.assistantMessage.message.usage,{mode:g,isAutoModeAvailable:_,isBypassPermissionsModeAvailable:v}=i,b=(0,Q.useMemo)(()=>Ax({showClearContext:p,usedPercent:p?jx(h,g):null,isAutoModeAvailable:_,isBypassPermissionsModeAvailable:v,onFeedbackChange:c}),[p,h,g,_,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};Mi(o),hc(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(l).filter(e=>e.type===`image`),w=C.length>0,T=At(),E=e.input.allowedPrompts,D=He(),O=!D||D.trim()===``,[k]=(0,Q.useState)(()=>Kt()??void 0),[A,j]=(0,Q.useState)(()=>He()??`No plan found. Please write your plan to the plan file first.`),[M,N]=(0,Q.useState)(!1),[ee,te]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{if(M){let e=setTimeout(N,5e3,!1);return()=>clearTimeout(e)}},[M]);let P=e=>{if(e.ctrl&&e.key===`g`){e.preventDefault(),X(`tengu_plan_external_editor_used`,{}),(async()=>{let e=await zh(T);e.error&&o({key:`external-editor-error`,text:e.error,color:`warning`,priority:`high`}),e.content!==null&&(e.content!==A&&te(!0),j(e.content),N(!0))})();return}if(e.shift&&e.key===`tab`){e.preventDefault(),F(p?`yes-accept-edits`:`yes-accept-edits-keep-context`);return}};async function F(r){let o=s.trim(),c=o||void 0,l=ee?{plan:A}:{};{let e=(r===`yes-resume-auto-mode`||r===`yes-auto-clear-context`)&&ce(),t=Os();r!==`no`&&!e&&t&&(rs(!1),ku(!0),a(e=>({...e,toolPermissionContext:{...gn(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`&&Ox(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`&&ce()&&(i=`auto`,rs(!0)),X(`tengu_plan_exit`,{planLengthChars:A.length,outcome:r,clearContext:!0,interviewPhaseEnabled:fl(),planStructureVariant:k,hasFeedback:!!c});let o=`\n\nIf you need specific details from before exiting plan mode (like exact code snippets, error messages, or content you generated), read the full transcript at: ${go()}`,s=c?`\n\nUser feedback on this plan: ${c}`:``;a(e=>({...e,initialMessage:{message:{...rr({content:`Implement the following plan:\n\n${A}${o}${s}`}),planContent:A},clearContext:!0,mode:i,allowedPrompts:E}})),Gu(!0),ju(!0),t(),n(),e.onReject();return}if(r===`yes-resume-auto-mode`&&ce()){X(`tengu_plan_exit`,{planLengthChars:A.length,outcome:r,clearContext:!1,interviewPhaseEnabled:fl(),planStructureVariant:k,hasFeedback:!!c}),Gu(!0),ju(!0),rs(!0),a(e=>({...e,toolPermissionContext:Po({...e.toolPermissionContext,mode:`auto`,prePlanMode:void 0})})),t(),e.onAllow(l,[],c);return}let d={"yes-accept-edits-keep-context":i.isBypassPermissionsModeAvailable?`bypassPermissions`:`acceptEdits`,"yes-default-keep-context":`default`,"yes-resume-auto-mode":`default`}[r];if(d){X(`tengu_plan_exit`,{planLengthChars:A.length,outcome:r,clearContext:!1,interviewPhaseEnabled:fl(),planStructureVariant:k,hasFeedback:!!c}),Gu(!0),ju(!0),t(),e.onAllow(l,Dx(d,E),c);return}let f={"yes-bypass-permissions":`bypassPermissions`,"yes-accept-edits":`acceptEdits`}[r];if(f){X(`tengu_plan_exit`,{planLengthChars:A.length,outcome:r,interviewPhaseEnabled:fl(),planStructureVariant:k,hasFeedback:!!c}),Gu(!0),ju(!0),t(),e.onAllow(l,Dx(f,E),c);return}if(r===`no`){if(!o&&!w)return;X(`tengu_plan_exit`,{planLengthChars:A.length,outcome:`no`,interviewPhaseEnabled:fl(),planStructureVariant:k});let r;w&&(r=await Promise.all(C.map(async e=>(await m({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 I=Fh(),L=I?Ua(I):null,ne=(0,Q.useRef)(F);ne.current=F;let re=(0,Q.useRef)(void 0);re.current=()=>{X(`tengu_plan_exit`,{planLengthChars:A.length,outcome:`no`,interviewPhaseEnabled:fl(),planStructureVariant:k}),t(),n(),e.onReject()};let ie=!O&&!!r;if((0,Q.useLayoutEffect)(()=>{if(ie)return r((0,$.jsxs)(G,{flexDirection:`column`,borderStyle:`round`,borderColor:`planMode`,borderLeft:!1,borderRight:!1,borderBottom:!1,paddingX:1,children:[(0,$.jsx)(K,{dimColor:!0,children:`Would you like to proceed?`}),(0,$.jsx)(G,{marginTop:1,children:(0,$.jsx)(Hn,{options:b,onChange:e=>void ne.current(e),onCancel:()=>re.current?.(),onImagePaste:x,pastedContents:l,onRemoveImage:S})}),L&&(0,$.jsxs)(G,{flexDirection:`row`,gap:1,marginTop:1,children:[(0,$.jsx)(K,{dimColor:!0,children:`ctrl-g to edit in `}),(0,$.jsx)(K,{bold:!0,dimColor:!0,children:L}),(0,$.jsxs)(K,{dimColor:!0,children:[` · `,Gd(T)]}),M&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(K,{dimColor:!0,children:` · `}),(0,$.jsxs)(K,{color:`success`,children:[u.tick,`Plan saved!`]})]})]})]})),()=>r(null)},[ie,r,b,l,L,T,M]),O){function r(r){r===`yes`?(X(`tengu_plan_exit`,{planLengthChars:0,outcome:`yes-default`,interviewPhaseEnabled:fl(),planStructureVariant:k}),Os()&&(rs(!1),ku(!0),a(e=>({...e,toolPermissionContext:{...gn(e.toolPermissionContext),prePlanMode:void 0}}))),Gu(!0),ju(!0),t(),e.onAllow({},[{type:`setMode`,mode:`default`,destination:`session`}])):(X(`tengu_plan_exit`,{planLengthChars:0,outcome:`no`,interviewPhaseEnabled:fl(),planStructureVariant:k}),t(),n(),e.onReject())}return(0,$.jsx)(hg,{color:`planMode`,title:`Exit plan mode?`,children:(0,$.jsxs)(G,{flexDirection:`column`,paddingX:1,marginTop:1,children:[(0,$.jsx)(K,{children:`Work Mate wants to exit plan mode`}),(0,$.jsx)(G,{marginTop:1,children:(0,$.jsx)(Hn,{options:[{label:`Yes`,value:`yes`},{label:`No`,value:`no`}],onChange:r,onCancel:()=>{X(`tengu_plan_exit`,{planLengthChars:0,outcome:`no`,interviewPhaseEnabled:fl(),planStructureVariant:k}),t(),n(),e.onReject()}})})]})})}return(0,$.jsxs)(G,{flexDirection:`column`,tabIndex:0,autoFocus:!0,onKeyDown:P,children:[(0,$.jsx)(hg,{color:`planMode`,title:`Ready to code?`,innerPaddingX:0,children:(0,$.jsxs)(G,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(G,{paddingX:1,flexDirection:`column`,children:(0,$.jsx)(K,{children:`Here is 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)(or,{children:A})}),(0,$.jsxs)(G,{flexDirection:`column`,paddingX:1,children:[(0,$.jsx)(Ly,{permissionResult:e.permissionResult,toolType:`tool`}),Ws()&&E&&E.length>0&&(0,$.jsxs)(G,{flexDirection:`column`,marginBottom:1,children:[(0,$.jsx)(K,{bold:!0,children:`Requested permissions:`}),E.map((e,t)=>(0,$.jsxs)(K,{dimColor:!0,children:[` `,`· `,e.tool,`(`,`prompt:`,` `,e.prompt,`)`]},t))]}),!ie&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(K,{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)(Hn,{options:b,onChange:F,onCancel:()=>re.current?.(),onImagePaste:x,pastedContents:l,onRemoveImage:S})})]})]})]})}),!ie&&L&&(0,$.jsxs)(G,{flexDirection:`row`,gap:1,paddingX:1,marginTop:1,children:[(0,$.jsxs)(G,{children:[(0,$.jsx)(K,{dimColor:!0,children:`ctrl-g to edit in `}),(0,$.jsx)(K,{bold:!0,dimColor:!0,children:L}),(0,$.jsxs)(K,{dimColor:!0,children:[` · `,Gd(T)]})]}),M&&(0,$.jsxs)(G,{children:[(0,$.jsx)(K,{dimColor:!0,children:` · `}),(0,$.jsxs)(K,{color:`success`,children:[u.tick,`Plan saved!`]})]})]})]})}function Ax({showClearContext:e,usedPercent:t,isAutoModeAvailable:n,isBypassPermissionsModeAvailable:r,onFeedbackChange:i}){let a=[],o=t===null?``:` (${t}% used)`;return e&&(n?a.push({label:`Yes, clear context${o} and use auto mode`,value:`yes-auto-clear-context`}):r?a.push({label:`Yes, clear context${o} and bypass permissions`,value:`yes-bypass-permissions`}):a.push({label:`Yes, clear context${o} and auto-accept edits`,value:`yes-accept-edits`})),n?a.push({label:`Yes, and use auto mode`,value:`yes-resume-auto-mode`}):r?a.push({label:`Yes, and bypass permissions`,value:`yes-accept-edits-keep-context`}):a.push({label:`Yes, auto-accept edits`,value:`yes-accept-edits-keep-context`}),a.push({label:`Yes, manually approve edits`,value:`yes-default-keep-context`}),a.push({type:`input`,label:`No, keep planning`,value:`no`,placeholder:`Tell Work Mate what to change`,description:`shift+tab to approve with this feedback`,onChange:i}),a}function jx(e,t){if(!e)return null;let n=ep(Dp({permissionMode:t,mainLoopModel:jp(),exceeds200kTokens:!1}),ed()),{used:r}=ap({input_tokens:e.input_tokens,cache_creation_input_tokens:e.cache_creation_input_tokens??0,cache_read_input_tokens:e.cache_read_input_tokens??0},n);return r}Wm(),q(),vc(),Mf(),U(),S();var Mx={accept:`tell Work Mate what to do next`,reject:`tell Work Mate what to do differently`};function Nx({options:e,onSelect:t,onCancel:n,question:r=`Do you want to proceed?`,toolAnalyticsContext:i}){let a=y(),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(!1),[v,b]=(0,Q.useState)(!1),x=e.find(e=>e.value===m)?.feedbackConfig?.type,S=x===`accept`&&!u||x===`reject`&&!f,C=(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=Mx[i];return o?{type:`input`,label:n,value:t,placeholder:a??d,onChange:c,allowEmptySubmitToCancel:!0}:{label:n,value:t}}),[e,u,f]),w=(0,Q.useCallback)(t=>{let n=e.find(e=>e.value===t);if(!n?.feedbackConfig)return;let{type:r}=n.feedbackConfig,a={toolName:i?.toolName,isMcp:i?.isMcp??!1};r===`accept`?u?(d(!1),X(`tengu_accept_feedback_mode_collapsed`,a)):(d(!0),_(!0),X(`tengu_accept_feedback_mode_entered`,a)):r===`reject`&&(f?(p(!1),X(`tengu_reject_feedback_mode_collapsed`,a)):(p(!0),b(!0),X(`tengu_reject_feedback_mode_entered`,a)))},[e,u,f,i]),T=(0,Q.useCallback)(n=>{let r=e.find(e=>e.value===n);if(!r)return;let a;if(r.feedbackConfig){let e=(r.feedbackConfig.type===`accept`?o:c).trim();e&&(a=e);let t={toolName:i?.toolName,isMcp:i?.isMcp??!1,has_instructions:!!e,instructions_length:e?.length??0,entered_feedback_mode:r.feedbackConfig.type===`accept`?g:v};r.feedbackConfig.type===`accept`?X(`tengu_accept_submitted`,t):r.feedbackConfig.type===`reject`&&X(`tengu_reject_submitted`,t)}t(n,a)},[e,o,c,t,i,g,v]);Sl((0,Q.useMemo)(()=>{let t={};for(let n of e)n.keybinding&&(t[n.keybinding]=()=>T(n.value));return t},[e,T]),{context:`Confirmation`});let E=(0,Q.useCallback)(()=>{X(`tengu_permission_request_escape`,{}),a(e=>({...e,attribution:{...e.attribution,escapeCount:e.attribution.escapeCount+1}})),n?.()},[n,a]);return(0,$.jsxs)(G,{flexDirection:`column`,children:[typeof r==`string`?(0,$.jsx)(K,{children:r}):r,(0,$.jsx)(Hn,{options:C,inlineDescriptions:!0,onChange:T,onCancel:E,onFocus:t=>{let n=e.find(e=>e.value===t);n?.feedbackConfig?.type!==`accept`&&u&&!o.trim()&&d(!1),n?.feedbackConfig?.type!==`reject`&&f&&!c.trim()&&p(!1),h(t)},onInputModeToggle:w}),(0,$.jsx)(G,{marginTop:1,children:(0,$.jsxs)(K,{dimColor:!0,children:[`Esc to cancel`,S&&` · Tab to amend`]})})]})}Ru(),q(),Tm(),Od(),di(),Jf(),pg();function Px({toolUseConfirm:e,onDone:t,onReject:n,verbose:r}){let[i]=Cl(),a=e.tool.userFacingName(e.input),o=a.endsWith(` (MCP)`)?a.slice(0,-6):a;_b(e,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let s=(0,Q.useCallback)((r,i)=>{switch(r){case`yes`:gb({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:Cd.platform}}),e.onAllow(e.input,[],i),t();break;case`yes-dont-ask-again`:gb({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:Cd.platform}}),e.onAllow(e.input,[{type:`addRules`,rules:[{toolName:e.tool.name}],behavior:`allow`,destination:`localSettings`}]),t();break;case`no`:gb({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:Cd.platform}}),e.onReject(i),n(),t();break}},[e,t,n]),c=(0,Q.useCallback)(()=>{gb({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id,platform:Cd.platform}}),e.onReject(),n(),t()},[e,t,n]),l=bu(),u=Ni(),d=(0,Q.useMemo)(()=>{let e=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}];return u&&e.push({label:(0,$.jsxs)(K,{children:[`Yes, and don't ask again for `,(0,$.jsx)(K,{bold:!0,children:o}),` commands in`,` `,(0,$.jsx)(K,{bold:!0,children:l})]}),value:`yes-dont-ask-again`}),e.push({label:`No`,value:`no`,feedbackConfig:{type:`reject`}}),e},[o,l,u]),f=(0,Q.useMemo)(()=>({toolName:Em(e.tool.name),isMcp:e.tool.isMcp??!1}),[e.tool.name,e.tool.isMcp]);return(0,$.jsxs)(hg,{title:`Tool use`,children:[(0,$.jsxs)(G,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsxs)(K,{children:[o,`(`,e.tool.renderToolUseMessage(e.input,{theme:i,verbose:!0}),`)`,a.endsWith(` (MCP)`)?(0,$.jsx)(K,{dimColor:!0,children:` (MCP)`}):``]}),(0,$.jsx)(K,{dimColor:!0,children:Kf(e.description,3)})]}),(0,$.jsxs)(G,{flexDirection:`column`,children:[(0,$.jsx)(Ly,{permissionResult:e.permissionResult,toolType:`tool`}),(0,$.jsx)(Nx,{options:d,onSelect:s,onCancel:c,toolAnalyticsContext:f})]})]})}function Fx(e,t,n,r){return{filePath:e,edits:[{old_string:t,new_string:n,replace_all:r}],editMode:`single`}}rd(),q();var Ix={getConfig:e=>Fx(e.file_path,e.old_string,e.new_string,e.replace_all),applyChanges:(e,t)=>{let n=t[0];return n?{...e,old_string:n.old_string,new_string:n.new_string,replace_all:n.replace_all}:e}};function Lx(e){let t=e=>Ci.inputSchema.parse(e),{file_path:n,old_string:r,new_string:i,replace_all:a}=t(e.toolUseConfirm.input);return(0,$.jsx)(px,{toolUseConfirm:e.toolUseConfirm,toolUseContext:e.toolUseContext,onDone:e.onDone,onReject:e.onReject,title:`Edit file`,subtitle:i_(id(),n),question:(0,$.jsxs)(K,{children:[`Do you want to make this edit to `,(0,$.jsx)(K,{bold:!0,children:e_(n)}),`?`]}),content:(0,$.jsx)(Wb,{file_path:n,edits:[{old_string:r,new_string:i,replace_all:a||!1}]}),path:n,completionType:`str_replace_single`,parseInput:t,ideDiffSupport:Ix})}q();function Rx(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 zx({toolUseConfirm:e,onDone:t,onReject:n,verbose:r,toolUseContext:i}){let[a]=Cl(),o=Rx(e),s=e.tool.userFacingName(e.input),c=e.tool.isReadOnly(e.input),l=`${c?`Read`:`Edit`} file`;return o?(0,$.jsx)(px,{toolUseConfirm:e,toolUseContext:i,onDone:t,onReject:n,title:l,content:(0,$.jsx)(G,{flexDirection:`column`,paddingX:2,paddingY:1,children:(0,$.jsxs)(K,{children:[s,`(`,e.tool.renderToolUseMessage(e.input,{theme:a,verbose:r}),`)`]})}),path:o,parseInput:e=>e,operationType:c?`read`:`write`,completionType:`tool_use_single`}):(0,$.jsx)(Px,{toolUseConfirm:e,toolUseContext:i,onDone:t,onReject:n,verbose:r})}$a(),q(),En(),ut();function Bx({file_path:e,content:t,fileExists:n,oldContent:r}){let{columns:i}=Ql(),a=(0,Q.useMemo)(()=>n?Oe({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?Id(a.map(t=>(0,$.jsx)(un,{patch:t,dim:!1,filePath:e,firstLine:o,fileContent:r,width:i-2},t.newStart)),e=>(0,$.jsx)(Al,{fromLeftEdge:!0,children:(0,$.jsx)(K,{dimColor:!0,children:`...`})},`ellipsis-${e}`)):(0,$.jsx)(Pe,{code:t||`(No content)`,filePath:e})})})}q(),rd(),ld(),Zd();var Vx={getConfig:e=>{let t;try{t=Dd(e.file_path)}catch(e){if(!ad(e))throw e;t=``}return Fx(e.file_path,t,e.content,!1)},applyChanges:(e,t)=>{let n=t[0];return n?{...e,content:n.new_string}:e}};function Hx(e){let t=e=>Ta.inputSchema.parse(e),{file_path:n,content:r}=t(e.toolUseConfirm.input),{fileExists:i,oldContent:a}=(0,Q.useMemo)(()=>{try{return{fileExists:!0,oldContent:Dd(n)}}catch(e){if(!ad(e))throw e;return{fileExists:!1,oldContent:``}}},[n]),o=i?`overwrite`:`create`;return(0,$.jsx)(px,{toolUseConfirm:e.toolUseConfirm,toolUseContext:e.toolUseContext,onDone:e.onDone,onReject:e.onReject,title:i?`Overwrite file`:`Create file`,subtitle:i_(id(),n),question:(0,$.jsxs)(K,{children:[`Do you want to `,o,` `,(0,$.jsx)(K,{bold:!0,children:e_(n)}),`?`]}),content:(0,$.jsx)(Bx,{file_path:n,content:r,fileExists:i,oldContent:a}),path:n,completionType:`write_file_single`,parseInput:t,ideDiffSupport:Vx})}q(),jd(),rd(),En(),md(),ut(),Mn();function Ux(e){let t=(0,Q.useMemo)(()=>yd().readFile(e.notebook_path,{encoding:`utf-8`}).then(e=>jf(e)).catch(()=>null),[e.notebook_path]);return(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Wx,{...e,promise:t})})}function Wx({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=pe(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:Oe({filePath:e,fileContents:l,edits:[{old_string:l,new_string:n,replace_all:!1}],ignoreWhitespace:!1}),[c,e,l,n,i]),d;switch(i){case`insert`:d=`Insert new cell`;break;case`delete`:d=`Delete cell`;break;default:d=`Replace cell contents`}return(0,$.jsx)(G,{flexDirection:`column`,children:(0,$.jsxs)(G,{borderStyle:`round`,flexDirection:`column`,paddingX:1,children:[(0,$.jsxs)(G,{paddingBottom:1,flexDirection:`column`,children:[(0,$.jsx)(K,{bold:!0,children:a?e:i_(id(),e)}),(0,$.jsxs)(K,{dimColor:!0,children:[d,` for cell `,t,r?` (${r})`:``]})]}),i===`delete`?(0,$.jsx)(G,{flexDirection:`column`,paddingLeft:2,children:(0,$.jsx)(Pe,{code:l,filePath:e})}):i===`insert`?(0,$.jsx)(G,{flexDirection:`column`,paddingLeft:2,children:(0,$.jsx)(Pe,{code:n,filePath:r===`markdown`?`file.md`:e})}):u?Id(u.map(t=>(0,$.jsx)(un,{patch:t,dim:!1,width:o,filePath:e,firstLine:n.split(`
25
+ `)[0]??null,fileContent:l},t.newStart)),e=>(0,$.jsx)(Al,{fromLeftEdge:!0,children:(0,$.jsx)(K,{dimColor:!0,children:`...`})},`ellipsis-${e}`)):(0,$.jsx)(Pe,{code:n,filePath:r===`markdown`?`file.md`:e})]})})}q(),Sf();function Gx(e){let t=e=>{let t=Ps.inputSchema.safeParse(e);return t.success?t.data:(Y(Error(`Failed to parse notebook edit input: ${t.error.message}`)),{notebook_path:``,new_source:``,cell_id:``})},n=t(e.toolUseConfirm.input),{notebook_path:r,edit_mode:i,cell_type:a}=n,o=a===`markdown`?`markdown`:`python`,s=i===`insert`?`insert this cell into`:i===`delete`?`delete this cell from`:`make this edit to`;return(0,$.jsx)(px,{toolUseConfirm:e.toolUseConfirm,toolUseContext:e.toolUseContext,onDone:e.onDone,onReject:e.onReject,title:`Edit notebook`,question:(0,$.jsxs)(K,{children:[`Do you want to `,s,` `,(0,$.jsx)(K,{bold:!0,children:e_(r)}),`?`]}),content:(0,$.jsx)(Ux,{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})}Jf(),Rn();async function Kx(e){if(e.nameType===`application`)return null;let t=e.name;if(!t||Ai.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 ob(n),i=await tb(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||Xy[n])?null:i}async function qx(e,t){let n=await Ys(e);if(!n.valid)return[];let r=mc(n).filter(e=>e.elementType===`CommandAst`);if(r.length<=1){let e=r[0]?await Kx(r[0]):null;return e?[e]:[]}let i=[];for(let e of r){if(t?.(e))continue;let n=await Kx(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=Jx(t);(n===``?0:Yf(n,` `)+1)<=1&&((await ob(e))?.subcommands?.length||Xy[e])||o.push(n)}return o}function Jx(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(` `)}di();function Yx({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`}),Ni()&&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=xx(e,Jp);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}q(),vc(),Mf(),Tm(),S(),pg();function Xx(e){let{toolUseConfirm:t,toolUseContext:n,onDone:r,onReject:i}=e,{command:a,description:o}=St.inputSchema.parse(t.input),[s]=Cl(),c=Vb({toolName:t.tool.name,toolInput:t.input,toolDescription:t.description,messages:n.messages}),{yesInputMode:l,noInputMode:u,yesFeedbackModeEntered:d,noFeedbackModeEntered:f,acceptFeedback:p,rejectFeedback:m,setAcceptFeedback:h,setRejectFeedback:g,focusedOption:_,handleInputModeToggle:v,handleReject:y,handleFocus:b}=_x({toolUseConfirm:t,onDone:r,onReject:i,explainerVisible:c.visible}),[x,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(a.includes(`
26
+ `)?void 0:a),T=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{let e=!1;return qx(a,e=>Fa(e,e.text)).then(t=>{e||T.current||t.length>0&&w(`${t[0]}:*`)}).catch(()=>{}),()=>{e=!0}},[a]);let E=(0,Q.useCallback)(e=>{T.current=!0,w(e)},[]);_b(t,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let D=(0,Q.useMemo)(()=>Yx({suggestions:t.permissionResult.behavior===`ask`?t.permissionResult.suggestions:void 0,onRejectFeedbackChange:g,onAcceptFeedbackChange:h,yesInputMode:l,noInputMode:u,editablePrefix:C,onEditablePrefixChange:E}),[t,l,u,C,E]);Ml(`permission:toggleDebug`,(0,Q.useCallback)(()=>{S(e=>!e)},[]),{context:`Confirmation`});function O(e){X(`tengu_permission_request_option_selected`,{option_index:{yes:1,"yes-apply-suggestions":2,"yes-prefix-edited":2,no:3}[e],explainer_visible:c.visible});let n=Em(t.tool.name);if(e===`yes-prefix-edited`){let e=(C??``).trim();if(gx(`tool_use_single`,t,`accept`),!e)t.onAllow(t.input,[]);else{let n=[{type:`addRules`,rules:[{toolName:St.name,ruleContent:e}],behavior:`allow`,destination:`localSettings`}];t.onAllow(t.input,n)}r();return}switch(e){case`yes`:{let e=p.trim();gx(`tool_use_single`,t,`accept`),X(`tengu_accept_submitted`,{toolName:n,isMcp:t.tool.isMcp??!1,has_instructions:!!e,instructions_length:e.length,entered_feedback_mode:d}),t.onAllow(t.input,[],e||void 0),r();break}case`yes-apply-suggestions`:{gx(`tool_use_single`,t,`accept`);let e=`suggestions`in t.permissionResult&&t.permissionResult.suggestions||[];t.onAllow(t.input,e),r();break}case`no`:{let e=m.trim();X(`tengu_reject_submitted`,{toolName:n,isMcp:t.tool.isMcp??!1,has_instructions:!!e,instructions_length:e.length,entered_feedback_mode:f}),y(e||void 0);break}}}return(0,$.jsxs)(hg,{title:`PowerShell command`,children:[(0,$.jsxs)(G,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(K,{dimColor:c.visible,children:St.renderToolUseMessage({command:a,description:o},{theme:s,verbose:!0})}),!c.visible&&(0,$.jsx)(K,{dimColor:!0,children:t.description}),(0,$.jsx)(Ub,{visible:c.visible,promise:c.promise})]}),x?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(wb,{permissionResult:t.permissionResult,toolName:`PowerShell`}),n.options.debug&&(0,$.jsx)(G,{justifyContent:`flex-end`,marginTop:1,children:(0,$.jsx)(K,{dimColor:!0,children:`Ctrl-D to hide debug info`})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(G,{flexDirection:`column`,children:[(0,$.jsx)(Ly,{permissionResult:t.permissionResult,toolType:`command`}),null,(0,$.jsx)(K,{children:`Do you want to proceed?`}),(0,$.jsx)(Hn,{options:D,inlineDescriptions:!0,onChange:O,onCancel:()=>y(),onFocus:b,onInputModeToggle:v})]}),(0,$.jsxs)(G,{justifyContent:`space-between`,marginTop:1,children:[(0,$.jsxs)(K,{dimColor:!0,children:[`Esc to cancel`,(_===`yes`&&!l||_===`no`&&!u)&&` · Tab to amend`,c.enabled&&` · ctrl+e to ${c.visible?`hide`:`explain`}`]}),n.options.debug&&(0,$.jsx)(K,{dimColor:!0,children:`Ctrl+d to show debug info`})]})]})]})}Sf(),Ru(),q(),Tm(),Od(),di(),pg();function Zx(e){let{toolUseConfirm:t,onDone:n,onReject:r,verbose:i}=e,a=(e=>{let t=zi.inputSchema.safeParse(e);return t.success?t.data.skill:(Y(Error(`Failed to parse skill tool input: ${t.error.message}`)),``)})(t.input),o=t.permissionResult.behavior===`ask`&&t.permissionResult.metadata&&`command`in t.permissionResult.metadata?t.permissionResult.metadata.command:void 0;_b(t,(0,Q.useMemo)(()=>({completion_type:`tool_use_single`,language_name:`none`}),[]));let s=bu(),c=Ni(),l=(0,Q.useMemo)(()=>{let e=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}],t=[];if(c){t.push({label:(0,$.jsxs)(K,{children:[`Yes, and don't ask again for `,(0,$.jsx)(K,{bold:!0,children:a}),` in `,(0,$.jsx)(K,{bold:!0,children:s})]}),value:`yes-exact`});let e=a.indexOf(` `);if(e>0){let n=a.substring(0,e);t.push({label:(0,$.jsxs)(K,{children:[`Yes, and don't ask again for `,(0,$.jsx)(K,{bold:!0,children:`${n}:*`}),` commands in`,` `,(0,$.jsx)(K,{bold:!0,children:s})]}),value:`yes-prefix`})}}let n={label:`No`,value:`no`,feedbackConfig:{type:`reject`}};return[...e,...t,n]},[a,s,c]),u=(0,Q.useMemo)(()=>({toolName:Em(t.tool.name),isMcp:t.tool.isMcp??!1}),[t.tool.name,t.tool.isMcp]),d=(0,Q.useCallback)((e,i)=>{switch(e){case`yes`:gb({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Cd.platform}}),t.onAllow(t.input,[],i),n();break;case`yes-exact`:gb({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Cd.platform}}),t.onAllow(t.input,[{type:`addRules`,rules:[{toolName:Ip,ruleContent:a}],behavior:`allow`,destination:`localSettings`}]),n();break;case`yes-prefix`:{gb({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Cd.platform}});let e=a.indexOf(` `),r=e>0?a.substring(0,e):a;t.onAllow(t.input,[{type:`addRules`,rules:[{toolName:Ip,ruleContent:`${r}:*`}],behavior:`allow`,destination:`localSettings`}]),n();break}case`no`:gb({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Cd.platform}}),t.onReject(i),r(),n();break}},[t,n,r,a]),f=(0,Q.useCallback)(()=>{gb({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:t.assistantMessage.message.id,platform:Cd.platform}}),t.onReject(),r(),n()},[t,n,r]);return(0,$.jsxs)(hg,{title:`Use skill "${a}"?`,children:[(0,$.jsx)(K,{children:`Work Mate may use instructions, code, or files from this Skill.`}),(0,$.jsx)(G,{flexDirection:`column`,paddingX:2,paddingY:1,children:(0,$.jsx)(K,{dimColor:!0,children:o?.description})}),(0,$.jsxs)(G,{flexDirection:`column`,children:[(0,$.jsx)(Ly,{permissionResult:t.permissionResult,toolType:`tool`}),(0,$.jsx)(Nx,{options:l,onSelect:d,onCancel:f,toolAnalyticsContext:u})]})]})}q(),Pr(),Od(),di(),pg();function Qx({toolUseConfirm:e,onDone:t,onReject:n}){let[r]=Cl(),i=at(r),a=e.input,o=(0,Q.useMemo)(()=>Ni(),[]),s=(0,Q.useMemo)(()=>{let t=[{label:`Yes`,value:`yes`,feedbackConfig:{type:`accept`}}];return o&&t.push({label:(0,$.jsxs)(K,{children:[`Yes, and don`,`’`,`t ask again for `,(0,$.jsx)(K,{bold:!0,children:e.tool.name}),` commands`]}),value:`yes-dont-ask-again`}),t.push({label:`No`,value:`no`,feedbackConfig:{type:`reject`}}),t},[o,e.tool.name]),c=(0,Q.useCallback)((r,i)=>{switch(r){case`yes`:gb({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Cd.platform}}),e.onAllow(e.input,[],i),t();break;case`yes-dont-ask-again`:gb({completion_type:`tool_use_single`,event:`accept`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Cd.platform}}),e.onAllow(e.input,[{type:`addRules`,rules:[{toolName:e.tool.name}],behavior:`allow`,destination:`localSettings`}]),t();break;case`no`:gb({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Cd.platform}}),e.onReject(i),n(),t();break}},[e,t,n]),l=(0,Q.useCallback)(()=>{gb({completion_type:`tool_use_single`,event:`reject`,metadata:{language_name:`none`,message_id:e.assistantMessage.message.id??``,platform:Cd.platform}}),e.onReject(),n(),t()},[e,t,n]);return(0,$.jsx)(hg,{title:`Workflow`,children:(0,$.jsxs)(G,{flexDirection:`column`,gap:1,children:[(0,$.jsxs)(G,{flexDirection:`column`,children:[(0,$.jsxs)(K,{bold:!0,color:i.permission,children:[`Execute workflow: `,a.workflow]}),a.args&&(0,$.jsxs)(K,{dimColor:!0,children:[`Arguments: `,a.args]})]}),(0,$.jsx)(Ly,{permissionResult:e.permissionResult,toolType:`command`}),(0,$.jsx)(Nx,{options:s,onSelect:c,onCancel:l})]})})}vc(),Or(),Qr(),ui(),qa(),wt(),ci(),Ec();var $x=Co();function eS(e){switch(e){case Ci:return Lx;case Ta:return Hx;case kr:return wx;case St:return Xx;case Ps:return Gx;case Zr:return kx;case Fe:return Ex;case zi:return Zx;case et:return Gy;case $x:return Qx??Px;case So:case gs:case bt:return zx;default:return Px}}function tS(e){let t=e.tool.userFacingName(e.input);return e.tool===Zr?`Work Mate needs your approval for the plan`:e.tool===Fe?`Work Mate wants to enter plan mode`:!t||t.trim()===``?`Work Mate needs your attention`:`Work Mate needs your permission to use ${t}`}function nS({toolUseConfirm:e,toolUseContext:t,onDone:n,onReject:r,verbose:i,setStickyFooter:a}){return Ml(`app:interrupt`,()=>{n(),r(),e.onReject()},{context:`Confirmation`}),Oy(tS(e),`permission_prompt`),(0,$.jsx)(eS(e.tool),{toolUseContext:t,toolUseConfirm:e,onDone:n,onReject:r,verbose:i,setStickyFooter:a})}ka(),ss(),Sf(),Bt();async function rS(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=em([`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 Oi({systemPrompt:u,userPrompt:d,signal:n,options:{querySource:`mcp_datetime_parse`,agents:[],isNonInteractiveSession:!1,hasAppendSystemPrompt:!1,mcpTools:[],enablePromptCaching:!1}}),t=dr(Array.isArray(e.message.content)?e.message.content:[]).trim();return!t||t===`INVALID`||!/^\d{4}/.test(t)?{success:!1,error:`Unable to parse date/time from input`}:{success:!0,value:t}}catch(e){return Y(e),{success:!1,error:`Unable to parse date/time. Please enter in ISO 8601 format manually.`}}}function iS(e){return/^\d{4}-\d{2}-\d{2}(T|$)/.test(e.trim())}vu(),bd(),Jf();var aS=e=>e.type===`string`&&(`enum`in e||`oneOf`in e);function oS(e){return e.type===`array`&&`items`in e&&typeof e.items==`object`&&e.items!==null&&(`enum`in e.items||`anyOf`in e.items)}function sS(e){return`anyOf`in e.items?e.items.anyOf.map(e=>e.const):`enum`in e.items?e.items.enum:[]}function cS(e){return`anyOf`in e.items?e.items.anyOf.map(e=>e.title):`enum`in e.items?e.items.enum:[]}function lS(e,t){let n=sS(e).indexOf(t);return n>=0?cS(e)[n]??t:t}function uS(e){return`oneOf`in e?e.oneOf.map(e=>e.const):`enum`in e?e.enum:[]}function dS(e){return`oneOf`in e?e.oneOf.map(e=>e.title):`enum`in e?(`enumNames`in e?e.enumNames:void 0)??e.enum:[]}function fS(e,t){let n=uS(e).indexOf(t);return n>=0?dS(e)[n]??t:t}function pS(e){if(aS(e)){let[t,...n]=uS(e);return t?hu([t,...n]):pu()}if(e.type===`string`){let t=fu();switch(e.minLength!==void 0&&(t=t.min(e.minLength,{message:`Must be at least ${e.minLength} ${qf(e.minLength,`character`)}`})),e.maxLength!==void 0&&(t=t.max(e.maxLength,{message:`Must be at most ${e.maxLength} ${qf(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=mu({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 _u();throw Error(`Unsupported schema: ${od(e)}`)}function mS(e,t){let n=pS(t).safeParse(e);return n.success?{value:n.data,isValid:!0}:{isValid:!1,error:n.error.issues.map(e=>e.message).join(`; `)}}function hS(e){return e.type===`string`&&`format`in e&&(e.format===`date`||e.format===`date-time`)}async function gS(e,t,n){let r=mS(e,t);if(r.isValid)return r;if(hS(t)&&!iS(e)){let r=await rS(e,t.format,n);if(r.success){let e=mS(r.value,t);if(e.isValid)return e}}return r}l(),$a(),q(),vc(),Jf(),Cn(),Ko();var _S=e=>[`string`,`number`,`integer`].includes(e.type),vS=`⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏`,yS=e=>(e+1)%10;function bS(e){e.buffer=``,e.timer=void 0}function xS(){let[e,t]=(0,Q.useState)(0);return(0,Q.useEffect)(()=>{let e=setInterval(t,80,yS);return()=>clearInterval(e)},[]),(0,$.jsx)(K,{color:`warning`,children:vS[e]})}function SS(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 CS({event:e,onResponse:t,onWaitingDismiss:n}){return e.params.mode===`url`?(0,$.jsx)(TS,{event:e,onResponse:t,onWaitingDismiss:n}):(0,$.jsx)(wS,{event:e,onResponse:t})}function wS({event:e,onResponse:t}){let{serverName:n,signal:r}=e,{message:i,requestedSchema:a}=e.params,o=Object.keys(a.properties).length>0,[s,c]=(0,Q.useState)(o?null:`accept`),[l,d]=(0,Q.useState)(()=>{let e={};if(a.properties)for(let[t,n]of Object.entries(a.properties))typeof n==`object`&&n&&n.default!==void 0&&(e[t]=n.default);return e}),[f,p]=(0,Q.useState)(()=>{let e={};for(let[t,n]of Object.entries(a.properties))if(_S(n)&&n?.default!==void 0){let r=mS(String(n.default),n);!r.isValid&&r.error&&(e[t]=r.error)}return e});(0,Q.useEffect)(()=>{if(!r)return;let e=()=>{t(`cancel`)};if(r.aborted){e();return}return r.addEventListener(`abort`,e),()=>{r.removeEventListener(`abort`,e)}},[r,t]);let m=(0,Q.useMemo)(()=>{let e=a.required??[];return Object.entries(a.properties).map(([t,n])=>({name:t,schema:n,isRequired:e.includes(t)}))},[a]),[h,g]=(0,Q.useState)(o?0:void 0),[_,v]=(0,Q.useState)(()=>{let e=m[0];if(e&&_S(e.schema)){let t=l[e.name];return t===void 0?``:String(t)}return``}),[y,b]=(0,Q.useState)(_.length),[x,S]=(0,Q.useState)(()=>new Set),[C,w]=(0,Q.useState)(),[T,E]=(0,Q.useState)(0),D=(0,Q.useRef)(void 0),O=(0,Q.useRef)(new Map),k=(0,Q.useRef)({buffer:``,timer:void 0});(0,Q.useEffect)(()=>()=>{D.current!==void 0&&clearTimeout(D.current);let e=k.current;e.timer!==void 0&&clearTimeout(e.timer);for(let e of O.current.values())e.abort();O.current.clear()},[]);let{columns:A,rows:j}=Ql(),M=h===void 0?void 0:m[h],N=M!==void 0&&_S(M.schema)&&!aS(M.schema)&&!s;qi(`elicitation`),Oy(`Work Mate needs your input`,`elicitation_dialog`);let ee=(0,Q.useCallback)(e=>{if(e===void 0){v(``),b(0);return}let t=m[e];if(t&&_S(t.schema)&&!aS(t.schema)){let e=l[t.name],n=e===void 0?``:String(e);v(n),b(n.length)}},[m,l]);function te(e,t){if(!oS(t))return;let n=l[e]??[],r=m.find(t=>t.name===e)?.isRequired??!1,i=t.minItems,a=t.maxItems;i!==void 0&&n.length<i&&(n.length>0||r)?I(e,`Select at least ${i} ${qf(i,`item`)}`):a!==void 0&&n.length>a?I(e,`Select at most ${a} ${qf(a,`item`)}`):I(e)}function P(e){M&&oS(M.schema)?(te(M.name,M.schema),w(void 0)):M&&aS(M.schema)&&w(void 0),N&&M&&(ne(M.name,M.schema,_),D.current!==void 0&&(clearTimeout(D.current),D.current=void 0),hS(M.schema)&&_.trim()!==``&&f[M.name]&&re(M.name,M.schema,_));let t=m.length+2,n=h??(s===`accept`?m.length:s===`decline`?m.length+1:void 0),r=n===void 0?0:(n+(e===`up`?t-1:1))%t;r<m.length?(g(r),c(null),ee(r)):(g(void 0),c(r===m.length?`accept`:`decline`),v(``))}function F(e,t){d(n=>{let r={...n};return t===void 0?delete r[e]:r[e]=t,r}),t!==void 0&&f[e]===`This field is required`&&I(e)}function I(e,t){p(n=>{let r={...n};return t?r[e]=t:delete r[e],r})}function L(e){e&&(F(e,void 0),I(e),v(``),b(0))}function ne(e,t,n){let r=n.trim();if(r===``&&(t.type!==`string`||`format`in t&&t.format!==void 0)){L(e);return}if(r===``){l[e]!==void 0&&F(e,``);return}let i=mS(n,t);F(e,i.isValid?i.value:n),I(e,i.isValid?void 0:i.error)}function re(e,t,n){if(!r)return;let i=O.current.get(e);i&&i.abort();let a=new AbortController;O.current.set(e,a),S(t=>new Set(t).add(e)),gS(n,t,a.signal).then(t=>{if(O.current.delete(e),S(t=>{let n=new Set(t);return n.delete(e),n}),!a.signal.aborted)if(t.isValid){F(e,t.value),I(e);let r=String(t.value);v(e=>e===n?(b(r.length),r):e)}else I(e,t.error)},()=>{O.current.delete(e),S(t=>{let n=new Set(t);return n.delete(e),n})})}function ie(e){if(v(e),M&&(ne(M.name,M.schema,e),D.current!==void 0&&(clearTimeout(D.current),D.current=void 0),hS(M.schema)&&e.trim()!==``&&f[M.name])){let t=M.name,n=M.schema;D.current=setTimeout((e,t,n,r,i)=>{e.current=void 0,t(n,r,i)},2e3,D,re,t,n,e)}}function ae(){P(`down`)}function oe(e,t,n){let r=k.current;r.timer!==void 0&&clearTimeout(r.timer),r.buffer+=e.toLowerCase(),r.timer=setTimeout(bS,2e3,r);let i=t.findIndex(e=>e.startsWith(r.buffer));i!==-1&&n(i)}Ml(`confirm:no`,()=>{if(N&&M){let e=l[M.name];v(e===void 0?``:String(e)),b(0)}t(`cancel`)},{context:`Settings`,isActive:!!M&&!s&&!C}),ql((e,n)=>{if(N&&!n.upArrow&&!n.downArrow&&!n.return&&!n.backspace)return;if(C&&M&&oS(M.schema)){let t=M.schema,r=sS(t),i=l[M.name]??[];if(n.leftArrow||n.escape){w(void 0),te(M.name,t);return}if(n.upArrow){T===0?(w(void 0),te(M.name,t)):E(T-1);return}if(n.downArrow){T>=r.length-1?(w(void 0),P(`down`)):E(T+1);return}if(e===` `){let e=r[T];if(e!==void 0){let n=i.includes(e)?i.filter(t=>t!==e):[...i,e],r=n.length>0?n:void 0;F(M.name,r);let a=t.minItems,o=t.maxItems;a!==void 0&&n.length<a&&(n.length>0||M.isRequired)?I(M.name,`Select at least ${a} ${qf(a,`item`)}`):o!==void 0&&n.length>o?I(M.name,`Select at most ${o} ${qf(o,`item`)}`):I(M.name)}return}if(n.return){let e=r[T];e!==void 0&&!i.includes(e)&&F(M.name,[...i,e]),w(void 0),P(`down`);return}if(e){oe(e,r.map(e=>lS(t,e).toLowerCase()),E);return}return}if(C&&M&&aS(M.schema)){let t=M.schema,r=uS(t);if(n.leftArrow||n.escape){w(void 0);return}if(n.upArrow){T===0?w(void 0):E(T-1);return}if(n.downArrow){T>=r.length-1?(w(void 0),P(`down`)):E(T+1);return}if(e===` `){let e=r[T];e!==void 0&&F(M.name,e),w(void 0);return}if(n.return){let e=r[T];e!==void 0&&F(M.name,e),w(void 0),P(`down`);return}if(e){oe(e,r.map(e=>fS(t,e).toLowerCase()),E);return}return}if(n.return&&s===`accept`){if(se()&&Object.keys(f).length===0)t(`accept`,l);else{let e=a.required||[];for(let t of e)l[t]===void 0&&I(t,`This field is required`);let t=m.findIndex(t=>e.includes(t.name)&&l[t.name]===void 0||f[t.name]!==void 0);t!==-1&&(g(t),c(null),ee(t))}return}if(n.return&&s===`decline`){t(`decline`);return}if(n.upArrow||n.downArrow){let e=k.current;e.buffer=``,e.timer!==void 0&&(clearTimeout(e.timer),e.timer=void 0),P(n.upArrow?`up`:`down`);return}if(s&&(n.leftArrow||n.rightArrow)){c(s===`accept`?`decline`:`accept`);return}if(!M)return;let{schema:r,name:i}=M,o=l[i];if(r.type===`boolean`){if(e===` `){F(i,o===void 0||!o);return}if(n.return){P(`down`);return}if(n.backspace&&o!==void 0){L(i);return}if(e&&!n.return){oe(e,[`yes`,`no`],e=>F(i,e===0));return}return}if(aS(r)||oS(r)){if(n.return){P(`down`);return}if(n.backspace&&o!==void 0){L(i);return}let t,a=0;if(aS(r)){let e=uS(r);t=e.map(e=>fS(r,e).toLowerCase()),o!==void 0&&(a=Math.max(0,e.indexOf(o)))}else t=sS(r).map(e=>lS(r,e).toLowerCase());if(n.rightArrow){w(i),E(a);return}if(e&&!n.leftArrow){oe(e,t,e=>{w(i),E(e)});return}return}if(n.backspace&&N&&_===``){L(i);return}},{isActive:!0});function se(){let e=a.required||[];for(let t of e){let e=l[t];if(e==null||e===``||Array.isArray(e)&&e.length===0)return!1}return!0}let ce=Math.max(2,Math.floor((j-14)/3)),le=(0,Q.useMemo)(()=>{let e=m.length;if(e<=ce)return{start:0,end:e};let t=h??e-1,n=Math.max(0,t-Math.floor(ce/2)),r=Math.min(n+ce,e);return n=Math.max(0,r-ce),{start:n,end:r}},[m.length,ce,h]),R=le.start>0,ue=le.end<m.length;function de(){return m.length?(0,$.jsxs)(G,{flexDirection:`column`,children:[R&&(0,$.jsx)(G,{marginLeft:2,children:(0,$.jsxs)(K,{dimColor:!0,children:[u.arrowUp,` `,le.start,` more above`]})}),m.slice(le.start,le.end).map((e,t)=>{let n=le.start+t,{name:r,schema:i,isRequired:a}=e,o=n===h&&!s,c=l[r],d=c!==void 0&&(!Array.isArray(c)||c.length>0),p=f[r],m=x.has(r)?(0,$.jsx)(xS,{}):p?(0,$.jsx)(K,{color:`error`,children:u.warning}):d?(0,$.jsx)(K,{color:`success`,dimColor:!o,children:u.tick}):a?(0,$.jsx)(K,{color:`error`,children:`*`}):(0,$.jsx)(K,{children:` `}),g=p?`error`:d?`success`:a?`error`:`suggestion`,v=o?g:void 0,S=(0,$.jsx)(K,{color:v,bold:o,children:i.title||r}),w,E=null;if(oS(i)){let e=sS(i),t=c??[];if(C===r&&o)w=(0,$.jsx)(K,{dimColor:!0,children:u.triangleDownSmall}),E=(0,$.jsx)(G,{flexDirection:`column`,marginLeft:6,children:e.map((e,n)=>{let r=lS(i,e),a=t.includes(e),o=n===T;return(0,$.jsxs)(G,{gap:1,children:[(0,$.jsx)(K,{color:`suggestion`,children:o?u.pointer:` `}),(0,$.jsx)(K,{color:a?`success`:void 0,children:a?u.checkboxOn:u.checkboxOff}),(0,$.jsx)(K,{color:o?`suggestion`:void 0,bold:o,children:r})]},e)})});else{let e=o?(0,$.jsxs)(K,{dimColor:!0,children:[u.triangleRightSmall,` `]}):null;w=t.length>0?(0,$.jsxs)(K,{children:[e,(0,$.jsx)(K,{color:v,bold:o,children:t.map(e=>lS(i,e)).join(`, `)})]}):(0,$.jsxs)(K,{children:[e,(0,$.jsx)(K,{dimColor:!0,italic:!0,children:`not set`})]})}}else if(aS(i)){let e=uS(i);if(C===r&&o)w=(0,$.jsx)(K,{dimColor:!0,children:u.triangleDownSmall}),E=(0,$.jsx)(G,{flexDirection:`column`,marginLeft:6,children:e.map((e,t)=>{let n=fS(i,e),r=c===e,a=t===T;return(0,$.jsxs)(G,{gap:1,children:[(0,$.jsx)(K,{color:`suggestion`,children:a?u.pointer:` `}),(0,$.jsx)(K,{color:r?`success`:void 0,children:r?u.radioOn:u.radioOff}),(0,$.jsx)(K,{color:a?`suggestion`:void 0,bold:a,children:n})]},e)})});else{let e=o?(0,$.jsxs)(K,{dimColor:!0,children:[u.triangleRightSmall,` `]}):null;w=d?(0,$.jsxs)(K,{children:[e,(0,$.jsx)(K,{color:v,bold:o,children:fS(i,c)})]}):(0,$.jsxs)(K,{children:[e,(0,$.jsx)(K,{dimColor:!0,italic:!0,children:`not set`})]})}}else if(i.type===`boolean`)w=o?d?(0,$.jsx)(K,{color:v,bold:!0,children:c?u.checkboxOn:u.checkboxOff}):(0,$.jsx)(K,{dimColor:!0,children:u.checkboxOff}):d?(0,$.jsx)(K,{children:c?u.checkboxOn:u.checkboxOff}):(0,$.jsx)(K,{dimColor:!0,italic:!0,children:`not set`});else if(_S(i))if(o)w=(0,$.jsx)(ha,{value:_,onChange:ie,onSubmit:ae,placeholder:`Type something…`,columns:Math.min(A-20,60),cursorOffset:y,onChangeCursorOffset:b,focus:!0,showCursor:!0});else{let e=d&&hS(i)?SS(String(c),i):String(c);w=d?(0,$.jsx)(K,{children:e}):(0,$.jsx)(K,{dimColor:!0,italic:!0,children:`not set`})}else w=d?(0,$.jsx)(K,{children:String(c)}):(0,$.jsx)(K,{dimColor:!0,italic:!0,children:`not set`});return(0,$.jsxs)(G,{flexDirection:`column`,children:[(0,$.jsxs)(G,{gap:1,children:[(0,$.jsx)(K,{color:g,children:o?u.pointer:` `}),m,(0,$.jsxs)(G,{children:[S,(0,$.jsx)(K,{color:v,children:`: `}),w]})]}),E,i.description&&(0,$.jsx)(G,{marginLeft:6,children:(0,$.jsx)(K,{dimColor:!0,children:i.description})}),(0,$.jsx)(G,{marginLeft:6,height:1,children:p?(0,$.jsx)(K,{color:`error`,italic:!0,children:p}):(0,$.jsx)(K,{children:` `})})]},r)}),ue&&(0,$.jsx)(G,{marginLeft:2,children:(0,$.jsxs)(K,{dimColor:!0,children:[u.arrowDown,` `,m.length-le.end,` more below`]})})]}):null}return(0,$.jsx)(au,{title:`MCP server \u201c${n}\u201d requests your input`,subtitle:`\n${i}`,color:`permission`,onCancel:()=>t(`cancel`),isCancelActive:(!M||!!s)&&!C,inputGuide:e=>e.pending?(0,$.jsxs)(K,{children:[`Press `,e.keyName,` again to exit`]}):(0,$.jsxs)(kl,{children:[(0,$.jsx)(ye,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),(0,$.jsx)(yl,{shortcut:`↑↓`,action:`navigate`}),M&&(0,$.jsx)(yl,{shortcut:`Backspace`,action:`unset`}),M&&M.schema.type===`boolean`&&(0,$.jsx)(yl,{shortcut:`Space`,action:`toggle`}),M&&aS(M.schema)&&(C?(0,$.jsx)(yl,{shortcut:`Space`,action:`select`}):(0,$.jsx)(yl,{shortcut:`→`,action:`expand`})),M&&oS(M.schema)&&(C?(0,$.jsx)(yl,{shortcut:`Space`,action:`toggle`}):(0,$.jsx)(yl,{shortcut:`→`,action:`expand`}))]}),children:(0,$.jsxs)(G,{flexDirection:`column`,children:[de(),(0,$.jsxs)(G,{children:[(0,$.jsx)(K,{color:`success`,children:s===`accept`?u.pointer:` `}),(0,$.jsx)(K,{bold:s===`accept`,color:s===`accept`?`success`:void 0,dimColor:s!==`accept`,children:` Accept `}),(0,$.jsx)(K,{color:`error`,children:s===`decline`?u.pointer:` `}),(0,$.jsx)(K,{bold:s===`decline`,color:s===`decline`?`error`:void 0,dimColor:s!==`decline`,children:` Decline`})]})]})})}function TS({event:e,onResponse:t,onWaitingDismiss:n}){let{serverName:r,signal:i,waitingState:a}=e,{message:o,url:s}=e.params,[c,l]=(0,Q.useState)(`prompt`),d=(0,Q.useRef)(`prompt`),[f,p]=(0,Q.useState)(`accept`),m=a?.showCancel??!1;Oy(`Work Mate needs your input`,`elicitation_url_dialog`),qi(`elicitation-url`),d.current=c;let h=(0,Q.useRef)(n);h.current=n,(0,Q.useEffect)(()=>{let e=()=>{d.current===`waiting`?h.current?.(`cancel`):t(`cancel`)};if(i.aborted){e();return}return i.addEventListener(`abort`,e),()=>i.removeEventListener(`abort`,e)},[i,t]);let g=``,_=``,v=``;try{g=new URL(s).hostname;let e=s.indexOf(g);_=s.slice(0,e),v=s.slice(e+g.length)}catch{g=s}(0,Q.useEffect)(()=>{c===`waiting`&&e.completed&&n?.(m?`retry`:`dismiss`)},[c,e.completed,n,m]);let y=(0,Q.useCallback)(()=>{lc(s),t(`accept`),l(`waiting`),d.current=`waiting`,p(`open`)},[t,s]);if(ql((e,r)=>{if(c===`prompt`){if(r.leftArrow||r.rightArrow){p(e=>e===`accept`?`decline`:`accept`);return}r.return&&(f===`accept`?y():t(`decline`))}else{let e=m?[`open`,`action`,`cancel`]:[`open`,`action`];if(r.leftArrow||r.rightArrow){p(t=>{let n=e.indexOf(t),i=r.rightArrow?1:-1;return e[(n+i+e.length)%e.length]});return}r.return&&(f===`open`?lc(s):f===`cancel`?n?.(`cancel`):n?.(m?`retry`:`dismiss`))}}),c===`waiting`){let e=a?.actionLabel??`Continue without waiting`;return(0,$.jsx)(au,{title:`MCP server \u201c${r}\u201d \u2014 waiting for completion`,subtitle:`\n${o}`,color:`permission`,onCancel:()=>n?.(`cancel`),isCancelActive:!0,inputGuide:e=>e.pending?(0,$.jsxs)(K,{children:[`Press `,e.keyName,` again to exit`]}):(0,$.jsxs)(kl,{children:[(0,$.jsx)(ye,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),(0,$.jsx)(yl,{shortcut:`\\u2190\\u2192`,action:`switch`})]}),children:(0,$.jsxs)(G,{flexDirection:`column`,children:[(0,$.jsx)(G,{marginBottom:1,flexDirection:`column`,children:(0,$.jsxs)(K,{children:[_,(0,$.jsx)(K,{bold:!0,children:g}),v]})}),(0,$.jsx)(G,{marginBottom:1,children:(0,$.jsx)(K,{dimColor:!0,italic:!0,children:`Waiting for the server to confirm completion…`})}),(0,$.jsxs)(G,{children:[(0,$.jsx)(K,{color:`success`,children:f===`open`?u.pointer:` `}),(0,$.jsx)(K,{bold:f===`open`,color:f===`open`?`success`:void 0,dimColor:f!==`open`,children:` Reopen URL `}),(0,$.jsx)(K,{color:`success`,children:f===`action`?u.pointer:` `}),(0,$.jsx)(K,{bold:f===`action`,color:f===`action`?`success`:void 0,dimColor:f!==`action`,children:` ${e}`}),m&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(K,{children:` `}),(0,$.jsx)(K,{color:`error`,children:f===`cancel`?u.pointer:` `}),(0,$.jsx)(K,{bold:f===`cancel`,color:f===`cancel`?`error`:void 0,dimColor:f!==`cancel`,children:` Cancel`})]})]})]})})}return(0,$.jsx)(au,{title:`MCP server \u201c${r}\u201d wants to open a URL`,subtitle:`\n${o}`,color:`permission`,onCancel:()=>t(`cancel`),isCancelActive:!0,inputGuide:e=>e.pending?(0,$.jsxs)(K,{children:[`Press `,e.keyName,` again to exit`]}):(0,$.jsxs)(kl,{children:[(0,$.jsx)(ye,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),(0,$.jsx)(yl,{shortcut:`\\u2190\\u2192`,action:`switch`})]}),children:(0,$.jsxs)(G,{flexDirection:`column`,children:[(0,$.jsx)(G,{marginBottom:1,flexDirection:`column`,children:(0,$.jsxs)(K,{children:[_,(0,$.jsx)(K,{bold:!0,children:g}),v]})}),(0,$.jsxs)(G,{children:[(0,$.jsx)(K,{color:`success`,children:f===`accept`?u.pointer:` `}),(0,$.jsx)(K,{bold:f===`accept`,color:f===`accept`?`success`:void 0,dimColor:f!==`accept`,children:` Accept `}),(0,$.jsx)(K,{color:`error`,children:f===`decline`?u.pointer:` `}),(0,$.jsx)(K,{bold:f===`decline`,color:f===`decline`?`error`:void 0,dimColor:f!==`decline`,children:` Decline`})]})]})})}q(),vc(),S(),pg();function ES({title:e,toolInputSummary:t,request:n,onRespond:r,onAbort:i}){Ml(`app:interrupt`,i,{isActive:!0});let a=n.options.map(e=>({label:e.label,value:e.key,description:e.description}));return(0,$.jsx)(hg,{title:e,subtitle:n.message,titleRight:t?(0,$.jsx)(K,{dimColor:!0,children:t}):void 0,children:(0,$.jsx)(G,{flexDirection:`column`,paddingY:1,children:(0,$.jsx)(Hn,{options:a,onChange:e=>{r(e)}})})})}function DS(){return(0,Q.useSyncExternalStore)(Jo,Ba)}Sf(),vu(),tc(),yu();var OS=`at_mentioned`,kS=gu(()=>uu({method:lu(OS),params:uu({filePath:fu(),lineStart:du().optional(),lineEnd:du().optional()})}));function AS(e,t){let n=(0,Q.useRef)(void 0);(0,Q.useEffect)(()=>{let r=Gs(e);n.current!==r&&(n.current=r),r&&r.client.setNotificationHandler(kS(),e=>{if(n.current===r)try{let n=e.params,r=n.lineStart===void 0?void 0:n.lineStart+1,i=n.lineEnd===void 0?void 0:n.lineEnd+1;t({filePath:n.filePath,lineStart:r,lineEnd:i})}catch(e){Y(e)}})},[e,t])}cg(),ug(),Mg();function jS(e){return(0,Q.useMemo)(()=>{let t=e?.find(e=>e.name===`ide`);if(!t)return{status:null,ideName:null};let n=t.config,r=n.type===`sse-ide`||n.type===`ws-ide`?n.ideName:null;return t.type===`connected`?{status:`connected`,ideName:r}:t.type===`pending`?{status:`pending`,ideName:r}:{status:`disconnected`,ideName:r}},[e])}Vh();function MS(){let[e,t]=(0,Q.useState)({...Be});return(0,Q.useEffect)(()=>{let e=e=>{t({...e})};return er.add(e),()=>{er.delete(e)}},[]),e}q();function NS({ideSelection:e,mcpClients:t}){let{status:n}=jS(t),r=n===`connected`&&(e?.filePath||e?.text&&e.lineCount>0);if(n===null||!r||!e)return null;if(e.text&&e.lineCount>0)return(0,$.jsxs)(K,{color:`ide`,wrap:`truncate`,children:[`⧉ `,e.lineCount,` `,e.lineCount===1?`line`:`lines`,` selected`]},`selection-indicator`);if(e.filePath)return(0,$.jsxs)(K,{color:`ide`,wrap:`truncate`,children:[`⧉ In `,e_(e.filePath)]},`selection-indicator`)}function PS(){return(0,Q.useSyncExternalStore)(ds.subscribe,ds.getState)}q(),Ac();function FS({tokenUsage:e,model:t}){let{percentLeft:n,isAboveWarningThreshold:r,isAboveErrorThreshold:i}=hr(e,t),a=PS();if(!r||a)return null;let o=ve(),s=Hi(`warning`),c=`${n}% until auto-compact`;return(0,$.jsx)(G,{flexDirection:`row`,children:o?(0,$.jsx)(K,{dimColor:!0,wrap:`truncate`,children:s?`${c} \u00b7 ${s}`:c}):(0,$.jsx)(K,{color:i?`error`:`warning`,wrap:`truncate`,children:s?`Context low (${n}% remaining) \u00b7 ${s}`:`Context low (${n}% remaining) \u00b7 Run /compact to compact & continue`})})}q(),uc();function IS(){let[e,t]=(0,Q.useState)(0),n=(0,Q.useRef)(null),r=Va(`app:toggleTranscript`,`Global`,`ctrl+o`);return(0,Q.useEffect)(()=>{if(!Wn.isSandboxingEnabled())return;let e=Wn.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)}},[]),!Wn.isSandboxingEnabled()||e===0?null:(0,$.jsx)(G,{paddingX:0,paddingY:0,children:(0,$.jsxs)(K,{color:`inactive`,wrap:`truncate`,children:[`⧈ Sandbox blocked `,e,` `,e===1?`operation`:`operations`,` ·`,` `,r,` for details · /sandbox to disable`]})})}Si(),Mf(),U(),q(),Te(),Ph(),Hf(),tc(),Bt(),Cn();var LS=5e3;function RS({apiKeyStatus:e,autoUpdaterResult:t,debug:n,isAutoUpdating:r,verbose:i,messages:a,onAutoUpdaterResult:o,onChangeIsUpdating:s,ideSelection:c,mcpClients:l,isInputWrapped:u=!1,isNarrow:d=!1}){let f=(0,Q.useMemo)(()=>Tn(Io(a)),[a]),p=Bh(),m=hr(f,p).isAboveWarningThreshold,{status:h}=jS(l),g=W(e=>e.notifications),{addNotification:_,removeNotification:v}=li(),y=MS();(0,Q.useEffect)(()=>(ke((e,t)=>{_({key:`env-hook`,text:e,color:t?`error`:void 0,priority:t?`medium`:`low`,timeoutMs:t?8e3:5e3})}),()=>ke(null)),[_]),h===`connected`&&(c?.filePath||c?.text&&c.lineCount);let b=y.isUsingOverage,x=Ep(),S=x===`team`||x===`enterprise`,C=Fh(),w=u&&!m&&e!==`invalid`&&e!==`missing`&&C!==void 0;return(0,Q.useEffect)(()=>{w&&C?(X(`tengu_external_editor_hint_shown`,{}),_({key:`external-editor-hint`,jsx:(0,$.jsx)(K,{dimColor:!0,children:(0,$.jsx)(ye,{action:`chat:externalEditor`,context:`Chat`,fallback:`ctrl+g`,description:`edit in ${Ua(C)}`})}),priority:`immediate`,timeoutMs:5e3})):v(`external-editor-hint`)},[w,C,_,v]),(0,$.jsx)(G,{flexDirection:`column`,alignItems:d?`flex-start`:`flex-end`,flexShrink:0,overflowX:`hidden`,children:(0,$.jsx)(zS,{ideSelection:c,mcpClients:l,notifications:g,isInOverageMode:b??!1,isTeamOrEnterprise:S,apiKeyStatus:e,debug:n,verbose:i,tokenUsage:f,mainLoopModel:p})})}function zS({ideSelection:e,mcpClients:t,notifications:n,isInOverageMode:r,isTeamOrEnterprise:i,apiKeyStatus:o,debug:s,verbose:c,tokenUsage:l,mainLoopModel:u}){let[d,f]=(0,Q.useState)(null);return(0,Q.useEffect)(()=>{if(!Np())return;let e=setInterval(e=>{let t=bp(),n=t>=1e4?Bf(t):null;e(e=>n===e?e:n)},1e3,f);return()=>clearInterval(e)},[]),(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(NS,{ideSelection:e,mcpClients:t}),n.current&&(`jsx`in n.current?(0,$.jsx)(K,{wrap:`truncate`,children:n.current.jsx},n.current.key):(0,$.jsx)(K,{color:n.current.color,dimColor:!n.current.color,wrap:`truncate`,children:n.current.text})),r&&!i&&(0,$.jsx)(G,{children:(0,$.jsx)(K,{dimColor:!0,wrap:`truncate`,children:`Now using extra usage`})}),d&&(0,$.jsxs)(G,{children:[(0,$.jsxs)(K,{color:`warning`,wrap:`truncate`,children:[`apiKeyHelper is taking a while`,` `]}),(0,$.jsxs)(K,{dimColor:!0,wrap:`truncate`,children:[`(`,d,`)`]})]}),(o===`invalid`||o===`missing`)&&(0,$.jsx)(G,{children:(0,$.jsx)(K,{color:`error`,wrap:`truncate`,children:a(process.env.CLAUDE_CODE_REMOTE)?`Authentication error · Try again`:`Not logged in`})}),s&&(0,$.jsx)(G,{children:(0,$.jsx)(K,{color:`warning`,wrap:`truncate`,children:`Debug mode`})}),o!==`invalid`&&o!==`missing`&&c&&(0,$.jsx)(G,{children:(0,$.jsxs)(K,{dimColor:!0,wrap:`truncate`,children:[l,` tokens`]})}),(0,$.jsx)(FS,{tokenUsage:l,model:u}),(0,$.jsx)(IS,{})]})}Si(),Cn(),q();var BS=10,VS=null,HS=0,US;async function WS(e,t){let n=Math.ceil(e/BS)*BS;if(VS&&HS>=n&&US===t)return VS;VS&&await VS,HS=n,US=t,VS=(async()=>{let e=[],n=0;for await(let r of sn())if(!(t&&Rr(r.display)!==t)&&(e.push(r),n++,n>=HS))break;return e})();try{return await VS}finally{VS=null,HS=0,US=void 0}}function GS(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}=li(),f=(0,Q.useRef)([]),p=(0,Q.useRef)(void 0),m=(0,Q.useRef)(0),h=(0,Q.useRef)(void 0),g=(0,Q.useRef)(t),_=(0,Q.useRef)(n),v=(0,Q.useRef)(i);g.current=t,_.current=n,v.current=i;let y=(0,Q.useCallback)((t,n,i,a=!1)=>{e(t,n,i),r?.(a?0:t.length)},[e,r]),b=(0,Q.useCallback)((e,t=!1)=>{if(!e?.display)return;let n=Rr(e.display),r=n===`bash`?e.display.slice(1):e.display;y(r,n,e.pastedContents??{},t)},[y]),x=(0,Q.useCallback)(()=>{u({key:`search-history-hint`,jsx:(0,$.jsx)(K,{dimColor:!0,children:(0,$.jsx)(ye,{action:`history:search`,context:`Global`,fallback:`ctrl+r`,description:`search history`})}),priority:`immediate`,timeoutMs:LS})},[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 WS(t,i);e.length>f.current.length&&(f.current=e)}if(e>=f.current.length){m.current--;return}let n=e+1;o(n),b(f.current[e],!0),n>=2&&!l.current&&(l.current=!0,x())})()},[b,x]),onHistoryDown:(0,Q.useCallback)(()=>{let e=m.current;if(e>1)m.current--,o(e-1),b(f.current[e-2]);else if(e===1)if(m.current=0,o(0),s){let e=s.mode;e?y(s.display,e,s.pastedContents??{}):b(s)}else y(``,h.current??`prompt`,{});return e<=0},[s,b,y]),resetHistory:(0,Q.useCallback)(()=>{c(void 0),o(0),m.current=0,h.current=void 0,d(`search-history-hint`),f.current=[],p.current=void 0},[d]),dismissSearchHint:(0,Q.useCallback)(()=>{d(`search-history-hint`)},[d])}}U();function KS(){let e=W(e=>e.tasks);return(0,Q.useMemo)(()=>{let t=Date.now();return Object.values(e).filter($n).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])}wr(),je(),q(),vc();function qS(e,t,n,r,i,a,o,s,c,l,u){let[d,f]=(0,Q.useState)(``),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(``),[_,v]=(0,Q.useState)(0),[y,b]=(0,Q.useState)(`prompt`),[x,S]=(0,Q.useState)({}),[C,w]=(0,Q.useState)(void 0),T=(0,Q.useRef)(void 0),E=(0,Q.useRef)(new Set),D=(0,Q.useRef)(null),O=(0,Q.useCallback)(()=>{T.current&&(T.current.return(void 0),T.current=void 0)},[]),k=(0,Q.useCallback)(()=>{c(!1),f(``),m(!1),g(``),v(0),b(`prompt`),S({}),w(void 0),O(),E.current.clear()},[c,O]),A=(0,Q.useCallback)(async(e,t)=>{if(s){if(d.length===0){O(),E.current.clear(),w(void 0),m(!1),n(h),r(_),a(y),l(x);return}if(e||(O(),T.current=st(),E.current.clear()),T.current)for(;;){if(t?.aborted)return;let e=await T.current.next();if(e.done){m(!0);return}let i=e.value.display,o=i.lastIndexOf(d);if(o!==-1&&!E.current.has(i)){E.current.add(i),w(e.value),m(!1),a(Rr(i)),n(i),l(e.value.pastedContents);let t=Ze(i).lastIndexOf(d);r(t===-1?o:t);return}}}},[s,d,O,n,r,a,l,h,_,y,x]),j=(0,Q.useCallback)(()=>{c(!0),g(t),v(i),b(o),S(u),T.current=st(),E.current.clear()},[c,t,i,o,u]),M=(0,Q.useCallback)(()=>{A(!0)},[A]),N=(0,Q.useCallback)(()=>{if(C){let e=Rr(C.display);n(Ze(C.display)),a(e),l(C.pastedContents)}else l(x);k()},[C,n,a,l,x,k]),ee=(0,Q.useCallback)(()=>{n(h),r(_),l(x),k()},[n,r,l,h,_,x,k]),te=(0,Q.useCallback)(()=>{if(d.length===0)e({display:h,pastedContents:x});else if(C){let t=Rr(C.display),n=Ze(C.display);a(t),e({display:n,pastedContents:C.pastedContents})}k()},[d,C,e,a,h,x,k]);Ml(`history:search`,j,{context:`Global`,isActive:!s}),Sl((0,Q.useMemo)(()=>({"historySearch:next":M,"historySearch:accept":N,"historySearch:cancel":ee,"historySearch:execute":te}),[M,N,ee,te]),{context:`HistorySearch`,isActive:s});let P=e=>{s&&e.key===`backspace`&&d===``&&(e.preventDefault(),ee())};ql((e,t,n)=>{P(new jl(n.keypress))},{isActive:s});let F=(0,Q.useRef)(A);return F.current=A,(0,Q.useEffect)(()=>{D.current?.abort();let e=new AbortController;return D.current=e,F.current(!1,e.signal),()=>{e.abort()}},[d]),{historyQuery:d,setHistoryQuery:f,historyMatch:C,historyFailedMatch:p,handleKeyDown:P}}function JS({maxBufferSize:e,debounceMs:t}){let[n,r]=(0,Q.useState)([]),[i,a]=(0,Q.useState)(-1),o=(0,Q.useRef)(0),s=(0,Q.useRef)(null),c=(0,Q.useCallback)((l,u,d={})=>{let f=Date.now();if(s.current&&(clearTimeout(s.current),s.current=null),f-o.current<t){s.current=setTimeout(c,t,l,u,d);return}o.current=f,r(t=>{let n=i>=0?t.slice(0,i+1):t,r=n[n.length-1];if(r&&r.text===l)return n;let a=[...n,{text:l,cursorOffset:u,pastedContents:d,timestamp:f}];return a.length>e?a.slice(-e):a}),a(t=>{let r=t>=0?t+1:n.length;return Math.min(r,e-1)})},[t,e,i,n.length]),l=(0,Q.useCallback)(()=>{if(i<0||n.length===0)return;let e=Math.max(0,i-1),t=n[e];if(t)return a(e),t},[n,i]),u=(0,Q.useCallback)(()=>{r([]),a(-1),o.current=0,s.current&&(clearTimeout(s.current),s.current=null)},[o,s]);return{pushToBuffer:c,undo:l,canUndo:i>0&&n.length>1,clearBuffer:u}}q(),Mf(),U();function YS({inputValue:e,isAssistantResponding:t}){let n=W(e=>e.promptSuggestion),r=y(),i=Nl(),{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)(()=>{Ur(r),r(e=>({...e,promptSuggestion:{text:null,promptId:null,shownAt:0,acceptedAt:0,generationRequestId:null}}))},[r]);return{suggestion:u,markAccepted:(0,Q.useCallback)(()=>{d&&r(e=>({...e,promptSuggestion:{...e.promptSuggestion,acceptedAt:Date.now()}}))},[d,r]),markShown:(0,Q.useCallback)(()=>{r(e=>e.promptSuggestion.shownAt!==0||!e.promptSuggestion.text?e:{...e,promptSuggestion:{...e.promptSuggestion,shownAt:Date.now()}})},[r]),logOutcomeAtSubmission:(0,Q.useCallback)((e,t)=>{if(!d)return;let n=c>s,r=n||e===a,i=r&&c||Date.now();X(`tengu_prompt_suggestion`,{source:`cli`,outcome:r?`accepted`:`ignored`,prompt_id:o,...l&&{generationRequestId:l},...r&&{acceptMethod:n?`tab`:`enter`},...r&&{timeToAcceptMs:i-s},...!r&&{timeToIgnoreMs:i-s},...f.current>0&&{timeToFirstKeystrokeMs:f.current-s},wasFocusedWhenShown:p.current,similarity:Math.round(e.length/(a?.length||1)*100)/100}),t?.skipReset||h()},[d,c,s,a,o,l,h])}}fa(),gd(),Km();var XS=15,ZS=1e3,QS=[`|`,`||`,`&&`,`;`];function $S(e){return typeof e==`object`&&!!e&&`op`in e&&QS.includes(e.op)}function eC(e){return e.startsWith(`$`)?`variable`:e.includes(`/`)||e.startsWith(`~`)||e.startsWith(`.`)?`file`:`command`}function tC(e){let t=e.findLastIndex(e=>typeof e==`string`);return t===-1?null:{token:e[t],index:t}}function nC(e,t){if(t===0)return!0;let n=e[t-1];return n!==void 0&&$S(n)}function rC(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=vm(n);if(!i.success){let e=n.split(/\s+/),t=e[e.length-1]||``;return{prefix:t,completionType:e.length===1&&!n.includes(` `)?`command`:eC(t)}}let a=tC(i.tokens);if(!a){let e=i.tokens[i.tokens.length-1];return{prefix:``,completionType:(e&&$S(e),`command`)}}if(n.endsWith(` `))return{prefix:``,completionType:`file`};let o=eC(a.token);if(o===`variable`||o===`file`)return{prefix:a.token,completionType:o};let s=nC(i.tokens,a.index)?`command`:`file`;return{prefix:a.token,completionType:s}}function iC(e,t){return t===`variable`?`compgen -v ${ym([e.slice(1)])} 2>/dev/null`:t===`file`?`compgen -f ${ym([e])} 2>/dev/null | head -${XS} | while IFS= read -r f; do [ -d "$f" ] && echo "$f/" || echo "$f "; done`:`compgen -c ${ym([e])} 2>/dev/null`}function aC(e,t){return t===`variable`?`print -rl -- \${(k)parameters[(I)${ym([e.slice(1)])}*]} 2>/dev/null`:t===`file`?`for f in ${ym([e])}*(N[1,${XS}]); do [[ -d "$f" ]] && echo "$f/" || echo "$f "; done`:`print -rl -- \${(k)commands[(I)${ym([e])}*]} 2>/dev/null`}async function oC(e,t,n,r){let i;if(e===`bash`)i=iC(t,n);else if(e===`zsh`)i=aC(t,n);else return[];return(await(await _n(i,r,`bash`,{timeout:ZS})).result).stdout.split(`
36
+ `).filter(e=>e.trim()).slice(0,XS).map(e=>({id:e,displayText:e,description:void 0,metadata:{completionType:n}}))}async function sC(e,t,n){let r=qm();if(r!==`bash`&&r!==`zsh`)return[];try{let{prefix:i,completionType:a}=rC(e,t);return i?(await oC(r,i,a,n)).map(t=>({...t,metadata:{...t.metadata,inputSnapshot:e}})):[]}catch(e){return J(`Shell completion failed: ${e}`),[]}}Gv();var cC=/[:_-]/g,lC=null;function uC(e){if(lC?.commands===e)return lC.fuse;let t=new Wv(e.filter(e=>!e.isHidden).map(e=>{let t=dl(e),n=t.split(cC).filter(Boolean);return{descriptionKey:(e.description??``).split(` `).map(e=>SC(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 lC={commands:e,fuse:t},t}function dC(e){return typeof e==`object`&&!!e&&`name`in e&&typeof e.name==`string`&&`type`in e}function fC(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 pC(e,t){if(!e)return null;let n=bC(`/${e}`,t);if(n.length===0)return null;let r=e.toLowerCase();for(let t of n){if(!dC(t.metadata))continue;let n=dl(t.metadata);if(n.toLowerCase().startsWith(r)){let t=n.slice(e.length);if(t)return{suffix:t,fullCommand:n}}}return null}function mC(e){return e.startsWith(`/`)}function hC(e){return!(!mC(e)||!e.includes(` `)||e.endsWith(` `))}function gC(e){return`/${e} `}function _C(e){let t=dl(e);return e.type===`prompt`?e.source===`plugin`&&e.pluginInfo?.repository?`${t}:${e.source}:${e.pluginInfo.repository}`:`${t}:${e.source}`:`${t}:${e.type}`}function vC(e,t){if(!(!t||t.length===0||e===``))return t.find(t=>t.toLowerCase().startsWith(e))}function yC(e,t){let n=dl(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:j(e))+(e.type===`prompt`&&e.argNames?.length?` (arguments: ${e.argNames.join(`, `)})`:``);return{id:_C(e),displayText:`/${n}${r}`,tag:i?`workflow`:a,description:o,metadata:e}}function bC(e,t){if(!mC(e)||hC(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:tl(dl(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=>_C(e))),a=[],o=[],s=[],c=[],l=[];e.forEach(e=>{i.has(_C(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)=>dl(e).localeCompare(dl(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=>yC(e))}let r=t.find(e=>e.isHidden&&dl(e).toLowerCase()===n);r&&t.some(e=>!e.isHidden&&dl(e).toLowerCase()===n)&&(r=void 0);let i=uC(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`?tl(dl(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 yC(t,vC(n,t.aliases))});if(r){let e=_C(r);if(!i.some(t=>t.id===e))return[yC(r),...i]}return i}function xC(e,t,n,r,i,a){let o,s;if(typeof e==`string`)o=e,s=t?Ao(o,n):void 0;else{if(!dC(e.metadata))return;o=dl(e.metadata),s=e.metadata}let c=gC(o);r(c),i(c.length),t&&s&&(s.type!==`prompt`||(s.argNames??[]).length===0)&&a(c,!0)}function SC(e){return e.toLowerCase().replace(/[^a-z0-9]/g,``)}function CC(e){let t=[],n=/(^|[\s])(\/[a-zA-Z][a-zA-Z0-9:\-_]*)/g,r=null;for(;(r=n.exec(e))!==null;){let e=r[1]??``,n=r[2]??``,i=r.index+e.length;t.push({start:i,end:i+n.length})}return t}Oh(),je(),gd();var wC=null,TC=0,EC=6e4;async function DC(){let e=Date.now();if(wC&&e-TC<EC)return wC;let t=[],n=new Set;try{for await(let e of sn()){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){J(`Failed to read shell history: ${e}`)}return wC=t,TC=e,t}function OC(e){if(!wC)return;let t=wC.indexOf(e);t!==-1&&wC.splice(t,1),wC.unshift(e)}async function kC(e){if(!e||e.length<2||!e.trim())return null;let t=await DC();for(let n of t)if(n.startsWith(e)&&n!==e)return{fullCommand:n,suffix:n.slice(e.length)};return null}Sm(),gd(),yu(),Yu(),bd();var AC=`slack_search_channels`,jC=new Map,MC=new Set,NC=0,PC=Hu(),FC=PC.subscribe,IC=null,LC=null;function RC(e){return e.find(e=>e.type===`connected`&&e.name.includes(`slack`))}async function zC(e,t){let n=RC(e);if(n?.type!==`connected`)return[];try{let e=(await n.client.callTool({name:AC,arguments:{query:t,limit:20,channel_types:`public_channel,private_channel`}},void 0,{timeout:5e3})).content;return Array.isArray(e)?HC(VC(e.filter(e=>e.type===`text`).map(e=>e.text).join(`
37
+ `))):[]}catch(e){return J(`Failed to fetch Slack channels: ${e}`),[]}}var BC=gu(()=>uu({results:fu()}));function VC(e){let t=e.trim();if(!t.startsWith(`{`))return e;try{let e=BC().safeParse(ud(t));if(e.success)return e.data.results}catch{}return e}function HC(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 UC(e){return RC(e)!==void 0}function WC(){return NC}function GC(e){let t=[],n=/(^|\s)#([a-z0-9][a-z0-9_-]{0,79})(?=\s|$)/g,r;for(;(r=n.exec(e))!==null;){if(!MC.has(r[2]))continue;let e=r.index+r[1].length;t.push({start:e,end:e+1+r[2].length})}return t}function KC(e){let t=Math.max(e.lastIndexOf(`-`),e.lastIndexOf(`_`));return t>0?e.slice(0,t):e}function qC(e,t){let n,r=0;for(let[i,a]of jC)e.startsWith(i)&&i.length>r&&a.some(e=>e.startsWith(t))&&(n=a,r=i.length);return n}async function JC(e,t){if(!t)return[];let n=KC(t),r=t.toLowerCase(),i=jC.get(n)??qC(n,r);if(!i)if(IC===n&&LC)i=await LC;else{IC=n,LC=zC(e,n),i=await LC,jC.set(n,i);let t=MC.size;for(let e of i)MC.add(e);MC.size!==t&&(NC++,PC.emit()),jC.size>50&&jC.delete(jC.keys().next().value),IC===n&&(IC=null,LC=null)}return i.filter(e=>e.startsWith(r)).sort().slice(0,10).map(e=>({id:`slack-channel-${e}`,displayText:`#${e}`}))}Gv(),Hh(),Rs(),Hf(),Sf();function YC(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 XC=15,ZC=60;function QC(e){return Lf(e,ZC)}function $C(e,t,n=!1){if(!t&&!n)return[];try{let n=e.map(e=>({type:`agent`,displayText:`${e.agentType} (agent)`,description:QC(e.whenToUse),agentType:e.agentType,color:Lt(e.agentType)}));if(!t)return n;let r=t.toLowerCase();return n.filter(e=>e.agentType.toLowerCase().includes(r)||e.displayText.toLowerCase().includes(r))}catch(e){return Y(e),[]}}async function ew(e,t,n,r=!1){if(!e&&!r)return[];let[i,a]=await Promise.all([Uh(e,r),Promise.resolve($C(n,e,r))]),o=i.map(e=>({type:`file`,displayText:e.displayText,description:e.description,path:e.displayText,filename:e_(e.displayText),score:e.metadata?.score})),s=Object.values(t).flat().map(e=>({type:`mcp_resource`,displayText:`${e.server}:${e.uri}`,description:QC(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,XC).map(YC);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 Wv(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:XC});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,XC).map(e=>e.source).map(YC)}Si(),q(),Mf(),Gt(),wr(),ss(),Cs(),vc(),ba(),U(),Hf(),da(),Hh();var tw=/^@[\p{L}\p{N}\p{M}_\-./\\()[\]~:]*/u,nw=/^[\p{L}\p{N}\p{M}_\-./\\()[\]~:]+/u,rw=/(@[\p{L}\p{N}\p{M}_\-./\\()[\]~:]*|[\p{L}\p{N}\p{M}_\-./\\()[\]~:]+)$/u,iw=/[\p{L}\p{N}\p{M}_\-./\\()[\]~:]+$/u,aw=/(^|\s)@([\p{L}\p{N}\p{M}_\-./\\()[\]~:]*|"[^"]*"?)$/u,ow=/(^|\s)#([a-z0-9][a-z0-9_-]*)$/;function sw(e){return typeof e==`object`&&!!e&&`type`in e&&(e.type===`directory`||e.type===`file`)}function cw(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 lw(e){let t=e.metadata;return t?.sessionId?`/resume ${t.sessionId}`:`/resume ${e.displayText}`}function uw(e){return e.isQuoted?e.token.slice(2).replace(/"$/,``):e.token.startsWith(`@`)?e.token.substring(1):e.token}function dw(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 fw(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 pw=/(^|\s)@[\w-]*$/;function mw(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 hw=null;async function gw(e,t){try{return hw&&hw.abort(),hw=new AbortController,await sC(e,t,hw.signal)}catch{return X(`tengu_shell_completion_failed`,{}),[]}}function _w(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 vw(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(tw);if(a&&a[0].length===i.length){let r=e.substring(t).match(nw),i=r?r[0]:``;return{token:a[0]+i,startPos:n,isQuoted:!1}}}}let i=n?rw:iw,a=r.match(i);if(!a||a.index===void 0)return null;let o=e.substring(t).match(nw),s=o?o[0]:``;return{token:a[0]+s,startPos:a.index,isQuoted:!1}}function yw(e){if(mC(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 bw(e,t){return!e&&t.includes(` `)&&!t.endsWith(` `)}function xw({commands:e,onInputChange:t,onSubmit:n,setCursorOffset:r,input:i,cursorOffset:a,mode:o,agents:s,setSuggestionsState:c,suggestionsState:{suggestions:l,selectedSuggestion:u,commandArgumentHint:d},suppressSuggestions:f=!1,markAccepted:p,onModeChange:m}){let{addNotification:h}=li(),g=Va(`chat:thinkingToggle`,`Chat`,`alt+t`),[_,v]=(0,Q.useState)(`none`),y=(0,Q.useMemo)(()=>{let t=e.filter(e=>!e.isHidden);if(t.length!==0)return Math.max(...t.map(e=>{let t=dl(e);return t?t.length:0}))+6},[e]),[b,x]=(0,Q.useState)(void 0),S=W(e=>e.mcp.resources),C=Bn(),w=W(e=>e.promptSuggestion),T=W(e=>!!e.viewingAgentTaskId),E=Il(),[D,O]=(0,Q.useState)(void 0),k=(0,Q.useMemo)(()=>{if(o!==`prompt`||f)return;let t=fC(i,a);if(!t)return;let n=pC(t.partialCommand,e);if(n)return{text:n.suffix,fullCommand:n.fullCommand,insertPosition:t.startPos+1+t.partialCommand.length}},[i,a,o,e,f]),A=f?void 0:o===`prompt`?k:D,j=(0,Q.useRef)(a);j.current=a;let M=(0,Q.useRef)(null),N=(0,Q.useRef)(``),ee=(0,Q.useRef)(``),te=(0,Q.useRef)(``),P=(0,Q.useRef)(``),F=(0,Q.useRef)(l);F.current=l;let I=(0,Q.useRef)(null),L=(0,Q.useCallback)(()=>{c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),v(`none`),x(void 0),O(void 0)},[c]),ne=(0,Q.useCallback)(async(e,t=!1)=>{M.current=e;let n=await ew(e,S,s,t);if(M.current===e){if(n.length===0){c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),v(`none`),x(void 0);return}c(e=>({commandArgumentHint:void 0,suggestions:n,selectedSuggestion:cw(e.suggestions,e.selectedSuggestion,n)})),v(n.length>0?`file`:`none`),x(void 0)}},[S,c,v,x,s]);(0,Q.useEffect)(()=>(Kh(),Wh(()=>{let e=M.current;e!==null&&(M.current=null,ne(e,e===``))})),[ne]);let re=ou(ne,50),ie=ou((0,Q.useCallback)(async e=>{P.current=e;let t=await JC(C.getState().mcp.clients,e);P.current===e&&(c(e=>({commandArgumentHint:void 0,suggestions:t,selectedSuggestion:cw(e.suggestions,e.selectedSuggestion,t)})),v(t.length>0?`slack-channel`:`none`),x(void 0))},[c]),150),ae=(0,Q.useCallback)(async(t,n)=>{let r=n??j.current;if(f){re.cancel(),L();return}if(o===`prompt`){let n=fC(t,r);if(n&&pC(n.partialCommand,e)){c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),v(`none`),x(void 0);return}}if(o===`bash`&&t.trim()){te.current=t;let e=await kC(t);if(te.current!==t)return;if(e){O({text:e.suffix,fullCommand:e.fullCommand,insertPosition:t.length}),c(()=>({commandArgumentHint:void 0,suggestions:[],selectedSuggestion:-1})),v(`none`),x(void 0);return}else O(void 0)}let i=o===`bash`?null:t.substring(0,r).match(/(^|\s)@([\w-]*)$/);if(i){let e=(i[2]??``).toLowerCase(),t=C.getState(),n=[],r=new Set;for(let[i,a]of t.agentNameRegistry){if(r.has(i)||!i.toLowerCase().startsWith(e))continue;let o=t.tasks[a]?.status;n.push({id:`dm-${i}`,displayText:`@${i}`,description:o?`send message · ${o}`:`send message`})}if(n.length>0){re.cancel(),c(e=>({commandArgumentHint:void 0,suggestions:n,selectedSuggestion:cw(e.suggestions,e.selectedSuggestion,n)})),v(`agent`),x(void 0);return}}if(o===`prompt`){let e=t.substring(0,r).match(ow);if(e&&UC(C.getState().mcp.clients)){ie(e[2]);return}else _===`slack-channel`&&(ie.cancel(),L())}let a=t.substring(0,r).match(aw),s=r===t.length&&r>0&&t.length>0&&t[r-1]===` `;if(o===`prompt`&&mC(t)&&r>0){let e=yw(t);if(e&&e.commandName===`add-dir`&&e.args){let{args:t}=e;if(t.match(/\s+$/)){re.cancel(),L();return}let n=await kh(t);if(n.length>0){c(e=>({suggestions:n,selectedSuggestion:cw(e.suggestions,e.selectedSuggestion,n),commandArgumentHint:void 0})),v(`directory`);return}re.cancel(),L();return}if(e&&e.commandName===`resume`&&e.args!==void 0&&t.includes(` `)){let{args:t}=e,n=(await Ja(t,{limit:10})).map(e=>{let t=Xa(e);return{id:`resume-title-${t}`,displayText:e.customTitle,description:zf(e),metadata:{sessionId:t}}});if(n.length>0){c(e=>({suggestions:n,selectedSuggestion:cw(e.suggestions,e.selectedSuggestion,n),commandArgumentHint:void 0})),v(`custom-title`);return}L();return}}let l=t.substring(0,r);if(o===`prompt`&&mC(l)&&r>0&&!bw(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=dl(e);return t&&t===r});if(o||i){if(o?.argumentHint&&a)t=o.argumentHint;else if(o?.type===`prompt`&&o.argNames?.length&&l.endsWith(` `)){let e=Xc(l.slice(n+1));t=al(o.argNames,e)}c(()=>({commandArgumentHint:t,suggestions:[],selectedSuggestion:-1})),v(`none`),x(void 0);return}}}let n=bC(l,e);c(()=>({commandArgumentHint:t,suggestions:n,selectedSuggestion:n.length>0?0:-1})),v(n.length>0?`command`:`none`),n.length>0&&x(y);return}if(_===`command`?(re.cancel(),L()):mC(l)&&bw(s,l)&&c(e=>e.commandArgumentHint?{...e,commandArgumentHint:void 0}:e),_===`custom-title`&&L(),_===`agent`&&F.current.some(e=>e.id?.startsWith(`dm-`))&&(t.substring(0,r).match(/(^|\s)@([\w-]*)$/)||L()),a&&o!==`bash`){let e=vw(t,r,!0);if(e?.token.startsWith(`@`)){let t=uw(e);if(Eh(t)){ee.current=t;let e=await Dh(t,{maxResults:10});if(ee.current!==t)return;if(e.length>0){c(t=>({suggestions:e,selectedSuggestion:cw(t.suggestions,t.selectedSuggestion,e),commandArgumentHint:void 0})),v(`directory`);return}}if(M.current===t)return;re(t,!0);return}}if(_===`file`){let e=vw(t,r,!0);if(e){let t=uw(e);if(M.current===t)return;re(t,!1)}else re.cancel(),L()}if(_===`shell`){let e=F.current[0]?.metadata?.inputSnapshot;(o!==`bash`||t!==e)&&(re.cancel(),L())}},[_,e,c,L,re,ie,o,f,y]);(0,Q.useEffect)(()=>{I.current!==i&&(N.current!==i&&(N.current=i,M.current=null),I.current=null,ae(i))},[i,ae]);let oe=(0,Q.useCallback)(async()=>{if(A){if(o===`bash`){t(A.fullCommand),r(A.fullCommand.length),O(void 0);return}let e=fC(i,a);if(e){let n=i.slice(0,e.startPos),a=i.slice(e.startPos+e.token.length),o=`${n}/${A.fullCommand} ${a}`,s=e.startPos+1+A.fullCommand.length+1;t(o),r(s);return}}if(l.length>0){re.cancel(),ie.cancel();let e=u===-1?0:u,n=l[e];if(_===`command`&&e<l.length){if(n){let e=n.metadata;if(e&&typeof e==`object`&&`name`in e&&`type`in e){let n=`/${dl(e)} `;t(n+i.slice(a)),r(n.length)}L()}}else if(_===`custom-title`&&l.length>0){if(n){let e=lw(n);t(e),r(e.length),L()}}else if(_===`directory`&&l.length>0){let n=l[e];if(n){let e=mC(i),o;if(e){let e=i.indexOf(` `),a=i.slice(0,e+1),s=sw(n.metadata)&&n.metadata.type===`directory`?`/`:` `;o=a+n.id+s,t(o),r(o.length),sw(n.metadata)&&n.metadata.type===`directory`?(c(e=>({...e,commandArgumentHint:void 0})),ae(o,o.length)):L()}else{let e=vw(i,a,!0)??vw(i,a,!1);if(e){let a=sw(n.metadata)&&n.metadata.type===`directory`,s=_w(i,n.id,e.startPos,e.token.length,a);o=s.newInput,t(o),r(s.cursorPos),a?(c(e=>({...e,commandArgumentHint:void 0})),ae(o,s.cursorPos)):L()}else L()}}}else if(_===`shell`&&l.length>0){let n=l[e];if(n){let e=n.metadata;fw(n,i,a,t,r,e?.completionType),L()}}else if(_===`agent`&&l.length>0&&l[e]?.id?.startsWith(`dm-`)){let n=l[e];n&&(mw(n,i,a,pw,t,r),L())}else if(_===`slack-channel`&&l.length>0){let n=l[e];n&&(mw(n,i,a,ow,t,r),L())}else if(_===`file`&&l.length>0){let n=vw(i,a,!0);if(!n){L();return}let s=Gh(l),c=n.token.startsWith(`@`),u;if(u=n.isQuoted?n.token.slice(2).replace(/"$/,``).length:c?n.token.length-1:n.token.length,s.length>u){let e=dw({displayText:s,mode:o,hasAtPrefix:c,needsQuotes:!1,isQuoted:n.isQuoted,isComplete:!1});qh(e,i,n.token,n.startPos,t,r),ae(i.replace(n.token,e),a)}else if(e<l.length){let a=l[e];if(a){let e=a.displayText.includes(` `);qh(dw({displayText:a.displayText,mode:o,hasAtPrefix:c,needsQuotes:e,isQuoted:n.isQuoted,isComplete:!0}),i,n.token,n.startPos,t,r),L()}}}}else if(i.trim()!==``){let e,n;if(o===`bash`){e=`shell`;let o=await gw(i,a);if(o.length===1){let e=o[0];if(e){let n=e.metadata;fw(e,i,a,t,r,n?.completionType)}n=[]}else n=o}else{e=`file`;let t=vw(i,a,!0);if(t){let e=t.token.startsWith(`@`);n=await ew(e?t.token.substring(1):t.token,S,s,e)}else n=[]}n.length>0&&(c(e=>({commandArgumentHint:void 0,suggestions:n,selectedSuggestion:cw(e.suggestions,e.selectedSuggestion,n)})),v(e),x(void 0))}},[l,u,i,_,e,o,t,r,n,L,a,ae,S,c,s,re,ie,A]),se=(0,Q.useCallback)(()=>{if(u<0||l.length===0)return;let s=l[u];if(_===`command`&&u<l.length)s&&(xC(s,!0,e,t,r,n),re.cancel(),L());else if(_===`custom-title`&&u<l.length){if(s){let e=lw(s);t(e),r(e.length),n(e,!0),re.cancel(),L()}}else if(_===`shell`&&u<l.length){let e=l[u];if(e){let n=e.metadata;fw(e,i,a,t,r,n?.completionType),re.cancel(),L()}}else if(_===`agent`&&u<l.length&&s?.id?.startsWith(`dm-`))mw(s,i,a,pw,t,r),re.cancel(),L();else if(_===`slack-channel`&&u<l.length)s&&(mw(s,i,a,ow,t,r),ie.cancel(),L());else if(_===`file`&&u<l.length){let e=vw(i,a,!0);if(e&&s){let n=e.token.startsWith(`@`),a=s.displayText.includes(` `);qh(dw({displayText:s.displayText,mode:o,hasAtPrefix:n,needsQuotes:a,isQuoted:e.isQuoted,isComplete:!0}),i,e.token,e.startPos,t,r),re.cancel(),L()}}else if(_===`directory`&&u<l.length&&s){if(mC(i)){re.cancel(),L();return}let e=vw(i,a,!0)??vw(i,a,!1);if(e){let n=sw(s.metadata)&&s.metadata.type===`directory`,a=_w(i,s.id,e.startPos,e.token.length,n);t(a.newInput),r(a.cursorPos)}re.cancel(),L()}},[l,u,_,e,i,a,o,t,r,n,L,re,ie]),ce=(0,Q.useCallback)(()=>{oe()},[oe]),le=(0,Q.useCallback)(()=>{re.cancel(),ie.cancel(),L(),I.current=i},[re,ie,L,i]),R=(0,Q.useCallback)(()=>{c(e=>({...e,selectedSuggestion:e.selectedSuggestion<=0?l.length-1:e.selectedSuggestion-1}))},[l.length,c]),ue=(0,Q.useCallback)(()=>{c(e=>({...e,selectedSuggestion:e.selectedSuggestion>=l.length-1?0:e.selectedSuggestion+1}))},[l.length,c]),de=(0,Q.useMemo)(()=>({"autocomplete:accept":ce,"autocomplete:dismiss":le,"autocomplete:previous":R,"autocomplete:next":ue}),[ce,le,R,ue]),fe=l.length>0||!!A,z=Ks();qi(`autocomplete`,fe),Pl(`Autocomplete`,fe),Sl(de,{context:`Autocomplete`,isActive:fe&&!z});function pe(e){let n=Rr(e);if(n!==`prompt`&&m){m(n);let i=Ze(e);t(i),r(i.length)}else t(e),r(e.length)}let me=e=>{if(e.key===`right`&&!T){let t=w.text,n=w.shownAt;if(t&&n>0&&i===``){p(),pe(t),e.stopImmediatePropagation();return}}if(e.key===`tab`&&!e.shift){if(l.length>0||A)return;let t=w.text,n=w.shownAt;if(t&&n>0&&i===``&&!T){e.preventDefault(),p(),pe(t);return}i.trim()===``&&(e.preventDefault(),h({key:`thinking-toggle-hint`,jsx:(0,$.jsxs)(K,{dimColor:!0,children:[`Use `,g,` to toggle thinking`]}),priority:`immediate`,timeoutMs:3e3}));return}if(l.length===0)return;let t=E?.pendingChord!=null;if(e.ctrl&&e.key===`n`&&!t){e.preventDefault(),ue();return}if(e.ctrl&&e.key===`p`&&!t){e.preventDefault(),R();return}e.key===`return`&&!e.shift&&!e.meta&&(e.preventDefault(),se())};return ql((e,t,n)=>{let r=new jl(n.keypress);me(r),r.didStopImmediatePropagation()&&n.stopImmediatePropagation()}),{suggestions:l,selectedSuggestion:u,suggestionType:_,maxColumnWidth:b,commandArgumentHint:d,inlineGhostText:A,handleKeyDown:me}}Zh();var Sw={"†":`alt+t`,π:`alt+p`,ø:`alt+o`};function Cw(e){return e in Sw}ra();function ww(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 Tw(e){let t=ww(e);return{nextMode:t,context:T(e.mode,t,e)}}mh();var Ew=Pg();Ru(),ss(),q(),vc(),U(),af();function Dw({onDone:e}){qi(`bridge-dialog`);let t=W(e=>e.replBridgeConnected),n=W(e=>e.replBridgeSessionActive),r=W(e=>e.replBridgeReconnecting),i=W(e=>e.replBridgeConnectUrl),a=W(e=>e.replBridgeSessionUrl),o=W(e=>e.replBridgeError),s=W(e=>e.replBridgeExplicit),c=W(e=>e.replBridgeEnvironmentId),l=W(e=>e.replBridgeSessionId),u=W(e=>e.verbose),d=y(),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(``),v=e_(bu());(0,Q.useEffect)(()=>{uf().then(_).catch(()=>{})},[]);let b=n?a:i;(0,Q.useEffect)(()=>{if(!f||!b){h(``);return}(0,Ew.toString)(b,{type:`terminal`,errorCorrectionLevel:`L`,small:!0}).then(h).catch(()=>h(``))},[f,b]),Sl({"confirm:yes":e,"confirm:toggle":()=>{p(e=>!e)}},{context:`Confirmation`}),ql(t=>{t===`d`&&(s&&sf(e=>e.remoteControlAtStartup===!1?e:{...e,remoteControlAtStartup:!1}),d(e=>e.replBridgeEnabled?{...e,replBridgeEnabled:!1}:e),e())});let{label:x,color:S}=uh({error:o,connected:t,sessionActive:n,reconnecting:r}),C=o?`×`:wd,w=m?m.split(`
39
+ `).filter(e=>e.length>0):[],T=[];v&&T.push(v),g&&T.push(g);let E=T.length>0?` \u00b7 ${T.join(` · `)}`:``,D=o?ph:b?n?fh(b):dh(b):void 0;return(0,$.jsx)(au,{title:`Remote Control`,onCancel:e,hideInputGuide:!0,children:(0,$.jsxs)(G,{flexDirection:`column`,gap:1,children:[(0,$.jsxs)(G,{flexDirection:`column`,children:[(0,$.jsxs)(K,{children:[(0,$.jsxs)(K,{color:S,children:[C,` `,x]}),(0,$.jsx)(K,{dimColor:!0,children:E})]}),o&&(0,$.jsx)(K,{color:`error`,children:o}),u&&c&&(0,$.jsxs)(K,{dimColor:!0,children:[`Environment: `,c]}),u&&l&&(0,$.jsxs)(K,{dimColor:!0,children:[`Session: `,l]})]}),f&&w.length>0&&(0,$.jsx)(G,{flexDirection:`column`,children:w.map((e,t)=>(0,$.jsx)(K,{children:e},t))}),D&&(0,$.jsx)(K,{dimColor:!0,children:D}),(0,$.jsx)(K,{dimColor:!0,children:`d to disconnect · space for QR code · Enter/Esc to close`})]})})}q(),ss(),$a(),q(),rd(),Ph(),Hf(),dn(),ss(),je(),$a(),q(),Hf(),Jh(),ss(),Hh(),$a(),q(),rd(),Ph(),Hf(),Li(),q(),vc(),Cn(),Fi();function Ow({currentValue:e,onSelect:t,onCancel:n,isMidConversation:r}){let i=ch(),[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`}];Ml(`confirm:no`,()=>{a===null?n?.():o(null)},{context:`Confirmation`}),Ml(`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)(iu,{color:`permission`,children:[(0,$.jsxs)(G,{flexDirection:`column`,children:[(0,$.jsxs)(G,{marginBottom:1,flexDirection:`column`,children:[(0,$.jsx)(K,{color:`remember`,bold:!0,children:`Toggle thinking mode`}),(0,$.jsx)(K,{dimColor:!0,children:`Enable or disable thinking for this session.`})]}),a===null?(0,$.jsx)(G,{flexDirection:`column`,marginBottom:1,children:(0,$.jsx)(Hn,{defaultValue:e?`true`:`false`,defaultFocusValue:e?`true`:`false`,options:s,onChange:c,onCancel:n??(()=>{}),visibleOptionCount:2})}):(0,$.jsxs)(G,{flexDirection:`column`,marginBottom:1,gap:1,children:[(0,$.jsx)(K,{color:`warning`,children:`Changing thinking mode mid-conversation will increase latency and may reduce quality. For best results, set this at the start of a session.`}),(0,$.jsx)(K,{color:`warning`,children:`Do you want to proceed?`})]})]}),(0,$.jsx)(K,{dimColor:!0,italic:!0,children:i.pending?(0,$.jsxs)($.Fragment,{children:[`Press `,i.keyName,` again to exit`]}):a===null?(0,$.jsxs)(kl,{children:[(0,$.jsx)(yl,{shortcut:`Enter`,action:`confirm`}),(0,$.jsx)(ye,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`exit`})]}):(0,$.jsxs)(kl,{children:[(0,$.jsx)(yl,{shortcut:`Enter`,action:`confirm`}),(0,$.jsx)(ye,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})]})}ct(),Im(),ta(),zg(),Lg();function kw(e,t,n){let r=t;for(let t=0;t<n;t++){let t=Aw(e,r);if(t.equals(r))break;r=t}return r}function Aw(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 jw(e){return`eE$`.includes(e)}function Mw(e){return`jkG`.includes(e)||e===`gg`}var Nw={"(":[`(`,`)`],")":[`(`,`)`],b:[`(`,`)`],"[":[`[`,`]`],"]":[`[`,`]`],"{":[`{`,`}`],"}":[`{`,`}`],B:[`{`,`}`],"<":[`<`,`>`],">":[`<`,`>`],'"':[`"`,`"`],"'":[`'`,`'`],"`":["`","`"]};function Pw(e,t,n,r){if(n===`w`)return Fw(e,t,r,ar);if(n===`W`)return Fw(e,t,r,e=>!Gc(e));let i=Nw[n];if(i){let[n,a]=i;return n===a?Iw(e,t,n,r):Lw(e,t,n,a,r)}return null}function Fw(e,t,n,r){let i=[];for(let{segment:t,index:n}of Nf().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=>Gc(o(e)),l=e=>r(o(e)),u=e=>oa(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 Iw(e,t,n,r){let i=e.lastIndexOf(`
40
+ `,t-1)+1,a=e.indexOf(`
41
+ `,t),o=a===-1?e.length:a,s=e.slice(i,o),c=t-i,l=[];for(let e=0;e<s.length;e++)s[e]===n&&l.push(e);for(let e=0;e<l.length-1;e+=2){let t=l[e],n=l[e+1];if(t<=c&&c<=n)return r?{start:i+t+1,end:i+n}:{start:i+t,end:i+n+1}}return null}function Lw(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}}el(),Pf(),Jf();function Rw(e,t,n,r){let i=kw(t,r.cursor,n);if(i.equals(r.cursor))return;let a=Xw(r.cursor,i,t,e,n);Qw(e,a.from,a.to,r,a.linewise),r.recordChange({type:`operator`,op:e,motion:t,count:n})}function zw(e,t,n,r,i){let a=i.cursor.findCharacter(n,t,r);if(a===null)return;let o=new Ri(i.cursor.measuredText,a),s=Zw(i.cursor,o,t);Qw(e,s.from,s.to,i),i.setLastFind(t,n),i.recordChange({type:`operatorFind`,op:e,find:t,char:n,count:r})}function Bw(e,t,n,r,i){let a=Pw(i.text,i.cursor.offset,n,t===`inner`);a&&(Qw(e,a.start,a.end,i),i.recordChange({type:`operatorTextObj`,op:e,objType:n,scope:t,count:r}))}function Vw(e,t,n){let r=n.text,i=r.split(`
42
+ `),a=Yf(r.slice(0,n.cursor.offset),`
43
+ `),o=Math.min(t,i.length-a),s=n.cursor.startOfLogicalLine().offset,c=s;for(let e=0;e<o;e++){let e=r.indexOf(`
44
+ `,c);c=e===-1?r.length:e+1}let l=r.slice(s,c);if(l.endsWith(`
45
+ `)||(l=`${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]===`
46
+ `&&--e;let i=r.slice(0,e)+r.slice(t);n.setText(i||``);let a=Math.max(0,i.length-(Ff(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(`
47
+ `);n.setText(r),n.enterInsert(s)}n.recordChange({type:`operator`,op:e,motion:e[0],count:t})}function Hw(e,t){let n=t.cursor.offset;if(n>=t.text.length)return;let r=t.cursor;for(let t=0;t<e&&!r.isAtEnd();t++)r=r.right();let i=r.offset,a=t.text.slice(n,i),o=t.text.slice(0,n)+t.text.slice(i);t.setRegister(a,!1),t.setText(o);let s=Math.max(0,o.length-(Ff(o).length||1));t.setOffset(Math.min(n,s)),t.recordChange({type:`x`,count:e})}function Uw(e,t,n){let r=n.cursor.offset,i=n.text;for(let n=0;n<t&&r<i.length;n++){let t=If(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 Ww(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=If(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 Gw(e,t){let n=t.text.split(`
48
+ `),{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(`
49
+ `);t.setText(c),t.setOffset(Yw(s,r)+o),t.recordChange({type:`join`,count:e})}function Kw(e,t,n){let r=n.getRegister();if(!r)return;let i=r.endsWith(`
50
+ `),a=i?r.slice(0,-1):r;if(i){let r=n.text.split(`
51
+ `),{line:i}=n.cursor.getPosition(),o=e?i+1:i,s=a.split(`
52
+ `),c=[];for(let e=0;e<t;e++)c.push(...s);let l=[...r.slice(0,o),...c,...r.slice(o)],u=l.join(`
53
+ `);n.setText(u),n.setOffset(Yw(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=Ff(r),c=i+r.length-(s.length||1);n.setText(o),n.setOffset(Math.max(i,c))}}function qw(e,t,n){let r=n.text.split(`
54
+ `),{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(`
55
+ `),s=((r[i]??``).match(/^\s*/)?.[0]??``).length;n.setText(o),n.setOffset(Yw(r,i)+s),n.recordChange({type:`indent`,dir:e,count:t})}function Jw(e,t){let n=t.text.split(`
56
+ `),{line:r}=t.cursor.getPosition(),i=e===`below`?r+1:r,a=[...n.slice(0,i),``,...n.slice(i)],o=a.join(`
57
+ `);t.setText(o),t.enterInsert(Yw(a,i)),t.recordChange({type:`openLine`,direction:e})}function Yw(e,t){return e.slice(0,t).join(`
58
+ `).length+ +(t>0)}function Xw(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(Mw(n)){s=!0;let t=e.text,n=t.indexOf(`
59
+ `,o);n===-1?(o=t.length,a>0&&t[a-1]===`
60
+ `&&--a):o=n+1}else jw(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 Zw(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 Qw(e,t,n,r,i=!1){let a=r.text.slice(t,n);if(i&&!a.endsWith(`
61
+ `)&&(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-(Ff(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 $w(e,t,n){let r=t===1?n.cursor.startOfLastLine():n.cursor.goToLine(t);if(r.equals(n.cursor))return;let i=Xw(n.cursor,r,`G`,e,t);Qw(e,i.from,i.to,n,i.linewise),n.recordChange({type:`operator`,op:e,motion:`G`,count:t})}function eT(e,t,n){let r=t===1?n.cursor.startOfFirstLine():n.cursor.goToLine(t);if(r.equals(n.cursor))return;let i=Xw(n.cursor,r,`gg`,e,t);Qw(e,i.from,i.to,n,i.linewise),n.recordChange({type:`operator`,op:e,motion:`gg`,count:t})}var tT={d:`delete`,c:`change`,y:`yank`};function nT(e){return e in tT}var rT=new Set([`h`,`l`,`j`,`k`,`w`,`b`,`e`,`W`,`B`,`E`,`0`,`^`,`$`]),iT=new Set([`f`,`F`,`t`,`T`]),aT={i:`inner`,a:`around`};function oT(e){return e in aT}var sT=new Set([`w`,`W`,`"`,`'`,"`",`(`,`)`,`b`,`[`,`]`,`{`,`}`,`B`,`<`,`>`]),cT=1e4;function lT(){return{mode:`INSERT`,insertedText:``}}function uT(){return{lastChange:null,lastFind:null,register:``,registerIsLinewise:!1}}function dT(e,t,n){switch(e.type){case`idle`:return mT(t,n);case`count`:return hT(e,t,n);case`operator`:return gT(e,t,n);case`operatorCount`:return _T(e,t,n);case`operatorFind`:return vT(e,t,n);case`operatorTextObj`:return yT(e,t,n);case`find`:return bT(e,t,n);case`g`:return xT(e,t,n);case`operatorG`:return ST(e,t,n);case`replace`:return CT(e,t,n);case`indent`:return wT(e,t,n)}}function fT(e,t,n){return nT(e)?{next:{type:`operator`,op:tT[e],count:t}}:rT.has(e)?{execute:()=>{let r=kw(e,n.cursor,t);n.setOffset(r.offset)}}:iT.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:()=>Ww(t,n)}:e===`x`?{execute:()=>Hw(t,n)}:e===`J`?{execute:()=>Gw(t,n)}:e===`p`||e===`P`?{execute:()=>Kw(e===`p`,t,n)}:e===`D`?{execute:()=>Rw(`delete`,`$`,1,n)}:e===`C`?{execute:()=>Rw(`change`,`$`,1,n)}:e===`Y`?{execute:()=>Vw(`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:()=>TT(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:()=>Jw(`below`,n)}:e===`O`?{execute:()=>Jw(`above`,n)}:null}function pT(e,t,n,r){return oT(n)?{next:{type:`operatorTextObj`,op:e,count:t,scope:aT[n]}}:iT.has(n)?{next:{type:`operatorFind`,op:e,count:t,find:n}}:rT.has(n)?{execute:()=>Rw(e,n,t,r)}:n===`G`?{execute:()=>$w(e,t,r)}:n===`g`?{next:{type:`operatorG`,op:e,count:t}}:null}function mT(e,t){return/[1-9]/.test(e)?{next:{type:`count`,digits:e}}:e===`0`?{execute:()=>t.setOffset(t.cursor.startOfLogicalLine().offset)}:fT(e,1,t)||{}}function hT(e,t,n){if(/[0-9]/.test(t)){let n=e.digits+t;return{next:{type:`count`,digits:String(Math.min(parseInt(n,10),cT))}}}return fT(t,parseInt(e.digits,10),n)||{next:{type:`idle`}}}function gT(e,t,n){return t===e.op[0]?{execute:()=>Vw(e.op,e.count,n)}:/[0-9]/.test(t)?{next:{type:`operatorCount`,op:e.op,count:e.count,digits:t}}:pT(e.op,e.count,t,n)||{next:{type:`idle`}}}function _T(e,t,n){if(/[0-9]/.test(t)){let n=e.digits+t,r=Math.min(parseInt(n,10),cT);return{next:{...e,digits:String(r)}}}let r=parseInt(e.digits,10),i=e.count*r;return pT(e.op,i,t,n)||{next:{type:`idle`}}}function vT(e,t,n){return{execute:()=>zw(e.op,e.find,t,e.count,n)}}function yT(e,t,n){return sT.has(t)?{execute:()=>Bw(e.op,e.scope,t,e.count,n)}:{next:{type:`idle`}}}function bT(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 xT(e,t,n){return t===`j`||t===`k`?{execute:()=>{let r=kw(`g${t}`,n.cursor,e.count);n.setOffset(r.offset)}}:t===`g`?e.count>1?{execute:()=>{let t=n.text.split(`
62
+ `),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 ST(e,t,n){return t===`j`||t===`k`?{execute:()=>Rw(e.op,`g${t}`,e.count,n)}:t===`g`?{execute:()=>eT(e.op,e.count,n)}:{next:{type:`idle`}}}function CT(e,t,n){return t===``?{next:{type:`idle`}}:{execute:()=>Uw(t,e.count,n)}}function wT(e,t,n){return t===e.dir?{execute:()=>qw(e.dir,e.count,n)}:{next:{type:`idle`}}}function TT(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)}el(),Pf();function ET(e){let t=Q.useRef(lT()),[n,r]=(0,Q.useState)(`INSERT`),i=Q.useRef(uT()),a=fo({...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]!==`
63
+ `&&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=Ri.fromText(e.value,e.columns,a.offset),r=u(n,!0);switch(t.type){case`insert`:if(t.text){let r=n.insert(t.text);e.onChange(r.text),a.setOffset(r.offset)}break;case`x`:Hw(t.count,r);break;case`replace`:Uw(t.char,t.count,r);break;case`toggleCase`:Ww(t.count,r);break;case`indent`:qw(t.dir,t.count,r);break;case`join`:Gw(t.count,r);break;case`openLine`:Jw(t.direction,r);break;case`operator`:Rw(t.op,t.motion,t.count,r);break;case`operatorFind`:zw(t.op,t.find,t.char,t.count,r);break;case`operatorTextObj`:Bw(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=Ri.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,-(Ff(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=dT(i.command,h,p);g.execute&&g.execute(),t.current.mode===`NORMAL`&&(g.next?t.current={mode:`NORMAL`,command:g.next}:g.execute&&(t.current={mode:`NORMAL`,command:{type:`idle`}})),c===`?`&&i.mode===`NORMAL`&&i.command.type===`idle`&&e.onChange(`?`)}let p=(0,Q.useCallback)(e=>{e===`INSERT`?t.current={mode:`INSERT`,insertedText:``}:t.current={mode:`NORMAL`,command:{type:`idle`}},r(e),o?.(e)},[o]);return{...a,onInput:f,mode:n,setMode:p}}Kl(),q();function DT(e){let[t]=Cl(),n=Nl();Nt(n,!!e.onImagePaste);let r=ET({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?Ul.inverse:e=>e,themeText:Yl(`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)(Sc,{inputState:r,terminalFocus:n,highlights:e.highlights,...e})})}sr(),yg(),o();function OT(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 kT(e){return`${e.input_tokens}|${e.cache_creation_input_tokens}|${e.cache_read_input_tokens}`}function AT(e){let t=c_(`sha256`).update(e).digest(`hex`).slice(0,16);return s_(i(),`cache-stats`,`${t}.json`)}var jT={version:1,signature:null,lastResetAt:null,lastHitRate:null};function MT(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 NT(e){try{let t=await __(e,`utf8`),n=JSON.parse(t);return MT(n)?n:{...jT}}catch{return{...jT}}}async function PT(e,t){await g_(o_(e),{recursive:!0});let n=`${e}.${process.pid}.tmp`;try{await y_(n,JSON.stringify(t),`utf8`),await v_(n,e)}catch{}}var FT={signature:null,lastResetAt:null,lastHitRate:null},IT=null;async function LT(e){IT=e;let t=await NT(AT(e));FT={signature:t.signature,lastResetAt:t.lastResetAt,lastHitRate:t.lastHitRate}}function RT(e){let t=kT(e),n=OT(e);return t!==FT.signature&&(FT={signature:t,lastResetAt:Date.now(),lastHitRate:n},IT!==null&&PT(AT(IT),{version:1,signature:t,lastResetAt:FT.lastResetAt,lastHitRate:n})),{...FT}}function zT(){return{...FT}}q(),Hf(),$a();function BT(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 VT(){return(0,$.jsx)(K,{dimColor:!0,children:` │ `})}function HT({modelName:e,contextUsedPct:t,usedTokens:n,contextWindowSize:r,totalCostUsd:i,rateLimits:a}){let{columns:o}=Ql(),[s,c]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{if(!((a.five_hour?.resets_at??0)||(a.seven_day?.resets_at??0)))return;let e=setInterval(()=>c(e=>e+1),6e4);return()=>clearInterval(e)},[a.five_hour?.resets_at,a.seven_day?.resets_at]);let l=e.split(` `),u=l.length>=2?`${l[0]} ${l[1]}`:e,d=o<60,f=a.five_hour!=null,p=a.seven_day!=null,m=f?Math.round(a.five_hour.utilization*100):0,h=p?Math.round(a.seven_day.utilization*100):0,g=`${Rf(n)}/${Rf(r)}`;return(0,$.jsxs)(G,{children:[(0,$.jsx)(K,{children:u}),(0,$.jsx)(VT,{}),(0,$.jsx)(K,{dimColor:!0,children:`Context `}),(0,$.jsxs)(K,{children:[t,`%`]}),!d&&(0,$.jsxs)(K,{dimColor:!0,children:[` (`,g,`)`]}),f&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(VT,{}),(0,$.jsx)(K,{dimColor:!0,children:`Session `}),(0,$.jsxs)(K,{children:[m,`%`]}),!d&&a.five_hour.resets_at>0&&(0,$.jsxs)(K,{dimColor:!0,children:[` `,BT(a.five_hour.resets_at)]})]}),p&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(VT,{}),(0,$.jsx)(K,{dimColor:!0,children:`Weekly `}),(0,$.jsxs)(K,{children:[h,`%`]}),!d&&a.seven_day.resets_at>0&&(0,$.jsxs)(K,{dimColor:!0,children:[` `,BT(a.seven_day.resets_at)]})]}),i>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(VT,{}),(0,$.jsx)(K,{children:P(i)})]})]})}var UT=Q.memo(HT);Mf(),U(),Ru(),Si(),hn(),Vh(),Is(),q(),Yt(),af(),Qf(),rd(),gd(),mo(),Bt(),_p(),da(),xe(),Hf();var WT=3600*1e3;function GT(e){return String(Math.floor(e)).padStart(2,`0`)}function KT(e){if(e<=0)return`exp`;let t=Math.floor(e/6e4),n=Math.floor(e%6e4/1e3);return`${GT(t)}:${GT(n)}`}function qT({messages:e}){let[t,n]=(0,Q.useState)(()=>Date.now()),[r,i]=(0,Q.useState)(!0),a=yr(e),o=(0,Q.useRef)(null);if(a!==null){let e=kT(a);e!==o.current&&(o.current=e,RT(a))}let{lastResetAt:s,lastHitRate:c}=zT(),l=s===null?null:t-s,u=l===null?null:WT-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,LT(Wu()))},[]);let h=a===null?c:OT(a);if(h===null&&s===null)return(0,$.jsx)(K,{dimColor:!0,children:` Cache --% --:--`});let g=u===null?`--:--`:KT(u),_=h===null?`--%`:`${h}%`,v;return v=f||d===null?`inactive`:d<20?`success`:d<40?`warning`:`error`,(0,$.jsxs)(K,{children:[(0,$.jsx)(K,{dimColor:!0,children:` Cache `}),(0,$.jsx)(K,{color:h!==null&&h>=50?`success`:`inactive`,children:_}),(0,$.jsxs)(K,{color:v,dimColor:p&&!r,children:[` `,g]})]})}function JT(){return null}function YT(e){return e?.statusLineEnabled===!1?!1:e?.statusLineEnabled===!0||!!e?.statusLine?.command}function XT(e,t,n,r,i,a,o){let s=Au(),c=ol(),l=Dp({permissionMode:e,mainLoopModel:a,exceeds200kTokens:t}),u=n?.outputStyle||`default`,d=yr(r),f=ep(l,ed()),p=ap(d,f),m=Zs(Wu()),h=_t(),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{...rn(),...m&&{session_name:m},model:{id:l,display_name:lp(l)},workspace:{current_dir:id(),project_dir:bu(),added_dirs:i},version:`0.0.20`,output_style:{name:u},cost:{total_cost_usd:Iu(),total_duration_ms:Ou(),total_api_duration_ms:td(),total_lines_added:Mu(),total_lines_removed:qu()},context_window:{total_input_tokens:Eu(),total_output_tokens:Cu(),context_window_size:f,current_usage:d,used_percentage:p.used,remaining_percentage:p.remaining},exceeds_200k_tokens:t,...(g.five_hour||g.seven_day)&&{rate_limits:g},...gg()&&{vim:{mode:o??`INSERT`}},...s&&{agent:{name:s}},...nd()&&{remote:{session_id:Wu()}},...c&&{worktree:{name:c.worktreeName,path:c.worktreePath,branch:c.worktreeBranch,original_cwd:c.originalCwd,original_branch:c.originalBranch}}}}function ZT(e){return vn(e)?.uuid??null}function QT({messagesRef:e,lastAssistantMessageId:t,vimMode:n}){let r=(0,Q.useRef)(void 0),i=W(e=>e.toolPermissionContext.mode),a=W(e=>e.toolPermissionContext.additionalWorkingDirectories),o=W(e=>e.statusLineText),s=y(),c=Et(),{addNotification:l}=li(),u=Bh(),d=(0,Q.useRef)(c);d.current=c;let f=(0,Q.useRef)(n);f.current=n;let p=(0,Q.useRef)(i);p.current=i;let m=(0,Q.useRef)(a);m.current=a;let h=(0,Q.useRef)(u);h.current=u;let g=(0,Q.useRef)({messageId:null,exceeds200kTokens:!1,permissionMode:i,vimMode:n,mainLoopModel:u}),_=(0,Q.useRef)(void 0),v=(0,Q.useRef)(!0),b=(0,Q.useCallback)(async()=>{r.current?.abort();let t=new AbortController;r.current=t;let n=e.current,i=v.current;if(v.current=!1,d.current?.statusLine?.command)try{let e=g.current.exceeds200kTokens,r=ZT(n);r!==g.current.messageId&&(e=de(n),g.current.messageId=r,g.current.exceeds200kTokens=e);let a=await hi(XT(p.current,e,d.current,n,Array.from(m.current.keys()),h.current,f.current),t.signal,void 0,i);t.signal.aborted||s(e=>e.statusLineText===a?e:{...e,statusLineText:a})}catch{}},[e,s]),x=(0,Q.useCallback)(()=>{_.current!==void 0&&clearTimeout(_.current),_.current=setTimeout((e,t)=>{e.current=void 0,t()},300,_,b)},[b]);(0,Q.useEffect)(()=>{(t!==g.current.messageId||i!==g.current.permissionMode||n!==g.current.vimMode||u!==g.current.mainLoopModel)&&(g.current.permissionMode=i,g.current.vimMode=n,g.current.mainLoopModel=u,x())},[t,i,n,u,x]);let S=c?.statusLine?.command,C=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>{if(C.current){C.current=!1;return}v.current=!0,b()},[S,b]),(0,Q.useEffect)(()=>{let e=c?.statusLine;e&&(X(`tengu_status_line_mount`,{command_length:e.command.length,padding:e.padding}),c.disableAllHooks===!0&&J(`Status line is configured but disableAllHooks is true`,{level:`warn`}),of()||(l({key:`statusline-trust-blocked`,text:`statusline skipped · restart to fix`,color:`warning`,priority:`low`}),J(`Status line command skipped: workspace trust not accepted`,{level:`warn`})))},[]),(0,Q.useEffect)(()=>(b(),()=>{r.current?.abort(),_.current!==void 0&&clearTimeout(_.current)}),[]);let w=c?.statusLine?.padding??0,T=Dp({permissionMode:i,mainLoopModel:u,exceeds200kTokens:g.current.exceeds200kTokens}),E=ep(T,ed()),D=yr(e.current),O=D?D.input_tokens+D.cache_creation_input_tokens+D.cache_read_input_tokens:0,k=D?Math.round(ap(D,E).used??0):0,A=_t(),j={...A.five_hour&&{five_hour:{utilization:A.five_hour.utilization,resets_at:A.five_hour.resets_at}},...A.seven_day&&{seven_day:{utilization:A.seven_day.utilization,resets_at:A.seven_day.resets_at}}},M=c?.statusLineEnabled===!0,N=!!c?.statusLine?.command;return(0,$.jsxs)(G,{flexDirection:`column`,paddingX:w,children:[M&&(0,$.jsxs)(G,{gap:2,children:[(0,$.jsx)(UT,{modelName:lp(T),contextUsedPct:k,usedTokens:O,contextWindowSize:E,totalCostUsd:Iu(),rateLimits:j}),(0,$.jsx)(JT,{}),(0,$.jsx)(qT,{messages:e.current})]}),o?(0,$.jsx)(K,{dimColor:!0,wrap:`truncate`,children:(0,$.jsx)(bl,{children:o})}):N&&Xr()?(0,$.jsx)(K,{children:` `}):null]})}var $T=(0,Q.memo)(QT);l(),U(),An(),q();function eE({tasksSelected:e,onOpenDialog:t}){let n=W(e=>e.tasks),r=(0,Q.useMemo)(()=>Object.values(n??{}).filter(e=>Ut(e)),[n]);return Ig(n??{},!1)||r.length===0?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(tE,{selected:e,onClick:t,children:cn(r)}),Me(r)&&(0,$.jsxs)(K,{dimColor:!0,children:[` · `,u.arrowDown,` to view`]})]})}function tE({selected:e,onClick:t,children:n}){let[r,i]=(0,Q.useState)(!1),a=(0,$.jsx)(K,{color:`background`,inverse:e||r,children:n});return t?(0,$.jsx)(G,{onClick:t,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:a}):a}q(),Ko();function nE({value:e,onChange:t,historyFailedMatch:n}){return(0,$.jsxs)(G,{gap:1,children:[(0,$.jsx)(K,{dimColor:!0,children:n?`no matching prompt:`:`search prompts:`}),(0,$.jsx)(ha,{value:e,onChange:t,cursorOffset:e.length,onChangeCursorOffset:()=>{},columns:xl(e)+1,focus:!0,showCursor:!0,multiline:!1,dimColor:!0})]})}mf(),pf(),bd();var rE=5e3;function iE(e,t){if(e)return`draft`;switch(t){case`APPROVED`:return`approved`;case`CHANGES_REQUESTED`:return`changes_requested`;default:return`pending`}}async function aE(){if(!await ff())return null;let[e,t]=await Promise.all([uf(),lf()]);if(e===t)return null;let{stdout:n,code:r}=await hf(`gh`,[`pr`,`view`,`--json`,`number,url,reviewDecision,isDraft,headRefName,state`],{timeout:rE,preserveOutputOnError:!1});if(r!==0||!n.trim())return null;try{let e=ud(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:iE(e.isDraft,e.reviewDecision)}}catch{return null}}Ru();var oE=6e4,sE=4e3,cE=60*6e4,lE={number:null,url:null,reviewState:null,lastUpdated:0};function uE(e,t=!0){let[n,r]=(0,Q.useState)(lE),i=(0,Q.useRef)(null),a=(0,Q.useRef)(!1),o=(0,Q.useRef)(0);return(0,Q.useEffect)(()=>{if(!t||a.current)return;let e=!1,n=-1,s=Date.now();async function c(){if(e)return;let t=Lu();if(n!==t)n=t,s=Date.now();else if(Date.now()-s>=cE)return;let l=Date.now(),u=await aE();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>sE){a.current=!0;return}e||(i.current=setTimeout(c,oE))}}let l=Date.now()-o.current;return l>=oE?c():i.current=setTimeout(c,oE-l),()=>{e=!0,i.current&&(clearTimeout(i.current),i.current=null)}},[e,t]),n}q(),l(),yg(),ba(),Yd(),ct(),jd(),zg(),U(),Ru(),$a(),Hf(),Er(),_p(),wm(),af(),kf(),L();var dE=()=>null,fE=5e3,pE=1e3;function mE(){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=Vf(e*1024*1024);t(e=>e?.text===r?e:{text:r,level:n})}e();let n=setInterval(e,fE);return()=>clearInterval(n)},[]),e}function hE(){let e=(0,Q.useSyncExternalStore)(sm,cm,dE),[t,n]=(0,Q.useState)(null);return(0,Q.useEffect)(()=>{if(e===null){n(null);return}function t(){let t=Math.max(0,Math.ceil((e-Date.now())/1e3));n(t)}t();let r=setInterval(t,1e3);return()=>clearInterval(r)},[e]),t===null?null:(0,$.jsxs)(K,{dimColor:!0,children:[`waiting `,Bf(t*1e3,{mostSignificantOnly:!0})]})}function gE(){let[t,n]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{let e=setInterval(()=>n(e=>e+1),pE);return()=>clearInterval(e)},[]);let r=(M(),e(xn)),i=r.getGoal();if(!i)return null;let a=r.getActiveElapsedMs(i),o=Math.floor(a/1e3),s=Math.floor(o/3600),c=Math.floor(o%3600/60),l=o%60,u;u=s>=1?`${s}h${c}min`:c>=1?`${c}min`:`${l}s`;let d;switch(i.status){case`active`:d=`ansi:green`;break;case`paused`:case`budget_limited`:case`usage_limited`:d=`ansi:yellow`;break;case`blocked`:d=`ansi:red`;break;case`complete`:d=`ansi:cyan`;break}return(0,$.jsxs)(K,{color:d,children:[`goal (`,u,`)`]})}function _E({exitMessage:e,vimMode:t,mode:n,toolPermissionContext:r,suppressHint:i,isLoading:a,tasksSelected:o,tmuxSelected:s,isPasting:c,isSearching:l,historyQuery:u,setHistoryQuery:d,historyFailedMatch:f,onOpenTasksDialog:p}){if(e.show)return(0,$.jsxs)(K,{dimColor:!0,children:[`Press `,e.key,` again to exit`]},`exit-message`);if(c)return(0,$.jsx)(K,{dimColor:!0,children:`Pasting text…`},`pasting-message`);let m=gg()&&t===`INSERT`&&!l;return(0,$.jsxs)(G,{justifyContent:`flex-start`,gap:1,children:[l&&(0,$.jsx)(nE,{value:u,onChange:d,historyFailedMatch:f}),m?(0,$.jsx)(K,{dimColor:!0,children:`-- INSERT --`},`vim-insert`):null,(0,$.jsx)(vE,{mode:n,toolPermissionContext:r,showHint:!i&&!m,isLoading:a,tasksSelected:o,tmuxSelected:s,onOpenTasksDialog:p})]})}function vE({mode:t,toolPermissionContext:n,showHint:r,isLoading:i,tasksSelected:a,tmuxSelected:o,onOpenTasksDialog:s}){let{columns:c}=Ql(),l=Va(`chat:cycleMode`,`Chat`,`shift+tab`),d=W(e=>e.tasks),f=Bn(),[p]=(0,Q.useState)(()=>f.getState().remoteSessionUrl),m=uE(i,bE()),h=(0,Q.useSyncExternalStore)(sm,cm,dE),g=Hl(),_=Zl().getState,v=h!==null,y=(0,Q.useMemo)(()=>Td(Object.values(d),e=>Ut(e)),[d]),b=Xe(),x=b!==void 0&&b.length>0,S=Va(`chat:cancel`,`Chat`,`esc`).toLowerCase(),C=Va(`app:toggleTodos`,`Global`,`ctrl+t`),w=Va(`chat:killAgents`,`Chat`,`ctrl+x ctrl+k`),T=W(e=>e.notifications.current?.key===`kill-agents-confirm`),E=mE(),D=(0,Q.useMemo)(()=>lp(jp()),[W(e=>e.mainLoopModel)]),O=Cm();if(t===`bash`)return(0,$.jsx)(K,{color:`bashBorder`,children:`! for bash mode`});let k=n?.mode,A=!Nd(k),j=y>0,N=+!!A+ +!!j,ee=bE()&&m.number!==null&&m.reviewState!==null&&m.url!==null&&N<2&&(N===0||c>=80),te=N<2,P=k&&A&&!nd()?(0,$.jsxs)(K,{color:xd(k),children:[Ed(k),` `,Md(k).toLowerCase(),` on`,te&&(0,$.jsxs)(K,{dimColor:!0,children:[` `,(0,$.jsx)(yl,{shortcut:l,action:`cycle`,parens:!0})]})]},`mode`):null,F=[...p?[(0,$.jsx)(El,{url:p,children:(0,$.jsxs)(K,{color:`ide`,children:[u.circleDouble,` remote`]})},`remote`)]:[],...ee?[(0,$.jsx)(ll,{number:m.number,url:m.url,reviewState:m.reviewState},`pr-status`)]:[],...E?[(0,$.jsxs)(K,{dimColor:E.level===`normal`,color:E.level===`error`?`error`:E.level===`warning`?`warning`:void 0,children:[E.text,` · pid:`,process.pid,` · `,D,O?` · ${O}`:``]},`rss`)]:[],...(M(),e(xn)).getGoal()?[(0,$.jsx)(gE,{},`goal-elapsed`)]:[]],I=Object.values(d).some(e=>e.type===`local_agent`&&e.status===`running`),L=r?yE(i,S,C,w,x,I,T):[];v?F.push((0,$.jsx)(hE,{},`proactive`)):r&&F.push(...L);let ne=j&&!Ig(d,!1)?(0,$.jsx)(eE,{tasksSelected:a,onOpenDialog:s}):null;F.length===0&&!ne&&!P&&r&&F.push((0,$.jsx)(K,{dimColor:!0,children:`? for shortcuts`},`shortcuts-hint`));let re=rf().copyOnSelect??!0,ie=g&&(!re||Jl());if(Xr()&&ie){let e=Of()===`macos`,t=e&&(_()?.lastPressHadAlt??!1);F.push((0,$.jsx)(K,{dimColor:!0,children:(0,$.jsxs)(kl,{children:[!re&&(0,$.jsx)(yl,{shortcut:`ctrl+c`,action:`copy`}),Jl()&&(t?(0,$.jsx)(K,{children:`set macOptionClickForcesSelection in VS Code settings`}):(0,$.jsx)(yl,{shortcut:e?`option+click`:`shift+click`,action:`native select`}))]})},`selection-copy`))}return ne&&r&&F.push((0,$.jsx)(K,{dimColor:!0,children:a?(0,$.jsx)(yl,{shortcut:`Enter`,action:`view tasks`}):(0,$.jsx)(yl,{shortcut:`↓`,action:`manage`})},`manage-tasks`)),F.length===0&&!ne&&!P?Xr()?(0,$.jsx)(K,{children:` `}):null:(0,$.jsxs)(G,{height:1,overflow:`hidden`,children:[P&&(0,$.jsxs)(G,{flexShrink:0,children:[P,(ne||F.length>0)&&(0,$.jsx)(K,{dimColor:!0,children:` · `})]}),ne&&(0,$.jsxs)(G,{flexShrink:0,children:[ne,F.length>0&&(0,$.jsx)(K,{dimColor:!0,children:` · `})]}),F.length>0&&(0,$.jsx)(K,{wrap:`truncate`,children:(0,$.jsx)(kl,{children:F})})]})}function yE(e,t,n,r,i,a,o){let s=i;return[...e?[(0,$.jsx)(K,{dimColor:!0,children:(0,$.jsx)(yl,{shortcut:t,action:`interrupt`})},`esc`)]:[],...!e&&a&&!o?[(0,$.jsx)(K,{dimColor:!0,children:(0,$.jsx)(yl,{shortcut:r,action:`stop agents`})},`kill-agents`)]:[],...s?[(0,$.jsx)(K,{dimColor:!0,children:(0,$.jsx)(yl,{shortcut:n,action:`show tasks`})},`toggle-tasks`)]:[]]}function bE(){return rf().prStatusFooterEnabled??!0}Is(),$a(),q(),Er(),Ah(),vg();function xE({apiKeyStatus:e,debug:t,exitMessage:n,vimMode:r,mode:i,autoUpdaterResult:a,isAutoUpdating:o,verbose:s,onAutoUpdaterResult:c,onChangeIsUpdating:l,suggestions:u,selectedSuggestion:d,maxColumnWidth:f,toolPermissionContext:p,helpOpen:m,suppressHint:h,isLoading:g,tasksSelected:_,bridgeSelected:v,tmuxSelected:y,ideSelection:b,mcpClients:x,isPasting:S=!1,isInputWrapped:C=!1,messages:w,isSearching:T,historyQuery:E,setHistoryQuery:D,historyFailedMatch:O,onOpenTasksDialog:k}){let A=Et(),{columns:j,rows:M}=Ql(),N=(0,Q.useRef)(w);N.current=w;let ee=(0,Q.useMemo)(()=>ZT(w),[w]),te=j<80,P=Xr(),F=P&&M<24,I=_,L=h||YT(A)||T;return Eg((0,Q.useMemo)(()=>P&&u.length?{suggestions:u,selectedSuggestion:d,maxColumnWidth:f}:null,[P,u,d,f])),u.length&&!P?(0,$.jsx)(G,{paddingX:2,paddingY:0,children:(0,$.jsx)(jh,{suggestions:u,selectedSuggestion:d,maxColumnWidth:f})}):m?(0,$.jsx)(bg,{dimColor:!0,fixedWidth:!0,paddingX:2}):(0,$.jsxs)(G,{flexDirection:te?`column`:`row`,justifyContent:te?`flex-start`:`space-between`,paddingX:2,gap:+!te,children:[(0,$.jsxs)(G,{flexDirection:`column`,flexShrink:+!te,children:[i===`prompt`&&!F&&!n.show&&!S&&YT(A)&&(0,$.jsx)($T,{messagesRef:N,lastAssistantMessageId:ee,vimMode:r}),(0,$.jsx)(CE,{}),(0,$.jsx)(_E,{exitMessage:n,vimMode:r,mode:i,toolPermissionContext:p,suppressHint:L,isLoading:g,tasksSelected:I,tmuxSelected:y,isPasting:S,isSearching:T,historyQuery:E,setHistoryQuery:D,historyFailedMatch:O,onOpenTasksDialog:k})]}),(0,$.jsx)(G,{flexShrink:1,gap:1,children:P?null:(0,$.jsx)(RS,{apiKeyStatus:e,autoUpdaterResult:a,debug:t,isAutoUpdating:o,verbose:s,messages:w,onAutoUpdaterResult:c,onChangeIsUpdating:l,ideSelection:b,mcpClients:x,isInputWrapped:C,isNarrow:te})})]})}var SE=(0,Q.memo)(xE);function CE(){return null}l(),q();function wE({isLoading:e}){return(0,$.jsxs)(K,{dimColor:e,children:[u.pointer,`\xA0`]})}function TE({mode:e,isLoading:t}){return(0,$.jsx)(G,{alignItems:`flex-start`,alignSelf:`flex-start`,flexWrap:`nowrap`,justifyContent:`flex-start`,children:e===`bash`?(0,$.jsx)(K,{color:`bashBorder`,dimColor:t,children:`!\xA0`}):(0,$.jsx)(wE,{isLoading:t})})}q();var EE=Q.createContext(void 0),DE=2;function OE({isFirst:e,children:t}){let n=DE,r=Q.useMemo(()=>({isQueued:!0,isFirst:e,paddingWidth:n*2}),[e,n]);return(0,$.jsx)(EE.Provider,{value:r,children:(0,$.jsx)(G,{paddingX:n,children:t})})}q(),U(),$s(),Bt(),bd(),$t();var kE=new Set;function AE(e){try{return ud(e)?.type===`idle_notification`}catch{return!1}}var jE=3;function ME(e){return`<${gf}>
64
+ <${bf}>+${e} more tasks completed</${bf}>
65
+ <${vf}>completed</${vf}>
66
+ </${gf}>`}function NE(e){let t=e.filter(e=>typeof e.value!=`string`||!AE(e.value)),n=t.filter(e=>e.mode===`task-notification`),r=t.filter(e=>e.mode!==`task-notification`);if(n.length<=jE)return[...r,...n];let i=n.slice(0,jE-1),a={value:ME(n.length-(jE-1)),mode:`task-notification`};return[...r,...i,a]}function PE(){let e=DS(),t=W(e=>!!e.viewingAgentTaskId),n=(0,Q.useMemo)(()=>{if(e.length===0)return null;let t=e.filter(na);return t.length===0?null:We(NE(t).map(e=>{let t=e.value;return e.mode===`bash`&&typeof t==`string`&&(t=`<bash-input>${t}</bash-input>`),rr({content:t})}))},[e]);return t||n===null?null:(0,$.jsx)(G,{marginTop:1,flexDirection:`column`,children:n.map((e,t)=>(0,$.jsx)(OE,{isFirst:t===0,children:(0,$.jsx)(O,{message:e,lookups:ja,addMargin:!1,tools:[],commands:[],verbose:!1,inProgressToolUseIDs:kE,progressMessagesForMessage:[],shouldAnimate:!1,shouldShowDot:!1,isTranscriptMode:!1,isStatic:!0})},t))})}var FE=Q.memo(PE);Eo(),l(),q();function IE({hasStash:e}){return e?(0,$.jsx)(G,{paddingLeft:2,children:(0,$.jsxs)(K,{dimColor:!0,children:[u.pointerSmall,` Stashed (auto-restores after submit)`]})}):null}je();var LE=1e4,RE=1e3;function zE(e,t){if(e.length<=LE)return{truncatedText:e,placeholderContent:``};let n=Math.floor(RE/2),r=e.slice(0,n),i=e.slice(-500),a=e.slice(n,-500);return{truncatedText:r+BE(t,kn(a))+i,placeholderContent:a}}function BE(e,t){return`[...Truncated text #${e} +${t} lines...]`}function VE(e,t){let n=Object.keys(t).map(Number),r=n.length>0?Math.max(...n)+1:1,{truncatedText:i,placeholderContent:a}=zE(e,r);return a?{newInput:i,newPastedContents:{...t,[r]:{id:r,type:`text`,content:a}}}:{newInput:e,newPastedContents:t}}function HE({input:e,pastedContents:t,onInputChange:n,setCursorOffset:r,setPastedContents:i}){let[a,o]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{if(a||e.length<=1e4)return;let{newInput:s,newPastedContents:c}=VE(e,t);n(s),r(s.length),i(c),o(!0)},[e,a,t,n,i,r]),(0,Q.useEffect)(()=>{e===``&&o(!1)},[e])}U(),af(),$s(),nm();var UE=3;function WE({input:e,submitCount:t}){let n=DS(),r=W(e=>e.promptSuggestionEnabled);return(0,Q.useMemo)(()=>{if(e===``){if(n.some(Do)&&(rf().queuedCommandUpHintCount||0)<UE)return`Press up to edit queued messages`;if(t<1&&r&&!hm())return qg()}},[e,n,t,r])}var GE=5e3,KE=!1;function qE(e){let[t,n]=(0,Q.useState)(!1);return(0,Q.useEffect)(()=>{if(KE||!e)return;KE=!0,n(!0);let t=setTimeout(n,GE,!1);return()=>{clearTimeout(t),n(!1)}},[e]),t}Kl(),Si(),Mf(),U(),rd(),$s(),wl(),Gt(),ss(),Mg(),je(),Vh(),$a(),q(),Cs(),oo(),vc(),Nr(),jd(),el(),af(),gd(),Od(),ld(),Er(),Ia(),Sf(),_p(),kf(),Rh(),Cn(),Ko(),zg(),wr(),yg();var JE=5,YE=3;function XE({debug:e,ideSelection:t,toolPermissionContext:n,setToolPermissionContext:r,apiKeyStatus:i,commands:a,agents:o,isLoading:s,verbose:c,messages:l,onAutoUpdaterResult:u,autoUpdaterResult:d,input:f,onInputChange:p,mode:m,onModeChange:h,stashedPrompt:g,setStashedPrompt:_,submitCount:v,onShowMessageSelector:b,onMessageActionsEnter:S,mcpClients:C,pastedContents:w,setPastedContents:T,vimMode:E,setVimMode:D,showBashesDialog:O,setShowBashesDialog:k,onExit:A,getToolUseContext:j,onSubmit:M,isSearchingHistory:N,setIsSearchingHistory:ee,onDismissSideQuestion:te,isSideQuestionVisible:P,helpOpen:F,setHelpOpen:I,hasSuppressedDialogs:L,isLocalJSXCommandActive:ne=!1,insertTextRef:re}){let ie=Bh(),ae=Ks()||ne,[oe,se]=(0,Q.useState)(!1),[ce,le]=(0,Q.useState)({show:!1}),[R,ue]=(0,Q.useState)(f.length),de=Q.useRef(f);f!==de.current&&(ue(f.length),de.current=f);let fe=Q.useCallback(e=>{de.current=e,p(e)},[p]);re&&(re.current={cursorOffset:R,insert:e=>{let t=R===f.length&&f.length>0&&!/\s$/.test(f)?` ${e}`:e,n=f.slice(0,R)+t+f.slice(R);de.current=n,p(n),ue(R+t.length)},setInputWithCursor:(e,t)=>{de.current=e,p(e),ue(t)}});let z=Bn(),pe=y(),me=W(e=>e.tasks),he=W(e=>e.replBridgeConnected),ge=W(e=>e.replBridgeExplicit),_e=W(e=>e.replBridgeReconnecting),ve=he&&(ge||_e),be=DS(),xe=W(e=>e.promptSuggestion),Se=W(e=>e.speculation),Ce=W(e=>e.speculationSessionTimeSavedMs),we=W(e=>e.mainLoopModel),Te=W(e=>e.mainLoopModelForSession),Ee=W(e=>e.thinkingEnabled),De=W(e=>hp()?e.fastMode:!1),Oe=W(e=>e.viewingAgentTaskId);W(e=>e.viewSelectionMode);let{historyQuery:ke,setHistoryQuery:Ae,historyMatch:je,historyFailedMatch:Me}=qS(e=>{T(e.pastedContents),Zt(e.display)},f,fe,ue,R,h,m,N,ee,T,w),Ne=(0,Q.useRef)(-1);Ne.current===-1&&(Ne.current=ZE(l));let Pe=(0,Q.useRef)(!1),[Fe,Ie]=(0,Q.useState)(!1),Le=W(e=>e.selectedBgAgentIndex),Re=(0,Q.useCallback)(e=>pe(t=>{let n=typeof e==`function`?e(t.selectedBgAgentIndex):e;return n===t.selectedBgAgentIndex?t:{...t,selectedBgAgentIndex:n}}),[pe]),[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,Xe]=(0,Q.useState)(!1),[Qe,$e]=(0,Q.useState)(!1),[et,tt]=(0,Q.useState)(!1),nt=(0,Q.useMemo)(()=>{let e=f.indexOf(`
67
+ `);return e===-1||R<=e},[f,R]),rt=(0,Q.useMemo)(()=>{let e=f.lastIndexOf(`
68
+ `);return e===-1||R>e},[f,R]),it=(0,Q.useMemo)(()=>Td(Object.values(me),e=>e.status===`running`),[me])>0&&!Ig(me,!1),at=KS(),ot=at.length>0,st=(0,Q.useMemo)(()=>[ot&&`bg_agent`,it&&`tasks`,ve&&`bridge`].filter(Boolean),[ot,it,ve]),ct=W(e=>e.footerSelection),lt=ct&&st.includes(ct)?ct:null;(0,Q.useEffect)(()=>{ct&&!lt&&pe(e=>e.footerSelection===null?e:{...e,footerSelection:null})},[ct,lt,pe]);let ut=lt===`tasks`,ft=lt===`tmux`,pt=lt===`bridge`,mt=lt===`bg_agent`;function ht(e){pe(t=>t.footerSelection===e?t:{...t,footerSelection:e}),e===`bg_agent`&&Re(-1)}function gt(e,t=!1){let n=lt?st.indexOf(lt):-1,r=st[n+e];return r?(ht(r),!0):e<0&&t?(ht(null),!0):!1}let{suggestion:_t,markAccepted:vt,logOutcomeAtSubmission:yt,markShown:bt}=YS({inputValue:f,isAssistantResponding:s}),xt=(0,Q.useMemo)(()=>N&&je?Ze(typeof je==`string`?je:je.display):f,[N,je,f]),St=(0,Q.useMemo)(()=>$i(xt),[xt]),Ct=(0,Q.useMemo)(()=>hh(xt),[xt]),wt=(0,Q.useMemo)(()=>CC(xt).filter(e=>dt(xt.slice(e.start+1,e.end),a)),[xt,a]),Tt=(0,Q.useMemo)(()=>[],[xt]),Et=(0,Q.useMemo)(()=>UC(z.getState().mcp.clients)?GC(xt):[],[xt,(0,Q.useSyncExternalStore)(FC,WC)]),Dt=(0,Q.useMemo)(()=>Ht(xt).filter(e=>e.match.startsWith(`[Image`)).map(e=>({start:e.index,end:e.index+e.match.length})),[xt]),Ot=Dt.some(e=>e.start===R);(0,Q.useEffect)(()=>{let e=Dt.find(e=>R>e.start&&R<e.end);if(e){let t=(e.start+e.end)/2;ue(R<t?e.start:e.end)}},[R,Dt,ue]);let kt=(0,Q.useMemo)(()=>{let e=[];for(let t of Dt)R===t.start&&e.push({start:t.start,end:t.end,color:void 0,inverse:!0,priority:8});N&&je&&!Me&&e.push({start:R,end:R+ke.length,color:`warning`,priority:20});for(let t of Ct)e.push({start:t.start,end:t.end,color:`warning`,priority:15});for(let t of wt)e.push({start:t.start,end:t.end,color:`suggestion`,priority:5});for(let t of Tt)e.push({start:t.start,end:t.end,color:`suggestion`,priority:5});for(let t of Et)e.push({start:t.start,end:t.end,color:`suggestion`,priority:5});if(va())for(let t of St)for(let n=t.start;n<t.end;n++)e.push({start:n,end:n+1,color:ys(n-t.start),shimmerColor:ys(n-t.start,!0),priority:10});return e},[N,ke,je,Me,R,Ct,Dt,wt,Tt,Et,xt,St]),{addNotification:At,removeNotification:jt}=li();(0,Q.useEffect)(()=>{St.length&&va()?At({key:`ultrathink-active`,text:`Ultrathink active for this turn`,priority:`immediate`,timeoutMs:5e3}):jt(`ultrathink-active`)},[At,jt,St.length]);let Mt=(0,Q.useRef)(f.length),Nt=(0,Q.useRef)(f.length),Pt=(0,Q.useCallback)(()=>{jt(`stash-hint`)},[jt]);(0,Q.useEffect)(()=>{let e=Mt.current,t=Nt.current,n=f.length;if(Mt.current=n,n>t){Nt.current=n;return}if(n===0){Nt.current=0;return}t>=20&&n<=5&&!(e>=20&&n<=5)&&(rf().hasUsedStash||At({key:`stash-hint`,jsx:(0,$.jsxs)(K,{dimColor:!0,children:[`Tip: `,(0,$.jsx)(ye,{action:`chat:stash`,context:`Chat`,fallback:`ctrl+s`,description:`stash`})]}),priority:`immediate`,timeoutMs:LS}),Nt.current=n)},[f.length,At]);let{pushToBuffer:Ft,undo:It,canUndo:Lt,clearBuffer:Rt}=JS({maxBufferSize:50,debounceMs:1e3});HE({input:f,pastedContents:w,onInputChange:fe,setCursorOffset:ue,setPastedContents:T});let zt=WE({input:f,submitCount:v}),Bt=(0,Q.useCallback)(e=>{if(e===`?`){X(`tengu_help_toggled`,{}),I(e=>!e);return}I(!1),Pt(),x(),Ur(pe);let t=e.length===f.length+1,n=R===0,r=Rr(e);if(n&&r!==`prompt`){if(t){h(r);return}if(f.length===0){h(r);let t=Ze(e).replaceAll(` `,` `);Ft(f,R,w),fe(t),ue(t.length);return}}let i=e.replaceAll(` `,` `);f!==i&&Ft(f,R,w),pe(e=>e.footerSelection===null?e:{...e,footerSelection:null}),fe(i)},[fe,h,f,R,Ft,w,Pt,pe]),{resetHistory:Vt,onHistoryUp:Ut,onHistoryDown:Wt,dismissSearchHint:Gt,historyIndex:Kt}=GS((e,t,n)=>{Bt(e),h(t),T(n)},f,w,ue,m);(0,Q.useEffect)(()=>{N&&Gt()},[N,Gt]);function qt(){if(!($t.length>1)&&nt){if(be.some(Do)){dn();return}Ut()}}function Jt(){if(!($t.length>1)&&rt&&Wt()&&st.length>0){let e=st[0];ht(e),e===`tasks`&&!rf().hasSeenTasksHint&&sf(e=>e.hasSeenTasksHint?e:{...e,hasSeenTasksHint:!0})}}let[B,Yt]=(0,Q.useState)({suggestions:[],selectedSuggestion:-1,commandArgumentHint:void 0}),Xt=(0,Q.useCallback)(e=>{Yt(t=>typeof e==`function`?e(t):e)},[]),Zt=(0,Q.useCallback)(async(e,t=!1)=>{e=e.trimEnd();let n=z.getState();if(n.footerSelection&&st.includes(n.footerSelection)||n.viewSelectionMode===`selecting-agent`)return;let r=Object.values(w).some(e=>e.type===`image`),i=xe.text;if((e.trim()===``||e===i)&&i&&!r&&!n.viewingAgentTaskId){if(Se.status===`active`){vt(),yt(i,{skipReset:!0}),M(i,{setCursorOffset:ue,clearBuffer:Rt,resetHistory:Vt},{state:Se,speculationSessionTimeSavedMs:Ce,setAppState:pe});return}xe.shownAt>0&&(vt(),e=i)}if(e.trim()===``&&!r)return;let a=B.suggestions.length>0&&B.suggestions.every(e=>e.description===`directory`);if(B.suggestions.length>0&&!t&&!a){J(`[onSubmit] early return: suggestions showing (count=${B.suggestions.length})`);return}xe.text&&xe.shownAt>0&&yt(e),jt(`stash-hint`),await M(e,{setCursorOffset:ue,clearBuffer:Rt,resetHistory:Vt})},[xe,Se,Ce,z,st,B.suggestions,M,Rt,Vt,yt,pe,vt,w,jt]),{suggestions:$t,selectedSuggestion:en,commandArgumentHint:tn,inlineGhostText:nn,maxColumnWidth:rn}=xw({commands:a,onInputChange:fe,onSubmit:Zt,setCursorOffset:ue,input:f,cursorOffset:R,mode:m,agents:o,setSuggestionsState:Xt,suggestionsState:B,suppressSuggestions:N||Kt>0,markAccepted:vt,onModeChange:h}),an=m===`prompt`&&$t.length===0&&_t&&!Oe;an&&bt(),xe.text&&!_t&&xe.shownAt===0&&!Oe&&(os(`timing`,xe.text),pe(e=>({...e,promptSuggestion:{text:null,promptId:null,shownAt:0,acceptedAt:0,generationRequestId:null}})));function on(e,t,n,r,i){X(`tengu_paste_image`,{}),h(`prompt`);let a=Ne.current++,o={id:a,type:`image`,content:e,mediaType:t||`image/png`,filename:n||`Pasted image`,dimensions:r,sourcePath:i};Mi(o),hc(o),T(e=>({...e,[a]:o})),ln((Pe.current?` `:``)+Oo(a)),Pe.current=!0}(0,Q.useEffect)(()=>{let e=new Set(Ht(f).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})},[f,T]);function sn(e){Pe.current=!1;let t=tu(e).replace(/\r/g,`
69
+ `).replaceAll(` `,` `);if(f.length===0){let e=Rr(t);e!==`prompt`&&(h(e),t=Ze(t))}let n=kn(t),r=Math.min(En-10,2);if(t.length>800||n>r){let e=Ne.current++,r={id:e,type:`text`,content:t};T(t=>({...t,[e]:r})),ln(Qt(e,n))}else ln(t)}let cn=(0,Q.useCallback)((e,t)=>Pe.current?(Pe.current=!1,_g(e,t)?` ${e}`:e):e,[]);function ln(e){Ft(f,R,w);let t=f.slice(0,R)+e+f.slice(R);fe(t),ue(R+e.length)}let un=Gl(()=>{},()=>b()),dn=(0,Q.useCallback)(()=>{let e=sc(f,R);return e?(fe(e.text),h(`prompt`),ue(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,f,R,T]);AS(C,e=>{X(`tengu_ext_at_mentioned`,{});let t,n=$g.relative(id(),e.filePath);t=e.lineStart&&e.lineEnd?e.lineStart===e.lineEnd?`@${n}#L${e.lineStart} `:`@${n}#L${e.lineStart}-${e.lineEnd} `:`@${n} `;let r=f[R-1]??` `;/\s/.test(r)||(t=` ${t}`),ln(t)});let fn=(0,Q.useCallback)(()=>{if(Lt){let e=It();e&&(fe(e.text),ue(e.cursorOffset),T(e.pastedContents))}},[Lt,It,fe,T]),pn=(0,Q.useCallback)(()=>{Ft(f,R,w);let e=`${f.slice(0,R)}\n${f.slice(R)}`;fe(e),ue(R+1)},[f,R,fe,ue,Ft,w]),mn=(0,Q.useCallback)(async()=>{X(`tengu_external_editor_used`,{}),He(!0);try{let e=await Ih(f,w);e.error&&At({key:`external-editor-error`,text:e.error,color:`warning`,priority:`high`}),e.content!==null&&e.content!==f&&(Ft(f,R,w),fe(e.content),ue(e.content.length))}catch(e){e instanceof Error&&Y(e),At({key:`external-editor-error`,text:`External editor failed: ${cd(e)}`,color:`warning`,priority:`high`})}finally{He(!1)}},[f,R,w,Ft,fe,At]),hn=(0,Q.useCallback)(()=>{f.trim()===``&&g!==void 0?(fe(g.text),ue(g.cursorOffset),T(g.pastedContents),_(void 0)):f.trim()!==``&&(_({text:f,cursorOffset:R,pastedContents:w}),fe(``),ue(0),T({}),sf(e=>e.hasUsedStash?e:{...e,hasUsedStash:!0}))},[f,R,g,fe,_,w,T]),gn=(0,Q.useCallback)(()=>{We(e=>!e),F&&I(!1)},[F]),_n=(0,Q.useCallback)(()=>{$e(e=>!e),F&&I(!1)},[F]),vn=(0,Q.useCallback)(()=>{tt(e=>!e),F&&I(!1)},[F]),yn=(0,Q.useCallback)(()=>{J(`[auto-mode] handleCycleMode: currentMode=${n.mode}`);let e=ww(n),{context:t}=Tw(n);X(`tengu_mode_cycle`,{to:e}),e===`plan`&&sf(e=>({...e,lastPlanModeUse:Date.now()})),pe(n=>({...n,toolPermissionContext:{...t,mode:e}})),r({...t,mode:e}),F&&I(!1)},[n,pe,r,F]),bn=(0,Q.useCallback)(()=>{Ns().then(e=>{if(e)on(e.base64,e.mediaType);else{let e=Yo(`chat:imagePaste`,`Chat`,`ctrl+v`),t=Cd.isSSH()?`No image found in clipboard. You're SSH'd; try scp?`:`No image found in clipboard. Use ${e} to paste images.`;At({key:`no-image-in-clipboard`,text:t,priority:`immediate`,timeoutMs:1e3})}})},[At,on]),xn=Il();(0,Q.useEffect)(()=>{if(!(!xn||ae))return xn.registerHandler({action:`chat:submit`,context:`Chat`,handler:()=>{Zt(f)}})},[xn,ae,Zt,f]),Sl((0,Q.useMemo)(()=>({"chat:undo":fn,"chat:newline":pn,"chat:externalEditor":mn,"chat:stash":hn,"chat:modelPicker":gn,"chat:thinkingToggle":vn,"chat:cycleMode":yn,"chat:imagePaste":bn}),[fn,pn,mn,hn,gn,vn,yn,bn]),{context:`Chat`,isActive:!ae}),Ml(`chat:messageActions`,()=>S?.(),{context:`Chat`,isActive:!ae&&!N}),Ml(`chat:fastMode`,_n,{context:`Chat`,isActive:!ae&&hp()&&pp()}),Ml(`help:dismiss`,()=>{I(!1)},{context:`Help`,isActive:F}),Ml(`app:quickOpen`,()=>{},{context:`Global`,isActive:!1}),Ml(`app:globalSearch`,()=>{},{context:`Global`,isActive:!1}),Ml(`history:search`,()=>{},{context:`Global`,isActive:!1}),Ml(`app:interrupt`,()=>{Ur(pe)},{context:`Global`,isActive:!s&&Se.status===`active`}),Sl({"footer:up":()=>{if(mt){Le>-1?Re(e=>e-1):ht(null);return}gt(-1,!0)},"footer:down":()=>{if(mt){Le<at.length-1&&Re(e=>e+1);return}if(ut){k(!0),ht(null);return}gt(1)},"footer:next":()=>{gt(1)},"footer:previous":()=>{gt(-1)},"footer:openSelected":()=>{switch(lt){case`tasks`:k(!0),ht(null);break;case`tmux`:break;case`bridge`:Ie(!0),ht(null);break;case`bg_agent`:break}},"footer:clearSelection":()=>{ht(null)},"footer:close":()=>!1},{context:`Footer`,isActive:!!lt&&!ae}),ql((e,t)=>{if(!(Ge||qe||Ye)){if(Of()===`macos`&&Cw(e)){let t=Sw[e],n=Qp();At({key:`option-meta-hint`,jsx:n?(0,$.jsxs)(K,{dimColor:!0,children:[`To enable `,t,`, set `,(0,$.jsx)(K,{bold:!0,children:`Option as Meta`}),` in `,n,` preferences (⌘,)`]}):(0,$.jsxs)(K,{dimColor:!0,children:[`To enable `,t,`, run /terminal-setup`]}),priority:`immediate`,timeoutMs:5e3})}if(lt&&e&&!t.ctrl&&!t.meta&&!t.escape&&!t.return){Bt(f.slice(0,R)+e+f.slice(R)),ue(R+e.length);return}if(R===0&&(t.escape||t.backspace||t.delete||t.ctrl&&e===`u`)&&(h(`prompt`),I(!1)),F&&f===``&&(t.backspace||t.delete)&&I(!1),t.escape){if(Se.status===`active`){Ur(pe);return}if(P&&te){te();return}if(F){I(!1);return}if(lt)return;if(be.some(Do)){dn();return}l.length>0&&!f&&!s&&un()}t.return&&F&&I(!1)}});let Sn=hp()?dp():!1,Cn=hp()?De&&(pp()||Sn):!1,wn=qE(Cn??!1),{columns:Tn,rows:En}=Ql(),Dn=Tn-3,On=Xr()?Math.max(YE,Math.floor(En/2)-JE):void 0,An=(0,Q.useCallback)(e=>{if(!f||N)return;let t=Ri.fromText(f,Dn,R),n=t.getViewportStartLine(On),r=t.measuredText.getOffsetFromPosition({line:e.localRow+n,column:e.localCol});ue(r)},[f,Dn,N,R,On]),jn=(0,Q.useCallback)(e=>k(e??!0),[k]),Mn=an&&_t?_t:zt,Nn=(0,Q.useMemo)(()=>f.includes(`
70
+ `),[f]),Pn=(0,Q.useCallback)(e=>{let t=!1;pe(n=>(t=hp()&&!sp(e)&&!!n.fastMode,{...n,mainLoopModel:e,mainLoopModelForSession:null,...t&&{fastMode:!1}})),We(!1);let n=(De??!1)&&!t,r=`Model set to ${Pp(e)}`;Yh(e,n,yp())&&(r+=` · Billed as extra usage`),t&&(r+=` · Fast mode OFF`),At({key:`model-switched`,jsx:(0,$.jsx)(K,{children:r}),priority:`immediate`,timeoutMs:3e3}),X(`tengu_model_picker_hotkey`,{model:e})},[pe,At,De]),Fn=(0,Q.useCallback)(()=>{We(!1)},[]),In=(0,Q.useMemo)(()=>Ue?(0,$.jsx)(G,{flexDirection:`column`,marginTop:1,children:(0,$.jsx)(Xh,{initial:we,sessionModel:Te,onSelect:Pn,onCancel:Fn,isStandaloneCommand:!0,showFastModeNotice:hp()&&De&&sp(we)&&pp()})}):null,[Ue,we,Te,Pn,Fn]),Ln=(0,Q.useCallback)(e=>{$e(!1),e&&At({key:`fast-mode-toggled`,jsx:(0,$.jsx)(K,{children:e}),priority:`immediate`,timeoutMs:3e3})},[At]),Rn=(0,Q.useMemo)(()=>Qe?(0,$.jsx)(G,{flexDirection:`column`,marginTop:1,children:(0,$.jsx)(dg,{onDone:Ln,unavailableReason:up()})}):null,[Qe,Ln]),zn=(0,Q.useCallback)(e=>{pe(t=>({...t,thinkingEnabled:e})),tt(!1),X(`tengu_thinking_toggled_hotkey`,{enabled:e}),At({key:`thinking-toggled-hotkey`,jsx:(0,$.jsxs)(K,{color:e?`suggestion`:void 0,dimColor:!e,children:[`Thinking `,e?`on`:`off`]}),priority:`immediate`,timeoutMs:3e3})},[pe,At]),Vn=(0,Q.useCallback)(()=>{tt(!1)},[]),Hn=(0,Q.useMemo)(()=>et?(0,$.jsx)(G,{flexDirection:`column`,marginTop:1,children:(0,$.jsx)(Ow,{currentValue:Ee??!0,onSelect:zn,onCancel:Vn,isMidConversation:l.some(e=>e.type===`assistant`)})}):null,[et,Ee,zn,Vn,l.length]);if(Og(null),O)return(0,$.jsx)(Bg,{onDone:()=>k(!1),toolUseContext:j(l,[],new AbortController,ie),initialDetailTaskId:typeof O==`string`?O:void 0});if(In)return In;if(Rn)return Rn;if(Hn)return Hn;if(Fe)return(0,$.jsx)(Dw,{onDone:()=>{Ie(!1),ht(null)}});let Un={multiline:!0,onSubmit:Zt,onChange:Bt,value:je?Ze(typeof je==`string`?je:je.display):f,onHistoryUp:qt,onHistoryDown:Jt,onHistoryReset:Vt,placeholder:Mn,onExit:A,onExitMessage:(e,t)=>le({show:e,key:t}),onImagePaste:on,columns:Dn,maxVisibleLines:On,disableCursorMovementForUpDownKeys:$t.length>0||!!lt,disableEscapeDoublePress:$t.length>0,cursorOffset:R,onChangeCursorOffset:ue,onPaste:sn,onIsPastingChange:Be,focus:!N&&!ae&&!lt,showCursor:!lt&&!N&&!Ot,argumentHint:tn,onUndo:Lt?()=>{let e=It();e&&(fe(e.text),ue(e.cursorOffset),T(e.pastedContents))}:void 0,highlights:kt,inlineGhostText:nn,inputFilter:cn},Wn=()=>{let e={bash:`bashBorder`};return e[m]?e[m]:`promptBorder`};if(Ve)return(0,$.jsx)(G,{flexDirection:`row`,alignItems:`center`,justifyContent:`center`,borderColor:Wn(),borderStyle:`round`,borderLeft:!1,borderRight:!1,borderBottom:!0,width:`100%`,children:(0,$.jsx)(K,{dimColor:!0,italic:!0,children:`Save and close editor to continue...`})});let Gn=gg()?(0,$.jsx)(DT,{...Un,initialMode:E,onModeChange:D}):(0,$.jsx)(ha,{...Un});return(0,$.jsxs)(G,{flexDirection:`column`,marginTop:1,children:[!Xr()&&(0,$.jsx)(FE,{}),L&&(0,$.jsx)(G,{marginTop:1,marginLeft:2,children:(0,$.jsx)(K,{dimColor:!0,children:`Waiting for permission…`})}),(0,$.jsx)(IE,{hasStash:g!==void 0}),(0,$.jsxs)(G,{flexDirection:`row`,alignItems:`flex-start`,justifyContent:`flex-start`,borderColor:Wn(),borderStyle:`round`,borderLeft:!1,borderRight:!1,borderBottom:!0,width:`100%`,borderText:QE(Cn??!1,wn,Sn),children:[(0,$.jsx)(TE,{mode:m,isLoading:s}),(0,$.jsx)(G,{flexGrow:1,flexShrink:1,onClick:An,children:Gn})]}),(0,$.jsx)(SE,{apiKeyStatus:i,debug:e,exitMessage:ce,vimMode:gg()?E:void 0,mode:m,autoUpdaterResult:d,isAutoUpdating:oe,verbose:c,onAutoUpdaterResult:u,onChangeIsUpdating:se,suggestions:$t,selectedSuggestion:en,maxColumnWidth:rn,toolPermissionContext:n,helpOpen:F,suppressHint:f.length>0,isLoading:s,tasksSelected:ut,bridgeSelected:pt,tmuxSelected:ft,ideSelection:t,mcpClients:C,isPasting:ze,isInputWrapped:Nn,messages:l,isSearching:N,historyQuery:ke,setHistoryQuery:Ae,historyFailedMatch:Me,onOpenTasksDialog:Xr()?jn:void 0}),Xr()?(0,$.jsx)(G,{position:`absolute`,marginTop:-1,height:+($t.length===0),width:`100%`,paddingLeft:2,paddingRight:1,flexDirection:`column`,justifyContent:`flex-end`,overflow:`hidden`,children:(0,$.jsx)(RS,{apiKeyStatus:i,autoUpdaterResult:d,debug:e,isAutoUpdating:oe,verbose:c,messages:l,onAutoUpdaterResult:u,onChangeIsUpdating:se,ideSelection:t,mcpClients:C,isInputWrapped:Nn})}):null]})}function ZE(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=Ht(e.text);for(let e of n)e.id>t&&(t=e.id)}}}return t+1}function QE(e,t,n){if(e)return{content:` ${t?`${lg(!0,n)} ${Ul.dim(`/fast`)}`:lg(!0,n)} `,position:`top`,align:`end`,offset:0}}var $E=Q.memo(XE);bd();function eD(e,t){return{type:`assistant`,uuid:l_(),message:{id:`remote-${t}`,type:`message`,role:`assistant`,content:[{type:`tool_use`,id:e.tool_use_id,name:e.tool_name,input:e.input}],model:``,stop_reason:null,stop_sequence:null,container:null,context_management:null,usage:{input_tokens:0,output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:0}},requestId:void 0,timestamp:new Date().toISOString()}}function tD(e){return{name:e,inputSchema:{},isEnabled:()=>!0,userFacingName:()=>e,renderToolUseMessage:e=>{let t=Object.entries(e);return t.length===0?``:t.slice(0,3).map(([e,t])=>`${e}: ${typeof t==`string`?t:od(t)}`).join(`, `)},call:async()=>({data:``}),description:async()=>``,prompt:()=>``,isReadOnly:()=>!1,isMcp:!1,needsPermissions:()=>!0}}gd(),Vm(),Bt();function nD(e){return{type:`assistant`,message:e.message,uuid:e.uuid,requestId:void 0,timestamp:new Date().toISOString(),error:e.error}}function rD(e){return{type:`stream_event`,event:e.event}}function iD(e){let t=e.subtype!==`success`;return{type:`system`,subtype:`informational`,content:t?e.errors?.join(`, `)||`Unknown error`:`Session completed successfully`,level:t?`warning`:`info`,uuid:e.uuid,timestamp:new Date().toISOString()}}function aD(e){return{type:`system`,subtype:`informational`,content:`Remote session initialized (model: ${e.model})`,level:`info`,uuid:e.uuid,timestamp:new Date().toISOString()}}function oD(e){return e.status?{type:`system`,subtype:`informational`,content:e.status===`compacting`?`Compacting conversation…`:`Status: ${e.status}`,level:`info`,uuid:e.uuid,timestamp:new Date().toISOString()}:null}function sD(e){return{type:`system`,subtype:`informational`,content:`Tool ${e.tool_name} running for ${e.elapsed_time_seconds}s…`,level:`info`,uuid:e.uuid,timestamp:new Date().toISOString(),toolUseID:e.tool_use_id}}function cD(e){return{type:`system`,subtype:`compact_boundary`,content:`Conversation compacted`,level:`info`,uuid:e.uuid,timestamp:new Date().toISOString(),compactMetadata:Hm(e.compact_metadata)}}function lD(e,t){switch(e.type){case`assistant`:return{type:`message`,message:nD(e)};case`user`:{let n=e,r=n.message?.content,i=Array.isArray(r)&&r.some(e=>e.type===`tool_result`);return t?.convertToolResults&&i||t?.convertUserTextMessages&&!i&&(typeof r==`string`||Array.isArray(r))?{type:`message`,message:rr({content:r,toolUseResult:n.tool_use_result,uuid:n.uuid,timestamp:n.timestamp})}:{type:`ignored`}}case`stream_event`:return{type:`stream_event`,event:rD(e)};case`result`:return e.subtype===`success`?{type:`ignored`}:{type:`message`,message:iD(e)};case`system`:{let t=e;if(t.subtype===`init`)return{type:`message`,message:aD(t)};if(t.subtype===`status`){let t=oD(e);return t?{type:`message`,message:t}:{type:`ignored`}}return t.subtype===`compact_boundary`?{type:`message`,message:cD(e)}:(J(`[sdkMessageAdapter] Ignoring system message subtype: ${t.subtype}`),{type:`ignored`})}case`tool_progress`:return{type:`message`,message:sD(e)};case`auth_status`:return J(`[sdkMessageAdapter] Ignoring auth_status message`),{type:`ignored`};case`tool_use_summary`:return J(`[sdkMessageAdapter] Ignoring tool_use_summary message`),{type:`ignored`};case`rate_limit_event`:return J(`[sdkMessageAdapter] Ignoring rate_limit_event message`),{type:`ignored`};case`task_state`:return J(`[sdkMessageAdapter] Ignoring task_state message`),{type:`ignored`};default:return J(`[sdkMessageAdapter] Unknown message type: ${e.type}`),{type:`ignored`}}}function uD(e){return e.type===`result`}U(),gd(),Hf(),Bt();var dD=6e4,fD=18e4;function pD({config:e,setMessages:t,setIsLoading:n,onInit:r,setToolUseConfirmQueue:i,tools:a,setStreamingToolUses:o,setStreamMode:s,setInProgressToolUseIDs:c}){let l=!!e,u=y(),d=(0,Q.useCallback)(e=>u(t=>t.remoteConnectionStatus===e?t:{...t,remoteConnectionStatus:e}),[u]),f=(0,Q.useRef)(new Set),p=(0,Q.useCallback)(()=>{let e=f.current.size;u(t=>t.remoteBackgroundTaskCount===e?t:{...t,remoteBackgroundTaskCount:e})},[u]),m=(0,Q.useRef)(null),h=(0,Q.useRef)(!1),g=(0,Q.useRef)(null),_=(0,Q.useRef)(!1),v=(0,Q.useRef)(new Gm(50)),b=(0,Q.useRef)(a);(0,Q.useEffect)(()=>{b.current=a},[a]),(0,Q.useEffect)(()=>{if(!e)return;J(`[useRemoteSession] Initializing for session ${e.sessionId}`);let a=new Jg(e,{onMessage:i=>{let a=[`type=${i.type}`];if(`subtype`in i&&a.push(`subtype=${i.subtype}`),i.type===`user`){let e=i.message?.content;a.push(`content=${Array.isArray(e)?e.map(e=>e.type).join(`,`):typeof e}`)}if(J(`[useRemoteSession] Received ${a.join(` `)}`),m.current&&(clearTimeout(m.current),m.current=null),i.type===`user`&&i.uuid&&v.current.has(i.uuid)){J(`[useRemoteSession] Dropping echoed user message ${i.uuid}`);return}if(i.type===`system`&&i.subtype===`init`&&r){let e=i.slash_commands;J(`[useRemoteSession] Init received with ${e.length} slash commands`),r(e)}if(i.type===`system`){if(i.subtype===`task_started`){f.current.add(i.task_id),p();return}if(i.subtype===`task_notification`){f.current.delete(i.task_id),p();return}if(i.subtype===`task_progress`)return;if(i.subtype===`status`){let e=h.current;if(h.current=i.status===`compacting`,e&&h.current)return}i.subtype===`compact_boundary`&&(h.current=!1)}if(uD(i)&&(h.current=!1,n(!1)),c&&i.type===`user`){let e=i.message?.content;if(Array.isArray(e)){let t=[];for(let n of e)n.type===`tool_result`&&t.push(n.tool_use_id);t.length>0&&c(e=>{let n=new Set(e);for(let e of t)n.delete(e);return n.size===e.size?e:n})}}let l=lD(i,e.viewerOnly?{convertToolResults:!0,convertUserTextMessages:!0}:void 0);if(l.type===`message`){if(o?.(e=>e.length>0?[]:e),c&&l.message.type===`assistant`){let e=(Array.isArray(l.message.message?.content)?l.message.message.content:[]).filter(e=>e.type===`tool_use`).map(e=>e.id);e.length>0&&c(t=>{let n=new Set(t);for(let t of e)n.add(t);return n})}t(e=>[...e,l.message])}else l.type===`stream_event`&&(o&&s?Dn(l.event,e=>t(t=>[...t,e]),()=>{},s,o):J(`[useRemoteSession] Stream event received but streaming callbacks not provided`))},onPermissionRequest:(e,t)=>{J(`[useRemoteSession] Permission request for tool: ${e.tool_name}`);let r=zp(b.current,e.tool_name)??tD(e.tool_name),o=eD(e,t),s={behavior:`ask`,message:e.description??`${e.tool_name} requires permission`,suggestions:e.permission_suggestions,blockedPath:e.blocked_path},c={assistantMessage:o,tool:r,description:e.description??`${e.tool_name} requires permission`,input:e.input,toolUseContext:{},toolUseID:e.tool_use_id,permissionResult:s,permissionPromptStartTimeMs:Date.now(),onUserInteraction(){},onAbort(){a.respondToPermissionRequest(t,{behavior:`deny`,message:`User aborted`}),i(t=>t.filter(t=>t.toolUseID!==e.tool_use_id))},onAllow(r,o,s){let c={behavior:`allow`,updatedInput:r};a.respondToPermissionRequest(t,c),i(t=>t.filter(t=>t.toolUseID!==e.tool_use_id)),n(!0)},onReject(n){let r={behavior:`deny`,message:n??`User denied permission`};a.respondToPermissionRequest(t,r),i(t=>t.filter(t=>t.toolUseID!==e.tool_use_id))},async recheckPermission(){}};i(e=>[...e,c]),n(!1)},onPermissionCancelled:(e,t)=>{J(`[useRemoteSession] Permission request cancelled: ${e}`);let r=t??e;i(e=>e.filter(e=>e.toolUseID!==r)),n(!0)},onConnected:()=>{J(`[useRemoteSession] Connected`),d(`connected`)},onReconnecting:()=>{J(`[useRemoteSession] Reconnecting`),d(`reconnecting`),f.current.clear(),p(),c?.(e=>e.size>0?new Set:e)},onDisconnected:()=>{J(`[useRemoteSession] Disconnected`),d(`disconnected`),n(!1),f.current.clear(),p(),c?.(e=>e.size>0?new Set:e)},onError:e=>{J(`[useRemoteSession] Error: ${e.message}`)}});return g.current=a,a.connect(),()=>{J(`[useRemoteSession] Cleanup - disconnecting`),m.current&&(clearTimeout(m.current),m.current=null),a.disconnect(),g.current=null}},[e,t,n,r,i,o,s,c,d,p]);let x=(0,Q.useCallback)(async(r,i)=>{let a=g.current;if(!a)return J(`[useRemoteSession] Cannot send - no manager`),!1;m.current&&clearTimeout(m.current),n(!0),i?.uuid&&v.current.add(i.uuid);let o=await a.sendMessage(r,i);if(!o)return n(!1),!1;if(!_.current&&e&&!e.hasInitialPrompt&&!e.viewerOnly){_.current=!0;let t=e.sessionId,n=typeof r==`string`?r:dr(r,` `);n&&Um(n,new AbortController().signal).then(e=>{Lm(t,e??Lf(n,75))})}if(!e?.viewerOnly){let e=h.current?fD:dD;m.current=setTimeout((e,t)=>{J(`[useRemoteSession] Response timeout - attempting reconnect`);let n=$c(`Remote session may be unresponsive. Attempting to reconnect…`,`warning`);e(e=>[...e,n]),t.reconnect()},e,t,a)}return o},[e,n,t]),S=(0,Q.useCallback)(()=>{m.current&&(clearTimeout(m.current),m.current=null),e?.viewerOnly||g.current?.cancelSession(),n(!1)},[e,n]),C=(0,Q.useCallback)(()=>{m.current&&(clearTimeout(m.current),m.current=null),g.current?.disconnect(),g.current=null},[]);return(0,Q.useMemo)(()=>({isRemoteMode:l,sendMessage:x,cancelRequest:S,disconnect:C}),[l,x,S,C])}gd(),bd(),s();function mD(e){return typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`}var hD=class{constructor(e,t){c(this,`ws`,null),c(this,`config`,void 0),c(this,`callbacks`,void 0),this.config=e,this.callbacks=t}connect(){let e={};this.config.authToken&&(e.authorization=`Bearer ${this.config.authToken}`),this.ws=new WebSocket(this.config.wsUrl,{headers:e}),this.ws.addEventListener(`open`,()=>{this.callbacks.onConnected?.()}),this.ws.addEventListener(`message`,e=>{let t=(typeof e.data==`string`?e.data:``).split(`
71
+ `).filter(e=>e.trim());for(let e of t){let t;try{t=ud(e)}catch{continue}if(!mD(t))continue;let n=t;if(n.type===`control_request`){n.request.subtype===`can_use_tool`?this.callbacks.onPermissionRequest(n.request,n.request_id):(J(`[DirectConnect] Unsupported control request subtype: ${n.request.subtype}`),this.sendErrorResponse(n.request_id,`Unsupported control request subtype: ${n.request.subtype}`));continue}n.type!==`control_response`&&n.type!==`keep_alive`&&n.type!==`control_cancel_request`&&n.type!==`streamlined_text`&&n.type!==`streamlined_tool_use_summary`&&!(n.type===`system`&&n.subtype===`post_turn_summary`)&&this.callbacks.onMessage(n)}}),this.ws.addEventListener(`close`,()=>{this.callbacks.onDisconnected?.()}),this.ws.addEventListener(`error`,()=>{this.callbacks.onError?.(Error(`WebSocket connection error`))})}sendMessage(e){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return!1;let t=od({type:`user`,message:{role:`user`,content:e},parent_tool_use_id:null,session_id:``});return this.ws.send(t),!0}respondToPermissionRequest(e,t){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return;let n=od({type:`control_response`,response:{subtype:`success`,request_id:e,response:{behavior:t.behavior,...t.behavior===`allow`?{updatedInput:t.updatedInput}:{message:t.message}}}});this.ws.send(n)}sendInterrupt(){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return;let e=od({type:`control_request`,request_id:crypto.randomUUID(),request:{subtype:`interrupt`}});this.ws.send(e)}sendErrorResponse(e,t){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return;let n=od({type:`control_response`,response:{subtype:`error`,request_id:e,error:t}});this.ws.send(n)}disconnect(){this.ws&&(this.ws.close(),this.ws=null)}isConnected(){return this.ws?.readyState===WebSocket.OPEN}};qp(),gd();function gD({config:e,setMessages:t,setIsLoading:n,setToolUseConfirmQueue:r,tools:i}){let a=!!e,o=(0,Q.useRef)(null),s=(0,Q.useRef)(!1),c=(0,Q.useRef)(!1),l=(0,Q.useRef)(i);(0,Q.useEffect)(()=>{l.current=i},[i]),(0,Q.useEffect)(()=>{if(!e)return;s.current=!1,J(`[useDirectConnect] Connecting to ${e.wsUrl}`);let i=new hD(e,{onMessage:e=>{if(uD(e)&&n(!1),e.type===`system`&&e.subtype===`init`){if(s.current)return;s.current=!0}let r=lD(e,{convertToolResults:!0});r.type===`message`&&t(e=>[...e,r.message])},onPermissionRequest:(e,t)=>{J(`[useDirectConnect] Permission request for tool: ${e.tool_name}`);let a=zp(l.current,e.tool_name)??tD(e.tool_name),o=eD(e,t),s={behavior:`ask`,message:e.description??`${e.tool_name} requires permission`,suggestions:e.permission_suggestions,blockedPath:e.blocked_path},c={assistantMessage:o,tool:a,description:e.description??`${e.tool_name} requires permission`,input:e.input,toolUseContext:{},toolUseID:e.tool_use_id,permissionResult:s,permissionPromptStartTimeMs:Date.now(),onUserInteraction(){},onAbort(){i.respondToPermissionRequest(t,{behavior:`deny`,message:`User aborted`}),r(t=>t.filter(t=>t.toolUseID!==e.tool_use_id))},onAllow(a,o,s){let c={behavior:`allow`,updatedInput:a};i.respondToPermissionRequest(t,c),r(t=>t.filter(t=>t.toolUseID!==e.tool_use_id)),n(!0)},onReject(n){let a={behavior:`deny`,message:n??`User denied permission`};i.respondToPermissionRequest(t,a),r(t=>t.filter(t=>t.toolUseID!==e.tool_use_id))},async recheckPermission(){}};r(e=>[...e,c]),n(!1)},onConnected:()=>{J(`[useDirectConnect] Connected`),c.current=!0},onDisconnected:()=>{J(`[useDirectConnect] Disconnected`),c.current?process.stderr.write(`
72
+ Server disconnected.
73
+ `):process.stderr.write(`\nFailed to connect to server at ${e.wsUrl}\n`),c.current=!1,ji(1),n(!1)},onError:e=>{J(`[useDirectConnect] Error: ${e.message}`)}});return o.current=i,i.connect(),()=>{J(`[useDirectConnect] Cleanup - disconnecting`),i.disconnect(),o.current=null}},[e,t,n,r]);let u=(0,Q.useCallback)(async e=>{let t=o.current;return t?(n(!0),t.sendMessage(e)):!1},[n]),d=(0,Q.useCallback)(()=>{o.current?.sendInterrupt(),n(!1)},[n]),f=(0,Q.useCallback)(()=>{o.current?.disconnect(),o.current=null,c.current=!1},[]);return(0,Q.useMemo)(()=>({isRemoteMode:a,sendMessage:u,cancelRequest:d,disconnect:f}),[a,u,d,f])}qp(),gd(),_();function _D({session:e,setMessages:t,setIsLoading:n,setToolUseConfirmQueue:r,tools:i}){let a=!!e,o=(0,Q.useRef)(null),s=(0,Q.useRef)(!1),c=(0,Q.useRef)(!1),l=(0,Q.useRef)(i);(0,Q.useEffect)(()=>{l.current=i},[i]),(0,Q.useEffect)(()=>{if(!e)return;s.current=!1,J(`[useSSHSession] wiring SSH session manager`);let i=e.createManager({onMessage:e=>{if(uD(e)&&n(!1),e.type===`system`&&e.subtype===`init`){if(s.current)return;s.current=!0}let r=lD(e,{convertToolResults:!0});r.type===`message`&&t(e=>[...e,r.message])},onPermissionRequest:(e,t)=>{J(`[useSSHSession] permission request: ${e.tool_name}`);let a=zp(l.current,e.tool_name)??tD(e.tool_name),o=eD(e,t),s={behavior:`ask`,message:e.description??`${e.tool_name} requires permission`,suggestions:e.permission_suggestions,blockedPath:e.blocked_path},c={assistantMessage:o,tool:a,description:e.description??`${e.tool_name} requires permission`,input:e.input,toolUseContext:{},toolUseID:e.tool_use_id,permissionResult:s,permissionPromptStartTimeMs:Date.now(),onUserInteraction(){},onAbort(){i.respondToPermissionRequest(t,{behavior:`deny`,message:`User aborted`}),r(t=>t.filter(t=>t.toolUseID!==e.tool_use_id))},onAllow(a){i.respondToPermissionRequest(t,{behavior:`allow`,updatedInput:a}),r(t=>t.filter(t=>t.toolUseID!==e.tool_use_id)),n(!0)},onReject(n){i.respondToPermissionRequest(t,{behavior:`deny`,message:n??`User denied permission`}),r(t=>t.filter(t=>t.toolUseID!==e.tool_use_id))},async recheckPermission(){}};r(e=>[...e,c]),n(!1)},onConnected:()=>{J(`[useSSHSession] connected`),c.current=!0},onReconnecting:(e,r)=>{J(`[useSSHSession] ssh dropped, reconnecting (${e}/${r})`),c.current=!1,n(!1);let i={type:`system`,subtype:`informational`,content:`SSH connection dropped — reconnecting (attempt ${e}/${r})...`,timestamp:new Date().toISOString(),uuid:l_(),level:`warning`};t(e=>[...e,i])},onDisconnected:()=>{J(`[useSSHSession] ssh process exited (giving up)`);let t=e.getStderrTail().trim(),r=c.current,i=e.proc.exitCode;c.current=!1,n(!1);let a=r?`Remote session ended.`:`SSH session failed before connecting.`;t&&(!r||i!==0)&&(a+=`\nRemote stderr (exit ${i??`signal ${e.proc.signalCode}`}):\n${t}`),ji(1,`other`,{finalMessage:a})},onError:e=>{J(`[useSSHSession] error: ${e.message}`)}});return o.current=i,i.connect(),()=>{J(`[useSSHSession] cleanup`),i.disconnect(),e.proxy.stop(),o.current=null}},[e,t,n,r]);let u=(0,Q.useCallback)(async e=>{let t=o.current;return t?(n(!0),t.sendMessage(e)):!1},[n]),d=(0,Q.useCallback)(()=>{o.current?.sendInterrupt(),n(!1)},[n]),f=(0,Q.useCallback)(()=>{o.current?.disconnect(),o.current=null,c.current=!1},[]);return(0,Q.useMemo)(()=>({isRemoteMode:a,sendMessage:u,cancelRequest:d,disconnect:f}),[a,u,d,f])}Jf();var vD=400;function yD({inputValue:e,setInputValue:t,isValidDigit:n,onDigit:r,enabled:i=!0,once:a=!1,debounceMs:o=vD}){let s=(0,Q.useRef)(e),c=(0,Q.useRef)(!1),l=(0,Q.useRef)(null),u=(0,Q.useRef)({setInputValue:t,isValidDigit:n,onDigit:r});u.current={setInputValue:t,isValidDigit:n,onDigit:r},(0,Q.useEffect)(()=>{if(!(!i||a&&c.current)){if(l.current!==null&&(clearTimeout(l.current),l.current=null),e!==s.current){let t=Xf(e.slice(-1));if(u.current.isValidDigit(t)){let n=e.slice(0,-1);l.current=setTimeout((e,t,n,r,i)=>{e.current=null,t.current=!0,n.current.setInputValue(r),n.current.onDigit(i)},o,l,c,u,n,t)}}return()=>{l.current!==null&&(clearTimeout(l.current),l.current=null)}}},[e,i,a,o])}q();var bD=[`0`,`1`,`2`,`3`],xD={0:`dismissed`,1:`bad`,2:`fine`,3:`good`},SD=e=>bD.includes(e),CD=`How is Work Mate doing this session? (optional)`;function wD({onSelect:e,inputValue:t,setInputValue:n,message:r=CD}){return yD({inputValue:t,setInputValue:n,isValidDigit:SD,onDigit:t=>e(xD[t])}),(0,$.jsxs)(G,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(G,{children:[(0,$.jsx)(K,{color:`ansi:cyan`,children:`● `}),(0,$.jsx)(K,{bold:!0,children:r})]}),(0,$.jsxs)(G,{marginLeft:2,children:[(0,$.jsx)(G,{width:10,children:(0,$.jsxs)(K,{children:[(0,$.jsx)(K,{color:`ansi:cyan`,children:`1`}),`: Bad`]})}),(0,$.jsx)(G,{width:10,children:(0,$.jsxs)(K,{children:[(0,$.jsx)(K,{color:`ansi:cyan`,children:`2`}),`: Fine`]})}),(0,$.jsx)(G,{width:10,children:(0,$.jsxs)(K,{children:[(0,$.jsx)(K,{color:`ansi:cyan`,children:`3`}),`: Good`]})}),(0,$.jsx)(G,{children:(0,$.jsxs)(K,{children:[(0,$.jsx)(K,{color:`ansi:cyan`,children:`0`}),`: Dismiss`]})})]})]})}Rd(),q(),Jf();function TD({isOpen:e,skillName:t,updates:n,handleSelect:r,inputValue:i,setInputValue:a}){return!e||i&&!SD(i)?null:(0,$.jsx)(OD,{skillName:t,updates:n,onSelect:r,inputValue:i,setInputValue:a})}var ED=[`0`,`1`];function DD(e){return ED.includes(e)}function OD({skillName:e,updates:t,onSelect:n,inputValue:r,setInputValue:i}){let a=(0,Q.useRef)(r);return(0,Q.useEffect)(()=>{if(r!==a.current){let e=Xf(r.slice(-1));DD(e)&&(i(r.slice(0,-1)),n(e===`1`?`good`:`dismissed`))}},[r,n,i]),(0,$.jsxs)(G,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(G,{children:[(0,$.jsxs)(K,{color:`ansi:cyan`,children:[Bd,` `]}),(0,$.jsxs)(K,{bold:!0,children:[`Skill improvement suggested for "`,e,`"`]})]}),(0,$.jsx)(G,{flexDirection:`column`,marginLeft:2,children:t.map((e,t)=>(0,$.jsxs)(K,{dimColor:!0,children:[`∙`,` `,e.change]},t))}),(0,$.jsxs)(G,{marginLeft:2,marginTop:1,children:[(0,$.jsx)(G,{width:12,children:(0,$.jsxs)(K,{children:[(0,$.jsx)(K,{color:`ansi:cyan`,children:`1`}),`: Apply`]})}),(0,$.jsx)(G,{width:14,children:(0,$.jsxs)(K,{children:[(0,$.jsx)(K,{color:`ansi:cyan`,children:`0`}),`: Dismiss`]})})]})]})}Mf(),U(),Bt();function kD(e){let t=W(e=>e.skillImprovement.suggestion),n=y(),[r,i]=(0,Q.useState)(!1),a=(0,Q.useRef)(t),o=(0,Q.useRef)(!1);t&&(a.current=t),t&&!r&&(i(!0),o.current||(o.current=!0,X(`tengu_skill_improvement_survey`,{event_type:`appeared`,_PROTO_skill_name:t.skillName??`unknown`})));let s=(0,Q.useCallback)(t=>{let r=a.current;if(!r)return;let s=t!==`dismissed`;X(`tengu_skill_improvement_survey`,{event_type:`responded`,response:s?`applied`:`dismissed`,_PROTO_skill_name:r.skillName}),s&&Yg(r.skillName,r.updates).then(()=>{e(e=>[...e,$c(`Skill "${r.skillName}" updated with improvements.`,`suggestion`)])}),i(!1),o.current=!1,n(e=>e.skillImprovement.suggestion?{...e,skillImprovement:{suggestion:null}}:e)},[n,e]);return{isOpen:r,suggestion:a.current,handleSelect:s}}function AD(e){return{onBeforeQuery:async()=>!0,onTurnComplete:async()=>{},render:()=>null}}Da(),Ue(),bs(),hn();function jD(e){(0,Q.useEffect)(()=>{let t=()=>{Fr()&&process.stdout.write(`\n${No()}\n`),Ve(e?.())};return process.on(`exit`,t),()=>{process.off(`exit`,t)}},[])}function MD(){(0,Q.useEffect)(()=>{},[])}function ND(e,t){let n=(0,Q.useRef)(e??null),r=(0,Q.useRef)(!e);return(0,Q.useEffect)(()=>{let e=n.current;if(!e)return;let i=!1;return e.then(e=>{i||(r.current=!0,n.current=null,e.length>0&&t(t=>[...e,...t]))}),()=>{i=!0}},[t]),(0,Q.useCallback)(async()=>{if(r.current||!n.current)return;let e=await n.current;r.current||(r.current=!0,n.current=null,e.length>0&&t(t=>[...e,...t]))},[t])}Ru(),ii(),op();function PD(){let[e,t]=(0,Q.useState)(()=>{if(!np()||Fp())return`valid`;let{key:e,source:t}=wp({skipRetrievingKeyFromApiKeyHelper:!0});return e||t===`apiKeyHelper`?`loading`:`missing`}),[n,r]=(0,Q.useState)(null);return{status:e,reverify:(0,Q.useCallback)(async()=>{if(!np()||Fp()){t(`valid`);return}await vp(Pu());let{key:e,source:n}=wp();if(!e){if(n===`apiKeyHelper`){t(`error`),r(Error(`API key helper did not return a valid key`));return}t(`missing`);return}try{let n=await za(e,!1)?`valid`:`invalid`;t(n);return}catch(e){r(e),t(`error`);return}},[]),error:n}}Ru(),q(),rd(),gd(),q(),vc(),Mf(),U();function FD({screen:e,setScreen:t,showAllInTranscript:n,setShowAllInTranscript:r,messageCount:i,onEnterTranscript:a,onExitTranscript:o,virtualScrollActive:s,searchBarOpen:c=!1}){let l=W(e=>e.expandedView),u=y(),d=(0,Q.useCallback)(()=>{X(`tengu_toggle_todos`,{is_expanded:l===`tasks`}),u(e=>({...e,expandedView:e.expandedView===`tasks`?`none`:`tasks`}))},[l,u]),f=(0,Q.useCallback)(()=>{let s=e!==`transcript`;X(`tengu_toggle_transcript`,{is_entering:s,show_all:n,message_count:i}),t(e=>e===`transcript`?`prompt`:`transcript`),r(!1),s&&a&&a(),!s&&o&&o()},[e,t,n,r,i,u,a,o]),p=(0,Q.useCallback)(()=>{X(`tengu_transcript_toggle_show_all`,{is_expanding:!n,message_count:i}),r(e=>!e)},[n,r,i]),m=(0,Q.useCallback)(()=>{X(`tengu_transcript_exit`,{show_all:n,message_count:i}),t(`prompt`),r(!1),o&&o()},[t,n,r,i,o]);Ml(`app:toggleTodos`,d,{context:`Global`}),Ml(`app:toggleTranscript`,f,{context:`Global`}),Ml(`app:toggleTerminal`,(0,Q.useCallback)(()=>{},[]),{context:`Global`}),Ml(`app:redraw`,(0,Q.useCallback)(()=>{Ol.get(process.stdout)?.forceRedraw()},[]),{context:`Global`});let h=e===`transcript`;return Ml(`transcript:toggleShowAll`,p,{context:`Transcript`,isActive:h&&!s}),Ml(`transcript:exit`,m,{context:`Transcript`,isActive:h&&!c}),null}ss(),Cs(),vc();var ID={setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}};function LD({onSubmit:e,isActive:t=!0}){let n=Il(),r=Ks(),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 Sl((0,Q.useMemo)(()=>{let t={};for(let n of i){let r=n.slice(8);t[n]=()=>{e(`/${r}`,ID,void 0,{fromKeybinding:!0})}}return t},[i,e]),{context:`Chat`,isActive:t&&!r}),null}Uo(),Mf(),U(),yg(),Si(),ss(),oo(),vc(),B(),$s();var RD=3e3;function zD(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=Bn(),g=y(),_=DS().length,{addNotification:v,removeNotification:b}=li(),x=(0,Q.useRef)(0),S=(0,Q.useCallback)(()=>{let e={source:`escape`,streamMode:m};if(o!==void 0&&!o.aborted){X(`tengu_cancel`,e),t(()=>[]),n();return}if(fs()&&s){s();return}X(`tengu_cancel`,e),t(()=>[]),n()},[o,s,t,n,m]),C=bo(),w=o!==void 0&&!o.aborted,T=_>0,E=f!==void 0&&f!==`prompt`&&!p,D=a!==`transcript`&&!u&&!i&&!l&&!d&&!C&&!(gg()&&c===`INSERT`),O=D&&(w||T)&&!E,k=D&&(w||T);Ml(`chat:cancel`,S,{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;ml(e,g);let n=[];for(let[e,r]of t)ie(e,g),n.push(r.description),gm(e,`stopped`,{toolUseId:r.toolUseId,summary:r.description});return Ii({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 Ml(`app:interrupt`,(0,Q.useCallback)(()=>{(w||T)&&S()},[w,T,S]),{context:`Global`,isActive:k}),Ml(`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-x.current<=RD){x.current=0,b(`kill-agents-confirm`),X(`tengu_cancel`,{source:`kill_agents`}),Hs(),A();return}x.current=t;let n=Yo(`chat:killAgents`,`Chat`,`ctrl+x ctrl+k`);v({key:`kill-agents-confirm`,text:`Press ${n} again to stop background agents`,priority:`immediate`,timeoutMs:RD})},[h,v,b,A]),{context:`Chat`}),null}q(),U(),ct();function BD(e){let t=W(e=>e.tasks),n=W(e=>e.pipeIpc),r=Object.values(t).some(Ut),i=t=>{if(t.shift&&(t.key===`up`||t.key===`down`)){t.preventDefault(),r?e?.onOpenBackgroundTasks?.():t.key===`down`&&n?.statusVisible&&e?.onTogglePipeSelector&&e.onTogglePipeSelector();return}};return ql((e,t,n)=>{i(new jl(n.keypress))}),{handleKeyDown:i}}Sf();async function VD(e){let{ctx:t,updatedInput:n,suggestions:r,permissionMode:i}=e;try{let e=await t.runHooks(i,r,n);if(e)return e}catch(e){e instanceof Error?Y(e):Y(Error(`Automated permission check failed: ${String(e)}`))}return null}var HD=new Map,UD=null;function WD(){return UD??null}function GD(e,t){let n=WD();if(!n)return null;let r=l_(),i={requestId:r,toolName:e.tool.name,toolUseID:e.toolUseID,description:e.description,input:e.input,permissionResult:e.permissionResult,permissionPromptStartTimeMs:e.permissionPromptStartTimeMs};return HD.set(r,{onResponse:t}),n({type:`permission_request`,data:JSON.stringify(i)}),r}function KD(e){e&&HD.delete(e)}function qD(e,t){if(!e)return;let n=WD();n&&n({type:`permission_cancel`,data:JSON.stringify({requestId:e,reason:t})})}Mf(),Tm(),tt(),gd(),mo(),Bt(),Ke(),vs();function JD(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 YD(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){ic({tool:e,input:a?.input??t,toolUseContext:n,messageId:s,toolUseID:i},r,a?.permissionPromptStartTimeMs)},logCancelled(){X(`tengu_tool_use_cancelled`,{messageID:s,toolName:Em(e.name)})},async persistPermissions(e){return e.length===0?!1:(Fs(e),a(Tr(n.getAppState().toolPermissionContext,e)),e.some(e=>Tt(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?ec:Ki}${t}`:a?ps:vo,s=a?o:Ln(o);return(r||!t&&!i?.length&&!a)&&(J(`Aborting: tool=${e.name} isAbort=${r} hasFeedback=${!!t} isSubagent=${a}`),n.abortController.abort()),{behavior:`ask`,message:s,contentBlocks:i}},async runHooks(r,a,o,s){for await(let c of Wr(e.name,i,t,n,r,a,n.abortController.signal))if(c.permissionRequestResult){let r=c.permissionRequestResult;if(r.behavior===`allow`){let e=r.updatedInput??o??t;return await this.handleHookAllow(e,r.updatedPermissions??[],s)}else if(r.behavior===`deny`)return this.logDecision({decision:`reject`,source:{type:`hook`}},{permissionPromptStartTimeMs:s}),r.interrupt&&(J(`Hook interrupt: tool=${e.name} hookMessage=${r.message}`),n.abortController.abort()),this.buildDeny(r.message||`Permission denied by hook`,{type:`hook`,hookName:`PermissionRequest`,reason:r.message})}return null},buildAllow(e,t){return{behavior:`allow`,updatedInput:e,userModified:t?.userModified??!1,...t?.decisionReason&&{decisionReason:t.decisionReason},...t?.acceptFeedback&&{acceptFeedback:t.acceptFeedback},...t?.contentBlocks&&t.contentBlocks.length>0&&{contentBlocks:t.contentBlocks}}},buildDeny(e,t){return{behavior:`deny`,message:e,decisionReason:t}},async handleUserAllow(n,r,i,a,o,s){let c=await this.persistPermissions(r);this.logDecision({decision:`accept`,source:{type:`user`,permanent:c}},{input:n,permissionPromptStartTimeMs:a});let l=e.inputsEquivalent?!e.inputsEquivalent(t,n):!1,u=i?.trim();return this.buildAllow(n,{userModified:l,decisionReason:s,acceptFeedback:u||void 0,contentBlocks:o})},async handleHookAllow(e,t,n){let r=await this.persistPermissions(t);return this.logDecision({decision:`accept`,source:{type:`hook`,permanent:r}},{input:e,permissionPromptStartTimeMs:n}),this.buildAllow(e,{decisionReason:{type:`hook`,hookName:`PermissionRequest`}})},pushToQueue(e){o?.push(e)},removeFromQueue(){o?.remove(i)},updateQueueItem(e){o?.update(i,e)}})}function XD(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))}}}gd(),q(),tt(),V(),ld();function ZD(e,t){let{ctx:n,description:r,result:i,awaitAutomatedChecksBeforeDialog:a,bridgeCallbacks:o}=e,{resolve:s,isResolved:c,claim:l}=JD(t),u,d,f=o?l_():void 0,p=Date.now(),m=i.updatedInput??n.input,h=null;function g(e){qD(h,e),KD(h),h=null}function _(){KD(h),h=null}let v={assistantMessage:n.assistantMessage,tool:n.tool,description:r,input:m,toolUseContext:n.toolUseContext,toolUseID:n.toolUseID,permissionResult:i,permissionPromptStartTimeMs:p,onUserInteraction(){Date.now()-p<200||n.toolUseID},onDismissCheckmark(){u&&(clearTimeout(u),u=void 0,d&&(n.toolUseContext.abortController.signal.removeEventListener(`abort`,d),d=void 0),n.removeFromQueue())},onAbort(){l()&&(g(`Permission request was aborted locally in sub.`),o&&f&&(o.sendResponse(f,{behavior:`deny`,message:`User aborted`}),o.cancelRequest(f)),n.logCancelled(),n.logDecision({decision:`reject`,source:{type:`user_abort`}},{permissionPromptStartTimeMs:p}),s(n.cancelAndAbort(void 0,!0)))},async onAllow(e,t,r,a){l()&&(g(`Permission request was approved locally in sub.`),o&&f&&(o.sendResponse(f,{behavior:`allow`,updatedInput:e,updatedPermissions:t}),o.cancelRequest(f)),s(await n.handleUserAllow(e,t,r,p,a,i.decisionReason)))},onReject(e,t){l()&&(g(`Permission request was rejected locally in sub.`),o&&f&&(o.sendResponse(f,{behavior:`deny`,message:e??`User denied permission`}),o.cancelRequest(f)),n.logDecision({decision:`reject`,source:{type:`user_reject`,hasFeedback:!!e}},{permissionPromptStartTimeMs:p}),s(n.cancelAndAbort(e,void 0,t)))},async recheckPermission(){if(c())return;let e=await F(n.tool,n.input,n.toolUseContext,n.assistantMessage,n.toolUseID);if(e.behavior===`allow`){if(!l())return;g(`Permission request was resolved locally in sub.`),o&&f&&o.cancelRequest(f),n.removeFromQueue(),n.logDecision({decision:`accept`,source:`config`}),s(n.buildAllow(e.updatedInput??n.input))}}};if(n.pushToQueue(v),h=GD(v,e=>{l()&&(_(),n.toolUseID,n.removeFromQueue(),o&&f&&o.cancelRequest(f),e.behavior===`allow`?(async()=>{e.permissionUpdates?.length&&n.persistPermissions(e.permissionUpdates),n.logDecision({decision:`accept`,source:{type:`user`,permanent:!!e.permissionUpdates?.length}},{permissionPromptStartTimeMs:p}),s(n.buildAllow(e.updatedInput??m,{acceptFeedback:e.feedback,contentBlocks:e.contentBlocks}))})():(n.logDecision({decision:`reject`,source:{type:`user_reject`,hasFeedback:!!e.feedback}},{permissionPromptStartTimeMs:p}),s(n.cancelAndAbort(e.feedback,void 0,e.contentBlocks))))}),o&&f){o.sendRequest(f,n.tool.name,m,n.toolUseID,r,i.suggestions,i.blockedPath);let e=n.toolUseContext.abortController.signal,t=o.onResponse(f,r=>{l()&&(g(`Permission request was resolved by bridge before pipe response.`),e.removeEventListener(`abort`,t),n.toolUseID,n.removeFromQueue(),r.behavior===`allow`?(r.updatedPermissions?.length&&n.persistPermissions(r.updatedPermissions),n.logDecision({decision:`accept`,source:{type:`user`,permanent:!!r.updatedPermissions?.length}},{permissionPromptStartTimeMs:p}),s(n.buildAllow(r.updatedInput??m))):(n.logDecision({decision:`reject`,source:{type:`user_reject`,hasFeedback:!!r.message}},{permissionPromptStartTimeMs:p}),s(n.cancelAndAbort(r.message))))});e.addEventListener(`abort`,t,{once:!0})}a||(async()=>{if(c())return;let e=n.toolUseContext.getAppState(),t=await n.runHooks(e.toolPermissionContext.mode,i.suggestions,i.updatedInput,p);!t||!l()||(g(`Permission request was resolved by hook before pipe response.`),o&&f&&o.cancelRequest(f),n.removeFromQueue(),s(t))})()}q(),tt(),V(),gd(),ld(),Sf(),Lr(),vs();function QD(e,t){return(0,Q.useCallback)(async(n,r,i,a,o,s)=>new Promise(c=>{let l=YD(n,r,i,a,o,t,XD(e));if(!l.resolveIfAborted(c))return(s===void 0?F(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`:ic({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 VD({ctx:l,updatedInput:e.updatedInput,suggestions:e.suggestions,permissionMode:t.toolPermissionContext.mode});if(n){c(n);return}}if(l.resolveIfAborted(c))return;ZD({ctx:l,description:a,result:e,awaitAutomatedChecksBeforeDialog:t.toolPermissionContext.awaitAutomatedChecksBeforeDialog,bridgeCallbacks:void 0},c);return}}).catch(e=>{e instanceof sd||e instanceof pd?(J(`Permission check threw ${e.constructor.name} for tool=${n.name}: ${e.message}`),l.logCancelled(),c(l.cancelAndAbort(void 0,!0))):(Y(e),c(l.cancelAndAbort(void 0,!0)))}).finally(()=>{})}),[e,t])}dm(),Mf(),Gt(),je(),rd(),gd(),_(),ld(),Sf(),$s(),_p();function $D(){zn(0)}async function eO(e){let{helpers:t,queryGuard:n,isExternalLoading:r=!1,commands:i,onInputChange:a,setPastedContents:o,setToolJSX:s,getToolUseContext:c,messages:l,mainLoopModel:u,ideSelection:d,setUserInputOnProcessing:f,setAbortController:p,onQuery:m,setAppState:h,onBeforeQuery:g,canUseTool:_,queuedCommands:v,uuid:y,skipSlashCommands:b,bridgeOrigin:x}=e,{setCursorOffset:S,clearBuffer:C,resetHistory:w}=t;if(v?.length){I(),await tO({queuedCommands:v,messages:l,mainLoopModel:u,ideSelection:d,querySource:e.querySource,commands:i,queryGuard:n,setToolJSX:s,getToolUseContext:c,setUserInputOnProcessing:f,setAbortController:p,onQuery:m,setAppState:h,onBeforeQuery:g,resetHistory:w,canUseTool:_,onInputChange:a});return}let T=e.input??``,E=e.mode??`prompt`,O=e.pastedContents??{},k=new Set(Ht(T).map(e=>e.id)),A=Object.fromEntries(Object.entries(O).filter(([,e])=>e.type!==`image`||k.has(e.id))),j=Object.values(A).some(Xt);if(T.trim()===``)return;if(!b&&[`exit`,`quit`,`:q`,`:q!`,`:wq`,`:wq!`].includes(T.trim())){i.find(e=>e.name===`exit`)?eO({...e,input:`/exit`}):$D();return}let M=D(T,A),N=Ht(T).filter(e=>A[e.id]?.type===`text`),ee=N.length;if(X(`tengu_paste_text`,{pastedTextCount:ee,pastedTextBytes:N.reduce((e,t)=>e+(A[t.id]?.content.length??0),0)}),!b&&M.trim().startsWith(`/`)){let t=M.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&&Br(e)&&(e.name===f||e.aliases?.includes(f)||dl(e)===f));if(m&&m.type===`local-jsx`&&(n.isActive||r)){X(`tengu_immediate_command_executed`,{commandName:m.name}),a(``),S(0),o({}),C();let t=c(l,[],On(),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?_i({value:r.nextInput,mode:`prompt`}):a(r.nextInput))},t,p);r&&!n&&s({jsx:r,shouldHidePromptInput:!1,isLocalJSXCommand:!0,isImmediate:!0});return}}if(n.isActive||r){if(E!==`prompt`&&E!==`bash`)return;e.hasInterruptibleToolInProgress&&(J(`[interrupt] Aborting current turn: streamMode=${e.streamMode}`),X(`tengu_cancel`,{source:`interrupt_on_submit`,streamMode:e.streamMode}),e.abortController?.abort(`interrupt`)),_i({value:M.trim(),preExpansionValue:T.trim(),mode:E,pastedContents:j?A:void 0,skipSlashCommands:b,bridgeOrigin:x,uuid:y}),a(``),S(0),o({}),w(),C();return}I(),await tO({queuedCommands:[{value:M,preExpansionValue:T,mode:E,pastedContents:j?A:void 0,skipSlashCommands:b,bridgeOrigin:x,uuid:y}],messages:l,mainLoopModel:u,ideSelection:d,querySource:e.querySource,commands:i,queryGuard:n,setToolJSX:s,getToolUseContext:c,setUserInputOnProcessing:f,setAbortController:p,onQuery:m,setAppState:h,onBeforeQuery:g,resetHistory:w,canUseTool:_,onInputChange:a})}async function tO(e){let{messages:t,mainLoopModel:n,ideSelection:r,querySource:i,queryGuard:a,setToolJSX:o,getToolUseContext:s,setUserInputOnProcessing:c,setAbortController:l,onQuery:u,setAppState:d,onBeforeQuery:f,resetHistory:p,canUseTool:m,queuedCommands:h}=e,g=On();l(g);function _(){return s(t,[],g,n)}try{a.reserve(),cl(`query_process_user_input_start`);let s=[],v=!1,y,b,x,S,C=h??[],w=await kc(C);C=w.attachmentCommands;let T=w.claimedCommands;if(C.length===0){l(null);return}let E=C[0]?.workload,D=E!==void 0&&C.every(e=>e.workload===E)?E:void 0,O=new Set,k;try{await cp(D,async()=>{for(let e=0;e<C.length;e++){let n=C[e],a=e===0,l=n.autonomy?.runId,u=await ah({input:n.value,preExpansionInput:n.preExpansionValue,mode:n.mode,setToolJSX:o,context:_(),pastedContents:a?n.pastedContents:void 0,messages:t,setUserInputOnProcessing:a?c:void 0,isAlreadyProcessing:!a,querySource:i,canUseTool:m,uuid:n.uuid,ideSelection:a?r:void 0,skipSlashCommands:n.skipSlashCommands,bridgeOrigin:n.bridgeOrigin,isMeta:n.isMeta,skipAttachments:!a,autonomy:n.autonomy});l&&u.deferAutonomyCompletion&&O.add(l);let d=n.origin??(n.mode===`task-notification`?{kind:`task-notification`}:void 0);if(d)for(let e of u.messages)e.type===`user`&&(e.origin=d);s.push(...u.messages),a&&(v=u.shouldQuery,y=u.allowedTools,b=u.model,x=u.nextInput,S=u.submitNextInput)}if(cl(`query_process_user_input_end`),es()&&(cl(`query_file_history_snapshot_start`),s.filter(rh).forEach(e=>{Bi(e=>{d(t=>({...t,fileHistory:e(t.fileHistory)}))},e.uuid)}),cl(`query_file_history_snapshot_end`)),s.length){p(),o({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0});let e=C[0],t=e?.mode??`prompt`,r=e&&typeof e.value==`string`?e.value:void 0,i=t===`prompt`;await u(s,g,v,y??[],b?$f(b,n):n,i?f:void 0,r)}else a.cancelReservation(),o({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0}),p(),l(null);x&&(S?_i({value:x,mode:`prompt`}):e.onInputChange(x))})}catch(e){k=e}if(T.length){let e=T.filter(e=>{let t=e.autonomy?.runId;return!t||!O.has(t)});if(k)try{await il({commands:e,outcome:{type:`failed`,error:k},currentDir:id(),priority:`later`,workload:D})}catch(e){Y(dd(e))}else try{let t=await il({commands:e,outcome:{type:`completed`},currentDir:id(),priority:`later`,workload:D});for(let e of t)_i(e)}catch(e){Y(dd(e))}}if(k)throw k}finally{a.cancelReservation(),c(void 0)}}$s();function nO(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 rO({executeInput:e}){let t=e=>e.agentId===void 0,n=Ss(t);if(!n)return{processed:!1};if(nO(n)||n.mode===`bash`)return e([Ot(t)]),{processed:!0};let r=n.mode,i=Di(e=>t(e)&&!nO(e)&&e.mode===r);return i.length===0?{processed:!1}:(e(i),{processed:!0})}$s();function iO({executeQueuedInput:e,hasActiveLocalJsxUI:t,queryGuard:n}){let r=(0,Q.useSyncExternalStore)(n.subscribe,n.getSnapshot),i=(0,Q.useSyncExternalStore)(Jo,Ba);(0,Q.useEffect)(()=>{r||t||i.length!==0&&rO({executeInput:e})},[i,r,e,t,n])}function aO({isLoading:e,onSubmitMessage:t}){let n=Yi();(0,Q.useEffect)(()=>{if(e)return;let r=n.poll();r&&t(r.content)},[e,(0,Q.useSyncExternalStore)((0,Q.useMemo)(()=>n.subscribe.bind(n),[n]),(0,Q.useCallback)(()=>n.revision,[n])),n,t])}function oO(e,t){return e&&t&&t.length>0?xa([...e,...t],`name`):e||[]}function sO(e,t){return(0,Q.useMemo)(()=>oO(e,t),[e,t])}Qi(),nh(),Nh(),yc();function cO(e,t){return(0,Q.useMemo)(()=>t.length>0?xa([...e,...t],`name`):e,[e,t])}Gt(),Sf();function lO(e,t){let n=(0,Q.useCallback)(async()=>{if(e)try{ge(),t(await tn(e))}catch(e){e instanceof Error&&Y(e)}},[e,t]);(0,Q.useEffect)(()=>xh.subscribe(n),[n])}Sf(),vu(),tc(),yu();var uO=gu(()=>uu({method:lu(`selection_changed`),params:uu({selection:uu({start:uu({line:du(),character:du()}),end:uu({line:du(),character:du()})}).nullable().optional(),text:fu().optional(),filePath:fu().optional()})}));function dO(e,t){let n=(0,Q.useRef)(!1),r=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{let i=Gs(e);if(r.current!==(i??null)&&(n.current=!1,r.current=i||null,t({lineCount:0,lineStart:void 0,text:void 0,filePath:void 0})),n.current||!i)return;let a=e=>{if(e.selection?.start&&e.selection?.end){let{start:n,end:r}=e.selection,i=r.line-n.line+1;r.character===0&&i--,t({lineCount:i,lineStart:n.line,text:e.text,filePath:e.filePath})}};i.client.setNotificationHandler(uO(),e=>{if(r.current===i)try{let t=e.params;t.selection?.start&&t.selection.end?a(t):t.text!==void 0&&a({selection:null,text:t.text,filePath:t.filePath})}catch(e){Y(e)}}),n.current=!0},[e,t])}pr(),rt(),Bc(),q(),Fg(),U(),Hf();function fO({task:e,selected:t}){let n=Rg(e.startTime,e.status===`running`),r=e.progress?.tokenCount??0;return(0,$.jsxs)(G,{flexDirection:`row`,width:`100%`,justifyContent:`space-between`,children:[(0,$.jsxs)(G,{flexDirection:`row`,flexShrink:1,children:[(0,$.jsx)(K,{color:e.status===`running`?`success`:void 0,children:t?`● `:`○ `}),(0,$.jsxs)(K,{bold:t,wrap:`truncate-end`,children:[e.agentType,` `,(0,$.jsx)(K,{dimColor:!0,children:e.description})]})]}),(0,$.jsx)(G,{flexShrink:0,children:(0,$.jsxs)(K,{dimColor:!0,children:[n,` · ↓ `,Rf(r),` tokens`]})})]})}function pO(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 mO(){let e=KS(),t=W(e=>e.viewingAgentTaskId),n=W(e=>e.footerSelection),r=W(e=>e.selectedBgAgentIndex);if(e.length===0)return null;let i=n===`bg_agent`,a=i?r===-1?null:e[r]?.agentId??null:t??null,o=i?r===-1:t===void 0,s=t?e.find(e=>e.agentId===t)??null:null;return(0,$.jsxs)(G,{flexDirection:`column`,width:`100%`,children:[(0,$.jsxs)(G,{flexDirection:`row`,width:`100%`,justifyContent:`space-between`,children:[(0,$.jsxs)(K,{bold:o,children:[o?`● `:`○ `,`main`]}),(0,$.jsx)(K,{dimColor:!0,children:pO(i,s)})]}),e.map(e=>(0,$.jsx)(fO,{task:e,selected:e.agentId===a},e.agentId))]})}Cf(),rd(),ua(),gd(),nm();var hO=3e4;function gO(e){let t=(0,Q.useRef)(e);t.current=e,(0,Q.useEffect)(()=>{if(!hm())return;let e=null,n=!1,r=!1;function i(){pm(Date.now()+hO),e=setTimeout(()=>{if(e=null,!um()){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 qc({basePrompt:`<${_f}>${new Date().toLocaleTimeString()}</${_f}>`,currentDir:id(),shouldCreate:()=>!n});if(n){await Vi({commands:e});return}let r=[];try{for(let n of e)t.current.onQueueTick(n),r.push(n)}catch(t){throw await Vi({commands:e.filter(e=>!r.includes(e))}),t}})().catch(e=>J(`[Proactive] failed to create tick: ${e}`,{level:`error`})).finally(()=>{r=!1}),i()},hO)}return i(),()=>{n=!0,e!==null&&(clearTimeout(e),e=null),pm(null)}},[hm(),im(),fm()])}rl(),M();function _O(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 vO(e){let t=mr(e),n=_O(e),r=`Continuation turns executed: ${e.turnsExecuted}`;return`<goal-steering type="continuation">
74
+ You have an active goal to work on. Continue making progress.
75
+
76
+ ## Active Goal
77
+ ${e.objective}
78
+
79
+ ## Status
80
+ - Elapsed active time: ${t}
81
+ - ${n}
82
+ - ${r}
83
+
84
+ ## Instructions
85
+
86
+ 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.
87
+
88
+ When you believe the goal is fully achieved, use the GoalTool to mark it complete. Before doing so, perform a strict Completion Audit:
89
+
90
+ ### Completion Audit
91
+ 1. Derive concrete requirements from the objective and any referenced files.
92
+ 2. Preserve the original scope — do not redefine success around what is already done.
93
+ 3. For every explicit requirement, identify authoritative evidence (test output, file content, command result).
94
+ 4. Treat tests, manifests, and verifiers as evidence only after confirming they actually cover the requirement.
95
+ 5. Treat uncertain or indirect evidence as "not achieved".
96
+ 6. The audit must PROVE completion, not merely fail to find remaining work.
97
+
98
+ ### Blocked Audit
99
+ If you encounter an obstacle you genuinely cannot overcome:
100
+ - Do NOT mark blocked on the first encounter.
101
+ - The same blocking condition must persist for at least 3 consecutive continuation turns before you may mark blocked.
102
+ - "Difficult", "slow", or "partially incomplete" is NOT blocked.
103
+ - If blocked, use the GoalTool with status "blocked" and a clear reason.
104
+
105
+ Resume working now.
106
+ </goal-steering>`}function yO(e){return`<goal-steering type="budget_limit">
107
+ ## Token Budget Reached
108
+
109
+ Your token budget for this goal has been exhausted.
110
+
111
+ - Goal: ${e.objective}
112
+ - Tokens used: ${e.tokensUsed}${e.tokenBudget===null?``:` / ${e.tokenBudget}`}
113
+ - Active time: ${mr(e)}
114
+
115
+ **Stop all substantive work immediately.** Do NOT start new file edits, tool calls, or explorations.
116
+
117
+ Instead, provide a brief summary:
118
+ 1. What has been accomplished so far.
119
+ 2. What remains to be done.
120
+ 3. Any blockers or issues encountered.
121
+
122
+ 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.
123
+ </goal-steering>`}gd(),M(),$s();function bO(e){J(`[goal] hook: ${e}`)}function xO(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?.()){bO(`skip: queryActiveNow=true`);return}if(e.wasAborted){bO(`skip: wasAborted=true`);return}if(n.current)return;if(Ba().length>0){bO(`skip: yielding to queued user messages`);return}if(e.hasActiveLocalJsxUI){bO(`skip: activeLocalJsxUI`);return}if(e.isInPlanMode){bO(`skip: planMode`);return}let t=_e();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=yO(t);J(`[goal] hook: budget limit reached, injecting wrap-up prompt`),_i({value:e,mode:`prompt`,priority:`now`,isMeta:!0,origin:`goal-budget-limit`,skipSlashCommands:!0});return}if(t.status!==`active`){bO(`skip: status="${t.status}" (not active)`);return}if(t.turnsExecuted>=150){jo()&&(la(),e.onMaxTurnsReached?.()),J(`[goal] hook: MAX_GOAL_TURNS (150) reached, stopping`);return}n.current=!0;let i=Bo();la();let a=vO(t);J(`[goal] hook: enqueuing turn ${i} for "${t.objective.slice(0,60)}"`),_i({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])}af(),o(),tc();function SO({autoConnectIdeFlag:e,ideToInstallExtension:t,setDynamicMcpConfig:n,setShowIdeOnboarding:i,setIDEInstallationState:o}){(0,Q.useEffect)(()=>{function s(i){i&&(rf().autoConnectIde||e||xc()||process.env.CLAUDE_CODE_SSE_PORT||t||a(process.env.CLAUDE_CODE_AUTO_CONNECT_IDE))&&!r(process.env.CLAUDE_CODE_AUTO_CONNECT_IDE)&&n(e=>e?.ide?e:{...e,ide:{type:i.url.startsWith(`ws:`)?`ws-ide`:`sse-ide`,url:i.url,ideName:i.name,authToken:i.authToken,ideRunningInWindows:i.ideRunningInWindows,scope:`dynamic`}})}ma(s,t,()=>i(!0),e=>o(e))},[e,t,n,i,o])}og(),no(),q(),vc(),ba(),U(),af(),Od(),o();function CO({onBackgroundSession:e,isLoading:t}){let n=y(),r=Bn(),[i,o]=(0,Q.useState)(!1),s=Gl(o,e,()=>{}),c=(0,Q.useCallback)(()=>{a(process.env.CLAUDE_CODE_DISABLE_BACKGROUND_TASKS)||(Ro(r.getState())?(yn(()=>r.getState(),n),rf().hasUsedBackgroundTask||sf(e=>e.hasUsedBackgroundTask?e:{...e,hasUsedBackgroundTask:!0})):a(`false`)&&t&&s())},[n,r,t,s]),l=W(Ro),u=a(`false`);Ml(`task:background`,c,{context:`Task`,isActive:l||u&&t});let d=Va(`task:background`,`Task`,`ctrl+b`),f=Cd.terminal===`tmux`&&d===`ctrl+b`?`ctrl+b ctrl+b`:d;return!t||!i?null:(0,$.jsx)(G,{paddingLeft:2,children:(0,$.jsx)(K,{dimColor:!0,children:(0,$.jsx)(yl,{shortcut:f,action:`background`})})})}U();function wO({setMessages:e,setIsLoading:t,resetLoadingState:n,setAbortController:r,onBackgroundQuery:i}){let a=W(e=>e.foregroundedTaskId),o=W(e=>e.foregroundedTaskId?e.tasks[e.foregroundedTaskId]:void 0),s=y(),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}}Qo(),q(),op(),af(),S(),pg();function TO({onDone:e}){let t=(0,Q.useRef)(e);t.current=e;let n=(0,Q.useCallback)(()=>{t.current(`dismiss`)},[]);(0,Q.useEffect)(()=>{sf(e=>e.remoteDialogSeen?e:{...e,remoteDialogSeen:!0})},[]);let r=(0,Q.useCallback)(e=>{t.current(e)},[]);return(0,$.jsx)(hg,{title:`Remote Control`,children:(0,$.jsxs)(G,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsxs)(G,{marginBottom:1,flexDirection:`column`,children:[(0,$.jsx)(K,{children:`Remote Control lets you access this CLI session from the web (claude.ai/code) or the Work Mate app, so you can pick up where you left off on any device.`}),(0,$.jsx)(K,{children:` `}),(0,$.jsx)(K,{children:`You can disconnect remote access anytime by running /remote-control again.`})]}),(0,$.jsx)(G,{children:(0,$.jsx)(Hn,{options:[{label:`Enable Remote Control for this session`,description:`Opens a secure connection to claude.ai.`,value:`enable`},{label:`Never mind`,description:`You can always enable it later with /remote-control.`,value:`dismiss`}],onChange:r,onCancel:n})})]})})}$m();function EO(e,t){return t}qs(),Ru(),Bt(),$a(),q(),vc(),ii(),op(),ka(),gd(),Od(),pf(),Sf(),da(),bd(),pa(),Cn(),Ko();function DO(e){let t=e;return t=t.replace(/"(sk-ant[^\s"']{24,})"/g,`"[REDACTED_API_KEY]"`),t=t.replace(/(?<![A-Za-z0-9"'])(sk-ant-?[A-Za-z0-9_-]{10,})(?![A-Za-z0-9"'])/g,`[REDACTED_API_KEY]`),t=t.replace(/AWS key: "(AWS[A-Z0-9]{20,})"/g,`AWS key: "[REDACTED_AWS_KEY]"`),t=t.replace(/(AKIA[A-Z0-9]{16})/g,`[REDACTED_AWS_KEY]`),t=t.replace(/(?<![A-Za-z0-9])(AIza[A-Za-z0-9_-]{35})(?![A-Za-z0-9])/g,`[REDACTED_GCP_KEY]`),t=t.replace(/(?<![A-Za-z0-9])([a-z0-9-]+@[a-z0-9-]+\.iam\.gserviceaccount\.com)(?![A-Za-z0-9])/g,`[REDACTED_GCP_SERVICE_ACCOUNT]`),t=t.replace(/(["']?x-api-key["']?\s*[:=]\s*["']?)[^"',\s)}\]]+/gi,`$1[REDACTED_API_KEY]`),t=t.replace(/(["']?authorization["']?\s*[:=]\s*["']?(bearer\s+)?)[^"',\s)}\]]+/gi,`$1[REDACTED_TOKEN]`),t=t.replace(/(AWS[_-][A-Za-z0-9_]+\s*[=:]\s*)["']?[^"',\s)}\]]+["']?/gi,`$1[REDACTED_AWS_VALUE]`),t=t.replace(/(GOOGLE[_-][A-Za-z0-9_]+\s*[=:]\s*)["']?[^"',\s)}\]]+["']?/gi,`$1[REDACTED_GCP_VALUE]`),t=t.replace(/((API[-_]?KEY|TOKEN|SECRET|PASSWORD)\s*[=:]\s*)["']?[^"',\s)}\]]+["']?/gi,`$1[REDACTED]`),t}p(),op(),gd(),ld(),fp(),Bt(),da(),bd();async function OO(e,t,n){try{J(`Collecting transcript for sharing`,{level:`info`});let r=jt(e),i=await Jt(pi(e)),a;try{let e=go(),{size:t}=await f_(e);t<=52428800?a=await u_(e,`utf-8`):J(`Skipping raw transcript read: file too large (${t} bytes)`,{level:`warn`})}catch{}let o=DO(od({trigger:t,version:`0.0.20`,platform:process.platform,transcript:r,subagentTranscripts:Object.keys(i).length>0?i:void 0,rawTranscriptJsonl:a}));await xp();let s=kp();if(s.error)return{success:!1};let c={"Content-Type":`application/json`,"User-Agent":mp(),...s.headers},l=await f.post(`https://api.anthropic.com/api/claude_code_shared_session_transcripts`,{content:o,appearance_id:n},{headers:c,timeout:3e4});if(l.status===200||l.status===201){let e=l.data;return J(`Transcript shared successfully`,{level:`info`}),{success:!0,transcriptId:e?.transcript_id}}return{success:!1}}catch(e){return J(cd(e),{level:`error`}),{success:!1}}}function kO({hideThanksAfterMs:e,onOpen:t,onSelect:n,shouldShowTranscriptPrompt:r,onTranscriptPromptShown:i,onTranscriptSelect:a}){let[o,s]=(0,Q.useState)(`closed`),[c,l]=(0,Q.useState)(null),u=(0,Q.useRef)(l_()),d=(0,Q.useRef)(null),f=(0,Q.useCallback)(()=>{s(`thanks`),setTimeout((e,t)=>{e(`closed`),t(null)},e,s,l)},[e]),p=(0,Q.useCallback)(()=>{s(`submitted`),setTimeout(s,e,`closed`)},[e]);return{state:o,lastResponse:c,open:(0,Q.useCallback)(()=>{o===`closed`&&(s(`open`),u.current=l_(),t(u.current))},[o,t]),handleSelect:(0,Q.useCallback)(e=>{if(l(e),d.current=e,n(u.current,e),e===`dismissed`)s(`closed`),l(null);else if(r?.(e))return s(`transcript_prompt`),i?.(u.current,e),!0;else f();return!1},[f,n,r,i]),handleTranscriptSelect:(0,Q.useCallback)(e=>{switch(e){case`yes`:s(`submitting`),(async()=>{try{await a?.(u.current,e,d.current)?p():f()}catch{f()}})();break;case`no`:case`dont_ask_again`:a?.(u.current,e,d.current),f();break}},[f,p,a])}}Mf(),af(),o(),Bt(),_p(),Jd();var AO={minTimeBeforeFeedbackMs:6e5,minTimeBetweenFeedbackMs:36e5,minTimeBetweenGlobalFeedbackMs:1e8,minUserTurnsBeforeFeedback:5,minUserTurnsBetweenFeedback:10,hideThanksAfterMs:3e3,onForModels:[`*`],probability:.005},jO={probability:0};function MO(e,t,n,r=`session`,i=!1){let o=(0,Q.useRef)(`unknown`);o.current=vn(e)?.message?.id||`unknown`;let[s,c]=(0,Q.useState)(()=>({timeLastShown:null,submitCountAtLastAppearance:null})),l=EO(`tengu_feedback_survey_config`,AO),u=EO(`tengu_bad_survey_transcript_ask_config`,jO),d=EO(`tengu_good_survey_transcript_ask_config`,jO),f=tf().feedbackSurveyRate,p=(0,Q.useRef)(Date.now()),m=(0,Q.useRef)(n),h=(0,Q.useRef)(n);h.current=n;let g=(0,Q.useRef)(e);g.current=e;let _=(0,Q.useRef)(!1),v=(0,Q.useRef)(null),y=(0,Q.useCallback)((e,t)=>{c(n=>n.timeLastShown===e&&n.submitCountAtLastAppearance===t?n:{timeLastShown:e,submitCountAtLastAppearance:t}),rf().feedbackSurveyState?.lastShownTime!==e&&sf(t=>({...t,feedbackSurveyState:{lastShownTime:e}}))},[]),b=(0,Q.useCallback)(e=>{y(Date.now(),h.current),X(`tengu_feedback_survey_event`,{event_type:`appeared`,appearance_id:e,last_assistant_message_id:o.current,survey_type:r}),Am(`feedback_survey`,{event_type:`appeared`,appearance_id:e,survey_type:r})},[y,r]),x=(0,Q.useCallback)((e,t)=>{y(Date.now(),h.current),X(`tengu_feedback_survey_event`,{event_type:`responded`,appearance_id:e,response:t,last_assistant_message_id:o.current,survey_type:r}),Am(`feedback_survey`,{event_type:`responded`,appearance_id:e,response:t,survey_type:r})},[y,r]),S=(0,Q.useCallback)(e=>{if(e!==`bad`&&e!==`good`||rf().transcriptShareDismissed||!Ji(`allow_product_feedback`))return!1;let t=e===`bad`?u.probability:d.probability;return Math.random()<=t},[u.probability,d.probability]),C=(0,Q.useCallback)((e,t)=>{let n=t===`good`?`good_feedback_survey`:`bad_feedback_survey`;X(`tengu_feedback_survey_event`,{event_type:`transcript_prompt_appeared`,appearance_id:e,last_assistant_message_id:o.current,survey_type:r,trigger:n}),Am(`feedback_survey`,{event_type:`transcript_prompt_appeared`,appearance_id:e,survey_type:r})},[r]),w=(0,Q.useCallback)(async(e,t,n)=>{let i=n===`good`?`good_feedback_survey`:`bad_feedback_survey`;if(X(`tengu_feedback_survey_event`,{event_type:`transcript_share_${t}`,appearance_id:e,last_assistant_message_id:o.current,survey_type:r,trigger:i}),t===`dont_ask_again`&&sf(e=>({...e,transcriptShareDismissed:!0})),t===`yes`){let t=await OO(g.current,i,e);return X(`tengu_feedback_survey_event`,{event_type:t.success?`transcript_share_submitted`:`transcript_share_failed`,appearance_id:e,trigger:i}),t.success}return!1},[r]),{state:T,lastResponse:E,open:D,handleSelect:O,handleTranscriptSelect:k}=kO({hideThanksAfterMs:l.hideThanksAfterMs,onOpen:b,onSelect:x,shouldShowTranscriptPrompt:S,onTranscriptPromptShown:C,onTranscriptSelect:w}),A=jp(),j=(0,Q.useMemo)(()=>l.onForModels.length===0?!1:l.onForModels.includes(`*`)?!0:l.onForModels.includes(A),[l.onForModels,A]),M=(0,Q.useMemo)(()=>{if(T!==`closed`||t||i)return!1;if(process.env.CLAUDE_FORCE_DISPLAY_SURVEY&&!s.timeLastShown)return!0;if(!j||a(process.env.CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY)||zm()||!Ji(`allow_product_feedback`))return!1;if(s.timeLastShown){if(Date.now()-s.timeLastShown<l.minTimeBetweenFeedbackMs||s.submitCountAtLastAppearance!==null&&n<s.submitCountAtLastAppearance+l.minUserTurnsBetweenFeedback)return!1}else if(Date.now()-p.current<l.minTimeBeforeFeedbackMs||n<m.current+l.minUserTurnsBeforeFeedback)return!1;if(v.current!==n&&(v.current=n,_.current=Math.random()<=(f??l.probability)),!_.current)return!1;let e=rf().feedbackSurveyState;return!(e?.lastShownTime&&Date.now()-e.lastShownTime<l.minTimeBetweenGlobalFeedbackMs)},[T,t,i,j,s.timeLastShown,s.submitCountAtLastAppearance,n,l.minTimeBetweenFeedbackMs,l.minTimeBetweenGlobalFeedbackMs,l.minUserTurnsBetweenFeedback,l.minTimeBeforeFeedbackMs,l.minUserTurnsBeforeFeedback,l.probability,f]);return(0,Q.useEffect)(()=>{M&&D()},[M,D]),{state:T,lastResponse:E,handleSelect:O,handleTranscriptSelect:k}}Rm(),Mf(),af(),o(),Bt(),Nm();var NO=3e3,PO=`tengu_memory_survey_event`,FO=`memory_survey`;function IO(e,t,n=!1,{enabled:r=!0}={}){let i=(0,Q.useRef)(new Set),a=(0,Q.useRef)(!1),o=(0,Q.useRef)(e);o.current=e;let{state:s,lastResponse:c,open:l,handleSelect:u,handleTranscriptSelect:d}=kO({hideThanksAfterMs:NO,onOpen:(0,Q.useCallback)(e=>{X(PO,{event_type:`appeared`,appearance_id:e}),Am(`feedback_survey`,{event_type:`appeared`,appearance_id:e,survey_type:`memory`})},[]),onSelect:(0,Q.useCallback)((e,t)=>{X(PO,{event_type:`responded`,appearance_id:e,response:t}),Am(`feedback_survey`,{event_type:`responded`,appearance_id:e,response:t,survey_type:`memory`})},[]),shouldShowTranscriptPrompt:(0,Q.useCallback)(e=>!1,[]),onTranscriptPromptShown:(0,Q.useCallback)(e=>{X(PO,{event_type:`transcript_prompt_appeared`,appearance_id:e,trigger:FO}),Am(`feedback_survey`,{event_type:`transcript_prompt_appeared`,appearance_id:e,survey_type:`memory`})},[]),onTranscriptSelect:(0,Q.useCallback)(async(e,t)=>{if(X(PO,{event_type:`transcript_share_${t}`,appearance_id:e,trigger:FO}),t===`dont_ask_again`&&sf(e=>({...e,transcriptShareDismissed:!0})),t===`yes`){let t=await OO(o.current,FO,e);return X(PO,{event_type:t.success?`transcript_share_submitted`:`transcript_share_failed`,appearance_id:e,trigger:FO}),t.success}return!1},[])});return(0,Q.useEffect)(()=>{if(r&&e.length===0){a.current=!1,i.current.clear();return}},[r,s,t,n,(0,Q.useMemo)(()=>vn(e),[e]),e,l]),{state:s,lastResponse:c,handleSelect:u,handleTranscriptSelect:d}}Rm(),Mf(),o(),Bt(),Nm();var LO=3e3,RO=.2;function zO(e,t){let n=e.findIndex(e=>e.uuid===t);if(n===-1)return!1;for(let t=n+1;t<e.length;t++){let n=e[t];if(n&&(n.type===`user`||n.type===`assistant`))return!0}return!1}function BO(e,t,n=!1,{enabled:r=!0}={}){let[i,o]=(0,Q.useState)(null),s=(0,Q.useRef)(new Set),c=(0,Q.useRef)(null),{state:l,lastResponse:u,open:d,handleSelect:f}=kO({hideThanksAfterMs:LO,onOpen:(0,Q.useCallback)(e=>{X(`tengu_post_compact_survey_event`,{event_type:`appeared`,appearance_id:e,session_memory_compaction_enabled:Vo()}),Am(`feedback_survey`,{event_type:`appeared`,appearance_id:e,survey_type:`post_compact`})},[]),onSelect:(0,Q.useCallback)((e,t)=>{X(`tengu_post_compact_survey_event`,{event_type:`responded`,appearance_id:e,response:t,session_memory_compaction_enabled:Vo()}),Am(`feedback_survey`,{event_type:`responded`,appearance_id:e,response:t,survey_type:`post_compact`})},[])});(0,Q.useEffect)(()=>{r&&o(!1)},[r]);let p=(0,Q.useMemo)(()=>new Set(e.filter(e=>Kn(e)).map(e=>e.uuid)),[e]);return(0,Q.useEffect)(()=>{if(!r||l!==`closed`||t||n||i!==!0||zm()||a(process.env.CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY))return;if(c.current!==null&&zO(e,c.current)){c.current=null,Math.random()<RO&&d();return}let o=Array.from(p).filter(e=>!s.current.has(e));o.length>0&&(s.current=new Set(p),c.current=o[o.length-1])},[r,p,l,t,n,i,e,d]),{state:l,lastResponse:u,handleSelect:f}}Rd(),q();var VO=[`1`,`2`,`3`],HO={1:`yes`,2:`no`,3:`dont_ask_again`},UO=e=>VO.includes(e);function WO({onSelect:e,inputValue:t,setInputValue:n}){return yD({inputValue:t,setInputValue:n,isValidDigit:UO,onDigit:t=>e(HO[t])}),(0,$.jsxs)(G,{flexDirection:`column`,marginTop:1,children:[(0,$.jsxs)(G,{children:[(0,$.jsxs)(K,{color:`ansi:cyan`,children:[Bd,` `]}),(0,$.jsx)(K,{bold:!0,children:`Can we look at your session transcript to help us improve Work Mate?`})]}),(0,$.jsx)(G,{marginLeft:2,children:(0,$.jsx)(K,{dimColor:!0,children:`Learn more: https://code.workmate.com/docs/en/data-usage#session-quality-surveys`})}),(0,$.jsxs)(G,{marginLeft:2,children:[(0,$.jsx)(G,{width:10,children:(0,$.jsxs)(K,{children:[(0,$.jsx)(K,{color:`ansi:cyan`,children:`1`}),`: Yes`]})}),(0,$.jsx)(G,{width:10,children:(0,$.jsxs)(K,{children:[(0,$.jsx)(K,{color:`ansi:cyan`,children:`2`}),`: No`]})}),(0,$.jsx)(G,{children:(0,$.jsxs)(K,{children:[(0,$.jsx)(K,{color:`ansi:cyan`,children:`3`}),`: Don't ask again`]})})]})]})}Mf(),q();function GO({state:e,lastResponse:t,handleSelect:n,handleTranscriptSelect:r,inputValue:i,setInputValue:a,onRequestFeedback:o,message:s}){return e===`closed`?null:e===`thanks`?(0,$.jsx)(qO,{lastResponse:t,inputValue:i,setInputValue:a,onRequestFeedback:o}):e===`submitted`?(0,$.jsx)(G,{marginTop:1,children:(0,$.jsxs)(K,{color:`success`,children:[`✓`,` Thanks for sharing your transcript!`]})}):e===`submitting`?(0,$.jsx)(G,{marginTop:1,children:(0,$.jsxs)(K,{dimColor:!0,children:[`Sharing transcript`,`…`]})}):e===`transcript_prompt`?!r||i&&![`1`,`2`,`3`].includes(i)?null:(0,$.jsx)(WO,{onSelect:r,inputValue:i,setInputValue:a}):i&&!SD(i)?null:(0,$.jsx)(wD,{onSelect:n,inputValue:i,setInputValue:a,message:s})}var KO=e=>e===`1`;function qO({lastResponse:e,inputValue:t,setInputValue:n,onRequestFeedback:r}){let i=r&&e===`good`;return yD({inputValue:t,setInputValue:n,isValidDigit:KO,enabled:!!i,once:!0,onDigit:()=>{X(`tengu_feedback_survey_event`,{event_type:`followup_accepted`,response:e}),r?.()}}),(0,$.jsxs)(G,{marginTop:1,flexDirection:`column`,children:[(0,$.jsx)(K,{color:`success`,children:`Thanks for the feedback!`}),i?(0,$.jsxs)(K,{dimColor:!0,children:[`(Optional) Press [`,(0,$.jsx)(K,{color:`ansi:cyan`,children:`1`}),`] to tell us what went well `,` · `,`/issue`]}):e===`bad`?(0,$.jsx)(K,{dimColor:!0,children:`Use /issue to report model behavior issues.`}):(0,$.jsx)(K,{dimColor:!0,children:`Use /issue to share detailed feedback anytime.`})]})}Jm(),Zm(),Ru(),Si(),Sf();function JO(e){let{addNotification:t}=li(),n=(0,Q.useRef)(!1),r=(0,Q.useRef)(e);r.current=e,(0,Q.useEffect)(()=>{nd()||n.current||(n.current=!0,Promise.resolve().then(()=>r.current()).then(e=>{if(e)for(let n of Array.isArray(e)?e:[e])t(n)}).catch(Y))},[t])}function YO(){JO(async()=>(await Xm()).map((e,t)=>{let n=`low`;return e.type===`error`||e.userActionRequired?n=`high`:(e.type===`path`||e.type===`alias`)&&(n=`medium`),{key:`install-message-${t}-${e.type}`,text:e.message,priority:n,color:e.type===`error`?`error`:`warning`}}))}af(),fd(),gd(),Bt(),_p(),pa(),ii(),q(),Bt();function XO(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=Rl();e!==`blurred`&&e!==`unknown`||o.current?.()},[n]),(0,Q.useEffect)(()=>{Rl()},[n,!1])}Mf(),af(),gd(),o(),ld(),Sf();function ZO(){return a(process.env.CLAUDE_CODE_DISABLE_OFFICIAL_MARKETPLACE_AUTOINSTALL)}var QO={MAX_ATTEMPTS:10,INITIAL_DELAY_MS:3600*1e3,BACKOFF_MULTIPLIER:2,MAX_DELAY_MS:10080*60*1e3};function $O(e){let t=QO.INITIAL_DELAY_MS*QO.BACKOFF_MULTIPLIER**e;return Math.min(t,QO.MAX_DELAY_MS)}function ek(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>=QO.MAX_ATTEMPTS||t===`policy_blocked`||r&&i<r?!1:t===`unknown`||t===`git_unavailable`||t===`gcs_unavailable`||t===void 0}async function tk(){let e=rf();if(!ek(e)){let t=e.officialMarketplaceAutoInstallFailReason??`already_attempted`;return J(`Official marketplace auto-install skipped: ${t}`),{installed:!1,skipped:!0,reason:t}}try{if(ZO())return J(`Official marketplace auto-install disabled via env var, skipping`),sf(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`policy_blocked`})),X(`tengu_official_marketplace_auto_install`,{installed:!1,skipped:!0,policy_blocked:!0}),{installed:!1,skipped:!0,reason:`policy_blocked`};if((await qt())[`claude-plugins-official`])return J(`Official marketplace '${cr}' already installed, skipping`),sf(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!0})),{installed:!1,skipped:!0,reason:`already_installed`};if(!gc(fe))return J(`Official marketplace blocked by enterprise policy, skipping`),sf(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`policy_blocked`})),X(`tengu_official_marketplace_auto_install`,{installed:!1,skipped:!0,policy_blocked:!0}),{installed:!1,skipped:!0,reason:`policy_blocked`};let t=Pn(),n=r_(t,cr);if(await It(n,t)!==null){let e=await qt();return e[cr]={source:fe,installLocation:n,lastUpdated:new Date().toISOString()},await Ar(e),sf(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!0,officialMarketplaceAutoInstallFailReason:void 0,officialMarketplaceAutoInstallRetryCount:void 0,officialMarketplaceAutoInstallLastAttemptTime:void 0,officialMarketplaceAutoInstallNextRetryTime:void 0})),X(`tengu_official_marketplace_auto_install`,{installed:!0,skipped:!1,via_gcs:!0}),{installed:!0,skipped:!1}}if(!await io()){J(`Git not available, skipping official marketplace auto-install`);let t=(e.officialMarketplaceAutoInstallRetryCount||0)+1,n=Date.now(),r=n+$O(t),i=!1;try{sf(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`git_unavailable`,officialMarketplaceAutoInstallRetryCount:t,officialMarketplaceAutoInstallLastAttemptTime:n,officialMarketplaceAutoInstallNextRetryTime:r}))}catch(e){i=!0,Y(dd(e)),J(`Failed to save marketplace auto-install git_unavailable state: ${e}`,{level:`error`})}return X(`tengu_official_marketplace_auto_install`,{installed:!1,skipped:!0,git_unavailable:!0,retry_count:t}),{installed:!1,skipped:!0,reason:`git_unavailable`,configSaveFailed:i}}J(`Attempting to auto-install official marketplace`),await ee(fe),J(`Successfully auto-installed official marketplace`);let r=e.officialMarketplaceAutoInstallRetryCount||0;return sf(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!0,officialMarketplaceAutoInstallFailReason:void 0,officialMarketplaceAutoInstallRetryCount:void 0,officialMarketplaceAutoInstallLastAttemptTime:void 0,officialMarketplaceAutoInstallNextRetryTime:void 0})),X(`tengu_official_marketplace_auto_install`,{installed:!0,skipped:!1,retry_count:r}),{installed:!0,skipped:!1}}catch(t){let n=t instanceof Error?t.message:String(t);if(n.includes(`xcrun: error:`))return jc(),J(`Official marketplace auto-install: git is a non-functional macOS xcrun shim, treating as git_unavailable`),X(`tengu_official_marketplace_auto_install`,{installed:!1,skipped:!0,git_unavailable:!0,macos_xcrun_shim:!0}),{installed:!1,skipped:!0,reason:`git_unavailable`};J(`Failed to auto-install official marketplace: ${n}`,{level:`error`}),Y(dd(t));let r=(e.officialMarketplaceAutoInstallRetryCount||0)+1,i=Date.now(),a=i+$O(r),o=!1;try{sf(e=>({...e,officialMarketplaceAutoInstallAttempted:!0,officialMarketplaceAutoInstalled:!1,officialMarketplaceAutoInstallFailReason:`unknown`,officialMarketplaceAutoInstallRetryCount:r,officialMarketplaceAutoInstallLastAttemptTime:i,officialMarketplaceAutoInstallNextRetryTime:a}))}catch(e){o=!0,Y(dd(e)),J(`Failed to save marketplace auto-install failure state: ${e}`,{level:`error`})}return X(`tengu_official_marketplace_auto_install`,{installed:!1,skipped:!0,failed:!0,retry_count:r}),{installed:!1,skipped:!0,reason:`unknown`,configSaveFailed:o}}}q(),gd();function nk(){JO(async()=>{let e=await tk(),t=[];return e.configSaveFailed&&(J(`Showing marketplace config save failure notification`),t.push({key:`marketplace-config-save-failed`,jsx:(0,$.jsx)(K,{color:`error`,children:`Failed to save marketplace retry info · Check ~/.workmate.json permissions`}),priority:`immediate`,timeoutMs:1e4})),e.installed?(J(`Showing marketplace installation success notification`),t.push({key:`marketplace-installed`,jsx:(0,$.jsx)(K,{color:`success`,children:`✓ Official marketplace installed · /plugin to see available plugins`}),priority:`immediate`,timeoutMs:7e3})):e.skipped&&e.reason===`unknown`&&(J(`Showing marketplace installation failure notification`),t.push({key:`marketplace-install-failed`,jsx:(0,$.jsx)(K,{color:`warning`,children:`Failed to install official marketplace · Will retry on next startup`}),priority:`immediate`,timeoutMs:8e3})),t})}Jd(),Mf();function rk(e){if(e.length===0)return;if(e.length===1)return e[0];let t=e.map(e=>({tip:e,sessions:Wg(e.id)}));return t.sort((e,t)=>t.sessions-e.sessions),t[0]?.tip}async function ik(e){if(qd().spinnerTipsEnabled===!1)return;let t=await Kg(e);if(t.length!==0)return rk(t)}function ak(e){Ug(e.id),X(`tengu_tip_shown`,{tipIdLength:e.id,cooldownSessions:e.cooldownSessions})}ld(),Sf(),Ru(),U(),ra();async function ok(e,t,n){}function sk(){let e=W(e=>e.mainLoopModel),t=W(e=>e.mainLoopModelForSession),n=W(e=>e.fastMode),r=y(),i=Bn(),a=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>{nd()||(a.current&&(a.current=!1),ok(i.getState().toolPermissionContext,r,n).catch(e=>{Y(Error(`Auto mode gate check failed`,{cause:dd(e)}))}))},[e,t,n])}ca();function ck(e,t,n){let r=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{!es()||r.current||(r.current=!0,e&&Dc(e,n))},[t,e,n])}q(),uc(),S(),pg();function lk({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`},..._o()?[]:[{label:(0,$.jsxs)(K,{children:[`Yes, and don't ask again for `,(0,$.jsx)(K,{bold:!0,children:e})]}),value:`yes-dont-ask-again`}],{label:(0,$.jsxs)(K,{children:[`No, and tell Work Mate what to do differently `,(0,$.jsx)(K,{bold:!0,children:`(esc)`})]}),value:`no`}];return(0,$.jsx)(hg,{title:`Network request outside of sandbox`,children:(0,$.jsxs)(G,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsxs)(G,{children:[(0,$.jsx)(K,{dimColor:!0,children:`Host:`}),(0,$.jsxs)(K,{children:[` `,e]})]}),(0,$.jsx)(G,{marginTop:1,children:(0,$.jsx)(K,{children:`Do you want to allow this connection?`})}),(0,$.jsx)(G,{children:(0,$.jsx)(Hn,{options:r,onChange:n,onCancel:()=>{t({allow:!1,persistToSettings:!1})}})})]})})}q(),uc(),kf();function uk(e){return`${e.getHours()%12||12}:${String(e.getMinutes()).padStart(2,`0`)}:${String(e.getSeconds()).padStart(2,`0`)}${e.getHours()<12?`am`:`pm`}`}function dk(){let[e,t]=(0,Q.useState)([]),[n,r]=(0,Q.useState)(0);return(0,Q.useEffect)(()=>{let e=Wn.getSandboxViolationStore();return e.subscribe(n=>{t(n.slice(-10)),r(e.getTotalCount())})},[]),!Wn.isSandboxingEnabled()||Of()===`linux`||n===0?null:(0,$.jsxs)(G,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(G,{marginLeft:0,children:(0,$.jsxs)(K,{color:`permission`,children:[`⧈ Sandbox blocked `,n,` total `,n===1?`operation`:`operations`]})}),e.map((e,t)=>(0,$.jsx)(G,{paddingLeft:2,children:(0,$.jsxs)(K,{dimColor:!0,children:[uk(e.timestamp),e.command?` ${e.command}:`:``,` `,e.line]})},`${e.timestamp.getTime()}-${t}`)),(0,$.jsx)(G,{paddingLeft:2,children:(0,$.jsxs)(K,{dimColor:!0,children:[`… showing last `,Math.min(10,e.length),` of `,n]})})]})}rg(),Si(),Ru(),q();var fk=[];function pk({mcpClients:e=fk}){let{addNotification:t}=li();(0,Q.useEffect)(()=>{if(nd())return;let n=e.filter(e=>e.type===`failed`&&e.config.type!==`sse-ide`&&e.config.type!==`ws-ide`&&e.config.type!==`claudeai-proxy`),r=e.filter(e=>e.type===`failed`&&e.config.type===`claudeai-proxy`&&gl(e.name)),i=e.filter(e=>e.type===`needs-auth`&&e.config.type!==`claudeai-proxy`),a=e.filter(e=>e.type===`needs-auth`&&e.config.type===`claudeai-proxy`&&gl(e.name));n.length===0&&r.length===0&&i.length===0&&a.length===0||(n.length>0&&t({key:`mcp-failed`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(K,{color:`error`,children:[n.length,` MCP `,n.length===1?`server`:`servers`,` failed`]}),(0,$.jsx)(K,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}),r.length>0&&t({key:`mcp-claudeai-failed`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(K,{color:`error`,children:[r.length,` claude.ai `,r.length===1?`connector`:`connectors`,` `,`unavailable`]}),(0,$.jsx)(K,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}),i.length>0&&t({key:`mcp-needs-auth`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(K,{color:`warning`,children:[i.length,` MCP `,i.length===1?`server needs`:`servers need`,` `,`auth`]}),(0,$.jsx)(K,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}),a.length>0&&t({key:`mcp-claudeai-needs-auth`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(K,{color:`warning`,children:[a.length,` claude.ai`,` `,a.length===1?`connector needs`:`connectors need`,` auth`]}),(0,$.jsx)(K,{dimColor:!0,children:` · /mcp`})]}),priority:`medium`}))},[t,e])}q(),Jd(),Fi();var mk=`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.`;ru(),Ru(),Si(),q(),U(),gd(),o();var hk=5e3;function gk(){let{addNotification:e}=li(),t=y(),[n,r]=Q.useState(()=>a(`true`)),i=Q.useRef(new Set),o=Q.useCallback((n,r)=>{let a=`${n}:${r}`;if(i.current.has(a))return;i.current.add(a),J(`LSP error: ${n} - ${r}`),t(e=>{let t=new Set(e.plugins.errors.map(e=>e.type===`generic-error`?`generic-error:${e.source}:${e.error}`:`${e.type}:${e.source}`)),i=`generic-error:${n}:${r}`;return t.has(i)?e:{...e,plugins:{...e.plugins,errors:[...e.plugins.errors,{type:`generic-error`,source:n,error:r}]}}});let o=n.startsWith(`plugin:`)?n.split(`:`)[1]??n:n;e({key:`lsp-error-${n}`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(K,{color:`error`,children:[`LSP for `,o,` failed`]}),(0,$.jsx)(K,{dimColor:!0,children:` · /plugin for details`})]}),priority:`medium`,timeoutMs:8e3})},[e,t]),s=Q.useCallback(()=>{if(nd()||wu())return;let e=Ds();if(e.status===`failed`){o(`lsp-manager`,e.error.message),r(!1);return}if(e.status===`pending`||e.status===`not-started`)return;let t=ts();if(t){let e=t.getAllServers();for(let[t,n]of e)n.state===`error`&&n.lastError&&o(t,n.lastError.message)}},[o]);Vl(s,n?hk:null),Q.useEffect(()=>{nd()||!n||s()},[s,n])}gd();var _k=new Map;async function vk(e){if(!e?.trim())return J(`[binaryCheck] Empty command provided, returning false`),!1;let t=e.trim(),n=_k.get(t);if(n!==void 0)return J(`[binaryCheck] Cache hit for '${t}': ${n}`),n;let r=!1;return await Ef(t).catch(()=>null)&&(r=!0),_k.set(t,r),J(`[binaryCheck] Binary '${t}' ${r?`found`:`not found`}`),r}af(),gd(),ht();var yk=5;function bk(e){return ef.has(e.toLowerCase())}function xk(e){if(!e)return null;if(typeof e==`string`)return J(`[lspRecommendation] Skipping string path lspServers (not readable from marketplace)`),null;if(Array.isArray(e)){for(let t of e){if(typeof t==`string`)continue;let e=Ck(t);if(e)return e}return null}return Ck(e)}function Sk(e){return typeof e==`object`&&!!e}function Ck(e){let t=new Set,n=null;for(let[r,i]of Object.entries(e)){if(!Sk(i))continue;!n&&typeof i.command==`string`&&(n=i.command);let e=i.extensionToLanguage;if(Sk(e))for(let n of Object.keys(e))t.add(n.toLowerCase())}return!n||t.size===0?null:{extensions:t,command:n}}async function wk(){let e=new Map;try{let t=await qt();for(let n of Object.keys(t))try{let t=await fn(n),r=bk(n);for(let i of t.plugins){if(!i.lspServers)continue;let t=xk(i.lspServers);if(!t)continue;let a=`${i.name}@${n}`;e.set(a,{entry:i,marketplaceName:n,extensions:t.extensions,command:t.command,isOfficial:r})}}catch(e){J(`[lspRecommendation] Failed to load marketplace ${n}: ${e}`)}}catch(e){J(`[lspRecommendation] Failed to load marketplaces config: ${e}`)}return e}async function Tk(e){if(Ok())return J(`[lspRecommendation] Recommendations are disabled`),[];let t=n_(e).toLowerCase();if(!t)return J(`[lspRecommendation] No file extension found`),[];J(`[lspRecommendation] Looking for LSP plugins for ${t}`);let n=await wk(),r=rf().lspRecommendationNeverPlugins??[],i=[];for(let[e,a]of n)if(a.extensions.has(t)){if(r.includes(e)){J(`[lspRecommendation] Skipping ${e} (in never suggest list)`);continue}if(gr(e)){J(`[lspRecommendation] Skipping ${e} (already installed)`);continue}i.push({info:a,pluginId:e})}let a=[];for(let{info:e,pluginId:t}of i)await vk(e.command)?(a.push({info:e,pluginId:t}),J(`[lspRecommendation] Binary '${e.command}' found for ${t}`)):J(`[lspRecommendation] Skipping ${t} (binary '${e.command}' not found)`);return a.sort((e,t)=>e.info.isOfficial&&!t.info.isOfficial?-1:!e.info.isOfficial&&t.info.isOfficial?1:0),a.map(({info:e,pluginId:t})=>({pluginId:t,pluginName:e.entry.name,marketplaceName:e.marketplaceName,description:e.entry.description,isOfficial:e.isOfficial,extensions:Array.from(e.extensions),command:e.command}))}function Ek(e){sf(t=>{let n=t.lspRecommendationNeverPlugins??[];return n.includes(e)?t:{...t,lspRecommendationNeverPlugins:[...n,e]}}),J(`[lspRecommendation] Added ${e} to never suggest`)}function Dk(){sf(e=>{let t=(e.lspRecommendationIgnoredCount??0)+1;return{...e,lspRecommendationIgnoredCount:t}}),J(`[lspRecommendation] Incremented ignored count`)}function Ok(){let e=rf();return e.lspRecommendationDisabled===!0||(e.lspRecommendationIgnoredCount??0)>=yk}l(),Ru(),q(),Sf(),ht();function kk(){let[e,t]=Q.useState(null),n=Q.useRef(!1),r=Q.useCallback(r=>{nd()||e||n.current||(n.current=!0,r().then(e=>{e&&t(e)}).catch(Y).finally(()=>{n.current=!1}))},[e]);return{recommendation:e,clearRecommendation:Q.useCallback(()=>t(null),[]),tryResolve:r}}async function Ak(e,t,n,r,i){try{let a=await Re(e);if(!a)throw Error(`Plugin ${e} not found in marketplace`);await i(a),r({key:`${n}-installed`,jsx:(0,$.jsxs)(K,{color:`success`,children:[u.tick,` `,t,` installed · restart to apply`]}),priority:`immediate`,timeoutMs:5e3})}catch(e){Y(e),r({key:`${n}-install-failed`,jsx:(0,$.jsxs)(K,{color:`error`,children:[`Failed to install `,t]}),priority:`immediate`,timeoutMs:5e3})}}Ru(),Si(),U(),af(),gd(),Sf(),Jd();var jk=28e3;function Mk(){let e=W(e=>e.fileHistory.trackedFiles),{addNotification:t}=li(),n=Q.useRef(new Set),{recommendation:r,clearRecommendation:i,tryResolve:a}=kk();return Q.useEffect(()=>{a(async()=>{if(Tu())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 Tk(e))[0];if(t)return J(`[useLspPluginRecommendation] Found match: ${t.pluginName} for ${e}`),Su(!0),{pluginId:t.pluginId,pluginName:t.pluginName,pluginDescription:t.description,fileExtension:n_(e),shownAt:Date.now()}}catch(e){Y(e)}return null})},[e,a]),{recommendation:r,handleResponse:Q.useCallback(e=>{if(!r)return;let{pluginId:n,pluginName:a,shownAt:o}=r;switch(J(`[useLspPluginRecommendation] User response: ${e} for ${a}`),e){case`yes`:Ak(n,a,`lsp-plugin`,t,async e=>{J(`[useLspPluginRecommendation] Installing plugin: ${n}`);let t=typeof e.entry.source==`string`?r_(e.marketplaceInstallLocation,e.entry.source):void 0;await Ya(n,e.entry,`user`,void 0,t),Wd(`userSettings`,{enabledPlugins:{...Qd(`userSettings`)?.enabledPlugins,[n]:!0}}),J(`[useLspPluginRecommendation] Plugin installed: ${n}`)});break;case`no`:{let e=Date.now()-o;e>=jk&&(J(`[useLspPluginRecommendation] Timeout detected (${e}ms), incrementing ignored count`),Dk());break}case`never`:Ek(n);break;case`disable`:sf(e=>e.lspRecommendationDisabled?e:{...e,lspRecommendationDisabled:!0});break}i()},[r,t,i])}}q(),S(),pg();var Nk=3e4;function Pk({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`),Nk,i);return()=>clearTimeout(e)},[]);function a(e){switch(e){case`yes`:r(`yes`);break;case`no`:r(`no`);break;case`never`:r(`never`);break;case`disable`:r(`disable`);break}}return(0,$.jsx)(hg,{title:`LSP Plugin Recommendation`,children:(0,$.jsxs)(G,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(G,{marginBottom:1,children:(0,$.jsx)(K,{dimColor:!0,children:`LSP provides code intelligence like go-to-definition and error checking`})}),(0,$.jsxs)(G,{children:[(0,$.jsx)(K,{dimColor:!0,children:`Plugin:`}),(0,$.jsxs)(K,{children:[` `,e]})]}),t&&(0,$.jsx)(G,{children:(0,$.jsx)(K,{dimColor:!0,children:t})}),(0,$.jsxs)(G,{children:[(0,$.jsx)(K,{dimColor:!0,children:`Triggered by:`}),(0,$.jsxs)(K,{children:[` `,n,` files`]})]}),(0,$.jsx)(G,{marginTop:1,children:(0,$.jsx)(K,{children:`Would you like to install this LSP plugin?`})}),(0,$.jsx)(G,{children:(0,$.jsx)(Hn,{options:[{label:(0,$.jsxs)(K,{children:[`Yes, install `,(0,$.jsx)(K,{bold:!0,children:e})]}),value:`yes`},{label:`No, not now`,value:`no`},{label:(0,$.jsxs)(K,{children:[`Never for `,(0,$.jsx)(K,{bold:!0,children:e})]}),value:`never`},{label:`Disable all LSP recommendations`,value:`disable`}],onChange:a,onCancel:()=>r(`no`)})})]})})}Si(),Mf(),gd(),ns();function Fk(){let e=Q.useSyncExternalStore(fr,H),{addNotification:t}=li(),{recommendation:n,clearRecommendation:r,tryResolve:i}=kk();return Q.useEffect(()=>{e&&i(async()=>{let t=await qo(e);return t&&(J(`[useClaudeCodeHintRecommendation] surfacing ${t.pluginId} from ${t.sourceCommand}`),Pc()),H()===e&&Kc(),t})},[e,i]),{recommendation:n,handleResponse:Q.useCallback(e=>{if(n){switch(ga(n.pluginId),X(`tengu_plugin_hint_response`,{_PROTO_plugin_name:n.pluginName,_PROTO_marketplace_name:n.marketplaceName,response:e}),e){case`yes`:{let{pluginId:e,pluginName:r,marketplaceName:i}=n;Ak(e,r,`hint-plugin`,t,async t=>{let n=await ho({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`:hs();break;case`no`:break}r()}},[n,t,r])}}q(),S(),pg();var Ik=3e4;function Lk({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`),Ik,a);return()=>clearTimeout(e)},[]);function o(e){switch(e){case`yes`:i(`yes`);break;case`disable`:i(`disable`);break;default:i(`no`)}}return(0,$.jsx)(hg,{title:`Plugin Recommendation`,children:(0,$.jsxs)(G,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(G,{marginBottom:1,children:(0,$.jsxs)(K,{dimColor:!0,children:[`The `,(0,$.jsx)(K,{bold:!0,children:r}),` command suggests installing a plugin.`]})}),(0,$.jsxs)(G,{children:[(0,$.jsx)(K,{dimColor:!0,children:`Plugin:`}),(0,$.jsxs)(K,{children:[` `,e]})]}),(0,$.jsxs)(G,{children:[(0,$.jsx)(K,{dimColor:!0,children:`Marketplace:`}),(0,$.jsxs)(K,{children:[` `,n]})]}),t&&(0,$.jsx)(G,{children:(0,$.jsx)(K,{dimColor:!0,children:t})}),(0,$.jsx)(G,{marginTop:1,children:(0,$.jsx)(K,{children:`Would you like to install it?`})}),(0,$.jsx)(G,{children:(0,$.jsx)(Hn,{options:[{label:(0,$.jsxs)(K,{children:[`Yes, install `,(0,$.jsx)(K,{bold:!0,children:e})]}),value:`yes`},{label:`No`,value:`no`},{label:`No, and don't show plugin installation hints again`,value:`disable`}],onChange:o,onCancel:()=>i(`no`)})})]})})}S(),pg();var Rk=3e4;function zk({tools:e,onSelect:t,onDismiss:n}){let r=Q.useRef(t),i=Q.useRef(n);r.current=t,i.current=n,Q.useEffect(()=>{let e=setTimeout(e=>e.current(),Rk,i);return()=>clearTimeout(e)},[]);let a=e.map(e=>({label:`${e.name} — ${e.description.slice(0,60)} (score: ${e.score.toFixed(2)})`,value:e.name}));return a.push({label:`Dismiss`,value:`__dismiss__`}),(0,$.jsx)(hg,{title:`Tool Recommendation`,children:(0,$.jsx)(Hn,{options:a,onChange:e=>{e===`__dismiss__`?i.current():(i.current(),r.current(e))}})})}var Bk=.15,Vk=3;function Hk(){let e=Q.useSyncExternalStore(sl,Wi),t=Q.useMemo(()=>e.length===0?[]:e.slice(0,Vk).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)>=Bk,handleSelect:Q.useCallback(e=>{ao()},[]),handleDismiss:Q.useCallback(()=>{ao()},[])}}Ru(),rd(),gd(),mf(),Sd();var Uk=`1.1.2396`;function Wk(){let e=[process.argv[1]||``,process.execPath||``],t=[`/build-ant/`,`/build-ant-native/`,`/build-external/`,`/build-external-native/`];return e.some(e=>t.some(t=>e.includes(t)))}function Gk(e){let t=Wk()?`claude-dev`:`claude`,n=new URL(`${t}://resume`);return n.searchParams.set(`session`,e),n.searchParams.set(`cwd`,id()),n.toString()}async function Kk(){if(Wk())return!0;let e=process.platform;if(e===`darwin`)return Pd(`/Applications/Work Mate.app`);if(e===`linux`){let{code:e,stdout:t}=await hf(`xdg-mime`,[`query`,`default`,`x-scheme-handler/claude`]);return e===0&&t.trim().length>0}else if(e===`win32`){let{code:e}=await hf(`reg`,[`query`,`HKEY_CLASSES_ROOT\\claude`,`/ve`]);return e===0}return!1}async function qk(){let e=process.platform;if(e===`darwin`){let{code:e,stdout:t}=await hf(`defaults`,[`read`,`/Applications/Work Mate.app/Contents/Info.plist`,`CFBundleShortVersionString`]);if(e!==0)return null;let n=t.trim();return n.length>0?n:null}else if(e===`win32`){let e=process.env.LOCALAPPDATA;if(!e)return null;let t=r_(e,`AnthropicClaude`);try{let e=(await d_(t)).filter(e=>e.startsWith(`app-`)).map(e=>e.slice(4)).filter(e=>(0,Kv.coerce)(e)!==null).sort((e,t)=>{let n=(0,Kv.coerce)(e),r=(0,Kv.coerce)(t);return n.compare(r)});return e.length>0?e[e.length-1]:null}catch{return null}}return null}async function Jk(){if(!await Kk())return{status:`not-installed`};let e;try{e=await qk()}catch{return{status:`ready`,version:`unknown`}}if(!e)return{status:`ready`,version:`unknown`};let t=(0,Kv.coerce)(e);return!t||!tm(t.version,Uk)?{status:`version-too-old`,version:e}:{status:`ready`,version:e}}async function Yk(e){let t=process.platform;if(J(`Opening deep link: ${e}`),t===`darwin`){if(Wk()){let{code:t}=await hf(`osascript`,[`-e`,`tell application "Electron" to open location "${e}"`]);return t===0}let{code:t}=await hf(`open`,[e]);return t===0}else if(t===`linux`){let{code:t}=await hf(`xdg-open`,[e]);return t===0}else if(t===`win32`){let{code:t}=await hf(`cmd`,[`/c`,`start`,``,e]);return t===0}return!1}async function Xk(){let e=Wu();if(!await Kk())return{success:!1,error:`Work Mate Desktop is not installed. Install it from https://claude.ai/download`};let t=Gk(e);return await Yk(t)?{success:!0,deepLinkUrl:t}:{success:!1,error:`Failed to open Work Mate Desktop. Please try opening it manually.`,deepLinkUrl:t}}q(),ka(),ld(),_(),da();var Zk=`https://clau.de/desktop`;function Qk(){switch(process.platform){case`win32`:return`https://claude.ai/api/desktop/win32/x64/exe/latest/redirect`;default:return`https://claude.ai/api/desktop/darwin/universal/dmg/latest/redirect`}}function $k({onDone:e}){let[t,n]=(0,Q.useState)(`checking`),[r,i]=(0,Q.useState)(null),[a,o]=(0,Q.useState)(``);return ql(n=>{if(t===`error`){e(r??`Unknown error`,{display:`system`});return}t===`prompt-download`&&(n===`y`||n===`Y`?(lc(Qk()).catch(()=>{}),e(`Starting download. Re-run /desktop once you\u2019ve installed the app.\nLearn more at ${Zk}`,{display:`system`})):(n===`n`||n===`N`)&&e(`The desktop app is required for /desktop. Learn more at ${Zk}`,{display:`system`}))}),(0,Q.useEffect)(()=>{async function t(){n(`checking`);let t=await Jk();if(t.status===`not-installed`){o(`Work Mate Desktop is not installed.`),n(`prompt-download`);return}if(t.status===`version-too-old`){o(`Work Mate Desktop needs to be updated (found v${t.version}, need v1.1.2396+).`),n(`prompt-download`);return}n(`flushing`),await b(),n(`opening`);let r=await Xk();if(!r.success){i(r.error??`Failed to open Work Mate Desktop`),n(`error`);return}n(`success`),setTimeout(async e=>{e(`Session transferred to Work Mate Desktop`,{display:`system`}),await ji(0,`other`)},500,e)}t().catch(e=>{i(cd(e)),n(`error`)})},[e]),t===`error`?(0,$.jsxs)(G,{flexDirection:`column`,paddingX:2,children:[(0,$.jsxs)(K,{color:`error`,children:[`Error: `,r]}),(0,$.jsx)(K,{dimColor:!0,children:`Press any key to continue…`})]}):t===`prompt-download`?(0,$.jsxs)(G,{flexDirection:`column`,paddingX:2,children:[(0,$.jsx)(K,{children:a}),(0,$.jsx)(K,{children:`Download now? (y/n)`})]}):(0,$.jsx)($l,{message:{checking:`Checking for Work Mate Desktop…`,flushing:`Saving session…`,opening:`Opening Work Mate Desktop…`,success:`Opening in Work Mate Desktop…`}[t]})}q(),Mf(),af(),S(),pg();var eA={enable_shortcut_tip:!1,enable_startup_dialog:!1};function tA(){return eA}function nA(){return process.platform===`darwin`||process.platform===`win32`&&process.arch===`x64`}function rA(){if(!nA()||!tA().enable_startup_dialog)return!1;let e=rf();return!(e.desktopUpsellDismissed||(e.desktopUpsellSeenCount??0)>=3)}function iA({onDone:e}){let[t,n]=(0,Q.useState)(!1);if((0,Q.useEffect)(()=>{let e=(rf().desktopUpsellSeenCount??0)+1;sf(t=>(t.desktopUpsellSeenCount??0)>=e?t:{...t,desktopUpsellSeenCount:e}),X(`tengu_desktop_upsell_shown`,{seen_count:e})},[]),t)return(0,$.jsx)($k,{onDone:()=>e()});function r(t){switch(t){case`try`:n(!0);return;case`never`:sf(e=>e.desktopUpsellDismissed?e:{...e,desktopUpsellDismissed:!0}),e();return;case`not-now`:e();return}}return(0,$.jsx)(hg,{title:`Try Work Mate Desktop`,children:(0,$.jsxs)(G,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,$.jsx)(G,{marginBottom:1,children:(0,$.jsx)(K,{children:`Same Work Mate with visual diffs, live app preview, parallel sessions, and more.`})}),(0,$.jsx)(Hn,{options:[{label:`Open in Work Mate Desktop`,value:`try`},{label:`Not now`,value:`not-now`},{label:`Don't ask again`,value:`never`}],onChange:r,onCancel:()=>r(`not-now`)})]})})}Ru(),Si(),q(),U(),gd(),Jf();function aA(){let{addNotification:e}=li(),t=W(e=>e.plugins.installationStatus),{totalFailed:n,failedMarketplacesCount:r,failedPluginsCount:i}=(0,Q.useMemo)(()=>{if(!t)return{totalFailed:0,failedMarketplacesCount:0,failedPluginsCount:0};let e=t.marketplaces.filter(e=>e.status===`failed`),n=t.plugins.filter(e=>e.status===`failed`);return{totalFailed:e.length+n.length,failedMarketplacesCount:e.length,failedPluginsCount:n.length}},[t]);(0,Q.useEffect)(()=>{if(!nd()){if(!t){J(`No installation status to monitor`);return}n!==0&&(J(`Plugin installation status: ${r} failed marketplaces, ${i} failed plugins`),n!==0&&(J(`Adding notification for ${n} failed installations`),e({key:`plugin-install-failed`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(K,{color:`error`,children:[n,` `,qf(n,`plugin`),` failed to install`]}),(0,$.jsx)(K,{dimColor:!0,children:` · /plugin for details`})]}),priority:`medium`})))}},[e,n,r,i])}Ru(),Si(),q(),gd(),xg();function oA(){let{addNotification:e}=li(),[t,n]=(0,Q.useState)([]);(0,Q.useEffect)(()=>{if(!nd())return Sg(e=>{J(`Plugin autoupdate notification: ${e.length} plugin(s) updated`),n(e)})},[]),(0,Q.useEffect)(()=>{if(nd()||t.length===0)return;let n=t.map(e=>{let t=e.indexOf(`@`);return t>0?e.substring(0,t):e}),r=n.length<=2?n.join(` and `):`${n.length} plugins`;e({key:`plugin-autoupdate-restart`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(K,{color:`success`,children:[n.length===1?`Plugin`:`Plugins`,` updated: `,r]}),(0,$.jsx)(K,{dimColor:!0,children:` · Run /reload-plugins to apply`})]}),priority:`low`,timeoutMs:1e4}),J(`Showing plugin autoupdate notification for: ${n.join(`, `)}`)},[t,e])}gd(),Sf(),ht(),Th(),Mf();function sA(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 cA(e){J(`performBackgroundPluginInstallations called`);try{let t=Ch(nn(),await qt().catch(()=>({}))),n=[...t.missing,...t.sourceChanged.map(e=>e.name)];if(e(e=>({...e,plugins:{...e.plugins,installationStatus:{marketplaces:n.map(e=>({name:e,status:`pending`})),plugins:[]}}})),n.length===0)return;J(`Installing ${n.length} marketplace(s) in background`);let r=await Sh({onProgress:t=>{switch(t.type){case`installing`:sA(e,t.name,`installing`);break;case`installed`:sA(e,t.name,`installed`);break;case`failed`:sA(e,t.name,`failed`,t.error);break}}}),i={installed_count:r.installed.length,updated_count:r.updated.length,failed_count:r.failed.length,up_to_date_count:r.upToDate.length};if(X(`tengu_marketplace_background_install`,i),df(`info`,`tengu_marketplace_background_install`,i),r.installed.length>0){Mo(),J(`Auto-refreshing plugins after ${r.installed.length} new marketplace(s) installed`);try{await wh(e)}catch(t){Y(t),J(`Auto-refresh failed, falling back to needsRefresh: ${t}`,{level:`warn`}),To(`performBackgroundPluginInstallations: auto-refresh failed`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}})}}else r.updated.length>0&&(Mo(),To(`performBackgroundPluginInstallations: marketplaces reconciled`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}}))}catch(e){Y(e)}}af(),gd(),ht(),_a();async function lA(e){if(J(`performStartupChecks called`),!of()){J(`Trust not accepted for current directory - skipping plugin installations`);return}try{J(`Starting background plugin installations`),await Hr()&&(Mo(),To(`performStartupChecks: seed marketplaces changed`),e(e=>e.plugins.needsRefresh?e:{...e,plugins:{...e.plugins,needsRefresh:!0}})),await cA(e)}catch(e){J(`Error initiating background plugin installations: ${e}`)}}q();var uA=/https?:\/\/\S+/;function dA(){let[e,t]=(0,Q.useState)(Mp.getInstance().getStatus());return(0,Q.useEffect)(()=>Mp.getInstance().subscribe(t),[]),!e.isAuthenticating&&!e.error&&e.output.length===0||!e.isAuthenticating&&!e.error?null:(0,$.jsxs)(G,{flexDirection:`column`,borderStyle:`round`,borderColor:`permission`,paddingX:1,marginY:1,children:[(0,$.jsx)(K,{bold:!0,color:`permission`,children:`Cloud Authentication`}),e.output.length>0&&(0,$.jsx)(G,{flexDirection:`column`,marginTop:1,children:e.output.slice(-5).map((e,t)=>{let n=e.match(uA);if(!n)return(0,$.jsx)(K,{dimColor:!0,children:e},t);let r=n[0],i=n.index??0,a=e.slice(0,i),o=e.slice(i+r.length);return(0,$.jsxs)(K,{dimColor:!0,children:[a,(0,$.jsx)(El,{url:r,children:r}),o]},t)})}),e.error&&(0,$.jsx)(G,{marginTop:1,children:(0,$.jsx)(K,{color:`error`,children:e.error})})]})}Si(),q(),Yt(),op(),ti(),Ru();function fA(e){let{addNotification:t}=li(),n=MS(),r=(0,Q.useMemo)(()=>hl(n,e),[n,e]),i=(0,Q.useMemo)(()=>oe(n),[n]),a=(0,Q.useRef)(null),o=Ep(),s=ot(),c=o===`team`||o===`enterprise`,[l,u]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{nd()||(n.isUsingOverage&&!l&&(!c||s)?(t({key:`limit-reached`,text:i,priority:`immediate`}),u(!0)):!n.isUsingOverage&&l&&u(!1))},[n.isUsingOverage,i,l,t,s,c]),(0,Q.useEffect)(()=>{nd()||r&&r!==a.current&&(a.current=r,t({key:`rate-limit-warning`,jsx:(0,$.jsx)(K,{children:(0,$.jsx)(K,{color:`warning`,children:r})}),priority:`high`}))},[r,t])}Si(),Ru();function pA(e){let{addNotification:t}=li(),n=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(nd())return;let r=Gg(e);r&&r!==n.current&&(n.current=r,t({key:`model-deprecation-warning`,text:r,color:`warning`,priority:`high`})),r||(n.current=null)},[e,t])}o();var mA=``;function hA(){JO(async()=>Uf()||a(process.env.DISABLE_INSTALLATION_CHECKS)||await Ym()===`development`?null:{timeoutMs:15e3,key:`npm-deprecation-warning`,text:mA,color:`warning`,priority:`high`})}Si(),q(),af(),tc(),Ru();var gA=5;function _A({ideSelection:e,mcpClients:t,ideInstallationStatus:n}){let{addNotification:r,removeNotification:i}=li(),{status:a,ideName:o}=jS(t),s=(0,Q.useRef)(!1),c=n?Go(n?.ideType):!1,l=n?.error||c,u=a===`connected`&&(e?.filePath||e?.text&&e.lineCount>0),d=a===`connected`&&!u,f=l&&!c&&!d&&!u,p=l&&c&&!d&&!u;(0,Q.useEffect)(()=>{if(nd())return;if(xc()||a!==null||p){i(`ide-status-hint`);return}if(s.current||(rf().ideHintShownCount??0)>=gA)return;let e=setTimeout((e,t)=>{as(!0).then(n=>{let r=n[0]?.name;r&&!e.current&&(e.current=!0,sf(e=>({...e,ideHintShownCount:(e.ideHintShownCount??0)+1})),t({key:`ide-status-hint`,jsx:(0,$.jsxs)(K,{dimColor:!0,children:[`/ide for `,(0,$.jsx)(K,{color:`ide`,children:r})]}),priority:`low`}))})},3e3,s,r);return()=>clearTimeout(e)},[r,i,a,p]),(0,Q.useEffect)(()=>{if(!nd()){if(f||p||a!==`disconnected`||!o){i(`ide-status-disconnected`);return}r({key:`ide-status-disconnected`,text:`${o} disconnected`,color:`error`,priority:`medium`})}},[r,i,a,o,f,p]),(0,Q.useEffect)(()=>{if(!nd()){if(!p){i(`ide-status-jetbrains-disconnected`);return}r({key:`ide-status-jetbrains-disconnected`,text:`IDE plugin not connected · /status for info`,priority:`medium`})}},[r,i,p]),(0,Q.useEffect)(()=>{if(!nd()){if(!f){i(`ide-status-install-error`);return}r({key:`ide-status-install-error`,text:`IDE extension install failed (see /status for info)`,color:`error`,priority:`medium`})}},[r,i,f])}af();var vA=[e=>{if(bA(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(bA(e.legacyOpusMigrationTimestamp??e.opusProMigrationTimestamp))return{key:`opus-pro-update`,text:t?`Model updated to Opus 4.7 · Set CLAUDE_CODE_DISABLE_LEGACY_MODEL_REMAP=1 to opt out`:`Model updated to Opus 4.7`,color:`suggestion`,priority:`high`,timeoutMs:t?8e3:3e3}}];function yA(){JO(()=>{let e=rf(),t=[];for(let n of vA){let r=n(e);r&&t.push(r)}return t.length>0?t:null})}function bA(e){return e!==void 0&&Date.now()-e<3e3}op(),q(),Mf(),af();var xA=3;function SA(){JO(async()=>{if((rf().subscriptionNoticeCount??0)>=xA)return null;let e=await CA();return e===null?null:(sf(e=>({...e,subscriptionNoticeCount:(e.subscriptionNoticeCount??0)+1})),X(`tengu_switch_to_subscription_notice_shown`,{}),{key:`switch-to-subscription`,jsx:(0,$.jsxs)(K,{color:`suggestion`,children:[`Use your existing Work Mate `,e,` plan with Work Mate`]}),priority:`low`})})}async function CA(){if(Fp())return null;let e=await tp();return e?e.account.has_claude_max?`Max`:e.account.has_claude_pro?`Pro`:null:null}Si(),U(),rp(),Hf(),Ru();var wA=`fast-mode-cooldown-started`,TA=`fast-mode-cooldown-expired`,EA=`fast-mode-org-changed`,DA=`fast-mode-overage-rejected`;function OA(){let{addNotification:e}=li(),t=W(e=>e.fastMode),n=y();(0,Q.useEffect)(()=>{if(!nd()&&hp())return Op(r=>{r?e({key:EA,color:`fastMode`,priority:`immediate`,text:`Fast mode is now available · /fast to turn on`}):t&&(n(e=>({...e,fastMode:!1})),e({key:EA,color:`warning`,priority:`immediate`,text:`Fast mode has been disabled by your organization`}))})},[e,t,n]),(0,Q.useEffect)(()=>{if(!nd()&&hp())return Ap(t=>{n(e=>({...e,fastMode:!1})),e({key:DA,color:`warning`,priority:`immediate`,text:t})})},[e,n]),(0,Q.useEffect)(()=>{if(nd()||!t)return;let n=Cp((t,n)=>{let r=kA(n,Bf(t-Date.now(),{hideTrailingZeros:!0}));e({key:wA,invalidates:[TA],text:r,color:`warning`,priority:`immediate`})}),r=Zf(()=>{e({key:TA,invalidates:[wA],color:`fastMode`,text:`Fast limit reset · now using fast mode`,priority:`immediate`})});return()=>{n(),r()}},[e,t])}function kA(e,t){switch(e){case`overloaded`:return`Fast mode overloaded and is temporarily unavailable · resets in ${t}`;case`rate_limit`:return`Fast limit reached and temporarily disabled · resets in ${t}`}}q(),vc();function AA({onRun:e,onCancel:t,reason:n}){let r=(0,Q.useRef)(!1);return Ml(`confirm:no`,t,{context:`Confirmation`}),(0,Q.useEffect)(()=>{r.current||(r.current=!0,e())},[e]),(0,$.jsxs)(G,{flexDirection:`column`,marginTop:1,children:[(0,$.jsx)(G,{children:(0,$.jsx)(K,{bold:!0,children:`Running feedback capture...`})}),(0,$.jsx)(G,{children:(0,$.jsxs)(K,{dimColor:!0,children:[`Press `,(0,$.jsx)(yl,{shortcut:`Esc`,action:`cancel`}),` anytime`]})}),(0,$.jsx)(G,{children:(0,$.jsxs)(K,{dimColor:!0,children:[`Reason: `,n]})})]})}function jA(e){switch(e){case`feedback_survey_bad`:return!1;case`feedback_survey_good`:return!1;default:return!1}}function MA(e){return`/issue`}function NA(e){switch(e){case`feedback_survey_bad`:return`You responded "Bad" to the feedback survey`;case`feedback_survey_good`:return`You responded "Good" to the feedback survey`;default:return`Unknown reason`}}function PA(){return null}function FA(e,t){return!1}Tg(),q(),af(),Pr();function IA(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||!(rf().copyOnSelect??!0))return;let a=e.copySelectionNoClear();if(!a?.trim()){r.current=!0;return}r.current=!0,i.current?.(a)})},[t,e])}function LA(e){let[t]=Cl();(0,Q.useEffect)(()=>{e.setSelectionBgColor(at(t).selectionBg)},[e,t])}Si(),q(),vc(),gd();var RA=40,zA=.3,BA=6,VA=200,HA=15,UA=15,WA=3,GA=1500,KA=150,qA=5,JA=5,YA=80,XA=3,ZA=6,QA=500;function $A(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 ej(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 tj(e,t,n){if(!e.xtermJs){if(e.wheelMode&&n-e.time>GA&&(e.wheelMode=!1,e.burstCount=0,e.mult=e.base),e.pendingFlip){if(e.pendingFlip=!1,t!==e.dir||n-e.time>VA)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<JA)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/KA),n=Math.max(UA,e.base*2),i=1+(e.mult-1)*t+HA*t;return e.mult=Math.min(n,i,e.mult+WA),Math.floor(e.mult)}if(r>RA)e.mult=e.base;else{let t=Math.max(BA,e.base*2);e.mult=Math.min(t,e.mult+zA)}return Math.floor(e.mult)}let r=n-e.time,i=t===e.dir;if(e.time=n,e.dir=t,i&&r<JA)return 1;if(!i||r>QA)e.mult=2,e.frac=0;else{let t=.5**(r/KA);e.mult=Math.min(r>=YA?XA:ZA,1+(e.mult-1)*t+qA*t)}let a=e.mult+e.frac,o=Math.floor(a);return e.frac=a-o,o}function nj(){let e=process.env.CLAUDE_CODE_SCROLL_SPEED;if(!e)return 1;let t=parseFloat(e);return Number.isNaN(t)||t<=0?1:Math.min(t,20)}function rj(e=!1,t=1){return{time:0,mult:t,dir:0,xtermJs:e,frac:0,base:t,pendingFlip:!1,wheelMode:!1,burstCount:0}}function ij(){let e=Jl(),t=nj();return J(`wheel accel: ${e?`decay (xterm.js)`:`window (native)`} · base=${t} · TERM_PROGRAM=${process.env.TERM_PROGRAM??`unset`}`),rj(e,t)}var aj=2,oj=50,sj=200;function cj({scrollRef:e,isActive:t,onScroll:n,isModal:r=!1}){let i=Zl(),{addNotification:a}=li(),o=(0,Q.useRef)(null);function s(e){let t=Xl(),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 Sl({"scroll:pageUp":()=>{let t=e.current;if(!t)return;let r=-Math.max(1,Math.floor(t.getViewportHeight()/2));l(t,r);let i=dj(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=dj(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=ij()),pj(t,tj(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=ij());let r=fj(t,tj(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}),Sl({"scroll:halfPageUp":()=>{let t=e.current;if(!t)return;let r=-Math.max(1,Math.floor(t.getViewportHeight()/2));l(t,r);let i=dj(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=dj(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=dj(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=dj(t,r);n?.(i,t)}},{context:`Scroll`,isActive:t}),ql((t,r,i)=>{let a=e.current;if(!a)return;let o=hj(a,mj(t,r),e=>l(a,e));o!==null&&(n?.(o,a),i.stopImmediatePropagation())},{isActive:t&&r}),ql((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=ej(t);if(r){i.moveFocus(r),n.stopImmediatePropagation();return}$A(t)&&i.clearSelection()},{isActive:t}),lj(e,i,t,n),IA(i,t,s),LA(i),null}function lj(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>sj){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(aj,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(aj,e-i.getScrollTop());t.captureScrolledRows(l,l+n-1,`above`),t.shiftAnchor(-n,l,u),i.scrollBy(aj)}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,oj)))}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=uj(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 uj(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 dj(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 fj(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 pj(e,t){if(e.getScrollTop()+e.getPendingDelta()-t<=0){e.scrollTo(0);return}e.scrollBy(-t)}function mj(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 hj(e,t,n){switch(t){case null:return null;case`lineUp`:case`lineDown`:{let r=t===`lineDown`?1:-1;return n(r),dj(e,r)}case`halfPageUp`:case`halfPageDown`:{let r=Math.max(1,Math.floor(e.getViewportHeight()/2)),i=t===`halfPageDown`?r:-r;return n(i),dj(e,i)}case`fullPageUp`:case`fullPageDown`:{let r=Math.max(1,e.getViewportHeight()),i=t===`fullPageDown`?r:-r;return n(i),dj(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}}}Ru(),Wc(),jd(),l(),q(),$a(),Ph(),Si(),gd(),o(),Hf(),ua(),B(),Gt(),oh(),hn(),je(),wr(),ba(),oo(),ld(),Sf(),rd(),Ke(),ra(),tt(),af(),ti(),Mf(),Bt(),Wm(),Cf(),_(),Vt(),kg(),ei(),mo(),Vh(),U(),bi(),da(),ca(),nm(),tc(),sr(),$s(),Nr(),Ae(),uc(),Er();var gj=[],_j=3e3;function vj({showAllInTranscript:e,virtualScroll:t,searchBadge:n,suppressShowAll:r=!1,status:i}){let a=Va(`app:toggleTranscript`,`Global`,`ctrl+o`),o=Va(`transcript:toggleShowAll`,`Transcript`,`ctrl+e`);return(0,$.jsxs)(G,{noSelect:!0,alignItems:`center`,alignSelf:`center`,borderTopDimColor:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,borderStyle:`single`,marginTop:1,paddingLeft:2,width:`100%`,children:[(0,$.jsxs)(K,{dimColor:!0,children:[`Showing detailed transcript · `,a,` to toggle`,n?` · n/N to navigate`:t?` · ${u.arrowUp}${u.arrowDown} scroll · home/end top/bottom`:r?``:` · ${o} to ${e?`collapse`:`show all`}`]}),i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(G,{flexGrow:1}),(0,$.jsxs)(K,{children:[i,` `]})]}):n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(G,{flexGrow:1}),(0,$.jsxs)(K,{dimColor:!0,children:[n.current,`/`,n.count,` `]})]}):null]})}function yj({jumpRef:e,count:t,current:n,onClose:r,onCancel:i,setHighlight:a,initialQuery:o}){let{query:s,cursorOffset:c}=Qh({isActive:!0,initialQuery:o,onExit:()=>r(s),onCancel:i}),[l,u]=Q.useState(`building`);Q.useEffect(()=>{let t=!0,n,r=e.current?.warmSearchIndex;if(!r){u(null);return}return u(`building`),r().then(e=>{t&&(e<20?u(null):(u({ms:e}),n=setTimeout(()=>t&&u(null),2e3)))}),()=>{t=!1,n&&clearTimeout(n)}},[e]);let d=l!==`building`;(0,Q.useEffect)(()=>{d&&(e.current?.setSearchQuery(s),a(s))},[e,s,a,d]);let f=c,p=f<s.length?s[f]:` `;return(0,$.jsxs)(G,{borderTopDimColor:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,borderStyle:`single`,marginTop:1,paddingLeft:2,width:`100%`,noSelect:!0,children:[(0,$.jsx)(K,{children:`/`}),(0,$.jsx)(K,{children:s.slice(0,f)}),(0,$.jsx)(K,{inverse:!0,children:p}),f<s.length&&(0,$.jsx)(K,{children:s.slice(f+1)}),(0,$.jsx)(G,{flexGrow:1}),l===`building`?(0,$.jsx)(K,{dimColor:!0,children:`indexing… `}):l?(0,$.jsxs)(K,{dimColor:!0,children:[`indexed in `,l.ms,`ms `]}):t===0&&s?(0,$.jsx)(K,{color:`error`,children:`no matches `}):t>0?(0,$.jsxs)(K,{dimColor:!0,children:[n,`/`,t,` `]}):null]})}var bj=[`⠂`,`⠐`],xj=`✳`,Sj=960;function Cj({isAnimating:e,title:t,disabled:n,noPrefix:r}){let i=Nl(),[a,o]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{if(n||r||!e||!i)return;let t=setInterval(e=>e(e=>(e+1)%bj.length),Sj,o);return()=>clearInterval(t)},[n,r,e,i]);let s=e?bj[a]??xj:xj;return Fl(n?null:r?t:`${s} ${t}`),null}var wj=`<${xf}>`;function Tj(e){return e.type===`text`&&typeof e.text==`string`&&e.text.includes(wj)}function Ej({commands:t,debug:n,initialTools:r,initialMessages:i,pendingHookMessages:o,initialFileHistorySnapshots:s,initialContentReplacements:c,initialAgentName:l,initialAgentColor:u,mcpClients:d,dynamicMcpConfig:f,autoConnectIdeFlag:p,strictMcpConfig:m=!1,systemPrompt:h,appendSystemPrompt:g,onBeforeQuery:_,onTurnComplete:v,disabled:b=!1,mainThreadAgentDefinition:x,disableSlashCommands:S=!1,taskListId:w,remoteSessionConfig:T,directConnectConfig:E,sshSession:O,thinkingConfig:k}){let A=!!T,j=(0,Q.useMemo)(()=>a(process.env.CLAUDE_CODE_DISABLE_TERMINAL_TITLE),[]),N=(0,Q.useMemo)(()=>a(process.env.CLAUDE_CODE_DISABLE_VIRTUAL_SCROLL),[]);(0,Q.useMemo)(()=>a(process.env.CLAUDE_CODE_DISABLE_MESSAGE_ACTIONS),[]),(0,Q.useEffect)(()=>(J(`[REPL:mount] REPL mounted, disabled=${b}`),()=>J(`[REPL:unmount] REPL unmounting`)),[b]);let[ee,P]=(0,Q.useState)(x),F=W(e=>e.toolPermissionContext),I=W(e=>e.verbose),L=W(e=>e.mcp),ne=W(e=>e.plugins),re=W(e=>e.agentDefinitions),ie=W(e=>e.fileHistory),ae=W(e=>e.initialMessage),oe=DS(),se=W(e=>e.spinnerTip),ce=W(e=>e.expandedView)===`tasks`,le=W(e=>e.tasks),de=W(e=>e.elicitation),fe=W(e=>e.viewingAgentTaskId),z=y(),pe=fe?le[fe]:void 0,he=$n(pe)&&pe.retain&&!pe.diskLoaded;(0,Q.useEffect)(()=>{if(!fe||!he)return;let e=fe;La(Ne(e)).then(t=>{z(n=>{let r=n.tasks[e];if(!$n(r)||r.diskLoaded||!r.retain)return n;let i=r.messages??[],a=new Set(i.map(e=>e.uuid)),o=t?t.messages.filter(e=>!a.has(e.uuid)):[];return{...n,tasks:{...n.tasks,[e]:{...r,messages:[...o,...i],diskLoaded:!0}}}})})},[fe,he,z]);let ge=Bn(),_e=Dl(),ve=Bh(),[ye,be]=(0,Q.useState)(t);lO(A?void 0:Qu(),be);let xe=Q.useSyncExternalStore(sm,hm),Se=Q.useSyncExternalStore(sm,cm),Ce=(0,Q.useMemo)(()=>Mt(F),[F,xe]);sk();let[Te,Ee]=(0,Q.useState)(f),Oe=(0,Q.useCallback)(e=>{Ee(e)},[Ee]),[ke,Ae]=(0,Q.useState)(`prompt`),[je,Me]=(0,Q.useState)(!1),[Pe,Fe]=(0,Q.useState)(!1),[Le,Re]=(0,Q.useState)(``),ze=(0,Q.useRef)(0),Be=(0,Q.useRef)(void 0),He=(0,Q.useRef)(!1),{addNotification:Ue,removeNotification:We}=li(),Ge=sO(d,L.clients),[Ke,Je]=(0,Q.useState)(void 0),[Xe,Ze]=(0,Q.useState)(null),[Qe,et]=(0,Q.useState)(null),[tt,nt]=(0,Q.useState)(!1),rt=W(e=>e.showRemoteCallout),[at,ot]=(0,Q.useState)(()=>rA());yA(),SA(),_A({ideSelection:Ke,mcpClients:Ge,ideInstallationStatus:Qe}),pk({mcpClients:Ge}),aA(),oA(),ng(),fA(ve),OA(),pA(ve),hA(),YO(),nk(),gk();let{recommendation:st,handleResponse:ct}=Mk(),{recommendation:ut,handleResponse:dt}=Fk(),ft=Hk(),mt=(0,Q.useMemo)(()=>[...Ce,...r],[Ce,r]);Qm({enabled:!A});let ht=Rt();(0,Q.useEffect)(()=>{A||lA(z)},[z,A]);let gt=Mh(mt,L.tools,F),{tools:_t,allowedAgentTypes:vt}=(0,Q.useMemo)(()=>{if(!ee)return{tools:gt,allowedAgentTypes:void 0};let e=jr(ee,gt,!1,!0);return{tools:e.resolvedTools,allowedAgentTypes:e.allowedAgentTypes}},[ee,gt]),yt=cO(cO(ye,ne.commands),L.commands),bt=(0,Q.useMemo)(()=>S?[]:yt,[S,yt]);Cy(A?gj:L.clients),dO(A?gj:L.clients,Je);let[St,Ct]=(0,Q.useState)(`responding`),wt=(0,Q.useRef)(St);wt.current=St;let[Tt,Et]=(0,Q.useState)([]),[Dt,Ot]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{if(Dt&&!Dt.isStreaming&&Dt.streamingEndedAt){let e=3e4-(Date.now()-Dt.streamingEndedAt);if(e>0){let t=setTimeout(Ot,e,null);return()=>clearTimeout(t)}else Ot(null)}},[Dt]);let[kt,At]=(0,Q.useState)(null),jt=(0,Q.useRef)(null);jt.current=kt;let Nt=(0,Q.useRef)(0),[It,Lt]=(0,Q.useState)(!1),zt=(0,Q.useRef)(()=>{}),Bt=(0,Q.useRef)(()=>{}),Vt=(0,Q.useRef)(null),Ut=(0,Q.useRef)(null),Wt=(0,Q.useRef)(0),Gt=Q.useRef(new yy).current,Kt=Q.useSyncExternalStore(Gt.subscribe,Gt.getSnapshot),[qt,Jt]=Q.useState(T?.hasInitialPrompt??!1),B=Kt||qt,[Yt,Xt]=Q.useState(void 0),Zt=Q.useRef(0),Qt=Q.useRef(!1),$t=Q.useRef(0),en=Q.useRef(0),tn=Q.useRef(null),nn=Q.useCallback(()=>{$t.current=Date.now(),en.current=0,tn.current=null},[]),rn=Q.useRef(!1);Kt&&!rn.current&&nn(),rn.current=Kt;let on=Q.useCallback(e=>{Jt(e),e&&nn()},[nn]),sn=Q.useRef(void 0),[cn,ln]=Q.useState(!1),[un,dn]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{un?.notifications&&un.notifications.forEach(e=>{Ue({key:`auto-updater-notification`,text:e,priority:`low`})})},[un,Ue]),(0,Q.useEffect)(()=>{Xr()&&Pt().then(e=>{e&&Ue({key:`tmux-mouse-hint`,text:e,priority:`low`})})},[]);let[fn,mn]=(0,Q.useState)(null),hn=(0,Q.useRef)(null),gn=(0,Q.useCallback)(e=>{if(e?.isLocalJSXCommand){let{clearLocalJSX:t,...n}=e;hn.current={...n,isLocalJSXCommand:!0},mn(n);return}if(hn.current){if(e?.clearLocalJSX){hn.current=null,mn(null),Nt.current=Date.now();return}return}if(e?.clearLocalJSX){mn(null);return}mn(e)},[]),[_n,vn]=(0,Q.useState)([]),[yn,bn]=(0,Q.useState)(null),[Sn,Cn]=(0,Q.useState)([]),[Tn,En]=(0,Q.useState)([]),kn=(0,Q.useRef)(new Map),An=W(e=>e.settings.terminalTitleFromRename)===!1?void 0:Zs(Wu()),[Mn,Nn]=(0,Q.useState)(),Pn=(0,Q.useRef)((i?.length??0)>0),Fn=ee?.agentType,In=An??Fn??Mn??`Work Mate`,Ln=_n.length>0||Tn.length>0,Rn=fn?.isLocalJSXCommand===!0&&fn?.jsx!=null,Hn=B&&!Ln&&!Rn;(0,Q.useEffect)(()=>{if(B&&!Ln&&!Rn)return fy(),()=>py()},[B,Ln,Rn]);let Yn=Ln||Rn?`waiting`:B?`busy`:`idle`,Zn=Yn===`waiting`?_n.length>0?`approve ${_n[0].tool.name}`:Rn?`dialog open`:`input needed`:void 0;(0,Q.useEffect)(()=>{Tc({status:Yn,waitingFor:Zn})},[Yn,Zn]),Ll(null);let[V,er]=(0,Q.useState)(i??[]),nr=(0,Q.useRef)(V),ar=(0,Q.useRef)(!1),H=(0,Q.useCallback)(e=>{let t=nr.current,n=typeof e==`function`?e(nr.current):e;if(nr.current=n,n.length<Zt.current)Zt.current=0;else if(n.length>t.length&&Qt.current){let e=n.length-t.length;(t.length===0||n[0]===t[0]?n.slice(-e):n.slice(0,e)).some(te)?Qt.current=!1:Zt.current=n.length}er(n)},[]),or=(0,Q.useCallback)(e=>{e===void 0?Qt.current=!1:(Zt.current=nr.current.length,Qt.current=!0),Xt(e)},[]),{dividerIndex:sr,dividerYRef:cr,onScrollAway:lr,onRepin:dr,jumpToNew:fr,shiftDivider:pr}=Ag(V.length);XO(V,H,B);let[mr,hr]=(0,Q.useState)(null),gr=(0,Q.useRef)(null),_r=(0,Q.useMemo)(()=>Dg(V,sr),[sr,V.length]),yr=(0,Q.useCallback)(()=>{Vt.current?.scrollToBottom(),dr(),hr(null)},[dr,hr]),br=V.at(-1),xr=br!=null&&te(br);(0,Q.useEffect)(()=>{xr&&yr()},[xr,br,yr]);let wr=(0,Q.useCallback)((e,t)=>{Wt.current=Date.now(),e?dr():lr(t)},[dr,lr,z]),Er=ND(o,H),Dr=(0,Q.useDeferredValue)(Q.useMemo(()=>V.length>500?V.slice(-500):V,[V])),Or=V.length-Dr.length;Or>0&&J(`[useDeferredValue] Messages deferred by ${Or} (${Dr.length}→${V.length})`);let[kr,Ar]=(0,Q.useState)(null),[Nr,Pr]=(0,Q.useState)(()=>Hg()),Ir=(0,Q.useRef)(Nr);Ir.current=Nr;let Lr=(0,Q.useRef)(null),Rr=(0,Q.useCallback)(e=>{Ir.current===``&&e!==``&&Date.now()-Wt.current>=_j&&yr(),Ir.current=e,Pr(e),ln(e.trim().length>0)},[ln,yr]);(0,Q.useEffect)(()=>{if(Nr.trim().length===0)return;let e=setTimeout(ln,1500,!1);return()=>clearTimeout(e)},[Nr]);let[zr,Vr]=(0,Q.useState)(`prompt`),[Hr,Ur]=(0,Q.useState)(),Wr=(0,Q.useCallback)(e=>{let t=new Set(e);be(e=>e.filter(e=>t.has(e.name)||Ic.has(e)))},[be]),[Gr,Yr]=(0,Q.useState)(new Set),Zr=(0,Q.useRef)(!1),Qr=pD({config:T,setMessages:H,setIsLoading:on,onInit:Wr,setToolUseConfirmQueue:vn,tools:mt,setStreamingToolUses:Et,setStreamMode:Ct,setInProgressToolUseIDs:Yr}),ei=gD({config:E,setMessages:H,setIsLoading:on,setToolUseConfirmQueue:vn,tools:mt}),ti=_D({session:O,setMessages:H,setIsLoading:on,setToolUseConfirmQueue:vn,tools:mt}),ni=ti.isRemoteMode?ti:ei.isRemoteMode?ei:Qr,[ii,ai]=(0,Q.useState)({}),[ci,ui]=(0,Q.useState)(0),di=(0,Q.useRef)(0),U=(0,Q.useRef)([]),fi=(0,Q.useCallback)(e=>{let t=di.current;if(di.current=e(t),di.current>t){let e=U.current;if(e.length>0){let t=e.at(-1);t.lastTokenTime=Date.now(),t.endResponseLength=di.current}}},[]),[pi,mi]=(0,Q.useState)(null),hi=!(W(e=>e.settings.prefersReducedMotion)??!1)&&!nu(),gi=(0,Q.useCallback)(e=>{hi&&mi(e)},[hi]),vi=pi&&hi&&pi.substring(0,pi.lastIndexOf(`
124
+ `)+1)||null,[yi,bi]=(0,Q.useState)(0),[xi,Si]=(0,Q.useState)(null),[Ci,wi]=(0,Q.useState)(null),[Ti,Di]=(0,Q.useState)(null),[Oi,ki]=(0,Q.useState)(!1),[Ai,ji]=(0,Q.useState)(void 0),[Mi,Ni]=(0,Q.useState)(!1),[Pi,Fi]=(0,Q.useState)(l_()),[Ii,Li]=(0,Q.useState)(null),Ri=(0,Q.useRef)(!1),zi=(0,Q.useRef)(yi);zi.current=yi;let[Vi]=(0,Q.useState)(()=>({current:Nc(i,c)}));Ie(()=>{Vi.current=Uc()});let[Hi,Ui]=(0,Q.useState)(rf().hasAcknowledgedCostThreshold),[Wi,Gi]=(0,Q.useState)(`INSERT`),[Ki,qi]=(0,Q.useState)(!1),[Ji,Yi]=(0,Q.useState)(!1),[Xi,Zi]=(0,Q.useState)(!1),Qi=Nl(),$i=(0,Q.useRef)(Qi);$i.current=Qi;let[ta]=Cl(),na=Q.useRef(!1),ra=(0,Q.useCallback)(()=>{if(na.current)return;na.current=!0;let e=nr.current.slice(Oa.current);for(let t of $r(e))Da.current.add(t);Oa.current=nr.current.length,ik({theme:ta,readFileState:Ta.current,bashTools:Da.current}).then(async e=>{if(e){let t=await e.content({theme:ta});z(e=>({...e,spinnerTip:t})),ak(e)}else z(e=>e.spinnerTip===void 0?e:{...e,spinnerTip:void 0})})},[z,ta]),oa=(0,Q.useCallback)(()=>{on(!1),or(void 0),di.current=0,U.current=[],mi(null),Et([]),Si(null),wi(null),Di(null),ra(),Mm(),pl()},[ra]),sa=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(F.mode!==`auto`){sa.current=!1;return}if(sa.current||(rf().autoPermissionsNotificationCount??0)>=3)return;let e=setTimeout((e,t)=>{e.current=!0,sf(e=>{let t=e.autoPermissionsNotificationCount??0;return t>=3?e:{...e,autoPermissionsNotificationCount:t+1}}),t(e=>[...e,$c(mk,`warning`)])},800,sa,H);return()=>clearTimeout(e)},[F.mode,H]);let ca=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(ca.current)return;let e=ol();if(!e?.creationDurationMs||e.usedSparsePaths||e.creationDurationMs<15e3)return;ca.current=!0;let t=Math.round(e.creationDurationMs/1e3);H(e=>[...e,$c(`Worktree creation took ${t}s. For large repos, set \`worktree.sparsePaths\` in .workmate/settings.json to check out only the directories you need — e.g. \`{"worktree": {"sparsePaths": ["src", "packages/foo"]}}\`.`,`info`)])},[H]);let la=(0,Q.useMemo)(()=>{let e=V.findLast(e=>e.type===`assistant`);if(e?.type!==`assistant`)return!1;let t=e.message?.content,n=(Array.isArray(t)?t:[]).filter(e=>e.type===`tool_use`&&Gr.has(e.id));return n.length>0&&n.every(e=>e.type===`tool_use`&&e.name===`Sleep`)},[V,Gr]),{onBeforeQuery:ua,onTurnComplete:da,render:fa}=AD({enabled:!1,setMessages:H,inputValue:Nr,setInputValue:Rr,setToolJSX:gn}),pa=(!fn||fn.showSpinner===!0)&&_n.length===0&&Tn.length===0&&(B||Yt||C()>0)&&!la&&!vi,ma=_n.length>0||Tn.length>0||Sn.length>0||de.queue.length>0,ha=MO(V,B,ci,`session`,ma),ga=kD(H),_a=FA(V,ci),va=(0,Q.useMemo)(()=>({...ha,handleSelect:e=>{Ra.current=!1;let t=ha.handleSelect(e);e===`bad`&&!t&&jA(`feedback_survey_bad`)&&(Ia(`feedback_survey_bad`),Ra.current=!0)}}),[ha]),ba=BO(V,B,ma,{enabled:!A}),xa=IO(V,B,ma,{enabled:!A});SO({autoConnectIdeFlag:p,ideToInstallExtension:Xe,setDynamicMcpConfig:Ee,setShowIdeOnboarding:nt,setIDEInstallationState:et}),ck(s,ie,e=>z(t=>({...t,fileHistory:e})));let Ca=(0,Q.useCallback)(async(t,n,r)=>{let i=performance.now();try{let a=ue(n.messages),o=ac();await Bs(`resume`,{getAppState:()=>ge.getState(),setAppState:z,signal:AbortSignal.timeout(o),timeoutMs:o});let s=await so(`resume`,{sessionId:t,agentType:ee?.agentType,model:ve});a.push(...s),r===`fork`?Sr(n,lt(t)):Kr(n,lt(t)),vh(n,z),n.fileHistorySnapshots&&Ka(n);let{agentDefinition:c}=gh(n.agentSetting,x,re);P(c),z(e=>({...e,agent:c?.agentType})),z(e=>({...e,standaloneAgentContext:_h(n.agentName,n.agentColor)})),aa(n.agentName),ja(a,n.projectPath??bu()),oa(),At(null),Fi(t);let l=an(t);if(Ve(),xu(),Bu(lt(t),n.fullPath?t_(n.fullPath):null),await pc(),Ft(),cs(n),n.goal){let{hydrateGoalFromTranscript:r}=(rl(),e(Oc)),i=new Map;i.set(t,n.goal),r(i,t)}if(Pn.current=!0,Nn(void 0),r!==`fork`)yh(),bh(n.worktreeSession),Qn(),xs({abortController:new AbortController,getAppState:()=>ge.getState(),setAppState:z});else{let e=ol();e&&Ea(e)}l&&Ju(l),Vi.current&&r!==`fork`&&(Vi.current=ur(a,n.contentReplacements??[])),H(()=>a),gn(null),Rr(``),X(`tengu_session_resumed`,{entrypoint:r,success:!0,resume_duration_ms:Math.round(performance.now()-i)})}catch(e){throw X(`tengu_session_resumed`,{entrypoint:r,success:!1}),e}},[oa,z]),[wa]=(0,Q.useState)(()=>Gn(100)),Ta=(0,Q.useRef)(wa),Da=(0,Q.useRef)(new Set),Oa=(0,Q.useRef)(0),ka=(0,Q.useRef)(new Set),Aa=(0,Q.useRef)(new Set),ja=(0,Q.useCallback)((e,t)=>{let n=Ye(e,t,100);Ta.current=Ma(Ta.current,n);for(let t of $r(e))Da.current.add(t)},[]);(0,Q.useEffect)(()=>{i&&i.length>0&&(ja(i,bu()),xs({abortController:new AbortController,getAppState:()=>ge.getState(),setAppState:z}))},[]);let{status:Na,reverify:Pa}=PD(),[Fa,Ia]=(0,Q.useState)(null),Ra=(0,Q.useRef)(!1),[za,Ba]=(0,Q.useState)(null),[Va,Ua]=(0,Q.useState)(!1),Wa=!B&&Mi;function Ga(){if(Va||za)return;if(Oi)return`message-selector`;if(cn)return;if(Sn[0])return`sandbox-permission`;let e=!fn||fn.shouldContinueAnimation;if(e&&_n[0])return`tool-permission`;if(e&&Tn[0])return`prompt`;if(e&&de.queue[0])return`elicitation`;if(e&&Wa)return`cost`;if(e&&Ii)return`idle-return`;if(e&&tt)return`ide-onboarding`;if(e&&rt)return`remote-callout`;if(e&&st)return`lsp-recommendation`;if(e&&ut)return`plugin-hint`;if(e&&ft.visible)return`search-extra-tools-hint`;if(e&&at)return`desktop-upsell`}let qa=Ga(),Ja=cn&&(Sn[0]||_n[0]||Tn[0]||de.queue[0]||Wa);sn.current=qa,(0,Q.useEffect)(()=>{if(!B)return;let e=qa===`tool-permission`,t=Date.now();e&&tn.current===null?tn.current=t:!e&&tn.current!==null&&(en.current+=t-tn.current,tn.current=null)},[qa,B]);let Ya=(0,Q.useRef)(qa);(0,Q.useLayoutEffect)(()=>{Ya.current===`tool-permission`!=(qa===`tool-permission`)&&yr(),Ya.current=qa},[qa,yr]);function Xa(){if(qa!==`elicitation`){if(Nt.current!==0&&Date.now()-Nt.current<500){Nt.current=0,J(`[onCancel] suppressed: local-jsx panel just dismissed`);return}if(Nt.current=0,J(`[onCancel] focusedInputDialog=${qa} streamMode=${St}`),lm(),Gt.getSnapshot()){let{getGoal:t,pauseGoal:n}=(M(),e(xn)),{persistCurrentGoal:r}=(rl(),e(Oc));t()?.status===`active`&&(n(),r())}if(Lt(!0),Gt.forceEnd(),Ri.current=!1,pi?.trim()&&H(e=>[...e,Zo({content:pi})]),oa(),Ku(null),qa===`tool-permission`)_n[0]?.onAbort(),vn([]);else if(qa===`prompt`){for(let e of Tn)e.reject(Error(`Prompt cancelled by user`));En([]),kt?.abort(`user-cancel`)}else ni.isRemoteMode?ni.cancelRequest():kt?.abort(`user-cancel`);At(null),da(nr.current,!0)}}let Za=(0,Q.useCallback)(()=>{let e=sc(Nr,0);e&&(Rr(e.text),Vr(`prompt`),e.images.length>0&&ai(t=>{let n={...t};for(let t of e.images)n[t.id]=t;return n}))},[Rr,Vr,Nr,ai]),Qa={setToolUseConfirmQueue:vn,onCancel:Xa,onAgentsKilled:()=>H(e=>[...e,Ha()]),isMessageSelectorVisible:Oi||!!Ki,screen:ke,abortSignal:kt?.signal,popCommandFromQueue:Za,vimMode:Wi,isLocalJSXCommand:fn?.isLocalJSXCommand,isSearchingHistory:Ji,isHelpOpen:Xi,inputMode:zr,inputValue:Nr,streamMode:St};(0,Q.useEffect)(()=>{Iu()>=5&&!Mi&&!Hi&&(X(`tengu_cost_threshold_reached`,{}),Ui(!0),Fr()&&Ni(!0))},[V,Mi,Hi]);let $a=(0,Q.useCallback)(async e=>new Promise(t=>{let n=!1;function r(e){n||(n=!0,t(e))}Cn(t=>[...t,{hostPattern:e,resolvePromise:r}])}),[z,ge]);(0,Q.useEffect)(()=>{let e=Wn.getSandboxUnavailableReason();if(e){if(Wn.isSandboxRequired()){process.stderr.write(`\nError: sandbox required but unavailable: ${e}\n sandbox.failIfUnavailable is set — refusing to start without a working sandbox.\n\n`),zn(1,`other`);return}J(`sandbox disabled: ${e}`,{level:`warn`}),Ue({key:`sandbox-unavailable`,jsx:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(K,{color:`warning`,children:`sandbox disabled`}),(0,$.jsx)(K,{dimColor:!0,children:` · /sandbox`})]}),priority:`medium`})}},[Ue]),Wn.isSandboxingEnabled()&&Wn.initialize($a).catch(e=>{process.stderr.write(`\n❌ Sandbox Error: ${cd(e)}\n`),zn(1,`other`)});let eo=(0,Q.useCallback)((e,t)=>{z(n=>({...n,toolPermissionContext:{...e,mode:t?.preserveMode?n.toolPermissionContext.mode:e.mode}})),setImmediate(e=>{e(e=>(e.forEach(e=>{e.recheckPermission()}),e))},vn)},[z,vn]),no=QD(vn,eo),io=(0,Q.useCallback)((e,t,r,i)=>{let a=ge.getState(),o=()=>{let e=ge.getState(),t=Cr(e.toolPermissionContext,e.mcp.tools),n=th(mt,t,e.toolPermissionContext.mode);return ee?jr(ee,n,!1,!0).resolvedTools:n};return{abortController:r,options:{commands:bt,tools:o(),debug:n,verbose:a.verbose,mainLoopModel:i,thinkingConfig:a.thinkingEnabled===!1?{type:`disabled`}:k,mcpClients:oO(d,a.mcp.clients),mcpResources:a.mcp.resources,ideInstallationStatus:Qe,isNonInteractiveSession:!1,dynamicMcpConfig:Te,theme:ta,agentDefinitions:vt?{...a.agentDefinitions,allowedAgentTypes:vt}:a.agentDefinitions,customSystemPrompt:h,appendSystemPrompt:g,refreshTools:o},getAppState:()=>ge.getState(),setAppState:z,messages:e,setMessages:H,updateFileHistoryState(e){z(t=>{let n=e(t.fileHistory);return n===t.fileHistory?t:{...t,fileHistory:n}})},updateAttributionState(e){z(t=>{let n=e(t.attribution);return n===t.attribution?t:{...t,attribution:n}})},openMessageSelector:()=>{b||ki(!0)},onChangeAPIKey:Pa,readFileState:Ta.current,setToolJSX:gn,addNotification:Ue,appendSystemMessage:e=>H(t=>[...t,e]),sendOSNotification:e=>{ey(e,_e)},onChangeDynamicMcpConfig:Oe,onInstallIDEExtension:Ze,nestedMemoryAttachmentTriggers:new Set,loadedNestedMemoryPaths:Aa.current,dynamicSkillDirTriggers:new Set,discoveredSkillNames:ka.current,setResponseLength:fi,pushApiMetricsEntry:void 0,setStreamMode:Ct,onCompactProgress:e=>{switch(e.type){case`hooks_start`:wi(`claudeBlue_FOR_SYSTEM_SPINNER`),Di(`claudeBlueShimmer_FOR_SYSTEM_SPINNER`),Si(e.hookType===`pre_compact`?`Running PreCompact hooks…`:e.hookType===`post_compact`?`Running PostCompact hooks…`:`Running SessionStart hooks…`);break;case`compact_start`:Si(`Compacting conversation`);break;case`compact_end`:Si(null),wi(null),Di(null);break}},setInProgressToolUseIDs:Yr,setHasInterruptibleToolInProgress:e=>{Zr.current=e},resume:Ca,setConversationId:Fi,requestPrompt:void 0,contentReplacementState:Vi.current}},[bt,mt,ee,n,d,Qe,Te,ta,vt,ge,z,Pa,Ue,H,Oe,Ca,(0,Q.useCallback)((e,t)=>n=>new Promise((r,i)=>{En(a=>[...a,{request:n,title:e,toolInputSummary:t,resolve:r,reject:i}])}),[]),b,h,g,Fi]),{handleBackgroundSession:ao}=wO({setMessages:H,setIsLoading:on,resetLoadingState:oa,setAbortController:At,onBackgroundQuery:(0,Q.useCallback)(()=>{kt?.abort(`background`);let e=ya(e=>e.mode===`task-notification`);(async()=>{let t=io(nr.current,[],new AbortController,ve),[n,r,i]=await Promise.all([ea(t.options.tools,ve,Array.from(F.additionalWorkingDirectories.keys()),t.options.mcpClients),xt(),js()]),a=qr({mainThreadAgentDefinition:ee,toolUseContext:t,customSystemPrompt:h,defaultSystemPrompt:n,appendSystemPrompt:g});t.renderedSystemPrompt=a;let o=(await De(e).catch(()=>[])).map(zc),s=new Set;for(let e of nr.current)e.type===`attachment`&&e.attachment.type===`queued_command`&&e.attachment.commandMode===`task-notification`&&typeof e.attachment.prompt==`string`&&s.add(e.attachment.prompt);let c=o.filter(e=>e.attachment.type===`queued_command`&&(typeof e.attachment.prompt!=`string`||!s.has(e.attachment.prompt)));jn({messages:[...nr.current,...c],queryParams:{systemPrompt:a,userContext:r,systemContext:i,canUseTool:no,toolUseContext:t,querySource:wo()},description:In,setAppState:z,agentDefinition:ee})})()},[kt,ve,F,ee,io,h,g,no,z])}),oo=(0,Q.useCallback)(t=>{Dn(t,t=>{if(Kn(t)?(Xr()?H(e=>{let n=Io(e,{includeSnipped:!0});return[...n.length>500?n.slice(-500):n,t]}):H(()=>[t]),Fi(l_()),om(!1)):t.type===`progress`&&R(t.data?.type)?H(e=>{let n=t.data;for(let r=e.length-1;r>=0;r--){let i=e[r];if(i.type!==`progress`)break;let a=i.data;if(i.parentToolUseID===t.parentToolUseID&&a?.type===n.type){let n=e.slice();return n[r]=t,n}}return[...e,t]}):H(e=>[...e,t]),t.type===`assistant`&&`isApiErrorMessage`in t&&t.isApiErrorMessage?om(!0):t.type===`assistant`&&om(!1),t.type===`assistant`&&`isApiErrorMessage`in t&&t.isApiErrorMessage){let n=(me(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}=(M(),e(xn)),{persistCurrentGoal:r}=(rl(),e(Oc));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=>{fi(t=>t+e.length)},Ct,Et,e=>{H(t=>t.filter(t=>t!==e)),Vn(e.uuid)},Ot,e=>{let t=Date.now(),n=di.current;U.current.push({...e,firstTokenTime:t,lastTokenTime:t,responseLengthBaseline:n,endResponseLength:n})},gi)},[H,fi,Ct,Et,Ot,gi]),lo=(0,Q.useCallback)(async(e,t,n,r,i,a)=>{if(r){let e=oO(d,ge.getState().mcp.clients);tr.handleQueryStart(e);let t=Gs(e);t&&fc(t)}if(Zp(),!j&&!An&&!Fn&&!Pn.current){let e=t.find(e=>e.type===`user`&&!e.isMeta),n=e?.type===`user`?me(e.message.content):null;n&&!n.startsWith(`<local-command-stdout>`)&&!n.startsWith(`<command-message>`)&&!n.startsWith(`<command-name>`)&&!n.startsWith(`<bash-input>`)&&(Pn.current=!0,Um(n,new AbortController().signal).then(e=>{e?Nn(e):Pn.current=!1},()=>{Pn.current=!1}))}if(ge.setState(e=>{let t=e.toolPermissionContext.alwaysAllowRules.command;return t===i||t?.length===i.length&&t.every((e,t)=>e===i[t])?e:{...e,toolPermissionContext:{...e.toolPermissionContext,alwaysAllowRules:{...e.toolPermissionContext.alwaysAllowRules,command:i}}}}),!r){t.some(Kn)&&(Fi(l_()),om(!1)),oa(),At(null);return}let o=io(e,t,n,a),{tools:s,mcpClients:c}=o.options;cl(`query_context_loading_start`);let[,,l,u,f]=await Promise.all([void 0,ok(F,z,ge.getState().fastMode),ea(s,a,Array.from(F.additionalWorkingDirectories.keys()),c),xt(),js()]),p={...u,...hm()&&!$i.current?{terminalFocus:`The terminal is unfocused — the user is not actively watching.`}:{}};cl(`query_context_loading_end`);let m=qr({mainThreadAgentDefinition:ee,toolUseContext:o,customSystemPrompt:h,defaultSystemPrompt:l,appendSystemPrompt:g});o.renderedSystemPrompt=m,cl(`query_query_start`),$u(),Xu(),Uu();for await(let t of Ts({messages:e,systemPrompt:m,userContext:p,systemContext:f,canUseTool:no,toolUseContext:o,querySource:wo()}))oo(t);cl(`query_end`),oa(),qn(),await v?.(nr.current)},[d,oa,io,F,z,h,v,g,no,ee,oo,An,j]),uo=(0,Q.useCallback)(async(e,t,n,r,i,a,o)=>{let s=Gt.tryStart();if(s===null)return X(`tengu_concurrent_onquery_detected`,{}),e.filter(e=>e.type===`user`&&!e.isMeta).map(e=>me(e.message.content)).filter(e=>e!==null).forEach((e,t)=>{_i({value:e,mode:`prompt`}),t===0&&X(`tengu_concurrent_onquery_enqueued`,{})}),!1;try{Lt(!1),nn(),H(t=>[...t,...e]),di.current=0,Ku((o?ir(o):null)??Du()),U.current=[],Et([]),mi(null);let s=nr.current;if(o&&await ua(o,s,e.length),a&&o&&!await a(o,s))return!0;await lo(s,e,t,n,r,i)}finally{if(Gt.end(s)){Lt(t.signal.aborted),bi(Date.now()),Ri.current=!1,oa(),await da(nr.current,t.signal.aborted),zt.current();let e;Du()!==null&&Du()>0&&!t.signal.aborted&&(e={tokens:Nu(),limit:Du(),nudges:Vu()}),Ku(null);let n=Date.now()-$t.current-en.current;(n>3e4||e!==void 0)&&!t.signal.aborted&&!xe&&H(t=>[...t,ia(n,e,Td(t,vr))]),At(null)}if(t.signal.reason===`user-cancel`&&!Gt.isActive&&Ir.current===``&&C()===0&&!ge.getState().viewingAgentTaskId){let e=nr.current,t=e.findLast(rh);t&&ih(e,e.lastIndexOf(t))&&(Jn(),Bt.current(t))}}return!0},[lo,z,oa,Gt,ua,da]),fo=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{let e=ae;if(!e||B||fo.current)return;fo.current=!0;async function t(e){if(e.clearContext){let t=e.message.planContent?As():void 0,{clearConversation:n}=await import(`./conversation-WxH5pb2z.js`);await n({setMessages:H,readFileState:Ta.current,discoveredSkillNames:ka.current,loadedNestedMemoryPaths:Aa.current,getAppState:()=>ge.getState(),setAppState:z,setConversationId:Fi}),Pn.current=!1,Nn(void 0),Da.current.clear(),Oa.current=0,t&&oi(Wu(),t)}z(t=>{let n=e.mode?Tr(t.toolPermissionContext,Dx(e.mode,e.allowedPrompts)):t.toolPermissionContext;return e.mode===`auto`&&(n=Po({...n,mode:`auto`,prePlanMode:void 0})),{...t,initialMessage:null,toolPermissionContext:n}}),es()&&Bi(e=>{z(t=>({...t,fileHistory:e(t.fileHistory)}))},e.message.uuid),await Er();let t=e.message.message.content;if(typeof t==`string`&&!e.message.planContent)po(t,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}});else{let t=On();At(t),uo([e.message],t,!0,[],ve)}setTimeout(e=>{e.current=!1},100,fo)}t(e)},[ae,B,H,z,uo,ve,_t]);let po=(0,Q.useCallback)(async(e,t,n,r)=>{if(yr(),am(),!n&&e.trim().startsWith(`/`)){let n=D(e,ii).trim(),i=n.indexOf(` `),a=i===-1?n.slice(1):n.slice(1,i),o=i===-1?``:n.slice(i+1).trim(),s=bt.find(e=>Br(e)&&(e.name===a||e.aliases?.includes(a)||dl(e)===a));s?.name===`clear`&&ar.current&&(X(`tengu_idle_return_action`,{action:`hint_converted`,variant:ar.current,idleMinutes:Math.round((Date.now()-zi.current)/6e4),messageCount:nr.current.length,totalInputTokens:Eu()}),ar.current=!1);let c=Gt.isActive&&(s?.immediate||r?.fromKeybinding);if(s&&c&&s.type===`local-jsx`){e.trim()===Ir.current.trim()&&(Rr(``),t.setCursorOffset(0),t.clearBuffer(),ai({}));let n=Ht(e).filter(e=>ii[e.id]?.type===`text`),i=n.length;X(`tengu_paste_text`,{pastedTextCount:i,pastedTextBytes:n.reduce((e,t)=>e+(ii[t.id]?.content.length??0),0)}),X(`tengu_immediate_command_executed`,{commandName:s.name,fromKeybinding:r?.fromKeybinding??!1}),(async()=>{let e=!1,n=(n,r)=>{e=!0,gn({jsx:null,shouldHidePromptInput:!1,clearLocalJSX:!0});let i=[];if(n&&r?.display!==`skip`&&(Ue({key:`immediate-${s.name}`,text:n,priority:`immediate`}),!Xr())){let e=r?.displayArgs??o;i.push(co(we(dl(s),e)),co(`<${yf}>${Xn(n)}</${yf}>`))}r?.metaMessages?.length&&i.push(...r.metaMessages.map(e=>rr({content:e,isMeta:!0}))),i.length&&H(e=>[...e,...i]),Hr!==void 0&&(Rr(Hr.text),t.setCursorOffset(Hr.cursorOffset),ai(Hr.pastedContents),Ur(void 0))},r=io(nr.current,[],On(),ve),i=await(await s.load()).call(n,r,o);i&&!e&&gn({jsx:i,shouldHidePromptInput:!1,isLocalJSXCommand:!0})})();return}}if(ni.isRemoteMode&&!e.trim())return;Number(process.env.CLAUDE_CODE_IDLE_THRESHOLD_MINUTES??75),Number(process.env.CLAUDE_CODE_IDLE_TOKEN_THRESHOLD??1e5),r?.fromKeybinding||(Lo({display:n?e:Jr(e,zr),pastedContents:n?{}:ii}),zr===`bash`&&OC(e.trim()));let i=!n&&e.trim().startsWith(`/`),a=!B||n||ni.isRemoteMode;if(Hr!==void 0&&!i&&a?(Rr(Hr.text),t.setCursorOffset(Hr.cursorOffset),ai(Hr.pastedContents),Ur(void 0)):a&&(r?.fromKeybinding||(Rr(``),t.setCursorOffset(0)),ai({})),a&&(Vr(`prompt`),Je(void 0),ui(e=>e+1),t.clearBuffer(),na.current=!1,!i&&zr===`prompt`&&!n&&!ni.isRemoteMode&&(or(e),nn()),z(e=>({...e,attribution:Fc(e.attribution,e=>{Mr(e).catch(e=>{J(`Attribution: Failed to save snapshot: ${e}`)})})}))),n){let{queryRequired:t}=await it(n.state,n.speculationSessionTimeSavedMs,n.setAppState,e,{setMessages:H,readFileState:Ta,cwd:bu()});if(t){let e=On();At(e),uo([],e,!0,[],ve)}return}if(ni.isRemoteMode&&!(i&&bt.find(t=>{let n=e.trim().slice(1).split(/\s/)[0];return Br(t)&&(t.name===n||t.aliases?.includes(n)||dl(t)===n)})?.type===`local-jsx`)){let t=Object.values(ii),n=t.filter(e=>e.type===`image`),r=n.length>0?n.map(e=>e.id):void 0,i=e.trim(),a=e.trim();if(t.length>0){let n=[],r=[],o=e.trim();o&&(n.push({type:`text`,text:o}),r.push({type:`text`,text:o}));for(let e of t)if(e.type===`image`){let t={type:`base64`,media_type:e.mediaType??`image/png`,data:e.content};n.push({type:`image`,source:t}),r.push({type:`image`,source:t})}else n.push({type:`text`,text:e.content}),r.push({type:`text`,text:e.content});i=n,a=r}let o=rr({content:i,imagePasteIds:r});H(e=>[...e,o]),await ni.sendMessage(a,{uuid:o.uuid});return}await Er(),await eO({input:e,helpers:t,queryGuard:Gt,isExternalLoading:qt,mode:zr,commands:bt,onInputChange:Rr,setPastedContents:ai,setToolJSX:gn,getToolUseContext:io,messages:nr.current,mainLoopModel:ve,pastedContents:ii,ideSelection:Ke,setUserInputOnProcessing:or,setAbortController:At,abortController:kt,onQuery:uo,setAppState:z,querySource:wo(),onBeforeQuery:_,canUseTool:no,addNotification:Ue,setMessages:H,streamMode:wt.current,hasInterruptibleToolInProgress:Zr.current}),(i||B)&&Hr!==void 0&&(Rr(Hr.text),t.setCursorOffset(Hr.cursorOffset),ai(Hr.pastedContents),Ur(void 0))},[Gt,B,qt,zr,bt,Rr,Vr,ai,ui,Je,gn,io,ve,ii,Ke,or,At,Ue,uo,Hr,Ur,z,_,no,Qr,H,Er,yr]),mo=(0,Q.useCallback)(()=>{let e=Fa?MA(Fa):`/issue`;Ia(null),po(e,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}}).catch(t=>{J(`Auto-run ${e} failed: ${cd(t)}`)})},[po,Fa]),ho=(0,Q.useCallback)(()=>{Ia(null)},[]),go=(0,Q.useCallback)(()=>{po(`/issue`,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}}).catch(e=>{J(`Survey feedback request failed: ${e instanceof Error?e.message:String(e)}`)})},[po]),_o=(0,Q.useRef)(po);_o.current=po;let vo=(0,Q.useCallback)(async()=>{if(Ua(!0),to()){h_(`tmux`,[`detach-client`],{stdio:`ignore`}),Ua(!1);return}if(ol()!==null){Ba((0,$.jsx)(sg,{showWorktree:!0,onDone:()=>{},onCancel:()=>{Ba(null),Ua(!1)}}));return}let e=await(await $e.load()).call(()=>{});Ba(e),e===null&&Ua(!1)},[]),yo=(0,Q.useCallback)(()=>{ki(e=>!e)},[]),bo=(0,Q.useCallback)(e=>{let t=nr.current,n=t.lastIndexOf(e);if(n===-1)return;X(`tengu_conversation_rewind`,{preRewindMessageCount:t.length,postRewindMessageCount:n,messagesRemoved:t.length-n,rewindToMessageIndex:n}),H(t.slice(0,n)),Fi(l_()),_c();let r=e.permissionMode;z(e=>({...e,toolPermissionContext:r&&e.toolPermissionContext.mode!==r?{...e.toolPermissionContext,mode:r}:e.toolPermissionContext,promptSuggestion:{text:null,promptId:null,shownAt:0,acceptedAt:0,generationRequestId:null}}))},[H,z]),xo=(0,Q.useCallback)(e=>{bo(e);let t=si(e);if(t&&(Rr(t.text),Vr(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}}}),ai(n)}}},[bo,Rr]);Bt.current=xo;let So=(0,Q.useCallback)(async e=>{setImmediate((e,t)=>e(t),xo,e)},[xo]),Co=e=>{let t=e.slice(0,24);return V.findIndex(e=>e.uuid.slice(0,24)===t)},{enter:To,handlers:Eo}=Wo(mr,hr,gr,{copy:e=>void Wl(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=Co(e.uuid),n=t>=0?V[t]:void 0;if(!n||!rh(n))return;let r=!await ro(ie,n.uuid),i=ih(V,t);r&&i?(Xa(),So(n)):(ji(n),ki(!0))}});async function Do(){Pa();let e=await ri();if(e.length>0){let t=e.map(e=>` [${e.type}] ${e.path} (${e.content.length} chars)${e.parent?` (included by ${e.parent})`:``}`).join(`
125
+ `);J(`Loaded ${e.length} AGENTS.md/rules files:\n${t}`)}else J(`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})}jD(Vg()),by(V,V.length===i?.length);let{sendBridgeResult:Oo}=xy(V,H,jt,bt,ve);zt.current=Oo,MD();let ko=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(oe.length<1){ko.current=!1;return}ko.current||(ko.current=!0,sf(e=>({...e,promptQueueUseCount:(e.promptQueueUseCount??0)+1})))},[oe.length]),iO({executeQueuedInput:(0,Q.useCallback)(async e=>{await eO({helpers:{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}},queryGuard:Gt,commands:bt,onInputChange:()=>{},setPastedContents:()=>{},setToolJSX:gn,getToolUseContext:io,messages:V,mainLoopModel:ve,ideSelection:Ke,setUserInputOnProcessing:or,setAbortController:At,onQuery:uo,setAppState:z,querySource:wo(),onBeforeQuery:_,canUseTool:no,addNotification:Ue,setMessages:H,queuedCommands:e})},[Gt,bt,gn,io,V,ve,Ke,or,no,At,uo,Ue,z,_]),hasActiveLocalJsxUI:Rn,queryGuard:Gt}),(0,Q.useEffect)(()=>{Ei.recordUserActivity(),Zu(!0)},[Nr,ci]),(0,Q.useEffect)(()=>{ci===1&&Xg()},[ci]),(0,Q.useEffect)(()=>{if(B||ci===0||yi===0)return;let e=setTimeout((e,t,n,r,i)=>{if(Lu()>e)return;let a=Date.now()-e;!t&&!n&&r.current===void 0&&a>=rf().messageIdleNotifThresholdMs&&ey({message:`Work Mate is waiting for your input`,notificationType:`idle_prompt`},i)},rf().messageIdleNotifThresholdMs,yi,B,fn,sn,_e);return()=>clearTimeout(e)},[B,fn,ci,yi,_e]),(0,Q.useEffect)(()=>{},[yi,B,Ue,We]),aO({isLoading:B,onSubmitMessage:(0,Q.useCallback)((e,t)=>{if(Gt.isActive||Un().some(e=>e.mode===`prompt`||e.mode===`bash`))return!1;let n=typeof e==`string`?{value:e,mode:`prompt`,isMeta:t?.isMeta?!0:void 0}:e;return(async()=>{let e=await kc([n]),t=e.attachmentCommands[0];if(!t)return;let r=On();At(r);let i=rr({content:t.value,isMeta:t.isMeta?!0:void 0,origin:t.origin}),a=!1;try{a=await uo([i],r,!0,[],ve)!==!1}catch(t){try{await il({commands:e.claimedCommands,outcome:{type:`failed`,error:t},currentDir:id(),priority:`later`})}catch(e){Y(dd(e))}Y(dd(t));return}if(a)try{let t=await il({commands:e.claimedCommands,outcome:{type:`completed`},currentDir:id(),priority:`later`});for(let e of t)_i(e)}catch(e){Y(dd(e))}})().catch(e=>{Y(dd(e))}),!0},[uo,ve,ge])}),gO({isLoading:B||ae!==null,queuedCommandsLength:oe.length,hasActiveLocalJsxUI:Rn,isInPlanMode:F.mode===`plan`,onQueueTick:e=>_i(e)}),xO({isLoading:B||ae!==null,wasAborted:It,queuedCommandsLength:oe.length,hasActiveLocalJsxUI:Rn,isInPlanMode:F.mode===`plan`,isQueryActiveNow:Gt.getSnapshot,onContinuationEnqueued:({turn:e,objective:t})=>{let n=`Goal auto-continue (${e}/1): continue advancing "${t}".`;H(e=>[...e,rr({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(!xe){mm(null);return}if(!B){if(Se!==null&&oe.length===0&&!Rn&&F.mode!==`plan`&&ae===null){mm({enabled:!0,phase:`standby`,next_tick_at:Se,sleep_until:null});return}mm({enabled:!0,phase:null,next_tick_at:null,sleep_until:null})}},[ae,B,Rn,xe,Se,oe.length,F.mode]),(0,Q.useEffect)(()=>{oe.some(e=>e.priority===`now`)&&jt.current?.abort(`interrupt`)},[oe]);let Ao=(0,Q.useRef)(Do);Ao.current=Do;let jo=(0,Q.useRef)(tr);jo.current=tr,(0,Q.useEffect)(()=>(Ao.current(),()=>{jo.current.shutdown()}),[]);let{internal_eventEmitter:Mo}=zl(),[No,Fo]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{let e=()=>{process.stdout.write(`
126
+ Work Mate has been suspended. Run \`fg\` to bring Work Mate back.
127
+ Note: ctrl + z now suspends Work Mate, ctrl + _ undoes input.
128
+ `)},t=()=>{Fo(e=>e+1)};return Mo?.on(`suspend`,e),Mo?.on(`resume`,t),()=>{Mo?.off(`suspend`,e),Mo?.off(`resume`,t)}},[Mo]);let Ro=(0,Q.useMemo)(()=>{if(!B)return null;let e=V.filter(e=>{if(e.type!==`progress`)return!1;let t=e.data;return t.type===`hook_progress`&&(t.hookEvent===`Stop`||t.hookEvent===`SubagentStop`)});if(e.length===0)return null;let t=e.at(-1)?.toolUseID;if(!t||V.some(e=>e.type===`system`&&e.subtype===`stop_hook_summary`&&e.toolUseID===t))return null;let n=e.filter(e=>e.toolUseID===t),r=n.length,i=Td(V,e=>{if(e.type!==`attachment`)return!1;let n=e.attachment;return`hookEvent`in n&&(n.hookEvent===`Stop`||n.hookEvent===`SubagentStop`)&&`toolUseID`in n&&n.toolUseID===t}),a=n.find(e=>e.data.statusMessage)?.data.statusMessage;if(a)return r===1?`${a}…`:`${a}… ${i}/${r}`;let o=n[0]?.data.hookEvent===`SubagentStop`?`subagent stop`:`stop`;return r===1?`running ${o} hook`:`running stop hooks… ${i}/${r}`},[V,B]),zo=(0,Q.useCallback)(()=>{Ar({messagesLength:V.length,streamingToolUsesLength:Tt.length})},[V.length,Tt.length]),Bo=(0,Q.useCallback)(()=>{Ar(null)},[]),Vo=Xr()&&!N,Ho=(0,Q.useRef)(null),[Uo,Go]=(0,Q.useState)(!1),[Ko,qo]=(0,Q.useState)(``),[Jo,Xo]=(0,Q.useState)(0),[Qo,$o]=(0,Q.useState)(0),ts=(0,Q.useCallback)((e,t)=>{Xo(e),$o(t)},[]);ql((e,t,n)=>{if(t.ctrl||t.meta)return;if(e===`/`){Ho.current?.setAnchor(),Go(!0),n.stopImmediatePropagation();return}let r=e[0];if((r===`n`||r===`N`)&&e===r.repeat(e.length)&&Jo>0){let t=r===`n`?Ho.current?.nextMatch:Ho.current?.prevMatch;if(t)for(let n=0;n<e.length;n++)t();n.stopImmediatePropagation()}},{isActive:ke===`transcript`&&Vo&&!Uo&&!Pe});let{setQuery:ns,scanElement:rs,setPositions:is}=eu(),as=Ql().columns,os=Q.useRef(as);Q.useEffect(()=>{os.current!==as&&(os.current=as,(Ko||Uo)&&(Go(!1),qo(``),Xo(0),$o(0),Ho.current?.disarmSearch(),ns(``)))},[as,Ko,Uo,ns]),ql((e,t,n)=>{if(!(t.ctrl||t.meta)){if(e===`q`){Bo(),n.stopImmediatePropagation();return}if(e===`[`&&!Pe)Fe(!0),Me(!0),n.stopImmediatePropagation();else if(e===`v`){if(n.stopImmediatePropagation(),He.current)return;He.current=!0;let e=ze.current,t=t=>{e===ze.current&&(clearTimeout(Be.current),Re(t))};t(`rendering ${Dr.length} messages…`),(async()=>{try{let e=Math.max(80,(process.stdout.columns??80)-6),n=(await Xv(Dr,_t,e)).replace(/[ \t]+$/gm,``),r=r_(Qg(),`cc-transcript-${Date.now()}.txt`);await p_(r,n);let i=Lh(r);t(i?`opening ${r}`:`wrote ${r} · no $VISUAL/$EDITOR set`)}catch(e){t(`render failed: ${e instanceof Error?e.message:String(e)}`)}He.current=!1,e===ze.current&&(Be.current=setTimeout(e=>e(``),4e3,Re))})()}}},{isActive:ke===`transcript`&&Vo&&!Uo});let ss=ke===`transcript`&&Vo;(0,Q.useEffect)(()=>{ss||(qo(``),Xo(0),$o(0),Go(!1),ze.current++,clearTimeout(Be.current),Fe(!1),Re(``))},[ss]),(0,Q.useEffect)(()=>{ns(ss?Ko:``),ss||is(null)},[ss,Ko,ns,is]);let ls={screen:ke,setScreen:Ae,showAllInTranscript:je,setShowAllInTranscript:Me,messageCount:V.length,onEnterTranscript:zo,onExitTranscript:Bo,virtualScrollActive:Vo,searchBarOpen:Uo},us=kr?Dr.slice(0,kr.messagesLength):Dr,ds=kr?Tt.slice(0,kr.streamingToolUsesLength):Tt;BD({onOpenBackgroundTasks:Rn?void 0:()=>qi(!0),onTogglePipeSelector:()=>{z(e=>{let t=e.pipeIpc??{};return{...e,pipeIpc:{...t,selectorOpen:!t.selectorOpen}}})}});let fs=fe?le[fe]:void 0,ps=fs&&$n(fs)?fs:void 0,ms=hi||!B,hs=ps?.messages,gs=(0,Q.useMemo)(()=>{if(!ps)return;let e=hs??[];if(!$n(ps)||ps.agentType!==`fork`||!ps.prompt)return e;let t=ps.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(Tj))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=>!Tj(e))}});if(i)return a;let o=n===-1?r+1:n+1,s=rr({content:ps.prompt,timestamp:new Date(ps.startTime).toISOString()});return[...a.slice(0,o),s,...a.slice(o)]},[ps,hs]),_s=ps?gs??[]:ms?V:Dr;if(ke===`transcript`){let e=Xr()&&!N&&!Pe?Vt:void 0,t=(0,$.jsx)(Ng,{messages:us,tools:_t,commands:bt,verbose:!0,toolJSX:null,toolUseConfirmQueue:[],inProgressToolUseIDs:Gr,isMessageSelectorVisible:!1,conversationId:Pi,screen:ke,agentDefinitions:re,streamingToolUses:ds,showAllInTranscript:je,isLoading:B,hidePastThinking:!0,streamingThinking:Dt,scrollRef:e,jumpRef:Ho,onSearchMatchesChange:ts,scanElement:rs,setPositions:is,disableRenderCap:Pe}),n=fn&&(0,$.jsx)(G,{flexDirection:`column`,width:`100%`,children:fn.jsx}),r=(0,$.jsxs)(wn,{children:[(0,$.jsx)(Cj,{isAnimating:Hn,title:In,disabled:j,noPrefix:!1}),(0,$.jsx)(FD,{...ls}),(0,$.jsx)(LD,{onSubmit:po,isActive:!fn?.isLocalJSXCommand}),e?(0,$.jsx)(cj,{scrollRef:Vt,isActive:!0,isModal:!Uo,onScroll:()=>Ho.current?.disarmSearch()}):null,(0,$.jsx)(zD,{...Qa}),e?(0,$.jsx)(jg,{scrollRef:Vt,scrollable:(0,$.jsxs)($.Fragment,{children:[t,n,(0,$.jsx)(dk,{})]}),bottom:Uo?(0,$.jsx)(yj,{jumpRef:Ho,initialQuery:``,count:Jo,current:Qo,onClose:e=>{qo(Jo>0?e:``),Go(!1),e||(Xo(0),$o(0),Ho.current?.setSearchQuery(``))},onCancel:()=>{Go(!1),Ho.current?.setSearchQuery(``),Ho.current?.setSearchQuery(Ko),ns(Ko)},setHighlight:ns}):(0,$.jsx)(vj,{showAllInTranscript:je,virtualScroll:!0,status:Le||void 0,searchBadge:Ko&&Jo>0?{current:Qo,count:Jo}:void 0})}):(0,$.jsxs)($.Fragment,{children:[t,n,(0,$.jsx)(dk,{}),(0,$.jsx)(vj,{showAllInTranscript:je,virtualScroll:!1,suppressShowAll:Pe,status:Le||void 0})]})]});return e?(0,$.jsx)(su,{mouseTracking:qe(),children:r}):r}let vs=Yt&&!ps&&_s.length<=Zt.current?Yt:void 0,ys=qa===`tool-permission`?(0,$.jsx)(nS,{onDone:()=>vn(([e,...t])=>t),onReject:Za,toolUseConfirm:_n[0],toolUseContext:io(V,V,kt??On(),ve),verbose:I,setStickyFooter:Xr()?bn:void 0},_n[0]?.toolUseID):null,bs=Xr()&&fn?.isLocalJSXCommand===!0,Ss=bs?fn.jsx:null,Cs=(0,$.jsxs)(wn,{children:[(0,$.jsx)(Cj,{isAnimating:Hn,title:In,disabled:j,noPrefix:!1}),(0,$.jsx)(FD,{...ls}),(0,$.jsx)(LD,{onSubmit:po,isActive:!fn?.isLocalJSXCommand}),(0,$.jsx)(cj,{scrollRef:Vt,isActive:Xr()&&(Ss!=null||!qa||qa===`tool-permission`),onScroll:wr}),null,(0,$.jsx)(zD,{...Qa}),(0,$.jsx)(eh,{dynamicMcpConfig:Te,isStrictMcpConfig:m,children:(0,$.jsx)(jg,{scrollRef:Vt,overlay:ys,modal:Ss,modalScrollRef:Ut,dividerYRef:cr,hidePill:!!ps,newMessageCount:_r?.count??0,onPillClick:()=>{hr(null),fr(Vt.current)},scrollable:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ng,{messages:_s,tools:_t,commands:bt,verbose:I,toolJSX:fn,toolUseConfirmQueue:_n,inProgressToolUseIDs:Gr,isMessageSelectorVisible:Oi,conversationId:Pi,screen:ke,streamingToolUses:Tt,showAllInTranscript:je,agentDefinitions:re,isLoading:B,streamingText:B&&!ps?vi:null,unseenDivider:ps?void 0:_r,scrollRef:Xr()?Vt:void 0,trackStickyPrompt:Xr()?!0:void 0,cursor:mr,setCursor:hr,cursorNavRef:gr}),(0,$.jsx)(dA,{}),!b&&vs&&!Ss&&(0,$.jsx)(Xs,{param:{text:vs,type:`text`},addMargin:!0,verbose:I}),fn&&!(fn.isLocalJSXCommand&&fn.isImmediate)&&!bs&&(0,$.jsx)(G,{flexDirection:`column`,width:`100%`,children:fn.jsx}),(0,$.jsx)(G,{flexGrow:1}),pa&&(0,$.jsx)(pn,{mode:St,spinnerTip:se,responseLengthRef:di,apiMetricsRef:U,overrideMessage:xi,spinnerSuffix:Ro,verbose:I,loadingStartTimeRef:$t,totalPausedMsRef:en,pauseStartTimeRef:tn,overrideColor:Ci,overrideShimmerColor:Ti,hasActiveTools:Gr.size>0,leaderIsIdle:!B})]}),bottom:(0,$.jsx)(G,{flexDirection:`row`,width:`100%`,alignItems:`flex-end`,children:(0,$.jsxs)(G,{flexDirection:`column`,flexGrow:1,children:[Xr()&&(0,$.jsx)(FE,{}),yn,fn?.isLocalJSXCommand&&fn.isImmediate&&!bs&&(0,$.jsx)(G,{flexDirection:`column`,width:`100%`,children:fn.jsx}),!pa&&!fn?.isLocalJSXCommand&&ce&&ht&&ht.length>0&&(0,$.jsx)(G,{width:`100%`,flexDirection:`column`,children:(0,$.jsx)(Vs,{tasks:ht,isStandalone:!0})}),qa===`sandbox-permission`&&(0,$.jsx)(lk,{hostPattern:Sn[0].hostPattern,onUserResponse:e=>{let{allow:t,persistToSettings:n}=e,r=Sn[0];if(!r)return;let i=r.hostPattern.host;Cn(e=>(e.filter(e=>e.hostPattern.host===i).forEach(e=>e.resolvePromise(t)),e.filter(e=>e.hostPattern.host!==i)));let a=kn.current.get(i);if(a){for(let e of a)e();kn.current.delete(i)}}},Sn[0].hostPattern.host),qa===`prompt`&&(0,$.jsx)(ES,{title:Tn[0].title,toolInputSummary:Tn[0].toolInputSummary,request:Tn[0].request,onRespond:e=>{let t=Tn[0];t&&(t.resolve({prompt_response:t.request.prompt,selected:e}),En(([,...e])=>e))},onAbort:()=>{let e=Tn[0];e&&(e.reject(Error(`Prompt cancelled by user`)),En(([,...e])=>e))}},Tn[0].request.prompt),qa===`elicitation`&&(0,$.jsx)(CS,{event:de.queue[0],onResponse:(e,t)=>{let n=de.queue[0];n&&(n.respond({action:e,content:t}),n.params.mode===`url`&&e===`accept`||z(e=>({...e,elicitation:{queue:e.elicitation.queue.slice(1)}})))},onWaitingDismiss:e=>{let t=de.queue[0];z(e=>({...e,elicitation:{queue:e.elicitation.queue.slice(1)}})),t?.onWaitingDismiss?.(e)}},`${de.queue[0].serverName}:${String(de.queue[0].requestId)}`),qa===`cost`&&(0,$.jsx)(Zv,{onDone:()=>{Ni(!1),Ui(!0),sf(e=>({...e,hasAcknowledgedCostThreshold:!0})),X(`tengu_cost_threshold_acknowledged`,{})}}),qa===`idle-return`&&Ii&&(0,$.jsx)(Qv,{idleMinutes:Ii.idleMinutes,totalInputTokens:Eu(),onDone:async e=>{let t=Ii;if(Li(null),X(`tengu_idle_return_action`,{action:e,idleMinutes:Math.round(t.idleMinutes),messageCount:nr.current.length,totalInputTokens:Eu()}),e===`dismiss`){Rr(t.input);return}if(e===`never`&&sf(e=>e.idleReturnDismissed?e:{...e,idleReturnDismissed:!0}),e===`clear`){let{clearConversation:e}=await import(`./conversation-WxH5pb2z.js`);await e({setMessages:H,readFileState:Ta.current,discoveredSkillNames:ka.current,loadedNestedMemoryPaths:Aa.current,getAppState:()=>ge.getState(),setAppState:z,setConversationId:Fi}),Pn.current=!1,Nn(void 0),Da.current.clear(),Oa.current=0}Ri.current=!0,_o.current(t.input,{setCursorOffset:()=>{},clearBuffer:()=>{},resetHistory:()=>{}})}}),qa===`ide-onboarding`&&(0,$.jsx)(ws,{onDone:()=>nt(!1),installationStatus:Qe}),qa===`remote-callout`&&(0,$.jsx)(TO,{onDone:e=>{z(t=>t.showRemoteCallout?{...t,showRemoteCallout:!1,...e===`enable`&&{replBridgeEnabled:!0,replBridgeExplicit:!0,replBridgeOutboundOnly:!1}}:t)}}),za,qa===`plugin-hint`&&ut&&(0,$.jsx)(Lk,{pluginName:ut.pluginName,pluginDescription:ut.pluginDescription,marketplaceName:ut.marketplaceName,sourceCommand:ut.sourceCommand,onResponse:dt}),qa===`search-extra-tools-hint`&&ft.visible&&(0,$.jsx)(zk,{tools:ft.tools,onSelect:ft.handleSelect,onDismiss:ft.handleDismiss}),qa===`lsp-recommendation`&&st&&(0,$.jsx)(Pk,{pluginName:st.pluginName,pluginDescription:st.pluginDescription,fileExtension:st.fileExtension,onResponse:ct}),qa===`desktop-upsell`&&(0,$.jsx)(iA,{onDone:()=>ot(!1)}),fa(),!fn?.shouldHidePromptInput&&!qa&&!Va&&!b&&!mr&&(0,$.jsxs)($.Fragment,{children:[Fa&&(0,$.jsx)(AA,{onRun:mo,onCancel:ho,reason:NA(Fa)}),ba.state===`closed`?xa.state===`closed`?(0,$.jsx)(GO,{state:va.state,lastResponse:va.lastResponse,handleSelect:va.handleSelect,handleTranscriptSelect:va.handleTranscriptSelect,inputValue:Nr,setInputValue:Rr,onRequestFeedback:Ra.current?void 0:go}):(0,$.jsx)(GO,{state:xa.state,lastResponse:xa.lastResponse,handleSelect:xa.handleSelect,handleTranscriptSelect:xa.handleTranscriptSelect,inputValue:Nr,setInputValue:Rr,onRequestFeedback:go,message:`How well did Work Mate use its memory? (optional)`}):(0,$.jsx)(GO,{state:ba.state,lastResponse:ba.lastResponse,handleSelect:ba.handleSelect,inputValue:Nr,setInputValue:Rr,onRequestFeedback:go}),ga.suggestion&&(0,$.jsx)(TD,{isOpen:ga.isOpen,skillName:ga.suggestion.skillName,updates:ga.suggestion.updates,handleSelect:ga.handleSelect,inputValue:Nr,setInputValue:Rr}),_a&&(0,$.jsx)(PA,{}),(0,$.jsx)($E,{debug:n,ideSelection:Ke,hasSuppressedDialogs:!!Ja,isLocalJSXCommandActive:Rn,getToolUseContext:io,toolPermissionContext:F,setToolPermissionContext:eo,apiKeyStatus:Na,commands:bt,agents:re.activeAgents,isLoading:B,onExit:vo,verbose:I,messages:V,onAutoUpdaterResult:dn,autoUpdaterResult:un,input:Nr,onInputChange:Rr,mode:zr,onModeChange:Vr,stashedPrompt:Hr,setStashedPrompt:Ur,submitCount:ci,onShowMessageSelector:yo,onMessageActionsEnter:void 0,mcpClients:Ge,pastedContents:ii,setPastedContents:ai,vimMode:Wi,setVimMode:Gi,showBashesDialog:Ki,setShowBashesDialog:qi,onSubmit:po,isSearchingHistory:Ji,setIsSearchingHistory:Yi,helpOpen:Xi,setHelpOpen:Zi,insertTextRef:Lr}),(0,$.jsx)(CO,{onBackgroundSession:ao,isLoading:B}),(0,$.jsx)(mO,{})]}),mr&&(0,$.jsx)(Us,{cursor:mr}),qa===`message-selector`&&(0,$.jsx)(sh,{messages:V,preselectedMessage:Ai,onPreRestore:Xa,onRestoreCode:async e=>{await nl(e=>{z(t=>({...t,fileHistory:e(t.fileHistory)}))},e.uuid)},onSummarize:async(e,t,n=`from`)=>{let r=Io(V),i=r.indexOf(e);if(i===-1){H(e=>[...e,$c(`That message is no longer in the active context (snipped or pre-compact). Choose a more recent message.`,`warning`)]);return}let a=On(),o=io(r,[],a,ve),s=o.getAppState(),c=await ea(o.options.tools,o.options.mainLoopModel,Array.from(s.toolPermissionContext.additionalWorkingDirectories.keys()),o.options.mcpClients),l=qr({mainThreadAgentDefinition:void 0,toolUseContext:o,customSystemPrompt:o.options.customSystemPrompt,defaultSystemPrompt:c,appendSystemPrompt:o.options.appendSystemPrompt}),[u,d]=await Promise.all([xt(),js()]),f=await Sa(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(Xr()&&n===`from`?H(t=>{let n=t.findIndex(t=>t.uuid===e.uuid);return[...t.slice(0,n===-1?0:n),...h]}):H(h),om(!1),Fi(l_()),pt(o.options.querySource),n===`from`){let t=si(e);t&&(Rr(t.text),Vr(t.mode))}let g=Yo(`app:toggleTranscript`,`Global`,`ctrl+o`);Ue({key:`summarize-ctrl-o-hint`,text:`Conversation summarized (${g} for history)`,priority:`medium`,timeoutMs:8e3})},onRestoreMessage:So,onClose:()=>{ki(!1),ji(void 0)}})]})})})},No)]});return Xr()?(0,$.jsx)(su,{mouseTracking:qe(),children:Cs}):Cs}export{Ej as t};