@readmagic/workmate 0.0.25 → 0.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (355) hide show
  1. package/dist/chunks/{AddWorkspaceDirectory-Y5S_lMjD.js → AddWorkspaceDirectory-mS8iUoWY.js} +1 -1
  2. package/dist/chunks/{AgentsMdExternalIncludesDialog-DVbU-BaD.js → AgentsMdExternalIncludesDialog-BHBkysy0.js} +1 -1
  3. package/dist/chunks/AgentsMdExternalIncludesDialog-DuStmCjj.js +1 -0
  4. package/dist/chunks/App-D--vtCyq.js +1 -0
  5. package/dist/chunks/BackgroundTasksDialog-mcDuiNGs.js +2 -0
  6. package/dist/chunks/{BypassPermissionsModeDialog-DjqGAL4C.js → BypassPermissionsModeDialog-DyqI98d2.js} +1 -1
  7. package/dist/chunks/CustomSelect-CpMbxYbt.js +1 -0
  8. package/dist/chunks/DiffDialog-BQAU2pJx.js +6 -0
  9. package/dist/chunks/Doctor-BU69VQzw.js +1 -0
  10. package/dist/chunks/Doctor-DJOMbSDE.js +3 -0
  11. package/dist/chunks/{ExitFlow-Dh9QdaYK.js → ExitFlow-xBOnvhiW.js} +2 -2
  12. package/dist/chunks/{InvalidConfigDialog-C9boykQn.js → InvalidConfigDialog-NiuhcaG5.js} +1 -1
  13. package/dist/chunks/{InvalidSettingsDialog-UN5mleCK.js → InvalidSettingsDialog-DrromC1I.js} +1 -1
  14. package/dist/chunks/KeybindingProviderSetup-CSUkJHTT.js +1 -0
  15. package/dist/chunks/MCPConnectionManager-Bn1PDn3R.js +1 -0
  16. package/dist/chunks/MCPToolListView-BRxjOaOL.js +1 -0
  17. package/dist/chunks/{McpParsingWarnings-zkM_lGd0.js → McpParsingWarnings-BYG2yqjO.js} +1 -1
  18. package/dist/chunks/MessageSelector-B7xAQqZI.js +3 -0
  19. package/dist/chunks/Messages-CxMsfjOa.js +10 -0
  20. package/dist/chunks/{Onboarding-BT90cFkn.js → Onboarding-CkATe87e.js} +1 -1
  21. package/dist/chunks/{PermissionDialog-BaibiQae.js → PermissionDialog-tEMMa5-a.js} +1 -1
  22. package/dist/chunks/{PressEnterToContinue-DZc_s_pE.js → PressEnterToContinue-CPOaYnym.js} +1 -1
  23. package/dist/chunks/{PromptInputFooterSuggestions-CCTZYbWI.js → PromptInputFooterSuggestions-CwqAsTI2.js} +1 -1
  24. package/dist/chunks/PromptInputHelpMenu-krq-hiFO.js +1 -0
  25. package/dist/chunks/{ProviderSetup-yIj8YOKF.js → ProviderSetup-J6Ty-Wj8.js} +1 -1
  26. package/dist/chunks/QueryEngine-Mdi_kUaL.js +1 -0
  27. package/dist/chunks/REPL-BgzQtSFF.js +1 -0
  28. package/dist/chunks/REPL-rirm6s_7.js +124 -0
  29. package/dist/chunks/ResumeConversation-Cmsbo5m7.js +1 -0
  30. package/dist/chunks/{SearchBox-C9xxQzh1.js → SearchBox-DQBLKyzJ.js} +1 -1
  31. package/dist/chunks/SearchExtraToolsTool-D1-7C04z.js +1 -0
  32. package/dist/chunks/{SelectMulti-BW7Ffk1G.js → SelectMulti-BpAjjhsn.js} +1 -1
  33. package/dist/chunks/Settings-B6DImvca.js +2 -0
  34. package/dist/chunks/Spinner-DhhSOFcN.js +1 -0
  35. package/dist/chunks/{SpinnerGlyph-CqrOK3Mx.js → SpinnerGlyph-CmVXC-_9.js} +1 -1
  36. package/dist/chunks/{TextInput-Cev5Awdd.js → TextInput-BboKIug2.js} +11 -11
  37. package/dist/chunks/ThemePicker-DTpXbEY0.js +1 -0
  38. package/dist/chunks/{TrustDialog-8Sjmuu0e.js → TrustDialog-CZ8JpySm.js} +1 -1
  39. package/dist/chunks/{ValidationErrorsList-INwwoerV.js → ValidationErrorsList-C_gDQfm1.js} +1 -1
  40. package/dist/chunks/{_baseEach-DrPH_FGo.js → _baseEach-DGbaIpJA.js} +1 -1
  41. package/dist/chunks/_baseSlice-D67_NpZ1.js +1 -0
  42. package/dist/chunks/{add-dir-D3RMaYxy.js → add-dir-B576wzi9.js} +1 -1
  43. package/dist/chunks/{agentDisplay-B3npXoCS.js → agentDisplay-ZuFoBZYu.js} +1 -1
  44. package/dist/chunks/{agents-2mPGmeq6.js → agents-Dy4_hDic.js} +1 -1
  45. package/dist/chunks/agents-HIOBiw4w.js +101 -0
  46. package/dist/chunks/allErrors-CxPNR2WN.js +1 -0
  47. package/dist/chunks/appleTerminalBackup-C9kjzdM9.js +1 -0
  48. package/dist/chunks/{backgroundHousekeeping-BkFxfjOf.js → backgroundHousekeeping-PyLNnGdw.js} +1 -1
  49. package/dist/chunks/backgroundHousekeeping-ZCMPmQuU.js +1 -0
  50. package/dist/chunks/{banner-DHpTmEO7.js → banner-DqFectPg.js} +2 -2
  51. package/dist/chunks/{branch-Be_yDFU8.js → branch-B_BL5N9N.js} +2 -2
  52. package/dist/chunks/{break-cache-UUt6Dkf2.js → break-cache-DL95nKZl.js} +2 -2
  53. package/dist/chunks/{btw-DUml5L1w.js → btw-Y44ctueB.js} +1 -1
  54. package/dist/chunks/bundledMode-BxyD5cqq.js +1 -0
  55. package/dist/chunks/caches-5xZ4dSXt.js +1 -0
  56. package/dist/chunks/caches-Be9saXxV.js +1 -0
  57. package/dist/chunks/{claudeDesktop-mBGFDbI6.js → claudeDesktop-g8eUUY2E.js} +1 -1
  58. package/dist/chunks/{clear-CrGjNe6E.js → clear-DtTkA707.js} +1 -1
  59. package/dist/chunks/{client-BDuhbzLD.js → client-Bw_L3lSc.js} +1 -1
  60. package/dist/chunks/{client-BYFVVMcf.js → client-aJ2Nr_sh.js} +1 -1
  61. package/dist/chunks/client-mnUISv_N.js +1 -0
  62. package/dist/chunks/client-wPqIdEVm.js +1 -0
  63. package/dist/chunks/commands-wfE12a4L.js +1 -0
  64. package/dist/chunks/compact-CvNOtu7J.js +2 -0
  65. package/dist/chunks/config-D3K87Mm1.js +3 -0
  66. package/dist/chunks/config-DTga6Ku8.js +1 -0
  67. package/dist/chunks/config-DtmqWusU.js +1 -0
  68. package/dist/chunks/{context-mV5zjqmc.js → context-Opu4E8dL.js} +1 -1
  69. package/dist/chunks/{context-noninteractive-DvfVvmSE.js → context-noninteractive-B1V2Mp26.js} +5 -5
  70. package/dist/chunks/context-noninteractive-eIlneYiL.js +1 -0
  71. package/dist/chunks/conversation-CG_z7TLE.js +1 -0
  72. package/dist/chunks/conversation-CHesBfFZ.js +1 -0
  73. package/dist/chunks/conversationRecovery-OhitW-7g.js +1 -0
  74. package/dist/chunks/crossProjectResume-mmYx8PrZ.js +40 -0
  75. package/dist/chunks/cwd-BH2f3u0o.js +1 -0
  76. package/dist/chunks/{cwd-BvNt_018.js → cwd-DrEEb4f5.js} +1 -1
  77. package/dist/chunks/{debug-CRnGsZOV.js → debug-kBjDaVkQ.js} +3 -3
  78. package/dist/chunks/{detectRepository-CsJLbVEe.js → detectRepository-M6K2wc7h.js} +1 -1
  79. package/dist/chunks/{diff-DUEoNCnJ.js → diff-Cv7tX2-P.js} +1 -1
  80. package/dist/chunks/{directoryCompletion-Bgi8DBT5.js → directoryCompletion-BHyjyKAM.js} +1 -1
  81. package/dist/chunks/doctor-DeBG5SL5.js +1 -0
  82. package/dist/chunks/{entry-D1iD76SW.js → entry-CbhyIWgj.js} +5 -5
  83. package/dist/chunks/envUtils-DZ_SvEVz.js +1 -0
  84. package/dist/chunks/execFileNoThrow-BfZFnCGa.js +1 -0
  85. package/dist/chunks/execa-CBhG1doD.js +34 -0
  86. package/dist/chunks/exit-OKEV_ddw.js +1 -0
  87. package/dist/chunks/{extraUsage-BtHE-SBX.js → extraUsage-BlRL3yeb.js} +1 -1
  88. package/dist/chunks/extractMemories-jnsv-_n_.js +1 -0
  89. package/dist/chunks/fast-4I_qPJCd.js +1 -0
  90. package/dist/chunks/fast-DiolM1M7.js +1 -0
  91. package/dist/chunks/{fetchModelList-Cjow_QGy.js → fetchModelList-BRFTQim4.js} +1 -1
  92. package/dist/chunks/fetchModelList-qPKAuu4m.js +1 -0
  93. package/dist/chunks/{fileSuggestions-C96V9-Ne.js → fileSuggestions-iWVXvvLB.js} +3 -3
  94. package/dist/chunks/{fpsMetrics-wxj9GAsd.js → fpsMetrics-Ixd0J4CH.js} +1 -1
  95. package/dist/chunks/{gemini-4YGElN3H.js → gemini-BfVyavwQ.js} +2 -2
  96. package/dist/chunks/{generateSessionName-BHIKyXpz.js → generateSessionName-CGaTTXCA.js} +1 -1
  97. package/dist/chunks/genericProcessUtils-CVtQOTO2.js +12 -0
  98. package/dist/chunks/{goal-ePK_jLo3.js → goal-BidR-GFa.js} +1 -1
  99. package/dist/chunks/grok-DLcuI-U7.js +1 -0
  100. package/dist/chunks/{help-B7xRle-V.js → help-CZuvYhXj.js} +1 -1
  101. package/dist/chunks/history-BxPGftQw.js +1 -0
  102. package/dist/chunks/hooks-Bg9WIjZQ.js +1 -0
  103. package/dist/chunks/{hooks-BN5f58HY.js → hooks-ehqfAM5F.js} +2 -2
  104. package/dist/chunks/install-ACGY0vhM.js +1 -0
  105. package/dist/chunks/{instrumentation-Oj5xagJG.js → instrumentation-B9bfF2mA.js} +5 -5
  106. package/dist/chunks/{job-D9ypO0cd.js → job-Coztdn6A.js} +1 -1
  107. package/dist/chunks/keybindings-DwSdLpaE.js +1 -0
  108. package/dist/chunks/{launchLocalMemory-DliLezJw.js → launchLocalMemory-DRzfpIOB.js} +1 -1
  109. package/dist/chunks/{launchOnboarding-A-kk-7ID.js → launchOnboarding-D2zFCJf-.js} +1 -1
  110. package/dist/chunks/{loadAgentsDir-DGozQu_6.js → loadAgentsDir-DR5PVAc3.js} +557 -561
  111. package/dist/chunks/loadAgentsDir-DqAbnpB-.js +1 -0
  112. package/dist/chunks/{loadPluginHooks-BiHPKDaY.js → loadPluginHooks-BiQgGfUJ.js} +1 -1
  113. package/dist/chunks/{loader-CtoR-vO-.js → loader-6MqzNGmV.js} +1 -1
  114. package/dist/chunks/{localSearch-BU02Qsv9.js → localSearch-CzkxDuOR.js} +1 -1
  115. package/dist/chunks/localSearch-DW3JT2MA.js +1 -0
  116. package/dist/chunks/lockfile-D_9vif6E.js +1 -0
  117. package/dist/chunks/{log-DoSpAwRP.js → log-DWZny1vM.js} +1 -1
  118. package/dist/chunks/{logoUtils-DLd6JKqW.js → logoUtils-DR5T0pr3.js} +1 -1
  119. package/dist/chunks/{magicDocs-Bj8LYrN2.js → magicDocs-BwBxjfLo.js} +2 -2
  120. package/dist/chunks/main-Ryi27wYq.js +345 -0
  121. package/dist/chunks/managedEnv-DCEJh3z3.js +1 -0
  122. package/dist/chunks/managedEnv-Do9fgLpk.js +1 -0
  123. package/dist/chunks/managedEnvConstants-CWcT7nYr.js +1 -0
  124. package/dist/chunks/mcp-BCpnF6wD.js +1 -0
  125. package/dist/chunks/mcp-CJ6SDJEK.js +6 -0
  126. package/dist/chunks/mcp-CZBTxbhu.js +2 -0
  127. package/dist/chunks/memory-BQO6Y0ak.js +1 -0
  128. package/dist/chunks/{modalContext-DDZdU1J8.js → modalContext-CBE8xuck.js} +1 -1
  129. package/dist/chunks/{mode-CBKawxnD.js → mode-wq70cR44.js} +1 -1
  130. package/dist/chunks/model-D42epddJ.js +1 -0
  131. package/dist/chunks/{model-DwbqvCY2.js → model-DVk9-2dk.js} +1 -1
  132. package/dist/chunks/{modelOptions-CXBfKFXA.js → modelOptions-beLgXORr.js} +1 -1
  133. package/dist/chunks/nativeInstaller-ChGSz1lb.js +1 -0
  134. package/dist/chunks/{notifications-ql0eSo0Y.js → notifications-dGBuNvFj.js} +1 -1
  135. package/dist/chunks/{onChangeAppState-D85b33R5.js → onChangeAppState-B4K-rSaF.js} +1 -1
  136. package/dist/chunks/openai-DAwnAV9K.js +2 -0
  137. package/dist/chunks/{overlayContext-CLjlCFBl.js → overlayContext-B6i_6y_0.js} +1 -1
  138. package/dist/chunks/{panel-DMZkOEiU.js → panel-C0CF3noE.js} +1 -1
  139. package/dist/chunks/parser-BZt0VFd_.js +1 -0
  140. package/dist/chunks/{parser-UqADrvxF.js → parser-DThLwgdM.js} +1 -1
  141. package/dist/chunks/{partition-CwxTlmMd.js → partition-BRQHofxD.js} +1 -1
  142. package/dist/chunks/{pasteStore-ovtxMVR5.js → pasteStore-BmehVo5j.js} +1 -1
  143. package/dist/chunks/{permissions-CgsvWOk_.js → permissions-DkfWKN-B.js} +3 -3
  144. package/dist/chunks/pidLock-YvAaIrIY.js +3 -0
  145. package/dist/chunks/plan-B6U3ioer.js +1 -0
  146. package/dist/chunks/{platform-DsMIk3eq.js → platform-Vl9IynC3.js} +1 -1
  147. package/dist/chunks/plugin-CTA2_-F7.js +17 -0
  148. package/dist/chunks/{pluginAutoupdate-DQqYDPVg.js → pluginAutoupdate-Dy5W3HWE.js} +1 -1
  149. package/dist/chunks/{pluginBlocklist-BAr9WTup.js → pluginBlocklist-DAoUENwc.js} +1 -1
  150. package/dist/chunks/pluginCliCommands-CaHnj0C_.js +1 -0
  151. package/dist/chunks/{pluginFlagging-BO_3qjfs.js → pluginFlagging-BCj9LJP3.js} +1 -1
  152. package/dist/chunks/pluginOperations-ClXNOOG6.js +2 -0
  153. package/dist/chunks/pluginStartupCheck-CiwMKGjx.js +1 -0
  154. package/dist/chunks/{pluginStartupCheck-BX6cv-vs.js → pluginStartupCheck-U8_xk25t.js} +1 -1
  155. package/dist/chunks/{plugins-9crasx2V.js → plugins-D7zyI9c4.js} +4 -4
  156. package/dist/chunks/{poller-CpLBoB-N.js → poller-BeyVwHAf.js} +1 -1
  157. package/dist/chunks/poorMode-DtzWNhsY.js +1 -0
  158. package/dist/chunks/poorMode-Ocff_UT1.js +1 -0
  159. package/dist/chunks/print-BzljdXem.js +13 -0
  160. package/dist/chunks/processBashCommand-RUkmyAl4.js +1 -0
  161. package/dist/chunks/processSlashCommand-DRLO-jNV.js +5 -0
  162. package/dist/chunks/{projectContext-5fmRr6Sd.js → projectContext-COeHKDrk.js} +1 -1
  163. package/dist/chunks/{projectContext-DhtjLv3k.js → projectContext-QN5U3Ggr.js} +1 -1
  164. package/dist/chunks/{projectOnboardingState--L3BKjOE.js → projectOnboardingState-KqcpRXls.js} +1 -1
  165. package/dist/chunks/{prompt-DzO1um1h.js → prompt-CTByhpUI.js} +20 -20
  166. package/dist/chunks/prompt-DTpfW6yP.js +1 -0
  167. package/dist/chunks/prompt-D__eHY_5.js +1 -0
  168. package/dist/chunks/promptEditor-CpUFgGzc.js +4 -0
  169. package/dist/chunks/{protocolHandler-BWgH1jaF.js → protocolHandler-BQSLVGnG.js} +2 -2
  170. package/dist/chunks/{proxy-BjkGlmBu.js → proxy-BtWuysHM.js} +2 -2
  171. package/dist/chunks/{reconciler-CVMmAaCy.js → reconciler-D6BUq8WB.js} +1 -1
  172. package/dist/chunks/refresh-B4pqFp12.js +1 -0
  173. package/dist/chunks/reject-C6IvUvBt.js +1 -0
  174. package/dist/chunks/{reload-plugins-DeyJTx4s.js → reload-plugins-DXQqk7q6.js} +1 -1
  175. package/dist/chunks/rename-D4XBmTBI.js +1 -0
  176. package/dist/chunks/{renderOptions-DRS2EslG.js → renderOptions-DkP98P_d.js} +1 -1
  177. package/dist/chunks/{resume-N4O5YI-S.js → resume-DzIev0JI.js} +2 -2
  178. package/dist/chunks/ripgrep-CYP26Fhg.js +1 -0
  179. package/dist/chunks/ripgrep-D1f1pbCz.js +5 -0
  180. package/dist/chunks/{runtimeObserver-DMSzdFWt.js → runtimeObserver-BPqlbu0B.js} +4 -4
  181. package/dist/chunks/{runtimeObserver-C0CJvA3q.js → runtimeObserver-BUHs3qjs.js} +1 -1
  182. package/dist/chunks/sandbox-adapter-CumL75tU.js +1 -0
  183. package/dist/chunks/{sandbox-toggle-Tbbaw18C.js → sandbox-toggle-CTtET6Xq.js} +1 -1
  184. package/dist/chunks/searchExtraTools-BMCU2zEf.js +1 -0
  185. package/dist/chunks/{select-Fq6g2Ejk.js → select-FrwoTzuc.js} +1 -1
  186. package/dist/chunks/sessionFileAccessHooks-WO8WTdT9.js +1 -0
  187. package/dist/chunks/{sessionObserver-CRie77tp.js → sessionObserver-B6xzxckA.js} +2 -2
  188. package/dist/chunks/sessionObserver-CBrM4opL.js +1 -0
  189. package/dist/chunks/sessionStorage-C1EAxDWG.js +1 -0
  190. package/dist/chunks/sessionTracing-UFK96PxT.js +11 -0
  191. package/dist/chunks/settings-BK6gCko-.js +1 -0
  192. package/dist/chunks/settings-YIDksG5Z.js +24 -0
  193. package/dist/chunks/setup-BBvZyrfz.js +3 -0
  194. package/dist/chunks/{shadowedRuleDetection-CTnYVrmP.js → shadowedRuleDetection-D6R2OeoH.js} +1 -1
  195. package/dist/chunks/{sideQuestion-Cl8m2qYx.js → sideQuestion-5jcbOMsR.js} +3 -3
  196. package/dist/chunks/{sinks-CiupmfTg.js → sinks-B-kFqjjd.js} +1 -1
  197. package/dist/chunks/sinks-DB_D4lmu.js +1 -0
  198. package/dist/chunks/skillChangeDetector-103-nEle.js +1 -0
  199. package/dist/chunks/{skillGapStore-es3K-aYe.js → skillGapStore-DOz1KCqo.js} +2 -2
  200. package/dist/chunks/{skillLifecycle-BcgoOQBk.js → skillLifecycle-D9NkIwFQ.js} +2 -2
  201. package/dist/chunks/{skillSearchPanel-CuDDb1L-.js → skillSearchPanel-DFiSZaJ4.js} +2 -2
  202. package/dist/chunks/skills-DgeLr52a.js +1 -0
  203. package/dist/chunks/sleep-BbWr_FL1.js +1 -0
  204. package/dist/chunks/{src-9vmGsuSI.js → src-Cy5_qH26.js} +1 -1
  205. package/dist/chunks/{src-DL3w8VPk.js → src-WZ94ZKI3.js} +4 -4
  206. package/dist/chunks/{startupProfiler-DF0AjiDf.js → startupProfiler-DIM_Ihyp.js} +2 -2
  207. package/dist/chunks/startupProfiler-FpGsKWYk.js +1 -0
  208. package/dist/chunks/{state-BQ4BEGin.js → state-CXY-q5gr.js} +1 -1
  209. package/dist/chunks/state-DXt6rahM.js +1 -0
  210. package/dist/chunks/{staticRender-BVWx0IM1.js → staticRender-RHUIg5ln.js} +1 -1
  211. package/dist/chunks/status-CKLecQZV.js +1 -0
  212. package/dist/chunks/{statusNoticeHelpers-BfmIub5L.js → statusNoticeHelpers-DI45AH-c.js} +1 -1
  213. package/dist/chunks/stringUtils-D_xPrwGQ.js +4 -0
  214. package/dist/chunks/switcher-D2Z2ZNQ0.js +1 -0
  215. package/dist/chunks/switcher-DhZCaAun.js +1 -0
  216. package/dist/chunks/{tasks-B6gYXxOx.js → tasks-6suPhqsK.js} +1 -1
  217. package/dist/chunks/{templateJobs-BW6TaqEC.js → templateJobs-BKVEWCsb.js} +1 -1
  218. package/dist/chunks/{terminalSetup-C-g9Xvj3.js → terminalSetup-7PUR4hfo.js} +1 -1
  219. package/dist/chunks/{terminalSetup-BgIXFBpd.js → terminalSetup-Cqy5_PhJ.js} +4 -4
  220. package/dist/chunks/{theme-9AZceq_m.js → theme-B-HG2PUs.js} +1 -1
  221. package/dist/chunks/tipRegistry-BR_lSGRw.js +2 -0
  222. package/dist/chunks/{toolEventObserver-DTuJcREC.js → toolEventObserver-BY3QVnr6.js} +1 -1
  223. package/dist/chunks/toolPool-BcwIF8Q_.js +1 -0
  224. package/dist/chunks/{types-97nL3naE.js → types-CD25a50S.js} +1 -1
  225. package/dist/chunks/udsClient-CCxgLiZy.js +1 -0
  226. package/dist/chunks/urlHandler-BNsQKqba.js +1 -0
  227. package/dist/chunks/{use-select-navigation-BStVRvcX.js → use-select-navigation-CW5alA9r.js} +1 -1
  228. package/dist/chunks/{useDoublePress-C9xxQzh1.js → useDoublePress-DQBLKyzJ.js} +1 -1
  229. package/dist/chunks/{useExitOnCtrlCDWithKeybindings-DWRFdFoU.js → useExitOnCtrlCDWithKeybindings-BgJrnuDl.js} +1 -1
  230. package/dist/chunks/useMainLoopModel-BVgJo4hN.js +1 -0
  231. package/dist/chunks/useManagePlugins-CrWjzESW.js +1 -0
  232. package/dist/chunks/useMergedTools-r6GQq5mI.js +1 -0
  233. package/dist/chunks/{useSearchInput-B_mY9wBq.js → useSearchInput-BITV_Txn.js} +1 -1
  234. package/dist/chunks/{useSettingsErrors-CM7tThcp.js → useSettingsErrors-CO0fTNzn.js} +1 -1
  235. package/dist/chunks/{util-Bb2S6g9N.js → util-_zo3I1y8.js} +1 -1
  236. package/dist/chunks/validatePlugin-DFGdRhA-.js +1 -0
  237. package/dist/chunks/{vim-Dpnhgoz_.js → vim-qgMS88ss.js} +1 -1
  238. package/dist/chunks/worktree-CR_M6Qfy.js +1 -0
  239. package/dist/cli.js +1 -1
  240. package/package.json +1 -1
  241. package/scripts/postinstall.cjs +16 -16
  242. package/dist/chunks/AgentsMdExternalIncludesDialog-Bnb1jWcg.js +0 -1
  243. package/dist/chunks/App-B8q8PV77.js +0 -1
  244. package/dist/chunks/BackgroundTasksDialog-i0TkZgQp.js +0 -2
  245. package/dist/chunks/CustomSelect-BvTftqEH.js +0 -1
  246. package/dist/chunks/DiffDialog-v5r8cBKW.js +0 -6
  247. package/dist/chunks/Doctor-DKpBnbuI.js +0 -1
  248. package/dist/chunks/Doctor-uvO6NM5m.js +0 -3
  249. package/dist/chunks/KeybindingProviderSetup-DsJqfEt-.js +0 -1
  250. package/dist/chunks/MCPConnectionManager-DkZVxLEj.js +0 -1
  251. package/dist/chunks/MCPToolListView-De1W4jpj.js +0 -1
  252. package/dist/chunks/MessageSelector-DW_itlX-.js +0 -3
  253. package/dist/chunks/Messages-BFsCpACq.js +0 -10
  254. package/dist/chunks/PromptInputHelpMenu-Bm5KY0Ma.js +0 -1
  255. package/dist/chunks/QueryEngine-egz5mbaW.js +0 -1
  256. package/dist/chunks/REPL-D27CE4WN.js +0 -124
  257. package/dist/chunks/REPL-e8wAT1wN.js +0 -1
  258. package/dist/chunks/ResumeConversation-CWA27Lke.js +0 -1
  259. package/dist/chunks/SearchExtraToolsTool-BRchtZ9Q.js +0 -1
  260. package/dist/chunks/Settings-axHLvYIy.js +0 -3
  261. package/dist/chunks/Spinner-VjwI7m_g.js +0 -1
  262. package/dist/chunks/ThemePicker-CtQYHmOr.js +0 -1
  263. package/dist/chunks/agents-DEnmg8Xo.js +0 -101
  264. package/dist/chunks/allErrors-C9kx6lnk.js +0 -1
  265. package/dist/chunks/appleTerminalBackup-CT7g8yOs.js +0 -1
  266. package/dist/chunks/backgroundHousekeeping-CvWfd99M.js +0 -1
  267. package/dist/chunks/caches-DWjwe-DN.js +0 -1
  268. package/dist/chunks/caches-VLs1tQkZ.js +0 -1
  269. package/dist/chunks/client-CO_6v4yl.js +0 -1
  270. package/dist/chunks/client-DO-O441l.js +0 -1
  271. package/dist/chunks/commands-Cn1P7Tms.js +0 -1
  272. package/dist/chunks/compact-DGUhdXcc.js +0 -2
  273. package/dist/chunks/config-C7GTF4iI.js +0 -1
  274. package/dist/chunks/config-CWPHVTic.js +0 -3
  275. package/dist/chunks/config-Cox0TM2Z.js +0 -1
  276. package/dist/chunks/context-noninteractive--OuiZUzL.js +0 -1
  277. package/dist/chunks/conversation--y8PD2Lk.js +0 -1
  278. package/dist/chunks/conversation-BIPJEOwO.js +0 -1
  279. package/dist/chunks/conversationRecovery-BBJzrA0g.js +0 -1
  280. package/dist/chunks/crossProjectResume-CwZb3cEU.js +0 -40
  281. package/dist/chunks/cwd-BZMp3CZ8.js +0 -1
  282. package/dist/chunks/doctor-4NiE46ZG.js +0 -1
  283. package/dist/chunks/envUtils-DfkgIdYf.js +0 -1
  284. package/dist/chunks/execFileNoThrow-BgRsj_SW.js +0 -34
  285. package/dist/chunks/exit-CrsQsjbx.js +0 -1
  286. package/dist/chunks/extractMemories-kogJzpit.js +0 -1
  287. package/dist/chunks/fast-CuNVwVTr.js +0 -1
  288. package/dist/chunks/fast-RlFnwGRV.js +0 -1
  289. package/dist/chunks/fetchModelList-uiCPVqbJ.js +0 -1
  290. package/dist/chunks/genericProcessUtils-BNlr-QxM.js +0 -23
  291. package/dist/chunks/grok-DnmklTrm.js +0 -1
  292. package/dist/chunks/history-kOw3CcLT.js +0 -1
  293. package/dist/chunks/hooks-BDY1jMbS.js +0 -1
  294. package/dist/chunks/install-DrMiHa2Q.js +0 -1
  295. package/dist/chunks/keybindings-BRRN_eap.js +0 -1
  296. package/dist/chunks/loadAgentsDir-CJAK4kif.js +0 -1
  297. package/dist/chunks/localSearch-DyaB2Rm-.js +0 -1
  298. package/dist/chunks/main-B_09WbaG.js +0 -345
  299. package/dist/chunks/managedEnv-BJGfe3m7.js +0 -1
  300. package/dist/chunks/managedEnv-CIWJsuty.js +0 -1
  301. package/dist/chunks/managedEnvConstants-BPwL2aWI.js +0 -1
  302. package/dist/chunks/mcp-1nBvcNxw.js +0 -1
  303. package/dist/chunks/mcp-7DXpXMdT.js +0 -2
  304. package/dist/chunks/mcp-kw99WVi2.js +0 -6
  305. package/dist/chunks/memory-CjWvzR_9.js +0 -1
  306. package/dist/chunks/model-DpZaKZMb.js +0 -1
  307. package/dist/chunks/nativeInstaller-SmPeEisk.js +0 -1
  308. package/dist/chunks/openai-D_j7-KW6.js +0 -2
  309. package/dist/chunks/parser-2usBI4G-.js +0 -1
  310. package/dist/chunks/pidLock-B-SW3Nhx.js +0 -3
  311. package/dist/chunks/plan-BJrWtXEh.js +0 -1
  312. package/dist/chunks/plugin-D97VJAxW.js +0 -17
  313. package/dist/chunks/pluginCliCommands-CUGPc853.js +0 -1
  314. package/dist/chunks/pluginOperations-rTrzu6Vg.js +0 -2
  315. package/dist/chunks/pluginStartupCheck-BRHnXlym.js +0 -1
  316. package/dist/chunks/poorMode-BaS0DBUO.js +0 -1
  317. package/dist/chunks/poorMode-DmvzFAz_.js +0 -1
  318. package/dist/chunks/print-Bi3xVdB3.js +0 -13
  319. package/dist/chunks/processBashCommand-BBtnCx-7.js +0 -1
  320. package/dist/chunks/processSlashCommand-jzF0GmLO.js +0 -5
  321. package/dist/chunks/prompt-CmijKW7G.js +0 -1
  322. package/dist/chunks/prompt-DYBx_D0H.js +0 -1
  323. package/dist/chunks/promptEditor-B6S_Rzcu.js +0 -4
  324. package/dist/chunks/refresh-CAGv8BJY.js +0 -1
  325. package/dist/chunks/reject-CEUkoI2G.js +0 -1
  326. package/dist/chunks/rename-DPFis9g_.js +0 -1
  327. package/dist/chunks/ripgrep-3omwGI-l.js +0 -1
  328. package/dist/chunks/ripgrep-CgQrN3XX.js +0 -5
  329. package/dist/chunks/sandbox-adapter-D15jjHJR.js +0 -1
  330. package/dist/chunks/searchExtraTools-BoFc__Eg.js +0 -1
  331. package/dist/chunks/sessionFileAccessHooks-Rgsp4_Ex.js +0 -1
  332. package/dist/chunks/sessionObserver-PcaVCVkX.js +0 -1
  333. package/dist/chunks/sessionStorage-Dkf7FRgA.js +0 -1
  334. package/dist/chunks/sessionTracing-D7rekMdW.js +0 -11
  335. package/dist/chunks/settings-8fwIkMDV.js +0 -1
  336. package/dist/chunks/settings-CodSADx8.js +0 -24
  337. package/dist/chunks/setup-DBiIrXrh.js +0 -3
  338. package/dist/chunks/sinks-DH83d_kd.js +0 -1
  339. package/dist/chunks/skillChangeDetector-BrrZaFkT.js +0 -1
  340. package/dist/chunks/skills-BRtgqnLz.js +0 -1
  341. package/dist/chunks/startupProfiler-D1NRu2nj.js +0 -1
  342. package/dist/chunks/state-D3gvDiu8.js +0 -1
  343. package/dist/chunks/status-WXA16wIM.js +0 -1
  344. package/dist/chunks/stringUtils-Bu_lJH5c.js +0 -4
  345. package/dist/chunks/switcher-5gilU5_R.js +0 -1
  346. package/dist/chunks/switcher-DMfuKuw_.js +0 -1
  347. package/dist/chunks/tipRegistry-DtO1H_Wo.js +0 -2
  348. package/dist/chunks/toolPool-DHS8jWaL.js +0 -1
  349. package/dist/chunks/udsClient-CmYHFiBD.js +0 -1
  350. package/dist/chunks/urlHandler-DLz3FZm1.js +0 -1
  351. package/dist/chunks/useMainLoopModel-DSN5HjV1.js +0 -1
  352. package/dist/chunks/useManagePlugins-ntnOf5OU.js +0 -1
  353. package/dist/chunks/useMergedTools-C5Yns9Ij.js +0 -1
  354. package/dist/chunks/validatePlugin-D8WQ5z4W.js +0 -1
  355. package/dist/chunks/worktree-a5oOPSYl.js +0 -1
