@readmagic/workmate 0.0.2 → 0.0.4

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 (490) hide show
  1. package/dist/chunks/{AddWorkspaceDirectory-BgNp7glC.js → AddWorkspaceDirectory-BTC7FPqM.js} +1 -1
  2. package/dist/chunks/{App-Coboqa8H.js → App-DOm71vtY.js} +1 -1
  3. package/dist/chunks/{ApproveApiKey-CYpBbj0k.js → ApproveApiKey-9YQzwrrC.js} +1 -1
  4. package/dist/chunks/ApproveApiKey-LPrZMlgU.js +1 -0
  5. package/dist/chunks/{AssistantSessionChooser-DxKsTdqj.js → AssistantSessionChooser-CnYfFWrx.js} +1 -1
  6. package/dist/chunks/BackgroundTasksDialog-D_UHm7xo.js +2 -0
  7. package/dist/chunks/{BypassPermissionsModeDialog-Cx3QGFz-.js → BypassPermissionsModeDialog-DAq-qbqC.js} +1 -1
  8. package/dist/chunks/ClaudeMdExternalIncludesDialog--w2zWWEn.js +1 -0
  9. package/dist/chunks/{ClaudeMdExternalIncludesDialog-BAK9fxwg.js → ClaudeMdExternalIncludesDialog-CyvidoR3.js} +1 -1
  10. package/dist/chunks/ConsoleOAuthFlow-BXdC6j3_.js +1 -0
  11. package/dist/chunks/{DesktopHandoff-BsHgLlTy.js → DesktopHandoff-gRvy-WlW.js} +1 -1
  12. package/dist/chunks/{DiffDialog-BgTW2Znv.js → DiffDialog-CdfVTgOx.js} +2 -2
  13. package/dist/chunks/Doctor-BuiYwjAS.js +1 -0
  14. package/dist/chunks/Doctor-DKlHJBXq.js +3 -0
  15. package/dist/chunks/ExitFlow-rExuBL3w.js +2 -0
  16. package/dist/chunks/Feedback-gGpjUC_F.js +2 -0
  17. package/dist/chunks/{Grove-Dsi4yU08.js → Grove-CD769Wvw.js} +1 -1
  18. package/dist/chunks/Grove-ENfM8hC6.js +1 -0
  19. package/dist/chunks/{HybridTransport-8qA64lCx.js → HybridTransport-kN1jmg26.js} +4 -4
  20. package/dist/chunks/{InvalidConfigDialog-CAZ1z5WG.js → InvalidConfigDialog-BpJub73a.js} +1 -1
  21. package/dist/chunks/{InvalidSettingsDialog-D82Qk_MR.js → InvalidSettingsDialog-DzOp3Ihx.js} +1 -1
  22. package/dist/chunks/MCPConnectionManager-CaBvO7NB.js +1 -0
  23. package/dist/chunks/{McpParsingWarnings-8ZueNqAd.js → McpParsingWarnings-Cc6FWyU4.js} +1 -1
  24. package/dist/chunks/MessageSelector-DOB1S2-O.js +3 -0
  25. package/dist/chunks/Messages-Clihwd2F.js +11 -0
  26. package/dist/chunks/{Onboarding-CUztnbbv.js → Onboarding-D00lTweB.js} +1 -1
  27. package/dist/chunks/{OverageCreditUpsell-DSgrZvMv.js → OverageCreditUpsell-B-Bf_-UX.js} +1 -1
  28. package/dist/chunks/PluginSettings-DUxj_oAg.js +17 -0
  29. package/dist/chunks/{PromptInputFooterSuggestions-IaihWay3.js → PromptInputFooterSuggestions-MwS_cExV.js} +1 -1
  30. package/dist/chunks/{PromptInputHelpMenu-okS2rQ4k.js → PromptInputHelpMenu-V2dEpzhC.js} +1 -1
  31. package/dist/chunks/QueryEngine-BLcPQYq_.js +1 -0
  32. package/dist/chunks/{REPL-Dto012J0.js → REPL-B_E07dnf.js} +44 -44
  33. package/dist/chunks/REPL-BhURgntS.js +1 -0
  34. package/dist/chunks/{RemoteCallout-C_UIYnuT.js → RemoteCallout-ChCjmgw1.js} +1 -1
  35. package/dist/chunks/{RemoteSessionManager-CuSSHAXN.js → RemoteSessionManager-B43isWQs.js} +2 -2
  36. package/dist/chunks/ResumeConversation-DaQ9n8_C.js +1 -0
  37. package/dist/chunks/{SSETransport-Chj_yfPv.js → SSETransport-h43pQVlJ.js} +3 -3
  38. package/dist/chunks/SearchExtraToolsTool-DSq7beKs.js +1 -0
  39. package/dist/chunks/Settings-CNsaWv8g.js +2 -0
  40. package/dist/chunks/{TeleportProgress-DP1a8jit.js → TeleportProgress-QtJrXSCX.js} +1 -1
  41. package/dist/chunks/{TeleportRepoMismatchDialog-B6sTwXuZ.js → TeleportRepoMismatchDialog-D-HVj-A6.js} +1 -1
  42. package/dist/chunks/{TeleportResumeWrapper-CKUuRQSG.js → TeleportResumeWrapper-C6sbzJsJ.js} +1 -1
  43. package/dist/chunks/{ThemePicker-Dyq1YVhb.js → ThemePicker-CqPCp5Hs.js} +1 -1
  44. package/dist/chunks/TrustDialog-CeVwxDlZ.js +1 -0
  45. package/dist/chunks/{ValidationErrorsList-DUNh4BNa.js → ValidationErrorsList-Bl68E-2-.js} +1 -1
  46. package/dist/chunks/{WelcomeV2-TPbOXGrO.js → WelcomeV2-DNiXQ5ES.js} +1 -1
  47. package/dist/chunks/{add-dir-Bf_5tCeR.js → add-dir-V3xjklnJ.js} +1 -1
  48. package/dist/chunks/{agentDisplay-CCeYiAta.js → agentDisplay-BuiwcrQi.js} +1 -1
  49. package/dist/chunks/{agents-Bt72Gz1v.js → agents-D7um1IXM.js} +7 -7
  50. package/dist/chunks/{agents-T8xHY5Wk.js → agents-ZY6IaVE7.js} +1 -1
  51. package/dist/chunks/{allErrors-CDWTJcMw.js → allErrors-CHVdQ3fT.js} +1 -1
  52. package/dist/chunks/{ant-DRF-v5bA.js → ant-D66LZCap.js} +1 -1
  53. package/dist/chunks/api-C-rOQY-l.js +1 -0
  54. package/dist/chunks/api-Dmn7DUgU.js +1 -0
  55. package/dist/chunks/asciicast-BsWpcxrc.js +1 -0
  56. package/dist/chunks/{asciicast-CQJlNTae.js → asciicast-CbAjUHT_.js} +4 -4
  57. package/dist/chunks/{assistant-z1ojxEET.js → assistant-CYF7ch7C.js} +1 -1
  58. package/dist/chunks/auth-C4Rvit2q.js +1 -0
  59. package/dist/chunks/auth-Cj7EX1eG.js +1 -0
  60. package/dist/chunks/auth-DAxGNCIR.js +15 -0
  61. package/dist/chunks/{autoMode-DW_H3i37.js → autoMode-TysBQkU_.js} +5 -5
  62. package/dist/chunks/{autonomy-OxhciwYa.js → autonomy-CNEbT-t_.js} +7 -7
  63. package/dist/chunks/{autonomy-46hnmyAi.js → autonomy-k3QPea5z.js} +1 -1
  64. package/dist/chunks/{autonomyPanel-CTEjq0Bd.js → autonomyPanel-DiztRblF.js} +1 -1
  65. package/dist/chunks/{backgroundHousekeeping-Cpxq4krt.js → backgroundHousekeeping-C9m4tiFi.js} +3 -3
  66. package/dist/chunks/backgroundHousekeeping-DQjzXBe0.js +1 -0
  67. package/dist/chunks/{banner-BVkLvJiB.js → banner-CWkrK10u.js} +1 -1
  68. package/dist/chunks/bg-B0iMGM9C.js +1 -0
  69. package/dist/chunks/{bg-zWGqkcST.js → bg-WnYN5ifx.js} +2 -2
  70. package/dist/chunks/{branch-DJzijRGm.js → branch-_NBgDfrK.js} +1 -1
  71. package/dist/chunks/{bridge-Dpr2AWpc.js → bridge-DpmFl8p8.js} +2 -2
  72. package/dist/chunks/{bridgeConfig-DDF3teRE.js → bridgeConfig-DMBOO3gW.js} +1 -1
  73. package/dist/chunks/bridgeConfig-DsI5d0s7.js +1 -0
  74. package/dist/chunks/bridgeEnabled-DZzlF2d8.js +1 -0
  75. package/dist/chunks/{bridgeEnabled-D4JDZd0y.js → bridgeEnabled-FjPuA7zx.js} +1 -1
  76. package/dist/chunks/bridgeMain-BppY0KW3.js +68 -0
  77. package/dist/chunks/bridgeMain-BrY4tkF6.js +1 -0
  78. package/dist/chunks/bridgeMessaging-N5zlzCCr.js +1 -0
  79. package/dist/chunks/bridgePointer-MqLe5Asm.js +1 -0
  80. package/dist/chunks/{browser-BKiu1max.js → browser-BmZuQom6.js} +1 -1
  81. package/dist/chunks/{btw-DG9CCeq4.js → btw-BFRje_Zi.js} +1 -1
  82. package/dist/chunks/caches-BBLH8G1I.js +1 -0
  83. package/dist/chunks/{caches-BB5_91gU.js → caches-CcfPJ4_A.js} +2 -2
  84. package/dist/chunks/ccrClient-q2JCVCU2.js +1 -0
  85. package/dist/chunks/{claudeDesktop-9xfIgkzE.js → claudeDesktop-Cx31Ugjp.js} +1 -1
  86. package/dist/chunks/{clear-ueMvDelv.js → clear-CxY7W5Wt.js} +1 -1
  87. package/dist/chunks/{cliLaunch-BJ9o-rIV.js → cliLaunch-BkPAatcs.js} +1 -1
  88. package/dist/chunks/client-CtVu3BLD.js +1 -0
  89. package/dist/chunks/{color-B0-MIfsq.js → color-DOWhfjnA.js} +1 -1
  90. package/dist/chunks/commands-BWw1sQeH.js +1 -0
  91. package/dist/chunks/{commitAttribution-DKun9CeU.js → commitAttribution-CLbEIaRJ.js} +2 -2
  92. package/dist/chunks/commitAttribution-DIT_s0vY.js +1 -0
  93. package/dist/chunks/compact-CaOnQVkH.js +2 -0
  94. package/dist/chunks/{completionCache-CdHCuiqq.js → completionCache-MN3_MqK8.js} +2 -2
  95. package/dist/chunks/completionCache-c4aiyZ_f.js +1 -0
  96. package/dist/chunks/config-DiT2Z8dY.js +3 -0
  97. package/dist/chunks/config-DmPGzNmi.js +1 -0
  98. package/dist/chunks/config-HHTwEsWp.js +1 -0
  99. package/dist/chunks/{context-DBswG0EY.js → context-B2OvKo2t.js} +1 -1
  100. package/dist/chunks/context-noninteractive-BilCSCV1.js +1 -0
  101. package/dist/chunks/{context-noninteractive-CTvyNimw.js → context-noninteractive-BuGxX3YL.js} +2 -2
  102. package/dist/chunks/conversation-BWXf3un9.js +1 -0
  103. package/dist/chunks/conversation-awh8AwwL.js +1 -0
  104. package/dist/chunks/{createSSHSession-BdO35H6o.js → createSSHSession-C-c7I5iJ.js} +5 -5
  105. package/dist/chunks/{createSession-Br1g8qSD.js → createSession-D_fIDqgc.js} +1 -1
  106. package/dist/chunks/createSession-Hvpx3Le7.js +1 -0
  107. package/dist/chunks/crossProjectResume-_XjvSXA3.js +40 -0
  108. package/dist/chunks/{daemon-BQiSFjc-.js → daemon-YtZbMQtn.js} +1 -1
  109. package/dist/chunks/datadog-Ed8emSFA.js +1 -0
  110. package/dist/chunks/{debug-DiuXEmUq.js → debug-BrXObCdR.js} +1 -1
  111. package/dist/chunks/{debugUtils-3YYWvb3H.js → debugUtils-NO5KtXqi.js} +1 -1
  112. package/dist/chunks/{desktop-W7SA8BFk.js → desktop-D_ofPlyi.js} +1 -1
  113. package/dist/chunks/{detached-Cv9gAylK.js → detached-TYk4hMFj.js} +1 -1
  114. package/dist/chunks/{detectRepository-B1PMTLAU.js → detectRepository-BPr0VWNO.js} +1 -1
  115. package/dist/chunks/detectRepository-BTPgN89l.js +1 -0
  116. package/dist/chunks/{diff-CMtRjFUb.js → diff-CUAgBDu1.js} +1 -1
  117. package/dist/chunks/{directoryCompletion-CeV63gvu.js → directoryCompletion-CW2ckkQg.js} +1 -1
  118. package/dist/chunks/doctor-CkdQ7Fv7.js +1 -0
  119. package/dist/chunks/{effort-BAlVDBHq.js → effort-DCgooYMY.js} +2 -2
  120. package/dist/chunks/{entry-DLqeVq5C.js → entry-Bh0gPOAo.js} +4 -4
  121. package/dist/chunks/envLessBridgeConfig-DJHZAlU-.js +1 -0
  122. package/dist/chunks/envLessBridgeConfig-sxodu0xO.js +1 -0
  123. package/dist/chunks/esm-B62dCLgf.js +1 -0
  124. package/dist/chunks/{execFileNoThrow-DResQRvR.js → execFileNoThrow-D244NytW.js} +1 -1
  125. package/dist/chunks/execSyncWrapper-CCMQShK-.js +1 -0
  126. package/dist/chunks/exit-CFJR3NfE.js +1 -0
  127. package/dist/chunks/extra-usage-CjaHpu8y.js +1 -0
  128. package/dist/chunks/extra-usage-D1Y-3OWQ.js +1 -0
  129. package/dist/chunks/{extra-usage-core-Dh4rVUI-.js → extra-usage-core-B6ga8Rni.js} +1 -1
  130. package/dist/chunks/{extra-usage-noninteractive-D4Ya5KPm.js → extra-usage-noninteractive-Dc9AndId.js} +1 -1
  131. package/dist/chunks/{extraUsage-DtWi8E78.js → extraUsage-2DwLEr26.js} +1 -1
  132. package/dist/chunks/extractMemories-C3qrwpu2.js +1 -0
  133. package/dist/chunks/{fast-DkUxqWhE.js → fast-CW_NsL0x.js} +1 -1
  134. package/dist/chunks/fast-D3CPmUX4.js +1 -0
  135. package/dist/chunks/{feedback-Cn7Sbqxa.js → feedback-BpRorTAC.js} +1 -1
  136. package/dist/chunks/{file-BZriE-XU.js → file-DcZWPH2V.js} +5 -5
  137. package/dist/chunks/firstPartyEventLogger-CuUiNdj8.js +5 -0
  138. package/dist/chunks/firstPartyEventLogger-DPUQnc6J.js +1 -0
  139. package/dist/chunks/{flushGate-ebqQZF1t.js → flushGate-BltVae97.js} +1 -1
  140. package/dist/chunks/gemini-YyIxfveQ.js +1 -0
  141. package/dist/chunks/generateRecap-tx4wLIkI.js +1 -0
  142. package/dist/chunks/{generateSessionName-DEAw5x_h.js → generateSessionName-BkDigIN8.js} +1 -1
  143. package/dist/chunks/{genericProcessUtils-DO7Fy0RJ.js → genericProcessUtils-CdQTApYX.js} +1 -1
  144. package/dist/chunks/git-CbcnOf0E.js +1 -0
  145. package/dist/chunks/git-Do0wJvux.js +6 -0
  146. package/dist/chunks/{githubRepoPathMapping-Tt-LdYFZ.js → githubRepoPathMapping-C4umZ1oC.js} +1 -1
  147. package/dist/chunks/{goal-DCaI1NPN.js → goal-DZrD4puM.js} +3 -3
  148. package/dist/chunks/{grok-CKlngG3b.js → grok-BZf7W_hL.js} +1 -1
  149. package/dist/chunks/{grove-DSWe6psK.js → grove-CFBPplP6.js} +2 -2
  150. package/dist/chunks/{heapdump-OVbV05On.js → heapdump-DWc3Z2NO.js} +5 -5
  151. package/dist/chunks/{help-CRtX5VX9.js → help-pap9jNUJ.js} +1 -1
  152. package/dist/chunks/{hooks-tpf90xd5.js → hooks-Bmat0L6A.js} +2 -2
  153. package/dist/chunks/hooks-cCAzfabs.js +1 -0
  154. package/dist/chunks/{hostGuard-t7QfbijF.js → hostGuard-C5xydXZI.js} +1 -1
  155. package/dist/chunks/inboundAttachments-DZgSqDwY.js +1 -0
  156. package/dist/chunks/inboundAttachments-DkfNHtF9.js +1 -0
  157. package/dist/chunks/initReplBridge-myzllvlk.js +1 -0
  158. package/dist/chunks/install-D4jmHjmk.js +1 -0
  159. package/dist/chunks/{instrumentation--Sx0y1Gk.js → instrumentation-Nqgm1SMw.js} +6 -6
  160. package/dist/chunks/{job-D7B35Usp.js → job-CT9bcgPb.js} +1 -1
  161. package/dist/chunks/jwtUtils-DE2GPUcx.js +1 -0
  162. package/dist/chunks/keybindings-DETOn3qJ.js +2 -0
  163. package/dist/chunks/{language-8Rnu_qxl.js → language-BA5WprZv.js} +1 -1
  164. package/dist/chunks/language-BbaOTWm3.js +1 -0
  165. package/dist/chunks/{launchAgentsPlatform-CNPkOVzu.js → launchAgentsPlatform-CuRQgd2Q.js} +1 -1
  166. package/dist/chunks/{launchLocalMemory-BxmDhENs.js → launchLocalMemory-CRMqifzn.js} +2 -2
  167. package/dist/chunks/{launchLocalVault-DQlTGA-g.js → launchLocalVault-DlKX_oDE.js} +3 -3
  168. package/dist/chunks/{launchMemoryStores-EYAwxI8i.js → launchMemoryStores-CN0ecWpP.js} +1 -1
  169. package/dist/chunks/{launchOnboarding-CTu5Zf4E.js → launchOnboarding-DTdUA_wE.js} +1 -1
  170. package/dist/chunks/{launchSchedule-CeHHSvO7.js → launchSchedule-psiSLmTA.js} +1 -1
  171. package/dist/chunks/{launchSkillStore-Bqh2Fru2.js → launchSkillStore-CQQ00Ads.js} +1 -1
  172. package/dist/chunks/{launchTeleport-Crc3XVZX.js → launchTeleport-CXFRPVMR.js} +1 -1
  173. package/dist/chunks/{launchVault-BHLgpth_.js → launchVault-Dn6jq0Rc.js} +1 -1
  174. package/dist/chunks/{v4-jw6qOKwQ.js → lazySchema-DcIJE_0i.js} +1 -1
  175. package/dist/chunks/{loadAgentsDir-ZQwvbURI.js → loadAgentsDir-BURvZNN6.js} +685 -683
  176. package/dist/chunks/loadAgentsDir-Db9UTm45.js +1 -0
  177. package/dist/chunks/loadPluginHooks-C9A9oS-w.js +1 -0
  178. package/dist/chunks/{localSearch-H0LchlTi.js → localSearch-D2Rs8wQP.js} +1 -1
  179. package/dist/chunks/localSearch-hBh1ATr2.js +1 -0
  180. package/dist/chunks/{log-Duzb4o6h.js → log-BMCygSzM.js} +1 -1
  181. package/dist/chunks/{logoV2Utils-5lcUu53m.js → logoV2Utils-DN9nzdX-.js} +1 -1
  182. package/dist/chunks/{magicDocs-D1FIPmYg.js → magicDocs-DIeTcwAA.js} +3 -3
  183. package/dist/chunks/{main-B8XtFN2P.js → main-CI54PZrG.js} +78 -78
  184. package/dist/chunks/{main-CR7cXdgy.js → main-D862LI_d.js} +2 -2
  185. package/dist/chunks/{mappers-DKU4RgE3.js → mappers-Q_Z3Kjo-.js} +1 -1
  186. package/dist/chunks/mcp-CtbhGaLC.js +2 -0
  187. package/dist/chunks/mcp-DMacvhqZ.js +1 -0
  188. package/dist/chunks/mcp-RvwPC7FB.js +6 -0
  189. package/dist/chunks/{memoize-DgMjqLtn.js → memoize-B0zhbT8Z.js} +1 -1
  190. package/dist/chunks/{memory-D-Q62bJ7.js → memory-BPN8gW7n.js} +1 -1
  191. package/dist/chunks/{mode-DFZgqKBd.js → mode-Jl_Boaym.js} +2 -2
  192. package/dist/chunks/model-BIVmcl_N.js +1 -0
  193. package/dist/chunks/{model-fDWtIRVr.js → model-CWBwPvTH.js} +1 -1
  194. package/dist/chunks/model-DlVpqR0P.js +1 -0
  195. package/dist/chunks/nativeInstaller-8arnRiUO.js +1 -0
  196. package/dist/chunks/{onChangeAppState-DaQ0R9Tw.js → onChangeAppState-DBantDJ6.js} +1 -1
  197. package/dist/chunks/{openai-DNS0-ivj.js → openai-yin1iDG8.js} +3 -3
  198. package/dist/chunks/{overageCreditGrant-qHN3tnp2.js → overageCreditGrant-CN_sVURL.js} +1 -1
  199. package/dist/chunks/{panelCall-BvKpHquo.js → panelCall-CPKC6VR5.js} +1 -1
  200. package/dist/chunks/parser-Bf6iasPV.js +1 -0
  201. package/dist/chunks/{parser-TYEkLFgh.js → parser-DFwaTGf7.js} +1 -1
  202. package/dist/chunks/{partition-Cv11dD5P.js → partition-CW0BJ881.js} +1 -1
  203. package/dist/chunks/{passes-DQdM2Ssq.js → passes-DOm9ukdK.js} +1 -1
  204. package/dist/chunks/{path-Cu_AKqg6.js → path-D5U-tm91.js} +1 -1
  205. package/dist/chunks/permissions-CxDJ__l6.js +3 -0
  206. package/dist/chunks/pidLock-C69HNTTb.js +3 -0
  207. package/dist/chunks/{pipeTransport-7GIO6GCA.js → pipeTransport-CqCnc-Ys.js} +1 -1
  208. package/dist/chunks/{plan-D8dQDl8W.js → plan-B0rEs32a.js} +1 -1
  209. package/dist/chunks/{platform-B5dCGT8t.js → platform-BrYefG_2.js} +1 -1
  210. package/dist/chunks/{plugin-w8MqsKHn.js → plugin-BSEMgcGu.js} +1 -1
  211. package/dist/chunks/{pluginAutoupdate-7FFHzSRz.js → pluginAutoupdate-CTByPD8J.js} +1 -1
  212. package/dist/chunks/pluginBlocklist-mogKaK0p.js +1 -0
  213. package/dist/chunks/pluginCliCommands-DQQ7C7kk.js +1 -0
  214. package/dist/chunks/{pluginFlagging-_WUQP3Lq.js → pluginFlagging-mHNff1t9.js} +1 -1
  215. package/dist/chunks/pluginOperations-JEedVzfS.js +2 -0
  216. package/dist/chunks/pluginStartupCheck-D7ts2V3p.js +1 -0
  217. package/dist/chunks/{pluginStartupCheck-BelpzwZI.js → pluginStartupCheck-RscVZDi4.js} +1 -1
  218. package/dist/chunks/plugins-Cr03lISA.js +4 -0
  219. package/dist/chunks/policyLimits-DWtLyJ4n.js +1 -0
  220. package/dist/chunks/pollConfig-DH2oCtFS.js +1 -0
  221. package/dist/chunks/{poor-D3T_8wwf.js → poor-DekfGNT7.js} +1 -1
  222. package/dist/chunks/poorMode-AE4WNYZo.js +1 -0
  223. package/dist/chunks/{poorMode-BqyVuBu-.js → poorMode-CtcqaiwD.js} +1 -1
  224. package/dist/chunks/print-CZUmAzmt.js +23 -0
  225. package/dist/chunks/{privacy-settings-D5zxu4Aa.js → privacy-settings-CwJ1H8Ua.js} +1 -1
  226. package/dist/chunks/processBashCommand-aKNneP2u.js +1 -0
  227. package/dist/chunks/processSlashCommand-BcPnWNxZ.js +5 -0
  228. package/dist/chunks/prompt-CIyhCdkE.js +1 -0
  229. package/dist/chunks/prompt-DNDgGM9q.js +139 -0
  230. package/dist/chunks/prompt-DRhjinu2.js +1 -0
  231. package/dist/chunks/{promptEditor-D6HzjcMS.js → promptEditor-DMJyosKj.js} +2 -2
  232. package/dist/chunks/{protocolHandler-BXlx1N7v.js → protocolHandler-z2zxAtB1.js} +4 -4
  233. package/dist/chunks/{proxy-CHnxhNZI.js → proxy-CRN7jYIi.js} +3 -3
  234. package/dist/chunks/{rate-limit-options-1hc-RyNR.js → rate-limit-options--Y3oF1g0.js} +1 -1
  235. package/dist/chunks/rcDebugLog-DoL1FpGJ.js +11 -0
  236. package/dist/chunks/reconciler-CJcSh6xo.js +4 -0
  237. package/dist/chunks/{referral-Cu9bEOFE.js → referral-UKJv23_5.js} +1 -1
  238. package/dist/chunks/{refresh-vJbxW4a1.js → refresh-ul_i5R1a.js} +1 -1
  239. package/dist/chunks/{registerProtocol-B_XbLDQO.js → registerProtocol-CukLQuxJ.js} +3 -3
  240. package/dist/chunks/{release-notes-CavWoMQR.js → release-notes-CGv_6MMt.js} +1 -1
  241. package/dist/chunks/{releaseNotes-Di6OaHF7.js → releaseNotes-BKZNuDLD.js} +2 -2
  242. package/dist/chunks/{reload-plugins-ofeLn07p.js → reload-plugins-2W11dpLQ.js} +1 -1
  243. package/dist/chunks/{remote-env-dXzHAuD6.js → remote-env-D9xsoBfx.js} +1 -1
  244. package/dist/chunks/remoteBridgeCore-asY9JAXU.js +1 -0
  245. package/dist/chunks/remoteManagedSettings-Bxo3bv1U.js +1 -0
  246. package/dist/chunks/{rename-CtjP0lop.js → rename-CHsHMWpO.js} +1 -1
  247. package/dist/chunks/{renderOptions-DOXmueQV.js → renderOptions-BUJB9nAm.js} +1 -1
  248. package/dist/chunks/{resume-C5h5JvY1.js → resume-NduOaghx.js} +2 -2
  249. package/dist/chunks/{ripgrep-BN_g-F7X.js → ripgrep-BXmXjAzA.js} +1 -1
  250. package/dist/chunks/ripgrep-BfIpz5uC.js +1 -0
  251. package/dist/chunks/{runtimeObserver-B93v1AxE.js → runtimeObserver-BXbjibFk.js} +4 -4
  252. package/dist/chunks/{runtimeObserver-DOZFrqJu.js → runtimeObserver-Bo80nWQf.js} +1 -1
  253. package/dist/chunks/sandbox-adapter-DDfVl_2V.js +1 -0
  254. package/dist/chunks/{sandbox-toggle-TiLGFwaZ.js → sandbox-toggle-C-WCDRN4.js} +1 -1
  255. package/dist/chunks/searchExtraTools-BHWzsbNO.js +1 -0
  256. package/dist/chunks/{session-v9tKHhU9.js → session-pDd13-wE.js} +2 -2
  257. package/dist/chunks/{sessionDiscovery-4byQKOnc.js → sessionDiscovery-CSUnpsCy.js} +1 -1
  258. package/dist/chunks/sessionFileAccessHooks-BZvxeufx.js +1 -0
  259. package/dist/chunks/sessionMemory-CAmpw2yb.js +1 -0
  260. package/dist/chunks/sessionMemory-DT0IkiA1.js +1 -0
  261. package/dist/chunks/sessionMemoryUtils-B4kGNH4j.js +1 -0
  262. package/dist/chunks/{sessionObserver-OgY9BUP4.js → sessionObserver-Ur7PqKl_.js} +1 -1
  263. package/dist/chunks/sessionObserver-oIkwTidC.js +1 -0
  264. package/dist/chunks/sessionStorage-DqARUj0K.js +1 -0
  265. package/dist/chunks/sessionTitle-pWMaI79N.js +14 -0
  266. package/dist/chunks/{sessionTracing-BBxhPccY.js → sessionTracing-CCPRzOvy.js} +3 -3
  267. package/dist/chunks/settings-DfWP5y6X.js +19 -0
  268. package/dist/chunks/settingsSync-D_4P3Esd.js +1 -0
  269. package/dist/chunks/setup-JHvhWKh9.js +3 -0
  270. package/dist/chunks/{shadowedRuleDetection-DDSOFi1W.js → shadowedRuleDetection-Chi3afMR.js} +1 -1
  271. package/dist/chunks/{shellQuote-yXoC_y5m.js → shellQuote-DkSy9MYE.js} +1 -1
  272. package/dist/chunks/{sideQuestion-CAiA6jAf.js → sideQuestion-D03MXdE2.js} +1 -1
  273. package/dist/chunks/sinks-B4_pw0Gb.js +2 -0
  274. package/dist/chunks/sinks-Cro1Y8C2.js +1 -0
  275. package/dist/chunks/{skill-learning-Dx1o4mMo.js → skill-learning-7ZQF5JvA.js} +1 -1
  276. package/dist/chunks/skillChangeDetector-uCaYrerZ.js +1 -0
  277. package/dist/chunks/{skillGapStore-BV_6qzxU.js → skillGapStore-BND2Lq0Z.js} +1 -1
  278. package/dist/chunks/{skillGapStore-Zvqiyxds.js → skillGapStore-z3LP64O-.js} +2 -2
  279. package/dist/chunks/{skillGenerator-jJQDphQ8.js → skillGenerator-DaNb-yKH.js} +2 -2
  280. package/dist/chunks/skillLearning-GZxYPlyl.js +1 -0
  281. package/dist/chunks/{skillLearning-BTT3_yGc.js → skillLearning-rMX1bSBa.js} +1 -1
  282. package/dist/chunks/{skillPanel-OW2M6SZr.js → skillPanel-q7GPSQ6_.js} +3 -3
  283. package/dist/chunks/{skillSearchPanel-C0Y56c5N.js → skillSearchPanel-oj8gy1ZL.js} +4 -4
  284. package/dist/chunks/{skills-BFsyLP33.js → skills-QqbeFP0s.js} +1 -1
  285. package/dist/chunks/startupProfiler-DIWVcO4e.js +1 -0
  286. package/dist/chunks/{startupProfiler-BquH_Yqm.js → startupProfiler-xa3NmN7Z.js} +2 -2
  287. package/dist/chunks/{stats-CrPmPT8f.js → stats-DmFubHpI.js} +1 -1
  288. package/dist/chunks/{status-BO5J2MAe.js → status-BEIsLmfj.js} +1 -1
  289. package/dist/chunks/{status-DHJbK4pV.js → status-DW3Z_7xa.js} +2 -2
  290. package/dist/chunks/{statusNoticeHelpers-CqeUBySi.js → statusNoticeHelpers-CaHS8xig.js} +1 -1
  291. package/dist/chunks/{stickers-BLFmyHZV.js → stickers-D5teCKMN.js} +1 -1
  292. package/dist/chunks/{stringUtils-D_g2L6A4.js → stringUtils-DGLPkqJ4.js} +1 -1
  293. package/dist/chunks/{tag-M2AEtXjW.js → tag-CRg93Die.js} +2 -2
  294. package/dist/chunks/{tasks-CoOs_Qkj.js → tasks-BEohK1ij.js} +1 -1
  295. package/dist/chunks/teleport-4Srg5vcP.js +1 -0
  296. package/dist/chunks/{templateJobs-Cl50Qw0s.js → templateJobs-DYP1fjYU.js} +1 -1
  297. package/dist/chunks/terminalSetup-BNs9nLbT.js +33 -0
  298. package/dist/chunks/{terminalSetup-Bdh9K31U.js → terminalSetup-RDKg8dVa.js} +1 -1
  299. package/dist/chunks/{theme-DgCIr0jU.js → theme-kNL4kl_3.js} +1 -1
  300. package/dist/chunks/{thinkback-ERCQ86CR.js → thinkback-gV-sKkMM.js} +1 -1
  301. package/dist/chunks/thinkback-hc5eJ9ul.js +1 -0
  302. package/dist/chunks/thinkback-play-BpWMqbgJ.js +1 -0
  303. package/dist/chunks/{tmux-ZZk68JBq.js → tmux-BY7IdQ1f.js} +1 -1
  304. package/dist/chunks/{toolEventObserver-9-5Ne25Z.js → toolEventObserver-C98uraqD.js} +1 -1
  305. package/dist/chunks/{toolEventObserver-9XCQXiMx.js → toolEventObserver-ar5NDa0M.js} +1 -1
  306. package/dist/chunks/toolPool-CNYKDRq5.js +1 -0
  307. package/dist/chunks/trustedDevice-0dehm9qz.js +1 -0
  308. package/dist/chunks/trustedDevice-BBKUhCCL.js +1 -0
  309. package/dist/chunks/{types-Cnorfsss.js → types-C-MRCL8J.js} +3 -3
  310. package/dist/chunks/udsClient-BuCtv7dN.js +1 -0
  311. package/dist/chunks/{ultrareviewCommand-BMBHepdu.js → ultrareviewCommand-yXlFsMnv.js} +2 -2
  312. package/dist/chunks/{undercover-DDgIKbO5.js → undercover-BTIRVF1t.js} +1 -1
  313. package/dist/chunks/undercover-CG_269xD.js +1 -0
  314. package/dist/chunks/{up-D6bNw_tT.js → up-BHkC97_C.js} +1 -1
  315. package/dist/chunks/updateCCB-B2xAJ4Nr.js +11 -0
  316. package/dist/chunks/upgrade-J7lKLkD2.js +1 -0
  317. package/dist/chunks/{upgrade-BN20nsCH.js → upgrade-yNl7EO4e.js} +1 -1
  318. package/dist/chunks/upload-BWVIHmMB.js +1 -0
  319. package/dist/chunks/{upstreamproxy-os5rw0Vg.js → upstreamproxy-DyR_eXO8.js} +4 -4
  320. package/dist/chunks/{usage-D_sqm8us.js → usage-B2PbCUMi.js} +1 -1
  321. package/dist/chunks/usage-Ck8Cu45g.js +1 -0
  322. package/dist/chunks/{useExitOnCtrlCDWithKeybindings-vzUoPY51.js → useExitOnCtrlCDWithKeybindings-CV4GZ-sq.js} +1 -1
  323. package/dist/chunks/useMainLoopModel-CO4yBjRM.js +1 -0
  324. package/dist/chunks/useManagePlugins-BzFKIDrD.js +1 -0
  325. package/dist/chunks/{useMergedTools-Bb4XbC9d.js → useMergedTools-CRLWSGDl.js} +1 -1
  326. package/dist/chunks/{useSearchInput-B1UOjxAI.js → useSearchInput-BzGq4t7t.js} +1 -1
  327. package/dist/chunks/{useSettingsErrors-BLbvu4--.js → useSettingsErrors-CSemUjj1.js} +1 -1
  328. package/dist/chunks/{util-CxlfALM4.js → util-BnReK81E.js} +1 -1
  329. package/dist/chunks/validatePlugin-D6sPqea1.js +1 -0
  330. package/dist/chunks/{vim-DLWBHwVM.js → vim-C0KTnJJs.js} +1 -1
  331. package/dist/chunks/{which-sEFQXpaX.js → which-CKQnSouy.js} +1 -1
  332. package/dist/chunks/windowsPaths-9pEkw0oV.js +1 -0
  333. package/dist/chunks/windowsPaths-DtapVxOo.js +1 -0
  334. package/dist/chunks/{workSecret-DvniZR71.js → workSecret-CNWiR2uQ.js} +1 -1
  335. package/dist/chunks/{workerRegistry-CFnGtb3L.js → workerRegistry-CUXbNyL9.js} +1 -1
  336. package/dist/chunks/worktree-89ttIVxH.js +1 -0
  337. package/dist/cli.js +1 -1
  338. package/package.json +5 -10
  339. package/dist/chunks/ApproveApiKey-CQsQdQBC.js +0 -1
  340. package/dist/chunks/BackgroundTasksDialog-AiVi-1pI.js +0 -2
  341. package/dist/chunks/ClaudeMdExternalIncludesDialog-DUu6iRJk.js +0 -1
  342. package/dist/chunks/ConsoleOAuthFlow-DVTPwR5I.js +0 -1
  343. package/dist/chunks/Doctor-BXhz8eUa.js +0 -3
  344. package/dist/chunks/Doctor-D75dsEyb.js +0 -1
  345. package/dist/chunks/ExitFlow-B1XNACQP.js +0 -2
  346. package/dist/chunks/Feedback-Cvz80lAn.js +0 -2
  347. package/dist/chunks/Grove-B7hhBvFw.js +0 -1
  348. package/dist/chunks/MCPConnectionManager-BLfKm4H2.js +0 -1
  349. package/dist/chunks/MessageSelector-DmKtBYX9.js +0 -3
  350. package/dist/chunks/Messages-CaFdI1kk.js +0 -11
  351. package/dist/chunks/PluginSettings-0FSNch8O.js +0 -17
  352. package/dist/chunks/QueryEngine-WYDWzQuY.js +0 -1
  353. package/dist/chunks/REPL-vV_jzAVx.js +0 -1
  354. package/dist/chunks/ResumeConversation-g_JyOWbl.js +0 -1
  355. package/dist/chunks/SearchExtraToolsTool-Daedym7_.js +0 -1
  356. package/dist/chunks/Settings-DUXA-qac.js +0 -2
  357. package/dist/chunks/TrustDialog-CdZS9t-T.js +0 -1
  358. package/dist/chunks/ajv-5vMo9UcX.js +0 -8
  359. package/dist/chunks/api-CLLIHLpn.js +0 -1
  360. package/dist/chunks/api-DMpNA1s8.js +0 -1
  361. package/dist/chunks/asciicast-BIr75_x9.js +0 -1
  362. package/dist/chunks/auth-Ce0jllLf.js +0 -1
  363. package/dist/chunks/auth-DV3P8Qup.js +0 -1
  364. package/dist/chunks/auth-DpFfHy1W.js +0 -15
  365. package/dist/chunks/backgroundHousekeeping-BycL9lOe.js +0 -1
  366. package/dist/chunks/bg-H849G7Sc.js +0 -1
  367. package/dist/chunks/bridgeConfig-CcANVX0P.js +0 -1
  368. package/dist/chunks/bridgeEnabled-Cn-u7P4_.js +0 -1
  369. package/dist/chunks/bridgeMain-CtgVyLjI.js +0 -68
  370. package/dist/chunks/bridgeMain-Dh0gWRVo.js +0 -1
  371. package/dist/chunks/bridgeMessaging-CRG6HqUb.js +0 -1
  372. package/dist/chunks/bridgePointer-Cug5fQ3e.js +0 -1
  373. package/dist/chunks/caches-C3NINY3K.js +0 -1
  374. package/dist/chunks/ccrClient-CRXGlUCe.js +0 -1
  375. package/dist/chunks/client-AnWHs0gW.js +0 -1
  376. package/dist/chunks/commands-DsKH3ogN.js +0 -1
  377. package/dist/chunks/commitAttribution-D7NrwLhc.js +0 -1
  378. package/dist/chunks/compact-BhWCO-oD.js +0 -2
  379. package/dist/chunks/completionCache-C9zlWBRz.js +0 -1
  380. package/dist/chunks/config-662VDD70.js +0 -3
  381. package/dist/chunks/config-CUN8YbOa.js +0 -1
  382. package/dist/chunks/config-DklnhNx1.js +0 -1
  383. package/dist/chunks/config-Wk3svGdH.js +0 -1
  384. package/dist/chunks/context-noninteractive-C3dICmA9.js +0 -1
  385. package/dist/chunks/conversation-CooSju3g.js +0 -1
  386. package/dist/chunks/conversation-DLLIOKYV.js +0 -1
  387. package/dist/chunks/createSession-CVG8SiEm.js +0 -1
  388. package/dist/chunks/crossProjectResume-DiKJb83I.js +0 -40
  389. package/dist/chunks/datadog-BE6D_6m0.js +0 -1
  390. package/dist/chunks/datadog-C69i7cfI.js +0 -1
  391. package/dist/chunks/debug-8kgDrUfj.js +0 -1
  392. package/dist/chunks/detectRepository-_Kj817Vi.js +0 -1
  393. package/dist/chunks/doctor-DEz8BHAz.js +0 -1
  394. package/dist/chunks/envLessBridgeConfig-3kCrKZl7.js +0 -1
  395. package/dist/chunks/envLessBridgeConfig-BfgXw47_.js +0 -1
  396. package/dist/chunks/esm-C8Zkk1Ux.js +0 -1
  397. package/dist/chunks/execSyncWrapper-CWxMek26.js +0 -1
  398. package/dist/chunks/exit-cyepwuyy.js +0 -1
  399. package/dist/chunks/extra-usage-DlFeNGQD.js +0 -1
  400. package/dist/chunks/extra-usage-nRFfBiXh.js +0 -1
  401. package/dist/chunks/extractMemories-BqN8fWZ5.js +0 -1
  402. package/dist/chunks/fast-NvqW2-t1.js +0 -1
  403. package/dist/chunks/firstPartyEventLogger-AhXYSrkP.js +0 -1
  404. package/dist/chunks/firstPartyEventLogger-BQYrBdvD.js +0 -5
  405. package/dist/chunks/gemini-Sr_00TsL.js +0 -1
  406. package/dist/chunks/generateRecap-5d4l_ODy.js +0 -1
  407. package/dist/chunks/git-Cc1jAz6r.js +0 -1
  408. package/dist/chunks/git-Cgc8X5l2.js +0 -6
  409. package/dist/chunks/hooks-DvtnNoYE.js +0 -1
  410. package/dist/chunks/inboundAttachments-BZ6MKpxd.js +0 -1
  411. package/dist/chunks/inboundAttachments-D5Ux2kCl.js +0 -1
  412. package/dist/chunks/initReplBridge-CjuO6in6.js +0 -1
  413. package/dist/chunks/install-DqpM2brU.js +0 -1
  414. package/dist/chunks/jwtUtils-CqXPjf-a.js +0 -1
  415. package/dist/chunks/keybindings-JvAmBpLt.js +0 -2
  416. package/dist/chunks/language-DaxZe0Xw.js +0 -1
  417. package/dist/chunks/lazySchema-uxlVVNM1.js +0 -1
  418. package/dist/chunks/loadAgentsDir-D7npVvsj.js +0 -1
  419. package/dist/chunks/loadPluginHooks-CaKvZVZI.js +0 -1
  420. package/dist/chunks/localSearch-BU5oulbF.js +0 -1
  421. package/dist/chunks/mcp-B06Mqsur.js +0 -6
  422. package/dist/chunks/mcp-C0AjA07u.js +0 -1
  423. package/dist/chunks/mcp-ghioDl7W.js +0 -2
  424. package/dist/chunks/metadata-CIx5CsoY.js +0 -1
  425. package/dist/chunks/model-BgrLt7P7.js +0 -1
  426. package/dist/chunks/model-aVc5c3Lz.js +0 -1
  427. package/dist/chunks/nativeInstaller-DKe1pWoL.js +0 -1
  428. package/dist/chunks/parser-Bj3gOqFv.js +0 -1
  429. package/dist/chunks/permissions-DB_2mmCl.js +0 -3
  430. package/dist/chunks/pidLock-DchmaAK6.js +0 -3
  431. package/dist/chunks/pluginBlocklist-Cw_l-yal.js +0 -1
  432. package/dist/chunks/pluginCliCommands-BtYWRxhS.js +0 -1
  433. package/dist/chunks/pluginOperations-BOkST1qE.js +0 -2
  434. package/dist/chunks/pluginStartupCheck-XBLJZZys.js +0 -1
  435. package/dist/chunks/plugins-6px6K1fh.js +0 -4
  436. package/dist/chunks/policyLimits-C07tQ0Wr.js +0 -1
  437. package/dist/chunks/pollConfig-C2Ac8WMU.js +0 -1
  438. package/dist/chunks/poorMode-BdBDiOFD.js +0 -1
  439. package/dist/chunks/print-DcQSuK0v.js +0 -23
  440. package/dist/chunks/processBashCommand-CEqA4QZi.js +0 -1
  441. package/dist/chunks/processSlashCommand-DMpFk59M.js +0 -5
  442. package/dist/chunks/prompt-CKvoqUC3.js +0 -1
  443. package/dist/chunks/prompt-aXZPR3q8.js +0 -1
  444. package/dist/chunks/prompt-wys9CwDo.js +0 -132
  445. package/dist/chunks/rcDebugLog-CivJaJ3V.js +0 -11
  446. package/dist/chunks/reconciler-BKX4jh34.js +0 -4
  447. package/dist/chunks/remoteBridgeCore-CmwkjiTK.js +0 -1
  448. package/dist/chunks/remoteManagedSettings-Co-CxR67.js +0 -1
  449. package/dist/chunks/ripgrep-hOjrgpMp.js +0 -1
  450. package/dist/chunks/sandbox-adapter-CO5GuywY.js +0 -1
  451. package/dist/chunks/searchExtraTools-CXZJU2Kv.js +0 -1
  452. package/dist/chunks/sessionFileAccessHooks-BUyIQVzL.js +0 -1
  453. package/dist/chunks/sessionMemory-ZsxCLHYd.js +0 -1
  454. package/dist/chunks/sessionMemory-e6YpTUhW.js +0 -1
  455. package/dist/chunks/sessionMemoryUtils-BD_dqyYB.js +0 -1
  456. package/dist/chunks/sessionObserver-DNItJztR.js +0 -1
  457. package/dist/chunks/sessionStorage-xvxpRETp.js +0 -1
  458. package/dist/chunks/sessionTitle-Bph6GO4F.js +0 -14
  459. package/dist/chunks/settings-BhvhCpVh.js +0 -19
  460. package/dist/chunks/settingsSync-D2B5K4BT.js +0 -1
  461. package/dist/chunks/setup-CEnNEK6Z.js +0 -3
  462. package/dist/chunks/sink-CyKOf5TT.js +0 -1
  463. package/dist/chunks/sink-DxPJ4khU.js +0 -1
  464. package/dist/chunks/sinks-BNo3DvxO.js +0 -2
  465. package/dist/chunks/sinks-CHgtwDha.js +0 -1
  466. package/dist/chunks/skillChangeDetector-BRBCwQ2w.js +0 -1
  467. package/dist/chunks/skillLearning-BH7EAU1m.js +0 -1
  468. package/dist/chunks/src-xRRBgNzF.js +0 -25
  469. package/dist/chunks/startupProfiler-CYCH-qos.js +0 -1
  470. package/dist/chunks/stdio-4S7b8Uhx.js +0 -1
  471. package/dist/chunks/stdio-W_Kokrkh.js +0 -3
  472. package/dist/chunks/teleport-DjIgQeBB.js +0 -1
  473. package/dist/chunks/terminalSetup-nvS3KCDG.js +0 -33
  474. package/dist/chunks/thinkback-BSv_fvbV.js +0 -1
  475. package/dist/chunks/thinkback-play-DNB0IWYt.js +0 -1
  476. package/dist/chunks/toolPool-uQKZRMKg.js +0 -1
  477. package/dist/chunks/trustedDevice-0ej6e3nx.js +0 -1
  478. package/dist/chunks/trustedDevice-nqhuw4tp.js +0 -1
  479. package/dist/chunks/udsClient-CiFj4M_h.js +0 -1
  480. package/dist/chunks/undercover-6UUO38fQ.js +0 -1
  481. package/dist/chunks/updateCCB-B-OlpLjA.js +0 -11
  482. package/dist/chunks/upgrade-DYqlCH80.js +0 -1
  483. package/dist/chunks/upload-BQGByiXE.js +0 -1
  484. package/dist/chunks/usage-DolSCKGi.js +0 -1
  485. package/dist/chunks/useMainLoopModel-cZd8EKo5.js +0 -1
  486. package/dist/chunks/useManagePlugins-DgGZBvXV.js +0 -1
  487. package/dist/chunks/validatePlugin-n8a4W_jI.js +0 -1
  488. package/dist/chunks/windowsPaths-BLevJOlm.js +0 -1
  489. package/dist/chunks/windowsPaths-N_YmYY6k.js +0 -1
  490. package/dist/chunks/worktree-Dr_WzlXs.js +0 -1
