@readmagic/workmate 0.0.10 → 0.0.12

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 (437) hide show
  1. package/dist/chunks/{AddWorkspaceDirectory-Vmmm7p1c.js → AddWorkspaceDirectory-CtRxzRny.js} +1 -1
  2. package/dist/chunks/AgentsMdExternalIncludesDialog-_bI4jo_P.js +1 -0
  3. package/dist/chunks/AgentsMdExternalIncludesDialog-_yJJ0wqu.js +1 -0
  4. package/dist/chunks/App-DoAZ7CYS.js +1 -0
  5. package/dist/chunks/ApproveApiKey-C8LwmDM2.js +1 -0
  6. package/dist/chunks/ApproveApiKey-DQP3qmb0.js +1 -0
  7. package/dist/chunks/BackgroundTasksDialog-CDA2noEk.js +2 -0
  8. package/dist/chunks/{BypassPermissionsModeDialog-CLSACUmo.js → BypassPermissionsModeDialog-COI_V57z.js} +1 -1
  9. package/dist/chunks/ConsoleOAuthFlow-Dn8fO-o_.js +1 -0
  10. package/dist/chunks/{DiffDialog-9AYwtupw.js → DiffDialog-CRWtQ1R5.js} +3 -3
  11. package/dist/chunks/Doctor-CZ513Df9.js +3 -0
  12. package/dist/chunks/Doctor-CzPvNZzF.js +1 -0
  13. package/dist/chunks/ExitFlow-BFeftDv0.js +2 -0
  14. package/dist/chunks/{Grove-B9-hhkZA.js → Grove-DRZrhbF0.js} +2 -2
  15. package/dist/chunks/{HybridTransport-MxJ_W_np.js → HybridTransport-BadJQe6u.js} +4 -4
  16. package/dist/chunks/InvalidConfigDialog-DQaT6aen.js +1 -0
  17. package/dist/chunks/{InvalidSettingsDialog-YyQcHocx.js → InvalidSettingsDialog-ISzcIGPU.js} +1 -1
  18. package/dist/chunks/MCPConnectionManager-BpjC7CEo.js +1 -0
  19. package/dist/chunks/MCPToolListView-Rb1Q--jG.js +1 -0
  20. package/dist/chunks/{McpParsingWarnings-BCpfHaBK.js → McpParsingWarnings-xv0RZCSL.js} +1 -1
  21. package/dist/chunks/MessageSelector-BHB55sZb.js +3 -0
  22. package/dist/chunks/Messages-CPX-nIdA.js +11 -0
  23. package/dist/chunks/Onboarding-CymgipoF.js +1 -0
  24. package/dist/chunks/{PromptInputFooterSuggestions-BSA9NrZc.js → PromptInputFooterSuggestions-8-awCxOn.js} +1 -1
  25. package/dist/chunks/PromptInputHelpMenu-BP3UgCdi.js +1 -0
  26. package/dist/chunks/QueryEngine-HkswHUNv.js +1 -0
  27. package/dist/chunks/REPL-CZfg65kg.js +133 -0
  28. package/dist/chunks/REPL-eZsYNBfl.js +1 -0
  29. package/dist/chunks/RemoteSessionManager-B4jqKVd3.js +2 -0
  30. package/dist/chunks/ResumeConversation-B03XN_SP.js +1 -0
  31. package/dist/chunks/{SSETransport-CoxQ8YpH.js → SSETransport-je346ofV.js} +3 -3
  32. package/dist/chunks/SearchExtraToolsTool-C85Sanww.js +1 -0
  33. package/dist/chunks/Settings-C8GKWod1.js +2 -0
  34. package/dist/chunks/{TeleportProgress-Doucj-50.js → TeleportProgress-zmdAsogZ.js} +1 -1
  35. package/dist/chunks/{TeleportRepoMismatchDialog-B5I73j7Y.js → TeleportRepoMismatchDialog-CG32I4cO.js} +1 -1
  36. package/dist/chunks/{TeleportResumeWrapper-D6kpr2c6.js → TeleportResumeWrapper-2Yjr74Lq.js} +1 -1
  37. package/dist/chunks/{ThemePicker-DrC8tlp0.js → ThemePicker-p7_hHk1V.js} +1 -1
  38. package/dist/chunks/TrustDialog-BVcny9vs.js +1 -0
  39. package/dist/chunks/{ValidationErrorsList-D_OUa4RT.js → ValidationErrorsList-DSSUWdgd.js} +1 -1
  40. package/dist/chunks/{WelcomeV2-DvfQHnZY.js → WelcomeV2-BnSYhyfu.js} +1 -1
  41. package/dist/chunks/add-dir-Bd7pilVx.js +1 -0
  42. package/dist/chunks/{agentDisplay-B755vMZE.js → agentDisplay-CfMLGPGH.js} +1 -1
  43. package/dist/chunks/{agents-CIvP8l0s.js → agents-BT82hwBN.js} +1 -1
  44. package/dist/chunks/agents-qR6r94-F.js +103 -0
  45. package/dist/chunks/allErrors-CS77lRvU.js +1 -0
  46. package/dist/chunks/api-C4VflFau.js +1 -0
  47. package/dist/chunks/{api-nSHc_GIQ.js → api-DAubp5q9.js} +1 -1
  48. package/dist/chunks/auth-CNCehj7y.js +1 -0
  49. package/dist/chunks/auth-DrD9DW6X.js +1 -0
  50. package/dist/chunks/{auth-5QB6tsfB.js → auth-yDsvFcM7.js} +2 -2
  51. package/dist/chunks/{autoMode-BnUiK9Cu.js → autoMode-C2lnBot9.js} +6 -6
  52. package/dist/chunks/backgroundHousekeeping-DbpTGbwl.js +1 -0
  53. package/dist/chunks/backgroundHousekeeping-SpTxViUq.js +17 -0
  54. package/dist/chunks/{banner-D0P7wXdw.js → banner-BcAM7iSx.js} +1 -1
  55. package/dist/chunks/bg-Ci7pG4eo.js +9 -0
  56. package/dist/chunks/{branch-DFWa4Oxo.js → branch-DJiMa8td.js} +2 -2
  57. package/dist/chunks/{break-cache-Chj9i9MP.js → break-cache-4rlQORVk.js} +2 -2
  58. package/dist/chunks/{bridgeConfig-Bb6URf4Q.js → bridgeConfig-BB6Hgali.js} +1 -1
  59. package/dist/chunks/bridgeConfig-Ccm79Jze.js +1 -0
  60. package/dist/chunks/{bridgeMessaging-C3huGcR3.js → bridgeMessaging-C9D0Lly2.js} +1 -1
  61. package/dist/chunks/{bridgePointer-DLYyvRKb.js → bridgePointer-DHWK3LEe.js} +1 -1
  62. package/dist/chunks/{bridgeStatusUtil-DFMftajD.js → bridgeStatusUtil-D8UbcVrZ.js} +1 -1
  63. package/dist/chunks/{btw-DSK9R2C8.js → btw-BO2B23f-.js} +1 -1
  64. package/dist/chunks/caches-BQmbXerw.js +1 -0
  65. package/dist/chunks/caches-Dtjmjm6G.js +1 -0
  66. package/dist/chunks/{capacityWake-amzeeBz0.js → capacityWake-ByL6fM6I.js} +1 -1
  67. package/dist/chunks/ccrClient-BG9HU_fW.js +1 -0
  68. package/dist/chunks/{claudeDesktop-CsJfF1b-.js → claudeDesktop-Ct_hyICL.js} +1 -1
  69. package/dist/chunks/{clear-ClFDpWVJ.js → clear-B4XN2fib.js} +1 -1
  70. package/dist/chunks/cliLaunch-OPOtzhvA.js +1 -0
  71. package/dist/chunks/client-7lIxWcaM.js +1 -0
  72. package/dist/chunks/client-B-2ccQZk.js +1 -0
  73. package/dist/chunks/{client-DFlE4fYh.js → client-BMA05FW8.js} +1 -1
  74. package/dist/chunks/commands-D_-v6_A0.js +1 -0
  75. package/dist/chunks/compact-kM0ETtB2.js +2 -0
  76. package/dist/chunks/config-9rLTDOYW.js +3 -0
  77. package/dist/chunks/config-Crf6Mzu3.js +1 -0
  78. package/dist/chunks/{config-CVHMRMwd.js → config-DMKtiMzJ.js} +1 -1
  79. package/dist/chunks/context-BY5oO5is.js +1 -0
  80. package/dist/chunks/{context-noninteractive-D5iQhasu.js → context-noninteractive-mAQt1p9l.js} +5 -5
  81. package/dist/chunks/context-noninteractive-tc4KTYfI.js +1 -0
  82. package/dist/chunks/conversation-CFIn-KsW.js +1 -0
  83. package/dist/chunks/conversation-DPI7VKBL.js +1 -0
  84. package/dist/chunks/createSSHSession-DjLSGm-0.js +6 -0
  85. package/dist/chunks/createSession-CftIZ3aq.js +1 -0
  86. package/dist/chunks/createSession-CjdLcRec.js +1 -0
  87. package/dist/chunks/crossProjectResume-BJqXBzkf.js +40 -0
  88. package/dist/chunks/{cwd-Cfdf7z7s.js → cwd-Besi3Os3.js} +1 -1
  89. package/dist/chunks/cwd-DpqwaYHw.js +1 -0
  90. package/dist/chunks/datadog-BGati3aQ.js +1 -0
  91. package/dist/chunks/debug-Dr1SjdXn.js +39 -0
  92. package/dist/chunks/{debugUtils-DX0KAXNK.js → debugUtils-cK-iOsEV.js} +1 -1
  93. package/dist/chunks/detached-CqfQYVOi.js +5 -0
  94. package/dist/chunks/detectRepository-BsKZDRoI.js +1 -0
  95. package/dist/chunks/detectRepository-CMEkS5_2.js +1 -0
  96. package/dist/chunks/{diff-jEJJe58I.js → diff-1HsxKGBh.js} +1 -1
  97. package/dist/chunks/{directoryCompletion-BbXR2bfy.js → directoryCompletion-ByBTSuLu.js} +1 -1
  98. package/dist/chunks/doctor-CJfvt9zR.js +1 -0
  99. package/dist/chunks/entry-CrZCZQQC.js +14 -0
  100. package/dist/chunks/{envUtils-BDhHQY0-.js → envUtils-DcaKZlRU.js} +1 -1
  101. package/dist/chunks/{esm-Cf4nSRjF.js → esm-BkOWaWVb.js} +1 -1
  102. package/dist/chunks/{execFileNoThrow-Dwu6psHW.js → execFileNoThrow-mXq4K0rl.js} +2 -2
  103. package/dist/chunks/execSyncWrapper-Ne33rRiD.js +1 -0
  104. package/dist/chunks/exit-B8MA4Ltm.js +1 -0
  105. package/dist/chunks/{extraUsage-Mi66JwFZ.js → extraUsage-0pUcYexI.js} +1 -1
  106. package/dist/chunks/extractMemories-DqhN0lba.js +1 -0
  107. package/dist/chunks/fast-DT5WDe3L.js +1 -0
  108. package/dist/chunks/{fast-BU4iUZ8E.js → fast-VOu2FUlV.js} +1 -1
  109. package/dist/chunks/{fileSuggestions-BMfQIDdW.js → fileSuggestions-Be-pyLLq.js} +3 -3
  110. package/dist/chunks/firstPartyEventLogger-B8RVGBQB.js +1 -0
  111. package/dist/chunks/{firstPartyEventLogger-B3cXgR67.js → firstPartyEventLogger-aFhcruXA.js} +2 -2
  112. package/dist/chunks/{flushGate-DgSDVGKZ.js → flushGate-BUSrMj_6.js} +1 -1
  113. package/dist/chunks/gemini-DB4M-MYv.js +1 -0
  114. package/dist/chunks/generateSessionName-DhCypqJ_.js +1 -0
  115. package/dist/chunks/{genericProcessUtils-CmsUPyRz.js → genericProcessUtils-Dc1pfb7J.js} +1 -1
  116. package/dist/chunks/git-Bs1vtuvX.js +1 -0
  117. package/dist/chunks/git-CoQQ6YEf.js +6 -0
  118. package/dist/chunks/githubRepoPathMapping-CmpEaQoo.js +1 -0
  119. package/dist/chunks/goal-TxXtfkQ6.js +3 -0
  120. package/dist/chunks/{grok-BXMvezWb.js → grok-D2a_J5wE.js} +1 -1
  121. package/dist/chunks/{grove-CeOjTaY6.js → grove-BnzBbGsX.js} +1 -1
  122. package/dist/chunks/{help-5DNZO6_H.js → help-C5ankDi4.js} +1 -1
  123. package/dist/chunks/{hooks-C637tFtd.js → hooks-BZS105Rd.js} +3 -3
  124. package/dist/chunks/hooks-D-twhU_z.js +1 -0
  125. package/dist/chunks/{initReplBridge-D1h10vQ9.js → initReplBridge-DL4klK0C.js} +1 -1
  126. package/dist/chunks/{install-C-6ItpH0.js → install-NZvHd_40.js} +1 -1
  127. package/dist/chunks/{instrumentation-DaiPDUst.js → instrumentation-CjBlVlFq.js} +5 -5
  128. package/dist/chunks/{job-BeYzQUiR.js → job-D502Zf8J.js} +1 -1
  129. package/dist/chunks/jwtUtils-FQWtM6iM.js +1 -0
  130. package/dist/chunks/keybindings-D9Boc8FD.js +2 -0
  131. package/dist/chunks/{launchLocalMemory-CE4J98xO.js → launchLocalMemory-DxC3LojF.js} +2 -2
  132. package/dist/chunks/{launchOnboarding-BfTdC6vp.js → launchOnboarding-BLp5k_H4.js} +1 -1
  133. package/dist/chunks/{loadAgentsDir-C7lOqvfh.js → loadAgentsDir-BXtV2jiO.js} +563 -570
  134. package/dist/chunks/loadAgentsDir-BjsAQWqt.js +1 -0
  135. package/dist/chunks/loadPluginHooks-Dt3XQ-3N.js +1 -0
  136. package/dist/chunks/{localSearch-BKrznW5x.js → localSearch-CeP4ef0a.js} +1 -1
  137. package/dist/chunks/localSearch-Cz8Ot7k2.js +1 -0
  138. package/dist/chunks/{log-CezCRpAN.js → log-27kCA_9u.js} +1 -1
  139. package/dist/chunks/{logoV2Utils-BkQfyQ1-.js → logoV2Utils-CEnU8qad.js} +1 -1
  140. package/dist/chunks/{magicDocs-BpVcON9o.js → magicDocs-YtfrqVC6.js} +4 -4
  141. package/dist/chunks/main-CGLCy2pM.js +31 -0
  142. package/dist/chunks/main-CkjTzYj1.js +513 -0
  143. package/dist/chunks/{managedEnv-DhWRJ5DK.js → managedEnv-B-BNY0xC.js} +1 -1
  144. package/dist/chunks/managedEnv-K9Si1UuL.js +1 -0
  145. package/dist/chunks/{mappers-bOab8ipV.js → mappers-IuJeXgvr.js} +1 -1
  146. package/dist/chunks/mcp-DMBoeQzm.js +6 -0
  147. package/dist/chunks/mcp-TMOPfLcW.js +1 -0
  148. package/dist/chunks/mcp-x5rgv-uv.js +2 -0
  149. package/dist/chunks/{memoize-DsqYrbeR.js → memoize-Co4vS6UF.js} +1 -1
  150. package/dist/chunks/memory-DDUoR63T.js +1 -0
  151. package/dist/chunks/{mode-DlKnUM8l.js → mode-GzBwK--u.js} +2 -2
  152. package/dist/chunks/model-BydaMaPr.js +1 -0
  153. package/dist/chunks/model-CDnVaVDR.js +1 -0
  154. package/dist/chunks/model-CIvbC7rW.js +1 -0
  155. package/dist/chunks/{modelOptions-CxP067Qv.js → modelOptions-ut0xePEe.js} +1 -1
  156. package/dist/chunks/nativeInstaller-fgCMR_c0.js +1 -0
  157. package/dist/chunks/oauth-D38aRTUb.js +1 -0
  158. package/dist/chunks/oauth-U649LV5H.js +1 -0
  159. package/dist/chunks/{observationStore-BpjlK0pG.js → observationStore-D0rm3GhP.js} +1 -1
  160. package/dist/chunks/omit-D4Udf-p-.js +1 -0
  161. package/dist/chunks/onChangeAppState-WbvtqDtk.js +1 -0
  162. package/dist/chunks/{openai-B9C2XN5Q.js → openai-DaVFXyBB.js} +3 -3
  163. package/dist/chunks/panel-CoF2a-h4.js +1 -0
  164. package/dist/chunks/parser-B2PlJg4C.js +1 -0
  165. package/dist/chunks/{parser-BwPXQomy.js → parser-CUUiH40T.js} +1 -1
  166. package/dist/chunks/{partition-D-UhsUCx.js → partition-CzW_31Y1.js} +1 -1
  167. package/dist/chunks/permissions-BT3lxYBM.js +3 -0
  168. package/dist/chunks/pidLock-d1VPd6CG.js +3 -0
  169. package/dist/chunks/{plan-CyU2zrCK.js → plan-M9DG3AqN.js} +1 -1
  170. package/dist/chunks/{platform-BMPbglug.js → platform-Dg1c9F_1.js} +1 -1
  171. package/dist/chunks/plugin-BiNHuq3h.js +17 -0
  172. package/dist/chunks/pluginAutoupdate-B5lel6s5.js +1 -0
  173. package/dist/chunks/pluginBlocklist-CNGmIlwU.js +1 -0
  174. package/dist/chunks/pluginCliCommands-WLOEhb2M.js +1 -0
  175. package/dist/chunks/pluginFlagging-CXSSOj4J.js +1 -0
  176. package/dist/chunks/pluginOperations-BFbty6WT.js +2 -0
  177. package/dist/chunks/pluginStartupCheck-BEd0VeQC.js +1 -0
  178. package/dist/chunks/pluginStartupCheck-Bcdxg484.js +1 -0
  179. package/dist/chunks/plugins-BMZ3aYKP.js +4 -0
  180. package/dist/chunks/poorMode-Djw0P9Gu.js +1 -0
  181. package/dist/chunks/{poorMode-DEwQOAJt.js → poorMode-DxgO_bUb.js} +1 -1
  182. package/dist/chunks/print-DmoLcwVq.js +26 -0
  183. package/dist/chunks/processBashCommand-B-VqME9O.js +1 -0
  184. package/dist/chunks/processSlashCommand-D6zEooTy.js +5 -0
  185. package/dist/chunks/{projectContext-CIxul6vA.js → projectContext-BN2ZWzOG.js} +1 -1
  186. package/dist/chunks/{projectContext-RUMJB798.js → projectContext-Bw3o5BrN.js} +1 -1
  187. package/dist/chunks/prompt-C3RRe4kW.js +1 -0
  188. package/dist/chunks/{prompt-M2lu8_Oa.js → prompt-CRc2QEZ5.js} +5 -5
  189. package/dist/chunks/prompt-EtAanewG.js +1 -0
  190. package/dist/chunks/{promptEditor-DhcZY-iu.js → promptEditor-Bo1d8ZLq.js} +2 -2
  191. package/dist/chunks/{protocolHandler-CkFaJKKo.js → protocolHandler-B83fCYI4.js} +4 -4
  192. package/dist/chunks/{proxy-CuMaO_YV.js → proxy-BEKNaTXI.js} +3 -3
  193. package/dist/chunks/rcDebugLog-DSchf3Hs.js +1 -0
  194. package/dist/chunks/reconciler-BGav_ezX.js +1 -0
  195. package/dist/chunks/refresh-DumNiLvM.js +1 -0
  196. package/dist/chunks/{registerProtocol-CsNYRZKr.js → registerProtocol-DduKPsn_.js} +2 -2
  197. package/dist/chunks/{reload-plugins-B7JAE3b4.js → reload-plugins-DNEgQ5vo.js} +1 -1
  198. package/dist/chunks/{remoteBridgeCore-CFLJhsB6.js → remoteBridgeCore-BGOqHADF.js} +1 -1
  199. package/dist/chunks/remoteManagedSettings-26nhzuca.js +1 -0
  200. package/dist/chunks/{rename-BCp2Vtqu.js → rename-BPknfVGF.js} +1 -1
  201. package/dist/chunks/{renderOptions-Q5oCLFIC.js → renderOptions-45A-EdsK.js} +1 -1
  202. package/dist/chunks/resume-DGz04xDh.js +2 -0
  203. package/dist/chunks/ripgrep-BLQnqPnE.js +1 -0
  204. package/dist/chunks/{ripgrep-DvOOsDMv.js → ripgrep-DQ_ILUJV.js} +5 -5
  205. package/dist/chunks/{runtimeObserver-CS_3BDNo.js → runtimeObserver-BZrF3GnQ.js} +4 -4
  206. package/dist/chunks/{runtimeObserver-DYUva6g-.js → runtimeObserver-CBV-7-w7.js} +1 -1
  207. package/dist/chunks/sandbox-adapter-DUqeqkQD.js +1 -0
  208. package/dist/chunks/sandbox-toggle-D61gVqcT.js +1 -0
  209. package/dist/chunks/searchExtraTools-CgsV6kb1.js +1 -0
  210. package/dist/chunks/{session-CO3gEqQP.js → session-Dy-_R7KP.js} +2 -2
  211. package/dist/chunks/sessionFileAccessHooks-BJlrZaRD.js +1 -0
  212. package/dist/chunks/sessionObserver-BGYoLRGx.js +1 -0
  213. package/dist/chunks/{sessionObserver-YkRHC-Aa.js → sessionObserver-CyLpHSkw.js} +1 -1
  214. package/dist/chunks/{sessionState-Bifmu95-.js → sessionState-DSWN4tMV.js} +2 -2
  215. package/dist/chunks/sessionStorage-zJ1esSCE.js +1 -0
  216. package/dist/chunks/{sessionStoragePortable-JZnGwqUM.js → sessionStoragePortable-BhkGMZWp.js} +1 -1
  217. package/dist/chunks/{sessionTitle-COBSgSXS.js → sessionTitle-L5tyJgdU.js} +2 -2
  218. package/dist/chunks/{sessionTracing-BrNx1k2V.js → sessionTracing-DpHGGIZm.js} +3 -3
  219. package/dist/chunks/settings-3ionQKNv.js +1 -0
  220. package/dist/chunks/settings-DiBMs2gM.js +20 -0
  221. package/dist/chunks/settingsSync-dBqlrbcU.js +1 -0
  222. package/dist/chunks/setup-zf3v3ICe.js +3 -0
  223. package/dist/chunks/{shadowedRuleDetection-DEaw-X5j.js → shadowedRuleDetection-DZ0AA2Rw.js} +1 -1
  224. package/dist/chunks/{shellQuote-BYeOv3Ip.js → shellQuote-C_I6DHLV.js} +2 -2
  225. package/dist/chunks/{sideQuestion-D0OKljee.js → sideQuestion-BYT8FdPF.js} +2 -2
  226. package/dist/chunks/sinks-DppGvgz1.js +1 -0
  227. package/dist/chunks/sinks-mFsijQ_S.js +2 -0
  228. package/dist/chunks/skillChangeDetector-D-iq09Xs.js +1 -0
  229. package/dist/chunks/{skillGapStore-N_kmvXML.js → skillGapStore-DQXHqoP7.js} +2 -2
  230. package/dist/chunks/{skillLifecycle-C4F5RXuh.js → skillLifecycle-BG_RnGSh.js} +2 -2
  231. package/dist/chunks/skillSearchPanel-DxYP4Q6R.js +21 -0
  232. package/dist/chunks/skills-BD-2ofXA.js +1 -0
  233. package/dist/chunks/startupProfiler-CUlV07MD.js +1 -0
  234. package/dist/chunks/{startupProfiler-L_UWZ03w.js → startupProfiler-Dc5r6LgE.js} +2 -2
  235. package/dist/chunks/{state-BemZdQIl.js → state-BPFYBqm1.js} +1 -1
  236. package/dist/chunks/state-CsdHk8n-.js +1 -0
  237. package/dist/chunks/{stats-IzV0_vEc.js → stats-BkadEKa-.js} +1 -1
  238. package/dist/chunks/status-BmHu-c7I.js +2 -0
  239. package/dist/chunks/{status-CeVP_uDT.js → status-CrmnCDIE.js} +1 -1
  240. package/dist/chunks/{statusNoticeHelpers-Bb9gxdSt.js → statusNoticeHelpers-DakAVtQO.js} +1 -1
  241. package/dist/chunks/{stringUtils-C84IJ91d.js → stringUtils-Df-Lnjxd.js} +1 -1
  242. package/dist/chunks/{subprocessEnv-Ci8VV_bi.js → subprocessEnv-CNBOhlDV.js} +1 -1
  243. package/dist/chunks/subprocessEnv-DtBCqQIo.js +1 -0
  244. package/dist/chunks/switcher-Dm646gO5.js +1 -0
  245. package/dist/chunks/switcher-sYTxnJQA.js +1 -0
  246. package/dist/chunks/syncCache-BofuFJEe.js +1 -0
  247. package/dist/chunks/{tasks-DZDhgx0w.js → tasks-NpI1iEem.js} +1 -1
  248. package/dist/chunks/teleport-Bs3kEipi.js +1 -0
  249. package/dist/chunks/{templateJobs-CrNPEKkh.js → templateJobs-C94jEE6O.js} +2 -2
  250. package/dist/chunks/{terminalSetup-CBqcwQll.js → terminalSetup-CbXKCpWM.js} +1 -1
  251. package/dist/chunks/{terminalSetup-D-N8YPiQ.js → terminalSetup-fwhFTxGi.js} +4 -4
  252. package/dist/chunks/{theme-Dazsirbw.js → theme-CEi3b_8f.js} +1 -1
  253. package/dist/chunks/tmux-d3cNCIZA.js +1 -0
  254. package/dist/chunks/{toolEventObserver-lnHJ9fLQ.js → toolEventObserver-DlL9CHmI.js} +1 -1
  255. package/dist/chunks/toolPool-DIT_uhtD.js +1 -0
  256. package/dist/chunks/trustedDevice-BokywSKL.js +1 -0
  257. package/dist/chunks/trustedDevice-Bzz03jCy.js +1 -0
  258. package/dist/chunks/{types-3j8PS-Du.js → types-BJ7qTz75.js} +2 -2
  259. package/dist/chunks/udsClient-CF8BmZgN.js +1 -0
  260. package/dist/chunks/{updateCCB-BPe9_FW6.js → updateCCB-CzBxsuJe.js} +1 -1
  261. package/dist/chunks/{upstreamproxy-DF00RzGG.js → upstreamproxy-BuBFDFAD.js} +2 -2
  262. package/dist/chunks/{useExitOnCtrlCDWithKeybindings-ChqBs9Lr.js → useExitOnCtrlCDWithKeybindings-BHQfwlAl.js} +1 -1
  263. package/dist/chunks/useMainLoopModel-BkyIIW9t.js +1 -0
  264. package/dist/chunks/useManagePlugins-BWROoGDs.js +1 -0
  265. package/dist/chunks/{useMergedTools-Dk5cPqLc.js → useMergedTools-CHxnwR7R.js} +1 -1
  266. package/dist/chunks/{useSearchInput-C7Y1I9P9.js → useSearchInput-q2CFPU4W.js} +1 -1
  267. package/dist/chunks/{useSettingsErrors-DAEO7AyB.js → useSettingsErrors-CPVQbsqq.js} +1 -1
  268. package/dist/chunks/{userAgent-CIq27vUR.js → userAgent-B7WkjI6I.js} +1 -1
  269. package/dist/chunks/util-BfqXOA-P.js +1 -0
  270. package/dist/chunks/{validatePlugin-Kk6pxnO2.js → validatePlugin-jrcrYEIu.js} +1 -1
  271. package/dist/chunks/{vim-EYQn94Kx.js → vim-C4Hs5U2h.js} +1 -1
  272. package/dist/chunks/{which-DzFN5TNM.js → which-mplwBbc0.js} +1 -1
  273. package/dist/chunks/windowsPaths-B8p9tFRF.js +1 -0
  274. package/dist/chunks/windowsPaths-C7Mdo9aU.js +1 -0
  275. package/dist/chunks/{workSecret-DUqdPy44.js → workSecret-XLodD7tw.js} +1 -1
  276. package/dist/chunks/workerRegistry-Cfo7bKlm.js +6 -0
  277. package/dist/chunks/worktree-D0k_pCEz.js +1 -0
  278. package/dist/cli.js +1 -1
  279. package/package.json +2 -3
  280. package/dist/chunks/App-C2yQjBgY.js +0 -1
  281. package/dist/chunks/ApproveApiKey-CKbv5C1x.js +0 -1
  282. package/dist/chunks/ApproveApiKey-MscC-ssL.js +0 -1
  283. package/dist/chunks/BackgroundTasksDialog-CL5NWsFL.js +0 -2
  284. package/dist/chunks/ClaudeMdExternalIncludesDialog-BqNxQOXJ.js +0 -1
  285. package/dist/chunks/ClaudeMdExternalIncludesDialog-C0-psohX.js +0 -1
  286. package/dist/chunks/ConsoleOAuthFlow-4mOvEer_.js +0 -1
  287. package/dist/chunks/Doctor-DmgAwce2.js +0 -1
  288. package/dist/chunks/Doctor-jEs9chPk.js +0 -3
  289. package/dist/chunks/ExitFlow-DVKxFdpX.js +0 -2
  290. package/dist/chunks/InvalidConfigDialog-o9DF1REI.js +0 -1
  291. package/dist/chunks/MCPConnectionManager-CUTuaa8T.js +0 -1
  292. package/dist/chunks/MCPToolListView-CvqB4nCw.js +0 -1
  293. package/dist/chunks/MessageSelector-BLzw172f.js +0 -3
  294. package/dist/chunks/Messages-4K5sLmNh.js +0 -11
  295. package/dist/chunks/Onboarding-ClwHS5rh.js +0 -1
  296. package/dist/chunks/PromptInputHelpMenu-Bb4KdIX_.js +0 -1
  297. package/dist/chunks/QueryEngine-DPHLSsax.js +0 -1
  298. package/dist/chunks/REPL-Bf46iQCN.js +0 -1
  299. package/dist/chunks/REPL-DIaAo9M9.js +0 -133
  300. package/dist/chunks/RemoteSessionManager-CS6mywIn.js +0 -2
  301. package/dist/chunks/ResumeConversation-Br2KsBoe.js +0 -1
  302. package/dist/chunks/SearchExtraToolsTool-i_YO3QvV.js +0 -1
  303. package/dist/chunks/Settings-BMXysXIx.js +0 -2
  304. package/dist/chunks/TrustDialog-Fk4m_Sy4.js +0 -1
  305. package/dist/chunks/add-dir-CZ6Clvq8.js +0 -1
  306. package/dist/chunks/agents-DHnNg4h6.js +0 -103
  307. package/dist/chunks/allErrors-CU89tF-z.js +0 -1
  308. package/dist/chunks/api-BSeE6MwB.js +0 -1
  309. package/dist/chunks/auth-BIGJth5U.js +0 -1
  310. package/dist/chunks/auth-CDQMhIZP.js +0 -1
  311. package/dist/chunks/autonomy-C1aSgWPQ.js +0 -1
  312. package/dist/chunks/autonomy-Src6sKCp.js +0 -15
  313. package/dist/chunks/autonomyPanel-DnHpuiy4.js +0 -1
  314. package/dist/chunks/backgroundHousekeeping-B-cw0UcS.js +0 -17
  315. package/dist/chunks/backgroundHousekeeping-BS_8z3_x.js +0 -1
  316. package/dist/chunks/bg-50rllUNh.js +0 -1
  317. package/dist/chunks/bg-DAPORXF3.js +0 -9
  318. package/dist/chunks/bridgeConfig-BeqChxJC.js +0 -1
  319. package/dist/chunks/caches-BTQAW9zc.js +0 -1
  320. package/dist/chunks/caches-BVtSCnV1.js +0 -1
  321. package/dist/chunks/ccrClient-Bu7Tf1Z5.js +0 -1
  322. package/dist/chunks/cliLaunch-BWcoyZDP.js +0 -1
  323. package/dist/chunks/client-BWQ4-rN7.js +0 -1
  324. package/dist/chunks/client-c-3-PW1F.js +0 -1
  325. package/dist/chunks/commands-Bi7k3Wg-.js +0 -1
  326. package/dist/chunks/compact-J-h0Yf4b.js +0 -2
  327. package/dist/chunks/config-Do1870_d.js +0 -3
  328. package/dist/chunks/config-yyFe87vW.js +0 -1
  329. package/dist/chunks/context-Tb1Ca2Q-.js +0 -1
  330. package/dist/chunks/context-noninteractive-soPYKAc9.js +0 -1
  331. package/dist/chunks/conversation-CSEtUxOY.js +0 -1
  332. package/dist/chunks/conversation-Dk1WDQuN.js +0 -1
  333. package/dist/chunks/createSSHSession-CJtzNQdZ.js +0 -6
  334. package/dist/chunks/createSession-DkT1GL8y.js +0 -1
  335. package/dist/chunks/createSession-eE8mswkv.js +0 -1
  336. package/dist/chunks/crossProjectResume-04n3Ppy9.js +0 -40
  337. package/dist/chunks/cwd-ClLru_7T.js +0 -1
  338. package/dist/chunks/datadog-DjeJThpV.js +0 -1
  339. package/dist/chunks/debug-RAynG_nM.js +0 -39
  340. package/dist/chunks/detached-X_yjYR7x.js +0 -5
  341. package/dist/chunks/detectRepository-DgpNd87p.js +0 -1
  342. package/dist/chunks/detectRepository-ctF9KDbb.js +0 -1
  343. package/dist/chunks/doctor-B-Wag4C1.js +0 -1
  344. package/dist/chunks/entry-oIqjxIjQ.js +0 -14
  345. package/dist/chunks/execSyncWrapper-BTZJjCuv.js +0 -1
  346. package/dist/chunks/exit-BtW7LfRX.js +0 -1
  347. package/dist/chunks/extractMemories-CUrdiNcr.js +0 -1
  348. package/dist/chunks/fast-C60p6AqJ.js +0 -1
  349. package/dist/chunks/firstPartyEventLogger-BfCYN7lt.js +0 -1
  350. package/dist/chunks/gemini-BwvSxGgn.js +0 -1
  351. package/dist/chunks/generateSessionName-DlrdedOk.js +0 -1
  352. package/dist/chunks/git-2c7WlGDL.js +0 -6
  353. package/dist/chunks/git-XtKbtJMc.js +0 -1
  354. package/dist/chunks/githubRepoPathMapping-DbWG4hFQ.js +0 -1
  355. package/dist/chunks/goal-ZmSRBx4q.js +0 -3
  356. package/dist/chunks/hooks-DWg07LmS.js +0 -1
  357. package/dist/chunks/jwtUtils-CUPXdX3W.js +0 -1
  358. package/dist/chunks/keybindings-DgIPdBy9.js +0 -2
  359. package/dist/chunks/loadAgentsDir-zikjxLvn.js +0 -1
  360. package/dist/chunks/loadPluginHooks-Cp8MSwAc.js +0 -1
  361. package/dist/chunks/localSearch-ZFyFy5FN.js +0 -1
  362. package/dist/chunks/main-9r5gLzUW.js +0 -605
  363. package/dist/chunks/main-CvOv59-7.js +0 -31
  364. package/dist/chunks/managedEnv-B61yLpwp.js +0 -1
  365. package/dist/chunks/mcp-BckPBjaM.js +0 -6
  366. package/dist/chunks/mcp-CS1DA3JL.js +0 -1
  367. package/dist/chunks/mcp-VcGPYCkW.js +0 -2
  368. package/dist/chunks/memory-C5ohwh-T.js +0 -1
  369. package/dist/chunks/model-BGu1AGq0.js +0 -1
  370. package/dist/chunks/model-BsZ4sP_H.js +0 -1
  371. package/dist/chunks/model-D19IIcll.js +0 -1
  372. package/dist/chunks/nativeInstaller-QB8cEJ18.js +0 -1
  373. package/dist/chunks/oauth-BN2I0_jl.js +0 -1
  374. package/dist/chunks/oauth-C9VBDB0Y.js +0 -1
  375. package/dist/chunks/omit-DDUIPHnl.js +0 -1
  376. package/dist/chunks/onChangeAppState-RBl6H7ho.js +0 -1
  377. package/dist/chunks/panel-KW-wmEvU.js +0 -1
  378. package/dist/chunks/parser-xSBaQRLH.js +0 -1
  379. package/dist/chunks/permissions-BoLXYN1j.js +0 -3
  380. package/dist/chunks/pidLock-nJHbufJN.js +0 -3
  381. package/dist/chunks/plugin-C6-GQke5.js +0 -17
  382. package/dist/chunks/pluginAutoupdate-SlRFJlTT.js +0 -1
  383. package/dist/chunks/pluginBlocklist-n6Imlh3y.js +0 -1
  384. package/dist/chunks/pluginCliCommands-Bd96zSOQ.js +0 -1
  385. package/dist/chunks/pluginFlagging-DZaYzecY.js +0 -1
  386. package/dist/chunks/pluginOperations-D90IRawu.js +0 -2
  387. package/dist/chunks/pluginStartupCheck-Bxkxpm4k.js +0 -1
  388. package/dist/chunks/pluginStartupCheck-CB2q2dLv.js +0 -1
  389. package/dist/chunks/plugins-B9eSjLSA.js +0 -4
  390. package/dist/chunks/poorMode-BAnubpn1.js +0 -1
  391. package/dist/chunks/print-eCRv_Li-.js +0 -26
  392. package/dist/chunks/processBashCommand-B5F2Cl7K.js +0 -1
  393. package/dist/chunks/processSlashCommand-BC_D3cH5.js +0 -5
  394. package/dist/chunks/prompt-C1JPqinc.js +0 -1
  395. package/dist/chunks/prompt-DZhBz_Vu.js +0 -1
  396. package/dist/chunks/rcDebugLog-CARUIORE.js +0 -1
  397. package/dist/chunks/reconciler-B4GDm_iC.js +0 -1
  398. package/dist/chunks/refresh-DBVizOzg.js +0 -1
  399. package/dist/chunks/remoteManagedSettings-xh_MViZH.js +0 -1
  400. package/dist/chunks/resume-DVCSzKvv.js +0 -2
  401. package/dist/chunks/ripgrep-e-iewvTf.js +0 -1
  402. package/dist/chunks/sandbox-adapter-BFZFHplu.js +0 -1
  403. package/dist/chunks/sandbox-toggle--zNSKce_.js +0 -1
  404. package/dist/chunks/searchExtraTools-ui5y2VSE.js +0 -1
  405. package/dist/chunks/sessionFileAccessHooks-CZvCqQJ6.js +0 -1
  406. package/dist/chunks/sessionObserver-Ba7um95p.js +0 -1
  407. package/dist/chunks/sessionStorage-CedwLLQs.js +0 -1
  408. package/dist/chunks/settings-DkDH7WQT.js +0 -1
  409. package/dist/chunks/settings-DnptdP79.js +0 -20
  410. package/dist/chunks/settingsSync-PmU7SmkU.js +0 -1
  411. package/dist/chunks/setup-BEsBuzsk.js +0 -3
  412. package/dist/chunks/sinks-BJHgxz6Y.js +0 -1
  413. package/dist/chunks/sinks-D5-yhcgU.js +0 -2
  414. package/dist/chunks/skillChangeDetector-Dd0WPdkO.js +0 -1
  415. package/dist/chunks/skillSearchPanel-CftorvAM.js +0 -21
  416. package/dist/chunks/skills-C4CTRN9o.js +0 -1
  417. package/dist/chunks/startupProfiler-D4FBdEQr.js +0 -1
  418. package/dist/chunks/state-BAGmpVBn.js +0 -1
  419. package/dist/chunks/state-D_lk6z-C.js +0 -1
  420. package/dist/chunks/status-Dzuw3hBv.js +0 -2
  421. package/dist/chunks/subprocessEnv-CZkA9Cdp.js +0 -1
  422. package/dist/chunks/switcher-4KzBvuKH.js +0 -1
  423. package/dist/chunks/switcher-CCs9xl1z.js +0 -1
  424. package/dist/chunks/syncCache-CBRiRU5x.js +0 -1
  425. package/dist/chunks/teleport-Bw0jSxe9.js +0 -1
  426. package/dist/chunks/tmux-DewYVEBm.js +0 -1
  427. package/dist/chunks/toolPool-CkXFlqsn.js +0 -1
  428. package/dist/chunks/trustedDevice-CFf5yaG-.js +0 -1
  429. package/dist/chunks/trustedDevice-CuwSv8dG.js +0 -1
  430. package/dist/chunks/udsClient-e9dIkwVA.js +0 -1
  431. package/dist/chunks/useMainLoopModel-2-eujv0n.js +0 -1
  432. package/dist/chunks/useManagePlugins-CYBIkaB1.js +0 -1
  433. package/dist/chunks/util-VO98TdOz.js +0 -1
  434. package/dist/chunks/windowsPaths-BU3yQWTB.js +0 -1
  435. package/dist/chunks/windowsPaths-DgZ3YY4a.js +0 -1
  436. package/dist/chunks/workerRegistry-C07BcZIw.js +0 -6
  437. package/dist/chunks/worktree-dFUkhVE_.js +0 -1
