@readmagic/workmate 0.0.21 → 0.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (461) hide show
  1. package/dist/chunks/AddWorkspaceDirectory-DWgTWJ7R.js +1 -0
  2. package/dist/chunks/AgentsMdExternalIncludesDialog-DCvgQ6n3.js +1 -0
  3. package/dist/chunks/AgentsMdExternalIncludesDialog-s0Orgord.js +1 -0
  4. package/dist/chunks/App-BcEI6U5j.js +1 -0
  5. package/dist/chunks/ApproveApiKey-DegdTXZl.js +1 -0
  6. package/dist/chunks/ApproveApiKey-_VXIMSwY.js +1 -0
  7. package/dist/chunks/BackgroundTasksDialog-CjBt1L0p.js +2 -0
  8. package/dist/chunks/BypassPermissionsModeDialog-D2Gesf-u.js +1 -0
  9. package/dist/chunks/CustomSelect-B46Eh0gU.js +1 -0
  10. package/dist/chunks/DiffDialog-v2IiYyi3.js +6 -0
  11. package/dist/chunks/Doctor-BP0Rqraa.js +1 -0
  12. package/dist/chunks/Doctor-By_y3C2V.js +3 -0
  13. package/dist/chunks/ExitFlow-BasHk1mk.js +2 -0
  14. package/dist/chunks/Grove-C3mhgshv.js +11 -0
  15. package/dist/chunks/InvalidConfigDialog-DYVQK5js.js +1 -0
  16. package/dist/chunks/InvalidSettingsDialog-Dg6OiStR.js +1 -0
  17. package/dist/chunks/KeybindingProviderSetup-Bn1jzN5F.js +1 -0
  18. package/dist/chunks/MCPConnectionManager-ChN4Ayjk.js +1 -0
  19. package/dist/chunks/MCPToolListView-DLSrQHDc.js +1 -0
  20. package/dist/chunks/{McpParsingWarnings-6ENzOklf.js → McpParsingWarnings-DZejAh8b.js} +1 -1
  21. package/dist/chunks/MessageSelector-CdDlJE48.js +3 -0
  22. package/dist/chunks/Messages-DuL_r1Or.js +10 -0
  23. package/dist/chunks/Onboarding-CE2GNA-h.js +1 -0
  24. package/dist/chunks/{PromptInputFooterSuggestions-Blzgj5yW.js → PromptInputFooterSuggestions-lkr_A5jQ.js} +1 -1
  25. package/dist/chunks/PromptInputHelpMenu-DaQKKyM5.js +1 -0
  26. package/dist/chunks/QueryEngine-DNNy1UCD.js +1 -0
  27. package/dist/chunks/REPL-CEhW-C41.js +1 -0
  28. package/dist/chunks/REPL-CkSL4C_8.js +124 -0
  29. package/dist/chunks/ResumeConversation-BMCO_3X7.js +1 -0
  30. package/dist/chunks/SearchExtraToolsTool-DSy_jDhf.js +1 -0
  31. package/dist/chunks/SelectMulti-CNE06VAN.js +1 -0
  32. package/dist/chunks/Settings-mDykHLok.js +2 -0
  33. package/dist/chunks/Spinner-DwsJJUtn.js +1 -0
  34. package/dist/chunks/SpinnerGlyph-A6G-gloN.js +1 -0
  35. package/dist/chunks/TextInput-7uqPhq9T.js +22 -0
  36. package/dist/chunks/ThemePicker-DT9zVy-0.js +1 -0
  37. package/dist/chunks/TrustDialog-G4jM9IfM.js +1 -0
  38. package/dist/chunks/{ValidationErrorsList-2QWIs_6h.js → ValidationErrorsList-BLtP647v.js} +1 -1
  39. package/dist/chunks/add-dir-7RfQAC3h.js +1 -0
  40. package/dist/chunks/{agentDisplay-1Y-N-gqz.js → agentDisplay-vLQHFrmq.js} +1 -1
  41. package/dist/chunks/agents-BNg_skSm.js +101 -0
  42. package/dist/chunks/{agents-CvW8XjoJ.js → agents-DLz0kfsr.js} +1 -1
  43. package/dist/chunks/allErrors-DaztSMrw.js +1 -0
  44. package/dist/chunks/appleTerminalBackup-BYKdf3of.js +1 -0
  45. package/dist/chunks/auth-BTB00dq5.js +10 -0
  46. package/dist/chunks/auth-Bbc0Ny8i.js +1 -0
  47. package/dist/chunks/backgroundHousekeeping-DYz83_8C.js +1 -0
  48. package/dist/chunks/backgroundHousekeeping-bEZtlJSf.js +17 -0
  49. package/dist/chunks/banner-mqZEluky.js +2 -0
  50. package/dist/chunks/branch-exFKkymg.js +2 -0
  51. package/dist/chunks/{break-cache-BZ_UMtEL.js → break-cache-BL2gnDLX.js} +2 -2
  52. package/dist/chunks/btw-3l78DYET.js +1 -0
  53. package/dist/chunks/caches-6Nx6tsk9.js +1 -0
  54. package/dist/chunks/caches-ouaWB9bY.js +1 -0
  55. package/dist/chunks/claudeDesktop-D3PEgx3U.js +1 -0
  56. package/dist/chunks/{clear-D2KRoibg.js → clear-CXfhVRp8.js} +1 -1
  57. package/dist/chunks/client-C01Bnxxv.js +1 -0
  58. package/dist/chunks/client-DYRgRQsr.js +1 -0
  59. package/dist/chunks/{client-C_jBL1yC.js → client-DdenNfkQ.js} +1 -1
  60. package/dist/chunks/client-DvhWKIOx.js +1 -0
  61. package/dist/chunks/commands-BoxOw75F.js +1 -0
  62. package/dist/chunks/compact-BOYr105K.js +2 -0
  63. package/dist/chunks/config-BddEvZZl.js +3 -0
  64. package/dist/chunks/config-GEv9hUzz.js +1 -0
  65. package/dist/chunks/config-kw4xg7Nk.js +1 -0
  66. package/dist/chunks/{context-Db9tH1VF.js → context-3s9wtn4L.js} +1 -1
  67. package/dist/chunks/{context-noninteractive-CacA9VlT.js → context-noninteractive-CJhUu_4y.js} +9 -9
  68. package/dist/chunks/context-noninteractive-DFvoZ2L9.js +1 -0
  69. package/dist/chunks/conversation-CoGharlH.js +1 -0
  70. package/dist/chunks/conversation-MxEVm54C.js +1 -0
  71. package/dist/chunks/conversationRecovery-Da_8uldZ.js +1 -0
  72. package/dist/chunks/crossProjectResume-CzPCHq_K.js +40 -0
  73. package/dist/chunks/cwd-BcO6WHKo.js +1 -0
  74. package/dist/chunks/cwd-CDUelriw.js +1 -0
  75. package/dist/chunks/{datadog-BuElf2EQ.js → datadog-v_mXWncN.js} +1 -1
  76. package/dist/chunks/{debug-D58GQBDG.js → debug-8DCufdSp.js} +4 -4
  77. package/dist/chunks/detectRepository-DfX8xXw2.js +1 -0
  78. package/dist/chunks/{diff-yA6v_dpP.js → diff-DJSt7QO6.js} +1 -1
  79. package/dist/chunks/directoryCompletion-CT6YVeg7.js +1 -0
  80. package/dist/chunks/doctor-DWvioSU9.js +1 -0
  81. package/dist/chunks/entry-ex0-RyYV.js +13 -0
  82. package/dist/chunks/esm-BQY8jJNR.js +1 -0
  83. package/dist/chunks/{execFileNoThrow-B_KRY4cT.js → execFileNoThrow-BsfuytkN.js} +1 -1
  84. package/dist/chunks/exit-BxC_ZEtO.js +1 -0
  85. package/dist/chunks/extraUsage-DYm33Occ.js +1 -0
  86. package/dist/chunks/extractMemories-CzN3Ax2B.js +1 -0
  87. package/dist/chunks/fast-DqUpl_Lr.js +1 -0
  88. package/dist/chunks/fast-NUdUyAaM.js +1 -0
  89. package/dist/chunks/fetchModelList-CqsTAWEN.js +1 -0
  90. package/dist/chunks/fetchModelList-DBMHE6Ng.js +1 -0
  91. package/dist/chunks/fileSuggestions-B-SLfb-o.js +3 -0
  92. package/dist/chunks/firstPartyEventLogger-C0q45h_4.js +3 -0
  93. package/dist/chunks/firstPartyEventLogger-CP8hCBDj.js +1 -0
  94. package/dist/chunks/gemini-BC9kHhwe.js +2 -0
  95. package/dist/chunks/generateSessionName-ChvKBVxB.js +1 -0
  96. package/dist/chunks/{genericProcessUtils-Cnyun_Wr.js → genericProcessUtils-BYi0OefF.js} +1 -1
  97. package/dist/chunks/goal-ByyimpVU.js +3 -0
  98. package/dist/chunks/grok-DenjixMl.js +1 -0
  99. package/dist/chunks/grove-Dq8QbQ9o.js +7 -0
  100. package/dist/chunks/help-CK90i4hE.js +1 -0
  101. package/dist/chunks/history-CNQNd6hT.js +1 -0
  102. package/dist/chunks/{hooks-BDgToO1Z.js → hooks-BRFDg9DV.js} +2 -2
  103. package/dist/chunks/hooks-BaYwmkxD.js +1 -0
  104. package/dist/chunks/install-ZMll-dAa.js +1 -0
  105. package/dist/chunks/instrumentation-BwVyvRfY.js +21 -0
  106. package/dist/chunks/{job-DYMfSglZ.js → job-G_ukhLc4.js} +1 -1
  107. package/dist/chunks/keybindings-wNxBzDVQ.js +1 -0
  108. package/dist/chunks/launchLocalMemory-BcRlXLm6.js +3 -0
  109. package/dist/chunks/launchOnboarding-CDjQ64RO.js +8 -0
  110. package/dist/chunks/{loadAgentsDir-C96o6gCj.js → loadAgentsDir-C1LkW7gl.js} +551 -621
  111. package/dist/chunks/loadAgentsDir-DKXap_Om.js +1 -0
  112. package/dist/chunks/{loadPluginHooks-0nGlugZ4.js → loadPluginHooks-DtmHtEiS.js} +1 -1
  113. package/dist/chunks/{loader-C33o_5kS.js → loader-C61fB6vU.js} +1 -1
  114. package/dist/chunks/localSearch-BB9x5C2N.js +1 -0
  115. package/dist/chunks/{localSearch-DLz5IGGu.js → localSearch-DFo_WTMm.js} +1 -1
  116. package/dist/chunks/log-DaILwWJa.js +1 -0
  117. package/dist/chunks/logoUtils-Dj_2SWmO.js +1 -0
  118. package/dist/chunks/{magicDocs-DmPNMnNY.js → magicDocs-DYc9TFmI.js} +2 -2
  119. package/dist/chunks/main-BRg8L_aw.js +346 -0
  120. package/dist/chunks/managedEnv-DsqAYOJ4.js +1 -0
  121. package/dist/chunks/managedEnv-lybrMred.js +1 -0
  122. package/dist/chunks/mcp-Bsw3cMiJ.js +6 -0
  123. package/dist/chunks/mcp-DDdud6Y7.js +1 -0
  124. package/dist/chunks/mcp-DbgTDUt7.js +2 -0
  125. package/dist/chunks/memory-CzwTzihf.js +1 -0
  126. package/dist/chunks/mode-Pan-Q2c4.js +2 -0
  127. package/dist/chunks/model-BYfmXKHf.js +1 -0
  128. package/dist/chunks/model-BwBE0Pt5.js +1 -0
  129. package/dist/chunks/modelOptions-DvNBapgG.js +1 -0
  130. package/dist/chunks/nativeInstaller-DnSNJWIi.js +1 -0
  131. package/dist/chunks/notifications-B0DTaYoy.js +1 -0
  132. package/dist/chunks/omit-Dl1Us_PY.js +1 -0
  133. package/dist/chunks/onChangeAppState-4KOJMN82.js +1 -0
  134. package/dist/chunks/openai-C_6C1_0N.js +10 -0
  135. package/dist/chunks/overlayContext-CMV7nYR9.js +1 -0
  136. package/dist/chunks/{panel-Cm23FDVt.js → panel-D9fGQgln.js} +1 -1
  137. package/dist/chunks/parser-BKAVMTyD.js +1 -0
  138. package/dist/chunks/{parser-eVu-cTRs.js → parser-D8slvrJP.js} +1 -1
  139. package/dist/chunks/partition-B504IgAa.js +1 -0
  140. package/dist/chunks/pasteStore-DNV1M5Xd.js +1 -0
  141. package/dist/chunks/permissions-CLFMhdRk.js +3 -0
  142. package/dist/chunks/pidLock-D9do1Afy.js +3 -0
  143. package/dist/chunks/{plan-s228H7IU.js → plan-CQLnPLuE.js} +1 -1
  144. package/dist/chunks/{platform-DMQxcm4K.js → platform-Dzff1WWw.js} +1 -1
  145. package/dist/chunks/plugin-BYdF7uob.js +17 -0
  146. package/dist/chunks/{pluginAutoupdate-aLXhSUVD.js → pluginAutoupdate-BJaAqwTH.js} +1 -1
  147. package/dist/chunks/{pluginBlocklist-BprCv0En.js → pluginBlocklist-DKKmOnWM.js} +1 -1
  148. package/dist/chunks/pluginCliCommands-z8TtJMKH.js +1 -0
  149. package/dist/chunks/{pluginFlagging-BSLuTk3M.js → pluginFlagging-DQP8tBi2.js} +1 -1
  150. package/dist/chunks/pluginOperations-BcfJCDco.js +2 -0
  151. package/dist/chunks/{pluginStartupCheck-xQbHZ5gf.js → pluginStartupCheck-CfRvCrFg.js} +1 -1
  152. package/dist/chunks/pluginStartupCheck-Cq4PvULa.js +1 -0
  153. package/dist/chunks/plugins-CTM8jpOw.js +4 -0
  154. package/dist/chunks/policyLimits-a7ix6GnU.js +1 -0
  155. package/dist/chunks/poorMode-C11JEH3d.js +1 -0
  156. package/dist/chunks/{poorMode-Bt_A2arj.js → poorMode-J5SYJvoY.js} +1 -1
  157. package/dist/chunks/print-u6MzL5Cr.js +13 -0
  158. package/dist/chunks/processBashCommand-DIwrI2QC.js +1 -0
  159. package/dist/chunks/processSlashCommand-B-Gujpxm.js +5 -0
  160. package/dist/chunks/projectOnboardingState-CJycxw5P.js +1 -0
  161. package/dist/chunks/{prompt-BNNE5tsG.js → prompt-BGqgPgCU.js} +3 -3
  162. package/dist/chunks/prompt-BPJDGlx5.js +1 -0
  163. package/dist/chunks/prompt-DEdZzkEz.js +1 -0
  164. package/dist/chunks/promptEditor-CmQ9p4oe.js +4 -0
  165. package/dist/chunks/{protocolHandler-DukQ6b4Q.js → protocolHandler-CJo9-PfZ.js} +2 -2
  166. package/dist/chunks/{proxy-BhIc7-mj.js → proxy-CB17QimU.js} +2 -2
  167. package/dist/chunks/reconciler-DSKLuOS7.js +1 -0
  168. package/dist/chunks/refresh-BbZFCNpn.js +1 -0
  169. package/dist/chunks/registerProtocol-CLIpzVwF.js +1 -0
  170. package/dist/chunks/reload-plugins-DjugL8jH.js +1 -0
  171. package/dist/chunks/rename-DOtCOtEr.js +1 -0
  172. package/dist/chunks/{renderOptions-D-aQZbzS.js → renderOptions-Zqfm2U1y.js} +1 -1
  173. package/dist/chunks/resume-BB4T4WIV.js +2 -0
  174. package/dist/chunks/ripgrep-BuzOTf1S.js +5 -0
  175. package/dist/chunks/ripgrep-CZ2CqaHb.js +1 -0
  176. package/dist/chunks/{runtimeObserver-DS1PK6We.js → runtimeObserver-CK_iZ6OB.js} +1 -1
  177. package/dist/chunks/{runtimeObserver-CsZw5XBt.js → runtimeObserver-CpP0L9T9.js} +4 -4
  178. package/dist/chunks/sandbox-adapter-DhJJ6WOV.js +1 -0
  179. package/dist/chunks/sandbox-toggle-KOHYvbQT.js +1 -0
  180. package/dist/chunks/searchExtraTools-CdJghGkj.js +1 -0
  181. package/dist/chunks/select-C_KXmqbI.js +1 -0
  182. package/dist/chunks/sessionFileAccessHooks-D7KbWFp7.js +1 -0
  183. package/dist/chunks/sessionObserver-DB-sLv-X.js +1 -0
  184. package/dist/chunks/{sessionObserver-N7fORFdL.js → sessionObserver-WOYv2n7C.js} +2 -2
  185. package/dist/chunks/sessionStorage-sgOAbDn7.js +1 -0
  186. package/dist/chunks/{sessionTracing-fIp8g04N.js → sessionTracing-yBre24PH.js} +2 -2
  187. package/dist/chunks/settings-C-KNkvsM.js +1 -0
  188. package/dist/chunks/settings-DKN4xSpQ.js +24 -0
  189. package/dist/chunks/setup-CN_Pk7AR.js +3 -0
  190. package/dist/chunks/{shadowedRuleDetection-DEo1hvGi.js → shadowedRuleDetection-Df-kZ_pK.js} +1 -1
  191. package/dist/chunks/{sideQuestion-C11KgNGL.js → sideQuestion-CMB8hfgX.js} +3 -3
  192. package/dist/chunks/sinks-BS17vtN0.js +1 -0
  193. package/dist/chunks/sinks-D1EjkHb4.js +1 -0
  194. package/dist/chunks/skillChangeDetector-CBKuGuEi.js +1 -0
  195. package/dist/chunks/{skillGapStore-H4MkUFUY.js → skillGapStore-CfmlO6pb.js} +2 -2
  196. package/dist/chunks/{skillLifecycle-ADUTDK7D.js → skillLifecycle-BQ2LMfMx.js} +2 -2
  197. package/dist/chunks/{skillSearchPanel-PpfVDMGR.js → skillSearchPanel-BwYuwLFs.js} +4 -4
  198. package/dist/chunks/skills-BVHPQma0.js +1 -0
  199. package/dist/chunks/startupProfiler-B_U4QDtf.js +1 -0
  200. package/dist/chunks/startupProfiler-DTs9w9EN.js +3 -0
  201. package/dist/chunks/{state-D5D6QpTX.js → state-BowF111d.js} +1 -1
  202. package/dist/chunks/state-CGuyDES7.js +1 -0
  203. package/dist/chunks/status-BurdTfyz.js +2 -0
  204. package/dist/chunks/status-DMq1An5h.js +1 -0
  205. package/dist/chunks/statusNoticeHelpers-X75JNlx5.js +1 -0
  206. package/dist/chunks/stringUtils-BQm3OfeJ.js +4 -0
  207. package/dist/chunks/{switcher-DWfKi17X.js → switcher-Bq1Ct_Sn.js} +1 -1
  208. package/dist/chunks/switcher-DGD4ORVf.js +1 -0
  209. package/dist/chunks/{tasks-BwSsj2vI.js → tasks-0c8Uy04D.js} +1 -1
  210. package/dist/chunks/tempfile-CHO5wXsV.js +1 -0
  211. package/dist/chunks/{templateJobs-fiKuu4DK.js → templateJobs-BdFzE9XG.js} +1 -1
  212. package/dist/chunks/terminalSetup-Cf_r6pwK.js +32 -0
  213. package/dist/chunks/{terminalSetup-Cte5a4hM.js → terminalSetup-D7J6bxcn.js} +1 -1
  214. package/dist/chunks/{theme-CAoGjf2D.js → theme-Bby4fssR.js} +1 -1
  215. package/dist/chunks/tipRegistry-CyRXWWTz.js +2 -0
  216. package/dist/chunks/{toolEventObserver-Cq_ZV7x9.js → toolEventObserver-CzFZUIsM.js} +1 -1
  217. package/dist/chunks/toolPool-CnrZcprA.js +1 -0
  218. package/dist/chunks/types-zk5Ltv5q.js +81 -0
  219. package/dist/chunks/udsClient-ftP0yIpe.js +1 -0
  220. package/dist/chunks/use-select-navigation-DMaC_3iw.js +1 -0
  221. package/dist/chunks/useDoublePress-C9xxQzh1.js +1 -0
  222. package/dist/chunks/useExitOnCtrlCDWithKeybindings-CjW3gUOt.js +1 -0
  223. package/dist/chunks/useMainLoopModel-DWscpA9I.js +1 -0
  224. package/dist/chunks/useManagePlugins-CYXVcql2.js +1 -0
  225. package/dist/chunks/useMergedTools-DarmnCEw.js +1 -0
  226. package/dist/chunks/useSearchInput-C2JuUW3g.js +1 -0
  227. package/dist/chunks/useSettingsErrors-DutJBiKZ.js +1 -0
  228. package/dist/chunks/util-Bq5l7FF5.js +1 -0
  229. package/dist/chunks/validatePlugin-DIdEydz_.js +1 -0
  230. package/dist/chunks/{vim-xruiCyUd.js → vim-D8prM2IH.js} +1 -1
  231. package/dist/chunks/worktree-Caqt2WRZ.js +1 -0
  232. package/dist/cli.js +1 -1
  233. package/package.json +1 -1
  234. package/dist/chunks/AddWorkspaceDirectory-DgAxYgBY.js +0 -1
  235. package/dist/chunks/AgentsMdExternalIncludesDialog-DGMRVexR.js +0 -1
  236. package/dist/chunks/AgentsMdExternalIncludesDialog-Dp6CwZyI.js +0 -1
  237. package/dist/chunks/App-VWyPd524.js +0 -1
  238. package/dist/chunks/ApproveApiKey-Bolw0sPs.js +0 -1
  239. package/dist/chunks/ApproveApiKey-CyNPMd6g.js +0 -1
  240. package/dist/chunks/BackgroundTasksDialog-DxagIOOw.js +0 -2
  241. package/dist/chunks/BypassPermissionsModeDialog-OS2S66zQ.js +0 -1
  242. package/dist/chunks/DiffDialog-CMtml9iw.js +0 -6
  243. package/dist/chunks/Doctor-Bk9P37mU.js +0 -1
  244. package/dist/chunks/Doctor-D9F3tKsr.js +0 -3
  245. package/dist/chunks/ExitFlow-DhRv5JPj.js +0 -2
  246. package/dist/chunks/Grove-Bbh8PpH0.js +0 -11
  247. package/dist/chunks/HybridTransport-P1vEUwhv.js +0 -2
  248. package/dist/chunks/InvalidConfigDialog-xAYpE-20.js +0 -1
  249. package/dist/chunks/InvalidSettingsDialog-CXFSISy3.js +0 -1
  250. package/dist/chunks/MCPConnectionManager-CoId-C__.js +0 -1
  251. package/dist/chunks/MCPToolListView-BQkQ-hyF.js +0 -1
  252. package/dist/chunks/MessageSelector-BvRVrfg6.js +0 -3
  253. package/dist/chunks/Messages-Cykztq1O.js +0 -10
  254. package/dist/chunks/Onboarding-CfeRwPNQ.js +0 -1
  255. package/dist/chunks/PromptInputHelpMenu-Ckp0k8E3.js +0 -1
  256. package/dist/chunks/QueryEngine-DduzztIG.js +0 -1
  257. package/dist/chunks/REPL-B8e5UU3H.js +0 -128
  258. package/dist/chunks/REPL-C4mbOhyL.js +0 -1
  259. package/dist/chunks/RemoteSessionManager-BPESC6Wu.js +0 -2
  260. package/dist/chunks/ResumeConversation-DG1sLryB.js +0 -1
  261. package/dist/chunks/SSETransport-CDNP2PlK.js +0 -2
  262. package/dist/chunks/SearchExtraToolsTool-vK2PP628.js +0 -1
  263. package/dist/chunks/Settings-B7n_dfP-.js +0 -2
  264. package/dist/chunks/TeleportProgress-QL3ibQfK.js +0 -1
  265. package/dist/chunks/TeleportRepoMismatchDialog-f-xl7biD.js +0 -1
  266. package/dist/chunks/TeleportResumeWrapper-DzVcrFuP.js +0 -1
  267. package/dist/chunks/ThemePicker-CIFKZza0.js +0 -1
  268. package/dist/chunks/TrustDialog-C0HEwZPk.js +0 -1
  269. package/dist/chunks/add-dir-DmEhPnvj.js +0 -1
  270. package/dist/chunks/agents-D96ng5I9.js +0 -101
  271. package/dist/chunks/allErrors-CT2dbBF3.js +0 -1
  272. package/dist/chunks/api-DTyrmy1O.js +0 -1
  273. package/dist/chunks/api-DumFOErN.js +0 -1
  274. package/dist/chunks/auth-CZ4EsFWF.js +0 -10
  275. package/dist/chunks/auth-QvonHoG9.js +0 -1
  276. package/dist/chunks/auth-jV5THRH8.js +0 -1
  277. package/dist/chunks/backgroundHousekeeping-C72oPgfD.js +0 -17
  278. package/dist/chunks/backgroundHousekeeping-D9PScHES.js +0 -1
  279. package/dist/chunks/banner-ChT5Ri7Q.js +0 -2
  280. package/dist/chunks/bg-qG2osBbP.js +0 -9
  281. package/dist/chunks/branch-K8X6jx0i.js +0 -2
  282. package/dist/chunks/bridgeConfig-C-bI-slm.js +0 -1
  283. package/dist/chunks/bridgeConfig-_xpxhGB5.js +0 -1
  284. package/dist/chunks/bridgeMessaging-DSJlYarJ.js +0 -1
  285. package/dist/chunks/bridgePointer-DfTOjgtX.js +0 -1
  286. package/dist/chunks/bridgeStatusUtil-DaEq5c69.js +0 -1
  287. package/dist/chunks/btw-BNs5OX7x.js +0 -1
  288. package/dist/chunks/bundledMode--fG1S62b.js +0 -1
  289. package/dist/chunks/caches-CC5NHwAz.js +0 -1
  290. package/dist/chunks/caches-nHxJWXgO.js +0 -1
  291. package/dist/chunks/capacityWake-BpP6c7x3.js +0 -3
  292. package/dist/chunks/ccrClient-JnhF5b3z.js +0 -1
  293. package/dist/chunks/claudeDesktop-DPc_SaVn.js +0 -1
  294. package/dist/chunks/cliLaunch-DDtwAolw.js +0 -1
  295. package/dist/chunks/client-9uHzAmFH.js +0 -1
  296. package/dist/chunks/client-BVal_QII.js +0 -1
  297. package/dist/chunks/client-BtTkq0YS.js +0 -1
  298. package/dist/chunks/client-Dd7CKMRX.js +0 -1
  299. package/dist/chunks/commands-C_rYjyQZ.js +0 -1
  300. package/dist/chunks/compact-Cqd6vKpn.js +0 -2
  301. package/dist/chunks/config-Be0BkAAr.js +0 -1
  302. package/dist/chunks/config-DUTgj3js.js +0 -3
  303. package/dist/chunks/config-DoEDgAfv.js +0 -1
  304. package/dist/chunks/context-noninteractive-D9tJYwi7.js +0 -1
  305. package/dist/chunks/controlMessageCompat-IFu4Gc1y.js +0 -1
  306. package/dist/chunks/conversation-DWfE4KGH.js +0 -1
  307. package/dist/chunks/conversation-Tvo4EDpQ.js +0 -1
  308. package/dist/chunks/createSSHSession-BQ83MMtr.js +0 -5
  309. package/dist/chunks/createSession-CqHnHhCR.js +0 -1
  310. package/dist/chunks/createSession-DqTtBycR.js +0 -1
  311. package/dist/chunks/crossProjectResume-DIXtiODF.js +0 -40
  312. package/dist/chunks/cwd-DLK3znO7.js +0 -1
  313. package/dist/chunks/cwd-Nh5IZNKO.js +0 -1
  314. package/dist/chunks/debugUtils-DXBRbwCE.js +0 -1
  315. package/dist/chunks/detached-Biz-xhu0.js +0 -4
  316. package/dist/chunks/detectRepository-DUJBh5s2.js +0 -1
  317. package/dist/chunks/detectRepository-pRAVv8SH.js +0 -1
  318. package/dist/chunks/directoryCompletion-CuA3_YIT.js +0 -1
  319. package/dist/chunks/doctor-eNAm6OiS.js +0 -1
  320. package/dist/chunks/entry-DidpiR-D.js +0 -13
  321. package/dist/chunks/esm-BCUC71kt.js +0 -1
  322. package/dist/chunks/execSyncWrapper-C3ZFV9od.js +0 -1
  323. package/dist/chunks/exit-DywUeiYd.js +0 -1
  324. package/dist/chunks/extraUsage-DiAirtuk.js +0 -1
  325. package/dist/chunks/extractMemories-_xiTnX95.js +0 -1
  326. package/dist/chunks/fast-DCXZACT9.js +0 -1
  327. package/dist/chunks/fast-Qo4WVqiW.js +0 -1
  328. package/dist/chunks/fetchModelList-fQDsmR3E.js +0 -1
  329. package/dist/chunks/fetchModelList-woVzIVde.js +0 -1
  330. package/dist/chunks/fileSuggestions-CRx1D6uk.js +0 -3
  331. package/dist/chunks/firstPartyEventLogger-B261Wksn.js +0 -3
  332. package/dist/chunks/firstPartyEventLogger-DtFTeHy-.js +0 -1
  333. package/dist/chunks/flushGate-BA8dSr0i.js +0 -1
  334. package/dist/chunks/gemini-BXAyy1JN.js +0 -1
  335. package/dist/chunks/generateSessionName-Cwmk2N3F.js +0 -1
  336. package/dist/chunks/git-Wid-XppW.js +0 -5
  337. package/dist/chunks/git-hO-TMvXc.js +0 -1
  338. package/dist/chunks/githubRepoPathMapping-OV8U1VFK.js +0 -1
  339. package/dist/chunks/goal-C9clrwEH.js +0 -3
  340. package/dist/chunks/grok-CjeCecsZ.js +0 -1
  341. package/dist/chunks/grove-DqTnK9nn.js +0 -7
  342. package/dist/chunks/hash-Tu-My5Vp.js +0 -1
  343. package/dist/chunks/help-Bb6LdzXK.js +0 -1
  344. package/dist/chunks/hooks-BX2s7aoL.js +0 -1
  345. package/dist/chunks/initReplBridge-D7cuY_os.js +0 -1
  346. package/dist/chunks/install-eCA8UACi.js +0 -1
  347. package/dist/chunks/instrumentation-BaRKojJh.js +0 -21
  348. package/dist/chunks/jwtUtils-JE2okZ70.js +0 -1
  349. package/dist/chunks/keybindings-iBqc1KHL.js +0 -1
  350. package/dist/chunks/launchLocalMemory-IZPGEzMk.js +0 -3
  351. package/dist/chunks/launchOnboarding-BeNf51Ig.js +0 -8
  352. package/dist/chunks/lazySchema-DULtBUCI.js +0 -65
  353. package/dist/chunks/lib-BlVGipXx.js +0 -14
  354. package/dist/chunks/loadAgentsDir-Bpke9CtB.js +0 -1
  355. package/dist/chunks/localSearch-dodgnjGn.js +0 -1
  356. package/dist/chunks/log-CZ7ploQm.js +0 -1
  357. package/dist/chunks/logoUtils-Cg_6QV1Z.js +0 -1
  358. package/dist/chunks/main-7ssnA9Yb.js +0 -31
  359. package/dist/chunks/main-BEv6MqMX.js +0 -356
  360. package/dist/chunks/managedEnv-CHYvwXBH.js +0 -1
  361. package/dist/chunks/managedEnv-CbjOQmEe.js +0 -1
  362. package/dist/chunks/mappers-D8VLUZ2N.js +0 -1
  363. package/dist/chunks/mcp-BUn3yqsT.js +0 -1
  364. package/dist/chunks/mcp-BskLq9iP.js +0 -2
  365. package/dist/chunks/mcp-C-0DMaXx.js +0 -6
  366. package/dist/chunks/memoize-CumjjK2Q.js +0 -1
  367. package/dist/chunks/memory-vDkJM58W.js +0 -1
  368. package/dist/chunks/mode-Dbh21H2Y.js +0 -2
  369. package/dist/chunks/model-BaMclMXn.js +0 -1
  370. package/dist/chunks/model-atn3_JBi.js +0 -1
  371. package/dist/chunks/model-vS1Iewyq.js +0 -1
  372. package/dist/chunks/modelOptions-Cw1ThINb.js +0 -1
  373. package/dist/chunks/nativeInstaller-CfZ5uNTh.js +0 -1
  374. package/dist/chunks/oauth-D38aRTUb.js +0 -1
  375. package/dist/chunks/oauth-U649LV5H.js +0 -1
  376. package/dist/chunks/omit-B7eQ9q0x.js +0 -1
  377. package/dist/chunks/onChangeAppState-kEAt8nxV.js +0 -1
  378. package/dist/chunks/openai-wh8AX5iz.js +0 -10
  379. package/dist/chunks/parser-Cq9X7HMP.js +0 -1
  380. package/dist/chunks/partition-CENvOfiS.js +0 -1
  381. package/dist/chunks/permissions-ChuIx-d4.js +0 -3
  382. package/dist/chunks/pidLock-C1hmh3YQ.js +0 -3
  383. package/dist/chunks/plugin-DVBEWwMP.js +0 -17
  384. package/dist/chunks/pluginCliCommands-WzzqR1Sr.js +0 -1
  385. package/dist/chunks/pluginOperations-Ca9Lup5G.js +0 -2
  386. package/dist/chunks/pluginStartupCheck-DdtxcNwH.js +0 -1
  387. package/dist/chunks/plugins-DdIaXpNb.js +0 -4
  388. package/dist/chunks/pollConfig-2nFzv6Hy.js +0 -1
  389. package/dist/chunks/poorMode-ZIq2oz7q.js +0 -1
  390. package/dist/chunks/print-vxrRE1O2.js +0 -14
  391. package/dist/chunks/processBashCommand-ISucgwpi.js +0 -1
  392. package/dist/chunks/processSlashCommand-BnpXO_fI.js +0 -5
  393. package/dist/chunks/prompt-2AA5W7EH.js +0 -1
  394. package/dist/chunks/prompt-AXiS2LoO.js +0 -1
  395. package/dist/chunks/promptEditor-DT6egmcb.js +0 -4
  396. package/dist/chunks/rcDebugLog-DSchf3Hs.js +0 -1
  397. package/dist/chunks/reconciler-D3zyJCnV.js +0 -1
  398. package/dist/chunks/refresh-BSG0t4cf.js +0 -1
  399. package/dist/chunks/registerProtocol-BOEYaX-X.js +0 -1
  400. package/dist/chunks/reload-plugins-BFMRhbv8.js +0 -1
  401. package/dist/chunks/remoteBridgeCore-D5OwvmAz.js +0 -1
  402. package/dist/chunks/remoteManagedSettings-DyGVvvcW.js +0 -1
  403. package/dist/chunks/rename-BrEwj3Xw.js +0 -1
  404. package/dist/chunks/resume-DR5JbICs.js +0 -2
  405. package/dist/chunks/ripgrep-Dt4a91S5.js +0 -5
  406. package/dist/chunks/ripgrep-KTOU5s9J.js +0 -1
  407. package/dist/chunks/sandbox-adapter-BqDyWcol.js +0 -1
  408. package/dist/chunks/sandbox-toggle-B9f_0NQI.js +0 -1
  409. package/dist/chunks/searchExtraTools-2pIT2C8u.js +0 -1
  410. package/dist/chunks/session-wkRTfdo8.js +0 -2
  411. package/dist/chunks/sessionFileAccessHooks-DV22q9JO.js +0 -1
  412. package/dist/chunks/sessionIdCompat-Dgp6PW_1.js +0 -1
  413. package/dist/chunks/sessionObserver-BLJg0qm_.js +0 -1
  414. package/dist/chunks/sessionState-8jutEorw.js +0 -11
  415. package/dist/chunks/sessionStorage-DRV7IhZF.js +0 -1
  416. package/dist/chunks/sessionStoragePortable-x0Yn02-G.js +0 -3
  417. package/dist/chunks/settings-BowI3jp-.js +0 -19
  418. package/dist/chunks/settings-CHn0gJCG.js +0 -1
  419. package/dist/chunks/settingsSync-DF4JgSNc.js +0 -1
  420. package/dist/chunks/setup-UiEO9i7F.js +0 -3
  421. package/dist/chunks/shellQuote-Ddgr1vif.js +0 -4
  422. package/dist/chunks/sinks-DnLqRPEC.js +0 -1
  423. package/dist/chunks/sinks-mGBiINp8.js +0 -1
  424. package/dist/chunks/skillChangeDetector-Dc6YZXJE.js +0 -1
  425. package/dist/chunks/skills-DKtN17ch.js +0 -1
  426. package/dist/chunks/startupProfiler-B90b5vuq.js +0 -3
  427. package/dist/chunks/startupProfiler-DG2TN5R_.js +0 -1
  428. package/dist/chunks/state-BStOuCh4.js +0 -1
  429. package/dist/chunks/stats-D4LEtkrw.js +0 -1
  430. package/dist/chunks/status-0ZBx6Ls0.js +0 -2
  431. package/dist/chunks/status-BUJ4-omB.js +0 -1
  432. package/dist/chunks/statusNoticeHelpers-BrpQWj0l.js +0 -1
  433. package/dist/chunks/stringUtils-D7oJIyY2.js +0 -4
  434. package/dist/chunks/subprocessEnv-CNBOhlDV.js +0 -1
  435. package/dist/chunks/subprocessEnv-DtBCqQIo.js +0 -1
  436. package/dist/chunks/switcher-D7Ey5uIi.js +0 -1
  437. package/dist/chunks/syncCache-DUhciJLz.js +0 -1
  438. package/dist/chunks/teleport-DwZMevmQ.js +0 -1
  439. package/dist/chunks/terminalSetup-a7-BNS4T.js +0 -32
  440. package/dist/chunks/tmux-DA06aewY.js +0 -1
  441. package/dist/chunks/toolPool-mdsxlKWR.js +0 -1
  442. package/dist/chunks/trustedDevice-C1m--Yjw.js +0 -1
  443. package/dist/chunks/trustedDevice-CeDIk_ln.js +0 -1
  444. package/dist/chunks/types-APu4OCXJ.js +0 -17
  445. package/dist/chunks/udsClient-BcwsY0XE.js +0 -1
  446. package/dist/chunks/upstreamproxy-CTOuotLO.js +0 -10
  447. package/dist/chunks/useExitOnCtrlCDWithKeybindings-L5idX6Kz.js +0 -1
  448. package/dist/chunks/useMainLoopModel-VXeS2EC6.js +0 -1
  449. package/dist/chunks/useManagePlugins-CAXp5CfH.js +0 -1
  450. package/dist/chunks/useMergedTools-DYXrPTIA.js +0 -1
  451. package/dist/chunks/useSearchInput-Bxl4wGcZ.js +0 -1
  452. package/dist/chunks/useSettingsErrors-sbjsaT7k.js +0 -1
  453. package/dist/chunks/userAgent-NbKd-hN7.js +0 -1
  454. package/dist/chunks/util-DU63xTwZ.js +0 -1
  455. package/dist/chunks/validatePlugin-DQ_9OCpP.js +0 -1
  456. package/dist/chunks/which-B8rchd8P.js +0 -1
  457. package/dist/chunks/windowsPaths-BdhjMYTm.js +0 -1
  458. package/dist/chunks/windowsPaths-DtGZ83kH.js +0 -1
  459. package/dist/chunks/workSecret-CaM2yIJD.js +0 -1
  460. package/dist/chunks/workerRegistry-BBgquE8F.js +0 -2
  461. package/dist/chunks/worktree-C28I8mFB.js +0 -1
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{l as t,o as n}from"./envUtils-DcaKZlRU.js";import{cn as r,d as i,h as a,ln as o,s}from"./settings-BowI3jp-.js";import{c,h as l}from"./config-DUTgj3js.js";import{d as u,g as d,h as f,l as p,n as m,t as h,v as g}from"./proxy-BhIc7-mj.js";import{n as _,t as v}from"./loader-C33o_5kS.js";import{n as y,t as b}from"./syncCache-DUhciJLz.js";import{n as x,r as S,t as C}from"./managedEnvConstants-BPwL2aWI.js";function w(e){if(!e||!process.env.ANTHROPIC_UNIX_SOCKET)return e||{};let{ANTHROPIC_UNIX_SOCKET:t,ANTHROPIC_BASE_URL:n,ANTHROPIC_API_KEY:r,ANTHROPIC_AUTH_TOKEN:i,CLAUDE_CODE_OAUTH_TOKEN:a,...o}=e;return o}function T(e){if(!e)return{};if(!t(process.env.CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST))return e;let n={};for(let[t,r]of Object.entries(e))S(t)||(n[t]=r);return n}function E(e){if(!e||!j)return e||{};let t={};for(let[n,r]of Object.entries(e))j.has(n)||(t[n]=r);return t}function D(e){if(!e)return{};let t=s(`userSettings`)?.activeProviderId;if(!t||!v(t))return e;let n={};for(let[t,r]of Object.entries(e))M.has(t.toUpperCase())||(n[t]=r);return n}function O(e){return E(T(D(w(e))))}function k(){j===void 0&&(j=process.env.CLAUDE_CODE_ENTRYPOINT===`claude-desktop`?new Set(Object.keys(process.env)):null),Object.assign(process.env,O(c().env));for(let e of N)e!==`policySettings`&&o(e)&&Object.assign(process.env,O(s(e)?.env));y(),Object.assign(process.env,O(s(`policySettings`)?.env));let e=O(i()?.env);for(let[t,n]of Object.entries(e))C.has(t.toUpperCase())&&(process.env[t]=n)}function A(){Object.assign(process.env,O(c().env)),Object.assign(process.env,O(i()?.env)),d(),u(),h(),m()}var j,M,N,P=e((()=>{_(),b(),g(),l(),n(),x(),f(),p(),r(),a(),M=new Set([`ANTHROPIC_BASE_URL`,`ANTHROPIC_API_KEY`,`ANTHROPIC_MODEL`,`CLAUDE_CODE_USE_OPENAI`,`OPENAI_BASE_URL`,`OPENAI_API_KEY`,`OPENAI_MODEL`]),N=[`userSettings`,`flagSettings`,`policySettings`]}));export{k as n,P as r,A as t};
@@ -1 +0,0 @@
1
- import{r as e,t}from"./managedEnv-CHYvwXBH.js";e();export{t as applyConfigEnvironmentVariables};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{$T as t,Tw as n,ea as r,rE as i}from"./loadAgentsDir-C96o6gCj.js";import{Kr as a,qr as o}from"./src-DL3w8VPk.js";import{Ut as s,ft as c}from"./state-D5D6QpTX.js";import{q as l}from"./log-CZ7ploQm.js";import{qt as u}from"./prompt-BNNE5tsG.js";import{randomUUID as d}from"crypto";function f(e){return e.flatMap(e=>{if(!e)return[];switch(e.type){case`assistant`:return[{type:`assistant`,message:e.message,uuid:e.uuid,requestId:void 0,timestamp:new Date().toISOString()}];case`user`:return[{type:`user`,message:e.message,uuid:e.uuid??d(),timestamp:e.timestamp??new Date().toISOString(),isMeta:e.isSynthetic}];default:return[]}})}function p(e){let t=e.preservedSegment;return{trigger:e.trigger,pre_tokens:e.preTokens,...t&&{preserved_segment:{head_uuid:t.headUuid,anchor_uuid:t.anchorUuid,tail_uuid:t.tailUuid}}}}function m(e){let t=e,n=t.preserved_segment;return{trigger:t.trigger,preTokens:t.pre_tokens,...n&&{preservedSegment:{headUuid:n.head_uuid,anchorUuid:n.anchor_uuid,tailUuid:n.tail_uuid}}}}function h(e){return e.flatMap(e=>{if(!e)return[];switch(e.type){case`assistant`:return[{type:`assistant`,message:v(e),session_id:c(),parent_tool_use_id:null,uuid:e.uuid,error:e?.error}];case`user`:return[{type:`user`,message:e.message,session_id:c(),parent_tool_use_id:null,uuid:e.uuid,timestamp:e.timestamp,isSynthetic:e.isMeta||e.isVisibleInTranscriptOnly,...e.toolUseResult===void 0?{}:{tool_use_result:e.toolUseResult}}];case`system`:return e.subtype===`compact_boundary`&&e.compactMetadata?[{type:`system`,subtype:`compact_boundary`,session_id:c(),uuid:e.uuid,compact_metadata:p(e.compactMetadata)}]:e.subtype===`local_command`&&(e.content.includes(`<local-command-stdout>`)||e.content.includes(`<local-command-stderr>`))?[g(e.content,e.uuid)]:[];default:return[]}})}function g(e,t){let r=n({content:o(e).replace(/<local-command-stdout>([\s\S]*?)<\/local-command-stdout>/,`$1`).replace(/<local-command-stderr>([\s\S]*?)<\/local-command-stderr>/,`$1`).trim()});return{type:`assistant`,content:r.message?.content,message:r.message,parent_tool_use_id:null,session_id:c(),uuid:t}}function _(e){if(e)return{type:`rate_limit`,status:e.status,...e.resetsAt!==void 0&&{resetsAt:e.resetsAt},...e.rateLimitType!==void 0&&{rateLimitType:e.rateLimitType},...e.utilization!==void 0&&{utilization:e.utilization},...e.overageStatus!==void 0&&{overageStatus:e.overageStatus},...e.overageResetsAt!==void 0&&{overageResetsAt:e.overageResetsAt},...e.overageDisabledReason!==void 0&&{overageDisabledReason:e.overageDisabledReason},...e.isUsingOverage!==void 0&&{isUsingOverage:e.isUsingOverage},...e.surpassedThreshold!==void 0&&{surpassedThreshold:e.surpassedThreshold}}}function v(e){let n=e.message.content;if(!Array.isArray(n))return e.message;let r=n.map(e=>{if(e.type!==`tool_use`)return e;if(e.name===`ExitPlanMode`){let n=t();if(n)return{...e,input:{...e.input,plan:n}}}return e});return{...e.message,content:r}}var y=e((()=>{s(),l(),u(),a(),r(),i()}));export{p as a,f as i,y as n,h as o,g as r,_ as s,m as t};
@@ -1 +0,0 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./figures-5ThXQEtq.js";import{Dh as i,Du as a,Eh as o,Eu as s,Fb as c,Hb as l,Th as u,Wb as d,lu as f,mb as p,np as m,pb as h,qb as g,rp as _,su as v,vb as y,yb as b,zS as x}from"./loadAgentsDir-C96o6gCj.js";import{D as S,Gt as ee,H as C,I as w,Lt as T,P as E,T as D,Wt as O,ai as k,j as A,t as j,y as M}from"./src-DL3w8VPk.js";import{t as N}from"./jsx-runtime-Bb4Xn-E0.js";import{a as te,i as ne}from"./debug-D58GQBDG.js";import{l as re,n as ie,o as P}from"./stringUtils-D7oJIyY2.js";import{C as ae,S as oe}from"./sessionState-8jutEorw.js";import{i as se,n as ce,r as le}from"./MCPConnectionManager-CoId-C__.js";import{n as ue,t as de}from"./McpParsingWarnings-6ENzOklf.js";import{a as fe,c as F,i as I,n as L,o as R,r as pe,s as me,t as he}from"./MCPToolListView-BQkQ-hyF.js";function ge({agentServer:e,onCancel:t,onComplete:n}){let[i]=C(),[o,s]=(0,z.useState)(!1),[c,l]=(0,z.useState)(null),[u,d]=(0,z.useState)(null),f=(0,z.useRef)(null);(0,z.useEffect)(()=>()=>f.current?.abort(),[]),O(`confirm:no`,(0,z.useCallback)(()=>{o&&(f.current?.abort(),f.current=null,s(!1),d(null))},[o]),{context:`Confirmation`,isActive:o});let p=(0,z.useCallback)(async()=>{if(!e.needsAuth||!e.url)return;s(!0),l(null);let t=new AbortController;f.current=t;try{let r={type:e.transport,url:e.url};await b(e.name,r,d,t.signal),n?.(`Authentication successful for ${e.name}. The server will connect when the agent runs.`)}catch(e){e instanceof Error&&!(e instanceof h)&&l(e.message)}finally{s(!1),f.current=null}},[e,n]),g=ie(String(e.name));if(o)return(0,B.jsxs)(w,{flexDirection:`column`,gap:1,padding:1,children:[(0,B.jsxs)(E,{color:`claude`,children:[`Authenticating with `,e.name,`…`]}),(0,B.jsxs)(w,{children:[(0,B.jsx)(v,{}),(0,B.jsx)(E,{children:` A browser window will open for authentication`})]}),u&&(0,B.jsxs)(w,{flexDirection:`column`,children:[(0,B.jsx)(E,{dimColor:!0,children:`If your browser doesn't open automatically, copy this URL manually:`}),(0,B.jsx)(T,{url:u})]}),(0,B.jsx)(w,{marginLeft:3,children:(0,B.jsxs)(E,{dimColor:!0,children:[`Return here after authenticating in your browser.`,` `,(0,B.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]})})]});let _=[];return e.needsAuth&&_.push({label:e.isAuthenticated?`Re-authenticate`:`Authenticate`,value:`auth`}),_.push({label:`Back`,value:`back`}),(0,B.jsxs)(M,{title:`${g} MCP Server`,subtitle:`agent-only`,onCancel:t,inputGuide:e=>e.pending?(0,B.jsxs)(E,{children:[`Press `,e.keyName,` again to exit`]}):(0,B.jsxs)(D,{children:[(0,B.jsx)(S,{shortcut:`↑↓`,action:`navigate`}),(0,B.jsx)(S,{shortcut:`Enter`,action:`confirm`}),(0,B.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]}),children:[(0,B.jsxs)(w,{flexDirection:`column`,gap:0,children:[(0,B.jsxs)(w,{children:[(0,B.jsx)(E,{bold:!0,children:`Type: `}),(0,B.jsx)(E,{dimColor:!0,children:e.transport})]}),e.url&&(0,B.jsxs)(w,{children:[(0,B.jsx)(E,{bold:!0,children:`URL: `}),(0,B.jsx)(E,{dimColor:!0,children:e.url})]}),e.command&&(0,B.jsxs)(w,{children:[(0,B.jsx)(E,{bold:!0,children:`Command: `}),(0,B.jsx)(E,{dimColor:!0,children:e.command})]}),(0,B.jsxs)(w,{children:[(0,B.jsx)(E,{bold:!0,children:`Used by: `}),(0,B.jsx)(E,{dimColor:!0,children:e.sourceAgents.join(`, `)})]}),(0,B.jsxs)(w,{marginTop:1,children:[(0,B.jsx)(E,{bold:!0,children:`Status: `}),(0,B.jsxs)(E,{children:[A(`inactive`,i)(r.radioOff),` not connected (agent-only)`]})]}),e.needsAuth&&(0,B.jsxs)(w,{children:[(0,B.jsx)(E,{bold:!0,children:`Auth: `}),e.isAuthenticated?(0,B.jsxs)(E,{children:[A(`success`,i)(r.tick),` authenticated`]}):(0,B.jsxs)(E,{children:[A(`warning`,i)(r.triangleUpOutline),` may need authentication`]})]})]}),(0,B.jsx)(w,{children:(0,B.jsx)(E,{dimColor:!0,children:`This server connects only when running the agent.`})}),c&&(0,B.jsx)(w,{children:(0,B.jsxs)(E,{color:`error`,children:[`Error: `,c]})}),(0,B.jsx)(w,{children:(0,B.jsx)(a,{options:_,onChange:async e=>{switch(e){case`auth`:await p();break;case`back`:t();break}},onCancel:t})})]})}var z,B,V=e((()=>{n(),z=t(k(),1),j(),x(),y(),P(),_(),s(),f(),B=N()}));function H(e){switch(e){case`project`:return{label:`Project MCPs`,path:c(e)};case`user`:return{label:`User MCPs`,path:c(e)};case`local`:return{label:`Local MCPs`,path:c(e)};case`enterprise`:return{label:`Enterprise MCPs`};case`dynamic`:return{label:`Built-in MCPs`,path:`always available`};default:return{label:e}}}function _e(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 ve({servers:e,agentServers:t=[],onSelectServer:n,onSelectAgentServer:i,onComplete:a}){let[o]=C(),[s,c]=(0,U.useState)(0),l=U.useMemo(()=>_e(e.filter(e=>e.client.config.type!==`claudeai-proxy`)),[e]),u=U.useMemo(()=>e.filter(e=>e.client.config.type===`claudeai-proxy`).sort((e,t)=>e.name.localeCompare(t.name)),[e]),d=U.useMemo(()=>(l.get(`dynamic`)??[]).sort((e,t)=>e.name.localeCompare(t.name)),[l]),f=H(`dynamic`),p=U.useMemo(()=>{let e=[];for(let t of G){let n=l.get(t)??[];for(let t of n)e.push({type:`server`,server:t})}for(let t of u)e.push({type:`server`,server:t});for(let n of t)e.push({type:`agent-server`,agentServer:n});for(let t of d)e.push({type:`server`,server:t});return e},[l,u,t,d]),h=(0,U.useCallback)(()=>{a(`MCP dialog dismissed`,{display:`system`})},[a]);ee({"confirm:previous":()=>c(e=>e===0?p.length-1:e-1),"confirm:next":()=>c(e=>e===p.length-1?0:e+1),"confirm:yes":(0,U.useCallback)(()=>{let e=p[s];e&&(e.type===`server`?n(e.server):e.type===`agent-server`&&i&&i(e.agentServer))},[p,s,n,i]),"confirm:no":h},{context:`Confirmation`});let g=e=>p.findIndex(t=>t.type===`server`&&t.server===e),_=e=>p.findIndex(t=>t.type===`agent-server`&&t.agentServer===e),v=te(),y=e.some(e=>e.client.type===`failed`);if(e.length===0&&t.length===0)return null;let b=e=>{let t=g(e),n=s===t,i=``,a=``;if(e.client.type===`disabled`)i=A(`inactive`,o)(r.radioOff),a=`disabled`;else if(e.client.type===`connected`)i=A(`success`,o)(r.tick),a=`connected`;else if(e.client.type===`pending`){i=A(`inactive`,o)(r.radioOff);let{reconnectAttempt:t,maxReconnectAttempts:n}=e.client;a=t&&n?`reconnecting (${t}/${n})…`:`connecting…`}else e.client.type===`needs-auth`?(i=A(`warning`,o)(r.triangleUpOutline),a=`needs authentication`):(i=A(`error`,o)(r.cross),a=`failed`);return(0,W.jsxs)(w,{children:[(0,W.jsx)(E,{color:n?`suggestion`:void 0,children:n?`${r.pointer} `:` `}),(0,W.jsx)(E,{color:n?`suggestion`:void 0,children:e.name}),(0,W.jsxs)(E,{dimColor:!n,children:[` · `,i,` `]}),(0,W.jsx)(E,{dimColor:!n,children:a})]},`${e.name}-${t}`)},x=e=>{let t=_(e),n=s===t,i=e.needsAuth?A(`warning`,o)(r.triangleUpOutline):A(`inactive`,o)(r.radioOff),a=e.needsAuth?`may need auth`:`agent-only`;return(0,W.jsxs)(w,{children:[(0,W.jsx)(E,{color:n?`suggestion`:void 0,children:n?`${r.pointer} `:` `}),(0,W.jsx)(E,{color:n?`suggestion`:void 0,children:e.name}),(0,W.jsxs)(E,{dimColor:!n,children:[` · `,i,` `]}),(0,W.jsx)(E,{dimColor:!n,children:a})]},`agent-${e.name}-${t}`)},O=e.length+t.length;return(0,W.jsxs)(w,{flexDirection:`column`,children:[(0,W.jsx)(de,{}),(0,W.jsx)(M,{title:`Manage MCP servers`,subtitle:`${O} ${re(O,`server`)}`,onCancel:h,hideInputGuide:!0,children:(0,W.jsxs)(w,{flexDirection:`column`,children:[G.map(e=>{let t=l.get(e);if(!t||t.length===0)return null;let n=H(e);return(0,W.jsxs)(w,{flexDirection:`column`,marginBottom:1,children:[(0,W.jsxs)(w,{paddingLeft:2,children:[(0,W.jsx)(E,{bold:!0,children:n.label}),n.path&&(0,W.jsxs)(E,{dimColor:!0,children:[` (`,n.path,`)`]})]}),t.map(e=>b(e))]},e)}),u.length>0&&(0,W.jsxs)(w,{flexDirection:`column`,marginBottom:1,children:[(0,W.jsx)(w,{paddingLeft:2,children:(0,W.jsx)(E,{bold:!0,children:`claude.ai`})}),u.map(e=>b(e))]}),t.length>0&&(0,W.jsxs)(w,{flexDirection:`column`,marginBottom:1,children:[(0,W.jsx)(w,{paddingLeft:2,children:(0,W.jsx)(E,{bold:!0,children:`Agent MCPs`})}),[...new Set(t.flatMap(e=>e.sourceAgents))].map(e=>(0,W.jsxs)(w,{flexDirection:`column`,marginTop:1,children:[(0,W.jsx)(w,{paddingLeft:2,children:(0,W.jsxs)(E,{dimColor:!0,children:[`@`,e]})}),t.filter(t=>t.sourceAgents.includes(e)).map(e=>x(e))]},e))]}),d.length>0&&(0,W.jsxs)(w,{flexDirection:`column`,marginBottom:1,children:[(0,W.jsxs)(w,{paddingLeft:2,children:[(0,W.jsx)(E,{bold:!0,children:f.label}),f.path&&(0,W.jsxs)(E,{dimColor:!0,children:[` (`,f.path,`)`]})]}),d.map(e=>b(e))]}),(0,W.jsxs)(w,{flexDirection:`column`,children:[y&&(0,W.jsx)(E,{dimColor:!0,children:v?`※ Error logs shown inline with --debug`:`※ Run claude --debug to see error logs`}),(0,W.jsxs)(E,{dimColor:!0,children:[(0,W.jsx)(T,{url:`https://code.workmate.com/docs/en/mcp`,children:`https://code.workmate.com/docs/en/mcp`}),` for help`]})]})]})}),(0,W.jsx)(w,{paddingX:1,children:(0,W.jsx)(E,{dimColor:!0,italic:!0,children:(0,W.jsxs)(D,{children:[(0,W.jsx)(S,{shortcut:`↑↓`,action:`navigate`}),(0,W.jsx)(S,{shortcut:`Enter`,action:`confirm`}),(0,W.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})})]})}var U,W,G,K=e((()=>{n(),U=t(k(),1),j(),x(),g(),ne(),P(),_(),ue(),W=N(),G=[`project`,`local`,`user`,`enterprise`]}));function ye({serverName:e,onComplete:t}){let[n]=C(),a=i(),o=le(),[s,c]=(0,q.useState)(!0),[l,u]=(0,q.useState)(null);return(0,q.useEffect)(()=>{async function n(){try{if(!a.getState().mcp.clients.find(t=>t.name===e)){u(`MCP server "${e}" not found`),c(!1),t(`MCP server "${e}" not found`);return}switch((await o(e)).client.type){case`connected`:c(!1),t(`Successfully reconnected to ${e}`);break;case`needs-auth`:u(`${e} requires authentication`),c(!1),t(`${e} requires authentication. Use /mcp to authenticate.`);break;case`pending`:case`failed`:case`disabled`:u(`Failed to reconnect to ${e}`),c(!1),t(`Failed to reconnect to ${e}`);break}}catch(e){let n=e instanceof Error?e.message:String(e);u(n),c(!1),t(`Error: ${n}`)}}n()},[e,o,a,t]),s?(0,J.jsxs)(w,{flexDirection:`column`,gap:1,padding:1,children:[(0,J.jsxs)(E,{color:`text`,children:[`Reconnecting to `,(0,J.jsx)(E,{bold:!0,children:e})]}),(0,J.jsxs)(w,{children:[(0,J.jsx)(v,{}),(0,J.jsx)(E,{children:` Establishing connection to MCP server`})]})]}):l?(0,J.jsxs)(w,{flexDirection:`column`,gap:1,padding:1,children:[(0,J.jsxs)(w,{children:[(0,J.jsxs)(E,{children:[A(`error`,n)(r.cross),` `]}),(0,J.jsxs)(E,{color:`error`,children:[`Failed to reconnect to `,e]})]}),(0,J.jsxs)(E,{dimColor:!0,children:[`Error: `,l]})]}):null}var q,J,Y=e((()=>{n(),q=t(k(),1),j(),ce(),u(),f(),J=N()}));function be({onComplete:e}){let t=o(e=>e.mcp),n=o(e=>e.agentDefinitions),r=t.clients,[i,a]=X.useState({type:`list`}),[s,c]=X.useState([]),u=(0,X.useMemo)(()=>l(n.allAgents),[n.allAgents]),f=X.useMemo(()=>r.filter(e=>e.name!==`ide`).sort((e,t)=>e.name.localeCompare(t.name)),[r]);switch(X.useEffect(()=>{let e=!1;async function n(){let n=await Promise.all(f.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;if(r||i){let n=await new p(e.name,e.config).tokens(),r=oe()!==null&&e.type===`connected`,i=e.type===`connected`&&d(t.tools,e.name).length>0;o=!!n||r||i}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||c(n)}return n(),()=>{e=!0}},[f,t.tools]),(0,X.useEffect)(()=>{s.length===0&&f.length>0||s.length===0&&u.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.")},[s.length,f.length,u.length,e]),i.type){case`list`:return(0,Z.jsx)(ve,{servers:s,agentServers:u,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=d(t.tools,i.server.name),r=i.server.transport===`claudeai-proxy`?`claude.ai`:`Work Mate`;return i.server.transport===`stdio`?(0,Z.jsx)(fe,{server:i.server,serverToolsCount:n.length,onViewTools:()=>a({type:`server-tools`,server:i.server}),onCancel:()=>a({type:`list`,defaultTab:r}),onComplete:e}):(0,Z.jsx)(me,{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,Z.jsx)(he,{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=d(t.tools,i.server.name)[i.toolIndex];return e?(0,Z.jsx)(pe,{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,Z.jsx)(ge,{agentServer:i.agentServer,onCancel:()=>a({type:`list`,defaultTab:`Agents`}),onComplete:e})}}var X,Z,xe=e((()=>{X=t(k(),1),y(),g(),u(),ae(),V(),K(),F(),R(),I(),L(),Z=N()})),Se=e((()=>{V(),K(),Y(),F(),xe(),R(),I(),L()}));function Ce({action:e,target:t,onComplete:n}){let r=o(e=>e.mcp.clients),i=se(),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 we(e,t,n){if(n){let t=n.trim().split(/\s+/);if(t[0]===`no-redirect`)return(0,$.jsx)(be,{onComplete:e});if(t[0]===`reconnect`&&t[1])return(0,$.jsx)(ye,{serverName:t.slice(1).join(` `),onComplete:e});if(t[0]===`enable`||t[0]===`disable`)return(0,$.jsx)(Ce,{action:t[0],target:t.length>1?t.slice(1).join(` `):`all`,onComplete:e})}return(0,$.jsx)(be,{onComplete:e})}var Q,$;e((()=>{Q=t(k(),1),Se(),Y(),ce(),u(),$=N()}))();export{we as call};
@@ -1,2 +0,0 @@
1
- import{B as e,Bx as t,Ds as n,Dy as r,Es as i,Gx as a,Hx as o,Jx as s,Kx as c,Lx as l,Oy as ee,Qx as u,Rx as d,Sc as f,Tw as p,Ux as m,V as h,Vx as g,Wx as _,Xx as v,Yx as te,Zx as ne,_S as y,aC as b,aS as x,bS as S,cS as C,eS as w,ea as T,gS as E,gl as D,h_ as O,hl as k,iC as A,iS as j,lS as M,lb as N,mS as P,m_ as F,nS as I,oS as L,pS as R,qx as re,rS as z,sS as B,uS as V,ub as H,vS as U,xc as W,yS as G,zx as K}from"./loadAgentsDir-C96o6gCj.js";import{C as q,x as J}from"./debug-D58GQBDG.js";import{o as Y,s as X}from"./log-CZ7ploQm.js";import{_ as ie,u as ae}from"./model-BaMclMXn.js";import{_n as Z,gn as oe,vn as se}from"./prompt-BNNE5tsG.js";import Q from"node:process";U(),c(),_(),E();var ce=class{constructor(e){this._server=e}requestStream(e,t,n){return this._server.requestStream(e,t,n)}createMessageStream(e,t){let n=this._server.getClientCapabilities();if((e.tools||e.toolChoice)&&!n?.sampling?.tools)throw Error(`Client does not support sampling tools capability.`);if(e.messages.length>0){let t=e.messages[e.messages.length-1],n=Array.isArray(t.content)?t.content:[t.content],r=n.some(e=>e.type===`tool_result`),i=e.messages.length>1?e.messages[e.messages.length-2]:void 0,a=i?Array.isArray(i.content)?i.content:[i.content]:[],o=a.some(e=>e.type===`tool_use`);if(r){if(n.some(e=>e.type!==`tool_result`))throw Error(`The last message must contain only tool_result content if any is present`);if(!o)throw Error(`tool_result blocks are not matching any tool_use from the previous message`)}if(o){let e=new Set(a.filter(e=>e.type===`tool_use`).map(e=>e.id)),t=new Set(n.filter(e=>e.type===`tool_result`).map(e=>e.toolUseId));if(e.size!==t.size||![...e].every(e=>t.has(e)))throw Error(`ids of tool_result blocks and tool_use blocks from previous message do not match`)}}return this.requestStream({method:`sampling/createMessage`,params:e},v,t)}elicitInputStream(e,t){let n=this._server.getClientCapabilities(),r=e.mode??`form`;switch(r){case`url`:if(!n?.elicitation?.url)throw Error(`Client does not support url elicitation.`);break;case`form`:if(!n?.elicitation?.form)throw Error(`Client does not support form elicitation.`);break}let i=r===`form`&&e.mode===void 0?{...e,mode:`form`}:e;return this.requestStream({method:`elicitation/create`,params:i},w,t)}async getTask(e,t){return this._server.getTask({taskId:e},t)}async getTaskResult(e,t,n){return this._server.getTaskResult({taskId:e},t,n)}async listTasks(e,t){return this._server.listTasks(e?{cursor:e}:void 0,t)}async cancelTask(e,t){return this._server.cancelTask({taskId:e},t)}};E(),o();var le=class extends a{constructor(e,t){super(t),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(M.options.map((e,t)=>[e,t])),this.isMessageIgnored=(e,t)=>{let n=this._loggingLevels.get(t);return n?this.LOG_LEVEL_SEVERITY.get(e)<this.LOG_LEVEL_SEVERITY.get(n):!1},this._capabilities=t?.capabilities??{},this._instructions=t?.instructions,this._jsonSchemaValidator=t?.jsonSchemaValidator??new m,this.setRequestHandler(j,e=>this._oninitialize(e)),this.setNotificationHandler(x,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(P,async(e,t)=>{let n=t.sessionId||t.requestInfo?.headers[`mcp-session-id`]||void 0,{level:r}=e.params,i=M.safeParse(r);return i.success&&this._loggingLevels.set(n,i.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new ce(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw Error(`Cannot register capabilities after connecting to transport`);this._capabilities=re(this._capabilities,e)}setRequestHandler(e,t){let n=y(e)?.method;if(!n)throw Error(`Schema is missing a method literal`);let r;if(G(n)){let e=n;r=e._zod?.def?.value??e.value}else{let e=n;r=e._def?.value??e.value}if(typeof r!=`string`)throw Error(`Schema method literal must be a string`);return r===`tools/call`?super.setRequestHandler(e,async(e,n)=>{let r=S(s,e);if(!r.success){let e=r.error instanceof Error?r.error.message:String(r.error);throw new V(z.InvalidParams,`Invalid tools/call request: ${e}`)}let{params:i}=r.data,a=await Promise.resolve(t(e,n));if(i.task){let e=S(u,a);if(!e.success){let t=e.error instanceof Error?e.error.message:String(e.error);throw new V(z.InvalidParams,`Invalid task creation result: ${t}`)}return e.data}let o=S(te,a);if(!o.success){let e=o.error instanceof Error?o.error.message:String(o.error);throw new V(z.InvalidParams,`Invalid tools/call result: ${e}`)}return o.data}):super.setRequestHandler(e,t)}assertCapabilityForMethod(e){switch(e){case`sampling/createMessage`:if(!this._clientCapabilities?.sampling)throw Error(`Client does not support sampling (required for ${e})`);break;case`elicitation/create`:if(!this._clientCapabilities?.elicitation)throw Error(`Client does not support elicitation (required for ${e})`);break;case`roots/list`:if(!this._clientCapabilities?.roots)throw Error(`Client does not support listing roots (required for ${e})`);break;case`ping`:break}}assertNotificationCapability(e){switch(e){case`notifications/message`:if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${e})`);break;case`notifications/resources/updated`:case`notifications/resources/list_changed`:if(!this._capabilities.resources)throw Error(`Server does not support notifying about resources (required for ${e})`);break;case`notifications/tools/list_changed`:if(!this._capabilities.tools)throw Error(`Server does not support notifying of tool list changes (required for ${e})`);break;case`notifications/prompts/list_changed`:if(!this._capabilities.prompts)throw Error(`Server does not support notifying of prompt list changes (required for ${e})`);break;case`notifications/elicitation/complete`:if(!this._clientCapabilities?.elicitation?.url)throw Error(`Client does not support URL elicitation (required for ${e})`);break;case`notifications/cancelled`:break;case`notifications/progress`:break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case`completion/complete`:if(!this._capabilities.completions)throw Error(`Server does not support completions (required for ${e})`);break;case`logging/setLevel`:if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${e})`);break;case`prompts/get`:case`prompts/list`:if(!this._capabilities.prompts)throw Error(`Server does not support prompts (required for ${e})`);break;case`resources/list`:case`resources/templates/list`:case`resources/read`:if(!this._capabilities.resources)throw Error(`Server does not support resources (required for ${e})`);break;case`tools/call`:case`tools/list`:if(!this._capabilities.tools)throw Error(`Server does not support tools (required for ${e})`);break;case`tasks/get`:case`tasks/list`:case`tasks/result`:case`tasks/cancel`:if(!this._capabilities.tasks)throw Error(`Server does not support tasks capability (required for ${e})`);break;case`ping`:case`initialize`:break}}assertTaskCapability(e){t(this._clientCapabilities?.tasks?.requests,e,`Client`)}assertTaskHandlerCapability(e){this._capabilities&&g(this._capabilities.tasks?.requests,e,`Server`)}async _oninitialize(e){let t=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:R.includes(t)?t:L,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:`ping`},I)}async createMessage(e,t){if((e.tools||e.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw Error(`Client does not support sampling tools capability.`);if(e.messages.length>0){let t=e.messages[e.messages.length-1],n=Array.isArray(t.content)?t.content:[t.content],r=n.some(e=>e.type===`tool_result`),i=e.messages.length>1?e.messages[e.messages.length-2]:void 0,a=i?Array.isArray(i.content)?i.content:[i.content]:[],o=a.some(e=>e.type===`tool_use`);if(r){if(n.some(e=>e.type!==`tool_result`))throw Error(`The last message must contain only tool_result content if any is present`);if(!o)throw Error(`tool_result blocks are not matching any tool_use from the previous message`)}if(o){let e=new Set(a.filter(e=>e.type===`tool_use`).map(e=>e.id)),t=new Set(n.filter(e=>e.type===`tool_result`).map(e=>e.toolUseId));if(e.size!==t.size||![...e].every(e=>t.has(e)))throw Error(`ids of tool_result blocks and tool_use blocks from previous message do not match`)}}return e.tools?this.request({method:`sampling/createMessage`,params:e},ne,t):this.request({method:`sampling/createMessage`,params:e},v,t)}async elicitInput(e,t){switch(e.mode??`form`){case`url`:{if(!this._clientCapabilities?.elicitation?.url)throw Error(`Client does not support url elicitation.`);let n=e;return this.request({method:`elicitation/create`,params:n},w,t)}case`form`:{if(!this._clientCapabilities?.elicitation?.form)throw Error(`Client does not support form elicitation.`);let n=e.mode===`form`?e:{...e,mode:`form`},r=await this.request({method:`elicitation/create`,params:n},w,t);if(r.action===`accept`&&r.content&&n.requestedSchema)try{let e=this._jsonSchemaValidator.getValidator(n.requestedSchema)(r.content);if(!e.valid)throw new V(z.InvalidParams,`Elicitation response content does not match requested schema: ${e.errorMessage}`)}catch(e){throw e instanceof V?e:new V(z.InternalError,`Error validating elicitation response: ${e instanceof Error?e.message:String(e)}`)}return r}}}createElicitationCompletionNotifier(e,t){if(!this._clientCapabilities?.elicitation?.url)throw Error(`Client does not support URL elicitation (required for notifications/elicitation/complete)`);return()=>this.notification({method:`notifications/elicitation/complete`,params:{elicitationId:e}},t)}async listRoots(e,t){return this.request({method:`roots/list`,params:e},B,t)}async sendLoggingMessage(e,t){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,t))return this.notification({method:`notifications/message`,params:e})}async sendResourceUpdated(e){return this.notification({method:`notifications/resources/updated`,params:e})}async sendResourceListChanged(){return this.notification({method:`notifications/resources/list_changed`})}async sendToolListChanged(){return this.notification({method:`notifications/tools/list_changed`})}async sendPromptListChanged(){return this.notification({method:`notifications/prompts/list_changed`})}};d();var $=class{constructor(e=Q.stdin,t=Q.stdout){this._stdin=e,this._stdout=t,this._readBuffer=new l,this._started=!1,this._ondata=e=>{this._readBuffer.append(e),this.processReadBuffer()},this._onerror=e=>{this.onerror?.(e)}}async start(){if(this._started)throw Error(`StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.`);this._started=!0,this._stdin.on(`data`,this._ondata),this._stdin.on(`error`,this._onerror)}processReadBuffer(){for(;;)try{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e)}catch(e){this.onerror?.(e)}}async close(){this._stdin.off(`data`,this._ondata),this._stdin.off(`error`,this._onerror),this._stdin.listenerCount(`data`)===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(e){return new Promise(t=>{let n=K(e);this._stdout.write(n)?t():this._stdout.once(`drain`,t)})}};E(),n(),se(),f(),H(),ee(),Y(),T(),ie(),h(),A(),J(),D(),F();var ue=[];async function de(t,n,a){let o=r(100);b(t);let c=new le({name:`claude/tengu`,version:`0.0.21`},{capabilities:{tools:{}}});c.setRequestHandler(C,async()=>{let e=Z(),t=W(e);return{tools:await Promise.all(t.map(async n=>{let r;if(n.outputSchema){let e=O(n.outputSchema);typeof e==`object`&&e&&`type`in e&&e.type===`object`&&(r=e)}return{...n,description:await n.prompt({getToolPermissionContext:async()=>e,tools:t,agents:[]}),inputSchema:O(n.inputSchema),outputSchema:r}}))}}),c.setRequestHandler(s,async({params:{name:t,arguments:r}})=>{let s=W(Z()),c=oe(s,t);if(!c)throw Error(`Tool ${t} not found`);let l={abortController:N(),options:{commands:ue,tools:s,mainLoopModel:ae(),thinkingConfig:{type:`disabled`},mcpClients:[],mcpResources:{},isNonInteractiveSession:!0,debug:n,verbose:a,agentDefinitions:{activeAgents:[],allAgents:[]}},getAppState:()=>i(),setAppState:()=>{},messages:[],readFileState:o,setInProgressToolUseIDs:()=>{},setResponseLength:()=>{},updateFileHistoryState:()=>{},updateAttributionState:()=>{}};try{if(!c.isEnabled())throw Error(`Tool ${t} is not enabled`);let n=await c.validateInput?.(r??{},l);if(n&&!n.result)throw Error(`Tool ${t} input is invalid: ${`message`in n?n.message:String(n)}`);let i=await c.call(r??{},l,e,p({content:[]}));return{content:[{type:`text`,text:typeof i==`string`?i:q(i.data)}]}}catch(e){return X(e),{isError:!0,content:[{type:`text`,text:(e instanceof Error?k(e):[String(e)]).filter(Boolean).join(`
2
- `).trim()||`Error`}]}}});async function l(){let e=new $;await c.connect(e)}return await l()}export{de as startMCPServer};
@@ -1,6 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-DaDcL9Zw.js";import{$y as t,Au as n,Ed as r,Fb as i,Ib as a,Kb as o,Od as s,SE as c,Sb as l,Th as u,Xb as d,Yy as f,_b as p,bb as m,gb as ee,hb as te,iu as ne,ku as h,np as g,nx as _,ox as v,qb as re,rp as ie,ru as ae,rx as oe,tb as se,tx as y,ux as b,vb as x,wh as S,xE as C}from"./loadAgentsDir-C96o6gCj.js";import{D as w,H as T,I as E,P as D,T as O,ai as k,j as A,kn as j,t as M,y as N}from"./src-DL3w8VPk.js";import{t as P}from"./jsx-runtime-Bb4Xn-E0.js";import{R as F,V as I}from"./debug-D58GQBDG.js";import{c as L,h as R,o as z,v as B}from"./config-DUTgj3js.js";import{n as ce,o as V}from"./process-gEbdy6uY.js";import{i as H,o as U}from"./platform-DMQxcm4K.js";import{s as W,u as G}from"./types-APu4OCXJ.js";import{n as le,r as K}from"./analytics-DJobLaWP.js";import{l as q,o as ue}from"./stringUtils-D7oJIyY2.js";import{n as J,t as Y}from"./exit-s9XGerrH.js";import{stat as de}from"fs/promises";import{cwd as fe}from"process";C();var X=e(k(),1);s(),ce(),M(),v(),ue(),ie(),n();var Z=P();function pe({servers:e,scope:t,onDone:n}){let i=Object.keys(e),[a,o]=(0,X.useState)({});(0,X.useEffect)(()=>{y().then(({servers:e})=>o(e))},[]);let s=i.filter(e=>a[e]!==void 0);async function c(n){let r=0;for(let i of n){let n=e[i];if(n){let e=i;if(a[e]!==void 0){let t=1;for(;a[`${i}_${t}`]!==void 0;)t++;e=`${i}_${t}`}await d(e,n,t),r++}}u(r)}let[l]=T(),u=(0,X.useCallback)(e=>{V(e>0?`\n${A(`success`,l)(`Successfully imported ${e} MCP ${q(e,`server`)} to ${t} config.`)}\n`:`
2
- No servers were imported.`),n(),r()},[l,t,n]),f=(0,X.useCallback)(()=>{u(0)},[u]);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(N,{title:`Import MCP Servers from Work Mate Desktop`,subtitle:`Found ${i.length} MCP ${q(i.length,`server`)} in Work Mate Desktop.`,color:`success`,onCancel:f,hideInputGuide:!0,children:[s.length>0&&(0,Z.jsx)(D,{color:`warning`,children:`Note: Some servers already exist with the same name. If selected, they will be imported with a numbered suffix.`}),(0,Z.jsx)(D,{children:`Please select the servers you want to import:`}),(0,Z.jsx)(h,{options:i.map(e=>({label:`${e}${s.includes(e)?` (already exists)`:``}`,value:e})),defaultValue:i.filter(e=>!s.includes(e)),onSubmit:c,onCancel:f,hideIndexes:!0})]}),(0,Z.jsx)(E,{paddingX:1,children:(0,Z.jsx)(D,{dimColor:!0,italic:!0,children:(0,Z.jsxs)(O,{children:[(0,Z.jsx)(w,{shortcut:`Space`,action:`select`}),(0,Z.jsx)(w,{shortcut:`Enter`,action:`confirm`}),(0,Z.jsx)(g,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})})]})}M(),ne(),le(),x(),se(),v(),re(),u(),R(),F(),s(),W(),U();async function Q(e,t){try{let n=await f(e,t);return n.type===`connected`?`✓ Connected`:n.type===`needs-auth`?`! Needs authentication`:`✗ Failed to connect`}catch{return`✗ Connection error`}}async function me({debug:e,verbose:t}){let n=fe();K(`tengu_mcp_start`,{});try{await de(n)}catch(e){throw I(e)&&Y(`Error: Directory ${n} does not exist`),e}try{let{setup:r}=await import(`./setup-UiEO9i7F.js`);await r(n,`default`,!1,!1,void 0,!1);let{startMCPServer:i}=await import(`./mcp-BskLq9iP.js`);await i(n,e??!1,t??!1)}catch(e){Y(`Error: Failed to start MCP server: ${e}`)}}async function he(e,t){let n=_(e),r=()=>{n&&(n.type===`sse`||n.type===`http`)&&(ee(e,n),te(e,n))};try{if(t.scope){let n=a(t.scope);K(`tengu_mcp_delete`,{name:e,scope:n}),await b(e,n),r(),process.stdout.write(`Removed MCP server ${e} from ${n} config\n`),J(`File modified: ${i(n)}`)}let n=z(),s=L(),{servers:c}=oe(`project`),l=!!c[e],u=[];if(n.mcpServers?.[e]&&u.push(`local`),l&&u.push(`project`),s.mcpServers?.[e]&&u.push(`user`),u.length===0)Y(`No MCP server found with name: "${e}"`);else if(u.length===1){let t=u[0];K(`tengu_mcp_delete`,{name:e,scope:t}),await b(e,t),r(),process.stdout.write(`Removed MCP server "${e}" from ${t} config\n`),J(`File modified: ${i(t)}`)}else process.stderr.write(`MCP server "${e}" exists in multiple scopes:\n`),u.forEach(e=>{process.stderr.write(` - ${o(e)} (${i(e)})\n`)}),process.stderr.write(`
3
- To remove from a specific scope, use:
4
- `),u.forEach(t=>{process.stderr.write(` claude mcp remove "${e}" -s ${t}\n`)}),Y()}catch(e){Y(e.message)}}async function ge(){K(`tengu_mcp_list`,{});let{servers:e}=await y();if(Object.keys(e).length===0)console.log("No MCP servers configured. Use `claude mcp add` to add a server.");else{console.log(`Checking MCP server health...
5
- `);let n=await c(Object.entries(e),async([e,t])=>({name:e,server:t,status:await Q(e,t)}),{concurrency:t()});for(let{name:e,server:t,status:r}of n)if(t.type===`sse`)console.log(`${e}: ${t.url} (SSE) - ${r}`);else if(t.type===`http`)console.log(`${e}: ${t.url} (HTTP) - ${r}`);else if(t.type===`claudeai-proxy`)console.log(`${e}: ${t.url} - ${r}`);else if(!t.type||t.type===`stdio`){let n=t,i=Array.isArray(n.args)?n.args:[];console.log(`${e}: ${n.command} ${i.join(` `)} - ${r}`)}}await r(0)}async function $(e){K(`tengu_mcp_get`,{name:e});let t=_(e);t||Y(`No MCP server found with name: ${e}`),console.log(`${e}:`),console.log(` Scope: ${o(t.scope)}`);let n=await Q(e,t);if(console.log(` Status: ${n}`),t.type===`sse`){if(console.log(` Type: sse`),console.log(` URL: ${t.url}`),t.headers){console.log(` Headers:`);for(let[e,n]of Object.entries(t.headers))console.log(` ${e}: ${n}`)}if(t.oauth?.clientId||t.oauth?.callbackPort){let n=[];t.oauth.clientId&&(n.push(`client_id configured`),p(e,t)?.clientSecret&&n.push(`client_secret configured`)),t.oauth.callbackPort&&n.push(`callback_port ${t.oauth.callbackPort}`),console.log(` OAuth: ${n.join(`, `)}`)}}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}`)}if(t.oauth?.clientId||t.oauth?.callbackPort){let n=[];t.oauth.clientId&&(n.push(`client_id configured`),p(e,t)?.clientSecret&&n.push(`client_secret configured`)),t.oauth.callbackPort&&n.push(`callback_port ${t.oauth.callbackPort}`),console.log(` OAuth: ${n.join(`, `)}`)}}else if(t.type===`stdio`){console.log(` Type: stdio`),console.log(` Command: ${t.command}`);let e=Array.isArray(t.args)?t.args:[];if(console.log(` Args: ${e.join(` `)}`),t.env){console.log(` Environment:`);for(let[e,n]of Object.entries(t.env))console.log(` ${e}=${n}`)}}console.log(`\nTo remove this server, run: claude mcp remove "${e}" -s ${t.scope}`),await r(0)}async function _e(e,t,n){try{let r=a(n.scope),i=G(t),o=n.clientSecret&&i&&typeof i==`object`&&`type`in i&&(i.type===`sse`||i.type===`http`)&&`url`in i&&typeof i.url==`string`&&`oauth`in i&&i.oauth&&typeof i.oauth==`object`&&`clientId`in i.oauth?await m():void 0;await d(e,i,r);let s=i&&typeof i==`object`&&`type`in i?String(i.type||`stdio`):`stdio`;o&&i&&typeof i==`object`&&`type`in i&&(i.type===`sse`||i.type===`http`)&&`url`in i&&typeof i.url==`string`&&l(e,{type:i.type,url:i.url},o),K(`tengu_mcp_add`,{scope:r,source:`json`,type:s}),J(`Added ${s} MCP server ${e} to ${r} config`)}catch(e){Y(e.message)}}async function ve(e){try{let t=a(e.scope);K(`tengu_mcp_add`,{scope:t,platform:H(),source:`desktop`});let{readClaudeDesktopMcpServers:n}=await import(`./claudeDesktop-DPc_SaVn.js`),r=await n();Object.keys(r).length===0&&J(`No MCP servers found in Work Mate Desktop configuration or configuration file does not exist.`);let{unmount:i}=await j((0,Z.jsx)(S,{children:(0,Z.jsx)(ae,{children:(0,Z.jsx)(pe,{servers:r,scope:t,onDone:()=>{i()}})})}),{exitOnCtrlC:!0})}catch(e){Y(e.message)}}async function ye(){K(`tengu_mcp_reset_mcpjson_choices`,{}),B(e=>({...e,enabledMcpjsonServers:[],disabledMcpjsonServers:[],enableAllProjectMcpServers:!1})),J(`All project-scoped (.mcp.json) server approvals and rejections have been reset.
6
- You will be prompted for approval next time you start Work Mate.`)}export{ve as mcpAddFromDesktopHandler,_e as mcpAddJsonHandler,$ as mcpGetHandler,ge as mcpListHandler,he as mcpRemoveHandler,ye as mcpResetChoicesHandler,me as mcpServeHandler};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./defineProperty-C-QyHrDq.js";import{a as r,c as i,i as a,n as o,o as s,r as c,s as l,t as u}from"./classPrivateFieldSet2-D4U5K-I3.js";import{n as d,t as f}from"./classPrivateMethodInitSpec-BXQD0Vh4.js";import{C as p,x as m}from"./debug-D58GQBDG.js";import{o as h,s as g}from"./log-CZ7ploQm.js";import{channel as ee,tracingChannel as _}from"node:diagnostics_channel";function te(){let e=new Ne(c(T,this)),t=new Ne(c(T,this));u(W,this,e),u(U,this,t);let n=this.ttlAutopurge?Array.from({length:c(T,this)}):void 0;u(G,this,n),u(ye,this,(n,r,a=c(A,this).now())=>{t[n]=r===0?0:a,e[n]=r,i(n,r)}),u(ve,this,n=>{t[n]=e[n]===0?0:c(A,this).now(),i(n,e[n])});let i=this.ttlAutopurge?(e,t)=>{if(n?.[e]&&(clearTimeout(n[e]),n[e]=void 0),t&&t!==0&&n){let a=setTimeout(()=>{c(Z,this).call(this,e)?(r(Y,this,w).call(this,c(P,this)[e],`expire`),n[e]=void 0):i(e,s(e))},t+1);a.unref&&a.unref(),n[e]=a}}:()=>{};u(X,this,(n,r)=>{if(e[r]){let i=e[r],s=t[r];if(!i||!s)return;n.ttl=i,n.start=s,n.now=a||o(),n.remainingTTL=i-(n.now-s)}});let a=0,o=()=>{let e=c(A,this).now();if(this.ttlResolution>0){a=e;let t=setTimeout(()=>a=0,this.ttlResolution);t.unref&&t.unref()}return e};this.getRemainingTTL=e=>{let t=c(N,this).get(e);return t===void 0?0:s(t)};let s=n=>{let r=e[n],i=t[n];return!r||!i?1/0:r-((a||o())-i)};u(Z,this,n=>{let r=t[n],i=e[n];return!!i&&!!r&&(a||o())-r>i})}function ne(){let e=new Ne(c(T,this));u(M,this,0),u(H,this,e),u(be,this,t=>{u(M,this,c(M,this)-e[t]),e[t]=0}),u(Se,this,(e,t,n,i)=>{if(!$(n)){if(r(Y,this,S).call(this,t))return this.backgroundFetchSize;if(i){if(typeof i!=`function`)throw TypeError(`sizeCalculation must be a function`);if(n=i(t,e),!$(n))throw TypeError(`sizeCalculation return invalid (expect positive integer)`)}else throw TypeError(`invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.`)}return n}),u(xe,this,(t,n,i)=>{if(e[t]=n,c(E,this)){let n=c(E,this)-e[t];for(;c(M,this)>n;)r(Y,this,x).call(this,!0)}u(M,this,c(M,this)+e[t]),i&&(i.entrySize=n,i.totalCalculatedSize=c(M,this))})}function*v({allowStale:e=this.allowStale}={}){if(c(j,this))for(let t=c(z,this);r(Y,this,re).call(this,t)&&((e||!c(Z,this).call(this,t))&&(yield t),t!==c(R,this));)t=c(L,this)[t]}function*y({allowStale:e=this.allowStale}={}){if(c(j,this))for(let t=c(R,this);r(Y,this,re).call(this,t)&&((e||!c(Z,this).call(this,t))&&(yield t),t!==c(z,this));)t=c(I,this)[t]}function re(e){return e!==void 0&&c(N,this).get(c(P,this)[e])===e}function b(e,t,n,i){var a;let{ttl:o=this.ttl,start:s,noDisposeOnSet:l=this.noDisposeOnSet,sizeCalculation:d=this.sizeCalculation,status:f}=n,p=r(Y,this,S).call(this,t);if(t===void 0)return f&&(f.set=`deleted`),this.delete(e),this;let{noUpdateTTL:m=this.noUpdateTTL}=n;f&&!p&&(f.value=t);let h=c(Se,this).call(this,e,t,n.size||0,d,f);if(this.maxEntrySize&&h>this.maxEntrySize)return r(Y,this,w).call(this,e,`set`),f&&(f.set=`miss`,f.maxEntrySizeExceeded=!0),this;let g=c(j,this)===0?void 0:c(N,this).get(e);if(g===void 0)g=c(j,this)===0?c(z,this):c(B,this).length===0?c(j,this)===c(T,this)?r(Y,this,x).call(this,!1):c(j,this):c(B,this).pop(),c(P,this)[g]=e,c(F,this)[g]=t,c(N,this).set(e,g),c(I,this)[c(z,this)]=g,c(L,this)[g]=c(z,this),u(z,this,g),u(j,this,(a=c(j,this),a++,a)),c(xe,this).call(this,g,h,f),f&&(f.set=`add`),m=!1,c(J,this)&&!p&&c(O,this)?.call(this,t,e,`add`);else{r(Y,this,de).call(this,g);let n=c(F,this)[g];if(t!==n){if(!l)if(r(Y,this,S).call(this,n)){n!==i&&n.__abortController.abort(Error(`replaced`));let{__staleWhileFetching:r}=n;r!==void 0&&r!==t&&(c(K,this)&&c(D,this)?.call(this,r,e,`set`),c(q,this)&&c(V,this)?.push([r,e,`set`]))}else c(K,this)&&c(D,this)?.call(this,n,e,`set`),c(q,this)&&c(V,this)?.push([n,e,`set`]);if(c(be,this).call(this,g),c(xe,this).call(this,g,h,f),c(F,this)[g]=t,!p){let i=n&&r(Y,this,S).call(this,n)?n.__staleWhileFetching:n,a=i===void 0?`add`:t===i?`update`:`replace`;f&&(f.set=a,i!==void 0&&(f.oldValue=i)),c(J,this)&&this.onInsert?.(t,e,a)}}else p||(f&&(f.set=`update`),c(J,this)&&this.onInsert?.(t,e,`update`))}if(o!==0&&!c(W,this)&&r(Y,this,te).call(this),c(W,this)&&(m||c(ye,this).call(this,g,o,s),f&&c(X,this).call(this,f,g)),!l&&c(q,this)&&c(V,this)){let e=c(V,this),t;for(;t=e?.shift();)c(k,this)?.call(this,...t)}return this}function x(e){var t;let n=c(R,this),i=c(P,this)[n],a=c(F,this)[n],o=r(Y,this,S).call(this,a);o&&a.__abortController.abort(Error(`evicted`));let s=o?a.__staleWhileFetching:a;return(c(K,this)||c(q,this))&&s!==void 0&&(c(K,this)&&c(D,this)?.call(this,s,i,`evict`),c(q,this)&&c(V,this)?.push([s,i,`evict`])),c(be,this).call(this,n),c(G,this)?.[n]&&(clearTimeout(c(G,this)[n]),c(G,this)[n]=void 0),e&&(c(P,this)[n]=void 0,c(F,this)[n]=void 0,c(B,this).push(n)),c(j,this)===1?(u(R,this,u(z,this,0)),c(B,this).length=0):u(R,this,c(I,this)[n]),c(N,this).delete(i),u(j,this,(t=c(j,this),t--,t)),n}function ie(e,t={}){let{updateAgeOnHas:n=this.updateAgeOnHas,status:i}=t,a=c(N,this).get(e);if(a!==void 0){let e=c(F,this)[a];if(r(Y,this,S).call(this,e)&&e.__staleWhileFetching===void 0)return!1;if(c(Z,this).call(this,a))i&&(i.has=`stale`,c(X,this).call(this,i,a));else return n&&c(ve,this).call(this,a),i&&(i.has=`hit`,c(X,this).call(this,i,a)),!0}else i&&(i.has=`miss`);return!1}function ae(e,t){let{status:n,allowStale:i=this.allowStale}=t,a=c(N,this).get(e);if(a===void 0||!i&&c(Z,this).call(this,a)){n&&(n.peek=a===void 0?`miss`:`stale`);return}let o=c(F,this)[a],s=r(Y,this,S).call(this,o)?o.__staleWhileFetching:o;return n&&(s===void 0?n.peek=`miss`:(n.peek=`hit`,n.value=s)),s}function oe(e,t,n,i){let a=t===void 0?void 0:c(F,this)[t];if(r(Y,this,S).call(this,a))return a;let o=new AbortController,{signal:s}=n;s?.addEventListener(`abort`,()=>o.abort(s.reason),{signal:o.signal});let l={signal:o.signal,options:n,context:i},u=(i,a=!1)=>{let{aborted:s}=o.signal,u=n.ignoreFetchAbort&&i!==void 0,d=n.ignoreFetchAbort||!!(n.allowStaleOnFetchAbort&&i!==void 0);if(n.status&&(s&&!a?(n.status.fetchAborted=!0,n.status.fetchError=o.signal.reason,u&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),s&&!u&&!a)return f(o.signal.reason,d);let p=m,h=c(F,this)[t];return(h===m||h===void 0&&u&&a)&&(i===void 0?p.__staleWhileFetching===void 0?r(Y,this,w).call(this,e,`fetch`):c(F,this)[t]=p.__staleWhileFetching:(n.status&&(n.status.fetchUpdated=!0),r(Y,this,b).call(this,e,i,l.options,p))),i},d=e=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=e),f(e,!1)),f=(i,a)=>{let{aborted:s}=o.signal,l=s&&n.allowStaleOnFetchAbort,u=l||n.allowStaleOnFetchRejection,d=u||n.noDeleteOnFetchRejection,f=m;if(c(F,this)[t]===m&&(!d||!a&&f.__staleWhileFetching===void 0?r(Y,this,w).call(this,e,`fetch`):l||(c(F,this)[t]=f.__staleWhileFetching)),u)return n.status&&f.__staleWhileFetching!==void 0&&(n.status.returnedStale=!0),f.__staleWhileFetching;if(f.__returned===f)throw i},p=(t,r)=>{let i=c(he,this)?.call(this,e,a,l);o.signal.addEventListener(`abort`,()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(t(void 0),n.allowStaleOnFetchAbort&&(t=e=>u(e,!0)))}),i&&i instanceof Promise?i.then(e=>t(e===void 0?void 0:e),r):i!==void 0&&t(i)};n.status&&(n.status.fetchDispatched=!0);let m=new Promise(p).then(u,d),h=Object.assign(m,{__abortController:o,__staleWhileFetching:a,__returned:void 0});return t===void 0?(r(Y,this,b).call(this,e,h,{...l.options,status:void 0}),t=c(N,this).get(e)):c(F,this)[t]=h,h}function S(e){if(!c(_e,this))return!1;let t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty(`__staleWhileFetching`)&&t.__abortController instanceof AbortController}async function se(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:s=this.noDisposeOnSet,size:l=0,sizeCalculation:u=this.sizeCalculation,noUpdateTTL:d=this.noUpdateTTL,noDeleteOnFetchRejection:f=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:p=this.allowStaleOnFetchRejection,ignoreFetchAbort:m=this.ignoreFetchAbort,allowStaleOnFetchAbort:h=this.allowStaleOnFetchAbort,context:g,forceRefresh:ee=!1,status:_,signal:te}=t;if(_&&(_.op=`fetch`,_.key=e,ee&&(_.forceRefresh=!0),_.cache=this),!c(_e,this))return _&&(_.fetch=`get`),r(Y,this,C).call(this,e,{allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:a,status:_});let ne={allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:a,ttl:o,noDisposeOnSet:s,size:l,sizeCalculation:u,noUpdateTTL:d,noDeleteOnFetchRejection:f,allowStaleOnFetchRejection:p,allowStaleOnFetchAbort:h,ignoreFetchAbort:m,status:_,signal:te},v=c(N,this).get(e);if(v===void 0){_&&(_.fetch=`miss`);let t=r(Y,this,oe).call(this,e,v,ne,g);return t.__returned=t}else{let t=c(F,this)[v];if(r(Y,this,S).call(this,t)){let e=n&&t.__staleWhileFetching!==void 0;return _&&(_.fetch=`inflight`,e&&(_.returnedStale=!0)),e?t.__staleWhileFetching:t.__returned=t}let a=c(Z,this).call(this,v);if(!ee&&!a)return _&&(_.fetch=`hit`),r(Y,this,de).call(this,v),i&&c(ve,this).call(this,v),_&&c(X,this).call(this,_,v),t;let o=r(Y,this,oe).call(this,e,v,ne,g),s=o.__staleWhileFetching!==void 0&&n;return _&&(_.fetch=a?`stale`:`refresh`,s&&a&&(_.returnedStale=!0)),s?o.__staleWhileFetching:o.__returned=o}}async function ce(e,t={}){let n=await r(Y,this,se).call(this,e,t);if(n===void 0)throw Error(`fetch() returned undefined`);return n}function le(e,t={}){let n=c(ge,this);if(!n)throw Error(`no memoMethod provided to constructor`);let{context:i,status:a,forceRefresh:o,...s}=t;a&&o&&(a.forceRefresh=!0);let l=r(Y,this,C).call(this,e,s),u=o||l===void 0;if(a&&(a.memo=u?`miss`:`hit`,u||(a.value=l)),!u)return l;let d=n(e,l,{options:s,context:i});return a&&(a.value=d),r(Y,this,b).call(this,e,d,s),d}function C(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,status:o}=t,s=c(N,this).get(e);if(s===void 0){o&&(o.get=`miss`);return}let l=c(F,this)[s],u=r(Y,this,S).call(this,l);return o&&c(X,this).call(this,o,s),c(Z,this).call(this,s)?u?(o&&(o.get=`stale-fetching`),n&&l.__staleWhileFetching!==void 0?(o&&(o.returnedStale=!0),l.__staleWhileFetching):void 0):(a||r(Y,this,w).call(this,e,`expire`),o&&(o.get=`stale`),n?(o&&(o.returnedStale=!0),l):void 0):(o&&(o.get=u?`fetching`:`hit`),r(Y,this,de).call(this,s),i&&c(ve,this).call(this,s),u?l.__staleWhileFetching:l)}function ue(e,t){c(L,this)[t]=e,c(I,this)[e]=t}function de(e){e!==c(z,this)&&(e===c(R,this)?u(R,this,c(I,this)[e]):r(Y,this,ue).call(this,c(L,this)[e],c(I,this)[e]),r(Y,this,ue).call(this,c(z,this),e),u(z,this,e))}function w(e,t){Q.hasSubscribers&&Q.publish({op:`delete`,delete:t,key:e,cache:this});let n=!1;if(c(j,this)!==0){let a=c(N,this).get(e);if(a!==void 0)if(c(G,this)?.[a]&&(clearTimeout(c(G,this)[a]),c(G,this)[a]=void 0),n=!0,c(j,this)===1)r(Y,this,fe).call(this,t);else{var i;c(be,this).call(this,a);let n=c(F,this)[a];if(r(Y,this,S).call(this,n)?n.__abortController.abort(Error(`deleted`)):(c(K,this)||c(q,this))&&(c(K,this)&&c(D,this)?.call(this,n,e,t),c(q,this)&&c(V,this)?.push([n,e,t])),c(N,this).delete(e),c(P,this)[a]=void 0,c(F,this)[a]=void 0,a===c(z,this))u(z,this,c(L,this)[a]);else if(a===c(R,this))u(R,this,c(I,this)[a]);else{let e=c(L,this)[a];c(I,this)[e]=c(I,this)[a];let t=c(I,this)[a];c(L,this)[t]=c(L,this)[a]}u(j,this,(i=c(j,this),i--,i)),c(B,this).push(a)}}if(c(q,this)&&c(V,this)?.length){let e=c(V,this),t;for(;t=e?.shift();)c(k,this)?.call(this,...t)}return n}function fe(e){for(let t of r(Y,this,y).call(this,{allowStale:!0})){let n=c(F,this)[t];if(r(Y,this,S).call(this,n))n.__abortController.abort(Error(`deleted`));else{let r=c(P,this)[t];c(K,this)&&c(D,this)?.call(this,n,r,e),c(q,this)&&c(V,this)?.push([n,r,e])}}if(c(N,this).clear(),c(F,this).fill(void 0),c(P,this).fill(void 0),c(W,this)&&c(U,this)){c(W,this).fill(0),c(U,this).fill(0);for(let e of c(G,this)??[])e!==void 0&&clearTimeout(e);c(G,this)?.fill(void 0)}if(c(H,this)&&c(H,this).fill(0),u(R,this,0),u(z,this,0),c(B,this).length=0,u(M,this,0),u(j,this,0),c(q,this)&&c(V,this)){let e=c(V,this),t;for(;t=e?.shift();)c(k,this)?.call(this,...t)}}var pe,me,T,E,D,O,k,he,ge,A,j,M,N,P,F,I,L,R,z,B,V,H,U,W,G,K,_e,q,J,Y,ve,X,ye,Z,be,xe,Se,Ce,we,Q,Te,Ee,De,Oe,ke,Ae,je,$,Me,Ne,Pe,Fe,Ie=e((()=>{t(),s(),d(),i(),a(),o(),Q=ee(`lru-cache:metrics`),Te=_(`lru-cache`),Ee=typeof performance==`object`&&performance&&typeof performance.now==`function`?performance:Date,De=()=>Q.hasSubscribers||Te.hasSubscribers,Oe=new Set,ke=typeof process==`object`&&process?process:{},Ae=(e,t,n,r)=>{typeof ke.emitWarning==`function`?ke.emitWarning(e,t,n,r):console.error(`[${n}] ${t}: ${e}`)},je=e=>!Oe.has(e),$=e=>!!e&&e===Math.floor(e)&&e>0&&isFinite(e),Me=e=>$(e)?e<=2**8?Uint8Array:e<=2**16?Uint16Array:e<=2**32?Uint32Array:e<=2**53-1?Ne:null:null,Ne=class extends Array{constructor(e){super(e),this.fill(0)}},Pe=(pe=class e{static create(t){let n=Me(t);if(!n)return[];me._=r(pe,e,!0);let i=new e(t,n);return me._=r(pe,e,!1),i}constructor(t,i){if(n(this,`heap`,void 0),n(this,`length`,void 0),!r(pe,e,me)._)throw TypeError(`instantiate Stack using Stack.create(n)`);this.heap=new i(t),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},me={_:!1},pe),Fe=(T=new WeakMap,E=new WeakMap,D=new WeakMap,O=new WeakMap,k=new WeakMap,he=new WeakMap,ge=new WeakMap,A=new WeakMap,j=new WeakMap,M=new WeakMap,N=new WeakMap,P=new WeakMap,F=new WeakMap,I=new WeakMap,L=new WeakMap,R=new WeakMap,z=new WeakMap,B=new WeakMap,V=new WeakMap,H=new WeakMap,U=new WeakMap,W=new WeakMap,G=new WeakMap,K=new WeakMap,_e=new WeakMap,q=new WeakMap,J=new WeakMap,Y=new WeakSet,ve=new WeakMap,X=new WeakMap,ye=new WeakMap,Z=new WeakMap,be=new WeakMap,xe=new WeakMap,Se=new WeakMap,we=Symbol.iterator,Ce=Symbol.toStringTag,class e{get perf(){return c(A,this)}static unsafeExposeInternals(e){return{starts:c(U,e),ttls:c(W,e),autopurgeTimers:c(G,e),sizes:c(H,e),keyMap:c(N,e),keyList:c(P,e),valList:c(F,e),next:c(I,e),prev:c(L,e),get head(){return c(R,e)},get tail(){return c(z,e)},free:c(B,e),isBackgroundFetch:t=>r(Y,e,S).call(e,t),backgroundFetch:(t,n,i,a)=>r(Y,e,oe).call(e,t,n,i,a),moveToTail:t=>r(Y,e,de).call(e,t),indexes:t=>r(Y,e,v).call(e,t),rindexes:t=>r(Y,e,y).call(e,t),isStale:t=>c(Z,e).call(e,t)}}get max(){return c(T,this)}get maxSize(){return c(E,this)}get calculatedSize(){return c(M,this)}get size(){return c(j,this)}get fetchMethod(){return c(he,this)}get memoMethod(){return c(ge,this)}get dispose(){return c(D,this)}get onInsert(){return c(O,this)}get disposeAfter(){return c(k,this)}constructor(t){f(this,Y),l(this,T,void 0),l(this,E,void 0),l(this,D,void 0),l(this,O,void 0),l(this,k,void 0),l(this,he,void 0),l(this,ge,void 0),l(this,A,void 0),n(this,`ttl`,void 0),n(this,`ttlResolution`,void 0),n(this,`ttlAutopurge`,void 0),n(this,`updateAgeOnGet`,void 0),n(this,`updateAgeOnHas`,void 0),n(this,`allowStale`,void 0),n(this,`noDisposeOnSet`,void 0),n(this,`noUpdateTTL`,void 0),n(this,`maxEntrySize`,void 0),n(this,`sizeCalculation`,void 0),n(this,`noDeleteOnFetchRejection`,void 0),n(this,`noDeleteOnStaleGet`,void 0),n(this,`allowStaleOnFetchAbort`,void 0),n(this,`allowStaleOnFetchRejection`,void 0),n(this,`ignoreFetchAbort`,void 0),n(this,`backgroundFetchSize`,void 0),l(this,j,void 0),l(this,M,void 0),l(this,N,void 0),l(this,P,void 0),l(this,F,void 0),l(this,I,void 0),l(this,L,void 0),l(this,R,void 0),l(this,z,void 0),l(this,B,void 0),l(this,V,void 0),l(this,H,void 0),l(this,U,void 0),l(this,W,void 0),l(this,G,void 0),l(this,K,void 0),l(this,_e,void 0),l(this,q,void 0),l(this,J,void 0),l(this,ve,()=>{}),l(this,X,()=>{}),l(this,ye,()=>{}),l(this,Z,()=>!1),l(this,be,e=>{}),l(this,xe,(e,t,n)=>{}),l(this,Se,(e,t,n,r)=>{if(n||r)throw TypeError(`cannot set size without setting maxSize or maxEntrySize on cache`);return 0}),n(this,Ce,`LRUCache`);let{max:i=0,ttl:a,ttlResolution:o=1,ttlAutopurge:s,updateAgeOnGet:d,updateAgeOnHas:p,allowStale:m,dispose:h,onInsert:g,disposeAfter:ee,noDisposeOnSet:_,noUpdateTTL:v,maxSize:y=0,maxEntrySize:re=0,sizeCalculation:b,fetchMethod:x,memoMethod:ie,noDeleteOnFetchRejection:ae,noDeleteOnStaleGet:oe,allowStaleOnFetchRejection:S,allowStaleOnFetchAbort:se,ignoreFetchAbort:ce,backgroundFetchSize:le=1,perf:C}=t;if(this.backgroundFetchSize=le,C!==void 0&&typeof C?.now!=`function`)throw TypeError(`perf option must have a now() method if specified`);if(u(A,this,C??Ee),i!==0&&!$(i))throw TypeError(`max option must be a nonnegative integer`);let ue=i?Me(i):Array;if(!ue)throw Error(`invalid max value: `+i);if(u(T,this,i),u(E,this,y),this.maxEntrySize=re||c(E,this),this.sizeCalculation=b,this.sizeCalculation){if(!c(E,this)&&!this.maxEntrySize)throw TypeError(`cannot set sizeCalculation without setting maxSize or maxEntrySize`);if(typeof this.sizeCalculation!=`function`)throw TypeError(`sizeCalculation set to non-function`)}if(ie!==void 0&&typeof ie!=`function`)throw TypeError(`memoMethod must be a function if defined`);if(u(ge,this,ie),x!==void 0&&typeof x!=`function`)throw TypeError(`fetchMethod must be a function if specified`);if(u(he,this,x),u(_e,this,!!x),u(N,this,new Map),u(P,this,Array.from({length:i}).fill(void 0)),u(F,this,Array.from({length:i}).fill(void 0)),u(I,this,new ue(i)),u(L,this,new ue(i)),u(R,this,0),u(z,this,0),u(B,this,Pe.create(i)),u(j,this,0),u(M,this,0),typeof h==`function`&&u(D,this,h),typeof g==`function`&&u(O,this,g),typeof ee==`function`?(u(k,this,ee),u(V,this,[])):(u(k,this,void 0),u(V,this,void 0)),u(K,this,!!c(D,this)),u(J,this,!!c(O,this)),u(q,this,!!c(k,this)),this.noDisposeOnSet=!!_,this.noUpdateTTL=!!v,this.noDeleteOnFetchRejection=!!ae,this.allowStaleOnFetchRejection=!!S,this.allowStaleOnFetchAbort=!!se,this.ignoreFetchAbort=!!ce,this.maxEntrySize!==0){if(c(E,this)!==0&&!$(c(E,this)))throw TypeError(`maxSize must be a positive integer if specified`);if(!$(this.maxEntrySize))throw TypeError(`maxEntrySize must be a positive integer if specified`);r(Y,this,ne).call(this)}if(this.allowStale=!!m,this.noDeleteOnStaleGet=!!oe,this.updateAgeOnGet=!!d,this.updateAgeOnHas=!!p,this.ttlResolution=$(o)||o===0?o:1,this.ttlAutopurge=!!s,this.ttl=a||0,this.ttl){if(!$(this.ttl))throw TypeError(`ttl must be a positive integer if specified`);r(Y,this,te).call(this)}if(c(T,this)===0&&this.ttl===0&&c(E,this)===0)throw TypeError(`At least one of max, maxSize, or ttl is required`);if(!this.ttlAutopurge&&!c(T,this)&&!c(E,this)){let t=`LRU_CACHE_UNBOUNDED`;je(t)&&(Oe.add(t),Ae(`TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.`,`UnboundedCacheWarning`,t,e))}}getRemainingTTL(e){return c(N,this).has(e)?1/0:0}*entries(){for(let e of r(Y,this,v).call(this))c(F,this)[e]!==void 0&&c(P,this)[e]!==void 0&&!r(Y,this,S).call(this,c(F,this)[e])&&(yield[c(P,this)[e],c(F,this)[e]])}*rentries(){for(let e of r(Y,this,y).call(this))c(F,this)[e]!==void 0&&c(P,this)[e]!==void 0&&!r(Y,this,S).call(this,c(F,this)[e])&&(yield[c(P,this)[e],c(F,this)[e]])}*keys(){for(let e of r(Y,this,v).call(this)){let t=c(P,this)[e];t!==void 0&&!r(Y,this,S).call(this,c(F,this)[e])&&(yield t)}}*rkeys(){for(let e of r(Y,this,y).call(this)){let t=c(P,this)[e];t!==void 0&&!r(Y,this,S).call(this,c(F,this)[e])&&(yield t)}}*values(){for(let e of r(Y,this,v).call(this))c(F,this)[e]!==void 0&&!r(Y,this,S).call(this,c(F,this)[e])&&(yield c(F,this)[e])}*rvalues(){for(let e of r(Y,this,y).call(this))c(F,this)[e]!==void 0&&!r(Y,this,S).call(this,c(F,this)[e])&&(yield c(F,this)[e])}[we](){return this.entries()}find(e,t={}){for(let n of r(Y,this,v).call(this)){let i=c(F,this)[n],a=r(Y,this,S).call(this,i)?i.__staleWhileFetching:i;if(a!==void 0&&e(a,c(P,this)[n],this))return r(Y,this,C).call(this,c(P,this)[n],t)}}forEach(e,t=this){for(let n of r(Y,this,v).call(this)){let i=c(F,this)[n],a=r(Y,this,S).call(this,i)?i.__staleWhileFetching:i;a!==void 0&&e.call(t,a,c(P,this)[n],this)}}rforEach(e,t=this){for(let n of r(Y,this,y).call(this)){let i=c(F,this)[n],a=r(Y,this,S).call(this,i)?i.__staleWhileFetching:i;a!==void 0&&e.call(t,a,c(P,this)[n],this)}}purgeStale(){let e=!1;for(let t of r(Y,this,y).call(this,{allowStale:!0}))c(Z,this).call(this,t)&&(r(Y,this,w).call(this,c(P,this)[t],`expire`),e=!0);return e}info(e){let t=c(N,this).get(e);if(t===void 0)return;let n=c(F,this)[t],i=r(Y,this,S).call(this,n)?n.__staleWhileFetching:n;if(i===void 0)return;let a={value:i};if(c(W,this)&&c(U,this)){let e=c(W,this)[t],n=c(U,this)[t];e&&n&&(a.ttl=e-(c(A,this).now()-n),a.start=Date.now())}return c(H,this)&&(a.size=c(H,this)[t]),a}dump(){let e=[];for(let t of r(Y,this,v).call(this,{allowStale:!0})){let n=c(P,this)[t],i=c(F,this)[t],a=r(Y,this,S).call(this,i)?i.__staleWhileFetching:i;if(a===void 0||n===void 0)continue;let o={value:a};if(c(W,this)&&c(U,this)){o.ttl=c(W,this)[t];let e=c(A,this).now()-c(U,this)[t];o.start=Math.floor(Date.now()-e)}c(H,this)&&(o.size=c(H,this)[t]),e.unshift([n,o])}return e}load(e){this.clear();for(let[t,n]of e){if(n.start){let e=Date.now()-n.start;n.start=c(A,this).now()-e}r(Y,this,b).call(this,t,n.value,n)}}set(e,t,n={}){let{status:i=Q.hasSubscribers?{}:void 0}=n;n.status=i,i&&(i.op=`set`,i.key=e,t!==void 0&&(i.value=t),i.cache=this);let a=r(Y,this,b).call(this,e,t,n);return i&&Q.hasSubscribers&&Q.publish(i),a}pop(){try{for(;c(j,this);){let e=c(F,this)[c(R,this)];if(r(Y,this,x).call(this,!0),r(Y,this,S).call(this,e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(c(q,this)&&c(V,this)){let e=c(V,this),t;for(;t=e?.shift();)c(k,this)?.call(this,...t)}}}has(e,t={}){let{status:n=Q.hasSubscribers?{}:void 0}=t;t.status=n,n&&(n.op=`has`,n.key=e,n.cache=this);let i=r(Y,this,ie).call(this,e,t);return Q.hasSubscribers&&Q.publish(n),i}peek(e,t={}){let{status:n=De()?{}:void 0}=t;n&&(n.op=`peek`,n.key=e,n.cache=this),t.status=n;let i=r(Y,this,ae).call(this,e,t);return Q.hasSubscribers&&Q.publish(n),i}fetch(e,t={}){let n=Te.hasSubscribers,{status:i=De()?{}:void 0}=t;t.status=i,i&&t.context&&(i.context=t.context);let a=r(Y,this,se).call(this,e,t);return i&&n&&(i.trace=!0,Te.tracePromise(()=>a,i).catch(()=>{})),a}forceFetch(e,t={}){let n=Te.hasSubscribers,{status:i=De()?{}:void 0}=t;t.status=i,i&&t.context&&(i.context=t.context);let a=r(Y,this,ce).call(this,e,t);return i&&n&&(i.trace=!0,Te.tracePromise(()=>a,i).catch(()=>{})),a}memo(e,t={}){let{status:n=Q.hasSubscribers?{}:void 0}=t;t.status=n,n&&(n.op=`memo`,n.key=e,t.context&&(n.context=t.context),n.cache=this);let i=r(Y,this,le).call(this,e,t);return n&&(n.value=i),Q.hasSubscribers&&Q.publish(n),i}get(e,t={}){let{status:n=Q.hasSubscribers?{}:void 0}=t;t.status=n,n&&(n.op=`get`,n.key=e,n.cache=this);let i=r(Y,this,C).call(this,e,t);return n&&(i!==void 0&&(n.value=i),Q.hasSubscribers&&Q.publish(n)),i}delete(e){return r(Y,this,w).call(this,e,`delete`)}clear(){return r(Y,this,fe).call(this,`delete`)}})}));function Le(e,t=300*1e3){let n=new Map,r=new Map,i=async(...i)=>{let a=p(i),o=n.get(a),s=Date.now();if(!o){let t=r.get(a);if(t)return t;let o=e(...i);r.set(a,o);try{let e=await o;return r.get(a)===o&&n.set(a,{value:e,timestamp:s,refreshing:!1}),e}finally{r.get(a)===o&&r.delete(a)}}if(o&&s-o.timestamp>t&&!o.refreshing){o.refreshing=!0;let t=o;return e(...i).then(e=>{n.get(a)===t&&n.set(a,{value:e,timestamp:Date.now(),refreshing:!1})}).catch(e=>{g(e),n.get(a)===t&&n.delete(a)}),o.value}return n.get(a).value};return i.cache={clear:()=>{n.clear(),r.clear()}},i}function Re(e,t,n=100){let r=new Fe({max:n}),i=(...n)=>{let i=t(...n),a=r.get(i);if(a!==void 0)return a;let o=e(...n);return r.set(i,o),o};return i.cache={clear:()=>r.clear(),size:()=>r.size,delete:e=>r.delete(e),get:e=>r.peek(e),has:e=>r.has(e)},i}var ze=e((()=>{Ie(),h(),m()}));export{Ie as a,Fe as i,Re as n,Le as r,ze as t};
@@ -1 +0,0 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{i as n,o as r}from"./envUtils-DcaKZlRU.js";import{Du as i,Eh as a,Eu as o,Hd as s,Th as c,Vd as l,cE as ee,cc as te,gy as u,jx as ne,kx as d,sc as f,uE as p,xy as m,yy as h,zS as g}from"./loadAgentsDir-C96o6gCj.js";import{I as _,Lt as v,P as y,Wt as b,_ as x,ai as S,di as re,fi as C,t as w,y as T}from"./src-DL3w8VPk.js";import{t as E}from"./jsx-runtime-Bb4Xn-E0.js";import{$ as D,Ut as O}from"./state-D5D6QpTX.js";import{n as k,t as A}from"./cwd-Nh5IZNKO.js";import{F as j,R as M}from"./debug-D58GQBDG.js";import{Cn as N,b as P,bn as ie,h as F}from"./settings-BowI3jp-.js";import{M as I,P as L,k as ae}from"./config-DUTgj3js.js";import{m as R,r as z}from"./git-Wid-XppW.js";import{o as oe,s as se}from"./log-CZ7ploQm.js";import{n as ce,r as B}from"./analytics-DJobLaWP.js";import{m as le,v as V}from"./startupProfiler-B90b5vuq.js";import{n as H,t as U}from"./useExitOnCtrlCDWithKeybindings-L5idX6Kz.js";import{r as ue,t as de}from"./promptEditor-DT6egmcb.js";import{homedir as fe}from"os";import{join as W,relative as pe}from"path";import{mkdir as G,writeFile as me}from"fs/promises";function he(e){return z(e)!==null}var K=e((()=>{R()}));function ge({onSelect:e,onCancel:t}){let r=(0,q.use)(h()),o=W(n(),`AGENTS.md`),c=W(D(),`AGENTS.md`),l=r.some(e=>e.path===o),u=r.some(e=>e.path===c),d=[...r.filter(e=>e.type!==`AutoMem`).map(e=>({...e,exists:!0})),...l?[]:[{path:o,type:`User`,content:``,exists:!1}],...u?[]:[{path:c,type:`Project`,content:``,exists:!1}]],f=new Map,p=d.map(e=>{let t=ie(e.path),n=e.exists?``:` (new)`,r=e.parent?(f.get(e.parent)??0)+1:0;f.set(e.path,r);let i=r>0?` `.repeat(r-1):``,a;a=e.type===`User`&&!e.isNested&&e.path===o?`User memory`:e.type===`Project`&&!e.isNested&&e.path===c?`Project memory`:r>0?`${i}L ${t}${n}`:`${t}`;let s,l=he(D());return s=e.type===`User`&&!e.isNested?`Saved in ~/.workmate/AGENTS.md`:e.type===`Project`&&!e.isNested&&e.path===c?`${l?`Checked in at`:`Saved in`} ./AGENTS.md`:e.parent?`@-imported`:e.isNested?`dynamically loaded`:``,{label:a,value:e.path,description:s}}),m=[],g=a(e=>e.agentDefinitions);if(L()){m.push({label:`Open auto-memory folder`,value:`${X}${ae()}`,description:``});for(let e of g.activeAgents)if(e.memory){let t=ee(e.agentType,e.memory);m.push({label:`Open ${re.bold(e.agentType)} agent memory`,value:`${X}${t}`,description:`${e.memory} scope`})}}p.push(...m);let v=Y&&p.some(e=>e.value===Y)?Y:p[0]?.value||``,[S,C]=(0,q.useState)(L),[w,T]=(0,q.useState)(te),[E]=(0,q.useState)(L),O=a(e=>Object.values(e.tasks).some(e=>e.type===`dream`&&e.status===`running`)),[k,A]=(0,q.useState)(null);(0,q.useEffect)(()=>{E&&s().then(A)},[E,O]);let j=O?`running`:k===null?``:k===0?`never`:`last ran ${le(new Date(k))}`,[M,N]=(0,q.useState)(null),F=M!==null,I=+!!E;function R(){let e=!S;P(`userSettings`,{autoMemoryEnabled:e}),C(e),B(`tengu_auto_memory_toggled`,{enabled:e})}function z(){let e=!w;P(`userSettings`,{autoDreamEnabled:e}),T(e),B(`tengu_auto_dream_toggled`,{enabled:e})}return H(),b(`confirm:no`,t,{context:`Confirmation`}),b(`confirm:yes`,()=>{M===0?R():M===1&&z()},{context:`Confirmation`,isActive:F}),b(`select:next`,()=>{N(e=>e!==null&&e<I?e+1:null)},{context:`Select`,isActive:F}),b(`select:previous`,()=>{N(e=>e!==null&&e>0?e-1:e)},{context:`Select`,isActive:F}),(0,J.jsxs)(_,{flexDirection:`column`,width:`100%`,children:[(0,J.jsxs)(_,{flexDirection:`column`,marginBottom:1,children:[(0,J.jsx)(x,{isFocused:M===0,children:(0,J.jsxs)(y,{children:[`Auto-memory: `,S?`on`:`off`]})}),E&&(0,J.jsx)(x,{isFocused:M===1,styled:!1,children:(0,J.jsxs)(y,{color:M===1?`suggestion`:void 0,children:[`Auto-dream: `,w?`on`:`off`,j&&(0,J.jsxs)(y,{dimColor:!0,children:[` · `,j]}),!O&&w&&(0,J.jsx)(y,{dimColor:!0,children:` · /dream to run`})]})})]}),(0,J.jsx)(i,{defaultFocusValue:v,options:p,isDisabled:F,onChange:t=>{if(t.startsWith(X)){let e=t.slice(15);G(e,{recursive:!0}).catch(()=>{}).then(()=>ne(e));return}Y=t,e(t)},onCancel:t,onUpFromFirstItem:()=>N(I)})]})}var q,J,Y,X,_e=e((()=>{C(),q=t(S(),1),O(),U(),w(),g(),I(),ce(),f(),l(),c(),p(),d(),m(),r(),N(),V(),K(),F(),o(),J=E(),X=`__open_folder__`}));function ve(e){let t=fe(),n=A(),r=e.startsWith(t)?`~${e.slice(t.length)}`:null,i=e.startsWith(n)?`./${pe(n,e)}`:null;return r&&i?r.length<=i.length?r:i:r||i||e}var ye=e((()=>{w(),k(),E()}));function be({onDone:e}){let t=async t=>{try{t.includes(n())&&await G(n(),{recursive:!0});try{await me(t,``,{encoding:`utf8`,flag:`wx`})}catch(e){if(j(e)!==`EEXIST`)throw e}await de(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 ${ve(t)}\n\n${o}`,{display:`system`})}catch(t){se(t),e(`Error opening memory file: ${t}`)}},r=()=>{e(`Cancelled memory editing`,{display:`system`})};return(0,Q.jsx)(T,{title:`Memory`,onCancel:r,color:`remember`,children:(0,Q.jsxs)(_,{flexDirection:`column`,children:[(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(ge,{onSelect:t,onCancel:r})}),(0,Q.jsx)(_,{marginTop:1,children:(0,Q.jsxs)(y,{dimColor:!0,children:[`Learn more: `,(0,Q.jsx)(v,{url:`https://code.workmate.com/docs/en/memory`})]})})]})})}var Z,Q,$;e((()=>{Z=t(S(),1),w(),_e(),ye(),m(),r(),M(),oe(),ue(),Q=E(),$=async e=>(u(),await h(),(0,Q.jsx)(be,{onDone:e}))}))();export{$ as call};
@@ -1,2 +0,0 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{Du as n,Ou as r,ct as i,lt as a,st as o,ut as s}from"./loadAgentsDir-C96o6gCj.js";import{I as c,P as l,ai as u,t as d}from"./src-DL3w8VPk.js";import{t as f}from"./jsx-runtime-Bb4Xn-E0.js";function p({onDone:e}){let t=a(),r=o(),i=(0,m.useMemo)(()=>t.map(e=>({label:(0,h.jsxs)(l,{children:[e.icon,` `,e.name,` `,(0,h.jsxs)(l,{dimColor:!0,children:[`(`,e.slug,`) — `,e.description]})]}),value:e.slug})),[t]);function u(n){s(n);let r=t.find(e=>e.slug===n);e(`${r?.icon} Mode switched to: ${r?.name} (${r?.slug}) — ${r?.description}`,{display:`system`})}function d(){e(`Mode selection cancelled.`,{display:`system`})}return(0,h.jsxs)(c,{flexDirection:`column`,children:[(0,h.jsxs)(c,{marginBottom:1,flexDirection:`column`,children:[(0,h.jsx)(l,{color:`remember`,bold:!0,children:`Select mode`}),(0,h.jsx)(l,{dimColor:!0,children:`Arrow keys to navigate, Enter to select, Esc to cancel.`})]}),(0,h.jsx)(n,{defaultValue:r,options:i,onChange:u,onCancel:d,visibleOptionCount:t.length})]})}var m,h,g;e((()=>{m=t(u(),1),d(),r(),i(),h=f(),g=async(e,t,n)=>{let r=n?.trim().toLowerCase();if(r){let t=a(),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
- `)}`,{display:`system`});return}s(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 +0,0 @@
1
- import{n as e,o as t,r as n}from"./rolldown-runtime-DaDcL9Zw.js";import{n as r,t as i}from"./memoize-BK3gG5ob.js";import{d as a,i as o,l as s,o as c,r as ee,s as l,t as u}from"./envUtils-DcaKZlRU.js";import{n as te,t as d}from"./defineProperty-C-QyHrDq.js";import{n as f,t as p}from"./axios-DaWTGg7G.js";import{di as ne,fi as re}from"./src-DL3w8VPk.js";import{D as ie,E as ae,N as oe,g as se,n as ce,r as le,t as ue}from"./lazySchema-DULtBUCI.js";import{Fn as de,Fr as fe,Ir as pe,Q as me,R as m,Rn as he,Ut as h,X as ge,Xt as _e,_n as ve,cr as ye,ft as be,lr as xe,on as Se,q as Ce,ut as we,y as Te}from"./state-D5D6QpTX.js";import{B as Ee,C as De,F as Oe,G as ke,P as g,R as Ae,S as je,T as Me,W as Ne,c as _,f as Pe,i as v,o as Fe,s as Ie,u as Le,x as Re}from"./debug-D58GQBDG.js";import{Ut as ze,b as Be,d as y,h as b,s as x,t as Ve}from"./settings-BowI3jp-.js";import{C as He,S as Ue,c as S,h as We,n as C,y as w}from"./config-DUTgj3js.js";import{a as Ge,i as Ke,o as qe,r as Je,s as Ye,t as Xe}from"./execFileNoThrow-B_KRY4cT.js";import{d as Ze,f as Qe,o as $e,s as T}from"./log-CZ7ploQm.js";import{r as et,t as tt}from"./memoize-CumjjK2Q.js";import{s as nt,u as rt}from"./types-APu4OCXJ.js";import{n as it,r as E}from"./analytics-DJobLaWP.js";import{l as D,n as at,r as ot,s as st,t as ct,u as O}from"./oauth-D38aRTUb.js";import{n as lt,t as ut}from"./bundledMode--fG1S62b.js";import{n as dt,o as ft}from"./stringUtils-D7oJIyY2.js";import{a as pt,i as mt,l as ht}from"./proxy-BhIc7-mj.js";import{userInfo as gt}from"os";import{join as _t}from"path";import{chmodSync as vt,mkdirSync as yt,readFileSync as bt,writeFileSync as xt}from"fs";import{createHash as St,randomUUID as Ct}from"crypto";import{mkdir as wt,stat as Tt,writeFile as Et}from"fs/promises";import{exec as Dt,execFile as Ot}from"child_process";import{AsyncLocalStorage as kt}from"async_hooks";function k(e=Ve()){let t=e.modelType;return t===`openai`?`openai`:t===`gemini`?`gemini`:t===`grok`?`grok`:s(process.env.CLAUDE_CODE_USE_BEDROCK)?`bedrock`:s(process.env.CLAUDE_CODE_USE_VERTEX)?`vertex`:s(process.env.CLAUDE_CODE_USE_FOUNDRY)?`foundry`:s(process.env.CLAUDE_CODE_USE_OPENAI)?`openai`:s(process.env.CLAUDE_CODE_USE_GEMINI)?`gemini`:s(process.env.CLAUDE_CODE_USE_GROK)?`grok`:`firstParty`}function At(){return k()}function jt(){let e=process.env.ANTHROPIC_BASE_URL;if(!e)return!0;try{return new URL(e).host===`api.anthropic.com`}catch{return!1}}var A=e((()=>{b(),c()}));function Mt(){return Pt.getStore()?.workload}function Nt(e,t){return Pt.run({workload:e},t)}var Pt,Ft=e((()=>{Pt=new kt}));function It(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 Lt=e((()=>{}));function Rt(e,t){return e.find(e=>e.includes(t))??null}async function zt(){let{BedrockClient:e}=await import(`./dist-es-yHGBqhBe.js`),t=u(),n=s(process.env.CLAUDE_CODE_SKIP_BEDROCK_AUTH),r={region:t,...process.env.ANTHROPIC_BEDROCK_BASE_URL&&{endpoint:process.env.ANTHROPIC_BEDROCK_BASE_URL},...await mt(),...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`}]}};if(!n&&!process.env.AWS_BEARER_TOKEN_BEDROCK){let e=await U();e&&(r.credentials={accessKeyId:e.accessKeyId,secretAccessKey:e.secretAccessKey,sessionToken:e.sessionToken})}return new e(r)}async function Bt(){let{BedrockRuntimeClient:e}=await import(`./dist-es-Gt_DpXlP.js`),t=u(),n=s(process.env.CLAUDE_CODE_SKIP_BEDROCK_AUTH),r={region:t,...process.env.ANTHROPIC_BEDROCK_BASE_URL&&{endpoint:process.env.ANTHROPIC_BEDROCK_BASE_URL},...await mt(),...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`}]}};if(!n&&!process.env.AWS_BEARER_TOKEN_BEDROCK){let e=await U();e&&(r.credentials={accessKeyId:e.accessKeyId,secretAccessKey:e.secretAccessKey,sessionToken:e.sessionToken})}return new e(r)}function Vt(e){return e.startsWith(`anthropic.`)}function Ht(e){if(!e.startsWith(`arn:`))return e;let t=e.lastIndexOf(`/`);return t===-1?e:e.substring(t+1)}function Ut(e){let t=Ht(e);for(let e of qt)if(t.startsWith(`${e}.anthropic.`))return e}function Wt(e,t){let n=Ut(e);return n?e.replace(`${n}.`,`${t}.`):Vt(e)?`${t}.${e}`:e}var Gt,Kt,qt,Jt=e((()=>{i(),G(),c(),$e(),ht(),Gt=r(async()=>{let[e,{ListInferenceProfilesCommand:t}]=await Promise.all([zt(),import(`./dist-es-yHGBqhBe.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 T(e),e}}),Kt=r(async e=>{try{let[t,{GetInferenceProfileCommand:n}]=await Promise.all([zt(),import(`./dist-es-yHGBqhBe.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 T(e),null}}),qt=[`us`,`eu`,`apac`,`global`]})),Yt,Xt,Zt,Qt,$t,en,tn,nn,rn,an,on,sn,cn,ln,un=e((()=>{Yt={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`},Xt={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`},Zt={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`},Qt={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`},$t={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`},en={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`},tn={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`},nn={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`},rn={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`},an={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`},on={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`},sn={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`},cn={haiku35:Zt,haiku45:Qt,sonnet35:Xt,sonnet37:Yt,sonnet40:$t,sonnet45:en,sonnet46:sn,opus40:tn,opus41:nn,opus45:rn,opus46:an,opus47:on},Object.values(cn).map(e=>e.firstParty),ln=Object.fromEntries(Object.entries(cn).map(([e,t])=>[t.firstParty,e]))}));function dn(e){let t={};for(let n of _n)t[n]=cn[n][e];return t}async function fn(){let e=dn(`bedrock`),t;try{t=await Gt()}catch(t){return T(t),e}if(!t?.length)return e;let n={};for(let r of _n){let i=cn[r].firstParty;n[r]=Rt(t,i)||e[r]}return n}function pn(e){let t=Ve().modelOverrides;if(!t)return e;let n={...e};for(let[e,r]of Object.entries(t)){let t=ln[e];t&&r&&(n[t]=r)}return n}function mn(e){let t;try{t=Ve().modelOverrides}catch{return e}if(!t)return e;for(let[n,r]of Object.entries(t))if(r===e)return n;return e}function hn(){if(ge()===null){if(k()!==`bedrock`){de(dn(k()));return}vn()}}function j(){let e=ge();return e===null?(hn(),pn(dn(k()))):pn(e)}async function gn(){if(ge()===null){if(k()!==`bedrock`){de(dn(k()));return}await vn()}}var _n,vn,yn=e((()=>{h(),$e(),Lt(),b(),Jt(),un(),A(),_n=Object.keys(cn),vn=It(async()=>{if(ge()===null)try{de(await fn())}catch(e){T(e)}})}));async function bn(){let e=S().oauthAccount?.accountUuid,t=$i();if(!e||!t)return;let n=`${D().BASE_API_URL}/api/claude_cli_profile`;try{return(await f.get(n,{headers:{"x-api-key":t,"anthropic-beta":st},params:{account_uuid:e},timeout:1e4})).data}catch(e){T(e)}}async function xn(e){let t=`${D().BASE_API_URL}/api/oauth/profile`;try{return(await f.get(t,{headers:{Authorization:`Bearer ${e}`,"Content-Type":`application/json`},timeout:1e4})).data}catch(e){T(e)}}var Sn=e((()=>{p(),O(),G(),We(),$e()}));function Cn(e){return!!e?.includes(at)}function wn(e){return e?.split(` `).filter(Boolean)??[]}function Tn({codeChallenge:e,state:t,port:n,isManual:r,loginWithClaudeAi:i,inferenceOnly:a,orgUUID:o,loginHint:s,loginMethod:c}){let ee=i?D().CLAUDE_AI_AUTHORIZE_URL:D().CONSOLE_AUTHORIZE_URL,l=new URL(ee);l.searchParams.append(`code`,`true`),l.searchParams.append(`client_id`,D().CLIENT_ID),l.searchParams.append(`response_type`,`code`),l.searchParams.append(`redirect_uri`,r?D().MANUAL_REDIRECT_URL:`http://localhost:${n}/callback`);let u=a?[at]:ct;return l.searchParams.append(`scope`,u.join(` `)),l.searchParams.append(`code_challenge`,e),l.searchParams.append(`code_challenge_method`,`S256`),l.searchParams.append(`state`,t),o&&l.searchParams.append(`orgUUID`,o),s&&l.searchParams.append(`login_hint`,s),c&&l.searchParams.append(`login_method`,c),l.toString()}async function En(e,t,n,r,i=!1,a){let o={grant_type:`authorization_code`,code:e,redirect_uri:i?D().MANUAL_REDIRECT_URL:`http://localhost:${r}/callback`,client_id:D().CLIENT_ID,code_verifier:n,state:t};a!==void 0&&(o.expires_in=a);let s=await f.post(D().TOKEN_URL,o,{headers:{"Content-Type":`application/json`},timeout:15e3});if(s.status!==200)throw Error(s.status===401?`Authentication failed: Invalid authorization code`:`Token exchange failed (${s.status}): ${s.statusText}`);return E(`tengu_oauth_token_exchange_success`,{}),s.data}async function Dn(e,{scopes:t}={}){let n={grant_type:`refresh_token`,refresh_token:e,client_id:D().CLIENT_ID,scope:(t?.length?t:ot).join(` `)};try{let t=await f.post(D().TOKEN_URL,n,{headers:{"Content-Type":`application/json`},timeout:15e3});if(t.status!==200)throw Error(`Token refresh failed: ${t.statusText}`);let r=t.data,{access_token:i,refresh_token:a=e,expires_in:o}=r,s=Date.now()+o*1e3,c=wn(r.scope);E(`tengu_oauth_token_refresh_success`,{});let ee=S(),l=W(),u=ee.oauthAccount?.billingType!==void 0&&ee.oauthAccount?.accountCreatedAt!==void 0&&ee.oauthAccount?.subscriptionCreatedAt!==void 0&&l?.subscriptionType!=null&&l?.rateLimitTier!=null?null:await jn(i);if(u&&ee.oauthAccount){let e={};u.displayName!==void 0&&(e.displayName=u.displayName),typeof u.hasExtraUsageEnabled==`boolean`&&(e.hasExtraUsageEnabled=u.hasExtraUsageEnabled),u.billingType!==null&&(e.billingType=u.billingType),u.accountCreatedAt!==void 0&&(e.accountCreatedAt=u.accountCreatedAt),u.subscriptionCreatedAt!==void 0&&(e.subscriptionCreatedAt=u.subscriptionCreatedAt),Object.keys(e).length>0&&w(t=>({...t,oauthAccount:t.oauthAccount?{...t.oauthAccount,...e}:t.oauthAccount}))}return{accessToken:i,refreshToken:a,expiresAt:s,scopes:c,subscriptionType:u?.subscriptionType??l?.subscriptionType??null,rateLimitTier:u?.rateLimitTier??l?.rateLimitTier??null,profile:u?.rawProfile,tokenAccount:r.account?{uuid:r.account.uuid,emailAddress:r.account.email_address,organizationUuid:r.organization?.uuid}:void 0}}catch(e){let t=f.isAxiosError(e)&&e.response?.data?JSON.stringify(e.response.data):void 0;throw E(`tengu_oauth_token_refresh_failure`,{error:e.message,...t&&{responseBody:t}}),e}}async function On(e){let t=await f.get(D().ROLES_URL,{headers:{Authorization:`Bearer ${e}`}});if(t.status!==200)throw Error(`Failed to fetch user roles: ${t.statusText}`);let n=t.data;if(!S().oauthAccount)throw Error(`OAuth account information not found in config`);w(e=>({...e,oauthAccount:e.oauthAccount?{...e.oauthAccount,organizationRole:n.organization_role,workspaceRole:n.workspace_role,organizationName:n.organization_name}:e.oauthAccount})),E(`tengu_oauth_roles_stored`,{org_role:n.organization_role})}async function kn(e){try{let t=await f.post(D().API_KEY_URL,null,{headers:{Authorization:`Bearer ${e}`}}),n=t.data?.raw_key;return n?(await Oa(n),E(`tengu_oauth_api_key`,{status:`success`,statusCode:t.status}),n):null}catch(e){throw E(`tengu_oauth_api_key`,{status:`failure`,error:e instanceof Error?e.message:String(e)}),e}}function An(e){return e!==null&&Date.now()+300*1e3>=e}async function jn(e){let t=await xn(e),n=t?.organization?.organization_type,r=null;switch(n){case`claude_max`:r=`max`;break;case`claude_pro`:r=`pro`;break;case`claude_enterprise`:r=`enterprise`;break;case`claude_team`:r=`team`;break;default:r=null;break}let i={subscriptionType:r,rateLimitTier:t?.organization?.rate_limit_tier??null,hasExtraUsageEnabled:t?.organization?.has_extra_usage_enabled??null,billingType:t?.organization?.billing_type??null};return t?.account?.display_name&&(i.displayName=t.account.display_name),t?.account?.created_at&&(i.accountCreatedAt=t.account.created_at),t?.organization?.subscription_created_at&&(i.subscriptionCreatedAt=t.organization.subscription_created_at),E(`tengu_oauth_profile_fetch_success`,{}),{...i,rawProfile:t}}async function Mn(){let e=S().oauthAccount?.organizationUuid;if(e)return e;let t=W()?.accessToken;return t===void 0||!Ba()?null:(await xn(t))?.organization?.uuid||null}async function Nn(){let e=process.env.CLAUDE_CODE_ACCOUNT_UUID,t=process.env.CLAUDE_CODE_USER_EMAIL,n=process.env.CLAUDE_CODE_ORGANIZATION_UUID,r=!!(e&&t&&n);e&&t&&n&&(S().oauthAccount||Pn({accountUuid:e,emailAddress:t,organizationUuid:n})),await Ra();let i=S();if(i.oauthAccount&&i.oauthAccount.billingType!==void 0&&i.oauthAccount.accountCreatedAt!==void 0&&i.oauthAccount.subscriptionCreatedAt!==void 0||!R()||!Ba())return!1;let a=W();if(a?.accessToken){let e=await xn(a.accessToken);if(e)return r&&_(`OAuth profile fetch succeeded, overriding env var account info`,{level:`info`}),Pn({accountUuid:e.account.uuid,emailAddress:e.account.email,organizationUuid:e.organization.uuid,displayName:e.account.display_name||void 0,hasExtraUsageEnabled:e.organization.has_extra_usage_enabled??!1,billingType:e.organization.billing_type??void 0,accountCreatedAt:e.account.created_at,subscriptionCreatedAt:e.organization.subscription_created_at??void 0}),!0}return!1}function Pn({accountUuid:e,emailAddress:t,organizationUuid:n,displayName:r,hasExtraUsageEnabled:i,billingType:a,accountCreatedAt:o,subscriptionCreatedAt:s}){let c={accountUuid:e,emailAddress:t,organizationUuid:n,hasExtraUsageEnabled:i,billingType:a,accountCreatedAt:o,subscriptionCreatedAt:s};r&&(c.displayName=r),w(e=>e.oauthAccount?.accountUuid===c.accountUuid&&e.oauthAccount?.emailAddress===c.emailAddress&&e.oauthAccount?.organizationUuid===c.organizationUuid&&e.oauthAccount?.displayName===c.displayName&&e.oauthAccount?.hasExtraUsageEnabled===c.hasExtraUsageEnabled&&e.oauthAccount?.billingType===c.billingType&&e.oauthAccount?.accountCreatedAt===c.accountCreatedAt&&e.oauthAccount?.subscriptionCreatedAt===c.subscriptionCreatedAt?e:{...e,oauthAccount:c})}var Fn=e((()=>{p(),it(),O(),G(),We(),v(),Sn()}));function In(e,t,n){if(s(process.env.CLAUDE_CODE_REMOTE))try{yt(Vn,{recursive:!0,mode:448}),xt(e,t,{encoding:`utf8`,mode:384}),_(`Persisted ${n} to ${e} for subprocess access`)}catch(e){_(`Failed to persist ${n} to disk (non-fatal): ${g(e)}`,{level:`error`})}}function Ln(e,t){try{let n=Le().readFileSync(e,{encoding:`utf8`}).trim();return n?(_(`Read ${t} from well-known file ${e}`),n):null}catch(n){return Ee(n)||_(`Failed to read ${t} from ${e}: ${g(n)}`,{level:`debug`}),null}}function Rn({envVar:e,wellKnownPath:t,label:n,getCached:r,setCached:i}){let a=r();if(a!==void 0)return a;let o=process.env[e];if(!o){let e=Ln(t,n);return i(e),e}let s=parseInt(o,10);if(Number.isNaN(s))return _(`${e} must be a valid file descriptor number, got: ${o}`,{level:`error`}),i(null),null;try{let e=Le(),r=process.platform===`darwin`||process.platform===`freebsd`?`/dev/fd/${s}`:`/proc/self/fd/${s}`,a=e.readFileSync(r,{encoding:`utf8`}).trim();return a?(_(`Successfully read ${n} from file descriptor ${s}`),i(a),In(t,a,n),a):(_(`File descriptor contained empty ${n}`,{level:`error`}),i(null),null)}catch(e){_(`Failed to read ${n} from file descriptor ${s}: ${g(e)}`,{level:`error`});let r=Ln(t,n);return i(r),r}}function zn(){return Rn({envVar:`CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR`,wellKnownPath:Hn,label:`OAuth token`,getCached:me,setCached:he})}function Bn(){return Rn({envVar:`CLAUDE_CODE_API_KEY_FILE_DESCRIPTOR`,wellKnownPath:Un,label:`API key`,getCached:Te,setCached:Se})}var Vn,Hn,Un,Wn,Gn=e((()=>{h(),v(),c(),Ae(),Pe(),Vn=`/home/claude/.workmate/remote`,Hn=`${Vn}/.oauth_token`,Un=`${Vn}/.api_key`,Wn=`${Vn}/.session_ingress_token`}));function M(e=``){let t=o(),n=process.env.WORKMATE_CONFIG_DIR?`-${St(`sha256`).update(t).digest(`hex`).substring(0,8)}`:``;return`Claude Code${D().OAUTH_FILE_SUFFIX}${e}${n}`}function Kn(){try{return process.env.USER||gt().username}catch{return`claude-code-user`}}function N(){P.cache={data:null,cachedAt:0},P.generation++,P.readInFlight=null}function qn(e){if(P.cache.cachedAt!==0)return;let t=null;if(e)try{t=JSON.parse(e)}catch{return}P.cache={data:t,cachedAt:Date.now()}}var Jn,P,Yn=e((()=>{O(),c(),Jn=`-credentials`,P={cache:{data:null,cachedAt:0},generation:0,readInFlight:null}}));async function Xn(){if(process.platform===`darwin`&&(await Ge(`security delete-generic-password -a $USER -s "${M()}"`,{shell:!0,reject:!1})).exitCode!==0)throw Error(`Failed to delete keychain entry`)}function Zn(e){return e.slice(-20)}var Qn=e((()=>{Ye(),Yn()}));function $n(e){return e?.name===`CredentialsProviderError`}function er(e){if(!e||typeof e!=`object`)return!1;let t=e;if(!t.Credentials||typeof t.Credentials!=`object`)return!1;let n=t.Credentials;return typeof n.AccessKeyId==`string`&&typeof n.SecretAccessKey==`string`&&typeof n.SessionToken==`string`&&n.AccessKeyId.length>0&&n.SecretAccessKey.length>0&&n.SessionToken.length>0}async function tr(){let{STSClient:e,GetCallerIdentityCommand:t}=await import(`./dist-es-C-OjW2Ao.js`);await new e().send(new t({}))}async function nr(){try{_(`Clearing AWS credential provider cache`);let{fromIni:e}=await import(`./dist-es-CIULjvtA2.js`);await e({ignoreCache:!0})(),_(`AWS credential provider cache refreshed`)}catch{_(`Failed to clear AWS credential cache (this is expected if no credentials are configured)`)}}var rr=e((()=>{v()})),ir,ar=e((()=>{xe(),te(),ir=class e{constructor(){d(this,`status`,{isAuthenticating:!1,output:[]}),d(this,`changed`,ye()),d(this,`subscribe`,this.changed.subscribe)}static getInstance(){return e.instance||(e.instance=new e),e.instance}getStatus(){return{...this.status,output:[...this.status.output]}}startAuthentication(){this.status={isAuthenticating:!0,output:[]},this.changed.emit(this.getStatus())}addOutput(e){this.status.output.push(e),this.changed.emit(this.getStatus())}setError(e){this.status.error=e,this.changed.emit(this.getStatus())}endAuthentication(e){e?this.status={isAuthenticating:!1,output:[]}:this.status.isAuthenticating=!1,this.changed.emit(this.getStatus())}static reset(){e.instance&&(e.instance.changed.clear(),e.instance=null)}},d(ir,`instance`,null)})),or,sr,cr,lr,ur,dr,fr,pr,mr,hr,gr,_r,vr,yr=e((()=>{or=`claude-code-20250219`,sr=`interleaved-thinking-2025-05-14`,cr=`context-1m-2025-08-07`,lr=`context-management-2025-06-27`,ur=`structured-outputs-2025-12-15`,dr=`tool-search-tool-2025-10-19`,fr=`task-budgets-2026-03-13`,pr=`prompt-caching-scope-2026-01-05`,mr=`fast-mode-2026-02-01`,hr=`redact-thinking-2026-02-12`,gr=`advisor-tool-2026-03-01`,_r=new Set([sr,cr,dr]),vr=new Set([or,sr,lr])}));function br(e,t){return fe(e,t)}var xr=e((()=>{pe()}));function Sr(){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=Mt(),r=n?`, workload/${n}`:``;return`claude-cli/0.0.21 (external, ${process.env.CLAUDE_CODE_ENTRYPOINT??`cli`}${e}${t}${r})`}function Cr(){let e=[];return process.env.CLAUDE_CODE_ENTRYPOINT&&e.push(process.env.CLAUDE_CODE_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.21${e.length>0?` (${e.join(`, `)})`:``}`}function wr(){if(R()){let e=W();return e?.accessToken?{headers:{Authorization:`Bearer ${e.accessToken}`,"anthropic-beta":st}}:{headers:{},error:`No OAuth token available`}}let e=$i();return e?{headers:{"x-api-key":e}}:{headers:{},error:`No API key available`}}async function Tr(e,t){try{return await e()}catch(n){if(!f.isAxiosError(n))throw n;let r=n.response?.status;if(!(r===401||t?.also403Revoked&&r===403&&typeof n.response?.data==`string`&&n.response.data.includes(`OAuth token has been revoked`)))throw n;let i=W()?.accessToken;if(!i)throw n;return await Fa(i),await e()}}var Er=e((()=>{p(),O(),G(),Ft()}));function Dr(){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 Or({apiKey:e,maxRetries:n,model:r,fetchOverride:i,source:a}){let o=process.env.CLAUDE_CODE_CONTAINER_ID,c=process.env.CLAUDE_CODE_REMOTE_SESSION_ID,l=process.env.CLAUDE_AGENT_SDK_CLIENT_APP,te=Ar(),d={"x-app":`cli`,"User-Agent":Sr(),"X-Claude-Code-Session-Id":be(),...te,...o?{"x-claude-remote-container-id":o}:{},...c?{"x-claude-remote-session-id":c}:{},...l?{"x-client-app":l}:{},...process.env.ANTHROPIC_AUTH_NONCE?{"x-auth-nonce":process.env.ANTHROPIC_AUTH_NONCE}:{}};_(`[API:request] Creating client, ANTHROPIC_CUSTOM_HEADERS present: ${!!process.env.ANTHROPIC_CUSTOM_HEADERS}, has Authorization header: ${!!te.Authorization}`),s(process.env.CLAUDE_CODE_ADDITIONAL_PROTECTION)&&(d[`x-anthropic-additional-protection`]=`true`),_(`[API:auth] OAuth token check starting`),await Ra(),_(`[API:auth] OAuth token check complete`),R()||await kr(d,m());let f=jr(i,a),p={defaultHeaders:d,maxRetries:n,timeout:parseInt(process.env.API_TIMEOUT_MS||`600000`,10),dangerouslyAllowBrowser:!0,fetchOptions:pt({forAnthropicAPI:!0}),...f&&{fetch:f}};if(s(process.env.CLAUDE_CODE_USE_BEDROCK)){let{BedrockClient:e}=await import(`./bedrockClient-DxE_mHFI.js`),t=r===js()&&process.env.ANTHROPIC_SMALL_FAST_MODEL_AWS_REGION?process.env.ANTHROPIC_SMALL_FAST_MODEL_AWS_REGION:u(),n={...p,awsRegion:t,...s(process.env.CLAUDE_CODE_SKIP_BEDROCK_AUTH)&&{skipAuth:!0},...Fe()&&{logger:Dr()}};if(process.env.AWS_BEARER_TOKEN_BEDROCK)n.skipAuth=!0,n.defaultHeaders={...n.defaultHeaders,Authorization:`Bearer ${process.env.AWS_BEARER_TOKEN_BEDROCK}`};else if(!s(process.env.CLAUDE_CODE_SKIP_BEDROCK_AUTH)){let e=await U();e&&(n.awsAccessKey=e.accessKeyId,n.awsSecretKey=e.secretAccessKey,n.awsSessionToken=e.sessionToken)}return new e(n)}if(s(process.env.CLAUDE_CODE_USE_FOUNDRY)){let{AnthropicFoundry:e}=await import(`./foundry-sdk-BdeF2aBu.js`),t;if(!process.env.ANTHROPIC_FOUNDRY_API_KEY)if(s(process.env.CLAUDE_CODE_SKIP_FOUNDRY_AUTH))t=()=>Promise.resolve(``);else{let{DefaultAzureCredential:e,getBearerTokenProvider:n}=await import(`./esm-CGx9qY3q.js`);t=n(new e,`https://cognitiveservices.azure.com/.default`)}return new e({...p,...t&&{azureADTokenProvider:t},...Fe()&&{logger:Dr()}})}if(s(process.env.CLAUDE_CODE_USE_VERTEX)){s(process.env.CLAUDE_CODE_SKIP_VERTEX_AUTH)||await po();let[{AnthropicVertex:e},{GoogleAuth:n}]=await Promise.all([import(`./vertex-sdk-DjXcZ2J7.js`),import(`./src-CiJCsqUl.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,a=process.env.GOOGLE_APPLICATION_CREDENTIALS||process.env.google_application_credentials,o=s(process.env.CLAUDE_CODE_SKIP_VERTEX_AUTH)?{getClient:()=>({getRequestHeaders:()=>({})})}:new n({scopes:[`https://www.googleapis.com/auth/cloud-platform`],...i||a?{}:{projectId:process.env.ANTHROPIC_VERTEX_PROJECT_ID}});return new e({...p,region:ee(r),googleAuth:o,...Fe()&&{logger:Dr()}})}return new ke({apiKey:R()?null:e||$i(),authToken:R()?W()?.accessToken:void 0,...p,...Fe()&&{logger:Dr()}})}async function kr(e,t){let n=process.env.ANTHROPIC_AUTH_TOKEN||await la(t);n&&(e.Authorization=`Bearer ${n}`)}function Ar(){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 jr(e,t){let n=e??globalThis.fetch,r=k()===`firstParty`&&jt();return(e,i)=>{let a=new Headers(i?.headers);r&&!a.has(`x-client-request-id`)&&a.set(Mr,Ct());try{let n=e instanceof Request?e.url:String(e),r=a.get(Mr);_(`[API REQUEST] ${new URL(n).pathname}${r?` ${Mr}=${r}`:``} source=${t??`unknown`}`)}catch{}return n(e,{...i,headers:a})}}var Mr,Nr=e((()=>{Ne(),G(),Er(),$(),A(),ht(),h(),v(),c(),Mr=`x-client-request-id`}));function Pr(){return _t(o(),`cache`)}function Fr(){return _t(Pr(),`model-capabilities.json`)}function Ir(){return!(k()!==`firstParty`||!jt())}function Lr(e){return[...e].sort((e,t)=>t.id.length-e.id.length||e.id.localeCompare(t.id))}function Rr(e){if(!Ir())return;let t=Hr(Fr());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 zr(){if(Ir()&&!Qe())try{let e=await Or({maxRetries:1}),t=R()?[st]:void 0,n=[];for await(let r of e.models.list({betas:t})){let e=Br().safeParse(r);e.success&&n.push(e.data)}if(n.length===0)return;let r=Fr(),i=Lr(n);if(br(Hr(r),i)){_(`[modelCapabilities] cache unchanged, skipping write`);return}await wt(Pr(),{recursive:!0}),await Et(r,De({models:i,timestamp:Date.now()}),{encoding:`utf-8`,mode:384}),Hr.cache.delete(r),_(`[modelCapabilities] cached ${i.length} models`)}catch(e){_(`[modelCapabilities] fetch failed: ${e instanceof Error?e.message:`unknown`}`)}}var Br,Vr,Hr,Ur=e((()=>{xr(),i(),le(),O(),Nr(),G(),v(),c(),nt(),ue(),Ze(),Re(),A(),Br=ce(()=>ie({id:oe(),max_input_tokens:ae().optional(),max_tokens:ae().optional()}).strip()),Vr=ce(()=>ie({models:se(Br()),timestamp:ae()})),Hr=r(e=>{try{let t=bt(e,`utf-8`),n=Vr().safeParse(rt(t,!1));return n.success?n.data.models:null}catch{return null}},e=>e)}));function Wr(){return s(process.env.CLAUDE_CODE_DISABLE_1M_CONTEXT)}function F(e){return!Wr()&&/\[1m\]/i.test(e)}function Gr(e){if(Wr())return!1;let t=Z(e);return t.includes(`claude-sonnet-4`)||t.includes(`opus-4-6`)||t.includes(`opus-4-7`)}function Kr(e,t){if(F(e))return 1e6;let n=Rr(e);return n?.max_input_tokens&&n.max_input_tokens>=1e5?n.max_input_tokens>2e5&&Wr()?Zr:n.max_input_tokens:t?.includes(`context-1m-2025-08-07`)&&Gr(e)||qr(e)?1e6:Zr}function qr(e){return Wr()||F(e)||!Z(e).includes(`sonnet-4-6`)?!1:S().clientDataCache?.coral_reef_sonnet===`true`}function Jr(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 Yr(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=$r,n=ei);let i=Rr(e);return i?.max_tokens&&i.max_tokens>=4096&&(n=i.max_tokens,t=Math.min(t,n)),{default:t,upperLimit:n}}function Xr(e){return Yr(e).upperLimit-1}var Zr,Qr,$r,ei,ti,ni=e((()=>{yr(),We(),c(),$(),Ur(),Zr=2e5,Qr=2e4,$r=32e3,ei=64e3,ti=8e3})),ri,ii,ai,oi=e((()=>{i(),A(),ri=[{modelEnvVar:`ANTHROPIC_DEFAULT_OPUS_MODEL`,capabilitiesEnvVar:`ANTHROPIC_DEFAULT_OPUS_MODEL_SUPPORTED_CAPABILITIES`},{modelEnvVar:`ANTHROPIC_DEFAULT_SONNET_MODEL`,capabilitiesEnvVar:`ANTHROPIC_DEFAULT_SONNET_MODEL_SUPPORTED_CAPABILITIES`},{modelEnvVar:`ANTHROPIC_DEFAULT_HAIKU_MODEL`,capabilitiesEnvVar:`ANTHROPIC_DEFAULT_HAIKU_MODEL_SUPPORTED_CAPABILITIES`}],ii=[{modelEnvVar:`OPENAI_DEFAULT_OPUS_MODEL`,capabilitiesEnvVar:`OPENAI_DEFAULT_OPUS_MODEL_SUPPORTED_CAPABILITIES`},{modelEnvVar:`OPENAI_DEFAULT_SONNET_MODEL`,capabilitiesEnvVar:`OPENAI_DEFAULT_SONNET_MODEL_SUPPORTED_CAPABILITIES`},{modelEnvVar:`OPENAI_DEFAULT_HAIKU_MODEL`,capabilitiesEnvVar:`OPENAI_DEFAULT_HAIKU_MODEL_SUPPORTED_CAPABILITIES`}],ai=r((e,t)=>{if(k()===`firstParty`)return;let n=e.toLowerCase(),r=k()===`openai`?ii:ri;for(let e of r){let r=process.env[e.modelEnvVar],i=process.env[e.capabilitiesEnvVar];if(!(!r||i===void 0)&&n===r.toLowerCase())return i.toLowerCase().split(`,`).map(e=>e.trim()).includes(t)}},(e,t)=>`${e.toLowerCase()}:${t}`)}));function si(e){let t=[],n=[];for(let r of e)_i.includes(r)?t.push(r):n.push(r);return{allowed:t,disallowed:n}}function ci(e){if(!e||e.length===0)return;if(R()){console.warn(`Warning: Custom betas are only available for API key users. Ignoring provided betas.`);return}let{allowed:t,disallowed:n}=si(e);for(let e of n)console.warn(`Warning: Beta header '${e}' is not allowed. Only the following betas are supported: ${_i.join(`, `)}`);return t.length>0?t:void 0}function li(e){let t=ai(e,`interleaved_thinking`);if(t!==void 0)return t;let n=Z(e),r=k();return r===`foundry`?!0:r===`firstParty`?!n.includes(`claude-3-`):n.includes(`claude-opus-4`)||n.includes(`claude-sonnet-4`)}function ui(e){let t=Z(e),n=k();return n===`foundry`?!0:n===`firstParty`?!t.includes(`claude-3-`):t.includes(`claude-opus-4`)||t.includes(`claude-sonnet-4`)||t.includes(`claude-haiku-4`)}function di(e){let t=Z(e),n=k();return n!==`firstParty`&&n!==`foundry`?!1:t.includes(`claude-sonnet-4-6`)||t.includes(`claude-sonnet-4-5`)||t.includes(`claude-opus-4-1`)||t.includes(`claude-opus-4-5`)||t.includes(`claude-opus-4-6`)||t.includes(`claude-opus-4-7`)||t.includes(`claude-haiku-4-5`)}function fi(e){return!0}function pi(){return(k()===`firstParty`||k()===`foundry`)&&!s(process.env.CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS)&&jt()}function mi(){return k()===`firstParty`&&!s(process.env.CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS)}function hi(e,t){let n=[...yi(e)];t?.isAgenticQuery&&(n.includes(`claude-code-20250219`)||n.push(or));let r=we();return!r||r.length===0?n:[...n,...r.filter(e=>!n.includes(e))]}function gi(){vi.cache?.clear?.(),yi.cache?.clear?.(),bi.cache?.clear?.()}var _i,vi,yi,bi,xi=e((()=>{i(),h(),yr(),O(),G(),ni(),c(),$(),oi(),A(),b(),_i=[cr],vi=r(e=>{let t=[],n=Z(e).includes(`haiku`);k();let r=pi();n||t.push(or),R()&&t.push(st),F(e)&&t.push(cr),!s(process.env.DISABLE_INTERLEAVED_THINKING)&&li(e)&&t.push(sr),r&&li(e)&&!m()&&Ve().showThinkingSummaries!==!0&&t.push(hr);let i=s(process.env.USE_API_CONTEXT_MANAGEMENT)||ui(e),a=ui(e);return pi()&&(i||a)&&t.push(lr),r&&di(e),r&&t.push(pr),process.env.ANTHROPIC_BETAS&&t.push(...process.env.ANTHROPIC_BETAS.split(`,`).map(e=>e.trim()).filter(Boolean)),t}),yi=r(e=>{let t=vi(e);return k()===`bedrock`?t.filter(e=>!_r.has(e)):t}),bi=r(e=>vi(e).filter(e=>_r.has(e)))}));function Si(e,t){return{name:`${e.name}-with-${t.name}-fallback`,read(){return e.read()??(t.read()||{})},async readAsync(){return await e.readAsync()??(await t.readAsync()||{})},update(n){let r=e.read(),i=e.update(n);if(i.success)return r===null&&t.delete(),i;let a=t.update(n);return a.success?(r!==null&&e.delete(),{success:!0,warning:a.warning}):{success:!1}},delete(){let n=e.delete(),r=t.delete();return n||r}}}var Ci=e((()=>{}));async function wi(){try{let e=M(Jn),{stdout:t,code:n}=await Xe(`security`,[`find-generic-password`,`-a`,Kn(),`-w`,`-s`,e],{useCwd:!1,preserveOutputOnError:!1});if(n===0&&t)return je(t.trim())}catch{}return null}function Ti(){if(Oi!==void 0)return Oi;if(process.platform!==`darwin`)return Oi=!1,!1;try{Oi=qe(`security`,[`show-keychain-info`],{reject:!1,stdio:[`ignore`,`pipe`,`pipe`]}).exitCode===36}catch{Oi=!1}return Oi}var Ei,Di,Oi,ki=e((()=>{Ye(),v(),Ke(),Re(),Yn(),Ei=4032,Di={name:`keychain`,read(){let e=P.cache;if(Date.now()-e.cachedAt<3e4)return e.data;try{let e=M(Jn),t=Je(`security find-generic-password -a "${Kn()}" -w -s "${e}"`);if(t){let e=je(t);return P.cache={data:e,cachedAt:Date.now()},e}}catch{}return e.data===null?(P.cache={data:null,cachedAt:Date.now()},null):(_(`[keychain] read failed; serving stale cache`,{level:`warn`}),P.cache={data:e.data,cachedAt:Date.now()},e.data)},async readAsync(){let e=P.cache;if(Date.now()-e.cachedAt<3e4)return e.data;if(P.readInFlight)return P.readInFlight;let t=P.generation,n=wi().then(n=>{if(t===P.generation){n===null&&e.data!==null&&_(`[keychain] readAsync failed; serving stale cache`,{level:`warn`});let t=n??e.data;return P.cache={data:t,cachedAt:Date.now()},P.readInFlight=null,t}return n});return P.readInFlight=n,n},update(e){N();try{let t=M(Jn),n=Kn(),r=De(e),i=Buffer.from(r,`utf-8`).toString(`hex`),a=`add-generic-password -U -a "${n}" -s "${t}" -X "${i}"\n`,o;return a.length<=Ei?o=qe(`security`,[`-i`],{input:a,stdio:[`pipe`,`pipe`,`pipe`],reject:!1}):(_(`Keychain payload (${r.length}B JSON) exceeds security -i stdin limit; using argv`,{level:`warn`}),o=qe(`security`,[`add-generic-password`,`-U`,`-a`,n,`-s`,t,`-X`,i],{stdio:[`ignore`,`pipe`,`pipe`],reject:!1})),o.exitCode===0?(P.cache={data:e,cachedAt:Date.now()},{success:!0}):{success:!1}}catch{return{success:!1}}},delete(){N();try{let e=M(Jn);return Je(`security delete-generic-password -a "${Kn()}" -s "${e}"`),!0}catch{return!1}}}}));function Ai(){let e=o();return{storageDir:e,storagePath:_t(e,`.credentials.json`)}}var ji,Mi=e((()=>{c(),Ae(),Pe(),Re(),ji={name:`plaintext`,read(){let{storagePath:e}=Ai();try{return je(Le().readFileSync(e,{encoding:`utf8`}))}catch{return null}},async readAsync(){let{storagePath:e}=Ai();try{return je(await Le().readFile(e,{encoding:`utf8`}))}catch{return null}},update(e){try{let{storageDir:t,storagePath:n}=Ai();try{Le().mkdirSync(t)}catch(e){if(Oe(e)!==`EEXIST`)throw e}return Me(n,De(e),{encoding:`utf8`,flush:!1}),vt(n,384),{success:!0,warning:`Warning: Storing credentials in plaintext.`}}catch{return{success:!1}}},delete(){let{storagePath:e}=Ai();try{return Le().unlinkSync(e),!0}catch(e){return Oe(e)===`ENOENT`}}}}));function Ni(){return process.platform===`darwin`?Si(Di,ji):ji}var Pi=e((()=>{Ci(),ki(),Mi()}));function Fi(e){return new Promise(t=>{Ot(`security`,[`find-generic-password`,`-a`,Kn(),`-w`,`-s`,e],{encoding:`utf-8`,timeout:Bi},(e,n)=>{t({stdout:e?null:n?.trim()||null,timedOut:!!(e&&`killed`in e&&e.killed)})})})}function Ii(){if(process.platform!==`darwin`||Hi||l())return;let e=Fi(M(Jn)),t=Fi(M());Hi=Promise.all([e,t]).then(([e,t])=>{e.timedOut||qn(e.stdout),t.timedOut||(Vi={stdout:t.stdout})})}async function Li(){Hi&&await Hi}function Ri(){return Vi}function zi(){Vi=null}var Bi,Vi,Hi,Ui=e((()=>{c(),Yn(),Bi=1e4,Vi=null,Hi=null}));function Wi(e,t,n){return new Promise((r,i)=>{if(t?.aborted){n?.throwOnAbort||n?.abortError?i(n.abortError?.()??Error(`aborted`)):r();return}let a=setTimeout((e,t,n)=>{e?.removeEventListener(`abort`,t),n()},e,t,o,r);function o(){clearTimeout(a),n?.throwOnAbort||n?.abortError?i(n.abortError?.()??Error(`aborted`)):r()}t?.addEventListener(`abort`,o,{once:!0}),n?.unref&&a.unref()})}var Gi=e((()=>{}));function Ki(){return Ji}function qi(){Ji.clear()}var Ji,Yi=e((()=>{Ji=new Map})),Xi=n({calculateApiKeyHelperTTL:()=>sa,checkAndRefreshOAuthTokenIfNeeded:()=>Ra,checkGcpCredentialsValid:()=>xa,clearApiKeyHelperCache:()=>pa,clearAwsCredentialsCache:()=>va,clearGcpCredentialsCache:()=>wa,clearOAuthTokenCache:()=>Na,getAccountInformation:()=>io,getAnthropicApiKey:()=>$i,getAnthropicApiKeyWithSource:()=>ta,getApiKeyFromApiKeyHelper:()=>la,getApiKeyFromApiKeyHelperCached:()=>fa,getApiKeyFromConfigOrMacOSKeychain:()=>mo,getApiKeyHelperElapsedMs:()=>ca,getAuthTokenSource:()=>Qi,getClaudeAIOAuthTokens:()=>W,getClaudeAIOAuthTokensAsync:()=>La,getConfiguredApiKeyHelper:()=>L,getOauthAccountInfo:()=>Ha,getOtelHeadersFromHelper:()=>to,getRateLimitTier:()=>Xa,getSubscriptionName:()=>Za,getSubscriptionType:()=>z,handleOAuth401Error:()=>Fa,hasAnthropicApiKeyAuth:()=>ea,hasOpusAccess:()=>Wa,hasProfileScope:()=>Ba,is1PApiCustomer:()=>Va,isAnthropicAuthEnabled:()=>I,isAwsAuthRefreshFromProjectSettings:()=>ia,isAwsCredentialExportFromProjectSettings:()=>oa,isClaudeAISubscriber:()=>R,isConsumerSubscriber:()=>ro,isCustomApiKeyApproved:()=>ka,isEnterpriseSubscriber:()=>Ja,isGcpAuthRefreshFromProjectSettings:()=>ba,isMaxSubscriber:()=>Ga,isOtelHeadersHelperFromProjectOrLocalSettings:()=>eo,isOverageProvisioningAllowed:()=>Ua,isProSubscriber:()=>Ya,isTeamPremiumSubscriber:()=>qa,isTeamSubscriber:()=>Ka,isUsing3PServices:()=>Qa,prefetchApiKeyFromApiKeyHelperIfSafe:()=>ma,prefetchAwsCredentialsAndBedRockInfoIfSafe:()=>Ea,prefetchGcpCredentialsIfSafe:()=>Ta,refreshAndGetAwsCredentials:()=>U,refreshAwsAuth:()=>ga,refreshGcpAuth:()=>Ca,refreshGcpCredentialsIfNeeded:()=>po,removeApiKey:()=>Aa,saveApiKey:()=>Oa,saveOAuthTokensIfNeeded:()=>Ma,validateForceLoginOrg:()=>ao});function Zi(){return s(process.env.CLAUDE_CODE_REMOTE)||process.env.CLAUDE_CODE_ENTRYPOINT===`claude-desktop`}function I(){if(l())return!1;if(process.env.ANTHROPIC_UNIX_SOCKET)return!!process.env.CLAUDE_CODE_OAUTH_TOKEN;let e=y()||{},t=s(process.env.CLAUDE_CODE_USE_BEDROCK)||s(process.env.CLAUDE_CODE_USE_VERTEX)||s(process.env.CLAUDE_CODE_USE_FOUNDRY)||e.modelType===`openai`||e.modelType===`gemini`||!!process.env.OPENAI_BASE_URL||!!process.env.GEMINI_BASE_URL,n=e.apiKeyHelper,r=process.env.ANTHROPIC_AUTH_TOKEN||n||process.env.CLAUDE_CODE_API_KEY_FILE_DESCRIPTOR,{source:i}=ta({skipRetrievingKeyFromApiKeyHelper:!0}),a=i===`ANTHROPIC_API_KEY`||i===`apiKeyHelper`;return!(t||r&&!Zi()||a&&!Zi())}function Qi(){if(l())return L()?{source:`apiKeyHelper`,hasToken:!0}:{source:`none`,hasToken:!1};if(process.env.ANTHROPIC_AUTH_TOKEN&&!Zi())return{source:`ANTHROPIC_AUTH_TOKEN`,hasToken:!0};if(process.env.CLAUDE_CODE_OAUTH_TOKEN)return{source:`CLAUDE_CODE_OAUTH_TOKEN`,hasToken:!0};if(zn())return process.env.CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR?{source:`CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR`,hasToken:!0}:{source:`CCR_OAUTH_TOKEN_FILE`,hasToken:!0};if(L()&&!Zi())return{source:`apiKeyHelper`,hasToken:!0};let e=W();return Cn(e?.scopes)&&e?.accessToken?{source:`claude.ai`,hasToken:!0}:{source:`none`,hasToken:!1}}function $i(){let{key:e}=ta();return e}function ea(){let{key:e,source:t}=ta({skipRetrievingKeyFromApiKeyHelper:!0});return e!==null&&t!==`none`}function ta(e={}){if(l())return process.env.ANTHROPIC_API_KEY?{key:process.env.ANTHROPIC_API_KEY,source:`ANTHROPIC_API_KEY`}:L()?{key:e.skipRetrievingKeyFromApiKeyHelper?null:fa(),source:`apiKeyHelper`}:{key:null,source:`none`};let t=a()?void 0:process.env.ANTHROPIC_API_KEY;if(_e()&&t)return{key:t,source:`ANTHROPIC_API_KEY`};if(s(process.env.CI)){let e=Bn();if(e)return{key:e,source:`ANTHROPIC_API_KEY`};if(!t&&!process.env.CLAUDE_CODE_OAUTH_TOKEN&&!process.env.CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR)throw Error(`ANTHROPIC_API_KEY or CLAUDE_CODE_OAUTH_TOKEN env var is required`);return t?{key:t,source:`ANTHROPIC_API_KEY`}:{key:null,source:`none`}}if(t&&S().customApiKeyResponses?.approved?.includes(Zn(t)))return{key:t,source:`ANTHROPIC_API_KEY`};let n=Bn();return n?{key:n,source:`ANTHROPIC_API_KEY`}:L()?e.skipRetrievingKeyFromApiKeyHelper?{key:null,source:`apiKeyHelper`}:{key:fa(),source:`apiKeyHelper`}:mo()||{key:null,source:`none`}}function L(){return l()?x(`flagSettings`)?.apiKeyHelper:(y()||{}).apiKeyHelper}function na(){let e=L();if(!e)return!1;let t=x(`projectSettings`),n=x(`localSettings`);return t?.apiKeyHelper===e||n?.apiKeyHelper===e}function ra(){return(y()||{}).awsAuthRefresh}function ia(){let e=ra();if(!e)return!1;let t=x(`projectSettings`),n=x(`localSettings`);return t?.awsAuthRefresh===e||n?.awsAuthRefresh===e}function aa(){return(y()||{}).awsCredentialExport}function oa(){let e=aa();if(!e)return!1;let t=x(`projectSettings`),n=x(`localSettings`);return t?.awsCredentialExport===e||n?.awsCredentialExport===e}function sa(){let e=process.env.CLAUDE_CODE_API_KEY_HELPER_TTL_MS;if(e){let t=parseInt(e,10);if(!Number.isNaN(t)&&t>=0)return t;_(`Found CLAUDE_CODE_API_KEY_HELPER_TTL_MS env var, but it was not a valid number. Got ${e}`,{level:`error`})}return oo}function ca(){let e=V?.startedAt;return e?Date.now()-e:0}async function la(e){if(!L())return null;let t=sa();return B?(Date.now()-B.timestamp<t||V||(V={promise:ua(e,!1,H),startedAt:null}),B.value):(V||(V={promise:ua(e,!0,H),startedAt:Date.now()}),V.promise)}async function ua(e,t,n){try{let t=await da(e);return n===H&&t!==null&&(B={value:t,timestamp:Date.now()}),t}catch(e){if(n!==H)return` `;let r=e instanceof Error?e.message:String(e);return console.error(ne.red(`apiKeyHelper failed: ${r}`)),_(`Error getting API key from apiKeyHelper: ${r}`,{level:`error`}),!t&&B&&B.value!==` `?(B={...B,timestamp:Date.now()},B.value):(B={value:` `,timestamp:Date.now()},` `)}finally{n===H&&(V=null)}}async function da(e){let t=L();if(!t)return null;if(na()&&!C()&&!e)return Ie(`apiKeyHelper invoked before trust check`,Error(`Security: apiKeyHelper executed before workspace trust is confirmed. If you see this message, post in .`)),E(`tengu_apiKeyHelper_missing_trust11`,{}),null;let n=await Ge(t,{shell:!0,timeout:600*1e3,reject:!1});if(n.failed){let e=n.timedOut?`timed out`:`exited ${n.exitCode}`,t=n.stderr?.trim();throw Error(t?`${e}: ${t}`:e)}let r=n.stdout?.trim();if(!r)throw Error(`did not return a value`);return r}function fa(){return B?.value??null}function pa(){H++,B=null,V=null}function ma(e){na()&&!C()||la(e)}async function ha(){let e=ra();if(!e)return!1;if(ia()&&!C()&&!m())return Ie(`awsAuthRefresh invoked before trust check`,Error(`Security: awsAuthRefresh executed before workspace trust is confirmed. If you see this message, post in .`)),E(`tengu_awsAuthRefresh_missing_trust`,{}),!1;try{return _(`Fetching AWS caller identity for AWS auth refresh command`),await tr(),_(`Fetched AWS caller identity, skipping AWS auth refresh command`),!1}catch{return ga(e)}}function ga(e){_(`Running AWS auth refresh command`);let t=ir.getInstance();return t.startAuthentication(),new Promise(n=>{let r=Dt(e,{timeout:co});r.stdout.on(`data`,e=>{let n=e.toString().trim();n&&(t.addOutput(n),_(n,{level:`debug`}))}),r.stderr.on(`data`,e=>{let n=e.toString().trim();n&&(t.setError(n),_(n,{level:`error`}))}),r.on(`close`,(e,r)=>{if(e===0)_(`AWS auth refresh completed successfully`),t.endAuthentication(!0),n(!0);else{let e=r===`SIGTERM`?ne.red(`AWS auth refresh timed out after 3 minutes. Run your auth command manually in a separate terminal.`):ne.red(`Error running awsAuthRefresh (in settings or ~/.workmate.json):`);console.error(e),t.endAuthentication(!1),n(!1)}})})}async function _a(){let e=aa();if(!e)return null;if(oa()&&!C()&&!m())return Ie(`awsCredentialExport invoked before trust check`,Error(`Security: awsCredentialExport executed before workspace trust is confirmed. If you see this message, post in .`)),E(`tengu_awsCredentialExport_missing_trust`,{}),null;try{return _(`Fetching AWS caller identity for credential export command`),await tr(),_(`Fetched AWS caller identity, skipping AWS credential export command`),null}catch{try{_(`Running AWS credential export command`);let t=await Ge(e,{shell:!0,reject:!1});if(t.exitCode!==0||!t.stdout)throw Error(`awsCredentialExport did not return a valid value`);let n=je(t.stdout.trim());if(!er(n))throw Error(`awsCredentialExport did not return valid AWS STS output structure`);return _(`AWS credentials retrieved from awsCredentialExport`),{accessKeyId:n.Credentials.AccessKeyId,secretAccessKey:n.Credentials.SecretAccessKey,sessionToken:n.Credentials.SessionToken}}catch(e){let t=ne.red(`Error getting AWS credentials from awsCredentialExport (in settings or ~/.workmate.json):`);return e instanceof Error?console.error(t,e.message):console.error(t,e),null}}}function va(){U.cache.clear()}function ya(){return(y()||{}).gcpAuthRefresh}function ba(){let e=ya();if(!e)return!1;let t=x(`projectSettings`),n=x(`localSettings`);return t?.gcpAuthRefresh===e||n?.gcpAuthRefresh===e}async function xa(){try{let{GoogleAuth:e}=await import(`./src-CiJCsqUl.js`).then(e=>t(e.default,1)),n=new e({scopes:[`https://www.googleapis.com/auth/cloud-platform`]}),r=(async()=>{await(await n.getClient()).getAccessToken()})(),i=Wi(lo).then(()=>{throw new xo(`GCP credentials check timed out`)});return await Promise.race([r,i]),!0}catch{return!1}}async function Sa(){let e=ya();if(!e)return!1;if(ba()&&!C()&&!m())return Ie(`gcpAuthRefresh invoked before trust check`,Error(`Security: gcpAuthRefresh executed before workspace trust is confirmed. If you see this message, post in .`)),E(`tengu_gcpAuthRefresh_missing_trust`,{}),!1;try{if(_(`Checking GCP credentials validity for auth refresh`),await xa())return _(`GCP credentials are valid, skipping auth refresh command`),!1}catch{}return Ca(e)}function Ca(e){_(`Running GCP auth refresh command`);let t=ir.getInstance();return t.startAuthentication(),new Promise(n=>{let r=Dt(e,{timeout:fo});r.stdout.on(`data`,e=>{let n=e.toString().trim();n&&(t.addOutput(n),_(n,{level:`debug`}))}),r.stderr.on(`data`,e=>{let n=e.toString().trim();n&&(t.setError(n),_(n,{level:`error`}))}),r.on(`close`,(e,r)=>{if(e===0)_(`GCP auth refresh completed successfully`),t.endAuthentication(!0),n(!0);else{let e=r===`SIGTERM`?ne.red(`GCP auth refresh timed out after 3 minutes. Run your auth command manually in a separate terminal.`):ne.red(`Error running gcpAuthRefresh (in settings or ~/.workmate.json):`);console.error(e),t.endAuthentication(!1),n(!1)}})})}function wa(){po.cache.clear()}function Ta(){ya()&&(ba()&&!C()&&!m()||po())}function Ea(){let e=ra(),t=aa();!e&&!t||(ia()||oa())&&!C()&&!m()||(U(),j())}function Da(e){return/^[a-zA-Z0-9-_]+$/.test(e)}async function Oa(e){if(!Da(e))throw Error(`Invalid API key format. API key must contain only alphanumeric characters, dashes, and underscores.`);await ja();let t=!1;if(process.platform===`darwin`)try{let n=M();await Ge(`security`,[`-i`],{input:`add-generic-password -U -a "${Kn()}" -s "${n}" -X "${Buffer.from(e,`utf-8`).toString(`hex`)}"\n`,reject:!1}),E(`tengu_api_key_saved_to_keychain`,{}),t=!0}catch(e){T(e),E(`tengu_api_key_keychain_error`,{error:g(e)}),E(`tengu_api_key_saved_to_config`,{})}else E(`tengu_api_key_saved_to_config`,{});let n=Zn(e);w(r=>{let i=r.customApiKeyResponses?.approved??[];return{...r,primaryApiKey:t?r.primaryApiKey:e,customApiKeyResponses:{...r.customApiKeyResponses,approved:i.includes(n)?i:[...i,n],rejected:r.customApiKeyResponses?.rejected??[]}}}),mo.cache.clear?.(),zi()}function ka(e){let t=S(),n=Zn(e);return t.customApiKeyResponses?.approved?.includes(n)??!1}async function Aa(){await ja(),w(e=>({...e,primaryApiKey:void 0})),mo.cache.clear?.(),zi()}async function ja(){try{await Xn()}catch(e){T(e)}}function Ma(e){if(!Cn(e.scopes))return E(`tengu_oauth_tokens_not_claude_ai`,{}),{success:!0};if(!e.refreshToken||!e.expiresAt)return E(`tengu_oauth_tokens_inference_only`,{}),{success:!0};let t=Ni(),n=t.name;try{let r=t.read()||{},i=r.claudeAiOauth;r.claudeAiOauth={accessToken:e.accessToken,refreshToken:e.refreshToken,expiresAt:e.expiresAt,scopes:e.scopes,subscriptionType:e.subscriptionType??i?.subscriptionType??null,rateLimitTier:e.rateLimitTier??i?.rateLimitTier??null};let a=t.update(r);return a.success?E(`tengu_oauth_tokens_saved`,{storageBackend:n}):E(`tengu_oauth_tokens_save_failed`,{storageBackend:n}),W.cache?.clear?.(),gi(),qi(),a}catch(e){return T(e),E(`tengu_oauth_tokens_save_exception`,{storageBackend:n,error:g(e)}),{success:!1,warning:`Failed to save OAuth tokens`}}}function Na(){W.cache?.clear?.(),N()}async function Pa(){try{let{mtimeMs:e}=await Tt(_t(o(),`.credentials.json`));e!==ho&&(ho=e,Na())}catch{W.cache?.clear?.()}}function Fa(e){let t=go.get(e);if(t)return t;let n=Ia(e).finally(()=>{go.delete(e)});return go.set(e,n),n}async function Ia(e){Na();let t=await La();return t?.refreshToken?t.accessToken===e?Ra(0,!0):(E(`tengu_oauth_401_recovered_from_keychain`,{}),!0):!1}async function La(){if(l())return null;if(process.env.CLAUDE_CODE_OAUTH_TOKEN||zn())return W();try{let e=(await Ni().readAsync())?.claudeAiOauth;return e?.accessToken?e:null}catch(e){return T(e),null}}function Ra(e=0,t=!1){return e===0&&!t?_o||(_o=za(e,t).finally(()=>{_o=null}),_o):za(e,t)}async function za(e,t){await Pa();let n=W();if(!t&&(!n?.refreshToken||!An(n.expiresAt))||!n?.refreshToken||!Cn(n.scopes))return!1;W.cache?.clear?.(),N();let r=await La();if(!r?.refreshToken||!An(r.expiresAt))return!1;let i=o();await wt(i,{recursive:!0});let a;try{E(`tengu_oauth_token_refresh_lock_acquiring`,{}),a=await He(i),E(`tengu_oauth_token_refresh_lock_acquired`,{})}catch(n){return n.code===`ELOCKED`?e<5?(E(`tengu_oauth_token_refresh_lock_retry`,{retryCount:e+1}),await Wi(1e3+Math.random()*1e3),za(e+1,t)):(E(`tengu_oauth_token_refresh_lock_retry_limit_reached`,{maxRetries:5}),!1):(T(n),E(`tengu_oauth_token_refresh_lock_error`,{error:g(n)}),!1)}try{W.cache?.clear?.(),N();let e=await La();return!e?.refreshToken||!An(e.expiresAt)?(E(`tengu_oauth_token_refresh_race_resolved`,{}),!1):(E(`tengu_oauth_token_refresh_starting`,{}),Ma(await Dn(e.refreshToken,{scopes:Cn(e.scopes)?void 0:e.scopes})),W.cache?.clear?.(),N(),!0)}catch(e){T(e),W.cache?.clear?.(),N();let t=await La();return t&&!An(t.expiresAt)?(E(`tengu_oauth_token_refresh_race_recovered`,{}),!0):!1}finally{E(`tengu_oauth_token_refresh_lock_releasing`,{}),await a(),E(`tengu_oauth_token_refresh_lock_released`,{})}}function R(){return I()?Cn(W()?.scopes):!1}function Ba(){return W()?.scopes?.includes(`user:profile`)??!1}function Va(){return!(s(process.env.CLAUDE_CODE_USE_BEDROCK)||s(process.env.CLAUDE_CODE_USE_VERTEX)||s(process.env.CLAUDE_CODE_USE_FOUNDRY)||R())}function Ha(){return I()?S().oauthAccount:void 0}function Ua(){let e=Ha()?.billingType;return!(!R()||!e||e!==`stripe_subscription`&&e!==`stripe_subscription_contracted`&&e!==`apple_subscription`&&e!==`google_play_subscription`)}function Wa(){let e=z();return e===`max`||e===`enterprise`||e===`team`||e===`pro`||e===null}function z(){if(!I())return null;let e=W();return e?e.subscriptionType??null:null}function Ga(){return z()===`max`}function Ka(){return z()===`team`}function qa(){return z()===`team`&&Xa()===`default_claude_max_5x`}function Ja(){return z()===`enterprise`}function Ya(){return z()===`pro`}function Xa(){if(!I())return null;let e=W();return e?e.rateLimitTier??null:null}function Za(){switch(z()){case`enterprise`:return`Work Mate Enterprise`;case`team`:return`Work Mate Team`;case`max`:return`Claude Max`;case`pro`:return`Claude Pro`;default:return`Work Mate API`}}function Qa(){return!!(s(process.env.CLAUDE_CODE_USE_BEDROCK)||s(process.env.CLAUDE_CODE_USE_VERTEX)||s(process.env.CLAUDE_CODE_USE_FOUNDRY)||s(process.env.CLAUDE_CODE_USE_OPENAI)||s(process.env.CLAUDE_CODE_USE_GEMINI)||s(process.env.CLAUDE_CODE_USE_GROK))}function $a(){return(y()||{}).otelHeadersHelper}function eo(){let e=$a();if(!e)return!1;let t=x(`projectSettings`),n=x(`localSettings`);return t?.otelHeadersHelper===e||n?.otelHeadersHelper===e}function to(){let e=$a();if(!e)return{};let t=parseInt(process.env.CLAUDE_CODE_OTEL_HEADERS_HELPER_DEBOUNCE_MS||bo.toString(),10);if(vo&&Date.now()-yo<t)return vo;if(eo()&&!C())return{};try{let t=Je(e,{timeout:3e4})?.toString().trim();if(!t)throw Error(`otelHeadersHelper did not return a valid value`);let n=je(t);if(typeof n!=`object`||!n||Array.isArray(n))throw Error(`otelHeadersHelper must return a JSON object with string key-value pairs`);for(let[e,t]of Object.entries(n))if(typeof t!=`string`)throw Error(`otelHeadersHelper returned non-string value for key "${e}": ${typeof t}`);return vo=n,yo=Date.now(),vo}catch(e){throw T(Error(`Error getting OpenTelemetry headers from otelHeadersHelper (in settings): ${g(e)}`)),e}}function no(e){return e===`max`||e===`pro`}function ro(){let e=z();return R()&&e!==null&&no(e)}function io(){if(k()!==`firstParty`)return;let{source:e}=Qi(),t={};e===`CLAUDE_CODE_OAUTH_TOKEN`||e===`CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR`?t.tokenSource=e:R()?t.subscription=Za():t.tokenSource=e;let{key:n,source:r}=ta();if(n&&(t.apiKeySource=r),e===`claude.ai`||r===`/login managed key`){let e=Ha()?.organizationName;e&&(t.organization=e)}let i=Ha()?.emailAddress;return(e===`claude.ai`||r===`/login managed key`)&&i&&(t.email=i),t}async function ao(){if(process.env.ANTHROPIC_UNIX_SOCKET||!I())return{valid:!0};let e=x(`policySettings`)?.forceLoginOrgUUID;if(!e)return{valid:!0};await Ra();let t=W();if(!t)return{valid:!0};let{source:n}=Qi(),r=n===`CLAUDE_CODE_OAUTH_TOKEN`||n===`CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR`,i=await xn(t.accessToken);if(!i)return{valid:!1,message:`Unable to verify organization for the current authentication token.\nThis machine requires organization ${e} but the profile could not be fetched.\nThis may be a network error, or the token may lack the user:profile scope required for\nverification.\nTry again, or obtain a full-scope token.`};let a=i.organization.uuid;return a===e?{valid:!0}:r?{valid:!1,message:`The ${n===`CLAUDE_CODE_OAUTH_TOKEN`?`CLAUDE_CODE_OAUTH_TOKEN`:`CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR`} environment variable provides a token for a\ndifferent organization than required by this machine's managed settings.\n\nRequired organization: ${e}\nToken organization: ${a}\n\nRemove the environment variable or obtain a token for the correct organization.`}:{valid:!1,message:`Your authentication token belongs to organization ${a},\nbut this machine requires organization ${e}.\n\nAuthentication token belongs to the wrong organization.`}}var oo,B,V,H,so,co,U,lo,uo,fo,po,mo,W,ho,go,_o,vo,yo,bo,xo,G=e((()=>{re(),Ye(),i(),O(),it(),yn(),A(),h(),Fn(),Sn(),Gn(),Qn(),rr(),ar(),xi(),We(),v(),c(),Ae(),Ke(),Ue(),$e(),tt(),Pi(),Ui(),Yn(),b(),Gi(),Re(),Yi(),oo=300*1e3,B=null,V=null,H=0,so=3600*1e3,co=180*1e3,U=et(async()=>{let e=await ha(),t=await _a();return(e||t)&&await nr(),t},so),lo=5e3,uo=3600*1e3,fo=180*1e3,po=et(async()=>await Sa(),uo),mo=r(()=>{if(l())return null;if(process.platform===`darwin`){let e=Ri();if(e){if(e.stdout)return{key:e.stdout,source:`/login managed key`}}else{let e=M();try{let t=Je(`security find-generic-password -a $USER -w -s "${e}"`);if(t)return{key:t,source:`/login managed key`}}catch(e){T(e)}}}let e=S();return e.primaryApiKey?{key:e.primaryApiKey,source:`/login managed key`}:null}),W=r(()=>{if(l())return null;if(process.env.CLAUDE_CODE_OAUTH_TOKEN)return{accessToken:process.env.CLAUDE_CODE_OAUTH_TOKEN,refreshToken:null,expiresAt:null,scopes:[`user:inference`],subscriptionType:null,rateLimitTier:null};let e=zn();if(e)return{accessToken:e,refreshToken:null,expiresAt:null,scopes:[`user:inference`],subscriptionType:null,rateLimitTier:null};try{let e=Ni().read()?.claudeAiOauth;return e?.accessToken?e:null}catch(e){return T(e),null}}),ho=0,go=new Map,_o=null,vo=null,yo=0,bo=1740*1e3,xo=class extends Error{}}));function K(){return!s(process.env.CLAUDE_CODE_DISABLE_FAST_MODE)}function So(){return K()?wo()===null:!1}function Co(e,t){switch(e){case`free`:return t===`oauth`?`Fast mode requires a paid subscription`:`Fast mode unavailable during evaluation. Please purchase credits.`;case`preference`:return`Fast mode has been disabled by your organization`;case`extra_usage_disabled`:return`Fast mode requires extra usage billing · enable it at claude.ai/settings/usage`;case`network_error`:return`Fast mode unavailable due to network connectivity issues`;case`unknown`:return`Fast mode is currently unavailable`}}function wo(){if(!K())return`Fast mode is not available`;if(lt(),m()&&_e()&&!x(`flagSettings`)?.fastMode){let e=`Fast mode is not available in the Agent SDK`;return _(`Fast mode unavailable: ${e}`),e}if(k()!==`firstParty`){let e=`Fast mode is not available on Bedrock, Vertex, or Foundry`;return _(`Fast mode unavailable: ${e}`),e}if(J.status===`disabled`){if((J.reason===`network_error`||J.reason===`unknown`)&&s(process.env.CLAUDE_CODE_SKIP_FAST_MODE_NETWORK_ERRORS))return null;let e=W()===null?`api-key`:`oauth`,t=Co(J.reason,e);return _(`Fast mode unavailable: ${t}`),t}return null}function To(){return`opus${Ks()?`[1m]`:``}`}function Eo(e){if(!K()||!So()||!Do(e))return!1;let t=Ve();return!t.fastModePerSessionOptIn&&t.fastMode===!0}function Do(e){if(!K())return!1;let t=Q(e??Vs());return t.toLowerCase().includes(`opus-4-7`)||t.toLowerCase().includes(`opus-4-6`)}function Oo(){return q.status===`cooldown`&&Date.now()>=q.resetAt&&(K()&&!Vo&&(_(`Fast mode cooldown expired, re-enabling fast mode`),Vo=!0,Uo.emit()),q={status:`active`}),q}function ko(e,t){if(!K())return;q={status:`cooldown`,resetAt:e,reason:t},Vo=!1;let n=e-Date.now();_(`Fast mode cooldown triggered (${t}), duration ${Math.round(n/1e3)}s`),E(`tengu_fast_mode_fallback_triggered`,{cooldown_duration_ms:n,cooldown_reason:t}),Ho.emit(e,t)}function Ao(){q={status:`active`}}function jo(){J.status!==`disabled`&&(J={status:`disabled`,reason:`preference`},Be(`userSettings`,{fastMode:void 0}),w(e=>({...e,penguinModeOrgEnabled:!1})),Jo.emit(!1))}function Mo(e){switch(e){case`out_of_credits`:return`Fast mode disabled · extra usage credits exhausted`;case`org_level_disabled`:case`org_service_level_disabled`:return`Fast mode disabled · extra usage disabled by your organization`;case`org_level_disabled_until`:return`Fast mode disabled · extra usage spending cap reached`;case`member_level_disabled`:return`Fast mode disabled · extra usage disabled for your account`;case`seat_tier_level_disabled`:case`seat_tier_zero_credit_limit`:case`member_zero_credit_limit`:return`Fast mode disabled · extra usage not available for your plan`;case`overage_not_provisioned`:case`no_limits_configured`:return`Fast mode requires extra usage billing · enable it at claude.ai/settings/usage`;default:return`Fast mode disabled · extra usage not available`}}function No(e){return e===`org_level_disabled_until`||e===`out_of_credits`}function Po(e){let t=Mo(e);_(`Fast mode overage rejection: ${e??`unknown`} — ${t}`),E(`tengu_fast_mode_overage_rejected`,{overage_disabled_reason:e??`unknown`}),No(e)||(Be(`userSettings`,{fastMode:void 0}),w(e=>({...e,penguinModeOrgEnabled:!1}))),Ko.emit(t)}function Fo(){return Oo().status===`cooldown`}function Io(e,t){let n=K()&&So()&&!!t&&Do(e);return n&&Fo()?`cooldown`:n?`on`:`off`}async function Lo(e){let t=`${D().BASE_API_URL}/api/claude_code_penguin_mode`,n=`accessToken`in e?{Authorization:`Bearer ${e.accessToken}`,"anthropic-beta":st}:{"x-api-key":e.apiKey};return(await f.get(t,{headers:n})).data}function Ro(){K()&&J.status===`pending`&&(J=S().penguinModeOrgEnabled===!0?{status:`enabled`}:{status:`disabled`,reason:`unknown`})}async function zo(){if(Qe()||!K())return;if(Qo)return _(`Fast mode prefetch in progress, returning in-flight promise`),Qo;let e=$i();if(!(W()?.accessToken&&Ba())&&!e){J=S().penguinModeOrgEnabled===!0?{status:`enabled`}:{status:`disabled`,reason:`preference`};return}let t=Date.now();if(t-Zo<Xo){_(`Skipping fast mode prefetch, fetched recently`);return}Zo=t;let n=async()=>{let t=W(),n=t?.accessToken&&Ba()?{accessToken:t.accessToken}:e?{apiKey:e}:null;if(!n)throw Error(`No auth available`);return Lo(n)};async function r(){try{let e;try{e=await n()}catch(t){if(f.isAxiosError(t)&&(t.response?.status===401||t.response?.status===403&&typeof t.response?.data==`string`&&t.response.data.includes(`OAuth token has been revoked`))){let r=W()?.accessToken;if(r)await Fa(r),e=await n();else throw t}else throw t}let t=J.status===`pending`?S().penguinModeOrgEnabled:J.status===`enabled`;J=e.enabled?{status:`enabled`}:{status:`disabled`,reason:e.disabled_reason??`preference`},t!==e.enabled&&(e.enabled||Be(`userSettings`,{fastMode:void 0}),w(t=>({...t,penguinModeOrgEnabled:e.enabled})),Jo.emit(e.enabled)),_(`Org fast mode: ${e.enabled?`enabled`:`disabled (${e.disabled_reason??`preference`})`}`)}catch(e){J=S().penguinModeOrgEnabled===!0?{status:`enabled`}:{status:`disabled`,reason:`network_error`},_(`Failed to fetch org fast mode status, defaulting to ${J.status===`enabled`?`enabled (cached)`:`disabled (network_error)`}: ${e}`,{level:`error`}),E(`tengu_org_penguin_mode_fetch_failed`,{})}finally{Qo=null}}return Qo=r(),Qo}var Bo,q,Vo,Ho,Uo,Wo,Go,Ko,qo,J,Jo,Yo,Xo,Zo,Qo,$o=e((()=>{p(),O(),h(),it(),G(),ut(),We(),v(),c(),$(),A(),Ze(),b(),xe(),Bo=`Opus 4.7`,q={status:`active`},Vo=!1,Ho=ye(),Uo=ye(),Wo=Ho.subscribe,Go=Uo.subscribe,Ko=ye(),qo=Ko.subscribe,J={status:`pending`},Jo=ye(),Yo=Jo.subscribe,Xo=3e4,Zo=0,Qo=null}));function es(e){return K()&&e?us:ls}function ts(e,t){return t.input_tokens/1e6*e.inputTokens+t.output_tokens/1e6*e.outputTokens+(t.cache_read_input_tokens??0)/1e6*e.promptCacheReadTokens+(t.cache_creation_input_tokens??0)/1e6*e.promptCacheWriteTokens+(t.server_tool_use?.web_search_requests??0)*e.webSearchRequests}function ns(e,t){let n=Z(e);return n===X(an.firstParty)?es(t.speed===`fast`):ms[n]||(rs(e,n),ms[Z(Vs())]??ps)}function rs(e,t){E(`tengu_unknown_model_cost`,{model:e,shortName:t}),ve()}function is(e,t){return ts(ns(e,t),t)}function as(e,t){return is(e,{input_tokens:t.inputTokens,output_tokens:t.outputTokens,cache_read_input_tokens:t.cacheReadInputTokens,cache_creation_input_tokens:t.cacheCreationInputTokens})}function os(e){return Number.isInteger(e)?`$${e}`:`$${e.toFixed(2)}`}function ss(e){return`${os(e.inputTokens)}/${os(e.outputTokens)} per Mtok`}var Y,cs,ls,us,ds,fs,ps,ms,hs=e((()=>{it(),h(),$o(),un(),$(),Y={inputTokens:3,outputTokens:15,promptCacheWriteTokens:3.75,promptCacheReadTokens:.3,webSearchRequests:.01},cs={inputTokens:15,outputTokens:75,promptCacheWriteTokens:18.75,promptCacheReadTokens:1.5,webSearchRequests:.01},ls={inputTokens:5,outputTokens:25,promptCacheWriteTokens:6.25,promptCacheReadTokens:.5,webSearchRequests:.01},us={inputTokens:30,outputTokens:150,promptCacheWriteTokens:37.5,promptCacheReadTokens:3,webSearchRequests:.01},ds={inputTokens:.8,outputTokens:4,promptCacheWriteTokens:1,promptCacheReadTokens:.08,webSearchRequests:.01},fs={inputTokens:1,outputTokens:5,promptCacheWriteTokens:1.25,promptCacheReadTokens:.1,webSearchRequests:.01},ps=ls,ms={[X(Zt.firstParty)]:ds,[X(Qt.firstParty)]:fs,[X(Xt.firstParty)]:Y,[X(Yt.firstParty)]:Y,[X($t.firstParty)]:Y,[X(en.firstParty)]:Y,[X(sn.firstParty)]:Y,[X(tn.firstParty)]:cs,[X(nn.firstParty)]:cs,[X(rn.firstParty)]:ls,[X(an.firstParty)]:ls}}));function gs(e){return vs.includes(e)}function _s(e){return ys.includes(e)}var vs,ys,bs=e((()=>{vs=[`sonnet`,`opus`,`haiku`,`best`,`sonnet[1m]`,`opus[1m]`,`opusplan`],ys=[`sonnet`,`opus`,`haiku`]}));function xs(e,t){return e.includes(t)?!0:gs(e)?Q(e).toLowerCase().includes(t):!1}function Ss(e,t){return e.startsWith(t)?e.length===t.length||e[t.length]===`-`:!1}function Cs(e,t){let n=gs(e)?Q(e).toLowerCase():e;return!!(Ss(n,t)||!t.startsWith(`claude-`)&&Ss(n,`claude-${t}`))}function ws(e,t){for(let n of t){if(_s(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 Ts(e){let{availableModels:t}=y()||{};if(!t)return!0;if(t.length===0)return!1;let n=mn(e).trim().toLowerCase(),r=t.map(e=>e.trim().toLowerCase());if(r.includes(n)&&(!_s(n)||!ws(n,r)))return!0;for(let e of r)if(_s(e)&&!ws(e,r)&&xs(n,e))return!0;if(gs(n)){let e=Q(n).toLowerCase();if(r.includes(e))return!0}for(let e of r)if(!_s(e)&&gs(e)&&Q(e).toLowerCase()===n)return!0;for(let e of r)if(!_s(e)&&!gs(e)&&Cs(n,e))return!0;return!1}var Es=e((()=>{b(),bs(),$(),yn()}));function Ds(){return process.env.OPENAI_AUTH_MODE===`chatgpt`}var Os,ks,As=e((()=>{Os=`gpt-5.5`,ks=`gpt-5.4-mini`}));function js(){let e=k();return e===`openai`&&Ds()?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||zs()}function Ms(e){return e===j().opus40||e===j().opus41||e===j().opus45||e===j().opus46||e===j().opus47}function Ns(){let e,t=Ce();if(t!==void 0)e=t;else{let t=y()||{};e=process.env.ANTHROPIC_MODEL||t.model||void 0}if(!(e&&!Ts(e)))return e}function Ps(){let e=Ns();return e==null?Hs():Q(e)}function Fs(){return Ls()}function Is(){let e=k();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 Ls(){let e=k();return e===`openai`&&Ds()?Os: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:Is()||j().opus47}function Rs(){let e=k();return e===`openai`&&Ds()?Os: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:Is()||(e===`firstParty`?j().sonnet46:j().sonnet45)}function zs(){let e=k();return e===`openai`&&Ds()?ks: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:Is()||j().haiku45}function Bs(e){let{permissionMode:t,mainLoopModel:n,exceeds200kTokens:r=!1}=e;return Ns()===`opusplan`&&t===`plan`&&!r?Ls():Ns()===`haiku`&&t===`plan`?Rs():n}function Vs(){return Ga()||qa()?Ls()+(Ks()?`[1m]`:``):Rs()}function Hs(){return Q(Vs())}function X(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 X(mn(e))}function Us(e=!1){return Ga()||qa()?Ks()?`Opus 4.7 with 1M context · Most capable for complex work${e?Gs(!0):``}`:`Opus 4.7 · Most capable for complex work${e?Gs(!0):``}`:`Sonnet 4.6 · Best for everyday tasks`}function Ws(e){return e===`opusplan`?`Opus 4.7 in plan mode, else Sonnet 4.6`:Ys(Q(e))}function Gs(e){if(k()!==`firstParty`)return``;let t=ss(es(e));return` ·${e?` (↯)`:``} ${t}`}function Ks(){return!(Wr()||Ya()||k()!==`firstParty`||!jt()||R()&&z()===null)}function qs(e){return e===`opusplan`?`Opus Plan`:gs(e)?dt(e):Ys(e)}function Js(e){switch(e){case j().opus47:return`Opus 4.7`;case`${j().opus47}[1m]`:return`Opus 4.7 (1M context)`;case j().opus46:return`Opus 4.6`;case`${j().opus46}[1m]`:return`Opus 4.6 (1M context)`;case j().opus45:return`Opus 4.5`;case j().opus41:return`Opus 4.1`;case j().opus40:return`Opus 4`;case`${j().sonnet46}[1m]`:return`Sonnet 4.6 (1M context)`;case j().sonnet46:return`Sonnet 4.6`;case`${j().sonnet45}[1m]`:return`Sonnet 4.5 (1M context)`;case j().sonnet45:return`Sonnet 4.5`;case j().sonnet40:return`Sonnet 4`;case`${j().sonnet40}[1m]`:return`Sonnet 4 (1M context)`;case j().sonnet37:return`Sonnet 3.7`;case j().sonnet35:return`Sonnet 3.5`;case j().haiku45:return`Haiku 4.5`;case j().haiku35:return`Haiku 3.5`;default:return null}}function Ys(e){return Js(e)||e}function Q(e){let t=e.trim(),n=t.toLowerCase(),r=F(n),i=r?n.replace(/\[1m]$/i,``).trim():n;if(gs(i))switch(i){case`opusplan`:return Rs()+(r?`[1m]`:``);case`sonnet`:return Rs()+(r?`[1m]`:``);case`haiku`:return zs()+(r?`[1m]`:``);case`opus`:return Ls()+(r?`[1m]`:``);case`best`:return Fs();default:}return k()===`firstParty`&&Zs(i)&&Qs()?Ls()+(r?`[1m]`:``):r?`${t.replace(/\[1m\]$/i,``).trim()}[1m]`:t}function Xs(e,t){return F(e)||!F(t)?e:Gr(Q(e))?`${e}[1m]`:e}function Zs(e){return nc.includes(e)}function Qs(){return!s(process.env.CLAUDE_CODE_DISABLE_LEGACY_MODEL_REMAP)}function $s(e){if(e===null)return R()?`Default (${Us()})`:`Default (${Hs()})`;let t=Q(e);return e===t?t:`${e} (${t})`}function ec(e){if(k()===`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 tc(e){return e.replace(/\[(1|2)m\]/gi,``)}var nc,$=e((()=>{h(),G(),ni(),c(),yn(),hs(),b(),A(),ze(),Es(),bs(),ft(),As(),nc=[`claude-opus-4-20250514`,`claude-opus-4-1-20250805`,`claude-opus-4-0`,`claude-opus-4-1`]}));export{Go as $,br as $n,k as $r,Ta as $t,vs as A,ai as An,wn as Ar,Fa as At,Ao as B,ni as Bn,yn as Br,ro as Bt,Q as C,hi as Cn,kn as Cr,La as Ct,Xs as D,di as Dn,Mn as Dr,Xa as Dt,qs as E,fi as En,jn as Er,to as Et,is as F,Kr as Fn,bn as Fr,Va as Ft,Eo as G,Or as Gn,Kt as Gr,eo as Gt,Oo as H,Ur as Hn,Bt as Hr,Ja as Ht,ss as I,Xr as In,xn as Ir,I as It,$o as J,Cr as Jn,Lt as Jr,qa as Jt,Po as K,Nr as Kn,Jt as Kr,Ua as Kt,es as L,Yr as Ln,Sn as Lr,ia as Lt,Y as M,ti as Mn,Dn as Mr,Wa as Mt,ms as N,Qr as Nn,Cn as Nr,Ba as Nt,Es as O,pi as On,Fn as Or,Za as Ot,as as P,Jr as Pn,Pn as Pr,G as Pt,Do as Q,xr as Qn,Nt as Qr,Ea as Qt,hs as R,qr as Rn,gn as Rr,oa as Rt,tc as S,bi as Sn,Tn as Sr,W as St,Ys as T,xi as Tn,On as Tr,Ha as Tt,Io as U,zr as Un,Gt as Ur,ba as Ut,To as V,Wr as Vn,Wt as Vr,ka as Vt,wo as W,Mr as Wn,Ut as Wr,Ga as Wt,Fo as X,Er as Xn,Mt as Xr,Qa as Xt,So as Y,Sr as Yn,It as Yr,Ka as Yt,K as Z,Tr as Zn,Ft as Zr,ma as Zt,$ as _,Pi as _n,Yn as _r,la as _t,zs as a,Oa as an,hr as ar,ko as at,Ks as b,gi as bn,In as br,ca as bt,Ls as c,qi as cn,vr as cr,Ra as ct,ec as d,Gi as dn,ar as dr,va as dt,At as ei,U as en,gr as er,Wo as et,Gs as f,Wi as fn,rr as fr,wa as ft,Ns as g,Ni as gn,N as gr,ta as gt,js as h,Ii as hn,Zn as hr,$i as ht,Us as i,Aa as in,pr as ir,Ro as it,bs as j,oi as jn,Nn as jr,ea as jt,Ts as k,mi as kn,An as kr,z as kt,Rs as l,Ki as ln,yr as lr,xa as lt,Bs as m,Ui as mn,Qn as mr,io as mt,Fs as n,jt as ni,Ca as nn,lr as nr,Yo as nt,Hs as o,Ma as on,ur as or,Xi as ot,Js as p,Li as pn,$n as pr,Na as pt,jo as q,wr as qn,Vt as qr,Ya as qt,Z as r,po as rn,mr as rr,zo as rt,Vs as s,ao as sn,fr as sr,sa as st,X as t,A as ti,ga as tn,cr as tr,qo as tt,Ps as u,Yi as un,ir as ur,pa as ut,Qs as v,ki as vn,Wn as vr,fa as vt,Ws as w,yi as wn,En as wr,L as wt,$s as x,ci as xn,Ln as xr,Qi as xt,Ms as y,Ti as yn,Gn as yr,mo as yt,Bo as z,F as zn,j as zr,R as zt};
@@ -1 +0,0 @@
1
- import{_ as e,u as t}from"./model-BaMclMXn.js";e();export{t as getMainLoopModel};
@@ -1 +0,0 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{Eh as n,Jf as r,Oh as i,Th as a,Xf as o,Xw as s,Yf as c,Yw as l}from"./loadAgentsDir-C96o6gCj.js";import{ai as u,di as d,fi as f}from"./src-DL3w8VPk.js";import{t as p}from"./jsx-runtime-Bb4Xn-E0.js";import{D as m,E as h,q as g}from"./log-CZ7ploQm.js";import{n as _,r as v}from"./analytics-DJobLaWP.js";import{A as y,B as b,J as x,O as S,Q as C,Y as w,Z as T,_ as E,b as D,j as O,k,s as A,w as j}from"./model-BaMclMXn.js";import{i as M,r as N}from"./switcher-DWfKi17X.js";import{i as P,n as F,r as I,t as L}from"./extraUsage-DiAirtuk.js";function R({onDone:e}){let t=n(e=>e.mainLoopModel),r=n(e=>e.mainLoopModelForSession),a=n(e=>e.fastMode),o=i();function s(){v(`tengu_model_command_menu`,{action:`cancel`});let n=W(t);e(`Kept model as ${d.bold(n)}`,{display:`system`})}async function c(n){v(`tengu_model_command_menu`,{action:n,from_model:t,to_model:n}),o(e=>({...e,mainLoopModel:n,mainLoopModelForSession:null}));let r=`Set model to ${d.bold(W(n))}`,i;if(T()&&(b(),!C(n)&&a?(o(e=>({...e,fastMode:!1})),i=!1):C(n)&&w()&&a&&(r+=` · Fast mode ON`,i=!0)),F(n,i===!0,D())&&(r+=` · Billed as extra usage`),i===!1&&(r+=` · Fast mode OFF`),n){let e=await M(n);e.kind===`updated`&&(r+=` · Provider "${e.providerId}" default model updated`)}e(r)}return(0,K.jsx)(I,{initial:t,sessionModel:r,onSelect:c,onCancel:s,isStandaloneCommand:!0,showFastModeNotice:T()&&a&&C(t)&&w()})}function z({args:e,onDone:t}){let r=n(e=>e.fastMode),a=i(),o=e==="default"?null:e;return G.useEffect(()=>{async function e(){if(o&&!k(o)){t(`Model '${o}' is not available. Your organization restricts model selection.`,{display:`system`});return}if(o&&V(o)){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(o&&H(o)){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(!o){n(null);return}if(B(o)){await n(o);return}try{let{valid:e,error:r}=await s(o);e?await n(o):t(r||`Model '${o}' not found`,{display:`system`})}catch(e){t(`Failed to validate model: ${e.message}`,{display:`system`})}}async function n(e){a(t=>({...t,mainLoopModel:e,mainLoopModelForSession:null}));let n=`Set model to ${d.bold(W(e))}`,i;if(T()&&(b(),!C(e)&&r?(a(e=>({...e,fastMode:!1})),i=!1):C(e)&&r&&(n+=` · Fast mode ON`,i=!0)),F(e,i===!0,D())&&(n+=` · Billed as extra usage`),i===!1&&(n+=` · Fast mode OFF`),e){let t=await M(e);t.kind===`updated`&&(n+=` · Provider "${t.providerId}" default model updated`)}t(n)}e()},[o,t,a]),null}function B(e){return y.includes(e.toLowerCase().trim())}function V(e){let t=e.toLowerCase();return!r()&&!D()&&t.includes(`opus`)&&t.includes(`[1m]`)}function H(e){let t=e.toLowerCase();return!c()&&(t.includes(`sonnet[1m]`)||t.includes(`sonnet-4-6[1m]`))}function U({onDone:e}){let t=n(e=>e.mainLoopModel),r=n(e=>e.mainLoopModelForSession),i=W(t);return e(r?`Current model: ${d.bold(W(r))} (session override from plan mode)\nBase model: ${i}`:`Current model: ${i}`),null}function W(e){let t=j(e??A());return e===null?`${t} (default)`:t}var G,K,q;e((()=>{f(),G=t(u(),1),P(),g(),_(),a(),L(),x(),O(),o(),E(),S(),l(),N(),K=p(),q=async(e,t,n)=>{if(n=n?.trim()||``,m.includes(n))return v(`tengu_model_command_inline_help`,{args:n}),(0,K.jsx)(U,{onDone:e});if(h.includes(n)){e(`Run /model to open the model selection menu, or /model [modelName] to set the model.`,{display:`system`});return}return n?(v(`tengu_model_command_inline`,{args:n}),(0,K.jsx)(z,{args:n,onDone:e})):(0,K.jsx)(R,{onDone:e})}}))();export{q as call};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{P as t,Ut as n}from"./state-D5D6QpTX.js";import{d as r,h as i}from"./settings-BowI3jp-.js";import{c as a,h as o}from"./config-DUTgj3js.js";import{$r as s,I as c,M as l,O as u,Pt as d,R as f,_ as p,g as m,i as h,k as g,s as _,ti as v,w as y,zt as b}from"./model-BaMclMXn.js";function x(e=!1){if(b())return{value:null,label:`Default (recommended)`,description:h(e)};let t=s()!==`firstParty`;return{value:null,label:`Default (recommended)`,description:`Use the default model (currently ${y(_())})${t?``:` · ${c(l)}`}`}}function S(e=!1){let n=[x(e)],r=process.env.ANTHROPIC_CUSTOM_MODEL_OPTION;r&&!n.some(e=>e.value===r)&&n.push({value:r,label:process.env.ANTHROPIC_CUSTOM_MODEL_OPTION_NAME??r,description:process.env.ANTHROPIC_CUSTOM_MODEL_OPTION_DESCRIPTION??`Custom model (${r})`});for(let e of a().additionalModelOptionsCache??[])n.some(t=>t.value===e.value)||n.push(e);let i=null,o=m(),s=t();return o==null?s!==null&&(i=s):i=o,i!==null&&!n.some(e=>e.value===i)&&n.push({value:i,label:i,description:`Custom model`}),C(n)}function C(e){return(r()||{}).availableModels?e.filter(e=>e.value===null||e.value!==null&&g(e.value)):e}function w(e,t){return e.length===0?null:C([x(t),...e])}var T=e((()=>{n(),o(),d(),f(),i(),u(),p(),v()}));export{S as n,T as r,w as t};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{l as t,o as n}from"./envUtils-DcaKZlRU.js";import{ft as r,ut as i}from"./esm-BCUC71kt.js";import{n as a,t as o}from"./axios-DaWTGg7G.js";import{B as s,F as c,P as l,R as u,U as d,c as f,f as p,i as m,nt as ee,tt as te,u as ne,x as re}from"./debug-D58GQBDG.js";import{Gt as ie,Jt as ae}from"./settings-BowI3jp-.js";import{C as h,S as oe,c as se,h as ce,x as le,y as ue}from"./config-DUTgj3js.js";import{i as g,n as _}from"./execFileNoThrow-B_KRY4cT.js";import{o as v,s as y}from"./log-CZ7ploQm.js";import{n as b,r as x}from"./analytics-DJobLaWP.js";import{dn as de,fn as fe}from"./model-BaMclMXn.js";import{_t as pe,gt as me,vt as he}from"./sessionState-8jutEorw.js";import{C as ge,E as _e,S as ve,T as ye,_ as be,a as S,b as xe,c as Se,d as Ce,f as we,g as Te,i as Ee,l as De,m as Oe,n as ke,o as C,p as Ae,s as je,t as Me,u as Ne,v as Pe,w as Fe,x as w,y as Ie}from"./pidLock-C1hmh3YQ.js";import{homedir as T}from"os";import{basename as Le,delimiter as Re,dirname as E,join as D,resolve as O}from"path";import{constants as ze}from"fs";import{createHash as Be}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 Ve,stat as L,symlink as He,unlink as R,writeFile as z}from"fs/promises";async function Ue(e=`latest`,t,n){let r=Date.now();try{let i=await a.get(`${t}/${e}`,{timeout:3e4,responseType:`text`,...n});return x(`tengu_version_check_success`,{latency_ms:Date.now()-r}),i.data.trim()}catch(n){let i=Date.now()-r,o=n instanceof Error?n.message:String(n),s;a.isAxiosError(n)&&n.response&&(s=n.response.status),x(`tengu_version_check_failure`,{latency_ms:i,http_status:s,is_timeout:o.includes(`timeout`)});let c=Error(`Failed to fetch version from ${t}/${e}: ${o}`);throw y(c),c}}async function We(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 Ue(t,B)}function Ge(){return Number(process.env.CLAUDE_CODE_STALL_TIMEOUT_MS_FOR_TESTING)||V}async function Ke(e,t,n,r={}){let i;for(let o=1;o<=3;o++){let s=new AbortController,c,l=()=>{c&&(clearTimeout(c),c=void 0)},u=()=>{l(),c=setTimeout(e=>e.abort(),Ge(),s)};try{u();let i=await a.get(e,{timeout:5*6e4,responseType:`arraybuffer`,signal:s.signal,onDownloadProgress:()=>{u()},...r});l();let o=Be(`sha256`);o.update(i.data);let c=o.digest(`hex`);if(c!==t)throw Error(`Checksum mismatch: expected ${t}, got ${c}`);await z(n,Buffer.from(i.data)),await A(n,493);return}catch(e){l();let t=a.isCancel(e);if(i=t?new H:d(e),t&&o<3){f(`Download stalled on attempt ${o}/3, retrying...`),await fe(1e3);continue}throw i}}throw i??Error(`Download failed after all retries`)}async function qe(e,t,n,r){let i=ne();await i.rm(t,{recursive:!0,force:!0});let o=U(),s=Date.now();x(`tengu_binary_download_attempt`,{});let c;try{c=(await a.get(`${n}/${e}/manifest.json`,{timeout:1e4,responseType:`json`,...r})).data}catch(t){let r=Date.now()-s,i=t instanceof Error?t.message:String(t),o;throw a.isAxiosError(t)&&t.response&&(o=t.response.status),x(`tengu_binary_manifest_fetch_failure`,{latency_ms:r,http_status:o,is_timeout:i.includes(`timeout`)}),y(Error(`Failed to fetch manifest from ${n}/${e}/manifest.json: ${i}`)),t}let l=c.platforms[o];if(!l)throw x(`tengu_binary_platform_not_found`,{}),Error(`Platform ${o} not found in manifest for version ${e}`);let u=l.checksum,d=W(o),f=`${n}/${e}/${o}/${d}`;await i.mkdir(t);let p=D(t,d);try{await Ke(f,u,p,r||{}),x(`tengu_binary_download_success`,{latency_ms:Date.now()-s})}catch(e){let t=Date.now()-s,n=e instanceof Error?e.message:String(e),r;throw a.isAxiosError(e)&&e.response&&(r=e.response.status),x(`tengu_binary_download_failure`,{latency_ms:t,http_status:r,is_timeout:n.includes(`timeout`),is_checksum_mismatch:n.includes(`Checksum mismatch`)}),y(Error(`Failed to download binary from ${f}: ${n}`)),e}}async function Je(e,t){return await qe(e,t,B),`binary`}var B,V,H,Ye=e((()=>{o(),b(),m(),u(),g(),p(),v(),de(),re(),$(),B=`https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases`,V=6e4,H=class extends Error{constructor(){super(`Download stalled: no data received for 60 seconds`),this.name=`StallTimeoutError`}}}));function U(){let e=ie.platform,t=process.arch===`x64`?`x64`:process.arch===`arm64`?`arm64`:null;if(!t){let e=Error(`Unsupported architecture: ${process.arch}`);throw f(`Native installer does not support architecture: ${process.arch}`,{level:`error`}),e}return e===`linux`&&i.isMuslEnvironment()?`linux-${t}-musl`:`${e}-${t}`}function W(e){return e.startsWith(`win32`)?`claude.exe`:`claude`}function G(){let e=W(U());return{versions:D(Ce(),`claude`,`versions`),staging:D(Ne(),`claude`,`staging`),locks:D(we(),`claude`,`locks`),executable:D(De(),e)}}async function K(e){try{let t=await L(e);return!t.isFile()||t.size===0?!1:(await k(e,ze.X_OK),!0)}catch{return!1}}async function q(e){let t=G(),n=[t.versions,t.staging,t.locks];await Promise.all(n.map(e=>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 Xe(e,t,n=0){let r=G(),i=J(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 Se(e,i,async()=>{try{await t()}catch(e){throw y(e),e}}))return x(`tengu_version_lock_acquired`,{is_pid_based:!0,is_lifetime_lock:!1,attempts:r+1}),!0;r++,r<a&&await fe(Math.min(o*2**(r-1),s))}return x(`tengu_version_lock_failed`,{is_pid_based:!0,is_lifetime_lock:!1,attempts:a}),Y(e,Error(`Lock held by another process`)),!1}let a=null;try{try{a=await h(e,{stale:Z,retries:{retries:n,minTimeout:n>0?1e3:100,maxTimeout:n>0?5e3:500},lockfilePath:i,onCompromised:e=>{f(`NON-FATAL: Version lock was compromised during operation: ${e.message}`,{level:`info`})}})}catch(t){return x(`tengu_version_lock_failed`,{is_pid_based:!1,is_lifetime_lock:!1}),Y(e,t),!1}try{return await t(),x(`tengu_version_lock_acquired`,{is_pid_based:!1,is_lifetime_lock:!1}),!0}catch(e){throw y(e),e}}finally{a&&await a()}}async function Ze(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),f(`Atomically installed binary to ${t}`)}catch(e){try{await R(n)}catch{}throw e}}async function Qe(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 x(`tengu_native_install_package_failure`,{stage_find_package:!0,error_package_not_found:!0}),Error(`Could not find platform-specific native package`);let i=D(n,r,`cli`);try{await L(i)}catch{throw x(`tengu_native_install_package_failure`,{stage_binary_exists:!0,error_binary_not_found:!0}),Error(`Native binary not found in staged package`)}await Ze(i,t),await I(e,{recursive:!0,force:!0}),x(`tengu_native_install_package_success`,{})}catch(e){let t=l(e);throw!t.includes(`Could not find platform-specific`)&&!t.includes(`Native binary not found`)&&x(`tengu_native_install_package_failure`,{stage_atomic_move:!0,error_move_failed:!0}),y(d(e)),e}}async function $e(e,t){try{let n=D(e,W(U()));try{await L(n)}catch{throw x(`tengu_native_install_binary_failure`,{stage_binary_exists:!0,error_binary_not_found:!0}),Error(`Staged binary not found`)}await Ze(n,t),await I(e,{recursive:!0,force:!0}),x(`tengu_native_install_binary_success`,{})}catch(e){throw l(e).includes(`Staged binary not found`)||x(`tengu_native_install_binary_failure`,{stage_atomic_move:!0,error_move_failed:!0}),y(d(e)),e}}async function et(e,t,n){n===`npm`?await Qe(e,t):await $e(e,t)}async function tt(e,n){let{stagingPath:r,installPath:i}=await q(e),{executable:a}=G(),o=t(process.env.ENABLE_LOCKLESS_UPDATES)?`${r}.${process.pid}.${Date.now()}`:r,s=!await nt(e)||n;if(s?(f(n?`Force reinstalling native installer version ${e}`:`Downloading native installer version ${e}`),await et(o,i,await Je(e,o))):f(`Version ${e} already installed, updating symlink`),await it(a),await at(a,i),!await K(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 nt(e){let{installPath:t}=await q(e);return K(t)}async function rt(e,n=!1){let r=Date.now(),i=await We(e),{executable:a}=G();if(f(`Checking for native installer update to version ${i}`),!n){let e=await be();if(e&&me(i,e)){if(f(`Native installer: maxVersion ${e} is set, capping update from ${i} to ${e}`),pe(`0.0.21`,e))return f(`Native installer: current version 0.0.21 is already at or above maxVersion ${e}, skipping update`),x(`tengu_native_update_skipped_max_version`,{latency_ms:Date.now()-r,max_version:e,available_version:i}),{success:!0,latestVersion:i};i=e}}if(!n&&i===`0.0.21`&&await nt(i)&&await K(a))return f(`Found ${i} at ${a}, skipping install`),x(`tengu_native_update_complete`,{latency_ms:Date.now()-r,was_new_install:!1,was_force_reinstall:!1,was_already_running:!0}),{success:!0,latestVersion:i};if(!n&&Ie(i))return x(`tengu_native_update_skipped_minimum_version`,{latency_ms:Date.now()-r,target_version:i}),{success:!0,latestVersion:i};let o=!1,s;if(t(process.env.ENABLE_LOCKLESS_UPDATES))o=await tt(i,n),s=Date.now()-r;else{let{installPath:e}=await q(i);n&&await dt(e);let t=await Xe(e,async()=>{o=await tt(i,n)},3);if(s=Date.now()-r,!t){let t=G(),n;if(C()){let r=J(t,e);S(r)&&(n=je(r)?.pid)}return x(`tengu_native_update_lock_failed`,{latency_ms:s,lock_holder_pid:n}),{success:!1,latestVersion:i,lockFailed:!0,lockHolderPid:n}}}return x(`tengu_native_update_complete`,{latency_ms:s,was_new_install:o,was_force_reinstall:n}),f(`Successfully updated to version ${i}`),{success:!0,latestVersion:i}}async function it(e){try{await Ve(e),f(`Removed empty directory at ${e}`)}catch(t){let n=c(t);n!==`ENOTDIR`&&n!==`ENOENT`&&n!==`ENOTEMPTY`&&f(`Could not remove directory at ${e}: ${t}`)}}async function at(e,t){if(U().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 y(n),n}throw t}}else try{await j(t,e)}catch(e){throw s(e)?Error(`Source file does not exist: ${t}`):e}return!0}catch(n){return y(Error(`Failed to copy executable from ${t} to ${e}: ${n}`)),!1}let n=E(e);try{await M(n,{recursive:!0}),f(`Created directory ${n} for symlink`)}catch(e){return y(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){y(Error(`Failed to check/remove existing symlink: ${e}`))}let r=`${e}.tmp.${process.pid}.${Date.now()}`;try{return await He(t,r),await F(r,e),f(`Atomically updated symlink ${e} -> ${t}`),!0}catch(n){try{await R(r)}catch{}return y(Error(`Failed to create symlink from ${e} to ${t}: ${n}`)),!1}}async function ot(e=!1){if(t(process.env.DISABLE_INSTALLATION_CHECKS))return[];let n=await Oe();if(n===`development`||!(e||n===`native`))return[];let r=G(),i=[],a=E(r.executable),o=O(a),c=U().startsWith(`win32`);try{await k(a)}catch{i.push({message:`installMethod is native, but directory ${a} does not exist`,userActionRequired:!0,type:`error`})}if(c)await K(r.executable)||i.push({message:`installMethod is native, but claude command is missing or invalid at ${r.executable}`,userActionRequired:!0,type:`error`});else try{let e=await P(r.executable);await K(O(E(r.executable),e))||i.push({message:`Work Mate symlink points to missing or invalid binary: ${e}`,userActionRequired:!0,type:`error`})}catch(e){s(e)?i.push({message:`installMethod is native, but claude command not found at ${r.executable}`,userActionRequired:!0,type:`error`}):await K(r.executable)||i.push({message:`${r.executable} exists but is not a valid Work Mate binary`,userActionRequired:!0,type:`error`})}if(!(process.env.PATH||``).split(Re).some(e=>{try{let t=O(e);return c?t.toLowerCase()===o.toLowerCase():t===o}catch{return!1}}))if(c){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=ye(),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 st(e,t=!1){if(t)return ct(e,t);if(Q)return f(`installLatest: joining in-flight call`),Q;let n=ct(e,t);Q=n;let r=()=>{Q=null};return n.then(r,r),n}async function ct(e,t=!1){let n=await rt(e,t);return n.success?(se().installMethod!==`native`&&(ue(e=>({...e,installMethod:`native`,autoUpdates:!1,autoUpdatesProtectedForNative:!0})),f(`Native installer: Set installMethod to "native" and disabled legacy auto-updater for protection`)),X(),{latestVersion:n.latestVersion,wasUpdated:n.success,lockFailed:!1}):{latestVersion:null,wasUpdated:!1,lockFailed:n.lockFailed,lockHolderPid:n.lockHolderPid}}async function lt(e){try{let t=await P(e),n=O(E(e),t);if(await K(n))return n}catch{}return null}function J(e,t){let n=Le(t);return D(e.locks,`${n}.lock`)}async function ut(){let e=G();if(!process.execPath.includes(e.versions))return;let t=O(process.execPath);try{let n=J(e,t);if(await M(e.locks,{recursive:!0}),C()){if(!await Me(t,n)){x(`tengu_version_lock_failed`,{is_pid_based:!0,is_lifetime_lock:!0}),Y(t,Error(`Lock already held by another process`));return}x(`tengu_version_lock_acquired`,{is_pid_based:!0,is_lifetime_lock:!0}),f(`Acquired PID lock on running version: ${t}`)}else{let e;try{e=await h(t,{stale:Z,retries:0,lockfilePath:n,onCompromised:e=>{f(`NON-FATAL: Lock on running version was compromised: ${e.message}`,{level:`info`})}}),x(`tengu_version_lock_acquired`,{is_pid_based:!1,is_lifetime_lock:!0}),f(`Acquired mtime-based lock on running version: ${t}`),ee(async()=>{try{await e?.()}catch{}})}catch(e){if(s(e)){f(`Cannot lock current version - file does not exist: ${t}`,{level:`info`});return}x(`tengu_version_lock_failed`,{is_pid_based:!1,is_lifetime_lock:!0}),Y(t,e);return}}}catch(e){if(s(e)){f(`Cannot lock current version - file does not exist: ${t}`,{level:`info`});return}f(`NON-FATAL: Failed to lock current version during execution ${l(e)}`,{level:`info`})}}function Y(e,t){y(Error(`NON-FATAL: Lock acquisition failed for ${e} (expected in multi-process scenarios)`,{cause:t}))}async function dt(e){let t=J(G(),e);try{await R(t),f(`Force-removed lock file at ${t}`)}catch(e){f(`Failed to force-remove lock file: ${l(e)}`)}}async function X(){await Promise.resolve();let e=G(),t=Date.now()-36e5;if(U().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&&f(`Cleaned up ${n} old Windows executables on startup`)}catch(e){s(e)||f(`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++,f(`Cleaned up old staging directory: ${i}`))}catch{}}r>0&&(f(`Cleaned up ${r} orphaned staging directories`),x(`tengu_native_staging_cleanup`,{cleaned_count:r}))}catch(e){s(e)||f(`Failed to clean up staging directories: ${e}`)}if(C()){let t=ke(e.locks);t>0&&(f(`Cleaned up ${t} stale version locks`),x(`tengu_native_stale_locks_cleanup`,{cleaned_count:t}))}let n;try{n=await N(e.versions)}catch(e){s(e)||f(`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++,f(`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&&(f(`Cleaned up ${i} orphaned temp install files`),x(`tengu_native_temp_files_cleanup`,{cleaned_count:i})),r.length!==0)try{let t=process.execPath,n=new Set;t?.includes(e.versions)&&n.add(O(t));let i=await lt(e.executable);i&&n.add(i);for(let t of r){if(n.has(t.resolvedPath))continue;let r=J(e,t.resolvedPath),i=!1;if(C())i=S(r);else try{i=await le(t.resolvedPath,{stale:Z,lockfilePath:r})}catch{i=!1}i&&(n.add(t.resolvedPath),f(`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){x(`tengu_native_version_cleanup`,{total_count:r.length,deleted_count:0,protected_count:n.size,retained_count:2,lock_failed_count:0,error_count:0});return}let o=0,s=0,c=0;await Promise.all(a.map(async e=>{try{await Xe(e.path,async()=>{await R(e.path)})?o++:(s++,f(`Skipping deletion of ${e.name} - locked by another process`))}catch(t){c++,y(Error(`Failed to delete version ${e.name}: ${t}`))}})),x(`tengu_native_version_cleanup`,{total_count:r.length,deleted_count:o,protected_count:n.size,retained_count:2,lock_failed_count:s,error_count:c})}catch(e){s(e)||y(Error(`Version cleanup failed: ${e}`))}}async function ft(){let e=[],t=w();for(let[n,r]of Object.entries(t))try{let t=await ge(r);if(!t)continue;let{filtered:i,hadAlias:a}=xe(t);a&&(await Fe(r,i),e.push({message:`Removed claude alias from ${r}. Run: unalias claude`,userActionRequired:!0,type:`alias`}),f(`Cleaned up claude alias from ${n} config`))}catch(t){y(t),e.push({message:`Failed to clean up ${r}: ${t}`,userActionRequired:!1,type:`error`})}return e}async function pt(e){try{let t=await _(`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),f(`Manually removed ${t}: ${e}`),!0}catch{return!1}}if(U().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?(f(`Successfully removed ${e} manually`),{success:!0,warning:`${e} executables removed, but node_modules directory was left intact for safety. You may manually delete it later at: ${U().startsWith(`win32`)?D(n,`node_modules`,e):D(n,`lib`,`node_modules`,e)}`}):{success:!1}}catch(e){return f(`Manual removal failed: ${e}`,{level:`error`}),{success:!1,error:`Manual removal failed: ${e}`}}}async function mt(e){let{code:t,stderr:n}=await _(`npm`,[`uninstall`,`-g`,e],{cwd:process.cwd()});if(t===0)return f(`Removed global npm installation of ${e}`),{success:!0};if(n&&!n.includes(`npm ERR! code E404`)){if(n.includes(`npm error code ENOTEMPTY`)){f(`Failed to uninstall global npm package ${e}: ${n}`,{level:`error`}),f(`Attempting manual removal due to ENOTEMPTY error`);let t=await pt(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 f(`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 ht(){let e=[],t=[],n=0,r=await mt(`@anthropic-ai/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++,f(`Removed local installation at ${i}`)}catch(t){s(t)||(e.push(`Failed to remove ${i}: ${t}`),f(`Failed to remove local installation: ${t}`,{level:`error`}))}return{removed:n,errors:e,warnings:t}}var Z,Q,$=e((()=>{b(),Pe(),te(),ce(),m(),Te(),ae(),r(),n(),u(),g(),_e(),oe(),v(),he(),ve(),de(),Ae(),Ye(),Ee(),Z=10080*60*1e3,Q=null})),gt=e((()=>{$()}));export{ft as a,ut as c,X as i,ot as n,$ as o,ht as r,st as s,gt as t};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";function t(){return process.env.CLAUDE_CODE_CUSTOM_OAUTH_URL?`-custom-oauth`:``}function n(){let e=u,t=process.env.CLAUDE_CODE_CUSTOM_OAUTH_URL;if(t){let n=t.replace(/\/$/,``);if(!f.includes(n))throw Error(`CLAUDE_CODE_CUSTOM_OAUTH_URL is not an approved endpoint.`);e={...e,BASE_API_URL:n,CONSOLE_AUTHORIZE_URL:`${n}/oauth/authorize`,CLAUDE_AI_AUTHORIZE_URL:`${n}/oauth/authorize`,CLAUDE_AI_ORIGIN:n,TOKEN_URL:`${n}/v1/oauth/token`,API_KEY_URL:`${n}/api/oauth/claude_cli/create_api_key`,ROLES_URL:`${n}/api/oauth/claude_cli/roles`,CONSOLE_SUCCESS_URL:`${n}/oauth/code/success?app=workmate`,CLAUDEAI_SUCCESS_URL:`${n}/oauth/code/success?app=workmate`,MANUAL_REDIRECT_URL:`${n}/oauth/code/callback`,OAUTH_FILE_SUFFIX:`-custom-oauth`}}let n=process.env.CLAUDE_CODE_OAUTH_CLIENT_ID;return n&&(e={...e,CLIENT_ID:n}),e}var r,i,a,o,s,c,l,u,d,f,p=e((()=>{r=`user:inference`,i=`user:profile`,a=`org:create_api_key`,o=`oauth-2025-04-20`,s=[a,i],c=[i,r,`user:sessions:claude_code`,`user:mcp_servers`,`user:file_upload`],l=Array.from(new Set([...s,...c])),u={BASE_API_URL:`https://api.anthropic.com`,CONSOLE_AUTHORIZE_URL:`https://platform.workmate.com/oauth/authorize`,CLAUDE_AI_AUTHORIZE_URL:`https://claude.com/cai/oauth/authorize`,CLAUDE_AI_ORIGIN:`https://claude.ai`,TOKEN_URL:`https://platform.workmate.com/v1/oauth/token`,API_KEY_URL:`https://api.anthropic.com/api/oauth/claude_cli/create_api_key`,ROLES_URL:`https://api.anthropic.com/api/oauth/claude_cli/roles`,CONSOLE_SUCCESS_URL:`https://platform.workmate.com/buy_credits?returnUrl=/oauth/code/success%3Fapp%3Dworkmate`,CLAUDEAI_SUCCESS_URL:`https://platform.workmate.com/oauth/code/success?app=workmate`,MANUAL_REDIRECT_URL:`https://platform.workmate.com/oauth/code/callback`,CLIENT_ID:`9d1c250a-e61b-44d9-88ed-5944d1962f5e`,OAUTH_FILE_SUFFIX:``,MCP_PROXY_URL:`https://mcp-proxy.anthropic.com`,MCP_PROXY_PATH:`/v1/mcp/{server_id}`},d=`https://claude.ai/oauth/claude-code-client-metadata`,f=[`https://beacon.claude-ai.staging.ant.dev`,`https://claude.fedstart.com`,`https://claude-staging.fedstart.com`]}));export{s as a,t as c,i,n as l,r as n,d as o,c as r,o as s,l as t,p as u};
@@ -1 +0,0 @@
1
- import{l as e,u as t}from"./oauth-D38aRTUb.js";t();export{e as getOauthConfig};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{a as t,o as n}from"./isObject-C6qM3WEW.js";import{DT as r,ET as i,MT as a,NT as o,bE as s,yE as c}from"./loadAgentsDir-C96o6gCj.js";import{Ar as l,Dr as u,Er as d,Nr as f,Or as p,Pr as m,Si as h,Tr as g,bi as _,kr as v,li as y,ui as b,xi as x,yi as S}from"./state-D5D6QpTX.js";import{$n as C,Qn as w,Tr as T,Xn as E,Zn as D,er as O,tr as k,wr as A}from"./settings-BowI3jp-.js";import{I as j,L as M}from"./config-DUTgj3js.js";function N(e){return _(e)||b(e)||!!(P&&e&&e[P])}var P,F=e((()=>{n(),y(),S(),P=t?t.isConcatSpreadable:void 0}));function I(e,t,n,r,i){var a=-1,o=e.length;for(n||(n=N),i||(i=[]);++a<o;){var s=e[a];t>0&&n(s)?t>1?I(s,t-1,n,r,i):x(i,s):r||(i[i.length]=s)}return i}var L=e((()=>{h(),F()}));function R(e){return e!=null&&e.length?I(e,1):[]}var z=e((()=>{L()}));function B(e){return D(C(e,void 0,R),e+``)}var V=e((()=>{z(),w(),E()}));function H(e,t){return t.length<2?e:g(e,a(t,0,-1))}var U=e((()=>{d(),o()}));function W(e,t){t=v(t,e);var n=-1,i=t.length;if(!i)return!0;for(;++n<i;){var a=p(t[n]);if(a===`__proto__`&&!G.call(e,`__proto__`)||(a===`constructor`||a===`prototype`)&&n<i-1)return!1}var o=H(e,t);return o==null||delete o[p(r(t))]}var G,K=e((()=>{l(),i(),U(),u(),G=Object.prototype.hasOwnProperty}));function q(e){return k(e)?void 0:e}var J=e((()=>{O()})),Y,X,Z,Q,$=e((()=>{m(),s(),K(),l(),T(),J(),V(),M(),Y=1,X=2,Z=4,Q=B(function(e,t){var n={};if(e==null)return n;var r=!1;t=f(t,function(t){return t=v(t,e),r||(r=t.length>1),t}),A(e,j(e),n),r&&(n=c(n,Y|X|Z,q));for(var i=t.length;i--;)W(n,t[i]);return n})}));export{Q as n,$ as t};
@@ -1 +0,0 @@
1
- import{Ut as e,jn as t}from"./state-D5D6QpTX.js";import{R as n,U as r}from"./debug-D58GQBDG.js";import{Pt as i,Rt as a,jt as o}from"./settings-BowI3jp-.js";import{c as s,h as c,y as l}from"./config-DUTgj3js.js";import{o as u,s as d}from"./log-CZ7ploQm.js";import{Pt as f,dt as p,ft as m,ut as h}from"./model-BaMclMXn.js";import{a as g,i as _,n as v}from"./sessionState-8jutEorw.js";import{r as y,t as b}from"./managedEnv-CHYvwXBH.js";e(),f(),c(),n(),u(),y(),o(),v();function x(e){return t=>({...t,...typeof e.permission_mode==`string`?{toolPermissionContext:{...t.toolPermissionContext,mode:i(e.permission_mode)}}:{}})}function S({newState:e,oldState:n}){let i=n.toolPermissionContext.mode,o=e.toolPermissionContext.mode;if(i!==o){let e=a(i),t=a(o);e!==t&&g({permission_mode:t}),_(o)}if(e.mainLoopModel!==n.mainLoopModel&&t(e.mainLoopModel),e.expandedView!==n.expandedView){let t=e.expandedView===`tasks`;s().showExpandedTodos!==t&&l(e=>({...e,showExpandedTodos:t}))}if(e.verbose!==n.verbose&&s().verbose!==e.verbose){let t=e.verbose;l(e=>({...e,verbose:t}))}if(e.settings!==n.settings)try{h(),p(),m(),e.settings.env!==n.settings.env&&b()}catch(e){d(r(e))}}export{S as n,x as t};
@@ -1,10 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{c as t,l as n,o as r}from"./envUtils-DcaKZlRU.js";import{Nw as i,c_ as a,cy as o,ea as s,ha as c,it as l,iy as u,l_ as d,pa as f,tt as p,u_ as ee,ww as m}from"./loadAgentsDir-C96o6gCj.js";import{c as h,i as g}from"./debug-D58GQBDG.js";import{Bn as _,F as te,Ln as v,R as y}from"./model-BaMclMXn.js";import{_n as ne,bn as re,i as ie,r as b,t as x,vn as S}from"./prompt-BNNE5tsG.js";import{E as C,O as w,T,Z as E,j as D,k as ae}from"./sessionState-8jutEorw.js";import{n as oe,r as O}from"./client-C_jBL1yC.js";import{n as se,t as k}from"./openaiShared-G2-w4gJt.js";import{homedir as A}from"os";import{join as j}from"path";import{randomUUID as M}from"crypto";import{chmod as ce,mkdir as N,readFile as P,writeFile as F}from"fs/promises";function I(){return j(L(),J)}function L(){return(process.env.WORKMATE_CONFIG_DIR??j(A(),`.workmate`)).normalize(`NFC`)}function R(){return j(process.env.CODEX_HOME??j(process.env.HOME??``,`.codex`),`auth.json`)}function z(e){return typeof e==`string`&&e.length>0?e:void 0}function B(e){try{let t=JSON.parse(e);return t&&typeof t==`object`?t:null}catch{return null}}function V(e){let[,t]=e.split(`.`);if(!t)return null;try{let e=t.replace(/-/g,`+`).replace(/_/g,`/`),n=e.padEnd(e.length+(4-e.length%4)%4,`=`);return B(Buffer.from(n,`base64`).toString(`utf8`))}catch{return null}}function H(e){let t=V(e),n=t?.[`https://api.openai.com/auth`];return n&&typeof n==`object`?n:t??{}}function U(e){let t=V(e)?.exp;return typeof t==`number`?t*1e3:null}function W(e){if(e.accountId)return e.accountId;for(let t of[e.idToken,e.accessToken]){if(!t)continue;let e=H(t),n=z(e.chatgpt_account_id)??z(e.chatgpt_account_user_id)??z(e.account_id);if(n)return n}}async function G(e){try{let t=await P(e,`utf8`),n=JSON.parse(t),r=n.tokens,i=r?.id_token,a=r?.access_token,o=r?.refresh_token;return!i||!a||!o?null:{idToken:i,accessToken:a,refreshToken:o,accountId:W({idToken:i,accessToken:a,accountId:r.account_id}),lastRefresh:n.last_refresh}}catch{return null}}async function le(e){let t=I();await N(L(),{recursive:!0});let n={auth_mode:`chatgpt`,tokens:{id_token:e.idToken,access_token:e.accessToken,refresh_token:e.refreshToken,account_id:W(e)},last_refresh:new Date().toISOString()};await F(t,`${JSON.stringify(n,null,2)}\n`,{mode:384}),await ce(t,384).catch(()=>void 0)}async function ue(e,t){let n=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:t});if(!n.ok){let e=await n.text().catch(()=>``);throw Error(`ChatGPT token request failed (${n.status})${e?`: ${e}`:``}`)}return await n.json()}async function de(e){let t=new URLSearchParams({grant_type:`refresh_token`,refresh_token:e.refreshToken,client_id:q,scope:`openid profile email offline_access api.connectors.read api.connectors.invoke`}),n=await ue(`${K}/oauth/token`,t);return{idToken:n.id_token,accessToken:n.access_token,refreshToken:n.refresh_token??e.refreshToken,accountId:W({idToken:n.id_token,accessToken:n.access_token,accountId:e.accountId})}}function fe(){return process.env.OPENAI_AUTH_MODE===`chatgpt`}async function pe(){let e=await G(I());if(e||(e=await G(R()),e&&h(`[OpenAI] Using ChatGPT auth from Codex auth.json`)),!e)throw Error(`ChatGPT account is not logged in.`);let t=U(e.accessToken);return t!==null&&t<=Date.now()+Y&&(e=await de(e),await le(e)),{accessToken:e.accessToken,accountId:e.accountId??W(e)}}var K,q,J,Y,X=e((()=>{g(),K=`https://auth.openai.com`,q=`app_EMoamEEZ73f0CkXaXp7hrann`,J=`openai-chatgpt-auth.json`,Y=300*1e3}));function Z(e){return typeof e==`string`?e:Array.isArray(e)?e.map(e=>{if(!e||typeof e!=`object`)return``;let t=e;return typeof t.text==`string`?t.text:``}).filter(Boolean).join(`
2
- `):``}function me(e){if(typeof e==`string`)return e;if(!Array.isArray(e))return Z(e);let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;if(e.type===`text`&&typeof e.text==`string`)t.push({type:`input_text`,text:e.text});else if(e.type===`image_url`){let n=e.image_url;typeof n?.url==`string`&&t.push({type:`input_image`,image_url:n.url})}}return t.length>0?t:Z(e)}function he(e){let t=[],n=[];for(let r of e){if(!r||typeof r!=`object`)continue;let e=r,i=e.role;if(i===`system`||i===`developer`){let t=Z(e.content);t&&n.push(t);continue}if(i===`tool`){let n=e.tool_call_id;typeof n==`string`&&t.push({type:`function_call_output`,call_id:n,output:Z(e.content)});continue}if(i===`assistant`){let n=Z(e.content);n&&t.push({role:`assistant`,content:n});let r=e.tool_calls;if(Array.isArray(r))for(let e of r){if(!e||typeof e!=`object`)continue;let n=e,r=n.function,i=typeof n.id==`string`?n.id:void 0,a=typeof r?.name==`string`?r.name:void 0;!i||!a||t.push({type:`function_call`,call_id:i,name:a,arguments:typeof r?.arguments==`string`?r.arguments:`{}`})}continue}i===`user`&&t.push({role:`user`,content:me(e.content)})}return{input:t,instructions:n.length>0?n.join(`
3
-
4
- `):void 0}}function ge(e){let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n.function,r=typeof e?.name==`string`?e.name:void 0;r&&t.push({type:`function`,name:r,description:typeof e?.description==`string`?e.description:``,parameters:e?.parameters&&typeof e.parameters==`object`?e.parameters:{type:`object`,properties:{}},strict:!1})}return t}function _e(e){if(e===`required`)return`required`;if(e===`auto`)return`auto`;if(!e||typeof e!=`object`)return e;let t=e,n=t.function;return t.type===`function`&&typeof n?.name==`string`?{type:`function`,name:n.name}:e}function ve(e){let{input:t,instructions:n}=he(e.messages),r=ge(e.tools);return{model:e.model,stream:!0,store:!1,input:t,...n?{instructions:n}:{},...r.length>0?{tools:r}:{},...e.toolChoice?{tool_choice:_e(e.toolChoice)}:{},parallel_tool_calls:!0}}async function*ye(e){if(!e.body)throw Error(`ChatGPT response did not include a body`);let t=e.body.getReader(),n=new TextDecoder,r=``;for(;;){let{done:e,value:i}=await t.read();if(e)break;r+=n.decode(i,{stream:!0});let a=r.indexOf(`
5
-
6
- `);for(;a>=0;){let e=r.slice(0,a);r=r.slice(a+2);let t=e.split(/\r?\n/).filter(e=>e.startsWith(`data:`)).map(e=>e.slice(5).trimStart()).join(`
7
- `);if(t&&t!==`[DONE]`){let e=JSON.parse(t);e&&typeof e==`object`&&(yield e)}a=r.indexOf(`
8
-
9
- `)}}}function be(e){let t=e?.usage,n=t?.input_tokens_details;return{input_tokens:typeof t?.input_tokens==`number`?t.input_tokens:0,output_tokens:typeof t?.output_tokens==`number`?t.output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:typeof n?.cached_tokens==`number`?n.cached_tokens:0}}function xe(e){return e?.status===`incomplete`?`max_tokens`:`end_turn`}async function*Q(e,t){let n=`msg_${M().replace(/-/g,``).slice(0,24)}`,r=new Map,i=!1,a=-1,o=!1,s=!1,c=async function*(){i||(i=!0,yield{type:`message_start`,message:{id:n,type:`message`,role:`assistant`,content:[],model:t,stop_reason:null,stop_sequence:null,usage:{input_tokens:0,output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:0}}})};for await(let t of e){for await(let e of c())yield e;let e=t.type;if(e===`response.output_text.delta`){o||(s&&(yield{type:`content_block_stop`,index:a},s=!1),a++,o=!0,yield{type:`content_block_start`,index:a,content_block:{type:`text`,text:``}}),yield{type:`content_block_delta`,index:a,delta:{type:`text_delta`,text:String(t.delta??``)}};continue}if(e===`response.reasoning_text.delta`){s||(o&&(yield{type:`content_block_stop`,index:a},o=!1),a++,s=!0,yield{type:`content_block_start`,index:a,content_block:{type:`thinking`,thinking:``,signature:``}}),yield{type:`content_block_delta`,index:a,delta:{type:`thinking_delta`,thinking:String(t.delta??``)}};continue}if(e===`response.output_item.added`){let e=t.item,n=typeof t.output_index==`number`?t.output_index:-1;if(e?.type===`function_call`&&n>=0){o&&(yield{type:`content_block_stop`,index:a},o=!1),s&&(yield{type:`content_block_stop`,index:a},s=!1),a++;let t=String(e.call_id??e.id??`call_${n}`),i=String(e.name??``);r.set(n,{contentIndex:a,open:!0,name:i,id:t}),yield{type:`content_block_start`,index:a,content_block:{type:`tool_use`,id:t,name:i,input:{}}}}continue}if(e===`response.function_call_arguments.delta`){let e=typeof t.output_index==`number`?t.output_index:-1,n=r.get(e);n&&(yield{type:`content_block_delta`,index:n.contentIndex,delta:{type:`input_json_delta`,partial_json:String(t.delta??``)}});continue}if(e===`response.output_item.done`){let e=typeof t.output_index==`number`?t.output_index:-1,n=r.get(e);n?.open&&(yield{type:`content_block_stop`,index:n.contentIndex},n.open=!1);continue}if(e===`response.error`){let e=t.error;throw Error(String(e?.message??`ChatGPT Responses API error`))}if(e===`response.failed`){let e=t.response?.error;throw Error(String(e?.message??`ChatGPT Responses API failed`))}if(e===`response.completed`||e===`response.incomplete`){o&&(yield{type:`content_block_stop`,index:a},o=!1),s&&(yield{type:`content_block_stop`,index:a},s=!1);let e=t.response;yield{type:`message_delta`,delta:{stop_reason:xe(e),stop_sequence:null},usage:be(e)},yield{type:`message_stop`}}}}async function Se(e){let t=await pe(),n=e.fetchOverride??globalThis.fetch,r={Authorization:`Bearer ${t.accessToken}`,"Content-Type":`application/json`,Accept:`text/event-stream`,"OpenAI-Beta":`responses=experimental`,Origin:`https://chatgpt.com`,Referer:`https://chatgpt.com/`,originator:`workmate`};t.accountId&&(r[`ChatGPT-Account-Id`]=t.accountId);let i=await n(`https://chatgpt.com/backend-api/codex/responses`,{method:`POST`,headers:r,body:JSON.stringify(e.request),signal:e.signal});if(!i.ok){let e=await i.text().catch(()=>``);throw Error(`ChatGPT Responses API request failed (${i.status})${e?`: ${e.slice(0,500)}`:``}`)}return ye(i)}var Ce=e((()=>{X()}));function we(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 Te(e,t){return t??(process.env.OPENAI_MAX_TOKENS&&parseInt(process.env.OPENAI_MAX_TOKENS,10)||void 0)??(process.env.CLAUDE_CODE_MAX_OUTPUT_TOKENS&&parseInt(process.env.CLAUDE_CODE_MAX_OUTPUT_TOKENS,10)||void 0)??e}function Ee(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 De=e((()=>{r()}));function Oe(e,t,n,r){if(!r||d())return e;let a=t.filter(e=>n.has(e.name)).map(x).sort().join(`
10
- `);return a?[i({content:`<available-deferred-tools>\n${a}\n</available-deferred-tools>`,isMeta:!0}),...e]:e}function ke(e){return e.type===`assistant`||e.type===`user`}function $(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:f(l,r,i),usage:a,stop_reason:o,stop_sequence:null},requestId:void 0,type:`assistant`,uuid:M(),timestamp:new Date().toISOString()}),o===`max_tokens`&&c.push(m({content:`Output truncated: response exceeded the ${s} token limit. Set OPENAI_MAX_TOKENS or CLAUDE_CODE_MAX_OUTPUT_TOKENS to override.`,apiError:`max_output_tokens`,error:`max_output_tokens`})),c}async function*Ae(e,t,n,r,i){try{let a=E(i.model),o=c(e,n),s=await ee(i.model,n,i.getToolPermissionContext||(async()=>ne()),i.agents||[],i.querySource),d=new Set;if(s)for(let e of n)ie(e)&&d.add(e.name);let f=n;s&&d.size>0&&(f=n.filter(e=>!!(!d.has(e.name)||re(e,`SearchExtraTools`))));let p=(await Promise.all(f.map(e=>l(e,{getToolPermissionContext:i.getToolPermissionContext,tools:n,agents:i.agents,allowedAgentTypes:i.allowedAgentTypes,model:i.model,deferLoading:s&&d.has(e.name)})))).filter(e=>{let t=e;return t.type!==`advisor_20260301`&&t.type!==`computer_20250124`}),m=we(a),g=D(Oe(o.filter(ke),n,d,s),t,{enableThinking:m}),_=ae(p),y=w(i.toolChoice);if(s){let e=f.filter(e=>d.has(e.name)).length;h(`[OpenAI] Tool search enabled: ${e}/${d.size} deferred tools included, total tools=${_.length}`)}else h(`[OpenAI] Tool search disabled, total tools=${_.length}`);let{upperLimit:b}=v(a),x=Te(b,i.maxOutputTokensOverride);h(`[OpenAI] Calling model=${a}, messages=${g.length}, tools=${_.length}, thinking=${m}`);let S=fe()?Q(await Se({request:ve({model:a,messages:g,tools:_,toolChoice:y}),signal:r,fetchOverride:i.fetchOverride}),a):C(await oe({maxRetries:0,fetchOverride:i.fetchOverride,source:i.querySource}).chat.completions.create(Ee({model:a,messages:g,tools:_,toolChoice:y,enableThinking:m,maxTokens:x,temperatureOverride:i.temperatureOverride}),{signal:r}),a),T={},O=null,k=null,A={input_tokens:0,output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:0},j=0,M=Date.now();for await(let e of S){switch(e.type){case`message_start`:O=e.message,j=Date.now()-M,e.message.usage&&(A={...A,...e.message.usage});break;case`content_block_start`:{let t=e.index,n=e.content_block;n.type===`tool_use`?T[t]={...n,input:``}:n.type===`text`?T[t]={...n,text:``}:n.type===`thinking`?T[t]={...n,thinking:``,signature:``}:T[t]={...n};break}case`content_block_delta`:{let t=e.index,n=e.delta,r=T[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&&(A=se(A,t)),e.delta.stop_reason!=null&&(k=e.delta.stop_reason);break}case`message_stop`:if(O){for(let e of $({partialMessage:O,contentBlocks:T,tools:n,agentId:i.agentId,usage:A,stopReason:k,maxTokens:x}))yield e;O=null}A.input_tokens+A.output_tokens>0&&u(te(a,A),A,i.model);break}yield{type:`stream_event`,event:e,...e.type===`message_start`?{ttftMs:j}:void 0}}if(O)for(let e of $({partialMessage:O,contentBlocks:T,tools:n,agentId:i.agentId,usage:A,stopReason:k,maxTokens:x}))yield e}catch(e){let t=e instanceof Error?e.message:String(e);h(`[OpenAI] Error: ${t}`,{level:`error`}),yield m({content:`API Error: ${t}`,apiError:`api_error`,error:e instanceof Error?e:Error(String(e))})}}e((()=>{O(),k(),T(),X(),Ce(),s(),p(),S(),g(),o(),y(),De(),_(),a(),b()}))();export{Ae as queryModelOpenAI};
@@ -1 +0,0 @@
1
- import{i as e,r as t}from"./parser-eVu-cTRs.js";t();export{e as parseCommand};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{OT as t,kT as n}from"./loadAgentsDir-C96o6gCj.js";import{Sr as r,bi as i,xr as a,yi as o}from"./state-D5D6QpTX.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,n,r,i){return t(e,function(e,t,a){n(i,e,r(e),a)}),i}var u=e((()=>{n()}));function d(e,t){return function(n,r){var o=i(n)?s:l,c=t?t():{};return o(n,e,a(r,2),c)}}var f=e((()=>{c(),u(),r(),o()})),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 +0,0 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./figures-5ThXQEtq.js";import{Du as i,Eh as a,GS as o,H as s,I as c,L as l,Lu as u,Oh as d,Ou as f,Ow as p,R as m,Ru as ee,Th as te,V as ne,_g as h,bg as g,ea as _,lT as re,oT as ie,vm as v,xg as ae,ym as y,z as oe,zS as b}from"./loadAgentsDir-C96o6gCj.js";import{I as x,P as S,Wt as se,Xn as ce,a as C,ai as w,di as T,fi as E,hn as D,k as O,kt as k,n as A,o as j,ot as le,r as ue,s as de,t as M,x as fe,y as N}from"./src-DL3w8VPk.js";import{t as P}from"./jsx-runtime-Bb4Xn-E0.js";import{$ as pe,Ut as F}from"./state-D5D6QpTX.js";import{C as I,x as me}from"./debug-D58GQBDG.js";import{B as L,R,V as z,a as B,cn as he,h as ge,nn as V}from"./settings-BowI3jp-.js";import{l as _e,o as ve}from"./stringUtils-D7oJIyY2.js";import{n as ye,t as be}from"./useExitOnCtrlCDWithKeybindings-L5idX6Kz.js";import{n as xe,t as Se}from"./AddWorkspaceDirectory-DgAxYgBY.js";import{t as Ce}from"./SearchBox-C9xxQzh1.js";import{n as we,t as Te}from"./useSearchInput-Bxl4wGcZ.js";import{n as H,t as Ee}from"./shadowedRuleDetection-DEo1hvGi.js";function De(){return U}var U,Oe=e((()=>{U=[]}));function ke({ruleValue:e}){switch(e.toolName){case v.name:return e.ruleContent?e.ruleContent.endsWith(`:*`)?(0,W.jsxs)(S,{dimColor:!0,children:[`Any Bash command starting with `,(0,W.jsx)(S,{bold:!0,children:e.ruleContent.slice(0,-2)})]}):(0,W.jsxs)(S,{dimColor:!0,children:[`The Bash command `,(0,W.jsx)(S,{bold:!0,children:e.ruleContent})]}):(0,W.jsx)(S,{dimColor:!0,children:`Any Bash command`});default:return e.ruleContent?null:(0,W.jsxs)(S,{dimColor:!0,children:[`Any use of the `,(0,W.jsx)(S,{bold:!0,children:e.toolName}),` tool`]})}}var W,Ae=e((()=>{M(),y(),W=P()}));function je(e){switch(e){case`localSettings`:return{label:`Project settings (local)`,description:`Saved in ${B(`localSettings`)}`,value:e};case`projectSettings`:return{label:`Project settings`,description:`Checked in at ${B(`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:a,setToolPermissionContext:o}){let s=V.map(je),c=(0,Ne.useCallback)(i=>{if(i===`cancel`){t();return}else if(V.includes(i)){let t=i,s=h(a,{type:`addRules`,rules:n,behavior:r,destination:t});ae({type:`addRules`,rules:n,behavior:r,destination:t}),o(s);let c=n.map(e=>({ruleValue:e,ruleBehavior:r,source:t})),l=Ee(s,{sandboxAutoAllowEnabled:ie.isSandboxingEnabled()&&ie.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,a,o]);return(0,G.jsxs)(N,{title:`Add ${r} permission ${_e(n.length,`rule`)}`,onCancel:t,color:`permission`,children:[(0,G.jsx)(x,{flexDirection:`column`,paddingX:2,children:n.map(e=>(0,G.jsxs)(x,{flexDirection:`column`,children:[(0,G.jsx)(S,{bold:!0,children:z(e)}),(0,G.jsx)(ke,{ruleValue:e})]},z(e)))}),(0,G.jsxs)(x,{flexDirection:`column`,marginY:1,children:[(0,G.jsx)(S,{children:n.length===1?`Where should this rule be saved?`:`Where should these rules be saved?`}),(0,G.jsx)(i,{options:s,onChange:c})]})]})}var Ne,G,Pe=e((()=>{Ne=t(w(),1),f(),M(),g(),R(),H(),re(),he(),ge(),ve(),Ae(),G=P()}));function Fe({onCancel:e,onSubmit:t,ruleBehavior:n}){let[i,a]=(0,Ie.useState)(``),[o,s]=(0,Ie.useState)(0),c=ye();se(`confirm:no`,e,{context:`Settings`});let{columns:l}=le(),d=l-6;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(x,{flexDirection:`column`,gap:1,borderStyle:`round`,paddingLeft:1,paddingRight:1,borderColor:`permission`,children:[(0,K.jsxs)(S,{bold:!0,color:`permission`,children:[`Add `,n,` permission rule`]}),(0,K.jsxs)(x,{flexDirection:`column`,children:[(0,K.jsxs)(S,{children:[`Permission rules are a tool name, optionally followed by a specifier in parentheses.`,(0,K.jsx)(k,{}),`e.g., `,(0,K.jsx)(S,{bold:!0,children:z({toolName:v.name})}),(0,K.jsx)(S,{bold:!1,children:` or `}),(0,K.jsx)(S,{bold:!0,children:z({toolName:v.name,ruleContent:`ls:*`})})]}),(0,K.jsx)(x,{borderDimColor:!0,borderStyle:`round`,marginY:1,paddingLeft:1,children:(0,K.jsx)(u,{showCursor:!0,value:i,onChange:a,onSubmit:e=>{let r=e.trim();r.length!==0&&t(L(r),n)},placeholder:`Enter permission rule${r.ellipsis}`,columns:d,cursorOffset:o,onChangeCursorOffset:s})})]})]}),(0,K.jsx)(x,{marginLeft:3,children:c.pending?(0,K.jsxs)(S,{dimColor:!0,children:[`Press `,c.keyName,` again to exit`]}):(0,K.jsx)(S,{dimColor:!0,children:`Enter to submit · Esc to cancel`})})]})}var Ie,K,Le=e((()=>{n(),Ie=t(w(),1),ee(),be(),o(),M(),b(),y(),R(),K=P()}));function Re({onHeaderFocusChange:e,onStateChange:t}){let{headerFocused:n,focusHeader:r}=C();(0,q.useEffect)(()=>{e?.(n)},[n,e]);let[a]=(0,q.useState)(()=>De()),[o,s]=(0,q.useState)(()=>new Set),[c,l]=(0,q.useState)(()=>new Set),[u,d]=(0,q.useState)(0);(0,q.useEffect)(()=>{t({approved:o,retry:c,denials:a})},[o,c,a,t]);let f=(0,q.useCallback)(e=>{let t=Number(e);s(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n})},[]),p=(0,q.useCallback)(e=>{d(Number(e))},[]);if(D((e,t)=>{e===`r`&&(l(e=>{let t=new Set(e);return t.has(u)?t.delete(u):t.add(u),t}),s(e=>{if(e.has(u))return e;let t=new Set(e);return t.add(u),t}))},{isActive:a.length>0}),a.length===0)return(0,J.jsx)(S,{dimColor:!0,children:`No recent denials. Commands denied by the auto mode classifier will appear here.`});let m=a.map((e,t)=>{let n=o.has(t),r=c.has(t)?` (retry)`:``;return{label:(0,J.jsxs)(S,{children:[(0,J.jsx)(de,{status:n?`success`:`error`,withSpace:!0}),e.display,(0,J.jsx)(S,{dimColor:!0,children:r})]}),value:String(t)}});return(0,J.jsxs)(x,{flexDirection:`column`,children:[(0,J.jsx)(S,{children:`Commands recently denied by the auto mode classifier.`}),(0,J.jsx)(x,{marginTop:1,children:(0,J.jsx)(i,{options:m,onChange:f,onFocus:p,visibleOptionCount:Math.min(10,m.length),isDisabled:n,onUpFromFirstItem:r})})]})}var q,J,ze=e((()=>{q=t(w(),1),M(),Oe(),f(),J=P()}));function Be({directoryPath:e,onRemove:t,onCancel:n,permissionContext:r,setPermissionContext:a}){let o=(0,Ve.useCallback)(()=>{a(h(r,{type:`removeDirectories`,directories:[e],destination:`session`})),t()},[e,r,a,t]),s=(0,Ve.useCallback)(e=>{e===`yes`?o():n()},[o,n]);return(0,Y.jsxs)(N,{title:`Remove directory from workspace?`,onCancel:n,color:`error`,children:[(0,Y.jsx)(x,{marginX:2,flexDirection:`column`,children:(0,Y.jsx)(S,{bold:!0,children:e})}),(0,Y.jsx)(S,{children:`Work Mate will no longer have access to files in this directory.`}),(0,Y.jsx)(i,{onChange:s,onCancel:n,options:[{label:`Yes`,value:`yes`},{label:`No`,value:`no`}]})]})}var Ve,Y,He=e((()=>{Ve=t(w(),1),f(),M(),g(),Y=P()}));function Ue({onExit:e,toolPermissionContext:t,onRequestAddDirectory:n,onRequestRemoveDirectory:a,onHeaderFocusChange:o}){let{headerFocused:s,focusHeader:c}=C();(0,X.useEffect)(()=>{o?.(s)},[s,o]);let l=We.useMemo(()=>Array.from(t.additionalWorkingDirectories.keys()).map(e=>({path:e,isCurrent:!1,isDeletable:!0})),[t.additionalWorkingDirectories]),u=(0,X.useCallback)(e=>{if(e===`add-directory`){n();return}let t=l.find(t=>t.path===e);t?.isDeletable&&a(t.path)},[l,n,a]),d=(0,X.useCallback)(()=>e(`Workspace dialog dismissed`,{display:`system`}),[e]),f=We.useMemo(()=>{let e=l.map(e=>({label:e.path,value:e.path}));return e.push({label:`Add directory${r.ellipsis}`,value:`add-directory`}),e},[l]);return(0,Z.jsxs)(x,{flexDirection:`column`,marginBottom:1,children:[(0,Z.jsxs)(x,{flexDirection:`row`,marginTop:1,marginLeft:2,gap:1,children:[(0,Z.jsx)(S,{children:`- ${pe()}`}),(0,Z.jsx)(S,{dimColor:!0,children:`(Original working directory)`})]}),(0,Z.jsx)(i,{options:f,onChange:u,onCancel:d,visibleOptionCount:Math.min(10,f.length),onUpFromFirstItem:c,isDisabled:s})]})}var We,X,Z,Ge=e((()=>{n(),We=t(w(),1),X=t(w(),1),F(),f(),M(),Z=P()}));function Ke({rule:e}){return(0,$.jsx)(S,{dimColor:!0,children:`From ${s(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=ye();se(`confirm:no`,n,{context:`Confirmation`});let a=(0,$.jsxs)(x,{flexDirection:`column`,marginX:2,children:[(0,$.jsx)(S,{bold:!0,children:z(e.ruleValue)}),(0,$.jsx)(ke,{ruleValue:e.ruleValue}),(0,$.jsx)(Ke,{rule:e})]}),o=(0,$.jsx)(x,{marginLeft:3,children:r.pending?(0,$.jsxs)(S,{dimColor:!0,children:[`Press `,r.keyName,` again to exit`]}):(0,$.jsx)(S,{dimColor:!0,children:`Esc to cancel`})});return e.source===`policySettings`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(x,{flexDirection:`column`,gap:1,borderStyle:`round`,paddingLeft:1,paddingRight:1,borderColor:`permission`,children:[(0,$.jsx)(S,{bold:!0,color:`permission`,children:`Rule details`}),a,(0,$.jsxs)(S,{italic:!0,children:[`This rule is configured by managed settings and cannot be modified.`,`
2
- `,`Contact your system administrator for more information.`]})]}),o]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(x,{flexDirection:`column`,gap:1,borderStyle:`round`,paddingLeft:1,paddingRight:1,borderColor:`error`,children:[(0,$.jsxs)(S,{bold:!0,color:`error`,children:[`Delete `,qe(e.ruleBehavior),` tool?`]}),a,(0,$.jsx)(S,{children:`Are you sure you want to delete this permission rule?`}),(0,$.jsx)(i,{onChange:e=>e===`yes`?t():n(),onCancel:n,options:[{label:`Yes`,value:`yes`},{label:`No`,value:`no`}]})]}),o]})}function Ye(e){let{options:t,searchQuery:n,isSearchMode:r,isFocused:a,onSelect:o,onCancel:s,lastFocusedRuleKey:c,cursorOffset:l,onHeaderFocusChange:u}=e,d=j(),{headerFocused:f,focusHeader:p,blurHeader:m}=C();return(0,Q.useEffect)(()=>{r&&f&&m()},[r,f,m]),(0,Q.useEffect)(()=>{u?.(f)},[f,u]),(0,$.jsxs)(x,{flexDirection:`column`,children:[(0,$.jsx)(x,{marginBottom:1,flexDirection:`column`,children:(0,$.jsx)(O,{query:n,isFocused:r&&!f,isTerminalFocused:a,width:d,cursorOffset:l})}),(0,$.jsx)(i,{options:t,onChange:o,onCancel:s,visibleOptionCount:Math.min(10,t.length),isDisabled:r||f,defaultFocusValue:c,onUpFromFirstItem:p})]})}function Xe({tab:e,getRulesOptions:t,handleToolSelect:n,...r}){return(0,$.jsxs)(x,{flexDirection:`column`,flexShrink:e===`allow`?0:void 0,children:[(0,$.jsx)(S,{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 i=De().length>0,o=t??(i?`recent`:`allow`),[s,u]=(0,Q.useState)([]),f=a(e=>e.toolPermissionContext),p=d(),ee=ce(),te=(0,Q.useRef)({approved:new Set,retry:new Set,denials:[]}),ne=(0,Q.useCallback)(e=>{te.current=e},[]),[g,_]=(0,Q.useState)(),[re,ie]=(0,Q.useState)(),[v,y]=(0,Q.useState)(null),[b,C]=(0,Q.useState)(null),[w,E]=(0,Q.useState)(!1),[D,O]=(0,Q.useState)(null),[k,j]=(0,Q.useState)(!1),[le,de]=(0,Q.useState)(!0),M=(0,Q.useCallback)(e=>{de(e)},[]),N=(0,Q.useMemo)(()=>{let e=new Map;return l(f).forEach(t=>{e.set(I(t),t)}),e},[f]),P=(0,Q.useMemo)(()=>{let e=new Map;return oe(f).forEach(t=>{e.set(I(t),t)}),e},[f]),pe=(0,Q.useMemo)(()=>{let e=new Map;return m(f).forEach(t=>{e.set(I(t),t)}),e},[f]),F=(0,Q.useCallback)((e,t=``)=>{let n=(()=>{switch(e){case`allow`:return N;case`deny`:return P;case`ask`:return pe;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=z(r.ruleValue).toLowerCase(),t=z(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=z(r.ruleValue);if(t&&!n.toLowerCase().includes(o))continue;i.push({label:n,value:e})}}return{options:i,rulesByKey:n}},[N,P,pe]),me=ye(),L=!g&&!v&&!b&&!w&&!D,{query:R,setQuery:B,cursorOffset:he}=we({isActive:L&&k,onExit:()=>{j(!1)}}),ge=(0,Q.useCallback)(e=>{L&&(k||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))))},[L,k,B]),V=(0,Q.useCallback)((e,t)=>{let{rulesByKey:n}=F(t);if(e===`add-new-rule`){y(t);return}else{_(n.get(e));return}},[F]),_e=(0,Q.useCallback)(()=>{y(null)},[]),ve=(0,Q.useCallback)((e,t)=>{C({ruleValue:e,ruleBehavior:t}),y(null)},[]),be=(0,Q.useCallback)((e,t)=>{C(null);for(let t of e)u(e=>[...e,`Added ${t.ruleBehavior} rule ${T.bold(z(t.ruleValue))}`]);if(t&&t.length>0)for(let e of t){let t=e.shadowType===`deny`?`blocked`:`shadowed`;u(n=>[...n,T.yellow(`${r.warning} Warning: ${z(e.rule.ruleValue)} is ${t}`),T.dim(` ${e.reason}`),T.dim(` Fix: ${e.fix}`)])}},[]),xe=(0,Q.useCallback)(()=>{C(null)},[]),Ce=(0,Q.useCallback)(()=>E(!0),[]),Te=(0,Q.useCallback)(e=>O(e),[]),H=(0,Q.useCallback)(()=>{let t=te.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||s.length>0?e([...a.length>0?[`Approved ${a.map(e=>T.bold(e.display)).join(`, `)}`]:[],...s].join(`
3
- `)):e(`Permissions dialog dismissed`,{display:`system`})},[s,e,n]);se(`confirm:no`,H,{context:`Settings`,isActive:L&&!k});let Ee=()=>{if(!g)return;let{options:e}=F(g.ruleBehavior),t=I(g),n=e.filter(e=>e.value!==`add-new-rule`).map(e=>e.value),r=n.indexOf(t),i;r!==-1&&(r<n.length-1?i=n[r+1]:r>0&&(i=n[r-1])),ie(i),c({rule:g,initialContext:f,setToolPermissionContext(e){p(t=>({...t,toolPermissionContext:e}))}}),u(e=>[...e,`Deleted ${g.ruleBehavior} rule ${T.bold(z(g.ruleValue))}`]),_(void 0)};if(g)return(0,$.jsx)(Je,{rule:g,onDelete:Ee,onCancel:()=>_(void 0)});if(v&&v!==`workspace`&&v!==`recent`)return(0,$.jsx)(Fe,{onCancel:_e,onSubmit:ve,ruleBehavior:v});if(b)return(0,$.jsx)(Me,{onAddRules:be,onCancel:xe,ruleValues:[b.ruleValue],ruleBehavior:b.ruleBehavior,initialContext:f,setToolPermissionContext:e=>{p(t=>({...t,toolPermissionContext:e}))}});if(w)return(0,$.jsx)(Se,{onAddDirectory:(e,t)=>{let n={type:`addDirectories`,directories:[e],destination:t?`localSettings`:`session`},r=h(f,n);p(e=>({...e,toolPermissionContext:r})),t&&ae(n),u(n=>[...n,`Added directory ${T.bold(e)} to workspace${t?` and saved to local settings`:` for this session`}`]),E(!1)},onCancel:()=>E(!1),permissionContext:f});if(D)return(0,$.jsx)(Be,{directoryPath:D,onRemove:()=>{u(e=>[...e,`Removed directory ${T.bold(D)} from workspace`]),O(null)},onCancel:()=>O(null),permissionContext:f,setPermissionContext:e=>{p(t=>({...t,toolPermissionContext:e}))}});let U={searchQuery:R,isSearchMode:k,isFocused:ee,onCancel:H,lastFocusedRuleKey:re,cursorOffset:he,getRulesOptions:F,handleToolSelect:V,onHeaderFocusChange:M};return(0,$.jsx)(x,{flexDirection:`column`,onKeyDown:ge,children:(0,$.jsxs)(fe,{color:`permission`,children:[(0,$.jsxs)(ue,{title:`Permissions:`,color:`permission`,defaultTab:o,hidden:!!g||!!v||!!b||w||!!D,initialHeaderFocused:!i,navFromContent:!k,children:[(0,$.jsx)(A,{id:`recent`,title:`Recently denied`,children:(0,$.jsx)(Re,{onHeaderFocusChange:M,onStateChange:ne})}),(0,$.jsx)(A,{id:`allow`,title:`Allow`,children:(0,$.jsx)(Xe,{tab:`allow`,...U})}),(0,$.jsx)(A,{id:`ask`,title:`Ask`,children:(0,$.jsx)(Xe,{tab:`ask`,...U})}),(0,$.jsx)(A,{id:`deny`,title:`Deny`,children:(0,$.jsx)(Xe,{tab:`deny`,...U})}),(0,$.jsx)(A,{id:`workspace`,title:`Workspace`,children:(0,$.jsxs)(x,{flexDirection:`column`,children:[(0,$.jsx)(S,{children:`Work Mate can read files in the workspace, and make edits when auto-accept edits is on.`}),(0,$.jsx)(Ue,{onExit:e,toolPermissionContext:f,onRequestAddDirectory:Ce,onRequestRemoveDirectory:Te,onHeaderFocusChange:M})]})})]}),(0,$.jsx)(x,{marginTop:1,paddingLeft:1,children:(0,$.jsx)(S,{dimColor:!0,children:me.pending?(0,$.jsxs)($.Fragment,{children:[`Press `,me.keyName,` again to exit`]}):le?(0,$.jsx)($.Fragment,{children:`←/→ tab switch · ↓ return · Esc cancel`}):k?(0,$.jsx)($.Fragment,{children:`Type to filter · Enter/↓ select · ↑ tabs · Esc clear`}):i&&o===`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((()=>{E(),n(),Q=t(w(),1),te(),g(),f(),be(),Te(),M(),b(),Oe(),R(),ne(),me(),Ce(),Pe(),xe(),Ae(),Le(),ze(),He(),Ge(),$=P()})),$e,et;e((()=>{Qe(),_(),$e=P(),et=async(e,t)=>(0,$e.jsx)(Ze,{onExit:e,onRetryDenials:e=>{t.setMessages(t=>[...t,p(e)])}})}))();export{et as call};