@readmagic/workmate 0.0.23 → 0.0.24

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 (210) hide show
  1. package/dist/chunks/{AddWorkspaceDirectory-OgcBcK5A.js → AddWorkspaceDirectory-Ch8IcWXO.js} +1 -1
  2. package/dist/chunks/AgentsMdExternalIncludesDialog-Cyia0s4g.js +1 -0
  3. package/dist/chunks/{AgentsMdExternalIncludesDialog-CNEifEyV.js → AgentsMdExternalIncludesDialog-LjI_H_Au.js} +1 -1
  4. package/dist/chunks/{App-B-3tPQ3k.js → App-BOqh_1tN.js} +1 -1
  5. package/dist/chunks/{BackgroundTasksDialog-COuhHcey.js → BackgroundTasksDialog-CSEuuoq9.js} +1 -1
  6. package/dist/chunks/{BypassPermissionsModeDialog-bJek4siJ.js → BypassPermissionsModeDialog-CwfCwUr9.js} +1 -1
  7. package/dist/chunks/CustomSelect-wmZ9jz0W.js +1 -0
  8. package/dist/chunks/{DiffDialog-B3X9FMpO.js → DiffDialog-BpXIEWiE.js} +1 -1
  9. package/dist/chunks/Doctor-CMpr7tdf.js +1 -0
  10. package/dist/chunks/{Doctor-6PXyjIi6.js → Doctor-DqW6j3_B.js} +1 -1
  11. package/dist/chunks/{ExitFlow-DgAZp_8U.js → ExitFlow-DacaBTlk.js} +1 -1
  12. package/dist/chunks/{Grove-CHatOzcE.js → Grove-CNqYPWI6.js} +1 -1
  13. package/dist/chunks/{InvalidConfigDialog-DXL92MN9.js → InvalidConfigDialog-0TMJItCC.js} +1 -1
  14. package/dist/chunks/{InvalidSettingsDialog-Dtmpzeps.js → InvalidSettingsDialog-iwh8H52b.js} +1 -1
  15. package/dist/chunks/{KeybindingProviderSetup-DA37QUFs.js → KeybindingProviderSetup-D49HHTXD.js} +1 -1
  16. package/dist/chunks/{MCPConnectionManager-thZd-xA_.js → MCPConnectionManager-Cie77ZAK.js} +1 -1
  17. package/dist/chunks/{MCPToolListView-CpY-YJg4.js → MCPToolListView-B4ehtkXd.js} +1 -1
  18. package/dist/chunks/{McpParsingWarnings-JvChf3xr.js → McpParsingWarnings-Bff66RtJ.js} +1 -1
  19. package/dist/chunks/{MessageSelector-C0_iw7SI.js → MessageSelector-Dpd6Iywp.js} +1 -1
  20. package/dist/chunks/{Messages-K4DDsDP9.js → Messages-DN7M3oS_.js} +1 -1
  21. package/dist/chunks/{Onboarding-C1UdzM-1.js → Onboarding-CQmE3rUf.js} +1 -1
  22. package/dist/chunks/{PromptInputFooterSuggestions-AyLog8p7.js → PromptInputFooterSuggestions-HI6HH3TP.js} +1 -1
  23. package/dist/chunks/{PromptInputHelpMenu-oyic20ip.js → PromptInputHelpMenu-3QNUC2Cg.js} +1 -1
  24. package/dist/chunks/{ProviderSetup-XcBHjUnd.js → ProviderSetup-BCSPsvfv.js} +1 -1
  25. package/dist/chunks/{QueryEngine-DYxBjJ4i.js → QueryEngine-DdLWvJv6.js} +1 -1
  26. package/dist/chunks/{REPL-CQBJRrT0.js → REPL-BqO9KcK_.js} +5 -5
  27. package/dist/chunks/REPL-CmZmypfF.js +1 -0
  28. package/dist/chunks/{ResumeConversation-Dl8H9Gfy.js → ResumeConversation-DBqX7gva.js} +1 -1
  29. package/dist/chunks/SearchExtraToolsTool-BsSoILFj.js +1 -0
  30. package/dist/chunks/{SelectMulti-Bc6l11_K.js → SelectMulti-BQRHed-d.js} +1 -1
  31. package/dist/chunks/{Settings-TGp3fPrS.js → Settings-B-7yBewS.js} +3 -3
  32. package/dist/chunks/{Spinner-zYPFVFHN.js → Spinner-ByQXTvAA.js} +1 -1
  33. package/dist/chunks/{TextInput-CD9iau2k.js → TextInput-B8ruWRf2.js} +1 -1
  34. package/dist/chunks/{ThemePicker-0F0hZYPX.js → ThemePicker-BQErFFW1.js} +1 -1
  35. package/dist/chunks/{TrustDialog-C76YiMKz.js → TrustDialog-BIhz6AZE.js} +1 -1
  36. package/dist/chunks/{_baseEach-4ff-vRlp.js → _baseEach-CsIRoaTH.js} +1 -1
  37. package/dist/chunks/{add-dir-JMsRLGfx.js → add-dir-CrUDs19x.js} +1 -1
  38. package/dist/chunks/{agentDisplay-BReJUBWg.js → agentDisplay-M4pfwbMC.js} +1 -1
  39. package/dist/chunks/{agents-9qQ8I6zW.js → agents-CGaCQeLw.js} +1 -1
  40. package/dist/chunks/{agents-B3x8yJ_r.js → agents-DddX7lLX.js} +1 -1
  41. package/dist/chunks/{allErrors-DfWylHSw.js → allErrors-BF73lon8.js} +1 -1
  42. package/dist/chunks/{backgroundHousekeeping-CVNIhQg8.js → backgroundHousekeeping-Bq3LMsVR.js} +2 -2
  43. package/dist/chunks/backgroundHousekeeping-Cl3Ox7Qh.js +1 -0
  44. package/dist/chunks/{branch-C4TsMEkx.js → branch-Yg_taNlT.js} +1 -1
  45. package/dist/chunks/{btw-Dn1eYFAz.js → btw-udbprVvu.js} +1 -1
  46. package/dist/chunks/caches-ChjIEcdd.js +1 -0
  47. package/dist/chunks/{caches-DArHxBgL.js → caches-DLJ6urv-.js} +1 -1
  48. package/dist/chunks/{clear-Bdhb6b39.js → clear-B8ZtFPOK.js} +1 -1
  49. package/dist/chunks/commands-CVCpJo7M.js +1 -0
  50. package/dist/chunks/{compact-Bu9BUpxV.js → compact-izk6RKHQ.js} +1 -1
  51. package/dist/chunks/config-CFqpXMFX.js +1 -0
  52. package/dist/chunks/{context-CY_yfdYa.js → context-BbVm4SWK.js} +1 -1
  53. package/dist/chunks/{context-noninteractive-Dd4xIoP1.js → context-noninteractive-C7wrRZnM.js} +1 -1
  54. package/dist/chunks/context-noninteractive-x0HAzWhc.js +1 -0
  55. package/dist/chunks/conversation-DouVzO0K.js +1 -0
  56. package/dist/chunks/{conversation-DUu9qBnq.js → conversation-DrVkifKy.js} +1 -1
  57. package/dist/chunks/{conversationRecovery-2ft8sCPE.js → conversationRecovery-DliPBo_z.js} +1 -1
  58. package/dist/chunks/{crossProjectResume-6boHMUBx.js → crossProjectResume-DxMy05_P.js} +1 -1
  59. package/dist/chunks/{datadog-BPuGcxxC.js → datadog-Cu3s7P48.js} +1 -1
  60. package/dist/chunks/{diff-BOAElpfQ.js → diff-DdpHThJ7.js} +1 -1
  61. package/dist/chunks/doctor-D_kV_D_l.js +1 -0
  62. package/dist/chunks/{entry-TNOoyy7_.js → entry-Bxseqbi_.js} +1 -1
  63. package/dist/chunks/{esm-eTAUP-La.js → esm-BXTZz3av.js} +1 -1
  64. package/dist/chunks/{exit-DXApFJIP.js → exit-C_R_FgzR.js} +1 -1
  65. package/dist/chunks/{extraUsage-CmQaLPV1.js → extraUsage-xMuDiNKh.js} +1 -1
  66. package/dist/chunks/extractMemories-D4Dl1itt.js +1 -0
  67. package/dist/chunks/{fast-eGx2IxD7.js → fast-DH-C5IZs.js} +1 -1
  68. package/dist/chunks/fast-bopOPrtf.js +1 -0
  69. package/dist/chunks/fetchModelList-DC4VQpqa.js +1 -0
  70. package/dist/chunks/{fetchModelList-CxLsVNsu.js → fetchModelList-FE8tzTDc.js} +1 -1
  71. package/dist/chunks/{fileSuggestions-DHxdwq28.js → fileSuggestions-C-9unnoJ.js} +1 -1
  72. package/dist/chunks/{firstPartyEventLogger-M6UMli2c.js → firstPartyEventLogger-QmjjQmgt.js} +2 -2
  73. package/dist/chunks/firstPartyEventLogger-lFeqhtfh.js +1 -0
  74. package/dist/chunks/{gemini-D_ORb_L6.js → gemini-C_ApXgwc.js} +1 -1
  75. package/dist/chunks/{generateSessionName-BQoDduyA.js → generateSessionName-CQ03xlYI.js} +1 -1
  76. package/dist/chunks/{goal-D7c2mSds.js → goal-CdL29Y8C.js} +1 -1
  77. package/dist/chunks/{grok-B2-ZbUiR.js → grok-C6WAslUT.js} +1 -1
  78. package/dist/chunks/{help-CZJdRviD.js → help-DxanITNN.js} +1 -1
  79. package/dist/chunks/{history-CQiUERTL.js → history-BMycjPTT.js} +1 -1
  80. package/dist/chunks/hooks-D9ApLkBp.js +1 -0
  81. package/dist/chunks/{hooks-DIvN6gdv.js → hooks-DR3IYPJ3.js} +1 -1
  82. package/dist/chunks/{install-T_CV1Slu.js → install-0D9u2dZw.js} +1 -1
  83. package/dist/chunks/{instrumentation-BjqUZ383.js → instrumentation-BFiGwntt.js} +3 -3
  84. package/dist/chunks/{job-R6c4-3c8.js → job-YhJQWgE0.js} +1 -1
  85. package/dist/chunks/{keybindings-CLRaiL_Z.js → keybindings-DZrF9iNd.js} +1 -1
  86. package/dist/chunks/{launchLocalMemory-DrbKrwXc.js → launchLocalMemory-DhJ56KDc.js} +1 -1
  87. package/dist/chunks/{launchOnboarding-tqsMD8ni.js → launchOnboarding-DmMoZwv5.js} +1 -1
  88. package/dist/chunks/{loadAgentsDir-DlPbtIsS.js → loadAgentsDir-B0Anodo0.js} +23 -23
  89. package/dist/chunks/loadAgentsDir-BbUR6pqH.js +1 -0
  90. package/dist/chunks/{loadPluginHooks-C_msxVIc.js → loadPluginHooks-BSwCtQ6T.js} +1 -1
  91. package/dist/chunks/{localSearch-CK-sFzPm.js → localSearch-BxLYi6w_.js} +1 -1
  92. package/dist/chunks/localSearch-zfn7jgrh.js +1 -0
  93. package/dist/chunks/{logoUtils-x2pHV-Nl.js → logoUtils-CRxTutvr.js} +1 -1
  94. package/dist/chunks/{magicDocs-BEF8D3if.js → magicDocs-Bkz7ZcmL.js} +1 -1
  95. package/dist/chunks/{main-kOVUGxOS.js → main-9ksgUUY_.js} +5 -5
  96. package/dist/chunks/{mcp-D0wAJrRT.js → mcp-ChF12reQ.js} +1 -1
  97. package/dist/chunks/{mcp-mgOlm1cY.js → mcp-DoEl5uah.js} +1 -1
  98. package/dist/chunks/{mcp-BNd29r6p.js → mcp-hp9qqjAy.js} +2 -2
  99. package/dist/chunks/{memory-DDLk9_LJ.js → memory-Qv-wGNQ5.js} +1 -1
  100. package/dist/chunks/{mode-CcNsWgK3.js → mode-bFXPCR2P.js} +1 -1
  101. package/dist/chunks/{model-DzCP4K-9.js → model-6lkW4o2c.js} +1 -1
  102. package/dist/chunks/{model-BwBG0V1u.js → model-BvQFFOf8.js} +1 -1
  103. package/dist/chunks/{modelOptions-DRaG3bo0.js → modelOptions-BBvF3wHK.js} +1 -1
  104. package/dist/chunks/{nativeInstaller-C3pVPqrZ.js → nativeInstaller-CdjmE9Zy.js} +1 -1
  105. package/dist/chunks/{notifications-4wP1Tx9Y.js → notifications-Bc6k-Ozy.js} +1 -1
  106. package/dist/chunks/{onChangeAppState-BlaoFbYF.js → onChangeAppState-DLjZ1x95.js} +1 -1
  107. package/dist/chunks/{openai-CDN71NdX.js → openai-D46QvESE.js} +1 -1
  108. package/dist/chunks/{overlayContext-BT2Lq8ei.js → overlayContext-8--_fbvY.js} +1 -1
  109. package/dist/chunks/{partition-CIl_ORUT.js → partition-DznN4XZH.js} +1 -1
  110. package/dist/chunks/{permissions-zSNOZSwr.js → permissions-DmGFViHI.js} +1 -1
  111. package/dist/chunks/{pidLock-BTqO-h7Y.js → pidLock-Cm4sW35f.js} +2 -2
  112. package/dist/chunks/{plan-Bs6em6lk.js → plan-CzGBz_87.js} +1 -1
  113. package/dist/chunks/{plugin-DDDxjBa0.js → plugin-CluR79xX.js} +1 -1
  114. package/dist/chunks/{pluginAutoupdate-8qugAFhb.js → pluginAutoupdate-ennb9k8_.js} +1 -1
  115. package/dist/chunks/{pluginBlocklist-q01ackCf.js → pluginBlocklist-9OrNEh--.js} +1 -1
  116. package/dist/chunks/{pluginCliCommands-DXZfCZsv.js → pluginCliCommands-CJv5uhOG.js} +1 -1
  117. package/dist/chunks/{pluginFlagging-BG2MHCQJ.js → pluginFlagging-js_-WmYj.js} +1 -1
  118. package/dist/chunks/{pluginOperations-hXYLrzM2.js → pluginOperations-CcUSHAIa.js} +1 -1
  119. package/dist/chunks/pluginStartupCheck-CRBUO9gP.js +1 -0
  120. package/dist/chunks/{pluginStartupCheck-DTMa6TgL.js → pluginStartupCheck-SRXOyqr7.js} +1 -1
  121. package/dist/chunks/{plugins-COoGBYk6.js → plugins-IwwaCDba.js} +1 -1
  122. package/dist/chunks/{print-BASybEtO.js → print-CgszM1ea.js} +2 -2
  123. package/dist/chunks/{processBashCommand-DDi_Pymt.js → processBashCommand-D098WsqY.js} +1 -1
  124. package/dist/chunks/{processSlashCommand-Cq9kaoSF.js → processSlashCommand-DOQFjJ88.js} +1 -1
  125. package/dist/chunks/prompt-BKPmDAuL.js +1 -0
  126. package/dist/chunks/{prompt-mM79EGnT.js → prompt-CJ1l3XXk.js} +1 -1
  127. package/dist/chunks/prompt-CgOklk7z.js +1 -0
  128. package/dist/chunks/{promptEditor-DLGN_eLu.js → promptEditor-DoGHJN_W.js} +1 -1
  129. package/dist/chunks/{reconciler-CeXqh95g.js → reconciler-ykkSPR-i.js} +1 -1
  130. package/dist/chunks/{refresh-Ce2yk28a.js → refresh-Dn_I1R4v.js} +1 -1
  131. package/dist/chunks/{reject-Bld5E-bn.js → reject-DtcCfuZV.js} +1 -1
  132. package/dist/chunks/{reload-plugins-C42xSB5l.js → reload-plugins-CQZFQLWP.js} +1 -1
  133. package/dist/chunks/{rename-CtBghpxZ.js → rename-DyEfsZiq.js} +1 -1
  134. package/dist/chunks/{resume-BWkaTDqd.js → resume-BcXEDUqZ.js} +1 -1
  135. package/dist/chunks/{runtimeObserver-1wQO8HSZ.js → runtimeObserver-DEuR8z0f.js} +1 -1
  136. package/dist/chunks/{runtimeObserver-XQrOux41.js → runtimeObserver-PJ1o8GRA.js} +2 -2
  137. package/dist/chunks/sandbox-adapter-DfB9kgQD.js +1 -0
  138. package/dist/chunks/{sandbox-toggle-Dir9Polo.js → sandbox-toggle-D9GDUsTl.js} +1 -1
  139. package/dist/chunks/searchExtraTools-D4gMMQv0.js +1 -0
  140. package/dist/chunks/{select-Bxf5-5sI.js → select-DIxfl_VN.js} +1 -1
  141. package/dist/chunks/sessionFileAccessHooks-lbgHnVvi.js +1 -0
  142. package/dist/chunks/{sessionObserver-DS4G6mb9.js → sessionObserver-BtKjvteq.js} +1 -1
  143. package/dist/chunks/sessionObserver-D6qzEdGJ.js +1 -0
  144. package/dist/chunks/sessionStorage-C_7gow_z.js +1 -0
  145. package/dist/chunks/{sessionTracing-BoDDYLxW.js → sessionTracing-CtbeAD0s.js} +1 -1
  146. package/dist/chunks/{setup-BRypY6iT.js → setup-qecdf-ES.js} +2 -2
  147. package/dist/chunks/{shadowedRuleDetection-BRxZjobz.js → shadowedRuleDetection-Bg_aIc5Z.js} +1 -1
  148. package/dist/chunks/{sideQuestion-DLJxyrlp.js → sideQuestion-D49GsfH7.js} +1 -1
  149. package/dist/chunks/sinks-C-lP7uyO.js +1 -0
  150. package/dist/chunks/{sinks-Cz2HfgMU.js → sinks-De-B1lPQ.js} +1 -1
  151. package/dist/chunks/{skillChangeDetector-xviGstqm.js → skillChangeDetector-DkOJoNhT.js} +1 -1
  152. package/dist/chunks/{skillGapStore-CKN_d3pO.js → skillGapStore-CcFoHNLl.js} +2 -2
  153. package/dist/chunks/{skillLifecycle-BMY2JGGG.js → skillLifecycle-Bnz_4wE5.js} +2 -2
  154. package/dist/chunks/{skillSearchPanel-D9trHULQ.js → skillSearchPanel-C_5yUhqn.js} +2 -2
  155. package/dist/chunks/{skills-CX_AvwLG.js → skills-BE5scC-g.js} +1 -1
  156. package/dist/chunks/status-Dw09WZLd.js +1 -0
  157. package/dist/chunks/{statusNoticeHelpers-vFVgIYuw.js → statusNoticeHelpers-BRQpUIlH.js} +1 -1
  158. package/dist/chunks/switcher-CgZVah7U.js +1 -0
  159. package/dist/chunks/{switcher-CAajZeNL.js → switcher-DZwUo5Ed.js} +1 -1
  160. package/dist/chunks/{tasks-BWNQr2d3.js → tasks-DdcUQEeD.js} +1 -1
  161. package/dist/chunks/{templateJobs-gUET39Ho.js → templateJobs-C8qsPrLj.js} +1 -1
  162. package/dist/chunks/{theme-B7fKI6E5.js → theme-f1h2QI8J.js} +1 -1
  163. package/dist/chunks/{tipRegistry-DamZr34w.js → tipRegistry-B71o4qWr.js} +1 -1
  164. package/dist/chunks/{toolEventObserver-BL06sDI4.js → toolEventObserver-7QP38x4t.js} +1 -1
  165. package/dist/chunks/{toolPool-CX5wDBi1.js → toolPool-V-7Yv0GA.js} +1 -1
  166. package/dist/chunks/{use-select-navigation-BiUJdWai.js → use-select-navigation-hWL5VHnL.js} +1 -1
  167. package/dist/chunks/{useExitOnCtrlCDWithKeybindings-C9BYG8Bo.js → useExitOnCtrlCDWithKeybindings-BKwzUpgb.js} +1 -1
  168. package/dist/chunks/useMainLoopModel-DxvV70Ru.js +1 -0
  169. package/dist/chunks/{useManagePlugins-BqfIVa6E.js → useManagePlugins-BXLXazrR.js} +1 -1
  170. package/dist/chunks/useMergedTools-CCgnBJzO.js +1 -0
  171. package/dist/chunks/{useSearchInput-B25K1RnK.js → useSearchInput-CzopttqC.js} +1 -1
  172. package/dist/chunks/{useSettingsErrors-DYQ44kX4.js → useSettingsErrors-SFPWfxsA.js} +1 -1
  173. package/dist/chunks/{util-CtlC2dsN.js → util-Cbb3S6SX.js} +1 -1
  174. package/dist/chunks/{validatePlugin-D6tFo87L.js → validatePlugin-BMSoeb_b.js} +1 -1
  175. package/dist/chunks/worktree-Vm-SNY5x.js +1 -0
  176. package/dist/cli.js +1 -1
  177. package/package.json +1 -1
  178. package/dist/chunks/AgentsMdExternalIncludesDialog-CDNd5-7E.js +0 -1
  179. package/dist/chunks/CustomSelect-DoeEXOIP.js +0 -1
  180. package/dist/chunks/Doctor-DNgkgYhB.js +0 -1
  181. package/dist/chunks/REPL-CrVuMQY2.js +0 -1
  182. package/dist/chunks/SearchExtraToolsTool-lv7VE50N.js +0 -1
  183. package/dist/chunks/backgroundHousekeeping-BGxHB_OX.js +0 -1
  184. package/dist/chunks/caches-BGzKwpnc.js +0 -1
  185. package/dist/chunks/commands-QepeBbFn.js +0 -1
  186. package/dist/chunks/config-D58C3_Lu.js +0 -1
  187. package/dist/chunks/context-noninteractive-BDDi3NLF.js +0 -1
  188. package/dist/chunks/conversation-B0wxBwzv.js +0 -1
  189. package/dist/chunks/doctor-CkLzqAMd.js +0 -1
  190. package/dist/chunks/extractMemories-xP63mv6R.js +0 -1
  191. package/dist/chunks/fast-C5nQH8rm.js +0 -1
  192. package/dist/chunks/fetchModelList-D24lRIgR.js +0 -1
  193. package/dist/chunks/firstPartyEventLogger-BVAogAX8.js +0 -1
  194. package/dist/chunks/hooks-BNuUlMzL.js +0 -1
  195. package/dist/chunks/loadAgentsDir-CcmY8zCj.js +0 -1
  196. package/dist/chunks/localSearch-DrUj0B-d.js +0 -1
  197. package/dist/chunks/pluginStartupCheck-HS1ZceZa.js +0 -1
  198. package/dist/chunks/prompt-CHobfCB1.js +0 -1
  199. package/dist/chunks/prompt-CMm6RHHc.js +0 -1
  200. package/dist/chunks/sandbox-adapter-8GO6eJxw.js +0 -1
  201. package/dist/chunks/searchExtraTools-BhDq8DTJ.js +0 -1
  202. package/dist/chunks/sessionFileAccessHooks-CozocHQE.js +0 -1
  203. package/dist/chunks/sessionObserver-DGEQM4cO.js +0 -1
  204. package/dist/chunks/sessionStorage-BcAscOGE.js +0 -1
  205. package/dist/chunks/sinks-CGdKmq_8.js +0 -1
  206. package/dist/chunks/status-Daaak6Bo.js +0 -1
  207. package/dist/chunks/switcher-BpgmH4AI.js +0 -1
  208. package/dist/chunks/useMainLoopModel-DwjSVzzO.js +0 -1
  209. package/dist/chunks/useMergedTools-Bw8FchX8.js +0 -1
  210. package/dist/chunks/worktree-B8apCnVe.js +0 -1
