@readmagic/workmate 0.0.27 → 0.0.28
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.
- package/dist/chunks/{AddWorkspaceDirectory-DqlPtsVK.js → AddWorkspaceDirectory-Bmgh8VS3.js} +1 -1
- package/dist/chunks/{AgentsMdExternalIncludesDialog-rJS5l6yk.js → AgentsMdExternalIncludesDialog-BJfHqScU.js} +1 -1
- package/dist/chunks/AgentsMdExternalIncludesDialog-BjbUilCE.js +1 -0
- package/dist/chunks/{App-DzRQpRKr.js → App-COdpsR2w.js} +1 -1
- package/dist/chunks/{BackgroundTasksDialog-CBhSmdz_.js → BackgroundTasksDialog-WkoL4g5Q.js} +1 -1
- package/dist/chunks/{BypassPermissionsModeDialog-zz-lnmJt.js → BypassPermissionsModeDialog-BT9yl0Qt.js} +1 -1
- package/dist/chunks/{CustomSelect-CYmc4vRh.js → CustomSelect-t4wXuXWH.js} +1 -1
- package/dist/chunks/{DiffDialog-CTUIAcEE.js → DiffDialog-CXZxnb7Y.js} +1 -1
- package/dist/chunks/Doctor-B6isid5K.js +1 -0
- package/dist/chunks/{Doctor-CLOYkPRR.js → Doctor-COj-tZBc.js} +1 -1
- package/dist/chunks/{ExitFlow-CATwJC4c.js → ExitFlow-CcMYH5iI.js} +1 -1
- package/dist/chunks/{InvalidConfigDialog-B-9Z58oD.js → InvalidConfigDialog-riLYEaUP.js} +1 -1
- package/dist/chunks/{InvalidSettingsDialog-B4EWjbp7.js → InvalidSettingsDialog-BGXl3V1A.js} +1 -1
- package/dist/chunks/{KeybindingProviderSetup-Dzg77_Xn.js → KeybindingProviderSetup-syiDgtpB.js} +1 -1
- package/dist/chunks/{MCPConnectionManager-CBY8nqdU.js → MCPConnectionManager-C7RmKzJh.js} +1 -1
- package/dist/chunks/{MCPToolListView-C7HT6rrl.js → MCPToolListView-CewNLJus.js} +1 -1
- package/dist/chunks/{McpParsingWarnings-Dj_Fu5o-.js → McpParsingWarnings-Czze2JPd.js} +1 -1
- package/dist/chunks/{MessageSelector-Dw_ERK_Z.js → MessageSelector-Kc6JlnDX.js} +1 -1
- package/dist/chunks/{Messages-RBfRELKn.js → Messages-BvFYO4Zn.js} +1 -1
- package/dist/chunks/{Onboarding-BRSXxc2E.js → Onboarding-CD_Uv5h9.js} +1 -1
- package/dist/chunks/{PromptInputFooterSuggestions-ChpyD9B7.js → PromptInputFooterSuggestions-CHXJsTtQ.js} +1 -1
- package/dist/chunks/{PromptInputHelpMenu-CrTT8MKE.js → PromptInputHelpMenu-BZIVCV7V.js} +1 -1
- package/dist/chunks/{ProviderSetup-BEV95bnz.js → ProviderSetup-CwMvjmjh.js} +1 -1
- package/dist/chunks/{QueryEngine-BBBkZWu2.js → QueryEngine-DAwfp_ht.js} +1 -1
- package/dist/chunks/{REPL-BDnZnm__.js → REPL-CtFtb35A.js} +4 -4
- package/dist/chunks/REPL-tFT1FGQF.js +1 -0
- package/dist/chunks/{ResumeConversation-BuSqBrm1.js → ResumeConversation-CERzSBvg.js} +1 -1
- package/dist/chunks/SearchExtraToolsTool-ndh4aEwQ.js +1 -0
- package/dist/chunks/{Settings-DYKmPdbd.js → Settings-CPaqWNdP.js} +2 -2
- package/dist/chunks/{Spinner-DOI8qqZi.js → Spinner-C0qHjfIY.js} +1 -1
- package/dist/chunks/{TextInput-ZKU-x_FD.js → TextInput-ou7ZhpVY.js} +1 -1
- package/dist/chunks/{ThemePicker-B69oDgXN.js → ThemePicker-CVFWqSc7.js} +1 -1
- package/dist/chunks/{TrustDialog-BSG8Ibh8.js → TrustDialog-CGXv_LF4.js} +1 -1
- package/dist/chunks/{ValidationErrorsList-BUYHEft4.js → ValidationErrorsList-CKeHoN2Z.js} +1 -1
- package/dist/chunks/{_baseEach-P0u1zIx6.js → _baseEach-BYhqv77g.js} +1 -1
- package/dist/chunks/{add-dir-C8RmmyQK.js → add-dir-BSizpuef.js} +1 -1
- package/dist/chunks/{agentDisplay-np7CH47m.js → agentDisplay-JKfYFD1m.js} +1 -1
- package/dist/chunks/{agents-DRQlR5M1.js → agents-BDTCH6YB.js} +1 -1
- package/dist/chunks/{agents-DedoH0Q4.js → agents-MEaV8P2G.js} +1 -1
- package/dist/chunks/{allErrors-DvcU0w0F.js → allErrors-Dhnf6rqg.js} +1 -1
- package/dist/chunks/{appleTerminalBackup-Bemd4RXh.js → appleTerminalBackup-CN8kS74J.js} +1 -1
- package/dist/chunks/backgroundHousekeeping-Bu-zRFCx.js +1 -0
- package/dist/chunks/{backgroundHousekeeping-BtEJ6TeC.js → backgroundHousekeeping-CsXlkIg3.js} +1 -1
- package/dist/chunks/{banner-CuoceXzz.js → banner-BKOzHotb.js} +1 -1
- package/dist/chunks/{branch-ClhlS7f8.js → branch-BllXcYwS.js} +1 -1
- package/dist/chunks/bridgeControl-aDnUrYZR.js +2 -0
- package/dist/chunks/{btw-B-FLxlx-.js → btw-DzaRBa6o.js} +1 -1
- package/dist/chunks/caches-CMF-MmR-.js +1 -0
- package/dist/chunks/{caches-Dn8yrJmL.js → caches-CW5YnYNS.js} +1 -1
- package/dist/chunks/channel-DVx21qde.js +1 -0
- package/dist/chunks/channel-Gw6skpUh.js +1 -0
- package/dist/chunks/{clear-BnWv0i65.js → clear-CDQs9_5P.js} +1 -1
- package/dist/chunks/commands-CfYMwgP7.js +1 -0
- package/dist/chunks/{compact-Banc-SNk.js → compact-6F2tuItE.js} +1 -1
- package/dist/chunks/config-BDkzWBnL.js +1 -0
- package/dist/chunks/{config-BDn2YIjC.js → config-Bio2EjUK.js} +1 -1
- package/dist/chunks/config-C_AEhZrn.js +1 -0
- package/dist/chunks/{context-BvDBAyJ9.js → context-TkdzCK3Y.js} +1 -1
- package/dist/chunks/{context-noninteractive-CuHHniJn.js → context-noninteractive-BcBo64vo.js} +1 -1
- package/dist/chunks/context-noninteractive-oFcnY1Er.js +1 -0
- package/dist/chunks/{conversation-Cjaftrrw.js → conversation-CYZyg1U1.js} +1 -1
- package/dist/chunks/conversation-DXzlRhNw.js +1 -0
- package/dist/chunks/{conversationRecovery-NL05oJb1.js → conversationRecovery-_hWC7JBO.js} +1 -1
- package/dist/chunks/{crossProjectResume-BzltC4NJ.js → crossProjectResume-CCo3iZrB.js} +1 -1
- package/dist/chunks/{diff--6gQCx_x.js → diff-BzVUPO4Z.js} +1 -1
- package/dist/chunks/doctor-B4jQbGQr.js +1 -0
- package/dist/chunks/{entry-DWYOrkFS.js → entry-333L52Lo.js} +1 -1
- package/dist/chunks/{exit-uKtXb5U3.js → exit-D5DYnRvR.js} +1 -1
- package/dist/chunks/{extraUsage-Dr0YXm1w.js → extraUsage-CmgRR-zH.js} +1 -1
- package/dist/chunks/extractMemories-CVUrBFMj.js +1 -0
- package/dist/chunks/fast-CRhW9zha.js +1 -0
- package/dist/chunks/{fast-C5-lNCQi.js → fast-D7oNjaZ3.js} +1 -1
- package/dist/chunks/{fetchModelList-9w1E4Ue8.js → fetchModelList-Cv1vWIpC.js} +1 -1
- package/dist/chunks/fetchModelList-DIa1HwAJ.js +1 -0
- package/dist/chunks/{fileSuggestions-BYD78vcF.js → fileSuggestions-DF3HTRKr.js} +1 -1
- package/dist/chunks/{gemini-BNBptTET.js → gemini-ou7_YyXc.js} +1 -1
- package/dist/chunks/{generateSessionName-CO2484aJ.js → generateSessionName-CeN9EZNY.js} +1 -1
- package/dist/chunks/{goal-j0wdadwM.js → goal-CCxo4Wyf.js} +1 -1
- package/dist/chunks/{grok-BpO1ZwK_.js → grok-BMmUcNbI.js} +1 -1
- package/dist/chunks/{help-DwhA0qQ6.js → help-CYtogTZk.js} +1 -1
- package/dist/chunks/{hooks-DG4_WdZ2.js → hooks-ByVkvodY.js} +1 -1
- package/dist/chunks/hooks-CBGUcyCs.js +1 -0
- package/dist/chunks/{install-BbmCNCuM.js → install-DIxyfdXG.js} +1 -1
- package/dist/chunks/{instrumentation-DpPmDyNF.js → instrumentation-BmHivmxs.js} +3 -3
- package/dist/chunks/{job-GcmX1ALd.js → job-D534P26R.js} +1 -1
- package/dist/chunks/{launchLocalMemory-CDgT5lst.js → launchLocalMemory-CWXLb3KF.js} +1 -1
- package/dist/chunks/{launchOnboarding-uQ_ux9sS.js → launchOnboarding-CocPmwzz.js} +1 -1
- package/dist/chunks/loadAgentsDir-Zw648oQO.js +1 -0
- package/dist/chunks/{loadAgentsDir-uuZYOgKn.js → loadAgentsDir-bmpKLPdG.js} +343 -343
- package/dist/chunks/{loadPluginHooks-QoVXsBjy.js → loadPluginHooks-BIfM53-_.js} +1 -1
- package/dist/chunks/{localSearch-yVCDrVrf.js → localSearch-Da8cVYoI.js} +1 -1
- package/dist/chunks/localSearch-Dbj8cXyO.js +1 -0
- package/dist/chunks/{logoUtils-B4wCDKs9.js → logoUtils-qNuBc2nI.js} +1 -1
- package/dist/chunks/{magicDocs-D53lV8b5.js → magicDocs-BsEiBLQl.js} +1 -1
- package/dist/chunks/{main-fy_XSXGj.js → main-B31aPMPP.js} +6 -6
- package/dist/chunks/managedEnv-DCGLDTP_.js +1 -0
- package/dist/chunks/{managedEnv-B8YWmM4A.js → managedEnv-EZ2IirNa.js} +1 -1
- package/dist/chunks/{mcp-DCl-Tz-C.js → mcp-BMeWtYCx.js} +1 -1
- package/dist/chunks/{mcp--LmEVBRg.js → mcp-CYbesbfl.js} +1 -1
- package/dist/chunks/{mcp-CZUVaPb3.js → mcp-Dd8TBfQQ.js} +1 -1
- package/dist/chunks/{memory-Bu5ku7y9.js → memory-DtQQGyPS.js} +1 -1
- package/dist/chunks/{mode-Bteqe2QG.js → mode-SM8doWgC.js} +1 -1
- package/dist/chunks/{model-CHDU5yqH.js → model-C2r-PaR4.js} +1 -1
- package/dist/chunks/{model-CcHyMyBv.js → model-Dd3x121y.js} +1 -1
- package/dist/chunks/{modelOptions-CJV1R3Jt.js → modelOptions-BQL4gbNk.js} +1 -1
- package/dist/chunks/{nativeInstaller-CIUYh1aD.js → nativeInstaller-DMkZdsof.js} +1 -1
- package/dist/chunks/{notifications-GLnjirCl.js → notifications-BwS1XsnZ.js} +1 -1
- package/dist/chunks/{onChangeAppState-CxGW2d-l.js → onChangeAppState-C9cYQJPF.js} +1 -1
- package/dist/chunks/{openai-BpGQT2Iv.js → openai-Bea4I2Od.js} +1 -1
- package/dist/chunks/{overlayContext-7wgLio1O.js → overlayContext-C5WPACKC.js} +1 -1
- package/dist/chunks/{partition-djFY9gGI.js → partition-CKgWl7p4.js} +1 -1
- package/dist/chunks/{permissions-DNedQyLg.js → permissions-Dv_PCfY0.js} +1 -1
- package/dist/chunks/{pidLock-CFUBtZck.js → pidLock-CqkC3-nD.js} +2 -2
- package/dist/chunks/{plan-DI0n7LIV.js → plan-Ce6wfjjI.js} +1 -1
- package/dist/chunks/{plugin-BQ8gRVYF.js → plugin-aK4tDrVg.js} +1 -1
- package/dist/chunks/{pluginAutoupdate-CNrHb4RJ.js → pluginAutoupdate-ByokIVEs.js} +1 -1
- package/dist/chunks/{pluginBlocklist-CKCsgWdY.js → pluginBlocklist-ByRQaVPu.js} +1 -1
- package/dist/chunks/{pluginCliCommands-CACeyIwz.js → pluginCliCommands-Dyk4HYHs.js} +1 -1
- package/dist/chunks/{pluginFlagging-CUvkKGOB.js → pluginFlagging-B2ZX5_oB.js} +1 -1
- package/dist/chunks/{pluginOperations-Ca_T-HYn.js → pluginOperations-BCvJvfOC.js} +1 -1
- package/dist/chunks/{pluginStartupCheck-DftTiXct.js → pluginStartupCheck-QG0d95dE.js} +1 -1
- package/dist/chunks/pluginStartupCheck-o_TC7wIt.js +1 -0
- package/dist/chunks/{plugins-Divl-P-X.js → plugins-DzsTDNWJ.js} +1 -1
- package/dist/chunks/{print-DSHypGJa.js → print-dUT7E1g9.js} +2 -2
- package/dist/chunks/{processBashCommand-BLcFmbyG.js → processBashCommand-DtGCgTkF.js} +1 -1
- package/dist/chunks/{processSlashCommand-Caif46Gi.js → processSlashCommand-wXblpK2C.js} +1 -1
- package/dist/chunks/{projectOnboardingState-nTCycGCD.js → projectOnboardingState-D-_ijZnG.js} +1 -1
- package/dist/chunks/prompt-BdH2zk0S.js +1 -0
- package/dist/chunks/{prompt-BfXryFt-.js → prompt-BnDapYGL.js} +1 -1
- package/dist/chunks/prompt-D0TFER0A.js +1 -0
- package/dist/chunks/{protocolHandler-VigBkAQQ.js → protocolHandler-CJO3CRYW.js} +1 -1
- package/dist/chunks/{reconciler-B9XFdL4f.js → reconciler-C_HKsocm.js} +1 -1
- package/dist/chunks/{refresh-CBHbWTGg.js → refresh-Cm4jZzLa.js} +1 -1
- package/dist/chunks/{reject-CBxnwckZ.js → reject-Tug1RmkE.js} +1 -1
- package/dist/chunks/{reload-plugins-5eFWrQlL.js → reload-plugins-CL9LWzpq.js} +1 -1
- package/dist/chunks/{rename-Cw7cMerG.js → rename-OfKJSazJ.js} +1 -1
- package/dist/chunks/{resume-U2D0ybfU.js → resume-BZ42SpS2.js} +1 -1
- package/dist/chunks/{runtimeObserver-DOYlxx9H.js → runtimeObserver-BLq2guVy.js} +1 -1
- package/dist/chunks/{runtimeObserver-CWaYMJG8.js → runtimeObserver-DT5P2_XL.js} +2 -2
- package/dist/chunks/sandbox-adapter-982rx2cm.js +1 -0
- package/dist/chunks/{sandbox-toggle-BtiPyjT3.js → sandbox-toggle-DghmaJhK.js} +1 -1
- package/dist/chunks/searchExtraTools-B4N1bpy0.js +1 -0
- package/dist/chunks/{select-BuTJbu_Q.js → select-CaxQ-BVq.js} +1 -1
- package/dist/chunks/sessionFileAccessHooks-BqQ58T7e.js +1 -0
- package/dist/chunks/{sessionObserver-cfwD8pV8.js → sessionObserver-DBoZUvWL.js} +1 -1
- package/dist/chunks/sessionObserver-qYpA90El.js +1 -0
- package/dist/chunks/sessionStorage-CC0v4zMs.js +1 -0
- package/dist/chunks/{sessionTracing-DsdcOqvc.js → sessionTracing-5a7HDF4e.js} +1 -1
- package/dist/chunks/{setup-DR-KEmxL.js → setup-DVLnIlse.js} +2 -2
- package/dist/chunks/{shadowedRuleDetection-DiZUDzxU.js → shadowedRuleDetection-L3tnySui.js} +1 -1
- package/dist/chunks/{sideQuestion-CdgUarC2.js → sideQuestion-BJTVma-5.js} +1 -1
- package/dist/chunks/sinks-C9NdbjLo.js +1 -0
- package/dist/chunks/{sinks-Cy3NqVbk.js → sinks-CV0SWuZW.js} +1 -1
- package/dist/chunks/{skillChangeDetector-CVFCJcG7.js → skillChangeDetector-DlodgOyC.js} +1 -1
- package/dist/chunks/{skillGapStore-BJV8ZIB1.js → skillGapStore-Cposc03e.js} +2 -2
- package/dist/chunks/{skillLifecycle-iO_3s9Ff.js → skillLifecycle-RXQp0JU7.js} +2 -2
- package/dist/chunks/{skillSearchPanel-BL5gXTHU.js → skillSearchPanel-B2pjskqk.js} +2 -2
- package/dist/chunks/{skills-BEp3_RyT.js → skills-D2ZjMtv4.js} +1 -1
- package/dist/chunks/status-BcSkj9nE.js +1 -0
- package/dist/chunks/{statusNoticeHelpers-BoloSeXY.js → statusNoticeHelpers-DsrqBOQt.js} +1 -1
- package/dist/chunks/switcher-BietN6il.js +1 -0
- package/dist/chunks/{switcher-DSt2cVjA.js → switcher-rep86o4_.js} +1 -1
- package/dist/chunks/{tasks-DyBUXnQb.js → tasks-B4coTfrq.js} +1 -1
- package/dist/chunks/{templateJobs-BBnReWWj.js → templateJobs-C5ukh6H3.js} +1 -1
- package/dist/chunks/{terminalSetup-CDpFfqqV.js → terminalSetup-CaGbEVjB.js} +1 -1
- package/dist/chunks/{terminalSetup-DedaY1P7.js → terminalSetup-xe_P98fY.js} +1 -1
- package/dist/chunks/{theme-BZOy9Iqh.js → theme-7RmvErYJ.js} +1 -1
- package/dist/chunks/{tipRegistry-Cl5sdLRX.js → tipRegistry-BYpJZIjR.js} +1 -1
- package/dist/chunks/{toolEventObserver-ClwWmVbH.js → toolEventObserver-Dzwzi5Vi.js} +1 -1
- package/dist/chunks/{toolPool-DSTbgGmX.js → toolPool-BGfiNj6h.js} +1 -1
- package/dist/chunks/{useExitOnCtrlCDWithKeybindings-ClN4NJnB.js → useExitOnCtrlCDWithKeybindings-BT0nexZw.js} +1 -1
- package/dist/chunks/useMainLoopModel-QuE7VkgX.js +1 -0
- package/dist/chunks/{useManagePlugins-CxHz-gUP.js → useManagePlugins-pGaGzsEg.js} +1 -1
- package/dist/chunks/{useMergedTools-BUuWew0-.js → useMergedTools-BLsIT3R_.js} +1 -1
- package/dist/chunks/{useSearchInput-BIQN_-Hm.js → useSearchInput-j12K4wEo.js} +1 -1
- package/dist/chunks/{useSettingsErrors-BDJCLei_.js → useSettingsErrors-C8VIzdws.js} +1 -1
- package/dist/chunks/{util-BHr5l6Bx.js → util-CCEK8oze.js} +1 -1
- package/dist/chunks/{validatePlugin-fx1Y8vam.js → validatePlugin-CTVnWx9H.js} +1 -1
- package/dist/chunks/{vim-CYjMtnwH.js → vim-BlO9V5_5.js} +1 -1
- package/dist/chunks/worktree-BWL0vR4o.js +1 -0
- package/dist/chunks/wrapper-B-Q3Illb.js +1 -0
- package/dist/chunks/{wrapper-K8ZapJVu.js → wrapper-DVKxC5fR.js} +1 -1
- package/dist/cli.js +1 -1
- package/package.json +2 -1
- package/dist/chunks/AgentsMdExternalIncludesDialog-CgSethgo.js +0 -1
- package/dist/chunks/Doctor-CiZNe_qx.js +0 -1
- package/dist/chunks/REPL-BHk0vZDf.js +0 -1
- package/dist/chunks/SearchExtraToolsTool-CdWB9sO8.js +0 -1
- package/dist/chunks/backgroundHousekeeping-B56nFTzq.js +0 -1
- package/dist/chunks/caches-D7arwhaa.js +0 -1
- package/dist/chunks/commands-AcfFLgl5.js +0 -1
- package/dist/chunks/config-BhBcadjZ.js +0 -1
- package/dist/chunks/config-Bm5pVdCq.js +0 -1
- package/dist/chunks/context-noninteractive-BK2IDLSS.js +0 -1
- package/dist/chunks/conversation-B2dX3X4Z.js +0 -1
- package/dist/chunks/doctor-CQf8xPZH.js +0 -1
- package/dist/chunks/extractMemories-8yvMGZ1J.js +0 -1
- package/dist/chunks/fast-aNkj6WvB.js +0 -1
- package/dist/chunks/fetchModelList-D2quBF6M.js +0 -1
- package/dist/chunks/hooks-B5Wq-KxE.js +0 -1
- package/dist/chunks/loadAgentsDir-BBbIAiay.js +0 -1
- package/dist/chunks/localSearch-D6MhwvnR.js +0 -1
- package/dist/chunks/managedEnv-ulQBH73B.js +0 -1
- package/dist/chunks/pluginStartupCheck-Du9yx2P8.js +0 -1
- package/dist/chunks/prompt-BZmu5CeK.js +0 -1
- package/dist/chunks/prompt-Cogr_WZr.js +0 -1
- package/dist/chunks/sandbox-adapter-Df7Wpt77.js +0 -1
- package/dist/chunks/searchExtraTools-CbJVb_Zk.js +0 -1
- package/dist/chunks/sessionFileAccessHooks-_mxyfQmn.js +0 -1
- package/dist/chunks/sessionObserver-BZVgzp3W.js +0 -1
- package/dist/chunks/sessionStorage-SC5RfnUP.js +0 -1
- package/dist/chunks/sinks-D41OiGE4.js +0 -1
- package/dist/chunks/status-6JMz8jmM.js +0 -1
- package/dist/chunks/switcher-95d4TrQH.js +0 -1
- package/dist/chunks/useMainLoopModel-Bgxpmn2Q.js +0 -1
- package/dist/chunks/worktree-CGu_58ue.js +0 -1
|
@@ -1 +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-BX54x08P.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-uuZYOgKn.js";import{a as ee,i as E}from"./debug-2pVES-2G.js";import{l as te,n as D,o as O}from"./stringUtils-Cs6E5f-B.js";import{i as k,n as A,r as j}from"./MCPConnectionManager-CBY8nqdU.js";import{t as ne}from"./select-BuTJbu_Q.js";import{r as M,t as re}from"./Spinner-DOI8qqZi.js";import{t as ie}from"./CustomSelect-CYmc4vRh.js";import{n as ae,t as N}from"./McpParsingWarnings-Dj_Fu5o-.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-C7HT6rrl.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};
|
|
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-BX54x08P.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-bmpKLPdG.js";import{a as ee,i as E}from"./debug-2pVES-2G.js";import{l as te,n as D,o as O}from"./stringUtils-Cs6E5f-B.js";import{i as k,n as A,r as j}from"./MCPConnectionManager-C7RmKzJh.js";import{t as ne}from"./select-CaxQ-BVq.js";import{r as M,t as re}from"./Spinner-C0qHjfIY.js";import{t as ie}from"./CustomSelect-t4wXuXWH.js";import{n as ae,t as N}from"./McpParsingWarnings-Czze2JPd.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-CewNLJus.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};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{bn as e,vn as t}from"./settings-D4M13toi.js";import{$d as n,Ad as r,Df as i,Hd as a,Id as o,Of as s,Pd as c,Qd as l,Vd as u,cf as d,gi as f,mf as p,mi as m,nf as h,of as g,sf as _,uf as v}from"./loadAgentsDir-
|
|
1
|
+
import{bn as e,vn as t}from"./settings-D4M13toi.js";import{$d as n,Ad as r,Df as i,Hd as a,Id as o,Of as s,Pd as c,Qd as l,Vd as u,cf as d,gi as f,mf as p,mi as m,nf as h,of as g,sf as _,uf as v}from"./loadAgentsDir-bmpKLPdG.js";import{I as y,z as b}from"./debug-2pVES-2G.js";import{a as x,d as S,m as C,o as w}from"./config-Bio2EjUK.js";import{n as T}from"./analytics-COpjZpvd.js";import{n as E,t as D}from"./exit-s9XGerrH.js";import{stat as O}from"fs/promises";import{cwd as k}from"process";i(),T(),o(),v(),n(),S(),y(),f(),t();async function A(e,t){try{let n=await r(e,t);return n.type===`connected`?`✓ Connected`:n.type===`needs-auth`?`! Needs authentication`:`✗ Failed to connect`}catch{return`✗ Connection error`}}async function j({debug:e,verbose:t}){let n=k();try{await O(n)}catch(e){throw b(e)&&D(`Error: Directory ${n} does not exist`),e}try{let{setup:r}=await import(`./setup-DVLnIlse.js`);await r(n,`default`,!1,!1,void 0,!1);let{startMCPServer:i}=await import(`./mcp-BMeWtYCx.js`);await i(n,e??!1,t??!1)}catch(e){D(`Error: Failed to start MCP server: ${e}`)}}async function M(e,t){_(e);try{if(t.scope){let n=a(t.scope);await p(e,n),process.stdout.write(`Removed MCP server ${e} from ${n} config\n`),E(`File modified: ${u(n)}`)}let n=x(),r=w(),{servers:i}=d(`project`),o=!!i[e],s=[];if(n.mcpServers?.[e]&&s.push(`local`),o&&s.push(`project`),r.mcpServers?.[e]&&s.push(`user`),s.length===0)D(`No MCP server found with name: "${e}"`);else if(s.length===1){let t=s[0];await p(e,t),process.stdout.write(`Removed MCP server "${e}" from ${t} config\n`),E(`File modified: ${u(t)}`)}else process.stderr.write(`MCP server "${e}" exists in multiple scopes:\n`),s.forEach(e=>{process.stderr.write(` - ${l(e)} (${u(e)})\n`)}),process.stderr.write(`
|
|
2
2
|
To remove from a specific scope, use:
|
|
3
3
|
`),s.forEach(t=>{process.stderr.write(` wm mcpremove "${e}" -s ${t}\n`)}),D()}catch(e){D(e.message)}}async function N(){let{servers:e}=await g();if(Object.keys(e).length===0)console.log("No MCP servers configured. Use `wm mcpadd` to add a server.");else{console.log(`Checking MCP server health...
|
|
4
4
|
`);let t=await s(Object.entries(e),async([e,t])=>({name:e,server:t,status:await A(e,t)}),{concurrency:c()});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 m(0)}async function P(e){let t=_(e);t||D(`No MCP server found with name: ${e}`),console.log(`${e}:`),console.log(` Scope: ${l(t.scope)}`);let n=await A(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: wm mcpremove "${e}" -s ${t.scope}`),await m(0)}async function F(t,n,r){try{let i=a(r.scope),o=e(n);await h(t,o,i),E(`Added ${o&&typeof o==`object`&&`type`in o?String(o.type||`stdio`):`stdio`} MCP server ${t} to ${i} config`)}catch(e){D(e.message)}}async function I(){C(e=>({...e,enabledMcpjsonServers:[],disabledMcpjsonServers:[],enableAllProjectMcpServers:!1})),E(`All project-scoped (.mcp.json) server approvals and rejections have been reset.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{i as n,o as r}from"./envUtils-QyzA_cFM.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-BX54x08P.js";import{t as p}from"./jsx-runtime-Bb4Xn-E0.js";import{In as m,Nn as te,m as h,qr as g,y as _,zr as v}from"./settings-D4M13toi.js";import{Pt as y,q as b}from"./state-CXY-q5gr.js";import{Bh as x,Dy as S,Kl as C,dw as w,fc as T,ky as E,pc as ne,pw as D,ql as re,tb as O,wy as k,xu as ie,yu as A,zh as j}from"./loadAgentsDir-
|
|
1
|
+
import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{i as n,o as r}from"./envUtils-QyzA_cFM.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-BX54x08P.js";import{t as p}from"./jsx-runtime-Bb4Xn-E0.js";import{In as m,Nn as te,m as h,qr as g,y as _,zr as v}from"./settings-D4M13toi.js";import{Pt as y,q as b}from"./state-CXY-q5gr.js";import{Bh as x,Dy as S,Kl as C,dw as w,fc as T,ky as E,pc as ne,pw as D,ql as re,tb as O,wy as k,xu as ie,yu as A,zh as j}from"./loadAgentsDir-bmpKLPdG.js";import{n as M,t as N}from"./cwd-DrEEb4f5.js";import{I as P,N as F}from"./debug-2pVES-2G.js";import{C as I,T as L,b as ae}from"./config-Bio2EjUK.js";import{o as R,s as oe}from"./log-L1kqxa_P.js";import{n as se}from"./analytics-COpjZpvd.js";import{_ as ce,p as z}from"./startupProfiler-B9Qv2QGH.js";import{n as B,t as V}from"./useExitOnCtrlCDWithKeybindings-BT0nexZw.js";import{t as H}from"./select-CaxQ-BVq.js";import{r as U,t as W}from"./promptEditor-14TB3MYt.js";import{t as le}from"./CustomSelect-t4wXuXWH.js";import{homedir as ue}from"os";import{join as G,relative as de}from"path";import{mkdir as K,writeFile as fe}from"fs/promises";function pe(e){return v(e)!==null}var me=e((()=>{g()}));function he({onSelect:e,onCancel:t}){let r=(0,q.use)(S()),a=G(n(),`AGENTS.md`),l=G(b(),`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=te(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=pe(b());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}}),h=[],g=x(e=>e.agentDefinitions);if(L()){h.push({label:`Open auto-memory folder`,value:`${X}${ae()}`,description:``});for(let e of g.activeAgents)if(e.memory){let t=w(e.agentType,e.memory);h.push({label:`Open ${ee.bold(e.agentType)} agent memory`,value:`${X}${t}`,description:`${e.memory} scope`})}}m.push(...h);let v=Y&&m.some(e=>e.value===Y)?Y:m[0]?.value||``,[y,C]=(0,q.useState)(L),[T,E]=(0,q.useState)(ne),[D]=(0,q.useState)(L),O=x(e=>Object.values(e.tasks).some(e=>e.type===`dream`&&e.status===`running`)),[k,A]=(0,q.useState)(null);(0,q.useEffect)(()=>{D&&re().then(A)},[D,O]);let j=O?`running`:k===null?``:k===0?`never`:`last ran ${z(new Date(k))}`,[M,N]=(0,q.useState)(null),P=M!==null,F=+!!D;function I(){let e=!y;_(`userSettings`,{autoMemoryEnabled:e}),C(e)}function R(){let e=!T;_(`userSettings`,{autoDreamEnabled:e}),E(e)}return B(),s(`confirm:no`,t,{context:`Confirmation`}),s(`confirm:yes`,()=>{M===0?I():M===1&&R()},{context:`Confirmation`,isActive:P}),s(`select:next`,()=>{N(e=>e!==null&&e<F?e+1:null)},{context:`Select`,isActive:P}),s(`select:previous`,()=>{N(e=>e!==null&&e>0?e-1:e)},{context:`Select`,isActive:P}),(0,J.jsxs)(i,{flexDirection:`column`,width:`100%`,children:[(0,J.jsxs)(i,{flexDirection:`column`,marginBottom:1,children:[(0,J.jsx)(c,{isFocused:M===0,children:(0,J.jsxs)(o,{children:[`Auto-memory: `,y?`on`:`off`]})}),D&&(0,J.jsx)(c,{isFocused:M===1,styled:!1,children:(0,J.jsxs)(o,{color:M===1?`suggestion`:void 0,children:[`Auto-dream: `,T?`on`:`off`,j&&(0,J.jsxs)(o,{dimColor:!0,children:[` · `,j]}),!O&&T&&(0,J.jsx)(o,{dimColor:!0,children:` · /dream to run`})]})})]}),(0,J.jsx)(H,{defaultFocusValue:v,options:m,isDisabled:P,onChange:t=>{if(t.startsWith(X)){let e=t.slice(15);K(e,{recursive:!0}).catch(()=>{}).then(()=>ie(e));return}Y=t,e(t)},onCancel:t,onUpFromFirstItem:()=>N(F)})]})}var q,J,Y,X,ge=e((()=>{u(),q=t(l(),1),y(),V(),d(),O(),I(),se(),T(),C(),j(),D(),A(),E(),r(),m(),ce(),me(),h(),le(),J=p(),X=`__open_folder__`}));function _e(e){let t=ue(),n=N(),r=e.startsWith(t)?`~${e.slice(t.length)}`:null,i=e.startsWith(n)?`./${de(n,e)}`:null;return r&&i?r.length<=i.length?r:i:r||i||e}var ve=e((()=>{d(),M(),p()}));function ye({onDone:e}){let t=async t=>{try{t.includes(n())&&await K(n(),{recursive:!0});try{await fe(t,``,{encoding:`utf8`,flag:`wx`})}catch(e){if(F(e)!==`EEXIST`)throw e}await W(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){oe(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)(he,{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(),ge(),ve(),E(),r(),P(),R(),U(),Q=p(),$=async e=>(k(),await S(),(0,Q.jsx)(ye,{onDone:e}))}))();export{$ as call};
|
|
@@ -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-BX54x08P.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-
|
|
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-BX54x08P.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-bmpKLPdG.js";import{n as d,t as f}from"./select-CaxQ-BVq.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};
|
|
@@ -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-BX54x08P.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-
|
|
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-BX54x08P.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-bmpKLPdG.js";import{A as y,k as b,q as x}from"./log-L1kqxa_P.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-Dd3x121y.js";import{i as j,r as M}from"./switcher-rep86o4_.js";import{i as N,n as P,r as F,t as I}from"./extraUsage-CmgRR-zH.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,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-QyzA_cFM.js";import{$t as c,Ni as te,Wi as ne,bn as l,d as u,ea as d,en as f,m as p,oa as re,t as m,ta as ie,vn as ae}from"./settings-D4M13toi.js";import{G as h,Pt as oe,Sn as se,U as ce,at as le,vr as ue,yr as de}from"./state-CXY-q5gr.js";import{C as fe,H as pe,U as me,c as g,i as he,o as _,x as ge}from"./debug-2pVES-2G.js";import{d as _e,o as ve}from"./config-BDn2YIjC.js";import{d as ye,f as be,o as xe,s as v}from"./log-L1kqxa_P.js";import{n as Se,o as Ce}from"./stringUtils-Cs6E5f-B.js";import{c as we,i as Te,r as Ee}from"./proxy--_NfbJhm.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=m()){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((()=>{p(),o()}));function Pe(){return Ie.getStore()?.workload}function Fe(e,t){return Ie.run({workload:e},t)}var Ie,Le=e((()=>{Ie=new Me})),S,C,Re,ze,Be,Ve,He,Ue,We,Ge,Ke,qe,Je,Ye=e((()=>{S=`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([S,C,ze])}));function Xe(e,t){return ue(e,t)}var Ze=e((()=>{de()}));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.27 (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.27${e.length>0?` (${e.join(`, `)})`:``}`}var et=e((()=>{Le()}));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,te=process.env.WORKMATE_REMOTE_SESSION_ID,ne=process.env.CLAUDE_AGENT_SDK_CLIENT_APP,l=nt(),u={"x-app":`cli`,"User-Agent":Qe(),"X-Work-Mate-Session-Id":le(),...l,...c?{"x-claude-remote-container-id":c}:{},...te?{"x-claude-remote-session-id":te}:{},...ne?{"x-client-app":ne}:{},...process.env.ANTHROPIC_AUTH_NONCE?{"x-auth-nonce":process.env.ANTHROPIC_AUTH_NONCE}:{}};g(`[API:request] Creating client, ANTHROPIC_CUSTOM_HEADERS present: ${!!process.env.ANTHROPIC_CUSTOM_HEADERS}, has Authorization header: ${!!l.Authorization}`),a(process.env.WORKMATE_ADDITIONAL_PROTECTION)&&(u[`x-anthropic-additional-protection`]=`true`);let d=rt(i,o),f={defaultHeaders:u,maxRetries:n,timeout:parseInt(process.env.API_TIMEOUT_MS||`600000`,10),dangerouslyAllowBrowser:!0,fetchOptions:Te({forAnthropicAPI:!0}),...d&&{fetch:d}};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={...f,awsRegion:t,...a(process.env.WORKMATE_SKIP_BEDROCK_AUTH)&&{skipAuth:!0},..._()&&{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({...f,...t&&{azureADTokenProvider:t},..._()&&{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({...f,region:ee(r),googleAuth:s,..._()&&{logger:w()}})}return new me({...e?{apiKey:e}:{},...f,..._()&&{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);g(`[API REQUEST] ${new URL(n).pathname}${r?` ${T}=${r}`:``} source=${t??`unknown`}`)}catch{}return n(e,{...i,headers:a})}}var T,it=e((()=>{pe(),et(),$(),x(),we(),oe(),he(),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=E(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=dt().safeParse(n);e.success&&t.push(e.data)}if(t.length===0)return;let n=ot(),r=ct(t);if(Xe(E(n),r)){g(`[modelCapabilities] cache unchanged, skipping write`);return}await Ae(at(),{recursive:!0}),await je(n,fe({models:r,timestamp:Date.now()}),{encoding:`utf-8`,mode:384}),E.cache.delete(n),g(`[modelCapabilities] cached ${r.length} models`)}catch(e){g(`[modelCapabilities] fetch failed: ${e instanceof Error?e.message:`unknown`}`)}}var dt,ft,E,pt=e((()=>{Ze(),r(),te(),it(),he(),o(),ae(),c(),ye(),ge(),x(),dt=f(()=>ie({id:re(),max_input_tokens:d().optional(),max_tokens:d().optional()}).strip()),ft=f(()=>ie({models:ne(dt()),timestamp:d()})),E=n(e=>{try{let t=Oe(e,`utf-8`),n=ft().safeParse(l(t,!1));return n.success?n.data.models:null}catch{return null}},e=>e)}));function D(){return a(process.env.WORKMATE_DISABLE_1M_CONTEXT)}function O(e){return!D()&&/\[1m\]/i.test(e)}function mt(e){if(D())return!1;let t=Z(e);return t.includes(`claude-sonnet-4`)||t.includes(`opus-4-6`)||t.includes(`opus-4-7`)}function ht(e,t){if(O(e))return 1e6;let n=lt(e);return n?.max_input_tokens&&n.max_input_tokens>=1e5?n.max_input_tokens>2e5&&D()?bt:n.max_input_tokens:t?.includes(`context-1m-2025-08-07`)&&mt(e)||gt(e)?1e6:bt}function gt(e){return D()||O(e)||!Z(e).includes(`sonnet-4-6`)?!1:ve().clientDataCache?.coral_reef_sonnet===`true`}function _t(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 vt(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=St,n=Ct);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 yt(e){return vt(e).upperLimit-1}var bt,xt,St,Ct,wt,Tt=e((()=>{Ye(),_e(),o(),$(),pt(),bt=2e5,xt=2e4,St=32e3,Ct=64e3,wt=8e3}));function Et(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 Dt=e((()=>{}));function Ot(e,t){return e.find(e=>e.includes(t))??null}async function kt(){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 At(){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 jt(e){return e.startsWith(`anthropic.`)}function Mt(e){if(!e.startsWith(`arn:`))return e;let t=e.lastIndexOf(`/`);return t===-1?e:e.substring(t+1)}function Nt(e){let t=Mt(e);for(let e of It)if(t.startsWith(`${e}.anthropic.`))return e}function Pt(e,t){let n=Nt(e);return n?e.replace(`${n}.`,`${t}.`):jt(e)?`${t}.${e}`:e}var k,Ft,It,Lt=e((()=>{r(),o(),xe(),we(),k=n(async()=>{let[e,{ListInferenceProfilesCommand:t}]=await Promise.all([kt(),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}}),Ft=n(async e=>{try{let[t,{GetInferenceProfileCommand:n}]=await Promise.all([kt(),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}}),It=[`us`,`eu`,`apac`,`global`]})),A,j,M,N,P,F,I,L,R,z,Rt,B,V,zt,Bt=e((()=>{A={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`},j={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`},M={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`},N={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`},P={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`},F={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`},I={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`},L={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`},R={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`},z={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`},Rt={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`},B={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:M,haiku45:N,sonnet35:j,sonnet37:A,sonnet40:P,sonnet45:F,sonnet46:B,opus40:I,opus41:L,opus45:R,opus46:z,opus47:Rt},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 W)t[n]=V[n][e];return t}async function Vt(){let e=H(`bedrock`),t;try{t=await k()}catch(t){return v(t),e}if(!t?.length)return e;let n={};for(let r of W){let i=V[r].firstParty;n[r]=Ot(t,i)||e[r]}return n}function Ht(e){let t=m().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=m().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(h()===null){if(y()!==`bedrock`){se(H(y()));return}Kt()}}function U(){let e=h();return e===null?(Wt(),Ht(H(y()))):Ht(e)}async function Gt(){if(h()===null){if(y()!==`bedrock`){se(H(y()));return}await Kt()}}var W,Kt,qt=e((()=>{oe(),xe(),Dt(),p(),Lt(),Bt(),x(),W=Object.keys(V),Kt=Et(async()=>{if(h()===null)try{se(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}=u()||{};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((()=>{p(),Xt(),$(),qt()}));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=ce();if(t!==void 0)e=t;else{let t=u()||{};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!(D()||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=O(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 O(e)||!O(t)?e:mt(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((()=>{oe(),Tt(),o(),qt(),p(),x(),nn(),Xt(),Ce(),on(),On=[`claude-opus-4-20250514`,`claude-opus-4-1-20250805`,`claude-opus-4-0`,`claude-opus-4-1`]}));export{_t as $,M as A,Le as At,P as B,nn as C,Ge as Ct,Gt as D,S as Dt,Xt as E,Je as Et,R as F,b as Ft,Nt as G,Pt as H,z as I,jt as J,Ft as K,I as L,A as M,y as Mt,N,Ne as Nt,U as O,Ye as Ot,L as P,x as Pt,xt as Q,F as R,Sn as S,Ue as St,Jt as T,He as Tt,At as U,Bt as V,k as W,Et as X,Dt as Y,wt as Z,Dn as _,qe as _t,Y as a,Tt as at,xn as b,We as bt,En as c,ut as ct,J as d,it as dt,ht as et,$ as f,$e as ft,Tn as g,Ke as gt,vn as h,Xe as ht,mn as i,O as it,j,Fe as jt,qt as k,Pe as kt,pn as l,T as lt,cn as m,Ze as mt,Z as n,vt as nt,X as o,D as ot,wn as p,et as pt,Lt as q,hn as r,gt as rt,ln as s,pt as st,gn as t,yt 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,B as z};
|
|
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-QyzA_cFM.js";import{$t as c,Ni as te,Wi as ne,bn as l,d as u,ea as d,en as f,m as p,oa as re,t as m,ta as ie,vn as ae}from"./settings-D4M13toi.js";import{G as h,Pt as oe,Sn as se,U as ce,at as le,vr as ue,yr as de}from"./state-CXY-q5gr.js";import{C as fe,H as pe,U as me,c as g,i as he,o as _,x as ge}from"./debug-2pVES-2G.js";import{d as _e,o as ve}from"./config-Bio2EjUK.js";import{d as ye,f as be,o as xe,s as v}from"./log-L1kqxa_P.js";import{n as Se,o as Ce}from"./stringUtils-Cs6E5f-B.js";import{c as we,i as Te,r as Ee}from"./proxy--_NfbJhm.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=m()){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((()=>{p(),o()}));function Pe(){return Ie.getStore()?.workload}function Fe(e,t){return Ie.run({workload:e},t)}var Ie,Le=e((()=>{Ie=new Me})),S,C,Re,ze,Be,Ve,He,Ue,We,Ge,Ke,qe,Je,Ye=e((()=>{S=`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([S,C,ze])}));function Xe(e,t){return ue(e,t)}var Ze=e((()=>{de()}));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.28 (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.28${e.length>0?` (${e.join(`, `)})`:``}`}var et=e((()=>{Le()}));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,te=process.env.WORKMATE_REMOTE_SESSION_ID,ne=process.env.CLAUDE_AGENT_SDK_CLIENT_APP,l=nt(),u={"x-app":`cli`,"User-Agent":Qe(),"X-Work-Mate-Session-Id":le(),...l,...c?{"x-claude-remote-container-id":c}:{},...te?{"x-claude-remote-session-id":te}:{},...ne?{"x-client-app":ne}:{},...process.env.ANTHROPIC_AUTH_NONCE?{"x-auth-nonce":process.env.ANTHROPIC_AUTH_NONCE}:{}};g(`[API:request] Creating client, ANTHROPIC_CUSTOM_HEADERS present: ${!!process.env.ANTHROPIC_CUSTOM_HEADERS}, has Authorization header: ${!!l.Authorization}`),a(process.env.WORKMATE_ADDITIONAL_PROTECTION)&&(u[`x-anthropic-additional-protection`]=`true`);let d=rt(i,o),f={defaultHeaders:u,maxRetries:n,timeout:parseInt(process.env.API_TIMEOUT_MS||`600000`,10),dangerouslyAllowBrowser:!0,fetchOptions:Te({forAnthropicAPI:!0}),...d&&{fetch:d}};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={...f,awsRegion:t,...a(process.env.WORKMATE_SKIP_BEDROCK_AUTH)&&{skipAuth:!0},..._()&&{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({...f,...t&&{azureADTokenProvider:t},..._()&&{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({...f,region:ee(r),googleAuth:s,..._()&&{logger:w()}})}return new me({...e?{apiKey:e}:{},...f,..._()&&{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);g(`[API REQUEST] ${new URL(n).pathname}${r?` ${T}=${r}`:``} source=${t??`unknown`}`)}catch{}return n(e,{...i,headers:a})}}var T,it=e((()=>{pe(),et(),$(),x(),we(),oe(),he(),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=E(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=dt().safeParse(n);e.success&&t.push(e.data)}if(t.length===0)return;let n=ot(),r=ct(t);if(Xe(E(n),r)){g(`[modelCapabilities] cache unchanged, skipping write`);return}await Ae(at(),{recursive:!0}),await je(n,fe({models:r,timestamp:Date.now()}),{encoding:`utf-8`,mode:384}),E.cache.delete(n),g(`[modelCapabilities] cached ${r.length} models`)}catch(e){g(`[modelCapabilities] fetch failed: ${e instanceof Error?e.message:`unknown`}`)}}var dt,ft,E,pt=e((()=>{Ze(),r(),te(),it(),he(),o(),ae(),c(),ye(),ge(),x(),dt=f(()=>ie({id:re(),max_input_tokens:d().optional(),max_tokens:d().optional()}).strip()),ft=f(()=>ie({models:ne(dt()),timestamp:d()})),E=n(e=>{try{let t=Oe(e,`utf-8`),n=ft().safeParse(l(t,!1));return n.success?n.data.models:null}catch{return null}},e=>e)}));function D(){return a(process.env.WORKMATE_DISABLE_1M_CONTEXT)}function O(e){return!D()&&/\[1m\]/i.test(e)}function mt(e){if(D())return!1;let t=Z(e);return t.includes(`claude-sonnet-4`)||t.includes(`opus-4-6`)||t.includes(`opus-4-7`)}function ht(e,t){if(O(e))return 1e6;let n=lt(e);return n?.max_input_tokens&&n.max_input_tokens>=1e5?n.max_input_tokens>2e5&&D()?bt:n.max_input_tokens:t?.includes(`context-1m-2025-08-07`)&&mt(e)||gt(e)?1e6:bt}function gt(e){return D()||O(e)||!Z(e).includes(`sonnet-4-6`)?!1:ve().clientDataCache?.coral_reef_sonnet===`true`}function _t(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 vt(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=St,n=Ct);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 yt(e){return vt(e).upperLimit-1}var bt,xt,St,Ct,wt,Tt=e((()=>{Ye(),_e(),o(),$(),pt(),bt=2e5,xt=2e4,St=32e3,Ct=64e3,wt=8e3}));function Et(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 Dt=e((()=>{}));function Ot(e,t){return e.find(e=>e.includes(t))??null}async function kt(){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 At(){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 jt(e){return e.startsWith(`anthropic.`)}function Mt(e){if(!e.startsWith(`arn:`))return e;let t=e.lastIndexOf(`/`);return t===-1?e:e.substring(t+1)}function Nt(e){let t=Mt(e);for(let e of It)if(t.startsWith(`${e}.anthropic.`))return e}function Pt(e,t){let n=Nt(e);return n?e.replace(`${n}.`,`${t}.`):jt(e)?`${t}.${e}`:e}var k,Ft,It,Lt=e((()=>{r(),o(),xe(),we(),k=n(async()=>{let[e,{ListInferenceProfilesCommand:t}]=await Promise.all([kt(),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}}),Ft=n(async e=>{try{let[t,{GetInferenceProfileCommand:n}]=await Promise.all([kt(),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}}),It=[`us`,`eu`,`apac`,`global`]})),A,j,M,N,P,F,I,L,R,z,Rt,B,V,zt,Bt=e((()=>{A={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`},j={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`},M={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`},N={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`},P={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`},F={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`},I={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`},L={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`},R={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`},z={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`},Rt={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`},B={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:M,haiku45:N,sonnet35:j,sonnet37:A,sonnet40:P,sonnet45:F,sonnet46:B,opus40:I,opus41:L,opus45:R,opus46:z,opus47:Rt},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 W)t[n]=V[n][e];return t}async function Vt(){let e=H(`bedrock`),t;try{t=await k()}catch(t){return v(t),e}if(!t?.length)return e;let n={};for(let r of W){let i=V[r].firstParty;n[r]=Ot(t,i)||e[r]}return n}function Ht(e){let t=m().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=m().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(h()===null){if(y()!==`bedrock`){se(H(y()));return}Kt()}}function U(){let e=h();return e===null?(Wt(),Ht(H(y()))):Ht(e)}async function Gt(){if(h()===null){if(y()!==`bedrock`){se(H(y()));return}await Kt()}}var W,Kt,qt=e((()=>{oe(),xe(),Dt(),p(),Lt(),Bt(),x(),W=Object.keys(V),Kt=Et(async()=>{if(h()===null)try{se(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}=u()||{};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((()=>{p(),Xt(),$(),qt()}));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=ce();if(t!==void 0)e=t;else{let t=u()||{};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!(D()||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=O(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 O(e)||!O(t)?e:mt(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((()=>{oe(),Tt(),o(),qt(),p(),x(),nn(),Xt(),Ce(),on(),On=[`claude-opus-4-20250514`,`claude-opus-4-1-20250805`,`claude-opus-4-0`,`claude-opus-4-1`]}));export{_t as $,M as A,Le as At,P as B,nn as C,Ge as Ct,Gt as D,S as Dt,Xt as E,Je as Et,R as F,b as Ft,Nt as G,Pt as H,z as I,jt as J,Ft as K,I as L,A as M,y as Mt,N,Ne as Nt,U as O,Ye as Ot,L as P,x as Pt,xt as Q,F as R,Sn as S,Ue as St,Jt as T,He as Tt,At as U,Bt as V,k as W,Et as X,Dt as Y,wt as Z,Dn as _,qe as _t,Y as a,Tt as at,xn as b,We as bt,En as c,ut as ct,J as d,it as dt,ht as et,$ as f,$e as ft,Tn as g,Ke as gt,vn as h,Xe as ht,mn as i,O as it,j,Fe as jt,qt as k,Pe as kt,pn as l,T as lt,cn as m,Ze as mt,Z as n,vt as nt,X as o,D as ot,wn as p,et as pt,Lt as q,hn as r,gt as rt,ln as s,pt as st,gn as t,yt 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,B as z};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{d as t,m as n}from"./settings-D4M13toi.js";import{Pt as r,j as i}from"./state-CXY-q5gr.js";import{gy as a,my as o,vy as s}from"./loadAgentsDir-
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{d as t,m as n}from"./settings-D4M13toi.js";import{Pt as r,j as i}from"./state-CXY-q5gr.js";import{gy as a,my as o,vy as s}from"./loadAgentsDir-bmpKLPdG.js";import{d as c,o as l}from"./config-Bio2EjUK.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-Dd3x121y.js";function v(e=!1){let t=d()!==`firstParty`;return{value:null,label:`Default (recommended)`,description:`Use the default model (currently ${_(h())})${t?``:` · ${a(o)}`}`}}function y(e=!1){let t=[v(e)],n=process.env.ANTHROPIC_CUSTOM_MODEL_OPTION;n&&!t.some(e=>e.value===n)&&t.push({value:n,label:process.env.ANTHROPIC_CUSTOM_MODEL_OPTION_NAME??n,description:process.env.ANTHROPIC_CUSTOM_MODEL_OPTION_DESCRIPTION??`Custom model (${n})`});for(let e of l().additionalModelOptionsCache??[])t.some(t=>t.value===e.value)||t.push(e);let r=null,a=p(),o=i();return a==null?o!==null&&(r=o):r=a,r!==null&&!t.some(e=>e.value===r)&&t.push({value:r,label:r,description:`Custom model`}),b(t)}function b(e){return(t()||{}).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((()=>{r(),c(),s(),n(),u(),m(),f()}));export{y as n,S as r,x as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{l as t,o as n}from"./envUtils-QyzA_cFM.js";import{n as r,t as i}from"./axios-DaWTGg7G.js";import{Xt as a,qt as o}from"./settings-D4M13toi.js";import{$ as s,I as c,M as l,N as u,R as d,V as f,c as p,et as ee,f as te,i as m,u as ne}from"./debug-2pVES-2G.js";import{d as re,h as ie,o as ae}from"./config-BDn2YIjC.js";import{o as h,s as g}from"./log-L1kqxa_P.js";import{i as _,n as v}from"./execFileNoThrow-DXSEj8ZO.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 x,t as le,v as ue,y as de}from"./sleep-xKMbXTJe.js";import{j as fe,k as pe}from"./sessionTracing-DsdcOqvc.js";import{C as me,E as he,S as ge,T as _e,_ as ve,a as S,b as ye,c as be,d as xe,f as Se,g as Ce,i as we,l as Te,m as Ee,n as De,o as C,p as Oe,s as ke,t as Ae,u as je,v as Me,w as Ne,x as w,y as Pe}from"./pidLock-CFUBtZck.js";import{homedir as T}from"os";import{basename as Fe,delimiter as Ie,dirname as E,join as D,resolve as O}from"path";import{constants as Le}from"fs";import{createHash as Re}from"crypto";import{access as k,chmod as A,copyFile as j,mkdir as M,readdir as N,readlink as P,rename as F,rm as I,rmdir as ze,stat as L,symlink as Be,unlink as R,writeFile as z}from"fs/promises";async function Ve(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 He(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 Ve(t,B)}function Ue(){return Number(process.env.WORKMATE_STALL_TIMEOUT_MS_FOR_TESTING)||V}async function We(e,t,n,i={}){let a;for(let o=1;o<=H;o++){let s=new AbortController,c,l=()=>{c&&(clearTimeout(c),c=void 0)},u=()=>{l(),c=setTimeout(e=>e.abort(),Ue(),s)};try{u();let a=await r.get(e,{timeout:5*6e4,responseType:`arraybuffer`,signal:s.signal,onDownloadProgress:()=>{u()},...i});l();let o=Re(`sha256`);o.update(a.data);let c=o.digest(`hex`);if(c!==t)throw Error(`Checksum mismatch: expected ${t}, got ${c}`);await z(n,Buffer.from(a.data)),await A(n,493);return}catch(e){l();let t=r.isCancel(e);if(a=t?new U:f(e),t&&o<H){p(`Download stalled on attempt ${o}/${H}, retrying...`),await x(1e3);continue}throw a}}throw a??Error(`Download failed after all retries`)}async function Ge(e,t,n,i){let a=ne();await a.rm(t,{recursive:!0,force:!0});let o=W(),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=G(o),f=`${n}/${e}/${o}/${d}`;await a.mkdir(t);let p=D(t,d);try{await We(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 Ke(e,t){return await Ge(e,t,B),`binary`}var B,V,H,U,qe=e((()=>{i(),y(),m(),c(),_(),te(),h(),le(),$(),B=`https://downloads.workmate.ai/native-releases`,V=6e4,H=3,U=class extends Error{constructor(){super(`Download stalled: no data received for 60 seconds`),this.name=`StallTimeoutError`}}}));function W(){let e=o.platform,t=process.arch===`x64`?`x64`:process.arch===`arm64`?`arm64`:null;if(!t){let e=Error(`Unsupported architecture: ${process.arch}`);throw p(`Native installer does not support architecture: ${process.arch}`,{level:`error`}),e}return e===`linux`&&pe.isMuslEnvironment()?`linux-${t}-musl`:`${e}-${t}`}function G(e){return e.startsWith(`win32`)?`claude.exe`:`claude`}function K(){let e=G(W());return{versions:D(xe(),`claude`,`versions`),staging:D(je(),`claude`,`staging`),locks:D(Se(),`claude`,`locks`),executable:D(Te(),e)}}async function q(e){try{let t=await L(e);return!t.isFile()||t.size===0?!1:(await k(e,Le.X_OK),!0)}catch{return!1}}async function J(e){let t=K(),n=[t.versions,t.staging,t.locks];await Promise.all(n.map(e=>M(e,{recursive:!0}))),await M(E(t.executable),{recursive:!0});let r=D(t.versions,e);try{await L(r)}catch{await z(r,``,{encoding:`utf8`})}return{stagingPath:D(t.staging,e),installPath:r}}async function Je(e,t,n=0){let r=K(),i=Y(r,e);if(await M(r.locks,{recursive:!0}),C()){let r=0,a=n+1,o=n>0?1e3:100,s=n>0?5e3:500;for(;r<a;){if(await be(e,i,async()=>{try{await t()}catch(e){throw g(e),e}}))return r+1,!0;r++,r<a&&await x(Math.min(o*2**(r-1),s))}return X(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=>{p(`NON-FATAL: Version lock was compromised during operation: ${e.message}`,{level:`info`})}})}catch(t){return X(e,t),!1}try{return await t(),!0}catch(e){throw g(e),e}}finally{a&&await a()}}async function Ye(e,t){await M(E(t),{recursive:!0});let n=`${t}.tmp.${process.pid}.${Date.now()}`;try{await j(e,n),await A(n,493),await F(n,t),p(`Atomically installed binary to ${t}`)}catch(e){try{await R(n)}catch{}throw e}}async function Xe(e,t){try{let n=D(e,`node_modules`,`@anthropic-ai`),r=(await N(n)).find(e=>e.startsWith(`claude-cli-native-`));if(!r)throw Error(`Could not find platform-specific native package`);let i=D(n,r,`cli`);try{await L(i)}catch{throw Error(`Native binary not found in staged package`)}await Ye(i,t),await I(e,{recursive:!0,force:!0})}catch(e){let t=l(e);throw!t.includes(`Could not find platform-specific`)&&t.includes(`Native binary not found`),g(f(e)),e}}async function Ze(e,t){try{let n=D(e,G(W()));try{await L(n)}catch{throw Error(`Staged binary not found`)}await Ye(n,t),await I(e,{recursive:!0,force:!0})}catch(e){throw l(e).includes(`Staged binary not found`),g(f(e)),e}}async function Qe(e,t,n){n===`npm`?await Xe(e,t):await Ze(e,t)}async function $e(e,n){let{stagingPath:r,installPath:i}=await J(e),{executable:a}=K(),o=t(process.env.ENABLE_LOCKLESS_UPDATES)?`${r}.${process.pid}.${Date.now()}`:r,s=!await et(e)||n;if(s?(p(n?`Force reinstalling native installer version ${e}`:`Downloading native installer version ${e}`),await Qe(o,i,await Ke(e,o))):p(`Version ${e} already installed, updating symlink`),await nt(a),await rt(a,i),!await q(a)){let e=!1;try{await L(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 et(e){let{installPath:t}=await J(e);return q(t)}async function tt(e,n=!1){let r=Date.now(),i=await He(e),{executable:a}=K();if(p(`Checking for native installer update to version ${i}`),!n){let e=await ve();if(e&&ue(i,e)){if(p(`Native installer: maxVersion ${e} is set, capping update from ${i} to ${e}`),de(`0.0.27`,e))return p(`Native installer: current version 0.0.27 is already at or above maxVersion ${e}, skipping update`),Date.now()-r,{success:!0,latestVersion:i};i=e}}if(!n&&i===`0.0.27`&&await et(i)&&await q(a))return p(`Found ${i} at ${a}, skipping install`),Date.now()-r,{success:!0,latestVersion:i};if(!n&&Pe(i))return Date.now()-r,{success:!0,latestVersion:i};if(t(process.env.ENABLE_LOCKLESS_UPDATES))await $e(i,n),Date.now()-r;else{let{installPath:e}=await J(i);n&&await lt(e);let t=await Je(e,async()=>{await $e(i,n)},3);if(Date.now()-r,!t){let t=K(),n;if(C()){let r=Y(t,e);S(r)&&(n=ke(r)?.pid)}return{success:!1,latestVersion:i,lockFailed:!0,lockHolderPid:n}}}return p(`Successfully updated to version ${i}`),{success:!0,latestVersion:i}}async function nt(e){try{await ze(e),p(`Removed empty directory at ${e}`)}catch(t){let n=u(t);n!==`ENOTDIR`&&n!==`ENOENT`&&n!==`ENOTEMPTY`&&p(`Could not remove directory at ${e}: ${t}`)}}async function rt(e,t){if(W().startsWith(`win32`))try{await M(E(e),{recursive:!0});let n;try{n=await L(e)}catch{}if(n){try{let e=await L(t);if(n.size===e.size)return!1}catch{}let r=`${e}.old.${Date.now()}`;await F(e,r);try{await j(t,e);try{await R(r)}catch{}}catch(t){try{await F(r,e)}catch(e){let n=Error(`Failed to restore old executable: ${e}`,{cause:t});throw g(n),n}throw t}}else try{await j(t,e)}catch(e){throw d(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=E(e);try{await M(n,{recursive:!0}),p(`Created directory ${n} for symlink`)}catch(e){return g(Error(`Failed to create directory ${n}: ${e}`)),!1}try{let n=!1;try{await L(e),n=!0}catch{}if(n){try{let n=await P(e);if(O(E(e),n)===O(t))return!1}catch{}await R(e)}}catch(e){g(Error(`Failed to check/remove existing symlink: ${e}`))}let r=`${e}.tmp.${process.pid}.${Date.now()}`;try{return await Be(t,r),await F(r,e),p(`Atomically updated symlink ${e} -> ${t}`),!0}catch(n){try{await R(r)}catch{}return g(Error(`Failed to create symlink from ${e} to ${t}: ${n}`)),!1}}async function it(e=!1){if(t(process.env.DISABLE_INSTALLATION_CHECKS))return[];let n=await Ee();if(n===`development`||!(e||n===`native`))return[];let r=K(),i=[],a=E(r.executable),o=O(a),s=W().startsWith(`win32`);try{await k(a)}catch{i.push({message:`installMethod is native, but directory ${a} does not exist`,userActionRequired:!0,type:`error`})}if(s)await q(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 P(r.executable);await q(O(E(r.executable),e))||i.push({message:`Work Mate symlink points to missing or invalid binary: ${e}`,userActionRequired:!0,type:`error`})}catch(e){d(e)?i.push({message:`installMethod is native, but claude command not found at ${r.executable}`,userActionRequired:!0,type:`error`}):await q(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(Ie).some(e=>{try{let t=O(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=_e(),t=w()[e],n=t?t.replace(T(),`~`):`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 at(e,t=!1){if(t)return ot(e,t);if(Q)return p(`installLatest: joining in-flight call`),Q;let n=ot(e,t);Q=n;let r=()=>{Q=null};return n.then(r,r),n}async function ot(e,t=!1){let n=await tt(e,t);return n.success?(ae().installMethod!==`native`&&(ie(e=>({...e,installMethod:`native`,autoUpdates:!1,autoUpdatesProtectedForNative:!0})),p(`Native installer: Set installMethod to "native" and disabled legacy auto-updater for protection`)),ut(),{latestVersion:n.latestVersion,wasUpdated:n.success,lockFailed:!1}):{latestVersion:null,wasUpdated:!1,lockFailed:n.lockFailed,lockHolderPid:n.lockHolderPid}}async function st(e){try{let t=await P(e),n=O(E(e),t);if(await q(n))return n}catch{}return null}function Y(e,t){let n=Fe(t);return D(e.locks,`${n}.lock`)}async function ct(){let e=K();if(!process.execPath.includes(e.versions))return;let t=O(process.execPath);try{let n=Y(e,t);if(await M(e.locks,{recursive:!0}),C()){if(!await Ae(t,n)){X(t,Error(`Lock already held by another process`));return}p(`Acquired PID lock on running version: ${t}`)}else{let e;try{e=await b(t,{stale:Z,retries:0,lockfilePath:n,onCompromised:e=>{p(`NON-FATAL: Lock on running version was compromised: ${e.message}`,{level:`info`})}}),p(`Acquired mtime-based lock on running version: ${t}`),ee(async()=>{try{await e?.()}catch{}})}catch(e){if(d(e)){p(`Cannot lock current version - file does not exist: ${t}`,{level:`info`});return}X(t,e);return}}}catch(e){if(d(e)){p(`Cannot lock current version - file does not exist: ${t}`,{level:`info`});return}p(`NON-FATAL: Failed to lock current version during execution ${l(e)}`,{level:`info`})}}function X(e,t){g(Error(`NON-FATAL: Lock acquisition failed for ${e} (expected in multi-process scenarios)`,{cause:t}))}async function lt(e){let t=Y(K(),e);try{await R(t),p(`Force-removed lock file at ${t}`)}catch(e){p(`Failed to force-remove lock file: ${l(e)}`)}}async function ut(){await Promise.resolve();let e=K(),t=Date.now()-36e5;if(W().startsWith(`win32`)){let t=E(e.executable);try{let e=await N(t),n=0;for(let r of e)if(/^claude\.exe\.old\.\d+$/.test(r))try{await R(D(t,r)),n++}catch{}n>0&&p(`Cleaned up ${n} old Windows executables on startup`)}catch(e){d(e)||p(`Failed to clean up old Windows executables: ${e}`)}}try{let n=await N(e.staging),r=0;for(let i of n){let n=D(e.staging,i);try{(await L(n)).mtime.getTime()<t&&(await I(n,{recursive:!0,force:!0}),r++,p(`Cleaned up old staging directory: ${i}`))}catch{}}r>0&&p(`Cleaned up ${r} orphaned staging directories`)}catch(e){d(e)||p(`Failed to clean up staging directories: ${e}`)}if(C()){let t=De(e.locks);t>0&&p(`Cleaned up ${t} stale version locks`)}let n;try{n=await N(e.versions)}catch(e){d(e)||p(`Failed to readdir versions directory: ${e}`);return}let r=[],i=0;for(let a of n){let n=D(e.versions,a);if(/\.tmp\.\d+\.\d+$/.test(a)){try{(await L(n)).mtime.getTime()<t&&(await R(n),i++,p(`Cleaned up orphaned temp install file: ${a}`))}catch{}continue}try{let e=await L(n);if(!e.isFile()||process.platform!==`win32`&&e.size>0&&!(e.mode&73))continue;r.push({name:a,path:n,resolvedPath:O(n),mtime:e.mtime})}catch{}}if(i>0&&p(`Cleaned up ${i} orphaned temp install files`),r.length!==0)try{let t=process.execPath,n=new Set;t?.includes(e.versions)&&n.add(O(t));let i=await st(e.executable);i&&n.add(i);for(let t of r){if(n.has(t.resolvedPath))continue;let r=Y(e,t.resolvedPath),i=!1;if(C())i=S(r);else try{i=await se(t.resolvedPath,{stale:Z,lockfilePath:r})}catch{i=!1}i&&(n.add(t.resolvedPath),p(`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 Je(e.path,async()=>{await R(e.path)})?o++:(s++,p(`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){d(e)||g(Error(`Version cleanup failed: ${e}`))}}async function dt(){let e=[],t=w();for(let[n,r]of Object.entries(t))try{let t=await me(r);if(!t)continue;let{filtered:i,hadAlias:a}=ye(t);a&&(await Ne(r,i),e.push({message:`Removed claude alias from ${r}. Run: unalias claude`,userActionRequired:!0,type:`alias`}),p(`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 R(e),p(`Manually removed ${t}: ${e}`),!0}catch{return!1}}if(W().startsWith(`win32`)){let e=D(n,`claude.cmd`),t=D(n,`claude.ps1`),a=D(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(D(n,`bin`,`claude`),`bin symlink`)&&(r=!0);return r?(p(`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: ${W().startsWith(`win32`)?D(n,`node_modules`,e):D(n,`lib`,`node_modules`,e)}`}):{success:!1}}catch(e){return p(`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 p(`Removed global npm installation of ${e}`),{success:!0};if(n&&!n.includes(`npm ERR! code E404`)){if(n.includes(`npm error code ENOTEMPTY`)){p(`Failed to uninstall global npm package ${e}: ${n}`,{level:`error`}),p(`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 p(`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(`@readmagic/workmate`);r.success?(n++,r.warning&&t.push(r.warning)):r.error&&e.push(r.error);let i=D(T(),`.workmate`,`local`);try{await I(i,{recursive:!0}),n++,p(`Removed local installation at ${i}`)}catch(t){d(t)||(e.push(`Failed to remove ${i}: ${t}`),p(`Failed to remove local installation: ${t}`,{level:`error`}))}return{removed:n,errors:e,warnings:t}}var Z,Q,$=e((()=>{y(),Me(),s(),re(),m(),Ce(),a(),fe(),n(),c(),_(),he(),oe(),h(),ce(),ge(),le(),Oe(),qe(),we(),Z=10080*60*1e3,Q=null})),ht=e((()=>{$()}));export{dt as a,ct as c,ut as i,it as n,$ as o,mt as r,at as s,ht as t};
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{l as t,o as n}from"./envUtils-QyzA_cFM.js";import{n as r,t as i}from"./axios-DaWTGg7G.js";import{Xt as a,qt as o}from"./settings-D4M13toi.js";import{$ as s,I as c,M as l,N as u,R as d,V as f,c as p,et as ee,f as te,i as m,u as ne}from"./debug-2pVES-2G.js";import{d as re,h as ie,o as ae}from"./config-Bio2EjUK.js";import{o as h,s as g}from"./log-L1kqxa_P.js";import{i as _,n as v}from"./execFileNoThrow-DXSEj8ZO.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 x,t as le,v as ue,y as de}from"./sleep-xKMbXTJe.js";import{j as fe,k as pe}from"./sessionTracing-5a7HDF4e.js";import{C as me,E as he,S as ge,T as _e,_ as ve,a as S,b as ye,c as be,d as xe,f as Se,g as Ce,i as we,l as Te,m as Ee,n as De,o as C,p as Oe,s as ke,t as Ae,u as je,v as Me,w as Ne,x as w,y as Pe}from"./pidLock-CqkC3-nD.js";import{homedir as T}from"os";import{basename as Fe,delimiter as Ie,dirname as E,join as D,resolve as O}from"path";import{constants as Le}from"fs";import{createHash as Re}from"crypto";import{access as k,chmod as A,copyFile as j,mkdir as M,readdir as N,readlink as P,rename as F,rm as I,rmdir as ze,stat as L,symlink as Be,unlink as R,writeFile as z}from"fs/promises";async function Ve(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 He(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 Ve(t,B)}function Ue(){return Number(process.env.WORKMATE_STALL_TIMEOUT_MS_FOR_TESTING)||V}async function We(e,t,n,i={}){let a;for(let o=1;o<=H;o++){let s=new AbortController,c,l=()=>{c&&(clearTimeout(c),c=void 0)},u=()=>{l(),c=setTimeout(e=>e.abort(),Ue(),s)};try{u();let a=await r.get(e,{timeout:5*6e4,responseType:`arraybuffer`,signal:s.signal,onDownloadProgress:()=>{u()},...i});l();let o=Re(`sha256`);o.update(a.data);let c=o.digest(`hex`);if(c!==t)throw Error(`Checksum mismatch: expected ${t}, got ${c}`);await z(n,Buffer.from(a.data)),await A(n,493);return}catch(e){l();let t=r.isCancel(e);if(a=t?new U:f(e),t&&o<H){p(`Download stalled on attempt ${o}/${H}, retrying...`),await x(1e3);continue}throw a}}throw a??Error(`Download failed after all retries`)}async function Ge(e,t,n,i){let a=ne();await a.rm(t,{recursive:!0,force:!0});let o=W(),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=G(o),f=`${n}/${e}/${o}/${d}`;await a.mkdir(t);let p=D(t,d);try{await We(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 Ke(e,t){return await Ge(e,t,B),`binary`}var B,V,H,U,qe=e((()=>{i(),y(),m(),c(),_(),te(),h(),le(),$(),B=`https://downloads.workmate.ai/native-releases`,V=6e4,H=3,U=class extends Error{constructor(){super(`Download stalled: no data received for 60 seconds`),this.name=`StallTimeoutError`}}}));function W(){let e=o.platform,t=process.arch===`x64`?`x64`:process.arch===`arm64`?`arm64`:null;if(!t){let e=Error(`Unsupported architecture: ${process.arch}`);throw p(`Native installer does not support architecture: ${process.arch}`,{level:`error`}),e}return e===`linux`&&pe.isMuslEnvironment()?`linux-${t}-musl`:`${e}-${t}`}function G(e){return e.startsWith(`win32`)?`claude.exe`:`claude`}function K(){let e=G(W());return{versions:D(xe(),`claude`,`versions`),staging:D(je(),`claude`,`staging`),locks:D(Se(),`claude`,`locks`),executable:D(Te(),e)}}async function q(e){try{let t=await L(e);return!t.isFile()||t.size===0?!1:(await k(e,Le.X_OK),!0)}catch{return!1}}async function J(e){let t=K(),n=[t.versions,t.staging,t.locks];await Promise.all(n.map(e=>M(e,{recursive:!0}))),await M(E(t.executable),{recursive:!0});let r=D(t.versions,e);try{await L(r)}catch{await z(r,``,{encoding:`utf8`})}return{stagingPath:D(t.staging,e),installPath:r}}async function Je(e,t,n=0){let r=K(),i=Y(r,e);if(await M(r.locks,{recursive:!0}),C()){let r=0,a=n+1,o=n>0?1e3:100,s=n>0?5e3:500;for(;r<a;){if(await be(e,i,async()=>{try{await t()}catch(e){throw g(e),e}}))return r+1,!0;r++,r<a&&await x(Math.min(o*2**(r-1),s))}return X(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=>{p(`NON-FATAL: Version lock was compromised during operation: ${e.message}`,{level:`info`})}})}catch(t){return X(e,t),!1}try{return await t(),!0}catch(e){throw g(e),e}}finally{a&&await a()}}async function Ye(e,t){await M(E(t),{recursive:!0});let n=`${t}.tmp.${process.pid}.${Date.now()}`;try{await j(e,n),await A(n,493),await F(n,t),p(`Atomically installed binary to ${t}`)}catch(e){try{await R(n)}catch{}throw e}}async function Xe(e,t){try{let n=D(e,`node_modules`,`@anthropic-ai`),r=(await N(n)).find(e=>e.startsWith(`claude-cli-native-`));if(!r)throw Error(`Could not find platform-specific native package`);let i=D(n,r,`cli`);try{await L(i)}catch{throw Error(`Native binary not found in staged package`)}await Ye(i,t),await I(e,{recursive:!0,force:!0})}catch(e){let t=l(e);throw!t.includes(`Could not find platform-specific`)&&t.includes(`Native binary not found`),g(f(e)),e}}async function Ze(e,t){try{let n=D(e,G(W()));try{await L(n)}catch{throw Error(`Staged binary not found`)}await Ye(n,t),await I(e,{recursive:!0,force:!0})}catch(e){throw l(e).includes(`Staged binary not found`),g(f(e)),e}}async function Qe(e,t,n){n===`npm`?await Xe(e,t):await Ze(e,t)}async function $e(e,n){let{stagingPath:r,installPath:i}=await J(e),{executable:a}=K(),o=t(process.env.ENABLE_LOCKLESS_UPDATES)?`${r}.${process.pid}.${Date.now()}`:r,s=!await et(e)||n;if(s?(p(n?`Force reinstalling native installer version ${e}`:`Downloading native installer version ${e}`),await Qe(o,i,await Ke(e,o))):p(`Version ${e} already installed, updating symlink`),await nt(a),await rt(a,i),!await q(a)){let e=!1;try{await L(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 et(e){let{installPath:t}=await J(e);return q(t)}async function tt(e,n=!1){let r=Date.now(),i=await He(e),{executable:a}=K();if(p(`Checking for native installer update to version ${i}`),!n){let e=await ve();if(e&&ue(i,e)){if(p(`Native installer: maxVersion ${e} is set, capping update from ${i} to ${e}`),de(`0.0.28`,e))return p(`Native installer: current version 0.0.28 is already at or above maxVersion ${e}, skipping update`),Date.now()-r,{success:!0,latestVersion:i};i=e}}if(!n&&i===`0.0.28`&&await et(i)&&await q(a))return p(`Found ${i} at ${a}, skipping install`),Date.now()-r,{success:!0,latestVersion:i};if(!n&&Pe(i))return Date.now()-r,{success:!0,latestVersion:i};if(t(process.env.ENABLE_LOCKLESS_UPDATES))await $e(i,n),Date.now()-r;else{let{installPath:e}=await J(i);n&&await lt(e);let t=await Je(e,async()=>{await $e(i,n)},3);if(Date.now()-r,!t){let t=K(),n;if(C()){let r=Y(t,e);S(r)&&(n=ke(r)?.pid)}return{success:!1,latestVersion:i,lockFailed:!0,lockHolderPid:n}}}return p(`Successfully updated to version ${i}`),{success:!0,latestVersion:i}}async function nt(e){try{await ze(e),p(`Removed empty directory at ${e}`)}catch(t){let n=u(t);n!==`ENOTDIR`&&n!==`ENOENT`&&n!==`ENOTEMPTY`&&p(`Could not remove directory at ${e}: ${t}`)}}async function rt(e,t){if(W().startsWith(`win32`))try{await M(E(e),{recursive:!0});let n;try{n=await L(e)}catch{}if(n){try{let e=await L(t);if(n.size===e.size)return!1}catch{}let r=`${e}.old.${Date.now()}`;await F(e,r);try{await j(t,e);try{await R(r)}catch{}}catch(t){try{await F(r,e)}catch(e){let n=Error(`Failed to restore old executable: ${e}`,{cause:t});throw g(n),n}throw t}}else try{await j(t,e)}catch(e){throw d(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=E(e);try{await M(n,{recursive:!0}),p(`Created directory ${n} for symlink`)}catch(e){return g(Error(`Failed to create directory ${n}: ${e}`)),!1}try{let n=!1;try{await L(e),n=!0}catch{}if(n){try{let n=await P(e);if(O(E(e),n)===O(t))return!1}catch{}await R(e)}}catch(e){g(Error(`Failed to check/remove existing symlink: ${e}`))}let r=`${e}.tmp.${process.pid}.${Date.now()}`;try{return await Be(t,r),await F(r,e),p(`Atomically updated symlink ${e} -> ${t}`),!0}catch(n){try{await R(r)}catch{}return g(Error(`Failed to create symlink from ${e} to ${t}: ${n}`)),!1}}async function it(e=!1){if(t(process.env.DISABLE_INSTALLATION_CHECKS))return[];let n=await Ee();if(n===`development`||!(e||n===`native`))return[];let r=K(),i=[],a=E(r.executable),o=O(a),s=W().startsWith(`win32`);try{await k(a)}catch{i.push({message:`installMethod is native, but directory ${a} does not exist`,userActionRequired:!0,type:`error`})}if(s)await q(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 P(r.executable);await q(O(E(r.executable),e))||i.push({message:`Work Mate symlink points to missing or invalid binary: ${e}`,userActionRequired:!0,type:`error`})}catch(e){d(e)?i.push({message:`installMethod is native, but claude command not found at ${r.executable}`,userActionRequired:!0,type:`error`}):await q(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(Ie).some(e=>{try{let t=O(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=_e(),t=w()[e],n=t?t.replace(T(),`~`):`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 at(e,t=!1){if(t)return ot(e,t);if(Q)return p(`installLatest: joining in-flight call`),Q;let n=ot(e,t);Q=n;let r=()=>{Q=null};return n.then(r,r),n}async function ot(e,t=!1){let n=await tt(e,t);return n.success?(ae().installMethod!==`native`&&(ie(e=>({...e,installMethod:`native`,autoUpdates:!1,autoUpdatesProtectedForNative:!0})),p(`Native installer: Set installMethod to "native" and disabled legacy auto-updater for protection`)),ut(),{latestVersion:n.latestVersion,wasUpdated:n.success,lockFailed:!1}):{latestVersion:null,wasUpdated:!1,lockFailed:n.lockFailed,lockHolderPid:n.lockHolderPid}}async function st(e){try{let t=await P(e),n=O(E(e),t);if(await q(n))return n}catch{}return null}function Y(e,t){let n=Fe(t);return D(e.locks,`${n}.lock`)}async function ct(){let e=K();if(!process.execPath.includes(e.versions))return;let t=O(process.execPath);try{let n=Y(e,t);if(await M(e.locks,{recursive:!0}),C()){if(!await Ae(t,n)){X(t,Error(`Lock already held by another process`));return}p(`Acquired PID lock on running version: ${t}`)}else{let e;try{e=await b(t,{stale:Z,retries:0,lockfilePath:n,onCompromised:e=>{p(`NON-FATAL: Lock on running version was compromised: ${e.message}`,{level:`info`})}}),p(`Acquired mtime-based lock on running version: ${t}`),ee(async()=>{try{await e?.()}catch{}})}catch(e){if(d(e)){p(`Cannot lock current version - file does not exist: ${t}`,{level:`info`});return}X(t,e);return}}}catch(e){if(d(e)){p(`Cannot lock current version - file does not exist: ${t}`,{level:`info`});return}p(`NON-FATAL: Failed to lock current version during execution ${l(e)}`,{level:`info`})}}function X(e,t){g(Error(`NON-FATAL: Lock acquisition failed for ${e} (expected in multi-process scenarios)`,{cause:t}))}async function lt(e){let t=Y(K(),e);try{await R(t),p(`Force-removed lock file at ${t}`)}catch(e){p(`Failed to force-remove lock file: ${l(e)}`)}}async function ut(){await Promise.resolve();let e=K(),t=Date.now()-36e5;if(W().startsWith(`win32`)){let t=E(e.executable);try{let e=await N(t),n=0;for(let r of e)if(/^claude\.exe\.old\.\d+$/.test(r))try{await R(D(t,r)),n++}catch{}n>0&&p(`Cleaned up ${n} old Windows executables on startup`)}catch(e){d(e)||p(`Failed to clean up old Windows executables: ${e}`)}}try{let n=await N(e.staging),r=0;for(let i of n){let n=D(e.staging,i);try{(await L(n)).mtime.getTime()<t&&(await I(n,{recursive:!0,force:!0}),r++,p(`Cleaned up old staging directory: ${i}`))}catch{}}r>0&&p(`Cleaned up ${r} orphaned staging directories`)}catch(e){d(e)||p(`Failed to clean up staging directories: ${e}`)}if(C()){let t=De(e.locks);t>0&&p(`Cleaned up ${t} stale version locks`)}let n;try{n=await N(e.versions)}catch(e){d(e)||p(`Failed to readdir versions directory: ${e}`);return}let r=[],i=0;for(let a of n){let n=D(e.versions,a);if(/\.tmp\.\d+\.\d+$/.test(a)){try{(await L(n)).mtime.getTime()<t&&(await R(n),i++,p(`Cleaned up orphaned temp install file: ${a}`))}catch{}continue}try{let e=await L(n);if(!e.isFile()||process.platform!==`win32`&&e.size>0&&!(e.mode&73))continue;r.push({name:a,path:n,resolvedPath:O(n),mtime:e.mtime})}catch{}}if(i>0&&p(`Cleaned up ${i} orphaned temp install files`),r.length!==0)try{let t=process.execPath,n=new Set;t?.includes(e.versions)&&n.add(O(t));let i=await st(e.executable);i&&n.add(i);for(let t of r){if(n.has(t.resolvedPath))continue;let r=Y(e,t.resolvedPath),i=!1;if(C())i=S(r);else try{i=await se(t.resolvedPath,{stale:Z,lockfilePath:r})}catch{i=!1}i&&(n.add(t.resolvedPath),p(`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 Je(e.path,async()=>{await R(e.path)})?o++:(s++,p(`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){d(e)||g(Error(`Version cleanup failed: ${e}`))}}async function dt(){let e=[],t=w();for(let[n,r]of Object.entries(t))try{let t=await me(r);if(!t)continue;let{filtered:i,hadAlias:a}=ye(t);a&&(await Ne(r,i),e.push({message:`Removed claude alias from ${r}. Run: unalias claude`,userActionRequired:!0,type:`alias`}),p(`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 R(e),p(`Manually removed ${t}: ${e}`),!0}catch{return!1}}if(W().startsWith(`win32`)){let e=D(n,`claude.cmd`),t=D(n,`claude.ps1`),a=D(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(D(n,`bin`,`claude`),`bin symlink`)&&(r=!0);return r?(p(`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: ${W().startsWith(`win32`)?D(n,`node_modules`,e):D(n,`lib`,`node_modules`,e)}`}):{success:!1}}catch(e){return p(`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 p(`Removed global npm installation of ${e}`),{success:!0};if(n&&!n.includes(`npm ERR! code E404`)){if(n.includes(`npm error code ENOTEMPTY`)){p(`Failed to uninstall global npm package ${e}: ${n}`,{level:`error`}),p(`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 p(`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(`@readmagic/workmate`);r.success?(n++,r.warning&&t.push(r.warning)):r.error&&e.push(r.error);let i=D(T(),`.workmate`,`local`);try{await I(i,{recursive:!0}),n++,p(`Removed local installation at ${i}`)}catch(t){d(t)||(e.push(`Failed to remove ${i}: ${t}`),p(`Failed to remove local installation: ${t}`,{level:`error`}))}return{removed:n,errors:e,warnings:t}}var Z,Q,$=e((()=>{y(),Me(),s(),re(),m(),Ce(),a(),fe(),n(),c(),_(),he(),oe(),h(),ce(),ge(),le(),Oe(),qe(),we(),Z=10080*60*1e3,Q=null})),ht=e((()=>{$()}));export{dt as a,ct as c,ut as i,it as n,$ as o,mt as r,at 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-BX54x08P.js";import{Hh as r,Vh as i,zh as a}from"./loadAgentsDir-
|
|
1
|
+
import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{ai as n}from"./src-BX54x08P.js";import{Hh as r,Vh as i,zh as a}from"./loadAgentsDir-bmpKLPdG.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-BX54x08P.js";import{t as n}from"./jsx-runtime-Bb4Xn-E0.js";import{Pt as r,Vt as i}from"./settings-D4M13toi.js";import{Pt as a,vn as o}from"./state-CXY-q5gr.js";import{Fl as s,Ml as c,Pl as l}from"./loadAgentsDir-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-DaDcL9Zw.js";import{ai as t}from"./src-BX54x08P.js";import{t as n}from"./jsx-runtime-Bb4Xn-E0.js";import{Pt as r,Vt as i}from"./settings-D4M13toi.js";import{Pt as a,vn as o}from"./state-CXY-q5gr.js";import{Fl as s,Ml as c,Pl as l}from"./loadAgentsDir-bmpKLPdG.js";import{I as u,V as d}from"./debug-2pVES-2G.js";import{d as f,h as p,m,o as h}from"./config-Bio2EjUK.js";import{o as g,s as _}from"./log-L1kqxa_P.js";import{r as v,t as y}from"./managedEnv-EZ2IirNa.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})}a(),f(),u(),g(),v(),r(),c();function D({newState:e,oldState:t}){let n=t.toolPermissionContext.mode,r=e.toolPermissionContext.mode;if(n!==r){let e=i(n),t=i(r);e!==t&&s({permission_mode:t}),l(r)}if(e.mainLoopModel!==t.mainLoopModel&&o(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){_(d(e))}}export{E as n,w as r,D as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{c as t,l as n,o as r}from"./envUtils-QyzA_cFM.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-
|
|
1
|
+
import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{c as t,l as n,o as r}from"./envUtils-QyzA_cFM.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-bmpKLPdG.js";import{c as w,i as T}from"./debug-2pVES-2G.js";import{at as E,nt as D}from"./model-Dd3x121y.js";import{_n as O,bn as k,i as A,r as j,t as M,vn as N}from"./prompt-BnDapYGL.js";import{n as P,r as F}from"./client-2w-g5kMx.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
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-BX54x08P.js";import{Bh as a,Rh as o,zh as s}from"./loadAgentsDir-
|
|
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-BX54x08P.js";import{Bh as a,Rh as o,zh as s}from"./loadAgentsDir-bmpKLPdG.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}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-
|
|
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-BYhqv77g.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,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-BX54x08P.js";import{t as y}from"./jsx-runtime-Bb4Xn-E0.js";import{B as b,L as x,a as S,cn as C,m as w,mn as T,z as E}from"./settings-D4M13toi.js";import{Pt as D,q as O}from"./state-CXY-q5gr.js";import{Bh as ie,H as k,Hh as ae,I as oe,Ji as A,Jx as j,L as se,Mg as M,Ng as ce,R as le,V as ue,_m as N,aC as P,gm as F,kg as de,sC as fe,sb as I,tb as L,z as pe,zh as R}from"./loadAgentsDir-
|
|
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-BX54x08P.js";import{t as y}from"./jsx-runtime-Bb4Xn-E0.js";import{B as b,L as x,a as S,cn as C,m as w,mn as T,z as E}from"./settings-D4M13toi.js";import{Pt as D,q as O}from"./state-CXY-q5gr.js";import{Bh as ie,H as k,Hh as ae,I as oe,Ji as A,Jx as j,L as se,Mg as M,Ng as ce,R as le,V as ue,_m as N,aC as P,gm as F,kg as de,sC as fe,sb as I,tb as L,z as pe,zh as R}from"./loadAgentsDir-bmpKLPdG.js";import{C as z,x as me}from"./debug-2pVES-2G.js";import{l as B,o as he}from"./stringUtils-Cs6E5f-B.js";import{n as ge,t as _e}from"./useExitOnCtrlCDWithKeybindings-BT0nexZw.js";import{n as ve,t as ye}from"./TextInput-ou7ZhpVY.js";import{n as V,t as H}from"./select-CaxQ-BVq.js";import{n as be,t as xe}from"./AddWorkspaceDirectory-Bmgh8VS3.js";import{t as Se}from"./SearchBox-zA5QwIpO.js";import{n as Ce,t as we}from"./useSearchInput-j12K4wEo.js";import{n as Te,t as Ee}from"./shadowedRuleDetection-L3tnySui.js";function De(){return U}var U,Oe=e((()=>{U=[]}));function ke({ruleValue:e}){switch(e.toolName){case F.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((()=>{_(),N(),W=y()}));function je(e){switch(e){case`localSettings`:return{label:`Project settings (local)`,description:`Saved in ${S(`localSettings`)}`,value:e};case`projectSettings`:return{label:`Project settings`,description:`Checked in at ${S(`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=C.map(je),l=(0,Ne.useCallback)(i=>{if(i===`cancel`){t();return}else if(C.includes(i)){let t=i,a=de(o,{type:`addRules`,rules:n,behavior:r,destination:t});ce({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:P.isSandboxingEnabled()&&P.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:b(e)}),(0,G.jsx)(ke,{ruleValue:e})]},b(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(),_(),M(),x(),Te(),fe(),T(),w(),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=ge();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:b({toolName:F.name})}),(0,K.jsx)(a,{bold:!1,children:` or `}),(0,K.jsx)(a,{bold:!0,children:b({toolName:F.name,ruleContent:`ls:*`})})]}),(0,K.jsx)(i,{borderDimColor:!0,borderStyle:`round`,marginY:1,paddingLeft:1,children:(0,K.jsx)(ye,{showCursor:!0,value:s,onChange:c,onSubmit:e=>{let r=e.trim();r.length!==0&&t(E(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),ve(),_e(),I(),_(),L(),N(),x(),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(),_(),M(),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:`- ${O()}`}),(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),D(),V(),_(),Z=y()}));function Ke({rule:e}){return(0,$.jsx)(a,{dimColor:!0,children:`From ${k(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=ge();o(`confirm:no`,n,{context:`Confirmation`});let s=(0,$.jsxs)(i,{flexDirection:`column`,marginX:2,children:[(0,$.jsx)(a,{bold:!0,children:b(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
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=ie(e=>e.toolPermissionContext),m=ae(),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,x]=(0,Q.useState)(),[S,C]=(0,Q.useState)(null),[w,T]=(0,Q.useState)(null),[E,D]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(null),[A,j]=(0,Q.useState)(!1),[M,ue]=(0,Q.useState)(!0),N=(0,Q.useCallback)(e=>{ue(e)},[]),P=(0,Q.useMemo)(()=>{let e=new Map;return se(p).forEach(t=>{e.set(z(t),t)}),e},[p]),F=(0,Q.useMemo)(()=>{let e=new Map;return pe(p).forEach(t=>{e.set(z(t),t)}),e},[p]),fe=(0,Q.useMemo)(()=>{let e=new Map;return le(p).forEach(t=>{e.set(z(t),t)}),e},[p]),I=(0,Q.useCallback)((e,t=``)=>{let n=(()=>{switch(e){case`allow`:return P;case`deny`:return F;case`ask`:return fe;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=b(r.ruleValue).toLowerCase(),t=b(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=b(r.ruleValue);if(t&&!n.toLowerCase().includes(o))continue;i.push({label:n,value:e})}}return{options:i,rulesByKey:n}},[P,F,fe]),L=ge(),R=!_&&!S&&!w&&!E&&!O,{query:me,setQuery:B,cursorOffset:he}=Ce({isActive:R&&A,onExit:()=>{j(!1)}}),_e=(0,Q.useCallback)(e=>{R&&(A||e.ctrl||e.meta||(e.key===`/`?(e.preventDefault(),j(!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(),j(!0),B(e.key))))},[R,A,B]),ve=(0,Q.useCallback)((e,t)=>{let{rulesByKey:n}=I(t);if(e===`add-new-rule`){C(t);return}else{v(n.get(e));return}},[I]),ye=(0,Q.useCallback)(()=>{C(null)},[]),V=(0,Q.useCallback)((e,t)=>{T({ruleValue:e,ruleBehavior:t}),C(null)},[]),H=(0,Q.useCallback)((e,t)=>{T(null);for(let t of e)f(e=>[...e,`Added ${t.ruleBehavior} rule ${u.bold(b(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: ${b(e.rule.ruleValue)} is ${t}`),u.dim(` ${e.reason}`),u.dim(` Fix: ${e.fix}`)])}},[]),be=(0,Q.useCallback)(()=>{T(null)},[]),Se=(0,Q.useCallback)(()=>D(!0),[]),we=(0,Q.useCallback)(e=>k(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
3
|
`)):e(`Permissions dialog dismissed`,{display:`system`})},[d,e,n]);o(`confirm:no`,Te,{context:`Settings`,isActive:R&&!A});let Ee=()=>{if(!_)return;let{options:e}=I(_.ruleBehavior),t=z(_),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])),x(i),oe({rule:_,initialContext:p,setToolPermissionContext(e){m(t=>({...t,toolPermissionContext:e}))}}),f(e=>[...e,`Deleted ${_.ruleBehavior} rule ${u.bold(b(_.ruleValue))}`]),v(void 0)};if(_)return(0,$.jsx)(Je,{rule:_,onDelete:Ee,onCancel:()=>v(void 0)});if(S&&S!==`workspace`&&S!==`recent`)return(0,$.jsx)(Fe,{onCancel:ye,onSubmit:V,ruleBehavior:S});if(w)return(0,$.jsx)(Me,{onAddRules:H,onCancel:be,ruleValues:[w.ruleValue],ruleBehavior:w.ruleBehavior,initialContext:p,setToolPermissionContext:e=>{m(t=>({...t,toolPermissionContext:e}))}});if(E)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&&ce(n),f(n=>[...n,`Added directory ${u.bold(e)} to workspace${t?` and saved to local settings`:` for this session`}`]),D(!1)},onCancel:()=>D(!1),permissionContext:p});if(O)return(0,$.jsx)(Be,{directoryPath:O,onRemove:()=>{f(e=>[...e,`Removed directory ${u.bold(O)} from workspace`]),k(null)},onCancel:()=>k(null),permissionContext:p,setPermissionContext:e=>{m(t=>({...t,toolPermissionContext:e}))}});let U={searchQuery:me,isSearchMode:A,isFocused:ee,onCancel:Te,lastFocusedRuleKey:y,cursorOffset:he,getRulesOptions:I,handleToolSelect:ve,onHeaderFocusChange:N};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:!!_||!!S||!!w||E||!!O,initialHeaderFocused:!c,navFromContent:!A,children:[(0,$.jsx)(h,{id:`recent`,title:`Recently denied`,children:(0,$.jsx)(Re,{onHeaderFocusChange:N,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:N})]})})]}),(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`]}):M?(0,$.jsx)($.Fragment,{children:`←/→ tab switch · ↓ return · Esc cancel`}):A?(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),R(),M(),V(),_e(),we(),_(),L(),Oe(),x(),ue(),me(),Se(),Pe(),be(),Ae(),Le(),ze(),He(),Ge(),$=y()})),$e,et;e((()=>{Qe(),A(),$e=y(),et=async(e,t)=>(0,$e.jsx)(Ze,{onExit:e,onRetryDenials:e=>{t.setMessages(t=>[...t,j(e)])}})}))();export{et as call};
|
|
@@ -1,3 +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-QyzA_cFM.js";import{A as s,M as c,Xt as l,m as ee,qt as te,rn as ne,t as re,tn as ie}from"./settings-D4M13toi.js";import{aC as ae,sC as oe}from"./loadAgentsDir-
|
|
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-QyzA_cFM.js";import{A as s,M as c,Xt as l,m as ee,qt as te,rn as ne,t as re,tn as ie}from"./settings-D4M13toi.js";import{aC as ae,sC as oe}from"./loadAgentsDir-bmpKLPdG.js";import{n as se}from"./cwd-DrEEb4f5.js";import{C as ce,D as le,I as u,R as d,S as ue,T as de,V as fe,c as f,f as p,i as m,u as h,x as g,z as pe}from"./debug-2pVES-2G.js";import{d as me,i as _,o as v,r as he}from"./config-Bio2EjUK.js";import{r as ge,t as _e}from"./execa-CBhG1doD.js";import{o as y,s as b}from"./log-L1kqxa_P.js";import{i as x,n as ve,t as S}from"./execFileNoThrow-DXSEj8ZO.js";import{c as ye,i as C,n as w,o as be,s as xe,t as Se}from"./bundledMode-D9omqD3L.js";import{b as Ce,y as we}from"./sleep-xKMbXTJe.js";import{a as Te,i as Ee}from"./ripgrep-67m14ImZ.js";import{n as De,r as Oe}from"./genericProcessUtils-GqURdVAv.js";import{homedir as T}from"os";import{basename as ke,delimiter as Ae,join as E,posix as D,win32 as O}from"path";import{constants as je}from"fs";import{access as k,open as Me,readFile as A,realpath as j,stat as Ne}from"fs/promises";function Pe(){return E(i(),`local`)}function Fe(){return E(Pe(),`workmate`)}function Ie(){return(process.argv[1]||``).includes(`/.workmate/local/node_modules/`)}async function Le(){try{return await k(E(Pe(),`node_modules`,`.bin`,`wm`)),!0}catch{return!1}}function Re(){let e=process.env.SHELL||``;return e.includes(`zsh`)?`zsh`:e.includes(`bash`)?`bash`:e.includes(`fish`)?`fish`:`unknown`}var M=e((()=>{me(),o(),u(),x(),p(),y(),g()}));function N(e){let t=e?.homedir??T();return{zsh:E((e?.env??process.env).ZDOTDIR||t,`.zshrc`),bash:E(t,`.bashrc`),fish:E(t,`.config/fish/config.fish`)}}function ze(e){let t=!1;return{filtered:e.filter(e=>{if(F.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()===Fe())return t=!0,!1}return!0}),hadAlias:t}}async function Be(e){try{return(await A(e,{encoding:`utf8`})).split(`
|
|
2
2
|
`)}catch(e){if(pe(e))return null;throw e}}async function Ve(e,t){let n=await Me(e,`w`);try{await n.writeFile(t.join(`
|
|
3
|
-
`),{encoding:`utf8`}),await n.datasync()}finally{await n.close()}}async function P(e){let t=N(e);for(let e of Object.values(t)){let t=await Be(e);if(t){for(let e of t)if(F.test(e)){let t=e.match(/alias\s+claude=["']?([^"'\s]+)/);if(t?.[1])return t[1]}}}return null}async function He(e){let t=await P(e);if(!t)return null;let n=e?.homedir??T(),r=t.startsWith(`~`)?t.replace(`~`,n):t;try{let e=await Ne(r);if(e.isFile()||e.isSymbolicLink())return t}catch{}return null}var F,I=e((()=>{u(),M(),F=/^\s*alias\s+claude\s*=/}));async function Ue(){}function We(e){let t=re()?.minimumVersion;if(!t)return!1;let n=!we(e,t);return n&&f(`Skipping update to ${e} - below minimumVersion ${t}`),n}async function Ge(){let e=te.isRunningWithBun(),t=null;return t=e?await ve(`bun`,[`pm`,`bin`,`-g`],{cwd:T()}):await ve(`npm`,[`-g`,`config`,`get`,`prefix`],{cwd:T()}),t.code===0?t.stdout.trim():(b(Error(`Failed to check ${e?`bun`:`npm`} permissions`)),null)}async function Ke(){try{let e=await Ge();if(!e)return{hasPermissions:!1,npmPrefix:null};try{return await k(e,je.W_OK),{hasPermissions:!0,npmPrefix:e}}catch{return b(new L(`Insufficient permissions for global npm install.`)),{hasPermissions:!1,npmPrefix:e}}}catch(e){return b(e),{hasPermissions:!1,npmPrefix:null}}}var L,R=e((()=>{m(),l(),o(),u(),x(),p(),y(),Ce(),ee(),I(),L=class extends le{}}));function z(e,t){return t.includes(e.id)||e.idLike.some(e=>t.includes(e))}function B(){let e=process.execPath||process.argv[0]||``;return/[/\\]mise[/\\]installs[/\\]/i.test(e)?(f(`Detected mise installation: ${e}`),!0):!1}function V(){let e=process.execPath||process.argv[0]||``;return/[/\\]\.?asdf[/\\]installs[/\\]/i.test(e)?(f(`Detected asdf installation: ${e}`),!0):!1}function H(){let e=C();if(e!==`macos`&&e!==`linux`&&e!==`wsl`)return!1;let t=process.execPath||process.argv[0]||``;return t.includes(`/Caskroom/`)?(f(`Detected Homebrew cask installation: ${t}`),!0):!1}function U(){if(C()!==`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 f(`Detected winget installation: ${e}`),!0;return!1}var W,G,K,q,J,qe,Je=e((()=>{n(),m(),x(),be(),W=t(async()=>{try{let e=await A(`/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(C()!==`linux`)return!1;let e=await W();if(e&&!z(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?(f(`Detected pacman installation: ${t.stdout.trim()}`),!0):!1}),K=t(async()=>{if(C()!==`linux`)return!1;let e=await W();if(e&&!z(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?(f(`Detected deb installation: ${t.stdout.trim()}`),!0):!1}),q=t(async()=>{if(C()!==`linux`)return!1;let e=await W();if(e&&!z(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?(f(`Detected rpm installation: ${t.stdout.trim()}`),!0):!1}),J=t(async()=>{if(C()!==`linux`)return!1;let e=await W();if(e&&!z(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?(f(`Detected apk installation: ${t.stdout.trim()}`),!0):!1}),qe=t(async()=>H()?`homebrew`:U()?`winget`:B()?`mise`:V()?`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 C()===`windows`&&(e=e.split(O.sep).join(D.sep),t=t.split(O.sep).join(D.sep)),[e,t]}async function Xe(){let[e]=Ye();if(w())return H()||U()||B()||V()||await G()||await K()||await q()||await J()?`package-manager`:`native`;if(Ie())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 j(process.execPath)}catch{}try{let e=await ye(`claude`);if(e)return e}catch{}try{return await h().stat(E(T(),`.local/bin/claude`)),E(T(),`.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=h(),t=[],n=E(T(),`.workmate`,`local`);await Le()&&t.push({type:`npm-local`,path:n});let r=[`@readmagic/workmate`],i=await S(`npm`,[`-g`,`config`,`get`,`prefix`]);if(i.code===0&&i.stdout){let n=i.stdout.trim(),a=C()===`windows`,o=a?E(n,`claude`):E(n,`bin`,`claude`),s=!1;try{await e.stat(o),s=!0}catch{}if(s){let e=!1;try{(await j(o)).includes(`/Caskroom/`)&&(e=H())}catch{}e||t.push({type:`npm-global`,path:o})}else for(let i of r){let r=a?E(n,`node_modules`,i):E(n,`lib`,`node_modules`,i);try{await e.stat(r),t.push({type:`npm-global-orphan`,path:r})}catch{}}}let a=E(T(),`.local`,`bin`,`claude`);try{await e.stat(a),t.push({type:`native`,path:a})}catch{}if(v().installMethod===`native`){let n=E(T(),`.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=ue(await A(E(ie(),`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: ${s.join(`, `)}.`});else{let e=n.filter(e=>typeof e==`string`&&!s.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: ${s.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(Ae),n=E(T(),`.local`,`bin`),r=n;if(C()===`windows`&&(r=n.split(O.sep).join(D.sep)),!e.some(e=>{let t=e;C()===`windows`&&(t=e.split(O.sep).join(D.sep));let n=t.replace(/\/+$/,``),i=e.replace(/[/\\]+$/,``);return n===r||i===`~/.local/bin`||i===`$HOME/.local/bin`}))if(C()===`windows`){let e=n.split(D.sep).join(O.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=Re(),n=N()[e],r=n?n.replace(T(),`~`):`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 Le()&&t.push({issue:`Local installation exists but not being used`,fix:`Consider using native installation: claude install`});let r=await P(),i=await He();return e===`npm-local`&&!await ye(`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(C()!==`linux`)return[];let e=[],t=ae.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.27`:`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=C()===`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 @readmagic/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 Ke()).hasPermissions,!s&&!_()&&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=Ee(),l={working:c.working??!0,mode:c.mode,systemPath:c.mode===`system`?c.path:null,note:c.note??null},ee=e===`package-manager`?await qe():void 0;return{installationType:e,version:t,installationPath:n,invokedBinary:r,configInstallMethod:o,autoUpdates:(()=>{let e=_();return e?`disabled (${he(e)})`:`enabled`})(),hasUpdatePermissions:s,multipleInstallations:i,warnings:a,packageManager:ee,ripgrepStatus:l}}var rt=e((()=>{ge(),R(),Se(),me(),se(),o(),x(),p(),M(),Je(),be(),Te(),oe(),ne(),c(),I(),g(),xe()}));function Y(e){return{env:e?.env??process.env,home:e?.homedir??process.env.HOME??T()}}function X(e,...t){return e.includes(`/`)&&!e.includes(`\\`)&&!/^[A-Za-z]:/.test(e)?D.join(e,...t):E(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=De(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=h();try{let n=t.readFileSync(e,{encoding:`utf8`});if(!n||n.trim()===``)return null;let r=ue(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 f(`Lock PID ${n} is running but does not appear to be Work Mate - treating as stale`),!1;let i=h();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=h(),r=`${e}.tmp.${process.pid}.${Date.now()}`;try{de(r,ce(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=h(),r=ke(e);if($(t))return f(`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?(f(`Acquired PID lock for ${r} (PID ${process.pid})`),()=>{try{Q(t)?.pid===process.pid&&(n.unlinkSync(t),f(`Released PID lock for ${r}`))}catch(e){f(`Failed to release lock for ${r}: ${e}`)}}):null}catch(e){return f(`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=h(),n=[];try{let r=t.readdirStringSync(e).filter(e=>e.endsWith(`.lock`));for(let t of r){let r=E(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(d(e))return n;b(fe(e))}return n}function gt(e){let t=h(),n=0;try{let r=t.readdirStringSync(e).filter(e=>e.endsWith(`.lock`));for(let i of r){let r=E(e,i);try{t.lstatSync(r).isDirectory()?(t.rmSync(r,{recursive:!0,force:!0}),n++,f(`Cleaned up legacy directory lock: ${i}`)):$(r)||(t.unlinkSync(r),n++,f(`Cleaned up stale lock: ${i}`))}catch{}}}catch(e){if(d(e))return 0;b(fe(e))}return n}var _t,vt=e((()=>{m(),o(),u(),p(),Oe(),y(),g(),_t=7200*1e3}));export{Be as C,M as E,I as S,Re as T,Ue as _,$ as a,ze 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,R as v,Ve as w,N as x,We as y};
|
|
3
|
+
`),{encoding:`utf8`}),await n.datasync()}finally{await n.close()}}async function P(e){let t=N(e);for(let e of Object.values(t)){let t=await Be(e);if(t){for(let e of t)if(F.test(e)){let t=e.match(/alias\s+claude=["']?([^"'\s]+)/);if(t?.[1])return t[1]}}}return null}async function He(e){let t=await P(e);if(!t)return null;let n=e?.homedir??T(),r=t.startsWith(`~`)?t.replace(`~`,n):t;try{let e=await Ne(r);if(e.isFile()||e.isSymbolicLink())return t}catch{}return null}var F,I=e((()=>{u(),M(),F=/^\s*alias\s+claude\s*=/}));async function Ue(){}function We(e){let t=re()?.minimumVersion;if(!t)return!1;let n=!we(e,t);return n&&f(`Skipping update to ${e} - below minimumVersion ${t}`),n}async function Ge(){let e=te.isRunningWithBun(),t=null;return t=e?await ve(`bun`,[`pm`,`bin`,`-g`],{cwd:T()}):await ve(`npm`,[`-g`,`config`,`get`,`prefix`],{cwd:T()}),t.code===0?t.stdout.trim():(b(Error(`Failed to check ${e?`bun`:`npm`} permissions`)),null)}async function Ke(){try{let e=await Ge();if(!e)return{hasPermissions:!1,npmPrefix:null};try{return await k(e,je.W_OK),{hasPermissions:!0,npmPrefix:e}}catch{return b(new L(`Insufficient permissions for global npm install.`)),{hasPermissions:!1,npmPrefix:e}}}catch(e){return b(e),{hasPermissions:!1,npmPrefix:null}}}var L,R=e((()=>{m(),l(),o(),u(),x(),p(),y(),Ce(),ee(),I(),L=class extends le{}}));function z(e,t){return t.includes(e.id)||e.idLike.some(e=>t.includes(e))}function B(){let e=process.execPath||process.argv[0]||``;return/[/\\]mise[/\\]installs[/\\]/i.test(e)?(f(`Detected mise installation: ${e}`),!0):!1}function V(){let e=process.execPath||process.argv[0]||``;return/[/\\]\.?asdf[/\\]installs[/\\]/i.test(e)?(f(`Detected asdf installation: ${e}`),!0):!1}function H(){let e=C();if(e!==`macos`&&e!==`linux`&&e!==`wsl`)return!1;let t=process.execPath||process.argv[0]||``;return t.includes(`/Caskroom/`)?(f(`Detected Homebrew cask installation: ${t}`),!0):!1}function U(){if(C()!==`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 f(`Detected winget installation: ${e}`),!0;return!1}var W,G,K,q,J,qe,Je=e((()=>{n(),m(),x(),be(),W=t(async()=>{try{let e=await A(`/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(C()!==`linux`)return!1;let e=await W();if(e&&!z(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?(f(`Detected pacman installation: ${t.stdout.trim()}`),!0):!1}),K=t(async()=>{if(C()!==`linux`)return!1;let e=await W();if(e&&!z(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?(f(`Detected deb installation: ${t.stdout.trim()}`),!0):!1}),q=t(async()=>{if(C()!==`linux`)return!1;let e=await W();if(e&&!z(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?(f(`Detected rpm installation: ${t.stdout.trim()}`),!0):!1}),J=t(async()=>{if(C()!==`linux`)return!1;let e=await W();if(e&&!z(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?(f(`Detected apk installation: ${t.stdout.trim()}`),!0):!1}),qe=t(async()=>H()?`homebrew`:U()?`winget`:B()?`mise`:V()?`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 C()===`windows`&&(e=e.split(O.sep).join(D.sep),t=t.split(O.sep).join(D.sep)),[e,t]}async function Xe(){let[e]=Ye();if(w())return H()||U()||B()||V()||await G()||await K()||await q()||await J()?`package-manager`:`native`;if(Ie())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 j(process.execPath)}catch{}try{let e=await ye(`claude`);if(e)return e}catch{}try{return await h().stat(E(T(),`.local/bin/claude`)),E(T(),`.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=h(),t=[],n=E(T(),`.workmate`,`local`);await Le()&&t.push({type:`npm-local`,path:n});let r=[`@readmagic/workmate`],i=await S(`npm`,[`-g`,`config`,`get`,`prefix`]);if(i.code===0&&i.stdout){let n=i.stdout.trim(),a=C()===`windows`,o=a?E(n,`claude`):E(n,`bin`,`claude`),s=!1;try{await e.stat(o),s=!0}catch{}if(s){let e=!1;try{(await j(o)).includes(`/Caskroom/`)&&(e=H())}catch{}e||t.push({type:`npm-global`,path:o})}else for(let i of r){let r=a?E(n,`node_modules`,i):E(n,`lib`,`node_modules`,i);try{await e.stat(r),t.push({type:`npm-global-orphan`,path:r})}catch{}}}let a=E(T(),`.local`,`bin`,`claude`);try{await e.stat(a),t.push({type:`native`,path:a})}catch{}if(v().installMethod===`native`){let n=E(T(),`.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=ue(await A(E(ie(),`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: ${s.join(`, `)}.`});else{let e=n.filter(e=>typeof e==`string`&&!s.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: ${s.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(Ae),n=E(T(),`.local`,`bin`),r=n;if(C()===`windows`&&(r=n.split(O.sep).join(D.sep)),!e.some(e=>{let t=e;C()===`windows`&&(t=e.split(O.sep).join(D.sep));let n=t.replace(/\/+$/,``),i=e.replace(/[/\\]+$/,``);return n===r||i===`~/.local/bin`||i===`$HOME/.local/bin`}))if(C()===`windows`){let e=n.split(D.sep).join(O.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=Re(),n=N()[e],r=n?n.replace(T(),`~`):`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 Le()&&t.push({issue:`Local installation exists but not being used`,fix:`Consider using native installation: claude install`});let r=await P(),i=await He();return e===`npm-local`&&!await ye(`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(C()!==`linux`)return[];let e=[],t=ae.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.28`:`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=C()===`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 @readmagic/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 Ke()).hasPermissions,!s&&!_()&&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=Ee(),l={working:c.working??!0,mode:c.mode,systemPath:c.mode===`system`?c.path:null,note:c.note??null},ee=e===`package-manager`?await qe():void 0;return{installationType:e,version:t,installationPath:n,invokedBinary:r,configInstallMethod:o,autoUpdates:(()=>{let e=_();return e?`disabled (${he(e)})`:`enabled`})(),hasUpdatePermissions:s,multipleInstallations:i,warnings:a,packageManager:ee,ripgrepStatus:l}}var rt=e((()=>{ge(),R(),Se(),me(),se(),o(),x(),p(),M(),Je(),be(),Te(),oe(),ne(),c(),I(),g(),xe()}));function Y(e){return{env:e?.env??process.env,home:e?.homedir??process.env.HOME??T()}}function X(e,...t){return e.includes(`/`)&&!e.includes(`\\`)&&!/^[A-Za-z]:/.test(e)?D.join(e,...t):E(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=De(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=h();try{let n=t.readFileSync(e,{encoding:`utf8`});if(!n||n.trim()===``)return null;let r=ue(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 f(`Lock PID ${n} is running but does not appear to be Work Mate - treating as stale`),!1;let i=h();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=h(),r=`${e}.tmp.${process.pid}.${Date.now()}`;try{de(r,ce(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=h(),r=ke(e);if($(t))return f(`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?(f(`Acquired PID lock for ${r} (PID ${process.pid})`),()=>{try{Q(t)?.pid===process.pid&&(n.unlinkSync(t),f(`Released PID lock for ${r}`))}catch(e){f(`Failed to release lock for ${r}: ${e}`)}}):null}catch(e){return f(`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=h(),n=[];try{let r=t.readdirStringSync(e).filter(e=>e.endsWith(`.lock`));for(let t of r){let r=E(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(d(e))return n;b(fe(e))}return n}function gt(e){let t=h(),n=0;try{let r=t.readdirStringSync(e).filter(e=>e.endsWith(`.lock`));for(let i of r){let r=E(e,i);try{t.lstatSync(r).isDirectory()?(t.rmSync(r,{recursive:!0,force:!0}),n++,f(`Cleaned up legacy directory lock: ${i}`)):$(r)||(t.unlinkSync(r),n++,f(`Cleaned up stale lock: ${i}`))}catch{}}}catch(e){if(d(e))return 0;b(fe(e))}return n}var _t,vt=e((()=>{m(),o(),u(),p(),Oe(),y(),g(),_t=7200*1e3}));export{Be as C,M as E,I as S,Re as T,Ue as _,$ as a,ze 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,R as v,Ve as w,N as x,We as y};
|