@@ -1,4 +1,4 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{i as t,o as n,t as r}from"./cliLaunch-BJ9o-rIV.js";import{a as i,i as a,n as o,r as s,t as c}from"./state-Cn_m2NOf.js";import{resolve as l}from"path";async function u(e){let t=e[0]||`status`;switch(t){case`start`:await h(e.slice(1));break;case`stop`:await p();break;case`status`:case`ps`:await f();break;case`bg`:await(await import(`./bg-H849G7Sc.js`)).handleBgStart(e.slice(1));break;case`attach`:await(await import(`./bg-H849G7Sc.js`)).attachHandler(e[1]);break;case`logs`:await(await import(`./bg-H849G7Sc.js`)).logsHandler(e[1]);break;case`kill`:await(await import(`./bg-H849G7Sc.js`)).killHandler(e[1]);break;case`--help`:case`-h`:case`help`:d();break;default:console.error(`Unknown daemon subcommand: ${t}`),d(),process.exitCode=1}}function d(){console.log(`
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{i as t,o as n,t as r}from"./cliLaunch-BkPAatcs.js";import{a as i,i as a,n as o,r as s,t as c}from"./state-Cn_m2NOf.js";import{resolve as l}from"path";async function u(e){let t=e[0]||`status`;switch(t){case`start`:await h(e.slice(1));break;case`stop`:await p();break;case`status`:case`ps`:await f();break;case`bg`:await(await import(`./bg-B0iMGM9C.js`)).handleBgStart(e.slice(1));break;case`attach`:await(await import(`./bg-B0iMGM9C.js`)).attachHandler(e[1]);break;case`logs`:await(await import(`./bg-B0iMGM9C.js`)).logsHandler(e[1]);break;case`kill`:await(await import(`./bg-B0iMGM9C.js`)).killHandler(e[1]);break;case`--help`:case`-h`:case`help`:d();break;default:console.error(`Unknown daemon subcommand: ${t}`),d(),process.exitCode=1}}function d(){console.log(`
2
2
  Work Mate Daemon — background process management
3
3
 
4
4
  USAGE
@@ -26,6 +26,6 @@ OPTIONS (for start)
26
26
  --name <name> Session name
27
27
  -h, --help Show this help
28
28
  `)}async function f(){let e=o();switch(console.log(`=== Daemon Supervisor ===`),e.status){case`running`:{let t=e.state;console.log(` Status: running`),console.log(` PID: ${t.pid}`),console.log(` CWD: ${t.cwd}`),console.log(` Started: ${t.startedAt}`),console.log(` Workers: ${t.workerKinds.join(`, `)}`);break}case`stopped`:console.log(` Status: stopped`);break;case`stale`:console.log(` Status: stale (cleaned up)`);break}console.log(`
29
- === Background Sessions ===`),await(await import(`./bg-H849G7Sc.js`)).psHandler([])}async function p(){let e=o();if(e.status===`stopped`){console.log(`daemon is not running`);return}if(e.status===`stale`){console.log(`daemon was stale (cleaned up)`);return}console.log(`stopping daemon (PID: ${e.state.pid})...`),await a()?console.log(`daemon stopped`):console.log(`daemon could not be stopped (may have already exited)`)}function m(e){let t={};for(let n=0;n<e.length;n++){let r=e[n];r===`--dir`&&n+1<e.length?t.dir=l(e[++n]):r.startsWith(`--dir=`)?t.dir=l(r.slice(6)):r===`--spawn-mode`&&n+1<e.length?t.spawnMode=e[++n]:r.startsWith(`--spawn-mode=`)?t.spawnMode=r.slice(13):r===`--capacity`&&n+1<e.length?t.capacity=e[++n]:r.startsWith(`--capacity=`)?t.capacity=r.slice(11):r===`--permission-mode`&&n+1<e.length?t.permissionMode=e[++n]:r.startsWith(`--permission-mode=`)?t.permissionMode=r.slice(18):r===`--sandbox`?t.sandbox=`1`:r===`--name`&&n+1<e.length?t.name=e[++n]:r.startsWith(`--name=`)&&(t.name=r.slice(7))}return t}async function h(e){let t=m(e),n=t.dir||l(`.`);console.log(`[daemon] supervisor starting in ${n}`);let r=[{kind:`remoteControl`,process:null,backoffMs:v,failureCount:0,parked:!1,lastStartTime:0,restartTimer:null}];i({pid:process.pid,cwd:n,startedAt:new Date().toISOString(),workerKinds:r.map(e=>e.kind),lastStatus:`running`});let a=new AbortController,o=()=>{console.log(`[daemon] supervisor shutting down...`),a.abort(),s();for(let e of r)e.restartTimer&&(clearTimeout(e.restartTimer),e.restartTimer=null),e.process&&!e.process.killed&&e.process.kill(`SIGTERM`)};process.on(`SIGTERM`,o),process.on(`SIGINT`,o);for(let e of r)a.signal.aborted||g(e,n,t,a.signal);await new Promise(e=>{if(a.signal.aborted){e();return}a.signal.addEventListener(`abort`,()=>e(),{once:!0})}),await Promise.all(r.filter(e=>e.process&&e.process.exitCode===null).map(e=>new Promise(t=>{if(!e.process||e.process.exitCode!==null){t();return}let n=null;e.process.on(`exit`,()=>{n&&(clearTimeout(n),n=null),t()}),n=setTimeout(()=>{e.process&&e.process.exitCode===null&&e.process.kill(`SIGKILL`),t()},3e4),n.unref?.()}))),console.log(`[daemon] supervisor stopped`)}function g(e,t,i,a){if(a.aborted||e.parked)return;e.lastStartTime=Date.now();let o={...process.env,DAEMON_WORKER_DIR:t,DAEMON_WORKER_NAME:i.name,DAEMON_WORKER_SPAWN_MODE:i.spawnMode||`same-dir`,DAEMON_WORKER_CAPACITY:i.capacity||`4`,DAEMON_WORKER_PERMISSION:i.permissionMode,DAEMON_WORKER_SANDBOX:i.sandbox||`0`,DAEMON_WORKER_CREATE_SESSION:`1`,CLAUDE_CODE_SESSION_KIND:`daemon-worker`};console.log(`[daemon] spawning worker '${e.kind}'`);let s=n(r([`--daemon-worker=${e.kind}`],{env:o}),{cwd:t,stdio:[`ignore`,`pipe`,`pipe`]});e.process=s,s.stdout?.on(`data`,e=>{let t=e.toString().trimEnd().split(`
29
+ === Background Sessions ===`),await(await import(`./bg-B0iMGM9C.js`)).psHandler([])}async function p(){let e=o();if(e.status===`stopped`){console.log(`daemon is not running`);return}if(e.status===`stale`){console.log(`daemon was stale (cleaned up)`);return}console.log(`stopping daemon (PID: ${e.state.pid})...`),await a()?console.log(`daemon stopped`):console.log(`daemon could not be stopped (may have already exited)`)}function m(e){let t={};for(let n=0;n<e.length;n++){let r=e[n];r===`--dir`&&n+1<e.length?t.dir=l(e[++n]):r.startsWith(`--dir=`)?t.dir=l(r.slice(6)):r===`--spawn-mode`&&n+1<e.length?t.spawnMode=e[++n]:r.startsWith(`--spawn-mode=`)?t.spawnMode=r.slice(13):r===`--capacity`&&n+1<e.length?t.capacity=e[++n]:r.startsWith(`--capacity=`)?t.capacity=r.slice(11):r===`--permission-mode`&&n+1<e.length?t.permissionMode=e[++n]:r.startsWith(`--permission-mode=`)?t.permissionMode=r.slice(18):r===`--sandbox`?t.sandbox=`1`:r===`--name`&&n+1<e.length?t.name=e[++n]:r.startsWith(`--name=`)&&(t.name=r.slice(7))}return t}async function h(e){let t=m(e),n=t.dir||l(`.`);console.log(`[daemon] supervisor starting in ${n}`);let r=[{kind:`remoteControl`,process:null,backoffMs:v,failureCount:0,parked:!1,lastStartTime:0,restartTimer:null}];i({pid:process.pid,cwd:n,startedAt:new Date().toISOString(),workerKinds:r.map(e=>e.kind),lastStatus:`running`});let a=new AbortController,o=()=>{console.log(`[daemon] supervisor shutting down...`),a.abort(),s();for(let e of r)e.restartTimer&&(clearTimeout(e.restartTimer),e.restartTimer=null),e.process&&!e.process.killed&&e.process.kill(`SIGTERM`)};process.on(`SIGTERM`,o),process.on(`SIGINT`,o);for(let e of r)a.signal.aborted||g(e,n,t,a.signal);await new Promise(e=>{if(a.signal.aborted){e();return}a.signal.addEventListener(`abort`,()=>e(),{once:!0})}),await Promise.all(r.filter(e=>e.process&&e.process.exitCode===null).map(e=>new Promise(t=>{if(!e.process||e.process.exitCode!==null){t();return}let n=null;e.process.on(`exit`,()=>{n&&(clearTimeout(n),n=null),t()}),n=setTimeout(()=>{e.process&&e.process.exitCode===null&&e.process.kill(`SIGKILL`),t()},3e4),n.unref?.()}))),console.log(`[daemon] supervisor stopped`)}function g(e,t,i,a){if(a.aborted||e.parked)return;e.lastStartTime=Date.now();let o={...process.env,DAEMON_WORKER_DIR:t,DAEMON_WORKER_NAME:i.name,DAEMON_WORKER_SPAWN_MODE:i.spawnMode||`same-dir`,DAEMON_WORKER_CAPACITY:i.capacity||`4`,DAEMON_WORKER_PERMISSION:i.permissionMode,DAEMON_WORKER_SANDBOX:i.sandbox||`0`,DAEMON_WORKER_CREATE_SESSION:`1`,CLAUDE_CODE_SESSION_KIND:`daemon-worker`};console.log(`[daemon] spawning worker '${e.kind}'`);let s=n(r([`--daemon-worker=${e.kind}`],{env:o}),{cwd:t,stdio:[`ignore`,`pipe`,`pipe`]});e.process=s,s.stdout?.on(`data`,e=>{let t=e.toString().trimEnd().split(`
30
30
  `);for(let e of t)console.log(` ${e}`)}),s.stderr?.on(`data`,e=>{let t=e.toString().trimEnd().split(`
31
31
  `);for(let e of t)console.error(` ${e}`)}),s.on(`exit`,(n,r)=>{if(e.process=null,!a.aborted){if(n===_){console.error(`[daemon] worker '${e.kind}' exited with permanent error — parking`),e.parked=!0;return}if(Date.now()-e.lastStartTime<1e4){if(e.failureCount++,e.failureCount>=x){console.error(`[daemon] worker '${e.kind}' failed ${e.failureCount} times rapidly — parking`),e.parked=!0;return}}else e.failureCount=0,e.backoffMs=v;console.log(`[daemon] worker '${e.kind}' exited (code=${n}, signal=${r}), restarting in ${e.backoffMs}ms`),e.restartTimer=setTimeout(()=>{e.restartTimer=null,!a.aborted&&!e.parked&&g(e,t,i,a)},e.backoffMs),e.restartTimer.unref?.(),e.backoffMs=Math.min(e.backoffMs*b,y)}})}var _,v,y,b,x;e((()=>{t(),c(),_=78,v=2e3,y=12e4,b=2,x=5}))();export{u as daemonMain};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Kr as t,qr as n}from"./src-CDCSSo0U2.js";import{en as r,ht as i}from"./state-ix0xIunV.js";import{My as a,Oy as o,po as s,zo as c}from"./loadAgentsDir-ZQwvbURI.js";import{Y as l}from"./log-Duzb4o6h.js";import{Vt as u}from"./prompt-wys9CwDo.js";import{randomUUID as d}from"crypto";function f(e){return e.flatMap(e=>{if(!e)return[];switch(e.type){case`assistant`:return[{type:`assistant`,message:e.message,uuid:e.uuid,requestId:void 0,timestamp:new Date().toISOString()}];case`user`:return[{type:`user`,message:e.message,uuid:e.uuid??d(),timestamp:e.timestamp??new Date().toISOString(),isMeta:e.isSynthetic}];default:return[]}})}function p(e){let t=e.preservedSegment;return{trigger:e.trigger,pre_tokens:e.preTokens,...t&&{preserved_segment:{head_uuid:t.headUuid,anchor_uuid:t.anchorUuid,tail_uuid:t.tailUuid}}}}function m(e){let t=e,n=t.preserved_segment;return{trigger:t.trigger,preTokens:t.pre_tokens,...n&&{preservedSegment:{headUuid:n.head_uuid,anchorUuid:n.anchor_uuid,tailUuid:n.tail_uuid}}}}function h(e){return e.flatMap(e=>{if(!e)return[];switch(e.type){case`assistant`:return[{type:`assistant`,message:v(e),session_id:i(),parent_tool_use_id:null,uuid:e.uuid,error:e?.error}];case`user`:return[{type:`user`,message:e.message,session_id:i(),parent_tool_use_id:null,uuid:e.uuid,timestamp:e.timestamp,isSynthetic:e.isMeta||e.isVisibleInTranscriptOnly,...e.toolUseResult===void 0?{}:{tool_use_result:e.toolUseResult}}];case`system`:return e.subtype===`compact_boundary`&&e.compactMetadata?[{type:`system`,subtype:`compact_boundary`,session_id:i(),uuid:e.uuid,compact_metadata:p(e.compactMetadata)}]:e.subtype===`local_command`&&(e.content.includes(`<local-command-stdout>`)||e.content.includes(`<local-command-stderr>`))?[g(e.content,e.uuid)]:[];default:return[]}})}function g(e,t){let r=s({content:n(e).replace(/<local-command-stdout>([\s\S]*?)<\/local-command-stdout>/,`$1`).replace(/<local-command-stderr>([\s\S]*?)<\/local-command-stderr>/,`$1`).trim()});return{type:`assistant`,content:r.message?.content,message:r.message,parent_tool_use_id:null,session_id:i(),uuid:t}}function _(e){if(e)return{type:`rate_limit`,status:e.status,...e.resetsAt!==void 0&&{resetsAt:e.resetsAt},...e.rateLimitType!==void 0&&{rateLimitType:e.rateLimitType},...e.utilization!==void 0&&{utilization:e.utilization},...e.overageStatus!==void 0&&{overageStatus:e.overageStatus},...e.overageResetsAt!==void 0&&{overageResetsAt:e.overageResetsAt},...e.overageDisabledReason!==void 0&&{overageDisabledReason:e.overageDisabledReason},...e.isUsingOverage!==void 0&&{isUsingOverage:e.isUsingOverage},...e.surpassedThreshold!==void 0&&{surpassedThreshold:e.surpassedThreshold}}}function v(e){let t=e.message.content;if(!Array.isArray(t))return e.message;let n=t.map(e=>{if(e.type!==`tool_use`)return e;if(e.name===`ExitPlanMode`){let t=o();if(t)return{...e,input:{...e.input,plan:t}}}return e});return{...e.message,content:n}}var y=e((()=>{r(),l(),u(),t(),c(),a()}));export{p as a,f as i,y as n,h as o,g as r,_ as s,m as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Kr as t,qr as n}from"./src-CDCSSo0U2.js";import{en as r,ht as i}from"./state-ix0xIunV.js";import{fb as a,gb as o,po as s,zo as c}from"./loadAgentsDir-BURvZNN6.js";import{Y as l}from"./log-BMCygSzM.js";import{Ut as u}from"./prompt-DNDgGM9q.js";import{randomUUID as d}from"crypto";function f(e){return e.flatMap(e=>{if(!e)return[];switch(e.type){case`assistant`:return[{type:`assistant`,message:e.message,uuid:e.uuid,requestId:void 0,timestamp:new Date().toISOString()}];case`user`:return[{type:`user`,message:e.message,uuid:e.uuid??d(),timestamp:e.timestamp??new Date().toISOString(),isMeta:e.isSynthetic}];default:return[]}})}function p(e){let t=e.preservedSegment;return{trigger:e.trigger,pre_tokens:e.preTokens,...t&&{preserved_segment:{head_uuid:t.headUuid,anchor_uuid:t.anchorUuid,tail_uuid:t.tailUuid}}}}function m(e){let t=e,n=t.preserved_segment;return{trigger:t.trigger,preTokens:t.pre_tokens,...n&&{preservedSegment:{headUuid:n.head_uuid,anchorUuid:n.anchor_uuid,tailUuid:n.tail_uuid}}}}function h(e){return e.flatMap(e=>{if(!e)return[];switch(e.type){case`assistant`:return[{type:`assistant`,message:v(e),session_id:i(),parent_tool_use_id:null,uuid:e.uuid,error:e?.error}];case`user`:return[{type:`user`,message:e.message,session_id:i(),parent_tool_use_id:null,uuid:e.uuid,timestamp:e.timestamp,isSynthetic:e.isMeta||e.isVisibleInTranscriptOnly,...e.toolUseResult===void 0?{}:{tool_use_result:e.toolUseResult}}];case`system`:return e.subtype===`compact_boundary`&&e.compactMetadata?[{type:`system`,subtype:`compact_boundary`,session_id:i(),uuid:e.uuid,compact_metadata:p(e.compactMetadata)}]:e.subtype===`local_command`&&(e.content.includes(`<local-command-stdout>`)||e.content.includes(`<local-command-stderr>`))?[g(e.content,e.uuid)]:[];default:return[]}})}function g(e,t){let r=s({content:n(e).replace(/<local-command-stdout>([\s\S]*?)<\/local-command-stdout>/,`$1`).replace(/<local-command-stderr>([\s\S]*?)<\/local-command-stderr>/,`$1`).trim()});return{type:`assistant`,content:r.message?.content,message:r.message,parent_tool_use_id:null,session_id:i(),uuid:t}}function _(e){if(e)return{type:`rate_limit`,status:e.status,...e.resetsAt!==void 0&&{resetsAt:e.resetsAt},...e.rateLimitType!==void 0&&{rateLimitType:e.rateLimitType},...e.utilization!==void 0&&{utilization:e.utilization},...e.overageStatus!==void 0&&{overageStatus:e.overageStatus},...e.overageResetsAt!==void 0&&{overageResetsAt:e.overageResetsAt},...e.overageDisabledReason!==void 0&&{overageDisabledReason:e.overageDisabledReason},...e.isUsingOverage!==void 0&&{isUsingOverage:e.isUsingOverage},...e.surpassedThreshold!==void 0&&{surpassedThreshold:e.surpassedThreshold}}}function v(e){let t=e.message.content;if(!Array.isArray(t))return e.message;let n=t.map(e=>{if(e.type!==`tool_use`)return e;if(e.name===`ExitPlanMode`){let t=a();if(t)return{...e,input:{...e.input,plan:t}}}return e});return{...e.message,content:n}}var y=e((()=>{r(),l(),u(),t(),c(),o()}));export{p as a,f as i,y as n,h as o,g as r,_ as s,m as t};
@@ -0,0 +1,2 @@
1
+ import{$v as e,Av as t,Bv as n,Dv as r,Ev as i,Fv as a,G as o,Gp as s,Gv as c,Hw as l,Ia as u,Iv as d,Jv as f,Kv as p,La as m,Lv as h,Mv as g,Nv as ee,Ov as te,Pv as ne,Qv as _,Rd as v,Rv as y,Uv as b,Uw as x,Vv as S,W as C,Wp as w,Xu as T,Xv as E,Yu as D,Yv as O,Zv as k,ay as A,cw as j,cy as M,jv as N,kv as P,lw as F,ly as I,nl as L,ny as R,oy as z,po as B,qv as re,ry as V,sy as H,tl as U,zd as W,zo as G,zv as K}from"./loadAgentsDir-BURvZNN6.js";import{S as q,w as J}from"./debug-BrXObCdR.js";import{o as Y,s as X}from"./log-BMCygSzM.js";import{_ as ie,u as ae}from"./model-BIVmcl_N.js";import{Cn as oe,Tn as se,wn as Z}from"./prompt-DNDgGM9q.js";import{a as Q,o as ce}from"./fileStateCache-DDW5toIs.js";import $ from"node:process";H(),a(),ee(),A();var le=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},K,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},b,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)}};A(),N();var ue=class extends ne{constructor(e,t){super(t),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(_.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 g,this.setRequestHandler(re,e=>this._oninitialize(e)),this.setNotificationHandler(f,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(V,async(e,t)=>{let n=t.sessionId||t.requestInfo?.headers[`mcp-session-id`]||void 0,{level:r}=e.params,i=_.safeParse(r);return i.success&&this._loggingLevels.set(n,i.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new le(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw Error(`Cannot register capabilities after connecting to transport`);this._capabilities=d(this._capabilities,e)}setRequestHandler(t,n){let r=z(t)?.method;if(!r)throw Error(`Schema is missing a method literal`);let i;if(M(r)){let e=r;i=e._zod?.def?.value??e.value}else{let e=r;i=e._def?.value??e.value}if(typeof i!=`string`)throw Error(`Schema method literal must be a string`);return i===`tools/call`?super.setRequestHandler(t,async(t,r)=>{let i=I(h,t);if(!i.success){let t=i.error instanceof Error?i.error.message:String(i.error);throw new e(p.InvalidParams,`Invalid tools/call request: ${t}`)}let{params:a}=i.data,o=await Promise.resolve(n(t,r));if(a.task){let t=I(S,o);if(!t.success){let n=t.error instanceof Error?t.error.message:String(t.error);throw new e(p.InvalidParams,`Invalid task creation result: ${n}`)}return t.data}let s=I(y,o);if(!s.success){let t=s.error instanceof Error?s.error.message:String(s.error);throw new e(p.InvalidParams,`Invalid tools/call result: ${t}`)}return s.data}):super.setRequestHandler(t,n)}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){P(this._clientCapabilities?.tasks?.requests,e,`Client`)}assertTaskHandlerCapability(e){this._capabilities&&t(this._capabilities.tasks?.requests,e,`Server`)}async _oninitialize(e){let t=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:R.includes(t)?t:O,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`},c)}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},n,t):this.request({method:`sampling/createMessage`,params:e},K,t)}async elicitInput(t,n){switch(t.mode??`form`){case`url`:{if(!this._clientCapabilities?.elicitation?.url)throw Error(`Client does not support url elicitation.`);let e=t;return this.request({method:`elicitation/create`,params:e},b,n)}case`form`:{if(!this._clientCapabilities?.elicitation?.form)throw Error(`Client does not support form elicitation.`);let r=t.mode===`form`?t:{...t,mode:`form`},i=await this.request({method:`elicitation/create`,params:r},b,n);if(i.action===`accept`&&i.content&&r.requestedSchema)try{let t=this._jsonSchemaValidator.getValidator(r.requestedSchema)(i.content);if(!t.valid)throw new e(p.InvalidParams,`Elicitation response content does not match requested schema: ${t.errorMessage}`)}catch(t){throw t instanceof e?t:new e(p.InternalError,`Error validating elicitation response: ${t instanceof Error?t.message:String(t)}`)}return i}}}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},E,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`})}};r();var de=class{constructor(e=$.stdin,t=$.stdout){this._stdin=e,this._stdout=t,this._readBuffer=new i,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=te(e);this._stdout.write(n)?t():this._stdout.once(`drain`,t)})}};A(),F(),u(),se(),T(),x(),ce(),Y(),G(),ie(),o(),w(),q(),W(),U();var fe=[m];async function pe(e,t,n){let r=Q(100);s(e);let i=new ue({name:`claude/tengu`,version:`0.0.4`},{capabilities:{tools:{}}});i.setRequestHandler(k,async()=>{let e=Z(),t=D(e);return{tools:await Promise.all(t.map(async n=>{let r;if(n.outputSchema){let e=L(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:L(n.inputSchema),outputSchema:r}}))}}),i.setRequestHandler(h,async({params:{name:e,arguments:i}})=>{let a=D(Z()),o=oe(a,e);if(!o)throw Error(`Tool ${e} not found`);let s={abortController:l(),options:{commands:fe,tools:a,mainLoopModel:ae(),thinkingConfig:{type:`disabled`},mcpClients:[],mcpResources:{},isNonInteractiveSession:!0,debug:t,verbose:n,agentDefinitions:{activeAgents:[],allAgents:[]}},getAppState:()=>j(),setAppState:()=>{},messages:[],readFileState:r,setInProgressToolUseIDs:()=>{},setResponseLength:()=>{},updateFileHistoryState:()=>{},updateAttributionState:()=>{}};try{if(!o.isEnabled())throw Error(`Tool ${e} is not enabled`);let t=await o.validateInput?.(i??{},s);if(t&&!t.result)throw Error(`Tool ${e} input is invalid: ${`message`in t?t.message:String(t)}`);let n=await o.call(i??{},s,C,B({content:[]}));return{content:[{type:`text`,text:typeof n==`string`?n:J(n.data)}]}}catch(e){return X(e),{isError:!0,content:[{type:`text`,text:(e instanceof Error?v(e):[String(e)]).filter(Boolean).join(`
2
+ `).trim()||`Error`}]}}});async function a(){let e=new de;await i.connect(e)}return await a()}export{pe as startMCPServer};
@@ -0,0 +1 @@
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./figures-5ThXQEtq.js";import{D as i,Gt as a,H as o,I as s,Lt as c,P as l,T as u,Wt as d,fi as f,j as p,t as m,y as h}from"./src-CDCSSo0U2.js";import{t as g}from"./jsx-runtime-Bb4Xn-E0.js";import{$g as _,D_ as v,Ex as y,JS as b,Lb as x,M_ as S,Qg as C,Tx as w,YS as T,_x as E,b_ as D,gx as O,i_ as k,k_ as A,qS as j,r_ as M,zb as ee}from"./loadAgentsDir-BURvZNN6.js";import{a as te,o as ne}from"./debug-BrXObCdR.js";import{l as re,n as ie,o as N}from"./stringUtils-DGLPkqJ4.js";import{D as ae,O as oe}from"./rcDebugLog-DoL1FpGJ.js";import{u as P}from"./referral-UKJv23_5.js";import{i as se,n as F,r as ce}from"./MCPConnectionManager-CaBvO7NB.js";import{n as le,t as ue}from"./McpParsingWarnings-Cc6FWyU4.js";import{a as de,c as I,i as L,l as fe,n as pe,o as R,r as me,s as he,t as ge,u as z}from"./PluginSettings-DUxj_oAg.js";function _e({agentServer:e,onCancel:t,onComplete:n}){let[a]=o(),[f,m]=(0,B.useState)(!1),[g,_]=(0,B.useState)(null),[v,y]=(0,B.useState)(null),b=(0,B.useRef)(null);(0,B.useEffect)(()=>()=>b.current?.abort(),[]),d(`confirm:no`,(0,B.useCallback)(()=>{f&&(b.current?.abort(),b.current=null,m(!1),y(null))},[f]),{context:`Confirmation`,isActive:f});let S=(0,B.useCallback)(async()=>{if(!e.needsAuth||!e.url)return;m(!0),_(null);let t=new AbortController;b.current=t;try{let r={type:e.transport,url:e.url};await k(e.name,r,y,t.signal),n?.(`Authentication successful for ${e.name}. The server will connect when the agent runs.`)}catch(e){e instanceof Error&&!(e instanceof C)&&_(e.message)}finally{m(!1),b.current=null}},[e,n]),T=ie(String(e.name));if(f)return(0,V.jsxs)(s,{flexDirection:`column`,gap:1,padding:1,children:[(0,V.jsxs)(l,{color:`claude`,children:[`Authenticating with `,e.name,`…`]}),(0,V.jsxs)(s,{children:[(0,V.jsx)(x,{}),(0,V.jsx)(l,{children:` A browser window will open for authentication`})]}),v&&(0,V.jsxs)(s,{flexDirection:`column`,children:[(0,V.jsx)(l,{dimColor:!0,children:`If your browser doesn't open automatically, copy this URL manually:`}),(0,V.jsx)(c,{url:v})]}),(0,V.jsx)(s,{marginLeft:3,children:(0,V.jsxs)(l,{dimColor:!0,children:[`Return here after authenticating in your browser.`,` `,(0,V.jsx)(w,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]})})]});let D=[];return e.needsAuth&&D.push({label:e.isAuthenticated?`Re-authenticate`:`Authenticate`,value:`auth`}),D.push({label:`Back`,value:`back`}),(0,V.jsxs)(h,{title:`${T} MCP Server`,subtitle:`agent-only`,onCancel:t,inputGuide:e=>e.pending?(0,V.jsxs)(l,{children:[`Press `,e.keyName,` again to exit`]}):(0,V.jsxs)(u,{children:[(0,V.jsx)(i,{shortcut:`↑↓`,action:`navigate`}),(0,V.jsx)(i,{shortcut:`Enter`,action:`confirm`}),(0,V.jsx)(w,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]}),children:[(0,V.jsxs)(s,{flexDirection:`column`,gap:0,children:[(0,V.jsxs)(s,{children:[(0,V.jsx)(l,{bold:!0,children:`Type: `}),(0,V.jsx)(l,{dimColor:!0,children:e.transport})]}),e.url&&(0,V.jsxs)(s,{children:[(0,V.jsx)(l,{bold:!0,children:`URL: `}),(0,V.jsx)(l,{dimColor:!0,children:e.url})]}),e.command&&(0,V.jsxs)(s,{children:[(0,V.jsx)(l,{bold:!0,children:`Command: `}),(0,V.jsx)(l,{dimColor:!0,children:e.command})]}),(0,V.jsxs)(s,{children:[(0,V.jsx)(l,{bold:!0,children:`Used by: `}),(0,V.jsx)(l,{dimColor:!0,children:e.sourceAgents.join(`, `)})]}),(0,V.jsxs)(s,{marginTop:1,children:[(0,V.jsx)(l,{bold:!0,children:`Status: `}),(0,V.jsxs)(l,{children:[p(`inactive`,a)(r.radioOff),` not connected (agent-only)`]})]}),e.needsAuth&&(0,V.jsxs)(s,{children:[(0,V.jsx)(l,{bold:!0,children:`Auth: `}),e.isAuthenticated?(0,V.jsxs)(l,{children:[p(`success`,a)(r.tick),` authenticated`]}):(0,V.jsxs)(l,{children:[p(`warning`,a)(r.triangleUpOutline),` may need authentication`]})]})]}),(0,V.jsx)(s,{children:(0,V.jsx)(l,{dimColor:!0,children:`This server connects only when running the agent.`})}),g&&(0,V.jsx)(s,{children:(0,V.jsxs)(l,{color:`error`,children:[`Error: `,g]})}),(0,V.jsx)(s,{children:(0,V.jsx)(E,{options:D,onChange:async e=>{switch(e){case`auth`:await S();break;case`back`:t();break}},onCancel:t})})]})}var B,V,H=e((()=>{n(),B=t(f(),1),m(),P(),M(),N(),y(),O(),ee(),V=g()}));function U(e){switch(e){case`project`:return{label:`Project MCPs`,path:D(e)};case`user`:return{label:`User MCPs`,path:D(e)};case`local`:return{label:`Local MCPs`,path:D(e)};case`enterprise`:return{label:`Enterprise MCPs`};case`dynamic`:return{label:`Built-in MCPs`,path:`always available`};default:return{label:e}}}function ve(e){let t=new Map;for(let n of e){let e=n.scope;t.has(e)||t.set(e,[]),t.get(e).push(n)}for(let[,e]of t)e.sort((e,t)=>e.name.localeCompare(t.name));return t}function ye({servers:e,agentServers:t=[],onSelectServer:n,onSelectAgentServer:d,onComplete:f}){let[m]=o(),[g,_]=(0,W.useState)(0),v=W.useMemo(()=>ve(e.filter(e=>e.client.config.type!==`claudeai-proxy`)),[e]),y=W.useMemo(()=>e.filter(e=>e.client.config.type===`claudeai-proxy`).sort((e,t)=>e.name.localeCompare(t.name)),[e]),b=W.useMemo(()=>(v.get(`dynamic`)??[]).sort((e,t)=>e.name.localeCompare(t.name)),[v]),x=U(`dynamic`),S=W.useMemo(()=>{let e=[];for(let t of K){let n=v.get(t)??[];for(let t of n)e.push({type:`server`,server:t})}for(let t of y)e.push({type:`server`,server:t});for(let n of t)e.push({type:`agent-server`,agentServer:n});for(let t of b)e.push({type:`server`,server:t});return e},[v,y,t,b]),C=(0,W.useCallback)(()=>{f(`MCP dialog dismissed`,{display:`system`})},[f]);a({"confirm:previous":()=>_(e=>e===0?S.length-1:e-1),"confirm:next":()=>_(e=>e===S.length-1?0:e+1),"confirm:yes":(0,W.useCallback)(()=>{let e=S[g];e&&(e.type===`server`?n(e.server):e.type===`agent-server`&&d&&d(e.agentServer))},[S,g,n,d]),"confirm:no":C},{context:`Confirmation`});let T=e=>S.findIndex(t=>t.type===`server`&&t.server===e),E=e=>S.findIndex(t=>t.type===`agent-server`&&t.agentServer===e),D=ne(),O=e.some(e=>e.client.type===`failed`);if(e.length===0&&t.length===0)return null;let k=e=>{let t=T(e),n=g===t,i=``,a=``;if(e.client.type===`disabled`)i=p(`inactive`,m)(r.radioOff),a=`disabled`;else if(e.client.type===`connected`)i=p(`success`,m)(r.tick),a=`connected`;else if(e.client.type===`pending`){i=p(`inactive`,m)(r.radioOff);let{reconnectAttempt:t,maxReconnectAttempts:n}=e.client;a=t&&n?`reconnecting (${t}/${n})…`:`connecting…`}else e.client.type===`needs-auth`?(i=p(`warning`,m)(r.triangleUpOutline),a=`needs authentication`):(i=p(`error`,m)(r.cross),a=`failed`);return(0,G.jsxs)(s,{children:[(0,G.jsx)(l,{color:n?`suggestion`:void 0,children:n?`${r.pointer} `:` `}),(0,G.jsx)(l,{color:n?`suggestion`:void 0,children:e.name}),(0,G.jsxs)(l,{dimColor:!n,children:[` · `,i,` `]}),(0,G.jsx)(l,{dimColor:!n,children:a})]},`${e.name}-${t}`)},A=e=>{let t=E(e),n=g===t,i=e.needsAuth?p(`warning`,m)(r.triangleUpOutline):p(`inactive`,m)(r.radioOff),a=e.needsAuth?`may need auth`:`agent-only`;return(0,G.jsxs)(s,{children:[(0,G.jsx)(l,{color:n?`suggestion`:void 0,children:n?`${r.pointer} `:` `}),(0,G.jsx)(l,{color:n?`suggestion`:void 0,children:e.name}),(0,G.jsxs)(l,{dimColor:!n,children:[` · `,i,` `]}),(0,G.jsx)(l,{dimColor:!n,children:a})]},`agent-${e.name}-${t}`)},j=e.length+t.length;return(0,G.jsxs)(s,{flexDirection:`column`,children:[(0,G.jsx)(ue,{}),(0,G.jsx)(h,{title:`Manage MCP servers`,subtitle:`${j} ${re(j,`server`)}`,onCancel:C,hideInputGuide:!0,children:(0,G.jsxs)(s,{flexDirection:`column`,children:[K.map(e=>{let t=v.get(e);if(!t||t.length===0)return null;let n=U(e);return(0,G.jsxs)(s,{flexDirection:`column`,marginBottom:1,children:[(0,G.jsxs)(s,{paddingLeft:2,children:[(0,G.jsx)(l,{bold:!0,children:n.label}),n.path&&(0,G.jsxs)(l,{dimColor:!0,children:[` (`,n.path,`)`]})]}),t.map(e=>k(e))]},e)}),y.length>0&&(0,G.jsxs)(s,{flexDirection:`column`,marginBottom:1,children:[(0,G.jsx)(s,{paddingLeft:2,children:(0,G.jsx)(l,{bold:!0,children:`claude.ai`})}),y.map(e=>k(e))]}),t.length>0&&(0,G.jsxs)(s,{flexDirection:`column`,marginBottom:1,children:[(0,G.jsx)(s,{paddingLeft:2,children:(0,G.jsx)(l,{bold:!0,children:`Agent MCPs`})}),[...new Set(t.flatMap(e=>e.sourceAgents))].map(e=>(0,G.jsxs)(s,{flexDirection:`column`,marginTop:1,children:[(0,G.jsx)(s,{paddingLeft:2,children:(0,G.jsxs)(l,{dimColor:!0,children:[`@`,e]})}),t.filter(t=>t.sourceAgents.includes(e)).map(e=>A(e))]},e))]}),b.length>0&&(0,G.jsxs)(s,{flexDirection:`column`,marginBottom:1,children:[(0,G.jsxs)(s,{paddingLeft:2,children:[(0,G.jsx)(l,{bold:!0,children:x.label}),x.path&&(0,G.jsxs)(l,{dimColor:!0,children:[` (`,x.path,`)`]})]}),b.map(e=>k(e))]}),(0,G.jsxs)(s,{flexDirection:`column`,children:[O&&(0,G.jsx)(l,{dimColor:!0,children:D?`※ Error logs shown inline with --debug`:`※ Run claude --debug to see error logs`}),(0,G.jsxs)(l,{dimColor:!0,children:[(0,G.jsx)(c,{url:`https://code.claude.com/docs/en/mcp`,children:`https://code.claude.com/docs/en/mcp`}),` for help`]})]})]})}),(0,G.jsx)(s,{paddingX:1,children:(0,G.jsx)(l,{dimColor:!0,italic:!0,children:(0,G.jsxs)(u,{children:[(0,G.jsx)(i,{shortcut:`↑↓`,action:`navigate`}),(0,G.jsx)(i,{shortcut:`Enter`,action:`confirm`}),(0,G.jsx)(w,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})})]})}var W,G,K,be=e((()=>{n(),W=t(f(),1),m(),P(),S(),te(),N(),y(),le(),G=g(),K=[`project`,`local`,`user`,`enterprise`]}));function xe({serverName:e,onComplete:t}){let[n]=o(),i=T(),a=ce(),[c,u]=(0,q.useState)(!0),[d,f]=(0,q.useState)(null);return(0,q.useEffect)(()=>{async function n(){try{if(!i.getState().mcp.clients.find(t=>t.name===e)){f(`MCP server "${e}" not found`),u(!1),t(`MCP server "${e}" not found`);return}switch((await a(e)).client.type){case`connected`:u(!1),t(`Successfully reconnected to ${e}`);break;case`needs-auth`:f(`${e} requires authentication`),u(!1),t(`${e} requires authentication. Use /mcp to authenticate.`);break;case`pending`:case`failed`:case`disabled`:f(`Failed to reconnect to ${e}`),u(!1),t(`Failed to reconnect to ${e}`);break}}catch(e){let n=e instanceof Error?e.message:String(e);f(n),u(!1),t(`Error: ${n}`)}}n()},[e,a,i,t]),c?(0,J.jsxs)(s,{flexDirection:`column`,gap:1,padding:1,children:[(0,J.jsxs)(l,{color:`text`,children:[`Reconnecting to `,(0,J.jsx)(l,{bold:!0,children:e})]}),(0,J.jsxs)(s,{children:[(0,J.jsx)(x,{}),(0,J.jsx)(l,{children:` Establishing connection to MCP server`})]})]}):d?(0,J.jsxs)(s,{flexDirection:`column`,gap:1,padding:1,children:[(0,J.jsxs)(s,{children:[(0,J.jsxs)(l,{children:[p(`error`,n)(r.cross),` `]}),(0,J.jsxs)(l,{color:`error`,children:[`Failed to reconnect to `,e]})]}),(0,J.jsxs)(l,{dimColor:!0,children:[`Error: `,d]})]}):null}var q,J,Y=e((()=>{n(),q=t(f(),1),m(),F(),j(),ee(),J=g()}));function Se({onComplete:e}){let t=b(e=>e.mcp),n=b(e=>e.agentDefinitions),r=t.clients,[i,a]=X.useState({type:`list`}),[o,s]=X.useState([]),c=(0,X.useMemo)(()=>v(n.allAgents),[n.allAgents]),l=X.useMemo(()=>r.filter(e=>e.name!==`ide`).sort((e,t)=>e.name.localeCompare(t.name)),[r]);switch(X.useEffect(()=>{let e=!1;async function n(){let n=await Promise.all(l.map(async e=>{let n=e.config.scope,r=e.config.type===`sse`,i=e.config.type===`http`,a=e.config.type===`claudeai-proxy`,o;if(r||i){let n=await new _(e.name,e.config).tokens(),r=ae()!==null&&e.type===`connected`,i=e.type===`connected`&&A(t.tools,e.name).length>0;o=!!n||r||i}let s={name:e.name,client:e,scope:n};return a?{...s,transport:`claudeai-proxy`,isAuthenticated:!1,config:e.config}:r?{...s,transport:`sse`,isAuthenticated:o,config:e.config}:i?{...s,transport:`http`,isAuthenticated:o,config:e.config}:{...s,transport:`stdio`,config:e.config}}));e||s(n)}return n(),()=>{e=!0}},[l,t.tools]),(0,X.useEffect)(()=>{o.length===0&&l.length>0||o.length===0&&c.length===0&&e("No MCP servers configured. Please run /doctor if this is unexpected. Otherwise, run `claude mcp --help` or visit https://code.claude.com/docs/en/mcp to learn more.")},[o.length,l.length,c.length,e]),i.type){case`list`:return(0,Z.jsx)(ye,{servers:o,agentServers:c,onSelectServer:e=>a({type:`server-menu`,server:e}),onSelectAgentServer:e=>a({type:`agent-server-menu`,agentServer:e}),onComplete:e,defaultTab:i.defaultTab});case`server-menu`:{let n=A(t.tools,i.server.name),r=i.server.transport===`claudeai-proxy`?`claude.ai`:`Work Mate`;return i.server.transport===`stdio`?(0,Z.jsx)(he,{server:i.server,serverToolsCount:n.length,onViewTools:()=>a({type:`server-tools`,server:i.server}),onCancel:()=>a({type:`list`,defaultTab:r}),onComplete:e}):(0,Z.jsx)(fe,{server:i.server,serverToolsCount:n.length,onViewTools:()=>a({type:`server-tools`,server:i.server}),onCancel:()=>a({type:`list`,defaultTab:r}),onComplete:e})}case`server-tools`:return(0,Z.jsx)(me,{server:i.server,onSelectTool:(e,t)=>a({type:`server-tool-detail`,server:i.server,toolIndex:t}),onBack:()=>a({type:`server-menu`,server:i.server})});case`server-tool-detail`:{let e=A(t.tools,i.server.name)[i.toolIndex];return e?(0,Z.jsx)(de,{tool:e,server:i.server,onBack:()=>a({type:`server-tools`,server:i.server})}):(a({type:`server-tools`,server:i.server}),null)}case`agent-server-menu`:return(0,Z.jsx)(_e,{agentServer:i.agentServer,onCancel:()=>a({type:`list`,defaultTab:`Agents`}),onComplete:e})}}var X,Z,Ce=e((()=>{X=t(f(),1),M(),S(),j(),oe(),H(),be(),z(),I(),R(),L(),Z=g()})),we=e((()=>{H(),be(),Y(),z(),Ce(),I(),R(),L()}));function Te({action:e,target:t,onComplete:n}){let r=b(e=>e.mcp.clients),i=se(),a=(0,Q.useRef)(!1);return(0,Q.useEffect)(()=>{if(a.current)return;a.current=!0;let o=e===`enable`,s=r.filter(e=>e.name!==`ide`),c=t===`all`?s.filter(e=>o?e.type===`disabled`:e.type!==`disabled`):s.filter(e=>e.name===t);if(c.length===0){n(t===`all`?`All MCP servers are already ${o?`enabled`:`disabled`}`:`MCP server "${t}" not found`);return}for(let e of c)i(e.name);n(t===`all`?`${o?`Enabled`:`Disabled`} ${c.length} MCP server(s)`:`MCP server "${t}" ${o?`enabled`:`disabled`}`)},[e,t,r,i,n]),null}async function Ee(e,t,n){if(n){let t=n.trim().split(/\s+/);if(t[0]===`no-redirect`)return(0,$.jsx)(Se,{onComplete:e});if(t[0]===`reconnect`&&t[1])return(0,$.jsx)(xe,{serverName:t.slice(1).join(` `),onComplete:e});if(t[0]===`enable`||t[0]===`disable`)return(0,$.jsx)(Te,{action:t[0],target:t.length>1?t.slice(1).join(` `):`all`,onComplete:e})}return process.env.USER_TYPE===`ant`?(0,$.jsx)(ge,{onComplete:e,args:`manage`,showMcpRedirectMessage:!0}):(0,$.jsx)(Se,{onComplete:e})}var Q,$;e((()=>{Q=t(f(),1),we(),Y(),F(),j(),pe(),$=g()}))();export{Ee as call};
@@ -0,0 +1,6 @@
1
+ import{o as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./p-map-HKDr3iDo.js";import{D as r,H as i,I as a,P as o,T as s,fi as c,j as ee,kn as l,t as u,y as te}from"./src-CDCSSo0U2.js";import{t as d}from"./jsx-runtime-Bb4Xn-E0.js";import{B_ as f,Ex as p,F_ as m,G_ as h,H_ as g,KS as _,M_ as ne,Mb as v,Nb as y,Tx as b,U_ as x,Y_ as S,a_ as re,ag as ie,b_ as C,bx as ae,dg as oe,e_ as se,fC as w,j_ as T,lg as E,n_ as D,qS as O,r_ as k,s_ as A,t_ as j,uC as M,x_ as N,yx as P}from"./loadAgentsDir-BURvZNN6.js";import{H as F,z as I}from"./debug-BrXObCdR.js";import{c as L,g as R,o as z,y as B}from"./config-DiT2Z8dY.js";import{n as V,o as H}from"./process-gEbdy6uY.js";import{i as U,o as W}from"./platform-BrYefG_2.js";import{s as ce,u as G}from"./types-C-MRCL8J.js";import{n as le,r as K}from"./analytics-BotDBGh0.js";import{l as q,o as ue}from"./stringUtils-DGLPkqJ4.js";import{n as J,t as Y}from"./exit-BOhGfSlm.js";import{stat as de}from"fs/promises";import{cwd as fe}from"process";n();var X=e(c(),1);w(),V(),u(),h(),ue(),p(),ae();var Z=d();function pe({servers:e,scope:t,onDone:n}){let c=Object.keys(e),[l,u]=(0,X.useState)({});(0,X.useEffect)(()=>{f().then(({servers:e})=>u(e))},[]);let d=c.filter(e=>l[e]!==void 0);async function p(n){let r=0;for(let i of n){let n=e[i];if(n){let e=i;if(l[e]!==void 0){let t=1;for(;l[`${i}_${t}`]!==void 0;)t++;e=`${i}_${t}`}await m(e,n,t),r++}}g(r)}let[h]=i(),g=(0,X.useCallback)(e=>{H(e>0?`\n${ee(`success`,h)(`Successfully imported ${e} MCP ${q(e,`server`)} to ${t} config.`)}\n`:`
2
+ No servers were imported.`),n(),M()},[h,t,n]),_=(0,X.useCallback)(()=>{g(0)},[g]);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(te,{title:`Import MCP Servers from Claude Desktop`,subtitle:`Found ${c.length} MCP ${q(c.length,`server`)} in Claude Desktop.`,color:`success`,onCancel:_,hideInputGuide:!0,children:[d.length>0&&(0,Z.jsx)(o,{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)(o,{children:`Please select the servers you want to import:`}),(0,Z.jsx)(P,{options:c.map(e=>({label:`${e}${d.includes(e)?` (already exists)`:``}`,value:e})),defaultValue:c.filter(e=>!d.includes(e)),onSubmit:p,onCancel:_,hideIndexes:!0})]}),(0,Z.jsx)(a,{paddingX:1,children:(0,Z.jsx)(o,{dimColor:!0,italic:!0,children:(0,Z.jsxs)(s,{children:[(0,Z.jsx)(r,{shortcut:`Space`,action:`select`}),(0,Z.jsx)(r,{shortcut:`Enter`,action:`confirm`}),(0,Z.jsx)(b,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})})]})}u(),y(),le(),k(),oe(),h(),ne(),O(),R(),I(),w(),ce(),W();async function Q(e,t){try{let n=await ie(e,t);return n.type===`connected`?`✓ Connected`:n.type===`needs-auth`?`! Needs authentication`:`✗ Failed to connect`}catch{return`✗ Connection error`}}async function me({debug:e,verbose:t}){let n=fe();K(`tengu_mcp_start`,{});try{await de(n)}catch(e){throw F(e)&&Y(`Error: Directory ${n} does not exist`),e}try{let{setup:r}=await import(`./setup-JHvhWKh9.js`);await r(n,`default`,!1,!1,void 0,!1);let{startMCPServer:i}=await import(`./mcp-CtbhGaLC.js`);await i(n,e??!1,t??!1)}catch(e){Y(`Error: Failed to start MCP server: ${e}`)}}async function he(e,t){let n=g(e),r=()=>{n&&(n.type===`sse`||n.type===`http`)&&(j(e,n),se(e,n))};try{if(t.scope){let n=N(t.scope);K(`tengu_mcp_delete`,{name:e,scope:n}),await S(e,n),r(),process.stdout.write(`Removed MCP server ${e} from ${n} config\n`),J(`File modified: ${C(n)}`)}let n=z(),i=L(),{servers:a}=x(`project`),o=!!a[e],s=[];if(n.mcpServers?.[e]&&s.push(`local`),o&&s.push(`project`),i.mcpServers?.[e]&&s.push(`user`),s.length===0)Y(`No MCP server found with name: "${e}"`);else if(s.length===1){let t=s[0];K(`tengu_mcp_delete`,{name:e,scope:t}),await S(e,t),r(),process.stdout.write(`Removed MCP server "${e}" from ${t} config\n`),J(`File modified: ${C(t)}`)}else process.stderr.write(`MCP server "${e}" exists in multiple scopes:\n`),s.forEach(e=>{process.stderr.write(` - ${T(e)} (${C(e)})\n`)}),process.stderr.write(`
3
+ To remove from a specific scope, use:
4
+ `),s.forEach(t=>{process.stderr.write(` claude mcp remove "${e}" -s ${t}\n`)}),Y()}catch(e){Y(e.message)}}async function ge(){K(`tengu_mcp_list`,{});let{servers:e}=await f();if(Object.keys(e).length===0)console.log("No MCP servers configured. Use `claude mcp add` to add a server.");else{console.log(`Checking MCP server health...
5
+ `);let n=await t(Object.entries(e),async([e,t])=>({name:e,server:t,status:await Q(e,t)}),{concurrency:E()});for(let{name:e,server:t,status:r}of n)if(t.type===`sse`)console.log(`${e}: ${t.url} (SSE) - ${r}`);else if(t.type===`http`)console.log(`${e}: ${t.url} (HTTP) - ${r}`);else if(t.type===`claudeai-proxy`)console.log(`${e}: ${t.url} - ${r}`);else if(!t.type||t.type===`stdio`){let n=t,i=Array.isArray(n.args)?n.args:[];console.log(`${e}: ${n.command} ${i.join(` `)} - ${r}`)}}await M(0)}async function $(e){K(`tengu_mcp_get`,{name:e});let t=g(e);t||Y(`No MCP server found with name: ${e}`),console.log(`${e}:`),console.log(` Scope: ${T(t.scope)}`);let n=await Q(e,t);if(console.log(` Status: ${n}`),t.type===`sse`){if(console.log(` Type: sse`),console.log(` URL: ${t.url}`),t.headers){console.log(` Headers:`);for(let[e,n]of Object.entries(t.headers))console.log(` ${e}: ${n}`)}if(t.oauth?.clientId||t.oauth?.callbackPort){let n=[];t.oauth.clientId&&(n.push(`client_id configured`),D(e,t)?.clientSecret&&n.push(`client_secret configured`)),t.oauth.callbackPort&&n.push(`callback_port ${t.oauth.callbackPort}`),console.log(` OAuth: ${n.join(`, `)}`)}}else if(t.type===`http`){if(console.log(` Type: http`),console.log(` URL: ${t.url}`),t.headers){console.log(` Headers:`);for(let[e,n]of Object.entries(t.headers))console.log(` ${e}: ${n}`)}if(t.oauth?.clientId||t.oauth?.callbackPort){let n=[];t.oauth.clientId&&(n.push(`client_id configured`),D(e,t)?.clientSecret&&n.push(`client_secret configured`)),t.oauth.callbackPort&&n.push(`callback_port ${t.oauth.callbackPort}`),console.log(` OAuth: ${n.join(`, `)}`)}}else if(t.type===`stdio`){console.log(` Type: stdio`),console.log(` Command: ${t.command}`);let e=Array.isArray(t.args)?t.args:[];if(console.log(` Args: ${e.join(` `)}`),t.env){console.log(` Environment:`);for(let[e,n]of Object.entries(t.env))console.log(` ${e}=${n}`)}}console.log(`\nTo remove this server, run: claude mcp remove "${e}" -s ${t.scope}`),await M(0)}async function _e(e,t,n){try{let r=N(n.scope),i=G(t),a=n.clientSecret&&i&&typeof i==`object`&&`type`in i&&(i.type===`sse`||i.type===`http`)&&`url`in i&&typeof i.url==`string`&&`oauth`in i&&i.oauth&&typeof i.oauth==`object`&&`clientId`in i.oauth?await re():void 0;await m(e,i,r);let o=i&&typeof i==`object`&&`type`in i?String(i.type||`stdio`):`stdio`;a&&i&&typeof i==`object`&&`type`in i&&(i.type===`sse`||i.type===`http`)&&`url`in i&&typeof i.url==`string`&&A(e,{type:i.type,url:i.url},a),K(`tengu_mcp_add`,{scope:r,source:`json`,type:o}),J(`Added ${o} MCP server ${e} to ${r} config`)}catch(e){Y(e.message)}}async function ve(e){try{let t=N(e.scope);K(`tengu_mcp_add`,{scope:t,platform:U(),source:`desktop`});let{readClaudeDesktopMcpServers:n}=await import(`./claudeDesktop-Cx31Ugjp.js`),r=await n();Object.keys(r).length===0&&J(`No MCP servers found in Claude Desktop configuration or configuration file does not exist.`);let{unmount:i}=await l((0,Z.jsx)(_,{children:(0,Z.jsx)(v,{children:(0,Z.jsx)(pe,{servers:r,scope:t,onDone:()=>{i()}})})}),{exitOnCtrlC:!0})}catch(e){Y(e.message)}}async function ye(){K(`tengu_mcp_reset_mcpjson_choices`,{}),B(e=>({...e,enabledMcpjsonServers:[],disabledMcpjsonServers:[],enableAllProjectMcpServers:!1})),J(`All project-scoped (.mcp.json) server approvals and rejections have been reset.
6
+ You will be prompted for approval next time you start Work Mate.`)}export{ve as mcpAddFromDesktopHandler,_e as mcpAddJsonHandler,$ as mcpGetHandler,ge as mcpListHandler,he as mcpRemoveHandler,ye as mcpResetChoicesHandler,me as mcpServeHandler};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{E as t,O as n}from"./debug-DiuXEmUq.js";import{o as r,s as i}from"./log-Duzb4o6h.js";import{n as a,t as o}from"./index.min-D75yiGLN.js";function s(e,t=300*1e3){let r=new Map,a=new Map,o=async(...o)=>{let s=n(o),c=r.get(s),l=Date.now();if(!c){let t=a.get(s);if(t)return t;let n=e(...o);a.set(s,n);try{let e=await n;return a.get(s)===n&&r.set(s,{value:e,timestamp:l,refreshing:!1}),e}finally{a.get(s)===n&&a.delete(s)}}if(c&&l-c.timestamp>t&&!c.refreshing){c.refreshing=!0;let t=c;return e(...o).then(e=>{r.get(s)===t&&r.set(s,{value:e,timestamp:Date.now(),refreshing:!1})}).catch(e=>{i(e),r.get(s)===t&&r.delete(s)}),c.value}return r.get(s).value};return o.cache={clear:()=>{r.clear(),a.clear()}},o}function c(e,t,n=100){let r=new o({max:n}),i=(...n)=>{let i=t(...n),a=r.get(i);if(a!==void 0)return a;let o=e(...n);return r.set(i,o),o};return i.cache={clear:()=>r.clear(),size:()=>r.size,delete:e=>r.delete(e),get:e=>r.peek(e),has:e=>r.has(e)},i}var l=e((()=>{a(),r(),t()}));export{c as n,s as r,l as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{S as t,w as n}from"./debug-BrXObCdR.js";import{o as r,s as i}from"./log-BMCygSzM.js";import{n as a,t as o}from"./index.min-D75yiGLN.js";function s(e,t=300*1e3){let r=new Map,a=new Map,o=async(...o)=>{let s=n(o),c=r.get(s),l=Date.now();if(!c){let t=a.get(s);if(t)return t;let n=e(...o);a.set(s,n);try{let e=await n;return a.get(s)===n&&r.set(s,{value:e,timestamp:l,refreshing:!1}),e}finally{a.get(s)===n&&a.delete(s)}}if(c&&l-c.timestamp>t&&!c.refreshing){c.refreshing=!0;let t=c;return e(...o).then(e=>{r.get(s)===t&&r.set(s,{value:e,timestamp:Date.now(),refreshing:!1})}).catch(e=>{i(e),r.get(s)===t&&r.delete(s)}),c.value}return r.get(s).value};return o.cache={clear:()=>{r.clear(),a.clear()}},o}function c(e,t,n=100){let r=new o({max:n}),i=(...n)=>{let i=t(...n),a=r.get(i);if(a!==void 0)return a;let o=e(...n);return r.set(i,o),o};return i.cache={clear:()=>r.clear(),size:()=>r.size,delete:e=>r.delete(e),get:e=>r.peek(e),has:e=>r.has(e)},i}var l=e((()=>{a(),r(),t()}));export{c as n,s as r,l as t};
@@ -1 +1 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,o as r}from"./envUtils-DSxRz_kt.js";import{I as i,Lt as a,P as o,Wt as s,_ as c,di as l,fi as u,t as d,ui as ee,y as f}from"./src-CDCSSo0U2.js";import{t as p}from"./jsx-runtime-Bb4Xn-E0.js";import{en as m,nt as h}from"./state-ix0xIunV.js";import{$T as g,Mb as _,Nb as te,Un as v,Vn as ne,XT as y,au as b,hf as re,lS as x,mf as S,ou as C,tE as w,uS as T}from"./loadAgentsDir-ZQwvbURI.js";import{n as E,t as D}from"./cwd-CYmmnQVS.js";import{B as O,U as k}from"./debug-DiuXEmUq.js";import{g as A,y as j}from"./settings-BhvhCpVh.js";import{I as M,P as N,j as ie}from"./config-662VDD70.js";import{_ as P,r as F}from"./git-Cgc8X5l2.js";import{o as I,s as L}from"./log-Duzb4o6h.js";import{f as R,l as ae}from"./file-BZriE-XU.js";import{n as oe,r as z}from"./analytics-BotDBGh0.js";import{b as se,h as ce}from"./startupProfiler-BquH_Yqm.js";import{u as B}from"./referral-Cu9bEOFE.js";import{r as V,t as H}from"./browser-BKiu1max.js";import{n as U,t as W}from"./useExitOnCtrlCDWithKeybindings-vzUoPY51.js";import{r as le,t as ue}from"./promptEditor-D6HzjcMS.js";import{homedir as de}from"os";import{join as G,relative as fe}from"path";import{mkdir as K,writeFile as pe}from"fs/promises";function me(e){return F(e)!==null}var he=e((()=>{P()}));function ge({onSelect:e,onCancel:t}){let r=(0,q.use)(g()),a=G(n(),`CLAUDE.md`),l=G(h(),`CLAUDE.md`),u=r.some(e=>e.path===a),d=r.some(e=>e.path===l),f=[...r.filter(e=>e.type!==`AutoMem`).map(e=>({...e,exists:!0})),...u?[]:[{path:a,type:`User`,content:``,exists:!1}],...d?[]:[{path:l,type:`Project`,content:``,exists:!1}]],p=new Map,m=f.map(e=>{let t=ae(e.path),n=e.exists?``:` (new)`,r=e.parent?(p.get(e.parent)??0)+1:0;p.set(e.path,r);let i=r>0?` `.repeat(r-1):``,o;o=e.type===`User`&&!e.isNested&&e.path===a?`User memory`:e.type===`Project`&&!e.isNested&&e.path===l?`Project memory`:r>0?`${i}L ${t}${n}`:`${t}`;let s,c=me(h());return s=e.type===`User`&&!e.isNested?`Saved in ~/.claude/CLAUDE.md`:e.type===`Project`&&!e.isNested&&e.path===l?`${c?`Checked in at`:`Saved in`} ./CLAUDE.md`:e.parent?`@-imported`:e.isNested?`dynamically loaded`:``,{label:o,value:e.path,description:s}}),_=[],v=T(e=>e.agentDefinitions);if(M()){_.push({label:`Open auto-memory folder`,value:`${X}${ie()}`,description:``});for(let e of v.activeAgents)if(e.memory){let t=ne(e.agentType,e.memory);_.push({label:`Open ${ee.bold(e.agentType)} agent memory`,value:`${X}${t}`,description:`${e.memory} scope`})}}m.push(..._);let y=Y&&m.some(e=>e.value===Y)?Y:m[0]?.value||``,[b,x]=(0,q.useState)(M),[S,w]=(0,q.useState)(C),[E]=(0,q.useState)(M),D=T(e=>Object.values(e.tasks).some(e=>e.type===`dream`&&e.status===`running`)),[O,k]=(0,q.useState)(null);(0,q.useEffect)(()=>{E&&re().then(k)},[E,D]);let A=D?`running`:O===null?``:O===0?`never`:`last ran ${ce(new Date(O))}`,[N,P]=(0,q.useState)(null),F=N!==null,I=+!!E;function L(){let e=!b;j(`userSettings`,{autoMemoryEnabled:e}),x(e),z(`tengu_auto_memory_toggled`,{enabled:e})}function R(){let e=!S;j(`userSettings`,{autoDreamEnabled:e}),w(e),z(`tengu_auto_dream_toggled`,{enabled:e})}return U(),s(`confirm:no`,t,{context:`Confirmation`}),s(`confirm:yes`,()=>{N===0?L():N===1&&R()},{context:`Confirmation`,isActive:F}),s(`select:next`,()=>{P(e=>e!==null&&e<I?e+1:null)},{context:`Select`,isActive:F}),s(`select:previous`,()=>{P(e=>e!==null&&e>0?e-1:e)},{context:`Select`,isActive:F}),(0,J.jsxs)(i,{flexDirection:`column`,width:`100%`,children:[(0,J.jsxs)(i,{flexDirection:`column`,marginBottom:1,children:[(0,J.jsx)(c,{isFocused:N===0,children:(0,J.jsxs)(o,{children:[`Auto-memory: `,b?`on`:`off`]})}),E&&(0,J.jsx)(c,{isFocused:N===1,styled:!1,children:(0,J.jsxs)(o,{color:N===1?`suggestion`:void 0,children:[`Auto-dream: `,S?`on`:`off`,A&&(0,J.jsxs)(o,{dimColor:!0,children:[` · `,A]}),!D&&S&&(0,J.jsx)(o,{dimColor:!0,children:` · /dream to run`})]})})]}),(0,J.jsx)(te,{defaultFocusValue:y,options:m,isDisabled:F,onChange:t=>{if(t.startsWith(X)){let e=t.slice(15);K(e,{recursive:!0}).catch(()=>{}).then(()=>V(e));return}Y=t,e(t)},onCancel:t,onUpFromFirstItem:()=>P(I)})]})}var q,J,Y,X,_e=e((()=>{l(),u(),q=t(u(),1),m(),W(),d(),B(),N(),oe(),b(),S(),x(),v(),H(),w(),r(),R(),se(),he(),A(),_(),J=p(),X=`__open_folder__`}));function ve(e){let t=de(),n=D(),r=e.startsWith(t)?`~`+e.slice(t.length):null,i=e.startsWith(n)?`./`+fe(n,e):null;return r&&i?r.length<=i.length?r:i:r||i||e}var ye=e((()=>{u(),d(),E(),p()}));function be({onDone:e}){let t=async t=>{try{t.includes(n())&&await K(n(),{recursive:!0});try{await pe(t,``,{encoding:`utf8`,flag:`wx`})}catch(e){if(O(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 ${ve(t)}\n\n${o}`,{display:`system`})}catch(t){L(t),e(`Error opening memory file: ${t}`)}},r=()=>{e(`Cancelled memory editing`,{display:`system`})};return(0,Q.jsx)(f,{title:`Memory`,onCancel:r,color:`remember`,children:(0,Q.jsxs)(i,{flexDirection:`column`,children:[(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(ge,{onSelect:t,onCancel:r})}),(0,Q.jsx)(i,{marginTop:1,children:(0,Q.jsxs)(o,{dimColor:!0,children:[`Learn more: `,(0,Q.jsx)(a,{url:`https://code.claude.com/docs/en/memory`})]})})]})})}var Z,Q,$;e((()=>{Z=t(u(),1),d(),_e(),ye(),w(),r(),k(),I(),le(),Q=p(),$=async e=>(y(),await g(),(0,Q.jsx)(be,{onDone:e}))}))();export{$ as call};
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,o as r}from"./envUtils-DSxRz_kt.js";import{I as i,Lt as a,P as o,Wt as s,_ as c,di as l,fi as u,t as d,ui as ee,y as f}from"./src-CDCSSo0U2.js";import{t as p}from"./jsx-runtime-Bb4Xn-E0.js";import{en as m,nt as h}from"./state-ix0xIunV.js";import{JS as g,LE as _,PE as v,Un as y,Vn as te,_x as ne,au as b,gx as x,hf as re,mf as S,ou as C,qS as w,zE as T}from"./loadAgentsDir-BURvZNN6.js";import{n as E,t as D}from"./cwd-CYmmnQVS.js";import{I as O,z as k}from"./debug-BrXObCdR.js";import{g as A,y as j}from"./settings-DfWP5y6X.js";import{I as M,P as N,j as ie}from"./config-DiT2Z8dY.js";import{_ as P,r as F}from"./git-Do0wJvux.js";import{o as I,s as L}from"./log-BMCygSzM.js";import{f as R,l as ae}from"./file-DcZWPH2V.js";import{n as oe,r as z}from"./analytics-BotDBGh0.js";import{b as se,h as ce}from"./startupProfiler-xa3NmN7Z.js";import{u as B}from"./referral-UKJv23_5.js";import{r as V,t as H}from"./browser-BmZuQom6.js";import{n as U,t as W}from"./useExitOnCtrlCDWithKeybindings-CV4GZ-sq.js";import{r as le,t as ue}from"./promptEditor-DMJyosKj.js";import{homedir as de}from"os";import{join as G,relative as fe}from"path";import{mkdir as K,writeFile as pe}from"fs/promises";function me(e){return F(e)!==null}var he=e((()=>{P()}));function ge({onSelect:e,onCancel:t}){let r=(0,q.use)(_()),a=G(n(),`CLAUDE.md`),l=G(h(),`CLAUDE.md`),u=r.some(e=>e.path===a),d=r.some(e=>e.path===l),f=[...r.filter(e=>e.type!==`AutoMem`).map(e=>({...e,exists:!0})),...u?[]:[{path:a,type:`User`,content:``,exists:!1}],...d?[]:[{path:l,type:`Project`,content:``,exists:!1}]],p=new Map,m=f.map(e=>{let t=ae(e.path),n=e.exists?``:` (new)`,r=e.parent?(p.get(e.parent)??0)+1:0;p.set(e.path,r);let i=r>0?` `.repeat(r-1):``,o;o=e.type===`User`&&!e.isNested&&e.path===a?`User memory`:e.type===`Project`&&!e.isNested&&e.path===l?`Project memory`:r>0?`${i}L ${t}${n}`:`${t}`;let s,c=me(h());return s=e.type===`User`&&!e.isNested?`Saved in ~/.claude/CLAUDE.md`:e.type===`Project`&&!e.isNested&&e.path===l?`${c?`Checked in at`:`Saved in`} ./CLAUDE.md`:e.parent?`@-imported`:e.isNested?`dynamically loaded`:``,{label:o,value:e.path,description:s}}),v=[],y=g(e=>e.agentDefinitions);if(M()){v.push({label:`Open auto-memory folder`,value:`${X}${ie()}`,description:``});for(let e of y.activeAgents)if(e.memory){let t=te(e.agentType,e.memory);v.push({label:`Open ${ee.bold(e.agentType)} agent memory`,value:`${X}${t}`,description:`${e.memory} scope`})}}m.push(...v);let b=Y&&m.some(e=>e.value===Y)?Y:m[0]?.value||``,[x,S]=(0,q.useState)(M),[w,T]=(0,q.useState)(C),[E]=(0,q.useState)(M),D=g(e=>Object.values(e.tasks).some(e=>e.type===`dream`&&e.status===`running`)),[O,k]=(0,q.useState)(null);(0,q.useEffect)(()=>{E&&re().then(k)},[E,D]);let A=D?`running`:O===null?``:O===0?`never`:`last ran ${ce(new Date(O))}`,[N,P]=(0,q.useState)(null),F=N!==null,I=+!!E;function L(){let e=!x;j(`userSettings`,{autoMemoryEnabled:e}),S(e),z(`tengu_auto_memory_toggled`,{enabled:e})}function R(){let e=!w;j(`userSettings`,{autoDreamEnabled:e}),T(e),z(`tengu_auto_dream_toggled`,{enabled:e})}return U(),s(`confirm:no`,t,{context:`Confirmation`}),s(`confirm:yes`,()=>{N===0?L():N===1&&R()},{context:`Confirmation`,isActive:F}),s(`select:next`,()=>{P(e=>e!==null&&e<I?e+1:null)},{context:`Select`,isActive:F}),s(`select:previous`,()=>{P(e=>e!==null&&e>0?e-1:e)},{context:`Select`,isActive:F}),(0,J.jsxs)(i,{flexDirection:`column`,width:`100%`,children:[(0,J.jsxs)(i,{flexDirection:`column`,marginBottom:1,children:[(0,J.jsx)(c,{isFocused:N===0,children:(0,J.jsxs)(o,{children:[`Auto-memory: `,x?`on`:`off`]})}),E&&(0,J.jsx)(c,{isFocused:N===1,styled:!1,children:(0,J.jsxs)(o,{color:N===1?`suggestion`:void 0,children:[`Auto-dream: `,w?`on`:`off`,A&&(0,J.jsxs)(o,{dimColor:!0,children:[` · `,A]}),!D&&w&&(0,J.jsx)(o,{dimColor:!0,children:` · /dream to run`})]})})]}),(0,J.jsx)(ne,{defaultFocusValue:b,options:m,isDisabled:F,onChange:t=>{if(t.startsWith(X)){let e=t.slice(15);K(e,{recursive:!0}).catch(()=>{}).then(()=>V(e));return}Y=t,e(t)},onCancel:t,onUpFromFirstItem:()=>P(I)})]})}var q,J,Y,X,_e=e((()=>{l(),u(),q=t(u(),1),m(),W(),d(),B(),N(),oe(),b(),S(),w(),y(),H(),T(),r(),R(),se(),he(),A(),x(),J=p(),X=`__open_folder__`}));function ve(e){let t=de(),n=D(),r=e.startsWith(t)?`~`+e.slice(t.length):null,i=e.startsWith(n)?`./`+fe(n,e):null;return r&&i?r.length<=i.length?r:i:r||i||e}var ye=e((()=>{u(),d(),E(),p()}));function be({onDone:e}){let t=async t=>{try{t.includes(n())&&await K(n(),{recursive:!0});try{await pe(t,``,{encoding:`utf8`,flag:`wx`})}catch(e){if(O(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 ${ve(t)}\n\n${o}`,{display:`system`})}catch(t){L(t),e(`Error opening memory file: ${t}`)}},r=()=>{e(`Cancelled memory editing`,{display:`system`})};return(0,Q.jsx)(f,{title:`Memory`,onCancel:r,color:`remember`,children:(0,Q.jsxs)(i,{flexDirection:`column`,children:[(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(ge,{onSelect:t,onCancel:r})}),(0,Q.jsx)(i,{marginTop:1,children:(0,Q.jsxs)(o,{dimColor:!0,children:[`Learn more: `,(0,Q.jsx)(a,{url:`https://code.claude.com/docs/en/memory`})]})})]})})}var Z,Q,$;e((()=>{Z=t(u(),1),d(),_e(),ye(),T(),r(),k(),I(),le(),Q=p(),$=async e=>(v(),await _(),(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{I as n,P as r,fi as i,t as a}from"./src-CDCSSo0U2.js";import{t as o}from"./jsx-runtime-Bb4Xn-E0.js";import{Nb as s,Pb as c,dt as l,ft as u,mt as d,pt as f}from"./loadAgentsDir-ZQwvbURI.js";function p({onDone:e}){let t=f(),i=l(),a=(0,m.useMemo)(()=>t.map(e=>({label:(0,h.jsxs)(r,{children:[e.icon,` `,e.name,` `,(0,h.jsxs)(r,{dimColor:!0,children:[`(`,e.slug,`) — `,e.description]})]}),value:e.slug})),[t]);function o(n){d(n);let r=t.find(e=>e.slug===n);e(`${r?.icon} Mode switched to: ${r?.name} (${r?.slug}) — ${r?.description}`,{display:`system`})}function c(){e(`Mode selection cancelled.`,{display:`system`})}return(0,h.jsxs)(n,{flexDirection:`column`,children:[(0,h.jsxs)(n,{marginBottom:1,flexDirection:`column`,children:[(0,h.jsx)(r,{color:`remember`,bold:!0,children:`Select mode`}),(0,h.jsx)(r,{dimColor:!0,children:`Arrow keys to navigate, Enter to select, Esc to cancel.`})]}),(0,h.jsx)(s,{defaultValue:i,options:a,onChange:o,onCancel:c,visibleOptionCount:t.length})]})}var m,h,g;e((()=>{m=t(i(),1),a(),c(),u(),h=o(),g=async(e,t,n)=>{let r=n?.trim().toLowerCase();if(r){let t=f(),n=t.find(e=>e.slug===r);if(!n){e(`Unknown mode: "${r}"\n\nAvailable modes:\n${t.map(e=>`${e.icon} ${e.slug} — ${e.description}`).join(`
2
- `)}`,{display:`system`});return}d(r),e(`${n.icon} Mode switched to: ${n.name} (${n.slug}) — ${n.description}`,{display:`system`});return}return(0,h.jsx)(p,{onDone:e})}}))();export{g as call};
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{I as n,P as r,fi as i,t as a}from"./src-CDCSSo0U2.js";import{t as o}from"./jsx-runtime-Bb4Xn-E0.js";import{_x as s,dt as c,ft as l,mt as u,pt as d,vx as f}from"./loadAgentsDir-BURvZNN6.js";function p({onDone:e}){let t=d(),i=c(),a=(0,m.useMemo)(()=>t.map(e=>({label:(0,h.jsxs)(r,{children:[e.icon,` `,e.name,` `,(0,h.jsxs)(r,{dimColor:!0,children:[`(`,e.slug,`) — `,e.description]})]}),value:e.slug})),[t]);function o(n){u(n);let r=t.find(e=>e.slug===n);e(`${r?.icon} Mode switched to: ${r?.name} (${r?.slug}) — ${r?.description}`,{display:`system`})}function l(){e(`Mode selection cancelled.`,{display:`system`})}return(0,h.jsxs)(n,{flexDirection:`column`,children:[(0,h.jsxs)(n,{marginBottom:1,flexDirection:`column`,children:[(0,h.jsx)(r,{color:`remember`,bold:!0,children:`Select mode`}),(0,h.jsx)(r,{dimColor:!0,children:`Arrow keys to navigate, Enter to select, Esc to cancel.`})]}),(0,h.jsx)(s,{defaultValue:i,options:a,onChange:o,onCancel:l,visibleOptionCount:t.length})]})}var m,h,g;e((()=>{m=t(i(),1),a(),f(),l(),h=o(),g=async(e,t,n)=>{let r=n?.trim().toLowerCase();if(r){let t=d(),n=t.find(e=>e.slug===r);if(!n){e(`Unknown mode: "${r}"\n\nAvailable modes:\n${t.map(e=>`${e.icon} ${e.slug} — ${e.description}`).join(`
2
+ `)}`,{display:`system`});return}u(r),e(`${n.icon} Mode switched to: ${n.name} (${n.slug}) — ${n.description}`,{display:`system`});return}return(0,h.jsx)(p,{onDone:e})}}))();export{g as call};
@@ -0,0 +1 @@
1
+ import{n as e,o as t,r as n}from"./rolldown-runtime-DaDcL9Zw.js";import{n as r,t as i}from"./memoize-BK3gG5ob.js";import{d as a,i as o,l as s,n as c,o as l,s as u,t as d}from"./envUtils-DSxRz_kt.js";import{n as ee,t as te}from"./defineProperty-C-QyHrDq.js";import{n as f,t as p}from"./axios-DaWTGg7G.js";import{di as ne,ui as re}from"./src-CDCSSo0U2.js";import{E as ie,M as ae,T as oe,h as se,n as ce,r as le,t as ue}from"./lazySchema-DcIJE_0i.js";import{$ as de,H as fe,Jr as pe,On as me,Sr as he,X as ge,Xn as _e,Yr as ve,_n as ye,en as m,ht as be,pt as xe,qn as Se,sn as Ce,tt as we,xr as Te,y as Ee,z as h}from"./state-ix0xIunV.js";import{C as De,E as Oe,F as g,G as ke,I as Ae,K as je,S as Me,V as Ne,a as _,c as Pe,d as Fe,l as v,p as Ie,s as Le,w as Re,z as ze}from"./debug-BrXObCdR.js";import{Kt as Be,c as y,f as b,g as x,n as Ve,y as He}from"./settings-DfWP5y6X.js";import{C as Ue,b as S,c as C,g as We,n as w,w as Ge}from"./config-DiT2Z8dY.js";import{a as Ke,c as qe,i as Je,o as Ye,r as Xe,s as Ze,t as Qe}from"./execFileNoThrow-D244NytW.js";import{d as $e,f as et,o as tt,s as T}from"./log-BMCygSzM.js";import{r as nt,t as rt}from"./memoize-B0zhbT8Z.js";import{s as it,u as at}from"./types-C-MRCL8J.js";import{n as ot,r as E}from"./analytics-BotDBGh0.js";import{l as D,n as st,r as ct,s as lt,t as ut,u as O}from"./oauth-BqJqV-2M.js";import{n as dt,t as ft}from"./bundledMode--fG1S62b.js";import{n as pt,o as mt}from"./stringUtils-DGLPkqJ4.js";import{a as ht,i as gt,l as _t}from"./proxy-CRN7jYIi.js";import{userInfo as vt}from"os";import{join as yt}from"path";import{chmodSync as bt,mkdirSync as xt,readFileSync as St,writeFileSync as Ct}from"fs";import{createHash as wt,randomUUID as Tt}from"crypto";import{mkdir as Et,stat as Dt,writeFile as Ot}from"fs/promises";import{exec as kt,execFile as At}from"child_process";import{AsyncLocalStorage as jt}from"async_hooks";function Mt(){return process.env.USER_TYPE,null}function Nt(){return process.env.USER_TYPE===`ant`?Mt()?.antModels??[]:[]}function Pt(e){if(process.env.USER_TYPE!==`ant`||e===void 0)return;let t=e.toLowerCase();return Nt().find(n=>n.alias===e||t.includes(n.model.toLowerCase()))}var Ft=e((()=>{}));function It(e){let t=[],n=!1;async function r(){if(!n&&t.length!==0){for(n=!0;t.length>0;){let{args:n,resolve:r,reject:i,context:a}=t.shift();try{r(await e.apply(a,n))}catch(e){i(e)}}n=!1,t.length>0&&r()}}return function(...e){return new Promise((n,i)=>{t.push({args:e,resolve:n,reject:i,context:this}),r()})}}var Lt=e((()=>{}));function Rt(e,t){return e.find(e=>e.includes(t))??null}async function zt(){let{BedrockClient:e}=await import(`./dist-es-yHGBqhBe.js`),t=d(),n=s(process.env.CLAUDE_CODE_SKIP_BEDROCK_AUTH),r={region:t,...process.env.ANTHROPIC_BEDROCK_BASE_URL&&{endpoint:process.env.ANTHROPIC_BEDROCK_BASE_URL},...await gt(),...n&&{requestHandler:new(await(import(`./dist-es-C7vygWzp.js`))).NodeHttpHandler,httpAuthSchemes:[{schemeId:`smithy.api#noAuth`,identityProvider:()=>async()=>({}),signer:new(await(import(`./dist-es-gUzZ_7Vf.js`))).NoAuthSigner}],httpAuthSchemeProvider:()=>[{schemeId:`smithy.api#noAuth`}]}};if(!n&&!process.env.AWS_BEARER_TOKEN_BEDROCK){let e=await W();e&&(r.credentials={accessKeyId:e.accessKeyId,secretAccessKey:e.secretAccessKey,sessionToken:e.sessionToken})}return new e(r)}async function Bt(){let{BedrockRuntimeClient:e}=await import(`./dist-es-Gt_DpXlP.js`),t=d(),n=s(process.env.CLAUDE_CODE_SKIP_BEDROCK_AUTH),r={region:t,...process.env.ANTHROPIC_BEDROCK_BASE_URL&&{endpoint:process.env.ANTHROPIC_BEDROCK_BASE_URL},...await gt(),...n&&{requestHandler:new(await(import(`./dist-es-C7vygWzp.js`))).NodeHttpHandler,httpAuthSchemes:[{schemeId:`smithy.api#noAuth`,identityProvider:()=>async()=>({}),signer:new(await(import(`./dist-es-gUzZ_7Vf.js`))).NoAuthSigner}],httpAuthSchemeProvider:()=>[{schemeId:`smithy.api#noAuth`}]}};if(!n&&!process.env.AWS_BEARER_TOKEN_BEDROCK){let e=await W();e&&(r.credentials={accessKeyId:e.accessKeyId,secretAccessKey:e.secretAccessKey,sessionToken:e.sessionToken})}return new e(r)}function Vt(e){return e.startsWith(`anthropic.`)}function Ht(e){if(!e.startsWith(`arn:`))return e;let t=e.lastIndexOf(`/`);return t===-1?e:e.substring(t+1)}function Ut(e){let t=Ht(e);for(let e of qt)if(t.startsWith(`${e}.anthropic.`))return e}function Wt(e,t){let n=Ut(e);return n?e.replace(`${n}.`,`${t}.`):Vt(e)?`${t}.${e}`:e}var Gt,Kt,qt,Jt=e((()=>{i(),K(),l(),tt(),_t(),Gt=r(async function(){let[e,{ListInferenceProfilesCommand:t}]=await Promise.all([zt(),import(`./dist-es-yHGBqhBe.js`)]),n=[],r;try{do{let i=new t({...r&&{nextToken:r},typeEquals:`SYSTEM_DEFINED`}),a=await e.send(i);a.inferenceProfileSummaries&&n.push(...a.inferenceProfileSummaries),r=a.nextToken}while(r);return n.filter(e=>e.inferenceProfileId?.includes(`anthropic`)).map(e=>e.inferenceProfileId).filter(Boolean)}catch(e){throw T(e),e}}),Kt=r(async function(e){try{let[t,{GetInferenceProfileCommand:n}]=await Promise.all([zt(),import(`./dist-es-yHGBqhBe.js`)]),r=new n({inferenceProfileIdentifier:e}),i=await t.send(r);if(!i.models||i.models.length===0)return null;let a=i.models[0];if(!a?.modelArn)return null;let o=a.modelArn.lastIndexOf(`/`);return o>=0?a.modelArn.substring(o+1):a.modelArn}catch(e){return T(e),null}}),qt=[`us`,`eu`,`apac`,`global`]})),Yt,Xt,Zt,Qt,$t,en,tn,nn,rn,an,on,sn,cn,ln,un=e((()=>{Yt={firstParty:`claude-3-7-sonnet-20250219`,bedrock:`us.anthropic.claude-3-7-sonnet-20250219-v1:0`,vertex:`claude-3-7-sonnet@20250219`,foundry:`claude-3-7-sonnet`,openai:`claude-3-7-sonnet-20250219`,gemini:`claude-3-7-sonnet-20250219`,grok:`claude-3-7-sonnet-20250219`},Xt={firstParty:`claude-3-5-sonnet-20241022`,bedrock:`anthropic.claude-3-5-sonnet-20241022-v2:0`,vertex:`claude-3-5-sonnet-v2@20241022`,foundry:`claude-3-5-sonnet`,openai:`claude-3-5-sonnet-20241022`,gemini:`claude-3-5-sonnet-20241022`,grok:`claude-3-5-sonnet-20241022`},Zt={firstParty:`claude-3-5-haiku-20241022`,bedrock:`us.anthropic.claude-3-5-haiku-20241022-v1:0`,vertex:`claude-3-5-haiku@20241022`,foundry:`claude-3-5-haiku`,openai:`claude-3-5-haiku-20241022`,gemini:`claude-3-5-haiku-20241022`,grok:`claude-3-5-haiku-20241022`},Qt={firstParty:`claude-haiku-4-5-20251001`,bedrock:`us.anthropic.claude-haiku-4-5-20251001-v1:0`,vertex:`claude-haiku-4-5@20251001`,foundry:`claude-haiku-4-5`,openai:`claude-haiku-4-5-20251001`,gemini:`claude-haiku-4-5-20251001`,grok:`claude-haiku-4-5-20251001`},$t={firstParty:`claude-sonnet-4-20250514`,bedrock:`us.anthropic.claude-sonnet-4-20250514-v1:0`,vertex:`claude-sonnet-4@20250514`,foundry:`claude-sonnet-4`,openai:`claude-sonnet-4-20250514`,gemini:`claude-sonnet-4-20250514`,grok:`claude-sonnet-4-20250514`},en={firstParty:`claude-sonnet-4-5-20250929`,bedrock:`us.anthropic.claude-sonnet-4-5-20250929-v1:0`,vertex:`claude-sonnet-4-5@20250929`,foundry:`claude-sonnet-4-5`,openai:`claude-sonnet-4-5-20250929`,gemini:`claude-sonnet-4-5-20250929`,grok:`claude-sonnet-4-5-20250929`},tn={firstParty:`claude-opus-4-20250514`,bedrock:`us.anthropic.claude-opus-4-20250514-v1:0`,vertex:`claude-opus-4@20250514`,foundry:`claude-opus-4`,openai:`claude-opus-4-20250514`,gemini:`claude-opus-4-20250514`,grok:`claude-opus-4-20250514`},nn={firstParty:`claude-opus-4-1-20250805`,bedrock:`us.anthropic.claude-opus-4-1-20250805-v1:0`,vertex:`claude-opus-4-1@20250805`,foundry:`claude-opus-4-1`,openai:`claude-opus-4-1-20250805`,gemini:`claude-opus-4-1-20250805`,grok:`claude-opus-4-1-20250805`},rn={firstParty:`claude-opus-4-5-20251101`,bedrock:`us.anthropic.claude-opus-4-5-20251101-v1:0`,vertex:`claude-opus-4-5@20251101`,foundry:`claude-opus-4-5`,openai:`claude-opus-4-5-20251101`,gemini:`claude-opus-4-5-20251101`,grok:`claude-opus-4-5-20251101`},an={firstParty:`claude-opus-4-6`,bedrock:`us.anthropic.claude-opus-4-6-v1`,vertex:`claude-opus-4-6`,foundry:`claude-opus-4-6`,openai:`claude-opus-4-6`,gemini:`claude-opus-4-6`,grok:`claude-opus-4-6`},on={firstParty:`claude-opus-4-7`,bedrock:`us.anthropic.claude-opus-4-7-v1`,vertex:`claude-opus-4-7`,foundry:`claude-opus-4-7`,openai:`claude-opus-4-7`,gemini:`claude-opus-4-7`,grok:`claude-opus-4-7`},sn={firstParty:`claude-sonnet-4-6`,bedrock:`us.anthropic.claude-sonnet-4-6`,vertex:`claude-sonnet-4-6`,foundry:`claude-sonnet-4-6`,openai:`claude-sonnet-4-6`,gemini:`claude-sonnet-4-6`,grok:`claude-sonnet-4-6`},cn={haiku35:Zt,haiku45:Qt,sonnet35:Xt,sonnet37:Yt,sonnet40:$t,sonnet45:en,sonnet46:sn,opus40:tn,opus41:nn,opus45:rn,opus46:an,opus47:on},Object.values(cn).map(e=>e.firstParty),ln=Object.fromEntries(Object.entries(cn).map(([e,t])=>[t.firstParty,e]))}));function k(e=Ve()){let t=e.modelType;return t===`openai`?`openai`:t===`gemini`?`gemini`:t===`grok`?`grok`:s(process.env.CLAUDE_CODE_USE_BEDROCK)?`bedrock`:s(process.env.CLAUDE_CODE_USE_VERTEX)?`vertex`:s(process.env.CLAUDE_CODE_USE_FOUNDRY)?`foundry`:s(process.env.CLAUDE_CODE_USE_OPENAI)?`openai`:s(process.env.CLAUDE_CODE_USE_GEMINI)?`gemini`:s(process.env.CLAUDE_CODE_USE_GROK)?`grok`:`firstParty`}function dn(){return k()}function fn(){let e=process.env.ANTHROPIC_BASE_URL;if(!e)return!0;try{let t=new URL(e).host,n=[`api.anthropic.com`];return process.env.USER_TYPE===`ant`&&n.push(`api-staging.anthropic.com`),n.includes(t)}catch{return!1}}var A=e((()=>{x(),l()}));function pn(e){let t={};for(let n of yn)t[n]=cn[n][e];return t}async function mn(){let e=pn(`bedrock`),t;try{t=await Gt()}catch(t){return T(t),e}if(!t?.length)return e;let n={};for(let r of yn){let i=cn[r].firstParty;n[r]=Rt(t,i)||e[r]}return n}function hn(e){let t=Ve().modelOverrides;if(!t)return e;let n={...e};for(let[e,r]of Object.entries(t)){let t=ln[e];t&&r&&(n[t]=r)}return n}function gn(e){let t;try{t=Ve().modelOverrides}catch{return e}if(!t)return e;for(let[n,r]of Object.entries(t))if(r===e)return n;return e}function _n(){if(de()===null){if(k()!==`bedrock`){Se(pn(k()));return}bn()}}function j(){let e=de();return e===null?(_n(),hn(pn(k()))):hn(e)}async function vn(){if(de()===null){if(k()!==`bedrock`){Se(pn(k()));return}await bn()}}var yn,bn,xn=e((()=>{m(),tt(),Lt(),x(),Jt(),un(),A(),yn=Object.keys(cn),bn=It(async()=>{if(de()===null)try{Se(await mn())}catch(e){T(e)}})}));function Sn(){if(s(process.env.DISABLE_COST_WARNINGS)||B())return!1;let e=Ma(),t=R()!==null;if(!e.hasToken&&!t)return!1;let n=C(),r=n.oauthAccount?.organizationRole,i=n.oauthAccount?.workspaceRole;return!r||!i?!1:[`admin`,`billing`].includes(r)||[`workspace_admin`,`workspace_billing`].includes(i)}function Cn(e){Tn=e}function wn(){if(Tn!==null)return Tn;if(!B())return!1;let e=V();if(e===`max`||e===`pro`)return!0;let t=C().oauthAccount?.organizationRole;return!!t&&[`admin`,`billing`,`owner`,`primary_owner`].includes(t)}var Tn,En=e((()=>{K(),We(),l(),Tn=null}));function Dn(){return process.env.USER_TYPE===`ant`?process.env.CLAUDE_MOCK_HEADERLESS_429?process.env.CLAUDE_MOCK_HEADERLESS_429:M?Ln:null:null}function On(){return!M||process.env.USER_TYPE!==`ant`||Object.keys(In).length===0?null:In}function kn(){In={},Vn=[],Rn=null,zn=null,N=null,Ln=null,Cn(null),M=!1}function An(e){let t=On();if(!t)return e;let n=new globalThis.Headers(e);return Object.entries(t).forEach(([e,t])=>{t!==void 0&&n.set(e,t)}),n}function jn(){return process.env.USER_TYPE===`ant`?M||!!process.env.CLAUDE_MOCK_HEADERLESS_429:!1}function Mn(){return!M||process.env.USER_TYPE!==`ant`?null:Rn||Bn}function Nn(){return M&&Rn!==null&&process.env.USER_TYPE===`ant`}function Pn(){return zn!==null}function Fn(e){if(zn===null||!e)return null;if(N!==null&&Date.now()>=N)return kn(),null;N===null&&(N=Date.now()+zn);let t=N-Date.now(),n={...In};return n[`retry-after`]=String(Math.max(1,Math.ceil(t/1e3))),n}var In,M,Ln,Rn,zn,N,Bn,Vn,Hn=e((()=>{En(),In={},M=!1,Ln=null,Rn=null,zn=null,N=null,Bn=`max`}));async function Un(){let e=C().oauthAccount?.accountUuid,t=R();if(!e||!t)return;let n=`${D().BASE_API_URL}/api/claude_cli_profile`;try{return(await f.get(n,{headers:{"x-api-key":t,"anthropic-beta":lt},params:{account_uuid:e},timeout:1e4})).data}catch(e){T(e)}}async function Wn(e){let t=`${D().BASE_API_URL}/api/oauth/profile`;try{return(await f.get(t,{headers:{Authorization:`Bearer ${e}`,"Content-Type":`application/json`},timeout:1e4})).data}catch(e){T(e)}}var Gn=e((()=>{p(),O(),K(),We(),tt()}));function Kn(e){return!!e?.includes(st)}function qn(e){return e?.split(` `).filter(Boolean)??[]}function Jn({codeChallenge:e,state:t,port:n,isManual:r,loginWithClaudeAi:i,inferenceOnly:a,orgUUID:o,loginHint:s,loginMethod:c}){let l=i?D().CLAUDE_AI_AUTHORIZE_URL:D().CONSOLE_AUTHORIZE_URL,u=new URL(l);u.searchParams.append(`code`,`true`),u.searchParams.append(`client_id`,D().CLIENT_ID),u.searchParams.append(`response_type`,`code`),u.searchParams.append(`redirect_uri`,r?D().MANUAL_REDIRECT_URL:`http://localhost:${n}/callback`);let d=a?[st]:ut;return u.searchParams.append(`scope`,d.join(` `)),u.searchParams.append(`code_challenge`,e),u.searchParams.append(`code_challenge_method`,`S256`),u.searchParams.append(`state`,t),o&&u.searchParams.append(`orgUUID`,o),s&&u.searchParams.append(`login_hint`,s),c&&u.searchParams.append(`login_method`,c),u.toString()}async function Yn(e,t,n,r,i=!1,a){let o={grant_type:`authorization_code`,code:e,redirect_uri:i?D().MANUAL_REDIRECT_URL:`http://localhost:${r}/callback`,client_id:D().CLIENT_ID,code_verifier:n,state:t};a!==void 0&&(o.expires_in=a);let s=await f.post(D().TOKEN_URL,o,{headers:{"Content-Type":`application/json`},timeout:15e3});if(s.status!==200)throw Error(s.status===401?`Authentication failed: Invalid authorization code`:`Token exchange failed (${s.status}): ${s.statusText}`);return E(`tengu_oauth_token_exchange_success`,{}),s.data}async function Xn(e,{scopes:t}={}){let n={grant_type:`refresh_token`,refresh_token:e,client_id:D().CLIENT_ID,scope:(t?.length?t:ct).join(` `)};try{let t=await f.post(D().TOKEN_URL,n,{headers:{"Content-Type":`application/json`},timeout:15e3});if(t.status!==200)throw Error(`Token refresh failed: ${t.statusText}`);let r=t.data,{access_token:i,refresh_token:a=e,expires_in:o}=r,s=Date.now()+o*1e3,c=qn(r.scope);E(`tengu_oauth_token_refresh_success`,{});let l=C(),u=G(),d=l.oauthAccount?.billingType!==void 0&&l.oauthAccount?.accountCreatedAt!==void 0&&l.oauthAccount?.subscriptionCreatedAt!==void 0&&u?.subscriptionType!=null&&u?.rateLimitTier!=null?null:await er(i);if(d&&l.oauthAccount){let e={};d.displayName!==void 0&&(e.displayName=d.displayName),typeof d.hasExtraUsageEnabled==`boolean`&&(e.hasExtraUsageEnabled=d.hasExtraUsageEnabled),d.billingType!==null&&(e.billingType=d.billingType),d.accountCreatedAt!==void 0&&(e.accountCreatedAt=d.accountCreatedAt),d.subscriptionCreatedAt!==void 0&&(e.subscriptionCreatedAt=d.subscriptionCreatedAt),Object.keys(e).length>0&&S(t=>({...t,oauthAccount:t.oauthAccount?{...t.oauthAccount,...e}:t.oauthAccount}))}return{accessToken:i,refreshToken:a,expiresAt:s,scopes:c,subscriptionType:d?.subscriptionType??u?.subscriptionType??null,rateLimitTier:d?.rateLimitTier??u?.rateLimitTier??null,profile:d?.rawProfile,tokenAccount:r.account?{uuid:r.account.uuid,emailAddress:r.account.email_address,organizationUuid:r.organization?.uuid}:void 0}}catch(e){let t=f.isAxiosError(e)&&e.response?.data?JSON.stringify(e.response.data):void 0;throw E(`tengu_oauth_token_refresh_failure`,{error:e.message,...t&&{responseBody:t}}),e}}async function Zn(e){let t=await f.get(D().ROLES_URL,{headers:{Authorization:`Bearer ${e}`}});if(t.status!==200)throw Error(`Failed to fetch user roles: ${t.statusText}`);let n=t.data;if(!C().oauthAccount)throw Error(`OAuth account information not found in config`);S(e=>({...e,oauthAccount:e.oauthAccount?{...e.oauthAccount,organizationRole:n.organization_role,workspaceRole:n.workspace_role,organizationName:n.organization_name}:e.oauthAccount})),E(`tengu_oauth_roles_stored`,{org_role:n.organization_role})}async function Qn(e){try{let t=await f.post(D().API_KEY_URL,null,{headers:{Authorization:`Bearer ${e}`}}),n=t.data?.raw_key;return n?(await so(n),E(`tengu_oauth_api_key`,{status:`success`,statusCode:t.status}),n):null}catch(e){throw E(`tengu_oauth_api_key`,{status:`failure`,error:e instanceof Error?e.message:String(e)}),e}}function $n(e){return e!==null&&Date.now()+300*1e3>=e}async function er(e){let t=await Wn(e),n=t?.organization?.organization_type,r=null;switch(n){case`claude_max`:r=`max`;break;case`claude_pro`:r=`pro`;break;case`claude_enterprise`:r=`enterprise`;break;case`claude_team`:r=`team`;break;default:r=null;break}let i={subscriptionType:r,rateLimitTier:t?.organization?.rate_limit_tier??null,hasExtraUsageEnabled:t?.organization?.has_extra_usage_enabled??null,billingType:t?.organization?.billing_type??null};return t?.account?.display_name&&(i.displayName=t.account.display_name),t?.account?.created_at&&(i.accountCreatedAt=t.account.created_at),t?.organization?.subscription_created_at&&(i.subscriptionCreatedAt=t.organization.subscription_created_at),E(`tengu_oauth_profile_fetch_success`,{}),{...i,rawProfile:t}}async function tr(){let e=C().oauthAccount?.organizationUuid;if(e)return e;let t=G()?.accessToken;return t===void 0||!bo()?null:(await Wn(t))?.organization?.uuid||null}async function nr(){let e=process.env.CLAUDE_CODE_ACCOUNT_UUID,t=process.env.CLAUDE_CODE_USER_EMAIL,n=process.env.CLAUDE_CODE_ORGANIZATION_UUID,r=!!(e&&t&&n);e&&t&&n&&(C().oauthAccount||rr({accountUuid:e,emailAddress:t,organizationUuid:n})),await vo();let i=C();if(i.oauthAccount&&i.oauthAccount.billingType!==void 0&&i.oauthAccount.accountCreatedAt!==void 0&&i.oauthAccount.subscriptionCreatedAt!==void 0||!B()||!bo())return!1;let a=G();if(a?.accessToken){let e=await Wn(a.accessToken);if(e)return r&&v(`OAuth profile fetch succeeded, overriding env var account info`,{level:`info`}),rr({accountUuid:e.account.uuid,emailAddress:e.account.email,organizationUuid:e.organization.uuid,displayName:e.account.display_name||void 0,hasExtraUsageEnabled:e.organization.has_extra_usage_enabled??!1,billingType:e.organization.billing_type??void 0,accountCreatedAt:e.account.created_at,subscriptionCreatedAt:e.organization.subscription_created_at??void 0}),!0}return!1}function rr({accountUuid:e,emailAddress:t,organizationUuid:n,displayName:r,hasExtraUsageEnabled:i,billingType:a,accountCreatedAt:o,subscriptionCreatedAt:s}){let c={accountUuid:e,emailAddress:t,organizationUuid:n,hasExtraUsageEnabled:i,billingType:a,accountCreatedAt:o,subscriptionCreatedAt:s};r&&(c.displayName=r),S(e=>e.oauthAccount?.accountUuid===c.accountUuid&&e.oauthAccount?.emailAddress===c.emailAddress&&e.oauthAccount?.organizationUuid===c.organizationUuid&&e.oauthAccount?.displayName===c.displayName&&e.oauthAccount?.hasExtraUsageEnabled===c.hasExtraUsageEnabled&&e.oauthAccount?.billingType===c.billingType&&e.oauthAccount?.accountCreatedAt===c.accountCreatedAt&&e.oauthAccount?.subscriptionCreatedAt===c.subscriptionCreatedAt?e:{...e,oauthAccount:c})}var ir=e((()=>{p(),ot(),O(),K(),We(),_(),Gn()}));function ar(e,t,n){if(s(process.env.CLAUDE_CODE_REMOTE))try{xt(ur,{recursive:!0,mode:448}),Ct(e,t,{encoding:`utf8`,mode:384}),v(`Persisted ${n} to ${e} for subprocess access`)}catch(e){v(`Failed to persist ${n} to disk (non-fatal): ${g(e)}`,{level:`error`})}}function or(e,t){try{let n=Fe().readFileSync(e,{encoding:`utf8`}).trim();return n?(v(`Read ${t} from well-known file ${e}`),n):null}catch(n){return Ne(n)||v(`Failed to read ${t} from ${e}: ${g(n)}`,{level:`debug`}),null}}function sr({envVar:e,wellKnownPath:t,label:n,getCached:r,setCached:i}){let a=r();if(a!==void 0)return a;let o=process.env[e];if(!o){let e=or(t,n);return i(e),e}let s=parseInt(o,10);if(Number.isNaN(s))return v(`${e} must be a valid file descriptor number, got: ${o}`,{level:`error`}),i(null),null;try{let e=Fe(),r=process.platform===`darwin`||process.platform===`freebsd`?`/dev/fd/${s}`:`/proc/self/fd/${s}`,a=e.readFileSync(r,{encoding:`utf8`}).trim();return a?(v(`Successfully read ${n} from file descriptor ${s}`),i(a),ar(t,a,n),a):(v(`File descriptor contained empty ${n}`,{level:`error`}),i(null),null)}catch(e){v(`Failed to read ${n} from file descriptor ${s}: ${g(e)}`,{level:`error`});let r=or(t,n);return i(r),r}}function cr(){return sr({envVar:`CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR`,wellKnownPath:dr,label:`OAuth token`,getCached:we,setCached:_e})}function lr(){return sr({envVar:`CLAUDE_CODE_API_KEY_FILE_DESCRIPTOR`,wellKnownPath:fr,label:`API key`,getCached:Ee,setCached:ye})}var ur,dr,fr,pr,mr=e((()=>{m(),_(),l(),ze(),Ie(),ur=`/home/claude/.claude/remote`,dr=`${ur}/.oauth_token`,fr=`${ur}/.api_key`,pr=`${ur}/.session_ingress_token`}));function P(e=``){let t=c(),n=process.env.CLAUDE_CONFIG_DIR?`-${wt(`sha256`).update(t).digest(`hex`).substring(0,8)}`:``;return`Claude Code${D().OAUTH_FILE_SUFFIX}${e}${n}`}function hr(){try{return process.env.USER||vt().username}catch{return`claude-code-user`}}function F(){I.cache={data:null,cachedAt:0},I.generation++,I.readInFlight=null}function gr(e){if(I.cache.cachedAt!==0)return;let t=null;if(e)try{t=JSON.parse(e)}catch{return}I.cache={data:t,cachedAt:Date.now()}}var _r,I,vr=e((()=>{O(),l(),_r=`-credentials`,I={cache:{data:null,cachedAt:0},generation:0,readInFlight:null}}));async function yr(){if(process.platform===`darwin`&&(await Ye(`security delete-generic-password -a $USER -s "${P()}"`,{shell:!0,reject:!1})).exitCode!==0)throw Error(`Failed to delete keychain entry`)}function br(e){return e.slice(-20)}var xr=e((()=>{qe(),vr()}));function Sr(e){return e?.name===`CredentialsProviderError`}function Cr(e){if(!e||typeof e!=`object`)return!1;let t=e;if(!t.Credentials||typeof t.Credentials!=`object`)return!1;let n=t.Credentials;return typeof n.AccessKeyId==`string`&&typeof n.SecretAccessKey==`string`&&typeof n.SessionToken==`string`&&n.AccessKeyId.length>0&&n.SecretAccessKey.length>0&&n.SessionToken.length>0}async function wr(){let{STSClient:e,GetCallerIdentityCommand:t}=await import(`./dist-es-C-OjW2Ao.js`);await new e().send(new t({}))}async function Tr(){try{v(`Clearing AWS credential provider cache`);let{fromIni:e}=await import(`./dist-es-CIULjvtA2.js`);await e({ignoreCache:!0})(),v(`AWS credential provider cache refreshed`)}catch{v(`Failed to clear AWS credential cache (this is expected if no credentials are configured)`)}}var Er=e((()=>{_()})),Dr,Or=e((()=>{he(),ee(),Dr=class e{constructor(){te(this,`status`,{isAuthenticating:!1,output:[]}),te(this,`changed`,Te()),te(this,`subscribe`,this.changed.subscribe)}static getInstance(){return e.instance||(e.instance=new e),e.instance}getStatus(){return{...this.status,output:[...this.status.output]}}startAuthentication(){this.status={isAuthenticating:!0,output:[]},this.changed.emit(this.getStatus())}addOutput(e){this.status.output.push(e),this.changed.emit(this.getStatus())}setError(e){this.status.error=e,this.changed.emit(this.getStatus())}endAuthentication(e){e?this.status={isAuthenticating:!1,output:[]}:this.status.isAuthenticating=!1,this.changed.emit(this.getStatus())}static reset(){e.instance&&(e.instance.changed.clear(),e.instance=null)}},te(Dr,`instance`,null)})),kr,Ar,jr,Mr,Nr,Pr,Fr,Ir,Lr,Rr,zr,Br,Vr,Hr,Ur,Wr,Gr=e((()=>{kr=`claude-code-20250219`,Ar=`interleaved-thinking-2025-05-14`,jr=`context-1m-2025-08-07`,Mr=`context-management-2025-06-27`,Nr=`structured-outputs-2025-12-15`,Pr=`tool-search-tool-2025-10-19`,Fr=`effort-2025-11-24`,Ir=`task-budgets-2026-03-13`,Lr=`prompt-caching-scope-2026-01-05`,Rr=`fast-mode-2026-02-01`,zr=`redact-thinking-2026-02-12`,Br=`afk-mode-2026-01-31`,Vr=process.env.USER_TYPE===`ant`?`cli-internal-2026-02-09`:``,Hr=`advisor-tool-2026-03-01`,Ur=new Set([Ar,jr,Pr]),Wr=new Set([kr,Ar,Mr])}));function Kr(e,t){return pe(e,t)}var qr=e((()=>{ve()}));function Jr(){return`claude-code/0.0.4`}var Yr=e((()=>{}));function Xr(){return Qr.getStore()?.workload}function Zr(e,t){return Qr.run({workload:e},t)}var Qr,$r=e((()=>{Qr=new jt}));function ei(){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=Xr(),r=n?`, workload/${n}`:``;return`claude-cli/0.0.4 (${process.env.USER_TYPE}, ${process.env.CLAUDE_CODE_ENTRYPOINT??`cli`}${e}${t}${r})`}function ti(){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}`),`claude-code/0.0.4${e.length>0?` (${e.join(`, `)})`:``}`}function ni(){return`Claude-User (${Jr()}; +https://support.anthropic.com/)`}function ri(){if(B()){let e=G();return e?.accessToken?{headers:{Authorization:`Bearer ${e.accessToken}`,"anthropic-beta":lt}}:{headers:{},error:`No OAuth token available`}}let e=R();return e?{headers:{"x-api-key":e}}:{headers:{},error:`No API key available`}}async function ii(e,t){try{return await e()}catch(n){if(!f.isAxiosError(n))throw n;let r=n.response?.status;if(!(r===401||t?.also403Revoked&&r===403&&typeof n.response?.data==`string`&&n.response.data.includes(`OAuth token has been revoked`)))throw n;let i=G()?.accessToken;if(!i)throw n;return await ho(i),await e()}}var ai=e((()=>{p(),O(),K(),Yr(),$r()}));function oi(){return{error:(e,...t)=>console.error(`[Anthropic SDK ERROR]`,e,...t),warn:(e,...t)=>console.error(`[Anthropic SDK WARN]`,e,...t),info:(e,...t)=>console.error(`[Anthropic SDK INFO]`,e,...t),debug:(e,...t)=>console.error(`[Anthropic SDK DEBUG]`,e,...t)}}async function si({apiKey:e,maxRetries:n,model:r,fetchOverride:i,source:a}){let c=process.env.CLAUDE_CODE_CONTAINER_ID,l=process.env.CLAUDE_CODE_REMOTE_SESSION_ID,u=process.env.CLAUDE_AGENT_SDK_CLIENT_APP,ee=li(),te={"x-app":`cli`,"User-Agent":ei(),"X-Claude-Code-Session-Id":be(),...ee,...c?{"x-claude-remote-container-id":c}:{},...l?{"x-claude-remote-session-id":l}:{},...u?{"x-client-app":u}:{},...process.env.ANTHROPIC_AUTH_NONCE?{"x-auth-nonce":process.env.ANTHROPIC_AUTH_NONCE}:{}};v(`[API:request] Creating client, ANTHROPIC_CUSTOM_HEADERS present: ${!!process.env.ANTHROPIC_CUSTOM_HEADERS}, has Authorization header: ${!!ee.Authorization}`),s(process.env.CLAUDE_CODE_ADDITIONAL_PROTECTION)&&(te[`x-anthropic-additional-protection`]=`true`),v(`[API:auth] OAuth token check starting`),await vo(),v(`[API:auth] OAuth token check complete`),B()||await ci(te,h());let f=ui(i,a),p={defaultHeaders:te,maxRetries:n,timeout:parseInt(process.env.API_TIMEOUT_MS||`600000`,10),dangerouslyAllowBrowser:!0,fetchOptions:ht({forAnthropicAPI:!0}),...f&&{fetch:f}};if(s(process.env.CLAUDE_CODE_USE_BEDROCK)){let{BedrockClient:e}=await import(`./bedrockClient-DxE_mHFI.js`),t=r===hc()&&process.env.ANTHROPIC_SMALL_FAST_MODEL_AWS_REGION?process.env.ANTHROPIC_SMALL_FAST_MODEL_AWS_REGION:d(),n={...p,awsRegion:t,...s(process.env.CLAUDE_CODE_SKIP_BEDROCK_AUTH)&&{skipAuth:!0},...Le()&&{logger:oi()}};if(process.env.AWS_BEARER_TOKEN_BEDROCK)n.skipAuth=!0,n.defaultHeaders={...n.defaultHeaders,Authorization:`Bearer ${process.env.AWS_BEARER_TOKEN_BEDROCK}`};else if(!s(process.env.CLAUDE_CODE_SKIP_BEDROCK_AUTH)){let e=await W();e&&(n.awsAccessKey=e.accessKeyId,n.awsSecretKey=e.secretAccessKey,n.awsSessionToken=e.sessionToken)}return new e(n)}if(s(process.env.CLAUDE_CODE_USE_FOUNDRY)){let{AnthropicFoundry:e}=await import(`./foundry-sdk-BdeF2aBu.js`),t;if(!process.env.ANTHROPIC_FOUNDRY_API_KEY)if(s(process.env.CLAUDE_CODE_SKIP_FOUNDRY_AUTH))t=()=>Promise.resolve(``);else{let{DefaultAzureCredential:e,getBearerTokenProvider:n}=await import(`./esm-CGx9qY3q.js`);t=n(new e,`https://cognitiveservices.azure.com/.default`)}return new e({...p,...t&&{azureADTokenProvider:t},...Le()&&{logger:oi()}})}if(s(process.env.CLAUDE_CODE_USE_VERTEX)){s(process.env.CLAUDE_CODE_SKIP_VERTEX_AUTH)||await qo();let[{AnthropicVertex:e},{GoogleAuth:n}]=await Promise.all([import(`./vertex-sdk-DjXcZ2J7.js`),import(`./src-CiJCsqUl.js`).then(e=>t(e.default,1))]),i=process.env.GCLOUD_PROJECT||process.env.GOOGLE_CLOUD_PROJECT||process.env.gcloud_project||process.env.google_cloud_project,a=process.env.GOOGLE_APPLICATION_CREDENTIALS||process.env.google_application_credentials,c=s(process.env.CLAUDE_CODE_SKIP_VERTEX_AUTH)?{getClient:()=>({getRequestHeaders:()=>({})})}:new n({scopes:[`https://www.googleapis.com/auth/cloud-platform`],...i||a?{}:{projectId:process.env.ANTHROPIC_VERTEX_PROJECT_ID}});return new e({...p,region:o(r),googleAuth:c,...Le()&&{logger:oi()}})}return new je({apiKey:B()?null:e||R(),authToken:B()?G()?.accessToken:void 0,...process.env.USER_TYPE===`ant`&&s(process.env.USE_STAGING_OAUTH)?{baseURL:D().BASE_API_URL}:{},...p,...Le()&&{logger:oi()}})}async function ci(e,t){let n=process.env.ANTHROPIC_AUTH_TOKEN||await Ha(t);n&&(e.Authorization=`Bearer ${n}`)}function li(){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 ui(e,t){let n=e??globalThis.fetch,r=k()===`firstParty`&&fn();return(e,i)=>{let a=new Headers(i?.headers);r&&!a.has(`x-client-request-id`)&&a.set(di,Tt());try{let n=e instanceof Request?e.url:String(e),r=a.get(di);v(`[API REQUEST] ${new URL(n).pathname}${r?` ${di}=${r}`:``} source=${t??`unknown`}`)}catch{}return n(e,{...i,headers:a})}}var di,fi=e((()=>{ke(),K(),ai(),$(),A(),_t(),m(),O(),_(),l(),di=`x-client-request-id`}));function pi(){return yt(c(),`cache`)}function mi(){return yt(pi(),`model-capabilities.json`)}function hi(){return!(k()!==`firstParty`||!fn())}function gi(e){return[...e].sort((e,t)=>t.id.length-e.id.length||e.id.localeCompare(t.id))}function _i(e){if(!hi())return;let t=xi(mi());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 vi(){if(hi()&&!et())try{let e=await si({maxRetries:1}),t=B()?[lt]:void 0,n=[];for await(let r of e.models.list({betas:t})){let e=yi().safeParse(r);e.success&&n.push(e.data)}if(n.length===0)return;let r=mi(),i=gi(n);if(Kr(xi(r),i)){v(`[modelCapabilities] cache unchanged, skipping write`);return}await Et(pi(),{recursive:!0}),await Ot(r,Re({models:i,timestamp:Date.now()}),{encoding:`utf-8`,mode:384}),xi.cache.delete(r),v(`[modelCapabilities] cached ${i.length} models`)}catch(e){v(`[modelCapabilities] fetch failed: ${e instanceof Error?e.message:`unknown`}`)}}var yi,bi,xi,Si=e((()=>{qr(),i(),le(),O(),fi(),K(),_(),l(),it(),ue(),$e(),Me(),A(),yi=ce(()=>ie({id:ae(),max_input_tokens:oe().optional(),max_tokens:oe().optional()}).strip()),bi=ce(()=>ie({models:se(yi()),timestamp:oe()})),xi=r(e=>{try{let t=St(e,`utf-8`),n=bi().safeParse(at(t,!1));return n.success?n.data.models:null}catch{return null}},e=>e)}));function Ci(){return s(process.env.CLAUDE_CODE_DISABLE_1M_CONTEXT)}function L(e){return!Ci()&&/\[1m\]/i.test(e)}function wi(e){if(Ci())return!1;let t=Z(e);return t.includes(`claude-sonnet-4`)||t.includes(`opus-4-6`)||t.includes(`opus-4-7`)}function Ti(e,t){if(process.env.USER_TYPE===`ant`&&process.env.CLAUDE_CODE_MAX_CONTEXT_TOKENS){let e=parseInt(process.env.CLAUDE_CODE_MAX_CONTEXT_TOKENS,10);if(!isNaN(e)&&e>0)return e}if(L(e))return 1e6;let n=_i(e);if(n?.max_input_tokens&&n.max_input_tokens>=1e5)return n.max_input_tokens>2e5&&Ci()?Ai:n.max_input_tokens;if(t?.includes(`context-1m-2025-08-07`)&&wi(e)||Ei(e))return 1e6;if(process.env.USER_TYPE===`ant`){let t=Pt(e);if(t?.contextWindow)return t.contextWindow}return Ai}function Ei(e){return Ci()||L(e)||!Z(e).includes(`sonnet-4-6`)?!1:C().clientDataCache?.coral_reef_sonnet===`true`}function Di(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 Oi(e){let t,n;if(process.env.USER_TYPE===`ant`){let r=Pt(e.toLowerCase());if(r)return t=r.defaultMaxTokens??Mi,n=r.upperMaxTokensLimit??Ni,{default:t,upperLimit:n}}let 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=Mi,n=Ni);let i=_i(e);return i?.max_tokens&&i.max_tokens>=4096&&(n=i.max_tokens,t=Math.min(t,n)),{default:t,upperLimit:n}}function ki(e){return Oi(e).upperLimit-1}var Ai,ji,Mi,Ni,Pi,Fi=e((()=>{Gr(),We(),l(),$(),Ft(),Si(),Ai=2e5,ji=2e4,Mi=32e3,Ni=64e3,Pi=8e3})),Ii,Li,Ri,zi=e((()=>{i(),A(),Ii=[{modelEnvVar:`ANTHROPIC_DEFAULT_OPUS_MODEL`,capabilitiesEnvVar:`ANTHROPIC_DEFAULT_OPUS_MODEL_SUPPORTED_CAPABILITIES`},{modelEnvVar:`ANTHROPIC_DEFAULT_SONNET_MODEL`,capabilitiesEnvVar:`ANTHROPIC_DEFAULT_SONNET_MODEL_SUPPORTED_CAPABILITIES`},{modelEnvVar:`ANTHROPIC_DEFAULT_HAIKU_MODEL`,capabilitiesEnvVar:`ANTHROPIC_DEFAULT_HAIKU_MODEL_SUPPORTED_CAPABILITIES`}],Li=[{modelEnvVar:`OPENAI_DEFAULT_OPUS_MODEL`,capabilitiesEnvVar:`OPENAI_DEFAULT_OPUS_MODEL_SUPPORTED_CAPABILITIES`},{modelEnvVar:`OPENAI_DEFAULT_SONNET_MODEL`,capabilitiesEnvVar:`OPENAI_DEFAULT_SONNET_MODEL_SUPPORTED_CAPABILITIES`},{modelEnvVar:`OPENAI_DEFAULT_HAIKU_MODEL`,capabilitiesEnvVar:`OPENAI_DEFAULT_HAIKU_MODEL_SUPPORTED_CAPABILITIES`}],Ri=r((e,t)=>{if(k()===`firstParty`)return;let n=e.toLowerCase(),r=k()===`openai`?Li:Ii;for(let e of r){let r=process.env[e.modelEnvVar],i=process.env[e.capabilitiesEnvVar];if(!(!r||i===void 0)&&n===r.toLowerCase())return i.toLowerCase().split(`,`).map(e=>e.trim()).includes(t)}},(e,t)=>`${e.toLowerCase()}:${t}`)}));function Bi(e){let t=[],n=[];for(let r of e)Xi.includes(r)?t.push(r):n.push(r);return{allowed:t,disallowed:n}}function Vi(e){if(!e||e.length===0)return;if(B()){console.warn(`Warning: Custom betas are only available for API key users. Ignoring provided betas.`);return}let{allowed:t,disallowed:n}=Bi(e);for(let e of n)console.warn(`Warning: Beta header '${e}' is not allowed. Only the following betas are supported: ${Xi.join(`, `)}`);return t.length>0?t:void 0}function Hi(e){let t=Ri(e,`interleaved_thinking`);if(t!==void 0)return t;let n=Z(e),r=k();return r===`foundry`?!0:r===`firstParty`?!n.includes(`claude-3-`):n.includes(`claude-opus-4`)||n.includes(`claude-sonnet-4`)}function Ui(e){let t=Z(e),n=k();return n===`foundry`?!0:n===`firstParty`?!t.includes(`claude-3-`):t.includes(`claude-opus-4`)||t.includes(`claude-sonnet-4`)||t.includes(`claude-haiku-4`)}function Wi(e){let t=Z(e),n=k();return n!==`firstParty`&&n!==`foundry`?!1:t.includes(`claude-sonnet-4-6`)||t.includes(`claude-sonnet-4-5`)||t.includes(`claude-opus-4-1`)||t.includes(`claude-opus-4-5`)||t.includes(`claude-opus-4-6`)||t.includes(`claude-opus-4-7`)||t.includes(`claude-haiku-4-5`)}function Gi(e){return!0}function Ki(){return(k()===`firstParty`||k()===`foundry`)&&!s(process.env.CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS)&&fn()}function qi(){return k()===`firstParty`&&!s(process.env.CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS)}function Ji(e,t){let n=[...Qi(e)];t?.isAgenticQuery&&(n.includes(`claude-code-20250219`)||n.push(kr),process.env.USER_TYPE===`ant`&&process.env.CLAUDE_CODE_ENTRYPOINT===`cli`&&Vr&&!n.includes(Vr)&&n.push(Vr));let r=xe();return!r||r.length===0?n:[...n,...r.filter(e=>!n.includes(e))]}function Yi(){Zi.cache?.clear?.(),Qi.cache?.clear?.(),$i.cache?.clear?.()}var Xi,Zi,Qi,$i,ea=e((()=>{i(),m(),Gr(),O(),K(),Fi(),l(),$(),zi(),A(),x(),Xi=[jr],Zi=r(e=>{let t=[],n=Z(e).includes(`haiku`);k();let r=Ki();n||(t.push(kr),process.env.USER_TYPE===`ant`&&process.env.CLAUDE_CODE_ENTRYPOINT===`cli`&&Vr&&t.push(Vr)),B()&&t.push(lt),L(e)&&t.push(jr),!s(process.env.DISABLE_INTERLEAVED_THINKING)&&Hi(e)&&t.push(Ar),r&&Hi(e)&&!h()&&Ve().showThinkingSummaries!==!0&&t.push(zr);let i=s(process.env.USE_API_CONTEXT_MANAGEMENT)||Ui(e),a=Ui(e);return Ki()&&(i||a)&&t.push(Mr),r&&Wi(e),process.env.USER_TYPE,r&&t.push(Lr),process.env.ANTHROPIC_BETAS&&t.push(...process.env.ANTHROPIC_BETAS.split(`,`).map(e=>e.trim()).filter(Boolean)),t}),Qi=r(e=>{let t=Zi(e);return k()===`bedrock`?t.filter(e=>!Ur.has(e)):t}),$i=r(e=>Zi(e).filter(e=>Ur.has(e)))}));function ta(e,t){return{name:`${e.name}-with-${t.name}-fallback`,read(){return e.read()??(t.read()||{})},async readAsync(){return await e.readAsync()??(await t.readAsync()||{})},update(n){let r=e.read(),i=e.update(n);if(i.success)return r===null&&t.delete(),i;let a=t.update(n);return a.success?(r!==null&&e.delete(),{success:!0,warning:a.warning}):{success:!1}},delete(){let n=e.delete(),r=t.delete();return n||r}}}var na=e((()=>{}));async function ra(){try{let e=P(_r),{stdout:t,code:n}=await Qe(`security`,[`find-generic-password`,`-a`,hr(),`-w`,`-s`,e],{useCwd:!1,preserveOutputOnError:!1});if(n===0&&t)return De(t.trim())}catch{}return null}function ia(){if(sa!==void 0)return sa;if(process.platform!==`darwin`)return sa=!1,!1;try{sa=Ze(`security`,[`show-keychain-info`],{reject:!1,stdio:[`ignore`,`pipe`,`pipe`]}).exitCode===36}catch{sa=!1}return sa}var aa,oa,sa,ca=e((()=>{qe(),_(),Xe(),Ke(),Me(),vr(),aa=4032,oa={name:`keychain`,read(){let e=I.cache;if(Date.now()-e.cachedAt<3e4)return e.data;try{let e=P(_r),t=Je(`security find-generic-password -a "${hr()}" -w -s "${e}"`);if(t){let e=De(t);return I.cache={data:e,cachedAt:Date.now()},e}}catch{}return e.data===null?(I.cache={data:null,cachedAt:Date.now()},null):(v(`[keychain] read failed; serving stale cache`,{level:`warn`}),I.cache={data:e.data,cachedAt:Date.now()},e.data)},async readAsync(){let e=I.cache;if(Date.now()-e.cachedAt<3e4)return e.data;if(I.readInFlight)return I.readInFlight;let t=I.generation,n=ra().then(n=>{if(t===I.generation){n===null&&e.data!==null&&v(`[keychain] readAsync failed; serving stale cache`,{level:`warn`});let t=n??e.data;return I.cache={data:t,cachedAt:Date.now()},I.readInFlight=null,t}return n});return I.readInFlight=n,n},update(e){F();try{let t=P(_r),n=hr(),r=Re(e),i=Buffer.from(r,`utf-8`).toString(`hex`),a=`add-generic-password -U -a "${n}" -s "${t}" -X "${i}"\n`,o;return a.length<=aa?o=Ze(`security`,[`-i`],{input:a,stdio:[`pipe`,`pipe`,`pipe`],reject:!1}):(v(`Keychain payload (${r.length}B JSON) exceeds security -i stdin limit; using argv`,{level:`warn`}),o=Ze(`security`,[`add-generic-password`,`-U`,`-a`,n,`-s`,t,`-X`,i],{stdio:[`ignore`,`pipe`,`pipe`],reject:!1})),o.exitCode===0?(I.cache={data:e,cachedAt:Date.now()},{success:!0}):{success:!1}}catch{return{success:!1}}},delete(){F();try{let e=P(_r);return Je(`security delete-generic-password -a "${hr()}" -s "${e}"`),!0}catch{return!1}}}}));function la(){let e=c();return{storageDir:e,storagePath:yt(e,`.credentials.json`)}}var ua,da=e((()=>{l(),ze(),Ie(),Me(),ua={name:`plaintext`,read(){let{storagePath:e}=la();try{return De(Fe().readFileSync(e,{encoding:`utf8`}))}catch{return null}},async readAsync(){let{storagePath:e}=la();try{return De(await Fe().readFile(e,{encoding:`utf8`}))}catch{return null}},update(e){try{let{storageDir:t,storagePath:n}=la();try{Fe().mkdirSync(t)}catch(e){if(Ae(e)!==`EEXIST`)throw e}return Oe(n,Re(e),{encoding:`utf8`,flush:!1}),bt(n,384),{success:!0,warning:`Warning: Storing credentials in plaintext.`}}catch{return{success:!1}}},delete(){let{storagePath:e}=la();try{return Fe().unlinkSync(e),!0}catch(e){return Ae(e)===`ENOENT`}}}}));function fa(){return process.platform===`darwin`?ta(oa,ua):ua}var pa=e((()=>{na(),ca(),da()}));function ma(e){return new Promise(t=>{At(`security`,[`find-generic-password`,`-a`,hr(),`-w`,`-s`,e],{encoding:`utf-8`,timeout:ya},(e,n)=>{t({stdout:e?null:n?.trim()||null,timedOut:!!(e&&`killed`in e&&e.killed)})})})}function ha(){if(process.platform!==`darwin`||xa||u())return;let e=ma(P(_r)),t=ma(P());xa=Promise.all([e,t]).then(([e,t])=>{e.timedOut||gr(e.stdout),t.timedOut||(ba={stdout:t.stdout})})}async function ga(){xa&&await xa}function _a(){return ba}function va(){ba=null}var ya,ba,xa,Sa=e((()=>{l(),vr(),ya=1e4,ba=null,xa=null}));function Ca(e,t,n){return new Promise((r,i)=>{if(t?.aborted){n?.throwOnAbort||n?.abortError?i(n.abortError?.()??Error(`aborted`)):r();return}let a=setTimeout((e,t,n)=>{e?.removeEventListener(`abort`,t),n()},e,t,o,r);function o(){clearTimeout(a),n?.throwOnAbort||n?.abortError?i(n.abortError?.()??Error(`aborted`)):r()}t?.addEventListener(`abort`,o,{once:!0}),n?.unref&&a.unref()})}var wa=e((()=>{}));function Ta(){return Da}function Ea(){Da.clear()}var Da,Oa=e((()=>{Da=new Map})),ka=n({calculateApiKeyHelperTTL:()=>Ba,checkAndRefreshOAuthTokenIfNeeded:()=>vo,checkGcpCredentialsValid:()=>eo,clearApiKeyHelperCache:()=>Ka,clearAwsCredentialsCache:()=>Za,clearGcpCredentialsCache:()=>ro,clearOAuthTokenCache:()=>po,getAccountInformation:()=>Ro,getAnthropicApiKey:()=>R,getAnthropicApiKeyWithSource:()=>Pa,getApiKeyFromApiKeyHelper:()=>Ha,getApiKeyFromApiKeyHelperCached:()=>Ga,getApiKeyFromConfigOrMacOSKeychain:()=>Jo,getApiKeyHelperElapsedMs:()=>Va,getAuthTokenSource:()=>Ma,getClaudeAIOAuthTokens:()=>G,getClaudeAIOAuthTokensAsync:()=>_o,getConfiguredApiKeyHelper:()=>z,getOauthAccountInfo:()=>So,getOtelHeadersFromHelper:()=>Fo,getRateLimitTier:()=>Ao,getSubscriptionName:()=>jo,getSubscriptionType:()=>V,handleOAuth401Error:()=>ho,hasAnthropicApiKeyAuth:()=>Na,hasOpusAccess:()=>wo,hasProfileScope:()=>bo,is1PApiCustomer:()=>xo,isAnthropicAuthEnabled:()=>ja,isAwsAuthRefreshFromProjectSettings:()=>La,isAwsCredentialExportFromProjectSettings:()=>za,isClaudeAISubscriber:()=>B,isConsumerSubscriber:()=>Lo,isCustomApiKeyApproved:()=>co,isEnterpriseSubscriber:()=>Oo,isGcpAuthRefreshFromProjectSettings:()=>$a,isMaxSubscriber:()=>To,isOtelHeadersHelperFromProjectOrLocalSettings:()=>Po,isOverageProvisioningAllowed:()=>Co,isProSubscriber:()=>ko,isTeamPremiumSubscriber:()=>Do,isTeamSubscriber:()=>Eo,isUsing3PServices:()=>Mo,prefetchApiKeyFromApiKeyHelperIfSafe:()=>qa,prefetchAwsCredentialsAndBedRockInfoIfSafe:()=>ao,prefetchGcpCredentialsIfSafe:()=>io,refreshAndGetAwsCredentials:()=>W,refreshAwsAuth:()=>Ya,refreshGcpAuth:()=>no,refreshGcpCredentialsIfNeeded:()=>qo,removeApiKey:()=>lo,saveApiKey:()=>so,saveOAuthTokensIfNeeded:()=>fo,validateForceLoginOrg:()=>zo});function Aa(){return s(process.env.CLAUDE_CODE_REMOTE)||process.env.CLAUDE_CODE_ENTRYPOINT===`claude-desktop`}function ja(){if(u())return!1;if(process.env.ANTHROPIC_UNIX_SOCKET)return!!process.env.CLAUDE_CODE_OAUTH_TOKEN;let e=b()||{},t=s(process.env.CLAUDE_CODE_USE_BEDROCK)||s(process.env.CLAUDE_CODE_USE_VERTEX)||s(process.env.CLAUDE_CODE_USE_FOUNDRY)||e.modelType===`openai`||e.modelType===`gemini`||!!process.env.OPENAI_BASE_URL||!!process.env.GEMINI_BASE_URL,n=e.apiKeyHelper,r=process.env.ANTHROPIC_AUTH_TOKEN||n||process.env.CLAUDE_CODE_API_KEY_FILE_DESCRIPTOR,{source:i}=Pa({skipRetrievingKeyFromApiKeyHelper:!0}),a=i===`ANTHROPIC_API_KEY`||i===`apiKeyHelper`;return!(t||r&&!Aa()||a&&!Aa())}function Ma(){if(u())return z()?{source:`apiKeyHelper`,hasToken:!0}:{source:`none`,hasToken:!1};if(process.env.ANTHROPIC_AUTH_TOKEN&&!Aa())return{source:`ANTHROPIC_AUTH_TOKEN`,hasToken:!0};if(process.env.CLAUDE_CODE_OAUTH_TOKEN)return{source:`CLAUDE_CODE_OAUTH_TOKEN`,hasToken:!0};if(cr())return process.env.CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR?{source:`CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR`,hasToken:!0}:{source:`CCR_OAUTH_TOKEN_FILE`,hasToken:!0};if(z()&&!Aa())return{source:`apiKeyHelper`,hasToken:!0};let e=G();return Kn(e?.scopes)&&e?.accessToken?{source:`claude.ai`,hasToken:!0}:{source:`none`,hasToken:!1}}function R(){let{key:e}=Pa();return e}function Na(){let{key:e,source:t}=Pa({skipRetrievingKeyFromApiKeyHelper:!0});return e!==null&&t!==`none`}function Pa(e={}){if(u())return process.env.ANTHROPIC_API_KEY?{key:process.env.ANTHROPIC_API_KEY,source:`ANTHROPIC_API_KEY`}:z()?{key:e.skipRetrievingKeyFromApiKeyHelper?null:Ga(),source:`apiKeyHelper`}:{key:null,source:`none`};let t=a()?void 0:process.env.ANTHROPIC_API_KEY;if(Ce()&&t)return{key:t,source:`ANTHROPIC_API_KEY`};if(s(process.env.CI)){let e=lr();if(e)return{key:e,source:`ANTHROPIC_API_KEY`};if(!t&&!process.env.CLAUDE_CODE_OAUTH_TOKEN&&!process.env.CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR)throw Error(`ANTHROPIC_API_KEY or CLAUDE_CODE_OAUTH_TOKEN env var is required`);return t?{key:t,source:`ANTHROPIC_API_KEY`}:{key:null,source:`none`}}if(t&&C().customApiKeyResponses?.approved?.includes(br(t)))return{key:t,source:`ANTHROPIC_API_KEY`};let n=lr();return n?{key:n,source:`ANTHROPIC_API_KEY`}:z()?e.skipRetrievingKeyFromApiKeyHelper?{key:null,source:`apiKeyHelper`}:{key:Ga(),source:`apiKeyHelper`}:Jo()||{key:null,source:`none`}}function z(){return u()?y(`flagSettings`)?.apiKeyHelper:(b()||{}).apiKeyHelper}function Fa(){let e=z();if(!e)return!1;let t=y(`projectSettings`),n=y(`localSettings`);return t?.apiKeyHelper===e||n?.apiKeyHelper===e}function Ia(){return(b()||{}).awsAuthRefresh}function La(){let e=Ia();if(!e)return!1;let t=y(`projectSettings`),n=y(`localSettings`);return t?.awsAuthRefresh===e||n?.awsAuthRefresh===e}function Ra(){return(b()||{}).awsCredentialExport}function za(){let e=Ra();if(!e)return!1;let t=y(`projectSettings`),n=y(`localSettings`);return t?.awsCredentialExport===e||n?.awsCredentialExport===e}function Ba(){let e=process.env.CLAUDE_CODE_API_KEY_HELPER_TTL_MS;if(e){let t=parseInt(e,10);if(!Number.isNaN(t)&&t>=0)return t;v(`Found CLAUDE_CODE_API_KEY_HELPER_TTL_MS env var, but it was not a valid number. Got ${e}`,{level:`error`})}return Bo}function Va(){let e=U?.startedAt;return e?Date.now()-e:0}async function Ha(e){if(!z())return null;let t=Ba();return H?(Date.now()-H.timestamp<t||U||(U={promise:Ua(e,!1,Vo),startedAt:null}),H.value):(U||(U={promise:Ua(e,!0,Vo),startedAt:Date.now()}),U.promise)}async function Ua(e,t,n){try{let t=await Wa(e);return n===Vo&&t!==null&&(H={value:t,timestamp:Date.now()}),t}catch(e){if(n!==Vo)return` `;let r=e instanceof Error?e.message:String(e);return console.error(re.red(`apiKeyHelper failed: ${r}`)),v(`Error getting API key from apiKeyHelper: ${r}`,{level:`error`}),!t&&H&&H.value!==` `?(H={...H,timestamp:Date.now()},H.value):(H={value:` `,timestamp:Date.now()},` `)}finally{n===Vo&&(U=null)}}async function Wa(e){let t=z();if(!t)return null;if(Fa()&&!w()&&!e)return Pe(`apiKeyHelper invoked before trust check`,Error(`Security: apiKeyHelper executed before workspace trust is confirmed. If you see this message, post in .`)),E(`tengu_apiKeyHelper_missing_trust11`,{}),null;let n=await Ye(t,{shell:!0,timeout:600*1e3,reject:!1});if(n.failed){let e=n.timedOut?`timed out`:`exited ${n.exitCode}`,t=n.stderr?.trim();throw Error(t?`${e}: ${t}`:e)}let r=n.stdout?.trim();if(!r)throw Error(`did not return a value`);return r}function Ga(){return H?.value??null}function Ka(){Vo++,H=null,U=null}function qa(e){Fa()&&!w()||Ha(e)}async function Ja(){let e=Ia();if(!e)return!1;if(La()&&!w()&&!h())return Pe(`awsAuthRefresh invoked before trust check`,Error(`Security: awsAuthRefresh executed before workspace trust is confirmed. If you see this message, post in .`)),E(`tengu_awsAuthRefresh_missing_trust`,{}),!1;try{return v(`Fetching AWS caller identity for AWS auth refresh command`),await wr(),v(`Fetched AWS caller identity, skipping AWS auth refresh command`),!1}catch{return Ya(e)}}function Ya(e){v(`Running AWS auth refresh command`);let t=Dr.getInstance();return t.startAuthentication(),new Promise(n=>{let r=kt(e,{timeout:Uo});r.stdout.on(`data`,e=>{let n=e.toString().trim();n&&(t.addOutput(n),v(n,{level:`debug`}))}),r.stderr.on(`data`,e=>{let n=e.toString().trim();n&&(t.setError(n),v(n,{level:`error`}))}),r.on(`close`,(e,r)=>{if(e===0)v(`AWS auth refresh completed successfully`),t.endAuthentication(!0),n(!0);else{let e=r===`SIGTERM`?re.red(`AWS auth refresh timed out after 3 minutes. Run your auth command manually in a separate terminal.`):re.red(`Error running awsAuthRefresh (in settings or ~/.claude.json):`);console.error(e),t.endAuthentication(!1),n(!1)}})})}async function Xa(){let e=Ra();if(!e)return null;if(za()&&!w()&&!h())return Pe(`awsCredentialExport invoked before trust check`,Error(`Security: awsCredentialExport executed before workspace trust is confirmed. If you see this message, post in .`)),E(`tengu_awsCredentialExport_missing_trust`,{}),null;try{return v(`Fetching AWS caller identity for credential export command`),await wr(),v(`Fetched AWS caller identity, skipping AWS credential export command`),null}catch{try{v(`Running AWS credential export command`);let t=await Ye(e,{shell:!0,reject:!1});if(t.exitCode!==0||!t.stdout)throw Error(`awsCredentialExport did not return a valid value`);let n=De(t.stdout.trim());if(!Cr(n))throw Error(`awsCredentialExport did not return valid AWS STS output structure`);return v(`AWS credentials retrieved from awsCredentialExport`),{accessKeyId:n.Credentials.AccessKeyId,secretAccessKey:n.Credentials.SecretAccessKey,sessionToken:n.Credentials.SessionToken}}catch(e){let t=re.red(`Error getting AWS credentials from awsCredentialExport (in settings or ~/.claude.json):`);return e instanceof Error?console.error(t,e.message):console.error(t,e),null}}}function Za(){W.cache.clear()}function Qa(){return(b()||{}).gcpAuthRefresh}function $a(){let e=Qa();if(!e)return!1;let t=y(`projectSettings`),n=y(`localSettings`);return t?.gcpAuthRefresh===e||n?.gcpAuthRefresh===e}async function eo(){try{let{GoogleAuth:e}=await import(`./src-CiJCsqUl.js`).then(e=>t(e.default,1)),n=new e({scopes:[`https://www.googleapis.com/auth/cloud-platform`]}),r=(async()=>{await(await n.getClient()).getAccessToken()})(),i=Ca(Wo).then(()=>{throw new ts(`GCP credentials check timed out`)});return await Promise.race([r,i]),!0}catch{return!1}}async function to(){let e=Qa();if(!e)return!1;if($a()&&!w()&&!h())return Pe(`gcpAuthRefresh invoked before trust check`,Error(`Security: gcpAuthRefresh executed before workspace trust is confirmed. If you see this message, post in .`)),E(`tengu_gcpAuthRefresh_missing_trust`,{}),!1;try{if(v(`Checking GCP credentials validity for auth refresh`),await eo())return v(`GCP credentials are valid, skipping auth refresh command`),!1}catch{}return no(e)}function no(e){v(`Running GCP auth refresh command`);let t=Dr.getInstance();return t.startAuthentication(),new Promise(n=>{let r=kt(e,{timeout:Ko});r.stdout.on(`data`,e=>{let n=e.toString().trim();n&&(t.addOutput(n),v(n,{level:`debug`}))}),r.stderr.on(`data`,e=>{let n=e.toString().trim();n&&(t.setError(n),v(n,{level:`error`}))}),r.on(`close`,(e,r)=>{if(e===0)v(`GCP auth refresh completed successfully`),t.endAuthentication(!0),n(!0);else{let e=r===`SIGTERM`?re.red(`GCP auth refresh timed out after 3 minutes. Run your auth command manually in a separate terminal.`):re.red(`Error running gcpAuthRefresh (in settings or ~/.claude.json):`);console.error(e),t.endAuthentication(!1),n(!1)}})})}function ro(){qo.cache.clear()}function io(){Qa()&&($a()&&!w()&&!h()||qo())}function ao(){let e=Ia(),t=Ra();!e&&!t||(La()||za())&&!w()&&!h()||(W(),j())}function oo(e){return/^[a-zA-Z0-9-_]+$/.test(e)}async function so(e){if(!oo(e))throw Error(`Invalid API key format. API key must contain only alphanumeric characters, dashes, and underscores.`);await uo();let t=!1;if(process.platform===`darwin`)try{let n=P();await Ye(`security`,[`-i`],{input:`add-generic-password -U -a "${hr()}" -s "${n}" -X "${Buffer.from(e,`utf-8`).toString(`hex`)}"\n`,reject:!1}),E(`tengu_api_key_saved_to_keychain`,{}),t=!0}catch(e){T(e),E(`tengu_api_key_keychain_error`,{error:g(e)}),E(`tengu_api_key_saved_to_config`,{})}else E(`tengu_api_key_saved_to_config`,{});let n=br(e);S(r=>{let i=r.customApiKeyResponses?.approved??[];return{...r,primaryApiKey:t?r.primaryApiKey:e,customApiKeyResponses:{...r.customApiKeyResponses,approved:i.includes(n)?i:[...i,n],rejected:r.customApiKeyResponses?.rejected??[]}}}),Jo.cache.clear?.(),va()}function co(e){let t=C(),n=br(e);return t.customApiKeyResponses?.approved?.includes(n)??!1}async function lo(){await uo(),S(e=>({...e,primaryApiKey:void 0})),Jo.cache.clear?.(),va()}async function uo(){try{await yr()}catch(e){T(e)}}function fo(e){if(!Kn(e.scopes))return E(`tengu_oauth_tokens_not_claude_ai`,{}),{success:!0};if(!e.refreshToken||!e.expiresAt)return E(`tengu_oauth_tokens_inference_only`,{}),{success:!0};let t=fa(),n=t.name;try{let r=t.read()||{},i=r.claudeAiOauth;r.claudeAiOauth={accessToken:e.accessToken,refreshToken:e.refreshToken,expiresAt:e.expiresAt,scopes:e.scopes,subscriptionType:e.subscriptionType??i?.subscriptionType??null,rateLimitTier:e.rateLimitTier??i?.rateLimitTier??null};let a=t.update(r);return a.success?E(`tengu_oauth_tokens_saved`,{storageBackend:n}):E(`tengu_oauth_tokens_save_failed`,{storageBackend:n}),G.cache?.clear?.(),Yi(),Ea(),a}catch(e){return T(e),E(`tengu_oauth_tokens_save_exception`,{storageBackend:n,error:g(e)}),{success:!1,warning:`Failed to save OAuth tokens`}}}function po(){G.cache?.clear?.(),F()}async function mo(){try{let{mtimeMs:e}=await Dt(yt(c(),`.credentials.json`));e!==Yo&&(Yo=e,po())}catch{G.cache?.clear?.()}}function ho(e){let t=Xo.get(e);if(t)return t;let n=go(e).finally(()=>{Xo.delete(e)});return Xo.set(e,n),n}async function go(e){po();let t=await _o();return t?.refreshToken?t.accessToken===e?vo(0,!0):(E(`tengu_oauth_401_recovered_from_keychain`,{}),!0):!1}async function _o(){if(u())return null;if(process.env.CLAUDE_CODE_OAUTH_TOKEN||cr())return G();try{let e=(await fa().readAsync())?.claudeAiOauth;return e?.accessToken?e:null}catch(e){return T(e),null}}function vo(e=0,t=!1){return e===0&&!t?Zo||(Zo=yo(e,t).finally(()=>{Zo=null}),Zo):yo(e,t)}async function yo(e,t){await mo();let n=G();if(!t&&(!n?.refreshToken||!$n(n.expiresAt))||!n?.refreshToken||!Kn(n.scopes))return!1;G.cache?.clear?.(),F();let r=await _o();if(!r?.refreshToken||!$n(r.expiresAt))return!1;let i=c();await Et(i,{recursive:!0});let a;try{E(`tengu_oauth_token_refresh_lock_acquiring`,{}),a=await Ge(i),E(`tengu_oauth_token_refresh_lock_acquired`,{})}catch(n){return n.code===`ELOCKED`?e<5?(E(`tengu_oauth_token_refresh_lock_retry`,{retryCount:e+1}),await Ca(1e3+Math.random()*1e3),yo(e+1,t)):(E(`tengu_oauth_token_refresh_lock_retry_limit_reached`,{maxRetries:5}),!1):(T(n),E(`tengu_oauth_token_refresh_lock_error`,{error:g(n)}),!1)}try{G.cache?.clear?.(),F();let e=await _o();return!e?.refreshToken||!$n(e.expiresAt)?(E(`tengu_oauth_token_refresh_race_resolved`,{}),!1):(E(`tengu_oauth_token_refresh_starting`,{}),fo(await Xn(e.refreshToken,{scopes:Kn(e.scopes)?void 0:e.scopes})),G.cache?.clear?.(),F(),!0)}catch(e){T(e),G.cache?.clear?.(),F();let t=await _o();return t&&!$n(t.expiresAt)?(E(`tengu_oauth_token_refresh_race_recovered`,{}),!0):!1}finally{E(`tengu_oauth_token_refresh_lock_releasing`,{}),await a(),E(`tengu_oauth_token_refresh_lock_released`,{})}}function B(){return ja()?Kn(G()?.scopes):!1}function bo(){return G()?.scopes?.includes(`user:profile`)??!1}function xo(){return!(s(process.env.CLAUDE_CODE_USE_BEDROCK)||s(process.env.CLAUDE_CODE_USE_VERTEX)||s(process.env.CLAUDE_CODE_USE_FOUNDRY)||B())}function So(){return ja()?C().oauthAccount:void 0}function Co(){let e=So()?.billingType;return!(!B()||!e||e!==`stripe_subscription`&&e!==`stripe_subscription_contracted`&&e!==`apple_subscription`&&e!==`google_play_subscription`)}function wo(){let e=V();return e===`max`||e===`enterprise`||e===`team`||e===`pro`||e===null}function V(){if(Nn())return Mn();if(!ja())return null;let e=G();return e?e.subscriptionType??null:null}function To(){return V()===`max`}function Eo(){return V()===`team`}function Do(){return V()===`team`&&Ao()===`default_claude_max_5x`}function Oo(){return V()===`enterprise`}function ko(){return V()===`pro`}function Ao(){if(!ja())return null;let e=G();return e?e.rateLimitTier??null:null}function jo(){switch(V()){case`enterprise`:return`Claude Enterprise`;case`team`:return`Claude Team`;case`max`:return`Claude Max`;case`pro`:return`Claude Pro`;default:return`Claude API`}}function Mo(){return!!(s(process.env.CLAUDE_CODE_USE_BEDROCK)||s(process.env.CLAUDE_CODE_USE_VERTEX)||s(process.env.CLAUDE_CODE_USE_FOUNDRY)||s(process.env.CLAUDE_CODE_USE_OPENAI)||s(process.env.CLAUDE_CODE_USE_GEMINI)||s(process.env.CLAUDE_CODE_USE_GROK))}function No(){return(b()||{}).otelHeadersHelper}function Po(){let e=No();if(!e)return!1;let t=y(`projectSettings`),n=y(`localSettings`);return t?.otelHeadersHelper===e||n?.otelHeadersHelper===e}function Fo(){let e=No();if(!e)return{};let t=parseInt(process.env.CLAUDE_CODE_OTEL_HEADERS_HELPER_DEBOUNCE_MS||es.toString(),10);if(Qo&&Date.now()-$o<t)return Qo;if(Po()&&!w())return{};try{let t=Je(e,{timeout:3e4})?.toString().trim();if(!t)throw Error(`otelHeadersHelper did not return a valid value`);let n=De(t);if(typeof n!=`object`||!n||Array.isArray(n))throw Error(`otelHeadersHelper must return a JSON object with string key-value pairs`);for(let[e,t]of Object.entries(n))if(typeof t!=`string`)throw Error(`otelHeadersHelper returned non-string value for key "${e}": ${typeof t}`);return Qo=n,$o=Date.now(),Qo}catch(e){throw T(Error(`Error getting OpenTelemetry headers from otelHeadersHelper (in settings): ${g(e)}`)),e}}function Io(e){return e===`max`||e===`pro`}function Lo(){let e=V();return B()&&e!==null&&Io(e)}function Ro(){if(k()!==`firstParty`)return;let{source:e}=Ma(),t={};e===`CLAUDE_CODE_OAUTH_TOKEN`||e===`CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR`?t.tokenSource=e:B()?t.subscription=jo():t.tokenSource=e;let{key:n,source:r}=Pa();if(n&&(t.apiKeySource=r),e===`claude.ai`||r===`/login managed key`){let e=So()?.organizationName;e&&(t.organization=e)}let i=So()?.emailAddress;return(e===`claude.ai`||r===`/login managed key`)&&i&&(t.email=i),t}async function zo(){if(process.env.ANTHROPIC_UNIX_SOCKET||!ja())return{valid:!0};let e=y(`policySettings`)?.forceLoginOrgUUID;if(!e)return{valid:!0};await vo();let t=G();if(!t)return{valid:!0};let{source:n}=Ma(),r=n===`CLAUDE_CODE_OAUTH_TOKEN`||n===`CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR`,i=await Wn(t.accessToken);if(!i)return{valid:!1,message:`Unable to verify organization for the current authentication token.\nThis machine requires organization ${e} but the profile could not be fetched.\nThis may be a network error, or the token may lack the user:profile scope required for\nverification (tokens from 'claude setup-token' do not include this scope).\nTry again, or obtain a full-scope token via 'claude auth login'.`};let a=i.organization.uuid;return a===e?{valid:!0}:r?{valid:!1,message:`The ${n===`CLAUDE_CODE_OAUTH_TOKEN`?`CLAUDE_CODE_OAUTH_TOKEN`:`CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR`} environment variable provides a token for a\ndifferent organization than required by this machine's managed settings.\n\nRequired organization: ${e}\nToken organization: ${a}\n\nRemove the environment variable or obtain a token for the correct organization.`}:{valid:!1,message:`Your authentication token belongs to organization ${a},\nbut this machine requires organization ${e}.\n\nPlease log in with the correct organization: claude auth login`}}var Bo,H,U,Vo,Ho,Uo,W,Wo,Go,Ko,qo,Jo,G,Yo,Xo,Zo,Qo,$o,es,ts,K=e((()=>{ne(),qe(),i(),O(),ot(),xn(),A(),m(),Hn(),ir(),Gn(),mr(),xr(),Er(),Or(),ea(),We(),_(),l(),ze(),Xe(),Ue(),tt(),rt(),pa(),Sa(),vr(),x(),wa(),Me(),Oa(),Bo=300*1e3,H=null,U=null,Vo=0,Ho=3600*1e3,Uo=180*1e3,W=nt(async()=>{let e=await Ja(),t=await Xa();return(e||t)&&await Tr(),t},Ho),Wo=5e3,Go=3600*1e3,Ko=180*1e3,qo=nt(async()=>await to(),Go),Jo=r(()=>{if(u())return null;if(process.platform===`darwin`){let e=_a();if(e){if(e.stdout)return{key:e.stdout,source:`/login managed key`}}else{let e=P();try{let t=Je(`security find-generic-password -a $USER -w -s "${e}"`);if(t)return{key:t,source:`/login managed key`}}catch(e){T(e)}}}let e=C();return e.primaryApiKey?{key:e.primaryApiKey,source:`/login managed key`}:null}),G=r(()=>{if(u())return null;if(process.env.CLAUDE_CODE_OAUTH_TOKEN)return{accessToken:process.env.CLAUDE_CODE_OAUTH_TOKEN,refreshToken:null,expiresAt:null,scopes:[`user:inference`],subscriptionType:null,rateLimitTier:null};let e=cr();if(e)return{accessToken:e,refreshToken:null,expiresAt:null,scopes:[`user:inference`],subscriptionType:null,rateLimitTier:null};try{let e=fa().read()?.claudeAiOauth;return e?.accessToken?e:null}catch(e){return T(e),null}}),Yo=0,Xo=new Map,Zo=null,Qo=null,$o=0,es=1740*1e3,ts=class extends Error{}}));function q(){return!s(process.env.CLAUDE_CODE_DISABLE_FAST_MODE)}function ns(){return q()?is()===null:!1}function rs(e,t){switch(e){case`free`:return t===`oauth`?`Fast mode requires a paid subscription`:`Fast mode unavailable during evaluation. Please purchase credits.`;case`preference`:return`Fast mode has been disabled by your organization`;case`extra_usage_disabled`:return`Fast mode requires extra usage billing · /extra-usage to enable`;case`network_error`:return`Fast mode unavailable due to network connectivity issues`;case`unknown`:return`Fast mode is currently unavailable`}}function is(){if(!q())return`Fast mode is not available`;if(dt(),h()&&Ce()&&!fe()&&!y(`flagSettings`)?.fastMode){let e=`Fast mode is not available in the Agent SDK`;return v(`Fast mode unavailable: ${e}`),e}if(k()!==`firstParty`){let e=`Fast mode is not available on Bedrock, Vertex, or Foundry`;return v(`Fast mode unavailable: ${e}`),e}if(J.status===`disabled`){if((J.reason===`network_error`||J.reason===`unknown`)&&s(process.env.CLAUDE_CODE_SKIP_FAST_MODE_NETWORK_ERRORS))return null;let e=G()===null?`api-key`:`oauth`,t=rs(J.reason,e);return v(`Fast mode unavailable: ${t}`),t}return null}function as(){return`opus`+(kc()?`[1m]`:``)}function os(e){if(!q()||!ns()||!ss(e))return!1;let t=Ve();return!t.fastModePerSessionOptIn&&t.fastMode===!0}function ss(e){if(!q())return!1;let t=Q(e??wc());return t.toLowerCase().includes(`opus-4-7`)||t.toLowerCase().includes(`opus-4-6`)}function cs(){return xs.status===`cooldown`&&Date.now()>=xs.resetAt&&(q()&&!Ss&&(v(`Fast mode cooldown expired, re-enabling fast mode`),Ss=!0,ws.emit()),xs={status:`active`}),xs}function ls(e,t){if(!q())return;xs={status:`cooldown`,resetAt:e,reason:t},Ss=!1;let n=e-Date.now();v(`Fast mode cooldown triggered (${t}), duration ${Math.round(n/1e3)}s`),E(`tengu_fast_mode_fallback_triggered`,{cooldown_duration_ms:n,cooldown_reason:t}),Cs.emit(e,t)}function us(){xs={status:`active`}}function ds(){J.status!==`disabled`&&(J={status:`disabled`,reason:`preference`},He(`userSettings`,{fastMode:void 0}),S(e=>({...e,penguinModeOrgEnabled:!1})),ks.emit(!1))}function fs(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 · /extra-usage to enable`;default:return`Fast mode disabled · extra usage not available`}}function ps(e){return e===`org_level_disabled_until`||e===`out_of_credits`}function ms(e){let t=fs(e);v(`Fast mode overage rejection: ${e??`unknown`} — ${t}`),E(`tengu_fast_mode_overage_rejected`,{overage_disabled_reason:e??`unknown`}),ps(e)||(He(`userSettings`,{fastMode:void 0}),S(e=>({...e,penguinModeOrgEnabled:!1}))),Ds.emit(t)}function hs(){return cs().status===`cooldown`}function gs(e,t){let n=q()&&ns()&&!!t&&ss(e);return n&&hs()?`cooldown`:n?`on`:`off`}async function _s(e){let t=`${D().BASE_API_URL}/api/claude_code_penguin_mode`,n=`accessToken`in e?{Authorization:`Bearer ${e.accessToken}`,"anthropic-beta":lt}:{"x-api-key":e.apiKey};return(await f.get(t,{headers:n})).data}function vs(){if(!q()||J.status!==`pending`)return;let e=process.env.USER_TYPE===`ant`,t=C().penguinModeOrgEnabled===!0;J=e||t?{status:`enabled`}:{status:`disabled`,reason:`unknown`}}async function ys(){if(et()||!q())return;if(Ns)return v(`Fast mode prefetch in progress, returning in-flight promise`),Ns;let e=R();if(!(G()?.accessToken&&bo())&&!e){let e=process.env.USER_TYPE===`ant`,t=C().penguinModeOrgEnabled===!0;J=e||t?{status:`enabled`}:{status:`disabled`,reason:`preference`};return}let t=Date.now();if(t-Ms<js){v(`Skipping fast mode prefetch, fetched recently`);return}Ms=t;let n=async()=>{let t=G(),n=t?.accessToken&&bo()?{accessToken:t.accessToken}:e?{apiKey:e}:null;if(!n)throw Error(`No auth available`);return _s(n)};async function r(){try{let e;try{e=await n()}catch(t){if(f.isAxiosError(t)&&(t.response?.status===401||t.response?.status===403&&typeof t.response?.data==`string`&&t.response.data.includes(`OAuth token has been revoked`))){let r=G()?.accessToken;if(r)await ho(r),e=await n();else throw t}else throw t}let t=J.status===`pending`?C().penguinModeOrgEnabled:J.status===`enabled`;J=e.enabled?{status:`enabled`}:{status:`disabled`,reason:e.disabled_reason??`preference`},t!==e.enabled&&(e.enabled||He(`userSettings`,{fastMode:void 0}),S(t=>({...t,penguinModeOrgEnabled:e.enabled})),ks.emit(e.enabled)),v(`Org fast mode: ${e.enabled?`enabled`:`disabled (${e.disabled_reason??`preference`})`}`)}catch(e){let t=process.env.USER_TYPE===`ant`,n=C().penguinModeOrgEnabled===!0;J=t||n?{status:`enabled`}:{status:`disabled`,reason:`network_error`},v(`Failed to fetch org fast mode status, defaulting to ${J.status===`enabled`?`enabled (cached)`:`disabled (network_error)`}: ${e}`,{level:`error`}),E(`tengu_org_penguin_mode_fetch_failed`,{})}finally{Ns=null}}return Ns=r(),Ns}var bs,xs,Ss,Cs,ws,Ts,Es,Ds,Os,J,ks,As,js,Ms,Ns,Ps=e((()=>{p(),O(),m(),ot(),K(),ft(),We(),_(),l(),$(),A(),$e(),x(),he(),bs=`Opus 4.7`,xs={status:`active`},Ss=!1,Cs=Te(),ws=Te(),Ts=Cs.subscribe,Es=ws.subscribe,Ds=Te(),Os=Ds.subscribe,J={status:`pending`},ks=Te(),As=ks.subscribe,js=3e4,Ms=0,Ns=null}));function Fs(e){return q()&&e?Ks:Gs}function Is(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 Ls(e,t){let n=Z(e);return n===X(an.firstParty)?Fs(t.speed===`fast`):Xs[n]||(Rs(e,n),Xs[Z(wc())]??Ys)}function Rs(e,t){E(`tengu_unknown_model_cost`,{model:e,shortName:t}),me()}function zs(e,t){return Is(Ls(e,t),t)}function Bs(e,t){return zs(e,{input_tokens:t.inputTokens,output_tokens:t.outputTokens,cache_read_input_tokens:t.cacheReadInputTokens,cache_creation_input_tokens:t.cacheCreationInputTokens})}function Vs(e){return Number.isInteger(e)?`$${e}`:`$${e.toFixed(2)}`}function Hs(e){return`${Vs(e.inputTokens)}/${Vs(e.outputTokens)} per Mtok`}var Us,Ws,Gs,Ks,qs,Js,Ys,Xs,Zs=e((()=>{ot(),m(),Ps(),un(),$(),Us={inputTokens:3,outputTokens:15,promptCacheWriteTokens:3.75,promptCacheReadTokens:.3,webSearchRequests:.01},Ws={inputTokens:15,outputTokens:75,promptCacheWriteTokens:18.75,promptCacheReadTokens:1.5,webSearchRequests:.01},Gs={inputTokens:5,outputTokens:25,promptCacheWriteTokens:6.25,promptCacheReadTokens:.5,webSearchRequests:.01},Ks={inputTokens:30,outputTokens:150,promptCacheWriteTokens:37.5,promptCacheReadTokens:3,webSearchRequests:.01},qs={inputTokens:.8,outputTokens:4,promptCacheWriteTokens:1,promptCacheReadTokens:.08,webSearchRequests:.01},Js={inputTokens:1,outputTokens:5,promptCacheWriteTokens:1.25,promptCacheReadTokens:.1,webSearchRequests:.01},Ys=Gs,Xs={[X(Zt.firstParty)]:qs,[X(Qt.firstParty)]:Js,[X(Xt.firstParty)]:Us,[X(Yt.firstParty)]:Us,[X($t.firstParty)]:Us,[X(en.firstParty)]:Us,[X(sn.firstParty)]:Us,[X(tn.firstParty)]:Ws,[X(nn.firstParty)]:Ws,[X(rn.firstParty)]:Gs,[X(an.firstParty)]:Gs}}));function Qs(e){return ec.includes(e)}function $s(e){return tc.includes(e)}var ec,tc,nc=e((()=>{ec=[`sonnet`,`opus`,`haiku`,`best`,`sonnet[1m]`,`opus[1m]`,`opusplan`],tc=[`sonnet`,`opus`,`haiku`]}));function rc(e,t){return e.includes(t)?!0:Qs(e)?Q(e).toLowerCase().includes(t):!1}function ic(e,t){return e.startsWith(t)?e.length===t.length||e[t.length]===`-`:!1}function ac(e,t){let n=Qs(e)?Q(e).toLowerCase():e;return!!(ic(n,t)||!t.startsWith(`claude-`)&&ic(n,`claude-${t}`))}function oc(e,t){for(let n of t){if($s(n))continue;let t=n.indexOf(e);if(t===-1)continue;let r=t+e.length;if(r===n.length||n[r]===`-`)return!0}return!1}function sc(e){let{availableModels:t}=b()||{};if(!t)return!0;if(t.length===0)return!1;let n=gn(e).trim().toLowerCase(),r=t.map(e=>e.trim().toLowerCase());if(r.includes(n)&&(!$s(n)||!oc(n,r)))return!0;for(let e of r)if($s(e)&&!oc(e,r)&&rc(n,e))return!0;if(Qs(n)){let e=Q(n).toLowerCase();if(r.includes(e))return!0}for(let e of r)if(!$s(e)&&Qs(e)&&Q(e).toLowerCase()===n)return!0;for(let e of r)if(!$s(e)&&!Qs(e)&&ac(n,e))return!0;return!1}var cc=e((()=>{x(),nc(),$(),xn()}));function lc(){return process.env.OPENAI_AUTH_MODE===`chatgpt`}function uc(e){let t=e.toLowerCase().replace(/\[1m\]$/,``);return pc.some(e=>e.value.toLowerCase()===t)}var dc,fc,pc,mc=e((()=>{dc=`gpt-5.5`,fc=`gpt-5.4-mini`,pc=[{value:`gpt-5.5`,label:`GPT-5.5`,description:`Frontier model for complex coding, research, and real-world work`},{value:`gpt-5.4`,label:`GPT-5.4`,description:`Strong model for everyday coding`},{value:`gpt-5.4-mini`,label:`GPT-5.4-Mini`,description:`Small, fast, and cost-efficient model for simpler coding tasks`},{value:`gpt-5.3-codex`,label:`GPT-5.3-Codex`,description:`Coding-optimized model`},{value:`gpt-5.3-codex-spark`,label:`GPT-5.3-Codex-Spark`,description:`Ultra-fast coding model`},{value:`gpt-5.2`,label:`GPT-5.2`,description:`Optimized for professional work and long-running agents`}]}));function hc(){let e=k();return e===`openai`&&lc()?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||Sc()}function gc(e){return e===j().opus40||e===j().opus41||e===j().opus45||e===j().opus46||e===j().opus47}function _c(){let e,t=ge();if(t!==void 0)e=t;else{let t=b()||{};e=process.env.ANTHROPIC_MODEL||t.model||void 0}if(!(e&&!sc(e)))return e}function vc(){let e=_c();return e==null?Tc():Q(e)}function yc(){return Y()}function bc(){let e=k();if(e===`openai`)return process.env.OPENAI_MODEL;if(e===`gemini`)return process.env.GEMINI_MODEL;if(e===`grok`)return process.env.GROK_MODEL}function Y(){let e=k();return e===`openai`&&lc()?dc: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:bc()||j().opus47}function xc(){let e=k();return e===`openai`&&lc()?dc: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:bc()||(e===`firstParty`?j().sonnet46:j().sonnet45)}function Sc(){let e=k();return e===`openai`&&lc()?fc: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:bc()||j().haiku45}function Cc(e){let{permissionMode:t,mainLoopModel:n,exceeds200kTokens:r=!1}=e;return _c()===`opusplan`&&t===`plan`&&!r?Y():_c()===`haiku`&&t===`plan`?xc():n}function wc(){return process.env.USER_TYPE===`ant`?Mt()?.defaultModel??Y()+`[1m]`:To()||Do()?Y()+(kc()?`[1m]`:``):xc()}function Tc(){return Q(wc())}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&&t[1]?t[1]:e}function Z(e){return X(gn(e))}function Ec(e=!1){return To()||Do()?kc()?`Opus 4.7 with 1M context · Most capable for complex work${e?Oc(!0):``}`:`Opus 4.7 · Most capable for complex work${e?Oc(!0):``}`:`Sonnet 4.6 · Best for everyday tasks`}function Dc(e){return e===`opusplan`?`Opus 4.7 in plan mode, else Sonnet 4.6`:Nc(Q(e))}function Oc(e){if(k()!==`firstParty`)return``;let t=Hs(Fs(e));return` ·${e?` (↯)`:``} ${t}`}function kc(){return!(Ci()||ko()||k()!==`firstParty`||!fn()||B()&&V()===null)}function Ac(e){return e===`opusplan`?`Opus Plan`:Qs(e)?pt(e):Nc(e)}function jc(e){switch(e){case j().opus47:return`Opus 4.7`;case j().opus47+`[1m]`:return`Opus 4.7 (1M context)`;case j().opus46:return`Opus 4.6`;case j().opus46+`[1m]`:return`Opus 4.6 (1M context)`;case j().opus45:return`Opus 4.5`;case j().opus41:return`Opus 4.1`;case j().opus40:return`Opus 4`;case j().sonnet46+`[1m]`:return`Sonnet 4.6 (1M context)`;case j().sonnet46:return`Sonnet 4.6`;case j().sonnet45+`[1m]`:return`Sonnet 4.5 (1M context)`;case j().sonnet45:return`Sonnet 4.5`;case j().sonnet40:return`Sonnet 4`;case j().sonnet40+`[1m]`:return`Sonnet 4 (1M context)`;case j().sonnet37:return`Sonnet 3.7`;case j().sonnet35:return`Sonnet 3.5`;case j().haiku45:return`Haiku 4.5`;case j().haiku35:return`Haiku 3.5`;default:return null}}function Mc(e){let[t=``,...n]=e.split(`-`);return[t.slice(0,3)+`*`.repeat(Math.max(0,t.length-3)),...n].join(`-`)}function Nc(e){let t=jc(e);if(t)return t;if(process.env.USER_TYPE===`ant`){let t=Q(e),n=Pt(e);return n?Mc(n.model.replace(/\[1m\]$/i,``))+(L(t)?`[1m]`:``):t===e?t:`${e} (${t})`}return e}function Q(e){let t=e.trim(),n=t.toLowerCase(),r=L(n),i=r?n.replace(/\[1m]$/i,``).trim():n;if(Qs(i))switch(i){case`opusplan`:return xc()+(r?`[1m]`:``);case`sonnet`:return xc()+(r?`[1m]`:``);case`haiku`:return Sc()+(r?`[1m]`:``);case`opus`:return Y()+(r?`[1m]`:``);case`best`:return yc();default:}if(k()===`firstParty`&&Fc(i)&&Ic())return Y()+(r?`[1m]`:``);if(process.env.USER_TYPE===`ant`){let e=L(n),t=Pt(n.replace(/\[1m]$/i,``).trim());if(t){let n=e?`[1m]`:``;return t.model+n}}return r?t.replace(/\[1m\]$/i,``).trim()+`[1m]`:t}function Pc(e,t){return L(e)||!L(t)?e:wi(Q(e))?e+`[1m]`:e}function Fc(e){return Bc.includes(e)}function Ic(){return!s(process.env.CLAUDE_CODE_DISABLE_LEGACY_MODEL_REMAP)}function Lc(e){if(e===null)return process.env.USER_TYPE===`ant`?`Default for Ants (${Dc(wc())})`:B()?`Default (${Ec()})`:`Default (${Tc()})`;let t=Q(e);return e===t?t:`${e} (${t})`}function Rc(e){if(k()===`foundry`)return;let t=e.toLowerCase().includes(`[1m]`),n=Z(e);if(n.includes(`claude-opus-4-7`))return t?`Opus 4.7 (with 1M context)`:`Opus 4.7`;if(n.includes(`claude-opus-4-6`))return t?`Opus 4.6 (with 1M context)`:`Opus 4.6`;if(n.includes(`claude-opus-4-5`))return`Opus 4.5`;if(n.includes(`claude-opus-4-1`))return`Opus 4.1`;if(n.includes(`claude-opus-4`))return`Opus 4`;if(n.includes(`claude-sonnet-4-6`))return t?`Sonnet 4.6 (with 1M context)`:`Sonnet 4.6`;if(n.includes(`claude-sonnet-4-5`))return t?`Sonnet 4.5 (with 1M context)`:`Sonnet 4.5`;if(n.includes(`claude-sonnet-4`))return t?`Sonnet 4 (with 1M context)`:`Sonnet 4`;if(n.includes(`claude-3-7-sonnet`))return`Claude 3.7 Sonnet`;if(n.includes(`claude-3-5-sonnet`))return`Claude 3.5 Sonnet`;if(n.includes(`claude-haiku-4-5`))return`Haiku 4.5`;if(n.includes(`claude-3-5-haiku`))return`Claude 3.5 Haiku`}function zc(e){return e.replace(/\[(1|2)m\]/gi,``)}var Bc,$=e((()=>{m(),Ft(),K(),Fi(),l(),xn(),Zs(),x(),A(),Be(),cc(),nc(),mt(),mc(),Bc=[`claude-opus-4-20250514`,`claude-opus-4-1-20250805`,`claude-opus-4-0`,`claude-opus-4-1`]}));export{ms as $,fi as $n,An as $r,Co as $t,mc as A,Ji as An,br as Ar,_o as At,Xs as B,ji as Bn,Zn as Br,bo as Bt,Q as C,It as Ci,fa as Cn,Wr as Cr,Pa as Ct,Pc as D,Pt as Di,Yi as Dn,Er as Dr,Va as Dt,Ac as E,Ft as Ei,ia as En,Or as Er,Jo as Et,ec as F,Ki as Fn,ar as Fr,jo as Ft,Zs as G,Ei as Gn,qn as Gr,za as Gt,zs as H,Ti as Hn,tr as Hr,xo as Ht,nc as I,qi as In,or as Ir,V as It,as as J,Ci as Jn,Kn as Jr,co as Jt,bs as K,L as Kn,nr as Kr,B as Kt,qs as L,Ri as Ln,Jn as Lr,ho as Lt,uc as M,ea as Mn,vr as Mr,So as Mt,cc as N,Gi as Nn,pr as Nr,Fo as Nt,dc as O,Vi as On,Sr as Or,Ma as Ot,sc as P,Wi as Pn,mr as Pr,Ao as Pt,os as Q,si as Qn,Gn as Qr,Po as Qt,Js as R,zi as Rn,Qn as Rr,Na as Rt,zc as S,Lt as Si,ha as Sn,Ir as Sr,R as St,Nc as T,Nt as Ti,ca as Tn,Dr as Tr,Ga as Tt,Hs as U,ki as Un,ir as Ur,ja as Ut,Bs as V,Di as Vn,er as Vr,K as Vt,Fs as W,Oi as Wn,$n as Wr,La as Wt,gs as X,vi as Xn,Un as Xr,$a as Xt,cs as Y,Si as Yn,rr as Yr,Oo as Yt,is as Z,di as Zn,Wn as Zr,To as Zt,$ as _,Bt as _i,Oa as _n,Fr as _r,Ka as _t,Sc as a,jn as ai,ao as an,ii as ar,ss as at,kc as b,Jt as bi,ga as bn,zr as br,po as bt,Y as c,En as ci,Ya as cn,Zr as cr,Os as ct,Rc as d,xn as di,lo as dn,qr as dr,vs as dt,Fn as ei,ko as en,ri as er,ds as et,Oc as f,k as fi,so as fn,Kr as fr,ls as ft,_c as g,Wt as gi,Ta as gn,Mr as gr,eo as gt,hc as h,fn as hi,Ea as hn,jr as hr,vo as ht,Ec as i,Pn as ii,qa as in,ai as ir,q as it,lc as j,Qi as jn,F as jr,z as jt,pc as k,$i as kn,xr as kr,G as kt,xc as l,vn as li,no as ln,Jr as lr,As as lt,Cc as m,A as mi,zo as mn,Br as mr,Ba as mt,yc as n,On as ni,Eo as nn,ei as nr,ns as nt,Tc as o,wn as oi,io as on,Xr as or,Es as ot,jc as p,dn as pi,fo as pn,Hr as pr,ka as pt,us as q,Fi as qn,Xn as qr,Lo as qt,Z as r,Hn as ri,Mo as rn,ni as rr,hs as rt,wc as s,Sn as si,W as sn,$r as sr,Ts as st,X as t,Dn as ti,Do as tn,ti as tr,Ps as tt,vc as u,j as ui,qo as un,Yr as ur,ys as ut,Ic as v,Ut as vi,wa as vn,Rr as vr,Za as vt,Dc as w,Mt as wi,pa as wn,Gr as wr,Ha as wt,Lc as x,Vt as xi,Sa as xn,Nr as xr,Ro as xt,gc as y,Kt as yi,Ca as yn,Lr as yr,ro as yt,Us as z,Pi as zn,Yn as zr,wo as zt};
@@ -1 +1 @@
1
- import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{di as n,fi as r,ui as i}from"./src-CDCSSo0U2.js";import{t as a}from"./jsx-runtime-Bb4Xn-E0.js";import{Ad as o,fS as s,gh as c,hh as l,kd as u,lS as d,mh as f,uS as p}from"./loadAgentsDir-ZQwvbURI.js";import{D as m,E as h,Y as g}from"./log-Duzb4o6h.js";import{n as _,r as v}from"./analytics-BotDBGh0.js";import{F as y,I as b,N as x,P as S,_ as C,at as w,b as T,it as E,nt as D,q as O,s as k,tt as A,w as j}from"./model-BgrLt7P7.js";import{i as M,n as N,r as P,t as F}from"./extraUsage-DtWi8E78.js";function I({onDone:e}){let t=p(e=>e.mainLoopModel),n=p(e=>e.mainLoopModelForSession),r=p(e=>e.fastMode),a=s();function o(){v(`tengu_model_command_menu`,{action:`cancel`});let n=H(t);e(`Kept model as ${i.bold(n)}`,{display:`system`})}function c(n,o){v(`tengu_model_command_menu`,{action:n,from_model:t,to_model:n}),a(e=>({...e,mainLoopModel:n,mainLoopModelForSession:null}));let s=`Set model to ${i.bold(H(n))}`;o!==void 0&&(s+=` with ${i.bold(o)} effort`);let c;E()&&(O(),!w(n)&&r?(a(e=>({...e,fastMode:!1})),c=!1):w(n)&&D()&&r&&(s+=` · Fast mode ON`,c=!0)),N(n,c===!0,T())&&(s+=` · Billed as extra usage`),c===!1&&(s+=` · Fast mode OFF`),e(s)}return(0,W.jsx)(P,{initial:t,sessionModel:n,onSelect:c,onCancel:o,isStandaloneCommand:!0,showFastModeNotice:E()&&r&&w(t)&&D()})}function L({args:e,onDone:t}){let n=p(e=>e.fastMode),r=s(),a=e==="default"?null:e;return U.useEffect(()=>{async function e(){if(a&&!S(a)){t(`Model '${a}' is not available. Your organization restricts model selection.`,{display:`system`});return}if(a&&z(a)){t(`Opus 4.7 with 1M context is not available for your account. Learn more: https://code.claude.com/docs/en/model-config#extended-context-with-1m`,{display:`system`});return}if(a&&B(a)){t(`Sonnet 4.6 with 1M context is not available for your account. Learn more: https://code.claude.com/docs/en/model-config#extended-context-with-1m`,{display:`system`});return}if(!a){s(null);return}if(R(a)){s(a);return}try{let{valid:e,error:n}=await o(a);e?s(a):t(n||`Model '${a}' not found`,{display:`system`})}catch(e){t(`Failed to validate model: ${e.message}`,{display:`system`})}}function s(e){r(t=>({...t,mainLoopModel:e,mainLoopModelForSession:null}));let a=`Set model to ${i.bold(H(e))}`,o;E()&&(O(),!w(e)&&n?(r(e=>({...e,fastMode:!1})),o=!1):w(e)&&n&&(a+=` · Fast mode ON`,o=!0)),N(e,o===!0,T())&&(a+=` · Billed as extra usage`),o===!1&&(a+=` · Fast mode OFF`),t(a)}e()},[a,t,r]),null}function R(e){return y.includes(e.toLowerCase().trim())}function z(e){let t=e.toLowerCase();return!f()&&!T()&&t.includes(`opus`)&&t.includes(`[1m]`)}function B(e){let t=e.toLowerCase();return!l()&&(t.includes(`sonnet[1m]`)||t.includes(`sonnet-4-6[1m]`))}function V({onDone:e}){let t=p(e=>e.mainLoopModel),n=p(e=>e.mainLoopModelForSession),r=p(e=>e.effortValue),a=H(t),o=r===void 0?``:` (effort: ${r})`;return e(n?`Current model: ${i.bold(H(n))} (session override from plan mode)\nBase model: ${a}${o}`:`Current model: ${a}${o}`),null}function H(e){let t=j(e??k());return e===null?`${t} (default)`:t}var U,W,G;e((()=>{n(),U=t(r(),1),M(),g(),_(),d(),F(),A(),b(),c(),C(),x(),u(),W=a(),G=async(e,t,n)=>{if(n=n?.trim()||``,m.includes(n))return v(`tengu_model_command_inline_help`,{args:n}),(0,W.jsx)(V,{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,W.jsx)(L,{args:n,onDone:e})):(0,W.jsx)(I,{onDone:e})}}))();export{G as call};
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{di as n,fi as r,ui as i}from"./src-CDCSSo0U2.js";import{t as a}from"./jsx-runtime-Bb4Xn-E0.js";import{Ad as o,JS as s,XS as c,gh as l,hh as u,kd as d,mh as f,qS as p}from"./loadAgentsDir-BURvZNN6.js";import{D as m,E as h,Y as g}from"./log-BMCygSzM.js";import{n as _,r as v}from"./analytics-BotDBGh0.js";import{F as y,I as b,N as x,P as S,_ as C,at as w,b as T,it as E,nt as D,q as O,s as k,tt as A,w as j}from"./model-BIVmcl_N.js";import{i as M,n as N,r as P,t as F}from"./extraUsage-2DwLEr26.js";function I({onDone:e}){let t=s(e=>e.mainLoopModel),n=s(e=>e.mainLoopModelForSession),r=s(e=>e.fastMode),a=c();function o(){v(`tengu_model_command_menu`,{action:`cancel`});let n=H(t);e(`Kept model as ${i.bold(n)}`,{display:`system`})}function l(n,o){v(`tengu_model_command_menu`,{action:n,from_model:t,to_model:n}),a(e=>({...e,mainLoopModel:n,mainLoopModelForSession:null}));let s=`Set model to ${i.bold(H(n))}`;o!==void 0&&(s+=` with ${i.bold(o)} effort`);let c;E()&&(O(),!w(n)&&r?(a(e=>({...e,fastMode:!1})),c=!1):w(n)&&D()&&r&&(s+=` · Fast mode ON`,c=!0)),N(n,c===!0,T())&&(s+=` · Billed as extra usage`),c===!1&&(s+=` · Fast mode OFF`),e(s)}return(0,W.jsx)(P,{initial:t,sessionModel:n,onSelect:l,onCancel:o,isStandaloneCommand:!0,showFastModeNotice:E()&&r&&w(t)&&D()})}function L({args:e,onDone:t}){let n=s(e=>e.fastMode),r=c(),a=e==="default"?null:e;return U.useEffect(()=>{async function e(){if(a&&!S(a)){t(`Model '${a}' is not available. Your organization restricts model selection.`,{display:`system`});return}if(a&&z(a)){t(`Opus 4.7 with 1M context is not available for your account. Learn more: https://code.claude.com/docs/en/model-config#extended-context-with-1m`,{display:`system`});return}if(a&&B(a)){t(`Sonnet 4.6 with 1M context is not available for your account. Learn more: https://code.claude.com/docs/en/model-config#extended-context-with-1m`,{display:`system`});return}if(!a){s(null);return}if(R(a)){s(a);return}try{let{valid:e,error:n}=await o(a);e?s(a):t(n||`Model '${a}' not found`,{display:`system`})}catch(e){t(`Failed to validate model: ${e.message}`,{display:`system`})}}function s(e){r(t=>({...t,mainLoopModel:e,mainLoopModelForSession:null}));let a=`Set model to ${i.bold(H(e))}`,o;E()&&(O(),!w(e)&&n?(r(e=>({...e,fastMode:!1})),o=!1):w(e)&&n&&(a+=` · Fast mode ON`,o=!0)),N(e,o===!0,T())&&(a+=` · Billed as extra usage`),o===!1&&(a+=` · Fast mode OFF`),t(a)}e()},[a,t,r]),null}function R(e){return y.includes(e.toLowerCase().trim())}function z(e){let t=e.toLowerCase();return!f()&&!T()&&t.includes(`opus`)&&t.includes(`[1m]`)}function B(e){let t=e.toLowerCase();return!u()&&(t.includes(`sonnet[1m]`)||t.includes(`sonnet-4-6[1m]`))}function V({onDone:e}){let t=s(e=>e.mainLoopModel),n=s(e=>e.mainLoopModelForSession),r=s(e=>e.effortValue),a=H(t),o=r===void 0?``:` (effort: ${r})`;return e(n?`Current model: ${i.bold(H(n))} (session override from plan mode)\nBase model: ${a}${o}`:`Current model: ${a}${o}`),null}function H(e){let t=j(e??k());return e===null?`${t} (default)`:t}var U,W,G;e((()=>{n(),U=t(r(),1),M(),g(),_(),p(),F(),A(),b(),l(),C(),x(),d(),W=a(),G=async(e,t,n)=>{if(n=n?.trim()||``,m.includes(n))return v(`tengu_model_command_inline_help`,{args:n}),(0,W.jsx)(V,{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,W.jsx)(L,{args:n,onDone:e})):(0,W.jsx)(I,{onDone:e})}}))();export{G as call};
@@ -0,0 +1 @@
1
+ import{_ as e,u as t}from"./model-BIVmcl_N.js";e();export{t as getMainLoopModel};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{l as t,o as n}from"./envUtils-DSxRz_kt.js";import{n as r,t as i}from"./axios-DaWTGg7G.js";import{E as a,F as o,I as s,S as c,V as l,W as u,a as d,d as f,l as p,nt as m,p as ee,rt as te,w as h,z as g}from"./debug-BrXObCdR.js";import{Jt as ne,Zt as re}from"./settings-DfWP5y6X.js";import{C as ie,S as ae,b as oe,c as se,g as ce,w as _}from"./config-DiT2Z8dY.js";import{n as v,r as y}from"./execFileNoThrow-D244NytW.js";import{o as b,s as x}from"./log-BMCygSzM.js";import{n as S,r as C}from"./analytics-BotDBGh0.js";import{vn as le,yn as ue}from"./model-BIVmcl_N.js";import{ft as de,ut as fe}from"./esm-B62dCLgf.js";import{n as pe,r as me,t as he}from"./semver-BMRJYn3q.js";import{C as ge,S as _e,_ as ve,a as w,b as ye,c as be,d as xe,g as Se,h as Ce,i as we,l as Te,n as Ee,o as T,p as De,s as Oe,t as ke,v as E,x as Ae,y as je}from"./pidLock-C69HNTTb.js";import{a as Me,i as Ne,n as Pe,r as Fe,t as Ie}from"./xdg-DcF9ejUM.js";import{homedir as D}from"os";import{basename as Le,delimiter as Re,dirname as O,join as k,resolve as A}from"path";import{constants as ze}from"fs";import{createHash as Be}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 Ve,stat as z,symlink as He,unlink as B,writeFile as V}from"fs/promises";async function Ue(e=`latest`){let t=Date.now(),{stdout:n,code:r,stderr:i}=await v(`npm`,[`view`,`@${e}`,`version`,`--prefer-online`,`--registry`,U],{timeout:3e4,preserveOutputOnError:!0}),a=Date.now()-t;if(r!==0){C(`tengu_version_check_failure`,{latency_ms:a,source_npm:!0,exit_code:r});let e=Error(`npm view failed with code ${r}: ${i}`);throw x(e),e}return C(`tengu_version_check_success`,{latency_ms:a,source_npm:!0}),p(`npm view @${e} version: ${n}`),n.trim()}async function We(e=`latest`,t,n){let i=Date.now();try{let a=await r.get(`${t}/${e}`,{timeout:3e4,responseType:`text`,...n});return C(`tengu_version_check_success`,{latency_ms:Date.now()-i}),a.data.trim()}catch(n){let a=Date.now()-i,o=n instanceof Error?n.message:String(n),s;r.isAxiosError(n)&&n.response&&(s=n.response.status),C(`tengu_version_check_failure`,{latency_ms:a,http_status:s,is_timeout:o.includes(`timeout`)});let c=Error(`Failed to fetch version from ${t}/${e}: ${o}`);throw x(c),c}}async function Ge(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 process.env.USER_TYPE===`ant`?Ue(t===`stable`?`stable`:`latest`):We(t,H)}async function Ke(e,t){let n=f();await n.rm(t,{recursive:!0,force:!0});let r=W(),i=`-${r}`;p(`Fetching integrity hash for ${i}@${e}`);let{stdout:o,code:s,stderr:c}=await v(`npm`,[`view`,`${i}@${e}`,`dist.integrity`,`--registry`,U],{timeout:3e4,preserveOutputOnError:!0});if(s!==0)throw Error(`npm view integrity failed with code ${s}: ${c}`);let l=o.trim();if(!l)throw Error(`Failed to fetch integrity hash for ${i}@${e}`);p(`Got integrity hash for ${r}: ${l}`),await n.mkdir(t);let u={name:`claude-native-installer`,version:`0.0.1`,dependencies:{"":e}},d={name:`claude-native-installer`,version:`0.0.1`,lockfileVersion:3,requires:!0,packages:{"":{name:`claude-native-installer`,version:`0.0.1`,dependencies:{"":e}},"node_modules/":{version:e,optionalDependencies:{[i]:e}},[`node_modules/${i}`]:{version:e,integrity:l}}};a(k(t,`package.json`),h(u,null,2),{encoding:`utf8`,flush:!0}),a(k(t,`package-lock.json`),h(d,null,2),{encoding:`utf8`,flush:!0});let m=await v(`npm`,[`ci`,`--prefer-online`,`--registry`,U],{timeout:6e4,preserveOutputOnError:!0,cwd:t});if(m.code!==0)throw Error(`npm ci failed with code ${m.code}: ${m.stderr}`);p(`Successfully downloaded and verified @${e}`)}function qe(){return Number(process.env.CLAUDE_CODE_STALL_TIMEOUT_MS_FOR_TESTING)||Ze}async function Je(e,t,n,i={}){let a;for(let o=1;o<=3;o++){let s=new AbortController,c,l=()=>{c&&(clearTimeout(c),c=void 0)},d=()=>{l(),c=setTimeout(e=>e.abort(),qe(),s)};try{d();let a=await r.get(e,{timeout:5*6e4,responseType:`arraybuffer`,signal:s.signal,onDownloadProgress:()=>{d()},...i});l();let o=Be(`sha256`);o.update(a.data);let c=o.digest(`hex`);if(c!==t)throw Error(`Checksum mismatch: expected ${t}, got ${c}`);await V(n,Buffer.from(a.data)),await M(n,493);return}catch(e){l();let t=r.isCancel(e);if(a=t?new Qe:u(e),t&&o<3){p(`Download stalled on attempt ${o}/3, retrying...`),await ue(1e3);continue}throw a}}throw a??Error(`Download failed after all retries`)}async function Ye(e,t,n,i){let a=f();await a.rm(t,{recursive:!0,force:!0});let o=W(),s=Date.now();C(`tengu_binary_download_attempt`,{});let c;try{c=(await r.get(`${n}/${e}/manifest.json`,{timeout:1e4,responseType:`json`,...i})).data}catch(t){let i=Date.now()-s,a=t instanceof Error?t.message:String(t),o;throw r.isAxiosError(t)&&t.response&&(o=t.response.status),C(`tengu_binary_manifest_fetch_failure`,{latency_ms:i,http_status:o,is_timeout:a.includes(`timeout`)}),x(Error(`Failed to fetch manifest from ${n}/${e}/manifest.json: ${a}`)),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),p=`${n}/${e}/${o}/${d}`;await a.mkdir(t);let m=k(t,d);try{await Je(p,u,m,i||{}),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),i;throw r.isAxiosError(e)&&e.response&&(i=e.response.status),C(`tengu_binary_download_failure`,{latency_ms:t,http_status:i,is_timeout:n.includes(`timeout`),is_checksum_mismatch:n.includes(`Checksum mismatch`)}),x(Error(`Failed to download binary from ${p}: ${n}`)),e}}async function Xe(e,t){return process.env.USER_TYPE===`ant`?(await Ke(e,t),`npm`):(await Ye(e,t,H),`binary`)}var H,U,Ze,Qe,$e=e((()=>{i(),S(),d(),g(),y(),ee(),b(),le(),c(),$(),H=`https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases`,U=`https://artifactory.infra.ant.dev/artifactory/api/npm/npm-all/`,Ze=6e4,Qe=class extends Error{constructor(){super(`Download stalled: no data received for 60 seconds`),this.name=`StallTimeoutError`}}}));function W(){let e=ne.platform,t=process.arch===`x64`?`x64`:process.arch===`arm64`?`arm64`:null;if(!t){let e=Error(`Unsupported architecture: ${process.arch}`);throw p(`Native installer does not support architecture: ${process.arch}`,{level:`error`}),e}return e===`linux`&&fe.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(Fe(),`claude`,`versions`),staging:k(Pe(),`claude`,`staging`),locks:k(Ne(),`claude`,`locks`),executable:k(Ie(),e)}}async function q(e){try{let t=await z(e);return!t.isFile()||t.size===0?!1:(await j(e,ze.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 V(r,``,{encoding:`utf8`})}return{stagingPath:k(t.staging,e),installPath:r}}async function et(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 x(e),e}}))return C(`tengu_version_lock_acquired`,{is_pid_based:!0,is_lifetime_lock:!1,attempts:r+1}),!0;r++,r<a&&await ue(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 _(e,{stale:Z,retries:{retries:n,minTimeout:n>0?1e3:100,maxTimeout:n>0?5e3:500},lockfilePath:i,onCompromised:e=>{p(`NON-FATAL: Version lock was compromised during operation: ${e.message}`,{level:`info`})}})}catch(t){return 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 x(e),e}}finally{a&&await a()}}async function tt(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),p(`Atomically installed binary to ${t}`)}catch(e){try{await B(n)}catch{}throw e}}async function nt(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 tt(i,t),await R(e,{recursive:!0,force:!0}),C(`tengu_native_install_package_success`,{})}catch(e){let t=o(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}),x(u(e)),e}}async function rt(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 tt(n,t),await R(e,{recursive:!0,force:!0}),C(`tengu_native_install_binary_success`,{})}catch(e){throw o(e).includes(`Staged binary not found`)||C(`tengu_native_install_binary_failure`,{stage_atomic_move:!0,error_move_failed:!0}),x(u(e)),e}}async function it(e,t,n){n===`npm`?await nt(e,t):await rt(e,t)}async function at(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 ot(e)||n;if(s?(p(n?`Force reinstalling native installer version ${e}`:`Downloading native installer version ${e}`),await it(o,i,await Xe(e,o))):p(`Version ${e} already installed, updating symlink`),await ct(a),await lt(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 ot(e){let{installPath:t}=await J(e);return q(t)}async function st(e,n=!1){let r=Date.now(),i=await Ge(e),{executable:a}=K();if(p(`Checking for native installer update to version ${i}`),!n){let e=await De();if(e&&he(i,e)){if(p(`Native installer: maxVersion ${e} is set, capping update from ${i} to ${e}`),pe(`0.0.4`,e))return p(`Native installer: current version 0.0.4 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.4`&&await ot(i)&&await q(a))return p(`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&&Se(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 at(i,n),s=Date.now()-r;else{let{installPath:e}=await J(i);n&&await ht(e);let t=await et(e,async()=>{o=await at(i,n)},3);if(s=Date.now()-r,!t){let t=K(),n;if(T()){let r=Y(t,e);w(r)&&(n=Oe(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}),p(`Successfully updated to version ${i}`),{success:!0,latestVersion:i}}async function ct(e){try{await Ve(e),p(`Removed empty directory at ${e}`)}catch(t){let n=s(t);n!==`ENOTDIR`&&n!==`ENOENT`&&n!==`ENOTEMPTY`&&p(`Could not remove directory at ${e}: ${t}`)}}async function lt(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 x(n),n}throw t}}else try{await N(t,e)}catch(e){throw l(e)?Error(`Source file does not exist: ${t}`):e}return!0}catch(n){return x(Error(`Failed to copy executable from ${t} to ${e}: ${n}`)),!1}let n=O(e);try{await P(n,{recursive:!0}),p(`Created directory ${n} for symlink`)}catch(e){return x(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){x(Error(`Failed to check/remove existing symlink: ${e}`))}let r=`${e}.tmp.${process.pid}.${Date.now()}`;try{return await He(t,r),await L(r,e),p(`Atomically updated symlink ${e} -> ${t}`),!0}catch(n){try{await B(r)}catch{}return x(Error(`Failed to create symlink from ${e} to ${t}: ${n}`)),!1}}async function ut(e=!1){if(t(process.env.DISABLE_INSTALLATION_CHECKS))return[];let n=await Te();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:`Claude symlink points to missing or invalid binary: ${e}`,userActionRequired:!0,type:`error`})}catch(e){l(e)?i.push({message:`installMethod is native, but claude command not found at ${r.executable}`,userActionRequired:!0,type:`error`}):await q(r.executable)||i.push({message:`${r.executable} exists but is not a valid Claude binary`,userActionRequired:!0,type:`error`})}if(!(process.env.PATH||``).split(Re).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 dt(e,t=!1){if(t)return ft(e,t);if(Q)return p(`installLatest: joining in-flight call`),Q;let n=ft(e,t);Q=n;let r=()=>{Q=null};return n.then(r,r),n}async function ft(e,t=!1){let n=await st(e,t);return n.success?(se().installMethod!==`native`&&(oe(e=>({...e,installMethod:`native`,autoUpdates:!1,autoUpdatesProtectedForNative:!0})),p(`Native installer: Set installMethod to "native" and disabled legacy auto-updater for protection`)),gt(),{latestVersion:n.latestVersion,wasUpdated:n.success,lockFailed:!1}):{latestVersion:null,wasUpdated:!1,lockFailed:n.lockFailed,lockHolderPid:n.lockHolderPid}}async function pt(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=Le(t);return k(e.locks,`${n}.lock`)}async function mt(){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 ke(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}),p(`Acquired PID lock on running version: ${t}`)}else{let e;try{e=await _(t,{stale:Z,retries:0,lockfilePath:n,onCompromised:e=>{p(`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}),p(`Acquired mtime-based lock on running version: ${t}`),te(async()=>{try{await e?.()}catch{}})}catch(e){if(l(e)){p(`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(l(e)){p(`Cannot lock current version - file does not exist: ${t}`,{level:`info`});return}p(`NON-FATAL: Failed to lock current version during execution ${o(e)}`,{level:`info`})}}function X(e,t){x(Error(`NON-FATAL: Lock acquisition failed for ${e} (expected in multi-process scenarios)`,{cause:t}))}async function ht(e){let t=Y(K(),e);try{await B(t),p(`Force-removed lock file at ${t}`)}catch(e){p(`Failed to force-remove lock file: ${o(e)}`)}}async function gt(){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&&p(`Cleaned up ${n} old Windows executables on startup`)}catch(e){l(e)||p(`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++,p(`Cleaned up old staging directory: ${i}`))}catch{}}r>0&&(p(`Cleaned up ${r} orphaned staging directories`),C(`tengu_native_staging_cleanup`,{cleaned_count:r}))}catch(e){l(e)||p(`Failed to clean up staging directories: ${e}`)}if(T()){let t=Ee(e.locks);t>0&&(p(`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){l(e)||p(`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++,p(`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&&(p(`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&&t.includes(e.versions)&&n.add(A(t));let i=await pt(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 ae(t.resolvedPath,{stale:Z,lockfilePath:r})}catch{i=!1}i&&(n.add(t.resolvedPath),p(`Protecting locked version from cleanup: ${t.name}`))}let a=r.filter(e=>!n.has(e.resolvedPath)).sort((e,t)=>t.mtime.getTime()-e.mtime.getTime()).slice(2);if(a.length===0){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 et(e.path,async()=>{await B(e.path)})?o++:(s++,p(`Skipping deletion of ${e.name} - locked by another process`))}catch(t){c++,x(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){l(e)||x(Error(`Version cleanup failed: ${e}`))}}async function _t(){let e=[],t=E();for(let[n,r]of Object.entries(t))try{let t=await ye(r);if(!t)continue;let{filtered:i,hadAlias:a}=ve(t);a&&(await Ae(r,i),e.push({message:`Removed claude alias from ${r}. Run: unalias claude`,userActionRequired:!0,type:`alias`}),p(`Cleaned up claude alias from ${n} config`))}catch(t){x(t),e.push({message:`Failed to clean up ${r}: ${t}`,userActionRequired:!1,type:`error`})}return e}async function vt(e){try{let t=await v(`npm`,[`config`,`get`,`prefix`]);if(t.code!==0||!t.stdout)return{success:!1,error:`Failed to get npm global prefix`};let n=t.stdout.trim(),r=!1;async function i(e,t){try{return await B(e),p(`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?(p(`Successfully removed ${e} manually`),{success:!0,warning:`${e} executables removed, but node_modules directory was left intact for safety. You may manually delete it later at: ${W().startsWith(`win32`)?k(n,`node_modules`,e):k(n,`lib`,`node_modules`,e)}`}):{success:!1}}catch(e){return p(`Manual removal failed: ${e}`,{level:`error`}),{success:!1,error:`Manual removal failed: ${e}`}}}async function yt(e){let{code:t,stderr:n}=await v(`npm`,[`uninstall`,`-g`,e],{cwd:process.cwd()});if(t===0)return p(`Removed global npm installation of ${e}`),{success:!0};if(n&&!n.includes(`npm ERR! code E404`)){if(n.includes(`npm error code ENOTEMPTY`)){p(`Failed to uninstall global npm package ${e}: ${n}`,{level:`error`}),p(`Attempting manual removal due to ENOTEMPTY error`);let t=await vt(e);if(t.success)return{success:!0,warning:t.warning};if(t.error)return{success:!1,error:`Failed to remove global npm installation of ${e}: ${n}. Manual removal also failed: ${t.error}`}}return p(`Failed to uninstall global npm package ${e}: ${n}`,{level:`error`}),{success:!1,error:`Failed to remove global npm installation of ${e}: ${n}`}}return{success:!1}}async function bt(){let e=[],t=[],n=0,r=await yt(`@anthropic-ai/claude-code`);r.success?(n++,r.warning&&t.push(r.warning)):r.error&&e.push(r.error);let i=k(D(),`.claude`,`local`);try{await R(i,{recursive:!0}),n++,p(`Removed local installation at ${i}`)}catch(t){l(t)||(e.push(`Failed to remove ${i}: ${t}`),p(`Failed to remove local installation: ${t}`,{level:`error`}))}return{removed:n,errors:e,warnings:t}}var Z,Q,$=e((()=>{S(),Ce(),m(),ce(),d(),xe(),re(),de(),n(),g(),y(),ge(),ie(),b(),me(),je(),le(),Me(),$e(),we(),Z=10080*60*1e3,Q=null})),xt=e((()=>{$()}));export{_t as a,mt as c,gt as i,ut as n,$ as o,bt as r,dt as s,xt as t};
@@ -1 +1 @@
1
- import{Un as e,en as t}from"./state-ix0xIunV.js";import{_a as n,ya as r}from"./loadAgentsDir-ZQwvbURI.js";import{J as i,U as a}from"./debug-DiuXEmUq.js";import{Ft as o,Ht as s,Rt as c}from"./settings-BhvhCpVh.js";import{b as l,c as u,g as d}from"./config-662VDD70.js";import{o as f,s as p}from"./log-Duzb4o6h.js";import{Vt as m,_t as h,vt as g,yt as _}from"./model-BgrLt7P7.js";import{d as v,m as y,p as b}from"./rcDebugLog-CivJaJ3V.js";t(),m(),d(),a(),f(),r(),o(),v();function x(e){return t=>({...t,...typeof e.permission_mode==`string`?{toolPermissionContext:{...t.toolPermissionContext,mode:c(e.permission_mode)}}:{},...typeof e.is_ultraplan_mode==`boolean`?{isUltraplanMode:e.is_ultraplan_mode}:{}})}function S({newState:t,oldState:r}){let a=r.toolPermissionContext.mode,o=t.toolPermissionContext.mode;if(a!==o){let e=s(a),n=s(o);e!==n&&y({permission_mode:n,is_ultraplan_mode:n===`plan`&&t.isUltraplanMode&&!r.isUltraplanMode?!0:null}),b(o)}if(t.mainLoopModel!==r.mainLoopModel&&e(t.mainLoopModel),t.expandedView!==r.expandedView){let e=t.expandedView===`tasks`;u().showExpandedTodos!==e&&l(t=>({...t,showExpandedTodos:e}))}if(t.verbose!==r.verbose&&u().verbose!==t.verbose){let e=t.verbose;l(t=>({...t,verbose:e}))}if(process.env.USER_TYPE===`ant`&&t.tungstenPanelVisible!==r.tungstenPanelVisible&&t.tungstenPanelVisible!==void 0&&u().tungstenPanelVisible!==t.tungstenPanelVisible){let e=t.tungstenPanelVisible;l(t=>({...t,tungstenPanelVisible:e}))}if(t.settings!==r.settings)try{h(),g(),_(),t.settings.env!==r.settings.env&&n()}catch(e){p(i(e))}}export{S as n,x as t};
1
+ import{Un as e,en as t}from"./state-ix0xIunV.js";import{_a as n,ya as r}from"./loadAgentsDir-BURvZNN6.js";import{W as i,z as a}from"./debug-BrXObCdR.js";import{Ft as o,Ht as s,Rt as c}from"./settings-DfWP5y6X.js";import{b as l,c as u,g as d}from"./config-DiT2Z8dY.js";import{o as f,s as p}from"./log-BMCygSzM.js";import{Vt as m,_t as h,vt as g,yt as _}from"./model-BIVmcl_N.js";import{d as v,m as y,p as b}from"./rcDebugLog-DoL1FpGJ.js";t(),m(),d(),a(),f(),r(),o(),v();function x(e){return t=>({...t,...typeof e.permission_mode==`string`?{toolPermissionContext:{...t.toolPermissionContext,mode:c(e.permission_mode)}}:{},...typeof e.is_ultraplan_mode==`boolean`?{isUltraplanMode:e.is_ultraplan_mode}:{}})}function S({newState:t,oldState:r}){let a=r.toolPermissionContext.mode,o=t.toolPermissionContext.mode;if(a!==o){let e=s(a),n=s(o);e!==n&&y({permission_mode:n,is_ultraplan_mode:n===`plan`&&t.isUltraplanMode&&!r.isUltraplanMode?!0:null}),b(o)}if(t.mainLoopModel!==r.mainLoopModel&&e(t.mainLoopModel),t.expandedView!==r.expandedView){let e=t.expandedView===`tasks`;u().showExpandedTodos!==e&&l(t=>({...t,showExpandedTodos:e}))}if(t.verbose!==r.verbose&&u().verbose!==t.verbose){let e=t.verbose;l(t=>({...t,verbose:e}))}if(process.env.USER_TYPE===`ant`&&t.tungstenPanelVisible!==r.tungstenPanelVisible&&t.tungstenPanelVisible!==void 0&&u().tungstenPanelVisible!==t.tungstenPanelVisible){let e=t.tungstenPanelVisible;l(t=>({...t,tungstenPanelVisible:e}))}if(t.settings!==r.settings)try{h(),g(),_(),t.settings.env!==r.settings.env&&n()}catch(e){p(i(e))}}export{S as n,x as t};
@@ -1,4 +1,4 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{c as t,l as n,o as r}from"./envUtils-DSxRz_kt.js";import{Jo as i,Ko as a,Rh as o,So as s,Xc as c,Yc as l,Zc as u,at as d,ct as f,fo as p,np as ee,op as m,zh as h,zo as g}from"./loadAgentsDir-ZQwvbURI.js";import{l as _,p as v}from"./debug-DiuXEmUq.js";import{G as y,H as te,Wn as ne,qn as b}from"./model-BgrLt7P7.js";import{Cn as x,Sn as re,i as ie,r as S,t as C,wn as w}from"./prompt-wys9CwDo.js";import{B as T,F as E,L as D,P as O,R as k,ot as ae}from"./rcDebugLog-CivJaJ3V.js";import{n as oe,t as A}from"./openaiShared-G2-w4gJt.js";import{homedir as j}from"os";import{join as M}from"path";import{randomUUID as N}from"crypto";import{chmod as P,mkdir as se,readFile as ce,writeFile as le}from"fs/promises";function F(){return M(I(),q)}function I(){return(process.env.CLAUDE_CONFIG_DIR??M(j(),`.claude`)).normalize(`NFC`)}function L(){return M(process.env.CODEX_HOME??M(process.env.HOME??``,`.codex`),`auth.json`)}function R(e){return typeof e==`string`&&e.length>0?e:void 0}function z(e){try{let t=JSON.parse(e);return t&&typeof t==`object`?t:null}catch{return null}}function B(e){let[,t]=e.split(`.`);if(!t)return null;try{let e=t.replace(/-/g,`+`).replace(/_/g,`/`),n=e.padEnd(e.length+(4-e.length%4)%4,`=`);return z(Buffer.from(n,`base64`).toString(`utf8`))}catch{return null}}function V(e){let t=B(e),n=t?.[`https://api.openai.com/auth`];return n&&typeof n==`object`?n:t??{}}function H(e){let t=B(e)?.exp;return typeof t==`number`?t*1e3:null}function U(e){if(e.accountId)return e.accountId;for(let t of[e.idToken,e.accessToken]){if(!t)continue;let e=V(t),n=R(e.chatgpt_account_id)??R(e.chatgpt_account_user_id)??R(e.account_id);if(n)return n}}async function W(e){try{let t=await ce(e,`utf8`),n=JSON.parse(t),r=n.tokens,i=r?.id_token,a=r?.access_token,o=r?.refresh_token;return!i||!a||!o?null:{idToken:i,accessToken:a,refreshToken:o,accountId:U({idToken:i,accessToken:a,accountId:r.account_id}),lastRefresh:n.last_refresh}}catch{return null}}async function ue(e){let t=F();await se(I(),{recursive:!0});let n={auth_mode:`chatgpt`,tokens:{id_token:e.idToken,access_token:e.accessToken,refresh_token:e.refreshToken,account_id:U(e)},last_refresh:new Date().toISOString()};await le(t,`${JSON.stringify(n,null,2)}\n`,{mode:384}),await P(t,384).catch(()=>void 0)}async function de(e,t){let n=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:t});if(!n.ok){let e=await n.text().catch(()=>``);throw Error(`ChatGPT token request failed (${n.status})${e?`: ${e}`:``}`)}return await n.json()}async function fe(e){let t=new URLSearchParams({grant_type:`refresh_token`,refresh_token:e.refreshToken,client_id:K,scope:`openid profile email offline_access api.connectors.read api.connectors.invoke`}),n=await de(`${G}/oauth/token`,t);return{idToken:n.id_token,accessToken:n.access_token,refreshToken:n.refresh_token??e.refreshToken,accountId:U({idToken:n.id_token,accessToken:n.access_token,accountId:e.accountId})}}function pe(){return process.env.OPENAI_AUTH_MODE===`chatgpt`}async function me(){let e=await W(F());if(e||(e=await W(L()),e&&v(`[OpenAI] Using ChatGPT auth from Codex auth.json`)),!e)throw Error(`ChatGPT account is not logged in. Run /login and select ChatGPT account with subscription.`);let t=H(e.accessToken);return t!==null&&t<=Date.now()+J&&(e=await fe(e),await ue(e)),{accessToken:e.accessToken,accountId:e.accountId??U(e)}}var G,K,q,J,Y=e((()=>{_(),G=`https://auth.openai.com`,K=`app_EMoamEEZ73f0CkXaXp7hrann`,q=`openai-chatgpt-auth.json`,J=300*1e3}));function X(e){return typeof e==`string`?e:Array.isArray(e)?e.map(e=>{if(!e||typeof e!=`object`)return``;let t=e;return typeof t.text==`string`?t.text:``}).filter(Boolean).join(`
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{c as t,l as n,o as r}from"./envUtils-DSxRz_kt.js";import{Jo as i,Ko as a,Rh as o,So as s,Xc as c,Yc as l,Zc as u,at as d,ct as f,fo as p,np as ee,op as m,zh as h,zo as g}from"./loadAgentsDir-BURvZNN6.js";import{a as _,l as v}from"./debug-BrXObCdR.js";import{G as y,H as te,Wn as ne,qn as b}from"./model-BIVmcl_N.js";import{En as re,Tn as x,i as ie,r as S,t as C,wn as w}from"./prompt-DNDgGM9q.js";import{B as T,F as E,L as D,P as O,R as k,ot as ae}from"./rcDebugLog-DoL1FpGJ.js";import{n as oe,t as A}from"./openaiShared-G2-w4gJt.js";import{homedir as j}from"os";import{join as M}from"path";import{randomUUID as N}from"crypto";import{chmod as P,mkdir as se,readFile as ce,writeFile as le}from"fs/promises";function F(){return M(I(),q)}function I(){return(process.env.CLAUDE_CONFIG_DIR??M(j(),`.claude`)).normalize(`NFC`)}function L(){return M(process.env.CODEX_HOME??M(process.env.HOME??``,`.codex`),`auth.json`)}function R(e){return typeof e==`string`&&e.length>0?e:void 0}function z(e){try{let t=JSON.parse(e);return t&&typeof t==`object`?t:null}catch{return null}}function B(e){let[,t]=e.split(`.`);if(!t)return null;try{let e=t.replace(/-/g,`+`).replace(/_/g,`/`),n=e.padEnd(e.length+(4-e.length%4)%4,`=`);return z(Buffer.from(n,`base64`).toString(`utf8`))}catch{return null}}function V(e){let t=B(e),n=t?.[`https://api.openai.com/auth`];return n&&typeof n==`object`?n:t??{}}function H(e){let t=B(e)?.exp;return typeof t==`number`?t*1e3:null}function U(e){if(e.accountId)return e.accountId;for(let t of[e.idToken,e.accessToken]){if(!t)continue;let e=V(t),n=R(e.chatgpt_account_id)??R(e.chatgpt_account_user_id)??R(e.account_id);if(n)return n}}async function W(e){try{let t=await ce(e,`utf8`),n=JSON.parse(t),r=n.tokens,i=r?.id_token,a=r?.access_token,o=r?.refresh_token;return!i||!a||!o?null:{idToken:i,accessToken:a,refreshToken:o,accountId:U({idToken:i,accessToken:a,accountId:r.account_id}),lastRefresh:n.last_refresh}}catch{return null}}async function ue(e){let t=F();await se(I(),{recursive:!0});let n={auth_mode:`chatgpt`,tokens:{id_token:e.idToken,access_token:e.accessToken,refresh_token:e.refreshToken,account_id:U(e)},last_refresh:new Date().toISOString()};await le(t,`${JSON.stringify(n,null,2)}\n`,{mode:384}),await P(t,384).catch(()=>void 0)}async function de(e,t){let n=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:t});if(!n.ok){let e=await n.text().catch(()=>``);throw Error(`ChatGPT token request failed (${n.status})${e?`: ${e}`:``}`)}return await n.json()}async function fe(e){let t=new URLSearchParams({grant_type:`refresh_token`,refresh_token:e.refreshToken,client_id:K,scope:`openid profile email offline_access api.connectors.read api.connectors.invoke`}),n=await de(`${G}/oauth/token`,t);return{idToken:n.id_token,accessToken:n.access_token,refreshToken:n.refresh_token??e.refreshToken,accountId:U({idToken:n.id_token,accessToken:n.access_token,accountId:e.accountId})}}function pe(){return process.env.OPENAI_AUTH_MODE===`chatgpt`}async function me(){let e=await W(F());if(e||(e=await W(L()),e&&v(`[OpenAI] Using ChatGPT auth from Codex auth.json`)),!e)throw Error(`ChatGPT account is not logged in. Run /login and select ChatGPT account with subscription.`);let t=H(e.accessToken);return t!==null&&t<=Date.now()+J&&(e=await fe(e),await ue(e)),{accessToken:e.accessToken,accountId:e.accountId??U(e)}}var G,K,q,J,Y=e((()=>{_(),G=`https://auth.openai.com`,K=`app_EMoamEEZ73f0CkXaXp7hrann`,q=`openai-chatgpt-auth.json`,J=300*1e3}));function X(e){return typeof e==`string`?e:Array.isArray(e)?e.map(e=>{if(!e||typeof e!=`object`)return``;let t=e;return typeof t.text==`string`?t.text:``}).filter(Boolean).join(`
2
2
  `):``}function he(e){if(typeof e==`string`)return e;if(!Array.isArray(e))return X(e);let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;if(e.type===`text`&&typeof e.text==`string`)t.push({type:`input_text`,text:e.text});else if(e.type===`image_url`){let n=e.image_url;typeof n?.url==`string`&&t.push({type:`input_image`,image_url:n.url})}}return t.length>0?t:X(e)}function ge(e){let t=[],n=[];for(let r of e){if(!r||typeof r!=`object`)continue;let e=r,i=e.role;if(i===`system`||i===`developer`){let t=X(e.content);t&&n.push(t);continue}if(i===`tool`){let n=e.tool_call_id;typeof n==`string`&&t.push({type:`function_call_output`,call_id:n,output:X(e.content)});continue}if(i===`assistant`){let n=X(e.content);n&&t.push({role:`assistant`,content:n});let r=e.tool_calls;if(Array.isArray(r))for(let e of r){if(!e||typeof e!=`object`)continue;let n=e,r=n.function,i=typeof n.id==`string`?n.id:void 0,a=typeof r?.name==`string`?r.name:void 0;!i||!a||t.push({type:`function_call`,call_id:i,name:a,arguments:typeof r?.arguments==`string`?r.arguments:`{}`})}continue}i===`user`&&t.push({role:`user`,content:he(e.content)})}return{input:t,instructions:n.length>0?n.join(`
3
3
 
4
4
  `):void 0}}function _e(e){let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n.function,r=typeof e?.name==`string`?e.name:void 0;r&&t.push({type:`function`,name:r,description:typeof e?.description==`string`?e.description:``,parameters:e?.parameters&&typeof e.parameters==`object`?e.parameters:{type:`object`,properties:{}},strict:!1})}return t}function ve(e){if(e===`required`)return`required`;if(e===`auto`)return`auto`;if(!e||typeof e!=`object`)return e;let t=e,n=t.function;return t.type===`function`&&typeof n?.name==`string`?{type:`function`,name:n.name}:e}function ye(e){let{input:t,instructions:n}=ge(e.messages),r=_e(e.tools);return{model:e.model,stream:!0,store:!1,input:t,...n?{instructions:n}:{},...r.length>0?{tools:r}:{},...e.toolChoice?{tool_choice:ve(e.toolChoice)}:{},...e.reasoningEffort?{reasoning:{effort:e.reasoningEffort}}:{},parallel_tool_calls:!0}}async function*be(e){if(!e.body)throw Error(`ChatGPT response did not include a body`);let t=e.body.getReader(),n=new TextDecoder,r=``;for(;;){let{done:e,value:i}=await t.read();if(e)break;r+=n.decode(i,{stream:!0});let a=r.indexOf(`
@@ -6,5 +6,5 @@ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{c as t,l as n,o as r}f
6
6
  `);for(;a>=0;){let e=r.slice(0,a);r=r.slice(a+2);let t=e.split(/\r?\n/).filter(e=>e.startsWith(`data:`)).map(e=>e.slice(5).trimStart()).join(`
7
7
  `);if(t&&t!==`[DONE]`){let e=JSON.parse(t);e&&typeof e==`object`&&(yield e)}a=r.indexOf(`
8
8
 
9
- `)}}}function xe(e){let t=e?.usage,n=t?.input_tokens_details;return{input_tokens:typeof t?.input_tokens==`number`?t.input_tokens:0,output_tokens:typeof t?.output_tokens==`number`?t.output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:typeof n?.cached_tokens==`number`?n.cached_tokens:0}}function Se(e){return e?.status===`incomplete`?`max_tokens`:`end_turn`}async function*Z(e,t){let n=`msg_${N().replace(/-/g,``).slice(0,24)}`,r=new Map,i=!1,a=-1,o=!1,s=!1,c=async function*(){i||(i=!0,yield{type:`message_start`,message:{id:n,type:`message`,role:`assistant`,content:[],model:t,stop_reason:null,stop_sequence:null,usage:{input_tokens:0,output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:0}}})};for await(let t of e){for await(let e of c())yield e;let e=t.type;if(e===`response.output_text.delta`){o||(s&&(yield{type:`content_block_stop`,index:a},s=!1),a++,o=!0,yield{type:`content_block_start`,index:a,content_block:{type:`text`,text:``}}),yield{type:`content_block_delta`,index:a,delta:{type:`text_delta`,text:String(t.delta??``)}};continue}if(e===`response.reasoning_text.delta`){s||(o&&(yield{type:`content_block_stop`,index:a},o=!1),a++,s=!0,yield{type:`content_block_start`,index:a,content_block:{type:`thinking`,thinking:``,signature:``}}),yield{type:`content_block_delta`,index:a,delta:{type:`thinking_delta`,thinking:String(t.delta??``)}};continue}if(e===`response.output_item.added`){let e=t.item,n=typeof t.output_index==`number`?t.output_index:-1;if(e?.type===`function_call`&&n>=0){o&&(yield{type:`content_block_stop`,index:a},o=!1),s&&(yield{type:`content_block_stop`,index:a},s=!1),a++;let t=String(e.call_id??e.id??`call_${n}`),i=String(e.name??``);r.set(n,{contentIndex:a,open:!0,name:i,id:t}),yield{type:`content_block_start`,index:a,content_block:{type:`tool_use`,id:t,name:i,input:{}}}}continue}if(e===`response.function_call_arguments.delta`){let e=typeof t.output_index==`number`?t.output_index:-1,n=r.get(e);n&&(yield{type:`content_block_delta`,index:n.contentIndex,delta:{type:`input_json_delta`,partial_json:String(t.delta??``)}});continue}if(e===`response.output_item.done`){let e=typeof t.output_index==`number`?t.output_index:-1,n=r.get(e);n?.open&&(yield{type:`content_block_stop`,index:n.contentIndex},n.open=!1);continue}if(e===`response.error`){let e=t.error;throw Error(String(e?.message??`ChatGPT Responses API error`))}if(e===`response.failed`){let e=t.response?.error;throw Error(String(e?.message??`ChatGPT Responses API failed`))}if(e===`response.completed`||e===`response.incomplete`){o&&(yield{type:`content_block_stop`,index:a},o=!1),s&&(yield{type:`content_block_stop`,index:a},s=!1);let e=t.response;yield{type:`message_delta`,delta:{stop_reason:Se(e),stop_sequence:null},usage:xe(e)},yield{type:`message_stop`}}}}async function Ce(e){let t=await me(),n=e.fetchOverride??globalThis.fetch,r={Authorization:`Bearer ${t.accessToken}`,"Content-Type":`application/json`,Accept:`text/event-stream`,"OpenAI-Beta":`responses=experimental`,Origin:`https://chatgpt.com`,Referer:`https://chatgpt.com/`,originator:`claude-code-best`};t.accountId&&(r[`ChatGPT-Account-Id`]=t.accountId);let i=await n(`https://chatgpt.com/backend-api/codex/responses`,{method:`POST`,headers:r,body:JSON.stringify(e.request),signal:e.signal});if(!i.ok){let e=await i.text().catch(()=>``);throw Error(`ChatGPT Responses API request failed (${i.status})${e?`: ${e.slice(0,500)}`:``}`)}return be(i)}var we=e((()=>{Y()}));function Te(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 Ee(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 De(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 Oe=e((()=>{r()}));function Q(e){if(e===`low`)return`low`;if(e===`medium`)return`medium`;if(e===`high`)return`high`;if(e===`xhigh`||e===`max`)return`xhigh`;if(typeof e==`number`)return`high`}function ke(e){let t=process.env.CLAUDE_CODE_EFFORT_LEVEL?.toLowerCase();if(!(t===`auto`||t===`unset`))return Q(t)??Q(e)??`medium`}function Ae(e,t,n,r){if(!r||c())return e;let i=t.filter(e=>n.has(e.name)).map(C).sort().join(`
10
- `);return i?[s({content:`<available-deferred-tools>\n${i}\n</available-deferred-tools>`,isMeta:!0}),...e]:e}function je(e){return e.type===`assistant`||e.type===`user`}function $(e){let{partialMessage:t,contentBlocks:n,tools:r,agentId:i,usage:o,stopReason:s,maxTokens:c}=e,l=[],u=Object.keys(n).sort((e,t)=>Number(e)-Number(t)).map(e=>n[Number(e)]).filter(Boolean);return u.length>0&&t&&l.push({message:{...t,content:a(u,r,i),usage:o,stop_reason:s,stop_sequence:null},requestId:void 0,type:`assistant`,uuid:N(),timestamp:new Date().toISOString()}),s===`max_tokens`&&l.push(p({content:`Output truncated: response exceeded the ${c} token limit. Set OPENAI_MAX_TOKENS or CLAUDE_CODE_MAX_OUTPUT_TOKENS to override.`,apiError:`max_output_tokens`,error:`max_output_tokens`})),l}async function*Me(e,t,n,r,a){try{let s=ae(a.model),c=i(e,n),l=await u(a.model,n,a.getToolPermissionContext||(async()=>re()),a.agents||[],a.querySource),d=new Set;if(l)for(let e of n)ie(e)&&d.add(e.name);let p=n;l&&d.size>0&&(p=n.filter(e=>!!(!d.has(e.name)||w(e,`SearchExtraTools`))));let m=(await Promise.all(p.map(e=>f(e,{getToolPermissionContext:a.getToolPermissionContext,tools:n,agents:a.agents,allowedAgentTypes:a.allowedAgentTypes,model:a.model,deferLoading:l&&d.has(e.name)})))).filter(e=>{let t=e;return t.type!==`advisor_20260301`&&t.type!==`computer_20250124`}),h=Te(s),g=T(Ae(c.filter(je),n,d,l),t,{enableThinking:h}),_=k(m),y=D(a.toolChoice),b=ke(a.effortValue);if(l){let e=p.filter(e=>d.has(e.name)).length;v(`[OpenAI] Tool search enabled: ${e}/${d.size} deferred tools included, total tools=${_.length}`)}else v(`[OpenAI] Tool search disabled, total tools=${_.length}`);let{upperLimit:x}=ne(s),S=Ee(x,a.maxOutputTokensOverride);v(`[OpenAI] Calling model=${s}, messages=${g.length}, tools=${_.length}, thinking=${h}`);let C=pe()?Z(await Ce({request:ye({model:s,messages:g,tools:_,toolChoice:y,reasoningEffort:b}),signal:r,fetchOverride:a.fetchOverride}),s):E(await o({maxRetries:0,fetchOverride:a.fetchOverride,source:a.querySource}).chat.completions.create(De({model:s,messages:g,tools:_,toolChoice:y,enableThinking:h,maxTokens:S,temperatureOverride:a.temperatureOverride}),{signal:r}),s),O={},A=null,j=null,M={input_tokens:0,output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:0},N=0,P=Date.now();for await(let e of C){switch(e.type){case`message_start`:A=e.message,N=Date.now()-P,e.message.usage&&(M={...M,...e.message.usage});break;case`content_block_start`:{let t=e.index,n=e.content_block;n.type===`tool_use`?O[t]={...n,input:``}:n.type===`text`?O[t]={...n,text:``}:n.type===`thinking`?O[t]={...n,thinking:``,signature:``}:O[t]={...n};break}case`content_block_delta`:{let t=e.index,n=e.delta,r=O[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&&(M=oe(M,t)),e.delta.stop_reason!=null&&(j=e.delta.stop_reason);break}case`message_stop`:if(A){for(let e of $({partialMessage:A,contentBlocks:O,tools:n,agentId:a.agentId,usage:M,stopReason:j,maxTokens:S}))yield e;A=null}M.input_tokens+M.output_tokens>0&&ee(te(s,M),M,a.model);break}yield{type:`stream_event`,event:e,...e.type===`message_start`?{ttftMs:N}:void 0}}if(A)for(let e of $({partialMessage:A,contentBlocks:O,tools:n,agentId:a.agentId,usage:M,stopReason:j,maxTokens:S}))yield e}catch(e){let t=e instanceof Error?e.message:String(e);v(`[OpenAI] Error: ${t}`,{level:`error`}),yield p({content:`API Error: ${t}`,apiError:`api_error`,error:e instanceof Error?e:Error(String(e))})}}e((()=>{h(),A(),O(),Y(),we(),g(),d(),x(),_(),m(),y(),Oe(),b(),l(),S()}))();export{Me as queryModelOpenAI};
9
+ `)}}}function xe(e){let t=e?.usage,n=t?.input_tokens_details;return{input_tokens:typeof t?.input_tokens==`number`?t.input_tokens:0,output_tokens:typeof t?.output_tokens==`number`?t.output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:typeof n?.cached_tokens==`number`?n.cached_tokens:0}}function Se(e){return e?.status===`incomplete`?`max_tokens`:`end_turn`}async function*Z(e,t){let n=`msg_${N().replace(/-/g,``).slice(0,24)}`,r=new Map,i=!1,a=-1,o=!1,s=!1,c=async function*(){i||(i=!0,yield{type:`message_start`,message:{id:n,type:`message`,role:`assistant`,content:[],model:t,stop_reason:null,stop_sequence:null,usage:{input_tokens:0,output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:0}}})};for await(let t of e){for await(let e of c())yield e;let e=t.type;if(e===`response.output_text.delta`){o||(s&&(yield{type:`content_block_stop`,index:a},s=!1),a++,o=!0,yield{type:`content_block_start`,index:a,content_block:{type:`text`,text:``}}),yield{type:`content_block_delta`,index:a,delta:{type:`text_delta`,text:String(t.delta??``)}};continue}if(e===`response.reasoning_text.delta`){s||(o&&(yield{type:`content_block_stop`,index:a},o=!1),a++,s=!0,yield{type:`content_block_start`,index:a,content_block:{type:`thinking`,thinking:``,signature:``}}),yield{type:`content_block_delta`,index:a,delta:{type:`thinking_delta`,thinking:String(t.delta??``)}};continue}if(e===`response.output_item.added`){let e=t.item,n=typeof t.output_index==`number`?t.output_index:-1;if(e?.type===`function_call`&&n>=0){o&&(yield{type:`content_block_stop`,index:a},o=!1),s&&(yield{type:`content_block_stop`,index:a},s=!1),a++;let t=String(e.call_id??e.id??`call_${n}`),i=String(e.name??``);r.set(n,{contentIndex:a,open:!0,name:i,id:t}),yield{type:`content_block_start`,index:a,content_block:{type:`tool_use`,id:t,name:i,input:{}}}}continue}if(e===`response.function_call_arguments.delta`){let e=typeof t.output_index==`number`?t.output_index:-1,n=r.get(e);n&&(yield{type:`content_block_delta`,index:n.contentIndex,delta:{type:`input_json_delta`,partial_json:String(t.delta??``)}});continue}if(e===`response.output_item.done`){let e=typeof t.output_index==`number`?t.output_index:-1,n=r.get(e);n?.open&&(yield{type:`content_block_stop`,index:n.contentIndex},n.open=!1);continue}if(e===`response.error`){let e=t.error;throw Error(String(e?.message??`ChatGPT Responses API error`))}if(e===`response.failed`){let e=t.response?.error;throw Error(String(e?.message??`ChatGPT Responses API failed`))}if(e===`response.completed`||e===`response.incomplete`){o&&(yield{type:`content_block_stop`,index:a},o=!1),s&&(yield{type:`content_block_stop`,index:a},s=!1);let e=t.response;yield{type:`message_delta`,delta:{stop_reason:Se(e),stop_sequence:null},usage:xe(e)},yield{type:`message_stop`}}}}async function Ce(e){let t=await me(),n=e.fetchOverride??globalThis.fetch,r={Authorization:`Bearer ${t.accessToken}`,"Content-Type":`application/json`,Accept:`text/event-stream`,"OpenAI-Beta":`responses=experimental`,Origin:`https://chatgpt.com`,Referer:`https://chatgpt.com/`,originator:`workmate`};t.accountId&&(r[`ChatGPT-Account-Id`]=t.accountId);let i=await n(`https://chatgpt.com/backend-api/codex/responses`,{method:`POST`,headers:r,body:JSON.stringify(e.request),signal:e.signal});if(!i.ok){let e=await i.text().catch(()=>``);throw Error(`ChatGPT Responses API request failed (${i.status})${e?`: ${e.slice(0,500)}`:``}`)}return be(i)}var we=e((()=>{Y()}));function Te(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 Ee(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 De(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 Oe=e((()=>{r()}));function Q(e){if(e===`low`)return`low`;if(e===`medium`)return`medium`;if(e===`high`)return`high`;if(e===`xhigh`||e===`max`)return`xhigh`;if(typeof e==`number`)return`high`}function ke(e){let t=process.env.CLAUDE_CODE_EFFORT_LEVEL?.toLowerCase();if(!(t===`auto`||t===`unset`))return Q(t)??Q(e)??`medium`}function Ae(e,t,n,r){if(!r||c())return e;let i=t.filter(e=>n.has(e.name)).map(C).sort().join(`
10
+ `);return i?[s({content:`<available-deferred-tools>\n${i}\n</available-deferred-tools>`,isMeta:!0}),...e]:e}function je(e){return e.type===`assistant`||e.type===`user`}function $(e){let{partialMessage:t,contentBlocks:n,tools:r,agentId:i,usage:o,stopReason:s,maxTokens:c}=e,l=[],u=Object.keys(n).sort((e,t)=>Number(e)-Number(t)).map(e=>n[Number(e)]).filter(Boolean);return u.length>0&&t&&l.push({message:{...t,content:a(u,r,i),usage:o,stop_reason:s,stop_sequence:null},requestId:void 0,type:`assistant`,uuid:N(),timestamp:new Date().toISOString()}),s===`max_tokens`&&l.push(p({content:`Output truncated: response exceeded the ${c} token limit. Set OPENAI_MAX_TOKENS or CLAUDE_CODE_MAX_OUTPUT_TOKENS to override.`,apiError:`max_output_tokens`,error:`max_output_tokens`})),l}async function*Me(e,t,n,r,a){try{let s=ae(a.model),c=i(e,n),l=await u(a.model,n,a.getToolPermissionContext||(async()=>w()),a.agents||[],a.querySource),d=new Set;if(l)for(let e of n)ie(e)&&d.add(e.name);let p=n;l&&d.size>0&&(p=n.filter(e=>!!(!d.has(e.name)||re(e,`SearchExtraTools`))));let m=(await Promise.all(p.map(e=>f(e,{getToolPermissionContext:a.getToolPermissionContext,tools:n,agents:a.agents,allowedAgentTypes:a.allowedAgentTypes,model:a.model,deferLoading:l&&d.has(e.name)})))).filter(e=>{let t=e;return t.type!==`advisor_20260301`&&t.type!==`computer_20250124`}),h=Te(s),g=T(Ae(c.filter(je),n,d,l),t,{enableThinking:h}),_=k(m),y=D(a.toolChoice),b=ke(a.effortValue);if(l){let e=p.filter(e=>d.has(e.name)).length;v(`[OpenAI] Tool search enabled: ${e}/${d.size} deferred tools included, total tools=${_.length}`)}else v(`[OpenAI] Tool search disabled, total tools=${_.length}`);let{upperLimit:x}=ne(s),S=Ee(x,a.maxOutputTokensOverride);v(`[OpenAI] Calling model=${s}, messages=${g.length}, tools=${_.length}, thinking=${h}`);let C=pe()?Z(await Ce({request:ye({model:s,messages:g,tools:_,toolChoice:y,reasoningEffort:b}),signal:r,fetchOverride:a.fetchOverride}),s):E(await o({maxRetries:0,fetchOverride:a.fetchOverride,source:a.querySource}).chat.completions.create(De({model:s,messages:g,tools:_,toolChoice:y,enableThinking:h,maxTokens:S,temperatureOverride:a.temperatureOverride}),{signal:r}),s),O={},A=null,j=null,M={input_tokens:0,output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:0},N=0,P=Date.now();for await(let e of C){switch(e.type){case`message_start`:A=e.message,N=Date.now()-P,e.message.usage&&(M={...M,...e.message.usage});break;case`content_block_start`:{let t=e.index,n=e.content_block;n.type===`tool_use`?O[t]={...n,input:``}:n.type===`text`?O[t]={...n,text:``}:n.type===`thinking`?O[t]={...n,thinking:``,signature:``}:O[t]={...n};break}case`content_block_delta`:{let t=e.index,n=e.delta,r=O[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&&(M=oe(M,t)),e.delta.stop_reason!=null&&(j=e.delta.stop_reason);break}case`message_stop`:if(A){for(let e of $({partialMessage:A,contentBlocks:O,tools:n,agentId:a.agentId,usage:M,stopReason:j,maxTokens:S}))yield e;A=null}M.input_tokens+M.output_tokens>0&&ee(te(s,M),M,a.model);break}yield{type:`stream_event`,event:e,...e.type===`message_start`?{ttftMs:N}:void 0}}if(A)for(let e of $({partialMessage:A,contentBlocks:O,tools:n,agentId:a.agentId,usage:M,stopReason:j,maxTokens:S}))yield e}catch(e){let t=e instanceof Error?e.message:String(e);v(`[OpenAI] Error: ${t}`,{level:`error`}),yield p({content:`API Error: ${t}`,apiError:`api_error`,error:e instanceof Error?e:Error(String(e))})}}e((()=>{h(),A(),O(),Y(),we(),g(),d(),x(),_(),m(),y(),Oe(),b(),l(),S()}))();export{Me as queryModelOpenAI};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./axios-DaWTGg7G.js";import{b as r,c as i,g as a}from"./config-662VDD70.js";import{d as o,f as s,o as c,s as l}from"./log-Duzb4o6h.js";import{l as u,u as d}from"./oauth-BqJqV-2M.js";import{Mt as f,Vt as p}from"./model-BgrLt7P7.js";import{a as m,l as h,o as g}from"./api-CLLIHLpn.js";async function _(){try{let{accessToken:e,orgUUID:n}=await h(),r=`${u().BASE_API_URL}/api/oauth/organizations/${n}/overage_credit_grant`;return(await t.get(r,{headers:m(e)})).data}catch(e){return l(e),null}}function v(){let e=f()?.organizationUuid;if(!e)return null;let t=i().overageCreditGrantCache?.[e];return!t||Date.now()-t.timestamp>S?null:t.info}function y(){let e=f()?.organizationUuid;if(!e)return;let t=i().overageCreditGrantCache;!t||!(e in t)||r(t=>{let n={...t.overageCreditGrantCache};return delete n[e],{...t,overageCreditGrantCache:n}})}async function b(){if(s())return;let e=f()?.organizationUuid;if(!e)return;let t=await _();t&&r(n=>{let r=n.overageCreditGrantCache?.[e],i=r?.info,a=i&&i.available===t.available&&i.eligible===t.eligible&&i.granted===t.granted&&i.amount_minor_units===t.amount_minor_units&&i.currency===t.currency;if(a&&r&&Date.now()-r.timestamp<=S)return n;let o={info:a?i:t,timestamp:Date.now()};return{...n,overageCreditGrantCache:{...n.overageCreditGrantCache,[e]:o}}})}function x(e){if(e.amount_minor_units==null||!e.currency)return null;if(e.currency.toUpperCase()===`USD`){let t=e.amount_minor_units/100;return Number.isInteger(t)?`$${t}`:`$${t.toFixed(2)}`}return null}var S,C=e((()=>{n(),d(),p(),a(),c(),o(),g(),S=3600*1e3}));export{b as a,y as i,v as n,C as r,x as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./axios-DaWTGg7G.js";import{b as r,c as i,g as a}from"./config-DiT2Z8dY.js";import{d as o,f as s,o as c,s as l}from"./log-BMCygSzM.js";import{l as u,u as d}from"./oauth-BqJqV-2M.js";import{Mt as f,Vt as p}from"./model-BIVmcl_N.js";import{a as m,l as h,o as g}from"./api-C-rOQY-l.js";async function _(){try{let{accessToken:e,orgUUID:n}=await h(),r=`${u().BASE_API_URL}/api/oauth/organizations/${n}/overage_credit_grant`;return(await t.get(r,{headers:m(e)})).data}catch(e){return l(e),null}}function v(){let e=f()?.organizationUuid;if(!e)return null;let t=i().overageCreditGrantCache?.[e];return!t||Date.now()-t.timestamp>S?null:t.info}function y(){let e=f()?.organizationUuid;if(!e)return;let t=i().overageCreditGrantCache;!t||!(e in t)||r(t=>{let n={...t.overageCreditGrantCache};return delete n[e],{...t,overageCreditGrantCache:n}})}async function b(){if(s())return;let e=f()?.organizationUuid;if(!e)return;let t=await _();t&&r(n=>{let r=n.overageCreditGrantCache?.[e],i=r?.info,a=i&&i.available===t.available&&i.eligible===t.eligible&&i.granted===t.granted&&i.amount_minor_units===t.amount_minor_units&&i.currency===t.currency;if(a&&r&&Date.now()-r.timestamp<=S)return n;let o={info:a?i:t,timestamp:Date.now()};return{...n,overageCreditGrantCache:{...n.overageCreditGrantCache,[e]:o}}})}function x(e){if(e.amount_minor_units==null||!e.currency)return null;if(e.currency.toUpperCase()===`USD`){let t=e.amount_minor_units/100;return Number.isInteger(t)?`$${t}`:`$${t.toFixed(2)}`}return null}var S,C=e((()=>{n(),d(),p(),a(),c(),o(),g(),S=3600*1e3}));export{b as a,y as i,v as n,C as r,x as t};