@@ -1,2 +1,2 @@
1
- import{Ay as e,B as t,By as n,Ch as r,Ds as i,Dy as a,E_ as o,Ec as s,Es as c,Ey as l,Hy as ee,Ly as u,My as d,Nb as f,Ny as p,Oy as m,Pb as h,Py as g,Ry as te,Sy as ne,T_ as _,Tc as v,Uy as y,V as b,Vy as x,Wy as S,Yi as C,_y as w,aS as T,bl as E,by as D,cy as O,dy as k,fy as A,gy as j,hy as M,jy as N,ky as P,ly as F,my as I,ny as re,py as L,sy as R,ty as z,uy as B,vy as V,wh as H,wy as U,xy as W,yl as G,yy as K}from"./loadAgentsDir-DlPbtIsS.js";import{C as q,x as J}from"./debug-Bglx1aTu.js";import{o as Y,s as X}from"./log-D2TIwHBV.js";import{d as ie,o as ae}from"./model-BwBG0V1u.js";import{_n as Z,gn as oe,vn as se}from"./prompt-mM79EGnT.js";import Q from"node:process";ee(),j(),I(),n();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},D,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},U,t)}async getTask(e,t){return this._server.getTask({taskId:e},t)}async getTaskResult(e,t,n){return this._server.getTaskResult({taskId:e},t,n)}async listTasks(e,t){return this._server.listTasks(e?{cursor:e}:void 0,t)}async cancelTask(e,t){return this._server.cancelTask({taskId:e},t)}};n(),A();var le=class extends M{constructor(e,t){super(t),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(p.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 L,this.setRequestHandler(m,e=>this._oninitialize(e)),this.setNotificationHandler(P,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(te,async(e,t)=>{let n=t.sessionId||t.requestInfo?.headers[`mcp-session-id`]||void 0,{level:r}=e.params,i=p.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=w(this._capabilities,e)}setRequestHandler(e,t){let n=x(e)?.method;if(!n)throw Error(`Schema is missing a method literal`);let r;if(y(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(V,e);if(!r.success){let e=r.error instanceof Error?r.error.message:String(r.error);throw new g(a.InvalidParams,`Invalid tools/call request: ${e}`)}let{params:i}=r.data,o=await Promise.resolve(t(e,n));if(i.task){let e=S(ne,o);if(!e.success){let t=e.error instanceof Error?e.error.message:String(e.error);throw new g(a.InvalidParams,`Invalid task creation result: ${t}`)}return e.data}let s=S(K,o);if(!s.success){let e=s.error instanceof Error?s.error.message:String(s.error);throw new g(a.InvalidParams,`Invalid tools/call result: ${e}`)}return s.data}):super.setRequestHandler(e,t)}assertCapabilityForMethod(e){switch(e){case`sampling/createMessage`:if(!this._clientCapabilities?.sampling)throw Error(`Client does not support sampling (required for ${e})`);break;case`elicitation/create`:if(!this._clientCapabilities?.elicitation)throw Error(`Client does not support elicitation (required for ${e})`);break;case`roots/list`:if(!this._clientCapabilities?.roots)throw Error(`Client does not support listing roots (required for ${e})`);break;case`ping`:break}}assertNotificationCapability(e){switch(e){case`notifications/message`:if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${e})`);break;case`notifications/resources/updated`:case`notifications/resources/list_changed`:if(!this._capabilities.resources)throw Error(`Server does not support notifying about resources (required for ${e})`);break;case`notifications/tools/list_changed`:if(!this._capabilities.tools)throw Error(`Server does not support notifying of tool list changes (required for ${e})`);break;case`notifications/prompts/list_changed`:if(!this._capabilities.prompts)throw Error(`Server does not support notifying of prompt list changes (required for ${e})`);break;case`notifications/elicitation/complete`:if(!this._clientCapabilities?.elicitation?.url)throw Error(`Client does not support URL elicitation (required for ${e})`);break;case`notifications/cancelled`:break;case`notifications/progress`:break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case`completion/complete`:if(!this._capabilities.completions)throw Error(`Server does not support completions (required for ${e})`);break;case`logging/setLevel`:if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${e})`);break;case`prompts/get`:case`prompts/list`:if(!this._capabilities.prompts)throw Error(`Server does not support prompts (required for ${e})`);break;case`resources/list`:case`resources/templates/list`:case`resources/read`:if(!this._capabilities.resources)throw Error(`Server does not support resources (required for ${e})`);break;case`tools/call`:case`tools/list`:if(!this._capabilities.tools)throw Error(`Server does not support tools (required for ${e})`);break;case`tasks/get`:case`tasks/list`:case`tasks/result`:case`tasks/cancel`:if(!this._capabilities.tasks)throw Error(`Server does not support tasks capability (required for ${e})`);break;case`ping`:case`initialize`:break}}assertTaskCapability(e){B(this._clientCapabilities?.tasks?.requests,e,`Client`)}assertTaskHandlerCapability(e){this._capabilities&&k(this._capabilities.tasks?.requests,e,`Server`)}async _oninitialize(t){let n=t.params.protocolVersion;return this._clientCapabilities=t.params.capabilities,this._clientVersion=t.params.clientInfo,{protocolVersion:u.includes(n)?n:e,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`},l)}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},W,t):this.request({method:`sampling/createMessage`,params:e},D,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},U,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},U,t);if(r.action===`accept`&&r.content&&n.requestedSchema)try{let e=this._jsonSchemaValidator.getValidator(n.requestedSchema)(r.content);if(!e.valid)throw new g(a.InvalidParams,`Elicitation response content does not match requested schema: ${e.errorMessage}`)}catch(e){throw e instanceof g?e:new g(a.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},N,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`})}};O();var $=class{constructor(e=Q.stdin,t=Q.stdout){this._stdin=e,this._stdout=t,this._readBuffer=new R,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=F(e);this._stdout.write(n)?t():this._stdout.once(`drain`,t)})}};n(),i(),se(),s(),re(),o(),Y(),C(),ie(),b(),f(),J(),E(),r();var ue=[];async function de(e,n,r){let i=_(100);h(e);let a=new le({name:`claude/tengu`,version:`0.0.23`},{capabilities:{tools:{}}});a.setRequestHandler(d,async()=>{let e=Z(),t=v(e);return{tools:await Promise.all(t.map(async n=>{let r;if(n.outputSchema){let e=H(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:H(n.inputSchema),outputSchema:r}}))}}),a.setRequestHandler(V,async({params:{name:e,arguments:a}})=>{let o=v(Z()),s=oe(o,e);if(!s)throw Error(`Tool ${e} not found`);let l={abortController:z(),options:{commands:ue,tools:o,mainLoopModel:ae(),thinkingConfig:{type:`disabled`},mcpClients:[],mcpResources:{},isNonInteractiveSession:!0,debug:n,verbose:r,agentDefinitions:{activeAgents:[],allAgents:[]}},getAppState:()=>c(),setAppState:()=>{},messages:[],readFileState:i,setInProgressToolUseIDs:()=>{},setResponseLength:()=>{},updateFileHistoryState:()=>{},updateAttributionState:()=>{}};try{if(!s.isEnabled())throw Error(`Tool ${e} is not enabled`);let n=await s.validateInput?.(a??{},l);if(n&&!n.result)throw Error(`Tool ${e} input is invalid: ${`message`in n?n.message:String(n)}`);let r=await s.call(a??{},l,t,T({content:[]}));return{content:[{type:`text`,text:typeof r==`string`?r:q(r.data)}]}}catch(e){return X(e),{isError:!0,content:[{type:`text`,text:(e instanceof Error?G(e):[String(e)]).filter(Boolean).join(`
1
+ import{Ay as e,B as t,By as n,Ch as r,Ds as i,Dy as a,E_ as o,Ec as s,Es as c,Ey as l,Hy as ee,Ly as u,My as d,Nb as f,Ny as p,Oy as m,Pb as h,Py as g,Ry as te,Sy as ne,T_ as _,Tc as v,Uy as y,V as b,Vy as x,Wy as S,Yi as C,_y as w,aS as T,bl as E,by as D,cy as O,dy as k,fy as A,gy as j,hy as M,jy as N,ky as P,ly as F,my as I,ny as re,py as L,sy as R,ty as z,uy as B,vy as V,wh as H,wy as U,xy as W,yl as G,yy as K}from"./loadAgentsDir-B0Anodo0.js";import{C as q,x as J}from"./debug-Bglx1aTu.js";import{o as Y,s as X}from"./log-D2TIwHBV.js";import{d as ie,o as ae}from"./model-BvQFFOf8.js";import{_n as Z,gn as oe,vn as se}from"./prompt-CJ1l3XXk.js";import Q from"node:process";ee(),j(),I(),n();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},D,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},U,t)}async getTask(e,t){return this._server.getTask({taskId:e},t)}async getTaskResult(e,t,n){return this._server.getTaskResult({taskId:e},t,n)}async listTasks(e,t){return this._server.listTasks(e?{cursor:e}:void 0,t)}async cancelTask(e,t){return this._server.cancelTask({taskId:e},t)}};n(),A();var le=class extends M{constructor(e,t){super(t),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(p.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 L,this.setRequestHandler(m,e=>this._oninitialize(e)),this.setNotificationHandler(P,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(te,async(e,t)=>{let n=t.sessionId||t.requestInfo?.headers[`mcp-session-id`]||void 0,{level:r}=e.params,i=p.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=w(this._capabilities,e)}setRequestHandler(e,t){let n=x(e)?.method;if(!n)throw Error(`Schema is missing a method literal`);let r;if(y(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(V,e);if(!r.success){let e=r.error instanceof Error?r.error.message:String(r.error);throw new g(a.InvalidParams,`Invalid tools/call request: ${e}`)}let{params:i}=r.data,o=await Promise.resolve(t(e,n));if(i.task){let e=S(ne,o);if(!e.success){let t=e.error instanceof Error?e.error.message:String(e.error);throw new g(a.InvalidParams,`Invalid task creation result: ${t}`)}return e.data}let s=S(K,o);if(!s.success){let e=s.error instanceof Error?s.error.message:String(s.error);throw new g(a.InvalidParams,`Invalid tools/call result: ${e}`)}return s.data}):super.setRequestHandler(e,t)}assertCapabilityForMethod(e){switch(e){case`sampling/createMessage`:if(!this._clientCapabilities?.sampling)throw Error(`Client does not support sampling (required for ${e})`);break;case`elicitation/create`:if(!this._clientCapabilities?.elicitation)throw Error(`Client does not support elicitation (required for ${e})`);break;case`roots/list`:if(!this._clientCapabilities?.roots)throw Error(`Client does not support listing roots (required for ${e})`);break;case`ping`:break}}assertNotificationCapability(e){switch(e){case`notifications/message`:if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${e})`);break;case`notifications/resources/updated`:case`notifications/resources/list_changed`:if(!this._capabilities.resources)throw Error(`Server does not support notifying about resources (required for ${e})`);break;case`notifications/tools/list_changed`:if(!this._capabilities.tools)throw Error(`Server does not support notifying of tool list changes (required for ${e})`);break;case`notifications/prompts/list_changed`:if(!this._capabilities.prompts)throw Error(`Server does not support notifying of prompt list changes (required for ${e})`);break;case`notifications/elicitation/complete`:if(!this._clientCapabilities?.elicitation?.url)throw Error(`Client does not support URL elicitation (required for ${e})`);break;case`notifications/cancelled`:break;case`notifications/progress`:break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case`completion/complete`:if(!this._capabilities.completions)throw Error(`Server does not support completions (required for ${e})`);break;case`logging/setLevel`:if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${e})`);break;case`prompts/get`:case`prompts/list`:if(!this._capabilities.prompts)throw Error(`Server does not support prompts (required for ${e})`);break;case`resources/list`:case`resources/templates/list`:case`resources/read`:if(!this._capabilities.resources)throw Error(`Server does not support resources (required for ${e})`);break;case`tools/call`:case`tools/list`:if(!this._capabilities.tools)throw Error(`Server does not support tools (required for ${e})`);break;case`tasks/get`:case`tasks/list`:case`tasks/result`:case`tasks/cancel`:if(!this._capabilities.tasks)throw Error(`Server does not support tasks capability (required for ${e})`);break;case`ping`:case`initialize`:break}}assertTaskCapability(e){B(this._clientCapabilities?.tasks?.requests,e,`Client`)}assertTaskHandlerCapability(e){this._capabilities&&k(this._capabilities.tasks?.requests,e,`Server`)}async _oninitialize(t){let n=t.params.protocolVersion;return this._clientCapabilities=t.params.capabilities,this._clientVersion=t.params.clientInfo,{protocolVersion:u.includes(n)?n:e,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`},l)}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},W,t):this.request({method:`sampling/createMessage`,params:e},D,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},U,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},U,t);if(r.action===`accept`&&r.content&&n.requestedSchema)try{let e=this._jsonSchemaValidator.getValidator(n.requestedSchema)(r.content);if(!e.valid)throw new g(a.InvalidParams,`Elicitation response content does not match requested schema: ${e.errorMessage}`)}catch(e){throw e instanceof g?e:new g(a.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},N,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`})}};O();var $=class{constructor(e=Q.stdin,t=Q.stdout){this._stdin=e,this._stdout=t,this._readBuffer=new R,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=F(e);this._stdout.write(n)?t():this._stdout.once(`drain`,t)})}};n(),i(),se(),s(),re(),o(),Y(),C(),ie(),b(),f(),J(),E(),r();var ue=[];async function de(e,n,r){let i=_(100);h(e);let a=new le({name:`claude/tengu`,version:`0.0.24`},{capabilities:{tools:{}}});a.setRequestHandler(d,async()=>{let e=Z(),t=v(e);return{tools:await Promise.all(t.map(async n=>{let r;if(n.outputSchema){let e=H(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:H(n.inputSchema),outputSchema:r}}))}}),a.setRequestHandler(V,async({params:{name:e,arguments:a}})=>{let o=v(Z()),s=oe(o,e);if(!s)throw Error(`Tool ${e} not found`);let l={abortController:z(),options:{commands:ue,tools:o,mainLoopModel:ae(),thinkingConfig:{type:`disabled`},mcpClients:[],mcpResources:{},isNonInteractiveSession:!0,debug:n,verbose:r,agentDefinitions:{activeAgents:[],allAgents:[]}},getAppState:()=>c(),setAppState:()=>{},messages:[],readFileState:i,setInProgressToolUseIDs:()=>{},setResponseLength:()=>{},updateFileHistoryState:()=>{},updateAttributionState:()=>{}};try{if(!s.isEnabled())throw Error(`Tool ${e} is not enabled`);let n=await s.validateInput?.(a??{},l);if(n&&!n.result)throw Error(`Tool ${e} input is invalid: ${`message`in n?n.message:String(n)}`);let r=await s.call(a??{},l,t,T({content:[]}));return{content:[{type:`text`,text:typeof r==`string`?r:q(r.data)}]}}catch(e){return X(e),{isError:!0,content:[{type:`text`,text:(e instanceof Error?G(e):[String(e)]).filter(Boolean).join(`
2
2
  `).trim()||`Error`}]}}});async function o(){let e=new $;await a.connect(e)}return await o()}export{de as startMCPServer};
@@ -1,5 +1,5 @@
1
- import{o as e}from"./rolldown-runtime-DaDcL9Zw.js";import{$_ as t,Cv as n,Dv as r,Ip as i,Kw as a,Pp as o,Tv as s,Z_ as c,_i as l,av as u,gv as d,hi as f,hv as p,iv as m,jv as h,md as g,pd as _,q_ as v,qw as ee,wv as y,yv as b}from"./loadAgentsDir-DlPbtIsS.js";import{D as x,H as S,I as C,P as w,T as te,ai as ne,j as re,kn as T,t as E,y as D}from"./src-DL3w8VPk.js";import{t as O}from"./jsx-runtime-Bb4Xn-E0.js";import{f as k,l as A}from"./types-Dx7P7JLQ.js";import{I as j,z as M}from"./debug-Bglx1aTu.js";import{g as N,o as P,p as F,s as I}from"./config-C-Y2qtB2.js";import{n as L,o as R}from"./process-gEbdy6uY.js";import{l as z,o as B}from"./stringUtils-C718f5ey.js";import{i as ie,o as V}from"./platform-BacQ6ACS.js";import{n as H,r as U}from"./analytics-DJobLaWP.js";import{n as W,t as G}from"./SelectMulti-Bc6l11_K.js";import{t as K}from"./KeybindingProviderSetup-DA37QUFs.js";import{n as q,t as J}from"./exit-s9XGerrH.js";import{stat as Y}from"fs/promises";import{cwd as ae}from"process";a();var X=e(ne(),1);l(),L(),E(),r(),B(),g(),W();var Z=O();function oe({servers:e,scope:t,onDone:r}){let i=Object.keys(e),[a,o]=(0,X.useState)({});(0,X.useEffect)(()=>{n().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 b(e,n,t),r++}}u(r)}let[l]=S(),u=(0,X.useCallback)(e=>{R(e>0?`\n${re(`success`,l)(`Successfully imported ${e} MCP ${z(e,`server`)} to ${t} config.`)}\n`:`
2
- No servers were imported.`),r(),f()},[l,t,r]),d=(0,X.useCallback)(()=>{u(0)},[u]);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(D,{title:`Import MCP Servers from Work Mate Desktop`,subtitle:`Found ${i.length} MCP ${z(i.length,`server`)} in Work Mate Desktop.`,color:`success`,onCancel:d,hideInputGuide:!0,children:[s.length>0&&(0,Z.jsx)(w,{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)(w,{children:`Please select the servers you want to import:`}),(0,Z.jsx)(G,{options:i.map(e=>({label:`${e}${s.includes(e)?` (already exists)`:``}`,value:e})),defaultValue:i.filter(e=>!s.includes(e)),onSubmit:c,onCancel:d,hideIndexes:!0})]}),(0,Z.jsx)(C,{paddingX:1,children:(0,Z.jsx)(w,{dimColor:!0,italic:!0,children:(0,Z.jsxs)(te,{children:[(0,Z.jsx)(x,{shortcut:`Space`,action:`select`}),(0,Z.jsx)(x,{shortcut:`Enter`,action:`confirm`}),(0,Z.jsx)(_,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})})]})}E(),H(),t(),r(),d(),i(),F(),j(),l(),A(),V();async function Q(e,t){try{let n=await v(e,t);return n.type===`connected`?`✓ Connected`:n.type===`needs-auth`?`! Needs authentication`:`✗ Failed to connect`}catch{return`✗ Connection error`}}async function se({debug:e,verbose:t}){let n=ae();U(`tengu_mcp_start`,{});try{await Y(n)}catch(e){throw M(e)&&J(`Error: Directory ${n} does not exist`),e}try{let{setup:r}=await import(`./setup-BRypY6iT.js`);await r(n,`default`,!1,!1,void 0,!1);let{startMCPServer:i}=await import(`./mcp-mgOlm1cY.js`);await i(n,e??!1,t??!1)}catch(e){J(`Error: Failed to start MCP server: ${e}`)}}async function ce(e,t){y(e);try{if(t.scope){let n=u(t.scope);U(`tengu_mcp_delete`,{name:e,scope:n}),await h(e,n),process.stdout.write(`Removed MCP server ${e} from ${n} config\n`),q(`File modified: ${m(n)}`)}let n=P(),r=I(),{servers:i}=s(`project`),a=!!i[e],o=[];if(n.mcpServers?.[e]&&o.push(`local`),a&&o.push(`project`),r.mcpServers?.[e]&&o.push(`user`),o.length===0)J(`No MCP server found with name: "${e}"`);else if(o.length===1){let t=o[0];U(`tengu_mcp_delete`,{name:e,scope:t}),await h(e,t),process.stdout.write(`Removed MCP server "${e}" from ${t} config\n`),q(`File modified: ${m(t)}`)}else process.stderr.write(`MCP server "${e}" exists in multiple scopes:\n`),o.forEach(e=>{process.stderr.write(` - ${p(e)} (${m(e)})\n`)}),process.stderr.write(`
1
+ import{o as e}from"./rolldown-runtime-DaDcL9Zw.js";import{$_ as t,Cv as n,Dv as r,Ip as i,Kw as a,Pp as o,Tv as s,Z_ as c,_i as l,av as u,gv as d,hi as f,hv as p,iv as m,jv as h,md as g,pd as _,q_ as v,qw as ee,wv as y,yv as b}from"./loadAgentsDir-B0Anodo0.js";import{D as x,H as S,I as C,P as w,T as te,ai as ne,j as re,kn as T,t as E,y as D}from"./src-DL3w8VPk.js";import{t as O}from"./jsx-runtime-Bb4Xn-E0.js";import{f as k,l as A}from"./types-Dx7P7JLQ.js";import{I as j,z as M}from"./debug-Bglx1aTu.js";import{g as N,o as P,p as F,s as I}from"./config-C-Y2qtB2.js";import{n as L,o as R}from"./process-gEbdy6uY.js";import{l as z,o as B}from"./stringUtils-C718f5ey.js";import{i as ie,o as V}from"./platform-BacQ6ACS.js";import{n as H,r as U}from"./analytics-DJobLaWP.js";import{n as W,t as G}from"./SelectMulti-BQRHed-d.js";import{t as K}from"./KeybindingProviderSetup-D49HHTXD.js";import{n as q,t as J}from"./exit-s9XGerrH.js";import{stat as Y}from"fs/promises";import{cwd as ae}from"process";a();var X=e(ne(),1);l(),L(),E(),r(),B(),g(),W();var Z=O();function oe({servers:e,scope:t,onDone:r}){let i=Object.keys(e),[a,o]=(0,X.useState)({});(0,X.useEffect)(()=>{n().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 b(e,n,t),r++}}u(r)}let[l]=S(),u=(0,X.useCallback)(e=>{R(e>0?`\n${re(`success`,l)(`Successfully imported ${e} MCP ${z(e,`server`)} to ${t} config.`)}\n`:`
2
+ No servers were imported.`),r(),f()},[l,t,r]),d=(0,X.useCallback)(()=>{u(0)},[u]);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(D,{title:`Import MCP Servers from Work Mate Desktop`,subtitle:`Found ${i.length} MCP ${z(i.length,`server`)} in Work Mate Desktop.`,color:`success`,onCancel:d,hideInputGuide:!0,children:[s.length>0&&(0,Z.jsx)(w,{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)(w,{children:`Please select the servers you want to import:`}),(0,Z.jsx)(G,{options:i.map(e=>({label:`${e}${s.includes(e)?` (already exists)`:``}`,value:e})),defaultValue:i.filter(e=>!s.includes(e)),onSubmit:c,onCancel:d,hideIndexes:!0})]}),(0,Z.jsx)(C,{paddingX:1,children:(0,Z.jsx)(w,{dimColor:!0,italic:!0,children:(0,Z.jsxs)(te,{children:[(0,Z.jsx)(x,{shortcut:`Space`,action:`select`}),(0,Z.jsx)(x,{shortcut:`Enter`,action:`confirm`}),(0,Z.jsx)(_,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})})]})}E(),H(),t(),r(),d(),i(),F(),j(),l(),A(),V();async function Q(e,t){try{let n=await v(e,t);return n.type===`connected`?`✓ Connected`:n.type===`needs-auth`?`! Needs authentication`:`✗ Failed to connect`}catch{return`✗ Connection error`}}async function se({debug:e,verbose:t}){let n=ae();U(`tengu_mcp_start`,{});try{await Y(n)}catch(e){throw M(e)&&J(`Error: Directory ${n} does not exist`),e}try{let{setup:r}=await import(`./setup-qecdf-ES.js`);await r(n,`default`,!1,!1,void 0,!1);let{startMCPServer:i}=await import(`./mcp-DoEl5uah.js`);await i(n,e??!1,t??!1)}catch(e){J(`Error: Failed to start MCP server: ${e}`)}}async function ce(e,t){y(e);try{if(t.scope){let n=u(t.scope);U(`tengu_mcp_delete`,{name:e,scope:n}),await h(e,n),process.stdout.write(`Removed MCP server ${e} from ${n} config\n`),q(`File modified: ${m(n)}`)}let n=P(),r=I(),{servers:i}=s(`project`),a=!!i[e],o=[];if(n.mcpServers?.[e]&&o.push(`local`),a&&o.push(`project`),r.mcpServers?.[e]&&o.push(`user`),o.length===0)J(`No MCP server found with name: "${e}"`);else if(o.length===1){let t=o[0];U(`tengu_mcp_delete`,{name:e,scope:t}),await h(e,t),process.stdout.write(`Removed MCP server "${e}" from ${t} config\n`),q(`File modified: ${m(t)}`)}else process.stderr.write(`MCP server "${e}" exists in multiple scopes:\n`),o.forEach(e=>{process.stderr.write(` - ${p(e)} (${m(e)})\n`)}),process.stderr.write(`
3
3
  To remove from a specific scope, use:
4
4
  `),o.forEach(t=>{process.stderr.write(` claude mcp remove "${e}" -s ${t}\n`)}),J()}catch(e){J(e.message)}}async function le(){U(`tengu_mcp_list`,{});let{servers:e}=await n();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
5
  `);let t=await ee(Object.entries(e),async([e,t])=>({name:e,server:t,status:await Q(e,t)}),{concurrency:c()});for(let{name:e,server:n,status:r}of t)if(n.type===`sse`)console.log(`${e}: ${n.url} (SSE) - ${r}`);else if(n.type===`http`)console.log(`${e}: ${n.url} (HTTP) - ${r}`);else if(n.type===`claudeai-proxy`)console.log(`${e}: ${n.url} - ${r}`);else if(!n.type||n.type===`stdio`){let t=n,i=Array.isArray(t.args)?t.args:[];console.log(`${e}: ${t.command} ${i.join(` `)} - ${r}`)}}await f(0)}async function $(e){U(`tengu_mcp_get`,{name:e});let t=y(e);t||J(`No MCP server found with name: ${e}`),console.log(`${e}:`),console.log(` Scope: ${p(t.scope)}`);let n=await Q(e,t);if(console.log(` Status: ${n}`),t.type===`sse`){if(console.log(` Type: sse`),console.log(` URL: ${t.url}`),t.headers){console.log(` Headers:`);for(let[e,n]of Object.entries(t.headers))console.log(` ${e}: ${n}`)}}else if(t.type===`http`){if(console.log(` Type: http`),console.log(` URL: ${t.url}`),t.headers){console.log(` Headers:`);for(let[e,n]of Object.entries(t.headers))console.log(` ${e}: ${n}`)}}else if(t.type===`stdio`){console.log(` Type: stdio`),console.log(` Command: ${t.command}`);let e=Array.isArray(t.args)?t.args:[];if(console.log(` Args: ${e.join(` `)}`),t.env){console.log(` Environment:`);for(let[e,n]of Object.entries(t.env))console.log(` ${e}=${n}`)}}console.log(`\nTo remove this server, run: claude mcp remove "${e}" -s ${t.scope}`),await f(0)}async function ue(e,t,n){try{let r=u(n.scope),i=k(t);await b(e,i,r);let a=i&&typeof i==`object`&&`type`in i?String(i.type||`stdio`):`stdio`;U(`tengu_mcp_add`,{scope:r,source:`json`,type:a}),q(`Added ${a} MCP server ${e} to ${r} config`)}catch(e){J(e.message)}}async function de(e){try{let t=u(e.scope);U(`tengu_mcp_add`,{scope:t,platform:ie(),source:`desktop`});let{readClaudeDesktopMcpServers:n}=await import(`./claudeDesktop-D8ml2767.js`),r=await n();Object.keys(r).length===0&&q(`No MCP servers found in Work Mate Desktop configuration or configuration file does not exist.`);let{unmount:i}=await T((0,Z.jsx)(o,{children:(0,Z.jsx)(K,{children:(0,Z.jsx)(oe,{servers:r,scope:t,onDone:()=>{i()}})})}),{exitOnCtrlC:!0})}catch(e){J(e.message)}}async function fe(){U(`tengu_mcp_reset_mcpjson_choices`,{}),N(e=>({...e,enabledMcpjsonServers:[],disabledMcpjsonServers:[],enableAllProjectMcpServers:!1})),q(`All project-scoped (.mcp.json) server approvals and rejections have been reset.
@@ -1 +1 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{i as n,o as r}from"./envUtils-DfkgIdYf.js";import{Fw as i,Gl as a,Ip as o,Kl as s,Lp as c,Nw as l,__ as u,bu as ee,dc as d,fc as te,m_ as f,mb as p,vu as m,y_ as h}from"./loadAgentsDir-DlPbtIsS.js";import{I as g,Lt as _,P as v,Wt as y,_ as b,ai as x,di as ne,fi as S,t as C,y as w}from"./src-DL3w8VPk.js";import{t as T}from"./jsx-runtime-Bb4Xn-E0.js";import{It as E,J as D}from"./state-B4jiUise.js";import{n as O,t as k}from"./cwd-Pa83R95t.js";import{I as A,N as j}from"./debug-Bglx1aTu.js";import{Lr as M,Or as N,b as P,h as F,wn as I,xn as re}from"./settings-B2jvL8Dp.js";import{A as L,O as R,T as ie}from"./config-C-Y2qtB2.js";import{o as z,s as ae}from"./log-D2TIwHBV.js";import{n as oe,r as B}from"./analytics-DJobLaWP.js";import{_ as se,p as ce}from"./startupProfiler-CJdr3SxP.js";import{n as le,t as V}from"./useExitOnCtrlCDWithKeybindings-C9BYG8Bo.js";import{t as H}from"./select-Bxf5-5sI.js";import{r as U,t as ue}from"./promptEditor-DLGN_eLu.js";import{t as de}from"./CustomSelect-DoeEXOIP.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 N(e)!==null}var ge=e((()=>{M()}));function _e({onSelect:e,onCancel:t}){let r=(0,K.use)(u()),i=W(n(),`AGENTS.md`),a=W(D(),`AGENTS.md`),o=r.some(e=>e.path===i),d=r.some(e=>e.path===a),f=[...r.filter(e=>e.type!==`AutoMem`).map(e=>({...e,exists:!0})),...o?[]:[{path:i,type:`User`,content:``,exists:!1}],...d?[]:[{path:a,type:`Project`,content:``,exists:!1}]],p=new Map,m=f.map(e=>{let t=re(e.path),n=e.exists?``:` (new)`,r=e.parent?(p.get(e.parent)??0)+1:0;p.set(e.path,r);let o=r>0?` `.repeat(r-1):``,s;s=e.type===`User`&&!e.isNested&&e.path===i?`User memory`:e.type===`Project`&&!e.isNested&&e.path===a?`Project memory`:r>0?`${o}L ${t}${n}`:`${t}`;let c,l=he(D());return c=e.type===`User`&&!e.isNested?`Saved in ~/.workmate/AGENTS.md`:e.type===`Project`&&!e.isNested&&e.path===a?`${l?`Checked in at`:`Saved in`} ./AGENTS.md`:e.parent?`@-imported`:e.isNested?`dynamically loaded`:``,{label:s,value:e.path,description:c}}),h=[],_=c(e=>e.agentDefinitions);if(L()){h.push({label:`Open auto-memory folder`,value:`${Y}${ie()}`,description:``});for(let e of _.activeAgents)if(e.memory){let t=l(e.agentType,e.memory);h.push({label:`Open ${ne.bold(e.agentType)} agent memory`,value:`${Y}${t}`,description:`${e.memory} scope`})}}m.push(...h);let x=J&&m.some(e=>e.value===J)?J:m[0]?.value||``,[S,C]=(0,K.useState)(L),[w,T]=(0,K.useState)(te),[E]=(0,K.useState)(L),O=c(e=>Object.values(e.tasks).some(e=>e.type===`dream`&&e.status===`running`)),[k,A]=(0,K.useState)(null);(0,K.useEffect)(()=>{E&&s().then(A)},[E,O]);let j=O?`running`:k===null?``:k===0?`never`:`last ran ${ce(new Date(k))}`,[M,N]=(0,K.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 le(),y(`confirm:no`,t,{context:`Confirmation`}),y(`confirm:yes`,()=>{M===0?R():M===1&&z()},{context:`Confirmation`,isActive:F}),y(`select:next`,()=>{N(e=>e!==null&&e<I?e+1:null)},{context:`Select`,isActive:F}),y(`select:previous`,()=>{N(e=>e!==null&&e>0?e-1:e)},{context:`Select`,isActive:F}),(0,q.jsxs)(g,{flexDirection:`column`,width:`100%`,children:[(0,q.jsxs)(g,{flexDirection:`column`,marginBottom:1,children:[(0,q.jsx)(b,{isFocused:M===0,children:(0,q.jsxs)(v,{children:[`Auto-memory: `,S?`on`:`off`]})}),E&&(0,q.jsx)(b,{isFocused:M===1,styled:!1,children:(0,q.jsxs)(v,{color:M===1?`suggestion`:void 0,children:[`Auto-dream: `,w?`on`:`off`,j&&(0,q.jsxs)(v,{dimColor:!0,children:[` · `,j]}),!O&&w&&(0,q.jsx)(v,{dimColor:!0,children:` · /dream to run`})]})})]}),(0,q.jsx)(H,{defaultFocusValue:x,options:m,isDisabled:F,onChange:t=>{if(t.startsWith(Y)){let e=t.slice(15);G(e,{recursive:!0}).catch(()=>{}).then(()=>ee(e));return}J=t,e(t)},onCancel:t,onUpFromFirstItem:()=>N(I)})]})}var K,q,J,Y,ve=e((()=>{S(),K=t(x(),1),E(),V(),C(),p(),R(),oe(),d(),a(),o(),i(),m(),h(),r(),I(),se(),ge(),F(),de(),q=T(),Y=`__open_folder__`}));function ye(e){let t=fe(),n=k(),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 X=e((()=>{C(),O(),T()}));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 ue(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 ${ye(t)}\n\n${o}`,{display:`system`})}catch(t){ae(t),e(`Error opening memory file: ${t}`)}},r=()=>{e(`Cancelled memory editing`,{display:`system`})};return(0,Q.jsx)(w,{title:`Memory`,onCancel:r,color:`remember`,children:(0,Q.jsxs)(g,{flexDirection:`column`,children:[(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(_e,{onSelect:t,onCancel:r})}),(0,Q.jsx)(g,{marginTop:1,children:(0,Q.jsxs)(v,{dimColor:!0,children:[`Learn more: `,(0,Q.jsx)(_,{url:`https://code.workmate.com/docs/en/memory`})]})})]})})}var Z,Q,$;e((()=>{Z=t(x(),1),C(),ve(),X(),h(),r(),A(),z(),U(),Q=T(),$=async e=>(f(),await u(),(0,Q.jsx)(be,{onDone:e}))}))();export{$ as call};
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{i as n,o as r}from"./envUtils-DfkgIdYf.js";import{Fw as i,Gl as a,Ip as o,Kl as s,Lp as c,Nw as l,__ as u,bu as ee,dc as d,fc as te,m_ as f,mb as p,vu as m,y_ as h}from"./loadAgentsDir-B0Anodo0.js";import{I as g,Lt as _,P as v,Wt as y,_ as b,ai as x,di as ne,fi as S,t as C,y as w}from"./src-DL3w8VPk.js";import{t as T}from"./jsx-runtime-Bb4Xn-E0.js";import{It as E,J as D}from"./state-B4jiUise.js";import{n as O,t as k}from"./cwd-Pa83R95t.js";import{I as A,N as j}from"./debug-Bglx1aTu.js";import{Lr as M,Or as N,b as P,h as F,wn as I,xn as re}from"./settings-B2jvL8Dp.js";import{A as L,O as R,T as ie}from"./config-C-Y2qtB2.js";import{o as z,s as ae}from"./log-D2TIwHBV.js";import{n as oe,r as B}from"./analytics-DJobLaWP.js";import{_ as se,p as ce}from"./startupProfiler-CJdr3SxP.js";import{n as le,t as V}from"./useExitOnCtrlCDWithKeybindings-BKwzUpgb.js";import{t as H}from"./select-DIxfl_VN.js";import{r as U,t as ue}from"./promptEditor-DoGHJN_W.js";import{t as de}from"./CustomSelect-wmZ9jz0W.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 N(e)!==null}var ge=e((()=>{M()}));function _e({onSelect:e,onCancel:t}){let r=(0,K.use)(u()),i=W(n(),`AGENTS.md`),a=W(D(),`AGENTS.md`),o=r.some(e=>e.path===i),d=r.some(e=>e.path===a),f=[...r.filter(e=>e.type!==`AutoMem`).map(e=>({...e,exists:!0})),...o?[]:[{path:i,type:`User`,content:``,exists:!1}],...d?[]:[{path:a,type:`Project`,content:``,exists:!1}]],p=new Map,m=f.map(e=>{let t=re(e.path),n=e.exists?``:` (new)`,r=e.parent?(p.get(e.parent)??0)+1:0;p.set(e.path,r);let o=r>0?` `.repeat(r-1):``,s;s=e.type===`User`&&!e.isNested&&e.path===i?`User memory`:e.type===`Project`&&!e.isNested&&e.path===a?`Project memory`:r>0?`${o}L ${t}${n}`:`${t}`;let c,l=he(D());return c=e.type===`User`&&!e.isNested?`Saved in ~/.workmate/AGENTS.md`:e.type===`Project`&&!e.isNested&&e.path===a?`${l?`Checked in at`:`Saved in`} ./AGENTS.md`:e.parent?`@-imported`:e.isNested?`dynamically loaded`:``,{label:s,value:e.path,description:c}}),h=[],_=c(e=>e.agentDefinitions);if(L()){h.push({label:`Open auto-memory folder`,value:`${Y}${ie()}`,description:``});for(let e of _.activeAgents)if(e.memory){let t=l(e.agentType,e.memory);h.push({label:`Open ${ne.bold(e.agentType)} agent memory`,value:`${Y}${t}`,description:`${e.memory} scope`})}}m.push(...h);let x=J&&m.some(e=>e.value===J)?J:m[0]?.value||``,[S,C]=(0,K.useState)(L),[w,T]=(0,K.useState)(te),[E]=(0,K.useState)(L),O=c(e=>Object.values(e.tasks).some(e=>e.type===`dream`&&e.status===`running`)),[k,A]=(0,K.useState)(null);(0,K.useEffect)(()=>{E&&s().then(A)},[E,O]);let j=O?`running`:k===null?``:k===0?`never`:`last ran ${ce(new Date(k))}`,[M,N]=(0,K.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 le(),y(`confirm:no`,t,{context:`Confirmation`}),y(`confirm:yes`,()=>{M===0?R():M===1&&z()},{context:`Confirmation`,isActive:F}),y(`select:next`,()=>{N(e=>e!==null&&e<I?e+1:null)},{context:`Select`,isActive:F}),y(`select:previous`,()=>{N(e=>e!==null&&e>0?e-1:e)},{context:`Select`,isActive:F}),(0,q.jsxs)(g,{flexDirection:`column`,width:`100%`,children:[(0,q.jsxs)(g,{flexDirection:`column`,marginBottom:1,children:[(0,q.jsx)(b,{isFocused:M===0,children:(0,q.jsxs)(v,{children:[`Auto-memory: `,S?`on`:`off`]})}),E&&(0,q.jsx)(b,{isFocused:M===1,styled:!1,children:(0,q.jsxs)(v,{color:M===1?`suggestion`:void 0,children:[`Auto-dream: `,w?`on`:`off`,j&&(0,q.jsxs)(v,{dimColor:!0,children:[` · `,j]}),!O&&w&&(0,q.jsx)(v,{dimColor:!0,children:` · /dream to run`})]})})]}),(0,q.jsx)(H,{defaultFocusValue:x,options:m,isDisabled:F,onChange:t=>{if(t.startsWith(Y)){let e=t.slice(15);G(e,{recursive:!0}).catch(()=>{}).then(()=>ee(e));return}J=t,e(t)},onCancel:t,onUpFromFirstItem:()=>N(I)})]})}var K,q,J,Y,ve=e((()=>{S(),K=t(x(),1),E(),V(),C(),p(),R(),oe(),d(),a(),o(),i(),m(),h(),r(),I(),se(),ge(),F(),de(),q=T(),Y=`__open_folder__`}));function ye(e){let t=fe(),n=k(),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 X=e((()=>{C(),O(),T()}));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 ue(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 ${ye(t)}\n\n${o}`,{display:`system`})}catch(t){ae(t),e(`Error opening memory file: ${t}`)}},r=()=>{e(`Cancelled memory editing`,{display:`system`})};return(0,Q.jsx)(w,{title:`Memory`,onCancel:r,color:`remember`,children:(0,Q.jsxs)(g,{flexDirection:`column`,children:[(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(_e,{onSelect:t,onCancel:r})}),(0,Q.jsx)(g,{marginTop:1,children:(0,Q.jsxs)(v,{dimColor:!0,children:[`Learn more: `,(0,Q.jsx)(_,{url:`https://code.workmate.com/docs/en/memory`})]})})]})})}var Z,Q,$;e((()=>{Z=t(x(),1),C(),ve(),X(),h(),r(),A(),z(),U(),Q=T(),$=async e=>(f(),await u(),(0,Q.jsx)(be,{onDone:e}))}))();export{$ as call};
@@ -1,2 +1,2 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{ct as n,lt as r,ot as i,st as a}from"./loadAgentsDir-DlPbtIsS.js";import{I as o,P as s,ai as c,t as l}from"./src-DL3w8VPk.js";import{t as u}from"./jsx-runtime-Bb4Xn-E0.js";import{n as d,t as f}from"./select-Bxf5-5sI.js";function p({onDone:e}){let t=n(),a=i(),c=(0,m.useMemo)(()=>t.map(e=>({label:(0,h.jsxs)(s,{children:[e.icon,` `,e.name,` `,(0,h.jsxs)(s,{dimColor:!0,children:[`(`,e.slug,`) — `,e.description]})]}),value:e.slug})),[t]);function l(n){r(n);let i=t.find(e=>e.slug===n);e(`${i?.icon} Mode switched to: ${i?.name} (${i?.slug}) — ${i?.description}`,{display:`system`})}function u(){e(`Mode selection cancelled.`,{display:`system`})}return(0,h.jsxs)(o,{flexDirection:`column`,children:[(0,h.jsxs)(o,{marginBottom:1,flexDirection:`column`,children:[(0,h.jsx)(s,{color:`remember`,bold:!0,children:`Select mode`}),(0,h.jsx)(s,{dimColor:!0,children:`Arrow keys to navigate, Enter to select, Esc to cancel.`})]}),(0,h.jsx)(f,{defaultValue:a,options:c,onChange:l,onCancel:u,visibleOptionCount:t.length})]})}var m,h,g;e((()=>{m=t(c(),1),l(),d(),a(),h=u(),g=async(e,t,i)=>{let a=i?.trim().toLowerCase();if(a){let t=n(),i=t.find(e=>e.slug===a);if(!i){e(`Unknown mode: "${a}"\n\nAvailable modes:\n${t.map(e=>`${e.icon} ${e.slug} — ${e.description}`).join(`
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{ct as n,lt as r,ot as i,st as a}from"./loadAgentsDir-B0Anodo0.js";import{I as o,P as s,ai as c,t as l}from"./src-DL3w8VPk.js";import{t as u}from"./jsx-runtime-Bb4Xn-E0.js";import{n as d,t as f}from"./select-DIxfl_VN.js";function p({onDone:e}){let t=n(),a=i(),c=(0,m.useMemo)(()=>t.map(e=>({label:(0,h.jsxs)(s,{children:[e.icon,` `,e.name,` `,(0,h.jsxs)(s,{dimColor:!0,children:[`(`,e.slug,`) — `,e.description]})]}),value:e.slug})),[t]);function l(n){r(n);let i=t.find(e=>e.slug===n);e(`${i?.icon} Mode switched to: ${i?.name} (${i?.slug}) — ${i?.description}`,{display:`system`})}function u(){e(`Mode selection cancelled.`,{display:`system`})}return(0,h.jsxs)(o,{flexDirection:`column`,children:[(0,h.jsxs)(o,{marginBottom:1,flexDirection:`column`,children:[(0,h.jsx)(s,{color:`remember`,bold:!0,children:`Select mode`}),(0,h.jsx)(s,{dimColor:!0,children:`Arrow keys to navigate, Enter to select, Esc to cancel.`})]}),(0,h.jsx)(f,{defaultValue:a,options:c,onChange:l,onCancel:u,visibleOptionCount:t.length})]})}var m,h,g;e((()=>{m=t(c(),1),l(),d(),a(),h=u(),g=async(e,t,i)=>{let a=i?.trim().toLowerCase();if(a){let t=n(),i=t.find(e=>e.slug===a);if(!i){e(`Unknown mode: "${a}"\n\nAvailable modes:\n${t.map(e=>`${e.icon} ${e.slug} — ${e.description}`).join(`
2
2
  `)}`,{display:`system`});return}r(a),e(`${i.icon} Mode switched to: ${i.name} (${i.slug}) — ${i.description}`,{display:`system`});return}return(0,h.jsx)(p,{onDone:e})}}))();export{g as call};
@@ -1 +1 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{AS as n,Ip as r,Lp as i,id as a,jS as o,nd as s,rd as c,zp as l}from"./loadAgentsDir-DlPbtIsS.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{A as m,k as h,q as g}from"./log-D2TIwHBV.js";import{n as _,r as v}from"./analytics-DJobLaWP.js";import{C as y,G as b,H as x,K as S,P as C,S as w,T,U as E,d as D,m as O,r as k,v as A,w as j}from"./model-BwBG0V1u.js";import{i as M,r as N}from"./switcher-CAajZeNL.js";import{i as P,n as F,r as I,t as L}from"./extraUsage-CmQaLPV1.js";function R({onDone:e}){let t=i(e=>e.mainLoopModel),n=i(e=>e.mainLoopModelForSession),r=i(e=>e.fastMode),a=l();function o(){v(`tengu_model_command_menu`,{action:`cancel`});let n=W(t);e(`Kept model as ${d.bold(n)}`,{display:`system`})}async function s(n){v(`tengu_model_command_menu`,{action:n,from_model:t,to_model:n}),a(e=>({...e,mainLoopModel:n,mainLoopModelForSession:null}));let i=`Set model to ${d.bold(W(n))}`,o;if(b()&&(C(),!S(n)&&r?(a(e=>({...e,fastMode:!1})),o=!1):S(n)&&E()&&r&&(i+=` · Fast mode ON`,o=!0)),F(n,o===!0,O())&&(i+=` · Billed as extra usage`),o===!1&&(i+=` · Fast mode OFF`),n){let e=await M(n);e.kind===`updated`&&(i+=` · Provider "${e.providerId}" default model updated`)}e(i)}return(0,K.jsx)(I,{initial:t,sessionModel:n,onSelect:s,onCancel:o,isStandaloneCommand:!0,showFastModeNotice:b()&&r&&S(t)&&E()})}function z({args:e,onDone:t}){let n=i(e=>e.fastMode),r=l(),a=e==="default"?null:e;return G.useEffect(()=>{async function e(){if(a&&!y(a)){t(`Model '${a}' is not available. Your organization restricts model selection.`,{display:`system`});return}if(a&&V(a)){t(`Opus 4.7 with 1M context is not available for your account. Learn more: https://code.workmate.com/docs/en/model-config#extended-context-with-1m`,{display:`system`});return}if(a&&H(a)){t(`Sonnet 4.6 with 1M context is not available for your account. Learn more: https://code.workmate.com/docs/en/model-config#extended-context-with-1m`,{display:`system`});return}if(!a){i(null);return}if(B(a)){await i(a);return}try{let{valid:e,error:n}=await o(a);e?await i(a):t(n||`Model '${a}' not found`,{display:`system`})}catch(e){t(`Failed to validate model: ${e.message}`,{display:`system`})}}async function i(e){r(t=>({...t,mainLoopModel:e,mainLoopModelForSession:null}));let i=`Set model to ${d.bold(W(e))}`,a;if(b()&&(C(),!S(e)&&n?(r(e=>({...e,fastMode:!1})),a=!1):S(e)&&n&&(i+=` · Fast mode ON`,a=!0)),F(e,a===!0,O())&&(i+=` · Billed as extra usage`),a===!1&&(i+=` · Fast mode OFF`),e){let t=await M(e);t.kind===`updated`&&(i+=` · Provider "${t.providerId}" default model updated`)}t(i)}e()},[a,t,r]),null}function B(e){return j.includes(e.toLowerCase().trim())}function V(e){let t=e.toLowerCase();return!s()&&!O()&&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=i(e=>e.mainLoopModel),n=i(e=>e.mainLoopModelForSession),r=W(t);return e(n?`Current model: ${d.bold(W(n))} (session override from plan mode)\nBase model: ${r}`:`Current model: ${r}`),null}function W(e){let t=A(e??k());return e===null?`${t} (default)`:t}var G,K,q;e((()=>{f(),G=t(u(),1),P(),g(),_(),r(),L(),x(),T(),a(),D(),w(),n(),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
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{AS as n,Ip as r,Lp as i,id as a,jS as o,nd as s,rd as c,zp as l}from"./loadAgentsDir-B0Anodo0.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{A as m,k as h,q as g}from"./log-D2TIwHBV.js";import{n as _,r as v}from"./analytics-DJobLaWP.js";import{C as y,G as b,H as x,K as S,P as C,S as w,T,U as E,d as D,m as O,r as k,v as A,w as j}from"./model-BvQFFOf8.js";import{i as M,r as N}from"./switcher-DZwUo5Ed.js";import{i as P,n as F,r as I,t as L}from"./extraUsage-xMuDiNKh.js";function R({onDone:e}){let t=i(e=>e.mainLoopModel),n=i(e=>e.mainLoopModelForSession),r=i(e=>e.fastMode),a=l();function o(){v(`tengu_model_command_menu`,{action:`cancel`});let n=W(t);e(`Kept model as ${d.bold(n)}`,{display:`system`})}async function s(n){v(`tengu_model_command_menu`,{action:n,from_model:t,to_model:n}),a(e=>({...e,mainLoopModel:n,mainLoopModelForSession:null}));let i=`Set model to ${d.bold(W(n))}`,o;if(b()&&(C(),!S(n)&&r?(a(e=>({...e,fastMode:!1})),o=!1):S(n)&&E()&&r&&(i+=` · Fast mode ON`,o=!0)),F(n,o===!0,O())&&(i+=` · Billed as extra usage`),o===!1&&(i+=` · Fast mode OFF`),n){let e=await M(n);e.kind===`updated`&&(i+=` · Provider "${e.providerId}" default model updated`)}e(i)}return(0,K.jsx)(I,{initial:t,sessionModel:n,onSelect:s,onCancel:o,isStandaloneCommand:!0,showFastModeNotice:b()&&r&&S(t)&&E()})}function z({args:e,onDone:t}){let n=i(e=>e.fastMode),r=l(),a=e==="default"?null:e;return G.useEffect(()=>{async function e(){if(a&&!y(a)){t(`Model '${a}' is not available. Your organization restricts model selection.`,{display:`system`});return}if(a&&V(a)){t(`Opus 4.7 with 1M context is not available for your account. Learn more: https://code.workmate.com/docs/en/model-config#extended-context-with-1m`,{display:`system`});return}if(a&&H(a)){t(`Sonnet 4.6 with 1M context is not available for your account. Learn more: https://code.workmate.com/docs/en/model-config#extended-context-with-1m`,{display:`system`});return}if(!a){i(null);return}if(B(a)){await i(a);return}try{let{valid:e,error:n}=await o(a);e?await i(a):t(n||`Model '${a}' not found`,{display:`system`})}catch(e){t(`Failed to validate model: ${e.message}`,{display:`system`})}}async function i(e){r(t=>({...t,mainLoopModel:e,mainLoopModelForSession:null}));let i=`Set model to ${d.bold(W(e))}`,a;if(b()&&(C(),!S(e)&&n?(r(e=>({...e,fastMode:!1})),a=!1):S(e)&&n&&(i+=` · Fast mode ON`,a=!0)),F(e,a===!0,O())&&(i+=` · Billed as extra usage`),a===!1&&(i+=` · Fast mode OFF`),e){let t=await M(e);t.kind===`updated`&&(i+=` · Provider "${t.providerId}" default model updated`)}t(i)}e()},[a,t,r]),null}function B(e){return j.includes(e.toLowerCase().trim())}function V(e){let t=e.toLowerCase();return!s()&&!O()&&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=i(e=>e.mainLoopModel),n=i(e=>e.mainLoopModelForSession),r=W(t);return e(n?`Current model: ${d.bold(W(n))} (session override from plan mode)\nBase model: ${r}`:`Current model: ${r}`),null}function W(e){let t=A(e??k());return e===null?`${t} (default)`:t}var G,K,q;e((()=>{f(),G=t(u(),1),P(),g(),_(),r(),L(),x(),T(),a(),D(),w(),n(),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 +1 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./memoize-BK3gG5ob.js";import{i,l as a,o,r as ee,t as s}from"./envUtils-DfkgIdYf.js";import{G as c,P as te,W as l,Z as ne,f as re,l as ie,o as u,s as ae,x as oe}from"./types-Dx7P7JLQ.js";import{Ht as se,I as ce,It as d,Jn as le,K as f,W as ue,br as de,qn as p,sn as fe,st as pe,wn as m,xr as me}from"./state-B4jiUise.js";import{C as he,H as ge,U as _e,c as h,i as ve,o as g,x as ye}from"./debug-Bglx1aTu.js";import{Ht as be,d as xe,h as _,s as Se,t as v}from"./settings-B2jvL8Dp.js";import{p as Ce,s as we}from"./config-C-Y2qtB2.js";import{d as Te,f as Ee,o as De,s as y}from"./log-D2TIwHBV.js";import{h as Oe,m as ke,n as Ae,o as je}from"./stringUtils-C718f5ey.js";import{n as Me,r as Ne}from"./analytics-DJobLaWP.js";import{c as Pe,i as Fe,r as Ie}from"./proxy-CDBfZjO7.js";import{join as Le}from"path";import{readFileSync as Re}from"fs";import{randomUUID as ze}from"crypto";import{mkdir as Be,writeFile as Ve}from"fs/promises";import{AsyncLocalStorage as He}from"async_hooks";function b(e=v()){let t=e.modelType;return t===`openai`?`openai`:t===`gemini`?`gemini`:t===`grok`?`grok`:a(process.env.CLAUDE_CODE_USE_BEDROCK)?`bedrock`:a(process.env.CLAUDE_CODE_USE_VERTEX)?`vertex`:a(process.env.CLAUDE_CODE_USE_FOUNDRY)?`foundry`:a(process.env.CLAUDE_CODE_USE_OPENAI)?`openai`:a(process.env.CLAUDE_CODE_USE_GEMINI)?`gemini`:a(process.env.CLAUDE_CODE_USE_GROK)?`grok`:`firstParty`}function Ue(){return b()}function x(){let e=process.env.ANTHROPIC_BASE_URL;if(!e)return!0;try{return new URL(e).host===`api.anthropic.com`}catch{return!1}}var S=e((()=>{_(),o()}));function We(){return Ke.getStore()?.workload}function Ge(e,t){return Ke.run({workload:e},t)}var Ke,qe=e((()=>{Ke=new He})),Je,C,Ye,Xe,Ze,Qe,$e,et,tt,nt,rt,it,at,ot=e((()=>{Je=`claude-code-20250219`,C=`interleaved-thinking-2025-05-14`,Ye=`context-1m-2025-08-07`,Xe=`context-management-2025-06-27`,Ze=`structured-outputs-2025-12-15`,Qe=`tool-search-tool-2025-10-19`,$e=`task-budgets-2026-03-13`,et=`prompt-caching-scope-2026-01-05`,tt=`fast-mode-2026-02-01`,nt=`redact-thinking-2026-02-12`,rt=`advisor-tool-2026-03-01`,it=new Set([C,Ye,Qe]),at=new Set([Je,C,Xe])}));function st(e,t){return de(e,t)}var ct=e((()=>{me()}));function lt(){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=We(),r=n?`, workload/${n}`:``;return`claude-cli/0.0.23 (external, ${process.env.CLAUDE_CODE_ENTRYPOINT??`cli`}${e}${t}${r})`}function ut(){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.23${e.length>0?` (${e.join(`, `)})`:``}`}function dt(){return{headers:{},error:`No auth available — login removed`}}var ft=e((()=>{qe()}));function w(){return{error:(e,...t)=>console.error(`[SDK ERROR]`,e,...t),warn:(e,...t)=>console.error(`[SDK WARN]`,e,...t),info:(e,...t)=>console.error(`[SDK INFO]`,e,...t),debug:(e,...t)=>console.error(`[SDK DEBUG]`,e,...t)}}async function pt({apiKey:e,maxRetries:n,model:r,fetchOverride:i,source:o}){let c=process.env.CLAUDE_CODE_CONTAINER_ID,te=process.env.CLAUDE_CODE_REMOTE_SESSION_ID,l=process.env.CLAUDE_AGENT_SDK_CLIENT_APP,ne=mt(),re={"x-app":`cli`,"User-Agent":lt(),"X-Claude-Code-Session-Id":pe(),...ne,...c?{"x-claude-remote-container-id":c}:{},...te?{"x-claude-remote-session-id":te}:{},...l?{"x-client-app":l}:{},...process.env.ANTHROPIC_AUTH_NONCE?{"x-auth-nonce":process.env.ANTHROPIC_AUTH_NONCE}:{}};h(`[API:request] Creating client, ANTHROPIC_CUSTOM_HEADERS present: ${!!process.env.ANTHROPIC_CUSTOM_HEADERS}, has Authorization header: ${!!ne.Authorization}`),a(process.env.CLAUDE_CODE_ADDITIONAL_PROTECTION)&&(re[`x-anthropic-additional-protection`]=`true`);let ie=ht(i,o),u={defaultHeaders:re,maxRetries:n,timeout:parseInt(process.env.API_TIMEOUT_MS||`600000`,10),dangerouslyAllowBrowser:!0,fetchOptions:Fe({forAnthropicAPI:!0}),...ie&&{fetch:ie}};if(a(process.env.CLAUDE_CODE_USE_BEDROCK)){let{BedrockClient:e}=await import(`./bedrockClient-CfiDN-kF.js`),t=r===fr()&&process.env.ANTHROPIC_SMALL_FAST_MODEL_AWS_REGION?process.env.ANTHROPIC_SMALL_FAST_MODEL_AWS_REGION:s(),n={...u,awsRegion:t,...a(process.env.CLAUDE_CODE_SKIP_BEDROCK_AUTH)&&{skipAuth:!0},...g()&&{logger:w()}};return process.env.AWS_BEARER_TOKEN_BEDROCK&&(n.skipAuth=!0,n.defaultHeaders={...n.defaultHeaders,Authorization:`Bearer ${process.env.AWS_BEARER_TOKEN_BEDROCK}`}),new e(n)}if(a(process.env.CLAUDE_CODE_USE_FOUNDRY)){let{AnthropicFoundry:e}=await import(`./foundry-sdk-BdeF2aBu.js`),t;if(!process.env.ANTHROPIC_FOUNDRY_API_KEY)if(a(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({...u,...t&&{azureADTokenProvider:t},...g()&&{logger:w()}})}if(a(process.env.CLAUDE_CODE_USE_VERTEX)){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,o=process.env.GOOGLE_APPLICATION_CREDENTIALS||process.env.google_application_credentials,s=a(process.env.CLAUDE_CODE_SKIP_VERTEX_AUTH)?{getClient:()=>({getRequestHeaders:()=>({})})}:new n({scopes:[`https://www.googleapis.com/auth/cloud-platform`],...i||o?{}:{projectId:process.env.ANTHROPIC_VERTEX_PROJECT_ID}});return new e({...u,region:ee(r),googleAuth:s,...g()&&{logger:w()}})}return new _e({...e?{apiKey:e}:{},...u,...g()&&{logger:w()}})}function mt(){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 ht(e,t){let n=e??globalThis.fetch,r=b()===`firstParty`&&x();return(e,i)=>{let a=new Headers(i?.headers);r&&!a.has(`x-client-request-id`)&&a.set(T,ze());try{let n=e instanceof Request?e.url:String(e),r=a.get(T);h(`[API REQUEST] ${new URL(n).pathname}${r?` ${T}=${r}`:``} source=${t??`unknown`}`)}catch{}return n(e,{...i,headers:a})}}var T,gt=e((()=>{ge(),ft(),$(),S(),Pe(),d(),ve(),o(),T=`x-client-request-id`}));function _t(){return Le(i(),`cache`)}function vt(){return Le(_t(),`model-capabilities.json`)}function yt(){return!(b()!==`firstParty`||!x())}function bt(e){return[...e].sort((e,t)=>t.id.length-e.id.length||e.id.localeCompare(t.id))}function xt(e){if(!yt())return;let t=D(vt());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 St(){if(yt()&&!Ee())try{let e=await pt({maxRetries:1}),t=[];for await(let n of e.models.list()){let e=E().safeParse(n);e.success&&t.push(e.data)}if(t.length===0)return;let n=vt(),r=bt(t);if(st(D(n),r)){h(`[modelCapabilities] cache unchanged, skipping write`);return}await Be(_t(),{recursive:!0}),await Ve(n,he({models:r,timestamp:Date.now()}),{encoding:`utf-8`,mode:384}),D.cache.delete(n),h(`[modelCapabilities] cached ${r.length} models`)}catch(e){h(`[modelCapabilities] fetch failed: ${e instanceof Error?e.message:`unknown`}`)}}var E,Ct,D,wt=e((()=>{ct(),r(),oe(),gt(),ve(),o(),ie(),u(),Te(),ye(),S(),E=ae(()=>c({id:ne(),max_input_tokens:l().optional(),max_tokens:l().optional()}).strip()),Ct=ae(()=>c({models:te(E()),timestamp:l()})),D=n(e=>{try{let t=Re(e,`utf-8`),n=Ct().safeParse(re(t,!1));return n.success?n.data.models:null}catch{return null}},e=>e)}));function O(){return a(process.env.CLAUDE_CODE_DISABLE_1M_CONTEXT)}function k(e){return!O()&&/\[1m\]/i.test(e)}function Tt(e){if(O())return!1;let t=Z(e);return t.includes(`claude-sonnet-4`)||t.includes(`opus-4-6`)||t.includes(`opus-4-7`)}function Et(e,t){if(k(e))return 1e6;let n=xt(e);return n?.max_input_tokens&&n.max_input_tokens>=1e5?n.max_input_tokens>2e5&&O()?A:n.max_input_tokens:t?.includes(`context-1m-2025-08-07`)&&Tt(e)||Dt(e)?1e6:A}function Dt(e){return O()||k(e)||!Z(e).includes(`sonnet-4-6`)?!1:we().clientDataCache?.coral_reef_sonnet===`true`}function Ot(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 kt(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=Mt,n=Nt);let i=xt(e);return i?.max_tokens&&i.max_tokens>=4096&&(n=i.max_tokens,t=Math.min(t,n)),{default:t,upperLimit:n}}function At(e){return kt(e).upperLimit-1}var A,jt,Mt,Nt,Pt,Ft=e((()=>{ot(),Ce(),o(),$(),wt(),A=2e5,jt=2e4,Mt=32e3,Nt=64e3,Pt=8e3}));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-BXXmyhQ2.js`),t=s(),n=a(process.env.CLAUDE_CODE_SKIP_BEDROCK_AUTH);return new e({region:t,...process.env.ANTHROPIC_BEDROCK_BASE_URL&&{endpoint:process.env.ANTHROPIC_BEDROCK_BASE_URL},...await Ie(),...n&&{requestHandler:new(await(import(`./dist-es-C7vygWzp.js`))).NodeHttpHandler,httpAuthSchemes:[{schemeId:`smithy.api#noAuth`,identityProvider:()=>async()=>({}),signer:new(await(import(`./dist-es-gUzZ_7Vf.js`))).NoAuthSigner}],httpAuthSchemeProvider:()=>[{schemeId:`smithy.api#noAuth`}]}})}async function Bt(){let{BedrockRuntimeClient:e}=await import(`./dist-es-CzTYn7xo.js`),t=s(),n=a(process.env.CLAUDE_CODE_SKIP_BEDROCK_AUTH);return new e({region:t,...process.env.ANTHROPIC_BEDROCK_BASE_URL&&{endpoint:process.env.ANTHROPIC_BEDROCK_BASE_URL},...await Ie(),...n&&{requestHandler:new(await(import(`./dist-es-C7vygWzp.js`))).NodeHttpHandler,httpAuthSchemes:[{schemeId:`smithy.api#noAuth`,identityProvider:()=>async()=>({}),signer:new(await(import(`./dist-es-gUzZ_7Vf.js`))).NoAuthSigner}],httpAuthSchemeProvider:()=>[{schemeId:`smithy.api#noAuth`}]}})}function 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((()=>{r(),o(),De(),Pe(),Gt=n(async()=>{let[e,{ListInferenceProfilesCommand:t}]=await Promise.all([zt(),import(`./dist-es-BXXmyhQ2.js`)]),n=[],r;try{do{let i=new t({...r&&{nextToken:r},typeEquals:`SYSTEM_DEFINED`}),a=await e.send(i);a.inferenceProfileSummaries&&n.push(...a.inferenceProfileSummaries),r=a.nextToken}while(r);return n.filter(e=>e.inferenceProfileId?.includes(`anthropic`)).map(e=>e.inferenceProfileId).filter(Boolean)}catch(e){throw y(e),e}}),Kt=n(async e=>{try{let[t,{GetInferenceProfileCommand:n}]=await Promise.all([zt(),import(`./dist-es-BXXmyhQ2.js`)]),r=new n({inferenceProfileIdentifier:e}),i=await t.send(r);if(!i.models||i.models.length===0)return null;let a=i.models[0];if(!a?.modelArn)return null;let o=a.modelArn.lastIndexOf(`/`);return o>=0?a.modelArn.substring(o+1):a.modelArn}catch(e){return y(e),null}}),qt=[`us`,`eu`,`apac`,`global`]})),Yt,Xt,Zt,Qt,$t,en,tn,nn,rn,j,an,M,N,on,sn=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`},j={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`},an={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`},M={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`},N={haiku35:Zt,haiku45:Qt,sonnet35:Xt,sonnet37:Yt,sonnet40:$t,sonnet45:en,sonnet46:M,opus40:tn,opus41:nn,opus45:rn,opus46:j,opus47:an},Object.values(N).map(e=>e.firstParty),on=Object.fromEntries(Object.entries(N).map(([e,t])=>[t.firstParty,e]))}));function P(e){let t={};for(let n of pn)t[n]=N[n][e];return t}async function cn(){let e=P(`bedrock`),t;try{t=await Gt()}catch(t){return y(t),e}if(!t?.length)return e;let n={};for(let r of pn){let i=N[r].firstParty;n[r]=Rt(t,i)||e[r]}return n}function ln(e){let t=v().modelOverrides;if(!t)return e;let n={...e};for(let[e,r]of Object.entries(t)){let t=on[e];t&&r&&(n[t]=r)}return n}function un(e){let t;try{t=v().modelOverrides}catch{return e}if(!t)return e;for(let[n,r]of Object.entries(t))if(r===e)return n;return e}function dn(){if(f()===null){if(b()!==`bedrock`){m(P(b()));return}mn()}}function F(){let e=f();return e===null?(dn(),ln(P(b()))):ln(e)}async function fn(){if(f()===null){if(b()!==`bedrock`){m(P(b()));return}await mn()}}var pn,mn,hn=e((()=>{d(),De(),Lt(),_(),Jt(),sn(),S(),pn=Object.keys(N),mn=It(async()=>{if(f()===null)try{m(await cn())}catch(e){y(e)}})}));function I(){return!a(process.env.CLAUDE_CODE_DISABLE_FAST_MODE)}function gn(){return I()?_n()===null:!1}function _n(){if(!I())return`Fast mode is not available`;if(Oe(),ce()&&se()&&!Se(`flagSettings`)?.fastMode){let e=`Fast mode is not available in the Agent SDK`;return h(`Fast mode unavailable: ${e}`),e}if(b()!==`firstParty`){let e=`Fast mode is not available on Bedrock, Vertex, or Foundry`;return h(`Fast mode unavailable: ${e}`),e}return null}function vn(){return`opus${xr()?`[1m]`:``}`}function yn(e){if(!I()||!gn()||!L(e))return!1;let t=v();return!t.fastModePerSessionOptIn&&t.fastMode===!0}function L(e){if(!I())return!1;let t=Q(e??Y());return t.toLowerCase().includes(`opus-4-7`)||t.toLowerCase().includes(`opus-4-6`)}function bn(){return R.status===`cooldown`&&Date.now()>=R.resetAt&&(I()&&!z&&(h(`Fast mode cooldown expired, re-enabling fast mode`),z=!0,Mn.emit()),R={status:`active`}),R}function xn(e,t){if(!I())return;R={status:`cooldown`,resetAt:e,reason:t},z=!1;let n=e-Date.now();h(`Fast mode cooldown triggered (${t}), duration ${Math.round(n/1e3)}s`),Ne(`tengu_fast_mode_fallback_triggered`,{cooldown_duration_ms:n,cooldown_reason:t}),jn.emit(e,t)}function Sn(){R={status:`active`}}function Cn(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 wn(){h(`Fast mode rejected by API, disabling`)}function Tn(e){let t=Cn(e);h(`Fast mode overage rejection: ${e??`unknown`} — ${t}`),Ne(`tengu_fast_mode_overage_rejected`,{overage_disabled_reason:e??`unknown`}),Fn.emit(t)}function En(){return bn().status===`cooldown`}function Dn(e,t){let n=I()&&gn()&&!!t&&L(e);return n&&En()?`cooldown`:n?`on`:`off`}function On(){}async function kn(){}var An,R,z,jn,Mn,Nn,Pn,Fn,In,Ln,Rn,zn=e((()=>{Me(),d(),ke(),ve(),o(),$(),S(),_(),le(),An=`Opus 4.7`,R={status:`active`},z=!1,jn=p(),Mn=p(),Nn=jn.subscribe,Pn=Mn.subscribe,Fn=p(),In=Fn.subscribe,Ln=p(),Rn=Ln.subscribe}));function Bn(e){return I()&&e?Yn:V}function Vn(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 Hn(e,t){let n=Z(e);return n===X(j.firstParty)?Bn(t.speed===`fast`):H[n]||(Un(e,n),H[Z(Y())]??Qn)}function Un(e,t){Ne(`tengu_unknown_model_cost`,{model:e,shortName:t}),fe()}function Wn(e,t){return Vn(Hn(e,t),t)}function Gn(e,t){return Wn(e,{input_tokens:t.inputTokens,output_tokens:t.outputTokens,cache_read_input_tokens:t.cacheReadInputTokens,cache_creation_input_tokens:t.cacheCreationInputTokens})}function Kn(e){return Number.isInteger(e)?`$${e}`:`$${e.toFixed(2)}`}function qn(e){return`${Kn(e.inputTokens)}/${Kn(e.outputTokens)} per Mtok`}var B,Jn,V,Yn,Xn,Zn,Qn,H,$n=e((()=>{Me(),d(),zn(),sn(),$(),B={inputTokens:3,outputTokens:15,promptCacheWriteTokens:3.75,promptCacheReadTokens:.3,webSearchRequests:.01},Jn={inputTokens:15,outputTokens:75,promptCacheWriteTokens:18.75,promptCacheReadTokens:1.5,webSearchRequests:.01},V={inputTokens:5,outputTokens:25,promptCacheWriteTokens:6.25,promptCacheReadTokens:.5,webSearchRequests:.01},Yn={inputTokens:30,outputTokens:150,promptCacheWriteTokens:37.5,promptCacheReadTokens:3,webSearchRequests:.01},Xn={inputTokens:.8,outputTokens:4,promptCacheWriteTokens:1,promptCacheReadTokens:.08,webSearchRequests:.01},Zn={inputTokens:1,outputTokens:5,promptCacheWriteTokens:1.25,promptCacheReadTokens:.1,webSearchRequests:.01},Qn=V,H={[X(Zt.firstParty)]:Xn,[X(Qt.firstParty)]:Zn,[X(Xt.firstParty)]:B,[X(Yt.firstParty)]:B,[X($t.firstParty)]:B,[X(en.firstParty)]:B,[X(M.firstParty)]:B,[X(tn.firstParty)]:Jn,[X(nn.firstParty)]:Jn,[X(rn.firstParty)]:V,[X(j.firstParty)]:V}}));function U(e){return er.includes(e)}function W(e){return tr.includes(e)}var er,tr,nr=e((()=>{er=[`sonnet`,`opus`,`haiku`,`best`,`sonnet[1m]`,`opus[1m]`,`opusplan`],tr=[`sonnet`,`opus`,`haiku`]}));function rr(e,t){return e.includes(t)?!0:U(e)?Q(e).toLowerCase().includes(t):!1}function ir(e,t){return e.startsWith(t)?e.length===t.length||e[t.length]===`-`:!1}function ar(e,t){let n=U(e)?Q(e).toLowerCase():e;return!!(ir(n,t)||!t.startsWith(`claude-`)&&ir(n,`claude-${t}`))}function or(e,t){for(let n of t){if(W(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 sr(e){let{availableModels:t}=xe()||{};if(!t)return!0;if(t.length===0)return!1;let n=un(e).trim().toLowerCase(),r=t.map(e=>e.trim().toLowerCase());if(r.includes(n)&&(!W(n)||!or(n,r)))return!0;for(let e of r)if(W(e)&&!or(e,r)&&rr(n,e))return!0;if(U(n)){let e=Q(n).toLowerCase();if(r.includes(e))return!0}for(let e of r)if(!W(e)&&U(e)&&Q(e).toLowerCase()===n)return!0;for(let e of r)if(!W(e)&&!U(e)&&ar(n,e))return!0;return!1}var cr=e((()=>{_(),nr(),$(),hn()}));function G(){return process.env.OPENAI_AUTH_MODE===`chatgpt`}var lr,ur,dr=e((()=>{lr=`gpt-5.5`,ur=`gpt-5.4-mini`}));function fr(){let e=b();return e===`openai`&&G()?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||_r()}function pr(e){return e===F().opus40||e===F().opus41||e===F().opus45||e===F().opus46||e===F().opus47}function K(){let e,t=ue();if(t!==void 0)e=t;else{let t=xe()||{};e=process.env.ANTHROPIC_MODEL||t.model||void 0}if(!(e&&!sr(e)))return e}function mr(){let e=K();return e==null?yr():Q(e)}function hr(){return q()}function gr(){let e=b();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 q(){let e=b();return e===`openai`&&G()?lr: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:gr()||F().opus47}function J(){let e=b();return e===`openai`&&G()?lr: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:gr()||(e===`firstParty`?F().sonnet46:F().sonnet45)}function _r(){let e=b();return e===`openai`&&G()?ur: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:gr()||F().haiku45}function vr(e){let{permissionMode:t,mainLoopModel:n,exceeds200kTokens:r=!1}=e;return K()===`opusplan`&&t===`plan`&&!r?q():K()===`haiku`&&t===`plan`?J():n}function Y(){return J()}function yr(){return Q(Y())}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(un(e))}function br(e){return e===`opusplan`?`Opus 4.7 in plan mode, else Sonnet 4.6`:wr(Q(e))}function xr(){return!(O()||b()!==`firstParty`||!x())}function Sr(e){return e===`opusplan`?`Opus Plan`:U(e)?Ae(e):wr(e)}function Cr(e){switch(e){case F().opus47:return`Opus 4.7`;case`${F().opus47}[1m]`:return`Opus 4.7 (1M context)`;case F().opus46:return`Opus 4.6`;case`${F().opus46}[1m]`:return`Opus 4.6 (1M context)`;case F().opus45:return`Opus 4.5`;case F().opus41:return`Opus 4.1`;case F().opus40:return`Opus 4`;case`${F().sonnet46}[1m]`:return`Sonnet 4.6 (1M context)`;case F().sonnet46:return`Sonnet 4.6`;case`${F().sonnet45}[1m]`:return`Sonnet 4.5 (1M context)`;case F().sonnet45:return`Sonnet 4.5`;case F().sonnet40:return`Sonnet 4`;case`${F().sonnet40}[1m]`:return`Sonnet 4 (1M context)`;case F().sonnet37:return`Sonnet 3.7`;case F().sonnet35:return`Sonnet 3.5`;case F().haiku45:return`Haiku 4.5`;case F().haiku35:return`Haiku 3.5`;default:return null}}function wr(e){return Cr(e)||e}function Q(e){let t=e.trim(),n=t.toLowerCase(),r=k(n),i=r?n.replace(/\[1m]$/i,``).trim():n;if(U(i))switch(i){case`opusplan`:return J()+(r?`[1m]`:``);case`sonnet`:return J()+(r?`[1m]`:``);case`haiku`:return _r()+(r?`[1m]`:``);case`opus`:return q()+(r?`[1m]`:``);case`best`:return hr();default:}return b()===`firstParty`&&Er(i)&&Dr()?q()+(r?`[1m]`:``):r?`${t.replace(/\[1m\]$/i,``).trim()}[1m]`:t}function Tr(e,t){return k(e)||!k(t)?e:Tt(Q(e))?`${e}[1m]`:e}function Er(e){return jr.includes(e)}function Dr(){return!a(process.env.CLAUDE_CODE_DISABLE_LEGACY_MODEL_REMAP)}function Or(e){if(e===null)return`Default (${yr()})`;let t=Q(e);return e===t?t:`${e} (${t})`}function kr(e){if(b()===`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 Ar(e){return e.replace(/\[(1|2)m\]/gi,``)}var jr,$=e((()=>{d(),Ft(),o(),hn(),$n(),_(),S(),be(),cr(),nr(),je(),dr(),jr=[`claude-opus-4-20250514`,`claude-opus-4-1-20250805`,`claude-opus-4-0`,`claude-opus-4-1`]}));export{xn as $,qn as A,ft as At,Tn as B,et as Bt,sr as C,St as Ct,H as D,dt as Dt,B as E,gt as Et,vn as F,Je as Ft,I as G,ot as Gt,zn as H,Ze as Ht,bn as I,Ye as It,Nn as J,Ge as Jt,L as K,We as Kt,Dn as L,Xe as Lt,$n as M,st as Mt,An as N,rt as Nt,Gn as O,ut as Ot,Sn as P,it as Pt,On as Q,x as Qt,_n as R,tt as Rt,cr as S,wt as St,nr as T,pt as Tt,gn as U,$e as Ut,wn as V,nt as Vt,En as W,at as Wt,Rn as X,Ue as Xt,In as Y,b as Yt,kn as Z,S as Zt,Q as _,kt as _t,J as a,Gt as at,Sr as b,Ft as bt,vr as c,Jt as ct,$ as d,It as dt,fn as et,Dr as f,Pt as ft,Ar as g,At as gt,Or as h,Et as ht,q as i,Bt as it,Bn as j,ct as jt,Wn as k,lt as kt,fr as l,Vt as lt,xr as m,Ot as mt,yr as n,hn as nt,mr as o,Ut as ot,pr as p,jt as pt,Pn as q,qe as qt,Y as r,Wt as rt,kr as s,Kt as st,Z as t,F as tt,K as u,Lt as ut,br as v,Dt as vt,er as w,T as wt,Tr as x,O as xt,wr as y,k as yt,yn as z,C as zt};
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./memoize-BK3gG5ob.js";import{i,l as a,o,r as ee,t as s}from"./envUtils-DfkgIdYf.js";import{G as c,P as te,W as l,Z as ne,f as re,l as ie,o as u,s as ae,x as oe}from"./types-Dx7P7JLQ.js";import{Ht as se,I as ce,It as d,Jn as le,K as f,W as ue,br as de,qn as p,sn as fe,st as pe,wn as m,xr as me}from"./state-B4jiUise.js";import{C as he,H as ge,U as _e,c as h,i as ve,o as g,x as ye}from"./debug-Bglx1aTu.js";import{Ht as be,d as xe,h as _,s as Se,t as v}from"./settings-B2jvL8Dp.js";import{p as Ce,s as we}from"./config-C-Y2qtB2.js";import{d as Te,f as Ee,o as De,s as y}from"./log-D2TIwHBV.js";import{h as Oe,m as ke,n as Ae,o as je}from"./stringUtils-C718f5ey.js";import{n as Me,r as Ne}from"./analytics-DJobLaWP.js";import{c as Pe,i as Fe,r as Ie}from"./proxy-CDBfZjO7.js";import{join as Le}from"path";import{readFileSync as Re}from"fs";import{randomUUID as ze}from"crypto";import{mkdir as Be,writeFile as Ve}from"fs/promises";import{AsyncLocalStorage as He}from"async_hooks";function b(e=v()){let t=e.modelType;return t===`openai`?`openai`:t===`gemini`?`gemini`:t===`grok`?`grok`:a(process.env.CLAUDE_CODE_USE_BEDROCK)?`bedrock`:a(process.env.CLAUDE_CODE_USE_VERTEX)?`vertex`:a(process.env.CLAUDE_CODE_USE_FOUNDRY)?`foundry`:a(process.env.CLAUDE_CODE_USE_OPENAI)?`openai`:a(process.env.CLAUDE_CODE_USE_GEMINI)?`gemini`:a(process.env.CLAUDE_CODE_USE_GROK)?`grok`:`firstParty`}function Ue(){return b()}function x(){let e=process.env.ANTHROPIC_BASE_URL;if(!e)return!0;try{return new URL(e).host===`api.anthropic.com`}catch{return!1}}var S=e((()=>{_(),o()}));function We(){return Ke.getStore()?.workload}function Ge(e,t){return Ke.run({workload:e},t)}var Ke,qe=e((()=>{Ke=new He})),Je,C,Ye,Xe,Ze,Qe,$e,et,tt,nt,rt,it,at,ot=e((()=>{Je=`claude-code-20250219`,C=`interleaved-thinking-2025-05-14`,Ye=`context-1m-2025-08-07`,Xe=`context-management-2025-06-27`,Ze=`structured-outputs-2025-12-15`,Qe=`tool-search-tool-2025-10-19`,$e=`task-budgets-2026-03-13`,et=`prompt-caching-scope-2026-01-05`,tt=`fast-mode-2026-02-01`,nt=`redact-thinking-2026-02-12`,rt=`advisor-tool-2026-03-01`,it=new Set([C,Ye,Qe]),at=new Set([Je,C,Xe])}));function st(e,t){return de(e,t)}var ct=e((()=>{me()}));function lt(){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=We(),r=n?`, workload/${n}`:``;return`claude-cli/0.0.24 (external, ${process.env.CLAUDE_CODE_ENTRYPOINT??`cli`}${e}${t}${r})`}function ut(){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.24${e.length>0?` (${e.join(`, `)})`:``}`}function dt(){return{headers:{},error:`No auth available — login removed`}}var ft=e((()=>{qe()}));function w(){return{error:(e,...t)=>console.error(`[SDK ERROR]`,e,...t),warn:(e,...t)=>console.error(`[SDK WARN]`,e,...t),info:(e,...t)=>console.error(`[SDK INFO]`,e,...t),debug:(e,...t)=>console.error(`[SDK DEBUG]`,e,...t)}}async function pt({apiKey:e,maxRetries:n,model:r,fetchOverride:i,source:o}){let c=process.env.CLAUDE_CODE_CONTAINER_ID,te=process.env.CLAUDE_CODE_REMOTE_SESSION_ID,l=process.env.CLAUDE_AGENT_SDK_CLIENT_APP,ne=mt(),re={"x-app":`cli`,"User-Agent":lt(),"X-Claude-Code-Session-Id":pe(),...ne,...c?{"x-claude-remote-container-id":c}:{},...te?{"x-claude-remote-session-id":te}:{},...l?{"x-client-app":l}:{},...process.env.ANTHROPIC_AUTH_NONCE?{"x-auth-nonce":process.env.ANTHROPIC_AUTH_NONCE}:{}};h(`[API:request] Creating client, ANTHROPIC_CUSTOM_HEADERS present: ${!!process.env.ANTHROPIC_CUSTOM_HEADERS}, has Authorization header: ${!!ne.Authorization}`),a(process.env.CLAUDE_CODE_ADDITIONAL_PROTECTION)&&(re[`x-anthropic-additional-protection`]=`true`);let ie=ht(i,o),u={defaultHeaders:re,maxRetries:n,timeout:parseInt(process.env.API_TIMEOUT_MS||`600000`,10),dangerouslyAllowBrowser:!0,fetchOptions:Fe({forAnthropicAPI:!0}),...ie&&{fetch:ie}};if(a(process.env.CLAUDE_CODE_USE_BEDROCK)){let{BedrockClient:e}=await import(`./bedrockClient-CfiDN-kF.js`),t=r===fr()&&process.env.ANTHROPIC_SMALL_FAST_MODEL_AWS_REGION?process.env.ANTHROPIC_SMALL_FAST_MODEL_AWS_REGION:s(),n={...u,awsRegion:t,...a(process.env.CLAUDE_CODE_SKIP_BEDROCK_AUTH)&&{skipAuth:!0},...g()&&{logger:w()}};return process.env.AWS_BEARER_TOKEN_BEDROCK&&(n.skipAuth=!0,n.defaultHeaders={...n.defaultHeaders,Authorization:`Bearer ${process.env.AWS_BEARER_TOKEN_BEDROCK}`}),new e(n)}if(a(process.env.CLAUDE_CODE_USE_FOUNDRY)){let{AnthropicFoundry:e}=await import(`./foundry-sdk-BdeF2aBu.js`),t;if(!process.env.ANTHROPIC_FOUNDRY_API_KEY)if(a(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({...u,...t&&{azureADTokenProvider:t},...g()&&{logger:w()}})}if(a(process.env.CLAUDE_CODE_USE_VERTEX)){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,o=process.env.GOOGLE_APPLICATION_CREDENTIALS||process.env.google_application_credentials,s=a(process.env.CLAUDE_CODE_SKIP_VERTEX_AUTH)?{getClient:()=>({getRequestHeaders:()=>({})})}:new n({scopes:[`https://www.googleapis.com/auth/cloud-platform`],...i||o?{}:{projectId:process.env.ANTHROPIC_VERTEX_PROJECT_ID}});return new e({...u,region:ee(r),googleAuth:s,...g()&&{logger:w()}})}return new _e({...e?{apiKey:e}:{},...u,...g()&&{logger:w()}})}function mt(){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 ht(e,t){let n=e??globalThis.fetch,r=b()===`firstParty`&&x();return(e,i)=>{let a=new Headers(i?.headers);r&&!a.has(`x-client-request-id`)&&a.set(T,ze());try{let n=e instanceof Request?e.url:String(e),r=a.get(T);h(`[API REQUEST] ${new URL(n).pathname}${r?` ${T}=${r}`:``} source=${t??`unknown`}`)}catch{}return n(e,{...i,headers:a})}}var T,gt=e((()=>{ge(),ft(),$(),S(),Pe(),d(),ve(),o(),T=`x-client-request-id`}));function _t(){return Le(i(),`cache`)}function vt(){return Le(_t(),`model-capabilities.json`)}function yt(){return!(b()!==`firstParty`||!x())}function bt(e){return[...e].sort((e,t)=>t.id.length-e.id.length||e.id.localeCompare(t.id))}function xt(e){if(!yt())return;let t=D(vt());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 St(){if(yt()&&!Ee())try{let e=await pt({maxRetries:1}),t=[];for await(let n of e.models.list()){let e=E().safeParse(n);e.success&&t.push(e.data)}if(t.length===0)return;let n=vt(),r=bt(t);if(st(D(n),r)){h(`[modelCapabilities] cache unchanged, skipping write`);return}await Be(_t(),{recursive:!0}),await Ve(n,he({models:r,timestamp:Date.now()}),{encoding:`utf-8`,mode:384}),D.cache.delete(n),h(`[modelCapabilities] cached ${r.length} models`)}catch(e){h(`[modelCapabilities] fetch failed: ${e instanceof Error?e.message:`unknown`}`)}}var E,Ct,D,wt=e((()=>{ct(),r(),oe(),gt(),ve(),o(),ie(),u(),Te(),ye(),S(),E=ae(()=>c({id:ne(),max_input_tokens:l().optional(),max_tokens:l().optional()}).strip()),Ct=ae(()=>c({models:te(E()),timestamp:l()})),D=n(e=>{try{let t=Re(e,`utf-8`),n=Ct().safeParse(re(t,!1));return n.success?n.data.models:null}catch{return null}},e=>e)}));function O(){return a(process.env.CLAUDE_CODE_DISABLE_1M_CONTEXT)}function k(e){return!O()&&/\[1m\]/i.test(e)}function Tt(e){if(O())return!1;let t=Z(e);return t.includes(`claude-sonnet-4`)||t.includes(`opus-4-6`)||t.includes(`opus-4-7`)}function Et(e,t){if(k(e))return 1e6;let n=xt(e);return n?.max_input_tokens&&n.max_input_tokens>=1e5?n.max_input_tokens>2e5&&O()?A:n.max_input_tokens:t?.includes(`context-1m-2025-08-07`)&&Tt(e)||Dt(e)?1e6:A}function Dt(e){return O()||k(e)||!Z(e).includes(`sonnet-4-6`)?!1:we().clientDataCache?.coral_reef_sonnet===`true`}function Ot(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 kt(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=Mt,n=Nt);let i=xt(e);return i?.max_tokens&&i.max_tokens>=4096&&(n=i.max_tokens,t=Math.min(t,n)),{default:t,upperLimit:n}}function At(e){return kt(e).upperLimit-1}var A,jt,Mt,Nt,Pt,Ft=e((()=>{ot(),Ce(),o(),$(),wt(),A=2e5,jt=2e4,Mt=32e3,Nt=64e3,Pt=8e3}));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-BXXmyhQ2.js`),t=s(),n=a(process.env.CLAUDE_CODE_SKIP_BEDROCK_AUTH);return new e({region:t,...process.env.ANTHROPIC_BEDROCK_BASE_URL&&{endpoint:process.env.ANTHROPIC_BEDROCK_BASE_URL},...await Ie(),...n&&{requestHandler:new(await(import(`./dist-es-C7vygWzp.js`))).NodeHttpHandler,httpAuthSchemes:[{schemeId:`smithy.api#noAuth`,identityProvider:()=>async()=>({}),signer:new(await(import(`./dist-es-gUzZ_7Vf.js`))).NoAuthSigner}],httpAuthSchemeProvider:()=>[{schemeId:`smithy.api#noAuth`}]}})}async function Bt(){let{BedrockRuntimeClient:e}=await import(`./dist-es-CzTYn7xo.js`),t=s(),n=a(process.env.CLAUDE_CODE_SKIP_BEDROCK_AUTH);return new e({region:t,...process.env.ANTHROPIC_BEDROCK_BASE_URL&&{endpoint:process.env.ANTHROPIC_BEDROCK_BASE_URL},...await Ie(),...n&&{requestHandler:new(await(import(`./dist-es-C7vygWzp.js`))).NodeHttpHandler,httpAuthSchemes:[{schemeId:`smithy.api#noAuth`,identityProvider:()=>async()=>({}),signer:new(await(import(`./dist-es-gUzZ_7Vf.js`))).NoAuthSigner}],httpAuthSchemeProvider:()=>[{schemeId:`smithy.api#noAuth`}]}})}function 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((()=>{r(),o(),De(),Pe(),Gt=n(async()=>{let[e,{ListInferenceProfilesCommand:t}]=await Promise.all([zt(),import(`./dist-es-BXXmyhQ2.js`)]),n=[],r;try{do{let i=new t({...r&&{nextToken:r},typeEquals:`SYSTEM_DEFINED`}),a=await e.send(i);a.inferenceProfileSummaries&&n.push(...a.inferenceProfileSummaries),r=a.nextToken}while(r);return n.filter(e=>e.inferenceProfileId?.includes(`anthropic`)).map(e=>e.inferenceProfileId).filter(Boolean)}catch(e){throw y(e),e}}),Kt=n(async e=>{try{let[t,{GetInferenceProfileCommand:n}]=await Promise.all([zt(),import(`./dist-es-BXXmyhQ2.js`)]),r=new n({inferenceProfileIdentifier:e}),i=await t.send(r);if(!i.models||i.models.length===0)return null;let a=i.models[0];if(!a?.modelArn)return null;let o=a.modelArn.lastIndexOf(`/`);return o>=0?a.modelArn.substring(o+1):a.modelArn}catch(e){return y(e),null}}),qt=[`us`,`eu`,`apac`,`global`]})),Yt,Xt,Zt,Qt,$t,en,tn,nn,rn,j,an,M,N,on,sn=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`},j={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`},an={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`},M={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`},N={haiku35:Zt,haiku45:Qt,sonnet35:Xt,sonnet37:Yt,sonnet40:$t,sonnet45:en,sonnet46:M,opus40:tn,opus41:nn,opus45:rn,opus46:j,opus47:an},Object.values(N).map(e=>e.firstParty),on=Object.fromEntries(Object.entries(N).map(([e,t])=>[t.firstParty,e]))}));function P(e){let t={};for(let n of pn)t[n]=N[n][e];return t}async function cn(){let e=P(`bedrock`),t;try{t=await Gt()}catch(t){return y(t),e}if(!t?.length)return e;let n={};for(let r of pn){let i=N[r].firstParty;n[r]=Rt(t,i)||e[r]}return n}function ln(e){let t=v().modelOverrides;if(!t)return e;let n={...e};for(let[e,r]of Object.entries(t)){let t=on[e];t&&r&&(n[t]=r)}return n}function un(e){let t;try{t=v().modelOverrides}catch{return e}if(!t)return e;for(let[n,r]of Object.entries(t))if(r===e)return n;return e}function dn(){if(f()===null){if(b()!==`bedrock`){m(P(b()));return}mn()}}function F(){let e=f();return e===null?(dn(),ln(P(b()))):ln(e)}async function fn(){if(f()===null){if(b()!==`bedrock`){m(P(b()));return}await mn()}}var pn,mn,hn=e((()=>{d(),De(),Lt(),_(),Jt(),sn(),S(),pn=Object.keys(N),mn=It(async()=>{if(f()===null)try{m(await cn())}catch(e){y(e)}})}));function I(){return!a(process.env.CLAUDE_CODE_DISABLE_FAST_MODE)}function gn(){return I()?_n()===null:!1}function _n(){if(!I())return`Fast mode is not available`;if(Oe(),ce()&&se()&&!Se(`flagSettings`)?.fastMode){let e=`Fast mode is not available in the Agent SDK`;return h(`Fast mode unavailable: ${e}`),e}if(b()!==`firstParty`){let e=`Fast mode is not available on Bedrock, Vertex, or Foundry`;return h(`Fast mode unavailable: ${e}`),e}return null}function vn(){return`opus${xr()?`[1m]`:``}`}function yn(e){if(!I()||!gn()||!L(e))return!1;let t=v();return!t.fastModePerSessionOptIn&&t.fastMode===!0}function L(e){if(!I())return!1;let t=Q(e??Y());return t.toLowerCase().includes(`opus-4-7`)||t.toLowerCase().includes(`opus-4-6`)}function bn(){return R.status===`cooldown`&&Date.now()>=R.resetAt&&(I()&&!z&&(h(`Fast mode cooldown expired, re-enabling fast mode`),z=!0,Mn.emit()),R={status:`active`}),R}function xn(e,t){if(!I())return;R={status:`cooldown`,resetAt:e,reason:t},z=!1;let n=e-Date.now();h(`Fast mode cooldown triggered (${t}), duration ${Math.round(n/1e3)}s`),Ne(`tengu_fast_mode_fallback_triggered`,{cooldown_duration_ms:n,cooldown_reason:t}),jn.emit(e,t)}function Sn(){R={status:`active`}}function Cn(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 wn(){h(`Fast mode rejected by API, disabling`)}function Tn(e){let t=Cn(e);h(`Fast mode overage rejection: ${e??`unknown`} — ${t}`),Ne(`tengu_fast_mode_overage_rejected`,{overage_disabled_reason:e??`unknown`}),Fn.emit(t)}function En(){return bn().status===`cooldown`}function Dn(e,t){let n=I()&&gn()&&!!t&&L(e);return n&&En()?`cooldown`:n?`on`:`off`}function On(){}async function kn(){}var An,R,z,jn,Mn,Nn,Pn,Fn,In,Ln,Rn,zn=e((()=>{Me(),d(),ke(),ve(),o(),$(),S(),_(),le(),An=`Opus 4.7`,R={status:`active`},z=!1,jn=p(),Mn=p(),Nn=jn.subscribe,Pn=Mn.subscribe,Fn=p(),In=Fn.subscribe,Ln=p(),Rn=Ln.subscribe}));function Bn(e){return I()&&e?Yn:V}function Vn(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 Hn(e,t){let n=Z(e);return n===X(j.firstParty)?Bn(t.speed===`fast`):H[n]||(Un(e,n),H[Z(Y())]??Qn)}function Un(e,t){Ne(`tengu_unknown_model_cost`,{model:e,shortName:t}),fe()}function Wn(e,t){return Vn(Hn(e,t),t)}function Gn(e,t){return Wn(e,{input_tokens:t.inputTokens,output_tokens:t.outputTokens,cache_read_input_tokens:t.cacheReadInputTokens,cache_creation_input_tokens:t.cacheCreationInputTokens})}function Kn(e){return Number.isInteger(e)?`$${e}`:`$${e.toFixed(2)}`}function qn(e){return`${Kn(e.inputTokens)}/${Kn(e.outputTokens)} per Mtok`}var B,Jn,V,Yn,Xn,Zn,Qn,H,$n=e((()=>{Me(),d(),zn(),sn(),$(),B={inputTokens:3,outputTokens:15,promptCacheWriteTokens:3.75,promptCacheReadTokens:.3,webSearchRequests:.01},Jn={inputTokens:15,outputTokens:75,promptCacheWriteTokens:18.75,promptCacheReadTokens:1.5,webSearchRequests:.01},V={inputTokens:5,outputTokens:25,promptCacheWriteTokens:6.25,promptCacheReadTokens:.5,webSearchRequests:.01},Yn={inputTokens:30,outputTokens:150,promptCacheWriteTokens:37.5,promptCacheReadTokens:3,webSearchRequests:.01},Xn={inputTokens:.8,outputTokens:4,promptCacheWriteTokens:1,promptCacheReadTokens:.08,webSearchRequests:.01},Zn={inputTokens:1,outputTokens:5,promptCacheWriteTokens:1.25,promptCacheReadTokens:.1,webSearchRequests:.01},Qn=V,H={[X(Zt.firstParty)]:Xn,[X(Qt.firstParty)]:Zn,[X(Xt.firstParty)]:B,[X(Yt.firstParty)]:B,[X($t.firstParty)]:B,[X(en.firstParty)]:B,[X(M.firstParty)]:B,[X(tn.firstParty)]:Jn,[X(nn.firstParty)]:Jn,[X(rn.firstParty)]:V,[X(j.firstParty)]:V}}));function U(e){return er.includes(e)}function W(e){return tr.includes(e)}var er,tr,nr=e((()=>{er=[`sonnet`,`opus`,`haiku`,`best`,`sonnet[1m]`,`opus[1m]`,`opusplan`],tr=[`sonnet`,`opus`,`haiku`]}));function rr(e,t){return e.includes(t)?!0:U(e)?Q(e).toLowerCase().includes(t):!1}function ir(e,t){return e.startsWith(t)?e.length===t.length||e[t.length]===`-`:!1}function ar(e,t){let n=U(e)?Q(e).toLowerCase():e;return!!(ir(n,t)||!t.startsWith(`claude-`)&&ir(n,`claude-${t}`))}function or(e,t){for(let n of t){if(W(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 sr(e){let{availableModels:t}=xe()||{};if(!t)return!0;if(t.length===0)return!1;let n=un(e).trim().toLowerCase(),r=t.map(e=>e.trim().toLowerCase());if(r.includes(n)&&(!W(n)||!or(n,r)))return!0;for(let e of r)if(W(e)&&!or(e,r)&&rr(n,e))return!0;if(U(n)){let e=Q(n).toLowerCase();if(r.includes(e))return!0}for(let e of r)if(!W(e)&&U(e)&&Q(e).toLowerCase()===n)return!0;for(let e of r)if(!W(e)&&!U(e)&&ar(n,e))return!0;return!1}var cr=e((()=>{_(),nr(),$(),hn()}));function G(){return process.env.OPENAI_AUTH_MODE===`chatgpt`}var lr,ur,dr=e((()=>{lr=`gpt-5.5`,ur=`gpt-5.4-mini`}));function fr(){let e=b();return e===`openai`&&G()?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||_r()}function pr(e){return e===F().opus40||e===F().opus41||e===F().opus45||e===F().opus46||e===F().opus47}function K(){let e,t=ue();if(t!==void 0)e=t;else{let t=xe()||{};e=process.env.ANTHROPIC_MODEL||t.model||void 0}if(!(e&&!sr(e)))return e}function mr(){let e=K();return e==null?yr():Q(e)}function hr(){return q()}function gr(){let e=b();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 q(){let e=b();return e===`openai`&&G()?lr: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:gr()||F().opus47}function J(){let e=b();return e===`openai`&&G()?lr: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:gr()||(e===`firstParty`?F().sonnet46:F().sonnet45)}function _r(){let e=b();return e===`openai`&&G()?ur: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:gr()||F().haiku45}function vr(e){let{permissionMode:t,mainLoopModel:n,exceeds200kTokens:r=!1}=e;return K()===`opusplan`&&t===`plan`&&!r?q():K()===`haiku`&&t===`plan`?J():n}function Y(){return J()}function yr(){return Q(Y())}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(un(e))}function br(e){return e===`opusplan`?`Opus 4.7 in plan mode, else Sonnet 4.6`:wr(Q(e))}function xr(){return!(O()||b()!==`firstParty`||!x())}function Sr(e){return e===`opusplan`?`Opus Plan`:U(e)?Ae(e):wr(e)}function Cr(e){switch(e){case F().opus47:return`Opus 4.7`;case`${F().opus47}[1m]`:return`Opus 4.7 (1M context)`;case F().opus46:return`Opus 4.6`;case`${F().opus46}[1m]`:return`Opus 4.6 (1M context)`;case F().opus45:return`Opus 4.5`;case F().opus41:return`Opus 4.1`;case F().opus40:return`Opus 4`;case`${F().sonnet46}[1m]`:return`Sonnet 4.6 (1M context)`;case F().sonnet46:return`Sonnet 4.6`;case`${F().sonnet45}[1m]`:return`Sonnet 4.5 (1M context)`;case F().sonnet45:return`Sonnet 4.5`;case F().sonnet40:return`Sonnet 4`;case`${F().sonnet40}[1m]`:return`Sonnet 4 (1M context)`;case F().sonnet37:return`Sonnet 3.7`;case F().sonnet35:return`Sonnet 3.5`;case F().haiku45:return`Haiku 4.5`;case F().haiku35:return`Haiku 3.5`;default:return null}}function wr(e){return Cr(e)||e}function Q(e){let t=e.trim(),n=t.toLowerCase(),r=k(n),i=r?n.replace(/\[1m]$/i,``).trim():n;if(U(i))switch(i){case`opusplan`:return J()+(r?`[1m]`:``);case`sonnet`:return J()+(r?`[1m]`:``);case`haiku`:return _r()+(r?`[1m]`:``);case`opus`:return q()+(r?`[1m]`:``);case`best`:return hr();default:}return b()===`firstParty`&&Er(i)&&Dr()?q()+(r?`[1m]`:``):r?`${t.replace(/\[1m\]$/i,``).trim()}[1m]`:t}function Tr(e,t){return k(e)||!k(t)?e:Tt(Q(e))?`${e}[1m]`:e}function Er(e){return jr.includes(e)}function Dr(){return!a(process.env.CLAUDE_CODE_DISABLE_LEGACY_MODEL_REMAP)}function Or(e){if(e===null)return`Default (${yr()})`;let t=Q(e);return e===t?t:`${e} (${t})`}function kr(e){if(b()===`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 Ar(e){return e.replace(/\[(1|2)m\]/gi,``)}var jr,$=e((()=>{d(),Ft(),o(),hn(),$n(),_(),S(),be(),cr(),nr(),je(),dr(),jr=[`claude-opus-4-20250514`,`claude-opus-4-1-20250805`,`claude-opus-4-0`,`claude-opus-4-1`]}));export{xn as $,qn as A,ft as At,Tn as B,et as Bt,sr as C,St as Ct,H as D,dt as Dt,B as E,gt as Et,vn as F,Je as Ft,I as G,ot as Gt,zn as H,Ze as Ht,bn as I,Ye as It,Nn as J,Ge as Jt,L as K,We as Kt,Dn as L,Xe as Lt,$n as M,st as Mt,An as N,rt as Nt,Gn as O,ut as Ot,Sn as P,it as Pt,On as Q,x as Qt,_n as R,tt as Rt,cr as S,wt as St,nr as T,pt as Tt,gn as U,$e as Ut,wn as V,nt as Vt,En as W,at as Wt,Rn as X,Ue as Xt,In as Y,b as Yt,kn as Z,S as Zt,Q as _,kt as _t,J as a,Gt as at,Sr as b,Ft as bt,vr as c,Jt as ct,$ as d,It as dt,fn as et,Dr as f,Pt as ft,Ar as g,At as gt,Or as h,Et as ht,q as i,Bt as it,Bn as j,ct as jt,Wn as k,lt as kt,fr as l,Vt as lt,xr as m,Ot as mt,yr as n,hn as nt,mr as o,Ut as ot,pr as p,jt as pt,Pn as q,qe as qt,Y as r,Wt as rt,kr as s,Kt as st,Z as t,F as tt,K as u,Lt as ut,br as v,Dt as vt,er as w,T as wt,Tr as x,O as xt,wr as y,k as yt,yn as z,C as zt};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{It as t,M as n}from"./state-B4jiUise.js";import{d as r,h as i}from"./settings-B2jvL8Dp.js";import{p as a,s as o}from"./config-C-Y2qtB2.js";import{A as s,C as c,E as l,M as u,S as d,Yt as f,Zt as p,d as m,r as h,u as g,v as _}from"./model-BwBG0V1u.js";function v(e=!1){let t=f()!==`firstParty`;return{value:null,label:`Default (recommended)`,description:`Use the default model (currently ${_(h())})${t?``:` · ${s(l)}`}`}}function y(e=!1){let t=[v(e)],r=process.env.ANTHROPIC_CUSTOM_MODEL_OPTION;r&&!t.some(e=>e.value===r)&&t.push({value:r,label:process.env.ANTHROPIC_CUSTOM_MODEL_OPTION_NAME??r,description:process.env.ANTHROPIC_CUSTOM_MODEL_OPTION_DESCRIPTION??`Custom model (${r})`});for(let e of o().additionalModelOptionsCache??[])t.some(t=>t.value===e.value)||t.push(e);let i=null,a=g(),s=n();return a==null?s!==null&&(i=s):i=a,i!==null&&!t.some(e=>e.value===i)&&t.push({value:i,label:i,description:`Custom model`}),b(t)}function b(e){return(r()||{}).availableModels?e.filter(e=>e.value===null||e.value!==null&&c(e.value)):e}function x(e,t){return e.length===0?null:b([v(t),...e])}var S=e((()=>{t(),a(),u(),i(),d(),m(),p()}));export{y as n,S as r,x as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{It as t,M as n}from"./state-B4jiUise.js";import{d as r,h as i}from"./settings-B2jvL8Dp.js";import{p as a,s as o}from"./config-C-Y2qtB2.js";import{A as s,C as c,E as l,M as u,S as d,Yt as f,Zt as p,d as m,r as h,u as g,v as _}from"./model-BvQFFOf8.js";function v(e=!1){let t=f()!==`firstParty`;return{value:null,label:`Default (recommended)`,description:`Use the default model (currently ${_(h())})${t?``:` · ${s(l)}`}`}}function y(e=!1){let t=[v(e)],r=process.env.ANTHROPIC_CUSTOM_MODEL_OPTION;r&&!t.some(e=>e.value===r)&&t.push({value:r,label:process.env.ANTHROPIC_CUSTOM_MODEL_OPTION_NAME??r,description:process.env.ANTHROPIC_CUSTOM_MODEL_OPTION_DESCRIPTION??`Custom model (${r})`});for(let e of o().additionalModelOptionsCache??[])t.some(t=>t.value===e.value)||t.push(e);let i=null,a=g(),s=n();return a==null?s!==null&&(i=s):i=a,i!==null&&!t.some(e=>e.value===i)&&t.push({value:i,label:i,description:`Custom model`}),b(t)}function b(e){return(r()||{}).availableModels?e.filter(e=>e.value===null||e.value!==null&&c(e.value)):e}function x(e,t){return e.length===0?null:b([v(t),...e])}var S=e((()=>{t(),a(),u(),i(),d(),m(),p()}));export{y as n,S as r,x as t};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{l as t,o as n}from"./envUtils-DfkgIdYf.js";import{ft as r,ut as i}from"./esm-eTAUP-La.js";import{n as a,t as o}from"./axios-DaWTGg7G.js";import{bw as s,vw as c,yw as l}from"./loadAgentsDir-DlPbtIsS.js";import{$ as u,I as d,M as f,N as p,R as m,V as h,c as g,et as ee,f as te,i as _,u as ne,x as re}from"./debug-Bglx1aTu.js";import{Wt as ie,qt as ae}from"./settings-B2jvL8Dp.js";import{_ as oe,b as se,p as ce,s as le,x as v,y as ue}from"./config-C-Y2qtB2.js";import{i as y,n as b}from"./execFileNoThrow-BTachNBI.js";import{o as x,s as S}from"./log-D2TIwHBV.js";import{n as de,r as C}from"./analytics-DJobLaWP.js";import{h as fe,m as pe}from"./firstPartyEventLogger-M6UMli2c.js";import{C as me,E as he,S as ge,T as _e,_ as ve,a as w,b as ye,c as be,d as xe,f as Se,g as Ce,i as we,l as Te,m as Ee,n as De,o as T,p as Oe,s as ke,t as Ae,u as je,v as Me,w as Ne,x as E,y as Pe}from"./pidLock-BTqO-h7Y.js";import{homedir as D}from"os";import{basename as Fe,delimiter as Ie,dirname as O,join as k,resolve as A}from"path";import{constants as Le}from"fs";import{createHash as Re}from"crypto";import{access as j,chmod as M,copyFile as N,mkdir as P,readdir as F,readlink as I,rename as L,rm as R,rmdir as ze,stat as z,symlink as Be,unlink as B,writeFile as Ve}from"fs/promises";async function He(e=`latest`,t,n){let r=Date.now();try{let i=await a.get(`${t}/${e}`,{timeout:3e4,responseType:`text`,...n});return C(`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),C(`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 S(c),c}}async function Ue(e){if(/^v?\d+\.\d+\.\d+(-\S+)?$/.test(e)){let t=e.startsWith(`v`)?e.slice(1):e;if(/^99\.99\./.test(t))throw Error(`Version ${t} is not available for installation. Use 'stable' or 'latest'.`);return t}let t=e;if(t!==`stable`&&t!==`latest`)throw Error(`Invalid channel: ${e}. Use 'stable' or 'latest'`);return He(t,V)}function We(){return Number(process.env.CLAUDE_CODE_STALL_TIMEOUT_MS_FOR_TESTING)||H}async function Ge(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(),We(),s)};try{u();let i=await a.get(e,{timeout:5*6e4,responseType:`arraybuffer`,signal:s.signal,onDownloadProgress:()=>{u()},...r});l();let o=Re(`sha256`);o.update(i.data);let c=o.digest(`hex`);if(c!==t)throw Error(`Checksum mismatch: expected ${t}, got ${c}`);await Ve(n,Buffer.from(i.data)),await M(n,493);return}catch(e){l();let t=a.isCancel(e);if(i=t?new U:h(e),t&&o<3){g(`Download stalled on attempt ${o}/3, retrying...`),await fe(1e3);continue}throw i}}throw i??Error(`Download failed after all retries`)}async function Ke(e,t,n,r){let i=ne();await i.rm(t,{recursive:!0,force:!0});let o=W(),s=Date.now();C(`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),C(`tengu_binary_manifest_fetch_failure`,{latency_ms:r,http_status:o,is_timeout:i.includes(`timeout`)}),S(Error(`Failed to fetch manifest from ${n}/${e}/manifest.json: ${i}`)),t}let l=c.platforms[o];if(!l)throw C(`tengu_binary_platform_not_found`,{}),Error(`Platform ${o} not found in manifest for version ${e}`);let u=l.checksum,d=G(o),f=`${n}/${e}/${o}/${d}`;await i.mkdir(t);let p=k(t,d);try{await Ge(f,u,p,r||{}),C(`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),C(`tengu_binary_download_failure`,{latency_ms:t,http_status:r,is_timeout:n.includes(`timeout`),is_checksum_mismatch:n.includes(`Checksum mismatch`)}),S(Error(`Failed to download binary from ${f}: ${n}`)),e}}async function qe(e,t){return await Ke(e,t,V),`binary`}var V,H,U,Je=e((()=>{o(),de(),_(),d(),y(),te(),x(),pe(),re(),$(),V=`https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases`,H=6e4,U=class extends Error{constructor(){super(`Download stalled: no data received for 60 seconds`),this.name=`StallTimeoutError`}}}));function W(){let e=ie.platform,t=process.arch===`x64`?`x64`:process.arch===`arm64`?`arm64`:null;if(!t){let e=Error(`Unsupported architecture: ${process.arch}`);throw g(`Native installer does not support architecture: ${process.arch}`,{level:`error`}),e}return e===`linux`&&i.isMuslEnvironment()?`linux-${t}-musl`:`${e}-${t}`}function G(e){return e.startsWith(`win32`)?`claude.exe`:`claude`}function K(){let e=G(W());return{versions:k(xe(),`claude`,`versions`),staging:k(je(),`claude`,`staging`),locks:k(Se(),`claude`,`locks`),executable:k(Te(),e)}}async function q(e){try{let t=await z(e);return!t.isFile()||t.size===0?!1:(await j(e,Le.X_OK),!0)}catch{return!1}}async function J(e){let t=K(),n=[t.versions,t.staging,t.locks];await Promise.all(n.map(e=>P(e,{recursive:!0}))),await P(O(t.executable),{recursive:!0});let r=k(t.versions,e);try{await z(r)}catch{await Ve(r,``,{encoding:`utf8`})}return{stagingPath:k(t.staging,e),installPath:r}}async function Ye(e,t,n=0){let r=K(),i=Y(r,e);if(await P(r.locks,{recursive:!0}),T()){let r=0,a=n+1,o=n>0?1e3:100,s=n>0?5e3:500;for(;r<a;){if(await be(e,i,async()=>{try{await t()}catch(e){throw S(e),e}}))return C(`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 C(`tengu_version_lock_failed`,{is_pid_based:!0,is_lifetime_lock:!1,attempts:a}),X(e,Error(`Lock held by another process`)),!1}let a=null;try{try{a=await v(e,{stale:Z,retries:{retries:n,minTimeout:n>0?1e3:100,maxTimeout:n>0?5e3:500},lockfilePath:i,onCompromised:e=>{g(`NON-FATAL: Version lock was compromised during operation: ${e.message}`,{level:`info`})}})}catch(t){return C(`tengu_version_lock_failed`,{is_pid_based:!1,is_lifetime_lock:!1}),X(e,t),!1}try{return await t(),C(`tengu_version_lock_acquired`,{is_pid_based:!1,is_lifetime_lock:!1}),!0}catch(e){throw S(e),e}}finally{a&&await a()}}async function Xe(e,t){await P(O(t),{recursive:!0});let n=`${t}.tmp.${process.pid}.${Date.now()}`;try{await N(e,n),await M(n,493),await L(n,t),g(`Atomically installed binary to ${t}`)}catch(e){try{await B(n)}catch{}throw e}}async function Ze(e,t){try{let n=k(e,`node_modules`,`@anthropic-ai`),r=(await F(n)).find(e=>e.startsWith(`claude-cli-native-`));if(!r)throw C(`tengu_native_install_package_failure`,{stage_find_package:!0,error_package_not_found:!0}),Error(`Could not find platform-specific native package`);let i=k(n,r,`cli`);try{await z(i)}catch{throw C(`tengu_native_install_package_failure`,{stage_binary_exists:!0,error_binary_not_found:!0}),Error(`Native binary not found in staged package`)}await Xe(i,t),await R(e,{recursive:!0,force:!0}),C(`tengu_native_install_package_success`,{})}catch(e){let t=f(e);throw!t.includes(`Could not find platform-specific`)&&!t.includes(`Native binary not found`)&&C(`tengu_native_install_package_failure`,{stage_atomic_move:!0,error_move_failed:!0}),S(h(e)),e}}async function Qe(e,t){try{let n=k(e,G(W()));try{await z(n)}catch{throw C(`tengu_native_install_binary_failure`,{stage_binary_exists:!0,error_binary_not_found:!0}),Error(`Staged binary not found`)}await Xe(n,t),await R(e,{recursive:!0,force:!0}),C(`tengu_native_install_binary_success`,{})}catch(e){throw f(e).includes(`Staged binary not found`)||C(`tengu_native_install_binary_failure`,{stage_atomic_move:!0,error_move_failed:!0}),S(h(e)),e}}async function $e(e,t,n){n===`npm`?await Ze(e,t):await Qe(e,t)}async function et(e,n){let{stagingPath:r,installPath:i}=await J(e),{executable:a}=K(),o=t(process.env.ENABLE_LOCKLESS_UPDATES)?`${r}.${process.pid}.${Date.now()}`:r,s=!await tt(e)||n;if(s?(g(n?`Force reinstalling native installer version ${e}`:`Downloading native installer version ${e}`),await $e(o,i,await qe(e,o))):g(`Version ${e} already installed, updating symlink`),await rt(a),await it(a,i),!await q(a)){let e=!1;try{await z(i),e=!0}catch{}throw Error(`Failed to create executable at ${a}. Source file exists: ${e}. Check write permissions to ${a}.`)}return s}async function tt(e){let{installPath:t}=await J(e);return q(t)}async function nt(e,n=!1){let r=Date.now(),i=await Ue(e),{executable:a}=K();if(g(`Checking for native installer update to version ${i}`),!n){let e=await ve();if(e&&c(i,e)){if(g(`Native installer: maxVersion ${e} is set, capping update from ${i} to ${e}`),l(`0.0.23`,e))return g(`Native installer: current version 0.0.23 is already at or above maxVersion ${e}, skipping update`),C(`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.23`&&await tt(i)&&await q(a))return g(`Found ${i} at ${a}, skipping install`),C(`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&&Pe(i))return C(`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 et(i,n),s=Date.now()-r;else{let{installPath:e}=await J(i);n&&await ut(e);let t=await Ye(e,async()=>{o=await et(i,n)},3);if(s=Date.now()-r,!t){let t=K(),n;if(T()){let r=Y(t,e);w(r)&&(n=ke(r)?.pid)}return C(`tengu_native_update_lock_failed`,{latency_ms:s,lock_holder_pid:n}),{success:!1,latestVersion:i,lockFailed:!0,lockHolderPid:n}}}return C(`tengu_native_update_complete`,{latency_ms:s,was_new_install:o,was_force_reinstall:n}),g(`Successfully updated to version ${i}`),{success:!0,latestVersion:i}}async function rt(e){try{await ze(e),g(`Removed empty directory at ${e}`)}catch(t){let n=p(t);n!==`ENOTDIR`&&n!==`ENOENT`&&n!==`ENOTEMPTY`&&g(`Could not remove directory at ${e}: ${t}`)}}async function it(e,t){if(W().startsWith(`win32`))try{await P(O(e),{recursive:!0});let n;try{n=await z(e)}catch{}if(n){try{let e=await z(t);if(n.size===e.size)return!1}catch{}let r=`${e}.old.${Date.now()}`;await L(e,r);try{await N(t,e);try{await B(r)}catch{}}catch(t){try{await L(r,e)}catch(e){let n=Error(`Failed to restore old executable: ${e}`,{cause:t});throw S(n),n}throw t}}else try{await N(t,e)}catch(e){throw m(e)?Error(`Source file does not exist: ${t}`):e}return!0}catch(n){return S(Error(`Failed to copy executable from ${t} to ${e}: ${n}`)),!1}let n=O(e);try{await P(n,{recursive:!0}),g(`Created directory ${n} for symlink`)}catch(e){return S(Error(`Failed to create directory ${n}: ${e}`)),!1}try{let n=!1;try{await z(e),n=!0}catch{}if(n){try{let n=await I(e);if(A(O(e),n)===A(t))return!1}catch{}await B(e)}}catch(e){S(Error(`Failed to check/remove existing symlink: ${e}`))}let r=`${e}.tmp.${process.pid}.${Date.now()}`;try{return await Be(t,r),await L(r,e),g(`Atomically updated symlink ${e} -> ${t}`),!0}catch(n){try{await B(r)}catch{}return S(Error(`Failed to create symlink from ${e} to ${t}: ${n}`)),!1}}async function at(e=!1){if(t(process.env.DISABLE_INSTALLATION_CHECKS))return[];let n=await Ee();if(n===`development`||!(e||n===`native`))return[];let r=K(),i=[],a=O(r.executable),o=A(a),s=W().startsWith(`win32`);try{await j(a)}catch{i.push({message:`installMethod is native, but directory ${a} does not exist`,userActionRequired:!0,type:`error`})}if(s)await q(r.executable)||i.push({message:`installMethod is native, but claude command is missing or invalid at ${r.executable}`,userActionRequired:!0,type:`error`});else try{let e=await I(r.executable);await q(A(O(r.executable),e))||i.push({message:`Work Mate symlink points to missing or invalid binary: ${e}`,userActionRequired:!0,type:`error`})}catch(e){m(e)?i.push({message:`installMethod is native, but claude command not found at ${r.executable}`,userActionRequired:!0,type:`error`}):await q(r.executable)||i.push({message:`${r.executable} exists but is not a valid Work Mate binary`,userActionRequired:!0,type:`error`})}if(!(process.env.PATH||``).split(Ie).some(e=>{try{let t=A(e);return s?t.toLowerCase()===o.toLowerCase():t===o}catch{return!1}}))if(s){let e=a.replace(/\//g,`\\`);i.push({message:`Native installation exists but ${e} is not in your PATH. Add it by opening: System Properties → Environment Variables → Edit User PATH → New → Add the path above. Then restart your terminal.`,userActionRequired:!0,type:`path`})}else{let e=_e(),t=E()[e],n=t?t.replace(D(),`~`):`your shell config file`;i.push({message:`Native installation exists but ~/.local/bin is not in your PATH. Run:\n\necho 'export PATH="$HOME/.local/bin:$PATH"' >> ${n} && source ${n}`,userActionRequired:!0,type:`path`})}return i}function ot(e,t=!1){if(t)return st(e,t);if(Q)return g(`installLatest: joining in-flight call`),Q;let n=st(e,t);Q=n;let r=()=>{Q=null};return n.then(r,r),n}async function st(e,t=!1){let n=await nt(e,t);return n.success?(le().installMethod!==`native`&&(oe(e=>({...e,installMethod:`native`,autoUpdates:!1,autoUpdatesProtectedForNative:!0})),g(`Native installer: Set installMethod to "native" and disabled legacy auto-updater for protection`)),dt(),{latestVersion:n.latestVersion,wasUpdated:n.success,lockFailed:!1}):{latestVersion:null,wasUpdated:!1,lockFailed:n.lockFailed,lockHolderPid:n.lockHolderPid}}async function ct(e){try{let t=await I(e),n=A(O(e),t);if(await q(n))return n}catch{}return null}function Y(e,t){let n=Fe(t);return k(e.locks,`${n}.lock`)}async function lt(){let e=K();if(!process.execPath.includes(e.versions))return;let t=A(process.execPath);try{let n=Y(e,t);if(await P(e.locks,{recursive:!0}),T()){if(!await Ae(t,n)){C(`tengu_version_lock_failed`,{is_pid_based:!0,is_lifetime_lock:!0}),X(t,Error(`Lock already held by another process`));return}C(`tengu_version_lock_acquired`,{is_pid_based:!0,is_lifetime_lock:!0}),g(`Acquired PID lock on running version: ${t}`)}else{let e;try{e=await v(t,{stale:Z,retries:0,lockfilePath:n,onCompromised:e=>{g(`NON-FATAL: Lock on running version was compromised: ${e.message}`,{level:`info`})}}),C(`tengu_version_lock_acquired`,{is_pid_based:!1,is_lifetime_lock:!0}),g(`Acquired mtime-based lock on running version: ${t}`),ee(async()=>{try{await e?.()}catch{}})}catch(e){if(m(e)){g(`Cannot lock current version - file does not exist: ${t}`,{level:`info`});return}C(`tengu_version_lock_failed`,{is_pid_based:!1,is_lifetime_lock:!0}),X(t,e);return}}}catch(e){if(m(e)){g(`Cannot lock current version - file does not exist: ${t}`,{level:`info`});return}g(`NON-FATAL: Failed to lock current version during execution ${f(e)}`,{level:`info`})}}function X(e,t){S(Error(`NON-FATAL: Lock acquisition failed for ${e} (expected in multi-process scenarios)`,{cause:t}))}async function ut(e){let t=Y(K(),e);try{await B(t),g(`Force-removed lock file at ${t}`)}catch(e){g(`Failed to force-remove lock file: ${f(e)}`)}}async function dt(){await Promise.resolve();let e=K(),t=Date.now()-36e5;if(W().startsWith(`win32`)){let t=O(e.executable);try{let e=await F(t),n=0;for(let r of e)if(/^claude\.exe\.old\.\d+$/.test(r))try{await B(k(t,r)),n++}catch{}n>0&&g(`Cleaned up ${n} old Windows executables on startup`)}catch(e){m(e)||g(`Failed to clean up old Windows executables: ${e}`)}}try{let n=await F(e.staging),r=0;for(let i of n){let n=k(e.staging,i);try{(await z(n)).mtime.getTime()<t&&(await R(n,{recursive:!0,force:!0}),r++,g(`Cleaned up old staging directory: ${i}`))}catch{}}r>0&&(g(`Cleaned up ${r} orphaned staging directories`),C(`tengu_native_staging_cleanup`,{cleaned_count:r}))}catch(e){m(e)||g(`Failed to clean up staging directories: ${e}`)}if(T()){let t=De(e.locks);t>0&&(g(`Cleaned up ${t} stale version locks`),C(`tengu_native_stale_locks_cleanup`,{cleaned_count:t}))}let n;try{n=await F(e.versions)}catch(e){m(e)||g(`Failed to readdir versions directory: ${e}`);return}let r=[],i=0;for(let a of n){let n=k(e.versions,a);if(/\.tmp\.\d+\.\d+$/.test(a)){try{(await z(n)).mtime.getTime()<t&&(await B(n),i++,g(`Cleaned up orphaned temp install file: ${a}`))}catch{}continue}try{let e=await z(n);if(!e.isFile()||process.platform!==`win32`&&e.size>0&&!(e.mode&73))continue;r.push({name:a,path:n,resolvedPath:A(n),mtime:e.mtime})}catch{}}if(i>0&&(g(`Cleaned up ${i} orphaned temp install files`),C(`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(A(t));let i=await ct(e.executable);i&&n.add(i);for(let t of r){if(n.has(t.resolvedPath))continue;let r=Y(e,t.resolvedPath),i=!1;if(T())i=w(r);else try{i=await ue(t.resolvedPath,{stale:Z,lockfilePath:r})}catch{i=!1}i&&(n.add(t.resolvedPath),g(`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){C(`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 Ye(e.path,async()=>{await B(e.path)})?o++:(s++,g(`Skipping deletion of ${e.name} - locked by another process`))}catch(t){c++,S(Error(`Failed to delete version ${e.name}: ${t}`))}})),C(`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){m(e)||S(Error(`Version cleanup failed: ${e}`))}}async function ft(){let e=[],t=E();for(let[n,r]of Object.entries(t))try{let t=await me(r);if(!t)continue;let{filtered:i,hadAlias:a}=ye(t);a&&(await Ne(r,i),e.push({message:`Removed claude alias from ${r}. Run: unalias claude`,userActionRequired:!0,type:`alias`}),g(`Cleaned up claude alias from ${n} config`))}catch(t){S(t),e.push({message:`Failed to clean up ${r}: ${t}`,userActionRequired:!1,type:`error`})}return e}async function pt(e){try{let t=await b(`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 B(e),g(`Manually removed ${t}: ${e}`),!0}catch{return!1}}if(W().startsWith(`win32`)){let e=k(n,`claude.cmd`),t=k(n,`claude.ps1`),a=k(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(k(n,`bin`,`claude`),`bin symlink`)&&(r=!0);return r?(g(`Successfully removed ${e} manually`),{success:!0,warning:`${e} executables removed, but node_modules directory was left intact for safety. You may manually delete it later at: ${W().startsWith(`win32`)?k(n,`node_modules`,e):k(n,`lib`,`node_modules`,e)}`}):{success:!1}}catch(e){return g(`Manual removal failed: ${e}`,{level:`error`}),{success:!1,error:`Manual removal failed: ${e}`}}}async function mt(e){let{code:t,stderr:n}=await b(`npm`,[`uninstall`,`-g`,e],{cwd:process.cwd()});if(t===0)return g(`Removed global npm installation of ${e}`),{success:!0};if(n&&!n.includes(`npm ERR! code E404`)){if(n.includes(`npm error code ENOTEMPTY`)){g(`Failed to uninstall global npm package ${e}: ${n}`,{level:`error`}),g(`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 g(`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=k(D(),`.workmate`,`local`);try{await R(i,{recursive:!0}),n++,g(`Removed local installation at ${i}`)}catch(t){m(t)||(e.push(`Failed to remove ${i}: ${t}`),g(`Failed to remove local installation: ${t}`,{level:`error`}))}return{removed:n,errors:e,warnings:t}}var Z,Q,$=e((()=>{de(),Me(),u(),ce(),_(),Ce(),ae(),r(),n(),d(),y(),he(),se(),x(),s(),ge(),pe(),Oe(),Je(),we(),Z=10080*60*1e3,Q=null})),gt=e((()=>{$()}));export{ft as a,lt as c,dt as i,at as n,$ as o,ht as r,ot as s,gt as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{l as t,o as n}from"./envUtils-DfkgIdYf.js";import{ft as r,ut as i}from"./esm-BXTZz3av.js";import{n as a,t as o}from"./axios-DaWTGg7G.js";import{bw as s,vw as c,yw as l}from"./loadAgentsDir-B0Anodo0.js";import{$ as u,I as d,M as f,N as p,R as m,V as h,c as g,et as ee,f as te,i as _,u as ne,x as re}from"./debug-Bglx1aTu.js";import{Wt as ie,qt as ae}from"./settings-B2jvL8Dp.js";import{_ as oe,b as se,p as ce,s as le,x as v,y as ue}from"./config-C-Y2qtB2.js";import{i as y,n as b}from"./execFileNoThrow-BTachNBI.js";import{o as x,s as S}from"./log-D2TIwHBV.js";import{n as de,r as C}from"./analytics-DJobLaWP.js";import{h as fe,m as pe}from"./firstPartyEventLogger-QmjjQmgt.js";import{C as me,E as he,S as ge,T as _e,_ as ve,a as w,b as ye,c as be,d as xe,f as Se,g as Ce,i as we,l as Te,m as Ee,n as De,o as T,p as Oe,s as ke,t as Ae,u as je,v as Me,w as Ne,x as E,y as Pe}from"./pidLock-Cm4sW35f.js";import{homedir as D}from"os";import{basename as Fe,delimiter as Ie,dirname as O,join as k,resolve as A}from"path";import{constants as Le}from"fs";import{createHash as Re}from"crypto";import{access as j,chmod as M,copyFile as N,mkdir as P,readdir as F,readlink as I,rename as L,rm as R,rmdir as ze,stat as z,symlink as Be,unlink as B,writeFile as Ve}from"fs/promises";async function He(e=`latest`,t,n){let r=Date.now();try{let i=await a.get(`${t}/${e}`,{timeout:3e4,responseType:`text`,...n});return C(`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),C(`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 S(c),c}}async function Ue(e){if(/^v?\d+\.\d+\.\d+(-\S+)?$/.test(e)){let t=e.startsWith(`v`)?e.slice(1):e;if(/^99\.99\./.test(t))throw Error(`Version ${t} is not available for installation. Use 'stable' or 'latest'.`);return t}let t=e;if(t!==`stable`&&t!==`latest`)throw Error(`Invalid channel: ${e}. Use 'stable' or 'latest'`);return He(t,V)}function We(){return Number(process.env.CLAUDE_CODE_STALL_TIMEOUT_MS_FOR_TESTING)||H}async function Ge(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(),We(),s)};try{u();let i=await a.get(e,{timeout:5*6e4,responseType:`arraybuffer`,signal:s.signal,onDownloadProgress:()=>{u()},...r});l();let o=Re(`sha256`);o.update(i.data);let c=o.digest(`hex`);if(c!==t)throw Error(`Checksum mismatch: expected ${t}, got ${c}`);await Ve(n,Buffer.from(i.data)),await M(n,493);return}catch(e){l();let t=a.isCancel(e);if(i=t?new U:h(e),t&&o<3){g(`Download stalled on attempt ${o}/3, retrying...`),await fe(1e3);continue}throw i}}throw i??Error(`Download failed after all retries`)}async function Ke(e,t,n,r){let i=ne();await i.rm(t,{recursive:!0,force:!0});let o=W(),s=Date.now();C(`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),C(`tengu_binary_manifest_fetch_failure`,{latency_ms:r,http_status:o,is_timeout:i.includes(`timeout`)}),S(Error(`Failed to fetch manifest from ${n}/${e}/manifest.json: ${i}`)),t}let l=c.platforms[o];if(!l)throw C(`tengu_binary_platform_not_found`,{}),Error(`Platform ${o} not found in manifest for version ${e}`);let u=l.checksum,d=G(o),f=`${n}/${e}/${o}/${d}`;await i.mkdir(t);let p=k(t,d);try{await Ge(f,u,p,r||{}),C(`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),C(`tengu_binary_download_failure`,{latency_ms:t,http_status:r,is_timeout:n.includes(`timeout`),is_checksum_mismatch:n.includes(`Checksum mismatch`)}),S(Error(`Failed to download binary from ${f}: ${n}`)),e}}async function qe(e,t){return await Ke(e,t,V),`binary`}var V,H,U,Je=e((()=>{o(),de(),_(),d(),y(),te(),x(),pe(),re(),$(),V=`https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases`,H=6e4,U=class extends Error{constructor(){super(`Download stalled: no data received for 60 seconds`),this.name=`StallTimeoutError`}}}));function W(){let e=ie.platform,t=process.arch===`x64`?`x64`:process.arch===`arm64`?`arm64`:null;if(!t){let e=Error(`Unsupported architecture: ${process.arch}`);throw g(`Native installer does not support architecture: ${process.arch}`,{level:`error`}),e}return e===`linux`&&i.isMuslEnvironment()?`linux-${t}-musl`:`${e}-${t}`}function G(e){return e.startsWith(`win32`)?`claude.exe`:`claude`}function K(){let e=G(W());return{versions:k(xe(),`claude`,`versions`),staging:k(je(),`claude`,`staging`),locks:k(Se(),`claude`,`locks`),executable:k(Te(),e)}}async function q(e){try{let t=await z(e);return!t.isFile()||t.size===0?!1:(await j(e,Le.X_OK),!0)}catch{return!1}}async function J(e){let t=K(),n=[t.versions,t.staging,t.locks];await Promise.all(n.map(e=>P(e,{recursive:!0}))),await P(O(t.executable),{recursive:!0});let r=k(t.versions,e);try{await z(r)}catch{await Ve(r,``,{encoding:`utf8`})}return{stagingPath:k(t.staging,e),installPath:r}}async function Ye(e,t,n=0){let r=K(),i=Y(r,e);if(await P(r.locks,{recursive:!0}),T()){let r=0,a=n+1,o=n>0?1e3:100,s=n>0?5e3:500;for(;r<a;){if(await be(e,i,async()=>{try{await t()}catch(e){throw S(e),e}}))return C(`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 C(`tengu_version_lock_failed`,{is_pid_based:!0,is_lifetime_lock:!1,attempts:a}),X(e,Error(`Lock held by another process`)),!1}let a=null;try{try{a=await v(e,{stale:Z,retries:{retries:n,minTimeout:n>0?1e3:100,maxTimeout:n>0?5e3:500},lockfilePath:i,onCompromised:e=>{g(`NON-FATAL: Version lock was compromised during operation: ${e.message}`,{level:`info`})}})}catch(t){return C(`tengu_version_lock_failed`,{is_pid_based:!1,is_lifetime_lock:!1}),X(e,t),!1}try{return await t(),C(`tengu_version_lock_acquired`,{is_pid_based:!1,is_lifetime_lock:!1}),!0}catch(e){throw S(e),e}}finally{a&&await a()}}async function Xe(e,t){await P(O(t),{recursive:!0});let n=`${t}.tmp.${process.pid}.${Date.now()}`;try{await N(e,n),await M(n,493),await L(n,t),g(`Atomically installed binary to ${t}`)}catch(e){try{await B(n)}catch{}throw e}}async function Ze(e,t){try{let n=k(e,`node_modules`,`@anthropic-ai`),r=(await F(n)).find(e=>e.startsWith(`claude-cli-native-`));if(!r)throw C(`tengu_native_install_package_failure`,{stage_find_package:!0,error_package_not_found:!0}),Error(`Could not find platform-specific native package`);let i=k(n,r,`cli`);try{await z(i)}catch{throw C(`tengu_native_install_package_failure`,{stage_binary_exists:!0,error_binary_not_found:!0}),Error(`Native binary not found in staged package`)}await Xe(i,t),await R(e,{recursive:!0,force:!0}),C(`tengu_native_install_package_success`,{})}catch(e){let t=f(e);throw!t.includes(`Could not find platform-specific`)&&!t.includes(`Native binary not found`)&&C(`tengu_native_install_package_failure`,{stage_atomic_move:!0,error_move_failed:!0}),S(h(e)),e}}async function Qe(e,t){try{let n=k(e,G(W()));try{await z(n)}catch{throw C(`tengu_native_install_binary_failure`,{stage_binary_exists:!0,error_binary_not_found:!0}),Error(`Staged binary not found`)}await Xe(n,t),await R(e,{recursive:!0,force:!0}),C(`tengu_native_install_binary_success`,{})}catch(e){throw f(e).includes(`Staged binary not found`)||C(`tengu_native_install_binary_failure`,{stage_atomic_move:!0,error_move_failed:!0}),S(h(e)),e}}async function $e(e,t,n){n===`npm`?await Ze(e,t):await Qe(e,t)}async function et(e,n){let{stagingPath:r,installPath:i}=await J(e),{executable:a}=K(),o=t(process.env.ENABLE_LOCKLESS_UPDATES)?`${r}.${process.pid}.${Date.now()}`:r,s=!await tt(e)||n;if(s?(g(n?`Force reinstalling native installer version ${e}`:`Downloading native installer version ${e}`),await $e(o,i,await qe(e,o))):g(`Version ${e} already installed, updating symlink`),await rt(a),await it(a,i),!await q(a)){let e=!1;try{await z(i),e=!0}catch{}throw Error(`Failed to create executable at ${a}. Source file exists: ${e}. Check write permissions to ${a}.`)}return s}async function tt(e){let{installPath:t}=await J(e);return q(t)}async function nt(e,n=!1){let r=Date.now(),i=await Ue(e),{executable:a}=K();if(g(`Checking for native installer update to version ${i}`),!n){let e=await ve();if(e&&c(i,e)){if(g(`Native installer: maxVersion ${e} is set, capping update from ${i} to ${e}`),l(`0.0.24`,e))return g(`Native installer: current version 0.0.24 is already at or above maxVersion ${e}, skipping update`),C(`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.24`&&await tt(i)&&await q(a))return g(`Found ${i} at ${a}, skipping install`),C(`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&&Pe(i))return C(`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 et(i,n),s=Date.now()-r;else{let{installPath:e}=await J(i);n&&await ut(e);let t=await Ye(e,async()=>{o=await et(i,n)},3);if(s=Date.now()-r,!t){let t=K(),n;if(T()){let r=Y(t,e);w(r)&&(n=ke(r)?.pid)}return C(`tengu_native_update_lock_failed`,{latency_ms:s,lock_holder_pid:n}),{success:!1,latestVersion:i,lockFailed:!0,lockHolderPid:n}}}return C(`tengu_native_update_complete`,{latency_ms:s,was_new_install:o,was_force_reinstall:n}),g(`Successfully updated to version ${i}`),{success:!0,latestVersion:i}}async function rt(e){try{await ze(e),g(`Removed empty directory at ${e}`)}catch(t){let n=p(t);n!==`ENOTDIR`&&n!==`ENOENT`&&n!==`ENOTEMPTY`&&g(`Could not remove directory at ${e}: ${t}`)}}async function it(e,t){if(W().startsWith(`win32`))try{await P(O(e),{recursive:!0});let n;try{n=await z(e)}catch{}if(n){try{let e=await z(t);if(n.size===e.size)return!1}catch{}let r=`${e}.old.${Date.now()}`;await L(e,r);try{await N(t,e);try{await B(r)}catch{}}catch(t){try{await L(r,e)}catch(e){let n=Error(`Failed to restore old executable: ${e}`,{cause:t});throw S(n),n}throw t}}else try{await N(t,e)}catch(e){throw m(e)?Error(`Source file does not exist: ${t}`):e}return!0}catch(n){return S(Error(`Failed to copy executable from ${t} to ${e}: ${n}`)),!1}let n=O(e);try{await P(n,{recursive:!0}),g(`Created directory ${n} for symlink`)}catch(e){return S(Error(`Failed to create directory ${n}: ${e}`)),!1}try{let n=!1;try{await z(e),n=!0}catch{}if(n){try{let n=await I(e);if(A(O(e),n)===A(t))return!1}catch{}await B(e)}}catch(e){S(Error(`Failed to check/remove existing symlink: ${e}`))}let r=`${e}.tmp.${process.pid}.${Date.now()}`;try{return await Be(t,r),await L(r,e),g(`Atomically updated symlink ${e} -> ${t}`),!0}catch(n){try{await B(r)}catch{}return S(Error(`Failed to create symlink from ${e} to ${t}: ${n}`)),!1}}async function at(e=!1){if(t(process.env.DISABLE_INSTALLATION_CHECKS))return[];let n=await Ee();if(n===`development`||!(e||n===`native`))return[];let r=K(),i=[],a=O(r.executable),o=A(a),s=W().startsWith(`win32`);try{await j(a)}catch{i.push({message:`installMethod is native, but directory ${a} does not exist`,userActionRequired:!0,type:`error`})}if(s)await q(r.executable)||i.push({message:`installMethod is native, but claude command is missing or invalid at ${r.executable}`,userActionRequired:!0,type:`error`});else try{let e=await I(r.executable);await q(A(O(r.executable),e))||i.push({message:`Work Mate symlink points to missing or invalid binary: ${e}`,userActionRequired:!0,type:`error`})}catch(e){m(e)?i.push({message:`installMethod is native, but claude command not found at ${r.executable}`,userActionRequired:!0,type:`error`}):await q(r.executable)||i.push({message:`${r.executable} exists but is not a valid Work Mate binary`,userActionRequired:!0,type:`error`})}if(!(process.env.PATH||``).split(Ie).some(e=>{try{let t=A(e);return s?t.toLowerCase()===o.toLowerCase():t===o}catch{return!1}}))if(s){let e=a.replace(/\//g,`\\`);i.push({message:`Native installation exists but ${e} is not in your PATH. Add it by opening: System Properties → Environment Variables → Edit User PATH → New → Add the path above. Then restart your terminal.`,userActionRequired:!0,type:`path`})}else{let e=_e(),t=E()[e],n=t?t.replace(D(),`~`):`your shell config file`;i.push({message:`Native installation exists but ~/.local/bin is not in your PATH. Run:\n\necho 'export PATH="$HOME/.local/bin:$PATH"' >> ${n} && source ${n}`,userActionRequired:!0,type:`path`})}return i}function ot(e,t=!1){if(t)return st(e,t);if(Q)return g(`installLatest: joining in-flight call`),Q;let n=st(e,t);Q=n;let r=()=>{Q=null};return n.then(r,r),n}async function st(e,t=!1){let n=await nt(e,t);return n.success?(le().installMethod!==`native`&&(oe(e=>({...e,installMethod:`native`,autoUpdates:!1,autoUpdatesProtectedForNative:!0})),g(`Native installer: Set installMethod to "native" and disabled legacy auto-updater for protection`)),dt(),{latestVersion:n.latestVersion,wasUpdated:n.success,lockFailed:!1}):{latestVersion:null,wasUpdated:!1,lockFailed:n.lockFailed,lockHolderPid:n.lockHolderPid}}async function ct(e){try{let t=await I(e),n=A(O(e),t);if(await q(n))return n}catch{}return null}function Y(e,t){let n=Fe(t);return k(e.locks,`${n}.lock`)}async function lt(){let e=K();if(!process.execPath.includes(e.versions))return;let t=A(process.execPath);try{let n=Y(e,t);if(await P(e.locks,{recursive:!0}),T()){if(!await Ae(t,n)){C(`tengu_version_lock_failed`,{is_pid_based:!0,is_lifetime_lock:!0}),X(t,Error(`Lock already held by another process`));return}C(`tengu_version_lock_acquired`,{is_pid_based:!0,is_lifetime_lock:!0}),g(`Acquired PID lock on running version: ${t}`)}else{let e;try{e=await v(t,{stale:Z,retries:0,lockfilePath:n,onCompromised:e=>{g(`NON-FATAL: Lock on running version was compromised: ${e.message}`,{level:`info`})}}),C(`tengu_version_lock_acquired`,{is_pid_based:!1,is_lifetime_lock:!0}),g(`Acquired mtime-based lock on running version: ${t}`),ee(async()=>{try{await e?.()}catch{}})}catch(e){if(m(e)){g(`Cannot lock current version - file does not exist: ${t}`,{level:`info`});return}C(`tengu_version_lock_failed`,{is_pid_based:!1,is_lifetime_lock:!0}),X(t,e);return}}}catch(e){if(m(e)){g(`Cannot lock current version - file does not exist: ${t}`,{level:`info`});return}g(`NON-FATAL: Failed to lock current version during execution ${f(e)}`,{level:`info`})}}function X(e,t){S(Error(`NON-FATAL: Lock acquisition failed for ${e} (expected in multi-process scenarios)`,{cause:t}))}async function ut(e){let t=Y(K(),e);try{await B(t),g(`Force-removed lock file at ${t}`)}catch(e){g(`Failed to force-remove lock file: ${f(e)}`)}}async function dt(){await Promise.resolve();let e=K(),t=Date.now()-36e5;if(W().startsWith(`win32`)){let t=O(e.executable);try{let e=await F(t),n=0;for(let r of e)if(/^claude\.exe\.old\.\d+$/.test(r))try{await B(k(t,r)),n++}catch{}n>0&&g(`Cleaned up ${n} old Windows executables on startup`)}catch(e){m(e)||g(`Failed to clean up old Windows executables: ${e}`)}}try{let n=await F(e.staging),r=0;for(let i of n){let n=k(e.staging,i);try{(await z(n)).mtime.getTime()<t&&(await R(n,{recursive:!0,force:!0}),r++,g(`Cleaned up old staging directory: ${i}`))}catch{}}r>0&&(g(`Cleaned up ${r} orphaned staging directories`),C(`tengu_native_staging_cleanup`,{cleaned_count:r}))}catch(e){m(e)||g(`Failed to clean up staging directories: ${e}`)}if(T()){let t=De(e.locks);t>0&&(g(`Cleaned up ${t} stale version locks`),C(`tengu_native_stale_locks_cleanup`,{cleaned_count:t}))}let n;try{n=await F(e.versions)}catch(e){m(e)||g(`Failed to readdir versions directory: ${e}`);return}let r=[],i=0;for(let a of n){let n=k(e.versions,a);if(/\.tmp\.\d+\.\d+$/.test(a)){try{(await z(n)).mtime.getTime()<t&&(await B(n),i++,g(`Cleaned up orphaned temp install file: ${a}`))}catch{}continue}try{let e=await z(n);if(!e.isFile()||process.platform!==`win32`&&e.size>0&&!(e.mode&73))continue;r.push({name:a,path:n,resolvedPath:A(n),mtime:e.mtime})}catch{}}if(i>0&&(g(`Cleaned up ${i} orphaned temp install files`),C(`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(A(t));let i=await ct(e.executable);i&&n.add(i);for(let t of r){if(n.has(t.resolvedPath))continue;let r=Y(e,t.resolvedPath),i=!1;if(T())i=w(r);else try{i=await ue(t.resolvedPath,{stale:Z,lockfilePath:r})}catch{i=!1}i&&(n.add(t.resolvedPath),g(`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){C(`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 Ye(e.path,async()=>{await B(e.path)})?o++:(s++,g(`Skipping deletion of ${e.name} - locked by another process`))}catch(t){c++,S(Error(`Failed to delete version ${e.name}: ${t}`))}})),C(`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){m(e)||S(Error(`Version cleanup failed: ${e}`))}}async function ft(){let e=[],t=E();for(let[n,r]of Object.entries(t))try{let t=await me(r);if(!t)continue;let{filtered:i,hadAlias:a}=ye(t);a&&(await Ne(r,i),e.push({message:`Removed claude alias from ${r}. Run: unalias claude`,userActionRequired:!0,type:`alias`}),g(`Cleaned up claude alias from ${n} config`))}catch(t){S(t),e.push({message:`Failed to clean up ${r}: ${t}`,userActionRequired:!1,type:`error`})}return e}async function pt(e){try{let t=await b(`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 B(e),g(`Manually removed ${t}: ${e}`),!0}catch{return!1}}if(W().startsWith(`win32`)){let e=k(n,`claude.cmd`),t=k(n,`claude.ps1`),a=k(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(k(n,`bin`,`claude`),`bin symlink`)&&(r=!0);return r?(g(`Successfully removed ${e} manually`),{success:!0,warning:`${e} executables removed, but node_modules directory was left intact for safety. You may manually delete it later at: ${W().startsWith(`win32`)?k(n,`node_modules`,e):k(n,`lib`,`node_modules`,e)}`}):{success:!1}}catch(e){return g(`Manual removal failed: ${e}`,{level:`error`}),{success:!1,error:`Manual removal failed: ${e}`}}}async function mt(e){let{code:t,stderr:n}=await b(`npm`,[`uninstall`,`-g`,e],{cwd:process.cwd()});if(t===0)return g(`Removed global npm installation of ${e}`),{success:!0};if(n&&!n.includes(`npm ERR! code E404`)){if(n.includes(`npm error code ENOTEMPTY`)){g(`Failed to uninstall global npm package ${e}: ${n}`,{level:`error`}),g(`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 g(`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=k(D(),`.workmate`,`local`);try{await R(i,{recursive:!0}),n++,g(`Removed local installation at ${i}`)}catch(t){m(t)||(e.push(`Failed to remove ${i}: ${t}`),g(`Failed to remove local installation: ${t}`,{level:`error`}))}return{removed:n,errors:e,warnings:t}}var Z,Q,$=e((()=>{de(),Me(),u(),ce(),_(),Ce(),ae(),r(),n(),d(),y(),he(),se(),x(),s(),ge(),pe(),Oe(),Je(),we(),Z=10080*60*1e3,Q=null})),gt=e((()=>{$()}));export{ft as a,lt as c,dt as i,at as n,$ as o,ht as r,ot as s,gt as t};
@@ -1 +1 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{Ip as n,Rp as r,zp as i}from"./loadAgentsDir-DlPbtIsS.js";import{ai as a}from"./src-DL3w8VPk.js";function o(){let e=r(),t=i(),n=(0,c.useCallback)(()=>{t(e=>{let r=s(e.notifications.queue);return e.notifications.current!==null||!r?e:(u=setTimeout((e,t,n)=>{u=null,e(e=>e.notifications.current?.key===t?{...e,notifications:{queue:e.notifications.queue,current:null}}:e),n()},r.timeoutMs??l,t,r.key,n),{...e,notifications:{queue:e.notifications.queue.filter(e=>e!==r),current:r}})})},[t]),a=(0,c.useCallback)(e=>{if(e.priority===`immediate`){u&&(clearTimeout(u),u=null),u=setTimeout((e,t,n)=>{u=null,e(e=>e.notifications.current?.key===t.key?{...e,notifications:{queue:e.notifications.queue.filter(e=>!t.invalidates?.includes(e.key)),current:null}}:e),n()},e.timeoutMs??l,t,e,n),t(t=>({...t,notifications:{current:e,queue:[...t.notifications.current?[t.notifications.current]:[],...t.notifications.queue].filter(t=>t.priority!==`immediate`&&!e.invalidates?.includes(t.key))}}));return}t(r=>{if(e.fold){if(r.notifications.current?.key===e.key){let i=e.fold(r.notifications.current,e);return u&&(clearTimeout(u),u=null),u=setTimeout((e,t,n)=>{u=null,e(e=>e.notifications.current?.key===t?{...e,notifications:{queue:e.notifications.queue,current:null}}:e),n()},i.timeoutMs??l,t,i.key,n),{...r,notifications:{current:i,queue:r.notifications.queue}}}let i=r.notifications.queue.findIndex(t=>t.key===e.key);if(i!==-1){let t=e.fold(r.notifications.queue[i],e),n=[...r.notifications.queue];return n[i]=t,{...r,notifications:{current:r.notifications.current,queue:n}}}}if(!(!new Set(r.notifications.queue.map(e=>e.key)).has(e.key)&&r.notifications.current?.key!==e.key))return r;let i=r.notifications.current!==null&&e.invalidates?.includes(r.notifications.current.key);return i&&u&&(clearTimeout(u),u=null),{...r,notifications:{current:i?null:r.notifications.current,queue:[...r.notifications.queue.filter(t=>t.priority!==`immediate`&&!e.invalidates?.includes(t.key)),e]}}}),n()},[t,n]),o=(0,c.useCallback)(e=>{t(t=>{let n=t.notifications.current?.key===e,r=t.notifications.queue.some(t=>t.key===e);return!n&&!r?t:(n&&u&&(clearTimeout(u),u=null),{...t,notifications:{current:n?null:t.notifications.current,queue:t.notifications.queue.filter(t=>t.key!==e)}})}),n()},[t,n]);return(0,c.useEffect)(()=>{e.getState().notifications.queue.length>0&&n()},[]),{addNotification:a,removeNotification:o}}function s(e){if(e.length!==0)return e.reduce((e,t)=>d[t.priority]<d[e.priority]?t:e)}var c,l,u,d,f=e((()=>{c=t(a(),1),n(),l=8e3,u=null,d={immediate:0,high:1,medium:2,low:3}}));export{o as n,f as t};
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{Ip as n,Rp as r,zp as i}from"./loadAgentsDir-B0Anodo0.js";import{ai as a}from"./src-DL3w8VPk.js";function o(){let e=r(),t=i(),n=(0,c.useCallback)(()=>{t(e=>{let r=s(e.notifications.queue);return e.notifications.current!==null||!r?e:(u=setTimeout((e,t,n)=>{u=null,e(e=>e.notifications.current?.key===t?{...e,notifications:{queue:e.notifications.queue,current:null}}:e),n()},r.timeoutMs??l,t,r.key,n),{...e,notifications:{queue:e.notifications.queue.filter(e=>e!==r),current:r}})})},[t]),a=(0,c.useCallback)(e=>{if(e.priority===`immediate`){u&&(clearTimeout(u),u=null),u=setTimeout((e,t,n)=>{u=null,e(e=>e.notifications.current?.key===t.key?{...e,notifications:{queue:e.notifications.queue.filter(e=>!t.invalidates?.includes(e.key)),current:null}}:e),n()},e.timeoutMs??l,t,e,n),t(t=>({...t,notifications:{current:e,queue:[...t.notifications.current?[t.notifications.current]:[],...t.notifications.queue].filter(t=>t.priority!==`immediate`&&!e.invalidates?.includes(t.key))}}));return}t(r=>{if(e.fold){if(r.notifications.current?.key===e.key){let i=e.fold(r.notifications.current,e);return u&&(clearTimeout(u),u=null),u=setTimeout((e,t,n)=>{u=null,e(e=>e.notifications.current?.key===t?{...e,notifications:{queue:e.notifications.queue,current:null}}:e),n()},i.timeoutMs??l,t,i.key,n),{...r,notifications:{current:i,queue:r.notifications.queue}}}let i=r.notifications.queue.findIndex(t=>t.key===e.key);if(i!==-1){let t=e.fold(r.notifications.queue[i],e),n=[...r.notifications.queue];return n[i]=t,{...r,notifications:{current:r.notifications.current,queue:n}}}}if(!(!new Set(r.notifications.queue.map(e=>e.key)).has(e.key)&&r.notifications.current?.key!==e.key))return r;let i=r.notifications.current!==null&&e.invalidates?.includes(r.notifications.current.key);return i&&u&&(clearTimeout(u),u=null),{...r,notifications:{current:i?null:r.notifications.current,queue:[...r.notifications.queue.filter(t=>t.priority!==`immediate`&&!e.invalidates?.includes(t.key)),e]}}}),n()},[t,n]),o=(0,c.useCallback)(e=>{t(t=>{let n=t.notifications.current?.key===e,r=t.notifications.queue.some(t=>t.key===e);return!n&&!r?t:(n&&u&&(clearTimeout(u),u=null),{...t,notifications:{current:n?null:t.notifications.current,queue:t.notifications.queue.filter(t=>t.key!==e)}})}),n()},[t,n]);return(0,c.useEffect)(()=>{e.getState().notifications.queue.length>0&&n()},[]),{addNotification:a,removeNotification:o}}function s(e){if(e.length!==0)return e.reduce((e,t)=>d[t.priority]<d[e.priority]?t:e)}var c,l,u,d,f=e((()=>{c=t(a(),1),n(),l=8e3,u=null,d={immediate:0,high:1,medium:2,low:3}}));export{o as n,f as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Nl as t,Pl as n,jl as r}from"./loadAgentsDir-DlPbtIsS.js";import{ai as i}from"./src-DL3w8VPk.js";import{t as a}from"./jsx-runtime-Bb4Xn-E0.js";import{It as o,bn as s}from"./state-B4jiUise.js";import{I as c,V as l}from"./debug-Bglx1aTu.js";import{Rt as u,jt as d}from"./settings-B2jvL8Dp.js";import{_ as f,g as p,p as m,s as h}from"./config-C-Y2qtB2.js";import{o as g,s as _}from"./log-D2TIwHBV.js";import{r as v,t as y}from"./managedEnv-OPlzUPbJ.js";var b=e(i(),1);m();var x=a();function S(e,t){let n=t/100*(e.length-1),r=Math.floor(n),i=Math.ceil(n);return r===i?e[r]:e[r]+(e[i]-e[r])*(n-r)}var C=1024;function w(){let e=new Map,t=new Map,n=new Map;return{increment(t,n=1){e.set(t,(e.get(t)??0)+n)},set(t,n){e.set(t,n)},observe(e,n){let r=t.get(e);if(r||(r={reservoir:[],count:0,sum:0,min:n,max:n},t.set(e,r)),r.count++,r.sum+=n,n<r.min&&(r.min=n),n>r.max&&(r.max=n),r.reservoir.length<C)r.reservoir.push(n);else{let e=Math.floor(Math.random()*r.count);e<C&&(r.reservoir[e]=n)}},add(e,t){let r=n.get(e);r||(r=new Set,n.set(e,r)),r.add(t)},getAll(){let r=Object.fromEntries(e);for(let[e,n]of t){if(n.count===0)continue;r[`${e}_count`]=n.count,r[`${e}_min`]=n.min,r[`${e}_max`]=n.max,r[`${e}_avg`]=n.sum/n.count;let t=[...n.reservoir].sort((e,t)=>e-t);r[`${e}_p50`]=S(t,50),r[`${e}_p95`]=S(t,95),r[`${e}_p99`]=S(t,99)}for(let[e,t]of n)r[e]=t.size;return r}}}var T=(0,b.createContext)(null);function E({store:e,children:t}){let n=(0,b.useMemo)(()=>w(),[]),r=e??n;return(0,b.useEffect)(()=>{let e=()=>{let e=r.getAll();Object.keys(e).length>0&&p(t=>({...t,lastSessionMetrics:e}))};return process.on(`exit`,e),()=>{process.off(`exit`,e)}},[r]),(0,x.jsx)(T.Provider,{value:r,children:t})}o(),m(),c(),g(),v(),d(),r();function D({newState:e,oldState:r}){let i=r.toolPermissionContext.mode,a=e.toolPermissionContext.mode;if(i!==a){let e=u(i),r=u(a);e!==r&&n({permission_mode:r}),t(a)}if(e.mainLoopModel!==r.mainLoopModel&&s(e.mainLoopModel),e.expandedView!==r.expandedView){let t=e.expandedView===`tasks`;h().showExpandedTodos!==t&&f(e=>({...e,showExpandedTodos:t}))}if(e.verbose!==r.verbose&&h().verbose!==e.verbose){let t=e.verbose;f(e=>({...e,verbose:t}))}if(e.settings!==r.settings)try{e.settings.env!==r.settings.env&&y()}catch(e){_(l(e))}}export{E as n,w as r,D as t};
1
+ import{o as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Nl as t,Pl as n,jl as r}from"./loadAgentsDir-B0Anodo0.js";import{ai as i}from"./src-DL3w8VPk.js";import{t as a}from"./jsx-runtime-Bb4Xn-E0.js";import{It as o,bn as s}from"./state-B4jiUise.js";import{I as c,V as l}from"./debug-Bglx1aTu.js";import{Rt as u,jt as d}from"./settings-B2jvL8Dp.js";import{_ as f,g as p,p as m,s as h}from"./config-C-Y2qtB2.js";import{o as g,s as _}from"./log-D2TIwHBV.js";import{r as v,t as y}from"./managedEnv-OPlzUPbJ.js";var b=e(i(),1);m();var x=a();function S(e,t){let n=t/100*(e.length-1),r=Math.floor(n),i=Math.ceil(n);return r===i?e[r]:e[r]+(e[i]-e[r])*(n-r)}var C=1024;function w(){let e=new Map,t=new Map,n=new Map;return{increment(t,n=1){e.set(t,(e.get(t)??0)+n)},set(t,n){e.set(t,n)},observe(e,n){let r=t.get(e);if(r||(r={reservoir:[],count:0,sum:0,min:n,max:n},t.set(e,r)),r.count++,r.sum+=n,n<r.min&&(r.min=n),n>r.max&&(r.max=n),r.reservoir.length<C)r.reservoir.push(n);else{let e=Math.floor(Math.random()*r.count);e<C&&(r.reservoir[e]=n)}},add(e,t){let r=n.get(e);r||(r=new Set,n.set(e,r)),r.add(t)},getAll(){let r=Object.fromEntries(e);for(let[e,n]of t){if(n.count===0)continue;r[`${e}_count`]=n.count,r[`${e}_min`]=n.min,r[`${e}_max`]=n.max,r[`${e}_avg`]=n.sum/n.count;let t=[...n.reservoir].sort((e,t)=>e-t);r[`${e}_p50`]=S(t,50),r[`${e}_p95`]=S(t,95),r[`${e}_p99`]=S(t,99)}for(let[e,t]of n)r[e]=t.size;return r}}}var T=(0,b.createContext)(null);function E({store:e,children:t}){let n=(0,b.useMemo)(()=>w(),[]),r=e??n;return(0,b.useEffect)(()=>{let e=()=>{let e=r.getAll();Object.keys(e).length>0&&p(t=>({...t,lastSessionMetrics:e}))};return process.on(`exit`,e),()=>{process.off(`exit`,e)}},[r]),(0,x.jsx)(T.Provider,{value:r,children:t})}o(),m(),c(),g(),v(),d(),r();function D({newState:e,oldState:r}){let i=r.toolPermissionContext.mode,a=e.toolPermissionContext.mode;if(i!==a){let e=u(i),r=u(a);e!==r&&n({permission_mode:r}),t(a)}if(e.mainLoopModel!==r.mainLoopModel&&s(e.mainLoopModel),e.expandedView!==r.expandedView){let t=e.expandedView===`tasks`;h().showExpandedTodos!==t&&f(e=>({...e,showExpandedTodos:t}))}if(e.verbose!==r.verbose&&h().verbose!==e.verbose){let t=e.verbose;f(e=>({...e,verbose:t}))}if(e.settings!==r.settings)try{e.settings.env!==r.settings.env&&y()}catch(e){_(l(e))}}export{E as n,w as r,D as t};
@@ -1,2 +1,2 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{c as t,l as n,o as r}from"./envUtils-DfkgIdYf.js";import{BS as i,FS as a,LS as o,PS as s,RS as c,Yi as l,_h as u,da as d,et as f,iC as p,iS as m,la as h,n_ as g,o_ as _,pS as v,rt as y,vh as b,yh as x}from"./loadAgentsDir-DlPbtIsS.js";import{c as S,i as C}from"./debug-Bglx1aTu.js";import{M as w,_t as T,bt as E,k as D}from"./model-BwBG0V1u.js";import{_n as O,bn as k,i as A,r as j,t as M,vn as N}from"./prompt-mM79EGnT.js";import{n as P,r as F}from"./client-4iqhC8xq.js";import{n as I,t as L}from"./openaiShared-G2-w4gJt.js";import{randomUUID as R}from"crypto";function z(e){if(t(process.env.OPENAI_ENABLE_THINKING))return!1;if(n(process.env.OPENAI_ENABLE_THINKING))return!0;let r=e.toLowerCase();return r.includes(`deepseek`)||r.includes(`mimo`)}function B(e,t){return t??(process.env.OPENAI_MAX_TOKENS&&parseInt(process.env.OPENAI_MAX_TOKENS,10)||void 0)??(process.env.CLAUDE_CODE_MAX_OUTPUT_TOKENS&&parseInt(process.env.CLAUDE_CODE_MAX_OUTPUT_TOKENS,10)||void 0)??e}function V(e){let{model:t,messages:n,tools:r,toolChoice:i,enableThinking:a,maxTokens:o,temperatureOverride:s}=e;return{model:t,messages:n,max_tokens:o,...r.length>0&&{tools:r,...i&&{tool_choice:i}},stream:!0,stream_options:{include_usage:!0},...a&&{thinking:{type:`enabled`},enable_thinking:!0,chat_template_kwargs:{thinking:!0,enable_thinking:!0}},...!a&&s!==void 0&&{temperature:s}}}var H=e((()=>{r()}));function U(e,t,n,r){if(!r||b())return e;let i=t.filter(e=>n.has(e.name)).map(M).sort().join(`
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{c as t,l as n,o as r}from"./envUtils-DfkgIdYf.js";import{BS as i,FS as a,LS as o,PS as s,RS as c,Yi as l,_h as u,da as d,et as f,iC as p,iS as m,la as h,n_ as g,o_ as _,pS as v,rt as y,vh as b,yh as x}from"./loadAgentsDir-B0Anodo0.js";import{c as S,i as C}from"./debug-Bglx1aTu.js";import{M as w,_t as T,bt as E,k as D}from"./model-BvQFFOf8.js";import{_n as O,bn as k,i as A,r as j,t as M,vn as N}from"./prompt-CJ1l3XXk.js";import{n as P,r as F}from"./client-4iqhC8xq.js";import{n as I,t as L}from"./openaiShared-G2-w4gJt.js";import{randomUUID as R}from"crypto";function z(e){if(t(process.env.OPENAI_ENABLE_THINKING))return!1;if(n(process.env.OPENAI_ENABLE_THINKING))return!0;let r=e.toLowerCase();return r.includes(`deepseek`)||r.includes(`mimo`)}function B(e,t){return t??(process.env.OPENAI_MAX_TOKENS&&parseInt(process.env.OPENAI_MAX_TOKENS,10)||void 0)??(process.env.CLAUDE_CODE_MAX_OUTPUT_TOKENS&&parseInt(process.env.CLAUDE_CODE_MAX_OUTPUT_TOKENS,10)||void 0)??e}function V(e){let{model:t,messages:n,tools:r,toolChoice:i,enableThinking:a,maxTokens:o,temperatureOverride:s}=e;return{model:t,messages:n,max_tokens:o,...r.length>0&&{tools:r,...i&&{tool_choice:i}},stream:!0,stream_options:{include_usage:!0},...a&&{thinking:{type:`enabled`},enable_thinking:!0,chat_template_kwargs:{thinking:!0,enable_thinking:!0}},...!a&&s!==void 0&&{temperature:s}}}var H=e((()=>{r()}));function U(e,t,n,r){if(!r||b())return e;let i=t.filter(e=>n.has(e.name)).map(M).sort().join(`
2
2
  `);return i?[v({content:`<available-deferred-tools>\n${i}\n</available-deferred-tools>`,isMeta:!0}),...e]:e}function W(e){return e.type===`assistant`||e.type===`user`}function G(e){let{partialMessage:t,contentBlocks:n,tools:r,agentId:i,usage:a,stopReason:o,maxTokens:s}=e,c=[],l=Object.keys(n).sort((e,t)=>Number(e)-Number(t)).map(e=>n[Number(e)]).filter(Boolean);return l.length>0&&t&&c.push({message:{...t,content:h(l,r,i),usage:a,stop_reason:o,stop_sequence:null},requestId:void 0,type:`assistant`,uuid:R(),timestamp:new Date().toISOString()}),o===`max_tokens`&&c.push(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*K(e,t,n,r,s){try{let l=p(s.model),u=d(e,n),f=await x(s.model,n,s.getToolPermissionContext||(async()=>O()),s.agents||[],s.querySource),m=new Set;if(f)for(let e of n)A(e)&&m.add(e.name);let h=n;f&&m.size>0&&(h=n.filter(e=>!!(!m.has(e.name)||k(e,`SearchExtraTools`))));let _=(await Promise.all(h.map(e=>y(e,{getToolPermissionContext:s.getToolPermissionContext,tools:n,agents:s.agents,allowedAgentTypes:s.allowedAgentTypes,model:s.model,deferLoading:f&&m.has(e.name)})))).filter(e=>{let t=e;return t.type!==`advisor_20260301`&&t.type!==`computer_20250124`}),v=z(l),b=i(U(u.filter(W),n,m,f),t,{enableThinking:v}),C=c(_),w=o(s.toolChoice);if(f){let e=h.filter(e=>m.has(e.name)).length;S(`[OpenAI] Tool search enabled: ${e}/${m.size} deferred tools included, total tools=${C.length}`)}else S(`[OpenAI] Tool search disabled, total tools=${C.length}`);let{upperLimit:E}=T(l),j=B(E,s.maxOutputTokensOverride);S(`[OpenAI] Calling model=${l}, messages=${b.length}, tools=${C.length}, thinking=${v}`);let M=a(await P({maxRetries:0,fetchOverride:s.fetchOverride,source:s.querySource}).chat.completions.create(V({model:l,messages:b,tools:C,toolChoice:w,enableThinking:v,maxTokens:j,temperatureOverride:s.temperatureOverride}),{signal:r}),l),N={},F=null,L=null,R={input_tokens:0,output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:0},H=0,K=Date.now();for await(let e of M){switch(e.type){case`message_start`:F=e.message,H=Date.now()-K,e.message.usage&&(R={...R,...e.message.usage});break;case`content_block_start`:{let t=e.index,n=e.content_block;n.type===`tool_use`?N[t]={...n,input:``}:n.type===`text`?N[t]={...n,text:``}:n.type===`thinking`?N[t]={...n,thinking:``,signature:``}:N[t]={...n};break}case`content_block_delta`:{let t=e.index,n=e.delta,r=N[t];if(!r)break;n.type===`text_delta`?r.text=(r.text||``)+n.text:n.type===`input_json_delta`?r.input=(r.input||``)+n.partial_json:n.type===`thinking_delta`?r.thinking=(r.thinking||``)+n.thinking:n.type===`signature_delta`&&(r.signature=n.signature);break}case`content_block_stop`:break;case`message_delta`:{let t=e.usage;t&&(R=I(R,t)),e.delta.stop_reason!=null&&(L=e.delta.stop_reason);break}case`message_stop`:if(F){for(let e of G({partialMessage:F,contentBlocks:N,tools:n,agentId:s.agentId,usage:R,stopReason:L,maxTokens:j}))yield e;F=null}R.input_tokens+R.output_tokens>0&&g(D(l,R),R,s.model);break}yield{type:`stream_event`,event:e,...e.type===`message_start`?{ttftMs:H}:void 0}}if(F)for(let e of G({partialMessage:F,contentBlocks:N,tools:n,agentId:s.agentId,usage:R,stopReason:L,maxTokens:j}))yield e}catch(e){let t=e instanceof Error?e.message:String(e);S(`[OpenAI] Error: ${t}`,{level:`error`}),yield m({content:`API Error: ${t}`,apiError:`api_error`,error:e instanceof Error?e:Error(String(e))})}}e((()=>{F(),L(),s(),l(),f(),N(),C(),_(),w(),H(),E(),u(),j()}))();export{K as queryModelOpenAI};
@@ -1 +1 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{Fp as n,Ip as r,Lp as i}from"./loadAgentsDir-DlPbtIsS.js";import{Rn as a,ai as o,t as s}from"./src-DL3w8VPk.js";function c(e,t=!0){let r=(0,d.useContext)(n)?.setState;(0,d.useEffect)(()=>{if(!(!t||!r))return r(t=>{if(t.activeOverlays.has(e))return t;let n=new Set(t.activeOverlays);return n.add(e),{...t,activeOverlays:n}}),()=>{r(t=>{if(!t.activeOverlays.has(e))return t;let n=new Set(t.activeOverlays);return n.delete(e),{...t,activeOverlays:n}})}},[e,t,r]),(0,d.useLayoutEffect)(()=>{if(t)return()=>a.get(process.stdout)?.invalidatePrevFrame()},[t])}function l(){return i(e=>e.activeOverlays.size>0)}function u(){return i(e=>{for(let t of e.activeOverlays)if(!f.has(t))return!0;return!1})}var d,f,p=e((()=>{d=t(o(),1),s(),r(),f=new Set([`autocomplete`])}));export{c as i,u as n,l as r,p as t};
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{Fp as n,Ip as r,Lp as i}from"./loadAgentsDir-B0Anodo0.js";import{Rn as a,ai as o,t as s}from"./src-DL3w8VPk.js";function c(e,t=!0){let r=(0,d.useContext)(n)?.setState;(0,d.useEffect)(()=>{if(!(!t||!r))return r(t=>{if(t.activeOverlays.has(e))return t;let n=new Set(t.activeOverlays);return n.add(e),{...t,activeOverlays:n}}),()=>{r(t=>{if(!t.activeOverlays.has(e))return t;let n=new Set(t.activeOverlays);return n.delete(e),{...t,activeOverlays:n}})}},[e,t,r]),(0,d.useLayoutEffect)(()=>{if(t)return()=>a.get(process.stdout)?.invalidatePrevFrame()},[t])}function l(){return i(e=>e.activeOverlays.size>0)}function u(){return i(e=>{for(let t of e.activeOverlays)if(!f.has(t))return!0;return!1})}var d,f,p=e((()=>{d=t(o(),1),s(),r(),f=new Set([`autocomplete`])}));export{c as i,u as n,l as r,p as t};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{ai as t,ii as n,or as r,sr as i}from"./state-B4jiUise.js";import{n as a,t as o}from"./_baseEach-4ff-vRlp.js";function s(e,t,n,r){for(var i=-1,a=e==null?0:e.length;++i<a;){var o=e[i];t(r,o,n(o),e)}return r}var c=e((()=>{}));function l(e,t,n,r){return o(e,function(e,i,a){t(r,e,n(e),a)}),r}var u=e((()=>{a()}));function d(e,n){return function(i,a){var o=t(i)?s:l,c=n?n():{};return o(i,e,r(a,2),c)}}var f=e((()=>{c(),u(),i(),n()})),p,m=e((()=>{f(),p=d(function(e,t,n){e[+!n].push(t)},function(){return[[],[]]})}));export{p as n,m as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{ai as t,ii as n,or as r,sr as i}from"./state-B4jiUise.js";import{n as a,t as o}from"./_baseEach-CsIRoaTH.js";function s(e,t,n,r){for(var i=-1,a=e==null?0:e.length;++i<a;){var o=e[i];t(r,o,n(o),e)}return r}var c=e((()=>{}));function l(e,t,n,r){return o(e,function(e,i,a){t(r,e,n(e),a)}),r}var u=e((()=>{a()}));function d(e,n){return function(i,a){var o=t(i)?s:l,c=n?n():{};return o(i,e,r(a,2),c)}}var f=e((()=>{c(),u(),i(),n()})),p,m=e((()=>{f(),p=d(function(e,t,n){e[+!n].push(t)},function(){return[[],[]]})}));export{p as n,m as t};
@@ -1,3 +1,3 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./figures-5ThXQEtq.js";import{Am as i,Em as a,H as o,I as s,Ip as c,L as l,Lp as u,Of as d,R as ee,V as f,Yi as p,bb as m,cS as te,gC as h,kf as ne,km as g,mb as _,yC as re,z as ie,zp as ae}from"./loadAgentsDir-DlPbtIsS.js";import{I as v,P as y,Wt as oe,Xn as se,a as b,ai as x,di as S,fi as C,hn as w,k as T,kt as E,n as D,o as O,ot as k,r as ce,s as A,t as j,x as le,y as M}from"./src-DL3w8VPk.js";import{t as N}from"./jsx-runtime-Bb4Xn-E0.js";import{It as ue,J as P}from"./state-B4jiUise.js";import{C as F,x as de}from"./debug-Bglx1aTu.js";import{B as fe,R as I,V as L,a as R,h as pe,ln as z,rn as me}from"./settings-B2jvL8Dp.js";import{l as B,o as he}from"./stringUtils-C718f5ey.js";import{n as ge,t as _e}from"./TextInput-CD9iau2k.js";import{n as ve,t as ye}from"./useExitOnCtrlCDWithKeybindings-C9BYG8Bo.js";import{n as V,t as H}from"./select-Bxf5-5sI.js";import{n as be,t as xe}from"./AddWorkspaceDirectory-OgcBcK5A.js";import{t as Se}from"./SearchBox-C9xxQzh1.js";import{n as Ce,t as we}from"./useSearchInput-B25K1RnK.js";import{n as Te,t as Ee}from"./shadowedRuleDetection-BRxZjobz.js";function De(){return U}var U,Oe=e((()=>{U=[]}));function ke({ruleValue:e}){switch(e.toolName){case d.name:return e.ruleContent?e.ruleContent.endsWith(`:*`)?(0,W.jsxs)(y,{dimColor:!0,children:[`Any Bash command starting with `,(0,W.jsx)(y,{bold:!0,children:e.ruleContent.slice(0,-2)})]}):(0,W.jsxs)(y,{dimColor:!0,children:[`The Bash command `,(0,W.jsx)(y,{bold:!0,children:e.ruleContent})]}):(0,W.jsx)(y,{dimColor:!0,children:`Any Bash command`});default:return e.ruleContent?null:(0,W.jsxs)(y,{dimColor:!0,children:[`Any use of the `,(0,W.jsx)(y,{bold:!0,children:e.toolName}),` tool`]})}}var W,Ae=e((()=>{j(),ne(),W=N()}));function je(e){switch(e){case`localSettings`:return{label:`Project settings (local)`,description:`Saved in ${R(`localSettings`)}`,value:e};case`projectSettings`:return{label:`Project settings`,description:`Checked in at ${R(`projectSettings`)}`,value:e};case`userSettings`:return{label:`User settings`,description:`Saved in at ~/.workmate/settings.json`,value:e}}}function Me({onAddRules:e,onCancel:t,ruleValues:n,ruleBehavior:r,initialContext:o,setToolPermissionContext:s}){let c=me.map(je),l=(0,Ne.useCallback)(c=>{if(c===`cancel`){t();return}else if(me.includes(c)){let t=c,l=a(o,{type:`addRules`,rules:n,behavior:r,destination:t});i({type:`addRules`,rules:n,behavior:r,destination:t}),s(l);let u=n.map(e=>({ruleValue:e,ruleBehavior:r,source:t})),d=Ee(l,{sandboxAutoAllowEnabled:h.isSandboxingEnabled()&&h.isAutoAllowBashIfSandboxedEnabled()}).filter(e=>n.some(t=>t.toolName===e.rule.ruleValue.toolName&&t.ruleContent===e.rule.ruleValue.ruleContent));e(u,d.length>0?d:void 0)}},[e,t,n,r,o,s]);return(0,G.jsxs)(M,{title:`Add ${r} permission ${B(n.length,`rule`)}`,onCancel:t,color:`permission`,children:[(0,G.jsx)(v,{flexDirection:`column`,paddingX:2,children:n.map(e=>(0,G.jsxs)(v,{flexDirection:`column`,children:[(0,G.jsx)(y,{bold:!0,children:L(e)}),(0,G.jsx)(ke,{ruleValue:e})]},L(e)))}),(0,G.jsxs)(v,{flexDirection:`column`,marginY:1,children:[(0,G.jsx)(y,{children:n.length===1?`Where should this rule be saved?`:`Where should these rules be saved?`}),(0,G.jsx)(H,{options:c,onChange:l})]})]})}var Ne,G,Pe=e((()=>{Ne=t(x(),1),V(),j(),g(),I(),Te(),re(),z(),pe(),he(),Ae(),G=N()}));function Fe({onCancel:e,onSubmit:t,ruleBehavior:n}){let[i,a]=(0,Ie.useState)(``),[o,s]=(0,Ie.useState)(0),c=ve();oe(`confirm:no`,e,{context:`Settings`});let{columns:l}=k(),u=l-6;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(v,{flexDirection:`column`,gap:1,borderStyle:`round`,paddingLeft:1,paddingRight:1,borderColor:`permission`,children:[(0,K.jsxs)(y,{bold:!0,color:`permission`,children:[`Add `,n,` permission rule`]}),(0,K.jsxs)(v,{flexDirection:`column`,children:[(0,K.jsxs)(y,{children:[`Permission rules are a tool name, optionally followed by a specifier in parentheses.`,(0,K.jsx)(E,{}),`e.g., `,(0,K.jsx)(y,{bold:!0,children:L({toolName:d.name})}),(0,K.jsx)(y,{bold:!1,children:` or `}),(0,K.jsx)(y,{bold:!0,children:L({toolName:d.name,ruleContent:`ls:*`})})]}),(0,K.jsx)(v,{borderDimColor:!0,borderStyle:`round`,marginY:1,paddingLeft:1,children:(0,K.jsx)(_e,{showCursor:!0,value:i,onChange:a,onSubmit:e=>{let r=e.trim();r.length!==0&&t(fe(r),n)},placeholder:`Enter permission rule${r.ellipsis}`,columns:u,cursorOffset:o,onChangeCursorOffset:s})})]})]}),(0,K.jsx)(v,{marginLeft:3,children:c.pending?(0,K.jsxs)(y,{dimColor:!0,children:[`Press `,c.keyName,` again to exit`]}):(0,K.jsx)(y,{dimColor:!0,children:`Enter to submit · Esc to cancel`})})]})}var Ie,K,Le=e((()=>{n(),Ie=t(x(),1),ge(),ye(),m(),j(),_(),ne(),I(),K=N()}));function Re({onHeaderFocusChange:e,onStateChange:t}){let{headerFocused:n,focusHeader:r}=b();(0,q.useEffect)(()=>{e?.(n)},[n,e]);let[i]=(0,q.useState)(()=>De()),[a,o]=(0,q.useState)(()=>new Set),[s,c]=(0,q.useState)(()=>new Set),[l,u]=(0,q.useState)(0);(0,q.useEffect)(()=>{t({approved:a,retry:s,denials:i})},[a,s,i,t]);let d=(0,q.useCallback)(e=>{let t=Number(e);o(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n})},[]),ee=(0,q.useCallback)(e=>{u(Number(e))},[]);if(w((e,t)=>{e===`r`&&(c(e=>{let t=new Set(e);return t.has(l)?t.delete(l):t.add(l),t}),o(e=>{if(e.has(l))return e;let t=new Set(e);return t.add(l),t}))},{isActive:i.length>0}),i.length===0)return(0,J.jsx)(y,{dimColor:!0,children:`No recent denials. Commands denied by the auto mode classifier will appear here.`});let f=i.map((e,t)=>{let n=a.has(t),r=s.has(t)?` (retry)`:``;return{label:(0,J.jsxs)(y,{children:[(0,J.jsx)(A,{status:n?`success`:`error`,withSpace:!0}),e.display,(0,J.jsx)(y,{dimColor:!0,children:r})]}),value:String(t)}});return(0,J.jsxs)(v,{flexDirection:`column`,children:[(0,J.jsx)(y,{children:`Commands recently denied by the auto mode classifier.`}),(0,J.jsx)(v,{marginTop:1,children:(0,J.jsx)(H,{options:f,onChange:d,onFocus:ee,visibleOptionCount:Math.min(10,f.length),isDisabled:n,onUpFromFirstItem:r})})]})}var q,J,ze=e((()=>{q=t(x(),1),j(),Oe(),V(),J=N()}));function Be({directoryPath:e,onRemove:t,onCancel:n,permissionContext:r,setPermissionContext:i}){let o=(0,Ve.useCallback)(()=>{i(a(r,{type:`removeDirectories`,directories:[e],destination:`session`})),t()},[e,r,i,t]),s=(0,Ve.useCallback)(e=>{e===`yes`?o():n()},[o,n]);return(0,Y.jsxs)(M,{title:`Remove directory from workspace?`,onCancel:n,color:`error`,children:[(0,Y.jsx)(v,{marginX:2,flexDirection:`column`,children:(0,Y.jsx)(y,{bold:!0,children:e})}),(0,Y.jsx)(y,{children:`Work Mate will no longer have access to files in this directory.`}),(0,Y.jsx)(H,{onChange:s,onCancel:n,options:[{label:`Yes`,value:`yes`},{label:`No`,value:`no`}]})]})}var Ve,Y,He=e((()=>{Ve=t(x(),1),V(),j(),g(),Y=N()}));function Ue({onExit:e,toolPermissionContext:t,onRequestAddDirectory:n,onRequestRemoveDirectory:i,onHeaderFocusChange:a}){let{headerFocused:o,focusHeader:s}=b();(0,X.useEffect)(()=>{a?.(o)},[o,a]);let c=We.useMemo(()=>Array.from(t.additionalWorkingDirectories.keys()).map(e=>({path:e,isCurrent:!1,isDeletable:!0})),[t.additionalWorkingDirectories]),l=(0,X.useCallback)(e=>{if(e===`add-directory`){n();return}let t=c.find(t=>t.path===e);t?.isDeletable&&i(t.path)},[c,n,i]),u=(0,X.useCallback)(()=>e(`Workspace dialog dismissed`,{display:`system`}),[e]),d=We.useMemo(()=>{let e=c.map(e=>({label:e.path,value:e.path}));return e.push({label:`Add directory${r.ellipsis}`,value:`add-directory`}),e},[c]);return(0,Z.jsxs)(v,{flexDirection:`column`,marginBottom:1,children:[(0,Z.jsxs)(v,{flexDirection:`row`,marginTop:1,marginLeft:2,gap:1,children:[(0,Z.jsx)(y,{children:`- ${P()}`}),(0,Z.jsx)(y,{dimColor:!0,children:`(Original working directory)`})]}),(0,Z.jsx)(H,{options:d,onChange:l,onCancel:u,visibleOptionCount:Math.min(10,d.length),onUpFromFirstItem:s,isDisabled:o})]})}var We,X,Z,Ge=e((()=>{n(),We=t(x(),1),X=t(x(),1),ue(),V(),j(),Z=N()}));function Ke({rule:e}){return(0,$.jsx)(y,{dimColor:!0,children:`From ${o(e.source)}`})}function qe(e){switch(e){case`allow`:return`allowed`;case`deny`:return`denied`;case`ask`:return`ask`}}function Je({rule:e,onDelete:t,onCancel:n}){let r=ve();oe(`confirm:no`,n,{context:`Confirmation`});let i=(0,$.jsxs)(v,{flexDirection:`column`,marginX:2,children:[(0,$.jsx)(y,{bold:!0,children:L(e.ruleValue)}),(0,$.jsx)(ke,{ruleValue:e.ruleValue}),(0,$.jsx)(Ke,{rule:e})]}),a=(0,$.jsx)(v,{marginLeft:3,children:r.pending?(0,$.jsxs)(y,{dimColor:!0,children:[`Press `,r.keyName,` again to exit`]}):(0,$.jsx)(y,{dimColor:!0,children:`Esc to cancel`})});return e.source===`policySettings`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(v,{flexDirection:`column`,gap:1,borderStyle:`round`,paddingLeft:1,paddingRight:1,borderColor:`permission`,children:[(0,$.jsx)(y,{bold:!0,color:`permission`,children:`Rule details`}),i,(0,$.jsxs)(y,{italic:!0,children:[`This rule is configured by managed settings and cannot be modified.`,`
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./figures-5ThXQEtq.js";import{Am as i,Em as a,H as o,I as s,Ip as c,L as l,Lp as u,Of as d,R as ee,V as f,Yi as p,bb as m,cS as te,gC as h,kf as ne,km as g,mb as _,yC as re,z as ie,zp as ae}from"./loadAgentsDir-B0Anodo0.js";import{I as v,P as y,Wt as oe,Xn as se,a as b,ai as x,di as S,fi as C,hn as w,k as T,kt as E,n as D,o as O,ot as k,r as ce,s as A,t as j,x as le,y as M}from"./src-DL3w8VPk.js";import{t as N}from"./jsx-runtime-Bb4Xn-E0.js";import{It as ue,J as P}from"./state-B4jiUise.js";import{C as F,x as de}from"./debug-Bglx1aTu.js";import{B as fe,R as I,V as L,a as R,h as pe,ln as z,rn as me}from"./settings-B2jvL8Dp.js";import{l as B,o as he}from"./stringUtils-C718f5ey.js";import{n as ge,t as _e}from"./TextInput-B8ruWRf2.js";import{n as ve,t as ye}from"./useExitOnCtrlCDWithKeybindings-BKwzUpgb.js";import{n as V,t as H}from"./select-DIxfl_VN.js";import{n as be,t as xe}from"./AddWorkspaceDirectory-Ch8IcWXO.js";import{t as Se}from"./SearchBox-C9xxQzh1.js";import{n as Ce,t as we}from"./useSearchInput-CzopttqC.js";import{n as Te,t as Ee}from"./shadowedRuleDetection-Bg_aIc5Z.js";function De(){return U}var U,Oe=e((()=>{U=[]}));function ke({ruleValue:e}){switch(e.toolName){case d.name:return e.ruleContent?e.ruleContent.endsWith(`:*`)?(0,W.jsxs)(y,{dimColor:!0,children:[`Any Bash command starting with `,(0,W.jsx)(y,{bold:!0,children:e.ruleContent.slice(0,-2)})]}):(0,W.jsxs)(y,{dimColor:!0,children:[`The Bash command `,(0,W.jsx)(y,{bold:!0,children:e.ruleContent})]}):(0,W.jsx)(y,{dimColor:!0,children:`Any Bash command`});default:return e.ruleContent?null:(0,W.jsxs)(y,{dimColor:!0,children:[`Any use of the `,(0,W.jsx)(y,{bold:!0,children:e.toolName}),` tool`]})}}var W,Ae=e((()=>{j(),ne(),W=N()}));function je(e){switch(e){case`localSettings`:return{label:`Project settings (local)`,description:`Saved in ${R(`localSettings`)}`,value:e};case`projectSettings`:return{label:`Project settings`,description:`Checked in at ${R(`projectSettings`)}`,value:e};case`userSettings`:return{label:`User settings`,description:`Saved in at ~/.workmate/settings.json`,value:e}}}function Me({onAddRules:e,onCancel:t,ruleValues:n,ruleBehavior:r,initialContext:o,setToolPermissionContext:s}){let c=me.map(je),l=(0,Ne.useCallback)(c=>{if(c===`cancel`){t();return}else if(me.includes(c)){let t=c,l=a(o,{type:`addRules`,rules:n,behavior:r,destination:t});i({type:`addRules`,rules:n,behavior:r,destination:t}),s(l);let u=n.map(e=>({ruleValue:e,ruleBehavior:r,source:t})),d=Ee(l,{sandboxAutoAllowEnabled:h.isSandboxingEnabled()&&h.isAutoAllowBashIfSandboxedEnabled()}).filter(e=>n.some(t=>t.toolName===e.rule.ruleValue.toolName&&t.ruleContent===e.rule.ruleValue.ruleContent));e(u,d.length>0?d:void 0)}},[e,t,n,r,o,s]);return(0,G.jsxs)(M,{title:`Add ${r} permission ${B(n.length,`rule`)}`,onCancel:t,color:`permission`,children:[(0,G.jsx)(v,{flexDirection:`column`,paddingX:2,children:n.map(e=>(0,G.jsxs)(v,{flexDirection:`column`,children:[(0,G.jsx)(y,{bold:!0,children:L(e)}),(0,G.jsx)(ke,{ruleValue:e})]},L(e)))}),(0,G.jsxs)(v,{flexDirection:`column`,marginY:1,children:[(0,G.jsx)(y,{children:n.length===1?`Where should this rule be saved?`:`Where should these rules be saved?`}),(0,G.jsx)(H,{options:c,onChange:l})]})]})}var Ne,G,Pe=e((()=>{Ne=t(x(),1),V(),j(),g(),I(),Te(),re(),z(),pe(),he(),Ae(),G=N()}));function Fe({onCancel:e,onSubmit:t,ruleBehavior:n}){let[i,a]=(0,Ie.useState)(``),[o,s]=(0,Ie.useState)(0),c=ve();oe(`confirm:no`,e,{context:`Settings`});let{columns:l}=k(),u=l-6;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(v,{flexDirection:`column`,gap:1,borderStyle:`round`,paddingLeft:1,paddingRight:1,borderColor:`permission`,children:[(0,K.jsxs)(y,{bold:!0,color:`permission`,children:[`Add `,n,` permission rule`]}),(0,K.jsxs)(v,{flexDirection:`column`,children:[(0,K.jsxs)(y,{children:[`Permission rules are a tool name, optionally followed by a specifier in parentheses.`,(0,K.jsx)(E,{}),`e.g., `,(0,K.jsx)(y,{bold:!0,children:L({toolName:d.name})}),(0,K.jsx)(y,{bold:!1,children:` or `}),(0,K.jsx)(y,{bold:!0,children:L({toolName:d.name,ruleContent:`ls:*`})})]}),(0,K.jsx)(v,{borderDimColor:!0,borderStyle:`round`,marginY:1,paddingLeft:1,children:(0,K.jsx)(_e,{showCursor:!0,value:i,onChange:a,onSubmit:e=>{let r=e.trim();r.length!==0&&t(fe(r),n)},placeholder:`Enter permission rule${r.ellipsis}`,columns:u,cursorOffset:o,onChangeCursorOffset:s})})]})]}),(0,K.jsx)(v,{marginLeft:3,children:c.pending?(0,K.jsxs)(y,{dimColor:!0,children:[`Press `,c.keyName,` again to exit`]}):(0,K.jsx)(y,{dimColor:!0,children:`Enter to submit · Esc to cancel`})})]})}var Ie,K,Le=e((()=>{n(),Ie=t(x(),1),ge(),ye(),m(),j(),_(),ne(),I(),K=N()}));function Re({onHeaderFocusChange:e,onStateChange:t}){let{headerFocused:n,focusHeader:r}=b();(0,q.useEffect)(()=>{e?.(n)},[n,e]);let[i]=(0,q.useState)(()=>De()),[a,o]=(0,q.useState)(()=>new Set),[s,c]=(0,q.useState)(()=>new Set),[l,u]=(0,q.useState)(0);(0,q.useEffect)(()=>{t({approved:a,retry:s,denials:i})},[a,s,i,t]);let d=(0,q.useCallback)(e=>{let t=Number(e);o(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n})},[]),ee=(0,q.useCallback)(e=>{u(Number(e))},[]);if(w((e,t)=>{e===`r`&&(c(e=>{let t=new Set(e);return t.has(l)?t.delete(l):t.add(l),t}),o(e=>{if(e.has(l))return e;let t=new Set(e);return t.add(l),t}))},{isActive:i.length>0}),i.length===0)return(0,J.jsx)(y,{dimColor:!0,children:`No recent denials. Commands denied by the auto mode classifier will appear here.`});let f=i.map((e,t)=>{let n=a.has(t),r=s.has(t)?` (retry)`:``;return{label:(0,J.jsxs)(y,{children:[(0,J.jsx)(A,{status:n?`success`:`error`,withSpace:!0}),e.display,(0,J.jsx)(y,{dimColor:!0,children:r})]}),value:String(t)}});return(0,J.jsxs)(v,{flexDirection:`column`,children:[(0,J.jsx)(y,{children:`Commands recently denied by the auto mode classifier.`}),(0,J.jsx)(v,{marginTop:1,children:(0,J.jsx)(H,{options:f,onChange:d,onFocus:ee,visibleOptionCount:Math.min(10,f.length),isDisabled:n,onUpFromFirstItem:r})})]})}var q,J,ze=e((()=>{q=t(x(),1),j(),Oe(),V(),J=N()}));function Be({directoryPath:e,onRemove:t,onCancel:n,permissionContext:r,setPermissionContext:i}){let o=(0,Ve.useCallback)(()=>{i(a(r,{type:`removeDirectories`,directories:[e],destination:`session`})),t()},[e,r,i,t]),s=(0,Ve.useCallback)(e=>{e===`yes`?o():n()},[o,n]);return(0,Y.jsxs)(M,{title:`Remove directory from workspace?`,onCancel:n,color:`error`,children:[(0,Y.jsx)(v,{marginX:2,flexDirection:`column`,children:(0,Y.jsx)(y,{bold:!0,children:e})}),(0,Y.jsx)(y,{children:`Work Mate will no longer have access to files in this directory.`}),(0,Y.jsx)(H,{onChange:s,onCancel:n,options:[{label:`Yes`,value:`yes`},{label:`No`,value:`no`}]})]})}var Ve,Y,He=e((()=>{Ve=t(x(),1),V(),j(),g(),Y=N()}));function Ue({onExit:e,toolPermissionContext:t,onRequestAddDirectory:n,onRequestRemoveDirectory:i,onHeaderFocusChange:a}){let{headerFocused:o,focusHeader:s}=b();(0,X.useEffect)(()=>{a?.(o)},[o,a]);let c=We.useMemo(()=>Array.from(t.additionalWorkingDirectories.keys()).map(e=>({path:e,isCurrent:!1,isDeletable:!0})),[t.additionalWorkingDirectories]),l=(0,X.useCallback)(e=>{if(e===`add-directory`){n();return}let t=c.find(t=>t.path===e);t?.isDeletable&&i(t.path)},[c,n,i]),u=(0,X.useCallback)(()=>e(`Workspace dialog dismissed`,{display:`system`}),[e]),d=We.useMemo(()=>{let e=c.map(e=>({label:e.path,value:e.path}));return e.push({label:`Add directory${r.ellipsis}`,value:`add-directory`}),e},[c]);return(0,Z.jsxs)(v,{flexDirection:`column`,marginBottom:1,children:[(0,Z.jsxs)(v,{flexDirection:`row`,marginTop:1,marginLeft:2,gap:1,children:[(0,Z.jsx)(y,{children:`- ${P()}`}),(0,Z.jsx)(y,{dimColor:!0,children:`(Original working directory)`})]}),(0,Z.jsx)(H,{options:d,onChange:l,onCancel:u,visibleOptionCount:Math.min(10,d.length),onUpFromFirstItem:s,isDisabled:o})]})}var We,X,Z,Ge=e((()=>{n(),We=t(x(),1),X=t(x(),1),ue(),V(),j(),Z=N()}));function Ke({rule:e}){return(0,$.jsx)(y,{dimColor:!0,children:`From ${o(e.source)}`})}function qe(e){switch(e){case`allow`:return`allowed`;case`deny`:return`denied`;case`ask`:return`ask`}}function Je({rule:e,onDelete:t,onCancel:n}){let r=ve();oe(`confirm:no`,n,{context:`Confirmation`});let i=(0,$.jsxs)(v,{flexDirection:`column`,marginX:2,children:[(0,$.jsx)(y,{bold:!0,children:L(e.ruleValue)}),(0,$.jsx)(ke,{ruleValue:e.ruleValue}),(0,$.jsx)(Ke,{rule:e})]}),a=(0,$.jsx)(v,{marginLeft:3,children:r.pending?(0,$.jsxs)(y,{dimColor:!0,children:[`Press `,r.keyName,` again to exit`]}):(0,$.jsx)(y,{dimColor:!0,children:`Esc to cancel`})});return e.source===`policySettings`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(v,{flexDirection:`column`,gap:1,borderStyle:`round`,paddingLeft:1,paddingRight:1,borderColor:`permission`,children:[(0,$.jsx)(y,{bold:!0,color:`permission`,children:`Rule details`}),i,(0,$.jsxs)(y,{italic:!0,children:[`This rule is configured by managed settings and cannot be modified.`,`
2
2
  `,`Contact your system administrator for more information.`]})]}),a]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(v,{flexDirection:`column`,gap:1,borderStyle:`round`,paddingLeft:1,paddingRight:1,borderColor:`error`,children:[(0,$.jsxs)(y,{bold:!0,color:`error`,children:[`Delete `,qe(e.ruleBehavior),` tool?`]}),i,(0,$.jsx)(y,{children:`Are you sure you want to delete this permission rule?`}),(0,$.jsx)(H,{onChange:e=>e===`yes`?t():n(),onCancel:n,options:[{label:`Yes`,value:`yes`},{label:`No`,value:`no`}]})]}),a]})}function Ye(e){let{options:t,searchQuery:n,isSearchMode:r,isFocused:i,onSelect:a,onCancel:o,lastFocusedRuleKey:s,cursorOffset:c,onHeaderFocusChange:l}=e,u=O(),{headerFocused:d,focusHeader:ee,blurHeader:f}=b();return(0,Q.useEffect)(()=>{r&&d&&f()},[r,d,f]),(0,Q.useEffect)(()=>{l?.(d)},[d,l]),(0,$.jsxs)(v,{flexDirection:`column`,children:[(0,$.jsx)(v,{marginBottom:1,flexDirection:`column`,children:(0,$.jsx)(T,{query:n,isFocused:r&&!d,isTerminalFocused:i,width:u,cursorOffset:c})}),(0,$.jsx)(H,{options:t,onChange:a,onCancel:o,visibleOptionCount:Math.min(10,t.length),isDisabled:r||d,defaultFocusValue:s,onUpFromFirstItem:ee})]})}function Xe({tab:e,getRulesOptions:t,handleToolSelect:n,...r}){return(0,$.jsxs)(v,{flexDirection:`column`,flexShrink:e===`allow`?0:void 0,children:[(0,$.jsx)(y,{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 o=De().length>0,c=t??(o?`recent`:`allow`),[d,f]=(0,Q.useState)([]),p=u(e=>e.toolPermissionContext),m=ae(),te=se(),h=(0,Q.useRef)({approved:new Set,retry:new Set,denials:[]}),ne=(0,Q.useCallback)(e=>{h.current=e},[]),[g,_]=(0,Q.useState)(),[re,b]=(0,Q.useState)(),[x,C]=(0,Q.useState)(null),[w,T]=(0,Q.useState)(null),[E,O]=(0,Q.useState)(!1),[k,A]=(0,Q.useState)(null),[j,M]=(0,Q.useState)(!1),[N,ue]=(0,Q.useState)(!0),P=(0,Q.useCallback)(e=>{ue(e)},[]),de=(0,Q.useMemo)(()=>{let e=new Map;return l(p).forEach(t=>{e.set(F(t),t)}),e},[p]),fe=(0,Q.useMemo)(()=>{let e=new Map;return ie(p).forEach(t=>{e.set(F(t),t)}),e},[p]),I=(0,Q.useMemo)(()=>{let e=new Map;return ee(p).forEach(t=>{e.set(F(t),t)}),e},[p]),R=(0,Q.useCallback)((e,t=``)=>{let n=(()=>{switch(e){case`allow`:return de;case`deny`:return fe;case`ask`:return I;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=L(r.ruleValue).toLowerCase(),t=L(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=L(r.ruleValue);if(t&&!n.toLowerCase().includes(o))continue;i.push({label:n,value:e})}}return{options:i,rulesByKey:n}},[de,fe,I]),pe=ve(),z=!g&&!x&&!w&&!E&&!k,{query:me,setQuery:B,cursorOffset:he}=Ce({isActive:z&&j,onExit:()=>{M(!1)}}),ge=(0,Q.useCallback)(e=>{z&&(j||e.ctrl||e.meta||(e.key===`/`?(e.preventDefault(),M(!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(),M(!0),B(e.key))))},[z,j,B]),_e=(0,Q.useCallback)((e,t)=>{let{rulesByKey:n}=R(t);if(e===`add-new-rule`){C(t);return}else{_(n.get(e));return}},[R]),ye=(0,Q.useCallback)(()=>{C(null)},[]),V=(0,Q.useCallback)((e,t)=>{T({ruleValue:e,ruleBehavior:t}),C(null)},[]),H=(0,Q.useCallback)((e,t)=>{T(null);for(let t of e)f(e=>[...e,`Added ${t.ruleBehavior} rule ${S.bold(L(t.ruleValue))}`]);if(t&&t.length>0)for(let e of t){let t=e.shadowType===`deny`?`blocked`:`shadowed`;f(n=>[...n,S.yellow(`${r.warning} Warning: ${L(e.rule.ruleValue)} is ${t}`),S.dim(` ${e.reason}`),S.dim(` Fix: ${e.fix}`)])}},[]),be=(0,Q.useCallback)(()=>{T(null)},[]),Se=(0,Q.useCallback)(()=>O(!0),[]),we=(0,Q.useCallback)(e=>A(e),[]),Te=(0,Q.useCallback)(()=>{let t=h.current,r=e=>Array.from(e).map(e=>t.denials[e]).filter(e=>e!==void 0),i=r(t.retry);if(i.length>0){let t=i.map(e=>e.display);n?.(t),e(void 0,{shouldQuery:!0,metaMessages:[`Permission granted for: ${t.join(`, `)}. You may now retry ${t.length===1?`this command`:`these commands`} if you would like.`]});return}let a=r(t.approved);a.length>0||d.length>0?e([...a.length>0?[`Approved ${a.map(e=>S.bold(e.display)).join(`, `)}`]:[],...d].join(`
3
3
  `)):e(`Permissions dialog dismissed`,{display:`system`})},[d,e,n]);oe(`confirm:no`,Te,{context:`Settings`,isActive:z&&!j});let Ee=()=>{if(!g)return;let{options:e}=R(g.ruleBehavior),t=F(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])),b(i),s({rule:g,initialContext:p,setToolPermissionContext(e){m(t=>({...t,toolPermissionContext:e}))}}),f(e=>[...e,`Deleted ${g.ruleBehavior} rule ${S.bold(L(g.ruleValue))}`]),_(void 0)};if(g)return(0,$.jsx)(Je,{rule:g,onDelete:Ee,onCancel:()=>_(void 0)});if(x&&x!==`workspace`&&x!==`recent`)return(0,$.jsx)(Fe,{onCancel:ye,onSubmit:V,ruleBehavior:x});if(w)return(0,$.jsx)(Me,{onAddRules:H,onCancel:be,ruleValues:[w.ruleValue],ruleBehavior:w.ruleBehavior,initialContext:p,setToolPermissionContext:e=>{m(t=>({...t,toolPermissionContext:e}))}});if(E)return(0,$.jsx)(xe,{onAddDirectory:(e,t)=>{let n={type:`addDirectories`,directories:[e],destination:t?`localSettings`:`session`},r=a(p,n);m(e=>({...e,toolPermissionContext:r})),t&&i(n),f(n=>[...n,`Added directory ${S.bold(e)} to workspace${t?` and saved to local settings`:` for this session`}`]),O(!1)},onCancel:()=>O(!1),permissionContext:p});if(k)return(0,$.jsx)(Be,{directoryPath:k,onRemove:()=>{f(e=>[...e,`Removed directory ${S.bold(k)} from workspace`]),A(null)},onCancel:()=>A(null),permissionContext:p,setPermissionContext:e=>{m(t=>({...t,toolPermissionContext:e}))}});let U={searchQuery:me,isSearchMode:j,isFocused:te,onCancel:Te,lastFocusedRuleKey:re,cursorOffset:he,getRulesOptions:R,handleToolSelect:_e,onHeaderFocusChange:P};return(0,$.jsx)(v,{flexDirection:`column`,onKeyDown:ge,children:(0,$.jsxs)(le,{color:`permission`,children:[(0,$.jsxs)(ce,{title:`Permissions:`,color:`permission`,defaultTab:c,hidden:!!g||!!x||!!w||E||!!k,initialHeaderFocused:!o,navFromContent:!j,children:[(0,$.jsx)(D,{id:`recent`,title:`Recently denied`,children:(0,$.jsx)(Re,{onHeaderFocusChange:P,onStateChange:ne})}),(0,$.jsx)(D,{id:`allow`,title:`Allow`,children:(0,$.jsx)(Xe,{tab:`allow`,...U})}),(0,$.jsx)(D,{id:`ask`,title:`Ask`,children:(0,$.jsx)(Xe,{tab:`ask`,...U})}),(0,$.jsx)(D,{id:`deny`,title:`Deny`,children:(0,$.jsx)(Xe,{tab:`deny`,...U})}),(0,$.jsx)(D,{id:`workspace`,title:`Workspace`,children:(0,$.jsxs)(v,{flexDirection:`column`,children:[(0,$.jsx)(y,{children:`Work Mate can read files in the workspace, and make edits when auto-accept edits is on.`}),(0,$.jsx)(Ue,{onExit:e,toolPermissionContext:p,onRequestAddDirectory:Se,onRequestRemoveDirectory:we,onHeaderFocusChange:P})]})})]}),(0,$.jsx)(v,{marginTop:1,paddingLeft:1,children:(0,$.jsx)(y,{dimColor:!0,children:pe.pending?(0,$.jsxs)($.Fragment,{children:[`Press `,pe.keyName,` again to exit`]}):N?(0,$.jsx)($.Fragment,{children:`←/→ tab switch · ↓ return · Esc cancel`}):j?(0,$.jsx)($.Fragment,{children:`Type to filter · Enter/↓ select · ↑ tabs · Esc clear`}):o&&c===`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((()=>{C(),n(),Q=t(x(),1),c(),g(),V(),ye(),we(),j(),_(),Oe(),I(),f(),de(),Se(),Pe(),be(),Ae(),Le(),ze(),He(),Ge(),$=N()})),$e,et;e((()=>{Qe(),p(),$e=N(),et=async(e,t)=>(0,$e.jsx)(Ze,{onExit:e,onRetryDenials:e=>{t.setMessages(t=>[...t,te(e)])}})}))();export{et as call};