@@ -0,0 +1 @@
1
+ import{r as e,t}from"./managedEnv-Do9fgLpk.js";e();export{t as applyConfigEnvironmentVariables};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{l as t,o as n}from"./envUtils-DZ_SvEVz.js";import{cn as r,d as i,ln as a,m as o,s}from"./settings-YIDksG5Z.js";import{d as c,o as l}from"./config-D3K87Mm1.js";import{_ as u,c as d,h as f,m as p,n as m,t as h,u as g}from"./proxy-BtWuysHM.js";import{n as _,t as v}from"./loader-6MqzNGmV.js";import{n as y,r as b,t as x}from"./managedEnvConstants-CWcT7nYr.js";function S(e){if(!e||!process.env.ANTHROPIC_UNIX_SOCKET)return e||{};let{ANTHROPIC_UNIX_SOCKET:t,ANTHROPIC_BASE_URL:n,ANTHROPIC_API_KEY:r,ANTHROPIC_AUTH_TOKEN:i,WORKMATE_OAUTH_TOKEN:a,...o}=e;return o}function C(e){if(!e)return{};if(!t(process.env.WORKMATE_PROVIDER_MANAGED_BY_HOST))return e;let n={};for(let[t,r]of Object.entries(e))b(t)||(n[t]=r);return n}function w(e){if(!e||!k)return e||{};let t={};for(let[n,r]of Object.entries(e))k.has(n)||(t[n]=r);return t}function T(e){if(!e)return{};let t=s(`userSettings`)?.activeProviderId;if(!t||!v(t))return e;let n={};for(let[t,r]of Object.entries(e))A.has(t.toUpperCase())||(n[t]=r);return n}function E(e){return w(C(T(S(e))))}function D(){k===void 0&&(k=process.env.WORKMATE_ENTRYPOINT===`claude-desktop`?new Set(Object.keys(process.env)):null),Object.assign(process.env,E(l().env));for(let e of j)e!==`policySettings`&&a(e)&&Object.assign(process.env,E(s(e)?.env));Object.assign(process.env,E(s(`policySettings`)?.env));let e=E(i()?.env);for(let[t,n]of Object.entries(e))x.has(t.toUpperCase())&&(process.env[t]=n)}function O(){Object.assign(process.env,E(l().env)),Object.assign(process.env,E(i()?.env)),f(),g(),h(),m()}var k,A,j,M=e((()=>{_(),u(),c(),n(),y(),p(),d(),r(),o(),A=new Set([`ANTHROPIC_BASE_URL`,`ANTHROPIC_API_KEY`,`ANTHROPIC_MODEL`,`WORKMATE_USE_OPENAI`,`OPENAI_BASE_URL`,`OPENAI_API_KEY`,`OPENAI_MODEL`]),j=[`userSettings`,`flagSettings`,`policySettings`]}));export{D as n,M as r,O as t};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";function t(e){let t=e.toUpperCase();return n.has(t)||r.some(e=>t.startsWith(e))}var n,r,i,a=e((()=>{n=new Set(`WORKMATE_PROVIDER_MANAGED_BY_HOST.WORKMATE_USE_BEDROCK.WORKMATE_USE_VERTEX.WORKMATE_USE_FOUNDRY.WORKMATE_USE_GEMINI.ANTHROPIC_BASE_URL.ANTHROPIC_BEDROCK_BASE_URL.ANTHROPIC_VERTEX_BASE_URL.ANTHROPIC_FOUNDRY_BASE_URL.ANTHROPIC_FOUNDRY_RESOURCE.ANTHROPIC_VERTEX_PROJECT_ID.GEMINI_BASE_URL.CLOUD_ML_REGION.ANTHROPIC_API_KEY.ANTHROPIC_AUTH_TOKEN.WORKMATE_OAUTH_TOKEN.AWS_BEARER_TOKEN_BEDROCK.ANTHROPIC_FOUNDRY_API_KEY.WORKMATE_SKIP_BEDROCK_AUTH.WORKMATE_SKIP_VERTEX_AUTH.WORKMATE_SKIP_FOUNDRY_AUTH.GEMINI_API_KEY.ANTHROPIC_MODEL.ANTHROPIC_DEFAULT_HAIKU_MODEL.ANTHROPIC_DEFAULT_HAIKU_MODEL_DESCRIPTION.ANTHROPIC_DEFAULT_HAIKU_MODEL_NAME.ANTHROPIC_DEFAULT_HAIKU_MODEL_SUPPORTED_CAPABILITIES.ANTHROPIC_DEFAULT_OPUS_MODEL.ANTHROPIC_DEFAULT_OPUS_MODEL_DESCRIPTION.ANTHROPIC_DEFAULT_OPUS_MODEL_NAME.ANTHROPIC_DEFAULT_OPUS_MODEL_SUPPORTED_CAPABILITIES.ANTHROPIC_DEFAULT_SONNET_MODEL.ANTHROPIC_DEFAULT_SONNET_MODEL_DESCRIPTION.ANTHROPIC_DEFAULT_SONNET_MODEL_NAME.ANTHROPIC_DEFAULT_SONNET_MODEL_SUPPORTED_CAPABILITIES.OPENAI_AUTH_MODE.OPENAI_API_KEY.OPENAI_BASE_URL.OPENAI_MODEL.OPENAI_DEFAULT_HAIKU_MODEL.OPENAI_DEFAULT_HAIKU_MODEL_DESCRIPTION.OPENAI_DEFAULT_HAIKU_MODEL_NAME.OPENAI_DEFAULT_HAIKU_MODEL_SUPPORTED_CAPABILITIES.OPENAI_DEFAULT_OPUS_MODEL.OPENAI_DEFAULT_OPUS_MODEL_DESCRIPTION.OPENAI_DEFAULT_OPUS_MODEL_NAME.OPENAI_DEFAULT_OPUS_MODEL_SUPPORTED_CAPABILITIES.OPENAI_DEFAULT_SONNET_MODEL.OPENAI_DEFAULT_SONNET_MODEL_DESCRIPTION.OPENAI_DEFAULT_SONNET_MODEL_NAME.OPENAI_DEFAULT_SONNET_MODEL_SUPPORTED_CAPABILITIES.OPENAI_SMALL_FAST_MODEL.ANTHROPIC_SMALL_FAST_MODEL.ANTHROPIC_SMALL_FAST_MODEL_AWS_REGION.WORKMATE_SUBAGENT_MODEL.GEMINI_MODEL.GEMINI_SMALL_FAST_MODEL.GEMINI_DEFAULT_HAIKU_MODEL.GEMINI_DEFAULT_HAIKU_MODEL_DESCRIPTION.GEMINI_DEFAULT_HAIKU_MODEL_NAME.GEMINI_DEFAULT_HAIKU_MODEL_SUPPORTED_CAPABILITIES.GEMINI_DEFAULT_OPUS_MODEL.GEMINI_DEFAULT_OPUS_MODEL_DESCRIPTION.GEMINI_DEFAULT_OPUS_MODEL_NAME.GEMINI_DEFAULT_OPUS_MODEL_SUPPORTED_CAPABILITIES.GEMINI_DEFAULT_SONNET_MODEL.GEMINI_DEFAULT_SONNET_MODEL_DESCRIPTION.GEMINI_DEFAULT_SONNET_MODEL_NAME.GEMINI_DEFAULT_SONNET_MODEL_SUPPORTED_CAPABILITIES`.split(`.`)),r=[`VERTEX_REGION_CLAUDE_`],i=new Set(`ANTHROPIC_CUSTOM_HEADERS.ANTHROPIC_CUSTOM_MODEL_OPTION.ANTHROPIC_CUSTOM_MODEL_OPTION_DESCRIPTION.ANTHROPIC_CUSTOM_MODEL_OPTION_NAME.ANTHROPIC_DEFAULT_HAIKU_MODEL.ANTHROPIC_DEFAULT_HAIKU_MODEL_DESCRIPTION.ANTHROPIC_DEFAULT_HAIKU_MODEL_NAME.ANTHROPIC_DEFAULT_HAIKU_MODEL_SUPPORTED_CAPABILITIES.ANTHROPIC_DEFAULT_OPUS_MODEL.ANTHROPIC_DEFAULT_OPUS_MODEL_DESCRIPTION.ANTHROPIC_DEFAULT_OPUS_MODEL_NAME.ANTHROPIC_DEFAULT_OPUS_MODEL_SUPPORTED_CAPABILITIES.ANTHROPIC_DEFAULT_SONNET_MODEL.ANTHROPIC_DEFAULT_SONNET_MODEL_DESCRIPTION.ANTHROPIC_DEFAULT_SONNET_MODEL_NAME.ANTHROPIC_DEFAULT_SONNET_MODEL_SUPPORTED_CAPABILITIES.OPENAI_API_KEY.OPENAI_AUTH_MODE.OPENAI_BASE_URL.OPENAI_DEFAULT_HAIKU_MODEL.OPENAI_DEFAULT_HAIKU_MODEL_DESCRIPTION.OPENAI_DEFAULT_HAIKU_MODEL_NAME.OPENAI_DEFAULT_HAIKU_MODEL_SUPPORTED_CAPABILITIES.OPENAI_DEFAULT_OPUS_MODEL.OPENAI_DEFAULT_OPUS_MODEL_DESCRIPTION.OPENAI_DEFAULT_OPUS_MODEL_NAME.OPENAI_DEFAULT_OPUS_MODEL_SUPPORTED_CAPABILITIES.OPENAI_DEFAULT_SONNET_MODEL.OPENAI_DEFAULT_SONNET_MODEL_DESCRIPTION.OPENAI_DEFAULT_SONNET_MODEL_NAME.OPENAI_DEFAULT_SONNET_MODEL_SUPPORTED_CAPABILITIES.OPENAI_ENABLE_THINKING.OPENAI_MAX_TOKENS.OPENAI_MODEL.OPENAI_ORG_ID.OPENAI_PROJECT_ID.OPENAI_SMALL_FAST_MODEL.GROK_API_KEY.GROK_BASE_URL.GROK_DEFAULT_HAIKU_MODEL.GROK_DEFAULT_OPUS_MODEL.GROK_DEFAULT_SONNET_MODEL.GROK_MODEL.GROK_MODEL_MAP.XAI_API_KEY.ANTHROPIC_FOUNDRY_API_KEY.ANTHROPIC_MODEL.ANTHROPIC_SMALL_FAST_MODEL_AWS_REGION.ANTHROPIC_SMALL_FAST_MODEL.AWS_DEFAULT_REGION.AWS_PROFILE.AWS_REGION.BASH_DEFAULT_TIMEOUT_MS.BASH_MAX_OUTPUT_LENGTH.BASH_MAX_TIMEOUT_MS.CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIR.WORKMATE_API_KEY_HELPER_TTL_MS.WORKMATE_DISABLE_EXPERIMENTAL_BETAS.WORKMATE_DISABLE_NONESSENTIAL_TRAFFIC.WORKMATE_DISABLE_TERMINAL_TITLE.WORKMATE_ENABLE_TELEMETRY.WORKMATE_IDE_SKIP_AUTO_INSTALL.WORKMATE_MAX_OUTPUT_TOKENS.WORKMATE_SKIP_BEDROCK_AUTH.WORKMATE_SKIP_FOUNDRY_AUTH.WORKMATE_SKIP_VERTEX_AUTH.WORKMATE_SUBAGENT_MODEL.WORKMATE_USE_BEDROCK.WORKMATE_USE_FOUNDRY.WORKMATE_USE_GEMINI.WORKMATE_USE_GROK.WORKMATE_USE_OPENAI.WORKMATE_USE_VERTEX.GEMINI_API_KEY.GEMINI_BASE_URL.GEMINI_MODEL.GEMINI_SMALL_FAST_MODEL.GEMINI_DEFAULT_HAIKU_MODEL.GEMINI_DEFAULT_HAIKU_MODEL_DESCRIPTION.GEMINI_DEFAULT_HAIKU_MODEL_NAME.GEMINI_DEFAULT_HAIKU_MODEL_SUPPORTED_CAPABILITIES.GEMINI_DEFAULT_OPUS_MODEL.GEMINI_DEFAULT_OPUS_MODEL_DESCRIPTION.GEMINI_DEFAULT_OPUS_MODEL_NAME.GEMINI_DEFAULT_OPUS_MODEL_SUPPORTED_CAPABILITIES.GEMINI_DEFAULT_SONNET_MODEL.GEMINI_DEFAULT_SONNET_MODEL_DESCRIPTION.GEMINI_DEFAULT_SONNET_MODEL_NAME.GEMINI_DEFAULT_SONNET_MODEL_SUPPORTED_CAPABILITIES.DISABLE_AUTOUPDATER.DISABLE_BUG_COMMAND.DISABLE_COST_WARNINGS.DISABLE_ERROR_REPORTING.DISABLE_FEEDBACK_COMMAND.DISABLE_TELEMETRY.ENABLE_SEARCH_EXTRA_TOOLS.MAX_MCP_OUTPUT_TOKENS.MAX_THINKING_TOKENS.MCP_TIMEOUT.MCP_TOOL_TIMEOUT.OTEL_EXPORTER_OTLP_HEADERS.OTEL_EXPORTER_OTLP_LOGS_HEADERS.OTEL_EXPORTER_OTLP_LOGS_PROTOCOL.OTEL_EXPORTER_OTLP_METRICS_CLIENT_CERTIFICATE.OTEL_EXPORTER_OTLP_METRICS_CLIENT_KEY.OTEL_EXPORTER_OTLP_METRICS_HEADERS.OTEL_EXPORTER_OTLP_METRICS_PROTOCOL.OTEL_EXPORTER_OTLP_PROTOCOL.OTEL_EXPORTER_OTLP_TRACES_HEADERS.OTEL_LOG_TOOL_DETAILS.OTEL_LOG_USER_PROMPTS.OTEL_LOGS_EXPORT_INTERVAL.OTEL_LOGS_EXPORTER.OTEL_METRIC_EXPORT_INTERVAL.OTEL_METRICS_EXPORTER.OTEL_METRICS_INCLUDE_ACCOUNT_UUID.OTEL_METRICS_INCLUDE_SESSION_ID.OTEL_METRICS_INCLUDE_VERSION.OTEL_RESOURCE_ATTRIBUTES.USE_BUILTIN_RIPGREP.VERTEX_REGION_CLAUDE_3_5_HAIKU.VERTEX_REGION_CLAUDE_3_5_SONNET.VERTEX_REGION_CLAUDE_3_7_SONNET.VERTEX_REGION_CLAUDE_4_0_OPUS.VERTEX_REGION_CLAUDE_4_0_SONNET.VERTEX_REGION_CLAUDE_4_1_OPUS.VERTEX_REGION_CLAUDE_4_5_SONNET.VERTEX_REGION_CLAUDE_4_6_SONNET.VERTEX_REGION_CLAUDE_HAIKU_4_5`.split(`.`))}));export{a as n,t as r,i as t};
@@ -0,0 +1 @@
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./figures-5ThXQEtq.js";import{D as i,Gt as a,H as o,I as s,Lt as c,P as l,T as u,ai as d,j as f,t as p,y as m}from"./src-WZ94ZKI3.js";import{t as h}from"./jsx-runtime-Bb4Xn-E0.js";import{$d as g,Bh as _,Jd as v,Vd as y,Vh as b,Xd as x,hd as S,md as C,tb as w,zh as T}from"./loadAgentsDir-DR5PVAc3.js";import{a as ee,i as E}from"./debug-kBjDaVkQ.js";import{l as te,n as D,o as O}from"./stringUtils-D_xPrwGQ.js";import{i as k,n as A,r as j}from"./MCPConnectionManager-Bn1PDn3R.js";import{t as ne}from"./select-FrwoTzuc.js";import{r as M,t as re}from"./Spinner-DhhSOFcN.js";import{t as ie}from"./CustomSelect-CpMbxYbt.js";import{n as ae,t as N}from"./McpParsingWarnings-BYG2yqjO.js";import{a as P,c as oe,i as se,n as ce,o as le,r as ue,s as F,t as I}from"./MCPToolListView-BRxjOaOL.js";function L({agentServer:e,onCancel:t}){let[n]=o();return(0,R.jsxs)(m,{title:`${D(String(e.name))} MCP Server`,subtitle:`agent-only`,onCancel:t,inputGuide:e=>e.pending?(0,R.jsxs)(l,{children:[`Press `,e.keyName,` again to exit`]}):(0,R.jsxs)(u,{children:[(0,R.jsx)(i,{shortcut:`↑↓`,action:`navigate`}),(0,R.jsx)(i,{shortcut:`Enter`,action:`confirm`}),(0,R.jsx)(C,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]}),children:[(0,R.jsxs)(s,{flexDirection:`column`,gap:0,children:[(0,R.jsxs)(s,{children:[(0,R.jsx)(l,{bold:!0,children:`Type: `}),(0,R.jsx)(l,{dimColor:!0,children:e.transport})]}),e.url&&(0,R.jsxs)(s,{children:[(0,R.jsx)(l,{bold:!0,children:`URL: `}),(0,R.jsx)(l,{dimColor:!0,children:e.url})]}),e.command&&(0,R.jsxs)(s,{children:[(0,R.jsx)(l,{bold:!0,children:`Command: `}),(0,R.jsx)(l,{dimColor:!0,children:e.command})]}),(0,R.jsxs)(s,{children:[(0,R.jsx)(l,{bold:!0,children:`Used by: `}),(0,R.jsx)(l,{dimColor:!0,children:e.sourceAgents.join(`, `)})]}),(0,R.jsxs)(s,{marginTop:1,children:[(0,R.jsx)(l,{bold:!0,children:`Status: `}),(0,R.jsxs)(l,{children:[f(`inactive`,n)(r.radioOff),` not connected (agent-only)`]})]})]}),(0,R.jsx)(s,{children:(0,R.jsx)(l,{dimColor:!0,children:`This server connects only when running the agent.`})}),(0,R.jsx)(s,{children:(0,R.jsx)(ne,{options:[{label:`Back`,value:`back`}],onChange:e=>{e===`back`&&t()},onCancel:t})})]})}var R,z=e((()=>{n(),p(),O(),S(),ie(),R=h()}));function B(e){switch(e){case`project`:return{label:`Project MCPs`,path:y(e)};case`user`:return{label:`User MCPs`,path:y(e)};case`local`:return{label:`Local MCPs`,path:y(e)};case`enterprise`:return{label:`Enterprise MCPs`};case`dynamic`:return{label:`Built-in MCPs`,path:`always available`};default:return{label:e}}}function V(e){let t=new Map;for(let n of e){let e=n.scope;t.has(e)||t.set(e,[]),t.get(e).push(n)}for(let[,e]of t)e.sort((e,t)=>e.name.localeCompare(t.name));return t}function H({servers:e,agentServers:t=[],onSelectServer:n,onSelectAgentServer:d,onComplete:p}){let[h]=o(),[g,_]=(0,U.useState)(0),v=U.useMemo(()=>V(e.filter(e=>e.client.config.type!==`claudeai-proxy`)),[e]),y=U.useMemo(()=>e.filter(e=>e.client.config.type===`claudeai-proxy`).sort((e,t)=>e.name.localeCompare(t.name)),[e]),b=U.useMemo(()=>(v.get(`dynamic`)??[]).sort((e,t)=>e.name.localeCompare(t.name)),[v]),x=B(`dynamic`),S=U.useMemo(()=>{let e=[];for(let t of G){let n=v.get(t)??[];for(let t of n)e.push({type:`server`,server:t})}for(let t of y)e.push({type:`server`,server:t});for(let n of t)e.push({type:`agent-server`,agentServer:n});for(let t of b)e.push({type:`server`,server:t});return e},[v,y,t,b]),w=(0,U.useCallback)(()=>{p(`MCP dialog dismissed`,{display:`system`})},[p]);a({"confirm:previous":()=>_(e=>e===0?S.length-1:e-1),"confirm:next":()=>_(e=>e===S.length-1?0:e+1),"confirm:yes":(0,U.useCallback)(()=>{let e=S[g];e&&(e.type===`server`?n(e.server):e.type===`agent-server`&&d&&d(e.agentServer))},[S,g,n,d]),"confirm:no":w},{context:`Confirmation`});let T=e=>S.findIndex(t=>t.type===`server`&&t.server===e),E=e=>S.findIndex(t=>t.type===`agent-server`&&t.agentServer===e),D=ee(),O=e.some(e=>e.client.type===`failed`);if(e.length===0&&t.length===0)return null;let k=e=>{let t=T(e),n=g===t,i=``,a=``;if(e.client.type===`disabled`)i=f(`inactive`,h)(r.radioOff),a=`disabled`;else if(e.client.type===`connected`)i=f(`success`,h)(r.tick),a=`connected`;else if(e.client.type===`pending`){i=f(`inactive`,h)(r.radioOff);let{reconnectAttempt:t,maxReconnectAttempts:n}=e.client;a=t&&n?`reconnecting (${t}/${n})…`:`connecting…`}else e.client.type===`needs-auth`?(i=f(`warning`,h)(r.triangleUpOutline),a=`needs authentication`):(i=f(`error`,h)(r.cross),a=`failed`);return(0,W.jsxs)(s,{children:[(0,W.jsx)(l,{color:n?`suggestion`:void 0,children:n?`${r.pointer} `:` `}),(0,W.jsx)(l,{color:n?`suggestion`:void 0,children:e.name}),(0,W.jsxs)(l,{dimColor:!n,children:[` · `,i,` `]}),(0,W.jsx)(l,{dimColor:!n,children:a})]},`${e.name}-${t}`)},A=e=>{let t=E(e),n=g===t,i=e.needsAuth?f(`warning`,h)(r.triangleUpOutline):f(`inactive`,h)(r.radioOff),a=e.needsAuth?`may need auth`:`agent-only`;return(0,W.jsxs)(s,{children:[(0,W.jsx)(l,{color:n?`suggestion`:void 0,children:n?`${r.pointer} `:` `}),(0,W.jsx)(l,{color:n?`suggestion`:void 0,children:e.name}),(0,W.jsxs)(l,{dimColor:!n,children:[` · `,i,` `]}),(0,W.jsx)(l,{dimColor:!n,children:a})]},`agent-${e.name}-${t}`)},j=e.length+t.length;return(0,W.jsxs)(s,{flexDirection:`column`,children:[(0,W.jsx)(N,{}),(0,W.jsx)(m,{title:`Manage MCP servers`,subtitle:`${j} ${te(j,`server`)}`,onCancel:w,hideInputGuide:!0,children:(0,W.jsxs)(s,{flexDirection:`column`,children:[G.map(e=>{let t=v.get(e);if(!t||t.length===0)return null;let n=B(e);return(0,W.jsxs)(s,{flexDirection:`column`,marginBottom:1,children:[(0,W.jsxs)(s,{paddingLeft:2,children:[(0,W.jsx)(l,{bold:!0,children:n.label}),n.path&&(0,W.jsxs)(l,{dimColor:!0,children:[` (`,n.path,`)`]})]}),t.map(e=>k(e))]},e)}),y.length>0&&(0,W.jsxs)(s,{flexDirection:`column`,marginBottom:1,children:[(0,W.jsx)(s,{paddingLeft:2,children:(0,W.jsx)(l,{bold:!0,children:`claude.ai`})}),y.map(e=>k(e))]}),t.length>0&&(0,W.jsxs)(s,{flexDirection:`column`,marginBottom:1,children:[(0,W.jsx)(s,{paddingLeft:2,children:(0,W.jsx)(l,{bold:!0,children:`Agent MCPs`})}),[...new Set(t.flatMap(e=>e.sourceAgents))].map(e=>(0,W.jsxs)(s,{flexDirection:`column`,marginTop:1,children:[(0,W.jsx)(s,{paddingLeft:2,children:(0,W.jsxs)(l,{dimColor:!0,children:[`@`,e]})}),t.filter(t=>t.sourceAgents.includes(e)).map(e=>A(e))]},e))]}),b.length>0&&(0,W.jsxs)(s,{flexDirection:`column`,marginBottom:1,children:[(0,W.jsxs)(s,{paddingLeft:2,children:[(0,W.jsx)(l,{bold:!0,children:x.label}),x.path&&(0,W.jsxs)(l,{dimColor:!0,children:[` (`,x.path,`)`]})]}),b.map(e=>k(e))]}),(0,W.jsxs)(s,{flexDirection:`column`,children:[O&&(0,W.jsx)(l,{dimColor:!0,children:D?`※ Error logs shown inline with --debug`:`※ Run claude --debug to see error logs`}),(0,W.jsxs)(l,{dimColor:!0,children:[(0,W.jsx)(c,{url:`https://code.workmate.com/docs/en/mcp`,children:`https://code.workmate.com/docs/en/mcp`}),` for help`]})]})]})}),(0,W.jsx)(s,{paddingX:1,children:(0,W.jsx)(l,{dimColor:!0,italic:!0,children:(0,W.jsxs)(u,{children:[(0,W.jsx)(i,{shortcut:`↑↓`,action:`navigate`}),(0,W.jsx)(i,{shortcut:`Enter`,action:`confirm`}),(0,W.jsx)(C,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})})]})}var U,W,G,de=e((()=>{n(),U=t(d(),1),p(),w(),g(),E(),O(),S(),ae(),W=h(),G=[`project`,`local`,`user`,`enterprise`]}));function K({onComplete:e}){let t=_(e=>e.mcp),n=_(e=>e.agentDefinitions),r=t.clients,[i,a]=q.useState({type:`list`}),[o,s]=q.useState([]),c=(0,q.useMemo)(()=>v(n.allAgents),[n.allAgents]),l=q.useMemo(()=>r.filter(e=>e.name!==`ide`).sort((e,t)=>e.name.localeCompare(t.name)),[r]);switch(q.useEffect(()=>{let e=!1;async function n(){let n=await Promise.all(l.map(async e=>{let n=e.config.scope,r=e.config.type===`sse`,i=e.config.type===`http`,a=e.config.type===`claudeai-proxy`,o;(r||i)&&(o=e.type===`connected`&&x(t.tools,e.name).length>0);let s={name:e.name,client:e,scope:n};return a?{...s,transport:`claudeai-proxy`,isAuthenticated:!1,config:e.config}:r?{...s,transport:`sse`,isAuthenticated:o,config:e.config}:i?{...s,transport:`http`,isAuthenticated:o,config:e.config}:{...s,transport:`stdio`,config:e.config}}));e||s(n)}return n(),()=>{e=!0}},[l,t.tools]),(0,q.useEffect)(()=>{o.length===0&&l.length>0||o.length===0&&c.length===0&&e("No MCP servers configured. Please run /doctor if this is unexpected. Otherwise, run `claude mcp --help` or visit https://code.workmate.com/docs/en/mcp to learn more.")},[o.length,l.length,c.length,e]),i.type){case`list`:return(0,J.jsx)(H,{servers:o,agentServers:c,onSelectServer:e=>a({type:`server-menu`,server:e}),onSelectAgentServer:e=>a({type:`agent-server-menu`,agentServer:e}),onComplete:e,defaultTab:i.defaultTab});case`server-menu`:{let n=x(t.tools,i.server.name),r=i.server.transport===`claudeai-proxy`?`claude.ai`:`Work Mate`;return i.server.transport===`stdio`?(0,J.jsx)(P,{server:i.server,serverToolsCount:n.length,onViewTools:()=>a({type:`server-tools`,server:i.server}),onCancel:()=>a({type:`list`,defaultTab:r}),onComplete:e}):(0,J.jsx)(F,{server:i.server,serverToolsCount:n.length,onViewTools:()=>a({type:`server-tools`,server:i.server}),onCancel:()=>a({type:`list`,defaultTab:r}),onComplete:e})}case`server-tools`:return(0,J.jsx)(I,{server:i.server,onSelectTool:(e,t)=>a({type:`server-tool-detail`,server:i.server,toolIndex:t}),onBack:()=>a({type:`server-menu`,server:i.server})});case`server-tool-detail`:{let e=x(t.tools,i.server.name)[i.toolIndex];return e?(0,J.jsx)(ue,{tool:e,server:i.server,onBack:()=>a({type:`server-tools`,server:i.server})}):(a({type:`server-tools`,server:i.server}),null)}case`agent-server-menu`:return(0,J.jsx)(L,{agentServer:i.agentServer,onCancel:()=>a({type:`list`,defaultTab:`Agents`}),onComplete:e})}}var q,J,fe=e((()=>{q=t(d(),1),g(),T(),z(),de(),oe(),le(),se(),ce(),J=h()})),pe=e((()=>{fe()}));function me({serverName:e,onComplete:t}){let[n]=o(),i=b(),a=j(),[c,u]=(0,Y.useState)(!0),[d,p]=(0,Y.useState)(null);return(0,Y.useEffect)(()=>{async function n(){try{if(!i.getState().mcp.clients.find(t=>t.name===e)){p(`MCP server "${e}" not found`),u(!1),t(`MCP server "${e}" not found`);return}switch((await a(e)).client.type){case`connected`:u(!1),t(`Successfully reconnected to ${e}`);break;case`needs-auth`:p(`${e} requires authentication`),u(!1),t(`${e} requires authentication.`);break;case`pending`:case`failed`:case`disabled`:p(`Failed to reconnect to ${e}`),u(!1),t(`Failed to reconnect to ${e}`);break}}catch(e){let n=e instanceof Error?e.message:String(e);p(n),u(!1),t(`Error: ${n}`)}}n()},[e,a,i,t]),c?(0,X.jsxs)(s,{flexDirection:`column`,gap:1,padding:1,children:[(0,X.jsxs)(l,{color:`text`,children:[`Reconnecting to `,(0,X.jsx)(l,{bold:!0,children:e})]}),(0,X.jsxs)(s,{children:[(0,X.jsx)(re,{}),(0,X.jsx)(l,{children:` Establishing connection to MCP server`})]})]}):d?(0,X.jsxs)(s,{flexDirection:`column`,gap:1,padding:1,children:[(0,X.jsxs)(s,{children:[(0,X.jsxs)(l,{children:[f(`error`,n)(r.cross),` `]}),(0,X.jsxs)(l,{color:`error`,children:[`Failed to reconnect to `,e]})]}),(0,X.jsxs)(l,{dimColor:!0,children:[`Error: `,d]})]}):null}var Y,X,Z=e((()=>{n(),Y=t(d(),1),p(),A(),T(),M(),X=h()}));function he({action:e,target:t,onComplete:n}){let r=_(e=>e.mcp.clients),i=k(),a=(0,Q.useRef)(!1);return(0,Q.useEffect)(()=>{if(a.current)return;a.current=!0;let o=e===`enable`,s=r.filter(e=>e.name!==`ide`),c=t===`all`?s.filter(e=>o?e.type===`disabled`:e.type!==`disabled`):s.filter(e=>e.name===t);if(c.length===0){n(t===`all`?`All MCP servers are already ${o?`enabled`:`disabled`}`:`MCP server "${t}" not found`);return}for(let e of c)i(e.name);n(t===`all`?`${o?`Enabled`:`Disabled`} ${c.length} MCP server(s)`:`MCP server "${t}" ${o?`enabled`:`disabled`}`)},[e,t,r,i,n]),null}async function ge(e,t,n){if(n){let t=n.trim().split(/\s+/);if(t[0]===`no-redirect`)return(0,$.jsx)(K,{onComplete:e});if(t[0]===`reconnect`&&t[1])return(0,$.jsx)(me,{serverName:t.slice(1).join(` `),onComplete:e});if(t[0]===`enable`||t[0]===`disable`)return(0,$.jsx)(he,{action:t[0],target:t.length>1?t.slice(1).join(` `):`all`,onComplete:e})}return(0,$.jsx)(K,{onComplete:e})}var Q,$;e((()=>{Q=t(d(),1),pe(),Z(),A(),T(),$=h()}))();export{ge as call};
@@ -0,0 +1,6 @@
1
+ import{o as e}from"./rolldown-runtime-DaDcL9Zw.js";import{D as t,H as n,I as r,P as i,T as a,ai as o,j as s,kn as c,t as l,y as ee}from"./src-WZ94ZKI3.js";import{t as u}from"./jsx-runtime-Bb4Xn-E0.js";import{d,l as f}from"./types-CD25a50S.js";import{$d as p,Ad as m,Df as h,Hd as g,Id as _,Lh as te,Of as ne,Pd as re,Qd as v,Vd as y,cf as b,gi as x,hd as S,md as C,mf as w,mi as T,nf as E,of as D,sf as O,uf as k,zh as A}from"./loadAgentsDir-DR5PVAc3.js";import{I as j,z as M}from"./debug-kBjDaVkQ.js";import{a as N,d as P,m as F,o as I}from"./config-D3K87Mm1.js";import{n as L,o as R}from"./process-gEbdy6uY.js";import{i as z,n as B}from"./platform-Vl9IynC3.js";import{n as V}from"./analytics-COpjZpvd.js";import{l as H,o as U}from"./stringUtils-D_xPrwGQ.js";import{n as ie,t as W}from"./SelectMulti-BpAjjhsn.js";import{t as G}from"./KeybindingProviderSetup-CSUkJHTT.js";import{n as K,t as q}from"./exit-s9XGerrH.js";import{stat as J}from"fs/promises";import{cwd as Y}from"process";h();var X=e(o(),1);x(),L(),l(),k(),U(),S(),ie();var Z=u();function ae({servers:e,scope:o,onDone:c}){let l=Object.keys(e),[u,d]=(0,X.useState)({});(0,X.useEffect)(()=>{D().then(({servers:e})=>d(e))},[]);let f=l.filter(e=>u[e]!==void 0);async function p(t){let n=0;for(let r of t){let t=e[r];if(t){let e=r;if(u[e]!==void 0){let t=1;for(;u[`${r}_${t}`]!==void 0;)t++;e=`${r}_${t}`}await E(e,t,o),n++}}h(n)}let[m]=n(),h=(0,X.useCallback)(e=>{R(e>0?`\n${s(`success`,m)(`Successfully imported ${e} MCP ${H(e,`server`)} to ${o} config.`)}\n`:`
2
+ No servers were imported.`),c(),T()},[m,o,c]),g=(0,X.useCallback)(()=>{h(0)},[h]);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(ee,{title:`Import MCP Servers from Work Mate Desktop`,subtitle:`Found ${l.length} MCP ${H(l.length,`server`)} in Work Mate Desktop.`,color:`success`,onCancel:g,hideInputGuide:!0,children:[f.length>0&&(0,Z.jsx)(i,{color:`warning`,children:`Note: Some servers already exist with the same name. If selected, they will be imported with a numbered suffix.`}),(0,Z.jsx)(i,{children:`Please select the servers you want to import:`}),(0,Z.jsx)(W,{options:l.map(e=>({label:`${e}${f.includes(e)?` (already exists)`:``}`,value:e})),defaultValue:l.filter(e=>!f.includes(e)),onSubmit:p,onCancel:g,hideIndexes:!0})]}),(0,Z.jsx)(r,{paddingX:1,children:(0,Z.jsx)(i,{dimColor:!0,italic:!0,children:(0,Z.jsxs)(a,{children:[(0,Z.jsx)(t,{shortcut:`Space`,action:`select`}),(0,Z.jsx)(t,{shortcut:`Enter`,action:`confirm`}),(0,Z.jsx)(C,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})})]})}l(),V(),_(),k(),p(),A(),P(),j(),x(),f(),z();async function Q(e,t){try{let n=await m(e,t);return n.type===`connected`?`✓ Connected`:n.type===`needs-auth`?`! Needs authentication`:`✗ Failed to connect`}catch{return`✗ Connection error`}}async function oe({debug:e,verbose:t}){let n=Y();try{await J(n)}catch(e){throw M(e)&&q(`Error: Directory ${n} does not exist`),e}try{let{setup:r}=await import(`./setup-BBvZyrfz.js`);await r(n,`default`,!1,!1,void 0,!1);let{startMCPServer:i}=await import(`./mcp-CZBTxbhu.js`);await i(n,e??!1,t??!1)}catch(e){q(`Error: Failed to start MCP server: ${e}`)}}async function se(e,t){O(e);try{if(t.scope){let n=g(t.scope);await w(e,n),process.stdout.write(`Removed MCP server ${e} from ${n} config\n`),K(`File modified: ${y(n)}`)}let n=N(),r=I(),{servers:i}=b(`project`),a=!!i[e],o=[];if(n.mcpServers?.[e]&&o.push(`local`),a&&o.push(`project`),r.mcpServers?.[e]&&o.push(`user`),o.length===0)q(`No MCP server found with name: "${e}"`);else if(o.length===1){let t=o[0];await w(e,t),process.stdout.write(`Removed MCP server "${e}" from ${t} config\n`),K(`File modified: ${y(t)}`)}else process.stderr.write(`MCP server "${e}" exists in multiple scopes:\n`),o.forEach(e=>{process.stderr.write(` - ${v(e)} (${y(e)})\n`)}),process.stderr.write(`
3
+ To remove from a specific scope, use:
4
+ `),o.forEach(t=>{process.stderr.write(` claude mcp remove "${e}" -s ${t}\n`)}),q()}catch(e){q(e.message)}}async function ce(){let{servers:e}=await D();if(Object.keys(e).length===0)console.log("No MCP servers configured. Use `claude mcp add` to add a server.");else{console.log(`Checking MCP server health...
5
+ `);let t=await ne(Object.entries(e),async([e,t])=>({name:e,server:t,status:await Q(e,t)}),{concurrency:re()});for(let{name:e,server:n,status:r}of t)if(n.type===`sse`)console.log(`${e}: ${n.url} (SSE) - ${r}`);else if(n.type===`http`)console.log(`${e}: ${n.url} (HTTP) - ${r}`);else if(n.type===`claudeai-proxy`)console.log(`${e}: ${n.url} - ${r}`);else if(!n.type||n.type===`stdio`){let t=n,i=Array.isArray(t.args)?t.args:[];console.log(`${e}: ${t.command} ${i.join(` `)} - ${r}`)}}await T(0)}async function le(e){let t=O(e);t||q(`No MCP server found with name: ${e}`),console.log(`${e}:`),console.log(` Scope: ${v(t.scope)}`);let n=await Q(e,t);if(console.log(` Status: ${n}`),t.type===`sse`){if(console.log(` Type: sse`),console.log(` URL: ${t.url}`),t.headers){console.log(` Headers:`);for(let[e,n]of Object.entries(t.headers))console.log(` ${e}: ${n}`)}}else if(t.type===`http`){if(console.log(` Type: http`),console.log(` URL: ${t.url}`),t.headers){console.log(` Headers:`);for(let[e,n]of Object.entries(t.headers))console.log(` ${e}: ${n}`)}}else if(t.type===`stdio`){console.log(` Type: stdio`),console.log(` Command: ${t.command}`);let e=Array.isArray(t.args)?t.args:[];if(console.log(` Args: ${e.join(` `)}`),t.env){console.log(` Environment:`);for(let[e,n]of Object.entries(t.env))console.log(` ${e}=${n}`)}}console.log(`\nTo remove this server, run: claude mcp remove "${e}" -s ${t.scope}`),await T(0)}async function $(e,t,n){try{let r=g(n.scope),i=d(t);await E(e,i,r),K(`Added ${i&&typeof i==`object`&&`type`in i?String(i.type||`stdio`):`stdio`} MCP server ${e} to ${r} config`)}catch(e){q(e.message)}}async function ue(e){try{let t=g(e.scope);B();let{readClaudeDesktopMcpServers:n}=await import(`./claudeDesktop-g8eUUY2E.js`),r=await n();Object.keys(r).length===0&&K(`No MCP servers found in Work Mate Desktop configuration or configuration file does not exist.`);let{unmount:i}=await c((0,Z.jsx)(te,{children:(0,Z.jsx)(G,{children:(0,Z.jsx)(ae,{servers:r,scope:t,onDone:()=>{i()}})})}),{exitOnCtrlC:!0})}catch(e){q(e.message)}}async function de(){F(e=>({...e,enabledMcpjsonServers:[],disabledMcpjsonServers:[],enableAllProjectMcpServers:!1})),K(`All project-scoped (.mcp.json) server approvals and rejections have been reset.
6
+ You will be prompted for approval next time you start Work Mate.`)}export{ue as mcpAddFromDesktopHandler,$ as mcpAddJsonHandler,le as mcpGetHandler,ce as mcpListHandler,se as mcpRemoveHandler,de as mcpResetChoicesHandler,oe as mcpServeHandler};
@@ -0,0 +1,2 @@
1
+ import{$f as e,Af as t,B as n,Bf as r,Bv as i,D_ as a,Dc as o,Ds as s,E_ as c,Ec as l,Ff as u,Gv as d,Gx as f,Hf as p,If as m,Jf as h,Ji as g,Kf as _,Lf as v,Mf as ee,Nf as te,Os as ne,Pf as y,Qf as b,Rf as x,Uf as S,V as C,Vf as w,Wf as T,Wv as E,Xf as D,Yf as O,Zf as k,ap as A,bb as j,bl as M,cp as N,dp as P,ep as F,fp as I,jf as L,kf as re,lp as R,np as z,op as B,tp as V,up as H,xb as U,xl as W,zf as G,zv as K}from"./loadAgentsDir-DR5PVAc3.js";import{C as q,x as J}from"./debug-kBjDaVkQ.js";import{o as Y,s as X}from"./log-DWZny1vM.js";import{f as Z,s as ie}from"./model-D42epddJ.js";import{_n as Q,gn as ae,vn as oe}from"./prompt-CTByhpUI.js";import $ from"node:process";H(),x(),m(),N();var se=class{constructor(e){this._server=e}requestStream(e,t,n){return this._server.requestStream(e,t,n)}createMessageStream(e,t){let n=this._server.getClientCapabilities();if((e.tools||e.toolChoice)&&!n?.sampling?.tools)throw Error(`Client does not support sampling tools capability.`);if(e.messages.length>0){let t=e.messages[e.messages.length-1],n=Array.isArray(t.content)?t.content:[t.content],r=n.some(e=>e.type===`tool_result`),i=e.messages.length>1?e.messages[e.messages.length-2]:void 0,a=i?Array.isArray(i.content)?i.content:[i.content]:[],o=a.some(e=>e.type===`tool_use`);if(r){if(n.some(e=>e.type!==`tool_result`))throw Error(`The last message must contain only tool_result content if any is present`);if(!o)throw Error(`tool_result blocks are not matching any tool_use from the previous message`)}if(o){let e=new Set(a.filter(e=>e.type===`tool_use`).map(e=>e.id)),t=new Set(n.filter(e=>e.type===`tool_result`).map(e=>e.toolUseId));if(e.size!==t.size||![...e].every(e=>t.has(e)))throw Error(`ids of tool_result blocks and tool_use blocks from previous message do not match`)}}return this.requestStream({method:`sampling/createMessage`,params:e},p,t)}elicitInputStream(e,t){let n=this._server.getClientCapabilities(),r=e.mode??`form`;switch(r){case`url`:if(!n?.elicitation?.url)throw Error(`Client does not support url elicitation.`);break;case`form`:if(!n?.elicitation?.form)throw Error(`Client does not support form elicitation.`);break}let i=r===`form`&&e.mode===void 0?{...e,mode:`form`}:e;return this.requestStream({method:`elicitation/create`,params:i},_,t)}async getTask(e,t){return this._server.getTask({taskId:e},t)}async getTaskResult(e,t,n){return this._server.getTaskResult({taskId:e},t,n)}async listTasks(e,t){return this._server.listTasks(e?{cursor:e}:void 0,t)}async cancelTask(e,t){return this._server.cancelTask({taskId:e},t)}};N(),y();var ce=class extends v{constructor(e,t){super(t),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(V.options.map((e,t)=>[e,t])),this.isMessageIgnored=(e,t)=>{let n=this._loggingLevels.get(t);return n?this.LOG_LEVEL_SEVERITY.get(e)<this.LOG_LEVEL_SEVERITY.get(n):!1},this._capabilities=t?.capabilities??{},this._instructions=t?.instructions,this._jsonSchemaValidator=t?.jsonSchemaValidator??new u,this.setRequestHandler(D,e=>this._oninitialize(e)),this.setNotificationHandler(k,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(B,async(e,t)=>{let n=t.sessionId||t.requestInfo?.headers[`mcp-session-id`]||void 0,{level:r}=e.params,i=V.safeParse(r);return i.success&&this._loggingLevels.set(n,i.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new se(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw Error(`Cannot register capabilities after connecting to transport`);this._capabilities=G(this._capabilities,e)}setRequestHandler(e,t){let n=R(e)?.method;if(!n)throw Error(`Schema is missing a method literal`);let i;if(P(n)){let e=n;i=e._zod?.def?.value??e.value}else{let e=n;i=e._def?.value??e.value}if(typeof i!=`string`)throw Error(`Schema method literal must be a string`);return i===`tools/call`?super.setRequestHandler(e,async(e,n)=>{let i=I(r,e);if(!i.success){let e=i.error instanceof Error?i.error.message:String(i.error);throw new z(O.InvalidParams,`Invalid tools/call request: ${e}`)}let{params:a}=i.data,o=await Promise.resolve(t(e,n));if(a.task){let e=I(T,o);if(!e.success){let t=e.error instanceof Error?e.error.message:String(e.error);throw new z(O.InvalidParams,`Invalid task creation result: ${t}`)}return e.data}let s=I(w,o);if(!s.success){let e=s.error instanceof Error?s.error.message:String(s.error);throw new z(O.InvalidParams,`Invalid tools/call result: ${e}`)}return s.data}):super.setRequestHandler(e,t)}assertCapabilityForMethod(e){switch(e){case`sampling/createMessage`:if(!this._clientCapabilities?.sampling)throw Error(`Client does not support sampling (required for ${e})`);break;case`elicitation/create`:if(!this._clientCapabilities?.elicitation)throw Error(`Client does not support elicitation (required for ${e})`);break;case`roots/list`:if(!this._clientCapabilities?.roots)throw Error(`Client does not support listing roots (required for ${e})`);break;case`ping`:break}}assertNotificationCapability(e){switch(e){case`notifications/message`:if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${e})`);break;case`notifications/resources/updated`:case`notifications/resources/list_changed`:if(!this._capabilities.resources)throw Error(`Server does not support notifying about resources (required for ${e})`);break;case`notifications/tools/list_changed`:if(!this._capabilities.tools)throw Error(`Server does not support notifying of tool list changes (required for ${e})`);break;case`notifications/prompts/list_changed`:if(!this._capabilities.prompts)throw Error(`Server does not support notifying of prompt list changes (required for ${e})`);break;case`notifications/elicitation/complete`:if(!this._clientCapabilities?.elicitation?.url)throw Error(`Client does not support URL elicitation (required for ${e})`);break;case`notifications/cancelled`:break;case`notifications/progress`:break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case`completion/complete`:if(!this._capabilities.completions)throw Error(`Server does not support completions (required for ${e})`);break;case`logging/setLevel`:if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${e})`);break;case`prompts/get`:case`prompts/list`:if(!this._capabilities.prompts)throw Error(`Server does not support prompts (required for ${e})`);break;case`resources/list`:case`resources/templates/list`:case`resources/read`:if(!this._capabilities.resources)throw Error(`Server does not support resources (required for ${e})`);break;case`tools/call`:case`tools/list`:if(!this._capabilities.tools)throw Error(`Server does not support tools (required for ${e})`);break;case`tasks/get`:case`tasks/list`:case`tasks/result`:case`tasks/cancel`:if(!this._capabilities.tasks)throw Error(`Server does not support tasks capability (required for ${e})`);break;case`ping`:case`initialize`:break}}assertTaskCapability(e){ee(this._clientCapabilities?.tasks?.requests,e,`Client`)}assertTaskHandlerCapability(e){this._capabilities&&te(this._capabilities.tasks?.requests,e,`Server`)}async _oninitialize(e){let t=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:A.includes(t)?t:b,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:`ping`},h)}async createMessage(e,t){if((e.tools||e.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw Error(`Client does not support sampling tools capability.`);if(e.messages.length>0){let t=e.messages[e.messages.length-1],n=Array.isArray(t.content)?t.content:[t.content],r=n.some(e=>e.type===`tool_result`),i=e.messages.length>1?e.messages[e.messages.length-2]:void 0,a=i?Array.isArray(i.content)?i.content:[i.content]:[],o=a.some(e=>e.type===`tool_use`);if(r){if(n.some(e=>e.type!==`tool_result`))throw Error(`The last message must contain only tool_result content if any is present`);if(!o)throw Error(`tool_result blocks are not matching any tool_use from the previous message`)}if(o){let e=new Set(a.filter(e=>e.type===`tool_use`).map(e=>e.id)),t=new Set(n.filter(e=>e.type===`tool_result`).map(e=>e.toolUseId));if(e.size!==t.size||![...e].every(e=>t.has(e)))throw Error(`ids of tool_result blocks and tool_use blocks from previous message do not match`)}}return e.tools?this.request({method:`sampling/createMessage`,params:e},S,t):this.request({method:`sampling/createMessage`,params:e},p,t)}async elicitInput(e,t){switch(e.mode??`form`){case`url`:{if(!this._clientCapabilities?.elicitation?.url)throw Error(`Client does not support url elicitation.`);let n=e;return this.request({method:`elicitation/create`,params:n},_,t)}case`form`:{if(!this._clientCapabilities?.elicitation?.form)throw Error(`Client does not support form elicitation.`);let n=e.mode===`form`?e:{...e,mode:`form`},r=await this.request({method:`elicitation/create`,params:n},_,t);if(r.action===`accept`&&r.content&&n.requestedSchema)try{let e=this._jsonSchemaValidator.getValidator(n.requestedSchema)(r.content);if(!e.valid)throw new z(O.InvalidParams,`Elicitation response content does not match requested schema: ${e.errorMessage}`)}catch(e){throw e instanceof z?e:new z(O.InternalError,`Error validating elicitation response: ${e instanceof Error?e.message:String(e)}`)}return r}}}createElicitationCompletionNotifier(e,t){if(!this._clientCapabilities?.elicitation?.url)throw Error(`Client does not support URL elicitation (required for notifications/elicitation/complete)`);return()=>this.notification({method:`notifications/elicitation/complete`,params:{elicitationId:e}},t)}async listRoots(t,n){return this.request({method:`roots/list`,params:t},e,n)}async sendLoggingMessage(e,t){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,t))return this.notification({method:`notifications/message`,params:e})}async sendResourceUpdated(e){return this.notification({method:`notifications/resources/updated`,params:e})}async sendResourceListChanged(){return this.notification({method:`notifications/resources/list_changed`})}async sendToolListChanged(){return this.notification({method:`notifications/tools/list_changed`})}async sendPromptListChanged(){return this.notification({method:`notifications/prompts/list_changed`})}};t();var le=class{constructor(e=$.stdin,t=$.stdout){this._stdin=e,this._stdout=t,this._readBuffer=new re,this._started=!1,this._ondata=e=>{this._readBuffer.append(e),this.processReadBuffer()},this._onerror=e=>{this.onerror?.(e)}}async start(){if(this._started)throw Error(`StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.`);this._started=!0,this._stdin.on(`data`,this._ondata),this._stdin.on(`error`,this._onerror)}processReadBuffer(){for(;;)try{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e)}catch(e){this.onerror?.(e)}}async close(){this._stdin.off(`data`,this._ondata),this._stdin.off(`error`,this._onerror),this._stdin.listenerCount(`data`)===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(e){return new Promise(t=>{let n=L(e);this._stdout.write(n)?t():this._stdout.once(`drain`,t)})}};N(),ne(),oe(),o(),i(),d(),Y(),g(),Z(),C(),j(),J(),W(),c();var ue=[];async function de(e,t,i){let o=E(100);U(e);let c=new ce({name:`claude/tengu`,version:`0.0.26`},{capabilities:{tools:{}}});c.setRequestHandler(F,async()=>{let e=Q(),t=l(e);return{tools:await Promise.all(t.map(async n=>{let r;if(n.outputSchema){let e=a(n.outputSchema);typeof e==`object`&&e&&`type`in e&&e.type===`object`&&(r=e)}return{...n,description:await n.prompt({getToolPermissionContext:async()=>e,tools:t,agents:[]}),inputSchema:a(n.inputSchema),outputSchema:r}}))}}),c.setRequestHandler(r,async({params:{name:e,arguments:r}})=>{let a=l(Q()),c=ae(a,e);if(!c)throw Error(`Tool ${e} not found`);let u={abortController:K(),options:{commands:ue,tools:a,mainLoopModel:ie(),thinkingConfig:{type:`disabled`},mcpClients:[],mcpResources:{},isNonInteractiveSession:!0,debug:t,verbose:i,agentDefinitions:{activeAgents:[],allAgents:[]}},getAppState:()=>s(),setAppState:()=>{},messages:[],readFileState:o,setInProgressToolUseIDs:()=>{},setResponseLength:()=>{},updateFileHistoryState:()=>{},updateAttributionState:()=>{}};try{if(!c.isEnabled())throw Error(`Tool ${e} is not enabled`);let t=await c.validateInput?.(r??{},u);if(t&&!t.result)throw Error(`Tool ${e} input is invalid: ${`message`in t?t.message:String(t)}`);let i=await c.call(r??{},u,n,f({content:[]}));return{content:[{type:`text`,text:typeof i==`string`?i:q(i.data)}]}}catch(e){return X(e),{isError:!0,content:[{type:`text`,text:(e instanceof Error?M(e):[String(e)]).filter(Boolean).join(`
2
+ `).trim()||`Error`}]}}});async function u(){let e=new le;await c.connect(e)}return await u()}export{de as startMCPServer};
@@ -0,0 +1 @@
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{i as n,o as r}from"./envUtils-DZ_SvEVz.js";import{I as i,Lt as a,P as o,Wt as s,_ as c,ai as l,di as ee,fi as u,t as d,y as f}from"./src-WZ94ZKI3.js";import{t as p}from"./jsx-runtime-Bb4Xn-E0.js";import{Pt as m,q as h}from"./state-CXY-q5gr.js";import{Bh as g,Dy as _,Kl as v,dw as te,fc as y,ky as b,pc as ne,pw as x,ql as re,tb as S,wy as C,xu as ie,yu as w,zh as T}from"./loadAgentsDir-DR5PVAc3.js";import{n as E,t as D}from"./cwd-DrEEb4f5.js";import{I as O,N as k}from"./debug-kBjDaVkQ.js";import{Cn as A,Er as j,Pr as M,bn as ae,m as N,y as P}from"./settings-YIDksG5Z.js";import{C as F,T as I,b as oe}from"./config-D3K87Mm1.js";import{o as L,s as se}from"./log-DWZny1vM.js";import{n as ce}from"./analytics-COpjZpvd.js";import{_ as le,p as R}from"./startupProfiler-DIM_Ihyp.js";import{n as z,t as B}from"./useExitOnCtrlCDWithKeybindings-BgJrnuDl.js";import{t as V}from"./select-FrwoTzuc.js";import{r as H,t as U}from"./promptEditor-CpUFgGzc.js";import{t as ue}from"./CustomSelect-CpMbxYbt.js";import{homedir as de}from"os";import{join as W,relative as fe}from"path";import{mkdir as G,writeFile as pe}from"fs/promises";function me(e){return j(e)!==null}var he=e((()=>{M()}));function ge({onSelect:e,onCancel:t}){let r=(0,K.use)(_()),a=W(n(),`AGENTS.md`),l=W(h(),`AGENTS.md`),u=r.some(e=>e.path===a),d=r.some(e=>e.path===l),f=[...r.filter(e=>e.type!==`AutoMem`).map(e=>({...e,exists:!0})),...u?[]:[{path:a,type:`User`,content:``,exists:!1}],...d?[]:[{path:l,type:`Project`,content:``,exists:!1}]],p=new Map,m=f.map(e=>{let t=ae(e.path),n=e.exists?``:` (new)`,r=e.parent?(p.get(e.parent)??0)+1:0;p.set(e.path,r);let i=r>0?` `.repeat(r-1):``,o;o=e.type===`User`&&!e.isNested&&e.path===a?`User memory`:e.type===`Project`&&!e.isNested&&e.path===l?`Project memory`:r>0?`${i}L ${t}${n}`:`${t}`;let s,c=me(h());return s=e.type===`User`&&!e.isNested?`Saved in ~/.workmate/AGENTS.md`:e.type===`Project`&&!e.isNested&&e.path===l?`${c?`Checked in at`:`Saved in`} ./AGENTS.md`:e.parent?`@-imported`:e.isNested?`dynamically loaded`:``,{label:o,value:e.path,description:s}}),v=[],y=g(e=>e.agentDefinitions);if(I()){v.push({label:`Open auto-memory folder`,value:`${Y}${oe()}`,description:``});for(let e of y.activeAgents)if(e.memory){let t=te(e.agentType,e.memory);v.push({label:`Open ${ee.bold(e.agentType)} agent memory`,value:`${Y}${t}`,description:`${e.memory} scope`})}}m.push(...v);let b=J&&m.some(e=>e.value===J)?J:m[0]?.value||``,[x,S]=(0,K.useState)(I),[C,w]=(0,K.useState)(ne),[T]=(0,K.useState)(I),E=g(e=>Object.values(e.tasks).some(e=>e.type===`dream`&&e.status===`running`)),[D,O]=(0,K.useState)(null);(0,K.useEffect)(()=>{T&&re().then(O)},[T,E]);let k=E?`running`:D===null?``:D===0?`never`:`last ran ${R(new Date(D))}`,[A,j]=(0,K.useState)(null),M=A!==null,N=+!!T;function F(){let e=!x;P(`userSettings`,{autoMemoryEnabled:e}),S(e)}function L(){let e=!C;P(`userSettings`,{autoDreamEnabled:e}),w(e)}return z(),s(`confirm:no`,t,{context:`Confirmation`}),s(`confirm:yes`,()=>{A===0?F():A===1&&L()},{context:`Confirmation`,isActive:M}),s(`select:next`,()=>{j(e=>e!==null&&e<N?e+1:null)},{context:`Select`,isActive:M}),s(`select:previous`,()=>{j(e=>e!==null&&e>0?e-1:e)},{context:`Select`,isActive:M}),(0,q.jsxs)(i,{flexDirection:`column`,width:`100%`,children:[(0,q.jsxs)(i,{flexDirection:`column`,marginBottom:1,children:[(0,q.jsx)(c,{isFocused:A===0,children:(0,q.jsxs)(o,{children:[`Auto-memory: `,x?`on`:`off`]})}),T&&(0,q.jsx)(c,{isFocused:A===1,styled:!1,children:(0,q.jsxs)(o,{color:A===1?`suggestion`:void 0,children:[`Auto-dream: `,C?`on`:`off`,k&&(0,q.jsxs)(o,{dimColor:!0,children:[` · `,k]}),!E&&C&&(0,q.jsx)(o,{dimColor:!0,children:` · /dream to run`})]})})]}),(0,q.jsx)(V,{defaultFocusValue:b,options:m,isDisabled:M,onChange:t=>{if(t.startsWith(Y)){let e=t.slice(15);G(e,{recursive:!0}).catch(()=>{}).then(()=>ie(e));return}J=t,e(t)},onCancel:t,onUpFromFirstItem:()=>j(N)})]})}var K,q,J,Y,X=e((()=>{u(),K=t(l(),1),m(),B(),d(),S(),F(),ce(),y(),v(),T(),x(),w(),b(),r(),A(),le(),he(),N(),ue(),q=p(),Y=`__open_folder__`}));function _e(e){let t=de(),n=D(),r=e.startsWith(t)?`~${e.slice(t.length)}`:null,i=e.startsWith(n)?`./${fe(n,e)}`:null;return r&&i?r.length<=i.length?r:i:r||i||e}var ve=e((()=>{d(),E(),p()}));function ye({onDone:e}){let t=async t=>{try{t.includes(n())&&await G(n(),{recursive:!0});try{await pe(t,``,{encoding:`utf8`,flag:`wx`})}catch(e){if(k(e)!==`EEXIST`)throw e}await U(t);let r=`default`,i=``;process.env.VISUAL?(r=`$VISUAL`,i=process.env.VISUAL):process.env.EDITOR&&(r=`$EDITOR`,i=process.env.EDITOR);let a=r==="default"?``:`Using ${r}="${i}".`,o=a?`> ${a} To change editor, set $EDITOR or $VISUAL environment variable.`:`> To use a different editor, set the $EDITOR or $VISUAL environment variable.`;e(`Opened memory file at ${_e(t)}\n\n${o}`,{display:`system`})}catch(t){se(t),e(`Error opening memory file: ${t}`)}},r=()=>{e(`Cancelled memory editing`,{display:`system`})};return(0,Q.jsx)(f,{title:`Memory`,onCancel:r,color:`remember`,children:(0,Q.jsxs)(i,{flexDirection:`column`,children:[(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(ge,{onSelect:t,onCancel:r})}),(0,Q.jsx)(i,{marginTop:1,children:(0,Q.jsxs)(o,{dimColor:!0,children:[`Learn more: `,(0,Q.jsx)(a,{url:`https://code.workmate.com/docs/en/memory`})]})})]})})}var Z,Q,$;e((()=>{Z=t(l(),1),d(),X(),ve(),b(),r(),O(),L(),H(),Q=p(),$=async e=>(C(),await _(),(0,Q.jsx)(ye,{onDone:e}))}))();export{$ as call};
@@ -1 +1 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{ai as n}from"./src-DL3w8VPk.js";function r(){return(0,a.useContext)(o)!==null}function i(e){let t=(0,a.useContext)(o);return t?{rows:t.rows,columns:t.columns}:e}var a,o,s=e((()=>{a=t(n(),1),o=(0,a.createContext)(null)}));export{i,s as n,r,o as t};
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{ai as n}from"./src-WZ94ZKI3.js";function r(){return(0,a.useContext)(o)!==null}function i(e){let t=(0,a.useContext)(o);return t?{rows:t.rows,columns:t.columns}:e}var a,o,s=e((()=>{a=t(n(),1),o=(0,a.createContext)(null)}));export{i,s as n,r,o as t};
@@ -1,2 +1,2 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{I as n,P as r,ai as i,t as a}from"./src-DL3w8VPk.js";import{t as o}from"./jsx-runtime-Bb4Xn-E0.js";import{ct as s,dt as c,lt as l,ut as u}from"./loadAgentsDir-DGozQu_6.js";import{n as d,t as f}from"./select-Fq6g2Ejk.js";function p({onDone:e}){let t=u(),i=s(),a=(0,m.useMemo)(()=>t.map(e=>({label:(0,h.jsxs)(r,{children:[e.icon,` `,e.name,` `,(0,h.jsxs)(r,{dimColor:!0,children:[`(`,e.slug,`) — `,e.description]})]}),value:e.slug})),[t]);function o(n){c(n);let r=t.find(e=>e.slug===n);e(`${r?.icon} Mode switched to: ${r?.name} (${r?.slug}) — ${r?.description}`,{display:`system`})}function l(){e(`Mode selection cancelled.`,{display:`system`})}return(0,h.jsxs)(n,{flexDirection:`column`,children:[(0,h.jsxs)(n,{marginBottom:1,flexDirection:`column`,children:[(0,h.jsx)(r,{color:`remember`,bold:!0,children:`Select mode`}),(0,h.jsx)(r,{dimColor:!0,children:`Arrow keys to navigate, Enter to select, Esc to cancel.`})]}),(0,h.jsx)(f,{defaultValue:i,options:a,onChange:o,onCancel:l,visibleOptionCount:t.length})]})}var m,h,g;e((()=>{m=t(i(),1),a(),d(),l(),h=o(),g=async(e,t,n)=>{let r=n?.trim().toLowerCase();if(r){let t=u(),n=t.find(e=>e.slug===r);if(!n){e(`Unknown mode: "${r}"\n\nAvailable modes:\n${t.map(e=>`${e.icon} ${e.slug} — ${e.description}`).join(`
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{I as n,P as r,ai as i,t as a}from"./src-WZ94ZKI3.js";import{t as o}from"./jsx-runtime-Bb4Xn-E0.js";import{ct as s,dt as c,lt as l,ut as u}from"./loadAgentsDir-DR5PVAc3.js";import{n as d,t as f}from"./select-FrwoTzuc.js";function p({onDone:e}){let t=u(),i=s(),a=(0,m.useMemo)(()=>t.map(e=>({label:(0,h.jsxs)(r,{children:[e.icon,` `,e.name,` `,(0,h.jsxs)(r,{dimColor:!0,children:[`(`,e.slug,`) — `,e.description]})]}),value:e.slug})),[t]);function o(n){c(n);let r=t.find(e=>e.slug===n);e(`${r?.icon} Mode switched to: ${r?.name} (${r?.slug}) — ${r?.description}`,{display:`system`})}function l(){e(`Mode selection cancelled.`,{display:`system`})}return(0,h.jsxs)(n,{flexDirection:`column`,children:[(0,h.jsxs)(n,{marginBottom:1,flexDirection:`column`,children:[(0,h.jsx)(r,{color:`remember`,bold:!0,children:`Select mode`}),(0,h.jsx)(r,{dimColor:!0,children:`Arrow keys to navigate, Enter to select, Esc to cancel.`})]}),(0,h.jsx)(f,{defaultValue:i,options:a,onChange:o,onCancel:l,visibleOptionCount:t.length})]})}var m,h,g;e((()=>{m=t(i(),1),a(),d(),l(),h=o(),g=async(e,t,n)=>{let r=n?.trim().toLowerCase();if(r){let t=u(),n=t.find(e=>e.slug===r);if(!n){e(`Unknown mode: "${r}"\n\nAvailable modes:\n${t.map(e=>`${e.icon} ${e.slug} — ${e.description}`).join(`
2
2
  `)}`,{display:`system`});return}c(r),e(`${n.icon} Mode switched to: ${n.name} (${n.slug}) — ${n.description}`,{display:`system`});return}return(0,h.jsx)(p,{onDone:e})}}))();export{g as call};
@@ -0,0 +1 @@
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./memoize-BK3gG5ob.js";import{i,l as a,o,r as ee,t as s}from"./envUtils-DZ_SvEVz.js";import{N as c,U as l,W as u,X as te,b as d,d as f,l as p,o as ne,s as re}from"./types-CD25a50S.js";import{G as m,Pt as ie,Sn as ae,U as oe,at as se,vr as ce,yr as le}from"./state-CXY-q5gr.js";import{C as ue,H as de,U as fe,c as h,i as pe,o as g,x as me}from"./debug-kBjDaVkQ.js";import{d as he,m as _,t as ge}from"./settings-YIDksG5Z.js";import{d as _e,o as ve}from"./config-D3K87Mm1.js";import{d as ye,f as be,o as xe,s as v}from"./log-DWZny1vM.js";import{n as Se,o as Ce}from"./stringUtils-D_xPrwGQ.js";import{c as we,i as Te,r as Ee}from"./proxy-BtWuysHM.js";import{join as De}from"path";import{readFileSync as Oe}from"fs";import{randomUUID as ke}from"crypto";import{mkdir as Ae,writeFile as je}from"fs/promises";import{AsyncLocalStorage as Me}from"async_hooks";function y(e=ge()){let t=e.modelType;return t===`openai`?`openai`:t===`gemini`?`gemini`:t===`grok`?`grok`:a(process.env.WORKMATE_USE_BEDROCK)?`bedrock`:a(process.env.WORKMATE_USE_VERTEX)?`vertex`:a(process.env.WORKMATE_USE_FOUNDRY)?`foundry`:a(process.env.WORKMATE_USE_OPENAI)?`openai`:a(process.env.WORKMATE_USE_GEMINI)?`gemini`:a(process.env.WORKMATE_USE_GROK)?`grok`:`firstParty`}function Ne(){return y()}function b(){let e=process.env.ANTHROPIC_BASE_URL;if(!e)return!0;try{return new URL(e).host===`api.anthropic.com`}catch{return!1}}var x=e((()=>{_(),o()}));function Pe(){return S.getStore()?.workload}function Fe(e,t){return S.run({workload:e},t)}var S,Ie=e((()=>{S=new Me})),Le,C,Re,ze,Be,Ve,He,Ue,We,Ge,Ke,qe,Je,Ye=e((()=>{Le=`workmate-20250219`,C=`interleaved-thinking-2025-05-14`,Re=`context-1m-2025-08-07`,ze=`context-management-2025-06-27`,Be=`structured-outputs-2025-12-15`,Ve=`tool-search-tool-2025-10-19`,He=`task-budgets-2026-03-13`,Ue=`prompt-caching-scope-2026-01-05`,We=`fast-mode-2026-02-01`,Ge=`redact-thinking-2026-02-12`,Ke=`advisor-tool-2026-03-01`,qe=new Set([C,Re,Ve]),Je=new Set([Le,C,ze])}));function Xe(e,t){return ce(e,t)}var Ze=e((()=>{le()}));function Qe(){let e=process.env.CLAUDE_AGENT_SDK_VERSION?`, agent-sdk/${process.env.CLAUDE_AGENT_SDK_VERSION}`:``,t=process.env.CLAUDE_AGENT_SDK_CLIENT_APP?`, client-app/${process.env.CLAUDE_AGENT_SDK_CLIENT_APP}`:``,n=Pe(),r=n?`, workload/${n}`:``;return`claude-cli/0.0.26 (external, ${process.env.WORKMATE_ENTRYPOINT??`cli`}${e}${t}${r})`}function $e(){let e=[];return process.env.WORKMATE_ENTRYPOINT&&e.push(process.env.WORKMATE_ENTRYPOINT),process.env.CLAUDE_AGENT_SDK_VERSION&&e.push(`agent-sdk/${process.env.CLAUDE_AGENT_SDK_VERSION}`),process.env.CLAUDE_AGENT_SDK_CLIENT_APP&&e.push(`client-app/${process.env.CLAUDE_AGENT_SDK_CLIENT_APP}`),`workmate/0.0.26${e.length>0?` (${e.join(`, `)})`:``}`}var et=e((()=>{Ie()}));function w(){return{error:(e,...t)=>console.error(`[SDK ERROR]`,e,...t),warn:(e,...t)=>console.error(`[SDK WARN]`,e,...t),info:(e,...t)=>console.error(`[SDK INFO]`,e,...t),debug:(e,...t)=>console.error(`[SDK DEBUG]`,e,...t)}}async function tt({apiKey:e,maxRetries:n,model:r,fetchOverride:i,source:o}){let c=process.env.WORKMATE_CONTAINER_ID,l=process.env.WORKMATE_REMOTE_SESSION_ID,u=process.env.CLAUDE_AGENT_SDK_CLIENT_APP,te=nt(),d={"x-app":`cli`,"User-Agent":Qe(),"X-Work-Mate-Session-Id":se(),...te,...c?{"x-claude-remote-container-id":c}:{},...l?{"x-claude-remote-session-id":l}:{},...u?{"x-client-app":u}:{},...process.env.ANTHROPIC_AUTH_NONCE?{"x-auth-nonce":process.env.ANTHROPIC_AUTH_NONCE}:{}};h(`[API:request] Creating client, ANTHROPIC_CUSTOM_HEADERS present: ${!!process.env.ANTHROPIC_CUSTOM_HEADERS}, has Authorization header: ${!!te.Authorization}`),a(process.env.WORKMATE_ADDITIONAL_PROTECTION)&&(d[`x-anthropic-additional-protection`]=`true`);let f=rt(i,o),p={defaultHeaders:d,maxRetries:n,timeout:parseInt(process.env.API_TIMEOUT_MS||`600000`,10),dangerouslyAllowBrowser:!0,fetchOptions:Te({forAnthropicAPI:!0}),...f&&{fetch:f}};if(a(process.env.WORKMATE_USE_BEDROCK)){let{BedrockClient:e}=await import(`./bedrockClient-CfiDN-kF.js`),t=r===sn()&&process.env.ANTHROPIC_SMALL_FAST_MODEL_AWS_REGION?process.env.ANTHROPIC_SMALL_FAST_MODEL_AWS_REGION:s(),n={...p,awsRegion:t,...a(process.env.WORKMATE_SKIP_BEDROCK_AUTH)&&{skipAuth:!0},...g()&&{logger:w()}};return process.env.AWS_BEARER_TOKEN_BEDROCK&&(n.skipAuth=!0,n.defaultHeaders={...n.defaultHeaders,Authorization:`Bearer ${process.env.AWS_BEARER_TOKEN_BEDROCK}`}),new e(n)}if(a(process.env.WORKMATE_USE_FOUNDRY)){let{AnthropicFoundry:e}=await import(`./foundry-sdk-BdeF2aBu.js`),t;if(!process.env.ANTHROPIC_FOUNDRY_API_KEY)if(a(process.env.WORKMATE_SKIP_FOUNDRY_AUTH))t=()=>Promise.resolve(``);else{let{DefaultAzureCredential:e,getBearerTokenProvider:n}=await import(`./esm-DUH16IqH.js`);t=n(new e,`https://cognitiveservices.azure.com/.default`)}return new e({...p,...t&&{azureADTokenProvider:t},...g()&&{logger:w()}})}if(a(process.env.WORKMATE_USE_VERTEX)){let[{AnthropicVertex:e},{GoogleAuth:n}]=await Promise.all([import(`./vertex-sdk-DjXcZ2J7.js`),import(`./src-C8gyNm5a.js`).then(e=>t(e.default,1))]),i=process.env.GCLOUD_PROJECT||process.env.GOOGLE_CLOUD_PROJECT||process.env.gcloud_project||process.env.google_cloud_project,o=process.env.GOOGLE_APPLICATION_CREDENTIALS||process.env.google_application_credentials,s=a(process.env.WORKMATE_SKIP_VERTEX_AUTH)?{getClient:()=>({getRequestHeaders:()=>({})})}:new n({scopes:[`https://www.googleapis.com/auth/cloud-platform`],...i||o?{}:{projectId:process.env.ANTHROPIC_VERTEX_PROJECT_ID}});return new e({...p,region:ee(r),googleAuth:s,...g()&&{logger:w()}})}return new fe({...e?{apiKey:e}:{},...p,...g()&&{logger:w()}})}function nt(){let e={},t=process.env.ANTHROPIC_CUSTOM_HEADERS;if(!t)return e;let n=t.split(/\n|\r\n/);for(let t of n){if(!t.trim())continue;let n=t.indexOf(`:`);if(n===-1)continue;let r=t.slice(0,n).trim(),i=t.slice(n+1).trim();r&&(e[r]=i)}return e}function rt(e,t){let n=e??globalThis.fetch,r=y()===`firstParty`&&b();return(e,i)=>{let a=new Headers(i?.headers);r&&!a.has(`x-client-request-id`)&&a.set(T,ke());try{let n=e instanceof Request?e.url:String(e),r=a.get(T);h(`[API REQUEST] ${new URL(n).pathname}${r?` ${T}=${r}`:``} source=${t??`unknown`}`)}catch{}return n(e,{...i,headers:a})}}var T,it=e((()=>{de(),et(),$(),x(),we(),ie(),pe(),o(),T=`x-client-request-id`}));function at(){return De(i(),`cache`)}function ot(){return De(at(),`model-capabilities.json`)}function st(){return!(y()!==`firstParty`||!b())}function ct(e){return[...e].sort((e,t)=>t.id.length-e.id.length||e.id.localeCompare(t.id))}function lt(e){if(!st())return;let t=D(ot());if(!t||t.length===0)return;let n=e.toLowerCase();return t.find(e=>e.id.toLowerCase()===n)||t.find(e=>n.includes(e.id.toLowerCase()))}async function ut(){if(st()&&!be())try{let e=await tt({maxRetries:1}),t=[];for await(let n of e.models.list()){let e=E().safeParse(n);e.success&&t.push(e.data)}if(t.length===0)return;let n=ot(),r=ct(t);if(Xe(D(n),r)){h(`[modelCapabilities] cache unchanged, skipping write`);return}await Ae(at(),{recursive:!0}),await je(n,ue({models:r,timestamp:Date.now()}),{encoding:`utf-8`,mode:384}),D.cache.delete(n),h(`[modelCapabilities] cached ${r.length} models`)}catch(e){h(`[modelCapabilities] fetch failed: ${e instanceof Error?e.message:`unknown`}`)}}var E,dt,D,ft=e((()=>{Ze(),r(),d(),it(),pe(),o(),p(),ne(),ye(),me(),x(),E=re(()=>u({id:te(),max_input_tokens:l().optional(),max_tokens:l().optional()}).strip()),dt=re(()=>u({models:c(E()),timestamp:l()})),D=n(e=>{try{let t=Oe(e,`utf-8`),n=dt().safeParse(f(t,!1));return n.success?n.data.models:null}catch{return null}},e=>e)}));function O(){return a(process.env.WORKMATE_DISABLE_1M_CONTEXT)}function k(e){return!O()&&/\[1m\]/i.test(e)}function pt(e){if(O())return!1;let t=Z(e);return t.includes(`claude-sonnet-4`)||t.includes(`opus-4-6`)||t.includes(`opus-4-7`)}function mt(e,t){if(k(e))return 1e6;let n=lt(e);return n?.max_input_tokens&&n.max_input_tokens>=1e5?n.max_input_tokens>2e5&&O()?A:n.max_input_tokens:t?.includes(`context-1m-2025-08-07`)&&pt(e)||ht(e)?1e6:A}function ht(e){return O()||k(e)||!Z(e).includes(`sonnet-4-6`)?!1:ve().clientDataCache?.coral_reef_sonnet===`true`}function gt(e,t){if(!e)return{used:null,remaining:null};let n=e.input_tokens+e.cache_creation_input_tokens+e.cache_read_input_tokens;if(n===0)return{used:null,remaining:null};let r=Math.round(n/t*100),i=Math.min(100,Math.max(0,r));return{used:i,remaining:100-i}}function _t(e){let t,n,r=Z(e);r.includes(`opus-4-7`)||r.includes(`opus-4-6`)?(t=64e3,n=128e3):r.includes(`sonnet-4-6`)?(t=32e3,n=128e3):r.includes(`opus-4-5`)||r.includes(`sonnet-4`)||r.includes(`haiku-4`)?(t=32e3,n=64e3):r.includes(`opus-4-1`)||r.includes(`opus-4`)?(t=32e3,n=32e3):r.includes(`claude-3-opus`)?(t=4096,n=4096):r.includes(`claude-3-sonnet`)?(t=8192,n=8192):r.includes(`claude-3-haiku`)?(t=4096,n=4096):r.includes(`3-5-sonnet`)||r.includes(`3-5-haiku`)?(t=8192,n=8192):r.includes(`3-7-sonnet`)?(t=32e3,n=64e3):(t=bt,n=xt);let i=lt(e);return i?.max_tokens&&i.max_tokens>=4096&&(n=i.max_tokens,t=Math.min(t,n)),{default:t,upperLimit:n}}function vt(e){return _t(e).upperLimit-1}var A,yt,bt,xt,St,Ct=e((()=>{Ye(),_e(),o(),$(),ft(),A=2e5,yt=2e4,bt=32e3,xt=64e3,St=8e3}));function wt(e){let t=[],n=!1;async function r(){if(!n&&t.length!==0){for(n=!0;t.length>0;){let{args:n,resolve:r,reject:i,context:a}=t.shift();try{r(await e.apply(a,n))}catch(e){i(e)}}n=!1,t.length>0&&r()}}return function(...e){return new Promise((n,i)=>{t.push({args:e,resolve:n,reject:i,context:this}),r()})}}var Tt=e((()=>{}));function Et(e,t){return e.find(e=>e.includes(t))??null}async function Dt(){let{BedrockClient:e}=await import(`./dist-es-BXXmyhQ2.js`),t=s(),n=a(process.env.WORKMATE_SKIP_BEDROCK_AUTH);return new e({region:t,...process.env.ANTHROPIC_BEDROCK_BASE_URL&&{endpoint:process.env.ANTHROPIC_BEDROCK_BASE_URL},...await Ee(),...n&&{requestHandler:new(await(import(`./dist-es-C7vygWzp.js`))).NodeHttpHandler,httpAuthSchemes:[{schemeId:`smithy.api#noAuth`,identityProvider:()=>async()=>({}),signer:new(await(import(`./dist-es-gUzZ_7Vf.js`))).NoAuthSigner}],httpAuthSchemeProvider:()=>[{schemeId:`smithy.api#noAuth`}]}})}async function Ot(){let{BedrockRuntimeClient:e}=await import(`./dist-es-CzTYn7xo.js`),t=s(),n=a(process.env.WORKMATE_SKIP_BEDROCK_AUTH);return new e({region:t,...process.env.ANTHROPIC_BEDROCK_BASE_URL&&{endpoint:process.env.ANTHROPIC_BEDROCK_BASE_URL},...await Ee(),...n&&{requestHandler:new(await(import(`./dist-es-C7vygWzp.js`))).NodeHttpHandler,httpAuthSchemes:[{schemeId:`smithy.api#noAuth`,identityProvider:()=>async()=>({}),signer:new(await(import(`./dist-es-gUzZ_7Vf.js`))).NoAuthSigner}],httpAuthSchemeProvider:()=>[{schemeId:`smithy.api#noAuth`}]}})}function kt(e){return e.startsWith(`anthropic.`)}function At(e){if(!e.startsWith(`arn:`))return e;let t=e.lastIndexOf(`/`);return t===-1?e:e.substring(t+1)}function jt(e){let t=At(e);for(let e of Pt)if(t.startsWith(`${e}.anthropic.`))return e}function Mt(e,t){let n=jt(e);return n?e.replace(`${n}.`,`${t}.`):kt(e)?`${t}.${e}`:e}var j,Nt,Pt,Ft=e((()=>{r(),o(),xe(),we(),j=n(async()=>{let[e,{ListInferenceProfilesCommand:t}]=await Promise.all([Dt(),import(`./dist-es-BXXmyhQ2.js`)]),n=[],r;try{do{let i=new t({...r&&{nextToken:r},typeEquals:`SYSTEM_DEFINED`}),a=await e.send(i);a.inferenceProfileSummaries&&n.push(...a.inferenceProfileSummaries),r=a.nextToken}while(r);return n.filter(e=>e.inferenceProfileId?.includes(`anthropic`)).map(e=>e.inferenceProfileId).filter(Boolean)}catch(e){throw v(e),e}}),Nt=n(async e=>{try{let[t,{GetInferenceProfileCommand:n}]=await Promise.all([Dt(),import(`./dist-es-BXXmyhQ2.js`)]),r=new n({inferenceProfileIdentifier:e}),i=await t.send(r);if(!i.models||i.models.length===0)return null;let a=i.models[0];if(!a?.modelArn)return null;let o=a.modelArn.lastIndexOf(`/`);return o>=0?a.modelArn.substring(o+1):a.modelArn}catch(e){return v(e),null}}),Pt=[`us`,`eu`,`apac`,`global`]})),M,N,P,F,I,L,R,z,B,It,Lt,Rt,V,zt,Bt=e((()=>{M={firstParty:`claude-3-7-sonnet-20250219`,bedrock:`us.anthropic.claude-3-7-sonnet-20250219-v1:0`,vertex:`claude-3-7-sonnet@20250219`,foundry:`claude-3-7-sonnet`,openai:`claude-3-7-sonnet-20250219`,gemini:`claude-3-7-sonnet-20250219`,grok:`claude-3-7-sonnet-20250219`},N={firstParty:`claude-3-5-sonnet-20241022`,bedrock:`anthropic.claude-3-5-sonnet-20241022-v2:0`,vertex:`claude-3-5-sonnet-v2@20241022`,foundry:`claude-3-5-sonnet`,openai:`claude-3-5-sonnet-20241022`,gemini:`claude-3-5-sonnet-20241022`,grok:`claude-3-5-sonnet-20241022`},P={firstParty:`claude-3-5-haiku-20241022`,bedrock:`us.anthropic.claude-3-5-haiku-20241022-v1:0`,vertex:`claude-3-5-haiku@20241022`,foundry:`claude-3-5-haiku`,openai:`claude-3-5-haiku-20241022`,gemini:`claude-3-5-haiku-20241022`,grok:`claude-3-5-haiku-20241022`},F={firstParty:`claude-haiku-4-5-20251001`,bedrock:`us.anthropic.claude-haiku-4-5-20251001-v1:0`,vertex:`claude-haiku-4-5@20251001`,foundry:`claude-haiku-4-5`,openai:`claude-haiku-4-5-20251001`,gemini:`claude-haiku-4-5-20251001`,grok:`claude-haiku-4-5-20251001`},I={firstParty:`claude-sonnet-4-20250514`,bedrock:`us.anthropic.claude-sonnet-4-20250514-v1:0`,vertex:`claude-sonnet-4@20250514`,foundry:`claude-sonnet-4`,openai:`claude-sonnet-4-20250514`,gemini:`claude-sonnet-4-20250514`,grok:`claude-sonnet-4-20250514`},L={firstParty:`claude-sonnet-4-5-20250929`,bedrock:`us.anthropic.claude-sonnet-4-5-20250929-v1:0`,vertex:`claude-sonnet-4-5@20250929`,foundry:`claude-sonnet-4-5`,openai:`claude-sonnet-4-5-20250929`,gemini:`claude-sonnet-4-5-20250929`,grok:`claude-sonnet-4-5-20250929`},R={firstParty:`claude-opus-4-20250514`,bedrock:`us.anthropic.claude-opus-4-20250514-v1:0`,vertex:`claude-opus-4@20250514`,foundry:`claude-opus-4`,openai:`claude-opus-4-20250514`,gemini:`claude-opus-4-20250514`,grok:`claude-opus-4-20250514`},z={firstParty:`claude-opus-4-1-20250805`,bedrock:`us.anthropic.claude-opus-4-1-20250805-v1:0`,vertex:`claude-opus-4-1@20250805`,foundry:`claude-opus-4-1`,openai:`claude-opus-4-1-20250805`,gemini:`claude-opus-4-1-20250805`,grok:`claude-opus-4-1-20250805`},B={firstParty:`claude-opus-4-5-20251101`,bedrock:`us.anthropic.claude-opus-4-5-20251101-v1:0`,vertex:`claude-opus-4-5@20251101`,foundry:`claude-opus-4-5`,openai:`claude-opus-4-5-20251101`,gemini:`claude-opus-4-5-20251101`,grok:`claude-opus-4-5-20251101`},It={firstParty:`claude-opus-4-6`,bedrock:`us.anthropic.claude-opus-4-6-v1`,vertex:`claude-opus-4-6`,foundry:`claude-opus-4-6`,openai:`claude-opus-4-6`,gemini:`claude-opus-4-6`,grok:`claude-opus-4-6`},Lt={firstParty:`claude-opus-4-7`,bedrock:`us.anthropic.claude-opus-4-7-v1`,vertex:`claude-opus-4-7`,foundry:`claude-opus-4-7`,openai:`claude-opus-4-7`,gemini:`claude-opus-4-7`,grok:`claude-opus-4-7`},Rt={firstParty:`claude-sonnet-4-6`,bedrock:`us.anthropic.claude-sonnet-4-6`,vertex:`claude-sonnet-4-6`,foundry:`claude-sonnet-4-6`,openai:`claude-sonnet-4-6`,gemini:`claude-sonnet-4-6`,grok:`claude-sonnet-4-6`},V={haiku35:P,haiku45:F,sonnet35:N,sonnet37:M,sonnet40:I,sonnet45:L,sonnet46:Rt,opus40:R,opus41:z,opus45:B,opus46:It,opus47:Lt},Object.values(V).map(e=>e.firstParty),zt=Object.fromEntries(Object.entries(V).map(([e,t])=>[t.firstParty,e]))}));function H(e){let t={};for(let n of Kt)t[n]=V[n][e];return t}async function Vt(){let e=H(`bedrock`),t;try{t=await j()}catch(t){return v(t),e}if(!t?.length)return e;let n={};for(let r of Kt){let i=V[r].firstParty;n[r]=Et(t,i)||e[r]}return n}function Ht(e){let t=ge().modelOverrides;if(!t)return e;let n={...e};for(let[e,r]of Object.entries(t)){let t=zt[e];t&&r&&(n[t]=r)}return n}function Ut(e){let t;try{t=ge().modelOverrides}catch{return e}if(!t)return e;for(let[n,r]of Object.entries(t))if(r===e)return n;return e}function Wt(){if(m()===null){if(y()!==`bedrock`){ae(H(y()));return}qt()}}function U(){let e=m();return e===null?(Wt(),Ht(H(y()))):Ht(e)}async function Gt(){if(m()===null){if(y()!==`bedrock`){ae(H(y()));return}await qt()}}var Kt,qt,W=e((()=>{ie(),xe(),Tt(),_(),Ft(),Bt(),x(),Kt=Object.keys(V),qt=wt(async()=>{if(m()===null)try{ae(await Vt())}catch(e){v(e)}})}));function G(e){return Jt.includes(e)}function K(e){return Yt.includes(e)}var Jt,Yt,Xt=e((()=>{Jt=[`sonnet`,`opus`,`haiku`,`best`,`sonnet[1m]`,`opus[1m]`,`opusplan`],Yt=[`sonnet`,`opus`,`haiku`]}));function Zt(e,t){return e.includes(t)?!0:G(e)?Q(e).toLowerCase().includes(t):!1}function Qt(e,t){return e.startsWith(t)?e.length===t.length||e[t.length]===`-`:!1}function $t(e,t){let n=G(e)?Q(e).toLowerCase():e;return!!(Qt(n,t)||!t.startsWith(`claude-`)&&Qt(n,`claude-${t}`))}function en(e,t){for(let n of t){if(K(n))continue;let t=n.indexOf(e);if(t===-1)continue;let r=t+e.length;if(r===n.length||n[r]===`-`)return!0}return!1}function tn(e){let{availableModels:t}=he()||{};if(!t)return!0;if(t.length===0)return!1;let n=Ut(e).trim().toLowerCase(),r=t.map(e=>e.trim().toLowerCase());if(r.includes(n)&&(!K(n)||!en(n,r)))return!0;for(let e of r)if(K(e)&&!en(e,r)&&Zt(n,e))return!0;if(G(n)){let e=Q(n).toLowerCase();if(r.includes(e))return!0}for(let e of r)if(!K(e)&&G(e)&&Q(e).toLowerCase()===n)return!0;for(let e of r)if(!K(e)&&!G(e)&&$t(n,e))return!0;return!1}var nn=e((()=>{_(),Xt(),$(),W()}));function q(){return process.env.OPENAI_AUTH_MODE===`chatgpt`}var rn,an,on=e((()=>{rn=`gpt-5.5`,an=`gpt-5.4-mini`}));function sn(){let e=y();return e===`openai`&&q()?process.env.OPENAI_SMALL_FAST_MODEL??`gpt-5.4-mini`:e===`openai`&&process.env.OPENAI_SMALL_FAST_MODEL?process.env.OPENAI_SMALL_FAST_MODEL:e===`gemini`&&process.env.GEMINI_SMALL_FAST_MODEL?process.env.GEMINI_SMALL_FAST_MODEL:process.env.ANTHROPIC_SMALL_FAST_MODEL||fn()}function cn(e){return e===U().opus40||e===U().opus41||e===U().opus45||e===U().opus46||e===U().opus47}function J(){let e,t=oe();if(t!==void 0)e=t;else{let t=he()||{};e=process.env.ANTHROPIC_MODEL||t.model||void 0}if(!(e&&!tn(e)))return e}function ln(){let e=J();return e==null?hn():Q(e)}function un(){return Y()}function dn(){let e=y();if(e===`openai`)return process.env.OPENAI_MODEL;if(e===`gemini`)return process.env.GEMINI_MODEL;if(e===`grok`)return process.env.GROK_MODEL}function Y(){let e=y();return e===`openai`&&q()?rn:e===`openai`&&process.env.OPENAI_DEFAULT_OPUS_MODEL?process.env.OPENAI_DEFAULT_OPUS_MODEL:e===`gemini`&&process.env.GEMINI_DEFAULT_OPUS_MODEL?process.env.GEMINI_DEFAULT_OPUS_MODEL:process.env.ANTHROPIC_DEFAULT_OPUS_MODEL?process.env.ANTHROPIC_DEFAULT_OPUS_MODEL:dn()||U().opus47}function X(){let e=y();return e===`openai`&&q()?rn:e===`openai`&&process.env.OPENAI_DEFAULT_SONNET_MODEL?process.env.OPENAI_DEFAULT_SONNET_MODEL:e===`gemini`&&process.env.GEMINI_DEFAULT_SONNET_MODEL?process.env.GEMINI_DEFAULT_SONNET_MODEL:process.env.ANTHROPIC_DEFAULT_SONNET_MODEL?process.env.ANTHROPIC_DEFAULT_SONNET_MODEL:dn()||(e===`firstParty`?U().sonnet46:U().sonnet45)}function fn(){let e=y();return e===`openai`&&q()?an:e===`openai`&&process.env.OPENAI_DEFAULT_HAIKU_MODEL?process.env.OPENAI_DEFAULT_HAIKU_MODEL:e===`gemini`&&process.env.GEMINI_DEFAULT_HAIKU_MODEL?process.env.GEMINI_DEFAULT_HAIKU_MODEL:process.env.ANTHROPIC_DEFAULT_HAIKU_MODEL?process.env.ANTHROPIC_DEFAULT_HAIKU_MODEL:dn()||U().haiku45}function pn(e){let{permissionMode:t,mainLoopModel:n,exceeds200kTokens:r=!1}=e;return J()===`opusplan`&&t===`plan`&&!r?Y():J()===`haiku`&&t===`plan`?X():n}function mn(){return X()}function hn(){return Q(mn())}function gn(e){if(e=e.toLowerCase(),e.includes(`claude-opus-4-7`))return`claude-opus-4-7`;if(e.includes(`claude-opus-4-6`))return`claude-opus-4-6`;if(e.includes(`claude-opus-4-5`))return`claude-opus-4-5`;if(e.includes(`claude-opus-4-1`))return`claude-opus-4-1`;if(e.includes(`claude-opus-4`))return`claude-opus-4`;if(e.includes(`claude-sonnet-4-6`))return`claude-sonnet-4-6`;if(e.includes(`claude-sonnet-4-5`))return`claude-sonnet-4-5`;if(e.includes(`claude-sonnet-4`))return`claude-sonnet-4`;if(e.includes(`claude-haiku-4-5`))return`claude-haiku-4-5`;if(e.includes(`claude-3-7-sonnet`))return`claude-3-7-sonnet`;if(e.includes(`claude-3-5-sonnet`))return`claude-3-5-sonnet`;if(e.includes(`claude-3-5-haiku`))return`claude-3-5-haiku`;if(e.includes(`claude-3-opus`))return`claude-3-opus`;if(e.includes(`claude-3-sonnet`))return`claude-3-sonnet`;if(e.includes(`claude-3-haiku`))return`claude-3-haiku`;let t=e.match(/(claude-(\d+-\d+-)?\w+)/);return t?.[1]?t[1]:e}function Z(e){return gn(Ut(e))}function _n(e){return e===`opusplan`?`Opus 4.7 in plan mode, else Sonnet 4.6`:xn(Q(e))}function vn(){return!(O()||y()!==`firstParty`||!b())}function yn(e){return e===`opusplan`?`Opus Plan`:G(e)?Se(e):xn(e)}function bn(e){switch(e){case U().opus47:return`Opus 4.7`;case`${U().opus47}[1m]`:return`Opus 4.7 (1M context)`;case U().opus46:return`Opus 4.6`;case`${U().opus46}[1m]`:return`Opus 4.6 (1M context)`;case U().opus45:return`Opus 4.5`;case U().opus41:return`Opus 4.1`;case U().opus40:return`Opus 4`;case`${U().sonnet46}[1m]`:return`Sonnet 4.6 (1M context)`;case U().sonnet46:return`Sonnet 4.6`;case`${U().sonnet45}[1m]`:return`Sonnet 4.5 (1M context)`;case U().sonnet45:return`Sonnet 4.5`;case U().sonnet40:return`Sonnet 4`;case`${U().sonnet40}[1m]`:return`Sonnet 4 (1M context)`;case U().sonnet37:return`Sonnet 3.7`;case U().sonnet35:return`Sonnet 3.5`;case U().haiku45:return`Haiku 4.5`;case U().haiku35:return`Haiku 3.5`;default:return null}}function xn(e){return bn(e)||e}function Q(e){let t=e.trim(),n=t.toLowerCase(),r=k(n),i=r?n.replace(/\[1m]$/i,``).trim():n;if(G(i))switch(i){case`opusplan`:return X()+(r?`[1m]`:``);case`sonnet`:return X()+(r?`[1m]`:``);case`haiku`:return fn()+(r?`[1m]`:``);case`opus`:return Y()+(r?`[1m]`:``);case`best`:return un();default:}return y()===`firstParty`&&Cn(i)&&wn()?Y()+(r?`[1m]`:``):r?`${t.replace(/\[1m\]$/i,``).trim()}[1m]`:t}function Sn(e,t){return k(e)||!k(t)?e:pt(Q(e))?`${e}[1m]`:e}function Cn(e){return On.includes(e)}function wn(){return!a(process.env.WORKMATE_DISABLE_LEGACY_MODEL_REMAP)}function Tn(e){if(e===null)return`Default (${hn()})`;let t=Q(e);return e===t?t:`${e} (${t})`}function En(e){if(y()===`foundry`)return;let t=e.toLowerCase().includes(`[1m]`),n=Z(e);if(n.includes(`claude-opus-4-7`))return t?`Opus 4.7 (with 1M context)`:`Opus 4.7`;if(n.includes(`claude-opus-4-6`))return t?`Opus 4.6 (with 1M context)`:`Opus 4.6`;if(n.includes(`claude-opus-4-5`))return`Opus 4.5`;if(n.includes(`claude-opus-4-1`))return`Opus 4.1`;if(n.includes(`claude-opus-4`))return`Opus 4`;if(n.includes(`claude-sonnet-4-6`))return t?`Sonnet 4.6 (with 1M context)`:`Sonnet 4.6`;if(n.includes(`claude-sonnet-4-5`))return t?`Sonnet 4.5 (with 1M context)`:`Sonnet 4.5`;if(n.includes(`claude-sonnet-4`))return t?`Sonnet 4 (with 1M context)`:`Sonnet 4`;if(n.includes(`claude-3-7-sonnet`))return`Work Mate 3.7 Sonnet`;if(n.includes(`claude-3-5-sonnet`))return`Work Mate 3.5 Sonnet`;if(n.includes(`claude-haiku-4-5`))return`Haiku 4.5`;if(n.includes(`claude-3-5-haiku`))return`Work Mate 3.5 Haiku`}function Dn(e){return e.replace(/\[(1|2)m\]/gi,``)}var On,$=e((()=>{ie(),Ct(),o(),W(),_(),x(),nn(),Xt(),Ce(),on(),On=[`claude-opus-4-20250514`,`claude-opus-4-1-20250805`,`claude-opus-4-0`,`claude-opus-4-1`]}));export{gt as $,P as A,Ie as At,I as B,nn as C,Ge as Ct,Gt as D,Le as Dt,Xt as E,Je as Et,B as F,b as Ft,jt as G,Mt as H,It as I,kt as J,Nt as K,R as L,M,y as Mt,F as N,Ne as Nt,U as O,Ye as Ot,z as P,x as Pt,yt as Q,L as R,Sn as S,Ue as St,Jt as T,He as Tt,Ot as U,Bt as V,j as W,wt as X,Tt as Y,St as Z,Dn as _,qe as _t,Y as a,Ct as at,xn as b,We as bt,En as c,ut as ct,J as d,it as dt,mt as et,$ as f,$e as ft,Tn as g,Ke as gt,vn as h,Xe as ht,mn as i,k as it,N as j,Fe as jt,W as k,Pe as kt,pn as l,T as lt,cn as m,Ze as mt,Z as n,_t as nt,X as o,O as ot,wn as p,et as pt,Ft as q,hn as r,ht as rt,ln as s,ft as st,gn as t,vt as tt,sn as u,tt as ut,Q as v,Re as vt,tn as w,Be as wt,yn as x,C as xt,_n as y,ze as yt,Rt as z};
@@ -1 +1 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{ai as n,di as r,fi as i}from"./src-DL3w8VPk.js";import{t as a}from"./jsx-runtime-Bb4Xn-E0.js";import{Bp as o,Hp as s,RS as c,XC as l,ad as u,aw as d,id as f,nw as p,ow as m,rd as h,rw as g,zS as _,zp as v}from"./loadAgentsDir-DGozQu_6.js";import{A as y,k as b,q as x}from"./log-DoSpAwRP.js";import{n as S}from"./analytics-COpjZpvd.js";import{C,E as w,T,f as E,h as D,i as O,w as k,y as A}from"./model-DpZaKZMb.js";import{i as j,r as M}from"./switcher-DMfuKuw_.js";import{i as N,n as P,r as F,t as I}from"./extraUsage-BtHE-SBX.js";function L({onDone:e}){let t=o(e=>e.mainLoopModel),n=o(e=>e.mainLoopModelForSession),i=o(e=>e.fastMode),a=s();function c(){let n=U(t);e(`Kept model as ${r.bold(n)}`,{display:`system`})}async function u(t){a(e=>({...e,mainLoopModel:t,mainLoopModelForSession:null}));let n=`Set model to ${r.bold(U(t))}`,o;if(d()&&(l(),!m(t)&&i?(a(e=>({...e,fastMode:!1})),o=!1):m(t)&&g()&&i&&(n+=` · Fast mode ON`,o=!0)),P(t,o===!0,D())&&(n+=` · Billed as extra usage`),o===!1&&(n+=` · Fast mode OFF`),t){let e=await j(t);e.kind===`updated`&&(n+=` · Provider "${e.providerId}" default model updated`)}e(n)}return(0,G.jsx)(F,{initial:t,sessionModel:n,onSelect:u,onCancel:c,isStandaloneCommand:!0,showFastModeNotice:d()&&i&&m(t)&&g()})}function R({args:e,onDone:t}){let n=o(e=>e.fastMode),i=s(),a=e==="default"?null:e;return W.useEffect(()=>{async function e(){if(a&&!k(a)){t(`Model '${a}' is not available. Your organization restricts model selection.`,{display:`system`});return}if(a&&B(a)){t(`Opus 4.7 with 1M context is not available for your account. Learn more: https://code.workmate.com/docs/en/model-config#extended-context-with-1m`,{display:`system`});return}if(a&&V(a)){t(`Sonnet 4.6 with 1M context is not available for your account. Learn more: https://code.workmate.com/docs/en/model-config#extended-context-with-1m`,{display:`system`});return}if(!a){o(null);return}if(z(a)){await o(a);return}try{let{valid:e,error:n}=await _(a);e?await o(a):t(n||`Model '${a}' not found`,{display:`system`})}catch(e){t(`Failed to validate model: ${e.message}`,{display:`system`})}}async function o(e){i(t=>({...t,mainLoopModel:e,mainLoopModelForSession:null}));let a=`Set model to ${r.bold(U(e))}`,o;if(d()&&(l(),!m(e)&&n?(i(e=>({...e,fastMode:!1})),o=!1):m(e)&&n&&(a+=` · Fast mode ON`,o=!0)),P(e,o===!0,D())&&(a+=` · Billed as extra usage`),o===!1&&(a+=` · Fast mode OFF`),e){let t=await j(e);t.kind===`updated`&&(a+=` · Provider "${t.providerId}" default model updated`)}t(a)}e()},[a,t,i]),null}function z(e){return T.includes(e.toLowerCase().trim())}function B(e){let t=e.toLowerCase();return!h()&&!D()&&t.includes(`opus`)&&t.includes(`[1m]`)}function V(e){let t=e.toLowerCase();return!f()&&(t.includes(`sonnet[1m]`)||t.includes(`sonnet-4-6[1m]`))}function H({onDone:e}){let t=o(e=>e.mainLoopModel),n=o(e=>e.mainLoopModelForSession),i=U(t);return e(n?`Current model: ${r.bold(U(n))} (session override from plan mode)\nBase model: ${i}`:`Current model: ${i}`),null}function U(e){let t=A(e??O());return e===null?`${t} (default)`:t}var W,G,K;e((()=>{i(),W=t(n(),1),N(),x(),S(),v(),I(),p(),w(),u(),E(),C(),c(),M(),G=a(),K=async(e,t,n)=>{if(n=n?.trim()||``,y.includes(n))return(0,G.jsx)(H,{onDone:e});if(b.includes(n)){e(`Run /model to open the model selection menu, or /model [modelName] to set the model.`,{display:`system`});return}return n?(0,G.jsx)(R,{args:n,onDone:e}):(0,G.jsx)(L,{onDone:e})}}))();export{K as call};
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{ai as n,di as r,fi as i}from"./src-WZ94ZKI3.js";import{t as a}from"./jsx-runtime-Bb4Xn-E0.js";import{AC as o,Bh as s,Hh as c,NC as l,PC as u,_S as d,ad as f,gS as p,id as m,jC as h,rd as g,wC as _,zh as v}from"./loadAgentsDir-DR5PVAc3.js";import{A as y,k as b,q as x}from"./log-DWZny1vM.js";import{n as S}from"./analytics-COpjZpvd.js";import{C,E as w,T,f as E,h as D,i as O,w as k,y as A}from"./model-D42epddJ.js";import{i as j,r as M}from"./switcher-DhZCaAun.js";import{i as N,n as P,r as F,t as I}from"./extraUsage-BlRL3yeb.js";function L({onDone:e}){let t=s(e=>e.mainLoopModel),n=s(e=>e.mainLoopModelForSession),i=s(e=>e.fastMode),a=c();function o(){let n=U(t);e(`Kept model as ${r.bold(n)}`,{display:`system`})}async function d(t){a(e=>({...e,mainLoopModel:t,mainLoopModelForSession:null}));let n=`Set model to ${r.bold(U(t))}`,o;if(l()&&(_(),!u(t)&&i?(a(e=>({...e,fastMode:!1})),o=!1):u(t)&&h()&&i&&(n+=` · Fast mode ON`,o=!0)),P(t,o===!0,D())&&(n+=` · Billed as extra usage`),o===!1&&(n+=` · Fast mode OFF`),t){let e=await j(t);e.kind===`updated`&&(n+=` · Provider "${e.providerId}" default model updated`)}e(n)}return(0,G.jsx)(F,{initial:t,sessionModel:n,onSelect:d,onCancel:o,isStandaloneCommand:!0,showFastModeNotice:l()&&i&&u(t)&&h()})}function R({args:e,onDone:t}){let n=s(e=>e.fastMode),i=c(),a=e==="default"?null:e;return W.useEffect(()=>{async function e(){if(a&&!k(a)){t(`Model '${a}' is not available. Your organization restricts model selection.`,{display:`system`});return}if(a&&B(a)){t(`Opus 4.7 with 1M context is not available for your account. Learn more: https://code.workmate.com/docs/en/model-config#extended-context-with-1m`,{display:`system`});return}if(a&&V(a)){t(`Sonnet 4.6 with 1M context is not available for your account. Learn more: https://code.workmate.com/docs/en/model-config#extended-context-with-1m`,{display:`system`});return}if(!a){o(null);return}if(z(a)){await o(a);return}try{let{valid:e,error:n}=await d(a);e?await o(a):t(n||`Model '${a}' not found`,{display:`system`})}catch(e){t(`Failed to validate model: ${e.message}`,{display:`system`})}}async function o(e){i(t=>({...t,mainLoopModel:e,mainLoopModelForSession:null}));let a=`Set model to ${r.bold(U(e))}`,o;if(l()&&(_(),!u(e)&&n?(i(e=>({...e,fastMode:!1})),o=!1):u(e)&&n&&(a+=` · Fast mode ON`,o=!0)),P(e,o===!0,D())&&(a+=` · Billed as extra usage`),o===!1&&(a+=` · Fast mode OFF`),e){let t=await j(e);t.kind===`updated`&&(a+=` · Provider "${t.providerId}" default model updated`)}t(a)}e()},[a,t,i]),null}function z(e){return T.includes(e.toLowerCase().trim())}function B(e){let t=e.toLowerCase();return!g()&&!D()&&t.includes(`opus`)&&t.includes(`[1m]`)}function V(e){let t=e.toLowerCase();return!m()&&(t.includes(`sonnet[1m]`)||t.includes(`sonnet-4-6[1m]`))}function H({onDone:e}){let t=s(e=>e.mainLoopModel),n=s(e=>e.mainLoopModelForSession),i=U(t);return e(n?`Current model: ${r.bold(U(n))} (session override from plan mode)\nBase model: ${i}`:`Current model: ${i}`),null}function U(e){let t=A(e??O());return e===null?`${t} (default)`:t}var W,G,K;e((()=>{i(),W=t(n(),1),N(),x(),S(),v(),I(),o(),w(),f(),E(),C(),p(),M(),G=a(),K=async(e,t,n)=>{if(n=n?.trim()||``,y.includes(n))return(0,G.jsx)(H,{onDone:e});if(b.includes(n)){e(`Run /model to open the model selection menu, or /model [modelName] to set the model.`,{display:`system`});return}return n?(0,G.jsx)(R,{args:n,onDone:e}):(0,G.jsx)(L,{onDone:e})}}))();export{K as call};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Pt as t,j as n}from"./state-BQ4BEGin.js";import{__ as r,h_ as i,y_ as a}from"./loadAgentsDir-DGozQu_6.js";import{d as o,h as s}from"./settings-CodSADx8.js";import{d as c,o as l}from"./config-CWPHVTic.js";import{C as u,Mt as d,Pt as f,d as p,f as m,i as h,w as g,y as _}from"./model-DpZaKZMb.js";function v(e=!1){let t=d()!==`firstParty`;return{value:null,label:`Default (recommended)`,description:`Use the default model (currently ${_(h())})${t?``:` · ${r(i)}`}`}}function y(e=!1){let t=[v(e)],r=process.env.ANTHROPIC_CUSTOM_MODEL_OPTION;r&&!t.some(e=>e.value===r)&&t.push({value:r,label:process.env.ANTHROPIC_CUSTOM_MODEL_OPTION_NAME??r,description:process.env.ANTHROPIC_CUSTOM_MODEL_OPTION_DESCRIPTION??`Custom model (${r})`});for(let e of l().additionalModelOptionsCache??[])t.some(t=>t.value===e.value)||t.push(e);let i=null,a=p(),o=n();return a==null?o!==null&&(i=o):i=a,i!==null&&!t.some(e=>e.value===i)&&t.push({value:i,label:i,description:`Custom model`}),b(t)}function b(e){return(o()||{}).availableModels?e.filter(e=>e.value===null||e.value!==null&&g(e.value)):e}function x(e,t){return e.length===0?null:b([v(t),...e])}var S=e((()=>{t(),c(),a(),s(),u(),m(),f()}));export{y as n,S as r,x as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Pt as t,j as n}from"./state-CXY-q5gr.js";import{gy as r,my as i,vy as a}from"./loadAgentsDir-DR5PVAc3.js";import{d as o,m as s}from"./settings-YIDksG5Z.js";import{d as c,o as l}from"./config-D3K87Mm1.js";import{C as u,Mt as d,Pt as f,d as p,f as m,i as h,w as g,y as _}from"./model-D42epddJ.js";function v(e=!1){let t=d()!==`firstParty`;return{value:null,label:`Default (recommended)`,description:`Use the default model (currently ${_(h())})${t?``:` · ${r(i)}`}`}}function y(e=!1){let t=[v(e)],r=process.env.ANTHROPIC_CUSTOM_MODEL_OPTION;r&&!t.some(e=>e.value===r)&&t.push({value:r,label:process.env.ANTHROPIC_CUSTOM_MODEL_OPTION_NAME??r,description:process.env.ANTHROPIC_CUSTOM_MODEL_OPTION_DESCRIPTION??`Custom model (${r})`});for(let e of l().additionalModelOptionsCache??[])t.some(t=>t.value===e.value)||t.push(e);let i=null,a=p(),o=n();return a==null?o!==null&&(i=o):i=a,i!==null&&!t.some(e=>e.value===i)&&t.push({value:i,label:i,description:`Custom model`}),b(t)}function b(e){return(o()||{}).availableModels?e.filter(e=>e.value===null||e.value!==null&&g(e.value)):e}function x(e,t){return e.length===0?null:b([v(t),...e])}var S=e((()=>{t(),c(),a(),s(),u(),m(),f()}));export{y as n,S as r,x as t};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{l as t,o as n}from"./envUtils-DZ_SvEVz.js";import{n as r,t as i}from"./axios-DaWTGg7G.js";import{$ as a,I as o,M as s,N as c,R as l,V as u,c as d,et as f,f as p,i as m,u as ee}from"./debug-kBjDaVkQ.js";import{Kt as te,Ut as ne}from"./settings-YIDksG5Z.js";import{d as re,h as ie,o as ae}from"./config-D3K87Mm1.js";import{o as h,s as g}from"./log-DWZny1vM.js";import{i as _,n as v}from"./execFileNoThrow-BfZFnCGa.js";import{n as y}from"./analytics-COpjZpvd.js";import{n as oe,r as b,t as se}from"./lockfile-D_9vif6E.js";import{b as ce,n as le,t as ue,v as de,y as fe}from"./sleep-BbWr_FL1.js";import{j as pe,k as me}from"./sessionTracing-UFK96PxT.js";import{C as he,E as ge,S as _e,T as ve,_ as ye,a as x,b as be,c as xe,d as Se,f as Ce,g as we,i as Te,l as Ee,m as De,n as Oe,o as S,p as ke,s as Ae,t as je,u as Me,v as Ne,w as Pe,x as C,y as Fe}from"./pidLock-YvAaIrIY.js";import{homedir as w}from"os";import{basename as Ie,delimiter as Le,dirname as T,join as E,resolve as D}from"path";import{constants as Re}from"fs";import{createHash as ze}from"crypto";import{access as O,chmod as k,copyFile as A,mkdir as j,readdir as M,readlink as N,rename as P,rm as F,rmdir as Be,stat as I,symlink as Ve,unlink as L,writeFile as R}from"fs/promises";async function He(e=`latest`,t,n){let i=Date.now();try{let a=await r.get(`${t}/${e}`,{timeout:3e4,responseType:`text`,...n});return Date.now()-i,a.data.trim()}catch(n){Date.now()-i;let a=n instanceof Error?n.message:String(n);r.isAxiosError(n)&&n.response&&n.response.status,a.includes(`timeout`);let o=Error(`Failed to fetch version from ${t}/${e}: ${a}`);throw g(o),o}}async function Ue(e){if(/^v?\d+\.\d+\.\d+(-\S+)?$/.test(e)){let t=e.startsWith(`v`)?e.slice(1):e;if(/^99\.99\./.test(t))throw Error(`Version ${t} is not available for installation. Use 'stable' or 'latest'.`);return t}let t=e;if(t!==`stable`&&t!==`latest`)throw Error(`Invalid channel: ${e}. Use 'stable' or 'latest'`);return He(t,z)}function We(){return Number(process.env.WORKMATE_STALL_TIMEOUT_MS_FOR_TESTING)||B}async function Ge(e,t,n,i={}){let a;for(let o=1;o<=V;o++){let s=new AbortController,c,l=()=>{c&&(clearTimeout(c),c=void 0)},f=()=>{l(),c=setTimeout(e=>e.abort(),We(),s)};try{f();let a=await r.get(e,{timeout:5*6e4,responseType:`arraybuffer`,signal:s.signal,onDownloadProgress:()=>{f()},...i});l();let o=ze(`sha256`);o.update(a.data);let c=o.digest(`hex`);if(c!==t)throw Error(`Checksum mismatch: expected ${t}, got ${c}`);await R(n,Buffer.from(a.data)),await k(n,493);return}catch(e){l();let t=r.isCancel(e);if(a=t?new H:u(e),t&&o<V){d(`Download stalled on attempt ${o}/${V}, retrying...`),await le(1e3);continue}throw a}}throw a??Error(`Download failed after all retries`)}async function Ke(e,t,n,i){let a=ee();await a.rm(t,{recursive:!0,force:!0});let o=U(),s=Date.now(),c;try{c=(await r.get(`${n}/${e}/manifest.json`,{timeout:1e4,responseType:`json`,...i})).data}catch(t){Date.now()-s;let i=t instanceof Error?t.message:String(t);throw r.isAxiosError(t)&&t.response&&t.response.status,i.includes(`timeout`),g(Error(`Failed to fetch manifest from ${n}/${e}/manifest.json: ${i}`)),t}let l=c.platforms[o];if(!l)throw Error(`Platform ${o} not found in manifest for version ${e}`);let u=l.checksum,d=W(o),f=`${n}/${e}/${o}/${d}`;await a.mkdir(t);let p=E(t,d);try{await Ge(f,u,p,i||{}),Date.now()-s}catch(e){Date.now()-s;let t=e instanceof Error?e.message:String(e);throw r.isAxiosError(e)&&e.response&&e.response.status,t.includes(`timeout`),t.includes(`Checksum mismatch`),g(Error(`Failed to download binary from ${f}: ${t}`)),e}}async function qe(e,t){return await Ke(e,t,z),`binary`}var z,B,V,H,Je=e((()=>{i(),y(),m(),o(),_(),p(),h(),ue(),$(),z=`https://downloads.workmate.ai/native-releases`,B=6e4,V=3,H=class extends Error{constructor(){super(`Download stalled: no data received for 60 seconds`),this.name=`StallTimeoutError`}}}));function U(){let e=ne.platform,t=process.arch===`x64`?`x64`:process.arch===`arm64`?`arm64`:null;if(!t){let e=Error(`Unsupported architecture: ${process.arch}`);throw d(`Native installer does not support architecture: ${process.arch}`,{level:`error`}),e}return e===`linux`&&me.isMuslEnvironment()?`linux-${t}-musl`:`${e}-${t}`}function W(e){return e.startsWith(`win32`)?`claude.exe`:`claude`}function G(){let e=W(U());return{versions:E(Se(),`claude`,`versions`),staging:E(Me(),`claude`,`staging`),locks:E(Ce(),`claude`,`locks`),executable:E(Ee(),e)}}async function K(e){try{let t=await I(e);return!t.isFile()||t.size===0?!1:(await O(e,Re.X_OK),!0)}catch{return!1}}async function q(e){let t=G(),n=[t.versions,t.staging,t.locks];await Promise.all(n.map(e=>j(e,{recursive:!0}))),await j(T(t.executable),{recursive:!0});let r=E(t.versions,e);try{await I(r)}catch{await R(r,``,{encoding:`utf8`})}return{stagingPath:E(t.staging,e),installPath:r}}async function Ye(e,t,n=0){let r=G(),i=J(r,e);if(await j(r.locks,{recursive:!0}),S()){let r=0,a=n+1,o=n>0?1e3:100,s=n>0?5e3:500;for(;r<a;){if(await xe(e,i,async()=>{try{await t()}catch(e){throw g(e),e}}))return r+1,!0;r++,r<a&&await le(Math.min(o*2**(r-1),s))}return Y(e,Error(`Lock held by another process`)),!1}let a=null;try{try{a=await b(e,{stale:Z,retries:{retries:n,minTimeout:n>0?1e3:100,maxTimeout:n>0?5e3:500},lockfilePath:i,onCompromised:e=>{d(`NON-FATAL: Version lock was compromised during operation: ${e.message}`,{level:`info`})}})}catch(t){return Y(e,t),!1}try{return await t(),!0}catch(e){throw g(e),e}}finally{a&&await a()}}async function Xe(e,t){await j(T(t),{recursive:!0});let n=`${t}.tmp.${process.pid}.${Date.now()}`;try{await A(e,n),await k(n,493),await P(n,t),d(`Atomically installed binary to ${t}`)}catch(e){try{await L(n)}catch{}throw e}}async function Ze(e,t){try{let n=E(e,`node_modules`,`@anthropic-ai`),r=(await M(n)).find(e=>e.startsWith(`claude-cli-native-`));if(!r)throw Error(`Could not find platform-specific native package`);let i=E(n,r,`cli`);try{await I(i)}catch{throw Error(`Native binary not found in staged package`)}await Xe(i,t),await F(e,{recursive:!0,force:!0})}catch(e){let t=s(e);throw!t.includes(`Could not find platform-specific`)&&t.includes(`Native binary not found`),g(u(e)),e}}async function Qe(e,t){try{let n=E(e,W(U()));try{await I(n)}catch{throw Error(`Staged binary not found`)}await Xe(n,t),await F(e,{recursive:!0,force:!0})}catch(e){throw s(e).includes(`Staged binary not found`),g(u(e)),e}}async function $e(e,t,n){n===`npm`?await Ze(e,t):await Qe(e,t)}async function et(e,n){let{stagingPath:r,installPath:i}=await q(e),{executable:a}=G(),o=t(process.env.ENABLE_LOCKLESS_UPDATES)?`${r}.${process.pid}.${Date.now()}`:r,s=!await tt(e)||n;if(s?(d(n?`Force reinstalling native installer version ${e}`:`Downloading native installer version ${e}`),await $e(o,i,await qe(e,o))):d(`Version ${e} already installed, updating symlink`),await rt(a),await it(a,i),!await K(a)){let e=!1;try{await I(i),e=!0}catch{}throw Error(`Failed to create executable at ${a}. Source file exists: ${e}. Check write permissions to ${a}.`)}return s}async function tt(e){let{installPath:t}=await q(e);return K(t)}async function nt(e,n=!1){let r=Date.now(),i=await Ue(e),{executable:a}=G();if(d(`Checking for native installer update to version ${i}`),!n){let e=await ye();if(e&&de(i,e)){if(d(`Native installer: maxVersion ${e} is set, capping update from ${i} to ${e}`),fe(`0.0.26`,e))return d(`Native installer: current version 0.0.26 is already at or above maxVersion ${e}, skipping update`),Date.now()-r,{success:!0,latestVersion:i};i=e}}if(!n&&i===`0.0.26`&&await tt(i)&&await K(a))return d(`Found ${i} at ${a}, skipping install`),Date.now()-r,{success:!0,latestVersion:i};if(!n&&Fe(i))return Date.now()-r,{success:!0,latestVersion:i};if(t(process.env.ENABLE_LOCKLESS_UPDATES))await et(i,n),Date.now()-r;else{let{installPath:e}=await q(i);n&&await ut(e);let t=await Ye(e,async()=>{await et(i,n)},3);if(Date.now()-r,!t){let t=G(),n;if(S()){let r=J(t,e);x(r)&&(n=Ae(r)?.pid)}return{success:!1,latestVersion:i,lockFailed:!0,lockHolderPid:n}}}return d(`Successfully updated to version ${i}`),{success:!0,latestVersion:i}}async function rt(e){try{await Be(e),d(`Removed empty directory at ${e}`)}catch(t){let n=c(t);n!==`ENOTDIR`&&n!==`ENOENT`&&n!==`ENOTEMPTY`&&d(`Could not remove directory at ${e}: ${t}`)}}async function it(e,t){if(U().startsWith(`win32`))try{await j(T(e),{recursive:!0});let n;try{n=await I(e)}catch{}if(n){try{let e=await I(t);if(n.size===e.size)return!1}catch{}let r=`${e}.old.${Date.now()}`;await P(e,r);try{await A(t,e);try{await L(r)}catch{}}catch(t){try{await P(r,e)}catch(e){let n=Error(`Failed to restore old executable: ${e}`,{cause:t});throw g(n),n}throw t}}else try{await A(t,e)}catch(e){throw l(e)?Error(`Source file does not exist: ${t}`):e}return!0}catch(n){return g(Error(`Failed to copy executable from ${t} to ${e}: ${n}`)),!1}let n=T(e);try{await j(n,{recursive:!0}),d(`Created directory ${n} for symlink`)}catch(e){return g(Error(`Failed to create directory ${n}: ${e}`)),!1}try{let n=!1;try{await I(e),n=!0}catch{}if(n){try{let n=await N(e);if(D(T(e),n)===D(t))return!1}catch{}await L(e)}}catch(e){g(Error(`Failed to check/remove existing symlink: ${e}`))}let r=`${e}.tmp.${process.pid}.${Date.now()}`;try{return await Ve(t,r),await P(r,e),d(`Atomically updated symlink ${e} -> ${t}`),!0}catch(n){try{await L(r)}catch{}return g(Error(`Failed to create symlink from ${e} to ${t}: ${n}`)),!1}}async function at(e=!1){if(t(process.env.DISABLE_INSTALLATION_CHECKS))return[];let n=await De();if(n===`development`||!(e||n===`native`))return[];let r=G(),i=[],a=T(r.executable),o=D(a),s=U().startsWith(`win32`);try{await O(a)}catch{i.push({message:`installMethod is native, but directory ${a} does not exist`,userActionRequired:!0,type:`error`})}if(s)await K(r.executable)||i.push({message:`installMethod is native, but claude command is missing or invalid at ${r.executable}`,userActionRequired:!0,type:`error`});else try{let e=await N(r.executable);await K(D(T(r.executable),e))||i.push({message:`Work Mate symlink points to missing or invalid binary: ${e}`,userActionRequired:!0,type:`error`})}catch(e){l(e)?i.push({message:`installMethod is native, but claude command not found at ${r.executable}`,userActionRequired:!0,type:`error`}):await K(r.executable)||i.push({message:`${r.executable} exists but is not a valid Work Mate binary`,userActionRequired:!0,type:`error`})}if(!(process.env.PATH||``).split(Le).some(e=>{try{let t=D(e);return s?t.toLowerCase()===o.toLowerCase():t===o}catch{return!1}}))if(s){let e=a.replace(/\//g,`\\`);i.push({message:`Native installation exists but ${e} is not in your PATH. Add it by opening: System Properties → Environment Variables → Edit User PATH → New → Add the path above. Then restart your terminal.`,userActionRequired:!0,type:`path`})}else{let e=ve(),t=C()[e],n=t?t.replace(w(),`~`):`your shell config file`;i.push({message:`Native installation exists but ~/.local/bin is not in your PATH. Run:\n\necho 'export PATH="$HOME/.local/bin:$PATH"' >> ${n} && source ${n}`,userActionRequired:!0,type:`path`})}return i}function ot(e,t=!1){if(t)return st(e,t);if(Q)return d(`installLatest: joining in-flight call`),Q;let n=st(e,t);Q=n;let r=()=>{Q=null};return n.then(r,r),n}async function st(e,t=!1){let n=await nt(e,t);return n.success?(ae().installMethod!==`native`&&(ie(e=>({...e,installMethod:`native`,autoUpdates:!1,autoUpdatesProtectedForNative:!0})),d(`Native installer: Set installMethod to "native" and disabled legacy auto-updater for protection`)),X(),{latestVersion:n.latestVersion,wasUpdated:n.success,lockFailed:!1}):{latestVersion:null,wasUpdated:!1,lockFailed:n.lockFailed,lockHolderPid:n.lockHolderPid}}async function ct(e){try{let t=await N(e),n=D(T(e),t);if(await K(n))return n}catch{}return null}function J(e,t){let n=Ie(t);return E(e.locks,`${n}.lock`)}async function lt(){let e=G();if(!process.execPath.includes(e.versions))return;let t=D(process.execPath);try{let n=J(e,t);if(await j(e.locks,{recursive:!0}),S()){if(!await je(t,n)){Y(t,Error(`Lock already held by another process`));return}d(`Acquired PID lock on running version: ${t}`)}else{let e;try{e=await b(t,{stale:Z,retries:0,lockfilePath:n,onCompromised:e=>{d(`NON-FATAL: Lock on running version was compromised: ${e.message}`,{level:`info`})}}),d(`Acquired mtime-based lock on running version: ${t}`),f(async()=>{try{await e?.()}catch{}})}catch(e){if(l(e)){d(`Cannot lock current version - file does not exist: ${t}`,{level:`info`});return}Y(t,e);return}}}catch(e){if(l(e)){d(`Cannot lock current version - file does not exist: ${t}`,{level:`info`});return}d(`NON-FATAL: Failed to lock current version during execution ${s(e)}`,{level:`info`})}}function Y(e,t){g(Error(`NON-FATAL: Lock acquisition failed for ${e} (expected in multi-process scenarios)`,{cause:t}))}async function ut(e){let t=J(G(),e);try{await L(t),d(`Force-removed lock file at ${t}`)}catch(e){d(`Failed to force-remove lock file: ${s(e)}`)}}async function X(){await Promise.resolve();let e=G(),t=Date.now()-36e5;if(U().startsWith(`win32`)){let t=T(e.executable);try{let e=await M(t),n=0;for(let r of e)if(/^claude\.exe\.old\.\d+$/.test(r))try{await L(E(t,r)),n++}catch{}n>0&&d(`Cleaned up ${n} old Windows executables on startup`)}catch(e){l(e)||d(`Failed to clean up old Windows executables: ${e}`)}}try{let n=await M(e.staging),r=0;for(let i of n){let n=E(e.staging,i);try{(await I(n)).mtime.getTime()<t&&(await F(n,{recursive:!0,force:!0}),r++,d(`Cleaned up old staging directory: ${i}`))}catch{}}r>0&&d(`Cleaned up ${r} orphaned staging directories`)}catch(e){l(e)||d(`Failed to clean up staging directories: ${e}`)}if(S()){let t=Oe(e.locks);t>0&&d(`Cleaned up ${t} stale version locks`)}let n;try{n=await M(e.versions)}catch(e){l(e)||d(`Failed to readdir versions directory: ${e}`);return}let r=[],i=0;for(let a of n){let n=E(e.versions,a);if(/\.tmp\.\d+\.\d+$/.test(a)){try{(await I(n)).mtime.getTime()<t&&(await L(n),i++,d(`Cleaned up orphaned temp install file: ${a}`))}catch{}continue}try{let e=await I(n);if(!e.isFile()||process.platform!==`win32`&&e.size>0&&!(e.mode&73))continue;r.push({name:a,path:n,resolvedPath:D(n),mtime:e.mtime})}catch{}}if(i>0&&d(`Cleaned up ${i} orphaned temp install files`),r.length!==0)try{let t=process.execPath,n=new Set;t?.includes(e.versions)&&n.add(D(t));let i=await ct(e.executable);i&&n.add(i);for(let t of r){if(n.has(t.resolvedPath))continue;let r=J(e,t.resolvedPath),i=!1;if(S())i=x(r);else try{i=await se(t.resolvedPath,{stale:Z,lockfilePath:r})}catch{i=!1}i&&(n.add(t.resolvedPath),d(`Protecting locked version from cleanup: ${t.name}`))}let a=r.filter(e=>!n.has(e.resolvedPath)).sort((e,t)=>t.mtime.getTime()-e.mtime.getTime()).slice(2);if(a.length===0){r.length,n.size;return}let o=0,s=0,c=0;await Promise.all(a.map(async e=>{try{await Ye(e.path,async()=>{await L(e.path)})?o++:(s++,d(`Skipping deletion of ${e.name} - locked by another process`))}catch(t){c++,g(Error(`Failed to delete version ${e.name}: ${t}`))}})),r.length,n.size}catch(e){l(e)||g(Error(`Version cleanup failed: ${e}`))}}async function dt(){let e=[],t=C();for(let[n,r]of Object.entries(t))try{let t=await he(r);if(!t)continue;let{filtered:i,hadAlias:a}=be(t);a&&(await Pe(r,i),e.push({message:`Removed claude alias from ${r}. Run: unalias claude`,userActionRequired:!0,type:`alias`}),d(`Cleaned up claude alias from ${n} config`))}catch(t){g(t),e.push({message:`Failed to clean up ${r}: ${t}`,userActionRequired:!1,type:`error`})}return e}async function ft(e){try{let t=await v(`npm`,[`config`,`get`,`prefix`]);if(t.code!==0||!t.stdout)return{success:!1,error:`Failed to get npm global prefix`};let n=t.stdout.trim(),r=!1;async function i(e,t){try{return await L(e),d(`Manually removed ${t}: ${e}`),!0}catch{return!1}}if(U().startsWith(`win32`)){let e=E(n,`claude.cmd`),t=E(n,`claude.ps1`),a=E(n,`claude`);await i(e,`bin script`)&&(r=!0),await i(t,`PowerShell script`)&&(r=!0),await i(a,`bin executable`)&&(r=!0)}else await i(E(n,`bin`,`claude`),`bin symlink`)&&(r=!0);return r?(d(`Successfully removed ${e} manually`),{success:!0,warning:`${e} executables removed, but node_modules directory was left intact for safety. You may manually delete it later at: ${U().startsWith(`win32`)?E(n,`node_modules`,e):E(n,`lib`,`node_modules`,e)}`}):{success:!1}}catch(e){return d(`Manual removal failed: ${e}`,{level:`error`}),{success:!1,error:`Manual removal failed: ${e}`}}}async function pt(e){let{code:t,stderr:n}=await v(`npm`,[`uninstall`,`-g`,e],{cwd:process.cwd()});if(t===0)return d(`Removed global npm installation of ${e}`),{success:!0};if(n&&!n.includes(`npm ERR! code E404`)){if(n.includes(`npm error code ENOTEMPTY`)){d(`Failed to uninstall global npm package ${e}: ${n}`,{level:`error`}),d(`Attempting manual removal due to ENOTEMPTY error`);let t=await ft(e);if(t.success)return{success:!0,warning:t.warning};if(t.error)return{success:!1,error:`Failed to remove global npm installation of ${e}: ${n}. Manual removal also failed: ${t.error}`}}return d(`Failed to uninstall global npm package ${e}: ${n}`,{level:`error`}),{success:!1,error:`Failed to remove global npm installation of ${e}: ${n}`}}return{success:!1}}async function mt(){let e=[],t=[],n=0,r=await pt(`@anthropic-ai/workmate`);r.success?(n++,r.warning&&t.push(r.warning)):r.error&&e.push(r.error);let i=E(w(),`.workmate`,`local`);try{await F(i,{recursive:!0}),n++,d(`Removed local installation at ${i}`)}catch(t){l(t)||(e.push(`Failed to remove ${i}: ${t}`),d(`Failed to remove local installation: ${t}`,{level:`error`}))}return{removed:n,errors:e,warnings:t}}var Z,Q,$=e((()=>{y(),Ne(),a(),re(),m(),we(),te(),pe(),n(),o(),_(),ge(),oe(),h(),ce(),_e(),ue(),ke(),Je(),Te(),Z=10080*60*1e3,Q=null})),ht=e((()=>{$()}));export{dt as a,lt as c,X as i,at as n,$ as o,mt as r,ot as s,ht as t};
@@ -1 +1 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{ai as n}from"./src-DL3w8VPk.js";import{Hp as r,Vp as i,zp as a}from"./loadAgentsDir-DGozQu_6.js";function o(){let e=i(),t=r(),n=(0,c.useCallback)(()=>{t(e=>{let r=s(e.notifications.queue);return e.notifications.current!==null||!r?e:(u=setTimeout((e,t,n)=>{u=null,e(e=>e.notifications.current?.key===t?{...e,notifications:{queue:e.notifications.queue,current:null}}:e),n()},r.timeoutMs??l,t,r.key,n),{...e,notifications:{queue:e.notifications.queue.filter(e=>e!==r),current:r}})})},[t]),a=(0,c.useCallback)(e=>{if(e.priority===`immediate`){u&&(clearTimeout(u),u=null),u=setTimeout((e,t,n)=>{u=null,e(e=>e.notifications.current?.key===t.key?{...e,notifications:{queue:e.notifications.queue.filter(e=>!t.invalidates?.includes(e.key)),current:null}}:e),n()},e.timeoutMs??l,t,e,n),t(t=>({...t,notifications:{current:e,queue:[...t.notifications.current?[t.notifications.current]:[],...t.notifications.queue].filter(t=>t.priority!==`immediate`&&!e.invalidates?.includes(t.key))}}));return}t(r=>{if(e.fold){if(r.notifications.current?.key===e.key){let i=e.fold(r.notifications.current,e);return u&&(clearTimeout(u),u=null),u=setTimeout((e,t,n)=>{u=null,e(e=>e.notifications.current?.key===t?{...e,notifications:{queue:e.notifications.queue,current:null}}:e),n()},i.timeoutMs??l,t,i.key,n),{...r,notifications:{current:i,queue:r.notifications.queue}}}let i=r.notifications.queue.findIndex(t=>t.key===e.key);if(i!==-1){let t=e.fold(r.notifications.queue[i],e),n=[...r.notifications.queue];return n[i]=t,{...r,notifications:{current:r.notifications.current,queue:n}}}}if(!(!new Set(r.notifications.queue.map(e=>e.key)).has(e.key)&&r.notifications.current?.key!==e.key))return r;let i=r.notifications.current!==null&&e.invalidates?.includes(r.notifications.current.key);return i&&u&&(clearTimeout(u),u=null),{...r,notifications:{current:i?null:r.notifications.current,queue:[...r.notifications.queue.filter(t=>t.priority!==`immediate`&&!e.invalidates?.includes(t.key)),e]}}}),n()},[t,n]),o=(0,c.useCallback)(e=>{t(t=>{let n=t.notifications.current?.key===e,r=t.notifications.queue.some(t=>t.key===e);return!n&&!r?t:(n&&u&&(clearTimeout(u),u=null),{...t,notifications:{current:n?null:t.notifications.current,queue:t.notifications.queue.filter(t=>t.key!==e)}})}),n()},[t,n]);return(0,c.useEffect)(()=>{e.getState().notifications.queue.length>0&&n()},[]),{addNotification:a,removeNotification:o}}function s(e){if(e.length!==0)return e.reduce((e,t)=>d[t.priority]<d[e.priority]?t:e)}var c,l,u,d,f=e((()=>{c=t(n(),1),a(),l=8e3,u=null,d={immediate:0,high:1,medium:2,low:3}}));export{o as n,f as t};
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{ai as n}from"./src-WZ94ZKI3.js";import{Hh as r,Vh as i,zh as a}from"./loadAgentsDir-DR5PVAc3.js";function o(){let e=i(),t=r(),n=(0,c.useCallback)(()=>{t(e=>{let r=s(e.notifications.queue);return e.notifications.current!==null||!r?e:(u=setTimeout((e,t,n)=>{u=null,e(e=>e.notifications.current?.key===t?{...e,notifications:{queue:e.notifications.queue,current:null}}:e),n()},r.timeoutMs??l,t,r.key,n),{...e,notifications:{queue:e.notifications.queue.filter(e=>e!==r),current:r}})})},[t]),a=(0,c.useCallback)(e=>{if(e.priority===`immediate`){u&&(clearTimeout(u),u=null),u=setTimeout((e,t,n)=>{u=null,e(e=>e.notifications.current?.key===t.key?{...e,notifications:{queue:e.notifications.queue.filter(e=>!t.invalidates?.includes(e.key)),current:null}}:e),n()},e.timeoutMs??l,t,e,n),t(t=>({...t,notifications:{current:e,queue:[...t.notifications.current?[t.notifications.current]:[],...t.notifications.queue].filter(t=>t.priority!==`immediate`&&!e.invalidates?.includes(t.key))}}));return}t(r=>{if(e.fold){if(r.notifications.current?.key===e.key){let i=e.fold(r.notifications.current,e);return u&&(clearTimeout(u),u=null),u=setTimeout((e,t,n)=>{u=null,e(e=>e.notifications.current?.key===t?{...e,notifications:{queue:e.notifications.queue,current:null}}:e),n()},i.timeoutMs??l,t,i.key,n),{...r,notifications:{current:i,queue:r.notifications.queue}}}let i=r.notifications.queue.findIndex(t=>t.key===e.key);if(i!==-1){let t=e.fold(r.notifications.queue[i],e),n=[...r.notifications.queue];return n[i]=t,{...r,notifications:{current:r.notifications.current,queue:n}}}}if(!(!new Set(r.notifications.queue.map(e=>e.key)).has(e.key)&&r.notifications.current?.key!==e.key))return r;let i=r.notifications.current!==null&&e.invalidates?.includes(r.notifications.current.key);return i&&u&&(clearTimeout(u),u=null),{...r,notifications:{current:i?null:r.notifications.current,queue:[...r.notifications.queue.filter(t=>t.priority!==`immediate`&&!e.invalidates?.includes(t.key)),e]}}}),n()},[t,n]),o=(0,c.useCallback)(e=>{t(t=>{let n=t.notifications.current?.key===e,r=t.notifications.queue.some(t=>t.key===e);return!n&&!r?t:(n&&u&&(clearTimeout(u),u=null),{...t,notifications:{current:n?null:t.notifications.current,queue:t.notifications.queue.filter(t=>t.key!==e)}})}),n()},[t,n]);return(0,c.useEffect)(()=>{e.getState().notifications.queue.length>0&&n()},[]),{addNotification:a,removeNotification:o}}function s(e){if(e.length!==0)return e.reduce((e,t)=>d[t.priority]<d[e.priority]?t:e)}var c,l,u,d,f=e((()=>{c=t(n(),1),a(),l=8e3,u=null,d={immediate:0,high:1,medium:2,low:3}}));export{o as n,f as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-DaDcL9Zw.js";import{ai as t}from"./src-DL3w8VPk.js";import{t as n}from"./jsx-runtime-Bb4Xn-E0.js";import{Pt as r,vn as i}from"./state-BQ4BEGin.js";import{Fl as a,Ml as o,Pl as s}from"./loadAgentsDir-DGozQu_6.js";import{I as c,V as l}from"./debug-CRnGsZOV.js";import{Rt as u,jt as d}from"./settings-CodSADx8.js";import{d as f,h as p,m,o as h}from"./config-CWPHVTic.js";import{o as g,s as _}from"./log-DoSpAwRP.js";import{r as v,t as y}from"./managedEnv-CIWJsuty.js";var b=e(t(),1);f();var x=n();function S(e,t){let n=t/100*(e.length-1),r=Math.floor(n),i=Math.ceil(n);return r===i?e[r]:e[r]+(e[i]-e[r])*(n-r)}var C=1024;function w(){let e=new Map,t=new Map,n=new Map;return{increment(t,n=1){e.set(t,(e.get(t)??0)+n)},set(t,n){e.set(t,n)},observe(e,n){let r=t.get(e);if(r||(r={reservoir:[],count:0,sum:0,min:n,max:n},t.set(e,r)),r.count++,r.sum+=n,n<r.min&&(r.min=n),n>r.max&&(r.max=n),r.reservoir.length<C)r.reservoir.push(n);else{let e=Math.floor(Math.random()*r.count);e<C&&(r.reservoir[e]=n)}},add(e,t){let r=n.get(e);r||(r=new Set,n.set(e,r)),r.add(t)},getAll(){let r=Object.fromEntries(e);for(let[e,n]of t){if(n.count===0)continue;r[`${e}_count`]=n.count,r[`${e}_min`]=n.min,r[`${e}_max`]=n.max,r[`${e}_avg`]=n.sum/n.count;let t=[...n.reservoir].sort((e,t)=>e-t);r[`${e}_p50`]=S(t,50),r[`${e}_p95`]=S(t,95),r[`${e}_p99`]=S(t,99)}for(let[e,t]of n)r[e]=t.size;return r}}}var T=(0,b.createContext)(null);function E({store:e,children:t}){let n=(0,b.useMemo)(()=>w(),[]),r=e??n;return(0,b.useEffect)(()=>{let e=()=>{let e=r.getAll();Object.keys(e).length>0&&m(t=>({...t,lastSessionMetrics:e}))};return process.on(`exit`,e),()=>{process.off(`exit`,e)}},[r]),(0,x.jsx)(T.Provider,{value:r,children:t})}r(),f(),c(),g(),v(),d(),o();function D({newState:e,oldState:t}){let n=t.toolPermissionContext.mode,r=e.toolPermissionContext.mode;if(n!==r){let e=u(n),t=u(r);e!==t&&a({permission_mode:t}),s(r)}if(e.mainLoopModel!==t.mainLoopModel&&i(e.mainLoopModel),e.expandedView!==t.expandedView){let t=e.expandedView===`tasks`;h().showExpandedTodos!==t&&p(e=>({...e,showExpandedTodos:t}))}if(e.verbose!==t.verbose&&h().verbose!==e.verbose){let t=e.verbose;p(e=>({...e,verbose:t}))}if(e.settings!==t.settings)try{e.settings.env!==t.settings.env&&y()}catch(e){_(l(e))}}export{E as n,w as r,D as t};
1
+ import{o as e}from"./rolldown-runtime-DaDcL9Zw.js";import{ai as t}from"./src-WZ94ZKI3.js";import{t as n}from"./jsx-runtime-Bb4Xn-E0.js";import{Pt as r,vn as i}from"./state-CXY-q5gr.js";import{Fl as a,Ml as o,Pl as s}from"./loadAgentsDir-DR5PVAc3.js";import{I as c,V as l}from"./debug-kBjDaVkQ.js";import{At as u,Lt as d}from"./settings-YIDksG5Z.js";import{d as f,h as p,m,o as h}from"./config-D3K87Mm1.js";import{o as g,s as _}from"./log-DWZny1vM.js";import{r as v,t as y}from"./managedEnv-Do9fgLpk.js";var b=e(t(),1);f();var x=n();function S(e,t){let n=t/100*(e.length-1),r=Math.floor(n),i=Math.ceil(n);return r===i?e[r]:e[r]+(e[i]-e[r])*(n-r)}var C=1024;function w(){let e=new Map,t=new Map,n=new Map;return{increment(t,n=1){e.set(t,(e.get(t)??0)+n)},set(t,n){e.set(t,n)},observe(e,n){let r=t.get(e);if(r||(r={reservoir:[],count:0,sum:0,min:n,max:n},t.set(e,r)),r.count++,r.sum+=n,n<r.min&&(r.min=n),n>r.max&&(r.max=n),r.reservoir.length<C)r.reservoir.push(n);else{let e=Math.floor(Math.random()*r.count);e<C&&(r.reservoir[e]=n)}},add(e,t){let r=n.get(e);r||(r=new Set,n.set(e,r)),r.add(t)},getAll(){let r=Object.fromEntries(e);for(let[e,n]of t){if(n.count===0)continue;r[`${e}_count`]=n.count,r[`${e}_min`]=n.min,r[`${e}_max`]=n.max,r[`${e}_avg`]=n.sum/n.count;let t=[...n.reservoir].sort((e,t)=>e-t);r[`${e}_p50`]=S(t,50),r[`${e}_p95`]=S(t,95),r[`${e}_p99`]=S(t,99)}for(let[e,t]of n)r[e]=t.size;return r}}}var T=(0,b.createContext)(null);function E({store:e,children:t}){let n=(0,b.useMemo)(()=>w(),[]),r=e??n;return(0,b.useEffect)(()=>{let e=()=>{let e=r.getAll();Object.keys(e).length>0&&m(t=>({...t,lastSessionMetrics:e}))};return process.on(`exit`,e),()=>{process.off(`exit`,e)}},[r]),(0,x.jsx)(T.Provider,{value:r,children:t})}r(),f(),c(),g(),v(),u(),o();function D({newState:e,oldState:t}){let n=t.toolPermissionContext.mode,r=e.toolPermissionContext.mode;if(n!==r){let e=d(n),t=d(r);e!==t&&a({permission_mode:t}),s(r)}if(e.mainLoopModel!==t.mainLoopModel&&i(e.mainLoopModel),e.expandedView!==t.expandedView){let t=e.expandedView===`tasks`;h().showExpandedTodos!==t&&p(e=>({...e,showExpandedTodos:t}))}if(e.verbose!==t.verbose&&h().verbose!==e.verbose){let t=e.verbose;p(e=>({...e,verbose:t}))}if(e.settings!==t.settings)try{e.settings.env!==t.settings.env&&y()}catch(e){_(l(e))}}export{E as n,w as r,D as t};
@@ -0,0 +1,2 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{c as t,l as n,o as r}from"./envUtils-DZ_SvEVz.js";import{$x as i,CS as a,ES as o,Ji as s,S_ as c,WS as l,Wx as u,bS as d,b_ as f,ca as p,dy as m,et as h,hy as g,rt as _,sy as v,ua as y,vy as b,wS as x,xS as S,x_ as C}from"./loadAgentsDir-DR5PVAc3.js";import{c as w,i as T}from"./debug-kBjDaVkQ.js";import{at as E,nt as D}from"./model-D42epddJ.js";import{_n as O,bn as k,i as A,r as j,t as M,vn as N}from"./prompt-CTByhpUI.js";import{n as P,r as F}from"./client-aJ2Nr_sh.js";import{n as I,t as L}from"./openaiShared-G2-w4gJt.js";import{randomUUID as R}from"crypto";function z(e){if(t(process.env.OPENAI_ENABLE_THINKING))return!1;if(n(process.env.OPENAI_ENABLE_THINKING))return!0;let r=e.toLowerCase();return r.includes(`deepseek`)||r.includes(`mimo`)}function B(e,t){return t??(process.env.OPENAI_MAX_TOKENS&&parseInt(process.env.OPENAI_MAX_TOKENS,10)||void 0)??(process.env.WORKMATE_MAX_OUTPUT_TOKENS&&parseInt(process.env.WORKMATE_MAX_OUTPUT_TOKENS,10)||void 0)??e}function V(e){let{model:t,messages:n,tools:r,toolChoice:i,enableThinking:a,maxTokens:o,temperatureOverride:s}=e;return{model:t,messages:n,max_tokens:o,...r.length>0&&{tools:r,...i&&{tool_choice:i}},stream:!0,stream_options:{include_usage:!0},...a&&{thinking:{type:`enabled`},enable_thinking:!0,chat_template_kwargs:{thinking:!0,enable_thinking:!0}},...!a&&s!==void 0&&{temperature:s}}}var H=e((()=>{r()}));function U(e,t,n,r){if(!r||C())return e;let a=t.filter(e=>n.has(e.name)).map(M).sort().join(`
2
+ `);return a?[i({content:`<available-deferred-tools>\n${a}\n</available-deferred-tools>`,isMeta:!0}),...e]:e}function W(e){return e.type===`assistant`||e.type===`user`}function G(e){let{partialMessage:t,contentBlocks:n,tools:r,agentId:i,usage:a,stopReason:o,maxTokens:s}=e,c=[],l=Object.keys(n).sort((e,t)=>Number(e)-Number(t)).map(e=>n[Number(e)]).filter(Boolean);return l.length>0&&t&&c.push({message:{...t,content:p(l,r,i),usage:a,stop_reason:o,stop_sequence:null},requestId:void 0,type:`assistant`,uuid:R(),timestamp:new Date().toISOString()}),o===`max_tokens`&&c.push(u({content:`Output truncated: response exceeded the ${s} token limit. Set OPENAI_MAX_TOKENS or WORKMATE_MAX_OUTPUT_TOKENS to override.`,apiError:`max_output_tokens`,error:`max_output_tokens`})),c}async function*K(e,t,n,r,i){try{let s=l(i.model),u=y(e,n),d=await c(i.model,n,i.getToolPermissionContext||(async()=>O()),i.agents||[],i.querySource),f=new Set;if(d)for(let e of n)A(e)&&f.add(e.name);let p=n;d&&f.size>0&&(p=n.filter(e=>!!(!f.has(e.name)||k(e,`SearchExtraTools`))));let m=(await Promise.all(p.map(e=>_(e,{getToolPermissionContext:i.getToolPermissionContext,tools:n,agents:i.agents,allowedAgentTypes:i.allowedAgentTypes,model:i.model,deferLoading:d&&f.has(e.name)})))).filter(e=>{let t=e;return t.type!==`advisor_20260301`&&t.type!==`computer_20250124`}),h=z(s),b=o(U(u.filter(W),n,f,d),t,{enableThinking:h}),C=x(m),T=a(i.toolChoice);if(d){let e=p.filter(e=>f.has(e.name)).length;w(`[OpenAI] Tool search enabled: ${e}/${f.size} deferred tools included, total tools=${C.length}`)}else w(`[OpenAI] Tool search disabled, total tools=${C.length}`);let{upperLimit:E}=D(s),j=B(E,i.maxOutputTokensOverride);w(`[OpenAI] Calling model=${s}, messages=${b.length}, tools=${C.length}, thinking=${h}`);let M=S(await P({maxRetries:0,fetchOverride:i.fetchOverride,source:i.querySource}).chat.completions.create(V({model:s,messages:b,tools:C,toolChoice:T,enableThinking:h,maxTokens:j,temperatureOverride:i.temperatureOverride}),{signal:r}),s),N={},F=null,L=null,R={input_tokens:0,output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:0},H=0,K=Date.now();for await(let e of M){switch(e.type){case`message_start`:F=e.message,H=Date.now()-K,e.message.usage&&(R={...R,...e.message.usage});break;case`content_block_start`:{let t=e.index,n=e.content_block;n.type===`tool_use`?N[t]={...n,input:``}:n.type===`text`?N[t]={...n,text:``}:n.type===`thinking`?N[t]={...n,thinking:``,signature:``}:N[t]={...n};break}case`content_block_delta`:{let t=e.index,n=e.delta,r=N[t];if(!r)break;n.type===`text_delta`?r.text=(r.text||``)+n.text:n.type===`input_json_delta`?r.input=(r.input||``)+n.partial_json:n.type===`thinking_delta`?r.thinking=(r.thinking||``)+n.thinking:n.type===`signature_delta`&&(r.signature=n.signature);break}case`content_block_stop`:break;case`message_delta`:{let t=e.usage;t&&(R=I(R,t)),e.delta.stop_reason!=null&&(L=e.delta.stop_reason);break}case`message_stop`:if(F){for(let e of G({partialMessage:F,contentBlocks:N,tools:n,agentId:i.agentId,usage:R,stopReason:L,maxTokens:j}))yield e;F=null}R.input_tokens+R.output_tokens>0&&v(g(s,R),R,i.model);break}yield{type:`stream_event`,event:e,...e.type===`message_start`?{ttftMs:H}:void 0}}if(F)for(let e of G({partialMessage:F,contentBlocks:N,tools:n,agentId:i.agentId,usage:R,stopReason:L,maxTokens:j}))yield e}catch(e){let t=e instanceof Error?e.message:String(e);w(`[OpenAI] Error: ${t}`,{level:`error`}),yield u({content:`API Error: ${t}`,apiError:`api_error`,error:e instanceof Error?e:Error(String(e))})}}e((()=>{F(),L(),d(),s(),h(),N(),T(),m(),b(),H(),E(),f(),j()}))();export{K as queryModelOpenAI};
@@ -1 +1 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{Rn as n,ai as r,t as i}from"./src-DL3w8VPk.js";import{Bp as a,Rp as o,zp as s}from"./loadAgentsDir-DGozQu_6.js";function c(e,t=!0){let r=(0,d.useContext)(o)?.setState;(0,d.useEffect)(()=>{if(!(!t||!r))return r(t=>{if(t.activeOverlays.has(e))return t;let n=new Set(t.activeOverlays);return n.add(e),{...t,activeOverlays:n}}),()=>{r(t=>{if(!t.activeOverlays.has(e))return t;let n=new Set(t.activeOverlays);return n.delete(e),{...t,activeOverlays:n}})}},[e,t,r]),(0,d.useLayoutEffect)(()=>{if(t)return()=>n.get(process.stdout)?.invalidatePrevFrame()},[t])}function l(){return a(e=>e.activeOverlays.size>0)}function u(){return a(e=>{for(let t of e.activeOverlays)if(!f.has(t))return!0;return!1})}var d,f,p=e((()=>{d=t(r(),1),i(),s(),f=new Set([`autocomplete`])}));export{c as i,u as n,l as r,p as t};
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{Rn as n,ai as r,t as i}from"./src-WZ94ZKI3.js";import{Bh as a,Rh as o,zh as s}from"./loadAgentsDir-DR5PVAc3.js";function c(e,t=!0){let r=(0,d.useContext)(o)?.setState;(0,d.useEffect)(()=>{if(!(!t||!r))return r(t=>{if(t.activeOverlays.has(e))return t;let n=new Set(t.activeOverlays);return n.add(e),{...t,activeOverlays:n}}),()=>{r(t=>{if(!t.activeOverlays.has(e))return t;let n=new Set(t.activeOverlays);return n.delete(e),{...t,activeOverlays:n}})}},[e,t,r]),(0,d.useLayoutEffect)(()=>{if(t)return()=>n.get(process.stdout)?.invalidatePrevFrame()},[t])}function l(){return a(e=>e.activeOverlays.size>0)}function u(){return a(e=>{for(let t of e.activeOverlays)if(!f.has(t))return!0;return!1})}var d,f,p=e((()=>{d=t(r(),1),i(),s(),f=new Set([`autocomplete`])}));export{c as i,u as n,l as r,p as t};
@@ -1 +1 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{I as n,P as r,ai as i,hn as a,t as o,y as s}from"./src-DL3w8VPk.js";import{t as c}from"./jsx-runtime-Bb4Xn-E0.js";import{o as l,r as u}from"./break-cache-UUt6Dkf2.js";async function d(e,t){let n=await u(e);n.type===`text`&&t(n.value,{display:`system`})}function f({onDone:e}){let[t,i]=(0,m.useState)(0),o=(0,m.useMemo)(()=>[{label:`Status`,description:`显示 pending 标记、always 模式与打断次数`,run:()=>void d(`status`,e)},{label:`Once`,description:`仅在下一次 API 调用打断 prompt cache`,run:()=>void d(`once`,e)},{label:`Always`,description:`在每次 API 调用都打断 prompt cache`,run:()=>void d(`always`,e)},{label:`Off`,description:`关闭 always 模式并清除 pending 的一次性标记`,run:()=>void d(`off`,e)},{label:`Clear Once`,description:`取消待生效的一次性 cache 打断`,run:()=>void d(`--clear`,e)}],[e]),c=()=>{let e=o[t];e&&e.run()};return a((e,t)=>{if(t.upArrow){i(e=>Math.max(0,e-1));return}if(t.downArrow){i(e=>Math.min(o.length-1,e+1));return}t.return&&c()}),(0,h.jsx)(s,{title:`Break Cache`,subtitle:`${o.length} actions`,onCancel:()=>e(`Break-cache panel dismissed`,{display:`system`}),color:`background`,hideInputGuide:!0,children:(0,h.jsxs)(n,{flexDirection:`column`,children:[o.map((e,i)=>(0,h.jsxs)(n,{flexDirection:`row`,children:[(0,h.jsx)(r,{children:`${i===t?`›`:` `} ${e.label}`.padEnd(g)}),(0,h.jsx)(r,{dimColor:!0,children:e.description})]},e.label)),(0,h.jsx)(n,{marginTop:1,children:(0,h.jsx)(r,{dimColor:!0,children:`↑/↓ select · Enter run · Esc close`})})]})})}async function p(e,t,n){let r=n?.trim()??``;return r?(await d(r,e),null):(0,h.jsx)(f,{onDone:e})}var m,h,g;e((()=>{m=t(i(),1),o(),l(),h=c(),g=28}))();export{p as call};
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{I as n,P as r,ai as i,hn as a,t as o,y as s}from"./src-WZ94ZKI3.js";import{t as c}from"./jsx-runtime-Bb4Xn-E0.js";import{o as l,r as u}from"./break-cache-DL95nKZl.js";async function d(e,t){let n=await u(e);n.type===`text`&&t(n.value,{display:`system`})}function f({onDone:e}){let[t,i]=(0,m.useState)(0),o=(0,m.useMemo)(()=>[{label:`Status`,description:`显示 pending 标记、always 模式与打断次数`,run:()=>void d(`status`,e)},{label:`Once`,description:`仅在下一次 API 调用打断 prompt cache`,run:()=>void d(`once`,e)},{label:`Always`,description:`在每次 API 调用都打断 prompt cache`,run:()=>void d(`always`,e)},{label:`Off`,description:`关闭 always 模式并清除 pending 的一次性标记`,run:()=>void d(`off`,e)},{label:`Clear Once`,description:`取消待生效的一次性 cache 打断`,run:()=>void d(`--clear`,e)}],[e]),c=()=>{let e=o[t];e&&e.run()};return a((e,t)=>{if(t.upArrow){i(e=>Math.max(0,e-1));return}if(t.downArrow){i(e=>Math.min(o.length-1,e+1));return}t.return&&c()}),(0,h.jsx)(s,{title:`Break Cache`,subtitle:`${o.length} actions`,onCancel:()=>e(`Break-cache panel dismissed`,{display:`system`}),color:`background`,hideInputGuide:!0,children:(0,h.jsxs)(n,{flexDirection:`column`,children:[o.map((e,i)=>(0,h.jsxs)(n,{flexDirection:`row`,children:[(0,h.jsx)(r,{children:`${i===t?`›`:` `} ${e.label}`.padEnd(g)}),(0,h.jsx)(r,{dimColor:!0,children:e.description})]},e.label)),(0,h.jsx)(n,{marginTop:1,children:(0,h.jsx)(r,{dimColor:!0,children:`↑/↓ select · Enter run · Esc close`})})]})})}async function p(e,t,n){let r=n?.trim()??``;return r?(await d(r,e),null):(0,h.jsx)(f,{onDone:e})}var m,h,g;e((()=>{m=t(i(),1),o(),l(),h=c(),g=28}))();export{p as call};
@@ -0,0 +1 @@
1
+ import{i as e,r as t}from"./parser-DThLwgdM.js";t();export{e as parseCommand};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{i as t}from"./debug-CRnGsZOV.js";var n,r=e((()=>{Promise.resolve(),n=new Set([`if`,`then`,`elif`,`else`,`fi`,`while`,`until`,`for`,`in`,`do`,`done`,`case`,`esac`,`function`,`select`])}));async function i(e){return!e||e.length,null}async function a(e){return!e||e.length,null}function o(e){if(e.type===`declaration_command`){let t=e.children[0];return t&&c.has(t.text)?[t.text]:[]}let t=[],n=!1;for(let r of e.children)if(r.type!==`variable_assignment`){if(r.type===`command_name`||!n&&r.type===`word`){n=!0,t.push(r.text);continue}if(l.has(r.type))t.push(s(r.text));else if(u.has(r.type))break}return t}function s(e){return e.length>=2&&(e[0]===`"`&&e.at(-1)===`"`||e[0]===`'`&&e.at(-1)===`'`)?e.slice(1,-1):e}var c,l,u,d,f=e((()=>{t(),r(),c=new Set([`export`,`declare`,`typeset`,`readonly`,`local`,`unset`,`unsetenv`]),l=new Set([`word`,`string`,`raw_string`,`number`]),u=new Set([`command_substitution`,`process_substitution`]),d=Symbol(`parse-aborted`)}));export{a,i,o as n,n as o,f as r,r as s,d as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{i as t}from"./debug-kBjDaVkQ.js";var n,r=e((()=>{Promise.resolve(),n=new Set([`if`,`then`,`elif`,`else`,`fi`,`while`,`until`,`for`,`in`,`do`,`done`,`case`,`esac`,`function`,`select`])}));async function i(e){return!e||e.length,null}async function a(e){return!e||e.length,null}function o(e){if(e.type===`declaration_command`){let t=e.children[0];return t&&c.has(t.text)?[t.text]:[]}let t=[],n=!1;for(let r of e.children)if(r.type!==`variable_assignment`){if(r.type===`command_name`||!n&&r.type===`word`){n=!0,t.push(r.text);continue}if(l.has(r.type))t.push(s(r.text));else if(u.has(r.type))break}return t}function s(e){return e.length>=2&&(e[0]===`"`&&e.at(-1)===`"`||e[0]===`'`&&e.at(-1)===`'`)?e.slice(1,-1):e}var c,l,u,d,f=e((()=>{t(),r(),c=new Set([`export`,`declare`,`typeset`,`readonly`,`local`,`unset`,`unsetenv`]),l=new Set([`word`,`string`,`raw_string`,`number`]),u=new Set([`command_substitution`,`process_substitution`]),d=Symbol(`parse-aborted`)}));export{a,i,o as n,n as o,f as r,r as s,d as t};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{ar as t,ir as n,ni as r,ri as i}from"./state-BQ4BEGin.js";import{n as a,t as o}from"./_baseEach-DrPH_FGo.js";function s(e,t,n,r){for(var i=-1,a=e==null?0:e.length;++i<a;){var o=e[i];t(r,o,n(o),e)}return r}var c=e((()=>{}));function l(e,t,n,r){return o(e,function(e,i,a){t(r,e,n(e),a)}),r}var u=e((()=>{a()}));function d(e,t){return function(r,a){var o=i(r)?s:l,c=t?t():{};return o(r,e,n(a,2),c)}}var f=e((()=>{c(),u(),t(),r()})),p,m=e((()=>{f(),p=d(function(e,t,n){e[+!n].push(t)},function(){return[[],[]]})}));export{p as n,m as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{ar as t,ir as n,ni as r,ri as i}from"./state-CXY-q5gr.js";import{n as a,t as o}from"./_baseEach-DGbaIpJA.js";function s(e,t,n,r){for(var i=-1,a=e==null?0:e.length;++i<a;){var o=e[i];t(r,o,n(o),e)}return r}var c=e((()=>{}));function l(e,t,n,r){return o(e,function(e,i,a){t(r,e,n(e),a)}),r}var u=e((()=>{a()}));function d(e,t){return function(r,a){var o=i(r)?s:l,c=t?t():{};return o(r,e,n(a,2),c)}}var f=e((()=>{c(),u(),t(),r()})),p,m=e((()=>{f(),p=d(function(e,t,n){e[+!n].push(t)},function(){return[[],[]]})}));export{p as n,m as t};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{i as t,o as n}from"./envUtils-DfkgIdYf.js";import{I as r,R as i,c as a,i as o}from"./debug-CRnGsZOV.js";import{join as s}from"path";import{createHash as c}from"crypto";import{mkdir as l,readFile as u,readdir as d,stat as f,unlink as p,writeFile as m}from"fs/promises";function h(){return s(t(),x)}function g(e){return c(`sha256`).update(e).digest(`hex`).slice(0,16)}function _(e){return s(h(),`${e}.txt`)}async function v(e,t){try{await l(h(),{recursive:!0});let n=_(e);await m(n,t,{encoding:`utf8`,mode:384}),a(`Stored paste ${e} to ${n}`)}catch(e){a(`Failed to store paste: ${e}`)}}async function y(e){try{return await u(_(e),{encoding:`utf8`})}catch(t){return i(t)||a(`Failed to retrieve paste ${e}: ${t}`),null}}async function b(e){let t=h(),n;try{n=await d(t)}catch{return}let r=e.getTime();for(let e of n){if(!e.endsWith(`.txt`))continue;let n=s(t,e);try{(await f(n)).mtimeMs<r&&(await p(n),a(`Cleaned up old paste: ${n}`))}catch{}}}var x,S=e((()=>{o(),n(),r(),x=`paste-cache`}));export{v as a,y as i,g as n,S as r,b as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{i as t,o as n}from"./envUtils-DZ_SvEVz.js";import{I as r,R as i,c as a,i as o}from"./debug-kBjDaVkQ.js";import{join as s}from"path";import{createHash as c}from"crypto";import{mkdir as l,readFile as u,readdir as d,stat as f,unlink as p,writeFile as m}from"fs/promises";function h(){return s(t(),x)}function g(e){return c(`sha256`).update(e).digest(`hex`).slice(0,16)}function _(e){return s(h(),`${e}.txt`)}async function v(e,t){try{await l(h(),{recursive:!0});let n=_(e);await m(n,t,{encoding:`utf8`,mode:384}),a(`Stored paste ${e} to ${n}`)}catch(e){a(`Failed to store paste: ${e}`)}}async function y(e){try{return await u(_(e),{encoding:`utf8`})}catch(t){return i(t)||a(`Failed to retrieve paste ${e}: ${t}`),null}}async function b(e){let t=h(),n;try{n=await d(t)}catch{return}let r=e.getTime();for(let e of n){if(!e.endsWith(`.txt`))continue;let n=s(t,e);try{(await f(n)).mtimeMs<r&&(await p(n),a(`Cleaned up old paste: ${n}`))}catch{}}}var x,S=e((()=>{o(),n(),r(),x=`paste-cache`}));export{v as a,y as i,g as n,S as r,b as t};
@@ -1,3 +1,3 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./figures-5ThXQEtq.js";import{I as i,P as a,Wt as o,Xn as s,a as c,ai as l,di as u,fi as d,hn as f,k as p,kt as m,n as h,o as ee,ot as g,r as te,s as ne,t as _,x as re,y as v}from"./src-DL3w8VPk.js";import{t as y}from"./jsx-runtime-Bb4Xn-E0.js";import{Pt as ie,q as b}from"./state-BQ4BEGin.js";import{Bp as ae,Cb as x,DC as S,H as C,Hp as oe,I as se,Ji as w,L as ce,Mf as T,Mm as E,Nm as le,R as ue,V as D,gS as O,jf as k,kC as de,kb as fe,km as pe,z as me,zp as A}from"./loadAgentsDir-DGozQu_6.js";import{C as j,x as M}from"./debug-CRnGsZOV.js";import{B as N,R as P,V as F,a as I,h as L,ln as R,rn as z}from"./settings-CodSADx8.js";import{l as B,o as he}from"./stringUtils-Bu_lJH5c.js";import{n as ge,t as _e}from"./TextInput-Cev5Awdd.js";import{n as ve,t as ye}from"./useExitOnCtrlCDWithKeybindings-DWRFdFoU.js";import{n as V,t as H}from"./select-Fq6g2Ejk.js";import{n as be,t as xe}from"./AddWorkspaceDirectory-Y5S_lMjD.js";import{t as Se}from"./SearchBox-C9xxQzh1.js";import{n as Ce,t as we}from"./useSearchInput-B_mY9wBq.js";import{n as Te,t as Ee}from"./shadowedRuleDetection-CTnYVrmP.js";function De(){return U}var U,Oe=e((()=>{U=[]}));function ke({ruleValue:e}){switch(e.toolName){case k.name:return e.ruleContent?e.ruleContent.endsWith(`:*`)?(0,W.jsxs)(a,{dimColor:!0,children:[`Any Bash command starting with `,(0,W.jsx)(a,{bold:!0,children:e.ruleContent.slice(0,-2)})]}):(0,W.jsxs)(a,{dimColor:!0,children:[`The Bash command `,(0,W.jsx)(a,{bold:!0,children:e.ruleContent})]}):(0,W.jsx)(a,{dimColor:!0,children:`Any Bash command`});default:return e.ruleContent?null:(0,W.jsxs)(a,{dimColor:!0,children:[`Any use of the `,(0,W.jsx)(a,{bold:!0,children:e.toolName}),` tool`]})}}var W,Ae=e((()=>{_(),T(),W=y()}));function je(e){switch(e){case`localSettings`:return{label:`Project settings (local)`,description:`Saved in ${I(`localSettings`)}`,value:e};case`projectSettings`:return{label:`Project settings`,description:`Checked in at ${I(`projectSettings`)}`,value:e};case`userSettings`:return{label:`User settings`,description:`Saved in at ~/.workmate/settings.json`,value:e}}}function Me({onAddRules:e,onCancel:t,ruleValues:n,ruleBehavior:r,initialContext:o,setToolPermissionContext:s}){let c=z.map(je),l=(0,Ne.useCallback)(i=>{if(i===`cancel`){t();return}else if(z.includes(i)){let t=i,a=pe(o,{type:`addRules`,rules:n,behavior:r,destination:t});le({type:`addRules`,rules:n,behavior:r,destination:t}),s(a);let c=n.map(e=>({ruleValue:e,ruleBehavior:r,source:t})),l=Ee(a,{sandboxAutoAllowEnabled:S.isSandboxingEnabled()&&S.isAutoAllowBashIfSandboxedEnabled()}).filter(e=>n.some(t=>t.toolName===e.rule.ruleValue.toolName&&t.ruleContent===e.rule.ruleValue.ruleContent));e(c,l.length>0?l:void 0)}},[e,t,n,r,o,s]);return(0,G.jsxs)(v,{title:`Add ${r} permission ${B(n.length,`rule`)}`,onCancel:t,color:`permission`,children:[(0,G.jsx)(i,{flexDirection:`column`,paddingX:2,children:n.map(e=>(0,G.jsxs)(i,{flexDirection:`column`,children:[(0,G.jsx)(a,{bold:!0,children:F(e)}),(0,G.jsx)(ke,{ruleValue:e})]},F(e)))}),(0,G.jsxs)(i,{flexDirection:`column`,marginY:1,children:[(0,G.jsx)(a,{children:n.length===1?`Where should this rule be saved?`:`Where should these rules be saved?`}),(0,G.jsx)(H,{options:c,onChange:l})]})]})}var Ne,G,Pe=e((()=>{Ne=t(l(),1),V(),_(),E(),P(),Te(),de(),R(),L(),he(),Ae(),G=y()}));function Fe({onCancel:e,onSubmit:t,ruleBehavior:n}){let[s,c]=(0,Ie.useState)(``),[l,u]=(0,Ie.useState)(0),d=ve();o(`confirm:no`,e,{context:`Settings`});let{columns:f}=g(),p=f-6;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(i,{flexDirection:`column`,gap:1,borderStyle:`round`,paddingLeft:1,paddingRight:1,borderColor:`permission`,children:[(0,K.jsxs)(a,{bold:!0,color:`permission`,children:[`Add `,n,` permission rule`]}),(0,K.jsxs)(i,{flexDirection:`column`,children:[(0,K.jsxs)(a,{children:[`Permission rules are a tool name, optionally followed by a specifier in parentheses.`,(0,K.jsx)(m,{}),`e.g., `,(0,K.jsx)(a,{bold:!0,children:F({toolName:k.name})}),(0,K.jsx)(a,{bold:!1,children:` or `}),(0,K.jsx)(a,{bold:!0,children:F({toolName:k.name,ruleContent:`ls:*`})})]}),(0,K.jsx)(i,{borderDimColor:!0,borderStyle:`round`,marginY:1,paddingLeft:1,children:(0,K.jsx)(_e,{showCursor:!0,value:s,onChange:c,onSubmit:e=>{let r=e.trim();r.length!==0&&t(N(r),n)},placeholder:`Enter permission rule${r.ellipsis}`,columns:p,cursorOffset:l,onChangeCursorOffset:u})})]})]}),(0,K.jsx)(i,{marginLeft:3,children:d.pending?(0,K.jsxs)(a,{dimColor:!0,children:[`Press `,d.keyName,` again to exit`]}):(0,K.jsx)(a,{dimColor:!0,children:`Enter to submit · Esc to cancel`})})]})}var Ie,K,Le=e((()=>{n(),Ie=t(l(),1),ge(),ye(),fe(),_(),x(),T(),P(),K=y()}));function Re({onHeaderFocusChange:e,onStateChange:t}){let{headerFocused:n,focusHeader:r}=c();(0,q.useEffect)(()=>{e?.(n)},[n,e]);let[o]=(0,q.useState)(()=>De()),[s,l]=(0,q.useState)(()=>new Set),[u,d]=(0,q.useState)(()=>new Set),[p,m]=(0,q.useState)(0);(0,q.useEffect)(()=>{t({approved:s,retry:u,denials:o})},[s,u,o,t]);let h=(0,q.useCallback)(e=>{let t=Number(e);l(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n})},[]),ee=(0,q.useCallback)(e=>{m(Number(e))},[]);if(f((e,t)=>{e===`r`&&(d(e=>{let t=new Set(e);return t.has(p)?t.delete(p):t.add(p),t}),l(e=>{if(e.has(p))return e;let t=new Set(e);return t.add(p),t}))},{isActive:o.length>0}),o.length===0)return(0,J.jsx)(a,{dimColor:!0,children:`No recent denials. Commands denied by the auto mode classifier will appear here.`});let g=o.map((e,t)=>{let n=s.has(t),r=u.has(t)?` (retry)`:``;return{label:(0,J.jsxs)(a,{children:[(0,J.jsx)(ne,{status:n?`success`:`error`,withSpace:!0}),e.display,(0,J.jsx)(a,{dimColor:!0,children:r})]}),value:String(t)}});return(0,J.jsxs)(i,{flexDirection:`column`,children:[(0,J.jsx)(a,{children:`Commands recently denied by the auto mode classifier.`}),(0,J.jsx)(i,{marginTop:1,children:(0,J.jsx)(H,{options:g,onChange:h,onFocus:ee,visibleOptionCount:Math.min(10,g.length),isDisabled:n,onUpFromFirstItem:r})})]})}var q,J,ze=e((()=>{q=t(l(),1),_(),Oe(),V(),J=y()}));function Be({directoryPath:e,onRemove:t,onCancel:n,permissionContext:r,setPermissionContext:o}){let s=(0,Ve.useCallback)(()=>{o(pe(r,{type:`removeDirectories`,directories:[e],destination:`session`})),t()},[e,r,o,t]),c=(0,Ve.useCallback)(e=>{e===`yes`?s():n()},[s,n]);return(0,Y.jsxs)(v,{title:`Remove directory from workspace?`,onCancel:n,color:`error`,children:[(0,Y.jsx)(i,{marginX:2,flexDirection:`column`,children:(0,Y.jsx)(a,{bold:!0,children:e})}),(0,Y.jsx)(a,{children:`Work Mate will no longer have access to files in this directory.`}),(0,Y.jsx)(H,{onChange:c,onCancel:n,options:[{label:`Yes`,value:`yes`},{label:`No`,value:`no`}]})]})}var Ve,Y,He=e((()=>{Ve=t(l(),1),V(),_(),E(),Y=y()}));function Ue({onExit:e,toolPermissionContext:t,onRequestAddDirectory:n,onRequestRemoveDirectory:o,onHeaderFocusChange:s}){let{headerFocused:l,focusHeader:u}=c();(0,X.useEffect)(()=>{s?.(l)},[l,s]);let d=We.useMemo(()=>Array.from(t.additionalWorkingDirectories.keys()).map(e=>({path:e,isCurrent:!1,isDeletable:!0})),[t.additionalWorkingDirectories]),f=(0,X.useCallback)(e=>{if(e===`add-directory`){n();return}let t=d.find(t=>t.path===e);t?.isDeletable&&o(t.path)},[d,n,o]),p=(0,X.useCallback)(()=>e(`Workspace dialog dismissed`,{display:`system`}),[e]),m=We.useMemo(()=>{let e=d.map(e=>({label:e.path,value:e.path}));return e.push({label:`Add directory${r.ellipsis}`,value:`add-directory`}),e},[d]);return(0,Z.jsxs)(i,{flexDirection:`column`,marginBottom:1,children:[(0,Z.jsxs)(i,{flexDirection:`row`,marginTop:1,marginLeft:2,gap:1,children:[(0,Z.jsx)(a,{children:`- ${b()}`}),(0,Z.jsx)(a,{dimColor:!0,children:`(Original working directory)`})]}),(0,Z.jsx)(H,{options:m,onChange:f,onCancel:p,visibleOptionCount:Math.min(10,m.length),onUpFromFirstItem:u,isDisabled:l})]})}var We,X,Z,Ge=e((()=>{n(),We=t(l(),1),X=t(l(),1),ie(),V(),_(),Z=y()}));function Ke({rule:e}){return(0,$.jsx)(a,{dimColor:!0,children:`From ${C(e.source)}`})}function qe(e){switch(e){case`allow`:return`allowed`;case`deny`:return`denied`;case`ask`:return`ask`}}function Je({rule:e,onDelete:t,onCancel:n}){let r=ve();o(`confirm:no`,n,{context:`Confirmation`});let s=(0,$.jsxs)(i,{flexDirection:`column`,marginX:2,children:[(0,$.jsx)(a,{bold:!0,children:F(e.ruleValue)}),(0,$.jsx)(ke,{ruleValue:e.ruleValue}),(0,$.jsx)(Ke,{rule:e})]}),c=(0,$.jsx)(i,{marginLeft:3,children:r.pending?(0,$.jsxs)(a,{dimColor:!0,children:[`Press `,r.keyName,` again to exit`]}):(0,$.jsx)(a,{dimColor:!0,children:`Esc to cancel`})});return e.source===`policySettings`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(i,{flexDirection:`column`,gap:1,borderStyle:`round`,paddingLeft:1,paddingRight:1,borderColor:`permission`,children:[(0,$.jsx)(a,{bold:!0,color:`permission`,children:`Rule details`}),s,(0,$.jsxs)(a,{italic:!0,children:[`This rule is configured by managed settings and cannot be modified.`,`
2
- `,`Contact your system administrator for more information.`]})]}),c]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(i,{flexDirection:`column`,gap:1,borderStyle:`round`,paddingLeft:1,paddingRight:1,borderColor:`error`,children:[(0,$.jsxs)(a,{bold:!0,color:`error`,children:[`Delete `,qe(e.ruleBehavior),` tool?`]}),s,(0,$.jsx)(a,{children:`Are you sure you want to delete this permission rule?`}),(0,$.jsx)(H,{onChange:e=>e===`yes`?t():n(),onCancel:n,options:[{label:`Yes`,value:`yes`},{label:`No`,value:`no`}]})]}),c]})}function Ye(e){let{options:t,searchQuery:n,isSearchMode:r,isFocused:a,onSelect:o,onCancel:s,lastFocusedRuleKey:l,cursorOffset:u,onHeaderFocusChange:d}=e,f=ee(),{headerFocused:m,focusHeader:h,blurHeader:g}=c();return(0,Q.useEffect)(()=>{r&&m&&g()},[r,m,g]),(0,Q.useEffect)(()=>{d?.(m)},[m,d]),(0,$.jsxs)(i,{flexDirection:`column`,children:[(0,$.jsx)(i,{marginBottom:1,flexDirection:`column`,children:(0,$.jsx)(p,{query:n,isFocused:r&&!m,isTerminalFocused:a,width:f,cursorOffset:u})}),(0,$.jsx)(H,{options:t,onChange:o,onCancel:s,visibleOptionCount:Math.min(10,t.length),isDisabled:r||m,defaultFocusValue:l,onUpFromFirstItem:h})]})}function Xe({tab:e,getRulesOptions:t,handleToolSelect:n,...r}){return(0,$.jsxs)(i,{flexDirection:`column`,flexShrink:e===`allow`?0:void 0,children:[(0,$.jsx)(a,{children:{allow:`Work Mate won't ask before using allowed tools.`,ask:`Work Mate will always ask for confirmation before using these tools.`,deny:`Work Mate will always reject requests to use denied tools.`}[e]}),(0,$.jsx)(Ye,{options:t(e,r.searchQuery).options,onSelect:t=>n(t,e),...r})]})}function Ze({onExit:e,initialTab:t,onRetryDenials:n}){let c=De().length>0,l=t??(c?`recent`:`allow`),[d,f]=(0,Q.useState)([]),p=ae(e=>e.toolPermissionContext),m=oe(),ee=s(),g=(0,Q.useRef)({approved:new Set,retry:new Set,denials:[]}),ne=(0,Q.useCallback)(e=>{g.current=e},[]),[_,v]=(0,Q.useState)(),[y,ie]=(0,Q.useState)(),[b,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(null),[w,T]=(0,Q.useState)(!1),[E,D]=(0,Q.useState)(null),[O,k]=(0,Q.useState)(!1),[de,fe]=(0,Q.useState)(!0),A=(0,Q.useCallback)(e=>{fe(e)},[]),M=(0,Q.useMemo)(()=>{let e=new Map;return ce(p).forEach(t=>{e.set(j(t),t)}),e},[p]),N=(0,Q.useMemo)(()=>{let e=new Map;return me(p).forEach(t=>{e.set(j(t),t)}),e},[p]),P=(0,Q.useMemo)(()=>{let e=new Map;return ue(p).forEach(t=>{e.set(j(t),t)}),e},[p]),I=(0,Q.useCallback)((e,t=``)=>{let n=(()=>{switch(e){case`allow`:return M;case`deny`:return N;case`ask`:return P;case`workspace`:case`recent`:return new Map}})(),i=[];e!==`workspace`&&e!==`recent`&&!t&&i.push({label:`Add a new rule${r.ellipsis}`,value:`add-new-rule`});let a=Array.from(n.keys()).sort((e,t)=>{let r=n.get(e),i=n.get(t);if(r&&i){let e=F(r.ruleValue).toLowerCase(),t=F(i.ruleValue).toLowerCase();return e.localeCompare(t)}return 0}),o=t.toLowerCase();for(let e of a){let r=n.get(e);if(r){let n=F(r.ruleValue);if(t&&!n.toLowerCase().includes(o))continue;i.push({label:n,value:e})}}return{options:i,rulesByKey:n}},[M,N,P]),L=ve(),R=!_&&!b&&!S&&!w&&!E,{query:z,setQuery:B,cursorOffset:he}=Ce({isActive:R&&O,onExit:()=>{k(!1)}}),ge=(0,Q.useCallback)(e=>{R&&(O||e.ctrl||e.meta||(e.key===`/`?(e.preventDefault(),k(!0),B(``)):e.key.length===1&&e.key!==`j`&&e.key!==`k`&&e.key!==`m`&&e.key!==`i`&&e.key!==`r`&&e.key!==` `&&(e.preventDefault(),k(!0),B(e.key))))},[R,O,B]),_e=(0,Q.useCallback)((e,t)=>{let{rulesByKey:n}=I(t);if(e===`add-new-rule`){x(t);return}else{v(n.get(e));return}},[I]),ye=(0,Q.useCallback)(()=>{x(null)},[]),V=(0,Q.useCallback)((e,t)=>{C({ruleValue:e,ruleBehavior:t}),x(null)},[]),H=(0,Q.useCallback)((e,t)=>{C(null);for(let t of e)f(e=>[...e,`Added ${t.ruleBehavior} rule ${u.bold(F(t.ruleValue))}`]);if(t&&t.length>0)for(let e of t){let t=e.shadowType===`deny`?`blocked`:`shadowed`;f(n=>[...n,u.yellow(`${r.warning} Warning: ${F(e.rule.ruleValue)} is ${t}`),u.dim(` ${e.reason}`),u.dim(` Fix: ${e.fix}`)])}},[]),be=(0,Q.useCallback)(()=>{C(null)},[]),Se=(0,Q.useCallback)(()=>T(!0),[]),we=(0,Q.useCallback)(e=>D(e),[]),Te=(0,Q.useCallback)(()=>{let t=g.current,r=e=>Array.from(e).map(e=>t.denials[e]).filter(e=>e!==void 0),i=r(t.retry);if(i.length>0){let t=i.map(e=>e.display);n?.(t),e(void 0,{shouldQuery:!0,metaMessages:[`Permission granted for: ${t.join(`, `)}. You may now retry ${t.length===1?`this command`:`these commands`} if you would like.`]});return}let a=r(t.approved);a.length>0||d.length>0?e([...a.length>0?[`Approved ${a.map(e=>u.bold(e.display)).join(`, `)}`]:[],...d].join(`
3
- `)):e(`Permissions dialog dismissed`,{display:`system`})},[d,e,n]);o(`confirm:no`,Te,{context:`Settings`,isActive:R&&!O});let Ee=()=>{if(!_)return;let{options:e}=I(_.ruleBehavior),t=j(_),n=e.filter(e=>e.value!==`add-new-rule`).map(e=>e.value),r=n.indexOf(t),i;r!==-1&&(r<n.length-1?i=n[r+1]:r>0&&(i=n[r-1])),ie(i),se({rule:_,initialContext:p,setToolPermissionContext(e){m(t=>({...t,toolPermissionContext:e}))}}),f(e=>[...e,`Deleted ${_.ruleBehavior} rule ${u.bold(F(_.ruleValue))}`]),v(void 0)};if(_)return(0,$.jsx)(Je,{rule:_,onDelete:Ee,onCancel:()=>v(void 0)});if(b&&b!==`workspace`&&b!==`recent`)return(0,$.jsx)(Fe,{onCancel:ye,onSubmit:V,ruleBehavior:b});if(S)return(0,$.jsx)(Me,{onAddRules:H,onCancel:be,ruleValues:[S.ruleValue],ruleBehavior:S.ruleBehavior,initialContext:p,setToolPermissionContext:e=>{m(t=>({...t,toolPermissionContext:e}))}});if(w)return(0,$.jsx)(xe,{onAddDirectory:(e,t)=>{let n={type:`addDirectories`,directories:[e],destination:t?`localSettings`:`session`},r=pe(p,n);m(e=>({...e,toolPermissionContext:r})),t&&le(n),f(n=>[...n,`Added directory ${u.bold(e)} to workspace${t?` and saved to local settings`:` for this session`}`]),T(!1)},onCancel:()=>T(!1),permissionContext:p});if(E)return(0,$.jsx)(Be,{directoryPath:E,onRemove:()=>{f(e=>[...e,`Removed directory ${u.bold(E)} from workspace`]),D(null)},onCancel:()=>D(null),permissionContext:p,setPermissionContext:e=>{m(t=>({...t,toolPermissionContext:e}))}});let U={searchQuery:z,isSearchMode:O,isFocused:ee,onCancel:Te,lastFocusedRuleKey:y,cursorOffset:he,getRulesOptions:I,handleToolSelect:_e,onHeaderFocusChange:A};return(0,$.jsx)(i,{flexDirection:`column`,onKeyDown:ge,children:(0,$.jsxs)(re,{color:`permission`,children:[(0,$.jsxs)(te,{title:`Permissions:`,color:`permission`,defaultTab:l,hidden:!!_||!!b||!!S||w||!!E,initialHeaderFocused:!c,navFromContent:!O,children:[(0,$.jsx)(h,{id:`recent`,title:`Recently denied`,children:(0,$.jsx)(Re,{onHeaderFocusChange:A,onStateChange:ne})}),(0,$.jsx)(h,{id:`allow`,title:`Allow`,children:(0,$.jsx)(Xe,{tab:`allow`,...U})}),(0,$.jsx)(h,{id:`ask`,title:`Ask`,children:(0,$.jsx)(Xe,{tab:`ask`,...U})}),(0,$.jsx)(h,{id:`deny`,title:`Deny`,children:(0,$.jsx)(Xe,{tab:`deny`,...U})}),(0,$.jsx)(h,{id:`workspace`,title:`Workspace`,children:(0,$.jsxs)(i,{flexDirection:`column`,children:[(0,$.jsx)(a,{children:`Work Mate can read files in the workspace, and make edits when auto-accept edits is on.`}),(0,$.jsx)(Ue,{onExit:e,toolPermissionContext:p,onRequestAddDirectory:Se,onRequestRemoveDirectory:we,onHeaderFocusChange:A})]})})]}),(0,$.jsx)(i,{marginTop:1,paddingLeft:1,children:(0,$.jsx)(a,{dimColor:!0,children:L.pending?(0,$.jsxs)($.Fragment,{children:[`Press `,L.keyName,` again to exit`]}):de?(0,$.jsx)($.Fragment,{children:`←/→ tab switch · ↓ return · Esc cancel`}):O?(0,$.jsx)($.Fragment,{children:`Type to filter · Enter/↓ select · ↑ tabs · Esc clear`}):c&&l===`recent`?(0,$.jsx)($.Fragment,{children:`Enter approve · r retry · ↑↓ navigate · ←/→ switch · Esc cancel`}):(0,$.jsx)($.Fragment,{children:`↑↓ navigate · Enter select · Type to search · ←/→ switch · Esc cancel`})})})]})})}var Q,$,Qe=e((()=>{d(),n(),Q=t(l(),1),A(),E(),V(),ye(),we(),_(),x(),Oe(),P(),D(),M(),Se(),Pe(),be(),Ae(),Le(),ze(),He(),Ge(),$=y()})),$e,et;e((()=>{Qe(),w(),$e=y(),et=async(e,t)=>(0,$e.jsx)(Ze,{onExit:e,onRetryDenials:e=>{t.setMessages(t=>[...t,O(e)])}})}))();export{et as call};
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./figures-5ThXQEtq.js";import{I as i,P as a,Wt as o,Xn as s,a as c,ai as l,di as u,fi as d,hn as f,k as p,kt as m,n as h,o as ee,ot as g,r as te,s as ne,t as _,x as re,y as v}from"./src-WZ94ZKI3.js";import{t as y}from"./jsx-runtime-Bb4Xn-E0.js";import{Pt as ie,q as b}from"./state-CXY-q5gr.js";import{Bh as ae,H as x,Hh as oe,I as se,Ji as S,Jx as C,L as ce,Mg as w,Ng as le,R as ue,V as T,_m as E,aC as D,gm as O,kg as de,sC as k,sb as fe,tb as pe,z as me,zh as A}from"./loadAgentsDir-DR5PVAc3.js";import{C as j,x as M}from"./debug-kBjDaVkQ.js";import{B as N,L as P,a as F,cn as I,m as L,nn as R,z as he}from"./settings-YIDksG5Z.js";import{l as z,o as ge}from"./stringUtils-D_xPrwGQ.js";import{n as _e,t as ve}from"./TextInput-BboKIug2.js";import{n as B,t as ye}from"./useExitOnCtrlCDWithKeybindings-BgJrnuDl.js";import{n as V,t as H}from"./select-FrwoTzuc.js";import{n as be,t as xe}from"./AddWorkspaceDirectory-mS8iUoWY.js";import{t as Se}from"./SearchBox-DQBLKyzJ.js";import{n as Ce,t as we}from"./useSearchInput-BITV_Txn.js";import{n as Te,t as Ee}from"./shadowedRuleDetection-D6R2OeoH.js";function De(){return U}var U,Oe=e((()=>{U=[]}));function ke({ruleValue:e}){switch(e.toolName){case O.name:return e.ruleContent?e.ruleContent.endsWith(`:*`)?(0,W.jsxs)(a,{dimColor:!0,children:[`Any Bash command starting with `,(0,W.jsx)(a,{bold:!0,children:e.ruleContent.slice(0,-2)})]}):(0,W.jsxs)(a,{dimColor:!0,children:[`The Bash command `,(0,W.jsx)(a,{bold:!0,children:e.ruleContent})]}):(0,W.jsx)(a,{dimColor:!0,children:`Any Bash command`});default:return e.ruleContent?null:(0,W.jsxs)(a,{dimColor:!0,children:[`Any use of the `,(0,W.jsx)(a,{bold:!0,children:e.toolName}),` tool`]})}}var W,Ae=e((()=>{_(),E(),W=y()}));function je(e){switch(e){case`localSettings`:return{label:`Project settings (local)`,description:`Saved in ${F(`localSettings`)}`,value:e};case`projectSettings`:return{label:`Project settings`,description:`Checked in at ${F(`projectSettings`)}`,value:e};case`userSettings`:return{label:`User settings`,description:`Saved in at ~/.workmate/settings.json`,value:e}}}function Me({onAddRules:e,onCancel:t,ruleValues:n,ruleBehavior:r,initialContext:o,setToolPermissionContext:s}){let c=R.map(je),l=(0,Ne.useCallback)(i=>{if(i===`cancel`){t();return}else if(R.includes(i)){let t=i,a=de(o,{type:`addRules`,rules:n,behavior:r,destination:t});le({type:`addRules`,rules:n,behavior:r,destination:t}),s(a);let c=n.map(e=>({ruleValue:e,ruleBehavior:r,source:t})),l=Ee(a,{sandboxAutoAllowEnabled:D.isSandboxingEnabled()&&D.isAutoAllowBashIfSandboxedEnabled()}).filter(e=>n.some(t=>t.toolName===e.rule.ruleValue.toolName&&t.ruleContent===e.rule.ruleValue.ruleContent));e(c,l.length>0?l:void 0)}},[e,t,n,r,o,s]);return(0,G.jsxs)(v,{title:`Add ${r} permission ${z(n.length,`rule`)}`,onCancel:t,color:`permission`,children:[(0,G.jsx)(i,{flexDirection:`column`,paddingX:2,children:n.map(e=>(0,G.jsxs)(i,{flexDirection:`column`,children:[(0,G.jsx)(a,{bold:!0,children:N(e)}),(0,G.jsx)(ke,{ruleValue:e})]},N(e)))}),(0,G.jsxs)(i,{flexDirection:`column`,marginY:1,children:[(0,G.jsx)(a,{children:n.length===1?`Where should this rule be saved?`:`Where should these rules be saved?`}),(0,G.jsx)(H,{options:c,onChange:l})]})]})}var Ne,G,Pe=e((()=>{Ne=t(l(),1),V(),_(),w(),P(),Te(),k(),I(),L(),ge(),Ae(),G=y()}));function Fe({onCancel:e,onSubmit:t,ruleBehavior:n}){let[s,c]=(0,Ie.useState)(``),[l,u]=(0,Ie.useState)(0),d=B();o(`confirm:no`,e,{context:`Settings`});let{columns:f}=g(),p=f-6;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(i,{flexDirection:`column`,gap:1,borderStyle:`round`,paddingLeft:1,paddingRight:1,borderColor:`permission`,children:[(0,K.jsxs)(a,{bold:!0,color:`permission`,children:[`Add `,n,` permission rule`]}),(0,K.jsxs)(i,{flexDirection:`column`,children:[(0,K.jsxs)(a,{children:[`Permission rules are a tool name, optionally followed by a specifier in parentheses.`,(0,K.jsx)(m,{}),`e.g., `,(0,K.jsx)(a,{bold:!0,children:N({toolName:O.name})}),(0,K.jsx)(a,{bold:!1,children:` or `}),(0,K.jsx)(a,{bold:!0,children:N({toolName:O.name,ruleContent:`ls:*`})})]}),(0,K.jsx)(i,{borderDimColor:!0,borderStyle:`round`,marginY:1,paddingLeft:1,children:(0,K.jsx)(ve,{showCursor:!0,value:s,onChange:c,onSubmit:e=>{let r=e.trim();r.length!==0&&t(he(r),n)},placeholder:`Enter permission rule${r.ellipsis}`,columns:p,cursorOffset:l,onChangeCursorOffset:u})})]})]}),(0,K.jsx)(i,{marginLeft:3,children:d.pending?(0,K.jsxs)(a,{dimColor:!0,children:[`Press `,d.keyName,` again to exit`]}):(0,K.jsx)(a,{dimColor:!0,children:`Enter to submit · Esc to cancel`})})]})}var Ie,K,Le=e((()=>{n(),Ie=t(l(),1),_e(),ye(),fe(),_(),pe(),E(),P(),K=y()}));function Re({onHeaderFocusChange:e,onStateChange:t}){let{headerFocused:n,focusHeader:r}=c();(0,q.useEffect)(()=>{e?.(n)},[n,e]);let[o]=(0,q.useState)(()=>De()),[s,l]=(0,q.useState)(()=>new Set),[u,d]=(0,q.useState)(()=>new Set),[p,m]=(0,q.useState)(0);(0,q.useEffect)(()=>{t({approved:s,retry:u,denials:o})},[s,u,o,t]);let h=(0,q.useCallback)(e=>{let t=Number(e);l(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n})},[]),ee=(0,q.useCallback)(e=>{m(Number(e))},[]);if(f((e,t)=>{e===`r`&&(d(e=>{let t=new Set(e);return t.has(p)?t.delete(p):t.add(p),t}),l(e=>{if(e.has(p))return e;let t=new Set(e);return t.add(p),t}))},{isActive:o.length>0}),o.length===0)return(0,J.jsx)(a,{dimColor:!0,children:`No recent denials. Commands denied by the auto mode classifier will appear here.`});let g=o.map((e,t)=>{let n=s.has(t),r=u.has(t)?` (retry)`:``;return{label:(0,J.jsxs)(a,{children:[(0,J.jsx)(ne,{status:n?`success`:`error`,withSpace:!0}),e.display,(0,J.jsx)(a,{dimColor:!0,children:r})]}),value:String(t)}});return(0,J.jsxs)(i,{flexDirection:`column`,children:[(0,J.jsx)(a,{children:`Commands recently denied by the auto mode classifier.`}),(0,J.jsx)(i,{marginTop:1,children:(0,J.jsx)(H,{options:g,onChange:h,onFocus:ee,visibleOptionCount:Math.min(10,g.length),isDisabled:n,onUpFromFirstItem:r})})]})}var q,J,ze=e((()=>{q=t(l(),1),_(),Oe(),V(),J=y()}));function Be({directoryPath:e,onRemove:t,onCancel:n,permissionContext:r,setPermissionContext:o}){let s=(0,Ve.useCallback)(()=>{o(de(r,{type:`removeDirectories`,directories:[e],destination:`session`})),t()},[e,r,o,t]),c=(0,Ve.useCallback)(e=>{e===`yes`?s():n()},[s,n]);return(0,Y.jsxs)(v,{title:`Remove directory from workspace?`,onCancel:n,color:`error`,children:[(0,Y.jsx)(i,{marginX:2,flexDirection:`column`,children:(0,Y.jsx)(a,{bold:!0,children:e})}),(0,Y.jsx)(a,{children:`Work Mate will no longer have access to files in this directory.`}),(0,Y.jsx)(H,{onChange:c,onCancel:n,options:[{label:`Yes`,value:`yes`},{label:`No`,value:`no`}]})]})}var Ve,Y,He=e((()=>{Ve=t(l(),1),V(),_(),w(),Y=y()}));function Ue({onExit:e,toolPermissionContext:t,onRequestAddDirectory:n,onRequestRemoveDirectory:o,onHeaderFocusChange:s}){let{headerFocused:l,focusHeader:u}=c();(0,X.useEffect)(()=>{s?.(l)},[l,s]);let d=We.useMemo(()=>Array.from(t.additionalWorkingDirectories.keys()).map(e=>({path:e,isCurrent:!1,isDeletable:!0})),[t.additionalWorkingDirectories]),f=(0,X.useCallback)(e=>{if(e===`add-directory`){n();return}let t=d.find(t=>t.path===e);t?.isDeletable&&o(t.path)},[d,n,o]),p=(0,X.useCallback)(()=>e(`Workspace dialog dismissed`,{display:`system`}),[e]),m=We.useMemo(()=>{let e=d.map(e=>({label:e.path,value:e.path}));return e.push({label:`Add directory${r.ellipsis}`,value:`add-directory`}),e},[d]);return(0,Z.jsxs)(i,{flexDirection:`column`,marginBottom:1,children:[(0,Z.jsxs)(i,{flexDirection:`row`,marginTop:1,marginLeft:2,gap:1,children:[(0,Z.jsx)(a,{children:`- ${b()}`}),(0,Z.jsx)(a,{dimColor:!0,children:`(Original working directory)`})]}),(0,Z.jsx)(H,{options:m,onChange:f,onCancel:p,visibleOptionCount:Math.min(10,m.length),onUpFromFirstItem:u,isDisabled:l})]})}var We,X,Z,Ge=e((()=>{n(),We=t(l(),1),X=t(l(),1),ie(),V(),_(),Z=y()}));function Ke({rule:e}){return(0,$.jsx)(a,{dimColor:!0,children:`From ${x(e.source)}`})}function qe(e){switch(e){case`allow`:return`allowed`;case`deny`:return`denied`;case`ask`:return`ask`}}function Je({rule:e,onDelete:t,onCancel:n}){let r=B();o(`confirm:no`,n,{context:`Confirmation`});let s=(0,$.jsxs)(i,{flexDirection:`column`,marginX:2,children:[(0,$.jsx)(a,{bold:!0,children:N(e.ruleValue)}),(0,$.jsx)(ke,{ruleValue:e.ruleValue}),(0,$.jsx)(Ke,{rule:e})]}),c=(0,$.jsx)(i,{marginLeft:3,children:r.pending?(0,$.jsxs)(a,{dimColor:!0,children:[`Press `,r.keyName,` again to exit`]}):(0,$.jsx)(a,{dimColor:!0,children:`Esc to cancel`})});return e.source===`policySettings`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(i,{flexDirection:`column`,gap:1,borderStyle:`round`,paddingLeft:1,paddingRight:1,borderColor:`permission`,children:[(0,$.jsx)(a,{bold:!0,color:`permission`,children:`Rule details`}),s,(0,$.jsxs)(a,{italic:!0,children:[`This rule is configured by managed settings and cannot be modified.`,`
2
+ `,`Contact your system administrator for more information.`]})]}),c]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(i,{flexDirection:`column`,gap:1,borderStyle:`round`,paddingLeft:1,paddingRight:1,borderColor:`error`,children:[(0,$.jsxs)(a,{bold:!0,color:`error`,children:[`Delete `,qe(e.ruleBehavior),` tool?`]}),s,(0,$.jsx)(a,{children:`Are you sure you want to delete this permission rule?`}),(0,$.jsx)(H,{onChange:e=>e===`yes`?t():n(),onCancel:n,options:[{label:`Yes`,value:`yes`},{label:`No`,value:`no`}]})]}),c]})}function Ye(e){let{options:t,searchQuery:n,isSearchMode:r,isFocused:a,onSelect:o,onCancel:s,lastFocusedRuleKey:l,cursorOffset:u,onHeaderFocusChange:d}=e,f=ee(),{headerFocused:m,focusHeader:h,blurHeader:g}=c();return(0,Q.useEffect)(()=>{r&&m&&g()},[r,m,g]),(0,Q.useEffect)(()=>{d?.(m)},[m,d]),(0,$.jsxs)(i,{flexDirection:`column`,children:[(0,$.jsx)(i,{marginBottom:1,flexDirection:`column`,children:(0,$.jsx)(p,{query:n,isFocused:r&&!m,isTerminalFocused:a,width:f,cursorOffset:u})}),(0,$.jsx)(H,{options:t,onChange:o,onCancel:s,visibleOptionCount:Math.min(10,t.length),isDisabled:r||m,defaultFocusValue:l,onUpFromFirstItem:h})]})}function Xe({tab:e,getRulesOptions:t,handleToolSelect:n,...r}){return(0,$.jsxs)(i,{flexDirection:`column`,flexShrink:e===`allow`?0:void 0,children:[(0,$.jsx)(a,{children:{allow:`Work Mate won't ask before using allowed tools.`,ask:`Work Mate will always ask for confirmation before using these tools.`,deny:`Work Mate will always reject requests to use denied tools.`}[e]}),(0,$.jsx)(Ye,{options:t(e,r.searchQuery).options,onSelect:t=>n(t,e),...r})]})}function Ze({onExit:e,initialTab:t,onRetryDenials:n}){let c=De().length>0,l=t??(c?`recent`:`allow`),[d,f]=(0,Q.useState)([]),p=ae(e=>e.toolPermissionContext),m=oe(),ee=s(),g=(0,Q.useRef)({approved:new Set,retry:new Set,denials:[]}),ne=(0,Q.useCallback)(e=>{g.current=e},[]),[_,v]=(0,Q.useState)(),[y,ie]=(0,Q.useState)(),[b,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(null),[w,T]=(0,Q.useState)(!1),[E,D]=(0,Q.useState)(null),[O,k]=(0,Q.useState)(!1),[fe,pe]=(0,Q.useState)(!0),A=(0,Q.useCallback)(e=>{pe(e)},[]),M=(0,Q.useMemo)(()=>{let e=new Map;return ce(p).forEach(t=>{e.set(j(t),t)}),e},[p]),P=(0,Q.useMemo)(()=>{let e=new Map;return me(p).forEach(t=>{e.set(j(t),t)}),e},[p]),F=(0,Q.useMemo)(()=>{let e=new Map;return ue(p).forEach(t=>{e.set(j(t),t)}),e},[p]),I=(0,Q.useCallback)((e,t=``)=>{let n=(()=>{switch(e){case`allow`:return M;case`deny`:return P;case`ask`:return F;case`workspace`:case`recent`:return new Map}})(),i=[];e!==`workspace`&&e!==`recent`&&!t&&i.push({label:`Add a new rule${r.ellipsis}`,value:`add-new-rule`});let a=Array.from(n.keys()).sort((e,t)=>{let r=n.get(e),i=n.get(t);if(r&&i){let e=N(r.ruleValue).toLowerCase(),t=N(i.ruleValue).toLowerCase();return e.localeCompare(t)}return 0}),o=t.toLowerCase();for(let e of a){let r=n.get(e);if(r){let n=N(r.ruleValue);if(t&&!n.toLowerCase().includes(o))continue;i.push({label:n,value:e})}}return{options:i,rulesByKey:n}},[M,P,F]),L=B(),R=!_&&!b&&!S&&!w&&!E,{query:he,setQuery:z,cursorOffset:ge}=Ce({isActive:R&&O,onExit:()=>{k(!1)}}),_e=(0,Q.useCallback)(e=>{R&&(O||e.ctrl||e.meta||(e.key===`/`?(e.preventDefault(),k(!0),z(``)):e.key.length===1&&e.key!==`j`&&e.key!==`k`&&e.key!==`m`&&e.key!==`i`&&e.key!==`r`&&e.key!==` `&&(e.preventDefault(),k(!0),z(e.key))))},[R,O,z]),ve=(0,Q.useCallback)((e,t)=>{let{rulesByKey:n}=I(t);if(e===`add-new-rule`){x(t);return}else{v(n.get(e));return}},[I]),ye=(0,Q.useCallback)(()=>{x(null)},[]),V=(0,Q.useCallback)((e,t)=>{C({ruleValue:e,ruleBehavior:t}),x(null)},[]),H=(0,Q.useCallback)((e,t)=>{C(null);for(let t of e)f(e=>[...e,`Added ${t.ruleBehavior} rule ${u.bold(N(t.ruleValue))}`]);if(t&&t.length>0)for(let e of t){let t=e.shadowType===`deny`?`blocked`:`shadowed`;f(n=>[...n,u.yellow(`${r.warning} Warning: ${N(e.rule.ruleValue)} is ${t}`),u.dim(` ${e.reason}`),u.dim(` Fix: ${e.fix}`)])}},[]),be=(0,Q.useCallback)(()=>{C(null)},[]),Se=(0,Q.useCallback)(()=>T(!0),[]),we=(0,Q.useCallback)(e=>D(e),[]),Te=(0,Q.useCallback)(()=>{let t=g.current,r=e=>Array.from(e).map(e=>t.denials[e]).filter(e=>e!==void 0),i=r(t.retry);if(i.length>0){let t=i.map(e=>e.display);n?.(t),e(void 0,{shouldQuery:!0,metaMessages:[`Permission granted for: ${t.join(`, `)}. You may now retry ${t.length===1?`this command`:`these commands`} if you would like.`]});return}let a=r(t.approved);a.length>0||d.length>0?e([...a.length>0?[`Approved ${a.map(e=>u.bold(e.display)).join(`, `)}`]:[],...d].join(`
3
+ `)):e(`Permissions dialog dismissed`,{display:`system`})},[d,e,n]);o(`confirm:no`,Te,{context:`Settings`,isActive:R&&!O});let Ee=()=>{if(!_)return;let{options:e}=I(_.ruleBehavior),t=j(_),n=e.filter(e=>e.value!==`add-new-rule`).map(e=>e.value),r=n.indexOf(t),i;r!==-1&&(r<n.length-1?i=n[r+1]:r>0&&(i=n[r-1])),ie(i),se({rule:_,initialContext:p,setToolPermissionContext(e){m(t=>({...t,toolPermissionContext:e}))}}),f(e=>[...e,`Deleted ${_.ruleBehavior} rule ${u.bold(N(_.ruleValue))}`]),v(void 0)};if(_)return(0,$.jsx)(Je,{rule:_,onDelete:Ee,onCancel:()=>v(void 0)});if(b&&b!==`workspace`&&b!==`recent`)return(0,$.jsx)(Fe,{onCancel:ye,onSubmit:V,ruleBehavior:b});if(S)return(0,$.jsx)(Me,{onAddRules:H,onCancel:be,ruleValues:[S.ruleValue],ruleBehavior:S.ruleBehavior,initialContext:p,setToolPermissionContext:e=>{m(t=>({...t,toolPermissionContext:e}))}});if(w)return(0,$.jsx)(xe,{onAddDirectory:(e,t)=>{let n={type:`addDirectories`,directories:[e],destination:t?`localSettings`:`session`},r=de(p,n);m(e=>({...e,toolPermissionContext:r})),t&&le(n),f(n=>[...n,`Added directory ${u.bold(e)} to workspace${t?` and saved to local settings`:` for this session`}`]),T(!1)},onCancel:()=>T(!1),permissionContext:p});if(E)return(0,$.jsx)(Be,{directoryPath:E,onRemove:()=>{f(e=>[...e,`Removed directory ${u.bold(E)} from workspace`]),D(null)},onCancel:()=>D(null),permissionContext:p,setPermissionContext:e=>{m(t=>({...t,toolPermissionContext:e}))}});let U={searchQuery:he,isSearchMode:O,isFocused:ee,onCancel:Te,lastFocusedRuleKey:y,cursorOffset:ge,getRulesOptions:I,handleToolSelect:ve,onHeaderFocusChange:A};return(0,$.jsx)(i,{flexDirection:`column`,onKeyDown:_e,children:(0,$.jsxs)(re,{color:`permission`,children:[(0,$.jsxs)(te,{title:`Permissions:`,color:`permission`,defaultTab:l,hidden:!!_||!!b||!!S||w||!!E,initialHeaderFocused:!c,navFromContent:!O,children:[(0,$.jsx)(h,{id:`recent`,title:`Recently denied`,children:(0,$.jsx)(Re,{onHeaderFocusChange:A,onStateChange:ne})}),(0,$.jsx)(h,{id:`allow`,title:`Allow`,children:(0,$.jsx)(Xe,{tab:`allow`,...U})}),(0,$.jsx)(h,{id:`ask`,title:`Ask`,children:(0,$.jsx)(Xe,{tab:`ask`,...U})}),(0,$.jsx)(h,{id:`deny`,title:`Deny`,children:(0,$.jsx)(Xe,{tab:`deny`,...U})}),(0,$.jsx)(h,{id:`workspace`,title:`Workspace`,children:(0,$.jsxs)(i,{flexDirection:`column`,children:[(0,$.jsx)(a,{children:`Work Mate can read files in the workspace, and make edits when auto-accept edits is on.`}),(0,$.jsx)(Ue,{onExit:e,toolPermissionContext:p,onRequestAddDirectory:Se,onRequestRemoveDirectory:we,onHeaderFocusChange:A})]})})]}),(0,$.jsx)(i,{marginTop:1,paddingLeft:1,children:(0,$.jsx)(a,{dimColor:!0,children:L.pending?(0,$.jsxs)($.Fragment,{children:[`Press `,L.keyName,` again to exit`]}):fe?(0,$.jsx)($.Fragment,{children:`←/→ tab switch · ↓ return · Esc cancel`}):O?(0,$.jsx)($.Fragment,{children:`Type to filter · Enter/↓ select · ↑ tabs · Esc clear`}):c&&l===`recent`?(0,$.jsx)($.Fragment,{children:`Enter approve · r retry · ↑↓ navigate · ←/→ switch · Esc cancel`}):(0,$.jsx)($.Fragment,{children:`↑↓ navigate · Enter select · Type to search · ←/→ switch · Esc cancel`})})})]})})}var Q,$,Qe=e((()=>{d(),n(),Q=t(l(),1),A(),w(),V(),ye(),we(),_(),pe(),Oe(),P(),T(),M(),Se(),Pe(),be(),Ae(),Le(),ze(),He(),Ge(),$=y()})),$e,et;e((()=>{Qe(),S(),$e=y(),et=async(e,t)=>(0,$e.jsx)(Ze,{onExit:e,onRetryDenials:e=>{t.setMessages(t=>[...t,C(e)])}})}))();export{et as call};
@@ -0,0 +1,3 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{c as r,i,l as a,o}from"./envUtils-DZ_SvEVz.js";import{aC as s,sC as c}from"./loadAgentsDir-DR5PVAc3.js";import{n as ee}from"./cwd-DrEEb4f5.js";import{C as te,D as ne,I as l,R as u,S as re,T as ie,V as ae,c as d,f,i as p,u as m,x as h,z as oe}from"./debug-kBjDaVkQ.js";import{A as g,Kt as se,M as ce,Ut as le,Yt as ue,Zt as de,m as fe,t as pe}from"./settings-YIDksG5Z.js";import{d as _,i as me,o as v,r as he}from"./config-D3K87Mm1.js";import{r as ge,t as _e}from"./execa-CBhG1doD.js";import{o as y,s as b}from"./log-DWZny1vM.js";import{i as x,n as ve,t as S}from"./execFileNoThrow-BfZFnCGa.js";import{a as C,i as ye,n as w,t as be}from"./bundledMode-BxyD5cqq.js";import{i as xe,n as T}from"./platform-Vl9IynC3.js";import{b as Se,y as Ce}from"./sleep-BbWr_FL1.js";import{a as we,i as Te}from"./ripgrep-D1f1pbCz.js";import{n as Ee,r as De}from"./genericProcessUtils-CVtQOTO2.js";import{homedir as E}from"os";import{basename as Oe,delimiter as ke,join as D,posix as O,win32 as k}from"path";import{constants as Ae}from"fs";import{access as A,open as je,readFile as j,realpath as M,stat as Me}from"fs/promises";function Ne(){return D(i(),`local`)}function Pe(){return D(Ne(),`claude`)}function Fe(){return(process.argv[1]||``).includes(`/.workmate/local/node_modules/`)}async function Ie(){try{return await A(D(Ne(),`node_modules`,`.bin`,`claude`)),!0}catch{return!1}}function Le(){let e=process.env.SHELL||``;return e.includes(`zsh`)?`zsh`:e.includes(`bash`)?`bash`:e.includes(`fish`)?`fish`:`unknown`}var N=e((()=>{_(),o(),l(),x(),f(),y(),h()}));function P(e){let t=e?.homedir??E();return{zsh:D((e?.env??process.env).ZDOTDIR||t,`.zshrc`),bash:D(t,`.bashrc`),fish:D(t,`.config/fish/config.fish`)}}function Re(e){let t=!1;return{filtered:e.filter(e=>{if(I.test(e)){let n=e.match(/alias\s+claude\s*=\s*["']([^"']+)["']/);if(n||(n=e.match(/alias\s+claude\s*=\s*([^#\n]+)/)),n?.[1]&&n[1].trim()===Pe())return t=!0,!1}return!0}),hadAlias:t}}async function ze(e){try{return(await j(e,{encoding:`utf8`})).split(`
2
+ `)}catch(e){if(oe(e))return null;throw e}}async function Be(e,t){let n=await je(e,`w`);try{await n.writeFile(t.join(`
3
+ `),{encoding:`utf8`}),await n.datasync()}finally{await n.close()}}async function F(e){let t=P(e);for(let e of Object.values(t)){let t=await ze(e);if(t){for(let e of t)if(I.test(e)){let t=e.match(/alias\s+claude=["']?([^"'\s]+)/);if(t?.[1])return t[1]}}}return null}async function Ve(e){let t=await F(e);if(!t)return null;let n=e?.homedir??E(),r=t.startsWith(`~`)?t.replace(`~`,n):t;try{let e=await Me(r);if(e.isFile()||e.isSymbolicLink())return t}catch{}return null}var I,L=e((()=>{l(),N(),I=/^\s*alias\s+claude\s*=/}));async function He(){}function Ue(e){let t=pe()?.minimumVersion;if(!t)return!1;let n=!Ce(e,t);return n&&d(`Skipping update to ${e} - below minimumVersion ${t}`),n}async function We(){let e=le.isRunningWithBun(),t=null;return t=e?await ve(`bun`,[`pm`,`bin`,`-g`],{cwd:E()}):await ve(`npm`,[`-g`,`config`,`get`,`prefix`],{cwd:E()}),t.code===0?t.stdout.trim():(b(Error(`Failed to check ${e?`bun`:`npm`} permissions`)),null)}async function Ge(){try{let e=await We();if(!e)return{hasPermissions:!1,npmPrefix:null};try{return await A(e,Ae.W_OK),{hasPermissions:!0,npmPrefix:e}}catch{return b(new R(`Insufficient permissions for global npm install.`)),{hasPermissions:!1,npmPrefix:e}}}catch(e){return b(e),{hasPermissions:!1,npmPrefix:null}}}var R,z=e((()=>{p(),se(),o(),l(),x(),f(),y(),Se(),fe(),L(),R=class extends ne{}}));function B(e,t){return t.includes(e.id)||e.idLike.some(e=>t.includes(e))}function V(){let e=process.execPath||process.argv[0]||``;return/[/\\]mise[/\\]installs[/\\]/i.test(e)?(d(`Detected mise installation: ${e}`),!0):!1}function H(){let e=process.execPath||process.argv[0]||``;return/[/\\]\.?asdf[/\\]installs[/\\]/i.test(e)?(d(`Detected asdf installation: ${e}`),!0):!1}function U(){let e=T();if(e!==`macos`&&e!==`linux`&&e!==`wsl`)return!1;let t=process.execPath||process.argv[0]||``;return t.includes(`/Caskroom/`)?(d(`Detected Homebrew cask installation: ${t}`),!0):!1}function Ke(){if(T()!==`windows`)return!1;let e=process.execPath||process.argv[0]||``;for(let t of[/Microsoft[/\\]WinGet[/\\]Packages/i,/Microsoft[/\\]WinGet[/\\]Links/i])if(t.test(e))return d(`Detected winget installation: ${e}`),!0;return!1}var W,G,K,q,J,qe,Je=e((()=>{n(),p(),x(),xe(),W=t(async()=>{try{let e=await j(`/etc/os-release`,`utf8`),t=e.match(/^ID=["']?(\S+?)["']?\s*$/m),n=e.match(/^ID_LIKE=["']?(.+?)["']?\s*$/m);return{id:t?.[1]??``,idLike:n?.[1]?.split(` `)??[]}}catch{return null}}),G=t(async()=>{if(T()!==`linux`)return!1;let e=await W();if(e&&!B(e,[`arch`]))return!1;let t=await S(`pacman`,[`-Qo`,process.execPath||process.argv[0]||``],{timeout:5e3,useCwd:!1});return t.code===0&&t.stdout?(d(`Detected pacman installation: ${t.stdout.trim()}`),!0):!1}),K=t(async()=>{if(T()!==`linux`)return!1;let e=await W();if(e&&!B(e,[`debian`]))return!1;let t=await S(`dpkg`,[`-S`,process.execPath||process.argv[0]||``],{timeout:5e3,useCwd:!1});return t.code===0&&t.stdout?(d(`Detected deb installation: ${t.stdout.trim()}`),!0):!1}),q=t(async()=>{if(T()!==`linux`)return!1;let e=await W();if(e&&!B(e,[`fedora`,`rhel`,`suse`]))return!1;let t=await S(`rpm`,[`-qf`,process.execPath||process.argv[0]||``],{timeout:5e3,useCwd:!1});return t.code===0&&t.stdout?(d(`Detected rpm installation: ${t.stdout.trim()}`),!0):!1}),J=t(async()=>{if(T()!==`linux`)return!1;let e=await W();if(e&&!B(e,[`alpine`]))return!1;let t=await S(`apk`,[`info`,`--who-owns`,process.execPath||process.argv[0]||``],{timeout:5e3,useCwd:!1});return t.code===0&&t.stdout?(d(`Detected apk installation: ${t.stdout.trim()}`),!0):!1}),qe=t(async()=>U()?`homebrew`:Ke()?`winget`:V()?`mise`:H()?`asdf`:await G()?`pacman`:await J()?`apk`:await K()?`deb`:await q()?`rpm`:`unknown`)}));function Ye(){let e=process.argv[1]||``,t=process.execPath||process.argv[0]||``;return T()===`windows`&&(e=e.split(k.sep).join(O.sep),t=t.split(k.sep).join(O.sep)),[e,t]}async function Xe(){let[e]=Ye();if(w())return U()||Ke()||V()||H()||await G()||await K()||await q()||await J()?`package-manager`:`native`;if(Fe())return`npm-local`;if([`/usr/local/lib/node_modules`,`/usr/lib/node_modules`,`/opt/homebrew/lib/node_modules`,`/opt/homebrew/bin`,`/usr/local/bin`,`/.nvm/versions/node/`].some(t=>e.includes(t))||e.includes(`/npm/`)||e.includes(`/nvm/`))return`npm-global`;let t=await _e(`npm config get prefix`,{shell:!0,reject:!1}),n=t.exitCode===0?t.stdout.trim():null;return n&&e.startsWith(n)?`npm-global`:`unknown`}async function Ze(){if(w()){try{return await M(process.execPath)}catch{}try{let e=await C(`claude`);if(e)return e}catch{}try{return await m().stat(D(E(),`.local/bin/claude`)),D(E(),`.local/bin/claude`)}catch{}return`native`}try{return process.argv[0]||`unknown`}catch{return`unknown`}}function Qe(){try{return w()?process.execPath||`unknown`:process.argv[1]||`unknown`}catch{return`unknown`}}async function $e(){let e=m(),t=[],n=D(E(),`.workmate`,`local`);await Ie()&&t.push({type:`npm-local`,path:n});let r=[`@anthropic-ai/workmate`],i=await S(`npm`,[`-g`,`config`,`get`,`prefix`]);if(i.code===0&&i.stdout){let n=i.stdout.trim(),a=T()===`windows`,o=a?D(n,`claude`):D(n,`bin`,`claude`),s=!1;try{await e.stat(o),s=!0}catch{}if(s){let e=!1;try{(await M(o)).includes(`/Caskroom/`)&&(e=U())}catch{}e||t.push({type:`npm-global`,path:o})}else for(let i of r){let r=a?D(n,`node_modules`,i):D(n,`lib`,`node_modules`,i);try{await e.stat(r),t.push({type:`npm-global-orphan`,path:r})}catch{}}}let a=D(E(),`.local`,`bin`,`claude`);try{await e.stat(a),t.push({type:`native`,path:a})}catch{}if(v().installMethod===`native`){let n=D(E(),`.local`,`share`,`claude`);try{await e.stat(n),t.some(e=>e.type===`native`)||t.push({type:`native`,path:n})}catch{}}return t}async function et(e){let t=[];try{let e=re(await j(D(ue(),`managed-settings.json`),`utf-8`)),n=e&&typeof e==`object`?e.strictPluginOnlyCustomization:void 0;if(n!==void 0&&typeof n!=`boolean`)if(!Array.isArray(n))t.push({issue:`managed-settings.json: strictPluginOnlyCustomization has an invalid value (expected true or an array, got ${typeof n})`,fix:`The field is silently ignored (schema .catch rescues it). Set it to true, or an array of: ${g.join(`, `)}.`});else{let e=n.filter(e=>typeof e==`string`&&!g.includes(e));e.length>0&&t.push({issue:`managed-settings.json: strictPluginOnlyCustomization has ${e.length} value(s) this client doesn't recognize: ${e.map(String).join(`, `)}`,fix:`These are silently ignored (forwards-compat). Known surfaces for this version: ${g.join(`, `)}. Either remove them, or this client is older than the managed-settings intended.`})}}catch{}let n=v();if(e===`development`)return t;if(e===`native`){let e=(process.env.PATH||``).split(ke),n=D(E(),`.local`,`bin`),r=n;if(T()===`windows`&&(r=n.split(k.sep).join(O.sep)),!e.some(e=>{let t=e;T()===`windows`&&(t=e.split(k.sep).join(O.sep));let n=t.replace(/\/+$/,``),i=e.replace(/[/\\]+$/,``);return n===r||i===`~/.local/bin`||i===`$HOME/.local/bin`}))if(T()===`windows`){let e=n.split(O.sep).join(k.sep);t.push({issue:`Native installation exists but ${e} is not in your PATH`,fix:`Add it by opening: System Properties → Environment Variables → Edit User PATH → New → Add the path above. Then restart your terminal.`})}else{let e=Le(),n=P()[e],r=n?n.replace(E(),`~`):`your shell config file`;t.push({issue:`Native installation exists but ~/.local/bin is not in your PATH`,fix:`Run: echo 'export PATH="$HOME/.local/bin:$PATH"' >> ${r} then open a new terminal or run: source ${r}`})}}a(process.env.DISABLE_INSTALLATION_CHECKS)||(e===`npm-local`&&n.installMethod!==`local`&&t.push({issue:`Running from local installation but config install method is '${n.installMethod}'`,fix:`Consider using native installation: claude install`}),e===`native`&&n.installMethod!==`native`&&t.push({issue:`Running native installation but config install method is '${n.installMethod}'`,fix:`Run claude install to update configuration`})),e===`npm-global`&&await Ie()&&t.push({issue:`Local installation exists but not being used`,fix:`Consider using native installation: claude install`});let r=await F(),i=await Ve();return e===`npm-local`&&!await C(`claude`)&&!i&&(r?t.push({issue:`Local installation not accessible`,fix:`Alias exists but points to invalid target: ${r}. Update alias: alias claude="~/.workmate/local/claude"`}):t.push({issue:`Local installation not accessible`,fix:`Create alias: alias claude="~/.workmate/local/claude"`})),t}function tt(){if(T()!==`linux`)return[];let e=[],t=s.getLinuxGlobPatternWarnings();if(t.length>0){let n=t.slice(0,3).join(`, `),r=t.length-3,i=r>0?`${n} (${r} more)`:n;e.push({issue:`Glob patterns in sandbox permission rules are not fully supported on Linux`,fix:`Found ${t.length} pattern(s): ${i}. On Linux, glob patterns in Edit/Read rules will be ignored.`})}return e}async function nt(){let e=await Xe(),t=typeof MACRO<`u`?`0.0.26`:`unknown`,n=await Ze(),r=Qe(),i=await $e(),a=await et(e);if(a.push(...tt()),e===`native`){let e=i.filter(e=>e.type===`npm-global`||e.type===`npm-global-orphan`||e.type===`npm-local`),t=T()===`windows`;for(let n of e)n.type===`npm-global`?a.push({issue:`Leftover npm global installation at ${n.path}`,fix:`Run: npm -g uninstall @anthropic-ai/workmate`}):n.type===`npm-global-orphan`?a.push({issue:`Orphaned npm global package at ${n.path}`,fix:t?`Run: rmdir /s /q "${n.path}"`:`Run: rm -rf ${n.path}`}):n.type===`npm-local`&&a.push({issue:`Leftover npm local installation at ${n.path}`,fix:t?`Run: rmdir /s /q "${n.path}"`:`Run: rm -rf ${n.path}`})}let o=v().installMethod||`not set`,s=null;e===`npm-global`&&(s=(await Ge()).hasPermissions,!s&&!me()&&a.push({issue:`Insufficient permissions for auto-updates`,fix:"Do one of: (1) Re-install node without sudo, or (2) Use `claude install` for native installation"}));let c=Te(),ee={working:c.working??!0,mode:c.mode,systemPath:c.mode===`system`?c.path:null,note:c.note??null},te=e===`package-manager`?await qe():void 0;return{installationType:e,version:t,installationPath:n,invokedBinary:r,configInstallMethod:o,autoUpdates:(()=>{let e=me();return e?`disabled (${he(e)})`:`enabled`})(),hasUpdatePermissions:s,multipleInstallations:i,warnings:a,packageManager:te,ripgrepStatus:ee}}var rt=e((()=>{ge(),z(),be(),_(),ee(),o(),x(),f(),N(),Je(),xe(),we(),c(),de(),ce(),L(),h(),ye()}));function Y(e){return{env:e?.env??process.env,home:e?.homedir??process.env.HOME??E()}}function X(e,...t){return e.includes(`/`)&&!e.includes(`\\`)&&!/^[A-Za-z]:/.test(e)?O.join(e,...t):D(e,...t)}function it(e){let{env:t,home:n}=Y(e);return t.XDG_STATE_HOME??X(n,`.local`,`state`)}function at(e){let{env:t,home:n}=Y(e);return t.XDG_CACHE_HOME??X(n,`.cache`)}function ot(e){let{env:t,home:n}=Y(e);return t.XDG_DATA_HOME??X(n,`.local`,`share`)}function st(e){let{home:t}=Y(e);return X(t,`.local`,`bin`)}var ct=e((()=>{}));function lt(){let e=process.env.ENABLE_PID_BASED_VERSION_LOCKING;return a(e)?!0:(r(e),!1)}function Z(e){if(e<=1)return!1;try{return process.kill(e,0),!0}catch{return!1}}function ut(e,t){if(!Z(e))return!1;if(e===process.pid)return!0;try{let n=Ee(e);if(!n)return!0;let r=n.toLowerCase(),i=t.toLowerCase();return r.includes(`claude`)||r.includes(i)}catch{return!0}}function Q(e){let t=m();try{let n=t.readFileSync(e,{encoding:`utf8`});if(!n||n.trim()===``)return null;let r=re(n);return typeof r.pid!=`number`||!r.version||!r.execPath?null:r}catch{return null}}function $(e){let t=Q(e);if(!t)return!1;let{pid:n,execPath:r}=t;if(!Z(n))return!1;if(!ut(n,r))return d(`Lock PID ${n} is running but does not appear to be Work Mate - treating as stale`),!1;let i=m();try{let t=i.statSync(e);if(Date.now()-t.mtimeMs>_t&&!Z(n))return!1}catch{}return!0}function dt(e,t){let n=m(),r=`${e}.tmp.${process.pid}.${Date.now()}`;try{ie(r,te(t,null,2),{encoding:`utf8`,flush:!0}),n.renameSync(r,e)}catch(e){try{n.unlinkSync(r)}catch{}throw e}}async function ft(e,t){let n=m(),r=Oe(e);if($(t))return d(`Cannot acquire lock for ${r} - held by PID ${Q(t)?.pid}`),null;let i={pid:process.pid,version:r,execPath:process.execPath,acquiredAt:Date.now()};try{return dt(t,i),Q(t)?.pid===process.pid?(d(`Acquired PID lock for ${r} (PID ${process.pid})`),()=>{try{Q(t)?.pid===process.pid&&(n.unlinkSync(t),d(`Released PID lock for ${r}`))}catch(e){d(`Failed to release lock for ${r}: ${e}`)}}):null}catch(e){return d(`Failed to acquire lock for ${r}: ${e}`),null}}async function pt(e,t){let n=await ft(e,t);if(!n)return!1;let r=()=>{try{n()}catch{}};return process.on(`exit`,r),process.on(`SIGINT`,r),process.on(`SIGTERM`,r),!0}async function mt(e,t,n){let r=await ft(e,t);if(!r)return!1;try{return await n(),!0}finally{r()}}function ht(e){let t=m(),n=[];try{let r=t.readdirStringSync(e).filter(e=>e.endsWith(`.lock`));for(let t of r){let r=D(e,t),i=Q(r);i&&n.push({version:i.version,pid:i.pid,isProcessRunning:Z(i.pid),execPath:i.execPath,acquiredAt:new Date(i.acquiredAt),lockFilePath:r})}}catch(e){if(u(e))return n;b(ae(e))}return n}function gt(e){let t=m(),n=0;try{let r=t.readdirStringSync(e).filter(e=>e.endsWith(`.lock`));for(let i of r){let r=D(e,i);try{t.lstatSync(r).isDirectory()?(t.rmSync(r,{recursive:!0,force:!0}),n++,d(`Cleaned up legacy directory lock: ${i}`)):$(r)||(t.unlinkSync(r),n++,d(`Cleaned up stale lock: ${i}`))}catch{}}}catch(e){if(u(e))return 0;b(ae(e))}return n}var _t,vt=e((()=>{p(),o(),l(),f(),De(),y(),h(),_t=7200*1e3}));export{ze as C,N as E,L as S,Le as T,He as _,$ as a,Re as b,mt as c,ot as d,it as f,rt as g,nt as h,vt as i,st as l,Xe as m,gt as n,lt as o,ct as p,ht as r,Q as s,pt as t,at as u,z as v,Be as w,P as x,Ue as y};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{I as t,P as n,t as r}from"./src-WZ94ZKI3.js";import{t as i}from"./jsx-runtime-Bb4Xn-E0.js";import{Pt as a,kt as o}from"./state-CXY-q5gr.js";import{D as s,Mg as c,aw as l,b as u,cw as d,iw as f,kg as p}from"./loadAgentsDir-DR5PVAc3.js";import{a as m,i as h,r as g,t as _}from"./promptEditor-CpUFgGzc.js";import{r as v,t as y}from"./staticRender-RHUIg5ln.js";function b({planContent:e,planPath:r,editorName:i}){return(0,S.jsxs)(t,{flexDirection:`column`,children:[(0,S.jsx)(n,{bold:!0,children:`Current Plan`}),(0,S.jsx)(n,{dimColor:!0,children:r}),(0,S.jsx)(t,{marginTop:1,children:(0,S.jsx)(n,{children:e})}),i&&(0,S.jsxs)(t,{marginTop:1,children:[(0,S.jsx)(n,{dimColor:!0,children:`"/plan open"`}),(0,S.jsx)(n,{dimColor:!0,children:` to edit this plan in `}),(0,S.jsx)(n,{bold:!0,dimColor:!0,children:i})]})]})}async function x(e,t,n){let{getAppState:r,setAppState:i}=t,a=r().toolPermissionContext.mode;if(a!==`plan`){o(a,`plan`),i(e=>({...e,toolPermissionContext:p(s(e.toolPermissionContext),{type:`setMode`,mode:`plan`,destination:`session`})}));let t=n.trim();return t&&t!==`open`?e(`Enabled plan mode`,{shouldQuery:!0}):e(`Enabled plan mode`),null}let c=f(),u=l();if(!c)return e(`Already in plan mode. No plan written yet.`),null;if(n.trim().split(/\s+/)[0]===`open`){let t=await _(u);return t.error?e(`Failed to open plan in editor: ${t.error}`):e(`Opened plan in editor: ${u}`),null}return e(await v((0,S.jsx)(b,{planContent:c,planPath:u,editorName:h()??void 0}))),null}var S;e((()=>{a(),r(),m(),c(),u(),d(),g(),y(),S=i()}))();export{x as call};
@@ -1,2 +1,2 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{f as r,u as i}from"./debug-CRnGsZOV.js";import{o as a,s as o}from"./log-DoSpAwRP.js";import{release as s}from"os";import{readFile as c}from"fs/promises";var l,u,d,f=e((()=>{n(),r(),a(),l=[`macos`,`wsl`],u=t(()=>{try{if(process.platform===`darwin`)return`macos`;if(process.platform===`win32`)return`windows`;if(process.platform===`linux`){try{let e=i().readFileSync(`/proc/version`,{encoding:`utf8`});if(e.toLowerCase().includes(`microsoft`)||e.toLowerCase().includes(`wsl`))return`wsl`}catch(e){o(e)}return`linux`}return`unknown`}catch(e){return o(e),`unknown`}}),d=t(()=>{if(process.platform===`linux`)try{let e=i().readFileSync(`/proc/version`,{encoding:`utf8`}),t=e.match(/WSL(\d+)/i);return t?.[1]?t[1]:e.toLowerCase().includes(`microsoft`)?`1`:void 0}catch(e){o(e);return}}),t(async()=>{if(process.platform!==`linux`)return;let e={linuxKernel:s()};try{let t=await c(`/etc/os-release`,`utf8`);for(let n of t.split(`
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{f as r,u as i}from"./debug-kBjDaVkQ.js";import{o as a,s as o}from"./log-DWZny1vM.js";import{release as s}from"os";import{readFile as c}from"fs/promises";var l,u,d,f=e((()=>{n(),r(),a(),l=[`macos`,`wsl`],u=t(()=>{try{if(process.platform===`darwin`)return`macos`;if(process.platform===`win32`)return`windows`;if(process.platform===`linux`){try{let e=i().readFileSync(`/proc/version`,{encoding:`utf8`});if(e.toLowerCase().includes(`microsoft`)||e.toLowerCase().includes(`wsl`))return`wsl`}catch(e){o(e)}return`linux`}return`unknown`}catch(e){return o(e),`unknown`}}),d=t(()=>{if(process.platform===`linux`)try{let e=i().readFileSync(`/proc/version`,{encoding:`utf8`}),t=e.match(/WSL(\d+)/i);return t?.[1]?t[1]:e.toLowerCase().includes(`microsoft`)?`1`:void 0}catch(e){o(e);return}}),t(async()=>{if(process.platform!==`linux`)return;let e={linuxKernel:s()};try{let t=await c(`/etc/os-release`,`utf8`);for(let n of t.split(`
2
2
  `)){let t=n.match(/^(ID|VERSION_ID)=(.*)$/);if(t?.[1]&&t[2]){let n=t[2].replace(/^"|"$/g,``);t[1]===`ID`?e.linuxDistroId=n:e.linuxDistroVersion=n}}}catch{}return e})}));export{f as i,u as n,d as r,l as t};