@@ -0,0 +1,3 @@
1
+ import{i as e,n as t,t as n}from"./rolldown-runtime-DaDcL9Zw.js";import{n as r,t as i}from"./isObject-C6qM3WEW.js";import{n as a,t as o}from"./memoize-BK3gG5ob.js";import{c as s,i as c,l,o as u}from"./envUtils-DcaKZlRU.js";import{t as d}from"./graceful-fs-DDVg0cja.js";import{Ar as f,Ci as p,Cr as m,Dr as h,Er as g,Fr as _,Or as v,Pr as ee,Si as te,Sr as ne,Wt as re,et as ie,fi as ae,gt as oe,hi as se,it as ce,jr as le,kr as ue,mi as de,oi as fe,pi as pe,si as me,vi as he,yi as ge}from"./state-BPFYBqm1.js";import{n as _e,t as ve}from"./cwd-Besi3Os3.js";import{C as y,F as b,O as x,R as ye,S as be,c as S,f as xe,i as Se,nt as Ce,tt as we,u as C,x as Te}from"./debug-Dr1SjdXn.js";import{Cr as Ee,Dr as De,Fn as Oe,Jt as w,Or as ke,Qt as Ae,Xt as je,Yt as Me,_r as Ne,c as T,cr as Pe,g as Fe,lr as E,n as Ie,vr as Le,wn as Re,wr as ze}from"./settings-DiBMs2gM.js";import{O as Be,k as Ve,m as He,n as Ue}from"./git-CoQQ6YEf.js";import{d as We,o as Ge,s as Ke,u as qe}from"./log-27kCA_9u.js";import{m as Je}from"./sessionStoragePortable-BhkGMZWp.js";import{f as Ye,p as Xe,s as Ze,u as Qe}from"./types-BJ7qTz75.js";import{n as $e,r as D}from"./analytics-DJobLaWP.js";import{homedir as et}from"os";import{basename as O,dirname as k,isAbsolute as tt,join as A,normalize as j,resolve as nt,sep as rt}from"path";import{unwatchFile as it,watchFile as at}from"fs";import{randomBytes as ot}from"crypto";var M,st=t((()=>{p(),Le(),pe(),de(),M=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)te(t,ae(e)),e=Ne(e);return t}:se}));function ct(e){return he(e,ze,M)}var lt=t((()=>{ge(),st(),Ee()}));function ut(){let e=process.env.CLAUDE_CODE_DISABLE_AUTO_MEMORY;if(l(e))return!1;if(s(e))return!0;if(l(process.env.CLAUDE_CODE_SIMPLE)||l(process.env.CLAUDE_CODE_REMOTE)&&!process.env.CLAUDE_CODE_REMOTE_MEMORY_DIR)return!1;let t=Ie();return t.autoMemoryEnabled===void 0||t.autoMemoryEnabled}function dt(){return!1}function ft(){return process.env.CLAUDE_CODE_REMOTE_MEMORY_DIR?process.env.CLAUDE_CODE_REMOTE_MEMORY_DIR:c()}function pt(e,t){if(!e)return;let n=e;if(t&&(n.startsWith(`~/`)||n.startsWith(`~\\`))){let e=n.slice(2),t=j(e||`.`);if(t===`.`||t===`..`)return;n=A(et(),e)}let r=j(n).replace(/[/\\]+$/,``);if(!(!tt(r)||r.length<3||/^[A-Za-z]:$/.test(r)||r.startsWith(`\\\\`)||r.startsWith(`//`)||r.includes(`\0`)))return(r+rt).normalize(`NFC`)}function mt(){return pt(process.env.CLAUDE_COWORK_MEMORY_PATH_OVERRIDE,!1)}function ht(){return pt(T(`policySettings`)?.autoMemoryDirectory??T(`flagSettings`)?.autoMemoryDirectory??T(`localSettings`)?.autoMemoryDirectory??T(`userSettings`)?.autoMemoryDirectory,!0)}function gt(){return mt()!==void 0}function _t(){return Ue(ce())??ce()}function vt(){return A(N(),xt)}function yt(e){return j(e).startsWith(N())}var bt,xt,N,St=t((()=>{o(),re(),u(),He(),Pe(),Fe(),bt=`memory`,xt=`MEMORY.md`,N=a(()=>(mt()??ht())||(A(A(ft(),`projects`),Je(_t()),bt)+rt).normalize(`NFC`),()=>ce())}));function Ct(e,t,n,i){if(!r(e))return e;t=f(t,e);for(var a=-1,o=t.length,s=o-1,c=e;c!=null&&++a<o;){var l=ue(t[a]),u=n;if(l===`__proto__`||l===`constructor`||l===`prototype`)return e;if(a!=s){var d=c[l];u=i?i(d,l,c):void 0,u===void 0&&(u=r(d)?d:me(t[a+1])?[]:{})}De(c,l,u),c=c[l]}return e}var wt=t((()=>{ke(),le(),fe(),i(),v()}));function Tt(e,t,n){for(var r=-1,i=t.length,a={};++r<i;){var o=t[r],s=g(e,o);n(s,o)&&Ct(a,f(o,e),s)}return a}var Et=t((()=>{h(),wt(),le()}));function P(e,t){if(e==null)return{};var n=ee(ct(e),function(e){return[e]});return t=ne(t),Tt(e,n,function(e,n){return t(e,n[0])})}var Dt=t((()=>{_(),m(),Et(),lt()})),Ot=n(((e,t)=>{function n(e,t){typeof t==`boolean`&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}t.exports=n,n.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts},n.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timeouts=[],this._cachedTimeouts=null},n.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.unshift(Error(`RetryOperation timeout occurred`)),!1;this._errors.push(e);var n=this._timeouts.shift();if(n===void 0)if(this._cachedTimeouts)this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),n=this._timeouts.shift();else return!1;var r=this,i=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},n);return this._options.unref&&i.unref(),!0},n.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){n._operationTimeoutCb()},n._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)},n.prototype.try=function(e){console.log(`Using RetryOperation.try() is deprecated`),this.attempt(e)},n.prototype.start=function(e){console.log(`Using RetryOperation.start() is deprecated`),this.attempt(e)},n.prototype.start=n.prototype.try,n.prototype.errors=function(){return this._errors},n.prototype.attempts=function(){return this._attempts},n.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},t=null,n=0,r=0;r<this._errors.length;r++){var i=this._errors[r],a=i.message,o=(e[a]||0)+1;e[a]=o,o>=n&&(t=i,n=o)}return t}})),kt=n((e=>{var t=Ot();e.operation=function(n){return new t(e.timeouts(n),{forever:n&&n.forever,unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})},e.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var n in e)t[n]=e[n];if(t.minTimeout>t.maxTimeout)throw Error(`minTimeout is greater than maxTimeout`);for(var r=[],i=0;i<t.retries;i++)r.push(this.createTimeout(i,t));return e&&e.forever&&!r.length&&r.push(this.createTimeout(i,t)),r.sort(function(e,t){return e-t}),r},e.createTimeout=function(e,t){var n=t.randomize?Math.random()+1:1,r=Math.round(n*t.minTimeout*t.factor**+e);return r=Math.min(r,t.maxTimeout),r},e.wrap=function(t,n,r){if(n instanceof Array&&(r=n,n=null),!r)for(var i in r=[],t)typeof t[i]==`function`&&r.push(i);for(var a=0;a<r.length;a++){var o=r[a],s=t[o];t[o]=function(r){var i=e.operation(n),a=Array.prototype.slice.call(arguments,1),o=a.pop();a.push(function(e){i.retry(e)||(e&&(arguments[0]=i.mainError()),o.apply(this,arguments))}),i.attempt(function(){r.apply(t,a)})}.bind(t,s),t[o].options=n}}})),At=n(((e,t)=>{t.exports=kt()})),jt=n(((e,t)=>{t.exports=[`SIGABRT`,`SIGALRM`,`SIGHUP`,`SIGINT`,`SIGTERM`],process.platform!==`win32`&&t.exports.push(`SIGVTALRM`,`SIGXCPU`,`SIGXFSZ`,`SIGUSR2`,`SIGTRAP`,`SIGSYS`,`SIGQUIT`,`SIGIOT`),process.platform===`linux`&&t.exports.push(`SIGIO`,`SIGPOLL`,`SIGPWR`,`SIGSTKFLT`,`SIGUNUSED`)})),Mt=n(((t,n)=>{var r=global.process,i=function(e){return e&&typeof e==`object`&&typeof e.removeListener==`function`&&typeof e.emit==`function`&&typeof e.reallyExit==`function`&&typeof e.listeners==`function`&&typeof e.kill==`function`&&typeof e.pid==`number`&&typeof e.on==`function`};if(!i(r))n.exports=function(){return function(){}};else{var a=e(`assert`),o=jt(),s=/^win/i.test(r.platform),c=e(`events`);typeof c!=`function`&&(c=c.EventEmitter);var l;r.__signal_exit_emitter__?l=r.__signal_exit_emitter__:(l=r.__signal_exit_emitter__=new c,l.count=0,l.emitted={}),l.infinite||(l.setMaxListeners(1/0),l.infinite=!0),n.exports=function(e,t){if(!i(global.process))return function(){};a.equal(typeof e,`function`,`a callback must be provided for exit handler`),p===!1&&m();var n=`exit`;return t&&t.alwaysLast&&(n=`afterexit`),l.on(n,e),function(){l.removeListener(n,e),l.listeners(`exit`).length===0&&l.listeners(`afterexit`).length===0&&u()}};var u=function(){!p||!i(global.process)||(p=!1,o.forEach(function(e){try{r.removeListener(e,f[e])}catch{}}),r.emit=_,r.reallyExit=h,--l.count)};n.exports.unload=u;var d=function(e,t,n){l.emitted[e]||(l.emitted[e]=!0,l.emit(e,t,n))},f={};o.forEach(function(e){f[e]=function(){i(global.process)&&r.listeners(e).length===l.count&&(u(),d(`exit`,null,e),d(`afterexit`,null,e),s&&e===`SIGHUP`&&(e=`SIGINT`),r.kill(r.pid,e))}}),n.exports.signals=function(){return o};var p=!1,m=function(){p||!i(global.process)||(p=!0,l.count+=1,o=o.filter(function(e){try{return r.on(e,f[e]),!0}catch{return!1}}),r.emit=v,r.reallyExit=g)};n.exports.load=m;var h=r.reallyExit,g=function(e){i(global.process)&&(r.exitCode=e||0,d(`exit`,r.exitCode,null),d(`afterexit`,r.exitCode,null),h.call(r,r.exitCode))},_=r.emit,v=function(e,t){if(e===`exit`&&i(global.process)){t!==void 0&&(r.exitCode=t);var n=_.apply(this,arguments);return d(`exit`,r.exitCode,null),d(`afterexit`,r.exitCode,null),n}else return _.apply(this,arguments)}}})),Nt=n(((e,t)=>{var n=Symbol();function r(e,t,r){let i=t[n];if(i)return t.stat(e,(e,t)=>{if(e)return r(e);r(null,t.mtime,i)});let a=new Date(Math.ceil(Date.now()/1e3)*1e3+5);t.utimes(e,a,a,i=>{if(i)return r(i);t.stat(e,(e,i)=>{if(e)return r(e);let a=i.mtime.getTime()%1e3==0?`s`:`ms`;Object.defineProperty(t,n,{value:a}),r(null,i.mtime,a)})})}function i(e){let t=Date.now();return e===`s`&&(t=Math.ceil(t/1e3)*1e3),new Date(t)}t.exports.probe=r,t.exports.getMtime=i})),Pt=n(((t,n)=>{var r=e(`path`),i=d(),a=At(),o=Mt(),s=Nt(),c={};function l(e,t){return t.lockfilePath||`${e}.lock`}function u(e,t,n){if(!t.realpath)return n(null,r.resolve(e));t.fs.realpath(e,n)}function f(e,t,n){let r=l(e,t);t.fs.mkdir(r,i=>{if(!i)return s.probe(r,t.fs,(e,i,a)=>{if(e)return t.fs.rmdir(r,()=>{}),n(e);n(null,i,a)});if(i.code!==`EEXIST`)return n(i);if(t.stale<=0)return n(Object.assign(Error(`Lock file is already being held`),{code:`ELOCKED`,file:e}));t.fs.stat(r,(r,i)=>{if(r)return r.code===`ENOENT`?f(e,{...t,stale:0},n):n(r);if(!p(i,t))return n(Object.assign(Error(`Lock file is already being held`),{code:`ELOCKED`,file:e}));m(e,t,r=>{if(r)return n(r);f(e,{...t,stale:0},n)})})})}function p(e,t){return e.mtime.getTime()<Date.now()-t.stale}function m(e,t,n){t.fs.rmdir(l(e,t),e=>{if(e&&e.code!==`ENOENT`)return n(e);n()})}function h(e,t){let n=c[e];n.updateTimeout||(n.updateDelay=n.updateDelay||t.update,n.updateTimeout=setTimeout(()=>{n.updateTimeout=null,t.fs.stat(n.lockfilePath,(r,i)=>{let a=n.lastUpdate+t.stale<Date.now();if(r)return r.code===`ENOENT`||a?g(e,n,Object.assign(r,{code:`ECOMPROMISED`})):(n.updateDelay=1e3,h(e,t));if(n.mtime.getTime()!==i.mtime.getTime())return g(e,n,Object.assign(Error(`Unable to update lock within the stale threshold`),{code:`ECOMPROMISED`}));let o=s.getMtime(n.mtimePrecision);t.fs.utimes(n.lockfilePath,o,o,r=>{let i=n.lastUpdate+t.stale<Date.now();if(!n.released){if(r)return r.code===`ENOENT`||i?g(e,n,Object.assign(r,{code:`ECOMPROMISED`})):(n.updateDelay=1e3,h(e,t));n.mtime=o,n.lastUpdate=Date.now(),n.updateDelay=null,h(e,t)}})})},n.updateDelay),n.updateTimeout.unref&&n.updateTimeout.unref())}function g(e,t,n){t.released=!0,t.updateTimeout&&clearTimeout(t.updateTimeout),c[e]===t&&delete c[e],t.options.onCompromised(n)}function _(e,t,n){t={stale:1e4,update:null,realpath:!0,retries:0,fs:i,onCompromised:e=>{throw e},...t},t.retries=t.retries||0,t.retries=typeof t.retries==`number`?{retries:t.retries}:t.retries,t.stale=Math.max(t.stale||0,2e3),t.update=t.update==null?t.stale/2:t.update||0,t.update=Math.max(Math.min(t.update,t.stale/2),1e3),u(e,t,(e,r)=>{if(e)return n(e);let i=a.operation(t.retries);i.attempt(()=>{f(r,t,(e,a,o)=>{if(i.retry(e))return;if(e)return n(i.mainError());let s=c[r]={lockfilePath:l(r,t),mtime:a,mtimePrecision:o,options:t,lastUpdate:Date.now()};h(r,t),n(null,e=>{if(s.released)return e&&e(Object.assign(Error(`Lock is already released`),{code:`ERELEASED`}));v(r,{...t,realpath:!1},e)})})})})}function v(e,t,n){t={fs:i,realpath:!0,...t},u(e,t,(e,r)=>{if(e)return n(e);let i=c[r];if(!i)return n(Object.assign(Error(`Lock is not acquired/owned by you`),{code:`ENOTACQUIRED`}));i.updateTimeout&&clearTimeout(i.updateTimeout),i.released=!0,delete c[r],m(r,t,n)})}function ee(e,t,n){t={stale:1e4,realpath:!0,fs:i,...t},t.stale=Math.max(t.stale||0,2e3),u(e,t,(e,r)=>{if(e)return n(e);t.fs.stat(l(r,t),(e,r)=>e?e.code===`ENOENT`?n(null,!1):n(e):n(null,!p(r,t)))})}function te(){return c}o(()=>{for(let e in c){let t=c[e].options;try{t.fs.rmdirSync(l(e,t))}catch{}}}),n.exports.lock=_,n.exports.unlock=v,n.exports.check=ee,n.exports.getLocks=te})),Ft=n(((e,t)=>{var n=d();function r(e){let t=[`mkdir`,`realpath`,`stat`,`rmdir`,`utimes`],n={...e};return t.forEach(t=>{n[t]=(...n)=>{let r=n.pop(),i;try{i=e[`${t}Sync`](...n)}catch(e){return r(e)}r(null,i)}}),n}function i(e){return(...t)=>new Promise((n,r)=>{t.push((e,t)=>{e?r(e):n(t)}),e(...t)})}function a(e){return(...t)=>{let n,r;if(t.push((e,t)=>{n=e,r=t}),e(...t),n)throw n;return r}}function o(e){if(e={...e},e.fs=r(e.fs||n),typeof e.retries==`number`&&e.retries>0||e.retries&&typeof e.retries.retries==`number`&&e.retries.retries>0)throw Object.assign(Error(`Cannot use retries with the sync api`),{code:`ESYNC`});return e}t.exports={toPromise:i,toSync:a,toSyncOptions:o}})),It=n(((e,t)=>{var n=Pt(),{toPromise:r,toSync:i,toSyncOptions:a}=Ft();async function o(e,t){return r(await r(n.lock)(e,t))}function s(e,t){return i(i(n.lock)(e,a(t)))}function c(e,t){return r(n.unlock)(e,t)}function l(e,t){return i(n.unlock)(e,a(t))}function u(e,t){return r(n.check)(e,t)}function d(e,t){return i(n.check)(e,a(t))}t.exports=o,t.exports.lock=o,t.exports.unlock=c,t.exports.lockSync=s,t.exports.unlockSync=l,t.exports.check=u,t.exports.checkSync=d}));function F(){return I||(I=It()),I}function Lt(e,t){return F().lock(e,t)}function Rt(e,t){return F().lockSync(e,t)}function zt(e,t){return F().check(e,t)}var I,Bt=t((()=>{}));function L(){return{numStartups:0,installMethod:void 0,autoUpdates:void 0,theme:`dark`,preferredNotifChannel:`auto`,verbose:!1,editorMode:`normal`,autoCompactEnabled:!0,showTurnDuration:!0,hasSeenTasksHint:!1,hasUsedStash:!1,hasUsedBackgroundTask:!1,queuedCommandUpHintCount:0,diffTool:`auto`,customApiKeyResponses:{approved:[],rejected:[]},env:{},tipsHistory:{},memoryUsageCount:0,promptQueueUseCount:0,btwUseCount:0,todoFeatureEnabled:!0,showExpandedTodos:!1,messageIdleNotifThresholdMs:6e4,autoConnectIde:!1,autoInstallIdeExtension:!0,fileCheckpointingEnabled:!0,terminalProgressBarEnabled:!0,cachedStatsigGates:{},cachedDynamicConfigs:{},respectGitignore:!0}}function Vt(){return fn||(fn=Ht())}function Ht(){if(oe())return!0;let e=B(),t=$();if(e.projects?.[t]?.hasTrustDialogAccepted)return!0;let n=E(ve());for(;;){if(e.projects?.[n]?.hasTrustDialogAccepted)return!0;let t=E(nt(n,`..`));if(t===n)break;n=t}return!1}function R(e){let t=K.config;if(!t)return!1;let n=t.oauthAccount!==void 0&&e.oauthAccount===void 0,r=t.hasCompletedOnboarding===!0&&e.hasCompletedOnboarding!==!0;return n||r}function Ut(e){let t=null;try{Zt(w(),L,n=>{let r=e(n);return r===n?n:(t={...r,projects:Kt(n.projects)},t)})&&t&&z(t)}catch(n){S(`Failed to save config with lock: ${n}`,{level:`error`});let r=H(w(),L);if(R(r)){S(`saveGlobalConfig fallback: re-read config is missing auth that cache has; refusing to write. See GH #3117.`,{level:`error`}),D(`tengu_config_auth_loss_prevented`,{});return}let i=e(r);if(i===r)return;t={...i,projects:Kt(r.projects)},Xt(w(),t,G),z(t)}}function Wt(){let e=J+Y;e>0&&D(`tengu_config_cache_stats`,{cache_hits:J,cache_misses:Y,hit_rate:J/e}),J=0,Y=0}function Gt(e){if(e.installMethod!==void 0)return e;let t=e,n=`unknown`,r=e.autoUpdates??!0;switch(t.autoUpdaterStatus){case`migrated`:n=`local`;break;case`installed`:n=`native`;break;case`disabled`:r=!1;break;case`enabled`:case`no_permissions`:case`not_configured`:n=`global`;break;case void 0:break}return{...e,installMethod:n,autoUpdates:r}}function Kt(e){if(!e)return e;let t={},n=!1;for(let[r,i]of Object.entries(e)){let e=i;if(e.history!==void 0){n=!0;let{history:i,...a}=e;t[r]=a}else t[r]=i}return n?t:e}function qt(){if(Z)return;Z=!0;let e=w();at(e,{interval:pn,persistent:!1},t=>{t.mtimeMs<=K.mtime||C().readFile(e,{encoding:`utf-8`}).then(e=>{if(t.mtimeMs<=K.mtime)return;let n=Qe(Xe(e));typeof n!=`object`||!n||(K={config:Gt({...L(),...n}),mtime:t.mtimeMs},q={mtime:t.mtimeMs,size:t.size})}).catch(()=>{})}),Ce(async()=>{it(e),Z=!1})}function z(e){K={config:e,mtime:Date.now()},q=null}function B(){if(K.config)return J++,K.config;Y++;try{let e=null;try{e=C().statSync(w())}catch{}let t=Gt(H(w(),L));return K={config:t,mtime:e?.mtimeMs??Date.now()},q=e?{mtime:e.mtimeMs,size:e.size}:null,qt(),t}catch{return Gt(H(w(),L))}}function Jt(){let e=B().remoteControlAtStartup;return e!==void 0&&e}function Yt(e){let t=B();return t.customApiKeyResponses?.approved?.includes(e)?`approved`:t.customApiKeyResponses?.rejected?.includes(e)?`rejected`:`new`}function Xt(e,t,n){let r=k(e);C().mkdirSync(r),Oe(e,y(P(t,(e,t)=>y(e)!==y(n[t])),null,2),{encoding:`utf-8`,mode:384}),e===w()&&X++}function Zt(e,t,n){let r=t(),i=k(e),a=C();a.mkdirSync(i);let o;try{let i=`${e}.lock`,s=Date.now();o=Rt(e,{lockfilePath:i,onCompromised:e=>{S(`Config lock compromised: ${e}`,{level:`error`})}});let c=Date.now()-s;if(c>100&&(S(`Lock acquisition took longer than expected - another Claude instance may be running`),D(`tengu_config_lock_contention`,{lock_time_ms:c})),q&&e===w())try{let t=a.statSync(e);(t.mtimeMs!==q.mtime||t.size!==q.size)&&D(`tengu_config_stale_write`,{read_mtime:q.mtime,write_mtime:t.mtimeMs,read_size:q.size,write_size:t.size})}catch(e){if(b(e)!==`ENOENT`)throw e}let l=H(e,t);if(e===w()&&R(l))return S(`saveConfigWithLock: re-read config is missing auth that cache has; refusing to write to avoid wiping ~/.workmate.json. See GH #3117.`,{level:`error`}),D(`tengu_config_auth_loss_prevented`,{}),!1;let u=n(l);if(u===l)return!1;let d=P(u,(e,t)=>y(e)!==y(r[t]));try{let t=O(e),n=V();try{a.mkdirSync(n)}catch(e){if(b(e)!==`EEXIST`)throw e}let r=a.readdirStringSync(n).filter(e=>e.startsWith(`${t}.backup.`)).sort().reverse(),i=r[0],o=i?Number(i.split(`.backup.`).pop()):0,s=Number.isNaN(o)||Date.now()-o>=6e4;if(s){let r=A(n,`${t}.backup.${Date.now()}`);a.copyFileSync(e,r)}let c=s?a.readdirStringSync(n).filter(e=>e.startsWith(`${t}.backup.`)).sort().reverse():r;for(let e of c.slice(5))try{a.unlinkSync(A(n,e))}catch{}}catch(e){b(e)!==`ENOENT`&&S(`Failed to backup config: ${e}`,{level:`error`})}return Oe(e,y(d,null,2),{encoding:`utf-8`,mode:384}),e===w()&&X++,!0}finally{o&&o()}}function Qt(){if(Q)return;let e=Date.now();Ve(`info`,`enable_configs_started`),Q=!0,H(w(),L,!0),Ve(`info`,`enable_configs_completed`,{duration_ms:Date.now()-e})}function V(){return A(c(),`backups`)}function $t(e){let t=C(),n=O(e),r=V();try{let e=t.readdirStringSync(r).filter(e=>e.startsWith(`${n}.backup.`)).sort().at(-1);if(e)return A(r,e)}catch{}let i=k(e);try{let r=t.readdirStringSync(i).filter(e=>e.startsWith(`${n}.backup.`)).sort().at(-1);if(r)return A(i,r);let a=`${e}.backup`;try{return t.statSync(a),a}catch{}}catch{}return null}function H(e,t,n){if(!Q)throw Error(`Config accessed before allowed.`);let r=C();try{let n=r.readFileSync(e,{encoding:`utf-8`});try{let e=be(Xe(n));return{...t(),...e}}catch(n){throw new x(n instanceof Error?n.message:String(n),e,t())}}catch(i){if(b(i)===`ENOENT`){let n=$t(e);return n&&process.stderr.write(`\nClaude configuration file not found at: ${e}\nA backup file exists at: ${n}\nYou can manually restore it by running: cp "${n}" "${e}"\n\n`),t()}if(i instanceof x&&n)throw i;if(i instanceof x){if(S(`Config file corrupted, resetting to defaults: ${i.message}`,{level:`error`}),!U){U=!0;try{Ke(i);let t=!1;try{r.statSync(`${e}.backup`),t=!0}catch{}D(`tengu_config_parse_error`,{has_backup:t})}finally{U=!1}}process.stderr.write(`\nClaude configuration file at ${e} is corrupted: ${i.message}\n`);let t=O(e),n=V();try{r.mkdirSync(n)}catch(e){if(b(e)!==`EEXIST`)throw e}let a=r.readdirStringSync(n).filter(e=>e.startsWith(`${t}.corrupted.`)),o,s=!1,c=r.readFileSync(e,{encoding:`utf-8`});for(let e of a)try{if(c===r.readFileSync(A(n,e),{encoding:`utf-8`})){s=!0;break}}catch{}if(!s){o=A(n,`${t}.corrupted.${Date.now()}`);try{r.copyFileSync(e,o),S(`Corrupted config backed up to: ${o}`,{level:`error`})}catch{}}let l=$t(e);o?process.stderr.write(`The corrupted file has been backed up to: ${o}\n`):s&&process.stderr.write(`The corrupted file has already been backed up.
2
+ `),l?process.stderr.write(`A backup file exists at: ${l}\nYou can manually restore it by running: cp "${l}" "${e}"\n\n`):process.stderr.write(`
3
+ `)}return t()}}function en(){let e=$(),t=B();if(!t.projects)return W;let n=t.projects[e]??W;return typeof n.allowedTools==`string`&&(n.allowedTools=Qe(n.allowedTools)??[]),n}function tn(e){let t=$(),n=null;try{Zt(w(),L,r=>{let i=r.projects?.[t]??W,a=e(i);return a===i?r:(n={...r,projects:{...r.projects,[t]:a}},n)})&&n&&z(n)}catch(r){S(`Failed to save config with lock: ${r}`,{level:`error`});let i=H(w(),L);if(R(i)){S(`saveCurrentProjectConfig fallback: re-read config is missing auth that cache has; refusing to write. See GH #3117.`,{level:`error`}),D(`tengu_config_auth_loss_prevented`,{});return}let a=i.projects?.[t]??W,o=e(a);if(o===a)return;n={...i,projects:{...i.projects,[t]:o}},Xt(w(),n,G),z(n)}}function nn(){return on()!==null}function rn(){return nn()&&!l(process.env.FORCE_AUTOUPDATE_PLUGINS)}function an(e){switch(e.type){case`development`:return`development build`;case`env`:return`${e.envVar} set`;case`config`:return`config`}}function on(){if(!l(process.env.ENABLE_AUTOUPDATER))return{type:`config`};if(l(process.env.DISABLE_AUTOUPDATER))return{type:`env`,envVar:`DISABLE_AUTOUPDATER`};let e=qe();if(e)return{type:`env`,envVar:e};let t=B();return t.autoUpdates===!1&&(t.installMethod!==`native`||t.autoUpdatesProtectedForNative!==!0)?{type:`config`}:null}function sn(){let e=B();if(e.userID)return e.userID;let t=ot(32).toString(`hex`);return Ut(e=>({...e,userID:t})),t}function cn(){if(!B().firstStartTime){let e=new Date().toISOString();Ut(t=>({...t,firstStartTime:t.firstStartTime??e}))}}function ln(e){let t=ie();switch(e){case`User`:return A(c(),`AGENTS.md`);case`Local`:return A(t,`AGENTS.local.md`);case`Project`:return A(t,`AGENTS.md`);case`Managed`:return A(je(),`AGENTS.md`);case`AutoMem`:return vt();default:return A(c(),`AGENTS.md`)}}function un(){return A(je(),`.workmate`,`rules`)}function dn(){return A(c(),`rules`)}var U,W,G,fn,K,q,J,Y,X,pn,Z,Q,$,mn=t((()=>{o(),Dt(),re(),St(),$e(),_e(),we(),Se(),Be(),Me(),u(),ye(),Re(),xe(),He(),Ze(),Ye(),Bt(),Ge(),Pe(),We(),Ae(),Te(),U=!1,W={allowedTools:[],mcpContextUris:[],mcpServers:{},enabledMcpjsonServers:[],disabledMcpjsonServers:[],hasTrustDialogAccepted:!1,projectOnboardingSeenCount:0,hasAgentsMdExternalIncludesApproved:!1,hasAgentsMdExternalIncludesWarningShown:!1},G=L(),fn=!1,{...G},{...W},K={config:null,mtime:0},q=null,J=0,Y=0,X=0,Ce(async()=>{Wt()}),pn=1e3,Z=!1,Q=!1,$=a(()=>{let e=ie();return E(Ue(e)||nt(e))})}));export{ft as A,Lt as C,wt as D,Ct as E,dt as F,ct as I,lt as L,St as M,yt as N,vt as O,ut as P,M as R,Bt as S,P as T,cn as _,on as a,rn as b,B as c,sn as d,$ as f,nn as g,mn as h,an as i,gt as j,N as k,un as l,dn as m,Vt as n,en as o,Jt as p,Qt as r,Yt as s,G as t,ln as u,tn as v,Dt as w,zt as x,Ut as y,st as z};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{t}from"./jsx-runtime-Bb4Xn-E0.js";import{n,t as r}from"./Settings-C8GKWod1.js";var i,a;e((()=>{n(),i=t(),a=async(e,t)=>(0,i.jsx)(r,{onClose:e,context:t,defaultTab:`Config`})}))();export{a as call};
@@ -1 +1 @@
1
- import{c as e,h as t,n,o as r,r as i,v as a,y as o}from"./config-Do1870_d.js";t();export{n as checkHasTrustDialogAccepted,i as enableConfigs,r as getCurrentProjectConfig,e as getGlobalConfig,a as saveCurrentProjectConfig,o as saveGlobalConfig};
1
+ import{c as e,h as t,n,o as r,r as i,v as a,y as o}from"./config-9rLTDOYW.js";t();export{n as checkHasTrustDialogAccepted,i as enableConfigs,r as getCurrentProjectConfig,e as getGlobalConfig,a as saveCurrentProjectConfig,o as saveGlobalConfig};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./figures-5ThXQEtq.js";import{$_ as r,Ba as i,Ma as a,Z_ as o,dv as s,uv as c}from"./loadAgentsDir-BXtV2jiO.js";import{I as l,P as u,fi as d,s as f,t as p}from"./src-P_wYS_NJ2.js";import{t as m}from"./jsx-runtime-Bb4Xn-E0.js";import{cn as h,ln as g,wn as _,xn as v}from"./settings-DiBMs2gM.js";import{_ as y,v as b}from"./startupProfiler-Dc5r6LgE.js";import{Et as x,Zt as S,an as C,on as w,rn as T,wt as E}from"./prompt-CRc2QEZ5.js";import{n as D,t as O}from"./staticRender-DrU6eWoq.js";function k(e){let t=[];return A(e,t),j(e,t),N(e,t),P(e,t),F(e,t),t.sort((e,t)=>e.severity===t.severity?(t.savingsTokens??0)-(e.savingsTokens??0):e.severity===`warning`?-1:1),t}function A(e,t){e.percentage>=z&&t.push({severity:`warning`,title:`Context is ${e.percentage}% full`,detail:e.isAutoCompactEnabled?`Autocompact will trigger soon, which discards older messages. Use /compact now to control what gets kept.`:`Autocompact is disabled. Use /compact to free space, or enable autocompact in /config.`})}function j(e,t){if(e.messageBreakdown)for(let n of e.messageBreakdown.toolCallsByType){let r=n.callTokens+n.resultTokens,i=r/e.rawMaxTokens*100;if(i<I||r<L)continue;let a=M(n.name,r,i);a&&t.push(a)}}function M(e,t,n){let r=y(t);switch(e){case C:return{severity:`warning`,title:`Bash results using ${r} tokens (${n.toFixed(0)}%)`,detail:`Pipe output through head, tail, or grep to reduce result size. Avoid cat on large files — use Read with offset/limit instead.`,savingsTokens:Math.floor(t*.5)};case S:return{severity:`info`,title:`Read results using ${r} tokens (${n.toFixed(0)}%)`,detail:`Use offset and limit parameters to read only the sections you need. Avoid re-reading entire files when you only need a few lines.`,savingsTokens:Math.floor(t*.3)};case E:return{severity:`info`,title:`Grep results using ${r} tokens (${n.toFixed(0)}%)`,detail:`Add more specific patterns or use the glob or type parameter to narrow file types. Consider Glob for file discovery instead of Grep.`,savingsTokens:Math.floor(t*.3)};default:return n>=20?{severity:`info`,title:`${e} using ${r} tokens (${n.toFixed(0)}%)`,detail:`This tool is consuming a significant portion of context.`,savingsTokens:Math.floor(t*.2)}:null}}function N(e,t){if(!e.messageBreakdown)return;let n=e.messageBreakdown.toolCallsByType.find(e=>e.name===S);if(!n)return;let r=n.callTokens+n.resultTokens,i=r/e.rawMaxTokens*100,a=n.resultTokens/e.rawMaxTokens*100;i>=I&&r>=L||a>=R&&n.resultTokens>=L&&t.push({severity:`info`,title:`File reads using ${y(n.resultTokens)} tokens (${a.toFixed(0)}%)`,detail:`If you are re-reading files, consider referencing earlier reads. Use offset/limit for large files.`,savingsTokens:Math.floor(n.resultTokens*.3)})}function P(e,t){let n=e.memoryFiles.reduce((e,t)=>e+t.tokens,0),r=n/e.rawMaxTokens*100;if(r>=B&&n>=V){let i=[...e.memoryFiles].sort((e,t)=>t.tokens-e.tokens).slice(0,3).map(e=>`${v(e.path)} (${y(e.tokens)})`).join(`, `);t.push({severity:`info`,title:`Memory files using ${y(n)} tokens (${r.toFixed(0)}%)`,detail:`Largest: ${i}. Use /memory to review and prune stale entries.`,savingsTokens:Math.floor(n*.3)})}}function F(e,t){!e.isAutoCompactEnabled&&e.percentage>=50&&e.percentage<z&&t.push({severity:`info`,title:`Autocompact is disabled`,detail:`Without autocompact, you will hit context limits and lose the conversation. Enable it in /config or use /compact manually.`})}var I,L,R,z,B,V,H=e((()=>{w(),T(),x(),_(),b(),I=15,L=1e4,R=5,z=80,B=5,V=5e3}));function U({suggestions:e}){return e.length===0?null:(0,W.jsxs)(l,{flexDirection:`column`,marginTop:1,children:[(0,W.jsx)(u,{bold:!0,children:`Suggestions`}),e.map((e,t)=>(0,W.jsxs)(l,{flexDirection:`column`,marginTop:t===0?0:1,children:[(0,W.jsxs)(l,{children:[(0,W.jsx)(f,{status:e.severity,withSpace:!0}),(0,W.jsx)(u,{bold:!0,children:e.title}),e.savingsTokens?(0,W.jsxs)(u,{dimColor:!0,children:[` `,n.arrowRight,` save ~`,y(e.savingsTokens)]}):null]}),(0,W.jsx)(l,{marginLeft:2,children:(0,W.jsx)(u,{dimColor:!0,children:e.detail})})]},t))]})}var W,G=e((()=>{t(),d(),p(),b(),W=m()}));function K(){return null}function q(e){let t=new Map;for(let n of e){let e=h(n.source),r=t.get(e)||[];r.push(n),t.set(e,r)}for(let[e,n]of t.entries())t.set(e,n.sort((e,t)=>t.tokens-e.tokens));let n=new Map;for(let e of Z){let r=t.get(e);r&&n.set(e,r)}return n}function J({data:e}){let{categories:t,totalTokens:n,rawMaxTokens:r,percentage:i,gridRows:a,model:o,memoryFiles:s,mcpTools:c,deferredBuiltinTools:d=[],agents:f,skills:p,cacheHitRate:m,cacheThreshold:h}=e,g=t.filter(e=>e.tokens>0&&e.name!==`Free space`&&e.name!==X&&!e.isDeferred),_=t.some(e=>e.isDeferred&&e.name.includes(`MCP`)),b=t.find(e=>e.name===X);return(0,Y.jsxs)(l,{flexDirection:`column`,paddingLeft:1,children:[(0,Y.jsx)(u,{bold:!0,children:`Context Usage`}),(0,Y.jsxs)(l,{flexDirection:`row`,gap:2,children:[(0,Y.jsx)(l,{flexDirection:`column`,flexShrink:0,children:a.map((e,t)=>(0,Y.jsx)(l,{flexDirection:`row`,marginLeft:-1,children:e.map((e,t)=>e.categoryName===`Free space`?(0,Y.jsx)(u,{dimColor:!0,children:`⛶ `},t):e.categoryName===X?(0,Y.jsx)(u,{color:e.color,children:`⛝ `},t):(0,Y.jsx)(u,{color:e.color,children:e.squareFullness>=.7?`⛁ `:`⛀ `},t))},t))}),(0,Y.jsxs)(l,{flexDirection:`column`,gap:0,flexShrink:0,children:[(0,Y.jsxs)(u,{dimColor:!0,children:[o,` · `,y(n),`/`,y(r),` tokens (`,i,`%)`]}),(0,Y.jsx)(K,{}),m!==void 0&&h!==void 0&&(0,Y.jsxs)(u,{color:m<h?`warning`:void 0,children:[`Cache hit rate: `,m.toFixed(0),`%`,m<h?` (below ${h}% threshold)`:``]}),(0,Y.jsx)(u,{children:` `}),(0,Y.jsx)(u,{dimColor:!0,italic:!0,children:`Estimated usage by category`}),g.map((e,t)=>{let n=y(e.tokens),i=e.isDeferred?`N/A`:`${(e.tokens/r*100).toFixed(1)}%`,a=e.name===X,o=e.name,s=e.isDeferred?` `:a?`⛝`:`⛁`;return(0,Y.jsxs)(l,{children:[(0,Y.jsx)(u,{color:e.color,children:s}),(0,Y.jsxs)(u,{children:[` `,o,`: `]}),(0,Y.jsxs)(u,{dimColor:!0,children:[n,` tokens (`,i,`)`]})]},t)}),(t.find(e=>e.name===`Free space`)?.tokens??0)>0&&(0,Y.jsxs)(l,{children:[(0,Y.jsx)(u,{dimColor:!0,children:`⛶`}),(0,Y.jsx)(u,{children:` Free space: `}),(0,Y.jsxs)(u,{dimColor:!0,children:[y(t.find(e=>e.name===`Free space`)?.tokens||0),` (`,((t.find(e=>e.name===`Free space`)?.tokens||0)/r*100).toFixed(1),`%)`]})]}),b&&b.tokens>0&&(0,Y.jsxs)(l,{children:[(0,Y.jsx)(u,{color:b.color,children:`⛝`}),(0,Y.jsxs)(u,{dimColor:!0,children:[` `,b.name,`: `]}),(0,Y.jsxs)(u,{dimColor:!0,children:[y(b.tokens),` tokens (`,(b.tokens/r*100).toFixed(1),`%)`]})]})]})]}),(0,Y.jsxs)(l,{flexDirection:`column`,marginLeft:-1,children:[c.length>0&&(0,Y.jsxs)(l,{flexDirection:`column`,marginTop:1,children:[(0,Y.jsxs)(l,{children:[(0,Y.jsx)(u,{bold:!0,children:`MCP tools`}),(0,Y.jsxs)(u,{dimColor:!0,children:[` · /mcp`,_?` (loaded on-demand)`:``]})]}),c.some(e=>e.isLoaded)&&(0,Y.jsxs)(l,{flexDirection:`column`,marginTop:1,children:[(0,Y.jsx)(u,{dimColor:!0,children:`Loaded`}),c.filter(e=>e.isLoaded).map((e,t)=>(0,Y.jsxs)(l,{children:[(0,Y.jsxs)(u,{children:[`└ `,e.name,`: `]}),(0,Y.jsxs)(u,{dimColor:!0,children:[y(e.tokens),` tokens`]})]},t))]}),_&&c.some(e=>!e.isLoaded)&&(0,Y.jsxs)(l,{flexDirection:`column`,marginTop:1,children:[(0,Y.jsx)(u,{dimColor:!0,children:`Available`}),c.filter(e=>!e.isLoaded).map((e,t)=>(0,Y.jsx)(l,{children:(0,Y.jsxs)(u,{dimColor:!0,children:[`└ `,e.name]})},t))]}),!_&&c.map((e,t)=>(0,Y.jsxs)(l,{children:[(0,Y.jsxs)(u,{children:[`└ `,e.name,`: `]}),(0,Y.jsxs)(u,{dimColor:!0,children:[y(e.tokens),` tokens`]})]},t))]}),f.length>0&&(0,Y.jsxs)(l,{flexDirection:`column`,marginTop:1,children:[(0,Y.jsxs)(l,{children:[(0,Y.jsx)(u,{bold:!0,children:`Custom agents`}),(0,Y.jsx)(u,{dimColor:!0,children:` · /agents`})]}),Array.from(q(f).entries()).map(([e,t])=>(0,Y.jsxs)(l,{flexDirection:`column`,marginTop:1,children:[(0,Y.jsx)(u,{dimColor:!0,children:e}),t.map((e,t)=>(0,Y.jsxs)(l,{children:[(0,Y.jsxs)(u,{children:[`└ `,e.agentType,`: `]}),(0,Y.jsxs)(u,{dimColor:!0,children:[y(e.tokens),` tokens`]})]},t))]},e))]}),s.length>0&&(0,Y.jsxs)(l,{flexDirection:`column`,marginTop:1,children:[(0,Y.jsxs)(l,{children:[(0,Y.jsx)(u,{bold:!0,children:`Memory files`}),(0,Y.jsx)(u,{dimColor:!0,children:` · /memory`})]}),s.map((e,t)=>(0,Y.jsxs)(l,{children:[(0,Y.jsxs)(u,{children:[`└ `,v(e.path),`: `]}),(0,Y.jsxs)(u,{dimColor:!0,children:[y(e.tokens),` tokens`]})]},t))]}),p&&p.tokens>0&&(0,Y.jsxs)(l,{flexDirection:`column`,marginTop:1,children:[(0,Y.jsxs)(l,{children:[(0,Y.jsx)(u,{bold:!0,children:`Skills`}),(0,Y.jsx)(u,{dimColor:!0,children:` · /skills`})]}),Array.from(q(p.skillFrontmatter).entries()).map(([e,t])=>(0,Y.jsxs)(l,{flexDirection:`column`,marginTop:1,children:[(0,Y.jsx)(u,{dimColor:!0,children:e}),t.map((e,t)=>(0,Y.jsxs)(l,{children:[(0,Y.jsxs)(u,{children:[`└ `,e.name,`: `]}),(0,Y.jsxs)(u,{dimColor:!0,children:[y(e.tokens),` tokens`]})]},t))]},e))]})]}),(0,Y.jsx)(U,{suggestions:k(e)})]})}var Y,X,Z,Q=e((()=>{d(),p(),H(),_(),b(),g(),G(),Y=m(),X=`Autocompact buffer`,Z=[`Project`,`User`,`Managed`,`Plugin`,`Built-in`]}));function ee(e){return a(e)}async function te(e,t){let{messages:n,getAppState:r,options:{mainLoopModel:i,tools:a}}=t,c=ee(n),{messages:l}=await s(c),u=process.stdout.columns||80,d=r();return e(await D((0,$.jsx)(J,{data:await o(l,i,async()=>d.toolPermissionContext,a,d.agentDefinitions,u,t,void 0,c)}))),null}var $;e((()=>{d(),Q(),c(),r(),i(),O(),$=m()}))();export{te as call};
@@ -1,4 +1,4 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Ba as t,Dv as n,Ma as r,Ov as i,gv as a,mv as o}from"./loadAgentsDir-C7lOqvfh.js";import{cn as s,sn as c}from"./settings-DnptdP79.js";import{_ as l,v as u}from"./startupProfiler-L_UWZ03w.js";async function d(e){let{messages:t,getAppState:n,options:{mainLoopModel:a,tools:s,agentDefinitions:c,customSystemPrompt:l,appendSystemPrompt:u}}=e,d=r(t),{messages:f}=await i(d),p=n();return o(f,a,async()=>p.toolPermissionContext,s,c,void 0,{options:{customSystemPrompt:l,appendSystemPrompt:u}},void 0,d)}async function f(e,t){return{type:`text`,value:p(await d(t))}}function p(e){let{categories:t,totalTokens:n,rawMaxTokens:r,percentage:i,model:a,memoryFiles:o,mcpTools:s,agents:u,skills:d}=e,f=`## Context Usage
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{$_ as t,Ba as n,Ma as r,Z_ as i,dv as a,uv as o}from"./loadAgentsDir-BXtV2jiO.js";import{cn as s,ln as c}from"./settings-DiBMs2gM.js";import{_ as l,v as u}from"./startupProfiler-Dc5r6LgE.js";async function d(e){let{messages:t,getAppState:n,options:{mainLoopModel:o,tools:s,agentDefinitions:c,customSystemPrompt:l,appendSystemPrompt:u}}=e,d=r(t),{messages:f}=await a(d),p=n();return i(f,o,async()=>p.toolPermissionContext,s,c,void 0,{options:{customSystemPrompt:l,appendSystemPrompt:u}},void 0,d)}async function f(e,t){return{type:`text`,value:p(await d(t))}}function p(e){let{categories:t,totalTokens:n,rawMaxTokens:r,percentage:i,model:a,memoryFiles:o,mcpTools:c,agents:u,skills:d}=e,f=`## Context Usage
2
2
 
3
3
  `;f+=`**Model:** ${a} \n`,f+=`**Tokens:** ${l(n)} / ${l(r)} (${i}%)\n`,f+=`
4
4
  `;let p=t.filter(e=>e.tokens>0&&e.name!==`Free space`&&e.name!==`Autocompact buffer`);if(p.length>0){f+=`### Estimated usage by category
@@ -6,11 +6,11 @@ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Ba as t,Dv as n,Ma as
6
6
  `,f+=`| Category | Tokens | Percentage |
7
7
  `,f+=`|----------|--------|------------|
8
8
  `;for(let e of p){let t=(e.tokens/r*100).toFixed(1);f+=`| ${e.name} | ${l(e.tokens)} | ${t}% |\n`}let e=t.find(e=>e.name===`Free space`);if(e&&e.tokens>0){let t=(e.tokens/r*100).toFixed(1);f+=`| Free space | ${l(e.tokens)} | ${t}% |\n`}let n=t.find(e=>e.name===`Autocompact buffer`);if(n&&n.tokens>0){let e=(n.tokens/r*100).toFixed(1);f+=`| Autocompact buffer | ${l(n.tokens)} | ${e}% |\n`}f+=`
9
- `}if(s.length>0){f+=`### MCP Tools
9
+ `}if(c.length>0){f+=`### MCP Tools
10
10
 
11
11
  `,f+=`| Tool | Server | Tokens |
12
12
  `,f+=`|------|--------|--------|
13
- `;for(let e of s)f+=`| ${e.name} | ${e.serverName} | ${l(e.tokens)} |\n`;f+=`
13
+ `;for(let e of c)f+=`| ${e.name} | ${e.serverName} | ${l(e.tokens)} |\n`;f+=`
14
14
  `}if(u.length>0){f+=`### Custom Agents
15
15
 
16
16
  `,f+=`| Agent Type | Source | Tokens |
@@ -25,5 +25,5 @@ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Ba as t,Dv as n,Ma as
25
25
 
26
26
  `,f+=`| Skill | Source | Tokens |
27
27
  `,f+=`|-------|--------|--------|
28
- `;for(let e of d.skillFrontmatter)f+=`| ${e.name} | ${c(e.source)} | ${l(e.tokens)} |\n`;f+=`
29
- `}return f}var m=e((()=>{n(),a(),u(),t(),s()}));export{d as n,m as r,f as t};
28
+ `;for(let e of d.skillFrontmatter)f+=`| ${e.name} | ${s(e.source)} | ${l(e.tokens)} |\n`;f+=`
29
+ `}return f}var m=e((()=>{o(),t(),u(),n(),c()}));export{d as n,m as r,f as t};
@@ -0,0 +1 @@
1
+ import{n as e,r as t,t as n}from"./context-noninteractive-mAQt1p9l.js";t();export{n as call,e as collectContextData};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./conversation-DPI7VKBL.js";e();export{t as clearConversation};
@@ -0,0 +1 @@
1
+ import{a as e,n as t}from"./rolldown-runtime-DaDcL9Zw.js";import{An as n,Bs as r,Cr as i,Gg as a,Hg as o,Mh as s,On as c,Ph as l,St as u,T_ as d,Tt as f,Vg as p,Vs as m,XC as h,Xt as g,YC as _,Yn as v,_E as y,_i as b,ii as x,ir as S,jn as C,mi as w,qg as T,uE as E,un as D,vc as O,vn as k,w_ as A}from"./loadAgentsDir-BXtV2jiO.js";import{Dn as j,G as M,Qt as N,Tn as P,Wt as F,en as I,et as L,wn as R}from"./state-BPFYBqm1.js";import{o as z,s as B}from"./log-27kCA_9u.js";import{n as V,r as H}from"./analytics-DJobLaWP.js";import{_ as U,x as W}from"./sessionState-DSWN4tMV.js";import{n as G,t as K}from"./caches-BQmbXerw.js";import{randomUUID as q}from"crypto";function J(){return Y}var Y,X=t((()=>{O(),Y=null}));function Z(){let e=J();if(!e)return;e.markTranscriptReset?.();let t={type:`status`,subtype:`status`,status:`conversation_cleared`,message:`conversation_cleared`,uuid:q()};e.writeSdkMessages([t])}async function Q({setMessages:t,readFileState:r,discoveredSkillNames:l,loadedNestedMemoryPaths:f,getAppState:p,setAppState:_,setConversationId:y}){let C=D();await g(`clear`,{getAppState:p,setAppState:_,signal:AbortSignal.timeout(C),timeoutMs:C});let T=M();T&&H(`tengu_cache_eviction_hint`,{scope:`conversation_clear`,last_request_id:T});let O=new Set,k=[],A=e=>`isBackgrounded`in e&&e.isBackgrounded===!1;if(p)for(let e of Object.values(p().tasks))A(e)||m(e)&&(O.add(e.agentId),k.push(e));t(()=>[]),Z();{let{setContextBlocked:t}=(U(),e(W));t(!1)}y&&y(q()),K(O),R(null),P(null),j(null),I(),h(L()),r.clear(),l?.clear(),f?.clear(),_&&_(e=>{let t={};for(let[n,r]of Object.entries(e.tasks)){if(!A(r)){t[n]=r;continue}try{r.status===`running`&&(o(r)&&(r.shellCommand?.kill(),r.shellCommand?.cleanup(),r.cleanupTimeoutId&&clearTimeout(r.cleanupTimeoutId)),`abortController`in r&&r.abortController?.abort(),`unregisterCleanup`in r&&r.unregisterCleanup?.())}catch(e){B(e)}c(n)}return{...e,tasks:t,attribution:s(),standaloneAgentContext:void 0,fileHistory:{snapshots:[],trackedFiles:new Set,snapshotSequence:0},mcp:{clients:[],tools:[],commands:[],resources:{},pluginReconnectKey:e.mcp.pluginReconnectKey}}}),E(),v(),N({setCurrentAsParent:!0}),await x();for(let e of k)e.status===`running`&&n(e.id,S(a(e.agentId)));let{saveMode:F}=(i(),e(b));F(`normal`);let z=u();z&&w(z);let V=await d(`clear`);V.length>0&&t(()=>V)}var $=t((()=>{X(),F(),V(),r(),p(),T(),l(),k(),z(),y(),_(),A(),i(),C(),f(),G()}));export{$ as n,Q as t};
@@ -0,0 +1,6 @@
1
+ import{n as e,t}from"./defineProperty-C-QyHrDq.js";import{C as n,S as r,c as i,i as a,x as o}from"./debug-Dr1SjdXn.js";import{l as s,u as c}from"./oauth-D38aRTUb.js";import{Bt as l,Ot as u}from"./model-CDnVaVDR.js";import{t as d}from"./cliLaunch-OPOtzhvA.js";import{resolve as f}from"path";import{existsSync as p,unlinkSync as m}from"fs";import{randomUUID as h}from"crypto";a(),o(),e();function g(e){return typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`}var _=2e3,v=15e3,y=3,b=class{constructor(e,n){t(this,`proc`,void 0),t(this,`options`,void 0),t(this,`connected`,!1),t(this,`disconnected`,!1),t(this,`readLoopAbort`,null),t(this,`reconnectAttempt`,0),t(this,`maxReconnectAttempts`,void 0),t(this,`userInitiatedDisconnect`,!1),t(this,`reconnecting`,!1),this.proc=e,this.options=n,this.maxReconnectAttempts=n.maxReconnectAttempts??y}connect(){this.connected||(this.readLoopAbort=new AbortController,this.startReadLoop(),this.monitorExit(),this.connected=!0,this.options.onConnected())}async startReadLoop(){let e=this.proc.stdout;if(!e){this.options.onError(Error(`SSH process stdout is not available`));return}let t=e.getReader(),n=new TextDecoder,r=``;try{for(;!this.disconnected;){let{done:e,value:i}=await t.read();if(e)break;r+=n.decode(i,{stream:!0});let a=r.split(`
2
+ `);r=a.pop()??``;for(let e of a){let t=e.trim();t&&this.processLine(t)}}}catch(e){this.disconnected||this.options.onError(e instanceof Error?e:Error(String(e)))}finally{t.releaseLock(),!this.disconnected&&!this.userInitiatedDisconnect&&this.handleProcessExit()}}monitorExit(){if(this.proc.exitCode!==null){this.userInitiatedDisconnect||this.handleProcessExit();return}this.proc.exited.then(()=>{!this.disconnected&&!this.userInitiatedDisconnect&&this.handleProcessExit()}).catch(()=>{!this.disconnected&&!this.userInitiatedDisconnect&&this.handleProcessExit()})}async handleProcessExit(){if(!(this.disconnected||this.reconnecting)){if(this.connected=!1,!this.options.reconnect){this.disconnected=!0,this.options.onDisconnected();return}if(this.reconnectAttempt>=this.maxReconnectAttempts){this.disconnected=!0,this.options.onDisconnected();return}this.reconnecting=!0;try{await this.attemptReconnect()}finally{this.reconnecting=!1}}}async attemptReconnect(){let e=this.options.reconnect;for(;this.reconnectAttempt<this.maxReconnectAttempts;){this.reconnectAttempt++,this.options.onReconnecting(this.reconnectAttempt,this.maxReconnectAttempts);let t=Math.min(_*2**(this.reconnectAttempt-1),v);if(await new Promise(e=>setTimeout(e,t)),this.userInitiatedDisconnect)return;try{let t=await e();this.proc=t,this.reconnectAttempt=0,this.connected=!0,this.startReadLoop(),this.monitorExit(),this.options.onConnected();return}catch(e){i(`[SSH] reconnect attempt ${this.reconnectAttempt} failed: ${e instanceof Error?e.message:String(e)}`)}}this.disconnected=!0,this.options.onDisconnected()}processLine(e){let t;try{t=r(e)}catch{return}if(!g(t))return;let n=t;if(n.type===`control_request`){let e=n;e.request.subtype===`can_use_tool`?this.options.onPermissionRequest(e.request,e.request_id):(i(`[SSH] Unsupported control request subtype: ${e.request.subtype}`),this.sendErrorResponse(e.request_id,`Unsupported control request subtype: ${e.request.subtype}`));return}n.type!==`control_response`&&n.type!==`keep_alive`&&n.type!==`control_cancel_request`&&n.type!==`streamlined_text`&&n.type!==`streamlined_tool_use_summary`&&!(n.type===`system`&&n.subtype===`post_turn_summary`)&&this.options.onMessage(n)}writeToStdin(e){try{let t=this.proc.stdin;if(!t||typeof t==`number`||this.disconnected)return!1;let n=new TextEncoder().encode(e+`
3
+ `);return t.write(n),t.flush?.(),!0}catch{return!1}}async sendMessage(e){let t=n({type:`user`,message:{role:`user`,content:e},parent_tool_use_id:null,session_id:``});return this.writeToStdin(t)}sendInterrupt(){let e=n({type:`control_request`,request_id:crypto.randomUUID(),request:{subtype:`interrupt`}});this.writeToStdin(e)}respondToPermissionRequest(e,t){let r=n({type:`control_response`,response:{subtype:`success`,request_id:e,response:{behavior:t.behavior,...t.behavior===`allow`?{updatedInput:t.updatedInput}:{message:t.message}}}});this.writeToStdin(r)}sendErrorResponse(e,t){let r=n({type:`control_response`,response:{subtype:`error`,request_id:e,error:t}});this.writeToStdin(r)}disconnect(){if(!this.disconnected){this.userInitiatedDisconnect=!0,this.disconnected=!0,this.connected=!1,this.readLoopAbort?.abort();try{let e=this.proc.stdin;e&&typeof e!=`number`&&e.end?.()}catch{}try{this.proc.kill()}catch{}}}isConnected(){return this.connected&&!this.disconnected}};l(),c(),a();var x=process.platform===`win32`;function S(){let e=process.env.ANTHROPIC_API_KEY;if(e)return{"x-api-key":e};let t=u();return t?.accessToken?{Authorization:`Bearer ${t.accessToken}`}:{}}function C(){return process.env.ANTHROPIC_BASE_URL||s().BASE_API_URL}async function w(e,t){if(t&&e.headers.get(`x-auth-nonce`)!==t)return new Response(`Forbidden`,{status:403});let n=C(),r=new URL(e.url),a=`${n}${r.pathname}${r.search}`,o=S();if(Object.keys(o).length===0)return new Response(JSON.stringify({error:`No API credentials available on local machine`}),{status:401,headers:{"content-type":`application/json`}});let s=new Headers(e.headers);for(let[e,t]of Object.entries(o))s.set(e,t);s.delete(`host`),s.delete(`x-auth-nonce`),i(`[SSHAuthProxy] ${e.method} ${r.pathname} -> ${a}`);try{let t=await fetch(a,{method:e.method,headers:s,body:e.body,duplex:`half`}),n=new Headers(t.headers);return n.delete(`content-encoding`),n.delete(`content-length`),new Response(t.body,{status:t.status,statusText:t.statusText,headers:n})}catch(e){let t=e instanceof Error?e.message:String(e);return i(`[SSHAuthProxy] upstream error: ${t}`),new Response(JSON.stringify({error:`Proxy upstream error: ${t}`}),{status:502,headers:{"content-type":`application/json`}})}}async function T(){let e=h();return x?D(e):E(e)}async function E(e){let t=`/tmp/claude-ssh-auth-${e}.sock`,n=Bun.serve({unix:t,fetch:e=>w(e,null)});return i(`[SSHAuthProxy] listening on unix:${t}`),{proxy:{stop(){n.stop(!0);try{m(t)}catch{}}},localAddress:t,authEnv:{ANTHROPIC_AUTH_SOCKET:t}}}async function D(e){let t=h(),n=Bun.serve({port:0,hostname:`127.0.0.1`,fetch:e=>w(e,t)}),r=n.port;return i(`[SSHAuthProxy] listening on TCP 127.0.0.1:${r} (nonce-protected)`),{proxy:{stop(){n.stop(!0)}},localAddress:`127.0.0.1:${r}`,authEnv:{ANTHROPIC_BASE_URL:`http://127.0.0.1:${r}`,ANTHROPIC_AUTH_NONCE:t}}}a();var O=15e3,k=class extends Error{constructor(e){super(e),this.name=`SSHProbeError`}};async function A(e,t){t?.(`Probing remote host…`);let n=Bun.spawn([`ssh`,`-o`,`BatchMode=yes`,`-o`,`ConnectTimeout=10`,e,`CLAUDE_BIN=$(test -x "$HOME/.local/bin/claude" && echo "$HOME/.local/bin/claude" || command -v claude 2>/dev/null); echo "$CLAUDE_BIN"; $CLAUDE_BIN --version 2>/dev/null; uname -sm; pwd`],{stdin:`ignore`,stdout:`pipe`,stderr:`pipe`}),r=await Promise.race([n.exited,new Promise((e,t)=>setTimeout(()=>t(new k(`SSH probe timed out after ${O/1e3}s`)),O))]),a=await new Response(n.stdout).text(),o=await new Response(n.stderr).text();if(r!==0)throw new k(`SSH probe failed: ${o.trim()||`exit code ${r}`}`);let s=a.split(`
4
+ `).map(e=>e.trim()).filter(Boolean);i(`[SSHProbe] raw lines: ${JSON.stringify(s)}`);let c=s.findIndex(e=>/^(Linux|Darwin)\s/.test(e));if(c===-1)throw new k(`Could not detect remote platform (uname output missing)`);let l=c>=2&&s[c-2]||null,u=c>=1&&s[c-1]||null,d=u&&/^\d+\.\d+/.test(u)?u:null,f=l!==null&&l.startsWith(`/`),p=s[c+1]||`/`,[m,h]=s[c].split(/\s+/),g=m===`Darwin`?`darwin`:`linux`,_=h===`aarch64`||h===`arm64`?`arm64`:`x64`;return t?.(`Detected ${g}/${_}`),{hasBinary:f&&d!==null,remoteVersion:d,remotePlatform:g,remoteArch:_,defaultCwd:p,binaryPath:f?l:null}}a();var j=6e4,M=`~/.local/bin`,N=`claude-code-cli.js`,P=`claude`;async function F(e,t,n=j){let r=Bun.spawn([`ssh`,`-o`,`ConnectTimeout=10`,e,t],{stdout:`pipe`,stderr:`pipe`}),i=setTimeout(()=>r.kill(),n);try{let[e,t]=await Promise.all([new Response(r.stdout).text(),new Response(r.stderr).text()]),n=await r.exited;return{stdout:e.trim(),stderr:t.trim(),exitCode:n}}finally{clearTimeout(i)}}function I(){let e=f(import.meta.dir,`../..`),t=f(e,`dist/cli.js`);if(p(t))return t;let n=f(e,`src/entrypoints/cli.tsx`);if(p(n))return n;throw Error("Cannot find local CLI binary to deploy. Run `bun run build` first.")}async function L(e){let{host:t,remotePlatform:n,remoteArch:r,localVersion:a,onProgress:o}=e;if(n!==`linux`&&n!==`darwin`)throw Error(`Remote platform "${n}" is not supported. Only linux and darwin are supported.`);i(`[SSHDeploy] deploying to ${t} (${n}/${r}, v${a})`);let s=I();i(`[SSHDeploy] local binary: ${s}`),o?.(`Creating remote directory...`);let c=await F(t,`mkdir -p ${M}`);if(c.exitCode!==0)throw Error(`Failed to create remote directory: ${c.stderr}`);o?.(`Uploading binary...`);let l=`${M}/${N}`,u=Bun.spawn([`scp`,`-o`,`ConnectTimeout=10`,s,`${t}:${l}`],{stdout:`pipe`,stderr:`pipe`}),d=setTimeout(()=>u.kill(),j),f=await new Response(u.stderr).text(),p=await u.exited;if(clearTimeout(d),p!==0)throw Error(`SCP upload failed (exit ${p}): ${f.trim()}`);o?.(`Installing wrapper script...`);let m=await F(t,[`cat > ${M}/${P} << 'WRAPPER'`,`#!/bin/sh`,`exec bun ${M}/${N} "$@"`,`WRAPPER`,`chmod +x ${M}/${P}`].join(`
5
+ `));if(m.exitCode!==0)throw Error(`Failed to install wrapper script: ${m.stderr}`);o?.(`Verifying installation...`);let h=await F(t,`${M}/${P} --version`);if(h.exitCode!==0)throw Error(`Binary deployed but verification failed (exit ${h.exitCode}): ${h.stderr}`);return i(`[SSHDeploy] deployed successfully, remote version: ${h.stdout}`),o?.(`Deployed v${h.stdout}`),`${M}/${P}`}a(),o();var R=3e4,z=20,B=class extends Error{constructor(e){super(e),this.name=`SSHSessionError`}};async function V(e,t){let{host:n,localVersion:r,extraCliArgs:a,remoteBin:o}=e,s=t?.onProgress,c,l=`/`;if(o){s?.(`Using custom remote binary, skipping probe/deploy…`),c=o,i(`[SSH] custom remoteBin: ${o}`);try{let e=Bun.spawn([`ssh`,`-o`,`BatchMode=yes`,`-o`,`ConnectTimeout=5`,n,`pwd`],{stdin:`ignore`,stdout:`pipe`,stderr:`ignore`});await e.exited;let t=(await new Response(e.stdout).text()).trim();t.startsWith(`/`)&&(l=t)}catch{}}else{let e=await A(n,s);i(`[SSH] probe result: ${JSON.stringify(e)}`),l=e.defaultCwd,c=e.binaryPath??`~/.local/bin/claude`,(!e.hasBinary||e.remoteVersion!==r)&&(s?.(e.hasBinary?`Updating remote binary (${e.remoteVersion} → ${r})…`:`Deploying binary to remote…`),c=await L({host:n,remotePlatform:e.remotePlatform,remoteArch:e.remoteArch,localVersion:r,onProgress:s}))}let{proxy:u,localAddress:d,authEnv:f}=await T();i(`[SSH] auth proxy listening on ${d}`);let p=h().slice(0,8),m=process.platform===`win32`,g=[];for(let[e,t]of Object.entries(f))g.push(`${e}=${t}`);g.push(c,`--output-format`,`stream-json`,`--input-format`,`stream-json`,`--verbose`,`-p`),e.cwd&&g.push(`--cwd`,e.cwd),e.permissionMode&&g.push(`--permission-mode`,e.permissionMode),e.dangerouslySkipPermissions&&g.push(`--dangerously-skip-permissions`),g.push(...a);let _=[`ssh`];if(m){let e=d.split(`:`)[1],t=1e4+Math.floor(Math.random()*5e4);_.push(`-R`,`${t}:127.0.0.1:${e}`);let n=g.findIndex(e=>e.startsWith(`ANTHROPIC_BASE_URL=`));n!==-1&&(g[n]=`ANTHROPIC_BASE_URL=http://127.0.0.1:${t}`)}else{let e=`/tmp/claude-ssh-auth-${p}.sock`;_.push(`-R`,`${e}:${d}`),_.push(`-o`,`StreamLocalBindUnlink=yes`);let t=g.indexOf(`ANTHROPIC_AUTH_SOCKET=${f.ANTHROPIC_AUTH_SOCKET}`);t!==-1&&(g[t]=`ANTHROPIC_AUTH_SOCKET=${e}`)}_.push(n,g.join(` `)),s?.(`Starting remote session…`),i(`[SSH] spawning: ${_.join(` `)}`);let v;try{v=Bun.spawn(_,{stdin:`pipe`,stdout:`pipe`,stderr:`pipe`})}catch(e){throw u.stop(),new B(`Failed to spawn SSH process: ${e instanceof Error?e.message:String(e)}`)}let y=[];W(v,y);let x;if(o){let t=await Promise.race([v.exited.then(e=>e),new Promise(e=>setTimeout(()=>e(null),3e3))]);if(t!==null){u.stop();let e=y.join(``).trim();throw new B(`Remote process exited immediately (code ${t})${e?`: ${e}`:``}`)}x=e.cwd||l||`/`}else try{x=await U(v,e.cwd||l)}catch(e){throw u.stop(),v.kill(),e}i(`[SSH] remote session initialized, remoteCwd=${x}`);let S=v,C=async()=>{i(`[SSH] reconnect: re-spawning SSH process with --continue`);let e=[..._],t=e.length-1,n=e[t];n.includes(`--continue`)||(e[t]=n.replace(/ -p(?:\s|$)/,` -p --continue `));let r=Bun.spawn(e,{stdin:`pipe`,stdout:`pipe`,stderr:`pipe`}),a=[];return W(r,a),await U(r,x),S=r,y.length=0,y.push(...a),r};return{remoteCwd:x,get proc(){return S},proxy:u,createManager(e){return new b(S,{...e,reconnect:C})},getStderrTail(){return y.slice(-20).join(``)}}}async function H(e){let{proxy:t,authEnv:n}=await T(),r=[`--output-format`,`stream-json`,`--input-format`,`stream-json`,`-p`];e.cwd&&r.push(`--cwd`,e.cwd),e.permissionMode&&r.push(`--permission-mode`,e.permissionMode),e.dangerouslySkipPermissions&&r.push(`--dangerously-skip-permissions`);let a=d(r),o;try{o=Bun.spawn([a.execPath,...a.args],{stdin:`pipe`,stdout:`pipe`,stderr:`pipe`,env:{...a.env,...n}})}catch(e){throw t.stop(),new B(`Failed to spawn local CLI process: ${e instanceof Error?e.message:String(e)}`)}i(`[SSH] local session spawned, waiting for init message...`);let s=[];W(o,s);let c;try{c=await U(o,e.cwd)}catch(e){throw t.stop(),o.kill(),e}i(`[SSH] local session initialized, remoteCwd=${c}`);let l=o,u=async()=>{i(`[SSH] local reconnect: re-spawning CLI with --continue`);let e=[...r];e.includes(`--continue`)||e.push(`--continue`);let t=d(e),a=Bun.spawn([t.execPath,...t.args],{stdin:`pipe`,stdout:`pipe`,stderr:`pipe`,env:{...t.env,...n}}),o=[];return W(a,o),await U(a,c),l=a,s.length=0,s.push(...o),a};return{remoteCwd:c,get proc(){return l},proxy:t,createManager(e){return new b(l,{...e,reconnect:u})},getStderrTail(){return s.slice(-20).join(``)}}}async function U(e,t){let n=e.stdout;if(!n)throw new B(`Child process stdout is not readable`);let i=n.getReader(),a=new TextDecoder,o=``,s=Date.now()+R;try{for(;Date.now()<s;){let e=s-Date.now(),n=await Promise.race([i.read(),new Promise((t,n)=>setTimeout(()=>n(new B(`Remote CLI did not initialize within 30 seconds. Check SSH connectivity and remote binary.`)),e))]);if(n.done)throw new B(`Child process exited before sending init message`);o+=a.decode(n.value,{stream:!0});let c=o.split(`
6
+ `);o=c.pop()??``;for(let e of c){let n=e.trim();if(n)try{let e=r(n);if(e.type===`system`&&e.subtype===`init`)return i.releaseLock(),e.cwd||t||process.cwd()}catch{}}}}catch(e){throw i.releaseLock(),e instanceof B?e:new B(`Error reading init message: ${e instanceof Error?e.message:String(e)}`)}throw i.releaseLock(),new B(`Remote CLI did not initialize within 30 seconds. Check SSH connectivity and remote binary.`)}function W(e,t){let n=e.stderr;if(!n)return;let r=n.getReader(),i=new TextDecoder;(async()=>{try{for(;;){let{done:e,value:n}=await r.read();if(e)break;t.push(i.decode(n,{stream:!0})),t.length>z*2&&t.splice(0,t.length-z)}}catch{}})()}export{B as SSHSessionError,H as createLocalSSHSession,V as createSSHSession};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{P as t,R as n,c as r,i}from"./debug-Dr1SjdXn.js";import{i as a,t as o}from"./sessionIdCompat-DMayYBrf.js";import{i as s,o as c}from"./debugUtils-cK-iOsEV.js";async function l({environmentId:e,title:n,events:i,gitRepoUrl:a,branch:o,signal:c,baseUrl:l,getAccessToken:u,permissionMode:d}){let{getClaudeAIOAuthTokens:f}=await import(`./auth-DrD9DW6X.js`),{getOrganizationUUID:p}=await import(`./client-B-2ccQZk.js`),{getOauthConfig:m}=await import(`./oauth-U649LV5H.js`),{getOAuthHeaders:h}=await import(`./api-C4VflFau.js`),{parseGitHubRepository:g}=await import(`./detectRepository-BsKZDRoI.js`),{getDefaultBranch:_}=await import(`./git-Bs1vtuvX.js`),{getMainLoopModel:v}=await import(`./model-CIvbC7rW.js`),{default:y}=await import(`./axios-BHBm_hhU.js`),{isSelfHostedBridge:b}=await import(`./bridgeConfig-Ccm79Jze.js`),x=u?.()??f()?.accessToken;if(!x)return r(`[bridge] No access token for session creation`),null;let S=b()?`self-hosted`:await p();if(!S)return r(`[bridge] No org UUID for session creation`),null;let C=null,w=null;if(a){let{parseGitRemote:e}=await import(`./detectRepository-BsKZDRoI.js`),t=e(a);if(t){let{host:e,owner:n,name:r}=t,i=o||await _()||void 0;C={type:`git_repository`,url:`https://${e}/${n}/${r}`,revision:i},w={type:`git_repository`,git_info:{type:`github`,repo:`${n}/${r}`,branches:[`claude/${o||`task`}`]}}}else{let e=g(a);if(e){let[t,n]=e.split(`/`);if(t&&n){let e=o||await _()||void 0;C={type:`git_repository`,url:`https://github.com/${t}/${n}`,revision:e},w={type:`git_repository`,git_info:{type:`github`,repo:`${t}/${n}`,branches:[`claude/${o||`task`}`]}}}}}}let T={...n!==void 0&&{title:n},events:i,session_context:{sources:C?[C]:[],outcomes:w?[w]:[],model:v()},environment_id:e,source:`remote-control`,...d&&{permission_mode:d}},E={...h(x),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":S},D=`${l??m().BASE_API_URL}/v1/sessions`,O;try{O=await y.post(D,T,{headers:E,signal:c,validateStatus:e=>e<500})}catch(e){return r(`[bridge] Session creation request failed: ${t(e)}`),null}if(!(O.status===200||O.status===201)){let e=s(O.data);return r(`[bridge] Session creation failed with status ${O.status}${e?`: ${e}`:``}`),null}let k=O.data;return!k||typeof k!=`object`||!(`id`in k)||typeof k.id!=`string`?(r(`[bridge] No session ID in response`),null):k.id}async function u(e,n){let{getClaudeAIOAuthTokens:i}=await import(`./auth-DrD9DW6X.js`),{getOrganizationUUID:a}=await import(`./client-B-2ccQZk.js`),{getOauthConfig:o}=await import(`./oauth-U649LV5H.js`),{getOAuthHeaders:c}=await import(`./api-C4VflFau.js`),{default:l}=await import(`./axios-BHBm_hhU.js`),{isSelfHostedBridge:u}=await import(`./bridgeConfig-Ccm79Jze.js`),d=n?.getAccessToken?.()??i()?.accessToken;if(!d)return r(`[bridge] No access token for session fetch`),null;let f=u()?`self-hosted`:await a();if(!f)return r(`[bridge] No org UUID for session fetch`),null;let p={...c(d),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":f},m=`${n?.baseUrl??o().BASE_API_URL}/v1/sessions/${e}`;r(`[bridge] Fetching session ${e}`);let h;try{h=await l.get(m,{headers:p,timeout:1e4,validateStatus:e=>e<500})}catch(e){return r(`[bridge] Session fetch request failed: ${t(e)}`),null}if(h.status!==200){let e=s(h.data);return r(`[bridge] Session fetch failed with status ${h.status}${e?`: ${e}`:``}`),null}return h.data}async function d(e,t){let{getClaudeAIOAuthTokens:n}=await import(`./auth-DrD9DW6X.js`),{getOrganizationUUID:i}=await import(`./client-B-2ccQZk.js`),{getOauthConfig:a}=await import(`./oauth-U649LV5H.js`),{getOAuthHeaders:o}=await import(`./api-C4VflFau.js`),{default:c}=await import(`./axios-BHBm_hhU.js`),{isSelfHostedBridge:l}=await import(`./bridgeConfig-Ccm79Jze.js`),u=t?.getAccessToken?.()??n()?.accessToken;if(!u){r(`[bridge] No access token for session archive`);return}let d=l()?`self-hosted`:await i();if(!d){r(`[bridge] No org UUID for session archive`);return}let f={...o(u),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":d},p=`${t?.baseUrl??a().BASE_API_URL}/v1/sessions/${e}/archive`;r(`[bridge] Archiving session ${e}`);let m=await c.post(p,{},{headers:f,timeout:t?.timeoutMs??1e4,validateStatus:e=>e<500});if(m.status===200)r(`[bridge] Session ${e} archived successfully`);else{let e=s(m.data);r(`[bridge] Session archive failed with status ${m.status}${e?`: ${e}`:``}`)}}async function f(e,n,i){let{getClaudeAIOAuthTokens:o}=await import(`./auth-DrD9DW6X.js`),{getOrganizationUUID:c}=await import(`./client-B-2ccQZk.js`),{getOauthConfig:l}=await import(`./oauth-U649LV5H.js`),{getOAuthHeaders:u}=await import(`./api-C4VflFau.js`),{default:d}=await import(`./axios-BHBm_hhU.js`),{isSelfHostedBridge:f}=await import(`./bridgeConfig-Ccm79Jze.js`),p=i?.getAccessToken?.()??o()?.accessToken;if(!p){r(`[bridge] No access token for session title update`);return}let m=f()?`self-hosted`:await c();if(!m){r(`[bridge] No org UUID for session title update`);return}let h={...u(p),"anthropic-beta":`ccr-byoc-2025-07-29`,"x-organization-uuid":m},g=a(e),_=`${i?.baseUrl??l().BASE_API_URL}/v1/sessions/${g}`;r(`[bridge] Updating session title: ${g} → ${n}`);try{let e=await d.patch(_,{title:n},{headers:h,timeout:1e4,validateStatus:e=>e<500});if(e.status===200)r(`[bridge] Session title updated successfully`);else{let t=s(e.data);r(`[bridge] Session title update failed with status ${e.status}${t?`: ${t}`:``}`)}}catch(e){r(`[bridge] Session title update request failed: ${t(e)}`)}}var p=e((()=>{i(),n(),c(),o()}));export{f as a,p as i,l as n,u as r,d as t};
@@ -0,0 +1 @@
1
+ import{a as e,i as t,n,r}from"./createSession-CftIZ3aq.js";t();export{n as createBridgeSession,r as getBridgeSession,e as updateBridgeSessionTitle};
@@ -0,0 +1,40 @@
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{$c as n,AC as r,Cr as i,Dr as a,Ei as o,Hu as s,IC as c,Ir as l,Mp as u,Nu as d,Qu as f,Ti as ee,Tr as te,Vu as ne,Zu as re,cd as ie,hr as p,jp as m,ju as ae,lT as h,li as oe,sd as se,sr as ce,tl as g,uT as le}from"./loadAgentsDir-BXtV2jiO.js";import{C as ue,D as _,Gr as v,H as de,I as y,P as b,T as x,Wt as fe,Xn as pe,ai as me,di as S,fi as C,hn as he,k as ge,ot as _e,p as ve,t as w,ui as ye}from"./src-P_wYS_NJ2.js";import{t as T}from"./jsx-runtime-Bb4Xn-E0.js";import{Wt as be,et as xe,pt as Se}from"./state-BPFYBqm1.js";import{S as E,c as D,i as Ce,x as we}from"./debug-Dr1SjdXn.js";import{Ln as O,Rn as Te}from"./settings-DiBMs2gM.js";import{i as Ee,m as De}from"./git-CoQQ6YEf.js";import{a as k,o as Oe,s as ke}from"./log-27kCA_9u.js";import{n as Ae,r as A}from"./analytics-DJobLaWP.js";import{C as j,d as je,m as Me,v as Ne}from"./startupProfiler-Dc5r6LgE.js";import{_ as M,h as N}from"./model-CDnVaVDR.js";import{i as Pe,r as Fe}from"./shellQuote-C_I6DHLV.js";import{n as Ie,t as Le}from"./useExitOnCtrlCDWithKeybindings-BHQfwlAl.js";import{t as Re}from"./SearchBox-C9vUA4IM.js";import{n as ze,t as Be}from"./useSearchInput-q2CFPU4W.js";import{n as P,t as F}from"./Messages-CPX-nIdA.js";function Ve({log:e,onExit:t,onSelect:r}){let[i,o]=I.useState(null);I.useEffect(()=>{o(null),a(e)&&l(e).then(o)},[e]);let s=a(e)&&i===null,c=i??e,u=p(c)||``,d=n();return fe(`confirm:no`,t,{context:`Confirmation`}),fe(`confirm:yes`,(0,I.useCallback)(()=>{r(i??e)},[r,i,e]),{context:`Confirmation`}),s?(0,L.jsxs)(y,{flexDirection:`column`,padding:1,children:[(0,L.jsx)(ve,{message:`Loading session…`}),(0,L.jsx)(b,{dimColor:!0,children:(0,L.jsx)(x,{children:(0,L.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})})})]}):(0,L.jsxs)(y,{flexDirection:`column`,children:[(0,L.jsx)(F,{messages:c.messages,tools:d,commands:[],verbose:!0,toolJSX:null,toolUseConfirmQueue:[],inProgressToolUseIDs:new Set,isMessageSelectorVisible:!1,conversationId:u,screen:`transcript`,streamingToolUses:[],showAllInTranscript:!0,isLoading:!1}),(0,L.jsxs)(y,{flexShrink:0,flexDirection:`column`,borderTopDimColor:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,borderStyle:`single`,paddingLeft:2,children:[(0,L.jsxs)(b,{children:[Me(c.modified),` · `,c.messageCount,` messages`,c.gitBranch?` · ${c.gitBranch}`:``]}),(0,L.jsx)(b,{dimColor:!0,children:(0,L.jsxs)(x,{children:[(0,L.jsx)(_,{shortcut:`Enter`,action:`resume`}),(0,L.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})]})]})}var I,L,He=e((()=>{I=t(C(),1),w(),r(),g(),Ne(),i(),u(),P(),L=T()}));function R(e,t){if(e===B)return 5;let n=v(e),r=t?Math.min(n,t-V-H):n;return Math.max(0,r)+V+H}function Ue(e,t){let n=t-V-H;return v(e)<=n?e:n<=1?e.charAt(0):j(e,n)}function We({tabs:e,selectedIndex:t,availableWidth:n,showAllProjects:r=!1}){let i=r?`Resume (All Projects)`:`Resume`,a=i.length+1,o=Math.max(Ye,W),s=n-a-o-2,c=Math.max(0,Math.min(t,e.length-1)),l=Math.max(20,Math.floor(s/2)),u=e.map(e=>R(e,l)),d=0,f=e.length;if(u.reduce((e,t,n)=>e+t+ +(n<u.length-1),0)>s){let t=s-Je,n=u[c]??0;for(d=c,f=c+1;d>0||f<e.length;){let r=d>0,i=f<e.length;if(r){let e=(u[d-1]??0)+1;if(n+e<=t){d--,n+=e;continue}}if(i){let e=(u[f]??0)+1;if(n+e<=t){f++,n+=e;continue}}break}}let ee=d,te=e.length-f,ne=e.slice(d,f),re=ne.map((e,t)=>d+t);return(0,z.jsxs)(y,{flexDirection:`row`,gap:1,children:[(0,z.jsx)(b,{color:`suggestion`,children:i}),ee>0&&(0,z.jsxs)(b,{dimColor:!0,children:[U,ee]}),ne.map((e,t)=>{let n=re[t]===c,r=e===B?e:`#${Ue(e,l-V)}`;return(0,z.jsxs)(b,{backgroundColor:n?`suggestion`:void 0,color:n?`inverseText`:void 0,bold:n,children:[` `,r,` `]},e)}),te>0?(0,z.jsxs)(b,{dimColor:!0,children:[Ge,te,Ke]}):(0,z.jsx)(b,{dimColor:!0,children:qe})]})}var z,B,V,H,U,Ge,Ke,qe,Je,Ye,W,G=e((()=>{C(),w(),Ne(),z=T(),B=`All`,V=2,H=1,U=`← `,Ge=`→`,Ke=` (tab to cycle)`,qe=`(tab to cycle)`,Je=5,Ye=18,W=14}));function Xe({nodes:e,onSelect:t,onCancel:n,onFocus:r,focusNodeId:i,visibleOptionCount:a,layout:o=`expanded`,isDisabled:s=!1,hideIndexes:c=!1,isNodeExpanded:l,onExpand:u,onCollapse:d,getParentPrefix:f,getChildPrefix:ee,onUpFromFirstItem:te}){let[ne,ie]=K.useState(new Set),p=K.useRef(!1),m=K.useRef(null),ae=K.useCallback(e=>l?l(e):ne.has(e),[l,ne]),h=K.useMemo(()=>{let t=[];function n(e,r,i){let a=!!e.children&&e.children.length>0,o=ae(e.id);if(t.push({node:e,depth:r,isExpanded:o,hasChildren:a,parentId:i}),a&&o&&e.children)for(let t of e.children)n(t,r+1,e.id)}for(let t of e)n(t,0);return t},[e,ae]),oe=K.useCallback(e=>e?`▼ `:`▶ `,[]),se=K.useCallback(e=>` ▸ `,[]),ce=f??oe,g=ee??se,le=K.useCallback(e=>{let t=``;return e.hasChildren?t=ce(e.isExpanded):e.depth>0&&(t=g(e.depth)),t+e.node.label},[ce,g]),ue=K.useMemo(()=>h.map(e=>({label:le(e),description:e.node.description,dimDescription:e.node.dimDescription??!0,value:e.node.id})),[h,le]),_=K.useMemo(()=>{let e=new Map;return h.forEach(t=>e.set(t.node.id,t.node)),e},[h]),v=K.useCallback(e=>h.find(t=>t.node.id===e),[h]),de=K.useCallback((e,t)=>{let n=v(e);!n||!n.hasChildren||(t?u?u(e):ie(t=>new Set(t).add(e)):d?d(e):ie(t=>{let n=new Set(t);return n.delete(e),n}))},[v,u,d]);return(0,Ze.jsx)(y,{tabIndex:0,autoFocus:!0,onKeyDown:e=>{if(!i||s)return;let t=v(i);if(t){if(e.key===`right`&&t.hasChildren)e.preventDefault(),de(i,!0);else if(e.key===`left`){if(t.hasChildren&&t.isExpanded)e.preventDefault(),de(i,!1);else if(t.parentId!==void 0&&(e.preventDefault(),p.current=!0,de(t.parentId,!1),r)){let e=_.get(t.parentId);e&&r(e)}}}},children:(0,Ze.jsx)(re,{options:ue,onChange:K.useCallback(e=>{let n=_.get(e);n&&t(n)},[_,t]),onFocus:K.useCallback(e=>{if(p.current){p.current=!1;return}if(m.current!==e&&(m.current=e,r)){let t=_.get(e);t&&r(t)}},[r,_]),onCancel:n,defaultFocusValue:i,visibleOptionCount:a,layout:o,isDisabled:s,hideIndexes:c,onUpFromFirstItem:te})})}var K,Ze,Qe=e((()=>{K=t(C(),1),w(),f(),Ze=T()}));function $e(e,t){return j(e.replace(/\s+/g,` `).trim(),t)}function et({before:e,match:t,after:n},r){return ye.dim(e)+r(t)+ye.dim(n)}function tt(e,t,n){let r=e.toLowerCase().indexOf(t.toLowerCase());if(r===-1)return null;let i=r+t.length,a=Math.max(0,r-n),o=Math.min(e.length,i+n),s=e.slice(a,r),c=e.slice(r,i),l=e.slice(i,o);return{before:(a>0?`…`:``)+s.replace(/\s+/g,` `).trimStart(),match:c.trim(),after:l.replace(/\s+/g,` `).trimEnd()+(o<e.length?`…`:``)}}function nt(e,t,n){let{isGroupHeader:r=!1,isChild:i=!1,forkCount:a=0}=n||{},o=r&&a>0?lt:i?ut:0,s=r&&a>0?` (+${a} other ${a===1?`session`:`sessions`})`:``,c=e.isSidechain?` (sidechain)`:``,l=t-o-c.length-s.length;return`${$e(k(e),l)}${c}${s}`}function rt(e,t){let{isChild:n=!1,showProjectPath:r=!1}=t||{},i=n?` `:``,a=je(e),o=r&&e.projectPath?` · ${e.projectPath}`:``;return i+a+o}function it({logs:e,maxHeight:t=1/0,forceWidth:n,onCancel:r,onSelect:i,onLogsChanged:a,onLoadMore:o,initialSearchQuery:s,showAllProjects:c=!1,onToggleAllProjects:l,onAgenticSearch:u}){let d=_e(),f=n===void 0?d.columns:n,ie=Ie(r),h=pe(),g=te(),[le]=de(),v=ne(le),S=q.useMemo(()=>e=>me(e,v.warning),[v.warning]),[C,ve]=q.useState(null),[w,ye]=q.useState(!1),[T,be]=q.useState(!1),[E,D]=q.useState(!1),Ce=q.useMemo(()=>xe(),[]),[we,O]=q.useState(``),[Te,De]=q.useState(0),[Oe,ke]=q.useState(new Set),[Ae,j]=q.useState(null),[Me,Ne]=q.useState(1),[M,N]=q.useState(`list`),[Pe,Fe]=q.useState(null),Le=q.useRef(null),[Re,Be]=q.useState(0),[P,F]=q.useState({status:`idle`}),[I,L]=q.useState(!1),He=q.useRef(null),{query:R,setQuery:Ue,cursorOffset:z}=ze({isActive:M===`search`&&P.status!==`searching`,onExit:()=>{N(`list`),A(`tengu_session_search_toggled`,{enabled:!1})},onExitUp:()=>{N(`list`),A(`tengu_session_search_toggled`,{enabled:!1})},passthroughCtrlKeys:[`n`],initialQuery:s||``}),B=q.useDeferredValue(R),[V,H]=q.useState(``);q.useEffect(()=>{if(!B){H(``);return}let e=setTimeout(H,300,B);return()=>clearTimeout(e)},[B]);let[U,Ge]=q.useState(null),[Ke,qe]=q.useState(!1);q.useEffect(()=>{Ee().then(e=>ve(e)),ee(Ce).then(e=>{D(e.length>1)})},[Ce]);let Je=q.useMemo(()=>new Map(e.map(e=>[e,ot(e)])),[e]),Ye=q.useMemo(()=>null,[e,Je,!1]),W=q.useMemo(()=>ct(e),[e]),G=W.length>0,K=q.useMemo(()=>G?[`All`,...W]:[],[G,W]),Ze=K.length>0&&Re<K.length?Re:0,Qe=K[Ze],it=Qe===`All`?void 0:Qe,at=+!!G,lt=q.useMemo(()=>{let t=e;return g&&(t=e.filter(e=>{let t=Se(),n=p(e);return!!(t&&n===t||e.customTitle||ce(e.messages)||e.firstPrompt||e.customTitle)})),it!==void 0&&(t=t.filter(e=>e.tag===it)),w&&C&&(t=t.filter(e=>e.gitBranch===C)),E&&!T&&(t=t.filter(e=>e.projectPath===Ce)),t},[e,g,it,w,C,E,T,Ce]),ut=q.useMemo(()=>{if(!R)return lt;let e=R.toLowerCase();return lt.filter(t=>{let n=k(t).toLowerCase(),r=(t.gitBranch||``).toLowerCase(),i=(t.tag||``).toLowerCase(),a=t.prNumber?`pr #${t.prNumber} ${t.prRepository||``}`.toLowerCase():``;return n.includes(e)||r.includes(e)||i.includes(e)||a.includes(e)})},[lt,R]);q.useEffect(()=>{},[B,V,!1]),q.useEffect(()=>{Ge(null),qe(!1)},[V,Ye,!1]);let{filteredLogs:Y,snippets:X}=q.useMemo(()=>{let e=new Map,t=ut;if(U&&V&&U.query===V){for(let t of U.results)if(t.searchableText){let n=tt(t.searchableText,V,dt);n&&e.set(t.log,n)}let n=new Set(t.map(e=>e.messages[0]?.uuid)),r=U.results.map(e=>e.log).filter(e=>!n.has(e.messages[0]?.uuid));t=[...t,...r]}return{filteredLogs:t,snippets:e}},[ut,U,V]),Z=q.useMemo(()=>P.status===`results`&&P.results.length>0?P.results:Y,[P,Y]),Q=Math.max(30,f-4),ft=q.useMemo(()=>{if(!g)return[];let e=st(Z);return Array.from(e.entries()).map(([e,t])=>{let n=t[0],r=Z.indexOf(n),i=X.get(n),a=i?et(i,S):null;if(t.length===1){let t=rt(n,{showProjectPath:c});return{id:`log:${e}:0`,value:{log:n,indexInFiltered:r},label:nt(n,Q),description:a?`${t}\n ${a}`:t,dimDescription:!0}}let o=t.length-1,s=t.slice(1).map((t,n)=>{let r=Z.indexOf(t),i=X.get(t),a=i?et(i,S):null,o=rt(t,{isChild:!0,showProjectPath:c});return{id:`log:${e}:${n+1}`,value:{log:t,indexInFiltered:r},label:nt(t,Q,{isChild:!0}),description:a?`${o}\n ${a}`:o,dimDescription:!0}}),l=rt(n,{showProjectPath:c});return{id:`group:${e}`,value:{log:n,indexInFiltered:r},label:nt(n,Q,{isGroupHeader:!0,forkCount:o}),description:a?`${l}\n ${a}`:l,dimDescription:!0,children:s}})},[g,Z,Q,c,X,S]),pt=q.useMemo(()=>g?[]:Z.map((e,t)=>{let n=$e(k(e)+(e.isSidechain?` (sidechain)`:``),Q),r=je(e),i=c&&e.projectPath?` · ${e.projectPath}`:``,a=X.get(e),o=a?et(a,S):null;return{label:n,description:o?`${r}${i}\n ${o}`:r+i,dimDescription:!0,value:t.toString()}}),[g,Z,S,Q,c,X]),$=Ae?.value.log??null,mt=()=>{if(!g||!$)return``;let e=p($);if(!e)return``;let t=Z.filter(t=>p(t)===e);if(!(t.length>1))return``;let n=Oe.has(e);return t.indexOf($)>0||n?`← to collapse`:`→ to expand`},ht=q.useCallback(async()=>{let e=$?p($):void 0;if(!$||!e){N(`list`),O(``);return}we.trim()&&(await oe(e,we.trim(),$.fullPath),g&&a&&a()),N(`list`),O(``)},[$,we,a,g]),gt=q.useCallback(()=>{N(`list`),A(`tengu_session_search_toggled`,{enabled:!1})},[]),_t=q.useCallback(()=>{N(`search`),A(`tengu_session_search_toggled`,{enabled:!0})},[]),vt=q.useCallback(async()=>{if(!R.trim()||!u||!0)return;He.current?.abort();let t=new AbortController;He.current=t,F({status:`searching`}),A(`tengu_agentic_search_started`,{query_length:R.length});try{let n=await u(R,e,t.signal);if(t.signal.aborted)return;F({status:`results`,results:n,query:R}),A(`tengu_agentic_search_completed`,{query_length:R.length,results_count:n.length})}catch(e){if(t.signal.aborted)return;F({status:`error`,message:e instanceof Error?e.message:`Search failed`}),A(`tengu_agentic_search_error`,{query_length:R.length})}},[R,u,!1,e]);q.useEffect(()=>{P.status!==`idle`&&P.status!==`searching`&&(P.status===`results`&&P.query!==R||P.status===`error`)&&F({status:`idle`})},[R,P]),q.useEffect(()=>()=>{He.current?.abort()},[]);let yt=q.useRef(P.status);q.useEffect(()=>{let e=yt.current;if(yt.current=P.status,e===`searching`&&P.status===`results`){if(g&&ft.length>0)j(ft[0]);else if(!g&&Z.length>0){let e=Z[0];j({id:`0`,value:{log:e,indexInFiltered:0},label:``})}}},[P.status,g,ft,Z]);let bt=q.useCallback(e=>{let t=parseInt(e,10),n=Z[t];!n||Le.current===t.toString()||(Le.current=t.toString(),j({id:t.toString(),value:{log:n,indexInFiltered:t},label:``}),Ne(t+1))},[Z]),xt=q.useCallback(e=>{j(e);let t=Z.findIndex(t=>p(t)===p(e.value.log));t>=0&&Ne(t+1)},[Z]);fe(`confirm:no`,()=>{He.current?.abort(),F({status:`idle`}),A(`tengu_agentic_search_cancelled`,{})},{context:`Confirmation`,isActive:M!==`preview`&&P.status===`searching`}),fe(`confirm:no`,()=>{N(`list`),O(``)},{context:`Settings`,isActive:M===`rename`&&P.status!==`searching`}),fe(`confirm:no`,()=>{Ue(``),L(!1),r?.()},{context:`Confirmation`,isActive:M!==`preview`&&M!==`rename`&&M!==`search`&&I&&P.status!==`searching`}),he((e,t)=>{if(M!==`preview`&&P.status!==`searching`&&M!==`rename`)if(M===`search`)e.toLowerCase()===`n`&&t.ctrl?gt():(t.return||t.downArrow)&&R.trim();else{if(I){if(t.return){vt(),L(!1);return}else if(t.downArrow){L(!1);return}else if(t.upArrow){N(`search`),L(!1);return}}if(G&&t.tab){let e=t.shift?-1:1;Be(t=>{let n=((t<K.length?t:0)+K.length+e)%K.length,r=K[n];return A(`tengu_session_tag_filter_changed`,{is_all:r===`All`,tag_count:W.length}),n});return}let n=!t.ctrl&&!t.meta,r=e.toLowerCase();if(r===`a`&&t.ctrl&&l)l(),A(`tengu_session_all_projects_toggled`,{enabled:!c});else if(r===`b`&&t.ctrl){let e=!w;ye(e),A(`tengu_session_branch_filter_toggled`,{enabled:e})}else if(r===`w`&&t.ctrl&&E){let e=!T;be(e),A(`tengu_session_worktree_filter_toggled`,{enabled:e})}else r===`/`&&n?(N(`search`),A(`tengu_session_search_toggled`,{enabled:!0})):r===`r`&&t.ctrl&&$?(N(`rename`),O(``),A(`tengu_session_rename_started`,{})):r===`v`&&t.ctrl&&$?(Fe($),N(`preview`),A(`tengu_session_preview_opened`,{messageCount:$.messageCount})):$&&n&&e.length>0&&!/^\s+$/.test(e)&&(N(`search`),Ue(e),A(`tengu_session_search_toggled`,{enabled:!0}))}},{isActive:!0});let St=[];w&&C&&St.push(C),E&&!T&&St.push(`current worktree`);let Ct=8+ +(St.length>0&&M!==`search`)+at,wt=Math.max(1,Math.floor((t-Ct-2)/3));return q.useEffect(()=>{if(!o)return;let e=wt*2;Me+e>=Z.length&&o(wt*3)},[Me,wt,Z.length,o]),e.length===0?null:M===`preview`&&Pe&&g?(0,J.jsx)(Ve,{log:Pe,onExit:()=>{N(`list`),Fe(null)},onSelect:i}):(0,J.jsxs)(y,{flexDirection:`column`,height:t-1,children:[(0,J.jsx)(y,{flexShrink:0,children:(0,J.jsx)(ue,{color:`suggestion`})}),(0,J.jsx)(y,{flexShrink:0,children:(0,J.jsx)(b,{children:` `})}),G?(0,J.jsx)(We,{tabs:K,selectedIndex:Ze,availableWidth:f,showAllProjects:c}):(0,J.jsx)(y,{flexShrink:0,children:(0,J.jsxs)(b,{bold:!0,color:`suggestion`,children:[`Resume Session`,M===`list`&&Z.length>wt&&(0,J.jsxs)(b,{dimColor:!0,children:[` `,`(`,Me,` of `,Z.length,`)`]})]})}),(0,J.jsx)(ge,{query:R,isFocused:M===`search`,isTerminalFocused:h,cursorOffset:z}),St.length>0&&M!==`search`&&(0,J.jsx)(y,{flexShrink:0,paddingLeft:2,children:(0,J.jsx)(b,{dimColor:!0,children:(0,J.jsx)(x,{children:St})})}),(0,J.jsx)(y,{flexShrink:0,children:(0,J.jsx)(b,{children:` `})}),P.status===`searching`&&(0,J.jsxs)(y,{paddingLeft:1,flexShrink:0,children:[(0,J.jsx)(ae,{}),(0,J.jsx)(b,{children:` Searching…`})]}),P.status===`results`&&P.results.length>0&&(0,J.jsx)(y,{paddingLeft:1,marginBottom:1,flexShrink:0,children:(0,J.jsx)(b,{dimColor:!0,italic:!0,children:`Claude found these results:`})}),P.status===`results`&&P.results.length===0&&Y.length===0&&(0,J.jsx)(y,{paddingLeft:1,marginBottom:1,flexShrink:0,children:(0,J.jsx)(b,{dimColor:!0,italic:!0,children:`No matching sessions found.`})}),P.status===`error`&&Y.length===0&&(0,J.jsx)(y,{paddingLeft:1,marginBottom:1,flexShrink:0,children:(0,J.jsx)(b,{dimColor:!0,italic:!0,children:`No matching sessions found.`})}),!!R.trim()&&u&&!1,P.status===`searching`?null:M===`rename`&&$?(0,J.jsxs)(y,{paddingLeft:2,flexDirection:`column`,children:[(0,J.jsx)(b,{bold:!0,children:`Rename session:`}),(0,J.jsx)(y,{paddingTop:1,children:(0,J.jsx)(se,{value:we,onChange:O,onSubmit:ht,placeholder:k($,`Enter new session name`),columns:f,cursorOffset:Te,onChangeCursorOffset:De,showCursor:!0})})]}):g?(0,J.jsx)(Xe,{nodes:ft,onSelect:e=>{i(e.value.log)},onFocus:xt,onCancel:r,focusNodeId:Ae?.id,visibleOptionCount:wt,layout:`expanded`,isDisabled:M===`search`||I,hideIndexes:!1,isNodeExpanded:e=>{if(M===`search`||w)return!0;let t=typeof e==`string`&&e.startsWith(`group:`)?e.substring(6):null;return t?Oe.has(t):!1},onExpand:e=>{let t=typeof e==`string`&&e.startsWith(`group:`)?e.substring(6):null;t&&(ke(e=>new Set(e).add(t)),A(`tengu_session_group_expanded`,{}))},onCollapse:e=>{let t=typeof e==`string`&&e.startsWith(`group:`)?e.substring(6):null;t&&ke(e=>{let n=new Set(e);return n.delete(t),n})},onUpFromFirstItem:_t}):(0,J.jsx)(re,{options:pt,onChange:e=>{let t=Z[parseInt(e,10)];t&&i(t)},visibleOptionCount:wt,onCancel:r,onFocus:bt,defaultFocusValue:Ae?.id.toString(),layout:`expanded`,isDisabled:M===`search`||I,onUpFromFirstItem:_t}),(0,J.jsx)(y,{paddingLeft:2,children:ie.pending?(0,J.jsxs)(b,{dimColor:!0,children:[`Press `,ie.keyName,` again to exit`]}):M===`rename`?(0,J.jsx)(b,{dimColor:!0,children:(0,J.jsxs)(x,{children:[(0,J.jsx)(_,{shortcut:`Enter`,action:`save`}),(0,J.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})}):P.status===`searching`?(0,J.jsx)(b,{dimColor:!0,children:(0,J.jsxs)(x,{children:[(0,J.jsx)(b,{children:`Searching with Claude…`}),(0,J.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})}):I?(0,J.jsx)(b,{dimColor:!0,children:(0,J.jsxs)(x,{children:[(0,J.jsx)(_,{shortcut:`Enter`,action:`search`}),(0,J.jsx)(_,{shortcut:`↓`,action:`skip`}),(0,J.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})}):M===`search`?(0,J.jsx)(b,{dimColor:!0,children:(0,J.jsxs)(x,{children:[(0,J.jsx)(b,{children:`Type to Search`}),(0,J.jsx)(_,{shortcut:`Enter`,action:`select`}),(0,J.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`clear`})]})}):(0,J.jsx)(b,{dimColor:!0,children:(0,J.jsxs)(x,{children:[l&&(0,J.jsx)(_,{shortcut:`Ctrl+A`,action:`show ${c?`current dir`:`all projects`}`}),C&&(0,J.jsx)(_,{shortcut:`Ctrl+B`,action:`toggle branch`}),E&&(0,J.jsx)(_,{shortcut:`Ctrl+W`,action:`show ${T?`current worktree`:`all worktrees`}`}),(0,J.jsx)(_,{shortcut:`Ctrl+V`,action:`preview`}),(0,J.jsx)(_,{shortcut:`Ctrl+R`,action:`rename`}),(0,J.jsx)(b,{children:`Type to search`}),(0,J.jsx)(m,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`}),mt()&&(0,J.jsx)(b,{children:mt()})]})})})]})}function at(e){if(e.type!==`user`&&e.type!==`assistant`)return``;let t=`message`in e?e.message?.content:void 0;return t?typeof t==`string`?t:Array.isArray(t)?t.map(e=>typeof e==`string`?e:`text`in e&&typeof e.text==`string`?e.text:``).filter(Boolean).join(` `):``:``}function ot(e){let t=(e.messages.length<=Y?e.messages:[...e.messages.slice(0,X),...e.messages.slice(-1e3)]).map(at).filter(Boolean).join(` `),n=`${[e.customTitle,e.summary,e.firstPrompt,e.gitBranch,e.tag,e.prNumber?`PR #${e.prNumber}`:void 0,e.prRepository].filter(Boolean).join(` `)} ${t}`.trim();return n.length>Z?n.slice(0,Z):n}function st(e){let t=new Map;for(let n of e){let e=p(n);if(e){let r=t.get(e);r?r.push(n):t.set(e,[n])}}return t.forEach(e=>e.sort((e,t)=>new Date(t.modified).getTime()-new Date(e.modified).getTime())),t}function ct(e){let t=new Set;for(let n of e)n.tag&&t.add(n.tag);return Array.from(t).sort((e,t)=>e.localeCompare(t))}var q,J,lt,ut,Y,X,Z,dt,Q=e((()=>{S(),q=t(C(),1),be(),Le(),Be(),c(),w(),r(),Ae(),Ne(),o(),De(),Oe(),i(),s(),u(),f(),Re(),He(),d(),G(),ie(),Qe(),J=T(),lt=2,ut=4,Y=2e3,X=1e3,Z=5e4,dt=50}));function ft(e){if(e.type!==`user`&&e.type!==`assistant`)return``;let t=`message`in e?e.message?.content:void 0;return t?typeof t==`string`?t:Array.isArray(t)?t.map(e=>typeof e==`string`?e:`text`in e&&typeof e.text==`string`?e.text:``).filter(Boolean).join(` `):``:``}function pt(e){if(e.length===0)return``;let t=(e.length<=gt?e:[...e.slice(0,gt/2),...e.slice(-100/2)]).map(ft).filter(Boolean).join(` `).replace(/\s+/g,` `).trim();return t.length>ht?t.slice(0,ht)+`…`:t}function $(e,t){return!!(k(e).toLowerCase().includes(t)||e.customTitle?.toLowerCase().includes(t)||e.tag?.toLowerCase().includes(t)||e.gitBranch?.toLowerCase().includes(t)||e.summary?.toLowerCase().includes(t)||e.firstPrompt?.toLowerCase().includes(t)||e.messages&&e.messages.length>0&&pt(e.messages).toLowerCase().includes(t))}async function mt(e,t,n){if(!e.trim()||t.length===0)return[];let r=e.toLowerCase(),i=t.filter(e=>$(e,r)),o;if(i.length>=_t)o=i.slice(0,_t);else{let e=t.filter(e=>!$(e,r)),n=_t-i.length;o=[...i,...e.slice(0,n)]}D(`Agentic search: ${o.length}/${t.length} logs, query="${e}", matching: ${i.length}, with messages: ${O(o,e=>e.messages?.length>0)}`);let s=o.map(async e=>{if(a(e))try{return await l(e)}catch(t){return ke(t),e}return e}),c=await Promise.all(s);D(`Agentic search: loaded ${O(c,e=>e.messages?.length>0)}/${o.length} logs with transcripts`);let u=`Sessions:
2
+ ${c.map((e,t)=>{let n=[`${t}:`],r=k(e);if(n.push(r),e.customTitle&&e.customTitle!==r&&n.push(`[custom title: ${e.customTitle}]`),e.tag&&n.push(`[tag: ${e.tag}]`),e.gitBranch&&n.push(`[branch: ${e.gitBranch}]`),e.summary&&n.push(`- Summary: ${e.summary}`),e.firstPrompt&&e.firstPrompt!==`No prompt`&&n.push(`- First message: ${e.firstPrompt.slice(0,300)}`),e.messages&&e.messages.length>0){let t=pt(e.messages);t&&n.push(`- Transcript: ${t}`)}return n.join(` `)}).join(`
3
+ `)}
4
+
5
+ Search query: "${e}"
6
+
7
+ Find the sessions that are most relevant to this query.`;D(`Agentic search prompt (first 500 chars): ${u.slice(0,500)}...`);try{let e=N();D(`Agentic search using model: ${e}`);let t=(await le({model:e,system:vt,messages:[{role:`user`,content:u}],signal:n,querySource:`session_search`})).content.find(e=>e.type===`text`);if(!t||t.type!==`text`)return D(`No text content in agentic search response`),[];D(`Agentic search response: ${t.text}`);let r=t.text.match(/\{[\s\S]*\}/);if(!r)return D(`Could not find JSON in agentic search response`),[];let i=(E(r[0]).relevant_indices||[]).filter(e=>e>=0&&e<c.length).map(e=>c[e]);return D(`Agentic search found ${i.length} relevant sessions`),i}catch(e){return ke(e),D(`Agentic search error: ${e}`),[]}}var ht,gt,_t,vt,yt=e((()=>{Te(),Ce(),Oe(),M(),i(),h(),we(),ht=2e3,gt=100,_t=100,vt=`Your goal is to find relevant sessions based on a user's search query.
8
+
9
+ You will be given a list of sessions with their metadata and a search query. Identify which sessions are most relevant to the query.
10
+
11
+ Each session may include:
12
+ - Title (display name or custom title)
13
+ - Tag (user-assigned category, shown as [tag: name] - users tag sessions with /tag command to categorize them)
14
+ - Branch (git branch name, shown as [branch: name])
15
+ - Summary (AI-generated summary)
16
+ - First message (beginning of the conversation)
17
+ - Transcript (excerpt of conversation content)
18
+
19
+ IMPORTANT: Tags are user-assigned labels that indicate the session's topic or category. If the query matches a tag exactly or partially, those sessions should be highly prioritized.
20
+
21
+ For each session, consider (in order of priority):
22
+ 1. Exact tag matches (highest priority - user explicitly categorized this session)
23
+ 2. Partial tag matches or tag-related terms
24
+ 3. Title matches (custom titles or first message content)
25
+ 4. Branch name matches
26
+ 5. Summary and transcript content matches
27
+ 6. Semantic similarity and related concepts
28
+
29
+ CRITICAL: Be VERY inclusive in your matching. Include sessions that:
30
+ - Contain the query term anywhere in any field
31
+ - Are semantically related to the query (e.g., "testing" matches sessions about "tests", "unit tests", "QA", etc.)
32
+ - Discuss topics that could be related to the query
33
+ - Have transcripts that mention the concept even in passing
34
+
35
+ When in doubt, INCLUDE the session. It's better to return too many results than too few. The user can easily scan through results, but missing relevant sessions is frustrating.
36
+
37
+ Return sessions ordered by relevance (most relevant first). If truly no sessions have ANY connection to the query, return an empty array - but this should be rare.
38
+
39
+ Respond with ONLY the JSON object, no markdown formatting:
40
+ {"relevant_indices": [2, 5, 0]}`}));function bt(e,t){let n=xe();if(!t||!e.projectPath||e.projectPath===n)return{isCrossProject:!1};let r=p(e);return{isCrossProject:!0,isSameRepoWorktree:!1,command:`cd ${Pe([e.projectPath])} && claude --resume ${r}`,projectPath:e.projectPath}}var xt=e((()=>{be(),Fe(),i()}));export{it as a,yt as i,xt as n,Q as o,mt as r,bt as t};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{O as t,Wt as n,et as r}from"./state-BemZdQIl.js";import{AsyncLocalStorage as i}from"async_hooks";function a(e,t){return c.run(e,t)}function o(){return c.getStore()??t()}function s(){try{return o()}catch{return r()}}var c,l=e((()=>{n(),c=new i}));export{a as i,l as n,o as r,s as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{O as t,Wt as n,et as r}from"./state-BPFYBqm1.js";import{AsyncLocalStorage as i}from"async_hooks";function a(e,t){return c.run(e,t)}function o(){return c.getStore()??t()}function s(){try{return o()}catch{return r()}}var c,l=e((()=>{n(),c=new i}));export{a as i,l as n,o as r,s as t};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./cwd-Besi3Os3.js";e();export{t as getCwd};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{n as r,t as i}from"./axios-DaWTGg7G.js";import{d as a,h as o}from"./config-9rLTDOYW.js";import{o as s,s as c}from"./log-27kCA_9u.js";import{W as l,_ as u,ai as d,r as f,si as p,z as m}from"./model-CDnVaVDR.js";import{Z as h,et as g}from"./esm-BkOWaWVb.js";import{f as _,p as v}from"./firstPartyEventLogger-aFhcruXA.js";import{createHash as y}from"crypto";function b(e){return e.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}async function x(){if(N.length===0)return;let e=N;N=[];try{await r.post(E,e,{headers:{"Content-Type":`application/json`,"DD-API-KEY":D},timeout:A})}catch(e){c(e)}}function S(){P||(P=setTimeout(()=>{P=null,x()},T()).unref())}async function C(){P&&(clearTimeout(P),P=null),await x()}async function w(e,t){if(d()!==`firstParty`)return;let n=F;if(n===null&&(n=await I()),!(!n||!j.has(e)))try{let{envContext:n,...r}=await h({model:t.model,betas:t.betas}),i={...r,...n,...t,userBucket:R()};if(typeof i.toolName==`string`&&i.toolName.startsWith(`mcp__`)&&(i.toolName=`mcp`),typeof i.model==`string`){let e=f(i.model.replace(/\[1m]$/i,``));i.model=e in m?e:`other`}if(typeof i.version==`string`&&(i.version=i.version.replace(/^(\d+\.\d+\.\d+-dev\.\d{8})\.t\d+\.sha[a-f0-9]+$/,`$1`)),i.status!==void 0&&i.status!==null){let e=String(i.status);i.http_status=e;let t=e.charAt(0);t>=`1`&&t<=`5`&&(i.http_status_range=`${t}xx`),delete i.status}let a=i,o={ddsource:`nodejs`,ddtags:[`event:${e}`,...M.filter(e=>a[e]!==void 0&&a[e]!==null).map(e=>`${b(e)}:${a[e]}`)].join(`,`),message:e,service:`workmate`,hostname:`workmate`,env:process.env.USER_TYPE};for(let[e,t]of Object.entries(i))t!=null&&(o[b(e)]=t);N.push(o),N.length>=k?(P&&(clearTimeout(P),P=null),x()):S()}catch(e){c(e)}}function T(){return parseInt(process.env.CLAUDE_CODE_DATADOG_FLUSH_INTERVAL_MS||``,10)||O}var E,D,O,k,A,j,M,N,P,F,I,L,R,z=e((()=>{i(),n(),o(),s(),u(),p(),l(),_(),g(),E=process.env.DATADOG_LOGS_ENDPOINT??``,D=process.env.DATADOG_API_KEY??``,O=15e3,k=100,A=5e3,j=new Set(`tengu_api_error.tengu_api_success.tengu_cancel.tengu_compact_failed.tengu_exit.tengu_flicker.tengu_init.tengu_model_fallback_triggered.tengu_oauth_error.tengu_oauth_success.tengu_oauth_token_refresh_failure.tengu_oauth_token_refresh_success.tengu_oauth_token_refresh_lock_acquiring.tengu_oauth_token_refresh_lock_acquired.tengu_oauth_token_refresh_starting.tengu_oauth_token_refresh_completed.tengu_oauth_token_refresh_lock_releasing.tengu_oauth_token_refresh_lock_released.tengu_query_error.tengu_session_file_read.tengu_started.tengu_tool_use_error.tengu_tool_use_granted_in_prompt_permanent.tengu_tool_use_granted_in_prompt_temporary.tengu_tool_use_rejected_in_prompt.tengu_tool_use_success.tengu_uncaught_exception.tengu_unhandled_rejection.tengu_voice_recording_started.tengu_voice_toggled.tengu_team_mem_sync_pull.tengu_team_mem_sync_push.tengu_team_mem_sync_started.tengu_team_mem_entries_capped`.split(`.`)),M=[`arch`,`clientType`,`errorType`,`http_status_range`,`http_status`,`model`,`platform`,`provider`,`skillMode`,`subscriptionType`,`toolName`,`userBucket`,`userType`,`version`,`versionBase`],N=[],P=null,F=null,I=t(async()=>{if(v()||!E||!D)return F=!1,!1;try{return F=!0,!0}catch(e){return c(e),F=!1,!1}}),L=30,R=t(()=>{let e=a(),t=y(`sha256`).update(e).digest(`hex`);return parseInt(t.slice(0,8),16)%L})}));export{C as n,w as r,z as t};
@@ -0,0 +1,39 @@
1
+ import{n as e,r as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./memoize-BK3gG5ob.js";import{i,l as a,o}from"./envUtils-DcaKZlRU.js";import{n as s,t as c}from"./defineProperty-C-QyHrDq.js";import{Wt as l,pt as u}from"./state-BPFYBqm1.js";import{a as ee,n as d}from"./process-gEbdy6uY.js";import{homedir as f}from"os";import*as p from"path";import{dirname as te,join as ne,resolve as re}from"path";import*as m from"fs";import{closeSync as ie,fsyncSync as ae,openSync as oe,writeFileSync as se}from"fs";import{appendFile as ce,mkdir as le,open as ue,readFile as de,readdir as fe,rename as pe,rm as me,rmdir as he,stat as ge,symlink as _e,unlink as ve}from"fs/promises";function ye({writeFn:e,flushIntervalMs:t=1e3,maxBufferSize:n=100,maxBufferBytes:r=1/0,immediateMode:i=!1}){let a=[],o=0,s=null,c=null;function l(){s&&(clearTimeout(s),s=null)}function u(){c&&(e(c.join(``)),c=null),a.length!==0&&(e(a.join(``)),a=[],o=0,l())}function ee(){s||(s=setTimeout(u,t))}function d(){if(c){c.push(...a),a=[],o=0,l();return}let t=a;a=[],o=0,l(),c=t,setImmediate(()=>{let t=c;c=null,t&&e(t.join(``))})}return{write(t){if(i){e(t);return}a.push(t),o+=t.length,ee(),(a.length>=n||o>=r)&&d()},flush:u,dispose(){u()}}}var be=e((()=>{}));function xe(e){return Ce.add(e),()=>Ce.delete(e)}async function Se(){await Promise.all(Array.from(Ce).map(e=>e()))}var Ce,we=e((()=>{Ce=new Set}));function Te(e){let t=[],n=e.match(/^MCP server ["']([^"']+)["']/);if(n&&n[1])t.push(`mcp`),t.push(n[1].toLowerCase());else{let n=e.match(/^([^:[]+):/);n&&n[1]&&t.push(n[1].trim().toLowerCase())}let r=e.match(/^\[([^\]]+)]/);r&&r[1]&&t.push(r[1].trim().toLowerCase()),e.toLowerCase().includes(`1p event:`)&&t.push(`1p`);let i=e.match(/:\s*([^:]+?)(?:\s+(?:type|mode|status|event))?:/);if(i&&i[1]){let e=i[1].trim().toLowerCase();e.length<30&&!e.includes(` `)&&t.push(e)}return Array.from(new Set(t))}function Ee(e,t){return t?e.length===0?!1:t.isExclusive?!e.some(e=>t.exclude.includes(e)):e.some(e=>t.include.includes(e)):!0}function De(e,t){return!t||Ee(Te(e),t)}var Oe,ke=e((()=>{r(),Oe=n(e=>{if(!e||e.trim()===``)return null;let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);if(t.length===0)return null;let n=t.some(e=>e.startsWith(`!`)),r=t.some(e=>!e.startsWith(`!`));if(n&&r)return null;let i=t.map(e=>e.replace(/^!/,``).toLowerCase());return{include:n?[]:i,exclude:n?i:[],isExclusive:n}})}));function h(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}function g(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}var _=e((()=>{})),Ae,je=e((()=>{Ae=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return Ae=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,e=>(e^n()&15>>e/4).toString(16))}}));function Me(e){return typeof e==`object`&&!!e&&(`name`in e&&e.name===`AbortError`||`message`in e&&String(e.message).includes(`FetchRequestCanceledException`))}var Ne,Pe=e((()=>{Ne=e=>{if(e instanceof Error)return e;if(typeof e==`object`&&e){try{if(Object.prototype.toString.call(e)===`[object Error]`){let t=Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return Error(JSON.stringify(e))}catch{}}return Error(e)}})),v,y,b,x,Fe,Ie,Le,Re,ze,Be,Ve,He,Ue,S=e((()=>{Pe(),v=class extends Error{},y=class e extends v{constructor(t,n,r,i,a){super(`${e.makeMessage(t,n,r)}`),this.status=t,this.headers=i,this.requestID=i?.get(`request-id`),this.error=n,this.type=a??null}static makeMessage(e,t,n){let r=t?.message?typeof t.message==`string`?t.message:JSON.stringify(t.message):t?JSON.stringify(t):n;return e&&r?`${e} ${r}`:e?`${e} status code (no body)`:r||`(no status code or body)`}static generate(t,n,r,i){if(!t||!i)return new x({message:r,cause:Ne(n)});let a=n,o=a?.error?.type;return t===400?new Ie(t,a,r,i,o):t===401?new Le(t,a,r,i,o):t===403?new Re(t,a,r,i,o):t===404?new ze(t,a,r,i,o):t===409?new Be(t,a,r,i,o):t===422?new Ve(t,a,r,i,o):t===429?new He(t,a,r,i,o):t>=500?new Ue(t,a,r,i,o):new e(t,a,r,i,o)}},b=class extends y{constructor({message:e}={}){super(void 0,void 0,e||`Request was aborted.`,void 0)}},x=class extends y{constructor({message:e,cause:t}){super(void 0,void 0,e||`Connection error.`,void 0),t&&(this.cause=t)}},Fe=class extends x{constructor({message:e}={}){super({message:e??`Request timed out.`})}},Ie=class extends y{},Le=class extends y{},Re=class extends y{},ze=class extends y{},Be=class extends y{},Ve=class extends y{},He=class extends y{},Ue=class extends y{}}));function We(e){return typeof e==`object`?e??{}:{}}function Ge(e){if(!e)return!0;for(let t in e)return!1;return!0}function Ke(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var qe,Je,Ye,Xe,Ze,Qe,$e=e((()=>{S(),qe=/^[a-z][a-z0-9+.-]*:/i,Je=e=>qe.test(e),Ye=e=>(Ye=Array.isArray,Ye(e)),Xe=Ye,Ze=(e,t)=>{if(typeof t!=`number`||!Number.isInteger(t))throw new v(`${e} must be an integer`);if(t<0)throw new v(`${e} must be a positive integer`);return t},Qe=e=>{try{return JSON.parse(e)}catch{return}}})),et,tt=e((()=>{et=e=>new Promise(t=>setTimeout(t,e))})),C,nt=e((()=>{C=`0.81.0`}));function rt(){return typeof Deno<`u`&&Deno.build!=null?`deno`:typeof EdgeRuntime<`u`?`edge`:Object.prototype.toString.call(globalThis.process===void 0?0:globalThis.process)===`[object process]`?`node`:`unknown`}function it(){if(typeof navigator>`u`||!navigator)return null;for(let{key:e,pattern:t}of[{key:`edge`,pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`ie`,pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`ie`,pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`chrome`,pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`firefox`,pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`safari`,pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}]){let n=t.exec(navigator.userAgent);if(n)return{browser:e,version:`${n[1]||0}.${n[2]||0}.${n[3]||0}`}}return null}var at,ot,st,ct,lt,ut,dt=e((()=>{nt(),at=()=>typeof window<`u`&&window.document!==void 0&&typeof navigator<`u`,ot=()=>{let e=rt();if(e===`deno`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":C,"X-Stainless-OS":ct(Deno.build.os),"X-Stainless-Arch":st(Deno.build.arch),"X-Stainless-Runtime":`deno`,"X-Stainless-Runtime-Version":typeof Deno.version==`string`?Deno.version:Deno.version?.deno??`unknown`};if(typeof EdgeRuntime<`u`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":C,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":`edge`,"X-Stainless-Runtime-Version":globalThis.process.version};if(e===`node`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":C,"X-Stainless-OS":ct(globalThis.process.platform??`unknown`),"X-Stainless-Arch":st(globalThis.process.arch??`unknown`),"X-Stainless-Runtime":`node`,"X-Stainless-Runtime-Version":globalThis.process.version??`unknown`};let t=it();return t?{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":C,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`unknown`,"X-Stainless-Runtime":`browser:${t.browser}`,"X-Stainless-Runtime-Version":t.version}:{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":C,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`unknown`,"X-Stainless-Runtime":`unknown`,"X-Stainless-Runtime-Version":`unknown`}},st=e=>e===`x32`?`x32`:e===`x86_64`||e===`x64`?`x64`:e===`arm`?`arm`:e===`aarch64`||e===`arm64`?`arm64`:e?`other:${e}`:`unknown`,ct=e=>(e=e.toLowerCase(),e.includes(`ios`)?`iOS`:e===`android`?`Android`:e===`darwin`?`MacOS`:e===`win32`?`Windows`:e===`freebsd`?`FreeBSD`:e===`openbsd`?`OpenBSD`:e===`linux`?`Linux`:e?`Other:${e}`:`Unknown`),ut=()=>lt??(lt=ot())}));function ft(){if(typeof fetch<`u`)return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new Anthropic({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function pt(...e){let t=globalThis.ReadableStream;if(t===void 0)throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function mt(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return pt({start(){},async pull(e){let{done:n,value:r}=await t.next();n?e.close():e.enqueue(r)},async cancel(){await t.return?.()}})}function ht(e){if(e[Symbol.asyncIterator])return e;let t=e.getReader();return{async next(){try{let e=await t.read();return e?.done&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){let e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function gt(e){if(typeof e!=`object`||!e)return;if(e[Symbol.asyncIterator]){await e[Symbol.asyncIterator]().return?.();return}let t=e.getReader(),n=t.cancel();t.releaseLock(),await n}var _t=e((()=>{})),vt,yt=e((()=>{vt=({headers:e,body:t})=>({bodyHeaders:{"content-type":`application/json`},body:JSON.stringify(t)})}));function bt(e){return Object.entries(e).filter(([e,t])=>t!==void 0).map(([e,t])=>{if(typeof t==`string`||typeof t==`number`||typeof t==`boolean`)return`${encodeURIComponent(e)}=${encodeURIComponent(t)}`;if(t===null)return`${encodeURIComponent(e)}=`;throw new v(`Cannot stringify type ${typeof t}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join(`&`)}var xt=e((()=>{S()}));function St(e){let t=0;for(let n of e)t+=n.length;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}function Ct(e){let t;return(Tt??(t=new globalThis.TextEncoder,Tt=t.encode.bind(t)))(e)}function wt(e){let t;return(Et??(t=new globalThis.TextDecoder,Et=t.decode.bind(t)))(e)}var Tt,Et,Dt=e((()=>{}));function Ot(e,t){for(let n=t??0;n<e.length;n++){if(e[n]===10)return{preceding:n,index:n+1,carriage:!1};if(e[n]===13)return{preceding:n,index:n+1,carriage:!0}}return null}function kt(e){for(let t=0;t<e.length-1;t++){if(e[t]===10&&e[t+1]===10||e[t]===13&&e[t+1]===13)return t+2;if(e[t]===13&&e[t+1]===10&&t+3<e.length&&e[t+2]===13&&e[t+3]===10)return t+4}return-1}var w,T,At,jt=e((()=>{_(),Dt(),At=class{constructor(){w.set(this,void 0),T.set(this,void 0),h(this,w,new Uint8Array,`f`),h(this,T,null,`f`)}decode(e){if(e==null)return[];let t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`string`?Ct(e):e;h(this,w,St([g(this,w,`f`),t]),`f`);let n=[],r;for(;(r=Ot(g(this,w,`f`),g(this,T,`f`)))!=null;){if(r.carriage&&g(this,T,`f`)==null){h(this,T,r.index,`f`);continue}if(g(this,T,`f`)!=null&&(r.index!==g(this,T,`f`)+1||r.carriage)){n.push(wt(g(this,w,`f`).subarray(0,g(this,T,`f`)-1))),h(this,w,g(this,w,`f`).subarray(g(this,T,`f`)),`f`),h(this,T,null,`f`);continue}let e=g(this,T,`f`)===null?r.preceding:r.preceding-1,t=wt(g(this,w,`f`).subarray(0,e));n.push(t),h(this,w,g(this,w,`f`).subarray(r.index),`f`),h(this,T,null,`f`)}return n}flush(){return g(this,w,`f`).length?this.decode(`
2
+ `):[]}},w=new WeakMap,T=new WeakMap,At.NEWLINE_CHARS=new Set([`
3
+ `,`\r`]),At.NEWLINE_REGEXP=/\r\n|[\n\r]/g}));function Mt(){}function Nt(e,t,n){return!t||Pt[e]>Pt[n]?Mt:t[e].bind(t)}function E(e){let t=e.logger,n=e.logLevel??`off`;if(!t)return It;let r=Lt.get(t);if(r&&r[0]===n)return r[1];let i={error:Nt(`error`,t,n),warn:Nt(`warn`,t,n),info:Nt(`info`,t,n),debug:Nt(`debug`,t,n)};return Lt.set(t,[n,i]),i}var Pt,Ft,It,Lt,D,Rt=e((()=>{$e(),Pt={off:0,error:200,warn:300,info:400,debug:500},Ft=(e,t,n)=>{if(e){if(Ke(Pt,e))return e;E(n).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(Pt))}`)}},It={error:Mt,warn:Mt,info:Mt,debug:Mt},Lt=new WeakMap,D=e=>(e.options&&(e.options={...e.options},delete e.options.headers),e.headers&&(e.headers=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([e,t])=>[e,e.toLowerCase()===`x-api-key`||e.toLowerCase()===`authorization`||e.toLowerCase()===`cookie`||e.toLowerCase()===`set-cookie`?`***`:t]))),`retryOfRequestLogID`in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e)}));async function*zt(e,t){if(!e.body)throw t.abort(),globalThis.navigator!==void 0&&globalThis.navigator.product===`ReactNative`?new v(`The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api`):new v(`Attempted to iterate over a response with no body`);let n=new Wt,r=new At,i=ht(e.body);for await(let e of Bt(i))for(let t of r.decode(e)){let e=n.decode(t);e&&(yield e)}for(let e of r.flush()){let t=n.decode(e);t&&(yield t)}}async function*Bt(e){let t=new Uint8Array;for await(let n of e){if(n==null)continue;let e=n instanceof ArrayBuffer?new Uint8Array(n):typeof n==`string`?Ct(n):n,r=new Uint8Array(t.length+e.length);r.set(t),r.set(e,t.length),t=r;let i;for(;(i=kt(t))!==-1;)yield t.slice(0,i),t=t.slice(i)}t.length>0&&(yield t)}function Vt(e,t){let n=e.indexOf(t);return n===-1?[e,``,``]:[e.substring(0,n),t,e.substring(n+t.length)]}var Ht,Ut,Wt,Gt=e((()=>{_(),S(),_t(),jt(),Pe(),$e(),Dt(),Rt(),Ut=class e{constructor(e,t,n){this.iterator=e,Ht.set(this,void 0),this.controller=t,h(this,Ht,n,`f`)}static fromSSEResponse(t,n,r){let i=!1,a=r?E(r):console;async function*o(){if(i)throw new v("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let e=!1;try{for await(let e of zt(t,n)){if(e.event===`completion`)try{yield JSON.parse(e.data)}catch(t){throw a.error(`Could not parse message into JSON:`,e.data),a.error(`From chunk:`,e.raw),t}if(e.event===`message_start`||e.event===`message_delta`||e.event===`message_stop`||e.event===`content_block_start`||e.event===`content_block_delta`||e.event===`content_block_stop`)try{yield JSON.parse(e.data)}catch(t){throw a.error(`Could not parse message into JSON:`,e.data),a.error(`From chunk:`,e.raw),t}if(e.event!==`ping`&&e.event===`error`){let n=Qe(e.data)??e.data,r=n?.error?.type;throw new y(void 0,n,void 0,t.headers,r)}}e=!0}catch(e){if(Me(e))return;throw e}finally{e||n.abort()}}return new e(o,n,r)}static fromReadableStream(t,n,r){let i=!1;async function*a(){let e=new At,n=ht(t);for await(let t of n)for(let n of e.decode(t))yield n;for(let t of e.flush())yield t}async function*o(){if(i)throw new v("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let e=!1;try{for await(let t of a())e||t&&(yield JSON.parse(t));e=!0}catch(e){if(Me(e))return;throw e}finally{e||n.abort()}}return new e(o,n,r)}[(Ht=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let t=[],n=[],r=this.iterator(),i=e=>({next:()=>{if(e.length===0){let e=r.next();t.push(e),n.push(e)}return e.shift()}});return[new e(()=>i(t),this.controller,g(this,Ht,`f`)),new e(()=>i(n),this.controller,g(this,Ht,`f`))]}toReadableStream(){let e=this,t;return pt({async start(){t=e[Symbol.asyncIterator]()},async pull(e){try{let{value:n,done:r}=await t.next();if(r)return e.close();let i=Ct(JSON.stringify(n)+`
4
+ `);e.enqueue(i)}catch(t){e.error(t)}},async cancel(){await t.return?.()}})}},Wt=class{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith(`\r`)&&(e=e.substring(0,e.length-1)),!e){if(!this.event&&!this.data.length)return null;let e={event:this.event,data:this.data.join(`
5
+ `),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],e}if(this.chunks.push(e),e.startsWith(`:`))return null;let[t,n,r]=Vt(e,`:`);return r.startsWith(` `)&&(r=r.substring(1)),t===`event`?this.event=r:t===`data`&&this.data.push(r),null}}}));async function Kt(e,t){let{response:n,requestLogID:r,retryOfRequestLogID:i,startTime:a}=t,o=await(async()=>{if(t.options.stream)return E(e).debug(`response`,n.status,n.url,n.headers,n.body),t.options.__streamClass?t.options.__streamClass.fromSSEResponse(n,t.controller):Ut.fromSSEResponse(n,t.controller);if(n.status===204)return null;if(t.options.__binaryResponse)return n;let r=n.headers.get(`content-type`)?.split(`;`)[0]?.trim();return r?.includes(`application/json`)||r?.endsWith(`+json`)?n.headers.get(`content-length`)===`0`?void 0:qt(await n.json(),n):await n.text()})();return E(e).debug(`[${r}] response parsed`,D({retryOfRequestLogID:i,url:n.url,status:n.status,body:o,durationMs:Date.now()-a})),o}function qt(e,t){return!e||typeof e!=`object`||Array.isArray(e)?e:Object.defineProperty(e,"_request_id",{value:t.headers.get(`request-id`),enumerable:!1})}var Jt=e((()=>{Gt(),Rt()})),Yt,Xt,Zt=e((()=>{_(),Jt(),Xt=class e extends Promise{constructor(e,t,n=Kt){super(e=>{e(null)}),this.responsePromise=t,this.parseResponse=n,Yt.set(this,void 0),h(this,Yt,e,`f`)}_thenUnwrap(t){return new e(g(this,Yt,`f`),this.responsePromise,async(e,n)=>qt(t(await this.parseResponse(e,n),n),n.response))}asResponse(){return this.responsePromise.then(e=>e.response)}async withResponse(){let[e,t]=await Promise.all([this.parse(),this.asResponse()]);return{data:e,response:t,request_id:t.headers.get(`request-id`)}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(e=>this.parseResponse(g(this,Yt,`f`),e))),this.parsedPromise}then(e,t){return this.parse().then(e,t)}catch(e){return this.parse().catch(e)}finally(e){return this.parse().finally(e)}},Yt=new WeakMap})),Qt,$t,en,tn,nn,O=e((()=>{_(),S(),Jt(),Zt(),$e(),$t=class{constructor(e,t,n,r){Qt.set(this,void 0),h(this,Qt,e,`f`),this.options=r,this.response=t,this.body=n}hasNextPage(){return this.getPaginatedItems().length?this.nextPageRequestOptions()!=null:!1}async getNextPage(){let e=this.nextPageRequestOptions();if(!e)throw new v("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await g(this,Qt,`f`).requestAPIList(this.constructor,e)}async*iterPages(){let e=this;for(yield e;e.hasNextPage();)e=await e.getNextPage(),yield e}async*[(Qt=new WeakMap,Symbol.asyncIterator)](){for await(let e of this.iterPages())for(let t of e.getPaginatedItems())yield t}},en=class extends Xt{constructor(e,t,n){super(e,t,async(e,t)=>new n(e,t.response,await Kt(e,t),t.options))}async*[Symbol.asyncIterator](){let e=await this;for await(let t of e)yield t}},tn=class extends $t{constructor(e,t,n,r){super(e,t,n,r),this.data=n.data||[],this.has_more=n.has_more||!1,this.first_id=n.first_id||null,this.last_id=n.last_id||null}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more!==!1&&super.hasNextPage()}nextPageRequestOptions(){if(this.options.query?.before_id){let e=this.first_id;return e?{...this.options,query:{...We(this.options.query),before_id:e}}:null}let e=this.last_id;return e?{...this.options,query:{...We(this.options.query),after_id:e}}:null}},nn=class extends $t{constructor(e,t,n,r){super(e,t,n,r),this.data=n.data||[],this.has_more=n.has_more||!1,this.next_page=n.next_page||null}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more!==!1&&super.hasNextPage()}nextPageRequestOptions(){let e=this.next_page;return e?{...this.options,query:{...We(this.options.query),page:e}}:null}}}));function k(e,t,n){return on(),new File(e,t??`unknown_file`,n)}function rn(e,t){let n=typeof e==`object`&&!!e&&(`name`in e&&e.name&&String(e.name)||`url`in e&&e.url&&String(e.url)||`filename`in e&&e.filename&&String(e.filename)||`path`in e&&e.path&&String(e.path))||``;return t?n.split(/[\\/]/).pop()||void 0:n}function an(e){let t=typeof e==`function`?e:e.fetch,n=ln.get(t);if(n)return n;let r=(async()=>{try{let e=`Response`in t?t.Response:(await t(`data:,`)).constructor,n=new FormData;return n.toString()!==await new e(n).text()}catch{return!0}})();return ln.set(t,r),r}var on,sn,cn,ln,un,dn,fn,pn=e((()=>{_t(),on=()=>{if(typeof File>`u`){let{process:e}=globalThis,t=typeof e?.versions?.node==`string`&&parseInt(e.versions.node.split(`.`))<20;throw Error("`File` is not defined as a global, which is required for file uploads."+(t?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":``))}},sn=e=>typeof e==`object`&&!!e&&typeof e[Symbol.asyncIterator]==`function`,cn=async(e,t,n=!0)=>({...e,body:await un(e.body,t,n)}),ln=new WeakMap,un=async(e,t,n=!0)=>{if(!await an(t))throw TypeError(`The provided fetch function does not support file uploads with the current global FormData class.`);let r=new FormData;return await Promise.all(Object.entries(e||{}).map(([e,t])=>fn(r,e,t,n))),r},dn=e=>e instanceof Blob&&`name`in e,fn=async(e,t,n,r)=>{if(n!==void 0){if(n==null)throw TypeError(`Received null for "${t}"; to pass null in FormData, you must use the string 'null'`);if(typeof n==`string`||typeof n==`number`||typeof n==`boolean`)e.append(t,String(n));else if(n instanceof Response){let i={},a=n.headers.get(`Content-Type`);a&&(i={type:a}),e.append(t,k([await n.blob()],rn(n,r),i))}else if(sn(n))e.append(t,k([await new Response(mt(n)).blob()],rn(n,r)));else if(dn(n))e.append(t,k([n],rn(n,r),{type:n.type}));else if(Array.isArray(n))await Promise.all(n.map(n=>fn(e,t+`[]`,n,r)));else if(typeof n==`object`)await Promise.all(Object.entries(n).map(([n,i])=>fn(e,`${t}[${n}]`,i,r)));else throw TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${n} instead`)}}}));async function mn(e,t,n){if(on(),e=await e,t||(t=rn(e,!0)),vn(e))return e instanceof File&&t==null&&n==null?e:k([await e.arrayBuffer()],t??e.name,{type:e.type,lastModified:e.lastModified,...n});if(yn(e)){let r=await e.blob();return t||(t=new URL(e.url).pathname.split(/[\\/]/).pop()),k(await hn(r),t,n)}let r=await hn(e);if(!n?.type){let e=r.find(e=>typeof e==`object`&&`type`in e&&e.type);typeof e==`string`&&(n={...n,type:e})}return k(r,t,n)}async function hn(e){let t=[];if(typeof e==`string`||ArrayBuffer.isView(e)||e instanceof ArrayBuffer)t.push(e);else if(_n(e))t.push(e instanceof Blob?e:await e.arrayBuffer());else if(sn(e))for await(let n of e)t.push(...await hn(n));else{let t=e?.constructor?.name;throw Error(`Unexpected data type: ${typeof e}${t?`; constructor: ${t}`:``}${gn(e)}`)}return t}function gn(e){return typeof e!=`object`||!e?``:`; props: [${Object.getOwnPropertyNames(e).map(e=>`"${e}"`).join(`, `)}]`}var _n,vn,yn,bn=e((()=>{pn(),_n=e=>typeof e==`object`&&!!e&&typeof e.size==`number`&&typeof e.type==`string`&&typeof e.text==`function`&&typeof e.slice==`function`&&typeof e.arrayBuffer==`function`,vn=e=>typeof e==`object`&&!!e&&typeof e.name==`string`&&typeof e.lastModified==`number`&&_n(e),yn=e=>typeof e==`object`&&!!e&&typeof e.url==`string`&&typeof e.blob==`function`})),xn=e((()=>{bn()})),Sn=e((()=>{})),A,j=e((()=>{A=class{constructor(e){this._client=e}}}));function*Cn(e){if(!e)return;if(wn in e){let{values:t,nulls:n}=e;yield*t.entries();for(let e of n)yield[e,null];return}let t=!1,n;e instanceof Headers?n=e.entries():Xe(e)?n=e:(t=!0,n=Object.entries(e??{}));for(let e of n){let n=e[0];if(typeof n!=`string`)throw TypeError(`expected header name to be a string`);let r=Xe(e[1])?e[1]:[e[1]],i=!1;for(let e of r)e!==void 0&&(t&&!i&&(i=!0,yield[n,null]),yield[n,e])}}var wn,M,N=e((()=>{$e(),wn=Symbol.for(`brand.privateNullableHeaders`),M=e=>{let t=new Headers,n=new Set;for(let r of e){let e=new Set;for(let[i,a]of Cn(r)){let r=i.toLowerCase();e.has(r)||(t.delete(i),e.add(r)),a===null?(t.delete(i),n.add(r)):(t.append(i,a),n.delete(r))}}return{[wn]:!0,values:t,nulls:n}}}));function Tn(e){return typeof e==`object`&&!!e&&kn in e}function En(e,t){let n=new Set;if(e)for(let t of e)Tn(t)&&n.add(t[kn]);if(t){for(let e of t)if(Tn(e)&&n.add(e[kn]),Array.isArray(e.content))for(let t of e.content)Tn(t)&&n.add(t[kn])}return Array.from(n)}function Dn(e,t){let n=En(e,t);return n.length===0?{}:{"x-stainless-helper":n.join(`, `)}}function On(e){return Tn(e)?{"x-stainless-helper":e[kn]}:{}}var kn,An=e((()=>{kn=Symbol(`anthropic.sdk.stainlessHelper`)}));function jn(e){return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}var Mn,Nn,P,F=e((()=>{S(),Mn=Object.freeze(Object.create(null)),Nn=(e=jn)=>function(t,...n){if(t.length===1)return t[0];let r=!1,i=[],a=t.reduce((t,a,o)=>{/[?#]/.test(a)&&(r=!0);let s=n[o],c=(r?encodeURIComponent:e)(``+s);return o!==n.length&&(s==null||typeof s==`object`&&s.toString===Object.getPrototypeOf(Object.getPrototypeOf(s.hasOwnProperty??Mn)??Mn)?.toString)&&(c=s+``,i.push({start:t.length+a.length,length:c.length,error:`Value of type ${Object.prototype.toString.call(s).slice(8,-1)} is not a valid path parameter`})),t+a+(o===n.length?``:c)},``),o=a.split(/[?#]/,1)[0],s=/(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi,c;for(;(c=s.exec(o))!==null;)i.push({start:c.index,length:c[0].length,error:`Value "${c[0]}" can\'t be safely passed as a path parameter`});if(i.sort((e,t)=>e.start-t.start),i.length>0){let e=0,t=i.reduce((t,n)=>{let r=` `.repeat(n.start-e),i=`^`.repeat(n.length);return e=n.start+n.length,t+r+i},``);throw new v(`Path parameters result in path with invalid segments:\n${i.map(e=>e.error).join(`
6
+ `)}\n${a}\n${t}`)}return a},P=Nn(jn)})),Pn,Fn=e((()=>{j(),O(),N(),An(),pn(),F(),Pn=class extends A{list(e={},t){let{betas:n,...r}=e??{};return this._client.getAPIList(`/v1/files`,tn,{query:r,...t,headers:M([{"anthropic-beta":[...n??[],`files-api-2025-04-14`].toString()},t?.headers])})}delete(e,t={},n){let{betas:r}=t??{};return this._client.delete(P`/v1/files/${e}`,{...n,headers:M([{"anthropic-beta":[...r??[],`files-api-2025-04-14`].toString()},n?.headers])})}download(e,t={},n){let{betas:r}=t??{};return this._client.get(P`/v1/files/${e}/content`,{...n,headers:M([{"anthropic-beta":[...r??[],`files-api-2025-04-14`].toString(),Accept:`application/binary`},n?.headers]),__binaryResponse:!0})}retrieveMetadata(e,t={},n){let{betas:r}=t??{};return this._client.get(P`/v1/files/${e}`,{...n,headers:M([{"anthropic-beta":[...r??[],`files-api-2025-04-14`].toString()},n?.headers])})}upload(e,t){let{betas:n,...r}=e;return this._client.post(`/v1/files`,cn({body:r,...t,headers:M([{"anthropic-beta":[...n??[],`files-api-2025-04-14`].toString()},On(r.file),t?.headers])},this._client))}}})),In,Ln=e((()=>{j(),O(),N(),F(),In=class extends A{retrieve(e,t={},n){let{betas:r}=t??{};return this._client.get(P`/v1/models/${e}?beta=true`,{...n,headers:M([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()}},n?.headers])})}list(e={},t){let{betas:n,...r}=e??{};return this._client.getAPIList(`/v1/models?beta=true`,tn,{query:r,...t,headers:M([{...n?.toString()==null?void 0:{"anthropic-beta":n?.toString()}},t?.headers])})}}})),Rn=e((()=>{S()})),zn,Bn=e((()=>{zn={"claude-opus-4-20250514":8192,"claude-opus-4-0":8192,"claude-4-opus-20250514":8192,"anthropic.claude-opus-4-20250514-v1:0":8192,"claude-opus-4@20250514":8192,"claude-opus-4-1-20250805":8192,"anthropic.claude-opus-4-1-20250805-v1:0":8192,"claude-opus-4-1@20250805":8192}}));function Vn(e){return e?.output_format??e?.output_config?.format}function Hn(e,t,n){let r=Vn(t);return!t||!(`parse`in(r??{}))?{...e,content:e.content.map(e=>{if(e.type===`text`){let t=Object.defineProperty({...e},"parsed_output",{value:null,enumerable:!1});return Object.defineProperty(t,"parsed",{get(){return n.logger.warn("The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead."),null},enumerable:!1})}return e}),parsed_output:null}:Un(e,t,n)}function Un(e,t,n){let r=null,i=e.content.map(e=>{if(e.type===`text`){let i=Wn(t,e.text);r===null&&(r=i);let a=Object.defineProperty({...e},"parsed_output",{value:i,enumerable:!1});return Object.defineProperty(a,"parsed",{get(){return n.logger.warn("The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead."),i},enumerable:!1})}return e});return{...e,content:i,parsed_output:r}}function Wn(e,t){let n=Vn(e);if(n?.type!==`json_schema`)return null;try{return`parse`in n?n.parse(t):JSON.parse(t)}catch(e){throw new v(`Failed to parse structured output: ${e}`)}}var Gn=e((()=>{S()})),Kn,qn,Jn,Yn,Xn,Zn=e((()=>{Kn=e=>{let t=0,n=[];for(;t<e.length;){let r=e[t];if(r===`\\`){t++;continue}if(r===`{`){n.push({type:`brace`,value:`{`}),t++;continue}if(r===`}`){n.push({type:`brace`,value:`}`}),t++;continue}if(r===`[`){n.push({type:`paren`,value:`[`}),t++;continue}if(r===`]`){n.push({type:`paren`,value:`]`}),t++;continue}if(r===`:`){n.push({type:`separator`,value:`:`}),t++;continue}if(r===`,`){n.push({type:`delimiter`,value:`,`}),t++;continue}if(r===`"`){let i=``,a=!1;for(r=e[++t];r!==`"`;){if(t===e.length){a=!0;break}if(r===`\\`){if(t++,t===e.length){a=!0;break}i+=r+e[t],r=e[++t]}else i+=r,r=e[++t]}r=e[++t],a||n.push({type:`string`,value:i});continue}if(r&&/\s/.test(r)){t++;continue}let i=/[0-9]/;if(r&&i.test(r)||r===`-`||r===`.`){let a=``;for(r===`-`&&(a+=r,r=e[++t]);r&&i.test(r)||r===`.`;)a+=r,r=e[++t];n.push({type:`number`,value:a});continue}let a=/[a-z]/i;if(r&&a.test(r)){let i=``;for(;r&&a.test(r)&&t!==e.length;)i+=r,r=e[++t];if(i==`true`||i==`false`||i===`null`)n.push({type:`name`,value:i});else{t++;continue}continue}t++}return n},qn=e=>{if(e.length===0)return e;let t=e[e.length-1];switch(t.type){case`separator`:return e=e.slice(0,e.length-1),qn(e);case`number`:let n=t.value[t.value.length-1];if(n===`.`||n===`-`)return e=e.slice(0,e.length-1),qn(e);case`string`:let r=e[e.length-2];if(r?.type===`delimiter`||r?.type===`brace`&&r.value===`{`)return e=e.slice(0,e.length-1),qn(e);break;case`delimiter`:return e=e.slice(0,e.length-1),qn(e)}return e},Jn=e=>{let t=[];return e.map(e=>{e.type===`brace`&&(e.value===`{`?t.push(`}`):t.splice(t.lastIndexOf(`}`),1)),e.type===`paren`&&(e.value===`[`?t.push(`]`):t.splice(t.lastIndexOf(`]`),1))}),t.length>0&&t.reverse().map(t=>{t===`}`?e.push({type:`brace`,value:`}`}):t===`]`&&e.push({type:`paren`,value:`]`})}),e},Yn=e=>{let t=``;return e.map(e=>{switch(e.type){case`string`:t+=`"`+e.value+`"`;break;default:t+=e.value;break}}),t},Xn=e=>JSON.parse(Yn(Jn(qn(Kn(e)))))})),Qn=e((()=>{Gt()}));function $n(e){return e.type===`tool_use`||e.type===`server_tool_use`||e.type===`mcp_tool_use`}var I,L,er,tr,nr,rr,ir,ar,or,R,sr,cr,lr,z,ur,dr,fr,pr,mr,hr,gr,_r,vr,yr,br,xr,Sr=e((()=>{_(),Zn(),Rn(),Pe(),Qn(),Gn(),br=`__json_buf`,xr=class e{constructor(e,t){I.add(this),this.messages=[],this.receivedMessages=[],L.set(this,void 0),er.set(this,null),this.controller=new AbortController,tr.set(this,void 0),nr.set(this,()=>{}),rr.set(this,()=>{}),ir.set(this,void 0),ar.set(this,()=>{}),or.set(this,()=>{}),R.set(this,{}),sr.set(this,!1),cr.set(this,!1),lr.set(this,!1),z.set(this,!1),ur.set(this,void 0),dr.set(this,void 0),fr.set(this,void 0),hr.set(this,e=>{if(h(this,cr,!0,`f`),Me(e)&&(e=new b),e instanceof b)return h(this,lr,!0,`f`),this._emit(`abort`,e);if(e instanceof v)return this._emit(`error`,e);if(e instanceof Error){let t=new v(e.message);return t.cause=e,this._emit(`error`,t)}return this._emit(`error`,new v(String(e)))}),h(this,tr,new Promise((e,t)=>{h(this,nr,e,`f`),h(this,rr,t,`f`)}),`f`),h(this,ir,new Promise((e,t)=>{h(this,ar,e,`f`),h(this,or,t,`f`)}),`f`),g(this,tr,`f`).catch(()=>{}),g(this,ir,`f`).catch(()=>{}),h(this,er,e,`f`),h(this,fr,t?.logger??console,`f`)}get response(){return g(this,ur,`f`)}get request_id(){return g(this,dr,`f`)}async withResponse(){h(this,z,!0,`f`);let e=await g(this,tr,`f`);if(!e)throw Error("Could not resolve a `Response` object");return{data:this,response:e,request_id:e.headers.get(`request-id`)}}static fromReadableStream(t){let n=new e(null);return n._run(()=>n._fromReadableStream(t)),n}static createMessage(t,n,r,{logger:i}={}){let a=new e(n,{logger:i});for(let e of n.messages)a._addMessageParam(e);return h(a,er,{...n,stream:!0},`f`),a._run(()=>a._createMessage(t,{...n,stream:!0},{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":`stream`}})),a}_run(e){e().then(()=>{this._emitFinal(),this._emit(`end`)},g(this,hr,`f`))}_addMessageParam(e){this.messages.push(e)}_addMessage(e,t=!0){this.receivedMessages.push(e),t&&this._emit(`message`,e)}async _createMessage(e,t,n){let r=n?.signal,i;r&&(r.aborted&&this.controller.abort(),i=this.controller.abort.bind(this.controller),r.addEventListener(`abort`,i));try{g(this,I,`m`,gr).call(this);let{response:r,data:i}=await e.create({...t,stream:!0},{...n,signal:this.controller.signal}).withResponse();this._connected(r);for await(let e of i)g(this,I,`m`,_r).call(this,e);if(i.controller.signal?.aborted)throw new b;g(this,I,`m`,vr).call(this)}finally{r&&i&&r.removeEventListener(`abort`,i)}}_connected(e){this.ended||(h(this,ur,e,`f`),h(this,dr,e?.headers.get(`request-id`),`f`),g(this,nr,`f`).call(this,e),this._emit(`connect`))}get ended(){return g(this,sr,`f`)}get errored(){return g(this,cr,`f`)}get aborted(){return g(this,lr,`f`)}abort(){this.controller.abort()}on(e,t){return(g(this,R,`f`)[e]||(g(this,R,`f`)[e]=[])).push({listener:t}),this}off(e,t){let n=g(this,R,`f`)[e];if(!n)return this;let r=n.findIndex(e=>e.listener===t);return r>=0&&n.splice(r,1),this}once(e,t){return(g(this,R,`f`)[e]||(g(this,R,`f`)[e]=[])).push({listener:t,once:!0}),this}emitted(e){return new Promise((t,n)=>{h(this,z,!0,`f`),e!==`error`&&this.once(`error`,n),this.once(e,t)})}async done(){h(this,z,!0,`f`),await g(this,ir,`f`)}get currentMessage(){return g(this,L,`f`)}async finalMessage(){return await this.done(),g(this,I,`m`,pr).call(this)}async finalText(){return await this.done(),g(this,I,`m`,mr).call(this)}_emit(e,...t){if(g(this,sr,`f`))return;e===`end`&&(h(this,sr,!0,`f`),g(this,ar,`f`).call(this));let n=g(this,R,`f`)[e];if(n&&(g(this,R,`f`)[e]=n.filter(e=>!e.once),n.forEach(({listener:e})=>e(...t))),e===`abort`){let e=t[0];!g(this,z,`f`)&&!n?.length&&Promise.reject(e),g(this,rr,`f`).call(this,e),g(this,or,`f`).call(this,e),this._emit(`end`);return}if(e===`error`){let e=t[0];!g(this,z,`f`)&&!n?.length&&Promise.reject(e),g(this,rr,`f`).call(this,e),g(this,or,`f`).call(this,e),this._emit(`end`)}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit(`finalMessage`,g(this,I,`m`,pr).call(this))}async _fromReadableStream(e,t){let n=t?.signal,r;n&&(n.aborted&&this.controller.abort(),r=this.controller.abort.bind(this.controller),n.addEventListener(`abort`,r));try{g(this,I,`m`,gr).call(this),this._connected(null);let t=Ut.fromReadableStream(e,this.controller);for await(let e of t)g(this,I,`m`,_r).call(this,e);if(t.controller.signal?.aborted)throw new b;g(this,I,`m`,vr).call(this)}finally{n&&r&&n.removeEventListener(`abort`,r)}}[(L=new WeakMap,er=new WeakMap,tr=new WeakMap,nr=new WeakMap,rr=new WeakMap,ir=new WeakMap,ar=new WeakMap,or=new WeakMap,R=new WeakMap,sr=new WeakMap,cr=new WeakMap,lr=new WeakMap,z=new WeakMap,ur=new WeakMap,dr=new WeakMap,fr=new WeakMap,hr=new WeakMap,I=new WeakSet,pr=function(){if(this.receivedMessages.length===0)throw new v(`stream ended without producing a Message with role=assistant`);return this.receivedMessages.at(-1)},mr=function(){if(this.receivedMessages.length===0)throw new v(`stream ended without producing a Message with role=assistant`);let e=this.receivedMessages.at(-1).content.filter(e=>e.type===`text`).map(e=>e.text);if(e.length===0)throw new v(`stream ended without producing a content block with type=text`);return e.join(` `)},gr=function(){this.ended||h(this,L,void 0,`f`)},_r=function(e){if(this.ended)return;let t=g(this,I,`m`,yr).call(this,e);switch(this._emit(`streamEvent`,e,t),e.type){case`content_block_delta`:{let n=t.content.at(-1);switch(e.delta.type){case`text_delta`:n.type===`text`&&this._emit(`text`,e.delta.text,n.text||``);break;case`citations_delta`:n.type===`text`&&this._emit(`citation`,e.delta.citation,n.citations??[]);break;case`input_json_delta`:$n(n)&&n.input&&this._emit(`inputJson`,e.delta.partial_json,n.input);break;case`thinking_delta`:n.type===`thinking`&&this._emit(`thinking`,e.delta.thinking,n.thinking);break;case`signature_delta`:n.type===`thinking`&&this._emit(`signature`,n.signature);break;case`compaction_delta`:n.type===`compaction`&&n.content&&this._emit(`compaction`,n.content);break;default:e.delta}break}case`message_stop`:this._addMessageParam(t),this._addMessage(Hn(t,g(this,er,`f`),{logger:g(this,fr,`f`)}),!0);break;case`content_block_stop`:this._emit(`contentBlock`,t.content.at(-1));break;case`message_start`:h(this,L,t,`f`);break;case`content_block_start`:case`message_delta`:break}},vr=function(){if(this.ended)throw new v(`stream has ended, this shouldn't happen`);let e=g(this,L,`f`);if(!e)throw new v(`request ended without sending any chunks`);return h(this,L,void 0,`f`),Hn(e,g(this,er,`f`),{logger:g(this,fr,`f`)})},yr=function(e){let t=g(this,L,`f`);if(e.type===`message_start`){if(t)throw new v(`Unexpected event order, got ${e.type} before receiving "message_stop"`);return e.message}if(!t)throw new v(`Unexpected event order, got ${e.type} before "message_start"`);switch(e.type){case`message_stop`:return t;case`message_delta`:return t.container=e.delta.container,t.stop_reason=e.delta.stop_reason,t.stop_sequence=e.delta.stop_sequence,t.usage.output_tokens=e.usage.output_tokens,t.context_management=e.context_management,e.usage.input_tokens!=null&&(t.usage.input_tokens=e.usage.input_tokens),e.usage.cache_creation_input_tokens!=null&&(t.usage.cache_creation_input_tokens=e.usage.cache_creation_input_tokens),e.usage.cache_read_input_tokens!=null&&(t.usage.cache_read_input_tokens=e.usage.cache_read_input_tokens),e.usage.server_tool_use!=null&&(t.usage.server_tool_use=e.usage.server_tool_use),e.usage.iterations!=null&&(t.usage.iterations=e.usage.iterations),t;case`content_block_start`:return t.content.push(e.content_block),t;case`content_block_delta`:{let n=t.content.at(e.index);switch(e.delta.type){case`text_delta`:n?.type===`text`&&(t.content[e.index]={...n,text:(n.text||``)+e.delta.text});break;case`citations_delta`:n?.type===`text`&&(t.content[e.index]={...n,citations:[...n.citations??[],e.delta.citation]});break;case`input_json_delta`:if(n&&$n(n)){let r=n[br]||``;r+=e.delta.partial_json;let i={...n};if(Object.defineProperty(i,br,{value:r,enumerable:!1,writable:!0}),r)try{i.input=Xn(r)}catch(e){let t=new v(`Unable to parse tool parameter JSON from model. Please retry your request or adjust your prompt. Error: ${e}. JSON: ${r}`);g(this,hr,`f`).call(this,t)}t.content[e.index]=i}break;case`thinking_delta`:n?.type===`thinking`&&(t.content[e.index]={...n,thinking:n.thinking+e.delta.thinking});break;case`signature_delta`:n?.type===`thinking`&&(t.content[e.index]={...n,signature:e.delta.signature});break;case`compaction_delta`:n?.type===`compaction`&&(t.content[e.index]={...n,content:(n.content||``)+e.delta.content});break;default:e.delta}return t}case`content_block_stop`:return t}},Symbol.asyncIterator)](){let e=[],t=[],n=!1;return this.on(`streamEvent`,n=>{let r=t.shift();r?r.resolve(n):e.push(n)}),this.on(`end`,()=>{n=!0;for(let e of t)e.resolve(void 0);t.length=0}),this.on(`abort`,e=>{n=!0;for(let n of t)n.reject(e);t.length=0}),this.on(`error`,e=>{n=!0;for(let n of t)n.reject(e);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:n?{value:void 0,done:!0}:new Promise((e,n)=>t.push({resolve:e,reject:n})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new Ut(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}})),Cr,wr=e((()=>{Cr=class extends Error{constructor(e){let t=typeof e==`string`?e:e.map(e=>e.type===`text`?e.text:`[${e.type}]`).join(` `);super(t),this.name=`ToolError`,this.content=e}}})),Tr,Er=e((()=>{Tr=`You have been working on the task described above but have not yet completed it. Write a continuation summary that will allow you (or another instance of yourself) to resume work efficiently in a future context window where the conversation history will be replaced with this summary. Your summary should be structured, concise, and actionable. Include:
7
+ 1. Task Overview
8
+ The user's core request and success criteria
9
+ Any clarifications or constraints they specified
10
+ 2. Current State
11
+ What has been completed so far
12
+ Files created, modified, or analyzed (with paths if relevant)
13
+ Key outputs or artifacts produced
14
+ 3. Important Discoveries
15
+ Technical constraints or requirements uncovered
16
+ Decisions made and their rationale
17
+ Errors encountered and how they were resolved
18
+ What approaches were tried that didn't work (and why)
19
+ 4. Next Steps
20
+ Specific actions needed to complete the task
21
+ Any blockers or open questions to resolve
22
+ Priority order if multiple steps remain
23
+ 5. Context to Preserve
24
+ User preferences or style requirements
25
+ Domain-specific details that aren't obvious
26
+ Any promises made to the user
27
+ Be concise but complete—err on the side of including information that would prevent duplicate work or repeated mistakes. Write in a way that enables immediate resumption of the task.
28
+ Wrap your summary in <summary></summary> tags.`}));function Dr(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}async function Or(e,t=e.messages.at(-1)){if(!t||t.role!==`assistant`||!t.content||typeof t.content==`string`)return null;let n=t.content.filter(e=>e.type===`tool_use`);return n.length===0?null:{role:`user`,content:await Promise.all(n.map(async t=>{let n=e.tools.find(e=>(`name`in e?e.name:e.mcp_server_name)===t.name);if(!n||!(`run`in n))return{type:`tool_result`,tool_use_id:t.id,content:`Error: Tool '${t.name}' not found`,is_error:!0};try{let e=t.input;`parse`in n&&n.parse&&(e=n.parse(e));let r=await n.run(e);return{type:`tool_result`,tool_use_id:t.id,content:r}}catch(e){return{type:`tool_result`,tool_use_id:t.id,content:e instanceof Cr?e.content:`Error: ${e instanceof Error?e.message:String(e)}`,is_error:!0}}}))}}var kr,B,V,H,Ar,U,W,G,jr,Mr,Nr,Pr,Fr=e((()=>{_(),wr(),S(),N(),Er(),An(),Pr=class{constructor(e,t,n){kr.add(this),this.client=e,B.set(this,!1),V.set(this,!1),H.set(this,void 0),Ar.set(this,void 0),U.set(this,void 0),W.set(this,void 0),G.set(this,void 0),jr.set(this,0),h(this,H,{params:{...t,messages:structuredClone(t.messages)}},`f`);let r=[`BetaToolRunner`,...En(t.tools,t.messages)].join(`, `);h(this,Ar,{...n,headers:M([{"x-stainless-helper":r},n?.headers])},`f`),h(this,G,Dr(),`f`)}async*[(B=new WeakMap,V=new WeakMap,H=new WeakMap,Ar=new WeakMap,U=new WeakMap,W=new WeakMap,G=new WeakMap,jr=new WeakMap,kr=new WeakSet,Mr=async function(){let e=g(this,H,`f`).params.compactionControl;if(!e||!e.enabled)return!1;let t=0;if(g(this,U,`f`)!==void 0)try{let e=await g(this,U,`f`);t=e.usage.input_tokens+(e.usage.cache_creation_input_tokens??0)+(e.usage.cache_read_input_tokens??0)+e.usage.output_tokens}catch{return!1}let n=e.contextTokenThreshold??1e5;if(t<n)return!1;let r=e.model??g(this,H,`f`).params.model,i=e.summaryPrompt??Tr,a=g(this,H,`f`).params.messages;if(a[a.length-1].role===`assistant`){let e=a[a.length-1];if(Array.isArray(e.content)){let t=e.content.filter(e=>e.type!==`tool_use`);t.length===0?a.pop():e.content=t}}let o=await this.client.beta.messages.create({model:r,messages:[...a,{role:`user`,content:[{type:`text`,text:i}]}],max_tokens:g(this,H,`f`).params.max_tokens},{headers:{"x-stainless-helper":`compaction`}});if(o.content[0]?.type!==`text`)throw new v(`Expected text response for compaction`);return g(this,H,`f`).params.messages=[{role:`user`,content:o.content}],!0},Symbol.asyncIterator)](){var e;if(g(this,B,`f`))throw new v(`Cannot iterate over a consumed stream`);h(this,B,!0,`f`),h(this,V,!0,`f`),h(this,W,void 0,`f`);try{for(;;){let t;try{if(g(this,H,`f`).params.max_iterations&&g(this,jr,`f`)>=g(this,H,`f`).params.max_iterations)break;h(this,V,!1,`f`),h(this,W,void 0,`f`),h(this,jr,(e=g(this,jr,`f`),e++,e),`f`),h(this,U,void 0,`f`);let{max_iterations:n,compactionControl:r,...i}=g(this,H,`f`).params;if(i.stream?(t=this.client.beta.messages.stream({...i},g(this,Ar,`f`)),h(this,U,t.finalMessage(),`f`),g(this,U,`f`).catch(()=>{}),yield t):(h(this,U,this.client.beta.messages.create({...i,stream:!1},g(this,Ar,`f`)),`f`),yield g(this,U,`f`)),!await g(this,kr,`m`,Mr).call(this)){if(!g(this,V,`f`)){let{role:e,content:t}=await g(this,U,`f`);g(this,H,`f`).params.messages.push({role:e,content:t})}let e=await g(this,kr,`m`,Nr).call(this,g(this,H,`f`).params.messages.at(-1));if(e)g(this,H,`f`).params.messages.push(e);else if(!g(this,V,`f`))break}}finally{t&&t.abort()}}if(!g(this,U,`f`))throw new v(`ToolRunner concluded without a message from the server`);g(this,G,`f`).resolve(await g(this,U,`f`))}catch(e){throw h(this,B,!1,`f`),g(this,G,`f`).promise.catch(()=>{}),g(this,G,`f`).reject(e),h(this,G,Dr(),`f`),e}}setMessagesParams(e){typeof e==`function`?g(this,H,`f`).params=e(g(this,H,`f`).params):g(this,H,`f`).params=e,h(this,V,!0,`f`),h(this,W,void 0,`f`)}async generateToolResponse(){let e=await g(this,U,`f`)??this.params.messages.at(-1);return e?g(this,kr,`m`,Nr).call(this,e):null}done(){return g(this,G,`f`).promise}async runUntilDone(){if(!g(this,B,`f`))for await(let e of this);return this.done()}get params(){return g(this,H,`f`).params}pushMessages(...e){this.setMessagesParams(t=>({...t,messages:[...t.messages,...e]}))}then(e,t){return this.runUntilDone().then(e,t)}},Nr=async function(e){return g(this,W,`f`)===void 0&&h(this,W,Or(g(this,H,`f`).params,e),`f`),g(this,W,`f`)}})),Ir,Lr=e((()=>{S(),_t(),jt(),Ir=class e{constructor(e,t){this.iterator=e,this.controller=t}async*decoder(){let e=new At;for await(let t of this.iterator)for(let n of e.decode(t))yield JSON.parse(n);for(let t of e.flush())yield JSON.parse(t)}[Symbol.asyncIterator](){return this.decoder()}static fromResponse(t,n){if(!t.body)throw n.abort(),globalThis.navigator!==void 0&&globalThis.navigator.product===`ReactNative`?new v(`The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api`):new v(`Attempted to iterate over a response with no body`);return new e(ht(t.body),n)}}})),Rr,zr=e((()=>{j(),O(),N(),Lr(),Rn(),F(),Rr=class extends A{create(e,t){let{betas:n,...r}=e;return this._client.post(`/v1/messages/batches?beta=true`,{body:r,...t,headers:M([{"anthropic-beta":[...n??[],`message-batches-2024-09-24`].toString()},t?.headers])})}retrieve(e,t={},n){let{betas:r}=t??{};return this._client.get(P`/v1/messages/batches/${e}?beta=true`,{...n,headers:M([{"anthropic-beta":[...r??[],`message-batches-2024-09-24`].toString()},n?.headers])})}list(e={},t){let{betas:n,...r}=e??{};return this._client.getAPIList(`/v1/messages/batches?beta=true`,tn,{query:r,...t,headers:M([{"anthropic-beta":[...n??[],`message-batches-2024-09-24`].toString()},t?.headers])})}delete(e,t={},n){let{betas:r}=t??{};return this._client.delete(P`/v1/messages/batches/${e}?beta=true`,{...n,headers:M([{"anthropic-beta":[...r??[],`message-batches-2024-09-24`].toString()},n?.headers])})}cancel(e,t={},n){let{betas:r}=t??{};return this._client.post(P`/v1/messages/batches/${e}/cancel?beta=true`,{...n,headers:M([{"anthropic-beta":[...r??[],`message-batches-2024-09-24`].toString()},n?.headers])})}async results(e,t={},n){let r=await this.retrieve(e);if(!r.results_url)throw new v(`No batch \`results_url\`; Has it finished processing? ${r.processing_status} - ${r.id}`);let{betas:i}=t??{};return this._client.get(r.results_url,{...n,headers:M([{"anthropic-beta":[...i??[],`message-batches-2024-09-24`].toString(),Accept:`application/binary`},n?.headers]),stream:!0,__binaryResponse:!0})._thenUnwrap((e,t)=>Ir.fromResponse(t.response,t.controller))}}}));function Br(e){if(!e.output_format)return e;if(e.output_config?.format)throw new v(`Both output_format and output_config.format were provided. Please use only output_config.format (output_format is deprecated).`);let{output_format:t,...n}=e;return{...n,output_config:{...e.output_config,format:t}}}var Vr,Hr,Ur,Wr=e((()=>{Rn(),j(),Bn(),N(),An(),Gn(),Sr(),Fr(),wr(),zr(),Vr={"claude-1.3":`November 6th, 2024`,"claude-1.3-100k":`November 6th, 2024`,"claude-instant-1.1":`November 6th, 2024`,"claude-instant-1.1-100k":`November 6th, 2024`,"claude-instant-1.2":`November 6th, 2024`,"claude-3-sonnet-20240229":`July 21st, 2025`,"claude-3-opus-20240229":`January 5th, 2026`,"claude-2.1":`July 21st, 2025`,"claude-2.0":`July 21st, 2025`,"claude-3-7-sonnet-latest":`February 19th, 2026`,"claude-3-7-sonnet-20250219":`February 19th, 2026`},Hr=[`claude-opus-4-6`],Ur=class extends A{constructor(){super(...arguments),this.batches=new Rr(this._client)}create(e,t){let n=Br(e),{betas:r,...i}=n;i.model in Vr&&console.warn(`The model '${i.model}' is deprecated and will reach end-of-life on ${Vr[i.model]}\nPlease migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`),i.model in Hr&&i.thinking&&i.thinking.type===`enabled`&&console.warn(`Using Claude with ${i.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking`);let a=this._client._options.timeout;if(!i.stream&&a==null){let e=zn[i.model]??void 0;a=this._client.calculateNonstreamingTimeout(i.max_tokens,e)}let o=Dn(i.tools,i.messages);return this._client.post(`/v1/messages?beta=true`,{body:i,timeout:a??6e5,...t,headers:M([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()}},o,t?.headers]),stream:n.stream??!1})}parse(e,t){return t={...t,headers:M([{"anthropic-beta":[...e.betas??[],`structured-outputs-2025-12-15`].toString()},t?.headers])},this.create(e,t).then(t=>Un(t,e,{logger:this._client.logger??console}))}stream(e,t){return xr.createMessage(this,e,t)}countTokens(e,t){let{betas:n,...r}=Br(e);return this._client.post(`/v1/messages/count_tokens?beta=true`,{body:r,...t,headers:M([{"anthropic-beta":[...n??[],`token-counting-2024-11-01`].toString()},t?.headers])})}toolRunner(e,t){return new Pr(this._client,e,t)}},Ur.Batches=Rr,Ur.BetaToolRunner=Pr,Ur.ToolError=Cr})),Gr,Kr=e((()=>{j(),O(),N(),pn(),F(),Gr=class extends A{create(e,t={},n){let{betas:r,...i}=t??{};return this._client.post(P`/v1/skills/${e}/versions?beta=true`,cn({body:i,...n,headers:M([{"anthropic-beta":[...r??[],`skills-2025-10-02`].toString()},n?.headers])},this._client))}retrieve(e,t,n){let{skill_id:r,betas:i}=t;return this._client.get(P`/v1/skills/${r}/versions/${e}?beta=true`,{...n,headers:M([{"anthropic-beta":[...i??[],`skills-2025-10-02`].toString()},n?.headers])})}list(e,t={},n){let{betas:r,...i}=t??{};return this._client.getAPIList(P`/v1/skills/${e}/versions?beta=true`,nn,{query:i,...n,headers:M([{"anthropic-beta":[...r??[],`skills-2025-10-02`].toString()},n?.headers])})}delete(e,t,n){let{skill_id:r,betas:i}=t;return this._client.delete(P`/v1/skills/${r}/versions/${e}?beta=true`,{...n,headers:M([{"anthropic-beta":[...i??[],`skills-2025-10-02`].toString()},n?.headers])})}}})),qr,Jr=e((()=>{j(),Kr(),O(),N(),pn(),F(),qr=class extends A{constructor(){super(...arguments),this.versions=new Gr(this._client)}create(e={},t){let{betas:n,...r}=e??{};return this._client.post(`/v1/skills?beta=true`,cn({body:r,...t,headers:M([{"anthropic-beta":[...n??[],`skills-2025-10-02`].toString()},t?.headers])},this._client,!1))}retrieve(e,t={},n){let{betas:r}=t??{};return this._client.get(P`/v1/skills/${e}?beta=true`,{...n,headers:M([{"anthropic-beta":[...r??[],`skills-2025-10-02`].toString()},n?.headers])})}list(e={},t){let{betas:n,...r}=e??{};return this._client.getAPIList(`/v1/skills?beta=true`,nn,{query:r,...t,headers:M([{"anthropic-beta":[...n??[],`skills-2025-10-02`].toString()},t?.headers])})}delete(e,t={},n){let{betas:r}=t??{};return this._client.delete(P`/v1/skills/${e}?beta=true`,{...n,headers:M([{"anthropic-beta":[...r??[],`skills-2025-10-02`].toString()},n?.headers])})}},qr.Versions=Gr})),K,Yr=e((()=>{j(),Fn(),Ln(),Wr(),Jr(),K=class extends A{constructor(){super(...arguments),this.models=new In(this._client),this.messages=new Ur(this._client),this.files=new Pn(this._client),this.skills=new qr(this._client)}},K.Models=In,K.Messages=Ur,K.Files=Pn,K.Skills=qr})),Xr,Zr=e((()=>{j(),N(),Xr=class extends A{create(e,t){let{betas:n,...r}=e;return this._client.post(`/v1/complete`,{body:r,timeout:this._client._options.timeout??6e5,...t,headers:M([{...n?.toString()==null?void 0:{"anthropic-beta":n?.toString()}},t?.headers]),stream:e.stream??!1})}}}));function Qr(e){return e?.output_config?.format}function $r(e,t,n){let r=Qr(t);return!t||!(`parse`in(r??{}))?{...e,content:e.content.map(e=>e.type===`text`?Object.defineProperty({...e},"parsed_output",{value:null,enumerable:!1}):e),parsed_output:null}:ei(e,t,n)}function ei(e,t,n){let r=null,i=e.content.map(e=>{if(e.type===`text`){let n=ti(t,e.text);return r===null&&(r=n),Object.defineProperty({...e},"parsed_output",{value:n,enumerable:!1})}return e});return{...e,content:i,parsed_output:r}}function ti(e,t){let n=Qr(e);if(n?.type!==`json_schema`)return null;try{return`parse`in n?n.parse(t):JSON.parse(t)}catch(e){throw new v(`Failed to parse structured output: ${e}`)}}var ni=e((()=>{S()}));function ri(e){return e.type===`tool_use`||e.type===`server_tool_use`}var q,J,ii,ai,oi,si,ci,li,ui,Y,di,fi,pi,X,mi,hi,gi,_i,vi,yi,bi,xi,Si,Ci,wi,Ti,Ei=e((()=>{_(),Pe(),Rn(),Qn(),Zn(),ni(),wi=`__json_buf`,Ti=class e{constructor(e,t){q.add(this),this.messages=[],this.receivedMessages=[],J.set(this,void 0),ii.set(this,null),this.controller=new AbortController,ai.set(this,void 0),oi.set(this,()=>{}),si.set(this,()=>{}),ci.set(this,void 0),li.set(this,()=>{}),ui.set(this,()=>{}),Y.set(this,{}),di.set(this,!1),fi.set(this,!1),pi.set(this,!1),X.set(this,!1),mi.set(this,void 0),hi.set(this,void 0),gi.set(this,void 0),yi.set(this,e=>{if(h(this,fi,!0,`f`),Me(e)&&(e=new b),e instanceof b)return h(this,pi,!0,`f`),this._emit(`abort`,e);if(e instanceof v)return this._emit(`error`,e);if(e instanceof Error){let t=new v(e.message);return t.cause=e,this._emit(`error`,t)}return this._emit(`error`,new v(String(e)))}),h(this,ai,new Promise((e,t)=>{h(this,oi,e,`f`),h(this,si,t,`f`)}),`f`),h(this,ci,new Promise((e,t)=>{h(this,li,e,`f`),h(this,ui,t,`f`)}),`f`),g(this,ai,`f`).catch(()=>{}),g(this,ci,`f`).catch(()=>{}),h(this,ii,e,`f`),h(this,gi,t?.logger??console,`f`)}get response(){return g(this,mi,`f`)}get request_id(){return g(this,hi,`f`)}async withResponse(){h(this,X,!0,`f`);let e=await g(this,ai,`f`);if(!e)throw Error("Could not resolve a `Response` object");return{data:this,response:e,request_id:e.headers.get(`request-id`)}}static fromReadableStream(t){let n=new e(null);return n._run(()=>n._fromReadableStream(t)),n}static createMessage(t,n,r,{logger:i}={}){let a=new e(n,{logger:i});for(let e of n.messages)a._addMessageParam(e);return h(a,ii,{...n,stream:!0},`f`),a._run(()=>a._createMessage(t,{...n,stream:!0},{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":`stream`}})),a}_run(e){e().then(()=>{this._emitFinal(),this._emit(`end`)},g(this,yi,`f`))}_addMessageParam(e){this.messages.push(e)}_addMessage(e,t=!0){this.receivedMessages.push(e),t&&this._emit(`message`,e)}async _createMessage(e,t,n){let r=n?.signal,i;r&&(r.aborted&&this.controller.abort(),i=this.controller.abort.bind(this.controller),r.addEventListener(`abort`,i));try{g(this,q,`m`,bi).call(this);let{response:r,data:i}=await e.create({...t,stream:!0},{...n,signal:this.controller.signal}).withResponse();this._connected(r);for await(let e of i)g(this,q,`m`,xi).call(this,e);if(i.controller.signal?.aborted)throw new b;g(this,q,`m`,Si).call(this)}finally{r&&i&&r.removeEventListener(`abort`,i)}}_connected(e){this.ended||(h(this,mi,e,`f`),h(this,hi,e?.headers.get(`request-id`),`f`),g(this,oi,`f`).call(this,e),this._emit(`connect`))}get ended(){return g(this,di,`f`)}get errored(){return g(this,fi,`f`)}get aborted(){return g(this,pi,`f`)}abort(){this.controller.abort()}on(e,t){return(g(this,Y,`f`)[e]||(g(this,Y,`f`)[e]=[])).push({listener:t}),this}off(e,t){let n=g(this,Y,`f`)[e];if(!n)return this;let r=n.findIndex(e=>e.listener===t);return r>=0&&n.splice(r,1),this}once(e,t){return(g(this,Y,`f`)[e]||(g(this,Y,`f`)[e]=[])).push({listener:t,once:!0}),this}emitted(e){return new Promise((t,n)=>{h(this,X,!0,`f`),e!==`error`&&this.once(`error`,n),this.once(e,t)})}async done(){h(this,X,!0,`f`),await g(this,ci,`f`)}get currentMessage(){return g(this,J,`f`)}async finalMessage(){return await this.done(),g(this,q,`m`,_i).call(this)}async finalText(){return await this.done(),g(this,q,`m`,vi).call(this)}_emit(e,...t){if(g(this,di,`f`))return;e===`end`&&(h(this,di,!0,`f`),g(this,li,`f`).call(this));let n=g(this,Y,`f`)[e];if(n&&(g(this,Y,`f`)[e]=n.filter(e=>!e.once),n.forEach(({listener:e})=>e(...t))),e===`abort`){let e=t[0];!g(this,X,`f`)&&!n?.length&&Promise.reject(e),g(this,si,`f`).call(this,e),g(this,ui,`f`).call(this,e),this._emit(`end`);return}if(e===`error`){let e=t[0];!g(this,X,`f`)&&!n?.length&&Promise.reject(e),g(this,si,`f`).call(this,e),g(this,ui,`f`).call(this,e),this._emit(`end`)}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit(`finalMessage`,g(this,q,`m`,_i).call(this))}async _fromReadableStream(e,t){let n=t?.signal,r;n&&(n.aborted&&this.controller.abort(),r=this.controller.abort.bind(this.controller),n.addEventListener(`abort`,r));try{g(this,q,`m`,bi).call(this),this._connected(null);let t=Ut.fromReadableStream(e,this.controller);for await(let e of t)g(this,q,`m`,xi).call(this,e);if(t.controller.signal?.aborted)throw new b;g(this,q,`m`,Si).call(this)}finally{n&&r&&n.removeEventListener(`abort`,r)}}[(J=new WeakMap,ii=new WeakMap,ai=new WeakMap,oi=new WeakMap,si=new WeakMap,ci=new WeakMap,li=new WeakMap,ui=new WeakMap,Y=new WeakMap,di=new WeakMap,fi=new WeakMap,pi=new WeakMap,X=new WeakMap,mi=new WeakMap,hi=new WeakMap,gi=new WeakMap,yi=new WeakMap,q=new WeakSet,_i=function(){if(this.receivedMessages.length===0)throw new v(`stream ended without producing a Message with role=assistant`);return this.receivedMessages.at(-1)},vi=function(){if(this.receivedMessages.length===0)throw new v(`stream ended without producing a Message with role=assistant`);let e=this.receivedMessages.at(-1).content.filter(e=>e.type===`text`).map(e=>e.text);if(e.length===0)throw new v(`stream ended without producing a content block with type=text`);return e.join(` `)},bi=function(){this.ended||h(this,J,void 0,`f`)},xi=function(e){if(this.ended)return;let t=g(this,q,`m`,Ci).call(this,e);switch(this._emit(`streamEvent`,e,t),e.type){case`content_block_delta`:{let n=t.content.at(-1);switch(e.delta.type){case`text_delta`:n.type===`text`&&this._emit(`text`,e.delta.text,n.text||``);break;case`citations_delta`:n.type===`text`&&this._emit(`citation`,e.delta.citation,n.citations??[]);break;case`input_json_delta`:ri(n)&&n.input&&this._emit(`inputJson`,e.delta.partial_json,n.input);break;case`thinking_delta`:n.type===`thinking`&&this._emit(`thinking`,e.delta.thinking,n.thinking);break;case`signature_delta`:n.type===`thinking`&&this._emit(`signature`,n.signature);break;default:e.delta}break}case`message_stop`:this._addMessageParam(t),this._addMessage($r(t,g(this,ii,`f`),{logger:g(this,gi,`f`)}),!0);break;case`content_block_stop`:this._emit(`contentBlock`,t.content.at(-1));break;case`message_start`:h(this,J,t,`f`);break;case`content_block_start`:case`message_delta`:break}},Si=function(){if(this.ended)throw new v(`stream has ended, this shouldn't happen`);let e=g(this,J,`f`);if(!e)throw new v(`request ended without sending any chunks`);return h(this,J,void 0,`f`),$r(e,g(this,ii,`f`),{logger:g(this,gi,`f`)})},Ci=function(e){let t=g(this,J,`f`);if(e.type===`message_start`){if(t)throw new v(`Unexpected event order, got ${e.type} before receiving "message_stop"`);return e.message}if(!t)throw new v(`Unexpected event order, got ${e.type} before "message_start"`);switch(e.type){case`message_stop`:return t;case`message_delta`:return t.stop_reason=e.delta.stop_reason,t.stop_sequence=e.delta.stop_sequence,t.usage.output_tokens=e.usage.output_tokens,e.usage.input_tokens!=null&&(t.usage.input_tokens=e.usage.input_tokens),e.usage.cache_creation_input_tokens!=null&&(t.usage.cache_creation_input_tokens=e.usage.cache_creation_input_tokens),e.usage.cache_read_input_tokens!=null&&(t.usage.cache_read_input_tokens=e.usage.cache_read_input_tokens),e.usage.server_tool_use!=null&&(t.usage.server_tool_use=e.usage.server_tool_use),t;case`content_block_start`:return t.content.push({...e.content_block}),t;case`content_block_delta`:{let n=t.content.at(e.index);switch(e.delta.type){case`text_delta`:n?.type===`text`&&(t.content[e.index]={...n,text:(n.text||``)+e.delta.text});break;case`citations_delta`:n?.type===`text`&&(t.content[e.index]={...n,citations:[...n.citations??[],e.delta.citation]});break;case`input_json_delta`:if(n&&ri(n)){let r=n[wi]||``;r+=e.delta.partial_json;let i={...n};Object.defineProperty(i,wi,{value:r,enumerable:!1,writable:!0}),r&&(i.input=Xn(r)),t.content[e.index]=i}break;case`thinking_delta`:n?.type===`thinking`&&(t.content[e.index]={...n,thinking:n.thinking+e.delta.thinking});break;case`signature_delta`:n?.type===`thinking`&&(t.content[e.index]={...n,signature:e.delta.signature});break;default:e.delta}return t}case`content_block_stop`:return t}},Symbol.asyncIterator)](){let e=[],t=[],n=!1;return this.on(`streamEvent`,n=>{let r=t.shift();r?r.resolve(n):e.push(n)}),this.on(`end`,()=>{n=!0;for(let e of t)e.resolve(void 0);t.length=0}),this.on(`abort`,e=>{n=!0;for(let n of t)n.reject(e);t.length=0}),this.on(`error`,e=>{n=!0;for(let n of t)n.reject(e);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:n?{value:void 0,done:!0}:new Promise((e,n)=>t.push({resolve:e,reject:n})).then(e=>e?{value:e,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new Ut(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}})),Di,Oi=e((()=>{j(),O(),N(),Lr(),Rn(),F(),Di=class extends A{create(e,t){return this._client.post(`/v1/messages/batches`,{body:e,...t})}retrieve(e,t){return this._client.get(P`/v1/messages/batches/${e}`,t)}list(e={},t){return this._client.getAPIList(`/v1/messages/batches`,tn,{query:e,...t})}delete(e,t){return this._client.delete(P`/v1/messages/batches/${e}`,t)}cancel(e,t){return this._client.post(P`/v1/messages/batches/${e}/cancel`,t)}async results(e,t){let n=await this.retrieve(e);if(!n.results_url)throw new v(`No batch \`results_url\`; Has it finished processing? ${n.processing_status} - ${n.id}`);return this._client.get(n.results_url,{...t,headers:M([{Accept:`application/binary`},t?.headers]),stream:!0,__binaryResponse:!0})._thenUnwrap((e,t)=>Ir.fromResponse(t.response,t.controller))}}})),ki,Ai,ji,Mi=e((()=>{j(),N(),An(),Ei(),ni(),Oi(),Bn(),ki=class extends A{constructor(){super(...arguments),this.batches=new Di(this._client)}create(e,t){e.model in Ai&&console.warn(`The model '${e.model}' is deprecated and will reach end-of-life on ${Ai[e.model]}\nPlease migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`),e.model in ji&&e.thinking&&e.thinking.type===`enabled`&&console.warn(`Using Claude with ${e.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking`);let n=this._client._options.timeout;if(!e.stream&&n==null){let t=zn[e.model]??void 0;n=this._client.calculateNonstreamingTimeout(e.max_tokens,t)}let r=Dn(e.tools,e.messages);return this._client.post(`/v1/messages`,{body:e,timeout:n??6e5,...t,headers:M([r,t?.headers]),stream:e.stream??!1})}parse(e,t){return this.create(e,t).then(t=>ei(t,e,{logger:this._client.logger??console}))}stream(e,t){return Ti.createMessage(this,e,t,{logger:this._client.logger??console})}countTokens(e,t){return this._client.post(`/v1/messages/count_tokens`,{body:e,...t})}},Ai={"claude-1.3":`November 6th, 2024`,"claude-1.3-100k":`November 6th, 2024`,"claude-instant-1.1":`November 6th, 2024`,"claude-instant-1.1-100k":`November 6th, 2024`,"claude-instant-1.2":`November 6th, 2024`,"claude-3-sonnet-20240229":`July 21st, 2025`,"claude-3-opus-20240229":`January 5th, 2026`,"claude-2.1":`July 21st, 2025`,"claude-2.0":`July 21st, 2025`,"claude-3-7-sonnet-latest":`February 19th, 2026`,"claude-3-7-sonnet-20250219":`February 19th, 2026`,"claude-3-5-haiku-latest":`February 19th, 2026`,"claude-3-5-haiku-20241022":`February 19th, 2026`},ji=[`claude-opus-4-6`],ki.Batches=Di})),Ni,Pi=e((()=>{j(),O(),N(),F(),Ni=class extends A{retrieve(e,t={},n){let{betas:r}=t??{};return this._client.get(P`/v1/models/${e}`,{...n,headers:M([{...r?.toString()==null?void 0:{"anthropic-beta":r?.toString()}},n?.headers])})}list(e={},t){let{betas:n,...r}=e??{};return this._client.getAPIList(`/v1/models`,tn,{query:r,...t,headers:M([{...n?.toString()==null?void 0:{"anthropic-beta":n?.toString()}},t?.headers])})}}})),Fi=e((()=>{Sn(),Yr(),Zr(),Mi(),Pi()})),Ii,Li=e((()=>{Ii=e=>{if(globalThis.process!==void 0)return globalThis.process.env?.[e]?.trim()??void 0;if(globalThis.Deno!==void 0)return globalThis.Deno.env?.get?.(e)?.trim()}})),Ri,zi,Bi,Vi,Hi,Ui,Z,Wi,Gi=e((()=>{_(),je(),$e(),tt(),Pe(),dt(),_t(),yt(),xt(),nt(),S(),O(),xn(),Fi(),Zt(),Zr(),Pi(),Yr(),Mi(),N(),Li(),Rt(),Hi=`\\n\\nHuman:`,Ui=`\\n\\nAssistant:`,Z=class{constructor({baseURL:e=Ii(`ANTHROPIC_BASE_URL`),apiKey:t=Ii(`ANTHROPIC_API_KEY`)??null,authToken:n=Ii(`ANTHROPIC_AUTH_TOKEN`)??null,...r}={}){Ri.add(this),Bi.set(this,void 0);let i={apiKey:t,authToken:n,...r,baseURL:e||`https://api.anthropic.com`};if(!i.dangerouslyAllowBrowser&&at())throw new v(`It looks like you're running in a browser-like environment.
29
+
30
+ This is disabled by default, as it risks exposing your secret API credentials to attackers.
31
+ If you understand the risks and have appropriate mitigations in place,
32
+ you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
33
+
34
+ new Anthropic({ apiKey, dangerouslyAllowBrowser: true });
35
+ `);this.baseURL=i.baseURL,this.timeout=i.timeout??zi.DEFAULT_TIMEOUT,this.logger=i.logger??console;let a=`warn`;this.logLevel=a,this.logLevel=Ft(i.logLevel,`ClientOptions.logLevel`,this)??Ft(Ii(`ANTHROPIC_LOG`),`process.env['ANTHROPIC_LOG']`,this)??a,this.fetchOptions=i.fetchOptions,this.maxRetries=i.maxRetries??2,this.fetch=i.fetch??ft(),h(this,Bi,vt,`f`),this._options=i,this.apiKey=typeof t==`string`?t:null,this.authToken=n}withOptions(e){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,authToken:this.authToken,...e})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:t}){if(!(e.get(`x-api-key`)||e.get(`authorization`))&&!(this.apiKey&&e.get(`x-api-key`))&&!t.has(`x-api-key`)&&!(this.authToken&&e.get(`authorization`))&&!t.has(`authorization`))throw Error(`Could not resolve authentication method. Expected either apiKey or authToken to be set. Or for one of the "X-Api-Key" or "Authorization" headers to be explicitly omitted`)}async authHeaders(e){return M([await this.apiKeyAuth(e),await this.bearerAuth(e)])}async apiKeyAuth(e){if(this.apiKey!=null)return M([{"X-Api-Key":this.apiKey}])}async bearerAuth(e){if(this.authToken!=null)return M([{Authorization:`Bearer ${this.authToken}`}])}stringifyQuery(e){return bt(e)}getUserAgent(){return`${this.constructor.name}/JS ${C}`}defaultIdempotencyKey(){return`stainless-node-retry-${Ae()}`}makeStatusError(e,t,n,r){return y.generate(e,t,n,r)}buildURL(e,t,n){let r=!g(this,Ri,`m`,Vi).call(this)&&n||this.baseURL,i=Je(e)?new URL(e):new URL(r+(r.endsWith(`/`)&&e.startsWith(`/`)?e.slice(1):e)),a=this.defaultQuery(),o=Object.fromEntries(i.searchParams);return(!Ge(a)||!Ge(o))&&(t={...o,...a,...t}),typeof t==`object`&&t&&!Array.isArray(t)&&(i.search=this.stringifyQuery(t)),i.toString()}_calculateNonstreamingTimeout(e){if(3600*e/128e3>600)throw new v(`Streaming is required for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-typescript#streaming-responses for more details`);return 600*1e3}async prepareOptions(e){}async prepareRequest(e,{url:t,options:n}){}get(e,t){return this.methodRequest(`get`,e,t)}post(e,t){return this.methodRequest(`post`,e,t)}patch(e,t){return this.methodRequest(`patch`,e,t)}put(e,t){return this.methodRequest(`put`,e,t)}delete(e,t){return this.methodRequest(`delete`,e,t)}methodRequest(e,t,n){return this.request(Promise.resolve(n).then(n=>({method:e,path:t,...n})))}request(e,t=null){return new Xt(this,this.makeRequest(e,t,void 0))}async makeRequest(e,t,n){let r=await e,i=r.maxRetries??this.maxRetries;t??(t=i),await this.prepareOptions(r);let{req:a,url:o,timeout:s}=await this.buildRequest(r,{retryCount:i-t});await this.prepareRequest(a,{url:o,options:r});let c=`log_`+(Math.random()*(1<<24)|0).toString(16).padStart(6,`0`),l=n===void 0?``:`, retryOf: ${n}`,u=Date.now();if(E(this).debug(`[${c}] sending request`,D({retryOfRequestLogID:n,method:r.method,url:o,options:r,headers:a.headers})),r.signal?.aborted)throw new b;let ee=new AbortController,d=await this.fetchWithTimeout(o,a,s,ee).catch(Ne),f=Date.now();if(d instanceof globalThis.Error){let e=`retrying, ${t} attempts remaining`;if(r.signal?.aborted)throw new b;let i=Me(d)||/timed? ?out/i.test(String(d)+(`cause`in d?String(d.cause):``));if(t)return E(this).info(`[${c}] connection ${i?`timed out`:`failed`} - ${e}`),E(this).debug(`[${c}] connection ${i?`timed out`:`failed`} (${e})`,D({retryOfRequestLogID:n,url:o,durationMs:f-u,message:d.message})),this.retryRequest(r,t,n??c);throw E(this).info(`[${c}] connection ${i?`timed out`:`failed`} - error; no more retries left`),E(this).debug(`[${c}] connection ${i?`timed out`:`failed`} (error; no more retries left)`,D({retryOfRequestLogID:n,url:o,durationMs:f-u,message:d.message})),i?new Fe:new x({cause:d})}let p=`[${c}${l}${[...d.headers.entries()].filter(([e])=>e===`request-id`).map(([e,t])=>`, `+e+`: `+JSON.stringify(t)).join(``)}] ${a.method} ${o} ${d.ok?`succeeded`:`failed`} with status ${d.status} in ${f-u}ms`;if(!d.ok){let e=await this.shouldRetry(d);if(t&&e){let e=`retrying, ${t} attempts remaining`;return await gt(d.body),E(this).info(`${p} - ${e}`),E(this).debug(`[${c}] response error (${e})`,D({retryOfRequestLogID:n,url:d.url,status:d.status,headers:d.headers,durationMs:f-u})),this.retryRequest(r,t,n??c,d.headers)}let i=e?`error; no more retries left`:`error; not retryable`;E(this).info(`${p} - ${i}`);let a=await d.text().catch(e=>Ne(e).message),o=Qe(a),s=o?void 0:a;throw E(this).debug(`[${c}] response error (${i})`,D({retryOfRequestLogID:n,url:d.url,status:d.status,headers:d.headers,message:s,durationMs:Date.now()-u})),this.makeStatusError(d.status,o,s,d.headers)}return E(this).info(p),E(this).debug(`[${c}] response start`,D({retryOfRequestLogID:n,url:d.url,status:d.status,headers:d.headers,durationMs:f-u})),{response:d,options:r,controller:ee,requestLogID:c,retryOfRequestLogID:n,startTime:u}}getAPIList(e,t,n){return this.requestAPIList(t,n&&`then`in n?n.then(t=>({method:`get`,path:e,...t})):{method:`get`,path:e,...n})}requestAPIList(e,t){let n=this.makeRequest(t,null,void 0);return new en(this,n,e)}async fetchWithTimeout(e,t,n,r){let{signal:i,method:a,...o}=t||{},s=this._makeAbort(r);i&&i.addEventListener(`abort`,s,{once:!0});let c=setTimeout(s,n),l=globalThis.ReadableStream&&o.body instanceof globalThis.ReadableStream||typeof o.body==`object`&&o.body!==null&&Symbol.asyncIterator in o.body,u={signal:r.signal,...l?{duplex:`half`}:{},method:`GET`,...o};a&&(u.method=a.toUpperCase());try{return await this.fetch.call(void 0,e,u)}finally{clearTimeout(c)}}async shouldRetry(e){let t=e.headers.get(`x-should-retry`);return t===`true`?!0:t===`false`?!1:e.status===408||e.status===409||e.status===429||e.status>=500}async retryRequest(e,t,n,r){let i,a=r?.get(`retry-after-ms`);if(a){let e=parseFloat(a);Number.isNaN(e)||(i=e)}let o=r?.get(`retry-after`);if(o&&!i){let e=parseFloat(o);i=Number.isNaN(e)?Date.parse(o)-Date.now():e*1e3}if(i===void 0){let n=e.maxRetries??this.maxRetries;i=this.calculateDefaultRetryTimeoutMillis(t,n)}return await et(i),this.makeRequest(e,t-1,n)}calculateDefaultRetryTimeoutMillis(e,t){let n=t-e;return Math.min(.5*2**n,8)*(1-Math.random()*.25)*1e3}calculateNonstreamingTimeout(e,t){let n=600*1e3;if(36e5*e/128e3>n||t!=null&&e>t)throw new v(`Streaming is required for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-typescript#long-requests for more details`);return n}async buildRequest(e,{retryCount:t=0}={}){let n={...e},{method:r,path:i,query:a,defaultBaseURL:o}=n,s=this.buildURL(i,a,o);`timeout`in n&&Ze(`timeout`,n.timeout),n.timeout=n.timeout??this.timeout;let{bodyHeaders:c,body:l}=this.buildBody({options:n});return{req:{method:r,headers:await this.buildHeaders({options:e,method:r,bodyHeaders:c,retryCount:t}),...n.signal&&{signal:n.signal},...globalThis.ReadableStream&&l instanceof globalThis.ReadableStream&&{duplex:`half`},...l&&{body:l},...this.fetchOptions??{},...n.fetchOptions??{}},url:s,timeout:n.timeout}}async buildHeaders({options:e,method:t,bodyHeaders:n,retryCount:r}){let i={};this.idempotencyHeader&&t!==`get`&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),i[this.idempotencyHeader]=e.idempotencyKey);let a=M([i,{Accept:`application/json`,"User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(r),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...ut(),...this._options.dangerouslyAllowBrowser?{"anthropic-dangerous-direct-browser-access":`true`}:void 0,"anthropic-version":`2023-06-01`},await this.authHeaders(e),this._options.defaultHeaders,n,e.headers]);return this.validateHeaders(a),a.values}_makeAbort(e){return()=>e.abort()}buildBody({options:{body:e,headers:t}}){if(!e)return{bodyHeaders:void 0,body:void 0};let n=M([t]);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||typeof e==`string`&&n.values.has(`content-type`)||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||globalThis.ReadableStream&&e instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:e}:typeof e==`object`&&(Symbol.asyncIterator in e||Symbol.iterator in e&&`next`in e&&typeof e.next==`function`)?{bodyHeaders:void 0,body:mt(e)}:typeof e==`object`&&n.values.get(`content-type`)===`application/x-www-form-urlencoded`?{bodyHeaders:{"content-type":`application/x-www-form-urlencoded`},body:this.stringifyQuery(e)}:g(this,Bi,`f`).call(this,{body:e,headers:n})}},zi=Z,Bi=new WeakMap,Ri=new WeakSet,Vi=function(){return this.baseURL!==`https://api.anthropic.com`},Z.Anthropic=zi,Z.HUMAN_PROMPT=Hi,Z.AI_PROMPT=Ui,Z.DEFAULT_TIMEOUT=6e5,Z.AnthropicError=v,Z.APIError=y,Z.APIConnectionError=x,Z.APIConnectionTimeoutError=Fe,Z.APIUserAbortError=b,Z.NotFoundError=ze,Z.ConflictError=Be,Z.RateLimitError=He,Z.BadRequestError=Ie,Z.AuthenticationError=Le,Z.InternalServerError=Ue,Z.PermissionDeniedError=Re,Z.UnprocessableEntityError=Ve,Z.toFile=mn,Wi=class extends Z{constructor(){super(...arguments),this.completions=new Xr(this),this.messages=new ki(this),this.models=new Ni(this),this.beta=new K(this)}},Wi.Completions=Xr,Wi.Messages=ki,Wi.Models=Ni,Wi.Beta=K})),Ki=e((()=>{Gi(),xn(),Zt(),O(),S()}));function qi(e){return e instanceof aa||e instanceof b||e instanceof Error&&e.name===`AbortError`}function Ji(e,t){return e instanceof Error&&e.message===t}function Yi(e){return e instanceof Error?e:Error(String(e))}function Xi(e){return e instanceof Error?e.message:String(e)}function Zi(e){if(e&&typeof e==`object`&&`code`in e&&typeof e.code==`string`)return e.code}function Qi(e){return Zi(e)===`ENOENT`}function $i(e){if(e&&typeof e==`object`&&`path`in e&&typeof e.path==`string`)return e.path}function ea(e,t=5){if(!(e instanceof Error))return String(e);if(!e.stack)return e.message;let n=e.stack.split(`
36
+ `),r=n[0]??e.message,i=n.slice(1).filter(e=>e.trim().startsWith(`at `));return i.length<=t?e.stack:[r,...i.slice(0,t)].join(`
37
+ `)}function ta(e){let t=Zi(e);return t===`ENOENT`||t===`EACCES`||t===`EPERM`||t===`ENOTDIR`||t===`ELOOP`}function na(e){let t=Xi(e);if(!e||typeof e!=`object`||!(`isAxiosError`in e)||!e.isAxiosError)return{kind:`other`,message:t};let n=e,r=n.response?.status;return r===401||r===403?{kind:`auth`,status:r,message:t}:n.code===`ECONNABORTED`?{kind:`timeout`,status:r,message:t}:n.code===`ECONNREFUSED`||n.code===`ENOTFOUND`?{kind:`network`,status:r,message:t}:{kind:`http`,status:r,message:t}}var ra,ia,aa,oa,sa,ca,la,ua=e((()=>{Ki(),s(),ra=class extends Error{constructor(e){super(e),this.name=this.constructor.name}},ia=class extends Error{},aa=class extends Error{constructor(e){super(e),this.name=`AbortError`}},oa=class extends Error{constructor(e,t,n){super(e),c(this,`filePath`,void 0),c(this,`defaultConfig`,void 0),this.name=`ConfigParseError`,this.filePath=t,this.defaultConfig=n}},sa=class extends Error{constructor(e,t,n,r){super(`Shell command failed`),c(this,`stdout`,void 0),c(this,`stderr`,void 0),c(this,`code`,void 0),c(this,`interrupted`,void 0),this.stdout=e,this.stderr=t,this.code=n,this.interrupted=r,this.name=`ShellError`}},ca=class extends Error{constructor(e,t){super(e),c(this,`formattedMessage`,void 0),this.formattedMessage=t,this.name=`TeleportOperationError`}},la=class extends Error{constructor(e,t){super(e),c(this,`telemetryMessage`,void 0),this.name=`TelemetrySafeError`,this.telemetryMessage=t??e}}}));function da(){return ha}function fa(e,t,n){return Q`JSON.stringify(${e})`,JSON.stringify(e,t,n)}function pa(e,t){return Q`structuredClone(${e})`,structuredClone(e,t)}function ma(e,t,n){if(Q`fs.writeFileSync(${e}, ${t})`,typeof n==`object`&&n&&`flush`in n&&n.flush===!0){let r=typeof n==`object`&&`encoding`in n?n.encoding:void 0,i=typeof n==`object`&&`mode`in n?n.mode:void 0,a;try{a=oe(e,`w`,i),se(a,t,{encoding:r??void 0}),ae(a)}finally{a!==void 0&&ie(a)}}else se(e,t,n)}var ha,Q,ga,_a=e((()=>{l(),Za(),(()=>{let e=process.env.CLAUDE_CODE_SLOW_OPERATION_THRESHOLD_MS;if(e!==void 0){let t=Number(e);if(!Number.isNaN(t)&&t>=0)return t}return 1/0})(),ha={[Symbol.dispose](){}},Q=da,ga=(e,t)=>(Q`JSON.parse(${e})`,t===void 0?JSON.parse(e):JSON.parse(e,t))}));function va(){var e=typeof SuppressedError==`function`?SuppressedError:function(e,t){var n=Error();return n.name=`SuppressedError`,n.error=e,n.suppressed=t,n},t={},n=[];function r(e,t){if(t!=null){if(Object(t)!==t)throw TypeError(`using declarations can only be used with objects, functions, null, or undefined.`);if(e)var r=t[Symbol.asyncDispose||Symbol.for(`Symbol.asyncDispose`)];if(r===void 0&&(r=t[Symbol.dispose||Symbol.for(`Symbol.dispose`)],e))var i=r;if(typeof r!=`function`)throw TypeError(`Object is not disposable.`);i&&(r=function(){try{i.call(t)}catch(e){return Promise.reject(e)}}),n.push({v:t,d:r,a:e})}else e&&n.push({d:t,a:e});return t}return{e:t,u:r.bind(null,!1),a:r.bind(null,!0),d:function(){var r,i=this.e,a=0;function o(){for(;r=n.pop();)try{if(!r.a&&a===1)return a=0,n.push(r),Promise.resolve().then(o);if(r.d){var e=r.d.call(r.v);if(r.a)return a|=2,Promise.resolve(e).then(o,s)}else a|=1}catch(e){return s(e)}if(a===1)return i===t?Promise.resolve():Promise.reject(i);if(i!==t)throw i}function s(n){return i=i===t?n:new e(n,i),o()}return o()}}}var ya=e((()=>{}));function ba(e,t){if(t.startsWith(`//`)||t.startsWith(`\\\\`))return{resolvedPath:t,isSymlink:!1,isCanonical:!1};try{let n=e.lstatSync(t);if(n.isFIFO()||n.isSocket()||n.isCharacterDevice()||n.isBlockDevice())return{resolvedPath:t,isSymlink:!1,isCanonical:!1};let r=e.realpathSync(t);return{resolvedPath:r,isSymlink:r!==t,isCanonical:!0}}catch{return{resolvedPath:t,isSymlink:!1,isCanonical:!1}}}function xa(e,t,n){let{resolvedPath:r}=ba(e,t);return n.has(r)?!0:(n.add(r),!1)}function Sa(e,t){let n=t,r=[];for(;n!==p.dirname(n);){let t;try{t=e.lstatSync(n)}catch{r.unshift(p.basename(n)),n=p.dirname(n);continue}if(t.isSymbolicLink())try{let t=e.realpathSync(n);return r.length===0?t:p.join(t,...r)}catch{let t=e.readlinkSync(n),i=p.isAbsolute(t)?t:p.resolve(p.dirname(n),t);return r.length===0?i:p.join(i,...r)}try{let t=e.realpathSync(n);if(t!==n)return r.length===0?t:p.join(t,...r)}catch{}return}}function Ca(e){let t=e;t===`~`?t=f().normalize(`NFC`):t.startsWith(`~/`)&&(t=p.join(f().normalize(`NFC`),t.slice(2)));let n=new Set,r=wa();if(n.add(t),t.startsWith(`//`)||t.startsWith(`\\\\`))return Array.from(n);try{let e=t,i=new Set;for(let a=0;a<40&&!i.has(e);a++){if(i.add(e),!r.existsSync(e)){if(e===t){let e=Sa(r,t);e!==void 0&&n.add(e)}break}let a=r.lstatSync(e);if(a.isFIFO()||a.isSocket()||a.isCharacterDevice()||a.isBlockDevice()||!a.isSymbolicLink())break;let o=r.readlinkSync(e),s=p.isAbsolute(o)?o:p.resolve(p.dirname(e),o);n.add(s),e=s}}catch{}let{resolvedPath:i,isSymlink:a}=ba(r,t);return a&&i!==t&&n.add(i),Array.from(n)}function wa(){return ka}async function Ta(e,t,n){try{var r=va();let i=r.a(await ue(e,`r`)),a=(await i.stat()).size;if(a<=t)return null;let o=Math.min(a-t,n),s=Buffer.allocUnsafe(o),c=0;for(;c<o;){let{bytesRead:e}=await i.read(s,c,o-c,t+c);if(e===0)break;c+=e}return{content:s.toString(`utf8`,0,c),bytesRead:c,bytesTotal:a}}catch(e){r.e=e}finally{await r.d()}}async function Ea(e,t){try{var n=va();let r=n.a(await ue(e,`r`)),i=(await r.stat()).size;if(i===0)return{content:``,bytesRead:0,bytesTotal:0};let a=Math.max(0,i-t),o=i-a,s=Buffer.allocUnsafe(o),c=0;for(;c<o;){let{bytesRead:e}=await r.read(s,c,o-c,a+c);if(e===0)break;c+=e}return{content:s.toString(`utf8`,0,c),bytesRead:c,bytesTotal:i}}catch(e){n.e=e}finally{await n.d()}}async function*Da(e){let t=1024*4,n=await ue(e,`r`);try{let e=(await n.stat()).size,r=Buffer.alloc(0),i=Buffer.alloc(t);for(;e>0;){let a=Math.min(t,e);e-=a,await n.read(i,0,a,e);let o=Buffer.concat([i.subarray(0,a),r]),s=o.indexOf(10);if(s===-1){r=o;continue}r=Buffer.from(o.subarray(0,s));let c=o.toString(`utf8`,s+1).split(`
38
+ `);for(let e=c.length-1;e>=0;e--){let t=c[e];t&&(yield t)}}r.length>0&&(yield r.toString(`utf8`))}finally{await n.close()}}var Oa,ka,Aa=e((()=>{ua(),_a(),ya(),Oa={cwd(){return process.cwd()},existsSync(e){return Q`fs.existsSync(${e})`,m.existsSync(e)},async stat(e){return ge(e)},async readdir(e){return fe(e,{withFileTypes:!0})},async unlink(e){return ve(e)},async rmdir(e){return he(e)},async rm(e,t){return me(e,t)},async mkdir(e,t){try{await le(e,{recursive:!0,...t})}catch(e){if(Zi(e)!==`EEXIST`)throw e}},async readFile(e,t){return de(e,{encoding:t.encoding})},async rename(e,t){return pe(e,t)},statSync(e){return Q`fs.statSync(${e})`,m.statSync(e)},lstatSync(e){return Q`fs.lstatSync(${e})`,m.lstatSync(e)},readFileSync(e,t){return Q`fs.readFileSync(${e})`,m.readFileSync(e,{encoding:t.encoding})},readFileBytesSync(e){return Q`fs.readFileBytesSync(${e})`,m.readFileSync(e)},readSync(e,t){Q`fs.readSync(${e}, ${t.length} bytes)`;let n;try{n=m.openSync(e,`r`);let r=Buffer.alloc(t.length);return{buffer:r,bytesRead:m.readSync(n,r,0,t.length,0)}}finally{n&&m.closeSync(n)}},appendFileSync(e,t,n){if(Q`fs.appendFileSync(${e}, ${t.length} chars)`,n?.mode!==void 0)try{let r=m.openSync(e,`ax`,n.mode);try{m.appendFileSync(r,t)}finally{m.closeSync(r)}return}catch(e){if(Zi(e)!==`EEXIST`)throw e}m.appendFileSync(e,t)},copyFileSync(e,t){Q`fs.copyFileSync(${e} → ${t})`,m.copyFileSync(e,t)},unlinkSync(e){Q`fs.unlinkSync(${e})`,m.unlinkSync(e)},renameSync(e,t){Q`fs.renameSync(${e} → ${t})`,m.renameSync(e,t)},linkSync(e,t){Q`fs.linkSync(${e} → ${t})`,m.linkSync(e,t)},symlinkSync(e,t,n){Q`fs.symlinkSync(${e} → ${t})`,m.symlinkSync(e,t,n)},readlinkSync(e){return Q`fs.readlinkSync(${e})`,m.readlinkSync(e)},realpathSync(e){return Q`fs.realpathSync(${e})`,m.realpathSync(e).normalize(`NFC`)},mkdirSync(e,t){Q`fs.mkdirSync(${e})`;let n={recursive:!0};t?.mode!==void 0&&(n.mode=t.mode);try{m.mkdirSync(e,n)}catch(e){if(Zi(e)!==`EEXIST`)throw e}},readdirSync(e){return Q`fs.readdirSync(${e})`,m.readdirSync(e,{withFileTypes:!0})},readdirStringSync(e){return Q`fs.readdirStringSync(${e})`,m.readdirSync(e)},isDirEmptySync(e){return Q`fs.isDirEmptySync(${e})`,this.readdirSync(e).length===0},rmdirSync(e){Q`fs.rmdirSync(${e})`,m.rmdirSync(e)},rmSync(e,t){Q`fs.rmSync(${e})`,m.rmSync(e,t)},createWriteStream(e){return m.createWriteStream(e)},async readFileBytes(e,t){if(t===void 0)return de(e);let n=await ue(e,`r`);try{let{size:e}=await n.stat(),r=Math.min(e,t),i=Buffer.allocUnsafe(r),a=0;for(;a<r;){let{bytesRead:e}=await n.read(i,a,r-a,a);if(e===0)break;a+=e}return a<r?i.subarray(0,a):i}finally{await n.close()}}},ka=Oa})),ja=t({flushDebugLogs:()=>Ra,getDebugFilePath:()=>qa,getDebugFilter:()=>Ga,getDebugLogPath:()=>Ba,getHasFormattedOutput:()=>Pa,getMinDebugLogLevel:()=>Ua,isDebugMode:()=>Wa,isDebugToStdErr:()=>Ka,logAntError:()=>Va,logForDebugging:()=>za,setHasFormattedOutput:()=>Na});function Ma(e){return!Wa()||typeof process>`u`||process.versions===void 0||process.versions.node===void 0?!1:De(e,Ga())}function Na(e){Ja=e}function Pa(){return Ja}async function Fa(e,t,n,r){e&&await le(t,{recursive:!0}).catch(()=>{}),await ce(n,r),Xa()}function Ia(){}function La(){if(!$){let e=null;$=ye({writeFn:t=>{let n=Ba(),r=te(n),i=e!==r;if(e=r,Wa()){if(i)try{wa().mkdirSync(r)}catch{}try{wa().appendFileSync(n,t)}catch{try{wa().mkdirSync(r),wa().appendFileSync(n,t)}catch{}}Xa();return}Ya=Ya.then(Fa.bind(null,i,r,n,t)).catch(Ia)},flushIntervalMs:1e3,maxBufferSize:100,immediateMode:Wa()}),xe(async()=>{$?.dispose(),await Ya})}return $}async function Ra(){$?.flush(),await Ya}function za(e,{level:t}={level:`debug`}){if(Ha[t]<Ha[Ua()]||!Ma(e))return;Ja&&e.includes(`
39
+ `)&&(e=fa(e));let n=`${new Date().toISOString()} [${t.toUpperCase()}] ${e.trim()}\n`;if(Ka()){ee(n);return}La().write(n)}function Ba(){return qa()??(process.env.CLAUDE_CODE_DEBUG_LOGS_DIR?re(process.env.CLAUDE_CODE_DEBUG_LOGS_DIR):null)??ne(i(),`debug`,`${u()}.txt`)}function Va(e,t){t instanceof Error&&t.stack&&za(`[ANT-ONLY] ${e} stack trace:\n${t.stack}`,{level:`error`})}var Ha,Ua,Wa,Ga,Ka,qa,Ja,$,Ya,Xa,Za=e((()=>{r(),l(),be(),we(),ke(),o(),Aa(),d(),_a(),Ha={verbose:0,debug:1,info:2,warn:3,error:4},Ua=n(()=>{let e=process.env.CLAUDE_CODE_DEBUG_LOG_LEVEL?.toLowerCase().trim();return e&&Object.hasOwn(Ha,e)?e:`debug`}),Wa=n(()=>a(process.env.DEBUG)||a(process.env.DEBUG_SDK)||process.argv.includes(`--debug`)||process.argv.includes(`-d`)||Ka()||process.argv.some(e=>e.startsWith(`--debug=`))||qa()!==null),Ga=n(()=>{let e=process.argv.find(e=>e.startsWith(`--debug=`));return e?Oe(e.substring(8)):null}),Ka=n(()=>process.argv.includes(`--debug-to-stderr`)),qa=n(()=>{for(let e=0;e<process.argv.length;e++){let t=process.argv[e];if(t.startsWith(`--debug-file=`))return re(t.substring(13));if(t===`--debug-file`&&e+1<process.argv.length)return re(process.argv[e+1])}return null}),Ja=!1,$=null,Ya=Promise.resolve(),Xa=n(async()=>{try{let e=Ba(),t=ne(te(e),`latest`);await ve(t).catch(()=>{}),await _e(e,t)}catch{}})}));export{ze as $,sa as A,Qi as B,fa as C,ra as D,aa as E,Zi as F,Wi as G,ea as H,$i as I,x as J,Gi as K,Ji as L,ca as M,na as N,oa as O,Xi as P,Le as Q,ua as R,ga as S,ma as T,Yi as U,ta as V,Ki as W,y as X,Fe as Y,b as Z,Ea as _,Wa as a,be as at,pa as b,za as c,Ca as d,S as et,Aa as f,ba as g,Da as h,Za as i,ye as it,la as j,ia as k,Na as l,Ta as m,Ba as n,xe as nt,Ka as o,xa as p,Rn as q,Pa as r,Se as rt,Va as s,ja as t,we as tt,wa as u,va as v,Q as w,_a as x,ya as y,qi as z};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{F as t,S as n,a as r,l as i,w as a,z as o}from"./debug-RAynG_nM.js";import{n as s,r as c}from"./analytics-DJobLaWP.js";function l(e){return e.replace(_,(e,t,n)=>n.length<v?`"${t}":"[REDACTED]"`:`"${t}":"${`${n.slice(0,8)}...${n.slice(-4)}`}"`)}function u(e){let t=e.replace(/\n/g,`\\n`);return t.length<=g?t:t.slice(0,g)+`... (${t.length} chars)`}function d(e){let t=l(typeof e==`string`?e:a(e));return t.length<=g?t:t.slice(0,g)+`... (${t.length} chars)`}function f(e){let n=t(e);if(e&&typeof e==`object`&&`response`in e){let t=e.response;if(t?.data&&typeof t.data==`object`){let e=t.data,r=typeof e.message==`string`?e.message:typeof e.error==`object`&&e.error&&`message`in e.error&&typeof e.error.message==`string`?e.error.message:void 0;if(r)return`${n}: ${r}`}}return n}function p(e){if(e&&typeof e==`object`&&`response`in e&&e.response&&typeof e.response.status==`number`)return e.response.status}function m(e){if(!(!e||typeof e!=`object`)){if(`message`in e&&typeof e.message==`string`)return e.message;if(`error`in e&&e.error!==null&&typeof e.error==`object`&&`message`in e.error&&typeof e.error.message==`string`)return e.error.message}}function h(e,t,n){t&&i(t),c(`tengu_bridge_repl_skipped`,{reason:e,...n!==void 0&&{v2:n}})}var g,_,v,y=e((()=>{s(),r(),o(),n(),g=2e3,_=RegExp(`"(${[`session_ingress_token`,`environment_secret`,`access_token`,`secret`,`token`].join(`|`)})"\\s*:\\s*"([^"]*)"`,`g`),v=16}));export{p as a,m as i,u as n,y as o,f as r,h as s,d as t};
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{C as t,P as n,R as r,c as i,i as a,x as o}from"./debug-Dr1SjdXn.js";import{n as s,r as c}from"./analytics-DJobLaWP.js";function l(e){return e.replace(_,(e,t,n)=>n.length<v?`"${t}":"[REDACTED]"`:`"${t}":"${`${n.slice(0,8)}...${n.slice(-4)}`}"`)}function u(e){let t=e.replace(/\n/g,`\\n`);return t.length<=g?t:t.slice(0,g)+`... (${t.length} chars)`}function d(e){let n=l(typeof e==`string`?e:t(e));return n.length<=g?n:n.slice(0,g)+`... (${n.length} chars)`}function f(e){let t=n(e);if(e&&typeof e==`object`&&`response`in e){let n=e.response;if(n?.data&&typeof n.data==`object`){let e=n.data,r=typeof e.message==`string`?e.message:typeof e.error==`object`&&e.error&&`message`in e.error&&typeof e.error.message==`string`?e.error.message:void 0;if(r)return`${t}: ${r}`}}return t}function p(e){if(e&&typeof e==`object`&&`response`in e&&e.response&&typeof e.response.status==`number`)return e.response.status}function m(e){if(!(!e||typeof e!=`object`)){if(`message`in e&&typeof e.message==`string`)return e.message;if(`error`in e&&e.error!==null&&typeof e.error==`object`&&`message`in e.error&&typeof e.error.message==`string`)return e.error.message}}function h(e,t,n){t&&i(t),c(`tengu_bridge_repl_skipped`,{reason:e,...n!==void 0&&{v2:n}})}var g,_,v,y=e((()=>{s(),a(),r(),o(),g=2e3,_=RegExp(`"(${[`session_ingress_token`,`environment_secret`,`access_token`,`secret`,`token`].join(`|`)})"\\s*:\\s*"([^"]*)"`,`g`),v=16}));export{p as a,m as i,u as n,y as o,f as r,h as s,d as t};
@@ -0,0 +1,5 @@
1
+ import{n as e,t}from"./defineProperty-C-QyHrDq.js";import{a as n,t as r}from"./cliLaunch-OPOtzhvA.js";import{dirname as i}from"path";import{closeSync as a,createReadStream as o,mkdirSync as s,openSync as c,readSync as l,statSync as u,unwatchFile as d,watchFile as f}from"fs";import{createInterface as p}from"readline";async function m(e){let t=0;try{if(t=u(e).size,t>0){let n=p({input:o(e,{start:0,end:t-1})});for await(let e of n)process.stdout.write(e+`
2
+ `)}}catch{}return console.log(`
3
+ [tail] Watching for new output... (Ctrl+C to detach)
4
+ `),new Promise(n=>{let r=()=>{d(e),process.removeListener(`SIGINT`,r),console.log(`
5
+ [tail] Detached from session.`),n()};process.on(`SIGINT`,r),f(e,{interval:300},()=>{try{let n=u(e);if(n.size<=t)return;let r=c(e,`r`);try{let e=Buffer.alloc(n.size-t);l(r,e,0,e.length,t),process.stdout.write(e),t=n.size}finally{a(r)}}catch{}})})}e();var h=class{constructor(){t(this,`name`,`detached`),t(this,`supportsInteractiveInput`,!1)}async available(){return!0}async start(e){s(i(e.logPath),{recursive:!0});let t=c(e.logPath,`a`),o=n(r(e.args,{env:{...e.env,CLAUDE_CODE_SESSION_KIND:`bg`,CLAUDE_CODE_SESSION_NAME:e.sessionName,CLAUDE_CODE_SESSION_LOG:e.logPath}}),{detached:!0,stdio:[`ignore`,t,t],cwd:e.cwd});return o.unref(),a(t),{pid:o.pid??0,sessionName:e.sessionName,logPath:e.logPath,engineUsed:`detached`}}async attach(e){if(!e.logPath)throw Error(`Session ${e.sessionId} has no log path.`);await m(e.logPath)}};export{h as DetachedEngine};
@@ -0,0 +1 @@
1
+ import{a as e,i as t,o as n}from"./detectRepository-CMEkS5_2.js";t();export{e as parseGitHubRepository,n as parseGitRemote};