@readmagic/workmate 0.0.1

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 (552) hide show
  1. package/dist/chunks/AddWorkspaceDirectory-BSLHrjbt.js +1 -0
  2. package/dist/chunks/App-DY5O6IKw.js +1 -0
  3. package/dist/chunks/ApproveApiKey-BEzfC6r3.js +1 -0
  4. package/dist/chunks/ApproveApiKey-DfAPwDix.js +1 -0
  5. package/dist/chunks/AssistantSessionChooser-Ce3PraaD.js +1 -0
  6. package/dist/chunks/BackgroundTasksDialog-Dvhcgahe.js +2 -0
  7. package/dist/chunks/BypassPermissionsModeDialog-B68V1bCq.js +1 -0
  8. package/dist/chunks/ClaudeMdExternalIncludesDialog-BV7HHcgL.js +1 -0
  9. package/dist/chunks/ClaudeMdExternalIncludesDialog-CTWhpIm8.js +1 -0
  10. package/dist/chunks/ConsoleOAuthFlow-CU5fCPKq.js +1 -0
  11. package/dist/chunks/DesktopHandoff-BRbU4is4.js +1 -0
  12. package/dist/chunks/Dialog-vfLXEPed.js +1 -0
  13. package/dist/chunks/DiffDialog-CBluIK-x.js +6 -0
  14. package/dist/chunks/Doctor-B0CRtxi2.js +1 -0
  15. package/dist/chunks/Doctor-WxNv49HC.js +3 -0
  16. package/dist/chunks/ExitFlow-CRPgptCN.js +2 -0
  17. package/dist/chunks/Feedback-CEtzaLr3.js +2 -0
  18. package/dist/chunks/Grove--kttLxvs.js +11 -0
  19. package/dist/chunks/Grove-CelgLWH4.js +1 -0
  20. package/dist/chunks/HybridTransport-BgV5_7Az.js +4 -0
  21. package/dist/chunks/InvalidConfigDialog-DCGwXW_p.js +1 -0
  22. package/dist/chunks/InvalidSettingsDialog-jTwsdXWr.js +1 -0
  23. package/dist/chunks/ListItem-vfLXEPed.js +1 -0
  24. package/dist/chunks/MCPConnectionManager-BX0LMz9J.js +1 -0
  25. package/dist/chunks/McpParsingWarnings-WQrWJeWP.js +1 -0
  26. package/dist/chunks/MessageSelector-_UZB8cGb.js +3 -0
  27. package/dist/chunks/Messages-jCoW_1Rr.js +11 -0
  28. package/dist/chunks/Onboarding-BoIVNCgc.js +1 -0
  29. package/dist/chunks/OverageCreditUpsell-1FCN8bH3.js +1 -0
  30. package/dist/chunks/PermissionDialog-0ya1CU5k.js +1 -0
  31. package/dist/chunks/PluginSettings-BD9JLV9-.js +17 -0
  32. package/dist/chunks/PressEnterToContinue-Dl9Hg9Mf.js +1 -0
  33. package/dist/chunks/PromptInputFooterSuggestions-CrGST0Cq.js +1 -0
  34. package/dist/chunks/PromptInputHelpMenu-B2TDpbpw.js +1 -0
  35. package/dist/chunks/QueryEngine-D2HUnwmU.js +1 -0
  36. package/dist/chunks/REPL-BV4WyYMg.js +142 -0
  37. package/dist/chunks/REPL-DcpN3MRC.js +1 -0
  38. package/dist/chunks/RemoteCallout-DS_EV6Fh.js +1 -0
  39. package/dist/chunks/RemoteSessionManager-Tx1N2uVL.js +2 -0
  40. package/dist/chunks/ResumeConversation-Cw3vP4G8.js +1 -0
  41. package/dist/chunks/SSETransport-BXiEBMpb.js +4 -0
  42. package/dist/chunks/SearchBox-vfLXEPed.js +1 -0
  43. package/dist/chunks/SearchExtraToolsTool-D3VOFq9R.js +1 -0
  44. package/dist/chunks/Settings-ns6mRsDc.js +2 -0
  45. package/dist/chunks/TeleportProgress-CcDzMC5L.js +1 -0
  46. package/dist/chunks/TeleportRepoMismatchDialog-DZbxl4sD.js +1 -0
  47. package/dist/chunks/TeleportResumeWrapper-EowJO5nm.js +1 -0
  48. package/dist/chunks/ThemePicker-BYbChJpu.js +1 -0
  49. package/dist/chunks/TrustDialog-DA3YTk_k.js +1 -0
  50. package/dist/chunks/TungstenTool-Cb7gJvq4.js +1 -0
  51. package/dist/chunks/TungstenTool-CxMQVCuF.js +1 -0
  52. package/dist/chunks/ValidationErrorsList-Cx-hoRwG.js +2 -0
  53. package/dist/chunks/WelcomeV2-BTfttGcv.js +1 -0
  54. package/dist/chunks/add-dir-CWt69NAZ.js +1 -0
  55. package/dist/chunks/agentDisplay-CQ4mZWFH.js +1 -0
  56. package/dist/chunks/agents-C6jzKOit.js +2 -0
  57. package/dist/chunks/agents-D4clhuCl.js +103 -0
  58. package/dist/chunks/ajv-5vMo9UcX.js +8 -0
  59. package/dist/chunks/allErrors-HMPqE0jK.js +1 -0
  60. package/dist/chunks/analytics-BotDBGh0.js +1 -0
  61. package/dist/chunks/ant-9Z5bppVC.js +1 -0
  62. package/dist/chunks/api-L2IgleTV.js +1 -0
  63. package/dist/chunks/api-TgV7fl9V.js +1 -0
  64. package/dist/chunks/asciicast-DYbkzGCN.js +1 -0
  65. package/dist/chunks/asciicast-n-BBfgDq.js +4 -0
  66. package/dist/chunks/assistant-BA9_Mo9U.js +1 -0
  67. package/dist/chunks/assistant-BiNOSla3.js +1 -0
  68. package/dist/chunks/assistant-YvbVKjVh.js +1 -0
  69. package/dist/chunks/attributionHooks-CUAoGkU6.js +1 -0
  70. package/dist/chunks/attributionTrailer-oKKrF3z8.js +1 -0
  71. package/dist/chunks/auth-CEig4Gxp.js +1 -0
  72. package/dist/chunks/auth-CbGDlhyO.js +1 -0
  73. package/dist/chunks/auth-DHyCIxCk.js +15 -0
  74. package/dist/chunks/autoMode-Db4QrgFr.js +45 -0
  75. package/dist/chunks/autoModeDenials-BxNzGJdR.js +1 -0
  76. package/dist/chunks/autonomy-BkAMA7du.js +1 -0
  77. package/dist/chunks/autonomy-D4Vy-RPQ.js +15 -0
  78. package/dist/chunks/autonomyPanel-EjfO8jvg.js +1 -0
  79. package/dist/chunks/axios-BHBm_hhU.js +1 -0
  80. package/dist/chunks/axios-DaWTGg7G.js +16 -0
  81. package/dist/chunks/backgroundHousekeeping-BNEKWHhH.js +1 -0
  82. package/dist/chunks/backgroundHousekeeping-hDDE8mJC.js +17 -0
  83. package/dist/chunks/banner-hD6wZygx.js +2 -0
  84. package/dist/chunks/base64-js-0wLHn8zB.js +1 -0
  85. package/dist/chunks/bedrockClient-DxE_mHFI.js +15 -0
  86. package/dist/chunks/bg-BzG63WOm.js +1 -0
  87. package/dist/chunks/bg-DQ0Q3Qv-.js +9 -0
  88. package/dist/chunks/branch-CeQ9IyZk.js +3 -0
  89. package/dist/chunks/break-cache-Bd0clV2N.js +8 -0
  90. package/dist/chunks/bridge-yerAiaK2.js +2 -0
  91. package/dist/chunks/bridgeConfig-CCtXe8ak.js +1 -0
  92. package/dist/chunks/bridgeConfig-D5dB38xD.js +1 -0
  93. package/dist/chunks/bridgeEnabled--F-6TUi4.js +1 -0
  94. package/dist/chunks/bridgeEnabled-DKX8-T_H.js +1 -0
  95. package/dist/chunks/bridgeMain--R1HFbOv.js +68 -0
  96. package/dist/chunks/bridgeMain-d06JByZn.js +1 -0
  97. package/dist/chunks/bridgeMessaging-CqbLTDcx.js +1 -0
  98. package/dist/chunks/bridgePointer-W_jdQ8zf.js +1 -0
  99. package/dist/chunks/browser-Bd7GeBH1.js +1 -0
  100. package/dist/chunks/btw-CVGRmL9a.js +1 -0
  101. package/dist/chunks/bundledMode--fG1S62b.js +1 -0
  102. package/dist/chunks/caches-BtmAri4e.js +3 -0
  103. package/dist/chunks/caches-BuTIAOtY.js +1 -0
  104. package/dist/chunks/capacityWake-CV_x9H8j.js +1 -0
  105. package/dist/chunks/ccrClient-HqMi5Kfu.js +1 -0
  106. package/dist/chunks/checksum-DgbnMdM-.js +1 -0
  107. package/dist/chunks/classPrivateFieldSet2-D4U5K-I3.js +1 -0
  108. package/dist/chunks/classPrivateMethodInitSpec-BXQD0Vh4.js +1 -0
  109. package/dist/chunks/claudeDesktop-aUMx06RK.js +1 -0
  110. package/dist/chunks/clear-C6nRzIQE.js +1 -0
  111. package/dist/chunks/cliLaunch-2AUoMnqx.js +1 -0
  112. package/dist/chunks/client-BeET1hnC.js +1 -0
  113. package/dist/chunks/client-DchQnIJD.js +36 -0
  114. package/dist/chunks/client-DvAL7lY8.js +8 -0
  115. package/dist/chunks/color-DXI_4ibU.js +1 -0
  116. package/dist/chunks/color-convert-p91EwGT7.js +1 -0
  117. package/dist/chunks/commands-VjcG4qFq.js +1 -0
  118. package/dist/chunks/commitAttribution-Cm40fdNU.js +2 -0
  119. package/dist/chunks/commitAttribution-Lb3qUlAR.js +1 -0
  120. package/dist/chunks/compact-DPTVpJ4D.js +2 -0
  121. package/dist/chunks/completionCache-BQaLkB4d.js +4 -0
  122. package/dist/chunks/completionCache-CW8lKIgy.js +1 -0
  123. package/dist/chunks/config-0cRberzR.js +1 -0
  124. package/dist/chunks/config-BSXLgwpD.js +1 -0
  125. package/dist/chunks/config-BrxKpHpR.js +1 -0
  126. package/dist/chunks/config-C7YHKCPV.js +3 -0
  127. package/dist/chunks/config-CLmFk-5V.js +1 -0
  128. package/dist/chunks/connectHeadless-CqRoEtrg.js +1 -0
  129. package/dist/chunks/context-C_cKrBUn.js +1 -0
  130. package/dist/chunks/context-noninteractive-DnH6Q9Lu.js +54 -0
  131. package/dist/chunks/context-noninteractive-rUZ3ydmJ.js +1 -0
  132. package/dist/chunks/controlMessageCompat-IFu4Gc1y.js +1 -0
  133. package/dist/chunks/conversation-GJxfkr6M.js +1 -0
  134. package/dist/chunks/conversation-oK3aFzqO.js +1 -0
  135. package/dist/chunks/createSSHSession--bWmmIk9.js +6 -0
  136. package/dist/chunks/createSession-DIr4sUp6.js +1 -0
  137. package/dist/chunks/createSession-DM4acqaC.js +1 -0
  138. package/dist/chunks/cron-3LntnnhJ.js +1 -0
  139. package/dist/chunks/crossProjectResume-DKrtjTpm.js +40 -0
  140. package/dist/chunks/cwd-BuJhkTrc.js +1 -0
  141. package/dist/chunks/cwd-D-tY2NKc.js +1 -0
  142. package/dist/chunks/daemon-B9lBPdBJ.js +2 -0
  143. package/dist/chunks/dangerousBackend-DwcP0P08.js +1 -0
  144. package/dist/chunks/datadog-ByS7LGGa.js +1 -0
  145. package/dist/chunks/datadog-DNCsyfSO.js +1 -0
  146. package/dist/chunks/debug-DzZUT2Wv.js +1 -0
  147. package/dist/chunks/debug-IKW-jE7K.js +39 -0
  148. package/dist/chunks/debugUtils-D2981c0Z.js +1 -0
  149. package/dist/chunks/defineProperty-C-QyHrDq.js +1 -0
  150. package/dist/chunks/desktop-B5cvrcOQ.js +1 -0
  151. package/dist/chunks/detached-rfIUyc-B.js +5 -0
  152. package/dist/chunks/detect-libc-CxbBtWJu.js +1 -0
  153. package/dist/chunks/detectRepository-6nw-Aw3v.js +1 -0
  154. package/dist/chunks/detectRepository-ReZ0Fz8Z.js +1 -0
  155. package/dist/chunks/diff-cXAp9cNN.js +1 -0
  156. package/dist/chunks/directoryCompletion-DBM2o5kx.js +1 -0
  157. package/dist/chunks/dist-CXlEpGqr.js +20 -0
  158. package/dist/chunks/dist-DESLAofA.js +1 -0
  159. package/dist/chunks/dist-DIee4wq1.js +29 -0
  160. package/dist/chunks/dist-Dopnn8wS.js +5 -0
  161. package/dist/chunks/dist-es-5t7v8oaj.js +1 -0
  162. package/dist/chunks/dist-es-BF6bR-Ik.js +2 -0
  163. package/dist/chunks/dist-es-BIjDeceU.js +1 -0
  164. package/dist/chunks/dist-es-BOPBJQo3.js +1 -0
  165. package/dist/chunks/dist-es-Bfr4TzQe.js +3 -0
  166. package/dist/chunks/dist-es-Byxccz_-.js +1 -0
  167. package/dist/chunks/dist-es-C-OjW2Ao.js +1 -0
  168. package/dist/chunks/dist-es-C3reqy7X.js +1 -0
  169. package/dist/chunks/dist-es-C7vygWzp.js +1 -0
  170. package/dist/chunks/dist-es-CEk66gUu.js +1 -0
  171. package/dist/chunks/dist-es-CIULjvtA2.js +1 -0
  172. package/dist/chunks/dist-es-CMtO44xC.js +1 -0
  173. package/dist/chunks/dist-es-CQMt6zRM.js +1 -0
  174. package/dist/chunks/dist-es-CYPVg66r.js +9 -0
  175. package/dist/chunks/dist-es-Cd_AeqMK.js +6 -0
  176. package/dist/chunks/dist-es-Cgsa8pb82.js +1 -0
  177. package/dist/chunks/dist-es-Cwru7c2B2.js +1 -0
  178. package/dist/chunks/dist-es-D1Y8zSMI.js +1 -0
  179. package/dist/chunks/dist-es-D1wHe_zh.js +1 -0
  180. package/dist/chunks/dist-es-DKFm0FJ7.js +1 -0
  181. package/dist/chunks/dist-es-DKIwwJME.js +1 -0
  182. package/dist/chunks/dist-es-DNFTCbrP.js +1 -0
  183. package/dist/chunks/dist-es-DXIR5NLi2.js +1 -0
  184. package/dist/chunks/dist-es-DelBIxNM.js +1 -0
  185. package/dist/chunks/dist-es-DmdZmEJ-.js +1 -0
  186. package/dist/chunks/dist-es-Gt_DpXlP.js +1 -0
  187. package/dist/chunks/dist-es-gUzZ_7Vf.js +1 -0
  188. package/dist/chunks/dist-es-kj-F5A132.js +1 -0
  189. package/dist/chunks/dist-es-yHGBqhBe.js +1 -0
  190. package/dist/chunks/doctor-CTMHXZvQ.js +1 -0
  191. package/dist/chunks/earlyInput-BTC_Wucv.js +2 -0
  192. package/dist/chunks/earlyInput-xcoTbKQn.js +1 -0
  193. package/dist/chunks/effort-Br8KKHdx.js +9 -0
  194. package/dist/chunks/entry-4lIRMrLI.js +14 -0
  195. package/dist/chunks/envLessBridgeConfig-CGuIxFzJ.js +1 -0
  196. package/dist/chunks/envLessBridgeConfig-D_Jg4fJy.js +1 -0
  197. package/dist/chunks/envUtils-DSxRz_kt.js +1 -0
  198. package/dist/chunks/esm-BYnFh4pG.js +1 -0
  199. package/dist/chunks/esm-Bx6rTxIs.js +1 -0
  200. package/dist/chunks/esm-C367Cyo-.js +1 -0
  201. package/dist/chunks/esm-C8Zkk1Ux.js +1 -0
  202. package/dist/chunks/esm-CGx9qY3q.js +56 -0
  203. package/dist/chunks/esm-CXM9jqO_.js +1 -0
  204. package/dist/chunks/esm-CXczu_-W.js +1 -0
  205. package/dist/chunks/esm-CXt5K8Xt.js +1 -0
  206. package/dist/chunks/esm-Cb-L4oAk.js +1 -0
  207. package/dist/chunks/esm-D6ZZCdtk.js +1 -0
  208. package/dist/chunks/esm-DhRjocaU.js +1 -0
  209. package/dist/chunks/esm-DklLYEuz.js +1 -0
  210. package/dist/chunks/esm-IYgGg4wR.js +1 -0
  211. package/dist/chunks/esm-lWlUmoUA.js +1 -0
  212. package/dist/chunks/esm-lyfry1WB.js +10 -0
  213. package/dist/chunks/esm-wGnzjq4Z.js +1 -0
  214. package/dist/chunks/event-streams-C0Zy0Uqv.js +1 -0
  215. package/dist/chunks/event-streams-DoqJmjFN.js +1 -0
  216. package/dist/chunks/eventLoopStallDetector-Cg_RXU1q.js +1 -0
  217. package/dist/chunks/execAsync-Bv2yxuGe.js +1 -0
  218. package/dist/chunks/execFileNoThrow-COKYqVQj.js +34 -0
  219. package/dist/chunks/execSyncWrapper-DZJ3tNWF.js +1 -0
  220. package/dist/chunks/exit-BOhGfSlm.js +2 -0
  221. package/dist/chunks/exit-Z9oWrqE4.js +1 -0
  222. package/dist/chunks/extra-usage-BS4aVOt5.js +1 -0
  223. package/dist/chunks/extra-usage-DtAIhW74.js +1 -0
  224. package/dist/chunks/extra-usage-core-CdL1ltqq.js +1 -0
  225. package/dist/chunks/extra-usage-noninteractive-DxxRI0Yx.js +1 -0
  226. package/dist/chunks/extraUsage-BYZdi44Y.js +1 -0
  227. package/dist/chunks/extractMemories-C4f9JWuI.js +1 -0
  228. package/dist/chunks/fast-B0OB4x7K.js +1 -0
  229. package/dist/chunks/fast-DKqiojzf.js +1 -0
  230. package/dist/chunks/featureCheck-CrJeuheQ.js +1 -0
  231. package/dist/chunks/featureCheck-HslM03dr.js +1 -0
  232. package/dist/chunks/feedback-yB19xph5.js +1 -0
  233. package/dist/chunks/figures-5ThXQEtq.js +1 -0
  234. package/dist/chunks/file-D1cN3LMK.js +12 -0
  235. package/dist/chunks/fileStateCache-DDW5toIs.js +1 -0
  236. package/dist/chunks/files-DAzGtmzz.js +2 -0
  237. package/dist/chunks/firstPartyEventLogger-CdUpe6Lh.js +1 -0
  238. package/dist/chunks/firstPartyEventLogger-hU-LPkje.js +5 -0
  239. package/dist/chunks/flushGate-ZFr8yv7F.js +1 -0
  240. package/dist/chunks/foundry-sdk-BdeF2aBu.js +1 -0
  241. package/dist/chunks/fpsMetrics-Cf_hdtiJ.js +1 -0
  242. package/dist/chunks/from-CgDRRLiX.js +4 -0
  243. package/dist/chunks/gemini-DqAv8_GY.js +1 -0
  244. package/dist/chunks/generateRecap-lO2PDlx8.js +1 -0
  245. package/dist/chunks/generateSessionName-48veu5dv.js +1 -0
  246. package/dist/chunks/genericProcessUtils-F1Qcb1sO.js +23 -0
  247. package/dist/chunks/getMachineId-bsd-Cut1kHoA.js +1 -0
  248. package/dist/chunks/getMachineId-darwin-CsRhaP3y.js +2 -0
  249. package/dist/chunks/getMachineId-linux-Bd7UBNRQ.js +1 -0
  250. package/dist/chunks/getMachineId-unsupported-vFGP8E_8.js +1 -0
  251. package/dist/chunks/getMachineId-win-DamF2CH_.js +1 -0
  252. package/dist/chunks/git-BE_FiJZp.js +1 -0
  253. package/dist/chunks/git-tyaWOgRL.js +6 -0
  254. package/dist/chunks/githubRepoPathMapping-BlR0BphY.js +1 -0
  255. package/dist/chunks/goal-Bn8Kz2Dp.js +3 -0
  256. package/dist/chunks/graceful-fs-DDVg0cja.js +2 -0
  257. package/dist/chunks/grok-DhnO_KDC.js +1 -0
  258. package/dist/chunks/grove-DotW04-v.js +7 -0
  259. package/dist/chunks/hash-Tu-My5Vp.js +1 -0
  260. package/dist/chunks/heapdump-DkZSKNbp.js +5 -0
  261. package/dist/chunks/help-DU_BcZtU.js +1 -0
  262. package/dist/chunks/hooks-BTMWE5Qx.js +79 -0
  263. package/dist/chunks/hooks-DONAb_nq.js +1 -0
  264. package/dist/chunks/hostGuard-Dh296c6q.js +1 -0
  265. package/dist/chunks/inboundAttachments-BcEgi49j.js +1 -0
  266. package/dist/chunks/inboundAttachments-DVs3_m48.js +1 -0
  267. package/dist/chunks/index.min-D75yiGLN.js +1 -0
  268. package/dist/chunks/initReplBridge-D0Xec8S-.js +1 -0
  269. package/dist/chunks/install-BkfXeXpv.js +1 -0
  270. package/dist/chunks/instinctParser-Dt-lqnDe.js +1 -0
  271. package/dist/chunks/instrumentation-H0XRS1yG.js +21 -0
  272. package/dist/chunks/intl-cKc-V6Mq.js +1 -0
  273. package/dist/chunks/isObject-C6qM3WEW.js +1 -0
  274. package/dist/chunks/isSymbol-BO6cdPI7.js +1 -0
  275. package/dist/chunks/job-DKtLkF8V.js +2 -0
  276. package/dist/chunks/json-bigint-bonnP-Hz.js +8 -0
  277. package/dist/chunks/jsx-runtime-Bb4Xn-E0.js +1 -0
  278. package/dist/chunks/jws-BscXOT9I.js +3 -0
  279. package/dist/chunks/jwtUtils-C-ojmb8W.js +1 -0
  280. package/dist/chunks/keybindings-ez51eHHp.js +2 -0
  281. package/dist/chunks/language-BuRSO2sR.js +1 -0
  282. package/dist/chunks/language-Da4KNbjm.js +1 -0
  283. package/dist/chunks/launchAgentsPlatform-BQyPdrHp.js +1 -0
  284. package/dist/chunks/launchCommand-1qkTCKpf.js +1 -0
  285. package/dist/chunks/launchLocalMemory-CWHAj7CX.js +3 -0
  286. package/dist/chunks/launchLocalVault-D8iJdtsP.js +3 -0
  287. package/dist/chunks/launchMemoryStores-W7jWG2uH.js +1 -0
  288. package/dist/chunks/launchOnboarding-q__LaLy1.js +8 -0
  289. package/dist/chunks/launchSchedule-BWi9F5vh.js +1 -0
  290. package/dist/chunks/launchSkillStore-4wd4MQBc.js +1 -0
  291. package/dist/chunks/launchTeleport-BlCf2QM_.js +3 -0
  292. package/dist/chunks/launchVault-C7u7LZV7.js +1 -0
  293. package/dist/chunks/lazySchema-uxlVVNM1.js +1 -0
  294. package/dist/chunks/lib-BSzUGQb_.js +2 -0
  295. package/dist/chunks/lib-BlVGipXx.js +14 -0
  296. package/dist/chunks/lib-rQZENxQg.js +8 -0
  297. package/dist/chunks/loadAgentsDir-Dgd-fzNt.js +1 -0
  298. package/dist/chunks/loadAgentsDir-nzr38hai.js +3990 -0
  299. package/dist/chunks/loadPluginHooks-z1-zvBLw.js +1 -0
  300. package/dist/chunks/loadSso-DSxfVpgX.js +1 -0
  301. package/dist/chunks/localSearch-B-L_ldos.js +1 -0
  302. package/dist/chunks/localSearch-D-FprOMr.js +1 -0
  303. package/dist/chunks/lockfile-D5-j7HOZ.js +1 -0
  304. package/dist/chunks/log-B3eB4EFv.js +1 -0
  305. package/dist/chunks/logoV2Utils-RQ160dI2.js +1 -0
  306. package/dist/chunks/magicDocs-BqZ0GewA.js +57 -0
  307. package/dist/chunks/main-DeFMhaFE.js +31 -0
  308. package/dist/chunks/main-y7LJ5qUc.js +1243 -0
  309. package/dist/chunks/mappers-CWykjGfP.js +1 -0
  310. package/dist/chunks/mcp-CSFPAfaW.js +2 -0
  311. package/dist/chunks/mcp-DBwT4pa9.js +6 -0
  312. package/dist/chunks/mcp-DvZTaHZE.js +1 -0
  313. package/dist/chunks/memoize-BK3gG5ob.js +1 -0
  314. package/dist/chunks/memoize-BO31Ws9Q.js +1 -0
  315. package/dist/chunks/memory-DcpPpYN0.js +1 -0
  316. package/dist/chunks/metadata-BRLJvh61.js +1 -0
  317. package/dist/chunks/modalContext-DFjKLCB6.js +1 -0
  318. package/dist/chunks/mode-BkViT_0o.js +2 -0
  319. package/dist/chunks/model--z4Di9QO.js +1 -0
  320. package/dist/chunks/model-CZktWw6o.js +1 -0
  321. package/dist/chunks/model-DfFA3qMO.js +1 -0
  322. package/dist/chunks/multipart-parser-DDLYsngd.js +2 -0
  323. package/dist/chunks/nativeInstaller-GcIk7G2Y.js +1 -0
  324. package/dist/chunks/oauth-BqJqV-2M.js +1 -0
  325. package/dist/chunks/oauth-C8X_p8Gc.js +1 -0
  326. package/dist/chunks/observationStore-DzCdXq8U.js +4 -0
  327. package/dist/chunks/onChangeAppState-DwGVi-BC.js +1 -0
  328. package/dist/chunks/open-BtQHzzL9.js +1 -0
  329. package/dist/chunks/openai-B2wxZDQx.js +10 -0
  330. package/dist/chunks/openaiShared-G2-w4gJt.js +1 -0
  331. package/dist/chunks/output-style-BM3qAHLA.js +1 -0
  332. package/dist/chunks/overageCreditGrant-CjK49axw.js +1 -0
  333. package/dist/chunks/p-map-B1EeBuI8.js +1 -0
  334. package/dist/chunks/p-map-HKDr3iDo.js +1 -0
  335. package/dist/chunks/package-BC0bllK8.js +1 -0
  336. package/dist/chunks/panel-B-nrcHpm.js +1 -0
  337. package/dist/chunks/panel-R4ue6pSW.js +1 -0
  338. package/dist/chunks/panelCall-I_fbgub5.js +1 -0
  339. package/dist/chunks/parseConnectUrl-BiyKR5-x.js +1 -0
  340. package/dist/chunks/parser-BlM_Fk4J.js +1 -0
  341. package/dist/chunks/parser-CQrasoUB.js +1 -0
  342. package/dist/chunks/partition-CxRF7T-f.js +1 -0
  343. package/dist/chunks/passes-U_h-hNu-.js +1 -0
  344. package/dist/chunks/path-BCSE0S-c.js +1 -0
  345. package/dist/chunks/permissions-B8epy16o.js +3 -0
  346. package/dist/chunks/permissions-CeYKbtSC.js +1 -0
  347. package/dist/chunks/permissions-Cn_6f8CB.js +1 -0
  348. package/dist/chunks/pidLock-CBJDnBG_.js +3 -0
  349. package/dist/chunks/pipeTransport-D3Qx9v1V.js +1 -0
  350. package/dist/chunks/plan-BAhStVci.js +1 -0
  351. package/dist/chunks/platform-EtecGacO.js +2 -0
  352. package/dist/chunks/plist-Bzo2VMe9.js +6 -0
  353. package/dist/chunks/plugin-D9huNnv6.js +1 -0
  354. package/dist/chunks/pluginAutoupdate-BfmyxR5g.js +1 -0
  355. package/dist/chunks/pluginBlocklist-03sZaZa6.js +1 -0
  356. package/dist/chunks/pluginCliCommands-P2Ndi1r1.js +1 -0
  357. package/dist/chunks/pluginFlagging-BVy7Xv_0.js +1 -0
  358. package/dist/chunks/pluginOperations-Cz37qcjF.js +2 -0
  359. package/dist/chunks/pluginStartupCheck-BqUwHcMD.js +1 -0
  360. package/dist/chunks/pluginStartupCheck-w24D-wwk.js +1 -0
  361. package/dist/chunks/plugins-B0hiIN4q.js +4 -0
  362. package/dist/chunks/policyLimits-Dem-XJ_h.js +1 -0
  363. package/dist/chunks/pollConfig-C2Ac8WMU.js +1 -0
  364. package/dist/chunks/poller-CpLBoB-N.js +1 -0
  365. package/dist/chunks/poor-CfbMKZNJ.js +1 -0
  366. package/dist/chunks/poorMode-Bsw2V-V_.js +1 -0
  367. package/dist/chunks/poorMode-jvImnkty.js +1 -0
  368. package/dist/chunks/postCommitAttribution-DoSP9wZD.js +1 -0
  369. package/dist/chunks/print-ozjC0Mhg.js +23 -0
  370. package/dist/chunks/privacy-settings-DeGoBRrZ.js +1 -0
  371. package/dist/chunks/process-CNfq37LF.js +1 -0
  372. package/dist/chunks/process-gEbdy6uY.js +1 -0
  373. package/dist/chunks/processBashCommand-loWZ8MSE.js +1 -0
  374. package/dist/chunks/processSlashCommand-BdouajZb.js +5 -0
  375. package/dist/chunks/projectContext-BaDZBAoK.js +1 -0
  376. package/dist/chunks/projectContext-D9MDwJUF.js +1 -0
  377. package/dist/chunks/prompt-Bef63FhB.js +132 -0
  378. package/dist/chunks/prompt-C7wd1H_i.js +1 -0
  379. package/dist/chunks/prompt-DIoNqZvO.js +1 -0
  380. package/dist/chunks/promptEditor-foiayhdY.js +4 -0
  381. package/dist/chunks/protocolHandler-BsiB1oW_.js +13 -0
  382. package/dist/chunks/protocols-CCsohXid.js +18 -0
  383. package/dist/chunks/protocols-CnYQjBlj.js +2 -0
  384. package/dist/chunks/proxy-Cn2YwITp.js +99 -0
  385. package/dist/chunks/rate-limit-options-DTJPDcTr.js +1 -0
  386. package/dist/chunks/rcDebugLog-BUuD-X1D.js +11 -0
  387. package/dist/chunks/reconciler-DqXTmV3J.js +4 -0
  388. package/dist/chunks/referral-DP_GshTS.js +1 -0
  389. package/dist/chunks/refresh-CNzXPAFw.js +1 -0
  390. package/dist/chunks/registerProtocol-CjxlFsKw.js +36 -0
  391. package/dist/chunks/release-notes-BxgK8zWO.js +4 -0
  392. package/dist/chunks/releaseNotes-CbSktIJW.js +2 -0
  393. package/dist/chunks/reload-plugins-CDu6yU5-.js +1 -0
  394. package/dist/chunks/remote-env-B4HnhISc.js +1 -0
  395. package/dist/chunks/remoteBridgeCore-D-wG5jau.js +1 -0
  396. package/dist/chunks/remoteManagedSettings-B7gt0VAX.js +1 -0
  397. package/dist/chunks/rename-DlbMb24l.js +1 -0
  398. package/dist/chunks/renderOptions-5kWQpVr2.js +1 -0
  399. package/dist/chunks/resume-BB5iBogS.js +2 -0
  400. package/dist/chunks/rewind-D12hCfZD.js +1 -0
  401. package/dist/chunks/ripgrep-BQgJ02F9.js +1 -0
  402. package/dist/chunks/ripgrep-BvDwiKJ3.js +5 -0
  403. package/dist/chunks/rollback-BPWRKlIZ.js +11 -0
  404. package/dist/chunks/rolldown-runtime-DaDcL9Zw.js +1 -0
  405. package/dist/chunks/runtimeObserver-BNH2WGE3.js +1 -0
  406. package/dist/chunks/runtimeObserver-Ci-5gvYg.js +10 -0
  407. package/dist/chunks/sandbox-adapter-Coe1GDAE.js +1 -0
  408. package/dist/chunks/sandbox-toggle-B2Yk4y2V.js +1 -0
  409. package/dist/chunks/sanitization-DV-94a9Z.js +1 -0
  410. package/dist/chunks/satisfies-DQJHNtpQ.js +1 -0
  411. package/dist/chunks/sdkHeapDumpMonitor-WdXUV7DV.js +1 -0
  412. package/dist/chunks/searchExtraTools-BnWZ9roi.js +1 -0
  413. package/dist/chunks/semver-BMRJYn3q.js +1 -0
  414. package/dist/chunks/semver-DQo45qGo.js +1 -0
  415. package/dist/chunks/serde-f76bObzR.js +4 -0
  416. package/dist/chunks/server-LdbAb0sV.js +1 -0
  417. package/dist/chunks/serverBanner-BdExKFHT.js +1 -0
  418. package/dist/chunks/serverLog-BFmvyJ93.js +1 -0
  419. package/dist/chunks/session-Bmx7L3Mt.js +2 -0
  420. package/dist/chunks/sessionDataUploader-CaCjwsA2.js +1 -0
  421. package/dist/chunks/sessionDiscovery-DcEAr5vJ.js +1 -0
  422. package/dist/chunks/sessionFileAccessHooks-BhdOmW9o.js +1 -0
  423. package/dist/chunks/sessionManager-CPa049BO.js +1 -0
  424. package/dist/chunks/sessionMemory-Bsg2unYX.js +1 -0
  425. package/dist/chunks/sessionMemory-CIbCojm-.js +1 -0
  426. package/dist/chunks/sessionMemoryUtils-Cjb57wtC.js +1 -0
  427. package/dist/chunks/sessionObserver-CRU1qWnP.js +1 -0
  428. package/dist/chunks/sessionObserver-DQwHsDrM.js +20 -0
  429. package/dist/chunks/sessionStorage-BxDN8qRc.js +1 -0
  430. package/dist/chunks/sessionStoragePortable-Cx6JQ5Ye.js +3 -0
  431. package/dist/chunks/sessionTitle-B8jcexkQ.js +14 -0
  432. package/dist/chunks/sessionTracing-BuLsL6qA.js +11 -0
  433. package/dist/chunks/settings-5PQdphqC.js +19 -0
  434. package/dist/chunks/settingsSync-BDeuErb5.js +1 -0
  435. package/dist/chunks/setup-BKEnSLR9.js +3 -0
  436. package/dist/chunks/shadowedRuleDetection-7Z8ezTKF.js +1 -0
  437. package/dist/chunks/shellQuote-fB02N16J.js +4 -0
  438. package/dist/chunks/sideQuestion-CYdNATPW.js +20 -0
  439. package/dist/chunks/signin-CPaEtsnK.js +1 -0
  440. package/dist/chunks/sink-DjKoYMsA.js +1 -0
  441. package/dist/chunks/sink-iYxWapbU.js +1 -0
  442. package/dist/chunks/sinks-GryGVRT8.js +2 -0
  443. package/dist/chunks/sinks-jfaIjsRJ.js +1 -0
  444. package/dist/chunks/skill-learning-E8tQed-Q.js +5 -0
  445. package/dist/chunks/skillChangeDetector-A8SAuyo9.js +1 -0
  446. package/dist/chunks/skillGapStore-B5rl12bV.js +1 -0
  447. package/dist/chunks/skillGapStore-CjJrxxjk.js +5 -0
  448. package/dist/chunks/skillGenerator-BDR_z3-X.js +8 -0
  449. package/dist/chunks/skillLearning-BQtfFE0g.js +1 -0
  450. package/dist/chunks/skillLearning-C8ihdryM.js +1 -0
  451. package/dist/chunks/skillPanel-yR8Oi-mO.js +28 -0
  452. package/dist/chunks/skillSearchPanel-DUQQUCUS.js +21 -0
  453. package/dist/chunks/skills-NAZQ3j-t.js +1 -0
  454. package/dist/chunks/slashCommandParsing-RQb_7Xzt.js +1 -0
  455. package/dist/chunks/src-CDCSSo0U2.js +53 -0
  456. package/dist/chunks/src-CHw1lvBc.js +3 -0
  457. package/dist/chunks/src-CST_jFnT.js +1 -0
  458. package/dist/chunks/src-CgZmCiiH.js +2 -0
  459. package/dist/chunks/src-CiJCsqUl.js +9 -0
  460. package/dist/chunks/src-D06Xyj4g.js +2 -0
  461. package/dist/chunks/src-DCUgdrYl.js +5 -0
  462. package/dist/chunks/src-DLz3FZm1.js +1 -0
  463. package/dist/chunks/src-DPUAq5Ty.js +1 -0
  464. package/dist/chunks/src-DQOX_xI1.js +1 -0
  465. package/dist/chunks/src-Dt5IJd3C.js +1 -0
  466. package/dist/chunks/src-Dvp6-vB7.js +19 -0
  467. package/dist/chunks/src-PM8NIIu_.js +1 -0
  468. package/dist/chunks/src-l6_O0K-a.js +1 -0
  469. package/dist/chunks/src-xRRBgNzF.js +25 -0
  470. package/dist/chunks/sso-oidc-DFJ7SBvI.js +1 -0
  471. package/dist/chunks/startupProfiler-B0m6crkd.js +1 -0
  472. package/dist/chunks/startupProfiler-DxRQteII.js +3 -0
  473. package/dist/chunks/state-4KQ3kaqz.js +1 -0
  474. package/dist/chunks/state-53JDbNQM.js +1 -0
  475. package/dist/chunks/state-Cn_m2NOf.js +1 -0
  476. package/dist/chunks/staticRender-BIxpgNUq.js +1 -0
  477. package/dist/chunks/stats-h4yu84Q-.js +1 -0
  478. package/dist/chunks/status-BbdeubJG.js +1 -0
  479. package/dist/chunks/status-is_Bg_IB.js +2 -0
  480. package/dist/chunks/statusNoticeHelpers-CQ7CUugR.js +1 -0
  481. package/dist/chunks/stdio-4S7b8Uhx.js +1 -0
  482. package/dist/chunks/stdio-W_Kokrkh.js +3 -0
  483. package/dist/chunks/stickers-qJoNhPk4.js +1 -0
  484. package/dist/chunks/store-Z8rTjDHe.js +1 -0
  485. package/dist/chunks/stringUtils-CvXbHQRH.js +4 -0
  486. package/dist/chunks/sts-C2Gf2WYN.js +1 -0
  487. package/dist/chunks/subprocessEnv-BSQSomcK.js +1 -0
  488. package/dist/chunks/subprocessEnv-vrwzMgKn.js +1 -0
  489. package/dist/chunks/supports-color-uJ1LqA-P.js +1 -0
  490. package/dist/chunks/systemPromptSections-CgpggIYX.js +1 -0
  491. package/dist/chunks/systemPromptSections-IePG5K8r.js +1 -0
  492. package/dist/chunks/systemTheme-Ceakddth.js +1 -0
  493. package/dist/chunks/tag-i3HZ4lhj.js +11 -0
  494. package/dist/chunks/tasks-HzsYNTZ1.js +1 -0
  495. package/dist/chunks/teleport-hN3cAbYC.js +1 -0
  496. package/dist/chunks/templateJobs-CIv_ysje.js +12 -0
  497. package/dist/chunks/terminalSetup-C0PF87iu.js +33 -0
  498. package/dist/chunks/terminalSetup-CxniwSF-.js +1 -0
  499. package/dist/chunks/theme-BKIHX_Dx.js +1 -0
  500. package/dist/chunks/thinkback-BA4cMz4D.js +1 -0
  501. package/dist/chunks/thinkback-mT-8FIT-.js +1 -0
  502. package/dist/chunks/thinkback-play-Cfk49mvF.js +1 -0
  503. package/dist/chunks/tmux-CbsW-VDJ.js +1 -0
  504. package/dist/chunks/toolEventObserver-8FQtxeVv.js +1 -0
  505. package/dist/chunks/toolEventObserver-B1xvyKdE.js +1 -0
  506. package/dist/chunks/toolPool-CHVDZqh7.js +1 -0
  507. package/dist/chunks/trustedDevice-BYCh1ff7.js +1 -0
  508. package/dist/chunks/trustedDevice-DnIWErCt.js +1 -0
  509. package/dist/chunks/tui-fTa_pzdA.js +6 -0
  510. package/dist/chunks/types-BUyOCzUt.js +1 -0
  511. package/dist/chunks/types-Czs-_G1S.js +3 -0
  512. package/dist/chunks/types-a7X-tJpJ.js +17 -0
  513. package/dist/chunks/udsClient-Cg9bBD0p.js +1 -0
  514. package/dist/chunks/ultrareviewCommand-DCFRZsKp.js +3 -0
  515. package/dist/chunks/undercover-B-kKUWtK.js +1 -0
  516. package/dist/chunks/undercover-CsLPQb-a.js +31 -0
  517. package/dist/chunks/up-dO5BcPaq.js +12 -0
  518. package/dist/chunks/updateCCB-CfUnkOLT.js +11 -0
  519. package/dist/chunks/upgrade-CngUwvY4.js +1 -0
  520. package/dist/chunks/upgrade-kpttjebY.js +1 -0
  521. package/dist/chunks/upload-DDhQqV8n.js +1 -0
  522. package/dist/chunks/upstreamproxy-CvcjNY7J.js +11 -0
  523. package/dist/chunks/usage-CJ5w0907.js +1 -0
  524. package/dist/chunks/usage-eZRwLa77.js +1 -0
  525. package/dist/chunks/useExitOnCtrlCDWithKeybindings-yAroCqu4.js +1 -0
  526. package/dist/chunks/useMainLoopModel-BNFW-g8E.js +1 -0
  527. package/dist/chunks/useManagePlugins-CTtPaQRP.js +1 -0
  528. package/dist/chunks/useMergedTools-CZJffsmf.js +1 -0
  529. package/dist/chunks/useSearchInput-C-CqUK6w.js +1 -0
  530. package/dist/chunks/useSettingsErrors-BWlJCgYF.js +1 -0
  531. package/dist/chunks/util-DJV0joAW.js +1 -0
  532. package/dist/chunks/v4-jw6qOKwQ.js +65 -0
  533. package/dist/chunks/validatePlugin-CRmpIGLV.js +1 -0
  534. package/dist/chunks/vertex-sdk-DjXcZ2J7.js +9 -0
  535. package/dist/chunks/vim-n8-UT5w-.js +1 -0
  536. package/dist/chunks/which-BBCjXfI2.js +1 -0
  537. package/dist/chunks/windowsPaths-D6T_3XaU.js +1 -0
  538. package/dist/chunks/windowsPaths-DUKTzBck.js +1 -0
  539. package/dist/chunks/workSecret-C_lv0dRh.js +1 -0
  540. package/dist/chunks/workerRegistry-BdHi7_sN.js +1 -0
  541. package/dist/chunks/worktree-YDeHMlHZ.js +1 -0
  542. package/dist/chunks/worktreeModeEnabled-BFOYTTTr.js +1 -0
  543. package/dist/chunks/worktreeModeEnabled-D68iEHpC.js +1 -0
  544. package/dist/chunks/wrapper-K8ZapJVu.js +6 -0
  545. package/dist/chunks/xdg-DcF9ejUM.js +1 -0
  546. package/dist/chunks/zod-CuNujUwx.js +1 -0
  547. package/dist/cli-bun.js +2 -0
  548. package/dist/cli-node.js +2 -0
  549. package/dist/cli.js +2 -0
  550. package/dist/vendor/ripgrep/x64-linux/rg +0 -0
  551. package/package.json +218 -0
  552. package/scripts/postinstall.cjs +389 -0
@@ -0,0 +1 @@
1
+ import{t as e}from"./backgroundHousekeeping-hDDE8mJC.js";export{e as startBackgroundHousekeeping};
@@ -0,0 +1,17 @@
1
+ import{a as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,o as r}from"./envUtils-DSxRz_kt.js";import{K as i,R as a,en as o}from"./state-4KQ3kaqz.js";import{Et as s,Fx as c,Jg as l,Kg as u,Px as d,So as f,To as ee,Xl as te,Yb as ne,Yl as p,aw as m,br as h,dT as g,et as _,ht as v,iw as y,jr as re,lw as ie,nt as ae,qb as oe,wo as se,zo as b}from"./loadAgentsDir-nzr38hai.js";import{n as ce,t as le}from"./cwd-BuJhkTrc.js";import{E as ue,J as de,U as x,_ as fe,h as S,l as C,p as w}from"./debug-IKW-jE7K.js";import{f as T,g as E,v as D}from"./settings-5PQdphqC.js";import{C as O,T as k,w as A}from"./config-C7YHKCPV.js";import{o as j,s as M,v as N,y as P}from"./log-B3eB4EFv.js";import{n as F,r as I}from"./analytics-BotDBGh0.js";import{_ as L,h as R}from"./model-DfFA3qMO.js";import{Cn as z,Sn as B}from"./prompt-Bef63FhB.js";import{st as V}from"./rcDebugLog-BUuD-X1D.js";import{i as H,t as U}from"./nativeInstaller-GcIk7G2Y.js";import{n as pe,t as me}from"./allErrors-HMPqE0jK.js";import{n as he,r as ge}from"./magicDocs-BqZ0GewA.js";import{n as _e,t as ve}from"./pluginAutoupdate-BfmyxR5g.js";import{n as ye,r as be}from"./registerProtocol-CjxlFsKw.js";import{homedir as xe}from"os";import{join as W}from"path";import"crypto";import*as G from"fs/promises";r(),o(),ce(),ue(),fe(),C(),P(),E(),L(),z(),ie(),te(),re(),ge(),_(),j(),x(),b(),g(),_(),m(),x(),j(),b(),g();async function Se(e,t){if(!e)return;let{join:n}=await import(`path`),r=await import(`fs/promises`),i=n(le(),`.claude`,`skills`,e,`SKILL.md`),a;try{a=await r.readFile(i,`utf-8`)}catch{M(Error(`Failed to read skill file for improvement: ${i}`));return}let o=t.map(e=>`- ${e.section}: ${e.change}`).join(`
2
+ `),s=R(),c=await ae({messages:[f({content:`You are editing a skill definition file. Apply the following improvements to the skill.
3
+
4
+ <current_skill_file>
5
+ ${a}
6
+ </current_skill_file>
7
+
8
+ <improvements>
9
+ ${o}
10
+ </improvements>
11
+
12
+ Rules:
13
+ - Integrate the improvements naturally into the existing structure
14
+ - Preserve frontmatter (--- block) exactly as-is
15
+ - Preserve the overall format and style
16
+ - Do not remove existing content unless an improvement explicitly replaces it
17
+ - Output the complete updated file inside <updated_file> tags`})],systemPrompt:V([`You edit skill definition files to incorporate user preferences. Output only the updated file content.`]),thinkingConfig:{type:`disabled`},tools:[],signal:y().signal,options:{getToolPermissionContext:async()=>B(),model:s,toolChoice:void 0,isNonInteractiveSession:!1,hasAppendSystemPrompt:!1,temperatureOverride:0,agents:[],querySource:`skill_improvement_apply`,mcpTools:[]}}),l=se(ee(Array.isArray(c.message.content)?c.message.content:[]).trim(),`updated_file`);if(!l){M(Error(`Skill improvement apply: no updated_file tag in response`));return}try{await r.writeFile(i,l,`utf-8`)}catch(e){M(de(e))}}F(),ne(),O(),j(),U(),c(),pe(),l(),s();var Ce=30;function K(){let e=((T()||{}).cleanupPeriodDays??Ce)*24*60*60*1e3;return new Date(Date.now()-e)}function we(e,t){return{messages:e.messages+t.messages,errors:e.errors+t.errors}}function Te(e){let t=e.split(`.`)[0].replace(/T(\d{2})-(\d{2})-(\d{2})-(\d{3})Z/,`T$1:$2:$3.$4Z`);return new Date(t)}async function q(e,t,n){let r={messages:0,errors:0};try{let i=await S().readdir(e);for(let a of i)try{Te(a.name)<t&&(await S().unlink(W(e,a.name)),n?r.messages++:r.errors++)}catch(e){M(e)}}catch(e){e instanceof Error&&`code`in e&&e.code!==`ENOENT`&&M(e)}return r}async function Ee(){let e=S(),t=K(),n=N.errors(),r=N.baseLogs(),i=await q(n,t,!1);try{let n;try{n=await e.readdir(r)}catch{return i}let a=n.filter(e=>e.isDirectory()&&e.name.startsWith(`mcp-logs-`)).map(e=>W(r,e.name));for(let n of a)i=we(i,await q(n,t,!0)),await Y(n,e)}catch(e){e instanceof Error&&`code`in e&&e.code!==`ENOENT`&&M(e)}return i}async function J(e,t,n){return(await n.stat(e)).mtime<t?(await n.unlink(e),!0):!1}async function Y(e,t){try{await t.rmdir(e)}catch{}}async function De(){let e=K(),t={messages:0,errors:0},n=h(),r=S(),i;try{i=await r.readdir(n)}catch{return t}for(let a of i){if(!a.isDirectory())continue;let i=W(n,a.name),o;try{o=await r.readdir(i)}catch{t.errors++;continue}for(let n of o)if(n.isFile()){if(!n.name.endsWith(`.jsonl`)&&!n.name.endsWith(`.cast`))continue;try{await J(W(i,n.name),e,r)&&t.messages++}catch{t.errors++}}else if(n.isDirectory()){let a=W(i,n.name),o=W(a,u),s;try{s=await r.readdir(o)}catch{await Y(a,r);continue}for(let n of s)if(n.isFile())try{await J(W(o,n.name),e,r)&&t.messages++}catch{t.errors++}else if(n.isDirectory()){let i=W(o,n.name),a;try{a=await r.readdir(i)}catch{continue}for(let n of a)if(n.isFile())try{await J(W(i,n.name),e,r)&&t.messages++}catch{t.errors++}await Y(i,r)}await Y(o,r),await Y(a,r)}await Y(i,r)}return t}async function Oe(e,t,n=!0){let r=K(),i={messages:0,errors:0},a=S(),o;try{o=await a.readdir(e)}catch{return i}for(let n of o)if(!(!n.isFile()||!n.name.endsWith(t)))try{await J(W(e,n.name),r,a)&&i.messages++}catch{i.errors++}return n&&await Y(e,a),i}function ke(){return Oe(W(n(),`plans`),`.md`)}async function Ae(){let e=K(),t={messages:0,errors:0},r=S();try{let i=W(n(),`file-history`),a;try{a=await r.readdir(i)}catch{return t}let o=a.filter(e=>e.isDirectory()).map(e=>W(i,e.name));await Promise.all(o.map(async n=>{try{(await r.stat(n)).mtime<e&&(await r.rm(n,{recursive:!0,force:!0}),t.messages++)}catch{t.errors++}})),await Y(i,r)}catch(e){M(e)}return t}async function X(){let e=K(),t={messages:0,errors:0},r=S();try{let i=W(n(),`session-env`),a;try{a=await r.readdir(i)}catch{return t}let o=a.filter(e=>e.isDirectory()).map(e=>W(i,e.name));for(let n of o)try{(await r.stat(n)).mtime<e&&(await r.rm(n,{recursive:!0,force:!0}),t.messages++)}catch{t.errors++}await Y(i,r)}catch(e){M(e)}return t}async function je(){let e=K(),t={messages:0,errors:0},r=S(),i=W(n(),`debug`),a;try{a=await r.readdir(i)}catch{return t}for(let n of a)if(!(!n.isFile()||!n.name.endsWith(`.txt`)||n.name===`latest`))try{await J(W(i,n.name),e,r)&&t.messages++}catch{t.errors++}return t}var Z=1440*60*1e3;async function Q(){let e=W(n(),`.npm-cache-cleanup`);try{let t=await G.stat(e);if(Date.now()-t.mtimeMs<Z){w(`npm cache cleanup: skipping, ran recently`);return}}catch{}try{await A(e,{retries:0,realpath:!1})}catch{w(`npm cache cleanup: skipping, lock held`);return}w(`npm cache cleanup: starting`);let r=W(xe(),`.npm`,`_cacache`),i=Date.now();try{let n=await import(`./lib-rQZENxQg.js`).then(e=>t(e.default,1)),a=i-Z,o=n.ls.stream(r),s=[];for await(let e of o)e.key.includes(`@anthropic-ai/claude-`)&&s.push({key:e.key,time:e.time});let c=new Map;for(let e of s){let t=e.key.lastIndexOf(`@`),n=t>0?e.key.slice(0,t):e.key,r=c.get(n)??[];r.push(e),c.set(n,r)}let l=[];for(let[,e]of c){e.sort((e,t)=>t.time-e.time);for(let t=0;t<e.length;t++){let n=e[t];(n.time<a||t>=5)&&l.push(n.key)}}await Promise.all(l.map(e=>n.rm.entry(r,e))),await G.writeFile(e,new Date().toISOString());let u=Date.now()-i;l.length>0?w(`npm cache cleanup: Removed ${l.length} old @anthropic-ai entries in ${u}ms`):w(`npm cache cleanup: completed in ${u}ms`),I(`tengu_npm_cache_cleanup`,{success:!0,durationMs:u,entriesRemoved:l.length})}catch(e){M(e),I(`tengu_npm_cache_cleanup`,{success:!1,durationMs:Date.now()-i})}finally{await k(e,{realpath:!1}).catch(()=>{})}}async function Me(){let e=W(n(),`.version-cleanup`);try{let t=await G.stat(e);if(Date.now()-t.mtimeMs<Z){w(`version cleanup: skipping, ran recently`);return}}catch{}try{await A(e,{retries:0,realpath:!1})}catch{w(`version cleanup: skipping, lock held`);return}w(`version cleanup: starting (throttled)`);try{await H(),await G.writeFile(e,new Date().toISOString())}catch(e){M(e)}finally{await k(e,{realpath:!1}).catch(()=>{})}}async function Ne(){let{errors:e}=me();if(e.length>0&&D(`cleanupPeriodDays`)){w(`Skipping cleanup: settings have validation errors but cleanupPeriodDays was explicitly set. Fix settings errors to enable cleanup.`);return}await Ee(),await De(),await ke(),await Ae(),await X(),await je(),await oe(),await d(K());let t=await v(K());t>0&&I(`tengu_worktree_cleanup`,{removed:t}),process.env.USER_TYPE===`ant`&&await Q()}o(),U(),_e();var Pe=(ye(),e(be)),Fe=1440*60*1e3,$=600*1e3;function Ie(){he(),import(`./extractMemories-C4f9JWuI.js`).then(({initExtractMemories:e})=>{e()}).catch(()=>{}),p(),ve(),a()&&Pe.ensureDeepLinkProtocolRegistered();let e=!0;async function t(){if(a()&&i()>Date.now()-1e3*60){setTimeout(t,$).unref();return}if(e&&(e=!1,await Ne()),a()&&i()>Date.now()-1e3*60){setTimeout(t,$).unref();return}await H()}setTimeout(t,$).unref(),process.env.USER_TYPE===`ant`&&setInterval(()=>{Q(),Me()},Fe).unref()}export{Se as n,Ie as t};
@@ -0,0 +1,2 @@
1
+ import{S as e,T as t,_ as n,s as r}from"./git-tyaWOgRL.js";import{b as i,h as a,p as o}from"./startupProfiler-DxRQteII.js";import{homedir as s}from"os";import{join as c,sep as l}from"path";import{stat as u}from"fs/promises";i(),t(),n();var d=10080*60*1e3,f=1e3;function p(e){let t=[`This session was opened by an external deep link in ${g(e.cwd)}`];if(e.repo){let n=e.lastFetch?a(e.lastFetch):`never`,r=!e.lastFetch||Date.now()-e.lastFetch.getTime()>d;t.push(`Resolved ${e.repo} from local clones · last fetched ${n}${r?` — CLAUDE.md may be stale`:``}`)}return e.prefillLength&&t.push(e.prefillLength>f?`The prompt below (${o(e.prefillLength)} chars) was supplied by the link — scroll to review the entire prompt before pressing Enter.`:`The prompt below was supplied by the link — review carefully before pressing Enter.`),t.join(`
2
+ `)}async function m(t){let n=await r(t);if(!n)return;let i=await e(n),[a,o]=await Promise.all([h(c(n,`FETCH_HEAD`)),i?h(c(i,`FETCH_HEAD`)):Promise.resolve(void 0)]);return a&&o?a>o?a:o:a??o}async function h(e){try{let{mtime:t}=await u(e);return t}catch{return}}function g(e){let t=s();return e===t?`~`:e.startsWith(t+l)?`~`+e.slice(t.length):e}export{m as n,p as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./rolldown-runtime-DaDcL9Zw.js";var t=e((e=>{e.byteLength=c,e.toByteArray=u,e.fromByteArray=p;for(var t=[],n=[],r=typeof Uint8Array<`u`?Uint8Array:Array,i=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,a=0,o=i.length;a<o;++a)t[a]=i[a],n[i.charCodeAt(a)]=a;n[45]=62,n[95]=63;function s(e){var t=e.length;if(t%4>0)throw Error(`Invalid string. Length must be a multiple of 4`);var n=e.indexOf(`=`);n===-1&&(n=t);var r=n===t?0:4-n%4;return[n,r]}function c(e){var t=s(e),n=t[0],r=t[1];return(n+r)*3/4-r}function l(e,t,n){return(t+n)*3/4-n}function u(e){var t,i=s(e),a=i[0],o=i[1],c=new r(l(e,a,o)),u=0,d=o>0?a-4:a,f;for(f=0;f<d;f+=4)t=n[e.charCodeAt(f)]<<18|n[e.charCodeAt(f+1)]<<12|n[e.charCodeAt(f+2)]<<6|n[e.charCodeAt(f+3)],c[u++]=t>>16&255,c[u++]=t>>8&255,c[u++]=t&255;return o===2&&(t=n[e.charCodeAt(f)]<<2|n[e.charCodeAt(f+1)]>>4,c[u++]=t&255),o===1&&(t=n[e.charCodeAt(f)]<<10|n[e.charCodeAt(f+1)]<<4|n[e.charCodeAt(f+2)]>>2,c[u++]=t>>8&255,c[u++]=t&255),c}function d(e){return t[e>>18&63]+t[e>>12&63]+t[e>>6&63]+t[e&63]}function f(e,t,n){for(var r,i=[],a=t;a<n;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(e[a+2]&255),i.push(d(r));return i.join(``)}function p(e){for(var n,r=e.length,i=r%3,a=[],o=16383,s=0,c=r-i;s<c;s+=o)a.push(f(e,s,s+o>c?c:s+o));return i===1?(n=e[r-1],a.push(t[n>>2]+t[n<<4&63]+`==`)):i===2&&(n=(e[r-2]<<8)+e[r-1],a.push(t[n>>10]+t[n>>4&63]+t[n<<2&63]+`=`)),a.join(``)}}));export{t};
@@ -0,0 +1,15 @@
1
+ import{a as e,n as t,r as n,t as r}from"./rolldown-runtime-DaDcL9Zw.js";import{_ as i,a,d as o,f as s,h as c,i as l,l as u,m as d,n as f,p,r as m,s as h,v as g,y as ee}from"./client-DchQnIJD.js";import{n as te,t as ne}from"./defineProperty-C-QyHrDq.js";import{G as re,n as ie,t as ae}from"./protocols-CnYQjBlj.js";import{c as oe,r as se}from"./serde-f76bObzR.js";import{Ht as ce,Lt as le,Pt as ue,Ut as de,t as fe}from"./dist-es-BOPBJQo3.js";import{Readable as pe}from"stream";import{Buffer as _}from"buffer";import me from"assert";import"https";function he(e,t){return new Request(e,t)}var ge=t((()=>{}));function _e(e=0){return new Promise((t,n)=>{e&&setTimeout(()=>{let t=Error(`Request did not complete within ${e} ms`);t.name=`TimeoutError`,n(t)},e)})}var ve=t((()=>{}));function ye(e){let t=e&&typeof e==`object`&&`reason`in e?e.reason:void 0;if(t){if(t instanceof Error){let e=Error(`Request aborted`);return e.name=`AbortError`,e.cause=t,e}let e=Error(String(t));return e.name=`AbortError`,e}let n=Error(`Request aborted`);return n.name=`AbortError`,n}var v,be,xe=t((()=>{ae(),ge(),ve(),te(),v={supported:void 0},be=class e{static create(t){return typeof t?.handle==`function`?t:new e(t)}constructor(e){ne(this,`config`,void 0),ne(this,`configProvider`,void 0),typeof e==`function`?this.configProvider=e().then(e=>e||{}):(this.config=e??{},this.configProvider=Promise.resolve(this.config)),v.supported===void 0&&(v.supported=typeof Request<`u`&&`keepalive`in he(`https://[::1]`))}destroy(){}async handle(e,{abortSignal:t,requestTimeout:n}={}){this.config||(this.config=await this.configProvider);let r=n??this.config.requestTimeout,i=this.config.keepAlive===!0,a=this.config.credentials;if(t?.aborted){let e=ye(t);return Promise.reject(e)}let o=e.path,s=ie(e.query||{});s&&(o+=`?${s}`),e.fragment&&(o+=`#${e.fragment}`);let c=``;(e.username!=null||e.password!=null)&&(c=`${e.username??``}:${e.password??``}@`);let{port:l,method:u}=e,d=`${e.protocol}//${c}${e.hostname}${l?`:${l}`:``}${o}`,f=u===`GET`||u===`HEAD`?void 0:e.body,p={body:f,headers:new Headers(e.headers),method:u,credentials:a};this.config?.cache&&(p.cache=this.config.cache),f&&(p.duplex=`half`),typeof AbortController<`u`&&(p.signal=t),v.supported&&(p.keepalive=i),typeof this.config.requestInit==`function`&&Object.assign(p,this.config.requestInit(e));let m=()=>{},h=he(d,p),g=[fetch(h).then(e=>{let t=e.headers,n={};for(let e of t.entries())n[e[0]]=e[1];return e.body==null?e.blob().then(t=>({response:new re({headers:n,reason:e.statusText,statusCode:e.status,body:t})})):{response:new re({headers:n,reason:e.statusText,statusCode:e.status,body:e.body})}}),_e(r)];return t&&g.push(new Promise((e,n)=>{let r=()=>{n(ye(t))};if(typeof t.addEventListener==`function`){let e=t;e.addEventListener(`abort`,r,{once:!0}),m=()=>e.removeEventListener(`abort`,r)}else t.onabort=r})),Promise.race(g).finally(m)}updateHttpClientConfig(e,t){this.config=void 0,this.configProvider=this.configProvider.then(n=>(n[e]=t,n))}httpHandlerConfigs(){return this.config??{}}}})),Se=t((()=>{xe(),se()})),y=n({__assign:()=>S,__asyncDelegator:()=>Le,__asyncGenerator:()=>Ie,__asyncValues:()=>Re,__await:()=>b,__awaiter:()=>Oe,__classPrivateFieldGet:()=>He,__classPrivateFieldSet:()=>Ue,__createBinding:()=>Ae,__decorate:()=>Te,__exportStar:()=>je,__extends:()=>Ce,__generator:()=>ke,__importDefault:()=>Ve,__importStar:()=>Be,__makeTemplateObject:()=>ze,__metadata:()=>De,__param:()=>Ee,__read:()=>Ne,__rest:()=>we,__spread:()=>Pe,__spreadArrays:()=>Fe,__values:()=>Me});function Ce(e,t){x(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function we(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function Te(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function Ee(e,t){return function(n,r){t(n,r,e)}}function De(e,t){if(typeof Reflect==`object`&&typeof Reflect.metadata==`function`)return Reflect.metadata(e,t)}function Oe(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||(n=Promise))(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function ke(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o;return o={next:s(0),throw:s(1),return:s(2)},typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(o){if(r)throw TypeError(`Generator is already executing.`);for(;n;)try{if(r=1,i&&(a=o[0]&2?i.return:o[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,o[1])).done)return a;switch(i=0,a&&(o=[o[0]&2,a.value]),o[0]){case 0:case 1:a=o;break;case 4:return n.label++,{value:o[1],done:!1};case 5:n.label++,i=o[1],o=[0];continue;case 7:o=n.ops.pop(),n.trys.pop();continue;default:if((a=n.trys,!(a=a.length>0&&a[a.length-1]))&&(o[0]===6||o[0]===2)){n=0;continue}if(o[0]===3&&(!a||o[1]>a[0]&&o[1]<a[3])){n.label=o[1];break}if(o[0]===6&&n.label<a[1]){n.label=a[1],a=o;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(o);break}a[2]&&n.ops.pop(),n.trys.pop();continue}o=t.call(e,n)}catch(e){o=[6,e],i=0}finally{r=a=0}if(o[0]&5)throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}}function Ae(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]}function je(e,t){for(var n in e)n!=="default"&&!t.hasOwnProperty(n)&&(t[n]=e[n])}function Me(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)}function Ne(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-->0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a}function Pe(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Ne(arguments[t]));return e}function Fe(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var r=Array(e),i=0,t=0;t<n;t++)for(var a=arguments[t],o=0,s=a.length;o<s;o++,i++)r[i]=a[o];return r}function b(e){return this instanceof b?(this.v=e,this):new b(e)}function Ie(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i={},o(`next`),o(`throw`),o(`return`),i[Symbol.asyncIterator]=function(){return this},i;function o(e){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||s(e,t)})})}function s(e,t){try{c(r[e](t))}catch(e){d(a[0][3],e)}}function c(e){e.value instanceof b?Promise.resolve(e.value.v).then(l,u):d(a[0][2],e)}function l(e){s(`next`,e)}function u(e){s(`throw`,e)}function d(e,t){e(t),a.shift(),a.length&&s(a[0][0],a[0][1])}}function Le(e){var t,n;return t={},r(`next`),r(`throw`,function(e){throw e}),r(`return`),t[Symbol.iterator]=function(){return this},t;function r(r,i){t[r]=e[r]?function(t){return(n=!n)?{value:b(e[r](t)),done:r===`return`}:i?i(t):t}:i}}function Re(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof Me==`function`?Me(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}}function ze(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function Be(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function Ve(e){return e&&e.__esModule?e:{default:e}}function He(e,t){if(!t.has(e))throw TypeError(`attempted to get private field on non-instance`);return t.get(e)}function Ue(e,t,n){if(!t.has(e))throw TypeError(`attempted to set private field on non-instance`);return t.set(e,n),n}var x,S,C=t((()=>{x=function(e,t){return x=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},x(e,t)},S=function(){return S=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},S.apply(this,arguments)}})),We=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.MAX_HASHABLE_LENGTH=e.INIT=e.KEY=e.DIGEST_LENGTH=e.BLOCK_SIZE=void 0,e.BLOCK_SIZE=64,e.DIGEST_LENGTH=32,e.KEY=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),e.INIT=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],e.MAX_HASHABLE_LENGTH=2**53-1})),Ge=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.RawSha256=void 0;var t=We();e.RawSha256=function(){function e(){this.state=Int32Array.from(t.INIT),this.temp=new Int32Array(64),this.buffer=new Uint8Array(64),this.bufferLength=0,this.bytesHashed=0,this.finished=!1}return e.prototype.update=function(e){if(this.finished)throw Error(`Attempted to update an already finished hash.`);var n=0,r=e.byteLength;if(this.bytesHashed+=r,this.bytesHashed*8>t.MAX_HASHABLE_LENGTH)throw Error(`Cannot hash more than 2^53 - 1 bits`);for(;r>0;)this.buffer[this.bufferLength++]=e[n++],r--,this.bufferLength===t.BLOCK_SIZE&&(this.hashBuffer(),this.bufferLength=0)},e.prototype.digest=function(){if(!this.finished){var e=this.bytesHashed*8,n=new DataView(this.buffer.buffer,this.buffer.byteOffset,this.buffer.byteLength),r=this.bufferLength;if(n.setUint8(this.bufferLength++,128),r%t.BLOCK_SIZE>=t.BLOCK_SIZE-8){for(var i=this.bufferLength;i<t.BLOCK_SIZE;i++)n.setUint8(i,0);this.hashBuffer(),this.bufferLength=0}for(var i=this.bufferLength;i<t.BLOCK_SIZE-8;i++)n.setUint8(i,0);n.setUint32(t.BLOCK_SIZE-8,Math.floor(e/4294967296),!0),n.setUint32(t.BLOCK_SIZE-4,e),this.hashBuffer(),this.finished=!0}for(var a=new Uint8Array(t.DIGEST_LENGTH),i=0;i<8;i++)a[i*4]=this.state[i]>>>24&255,a[i*4+1]=this.state[i]>>>16&255,a[i*4+2]=this.state[i]>>>8&255,a[i*4+3]=this.state[i]>>>0&255;return a},e.prototype.hashBuffer=function(){for(var e=this,n=e.buffer,r=e.state,i=r[0],a=r[1],o=r[2],s=r[3],c=r[4],l=r[5],u=r[6],d=r[7],f=0;f<t.BLOCK_SIZE;f++){if(f<16)this.temp[f]=(n[f*4]&255)<<24|(n[f*4+1]&255)<<16|(n[f*4+2]&255)<<8|n[f*4+3]&255;else{var p=this.temp[f-2],m=(p>>>17|p<<15)^(p>>>19|p<<13)^p>>>10;p=this.temp[f-15];var h=(p>>>7|p<<25)^(p>>>18|p<<14)^p>>>3;this.temp[f]=(m+this.temp[f-7]|0)+(h+this.temp[f-16]|0)}var g=(((c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7))+(c&l^~c&u)|0)+(d+(t.KEY[f]+this.temp[f]|0)|0)|0,ee=((i>>>2|i<<30)^(i>>>13|i<<19)^(i>>>22|i<<10))+(i&a^i&o^a&o)|0;d=u,u=l,l=c,c=s+g|0,s=o,o=a,a=i,i=g+ee|0}r[0]+=i,r[1]+=a,r[2]+=o,r[3]+=s,r[4]+=c,r[5]+=l,r[6]+=u,r[7]+=d},e}()})),Ke,qe,Je=t((()=>{Ke=e=>{let t=[];for(let n=0,r=e.length;n<r;n++){let r=e.charCodeAt(n);if(r<128)t.push(r);else if(r<2048)t.push(r>>6|192,r&63|128);else if(n+1<e.length&&(r&64512)==55296&&(e.charCodeAt(n+1)&64512)==56320){let i=65536+((r&1023)<<10)+(e.charCodeAt(++n)&1023);t.push(i>>18|240,i>>12&63|128,i>>6&63|128,i&63|128)}else t.push(r>>12|224,r>>6&63|128,r&63|128)}return Uint8Array.from(t)},qe=e=>{let t=``;for(let n=0,r=e.length;n<r;n++){let r=e[n];if(r<128)t+=String.fromCharCode(r);else if(192<=r&&r<224){let i=e[++n];t+=String.fromCharCode((r&31)<<6|i&63)}else if(240<=r&&r<365){let i=`%`+[r,e[++n],e[++n],e[++n]].map(e=>e.toString(16)).join(`%`);t+=decodeURIComponent(i)}else t+=String.fromCharCode((r&15)<<12|(e[++n]&63)<<6|e[++n]&63)}return t}}));function Ye(e){return new TextEncoder().encode(e)}function Xe(e){return new TextDecoder(`utf-8`).decode(e)}var Ze=t((()=>{})),Qe=n({fromUtf8:()=>$e,toUtf8:()=>et}),$e,et,tt=t((()=>{Je(),Ze(),$e=e=>typeof TextEncoder==`function`?Ye(e):Ke(e),et=e=>typeof TextDecoder==`function`?Xe(e):qe(e)})),nt=r((t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.convertToBuffer=void 0;var n=(tt(),e(Qe)),r=typeof Buffer<`u`&&Buffer.from?function(e){return Buffer.from(e,`utf8`)}:n.fromUtf8;function i(e){return e instanceof Uint8Array?e:typeof e==`string`?r(e):ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength/Uint8Array.BYTES_PER_ELEMENT):new Uint8Array(e)}t.convertToBuffer=i})),rt=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isEmptyData=void 0;function t(e){return typeof e==`string`?e.length===0:e.byteLength===0}e.isEmptyData=t})),it=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.numToUint8=void 0;function t(e){return new Uint8Array([(e&4278190080)>>24,(e&16711680)>>16,(e&65280)>>8,e&255])}e.numToUint8=t})),at=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.uint32ArrayFrom=void 0;function t(e){if(!Uint32Array.from){for(var t=new Uint32Array(e.length),n=0;n<e.length;)t[n]=e[n],n+=1;return t}return Uint32Array.from(e)}e.uint32ArrayFrom=t})),ot=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.uint32ArrayFrom=e.numToUint8=e.isEmptyData=e.convertToBuffer=void 0;var t=nt();Object.defineProperty(e,"convertToBuffer",{enumerable:!0,get:function(){return t.convertToBuffer}});var n=rt();Object.defineProperty(e,"isEmptyData",{enumerable:!0,get:function(){return n.isEmptyData}});var r=it();Object.defineProperty(e,"numToUint8",{enumerable:!0,get:function(){return r.numToUint8}});var i=at();Object.defineProperty(e,"uint32ArrayFrom",{enumerable:!0,get:function(){return i.uint32ArrayFrom}})})),st=r((t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Sha256=void 0;var n=(C(),e(y)),r=We(),i=Ge(),a=ot();t.Sha256=function(){function e(e){this.secret=e,this.hash=new i.RawSha256,this.reset()}return e.prototype.update=function(e){if(!((0,a.isEmptyData)(e)||this.error))try{this.hash.update((0,a.convertToBuffer)(e))}catch(e){this.error=e}},e.prototype.digestSync=function(){if(this.error)throw this.error;return this.outer?(this.outer.finished||this.outer.update(this.hash.digest()),this.outer.digest()):this.hash.digest()},e.prototype.digest=function(){return n.__awaiter(this,void 0,void 0,function(){return n.__generator(this,function(e){return[2,this.digestSync()]})})},e.prototype.reset=function(){if(this.hash=new i.RawSha256,this.secret){this.outer=new i.RawSha256;var e=o(this.secret),t=new Uint8Array(r.BLOCK_SIZE);t.set(e);for(var n=0;n<r.BLOCK_SIZE;n++)e[n]^=54,t[n]^=92;this.hash.update(e),this.outer.update(t);for(var n=0;n<e.byteLength;n++)e[n]=0}},e}();function o(e){var t=(0,a.convertToBuffer)(e);if(t.byteLength>r.BLOCK_SIZE){var n=new i.RawSha256;n.update(t),t=n.digest()}var o=new Uint8Array(r.BLOCK_SIZE);return o.set(t),o}})),ct=r((t=>{Object.defineProperty(t,"__esModule",{value:!0}),(C(),e(y)).__exportStar(st(),t)})),lt=t((()=>{})),ut=t((()=>{lt()})),dt=t((()=>{})),ft,pt=t((()=>{(function(e){e.HEADER=`header`,e.QUERY=`query`})(ft||(ft={}))})),mt,ht=t((()=>{(function(e){e.HEADER=`header`,e.QUERY=`query`})(mt||(mt={}))})),gt=t((()=>{})),_t=t((()=>{})),vt=t((()=>{})),yt=t((()=>{})),bt=t((()=>{pt(),ht(),gt(),_t(),vt(),yt()})),xt=t((()=>{})),St=t((()=>{})),Ct=t((()=>{})),wt=t((()=>{})),Tt=t((()=>{})),Et=t((()=>{})),Dt=t((()=>{})),Ot=t((()=>{Tt(),Et(),Dt()})),kt=t((()=>{})),At=t((()=>{})),jt,Mt=t((()=>{(function(e){e.HTTP=`http`,e.HTTPS=`https`})(jt||(jt={}))})),Nt=t((()=>{})),Pt=t((()=>{})),Ft=t((()=>{})),It=t((()=>{})),Lt=t((()=>{})),Rt=t((()=>{Nt(),Pt(),Ft(),It(),Lt()})),zt=t((()=>{})),Bt,Vt=t((()=>{(function(e){e.MD5=`md5`,e.CRC32=`crc32`,e.CRC32C=`crc32c`,e.SHA1=`sha1`,e.SHA256=`sha256`})(Bt||(Bt={}))})),Ht=t((()=>{Vt()})),Ut=t((()=>{})),Wt=t((()=>{Ht(),Ut(),Vt()})),Gt,Kt=t((()=>{(function(e){e[e.HEADER=0]=`HEADER`,e[e.TRAILER=1]=`TRAILER`})(Gt||(Gt={}))})),qt=t((()=>{})),Jt=t((()=>{})),Yt=t((()=>{})),Xt=t((()=>{})),Zt=t((()=>{})),Qt=t((()=>{Jt(),Yt(),Xt(),Zt()})),$t=t((()=>{})),en=t((()=>{})),tn=t((()=>{})),nn,rn=t((()=>{(function(e){e.PROFILE=`profile`,e.SSO_SESSION=`sso-session`,e.SERVICES=`services`})(nn||(nn={}))})),an=t((()=>{})),on=t((()=>{})),sn=t((()=>{})),cn=t((()=>{})),ln=t((()=>{})),un=t((()=>{})),dn=t((()=>{})),fn=t((()=>{})),pn=t((()=>{})),mn,hn=t((()=>{(function(e){e.HTTP_0_9=`http/0.9`,e.HTTP_1_0=`http/1.0`,e.TDS_8_0=`tds/8.0`})(mn||(mn={}))})),gn=t((()=>{})),_n=t((()=>{})),vn=t((()=>{})),yn=t((()=>{})),bn=t((()=>{})),xn=t((()=>{})),Sn=t((()=>{dt(),bt(),xt(),St(),Ct(),wt(),Ot(),kt(),At(),Mt(),Rt(),zt(),Wt(),Kt(),qt(),Qt(),$t(),en(),tn(),rn(),an(),on(),sn(),cn(),ln(),un(),dn(),fn(),pn(),hn(),gn(),_n(),vn(),yn(),bn(),xn()})),Cn=t((()=>{Sn()})),wn=t((()=>{})),Tn=t((()=>{}));function En(e){return Object.keys(e).reduce((t,n)=>{let r=e[n];return{...t,[n]:Array.isArray(r)?[...r]:r}},{})}var Dn,On=t((()=>{Dn=class e{constructor(e){this.method=e.method||`GET`,this.hostname=e.hostname||`localhost`,this.port=e.port,this.query=e.query||{},this.headers=e.headers||{},this.body=e.body,this.protocol=e.protocol?e.protocol.slice(-1)===`:`?e.protocol:`${e.protocol}:`:`https:`,this.path=e.path?e.path.charAt(0)===`/`?e.path:`/${e.path}`:`/`,this.username=e.username,this.password=e.password,this.fragment=e.fragment}static isInstance(e){if(!e)return!1;let t=e;return`method`in t&&`protocol`in t&&`hostname`in t&&`path`in t&&typeof t.query==`object`&&typeof t.headers==`object`}clone(){let t=new e({...this,headers:{...this.headers}});return t.query&&(t.query=En(t.query)),t}}})),kn=t((()=>{})),An=t((()=>{})),jn=t((()=>{})),w=t((()=>{ut(),Cn(),wn(),Tn(),On(),kn(),An(),jn()}));function Mn(e){if(e.length%2!=0)throw Error(`Hex encoded strings must have an even number length`);let t=new Uint8Array(e.length/2);for(let n=0;n<e.length;n+=2){let r=e.slice(n,n+2).toLowerCase();if(r in E)t[n/2]=E[r];else throw Error(`Cannot decode unrecognized sequence ${r} as hexadecimal`)}return t}function T(e){let t=``;for(let n=0;n<e.byteLength;n++)t+=Nn[e[n]];return t}var Nn,E,D=t((()=>{Nn={},E={};for(let e=0;e<256;e++){let t=e.toString(16).toLowerCase();t.length===1&&(t=`0${t}`),Nn[e]=t,E[t]=e}})),Pn=t((()=>{})),Fn,In=t((()=>{(function(e){e.HEADER=`header`,e.QUERY=`query`})(Fn||(Fn={}))})),Ln,Rn=t((()=>{(function(e){e.HEADER=`header`,e.QUERY=`query`})(Ln||(Ln={}))})),zn=t((()=>{})),Bn=t((()=>{})),Vn=t((()=>{})),Hn=t((()=>{})),Un=t((()=>{In(),Rn(),zn(),Bn(),Vn(),Hn()})),Wn=t((()=>{})),Gn=t((()=>{})),Kn=t((()=>{})),qn=t((()=>{})),Jn=t((()=>{})),Yn=t((()=>{})),Xn=t((()=>{})),Zn=t((()=>{Jn(),Yn(),Xn()})),Qn=t((()=>{})),$n=t((()=>{})),er,tr=t((()=>{(function(e){e.HTTP=`http`,e.HTTPS=`https`})(er||(er={}))})),nr=t((()=>{})),rr=t((()=>{})),ir=t((()=>{})),ar=t((()=>{})),or=t((()=>{})),sr=t((()=>{nr(),rr(),ir(),ar(),or()})),cr=t((()=>{})),lr,ur=t((()=>{(function(e){e.MD5=`md5`,e.CRC32=`crc32`,e.CRC32C=`crc32c`,e.SHA1=`sha1`,e.SHA256=`sha256`})(lr||(lr={}))})),dr=t((()=>{ur()})),fr=t((()=>{})),pr=t((()=>{dr(),fr(),ur()})),mr=t((()=>{})),hr,gr=t((()=>{(function(e){e[e.HEADER=0]=`HEADER`,e[e.TRAILER=1]=`TRAILER`})(hr||(hr={}))})),_r=t((()=>{})),vr=t((()=>{})),yr=t((()=>{})),br=t((()=>{})),xr=t((()=>{})),Sr=t((()=>{vr(),yr(),br(),xr()})),Cr=t((()=>{})),wr=t((()=>{})),Tr=t((()=>{})),Er,Dr=t((()=>{(function(e){e.PROFILE=`profile`,e.SSO_SESSION=`sso-session`,e.SERVICES=`services`})(Er||(Er={}))})),Or=t((()=>{})),kr=t((()=>{})),Ar=t((()=>{})),jr=t((()=>{})),Mr=t((()=>{})),Nr=t((()=>{})),Pr=t((()=>{})),Fr=t((()=>{})),Ir=t((()=>{})),Lr,Rr=t((()=>{(function(e){e.HTTP_0_9=`http/0.9`,e.HTTP_1_0=`http/1.0`,e.TDS_8_0=`tds/8.0`})(Lr||(Lr={}))})),zr=t((()=>{})),Br=t((()=>{})),Vr=t((()=>{})),Hr=t((()=>{})),Ur=t((()=>{})),Wr=t((()=>{})),Gr=t((()=>{Pn(),Un(),Wn(),Gn(),Kn(),qn(),Zn(),Qn(),$n(),tr(),sr(),cr(),pr(),mr(),gr(),_r(),Sr(),Cr(),wr(),Tr(),Dr(),Or(),kr(),Ar(),jr(),Mr(),Nr(),Pr(),Fr(),Ir(),Rr(),zr(),Br(),Vr(),Hr(),Ur(),Wr()})),Kr=t((()=>{Gr()})),qr,Jr=t((()=>{qr=e=>{if(typeof e==`function`)return e;let t=Promise.resolve(e);return()=>t}})),Yr=t((()=>{Kr(),Jr()})),O,Xr,Zr=t((()=>{O=e=>encodeURIComponent(e).replace(/[!'()*]/g,Xr),Xr=e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`})),Qr=t((()=>{})),$r=t((()=>{Zr(),Qr()})),ei,ti=t((()=>{ei=e=>typeof ArrayBuffer==`function`&&e instanceof ArrayBuffer||Object.prototype.toString.call(e)===`[object ArrayBuffer]`})),ni,ri=t((()=>{ni=(e,t)=>{if(typeof e!=`string`)throw TypeError(`The "input" argument must be of type string. Received type ${typeof e} (${e})`);return t?_.from(e,t):_.from(e)}})),k,ii=t((()=>{ri(),k=e=>{let t=ni(e,`utf8`);return new Uint8Array(t.buffer,t.byteOffset,t.byteLength/Uint8Array.BYTES_PER_ELEMENT)}})),A,ai=t((()=>{ii(),A=e=>typeof e==`string`?k(e):ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength/Uint8Array.BYTES_PER_ELEMENT):new Uint8Array(e)})),oi=t((()=>{})),j=t((()=>{ii(),ai(),oi()})),si,ci,li,ui,di,fi,pi,mi,hi,gi,_i,vi,yi,bi,xi,Si,M,Ci,wi,Ti,N=t((()=>{si=`X-Amz-Algorithm`,ci=`X-Amz-Credential`,li=`X-Amz-Date`,ui=`X-Amz-SignedHeaders`,di=`X-Amz-Expires`,fi=`X-Amz-Signature`,pi=`X-Amz-Security-Token`,mi=`authorization`,hi=li.toLowerCase(),gi=`date`,_i=[mi,hi,gi],fi.toLowerCase(),vi=`x-amz-content-sha256`,yi=pi.toLowerCase(),bi={authorization:!0,"cache-control":!0,connection:!0,expect:!0,from:!0,"keep-alive":!0,"max-forwards":!0,pragma:!0,referer:!0,te:!0,trailer:!0,"transfer-encoding":!0,upgrade:!0,"user-agent":!0,"x-amzn-trace-id":!0},xi=/^proxy-/,Si=/^sec-/,M=`AWS4-HMAC-SHA256`,Ci=`AWS4-HMAC-SHA256-PAYLOAD`,wi=`UNSIGNED-PAYLOAD`,Ti=`aws4_request`})),P,F,I,Ei,Di,Oi=t((()=>{D(),j(),N(),P={},F=[],I=(e,t,n)=>`${e}/${t}/${n}/${Ti}`,Ei=async(e,t,n,r,i)=>{let a=`${n}:${r}:${i}:${T(await Di(e,t.secretAccessKey,t.accessKeyId))}:${t.sessionToken}`;if(a in P)return P[a];for(F.push(a);F.length>50;)delete P[F.shift()];let o=`AWS4${t.secretAccessKey}`;for(let t of[n,r,i,Ti])o=await Di(e,o,t);return P[a]=o},Di=(e,t,n)=>{let r=new e(t);return r.update(A(n)),r.digest()}})),ki,Ai=t((()=>{N(),ki=({headers:e},t,n)=>{let r={};for(let i of Object.keys(e).sort()){if(e[i]==null)continue;let a=i.toLowerCase();(a in bi||t?.has(a)||xi.test(a)||Si.test(a))&&(!n||n&&!n.has(a))||(r[a]=e[i].trim().replace(/\s+/g,` `))}return r}})),ji,Mi=t((()=>{$r(),N(),ji=({query:e={}})=>{let t=[],n={};for(let r of Object.keys(e).sort()){if(r.toLowerCase()===`x-amz-signature`)continue;t.push(r);let i=e[r];typeof i==`string`?n[r]=`${O(r)}=${O(i)}`:Array.isArray(i)&&(n[r]=i.slice(0).reduce((e,t)=>e.concat([`${O(r)}=${O(t)}`]),[]).sort().join(`&`))}return t.map(e=>n[e]).filter(e=>e).join(`&`)}})),L,Ni=t((()=>{ti(),D(),j(),N(),L=async({headers:e,body:t},n)=>{for(let t of Object.keys(e))if(t.toLowerCase()===`x-amz-content-sha256`)return e[t];if(t==null)return`e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855`;if(typeof t==`string`||ArrayBuffer.isView(t)||ei(t)){let e=new n;return e.update(A(t)),T(await e.digest())}return wi}}));function Pi(e){for(let t=0;t<8;t++)e[t]^=255;for(let t=7;t>-1&&(e[t]++,e[t]===0);t--);}var Fi,Ii,Li,Ri,zi=t((()=>{D(),j(),Fi=class{format(e){let t=[];for(let n of Object.keys(e)){let r=k(n);t.push(Uint8Array.from([r.byteLength]),r,this.formatHeaderValue(e[n]))}let n=new Uint8Array(t.reduce((e,t)=>e+t.byteLength,0)),r=0;for(let e of t)n.set(e,r),r+=e.byteLength;return n}formatHeaderValue(e){switch(e.type){case`boolean`:return Uint8Array.from([+!e.value]);case`byte`:return Uint8Array.from([2,e.value]);case`short`:let t=new DataView(new ArrayBuffer(3));return t.setUint8(0,3),t.setInt16(1,e.value,!1),new Uint8Array(t.buffer);case`integer`:let n=new DataView(new ArrayBuffer(5));return n.setUint8(0,4),n.setInt32(1,e.value,!1),new Uint8Array(n.buffer);case`long`:let r=new Uint8Array(9);return r[0]=5,r.set(e.value.bytes,1),r;case`binary`:let i=new DataView(new ArrayBuffer(3+e.value.byteLength));i.setUint8(0,6),i.setUint16(1,e.value.byteLength,!1);let a=new Uint8Array(i.buffer);return a.set(e.value,3),a;case`string`:let o=k(e.value),s=new DataView(new ArrayBuffer(3+o.byteLength));s.setUint8(0,7),s.setUint16(1,o.byteLength,!1);let c=new Uint8Array(s.buffer);return c.set(o,3),c;case`timestamp`:let l=new Uint8Array(9);return l[0]=8,l.set(Ri.fromNumber(e.value.valueOf()).bytes,1),l;case`uuid`:if(!Li.test(e.value))throw Error(`Invalid UUID received: ${e.value}`);let u=new Uint8Array(17);return u[0]=9,u.set(Mn(e.value.replace(/\-/g,``)),1),u}}},(function(e){e[e.boolTrue=0]=`boolTrue`,e[e.boolFalse=1]=`boolFalse`,e[e.byte=2]=`byte`,e[e.short=3]=`short`,e[e.integer=4]=`integer`,e[e.long=5]=`long`,e[e.byteArray=6]=`byteArray`,e[e.string=7]=`string`,e[e.timestamp=8]=`timestamp`,e[e.uuid=9]=`uuid`})(Ii||(Ii={})),Li=/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/,Ri=class e{constructor(e){if(this.bytes=e,e.byteLength!==8)throw Error(`Int64 buffers must be exactly 8 bytes`)}static fromNumber(t){if(t>0x8000000000000000||t<-0x8000000000000000)throw Error(`${t} is too large (or, if negative, too small) to represent as an Int64`);let n=new Uint8Array(8);for(let e=7,r=Math.abs(Math.round(t));e>-1&&r>0;e--,r/=256)n[e]=r;return t<0&&Pi(n),new e(n)}valueOf(){let e=this.bytes.slice(0),t=e[0]&128;return t&&Pi(e),parseInt(T(e),16)*(t?-1:1)}toString(){return String(this.valueOf())}}})),Bi,Vi=t((()=>{Bi=(e,t)=>{e=e.toLowerCase();for(let n of Object.keys(t))if(e===n.toLowerCase())return!0;return!1}})),Hi,Ui,Wi=t((()=>{Hi=({headers:e,query:t,...n})=>({...n,headers:{...e},query:t?Ui(t):void 0}),Ui=e=>Object.keys(e).reduce((t,n)=>{let r=e[n];return{...t,[n]:Array.isArray(r)?[...r]:r}},{})})),Gi,Ki=t((()=>{Wi(),Gi=(e,t={})=>{let{headers:n,query:r={}}=typeof e.clone==`function`?e.clone():Hi(e);for(let e of Object.keys(n)){let i=e.toLowerCase();i.slice(0,6)===`x-amz-`&&!t.unhoistableHeaders?.has(i)&&(r[e]=n[e],delete n[e])}return{...e,headers:n,query:r}}})),qi,Ji=t((()=>{Wi(),N(),qi=e=>{e=typeof e.clone==`function`?e.clone():Hi(e);for(let t of Object.keys(e.headers))_i.indexOf(t.toLowerCase())>-1&&delete e.headers[t];return e}})),Yi,Xi,Zi=t((()=>{Yi=e=>Xi(e).toISOString().replace(/\.\d{3}Z$/,`Z`),Xi=e=>typeof e==`number`?new Date(e*1e3):typeof e==`string`?Number(e)?new Date(Number(e)*1e3):new Date(e):e})),Qi,R,$i,ea=t((()=>{D(),Yr(),$r(),j(),N(),Oi(),Ai(),Mi(),Ni(),zi(),Vi(),Ki(),Ji(),Zi(),Qi=class{constructor({applyChecksum:e,credentials:t,region:n,service:r,sha256:i,uriEscapePath:a=!0}){this.headerFormatter=new Fi,this.service=r,this.sha256=i,this.uriEscapePath=a,this.applyChecksum=typeof e!=`boolean`||e,this.regionProvider=qr(n),this.credentialProvider=qr(t)}async presign(e,t={}){let{signingDate:n=new Date,expiresIn:r=3600,unsignableHeaders:i,unhoistableHeaders:a,signableHeaders:o,signingRegion:s,signingService:c}=t,l=await this.credentialProvider();this.validateResolvedCredentials(l);let u=s??await this.regionProvider(),{longDate:d,shortDate:f}=R(n);if(r>604800)return Promise.reject(`Signature version 4 presigned URLs must have an expiration date less than one week in the future`);let p=I(f,u,c??this.service),m=Gi(qi(e),{unhoistableHeaders:a});l.sessionToken&&(m.query[pi]=l.sessionToken),m.query[si]=M,m.query[ci]=`${l.accessKeyId}/${p}`,m.query[li]=d,m.query[di]=r.toString(10);let h=ki(m,i,o);return m.query[ui]=$i(h),m.query[fi]=await this.getSignature(d,p,this.getSigningKey(l,u,f,c),this.createCanonicalRequest(m,h,await L(e,this.sha256))),m}async sign(e,t){return typeof e==`string`?this.signString(e,t):e.headers&&e.payload?this.signEvent(e,t):e.message?this.signMessage(e,t):this.signRequest(e,t)}async signEvent({headers:e,payload:t},{signingDate:n=new Date,priorSignature:r,signingRegion:i,signingService:a}){let o=i??await this.regionProvider(),{shortDate:s,longDate:c}=R(n),l=I(s,o,a??this.service),u=await L({headers:{},body:t},this.sha256),d=new this.sha256;d.update(e);let f=[Ci,c,l,r,T(await d.digest()),u].join(`
2
+ `);return this.signString(f,{signingDate:n,signingRegion:o,signingService:a})}async signMessage(e,{signingDate:t=new Date,signingRegion:n,signingService:r}){return this.signEvent({headers:this.headerFormatter.format(e.message.headers),payload:e.message.body},{signingDate:t,signingRegion:n,signingService:r,priorSignature:e.priorSignature}).then(t=>({message:e.message,signature:t}))}async signString(e,{signingDate:t=new Date,signingRegion:n,signingService:r}={}){let i=await this.credentialProvider();this.validateResolvedCredentials(i);let a=n??await this.regionProvider(),{shortDate:o}=R(t),s=new this.sha256(await this.getSigningKey(i,a,o,r));return s.update(A(e)),T(await s.digest())}async signRequest(e,{signingDate:t=new Date,signableHeaders:n,unsignableHeaders:r,signingRegion:i,signingService:a}={}){let o=await this.credentialProvider();this.validateResolvedCredentials(o);let s=i??await this.regionProvider(),c=qi(e),{longDate:l,shortDate:u}=R(t),d=I(u,s,a??this.service);c.headers[hi]=l,o.sessionToken&&(c.headers[yi]=o.sessionToken);let f=await L(c,this.sha256);!Bi(`x-amz-content-sha256`,c.headers)&&this.applyChecksum&&(c.headers[vi]=f);let p=ki(c,r,n),m=await this.getSignature(l,d,this.getSigningKey(o,s,u,a),this.createCanonicalRequest(c,p,f));return c.headers[mi]=`${M} Credential=${o.accessKeyId}/${d}, SignedHeaders=${$i(p)}, Signature=${m}`,c}createCanonicalRequest(e,t,n){let r=Object.keys(t).sort();return`${e.method}
3
+ ${this.getCanonicalPath(e)}
4
+ ${ji(e)}
5
+ ${r.map(e=>`${e}:${t[e]}`).join(`
6
+ `)}
7
+
8
+ ${r.join(`;`)}
9
+ ${n}`}async createStringToSign(e,t,n){let r=new this.sha256;return r.update(A(n)),`${M}
10
+ ${e}
11
+ ${t}
12
+ ${T(await r.digest())}`}getCanonicalPath({path:e}){if(this.uriEscapePath){let t=[];for(let n of e.split(`/`))n?.length!==0&&n!==`.`&&(n===`..`?t.pop():t.push(n));return O(`${e?.startsWith(`/`)?`/`:``}${t.join(`/`)}${t.length>0&&e?.endsWith(`/`)?`/`:``}`).replace(/%2F/g,`/`)}return e}async getSignature(e,t,n,r){let i=await this.createStringToSign(e,t,r),a=new this.sha256(await n);return a.update(A(i)),T(await a.digest())}getSigningKey(e,t,n,r){return Ei(this.sha256,e,n,t,r||this.service)}validateResolvedCredentials(e){if(typeof e!=`object`||typeof e.accessKeyId!=`string`||typeof e.secretAccessKey!=`string`)throw Error(`Resolved credential object is not valid`)}},R=e=>{let t=Yi(e).replace(/[\-:]/g,``);return{longDate:t,shortDate:t.slice(0,8)}},$i=e=>Object.keys(e).sort().join(`;`)})),ta=t((()=>{ea(),Ai(),Mi(),Ni(),Ki(),Ji(),Oi()})),na,ra,ia,aa=t((()=>{na=ct(),Se(),w(),ta(),ra=()=>import(`./dist-es-CIULjvtA2.js`).then(({fromNodeProviderChain:e})=>e({clientConfig:{requestHandler:new be({requestInit:e=>({...e})})}})).catch(e=>{throw Error(`Failed to import '@aws-sdk/credential-providers'.You can provide a custom \`providerChainResolver\` in the client options if your runtime does not have access to '@aws-sdk/credential-providers': \`new AnthropicBedrock({ providerChainResolver })\` Original error: ${e.message}`)}),ia=async(e,t)=>{me(e.method,`Expected request method property to be set`);let n;n=t.awsAccessKey&&t.awsSecretKey?{accessKeyId:t.awsAccessKey,secretAccessKey:t.awsSecretKey,...t.awsSessionToken!=null&&{sessionToken:t.awsSessionToken}}:await(await(t.providerChainResolver?t.providerChainResolver():ra()))();let r=new Qi({service:`bedrock`,region:t.regionName,credentials:n,sha256:na.Sha256}),i=new URL(t.url),a=e.headers?Symbol.iterator in e.headers?Object.fromEntries(Array.from(e.headers).map(e=>[...e])):{...e.headers}:{};delete a.connection,a.host=i.hostname;let o=new Dn({method:e.method.toUpperCase(),protocol:i.protocol,path:i.pathname,headers:a,body:e.body});return(await r.sign(o)).headers}})),oa=r((t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.convertToBuffer=void 0;var n=(tt(),e(Qe)),r=typeof Buffer<`u`&&Buffer.from?function(e){return Buffer.from(e,`utf8`)}:n.fromUtf8;function i(e){return e instanceof Uint8Array?e:typeof e==`string`?r(e):ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength/Uint8Array.BYTES_PER_ELEMENT):new Uint8Array(e)}t.convertToBuffer=i})),sa=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isEmptyData=void 0;function t(e){return typeof e==`string`?e.length===0:e.byteLength===0}e.isEmptyData=t})),ca=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.numToUint8=void 0;function t(e){return new Uint8Array([(e&4278190080)>>24,(e&16711680)>>16,(e&65280)>>8,e&255])}e.numToUint8=t})),la=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.uint32ArrayFrom=void 0;function t(e){if(!Uint32Array.from){for(var t=new Uint32Array(e.length),n=0;n<e.length;)t[n]=e[n],n+=1;return t}return Uint32Array.from(e)}e.uint32ArrayFrom=t})),ua=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.uint32ArrayFrom=e.numToUint8=e.isEmptyData=e.convertToBuffer=void 0;var t=oa();Object.defineProperty(e,"convertToBuffer",{enumerable:!0,get:function(){return t.convertToBuffer}});var n=sa();Object.defineProperty(e,"isEmptyData",{enumerable:!0,get:function(){return n.isEmptyData}});var r=ca();Object.defineProperty(e,"numToUint8",{enumerable:!0,get:function(){return r.numToUint8}});var i=la();Object.defineProperty(e,"uint32ArrayFrom",{enumerable:!0,get:function(){return i.uint32ArrayFrom}})})),da=r((t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AwsCrc32=void 0;var n=(C(),e(y)),r=ua(),i=fa();t.AwsCrc32=function(){function e(){this.crc32=new i.Crc32}return e.prototype.update=function(e){(0,r.isEmptyData)(e)||this.crc32.update((0,r.convertToBuffer)(e))},e.prototype.digest=function(){return n.__awaiter(this,void 0,void 0,function(){return n.__generator(this,function(e){return[2,(0,r.numToUint8)(this.crc32.digest())]})})},e.prototype.reset=function(){this.crc32=new i.Crc32},e}()})),fa=r((t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AwsCrc32=t.Crc32=t.crc32=void 0;var n=(C(),e(y)),r=ua();function i(e){return new a().update(e).digest()}t.crc32=i;var a=function(){function e(){this.checksum=4294967295}return e.prototype.update=function(e){var t,r;try{for(var i=n.__values(e),a=i.next();!a.done;a=i.next()){var s=a.value;this.checksum=this.checksum>>>8^o[(this.checksum^s)&255]}}catch(e){t={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}return this},e.prototype.digest=function(){return(this.checksum^4294967295)>>>0},e}();t.Crc32=a;var o=(0,r.uint32ArrayFrom)([0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117]),s=da();Object.defineProperty(t,"AwsCrc32",{enumerable:!0,get:function(){return s.AwsCrc32}})}));function pa(e){if(e.length%2!=0)throw Error(`Hex encoded strings must have an even number length`);let t=new Uint8Array(e.length/2);for(let n=0;n<e.length;n+=2){let r=e.slice(n,n+2).toLowerCase();if(r in B)t[n/2]=B[r];else throw Error(`Cannot decode unrecognized sequence ${r} as hexadecimal`)}return t}function z(e){let t=``;for(let n=0;n<e.byteLength;n++)t+=ma[e[n]];return t}var ma,B,ha=t((()=>{ma={},B={};for(let e=0;e<256;e++){let t=e.toString(16).toLowerCase();t.length===1&&(t=`0${t}`),ma[e]=t,B[t]=e}}));function ga(e){for(let t=0;t<8;t++)e[t]^=255;for(let t=7;t>-1&&(e[t]++,e[t]===0);t--);}var V,_a=t((()=>{ha(),V=class e{constructor(e){if(this.bytes=e,e.byteLength!==8)throw Error(`Int64 buffers must be exactly 8 bytes`)}static fromNumber(t){if(t>0x8000000000000000||t<-0x8000000000000000)throw Error(`${t} is too large (or, if negative, too small) to represent as an Int64`);let n=new Uint8Array(8);for(let e=7,r=Math.abs(Math.round(t));e>-1&&r>0;e--,r/=256)n[e]=r;return t<0&&ga(n),new e(n)}valueOf(){let e=this.bytes.slice(0),t=e[0]&128;return t&&ga(e),parseInt(z(e),16)*(t?-1:1)}toString(){return String(this.valueOf())}}})),va,ya,ba,xa,Sa,Ca,wa,Ta,Ea,Da,Oa,ka,Aa=t((()=>{ha(),_a(),va=class{constructor(e,t){this.toUtf8=e,this.fromUtf8=t}format(e){let t=[];for(let n of Object.keys(e)){let r=this.fromUtf8(n);t.push(Uint8Array.from([r.byteLength]),r,this.formatHeaderValue(e[n]))}let n=new Uint8Array(t.reduce((e,t)=>e+t.byteLength,0)),r=0;for(let e of t)n.set(e,r),r+=e.byteLength;return n}formatHeaderValue(e){switch(e.type){case`boolean`:return Uint8Array.from([+!e.value]);case`byte`:return Uint8Array.from([2,e.value]);case`short`:let t=new DataView(new ArrayBuffer(3));return t.setUint8(0,3),t.setInt16(1,e.value,!1),new Uint8Array(t.buffer);case`integer`:let n=new DataView(new ArrayBuffer(5));return n.setUint8(0,4),n.setInt32(1,e.value,!1),new Uint8Array(n.buffer);case`long`:let r=new Uint8Array(9);return r[0]=5,r.set(e.value.bytes,1),r;case`binary`:let i=new DataView(new ArrayBuffer(3+e.value.byteLength));i.setUint8(0,6),i.setUint16(1,e.value.byteLength,!1);let a=new Uint8Array(i.buffer);return a.set(e.value,3),a;case`string`:let o=this.fromUtf8(e.value),s=new DataView(new ArrayBuffer(3+o.byteLength));s.setUint8(0,7),s.setUint16(1,o.byteLength,!1);let c=new Uint8Array(s.buffer);return c.set(o,3),c;case`timestamp`:let l=new Uint8Array(9);return l[0]=8,l.set(V.fromNumber(e.value.valueOf()).bytes,1),l;case`uuid`:if(!ka.test(e.value))throw Error(`Invalid UUID received: ${e.value}`);let u=new Uint8Array(17);return u[0]=9,u.set(pa(e.value.replace(/\-/g,``)),1),u}}parse(e){let t={},n=0;for(;n<e.byteLength;){let r=e.getUint8(n++),i=this.toUtf8(new Uint8Array(e.buffer,e.byteOffset+n,r));switch(n+=r,e.getUint8(n++)){case 0:t[i]={type:ba,value:!0};break;case 1:t[i]={type:ba,value:!1};break;case 2:t[i]={type:xa,value:e.getInt8(n++)};break;case 3:t[i]={type:Sa,value:e.getInt16(n,!1)},n+=2;break;case 4:t[i]={type:Ca,value:e.getInt32(n,!1)},n+=4;break;case 5:t[i]={type:wa,value:new V(new Uint8Array(e.buffer,e.byteOffset+n,8))},n+=8;break;case 6:let r=e.getUint16(n,!1);n+=2,t[i]={type:Ta,value:new Uint8Array(e.buffer,e.byteOffset+n,r)},n+=r;break;case 7:let a=e.getUint16(n,!1);n+=2,t[i]={type:Ea,value:this.toUtf8(new Uint8Array(e.buffer,e.byteOffset+n,a))},n+=a;break;case 8:t[i]={type:Da,value:new Date(new V(new Uint8Array(e.buffer,e.byteOffset+n,8)).valueOf())},n+=8;break;case 9:let o=new Uint8Array(e.buffer,e.byteOffset+n,16);n+=16,t[i]={type:Oa,value:`${z(o.subarray(0,4))}-${z(o.subarray(4,6))}-${z(o.subarray(6,8))}-${z(o.subarray(8,10))}-${z(o.subarray(10))}`};break;default:throw Error(`Unrecognized header type tag`)}}return t}},(function(e){e[e.boolTrue=0]=`boolTrue`,e[e.boolFalse=1]=`boolFalse`,e[e.byte=2]=`byte`,e[e.short=3]=`short`,e[e.integer=4]=`integer`,e[e.long=5]=`long`,e[e.byteArray=6]=`byteArray`,e[e.string=7]=`string`,e[e.timestamp=8]=`timestamp`,e[e.uuid=9]=`uuid`})(ya||(ya={})),ba=`boolean`,xa=`byte`,Sa=`short`,Ca=`integer`,wa=`long`,Ta=`binary`,Ea=`string`,Da=`timestamp`,Oa=`uuid`,ka=/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/}));function ja({byteLength:e,byteOffset:t,buffer:n}){if(e<Pa)throw Error(`Provided message too short to accommodate event stream message overhead`);let r=new DataView(n,t,e),i=r.getUint32(0,!1);if(e!==i)throw Error(`Reported message length does not match received message length`);let a=r.getUint32(Na,!1),o=r.getUint32(H,!1),s=r.getUint32(e-U,!1),c=new Ma.Crc32().update(new Uint8Array(n,t,H));if(o!==c.digest())throw Error(`The prelude checksum specified in the message (${o}) does not match the calculated CRC32 checksum (${c.digest()})`);if(c.update(new Uint8Array(n,t+H,e-12)),s!==c.digest())throw Error(`The message checksum (${c.digest()}) did not match the expected value of ${s}`);return{headers:new DataView(n,t+H+U,a),body:new Uint8Array(n,t+H+U+a,i-a-16)}}var Ma,Na,H,U,Pa,Fa=t((()=>{Ma=fa(),Na=4,H=Na*2,U=4,Pa=16})),Ia,La,Ra=t((()=>{Ia=fa(),Aa(),Fa(),La=class{constructor(e,t){this.headerMarshaller=new va(e,t),this.messageBuffer=[],this.isEndOfStream=!1}feed(e){this.messageBuffer.push(this.decode(e))}endOfStream(){this.isEndOfStream=!0}getMessage(){let e=this.messageBuffer.pop(),t=this.isEndOfStream;return{getMessage(){return e},isEndOfStream(){return t}}}getAvailableMessages(){let e=this.messageBuffer;this.messageBuffer=[];let t=this.isEndOfStream;return{getMessages(){return e},isEndOfStream(){return t}}}encode({headers:e,body:t}){let n=this.headerMarshaller.format(e),r=n.byteLength+t.byteLength+16,i=new Uint8Array(r),a=new DataView(i.buffer,i.byteOffset,i.byteLength),o=new Ia.Crc32;return a.setUint32(0,r,!1),a.setUint32(4,n.byteLength,!1),a.setUint32(8,o.update(i.subarray(0,8)).digest(),!1),i.set(n,12),i.set(t,n.byteLength+12),a.setUint32(r-4,o.update(i.subarray(8,r-4)).digest(),!1),i}decode(e){let{headers:t,body:n}=ja(e);return{headers:this.headerMarshaller.parse(t),body:n}}formatHeaders(e){return this.headerMarshaller.format(e)}}})),za=t((()=>{})),Ba,Va=t((()=>{Ba=class{constructor(e){this.options=e}[Symbol.asyncIterator](){return this.asyncIterator()}async*asyncIterator(){for await(let e of this.options.inputStream)yield this.options.decoder.decode(e)}}})),Ha,Ua=t((()=>{Ha=class{constructor(e){this.options=e}[Symbol.asyncIterator](){return this.asyncIterator()}async*asyncIterator(){for await(let e of this.options.messageStream)yield this.options.encoder.encode(e);this.options.includeEndFrame&&(yield new Uint8Array)}}})),Wa,Ga=t((()=>{Wa=class{constructor(e){this.options=e}[Symbol.asyncIterator](){return this.asyncIterator()}async*asyncIterator(){for await(let e of this.options.messageStream){let t=await this.options.deserializer(e);t!==void 0&&(yield t)}}}})),Ka,qa=t((()=>{Ka=class{constructor(e){this.options=e}[Symbol.asyncIterator](){return this.asyncIterator()}async*asyncIterator(){for await(let e of this.options.inputStream)yield this.options.serializer(e)}}})),Ja=t((()=>{Ra(),Aa(),_a(),za(),Va(),Ua(),Ga(),qa()}));function Ya(e){let t=0,n=0,r=null,i=null,a=e=>{if(typeof e!=`number`)throw Error(`Attempted to allocate an event message where size was not a number: `+e);t=e,n=4,r=new Uint8Array(e),new DataView(r.buffer).setUint32(0,e,!1)},o=async function*(){let o=e[Symbol.asyncIterator]();for(;;){let{value:e,done:s}=await o.next();if(s){if(!t)return;if(t===n)yield r;else throw Error(`Truncated event message received.`);return}let c=e.length,l=0;for(;l<c;){if(!r){let t=c-l;i||(i=new Uint8Array(4));let r=Math.min(4-n,t);if(i.set(e.slice(l,l+r),n),n+=r,l+=r,n<4)break;a(new DataView(i.buffer).getUint32(0,!1)),i=null}let o=Math.min(t-n,c-l);r.set(e.slice(l,l+o),n),n+=o,l+=o,t&&t===n&&(yield r,r=null,t=0,n=0)}}};return{[Symbol.asyncIterator]:o}}var Xa=t((()=>{}));function Za(e,t){return async function(n){let{value:r}=n.headers[`:message-type`];if(r===`error`){let e=Error(n.headers[`:error-message`].value||`UnknownError`);throw e.name=n.headers[`:error-code`].value,e}else if(r===`exception`){let r=n.headers[`:exception-type`].value,i=await e({[r]:n});if(i.$unknown){let e=Error(t(n.body));throw e.name=r,e}throw i[r]}else if(r===`event`){let t=await e({[n.headers[`:event-type`].value]:n});return t.$unknown?void 0:t}else throw Error(`Unrecognizable event type: ${n.headers[`:event-type`].value}`)}}var Qa=t((()=>{})),$a,eo=t((()=>{Ja(),Xa(),Qa(),$a=class{constructor({utf8Encoder:e,utf8Decoder:t}){this.eventStreamCodec=new La(e,t),this.utfEncoder=e}deserialize(e,t){return new Wa({messageStream:new Ba({inputStream:Ya(e),decoder:this.eventStreamCodec}),deserializer:Za(t,this.utfEncoder)})}serialize(e,t){return new Ha({messageStream:new Ka({inputStream:e,serializer:t}),encoder:this.eventStreamCodec,includeEndFrame:!0})}}})),to=t((()=>{eo()})),no=t((()=>{eo(),to()}));async function*ro(e){let t=!1,n=!1,r=[];for(e.on(`error`,e=>{if(t||(t=!0),e)throw e}),e.on(`data`,e=>{r.push(e)}),e.on(`end`,()=>{t=!0});!n;){let e=await new Promise(e=>setTimeout(()=>e(r.shift()),0));e&&(yield e),n=t&&r.length===0}}var io=t((()=>{})),ao,oo=t((()=>{no(),io(),ao=class{constructor({utf8Encoder:e,utf8Decoder:t}){this.universalMarshaller=new $a({utf8Decoder:t,utf8Encoder:e})}deserialize(e,t){let n=typeof e[Symbol.asyncIterator]==`function`?e:ro(e);return this.universalMarshaller.deserialize(n,t)}serialize(e,t){return pe.from(this.universalMarshaller.serialize(e,t))}}})),so=t((()=>{oo()})),co=t((()=>{oo(),so()})),lo,uo=t((()=>{lo=e=>typeof ArrayBuffer==`function`&&e instanceof ArrayBuffer||Object.prototype.toString.call(e)===`[object ArrayBuffer]`})),fo,po,W=t((()=>{uo(),fo=(e,t=0,n=e.byteLength-t)=>{if(!lo(e))throw TypeError(`The "input" argument must be ArrayBuffer. Received type ${typeof e} (${e})`);return _.from(e,t,n)},po=(e,t)=>{if(typeof e!=`string`)throw TypeError(`The "input" argument must be of type string. Received type ${typeof e} (${e})`);return t?_.from(e,t):_.from(e)}})),mo,ho,go=t((()=>{W(),mo=/^[A-Za-z0-9+/]*={0,2}$/,ho=e=>{if(e.length*3%4!=0)throw TypeError(`Incorrect padding on base64 string.`);if(!mo.exec(e))throw TypeError(`Invalid base64 string.`);let t=po(e,`base64`);return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}})),_o,vo=t((()=>{W(),_o=e=>{let t=po(e,`utf8`);return new Uint8Array(t.buffer,t.byteOffset,t.byteLength/Uint8Array.BYTES_PER_ELEMENT)}})),yo=t((()=>{})),bo,xo=t((()=>{W(),bo=e=>{if(typeof e==`string`)return e;if(typeof e!=`object`||typeof e.byteOffset!=`number`||typeof e.byteLength!=`number`)throw Error(`@smithy/util-utf8: toUtf8 encoder function only accepts string | Uint8Array.`);return fo(e.buffer,e.byteOffset,e.byteLength).toString(`utf8`)}})),So=t((()=>{vo(),yo(),xo()})),Co,wo=t((()=>{W(),So(),Co=e=>{let t;if(t=typeof e==`string`?_o(e):e,typeof t!=`object`||typeof t.byteOffset!=`number`||typeof t.byteLength!=`number`)throw Error(`@smithy/util-base64: toBase64 encoder function only accepts string | Uint8Array.`);return fo(t.buffer,t.byteOffset,t.byteLength).toString(`base64`)}})),To=t((()=>{go(),wo()})),Eo=t((()=>{m(),d(),p(),ee()})),Do=t((()=>{})),Oo=t((()=>{})),ko=t((()=>{Oo()})),Ao=t((()=>{ko()}));function jo(e,t=`utf-8`){return t===`base64`?Co(e):bo(e)}function Mo(e,t){return t===`base64`?G.mutate(ho(e)):G.mutate(_o(e))}var No=t((()=>{To(),So(),Po()})),G,Po=t((()=>{No(),G=class e extends Uint8Array{static fromString(e,t=`utf-8`){switch(typeof e){case`string`:return Mo(e,t);default:throw Error(`Unsupported conversion from ${typeof e} to Uint8ArrayBlobAdapter.`)}}static mutate(t){return Object.setPrototypeOf(t,e.prototype),t}transformToString(e=`utf-8`){return jo(this,e)}}})),Fo=t((()=>{})),Io=t((()=>{})),Lo=t((()=>{})),Ro=t((()=>{Io(),Lo()})),zo=t((()=>{Ro()})),Bo=t((()=>{w(),zo()})),Vo=t((()=>{w(),zo()})),Ho=t((()=>{})),Uo=t((()=>{Bo(),Vo(),Ho()})),Wo=t((()=>{Uo()})),Go=t((()=>{Po(),Fo(),Wo()})),Ko,qo=t((()=>{Go(),Ko=async(e=new Uint8Array,t)=>{if(e instanceof Uint8Array)return G.mutate(e);if(!e)return G.mutate(new Uint8Array);let n=t.streamCollector(e);return G.mutate(await n)}})),Jo=t((()=>{ko(),Sn()})),Yo=t((()=>{})),Xo=t((()=>{})),Zo,Qo,$o,es,K,ts,ns,rs=t((()=>{Zo=e=>{if(e!=null){if(Number.isInteger(e)&&!Number.isNaN(e))return e;throw TypeError(`Expected integer, got ${typeof e}: ${e}`)}},Qo=e=>$o(e,32),$o=(e,t)=>{let n=Zo(e);if(n!==void 0&&es(n,t)!==n)throw TypeError(`Expected ${t}-bit integer, got ${e}`);return n},es=(e,t)=>{switch(t){case 32:return Int32Array.of(e)[0];case 16:return Int16Array.of(e)[0];case 8:return Int8Array.of(e)[0]}},K=e=>{if(e!=null){if(typeof e==`string`)return e;if([`boolean`,`number`,`bigint`].includes(typeof e))return ns.warn(ts(`Expected string, got ${typeof e}: ${e}`)),String(e);throw TypeError(`Expected string, got ${typeof e}: ${e}`)}},ts=e=>String(TypeError(e).stack||e).split(`
13
+ `).slice(0,5).filter(e=>!e.includes(`stackTraceWarning`)).join(`
14
+ `),ns={warn:console.warn}})),is=t((()=>{})),q,as=t((()=>{q=(e,t={})=>(Object.entries(t).filter(([,e])=>e!==void 0).forEach(([t,n])=>{(e[t]==null||e[t]===``)&&(e[t]=n)}),e.message=e.message||e.Message||`UnknownError`,delete e.Message,e)})),os=t((()=>{})),ss=t((()=>{})),cs=t((()=>{})),ls=t((()=>{Sn()})),us=t((()=>{ls()})),ds=t((()=>{us()})),fs=t((()=>{})),ps=t((()=>{})),ms=t((()=>{})),J,hs=t((()=>{J=function(){let e=Object.getPrototypeOf(this).constructor,t=new(Function.bind.apply(String,[null,...arguments]));return Object.setPrototypeOf(t,e.prototype),t},J.prototype=Object.create(String.prototype,{constructor:{value:J,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf(J,String)}));function Y(e,t,n){let r,i,a;if(t===void 0&&n===void 0)r={},a=e;else{if(r=e,typeof t==`function`)return i=t,a=n,gs(r,i,a);a=t}for(let e of Object.keys(a)){if(!Array.isArray(a[e])){r[e]=a[e];continue}_s(r,null,a,e)}return r}var X,gs,_s,vs,ys,bs=t((()=>{X=(e,t)=>{let n={};for(let r in t)_s(n,e,t,r);return n},gs=(e,t,n)=>Y(e,Object.entries(n).reduce((e,[n,r])=>(Array.isArray(r)?e[n]=r:typeof r==`function`?e[n]=[t,r()]:e[n]=[t,r],e),{})),_s=(e,t,n,r)=>{if(t!==null){let i=n[r];typeof i==`function`&&(i=[,i]);let[a=vs,o=ys,s=r]=i;(typeof a==`function`&&a(t[s])||typeof a!=`function`&&a)&&(e[r]=o(t[s]));return}let[i,a]=n[r];if(typeof a==`function`){let t,n=i===void 0&&(t=a())!=null,o=typeof i==`function`&&!!i(void 0)||typeof i!=`function`&&!!i;n?e[r]=t:o&&(e[r]=a())}else{let t=i===void 0&&a!=null,n=typeof i==`function`&&!!i(a)||typeof i!=`function`&&!!i;(t||n)&&(e[r]=a)}},vs=e=>e!=null,ys=e=>e})),xs=t((()=>{})),Ss=t((()=>{})),Cs=t((()=>{})),ws=t((()=>{})),Ts=t((()=>{Do(),Ao(),qo(),Jo(),Yo(),Xo(),is(),os(),ss(),cs(),ds(),as(),fs(),ps(),ms(),hs(),bs(),rs(),xs(),Ss(),Cs(),ws()})),Es,Ds,Os,ks,As,js,Ms,Ns,Ps,Fs,Is,Z,Ls,Q,Rs=t((()=>{Ts(),fe(),Es=async(e,t)=>{let n=Y({}),r=e.body,i=X(r,{message:K});return Object.assign(n,i),q(new ue({$metadata:Z(e),...n}),e.body)},Ds=async(e,t)=>{let n=Y({}),r=e.body,i=X(r,{message:K,originalMessage:K,originalStatusCode:Qo});return Object.assign(n,i),q(new le({$metadata:Z(e),...n}),e.body)},Os=async(e,t)=>{let n=Y({}),r=e.body,i=X(r,{message:K});return Object.assign(n,i),q(new ce({$metadata:Z(e),...n}),e.body)},ks=async(e,t)=>{let n=Y({}),r=e.body,i=X(r,{message:K});return Object.assign(n,i),q(new de({$metadata:Z(e),...n}),e.body)},As=(e,t)=>t.eventStreamMarshaller.deserialize(e,async n=>n.chunk==null?n.internalServerException==null?n.modelStreamErrorException==null?n.validationException==null?n.throttlingException==null?{$unknown:e}:{throttlingException:await Ps(n.throttlingException,t)}:{validationException:await Fs(n.validationException,t)}:{modelStreamErrorException:await Ms(n.modelStreamErrorException,t)}:{internalServerException:await js(n.internalServerException,t)}:{chunk:await Ns(n.chunk,t)}),js=async(e,t)=>{let n={...e,body:await Q(e.body,t)};return Es(n,t)},Ms=async(e,t)=>{let n={...e,body:await Q(e.body,t)};return Ds(n,t)},Ns=async(e,t)=>{let n={},r=await Q(e.body,t);return Object.assign(n,Is(r,t)),n},Ps=async(e,t)=>{let n={...e,body:await Q(e.body,t)};return Os(n,t)},Fs=async(e,t)=>{let n={...e,body:await Q(e.body,t)};return ks(n,t)},Is=(e,t)=>X(e,{bytes:t.base64Decoder}),Z=e=>({httpStatusCode:e.statusCode,requestId:e.headers[`x-amzn-requestid`]??e.headers[`x-amzn-request-id`]??e.headers[`x-amz-request-id`]??``,extendedRequestId:e.headers[`x-amz-id-2`]??``,cfId:e.headers[`x-amz-cf-id`]??``}),Ls=(e,t)=>Ko(e,t).then(e=>t.utf8Encoder(e)),Q=(e,t)=>Ls(e,t).then(e=>e.length?JSON.parse(e):{})}));function zs(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}}}var Bs=t((()=>{})),Vs=t((()=>{ee()}));function Hs(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Us,Ws,Gs,Ks=t((()=>{Vs(),Us=e=>(Us=Array.isArray,Us(e)),Ws=Us,Gs=e=>{try{return JSON.parse(e)}catch{return}}}));function $(){}function qs(e,t,n){return!t||Ys[e]>Ys[n]?$:t[e].bind(t)}function Js(e){let t=e.logger,n=e.logLevel??`off`;if(!t)return Xs;let r=Zs.get(t);if(r&&r[0]===n)return r[1];let i={error:qs(`error`,t,n),warn:qs(`warn`,t,n),info:qs(`info`,t,n),debug:qs(`debug`,t,n)};return Zs.set(t,[n,i]),i}var Ys,Xs,Zs,Qs=t((()=>{Ks(),Ys={off:0,error:200,warn:300,info:400,debug:500},Xs={error:$,warn:$,info:$,debug:$},Zs=new WeakMap}));function $s(e){return typeof e==`object`&&!!e&&(`name`in e&&e.name===`AbortError`||`message`in e&&String(e.message).includes(`FetchRequestCanceledException`))}var ec,tc,nc,rc,ic=t((()=>{co(),To(),Se(),o(),s(),Eo(),Rs(),Bs(),Ks(),Qs(),ec=e=>new TextDecoder(`utf-8`).decode(e),tc=e=>new TextEncoder().encode(e),nc=()=>{let e=new ao({utf8Encoder:ec,utf8Decoder:tc});return{base64Decoder:ho,base64Encoder:Co,utf8Decoder:tc,utf8Encoder:ec,eventStreamMarshaller:e,streamCollector:oe}},rc=class e extends c{static fromSSEResponse(t,n,r){let a=!1,o=r?Js(r):console;async function*s(){if(!t.body)throw n.abort(),new g(`Attempted to iterate over a response with no body`);let e=As(zs(t.body),nc());for await(let t of e)t.chunk&&t.chunk.bytes?yield{event:`chunk`,data:ec(t.chunk.bytes),raw:[]}:t.internalServerException?yield{event:`error`,data:`InternalServerException`,raw:[]}:t.modelStreamErrorException?yield{event:`error`,data:`ModelStreamErrorException`,raw:[]}:t.validationException?yield{event:`error`,data:`ValidationException`,raw:[]}:t.throttlingException&&(yield{event:`error`,data:`ThrottlingException`,raw:[]})}async function*c(){if(a)throw Error("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");a=!0;let e=!1;try{for await(let e of s()){if(e.event===`chunk`){let n;try{n=JSON.parse(e.data)}catch(t){throw o.error(`Could not parse message into JSON:`,e.data),o.error(`From chunk:`,e.raw),t}if(n&&typeof n==`object`&&n.type===`error`)throw new i(void 0,n,void 0,t.headers,n.error?.type);yield n}if(e.event===`error`){let n=e.data,r=Gs(n),a=r?void 0:n;throw i.generate(void 0,r,a,t.headers)}}e=!0}catch(e){if($s(e))return;throw e}finally{e||n.abort()}}return new e(c,n)}}})),ac,oc=t((()=>{ac=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()||void 0}}));function*sc(e){if(!e)return;if(cc 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():Ws(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=Ws(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 cc,lc,uc=t((()=>{Ks(),cc=Symbol.for(`brand.privateNullableHeaders`),lc=e=>{let t=new Headers,n=new Set;for(let r of e){let e=new Set;for(let[i,a]of sc(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{[cc]:!0,values:t,nulls:n}}}));function dc(e){return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}var fc,pc,mc,hc=t((()=>{Vs(),fc=Object.freeze(Object.create(null)),pc=(e=dc)=>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??fc)??fc)?.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 g(`Path parameters result in path with invalid segments:\n${i.map(e=>e.error).join(`
15
+ `)}\n${a}\n${t}`)}return a},mc=pc(dc)}));function gc(e){let t=new a(e);return delete t.batches,delete t.countTokens,t}function _c(e){let t=new u(e);return delete t.promptCaching,delete t.messages.batches,delete t.messages.countTokens,t}var vc,yc,bc,xc=t((()=>{m(),l(),aa(),ic(),oc(),Ks(),uc(),hc(),Qs(),vc=`bedrock-2023-05-31`,yc=new Set([`/v1/complete`,`/v1/messages`,`/v1/messages?beta=true`]),bc=class extends f{constructor({awsRegion:e=ac(`AWS_REGION`)??`us-east-1`,baseURL:t=ac(`ANTHROPIC_BEDROCK_BASE_URL`)??`https://bedrock-runtime.${e}.amazonaws.com`,apiKey:n=ac(`AWS_BEARER_TOKEN_BEDROCK`),awsSecretKey:r=null,awsAccessKey:i=null,awsSessionToken:a=null,providerChainResolver:o=null,...s}={}){super({baseURL:t,authToken:n,...s}),this.skipAuth=!1,this.messages=gc(this),this.completions=new h(this),this.beta=_c(this),i!=null!=(r!=null)&&Js(this).warn("Warning: Passing only one of `awsAccessKey` or `awsSecretKey` is deprecated. Please provide both keys, or provide neither and rely on the AWS credential provider chain."),this.awsSecretKey=r,this.awsAccessKey=i,this.awsRegion=e,this.awsSessionToken=a,this.skipAuth=s.skipAuth??!1,this.providerChainResolver=o}validateHeaders(){}async prepareRequest(e,{url:t,options:n}){if(this.skipAuth){e.headers.delete(`Authorization`);return}if(this.authToken)return;let r=this.awsRegion;if(!r)throw Error("Expected `awsRegion` option to be passed to the client or the `AWS_REGION` environment variable to be present");e.headers=lc([await ia(e,{url:t,regionName:r,awsAccessKey:this.awsAccessKey,awsSecretKey:this.awsSecretKey,awsSessionToken:this.awsSessionToken,fetchOptions:this.fetchOptions,providerChainResolver:this.providerChainResolver}),e.headers]).values}async buildRequest(e){if(e.__streamClass=rc,Hs(e.body)&&(e.body={...e.body}),Hs(e.body)&&(e.body.anthropic_version||(e.body.anthropic_version=vc),e.headers&&!e.body.anthropic_beta)){let t=lc([e.headers]).values.get(`anthropic-beta`);t!=null&&(e.body.anthropic_beta=t.split(`,`))}if(yc.has(e.path)&&e.method===`post`){if(!Hs(e.body))throw Error(`Expected request body to be an object for post /v1/messages`);let t=e.body.model;e.body.model=void 0;let n=e.body.stream;e.body.stream=void 0,n?e.path=mc`/model/${t}/invoke-with-response-stream`:e.path=mc`/model/${t}/invoke`}return super.buildRequest(e)}}})),Sc=t((()=>{ct(),w(),ta()})),Cc=t((()=>{uc(),Vs(),m(),l(),Sc()})),wc=t((()=>{xc(),xc(),Cc()})),Tc;t((()=>{wc(),Tc=class extends bc{async buildRequest(e){let t=await super.buildRequest(e),n=t?.req;if(!n||typeof n.body!=`string`||n.body.length===0)return t;let r;try{r=JSON.parse(n.body)}catch{return t}if(!(`anthropic_beta`in r))return t;delete r.anthropic_beta;let i=JSON.stringify(r);n.body=i;let a=String(new TextEncoder().encode(i).length),o=n.headers;if(typeof Headers<`u`&&o instanceof Headers)o.has(`content-length`)&&o.set(`content-length`,a);else if(o&&typeof o==`object`){let e=o;`content-length`in e&&(e[`content-length`]=a)}return t}}}))();export{Tc as BedrockClient};
@@ -0,0 +1 @@
1
+ import{a as e,c as t,i as n,r,s as i,t as a}from"./bg-DQ0Q3Qv-.js";n();export{a as attachHandler,r as handleBgStart,e as killHandler,i as logsHandler,t as psHandler};
@@ -0,0 +1,9 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,o as n}from"./envUtils-DSxRz_kt.js";import{D as r,E as i}from"./debug-IKW-jE7K.js";import{a,i as o}from"./genericProcessUtils-F1Qcb1sO.js";import{join as s}from"path";import{randomUUID as c}from"crypto";import{readFile as l,readdir as u,unlink as d}from"fs/promises";async function f(){if(process.platform===`win32`){let{DetachedEngine:e}=await import(`./detached-rfIUyc-B.js`);return new e}let{TmuxEngine:e}=await import(`./tmux-CbsW-VDJ.js`),t=new e;if(await t.available())return t;let{DetachedEngine:n}=await import(`./detached-rfIUyc-B.js`);return new n}var p=e((()=>{}));function m(){return s(t(),`sessions`)}async function h(){let e=m(),t;try{t=await u(e)}catch{return[]}let n=[];for(let i of t)if(/^\d+\.json$/.test(i)){if(!a(parseInt(i.slice(0,-5),10))){d(s(e,i)).catch(()=>{});continue}try{let t=r(await l(s(e,i),`utf-8`));n.push(t)}catch{}}return n}function g(e,t){let n=parseInt(t,10);return e.find(e=>e.sessionId===t||e.pid===n||e.name&&e.name===t)}function _(e){return new Date(e).toLocaleString()}function v(e){return e.engine?e.engine:e.tmuxSessionName?`tmux`:`detached`}async function y(e){let t=await h();if(t.length===0){console.log(`No active sessions.`);return}console.log(`${t.length} active session${t.length>1?`s`:``}:\n`);for(let e of t){let t=v(e),n=[` PID: ${e.pid}`,` Kind: ${e.kind}`,` Engine: ${t}`,` Session: ${e.sessionId}`,` CWD: ${e.cwd}`];e.name&&n.push(` Name: ${e.name}`),e.startedAt&&n.push(` Started: ${_(e.startedAt)}`),e.status&&n.push(` Status: ${e.status}`),e.waitingFor&&n.push(` Waiting for: ${e.waitingFor}`),e.bridgeSessionId&&n.push(` Bridge: ${e.bridgeSessionId}`),e.tmuxSessionName&&n.push(` Tmux: ${e.tmuxSessionName}`),e.logPath&&n.push(` Log: ${e.logPath}`),console.log(n.join(`
2
+ `)),console.log()}}async function b(e){let t=await h();if(!e){if(t.length===0){console.log(`No active sessions.`);return}if(t.length===1)e=t[0].sessionId;else{console.log(`Multiple sessions active. Specify one:`);for(let e of t){let t=e.name?`${e.name} (${e.sessionId})`:e.sessionId;console.log(` ${t} PID=${e.pid}`)}return}}let n=g(t,e);if(!n){console.error(`Session not found: ${e}`),process.exitCode=1;return}if(!n.logPath){console.log(`No log path recorded for session ${n.sessionId}`);return}try{let e=await l(n.logPath,`utf-8`);process.stdout.write(e)}catch(e){console.error(`Failed to read log file: ${n.logPath}`),console.error(e instanceof Error?e.message:String(e)),process.exitCode=1}}async function x(e){let t=await h();if(!e){let n=t.filter(e=>e.tmuxSessionName||e.engine===`detached`);if(n.length===0){console.log("No background sessions to attach to. Start one with `claude daemon bg`.");return}if(n.length===1)e=n[0].sessionId;else{console.log(`Multiple background sessions. Specify one:`);for(let e of n){let t=e.name?`${e.name} (${e.sessionId})`:e.sessionId,n=v(e);console.log(` ${t} PID=${e.pid} engine=${n}`)}return}}let n=g(t,e);if(!n){console.error(`Session not found: ${e}`),process.exitCode=1;return}let r=v(n);try{if(r===`tmux`){let{TmuxEngine:e}=await import(`./tmux-CbsW-VDJ.js`),t=new e;if(!await t.available()){console.error(`tmux is no longer available. Cannot attach to tmux session.`),process.exitCode=1;return}await t.attach(n)}else{let{DetachedEngine:e}=await import(`./detached-rfIUyc-B.js`);await new e().attach(n)}}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exitCode=1}}async function S(e){let t=await h();if(!e){if(t.length===0){console.log(`No active sessions to kill.`);return}console.log(`Specify a session to kill:`);for(let e of t){let t=e.name?`${e.name} (${e.sessionId})`:e.sessionId;console.log(` ${t} PID=${e.pid}`)}return}let n=g(t,e);if(!n){console.error(`Session not found: ${e}`),process.exitCode=1;return}console.log(`Killing session ${n.sessionId} (PID: ${n.pid})...`);try{process.kill(n.pid,`SIGTERM`)}catch{console.log(`Session already exited.`);return}if(await new Promise(e=>setTimeout(e,2e3)),a(n.pid))try{process.kill(n.pid,`SIGKILL`),console.log(`Session force-killed.`)}catch{console.log(`Session exited during grace period.`)}else console.log(`Session stopped.`);d(s(m(),`${n.pid}.json`)).catch(()=>{})}async function C(e){let n=await f(),r=e.filter(e=>e!==`--bg`&&e!==`--background`);if(!n.supportsInteractiveInput&&!r.some(e=>e===`-p`||e===`--print`||e===`--pipe`)){console.error(`Error: Background sessions with detached engine require -p/--print flag.
3
+ The detached engine has no terminal for interactive input.
4
+
5
+ Usage:
6
+ claude daemon bg -p "your prompt here"
7
+ echo "prompt" | claude daemon bg --pipe`),process.platform!==`win32`&&console.error(`
8
+ Alternatively, install tmux for interactive background sessions:
9
+ ${process.platform===`darwin`?`brew install tmux`:`sudo apt install tmux`}`),process.exitCode=1;return}let i=`claude-bg-${c().slice(0,8)}`,a=s(t(),`sessions`,`logs`,`${i}.log`);try{let e=await n.start({sessionName:i,args:r,env:{...process.env},logPath:a,cwd:process.cwd()});console.log(`Background session started: ${e.sessionName}`),console.log(` Engine: ${e.engineUsed}`),console.log(` Log: ${e.logPath}`),console.log(),console.log(`Use \`claude daemon attach ${e.sessionName}\` to reconnect.`),console.log("Use `claude daemon status` to check status."),console.log(`Use \`claude daemon kill ${e.sessionName}\` to stop.`)}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exitCode=1}}var w=e((()=>{n(),o(),i(),p()}));export{S as a,y as c,w as i,g as n,h as o,C as r,b as s,x as t};
@@ -0,0 +1,3 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{en as t,ht as n,nt as r}from"./state-4KQ3kaqz.js";import{Dr as i,Er as a,Lr as o,jr as s,vi as c,wi as l,yr as u}from"./loadAgentsDir-nzr38hai.js";import{E as d,O as f}from"./debug-IKW-jE7K.js";import{c as p,s as m}from"./types-a7X-tJpJ.js";import{n as h,r as g}from"./analytics-BotDBGh0.js";import{i as _,o as v}from"./stringUtils-CvXbHQRH.js";import{randomUUID as y}from"crypto";import{mkdir as b,readFile as x,writeFile as S}from"fs/promises";function C(e){let t=e?.message?.content;if(!t)return`Branched conversation`;let n=typeof t==`string`?t:t.find(e=>e.type===`text`)?.text;return n&&n.replace(/\s+/g,` `).trim().slice(0,100)||`Branched conversation`}async function w(e){let t=y(),s=n(),c=u(r()),l=i(t),d=a();await b(c,{recursive:!0,mode:448});let m;try{m=await x(d)}catch{throw Error(`No conversation to branch`)}if(m.length===0)throw Error(`No conversation to branch`);let h=p(m),g=h.filter(e=>o(e)&&!e.isSidechain),_=h.filter(e=>e.type===`content-replacement`&&e.sessionId===s).flatMap(e=>e.replacements);if(g.length===0)throw Error(`No messages to branch`);let v=null,C=[],w=[];for(let e of g){let n={...e,sessionId:t,parentUuid:v,isSidechain:!1,forkedFrom:{sessionId:s,messageUuid:e.uuid}},r={...e,sessionId:t};w.push(r),C.push(f(n)),e.type!==`progress`&&(v=e.uuid)}if(_.length>0){let e={type:`content-replacement`,sessionId:t,replacements:_};C.push(f(e))}return await S(l,C.join(`
2
+ `)+`
3
+ `,{encoding:`utf8`,mode:384}),{sessionId:t,title:e,forkPath:l,serializedMessages:w,contentReplacementRecords:_}}async function T(e){let t=`${e} (Branch)`;if((await l(t,{exact:!0})).length===0)return t;let n=await l(`${e} (Branch`),r=new Set([1]),i=RegExp(`^${_(e)} \\(Branch(?: (\\d+))?\\)$`);for(let e of n){let t=e.customTitle?.match(i);t&&(t[1]?r.add(parseInt(t[1],10)):r.add(1))}let a=2;for(;r.has(a);)a++;return`${e} (Branch ${a})`}async function E(e,t,r){let i=r?.trim()||void 0,a=n();try{let{sessionId:n,title:r,forkPath:o,serializedMessages:s,contentReplacementRecords:l}=await w(i),u=new Date,d=C(s.find(e=>e.type===`user`)),f=await T(r??d);await c(n,f,o),g(`tengu_conversation_forked`,{message_count:s.length,has_custom_title:!!r});let p={date:u.toISOString().split(`T`)[0],messages:s,fullPath:o,value:u.getTime(),created:u,modified:u,firstPrompt:d,messageCount:s.length,isSidechain:!1,sessionId:n,customTitle:f,contentReplacements:l},m=r?` "${r}"`:``,h=`Branched conversation${m}. You are now in the branch.${`\nTo resume the original: claude -r ${a}`}`;return t.resume?(await t.resume(n,p,`fork`),e(h,{display:`system`})):e(`Branched conversation${m}. Resume with: /resume ${n}`),null}catch(t){return e(`Failed to branch conversation: ${t instanceof Error?t.message:`Unknown error occurred`}`),null}}e((()=>{t(),h(),m(),s(),d(),v()}))();export{E as call,C as deriveFirstPrompt};
@@ -0,0 +1,8 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,o as n}from"./envUtils-DSxRz_kt.js";import{en as r,z as i}from"./state-4KQ3kaqz.js";import{join as a}from"node:path";import{appendFileSync as o,existsSync as s,mkdirSync as c,readFileSync as l,unlinkSync as u,writeFileSync as d}from"node:fs";function f(){return a(t(),`.next-request-no-cache`)}function p(){return a(t(),`.break-cache-always`)}function m(){return a(t(),`break-cache-events.jsonl`)}function h(){try{let e=l(m(),`utf8`).trim().split(`
2
+ `).filter(Boolean).map(e=>{try{return JSON.parse(e)}catch{return null}}).filter(e=>e!==null),t=e.filter(e=>e.kind===`once`),n=e[e.length-1],r=e.filter(e=>e.kind===`always_on`||e.kind===`always_off`),i=r[r.length-1];return{totalBreaks:t.length,lastBreakAt:n?.at??null,alwaysModeEnabled:i?.kind===`always_on`}}catch{return{totalBreaks:0,lastBreakAt:null,alwaysModeEnabled:!1}}}function g(e){let n=m();c(t(),{recursive:!0});let r={at:new Date().toISOString(),kind:e};o(n,JSON.stringify(r)+`
3
+ `,`utf8`)}function _(){g(`once`)}async function v(e){let t=e.trim().toLowerCase(),n=f(),r=p();if(t===`status`){let e=h(),t=s(n),i=s(r);return{type:`text`,value:[`## Break-Cache Status`,``,` Once marker: ${t?`ACTIVE (next call will bust cache)`:`not set`}`,` Always mode: ${i?`ON (every call busts cache)`:`off`}`,``,`## Stats`,` total_breaks: ${e.totalBreaks}`,` last_break_at: ${e.lastBreakAt??`never`}`].join(`
4
+ `)}}if(t===`off`){let e=!1;return s(n)&&(u(n),e=!0),s(r)&&(u(r),e=!0),g(`always_off`),{type:`text`,value:e?`Break-cache disabled. Removed once marker and/or always flag.`:`Break-cache was not active.`}}if(t===`--clear`)return s(n)?(u(n),{type:`text`,value:`Cache-break marker cleared.\n \`${n}\``}):{type:`text`,value:`No cache-break marker was set.`};if(t===`always`)return d(r,new Date().toISOString(),`utf8`),g(`always_on`),{type:`text`,value:[`## Always-on cache break enabled`,``,`Flag written: \`${r}\``,``,`Every API call will now append a random nonce to the system prompt,`,`permanently preventing prompt-cache hits for this session.`,``,"To disable: `/break-cache off`"].join(`
5
+ `)};if(t===``||t===`once`){let e=new Date().toISOString();d(n,e,`utf8`),_();let t=h();return{type:`text`,value:[`## Cache break scheduled`,``,`Marker written: \`${n}\``,`Timestamp: ${e}`,``,`The next API call will append a random nonce to the system prompt,`,`causing a cache miss. The marker is removed automatically after use.`,``,"To cancel before the next call: `/break-cache --clear`","For every call: `/break-cache always`",``,`Total breaks this session: ${t.totalBreaks}`,``,`_How it works: Anthropic prompt cache keys on the system-prompt prefix hash._`,`_A unique nonce invalidates the hash, forcing a fresh compute._`].join(`
6
+ `)}}return{type:`text`,value:[`Unknown scope: "${t}"`,``,y].join(`
7
+ `)}}var y,b,x,S=e((()=>{r(),n(),y=[`Usage: /break-cache [scope]`,``,` (no args) Schedule a one-time cache break for the next API call`,` once Same as no args`,` always Enable persistent cache-break mode (every request)`,` off Disable always mode and clear any pending marker`,` --clear Clear the pending once marker (cancel before next call)`,` status Show current break-cache status and stats`,``,`How it works:`,` The Anthropic prompt cache keys on the system-prompt prefix hash.`,` A unique nonce invalidates the hash, forcing a fresh compute.`,` This is useful when you want to ensure a clean context window.`].join(`
8
+ `),b={type:`local-jsx`,name:`break-cache`,description:`Manage prompt-cache breaking. Open actions or run: once, status, always, off`,isHidden:!1,isEnabled:()=>!i(),argumentHint:`[once|status|always|off|--clear]`,bridgeSafe:!0,getBridgeInvocationError:e=>e.trim()?void 0:`Use /break-cache once/status/always/off over Remote Control.`,load:()=>import(`./panel-B-nrcHpm.js`)},x={type:`local`,name:`break-cache`,description:`Force the next (or all) API call(s) to miss prompt cache. Scopes: once, status, always, off`,isHidden:!1,isEnabled:()=>i(),supportsNonInteractive:!0,bridgeSafe:!0,load:async()=>({call:v})}}));export{f as a,p as i,x as n,S as o,v as r,b as t};
@@ -0,0 +1,2 @@
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{Gt as n,I as r,P as i,_ as a,fi as o,t as s,y as c}from"./src-CDCSSo0U2.js";import{t as l}from"./jsx-runtime-Bb4Xn-E0.js";import{Bb as u,Lb as d,fS as f,lS as p,uS as m}from"./loadAgentsDir-nzr38hai.js";import{l as h,p as g}from"./debug-IKW-jE7K.js";import{n as _,r as v}from"./analytics-BotDBGh0.js";import{u as y}from"./referral-DP_GshTS.js";import{a as b,t as x}from"./bridgeConfig-CCtXe8ak.js";import{n as S,r as C,s as w,t as T}from"./bridgeEnabled--F-6TUi4.js";import{a as E,i as D,n as O}from"./types-Czs-_G1S.js";import{t as k}from"./lib-BlVGipXx.js";import{i as A,n as j}from"./envLessBridgeConfig-D_Jg4fJy.js";import{n as M,r as N}from"./RemoteCallout-DS_EV6Fh.js";function P({onDone:e,name:t}){let n=f(),r=m(e=>e.replBridgeConnected),i=m(e=>e.replBridgeEnabled),a=m(e=>e.replBridgeOutboundOnly),[o,s]=(0,z.useState)(!1);return(0,z.useEffect)(()=>{if((r||i)&&!a){s(!0);return}let o=!1;return(async()=>{let r=await I();if(!o){if(r){v(`tengu_bridge_command`,{action:`preflight_failed`}),e(r,{display:`system`});return}if(N()){n(e=>e.showRemoteCallout?e:{...e,showRemoteCallout:!0,replBridgeInitialName:t}),e(``,{display:`system`});return}v(`tengu_bridge_command`,{action:`connect`}),n(e=>e.replBridgeEnabled&&!e.replBridgeOutboundOnly?e:{...e,replBridgeEnabled:!0,replBridgeExplicit:!0,replBridgeOutboundOnly:!1,replBridgeInitialName:t}),e(`Remote Control connecting…`,{display:`system`})}})(),()=>{o=!0}},[]),o?(0,B.jsx)(F,{onDone:e}):null}function F({onDone:e}){u(`bridge-disconnect-dialog`);let t=f(),o=m(e=>e.replBridgeSessionUrl),s=m(e=>e.replBridgeConnectUrl),l=m(e=>e.replBridgeSessionActive),[d,p]=(0,z.useState)(2),[h,g]=(0,z.useState)(!1),[_,y]=(0,z.useState)(``),b=l?o:s;(0,z.useEffect)(()=>{if(!h||!b){y(``);return}(0,R.toString)(b,{type:`utf8`,errorCorrectionLevel:`L`,small:!0}).then(y).catch(()=>y(``))},[h,b]);function x(){t(e=>e.replBridgeEnabled?{...e,replBridgeEnabled:!1,replBridgeExplicit:!1,replBridgeOutboundOnly:!1}:e),v(`tengu_bridge_command`,{action:`disconnect`}),e(D,{display:`system`})}function S(){g(e=>!e)}function C(){e(void 0,{display:`skip`})}n({"select:next":()=>p(e=>(e+1)%3),"select:previous":()=>p(e=>(e-1+3)%3),"select:accept":()=>{d===0?x():d===1?S():C()}},{context:`Select`});let w=_?_.split(`
2
+ `).filter(e=>e.length>0):[];return(0,B.jsx)(c,{title:`Remote Control`,onCancel:C,hideInputGuide:!0,children:(0,B.jsxs)(r,{flexDirection:`column`,gap:1,children:[(0,B.jsxs)(i,{children:[`This session is available via Remote Control`,b?` at ${b}`:``,`.`]}),h&&w.length>0&&(0,B.jsx)(r,{flexDirection:`column`,children:w.map((e,t)=>(0,B.jsx)(i,{children:e},t))}),(0,B.jsxs)(r,{flexDirection:`column`,children:[(0,B.jsx)(a,{isFocused:d===0,children:(0,B.jsx)(i,{children:`Disconnect this session`})}),(0,B.jsx)(a,{isFocused:d===1,children:(0,B.jsx)(i,{children:h?`Hide QR code`:`Show QR code`})}),(0,B.jsx)(a,{isFocused:d===2,children:(0,B.jsx)(i,{children:`Continue`})})]}),(0,B.jsx)(i,{dimColor:!0,children:`Enter to select · Esc to continue`})]})})}async function I(){let{waitForPolicyLimitsToLoad:e,isPolicyAllowed:t}=await import(`./policyLimits-Dem-XJ_h.js`);if(await e(),!t(`allow_remote_control`))return`Remote Control is disabled by your organization's policy.`;let n=await S();if(n)return n;let r=w();if(r){let{isAssistantMode:e}=await import(`./assistant-YvbVKjVh.js`);e()&&(r=!1)}return(r?await j():T())||(x()?(g(`[bridge] Prerequisites passed, enabling bridge`),null):O)}async function L(e,t,n){return(0,B.jsx)(P,{onDone:e,name:n.trim()||void 0})}var R,z,B;e((()=>{R=k(),o(),z=t(o(),1),b(),C(),A(),E(),s(),M(),d(),y(),_(),p(),h(),B=l()}))();export{L as call};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{l as t,u as n}from"./oauth-BqJqV-2M.js";import{Vt as r,kt as i}from"./model-DfFA3qMO.js";function a(){return process.env.CLAUDE_BRIDGE_OAUTH_TOKEN||void 0}function o(){return process.env.CLAUDE_BRIDGE_BASE_URL||void 0}function s(){return a()??i()?.accessToken}function c(){return o()??t().BASE_API_URL}function l(){return!!o()}var u=e((()=>{n(),r()}));export{u as a,a as i,c as n,l as o,o as r,s as t};
@@ -0,0 +1 @@
1
+ import{a as e,n as t,o as n,t as r}from"./bridgeConfig-CCtXe8ak.js";e();export{r as getBridgeAccessToken,t as getBridgeBaseUrl,n as isSelfHostedBridge};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{o as t}from"./envUtils-DSxRz_kt.js";import{Bt as n,Kt as r,Mt as i,Vt as a}from"./model-DfFA3qMO.js";import{i as o,r as s}from"./semver-BMRJYn3q.js";import{a as c,o as l}from"./bridgeConfig-CCtXe8ak.js";function u(){return l()?!0:p()}async function d(){return l()?!0:p()}async function f(){return l()?null:p()?m()?h()?.organizationUuid?null:"Unable to determine your organization for Remote Control eligibility. Run `claude auth login` to refresh your account information.":"Remote Control requires a full-scope login token. Long-lived tokens (from `claude setup-token` or CLAUDE_CODE_OAUTH_TOKEN) are limited to inference-only for security reasons. Run `claude auth login` to use Remote Control.":"Remote Control requires a claude.ai subscription. Run `claude auth login` to sign in with your claude.ai account."}function p(){try{return r()}catch{return!1}}function m(){try{return n()}catch{return!1}}function h(){try{return i()}catch{return}}function g(){return!1}function _(){return!0}function v(){{let e={minVersion:`0.0.0`};if(e.minVersion&&o(`0.0.1`,e.minVersion))return`Your version of Claude Code (0.0.1) is too old for Remote Control.\nVersion ${e.minVersion} or higher is required. Run \`claude update\` to update.`}return null}var y=e((()=>{c(),a(),t(),s()}));export{d as a,u as i,f as n,_ as o,y as r,g as s,v as t};
@@ -0,0 +1 @@
1
+ import{n as e,r as t,t as n}from"./bridgeEnabled--F-6TUi4.js";t();export{n as checkBridgeMinVersion,e as getBridgeDisabledReason};
@@ -0,0 +1,68 @@
1
+ import{l as e,o as t,u as n}from"./envUtils-DSxRz_kt.js";import{Gr as r,di as i,t as a,ui as o}from"./src-CDCSSo0U2.js";import{$S as s,Aa as c,Ab as l,Db as u,Eb as d,Et as f,Fa as p,Ma as m,Na as h,Pa as g,Sb as _,Tb as v,eC as y,ja as ee,jb as b,jt as x,kb as S,vt as C,wb as te}from"./loadAgentsDir-nzr38hai.js";import{D as w,E as T,O as E,U as D,l as O,p as k,z as A}from"./debug-IKW-jE7K.js";import{Gt as j,Kt as M,Wt as ne}from"./settings-5PQdphqC.js";import{M as N,j as P}from"./git-tyaWOgRL.js";import{o as F,s as I}from"./log-B3eB4EFv.js";import{i as L,n as R,r as z}from"./analytics-BotDBGh0.js";import{T as B,b as V,u as H}from"./startupProfiler-DxRQteII.js";import{vn as U,yn as W}from"./model-DfFA3qMO.js";import{n as G,t as K}from"./rcDebugLog-BUuD-X1D.js";import{c as q,d as re,f as J,n as Y,o as X,r as ie}from"./debugUtils-D2981c0Z.js";import{r as ae,t as oe}from"./datadog-DNCsyfSO.js";import{n as se,s as ce}from"./firstPartyEventLogger-hU-LPkje.js";import{a as le,t as ue}from"./types-Czs-_G1S.js";import{t as de}from"./lib-BlVGipXx.js";import{i as Z,n as Q,r as $}from"./cliLaunch-2AUoMnqx.js";import{t as fe}from"./capacityWake-CV_x9H8j.js";import{t as pe}from"./jwtUtils-C-ojmb8W.js";import{t as me}from"./pollConfig-C2Ac8WMU.js";import{i as he}from"./trustedDevice-BYCh1ff7.js";import{a as ge,i as _e,n as ve,r as ye,t as be}from"./workSecret-C_lv0dRh.js";import{hostname as xe,tmpdir as Se}from"os";import{basename as Ce,dirname as we,join as Te,resolve as Ee}from"path";import{createWriteStream as De}from"fs";import{randomUUID as Oe}from"crypto";import{spawn as ke}from"child_process";import{createInterface as Ae}from"readline";t(),D(),T(),P(),F(),R(),V(),U(),y(),oe(),se(),X(),K(),le(),m(),f(),Z(),i();var je=de();M(),a(),O(),S();var Me={type:`utf8`,errorCorrectionLevel:`L`,small:!0};async function Ne(e){return(await(0,je.toString)(e,Me)).split(`
2
+ `).filter(e=>e.length>0)}function Pe(e){let t=e.write??(e=>process.stdout.write(e)),n=e.verbose,i=0,a=`idle`,s=`Ready`,c=``,f=``,p=``,m=``,h=``,g=``,y=null,ee=[],x=!1,S=null,C=0,w=0,T=1,E=null,D=`single-session`,O=new Map,A=null,M=0;function N(e){let t=process.stdout.columns||80,n=0;for(let i of e.split(`
3
+ `)){if(i.length===0){n++;continue}let e=r(i);n+=Math.max(1,Math.ceil(e/t))}return e.endsWith(`
4
+ `)&&n--,n}function P(e){t(e),i+=N(e)}function F(){i<=0||(k(`[bridge:ui] clearStatusLines count=${i}`),t(`\x1b[${i}A`),t(`\x1B[J`),i=0)}function I(e){F(),t(e)}function L(e){Ne(e).then(e=>{ee=e,U()}).catch(e=>{k(`QR code generation failed: ${e}`,{level:`error`})})}function R(){F();let e=j[M%j.length],t=``;c&&(t+=o.dim(` · `)+o.dim(c)),f&&(t+=o.dim(` · `)+o.dim(f)),P(`${o.yellow(e)} ${o.yellow(`Connecting`)}${t}\n`)}function z(){V(),R(),A=setInterval(()=>{M++,R()},150)}function V(){A&&(clearInterval(A),A=null)}function U(){if(a===`reconnecting`||a===`failed`)return;F();let e=a===`idle`;if(x)for(let e of ee)P(`${o.dim(e)}\n`);let t=ne,n=e?o.green:o.cyan,r=(e?o.green:o.cyan)(s),i=``;if(c&&(i+=o.dim(` · `)+o.dim(c)),f&&D!==`worktree`&&(i+=o.dim(` · `)+o.dim(f)),process.env.USER_TYPE===`ant`&&p&&P(`${o.yellow(`[ANT-ONLY] Logs:`)} ${o.dim(p)}\n`),P(`${n(t)} ${r}${i}\n`),T>1){let e=D===`worktree`?`New sessions will be created in an isolated worktree`:`New sessions will be created in the current directory`;P(` ${o.dim(`Capacity: ${w}/${T} \u00b7 ${e}`)}\n`);for(let[,e]of O){let t=b(e.title?B(e.title,35):o.dim(`Attached`),e.url),n=e.activity;P(` ${t}${n&&n.type!==`result`&&n.type!==`error`?o.dim(` ${B(n.summary,40)}`):``}
5
+ `)}}if(T===1){let e=D===`single-session`?`Single session · exits when complete`:D===`worktree`?`Capacity: ${w}/1 \u00b7 New sessions will be created in an isolated worktree`:`Capacity: ${w}/1 \u00b7 New sessions will be created in the current directory`;P(` ${o.dim(e)}\n`)}T===1&&!e&&S&&Date.now()-C<3e4&&P(` ${o.dim(B(S,60))}\n`);let l=y??m;if(l){P(`
6
+ `);let t=e?u(l):te(l),n=x?o.dim.italic(`space to hide QR code`):o.dim.italic(`space to show QR code`),r=E?o.dim.italic(` · w to toggle spawn mode`):``;P(`${o.dim(t)}\n`),P(`${n}${r}\n`)}}return{printBanner(e,r){h=e.sessionIngressUrl,g=r,m=v(r,h),L(m),n&&t(o.dim(`Remote Control`)+` v0.0.1
7
+ `),n&&(e.spawnMode!==`single-session`&&(t(o.dim(`Spawn mode: `)+`${e.spawnMode}\n`),t(o.dim(`Max concurrent sessions: `)+`${e.maxSessions}\n`)),t(o.dim(`Environment ID: `)+`${r}\n`)),e.sandbox&&t(o.dim(`Sandbox: `)+`${o.green(`Enabled`)}\n`),t(`
8
+ `),z()},logSessionStart(e,t){if(n){let n=B(t,80);I(o.dim(`[${l()}]`)+` Session started: ${o.white(`"${n}"`)} (${o.dim(e)})\n`)}},logSessionComplete(e,t){I(o.dim(`[${l()}]`)+` Session ${o.green(`completed`)} (${H(t)}) ${o.dim(e)}\n`)},logSessionFailed(e,t){I(o.dim(`[${l()}]`)+` Session ${o.red(`failed`)}: ${t} ${o.dim(e)}\n`)},logStatus(e){I(o.dim(`[${l()}]`)+` ${e}\n`)},logVerbose(e){n&&I(o.dim(`[${l()}] ${e}`)+`
9
+ `)},logError(e){I(o.red(`[${l()}] Error: ${e}`)+`
10
+ `)},logReconnected(e){I(o.dim(`[${l()}]`)+` ${o.green(`Reconnected`)} after ${H(e)}\n`)},setRepoInfo(e,t){c=e,f=t},setDebugLogPath(e){p=e},updateIdleStatus(){V(),a=`idle`,s=`Ready`,S=null,C=0,y=null,L(m),U()},setAttached(e){V(),a=`attached`,s=`Connected`,S=null,C=0,T<=1&&(y=d(e,g,h),L(y)),U()},updateReconnectingStatus(e,t){if(V(),F(),a=`reconnecting`,x)for(let e of ee)P(`${o.dim(e)}\n`);let n=j[M%j.length];M++,P(`${o.yellow(n)} ${o.yellow(`Reconnecting`)} ${o.dim(`·`)} ${o.dim(`retrying in ${e}`)} ${o.dim(`·`)} ${o.dim(`disconnected ${t}`)}\n`)},updateFailedStatus(e){V(),F(),a=`failed`;let t=``;c&&(t+=o.dim(` · `)+o.dim(c)),f&&(t+=o.dim(` · `)+o.dim(f)),P(`${o.red(`×`)} ${o.red(`Remote Control Failed`)}${t}\n`),P(`${o.dim(_)}\n`),e&&P(`${o.red(e)}\n`)},updateSessionStatus(e,t,n,r){n.type===`tool_start`&&(S=n.summary,C=Date.now()),U()},clearStatus(){V(),F()},toggleQr(){x=!x,U()},updateSessionCount(e,t,n){w===e&&T===t&&D===n||(w=e,T=t,D=n)},setSpawnModeDisplay(e){E!==e&&(E=e,e&&(D=e))},addSession(e,t){O.set(e,{url:t})},updateSessionActivity(e,t){let n=O.get(e);n&&(n.activity=t)},setSessionTitle(e,t){let n=O.get(e);n&&(n.title=t,!(a===`reconnecting`||a===`failed`)&&(T===1&&(a=`titled`,s=B(t,40)),U()))},removeSession(e){O.delete(e)},refreshDisplay(){a===`reconnecting`||a===`failed`||U()}}}q();var Fe=10,Ie=10;function Le(e){return e.replace(/[^a-zA-Z0-9_-]/g,`_`)}var Re={Read:`Reading`,Write:`Writing`,Edit:`Editing`,MultiEdit:`Editing`,Bash:`Running`,Glob:`Searching`,Grep:`Searching`,WebFetch:`Fetching`,WebSearch:`Searching`,Task:`Running task`,FileReadTool:`Reading`,FileWriteTool:`Writing`,FileEditTool:`Editing`,GlobTool:`Searching`,GrepTool:`Searching`,BashTool:`Running`,NotebookEditTool:`Editing notebook`,LSP:`LSP`};function ze(e,t){let n=Re[e]??e,r=t.file_path??t.filePath??t.pattern??t.command?.slice(0,60)??t.url??t.query??``;return r?`${n} ${r}`:n}function Be(e,t,n){let r;try{r=w(e)}catch{return[]}if(!r||typeof r!=`object`)return[];let i=r,a=[],o=Date.now();switch(i.type){case`assistant`:{let e=i.message;if(!e)break;let r=e.content;if(!Array.isArray(r))break;for(let e of r){if(!e||typeof e!=`object`)continue;let r=e;if(r.type===`tool_use`){let e=r.name??`Tool`,i=r.input??{},s=ze(e,i);a.push({type:`tool_start`,summary:s,timestamp:o}),n(`[bridge:activity] sessionId=${t} tool_use name=${e} ${He(i)}`)}else if(r.type===`text`){let e=r.text??``;e.length>0&&(a.push({type:`text`,summary:e.slice(0,80),timestamp:o}),n(`[bridge:activity] sessionId=${t} text "${e.slice(0,100)}"`))}}break}case`result`:{let e=i.subtype;if(e===`success`)a.push({type:`result`,summary:`Session completed`,timestamp:o}),n(`[bridge:activity] sessionId=${t} result subtype=success`);else if(e){let r=i.errors?.[0]??`Error: ${e}`;a.push({type:`error`,summary:r,timestamp:o}),n(`[bridge:activity] sessionId=${t} result subtype=${e} error="${r}"`)}else n(`[bridge:activity] sessionId=${t} result subtype=undefined`);break}default:break}return a}function Ve(e){if(e.parent_tool_use_id!=null||e.isSynthetic||e.isReplay)return;let t=e.message?.content,n;if(typeof t==`string`)n=t;else if(Array.isArray(t)){for(let e of t)if(e&&typeof e==`object`&&e.type===`text`){n=e.text;break}}return n=n?.trim(),n||void 0}function He(e){let t=[];for(let[n,r]of Object.entries(e))if(typeof r==`string`&&t.push(`${n}="${r.slice(0,100)}"`),t.length>=3)break;return t.join(` `)}function Ue(e){return{spawn(t,n){let r=Le(t.sessionId),i;if(e.debugFile){let t=e.debugFile.lastIndexOf(`.`);i=t>0?`${e.debugFile.slice(0,t)}-${r}${e.debugFile.slice(t)}`:`${e.debugFile}-${r}`}else(e.verbose||process.env.USER_TYPE===`ant`)&&(i=Te(Se(),`claude`,`bridge-session-${r}.log`));let a=null,o;e.debugFile&&(o=Te(we(e.debugFile),`bridge-transcript-${r}.jsonl`),a=De(o,{flags:`a`}),a.on(`error`,t=>{e.onDebug(`[bridge:session] Transcript write error: ${t.message}`),a=null}),e.onDebug(`[bridge:session] Transcript log: ${o}`));let s=[...e.scriptArgs,`--print`,`--sdk-url`,t.sdkUrl,`--session-id`,t.sessionId,`--input-format`,`stream-json`,`--output-format`,`stream-json`,`--replay-user-messages`,...e.verbose?[`--verbose`]:[],...i?[`--debug-file`,i]:[],...e.permissionMode?[`--permission-mode`,e.permissionMode]:[]],c={...e.env,CLAUDE_CODE_OAUTH_TOKEN:void 0,CLAUDE_CODE_ENVIRONMENT_KIND:`bridge`,...e.sandbox&&{CLAUDE_CODE_FORCE_SANDBOX:`1`},CLAUDE_CODE_SESSION_ACCESS_TOKEN:t.accessToken,CLAUDE_CODE_POST_FOR_SESSION_INGRESS_V2:`1`,...t.useCcrV2&&{CLAUDE_CODE_USE_CCR_V2:`1`,CLAUDE_CODE_WORKER_EPOCH:String(t.workerEpoch)}};e.onDebug(`[bridge:session] Spawning sessionId=${t.sessionId} sdkUrl=${t.sdkUrl} accessToken=${t.accessToken?`present`:`MISSING`}`),e.onDebug(`[bridge:session] Child args: ${s.join(` `)}`),i&&e.onDebug(`[bridge:session] Debug log: ${i}`);let l=ke(e.execPath,s,{cwd:n,stdio:[`pipe`,`pipe`,`pipe`],env:c,windowsHide:!0});e.onDebug(`[bridge:session] sessionId=${t.sessionId} pid=${l.pid}`);let u=[],d=null,f=[],p=!1,m=!1;l.stderr&&Ae({input:l.stderr}).on(`line`,t=>{e.verbose&&process.stderr.write(t+`
11
+ `),f.length>=Ie&&f.shift(),f.push(t)}),l.stdout&&Ae({input:l.stdout}).on(`line`,n=>{a&&a.write(n+`
12
+ `),e.onDebug(`[bridge:ws] sessionId=${t.sessionId} <<< ${Y(n)}`),e.verbose&&process.stderr.write(n+`
13
+ `);let r=Be(n,t.sessionId,e.onDebug);for(let n of r)u.length>=Fe&&u.shift(),u.push(n),d=n,e.onActivity?.(t.sessionId,n);{let r;try{r=w(n)}catch{}if(r&&typeof r==`object`){let n=r;if(n.type===`control_request`)n.request?.subtype===`can_use_tool`&&e.onPermissionRequest&&e.onPermissionRequest(t.sessionId,r,t.accessToken);else if(n.type===`user`&&!m&&t.onFirstUserMessage){let e=Ve(n);e&&(m=!0,t.onFirstUserMessage(e))}}}});let h=new Promise(n=>{l.on(`close`,(r,i)=>{a&&(a.end(),a=null),i===`SIGTERM`||i===`SIGINT`?(e.onDebug(`[bridge:session] sessionId=${t.sessionId} interrupted signal=${i} pid=${l.pid}`),n(`interrupted`)):r===0?(e.onDebug(`[bridge:session] sessionId=${t.sessionId} completed exit_code=0 pid=${l.pid}`),n(`completed`)):(e.onDebug(`[bridge:session] sessionId=${t.sessionId} failed exit_code=${r} pid=${l.pid}`),n(`failed`))}),l.on(`error`,r=>{e.onDebug(`[bridge:session] sessionId=${t.sessionId} spawn error: ${r.message}`),n(`failed`)})}),g={sessionId:t.sessionId,done:h,activities:u,accessToken:t.accessToken,lastStderr:f,get currentActivity(){return d},kill(){l.killed||(e.onDebug(`[bridge:session] Sending SIGTERM to sessionId=${t.sessionId} pid=${l.pid}`),process.platform===`win32`?l.kill():l.kill(`SIGTERM`))},forceKill(){!p&&l.pid&&(p=!0,e.onDebug(`[bridge:session] Sending SIGKILL to sessionId=${t.sessionId} pid=${l.pid}`),process.platform===`win32`?l.kill():l.kill(`SIGKILL`))},writeStdin(n){l.stdin&&!l.stdin.destroyed&&(e.onDebug(`[bridge:ws] sessionId=${t.sessionId} >>> ${Y(n)}`),l.stdin.write(n))},updateAccessToken(n){g.accessToken=n,g.writeStdin(E({type:`update_environment_variables`,variables:{CLAUDE_CODE_SESSION_ACCESS_TOKEN:n}})+`
14
+ `),e.onDebug(`[bridge:session] Sent token refresh via stdin for sessionId=${t.sessionId}`)}};return g}}}O(),S(),X();var We={connInitialMs:2e3,connCapMs:12e4,connGiveUpMs:6e5,generalInitialMs:500,generalCapMs:3e4,generalGiveUpMs:6e5},Ge=1e3,Ke=32;async function qe(){return!1}function Je(e){return e.connCapMs*2}function Ye(){let e=[...Q()],t=$();return t&&e.push(t),e}function Xe(e,t,n){try{return e.spawn(t,n)}catch(e){let t=A(e);return I(Error(`Session spawn failed: ${t}`)),t}}async function Ze(t,r,i,a,o,l,u,d=We,f,m){let _=new AbortController;u.aborted?_.abort():u.addEventListener(`abort`,()=>_.abort(),{once:!0});let v=_.signal,y=new Map,ee=new Map,b=new Map,S=new Map,te=new Map,w=new Map,T=new Set,E=new Map,D=new Set,O=new Set,j=fe(v);async function M(){G(`heartbeat: checking ${y.size} active session(s)`);let e=!1,t=!1,n=[];for(let[i]of y){let o=b.get(i),s=te.get(i);if(!(!o||!s))try{await a.heartbeatWork(r,o,s),e=!0}catch(e){k(`[bridge:heartbeat] Failed for sessionId=${i} workId=${o}: ${A(e)}`),e instanceof c&&(z(`tengu_bridge_heartbeat_error`,{status:e.status,error_type:e.status===401||e.status===403?`auth_failed`:`fatal`}),e.status===401||e.status===403?n.push(i):t=!0)}}for(let e of n){l.logVerbose(`Session ${e} token expired — re-queuing via bridge/reconnect`);try{await a.reconnectSession(r,e),k(`[bridge:heartbeat] Re-queued sessionId=${e} via bridge/reconnect`)}catch(t){l.logError(`Failed to refresh session ${e} token: ${A(t)}`),k(`[bridge:heartbeat] reconnectSession(${e}) failed: ${A(t)}`,{level:`error`})}}return t?`fatal`:n.length>0?`auth_failed`:e?`ok`:`failed`}let ne=new Set,P=m?pe({getAccessToken:m,onRefresh:(e,t)=>{let n=y.get(e);n&&(ne.has(e)?(l.logVerbose(`Refreshing session ${e} token via bridge/reconnect`),a.reconnectSession(r,e).catch(t=>{l.logError(`Failed to refresh session ${e} token: ${A(t)}`),k(`[bridge:token] reconnectSession(${e}) failed: ${A(t)}`,{level:`error`})})):n.updateAccessToken(t))},label:`bridge`}):null,F=Date.now(),L=new Set;function R(e){L.add(e),e.finally(()=>L.delete(e))}let B=0,V=0,U=null,K=null,q=null,J=null,Y=!1;if(k(`[bridge:work] Starting poll loop spawnMode=${t.spawnMode} maxSessions=${t.maxSessions} environmentId=${r}`),N(`info`,`bridge_loop_started`,{max_sessions:t.maxSessions,spawn_mode:t.spawnMode}),process.env.USER_TYPE===`ant`){let e;if(t.debugFile){let n=t.debugFile.lastIndexOf(`.`);e=n>0?`${t.debugFile.slice(0,n)}-*${t.debugFile.slice(n)}`:`${t.debugFile}-*`}else e=Te(Se(),`claude`,`bridge-session-*.log`);l.setDebugLogPath(e)}l.printBanner(t,r),l.updateSessionCount(0,t.maxSessions,t.spawnMode),f&&l.setAttached(f);function X(){l.updateSessionCount(y.size,t.maxSessions,t.spawnMode);for(let[e,t]of y){let n=t.currentActivity;n&&l.updateSessionActivity(S.get(e)??e,n)}if(y.size===0){l.updateIdleStatus();return}let[e,n]=[...y.entries()].pop(),r=ee.get(e);if(!r)return;let i=n.currentActivity;if(!i||i.type===`result`||i.type===`error`){t.maxSessions>1&&l.refreshDisplay();return}let a=H(Date.now()-r),o=n.activities.filter(e=>e.type===`tool_start`).slice(-5).map(e=>e.summary);l.updateSessionStatus(e,a,i,o)}function ae(){oe(),X(),J=setInterval(X,Ge)}function oe(){J&&(clearInterval(J),J=null)}function se(e,n,i){return o=>{let s=b.get(e);G(`session done: sessionId=${e} workId=${s??`none`} status=${o} wasTimedOut=${D.has(e)} duration=${Math.round((Date.now()-n)/1e3)}s stderr=${i.lastStderr.length>0?i.lastStderr.join(`\\n`).slice(0,500):`(none)`}`),y.delete(e),ee.delete(e),b.delete(e),te.delete(e);let c=S.get(e)??e;S.delete(e),l.removeSession(c),O.delete(c),ne.delete(e);let u=w.get(e);u&&(clearTimeout(u),w.delete(e)),P?.cancel(e),j.wake();let f=D.delete(e),p=f&&o===`interrupted`?`failed`:o,m=Date.now()-n;k(`[bridge:session] sessionId=${e} workId=${s??`unknown`} exited status=${p} duration=${H(m)}`),z(`tengu_bridge_session_done`,{status:p,duration_ms:m}),N(`info`,`bridge_session_done`,{status:p,duration_ms:m}),l.clearStatus(),oe();let h=i.lastStderr.length>0?i.lastStderr.join(`
15
+ `):void 0,g;switch(p){case`completed`:l.logSessionComplete(e,m);break;case`failed`:!f&&!v.aborted&&(g=h??`Process exited with error`,l.logSessionFailed(e,g),I(Error(`Bridge session failed: ${g}`)));break;case`interrupted`:l.logVerbose(`Session ${e} interrupted`);break}p!==`interrupted`&&s&&(R(rt(a,r,s,l,d.stopWorkBaseDelayMs)),T.add(s));let C=E.get(e);if(C&&(E.delete(e),R(x(C.worktreePath,C.worktreeBranch,C.gitRoot,C.hookBased).catch(e=>l.logVerbose(`Failed to remove worktree ${C.worktreePath}: ${A(e)}`)))),p!==`interrupted`&&!v.aborted)if(t.spawnMode!==`single-session`)R(a.archiveSession(c).catch(t=>l.logVerbose(`Failed to archive session ${e}: ${A(t)}`))),k(`[bridge:session] Session ${p}, returning to idle (multi-session mode)`);else{k(`[bridge:session] Session ${p}, aborting poll loop to tear down environment`),_.abort();return}v.aborted||ae()}}for(f||ae();!v.aborted;){let u=me();try{G(`poll: envId=${r} activeSessions=${y.size}`);let c=await a.pollForWork(r,i,v,u.reclaim_older_than_ms);if(U!==null||K!==null){let e=Date.now()-(U??K??Date.now());l.logReconnected(e),k(`[bridge:poll] Reconnected after ${H(e)}`),z(`tengu_bridge_reconnected`,{disconnected_ms:e})}if(B=0,V=0,U=null,K=null,q=null,!c){if(y.size>=t.maxSessions){let e=u.multisession_poll_interval_ms_at_capacity;if(u.non_exclusive_heartbeat_interval_ms>0){z(`tengu_bridge_heartbeat_mode_entered`,{active_sessions:y.size,heartbeat_interval_ms:u.non_exclusive_heartbeat_interval_ms});let n=e>0?Date.now()+e:null,r=`ok`,i=0;for(;!v.aborted&&y.size>=t.maxSessions&&(n===null||Date.now()<n);){let e=me();if(e.non_exclusive_heartbeat_interval_ms<=0)break;let t=j.signal();if(r=await M(),r===`auth_failed`||r===`fatal`){t.cleanup();break}i++,await W(e.non_exclusive_heartbeat_interval_ms,t.signal),t.cleanup()}let a=r===`auth_failed`||r===`fatal`?r:v.aborted?`shutdown`:y.size<t.maxSessions?`capacity_changed`:n!==null&&Date.now()>=n?`poll_due`:`config_disabled`;if(z(`tengu_bridge_heartbeat_mode_exited`,{reason:a,heartbeat_cycles:i,active_sessions:y.size}),a===`poll_due`&&k(`[bridge:poll] Heartbeat poll_due after ${i} cycles — falling through to pollForWork`),r===`auth_failed`||r===`fatal`){let t=j.signal();await W(e>0?e:u.non_exclusive_heartbeat_interval_ms,t.signal),t.cleanup()}}else if(e>0){let t=j.signal();await W(e,t.signal),t.cleanup()}}else await W(y.size>0?u.multisession_poll_interval_ms_partial_capacity:u.multisession_poll_interval_ms_not_at_capacity,v);continue}let m=y.size>=t.maxSessions;if(T.has(c.id)){if(k(`[bridge:work] Skipping already-completed workId=${c.id}`),m){let e=j.signal();u.non_exclusive_heartbeat_interval_ms>0?(await M(),await W(u.non_exclusive_heartbeat_interval_ms,e.signal)):u.multisession_poll_interval_ms_at_capacity>0&&await W(u.multisession_poll_interval_ms_at_capacity,e.signal),e.cleanup()}else await W(1e3,v);continue}let h;try{h=ye(c.secret)}catch(e){let t=A(e);if(l.logError(`Failed to decode work secret for workId=${c.id}: ${t}`),z(`tengu_bridge_work_secret_failed`,{}),T.add(c.id),R(rt(a,r,c.id,l,d.stopWorkBaseDelayMs)),m){let e=j.signal();u.non_exclusive_heartbeat_interval_ms>0?(await M(),await W(u.non_exclusive_heartbeat_interval_ms,e.signal)):u.multisession_poll_interval_ms_at_capacity>0&&await W(u.multisession_poll_interval_ms_at_capacity,e.signal),e.cleanup()}continue}let g=async()=>{k(`[bridge:work] Acknowledging workId=${c.id}`);try{await a.acknowledgeWork(r,c.id,h.session_ingress_token)}catch(e){k(`[bridge:work] Acknowledge failed workId=${c.id}: ${A(e)}`)}},_=c.data.type;switch(c.data.type){case`healthcheck`:await g(),k(`[bridge:work] Healthcheck received`),l.logVerbose(`Healthcheck received`);break;case`session`:{let i=c.data.id;G(`work received: type=session sessionId=${i} workId=${c.id}`);try{p(i,`session_id`)}catch{await g(),l.logError(`Invalid session_id received: ${i}`);break}let u=y.get(i);if(u){u.updateAccessToken(h.session_ingress_token),te.set(i,h.session_ingress_token),b.set(i,c.id),P?.schedule(i,h.session_ingress_token),k(`[bridge:work] Updated access token for existing sessionId=${i} workId=${c.id}`),await g();break}if(y.size>=t.maxSessions){k(`[bridge:work] At capacity (${y.size}/${t.maxSessions}), cannot spawn new session for workId=${c.id}`);break}await g();let m=Date.now(),_,j=!1,M;if(h.use_code_sessions===!0||e(process.env.CLAUDE_BRIDGE_USE_CCR_V2)){_=be(t.apiBaseUrl,i);for(let e=1;e<=2;e++)try{M=await _e(_,h.session_ingress_token),j=!0,k(`[bridge:session] CCR v2: registered worker sessionId=${i} epoch=${M} attempt=${e}`);break}catch(t){let n=A(t);if(e<2){if(k(`[bridge:session] CCR v2: registerWorker attempt ${e} failed, retrying: ${n}`),await W(2e3,v),v.aborted)break;continue}l.logError(`CCR v2 worker registration failed for session ${i}: ${n}`),I(Error(`registerWorker failed: ${n}`)),T.add(c.id),R(rt(a,r,c.id,l,d.stopWorkBaseDelayMs))}if(!j)break}else _=ve(t.sessionIngressUrl,i);let F=t.spawnMode,L=t.dir,B=0;if(F===`worktree`&&(f===void 0||!ge(i,f))){let e=Date.now();try{let t=await C(`bridge-${Le(i)}`);B=Date.now()-e,E.set(i,{worktreePath:t.worktreePath,worktreeBranch:t.worktreeBranch,gitRoot:t.gitRoot,hookBased:t.hookBased}),L=t.worktreePath,k(`[bridge:session] Created worktree for sessionId=${i} at ${t.worktreePath}`)}catch(e){let t=A(e);l.logError(`Failed to create worktree for session ${i}: ${t}`),I(Error(`Worktree creation failed: ${t}`)),T.add(c.id),R(rt(a,r,c.id,l,d.stopWorkBaseDelayMs));break}}k(`[bridge:session] Spawning sessionId=${i} sdkUrl=${_}`);let V=re(i);G(`spawning session: sessionId=${i} sdkUrl=${_} useCcrV2=${j} workerEpoch=${M} dir=${L} accessToken=${h.session_ingress_token?h.session_ingress_token.slice(0,8)+`...`:`NONE`}`);let H=Xe(o,{sessionId:i,sdkUrl:_,accessToken:h.session_ingress_token,useCcrV2:j,workerEpoch:M,onFirstUserMessage:e=>{if(O.has(V))return;O.add(V);let n=dt(e);l.setSessionTitle(V,n),k(`[bridge:title] derived title for ${V}: ${n}`),import(`./createSession-DM4acqaC.js`).then(({updateBridgeSessionTitle:e})=>e(V,n,{baseUrl:t.apiBaseUrl})).catch(e=>k(`[bridge:title] failed to update title for ${V}: ${e}`,{level:`error`}))}},L);if(typeof H==`string`){l.logError(`Failed to spawn session ${i}: ${H}`);let e=E.get(i);e&&(E.delete(i),R(x(e.worktreePath,e.worktreeBranch,e.gitRoot,e.hookBased).catch(t=>l.logVerbose(`Failed to remove worktree ${e.worktreePath}: ${A(t)}`)))),T.add(c.id),R(rt(a,r,c.id,l,d.stopWorkBaseDelayMs));break}let U=H,K=Date.now()-m;z(`tengu_bridge_session_started`,{active_sessions:y.size,spawn_mode:F,in_worktree:E.has(i),spawn_duration_ms:K,worktree_create_ms:B,inProtectedNamespace:n()}),N(`info`,`bridge_session_started`,{spawn_mode:F,in_worktree:E.has(i),spawn_duration_ms:K,worktree_create_ms:B}),y.set(i,U),b.set(i,c.id),te.set(i,h.session_ingress_token),S.set(i,V);let q=Date.now();ee.set(i,q),l.logSessionStart(i,`Session ${i}`);let J=Le(i),Y;if(t.debugFile){let e=t.debugFile.lastIndexOf(`.`);Y=e>0?`${t.debugFile.slice(0,e)}-${J}${t.debugFile.slice(e)}`:`${t.debugFile}-${J}`}else(t.verbose||process.env.USER_TYPE===`ant`)&&(Y=Te(Se(),`claude`,`bridge-session-${J}.log`));Y&&l.logVerbose(`Debug log: ${Y}`),l.addSession(V,s(V,t.sessionIngressUrl)),ae(),l.setAttached(V),ft(V,t.apiBaseUrl).then(e=>{e&&y.has(i)&&(O.add(V),l.setSessionTitle(V,e),k(`[bridge:title] server title for ${V}: ${e}`))}).catch(e=>k(`[bridge:title] failed to fetch title for ${V}: ${e}`,{level:`error`}));let X=t.sessionTimeoutMs??864e5;if(X>0){let e=setTimeout(it,X,i,X,l,D,U);w.set(i,e)}j&&ne.add(i),P?.schedule(i,h.session_ingress_token),U.done.then(se(i,q,U));break}default:await g(),k(`[bridge:work] Unknown work type: ${_}, skipping`);break}if(m){let e=j.signal();u.non_exclusive_heartbeat_interval_ms>0?(await M(),await W(u.non_exclusive_heartbeat_interval_ms,e.signal)):u.multisession_poll_interval_ms_at_capacity>0&&await W(u.multisession_poll_interval_ms_at_capacity,e.signal),e.cleanup()}}catch(e){if(v.aborted)break;if(e instanceof c){Y=!0,h(e.errorType)?l.logStatus(e.message):g(e)?k(`[bridge:work] Suppressed 403 error: ${e.message}`):(l.logError(e.message),I(e)),z(`tengu_bridge_fatal_error`,{status:e.status,error_type:e.errorType}),N(h(e.errorType)?`info`:`error`,`bridge_fatal_error`,{status:e.status,error_type:e.errorType});break}let t=ie(e);if(G(`poll error: ${t} isConn=${$e(e)} isServer=${et(e)} activeSessions=${y.size}`),$e(e)||et(e)){let e=Date.now();q!==null&&e-q>Je(d)&&(k(`[bridge:work] Detected system sleep (${Math.round((e-q)/1e3)}s gap), resetting error budget`),N(`info`,`bridge_poll_sleep_detected`,{gapMs:e-q}),U=null,B=0,K=null,V=0),q=e,U||(U=e);let n=e-U;if(n>=d.connGiveUpMs){l.logError(`Server unreachable for ${Math.round(n/6e4)} minutes, giving up.`),z(`tengu_bridge_poll_give_up`,{error_type:`connection`,elapsed_ms:n}),N(`error`,`bridge_poll_give_up`,{error_type:`connection`,elapsed_ms:n}),Y=!0;break}K=null,V=0,B=B?Math.min(B*2,d.connCapMs):d.connInitialMs;let r=tt(B);l.logVerbose(`Connection error, retrying in ${nt(r)} (${Math.round(n/1e3)}s elapsed): ${t}`),l.updateReconnectingStatus(nt(r),H(n)),me().non_exclusive_heartbeat_interval_ms>0&&await M(),await W(r,v)}else{let e=Date.now();q!==null&&e-q>Je(d)&&(k(`[bridge:work] Detected system sleep (${Math.round((e-q)/1e3)}s gap), resetting error budget`),N(`info`,`bridge_poll_sleep_detected`,{gapMs:e-q}),U=null,B=0,K=null,V=0),q=e,K||(K=e);let n=e-K;if(n>=d.generalGiveUpMs){l.logError(`Persistent errors for ${Math.round(n/6e4)} minutes, giving up.`),z(`tengu_bridge_poll_give_up`,{error_type:`general`,elapsed_ms:n}),N(`error`,`bridge_poll_give_up`,{error_type:`general`,elapsed_ms:n}),Y=!0;break}U=null,B=0,V=V?Math.min(V*2,d.generalCapMs):d.generalInitialMs;let r=tt(V);l.logVerbose(`Poll failed, retrying in ${nt(r)} (${Math.round(n/1e3)}s elapsed): ${t}`),l.updateReconnectingStatus(nt(r),H(n)),me().non_exclusive_heartbeat_interval_ms>0&&await M(),await W(r,v)}}}oe(),l.clearStatus();let ce=Date.now()-F;z(`tengu_bridge_shutdown`,{active_sessions:y.size,loop_duration_ms:ce}),N(`info`,`bridge_shutdown`,{active_sessions:y.size,loop_duration_ms:ce});let le=new Set(y.keys());f&&le.add(f);let ue=new Map(S);if(y.size>0){k(`[bridge:shutdown] Shutting down ${y.size} active session(s)`),l.logStatus(`Shutting down ${y.size} active session(s)\u2026`);let e=new Map(b);for(let[e,t]of y.entries())k(`[bridge:shutdown] Sending SIGTERM to sessionId=${e}`),t.kill();let t=new AbortController;await Promise.race([Promise.allSettled([...y.values()].map(e=>e.done)),W(d.shutdownGraceMs??3e4,t.signal)]),t.abort();for(let[e,t]of y.entries())k(`[bridge:shutdown] Force-killing stuck sessionId=${e}`),t.forceKill();for(let e of w.values())clearTimeout(e);if(w.clear(),P?.cancelAll(),E.size>0){let e=[...E.values()];E.clear(),k(`[bridge:shutdown] Cleaning up ${e.length} worktree(s)`),await Promise.allSettled(e.map(e=>x(e.worktreePath,e.worktreeBranch,e.gitRoot,e.hookBased)))}await Promise.allSettled([...e.entries()].map(([e,t])=>a.stopWork(r,t,!0).catch(n=>l.logVerbose(`Failed to stop work ${t} for session ${e}: ${A(n)}`))))}if(L.size>0&&await Promise.allSettled([...L]),t.spawnMode===`single-session`&&f&&!Y){l.logStatus("Resume this session by running `claude remote-control --continue`"),k(`[bridge:shutdown] Skipping archive+deregister to allow resume of session ${f}`);return}le.size>0&&(k(`[bridge:shutdown] Archiving ${le.size} session(s)`),await Promise.allSettled([...le].map(e=>a.archiveSession(ue.get(e)??re(e)).catch(t=>l.logVerbose(`Failed to archive session ${e}: ${A(t)}`)))));try{await a.deregisterEnvironment(r),k(`[bridge:shutdown] Environment deregistered, bridge offline`),l.logVerbose(`Environment deregistered.`)}catch(e){l.logVerbose(`Failed to deregister environment: ${A(e)}`)}let{clearBridgePointer:de}=await import(`./bridgePointer-W_jdQ8zf.js`);await de(t.dir),l.logVerbose(`Environment offline.`)}var Qe=new Set([`ECONNREFUSED`,`ECONNRESET`,`ETIMEDOUT`,`ENETUNREACH`,`EHOSTUNREACH`]);function $e(e){return!!(e&&typeof e==`object`&&`code`in e&&typeof e.code==`string`&&Qe.has(e.code))}function et(e){return!!e&&typeof e==`object`&&`code`in e&&typeof e.code==`string`&&e.code===`ERR_BAD_RESPONSE`}function tt(e){return Math.max(0,e+e*.25*(2*Math.random()-1))}function nt(e){return e>=1e3?`${(e/1e3).toFixed(1)}s`:`${Math.round(e)}ms`}async function rt(e,t,n,r,i=1e3){for(let a=1;a<=3;a++)try{await e.stopWork(t,n,!1),k(`[bridge:work] stopWork succeeded for workId=${n} on attempt ${a}/3`);return}catch(e){if(e instanceof c){g(e)?k(`[bridge:work] Suppressed stopWork 403 for ${n}: ${e.message}`):r.logError(`Failed to stop work ${n}: ${e.message}`),N(`error`,`bridge_stop_work_failed`,{attempts:a,fatal:!0});return}let t=A(e);if(a<3){let e=tt(i*2**(a-1));r.logVerbose(`Failed to stop work ${n} (attempt ${a}/3), retrying in ${nt(e)}: ${t}`),await W(e)}else r.logError(`Failed to stop work ${n} after 3 attempts: ${t}`),N(`error`,`bridge_stop_work_failed`,{attempts:3})}}function it(e,t,n,r,i){k(`[bridge:session] sessionId=${e} timed out after ${H(t)}`),z(`tengu_bridge_session_timeout`,{timeout_ms:t}),n.logSessionFailed(e,`Session timed out after ${H(t)}`),r.add(e),i.kill()}var at=[`session`,`same-dir`,`worktree`];function ot(e){return e===`session`?`single-session`:e===`same-dir`?`same-dir`:e===`worktree`?`worktree`:`--spawn requires one of: ${at.join(`, `)} (got: ${e??`<missing>`})`}function st(e){let t=e===void 0?NaN:parseInt(e,10);return isNaN(t)||t<1?`--capacity requires a positive integer (got: ${e??`<missing>`})`:t}function ct(e){let t=!1,n=!1,r,i,a,o,s=!1,c,l,u,d,f=!1;for(let m=0;m<e.length;m++){let h=e[m];if(h===`--help`||h===`-h`)s=!0;else if(h===`--verbose`||h===`-v`)t=!0;else if(h===`--sandbox`)n=!0;else if(h===`--no-sandbox`)n=!1;else if(h===`--debug-file`&&m+1<e.length)r=Ee(e[++m]);else if(h.startsWith(`--debug-file=`))r=Ee(h.slice(13));else if(h===`--session-timeout`&&m+1<e.length)i=parseInt(e[++m],10)*1e3;else if(h.startsWith(`--session-timeout=`))i=parseInt(h.slice(18),10)*1e3;else if(h===`--permission-mode`&&m+1<e.length)a=e[++m];else if(h.startsWith(`--permission-mode=`))a=h.slice(18);else if(h===`--name`&&m+1<e.length)o=e[++m];else if(h.startsWith(`--name=`))o=h.slice(7);else if(h===`--session-id`&&m+1<e.length){if(d=e[++m],!d)return p(`--session-id requires a value`)}else if(h.startsWith(`--session-id=`)){if(d=h.slice(13),!d)return p(`--session-id requires a value`)}else if(h===`--continue`||h===`-c`)f=!0;else if(h===`--spawn`||h.startsWith(`--spawn=`)){if(c!==void 0)return p(`--spawn may only be specified once`);let t=ot(h.startsWith(`--spawn=`)?h.slice(8):e[++m]);if(t===`single-session`||t===`same-dir`||t===`worktree`)c=t;else return p(t)}else if(h===`--capacity`||h.startsWith(`--capacity=`)){if(l!==void 0)return p(`--capacity may only be specified once`);let t=st(h.startsWith(`--capacity=`)?h.slice(11):e[++m]);if(typeof t==`number`)l=t;else return p(t)}else if(h===`--create-session-in-dir`)u=!0;else if(h===`--no-create-session-in-dir`)u=!1;else return p(`Unknown argument: ${h}\nRun 'claude remote-control --help' for usage.`)}if(c===`single-session`&&l!==void 0)return p(`--capacity cannot be used with --spawn=session (single-session mode has fixed capacity 1).`);if((d||f)&&(c!==void 0||l!==void 0||u!==void 0))return p(`--session-id and --continue cannot be used with --spawn, --capacity, or --create-session-in-dir.`);if(d&&f)return p(`--session-id and --continue cannot be used together.`);return{verbose:t,sandbox:n,debugFile:r,sessionTimeoutMs:i,permissionMode:a,name:o,spawnMode:c,capacity:l,createSessionInDir:u,sessionId:d,continueSession:f,help:s};function p(e){return{verbose:t,sandbox:n,debugFile:r,sessionTimeoutMs:i,permissionMode:a,name:o,spawnMode:c,capacity:l,createSessionInDir:u,sessionId:d,continueSession:f,help:s,error:e}}}async function lt(){let{EXTERNAL_PERMISSION_MODES:e}=await import(`./permissions-CeYKbtSC.js`),t=e.join(`, `),n=await qe(),r=`
16
+ Remote Control - Connect your local environment to claude.ai/code
17
+
18
+ USAGE
19
+ claude remote-control [options]
20
+ OPTIONS
21
+ --name <name> Name for the session (shown in claude.ai/code)
22
+ -c, --continue Resume the last session in this directory
23
+ --session-id <id> Resume a specific session by ID (cannot be
24
+ used with spawn flags or --continue)
25
+ --permission-mode <mode> Permission mode for spawned sessions
26
+ (${t})
27
+ --debug-file <path> Write debug logs to file
28
+ -v, --verbose Enable verbose output
29
+ -h, --help Show this help
30
+ ${n?` --spawn <mode> Spawn mode: same-dir, worktree, session
31
+ (default: same-dir)
32
+ --capacity <N> Max concurrent sessions in worktree or
33
+ same-dir mode (default: ${Ke})
34
+ --[no-]create-session-in-dir Pre-create a session in the current
35
+ directory; in worktree mode this session
36
+ stays in cwd while on-demand sessions get
37
+ isolated worktrees (default: on)
38
+ `:``}
39
+ DESCRIPTION
40
+ Remote Control allows you to control sessions on your local device from
41
+ claude.ai/code (https://claude.ai/code). Run this command in the
42
+ directory you want to work in, then connect from the Claude app or web.
43
+ ${n?`
44
+ Remote Control runs as a persistent server that accepts multiple concurrent
45
+ sessions in the current directory. One session is pre-created on start so
46
+ you have somewhere to type immediately. Use --spawn=worktree to isolate
47
+ each on-demand session in its own git worktree, or --spawn=session for
48
+ the classic single-session mode (exits when that session ends). Press 'w'
49
+ during runtime to toggle between same-dir and worktree.
50
+ `:``}
51
+ NOTES
52
+ - You must be logged in with a Claude account that has a subscription
53
+ - Run \`claude\` first in the directory to accept the workspace trust dialog
54
+ ${n?` - Worktree mode requires a git repository or WorktreeCreate/WorktreeRemove hooks
55
+ `:``}`;console.log(r)}var ut=80;function dt(e){return B(e.replace(/\s+/g,` `).trim(),ut)}async function ft(e,t){let{getBridgeSession:n}=await import(`./createSession-DM4acqaC.js`);return(await n(e,{baseUrl:t}))?.title||void 0}async function pt(e){let t=ct(e);if(t.help){await lt();return}t.error&&(console.error(`Error: ${t.error}`),process.exit(1));let{verbose:n,sandbox:r,debugFile:i,sessionTimeoutMs:a,permissionMode:o,name:s,spawnMode:l,capacity:u,createSessionInDir:d,sessionId:f,continueSession:m}=t,h=f,g,_=l!==void 0||u!==void 0||d!==void 0;if(o!==void 0){let{PERMISSION_MODES:e}=await import(`./permissions-CeYKbtSC.js`),t=e;t.includes(o)||(console.error(`Error: Invalid permission mode '${o}'. Valid modes: ${t.join(`, `)}`),process.exit(1))}let v=Ee(`.`),{enableConfigs:y,checkHasTrustDialogAccepted:b}=await import(`./config-BrxKpHpR.js`);y();let{initSinks:x}=await import(`./sinks-jfaIjsRJ.js`);x();let S=await qe();_&&!S&&(await L(`tengu_bridge_multi_session_denied`,{used_spawn:l!==void 0,used_capacity:u!==void 0,used_create_session_in_dir:d!==void 0}),await Promise.race([Promise.all([ce(),ae()]),W(500,void 0,{unref:!0})]).catch(()=>{}),console.error(`Error: Multi-session Remote Control is not enabled for your account yet.`),process.exit(1));let{setOriginalCwd:C,setCwdState:te}=await import(`./state-53JDbNQM.js`);C(v),te(v),b()||(console.error(`Error: Workspace not trusted. Please run \`claude\` in ${v} first to review and accept the workspace trust dialog.`),process.exit(1));let{clearOAuthTokenCache:w,checkAndRefreshOAuthTokenIfNeeded:T}=await import(`./auth-CEig4Gxp.js`),{getBridgeAccessToken:E,getBridgeBaseUrl:D}=await import(`./bridgeConfig-D5dB38xD.js`);E()||(console.error(ue),process.exit(1));let{getGlobalConfig:O,saveGlobalConfig:j,getCurrentProjectConfig:M,saveCurrentProjectConfig:ne}=await import(`./config-BrxKpHpR.js`);if(!O().remoteDialogSeen){let e=(await import(`readline`)).createInterface({input:process.stdin,output:process.stdout});console.log(`
56
+ Remote Control lets you access this CLI session from the web (claude.ai/code)
57
+ or the Claude app, so you can pick up where you left off on any device.
58
+
59
+ You can disconnect remote access anytime by running /remote-control again.
60
+ `);let t=await new Promise(t=>{e.question(`Enable Remote Control? (y/n) `,t)});e.close(),j(e=>e.remoteDialogSeen?e:{...e,remoteDialogSeen:!0}),t.toLowerCase()!==`y`&&t.toLowerCase()!==`yes`&&process.exit(0)}if(m){let{readBridgePointerAcrossWorktrees:e}=await import(`./bridgePointer-W_jdQ8zf.js`),t=await e(v);t||(console.error("Error: No recent session found in this directory or its worktrees. Run `claude remote-control` to start a new one."),process.exit(1));let{pointer:n,dir:r}=t,i=Math.round(n.ageMs/6e4),a=i<60?`${i}m`:`${Math.round(i/60)}h`,o=r===v?``:` from worktree ${r}`;console.error(`Resuming session ${n.sessionId} (${a} ago)${o}\u2026`),h=n.sessionId,g=r}let P=D();P.startsWith(`http://`)&&!P.includes(`localhost`)&&!P.includes(`127.0.0.1`)&&(console.error(`Error: Remote Control base URL uses HTTP. Only HTTPS or localhost HTTP is allowed.`),process.exit(1));let F=process.env.CLAUDE_BRIDGE_SESSION_INGRESS_URL||P,{getBranch:R,getRemoteUrl:B,findGitRoot:V}=await import(`./git-BE_FiJZp.js`),{hasWorktreeCreateHook:H}=await import(`./hooks-DONAb_nq.js`),U=H()||V(v)!==null,G=S?M().remoteControlSpawnMode:void 0;if(G===`worktree`&&!U&&(console.error(`Warning: Saved spawn mode is worktree but this directory is not a git repository. Falling back to same-dir.`),G=void 0,ne(e=>e.remoteControlSpawnMode===void 0?e:{...e,remoteControlSpawnMode:void 0})),S&&!G&&U&&l===void 0&&!h&&process.stdin.isTTY){let e=(await import(`readline`)).createInterface({input:process.stdin,output:process.stdout});console.log(`
61
+ Claude Remote Control is launching in spawn mode which lets you create new sessions in this project from Claude Code on Web or your Mobile app. Learn more here: https://code.claude.com/docs/en/remote-control
62
+
63
+ Spawn mode for this project:
64
+ [1] same-dir — sessions share the current directory (default)
65
+ [2] worktree — each session gets an isolated git worktree
66
+
67
+ This can be changed later or explicitly set with --spawn=same-dir or --spawn=worktree.
68
+ `);let t=await new Promise(t=>{e.question(`Choose [1/2] (default: 1): `,t)});e.close();let n=t.trim()===`2`?`worktree`:`same-dir`;G=n,z(`tengu_bridge_spawn_mode_chosen`,{spawn_mode:n}),ne(e=>e.remoteControlSpawnMode===n?e:{...e,remoteControlSpawnMode:n})}let K,q;h?(q=`single-session`,K=`resume`):l===void 0?G===void 0?(q=S?`same-dir`:`single-session`,K=`gate_default`):(q=G,K=`saved`):(q=l,K=`flag`);let re=q===`single-session`?1:u??Ke,Y=d??!0;if(!h){let{clearBridgePointer:e}=await import(`./bridgePointer-W_jdQ8zf.js`);await e(v)}q===`worktree`&&!U&&(console.error(`Error: Worktree mode requires a git repository or WorktreeCreate hooks configured. Use --spawn=session for single-session mode.`),process.exit(1));let X=await R(),ie=await B(),oe=xe(),se=Oe(),{handleOAuth401Error:le}=await import(`./auth-CEig4Gxp.js`),de=ee({baseUrl:P,getAccessToken:E,runnerVersion:`0.0.1`,onDebug:k,onAuth401:le,getTrustedDeviceToken:he}),Z;if(h){try{p(h,`sessionId`)}catch{console.error(`Error: Invalid session ID "${h}". Session IDs must not contain unsafe characters.`),process.exit(1)}await T(),w();let{getBridgeSession:e}=await import(`./createSession-DM4acqaC.js`),t=await e(h,{baseUrl:P,getAccessToken:E});if(!t){if(g){let{clearBridgePointer:e}=await import(`./bridgePointer-W_jdQ8zf.js`);await e(g)}console.error(`Error: Session ${h} not found. It may have been archived or expired, or your login may have lapsed (run \`claude /login\`).`),process.exit(1)}if(!t.environment_id){if(g){let{clearBridgePointer:e}=await import(`./bridgePointer-W_jdQ8zf.js`);await e(g)}console.error(`Error: Session ${h} has no environment_id. It may never have been attached to a bridge.`),process.exit(1)}Z=t.environment_id,k(`[bridge:init] Resuming session ${h} on environment ${Z}`)}let Q={dir:v,machineName:oe,branch:X,gitRepoUrl:ie,maxSessions:re,spawnMode:q,verbose:n,sandbox:r,bridgeId:se,workerType:`claude_code`,environmentId:Oe(),reuseEnvironmentId:Z,apiBaseUrl:P,sessionIngressUrl:F,debugFile:i,sessionTimeoutMs:a};k(`[bridge:init] bridgeId=${se}${Z?` reuseEnvironmentId=${Z}`:``} dir=${v} branch=${X} gitRepoUrl=${ie} machine=${oe}`),k(`[bridge:init] apiBaseUrl=${P} sessionIngressUrl=${F}`),k(`[bridge:init] sandbox=${r}${i?` debugFile=${i}`:``}`);let $,fe;try{let e=await de.registerBridgeEnvironment(Q);$=e.environment_id,fe=e.environment_secret}catch(e){z(`tengu_bridge_registration_failed`,{status:e instanceof c?e.status:void 0}),console.error(e instanceof c&&e.status===404?`Remote Control environments are not available for your account.`:`Error: ${A(e)}`),process.exit(1)}let pe;if(h)if(Z&&$!==Z)I(Error(`Bridge resume env mismatch: requested ${Z}, backend returned ${$}. Falling back to fresh session.`)),console.warn(`Warning: Could not resume session ${h} — its environment has expired. Creating a fresh session instead.`);else{let e=J(h),t=e===h?[h]:[h,e],n=!1,r;for(let e of t)try{await de.reconnectSession($,e),k(`[bridge:init] Session ${e} re-queued via bridge/reconnect`),pe=h,n=!0;break}catch(t){r=t,k(`[bridge:init] reconnectSession(${e}) failed: ${A(t)}`)}if(!n){let e=r,t=e instanceof c;if(g&&t){let{clearBridgePointer:e}=await import(`./bridgePointer-W_jdQ8zf.js`);await e(g)}console.error(t?`Error: ${A(e)}`:`Error: Failed to reconnect session ${h}: ${A(e)}\nThe session may still be resumable — try running the same command again.`),process.exit(1)}}k(`[bridge:init] Registered, server environmentId=${$}`);let ge=me();z(`tengu_bridge_started`,{max_sessions:Q.maxSessions,has_debug_file:!!Q.debugFile,sandbox:Q.sandbox,verbose:Q.verbose,heartbeat_interval_ms:ge.non_exclusive_heartbeat_interval_ms,spawn_mode:Q.spawnMode,spawn_mode_source:K,multi_session_gate:S,pre_create_session:Y,worktree_available:U}),N(`info`,`bridge_started`,{max_sessions:Q.maxSessions,sandbox:Q.sandbox,spawn_mode:Q.spawnMode});let _e=Ue({execPath:process.execPath,scriptArgs:Ye(),env:process.env,verbose:n,sandbox:r,debugFile:i,permissionMode:o,onDebug:k,onActivity:(e,t)=>{k(`[bridge:activity] sessionId=${e} ${t.type} ${t.summary}`)},onPermissionRequest:(e,t,n)=>{k(`[bridge:perm] sessionId=${e} tool=${t.request.tool_name} request_id=${t.request_id} (not auto-approving)`)}}),ve=Pe({verbose:n}),{parseGitHubRepository:ye}=await import(`./detectRepository-6nw-Aw3v.js`),be=ie?ye(ie):null,Se=be?be.split(`/`).pop():Ce(v);ve.setRepoInfo(Se,X);let we=q!==`single-session`&&U;we&&ve.setSpawnModeDisplay(q);let Te=e=>{if(e[0]===3||e[0]===4){process.emit(`SIGINT`);return}if(e[0]===32){ve.toggleQr();return}if(e[0]===119){if(!we)return;let e=Q.spawnMode===`same-dir`?`worktree`:`same-dir`;Q.spawnMode=e,z(`tengu_bridge_spawn_mode_toggled`,{spawn_mode:e}),ve.logStatus(e===`worktree`?`Spawn mode: worktree (new sessions get isolated git worktrees)`:`Spawn mode: same-dir (new sessions share the current directory)`),ve.setSpawnModeDisplay(e),ve.refreshDisplay(),ne(t=>t.remoteControlSpawnMode===e?t:{...t,remoteControlSpawnMode:e});return}};process.stdin.isTTY&&(process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.on(`data`,Te));let De=new AbortController,ke=()=>{k(`[bridge:shutdown] SIGINT received, shutting down`),De.abort()},Ae=()=>{k(`[bridge:shutdown] SIGTERM received, shutting down`),De.abort()};process.on(`SIGINT`,ke),process.on(`SIGTERM`,Ae);let je=pe||null;if(Y&&!pe){let{createBridgeSession:e}=await import(`./createSession-DM4acqaC.js`);try{je=await e({environmentId:$,title:s,events:[],gitRepoUrl:ie,branch:X,signal:De.signal,baseUrl:P,getAccessToken:E,permissionMode:o}),je&&k(`[bridge:init] Created initial session ${je}`)}catch(e){k(`[bridge:init] Session creation failed (non-fatal): ${A(e)}`)}}let Me=null;if(je&&q===`single-session`){let{writeBridgePointer:e}=await import(`./bridgePointer-W_jdQ8zf.js`),t={sessionId:je,environmentId:$,source:`standalone`};await e(Q.dir,t),Me=setInterval(e,3600*1e3,Q.dir,t),Me.unref?.()}try{await Ze(Q,$,fe,de,_e,ve,De.signal,void 0,je??void 0,async()=>(w(),await T(),E()))}finally{Me!==null&&clearInterval(Me),process.off(`SIGINT`,ke),process.off(`SIGTERM`,Ae),process.stdin.off(`data`,Te),process.stdin.isTTY&&process.stdin.setRawMode(!1),process.stdin.pause()}process.exit(0)}var mt=class extends Error{constructor(e){super(e),this.name=`BridgeHeadlessPermanentError`}};async function ht(e,t){let{dir:n,log:r}=e;process.chdir(n);let{setOriginalCwd:i,setCwdState:a}=await import(`./state-53JDbNQM.js`);i(n),a(n);let{enableConfigs:o,checkHasTrustDialogAccepted:s}=await import(`./config-BrxKpHpR.js`);o();let{initSinks:c}=await import(`./sinks-jfaIjsRJ.js`);if(c(),!s())throw new mt(`Workspace not trusted: ${n}. Run \`claude\` in that directory first to accept the trust dialog.`);if(!e.getAccessToken())throw Error(ue);let{getBridgeBaseUrl:l}=await import(`./bridgeConfig-D5dB38xD.js`),u=l();if(u.startsWith(`http://`)&&!u.includes(`localhost`)&&!u.includes(`127.0.0.1`))throw new mt(`Remote Control base URL uses HTTP. Only HTTPS or localhost HTTP is allowed.`);let d=process.env.CLAUDE_BRIDGE_SESSION_INGRESS_URL||u,{getBranch:f,getRemoteUrl:p,findGitRoot:m}=await import(`./git-BE_FiJZp.js`),{hasWorktreeCreateHook:h}=await import(`./hooks-DONAb_nq.js`);if(e.spawnMode===`worktree`&&!(h()||m(n)!==null))throw new mt(`Worktree mode requires a git repository or WorktreeCreate hooks. Directory ${n} has neither.`);let g=await f(),_=await p(),v=xe(),y=Oe(),b={dir:n,machineName:v,branch:g,gitRepoUrl:_,maxSessions:e.capacity,spawnMode:e.spawnMode,verbose:!1,sandbox:e.sandbox,bridgeId:y,workerType:`claude_code`,environmentId:Oe(),apiBaseUrl:u,sessionIngressUrl:d,sessionTimeoutMs:e.sessionTimeoutMs},x=ee({baseUrl:u,getAccessToken:e.getAccessToken,runnerVersion:`0.0.1`,onDebug:r,onAuth401:e.onAuth401,getTrustedDeviceToken:he}),S,C;try{let e=await x.registerBridgeEnvironment(b);S=e.environment_id,C=e.environment_secret}catch(e){throw Error(`Bridge registration failed: ${A(e)}`)}let te=Ue({execPath:process.execPath,scriptArgs:Ye(),env:process.env,verbose:!1,sandbox:e.sandbox,permissionMode:e.permissionMode,onDebug:r}),w=gt(r);w.printBanner(b,S);let T;if(e.createSessionOnStart){let{createBridgeSession:n}=await import(`./createSession-DM4acqaC.js`);try{let i=await n({environmentId:S,title:e.name,events:[],gitRepoUrl:_,branch:g,signal:t,baseUrl:u,getAccessToken:e.getAccessToken,permissionMode:e.permissionMode});i&&(T=i,r(`created initial session ${i}`))}catch(e){r(`session pre-creation failed (non-fatal): ${A(e)}`)}}await Ze(b,S,C,x,te,w,t,void 0,T,async()=>e.getAccessToken())}function gt(e){let t=()=>{};return{printBanner:(t,n)=>e(`registered environmentId=${n} dir=${t.dir} spawnMode=${t.spawnMode} capacity=${t.maxSessions}`),logSessionStart:(t,n)=>e(`session start ${t}`),logSessionComplete:(t,n)=>e(`session complete ${t} (${n}ms)`),logSessionFailed:(t,n)=>e(`session failed ${t}: ${n}`),logStatus:e,logVerbose:e,logError:t=>e(`error: ${t}`),logReconnected:t=>e(`reconnected after ${t}ms`),addSession:(t,n)=>e(`session attached ${t}`),removeSession:t=>e(`session detached ${t}`),updateIdleStatus:t,updateReconnectingStatus:t,updateSessionStatus:t,updateSessionActivity:t,updateSessionCount:t,updateFailedStatus:t,setSpawnModeDisplay:t,setRepoInfo:t,setDebugLogPath:t,setAttached:t,setSessionTitle:t,clearStatus:t,toggleQr:t,refreshDisplay:t}}export{ct as a,et as i,pt as n,ht as o,$e as r,Ze as s,mt as t};
@@ -0,0 +1 @@
1
+ import{n as e}from"./bridgeMain--R1HFbOv.js";export{e as bridgeMain};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./defineProperty-C-QyHrDq.js";import{D as n,E as r,U as i,l as a,p as o,z as s}from"./debug-IKW-jE7K.js";import{B as c,F as l,G as u,I as d,O as f,U as p,Y as m,b as h,g,m as _}from"./log-B3eB4EFv.js";import{n as v,r as y}from"./analytics-BotDBGh0.js";import{P as b,lt as x,n as S,t as C}from"./rcDebugLog-BUuD-X1D.js";import{t as w}from"./controlMessageCompat-IFu4Gc1y.js";import{randomUUID as T}from"crypto";v(),b(),a(),C(),_(),i(),r(),m(),e();function E(e){return typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`}function D(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`control_response`&&`response`in e}function O(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`control_request`&&`request_id`in e&&`request`in e}function k(e){return(e.type===`user`||e.type===`assistant`)&&e.isVirtual?!1:e.type===`user`||e.type===`assistant`||e.type===`system`&&e.subtype===`local_command`}function A(e){if(e.type!==`user`||e.isMeta||e.toolUseResult||e.isCompactSummary||e.origin&&e.origin.kind!==`human`)return;let t=e.message.content,n;if(typeof t==`string`)n=t;else for(let e of t??[])if(e.type===`text`){n=e.text;break}if(n)return g(n)||void 0}var j=`system-reminder`,M=/\s*<([a-z][\w-]*)(?:\s[^>]*)?>[\s\S]*?<\/\1>\s*/gy,N=new Set([h,f,l,d,c,p,u]);function P(e){let t=e.message?.content;return typeof t==`string`?t:Array.isArray(t)?t.filter(e=>!!e&&typeof e==`object`&&e.type===`text`&&typeof e.text==`string`).map(e=>e.text).join(``):``}function F(e){let t=e.trim();if(!t)return null;M.lastIndex=0;let n=[];for(;M.lastIndex<t.length;){let e=M.exec(t);if(!e)return null;n.push(e[1])}return n.length>0?n:null}function I(e){if(e.type!==`user`||e.isVisibleInTranscriptOnly)return!1;if(e.toolUseResult!==void 0||!e.isMeta)return!0;let t=F(P(e));return!t||t.some(e=>e!==`local-command-caveat`&&e!==j&&N.has(e))}function L(e){return e.some(I)}function R(e,t,r,i,a,c){try{let s=w(n(e));if(D(s)){o(`[bridge:repl] Ingress message type=control_response`),a?.(s);return}if(O(s)){o(`[bridge:repl] Inbound control_request subtype=${s.request.subtype}`),c?.(s);return}if(!E(s))return;let l=`uuid`in s&&typeof s.uuid==`string`?s.uuid:void 0;if(l&&t.has(l)){o(`[bridge:repl] Ignoring echo: type=${s.type} uuid=${l}`);return}if(l&&r.has(l)){o(`[bridge:repl] Ignoring re-delivered inbound: type=${s.type} uuid=${l}`);return}o(`[bridge:repl] Ingress message type=${s.type}${l?` uuid=${l}`:``}`),s.type===`user`?(l&&r.add(l),y(`tengu_bridge_message_received`,{is_repl:!0}),i?.(s)):o(`[bridge:repl] Ignoring non-user inbound message: type=${s.type}`)}catch(e){o(`[bridge:repl] Failed to parse ingress message: ${s(e)}`)}}var z=`This session is outbound-only. Enable Remote Control locally to allow inbound control.`;function B(e,t){let{transport:n,sessionId:r,outboundOnly:i,onInterrupt:a,onSetModel:s,onSetMaxThinkingTokens:c,onSetPermissionMode:l}=t;if(!n){o(`[bridge:repl] Cannot respond to control_request: transport not configured`);return}let u,d=e.request;if(i&&d.subtype!==`initialize`){u={type:`control_response`,response:{subtype:`error`,request_id:e.request_id,error:z}};let t={...u,session_id:r};n.write(t),o(`[bridge:repl] Rejected ${d.subtype} (outbound-only) request_id=${e.request_id}`);return}switch(d.subtype){case`initialize`:u={type:`control_response`,response:{subtype:`success`,request_id:e.request_id,response:{commands:[],output_style:`normal`,available_output_styles:[`normal`],models:[],account:{},pid:process.pid}}};break;case`set_model`:s?.(d.model),u={type:`control_response`,response:{subtype:`success`,request_id:e.request_id}};break;case`set_max_thinking_tokens`:c?.(d.max_thinking_tokens??null),u={type:`control_response`,response:{subtype:`success`,request_id:e.request_id}};break;case`set_permission_mode`:{let t=l?.(d.mode)??{ok:!1,error:`set_permission_mode is not supported in this context (onSetPermissionMode callback not registered)`};u=t.ok?{type:`control_response`,response:{subtype:`success`,request_id:e.request_id}}:{type:`control_response`,response:{subtype:`error`,request_id:e.request_id,error:t.error}};break}case`interrupt`:a?.(),u={type:`control_response`,response:{subtype:`success`,request_id:e.request_id}};break;default:u={type:`control_response`,response:{subtype:`error`,request_id:e.request_id,error:`REPL bridge does not handle control_request subtype: ${d.subtype}`}}}let f={...u,session_id:r};n.write(f),S(`control_response: subtype=${d.subtype} request_id=${e.request_id} result=${u.response.subtype}`),o(`[bridge:repl] Sent control_response for ${d.subtype} request_id=${e.request_id} result=${u.response.subtype}`)}function V(e){return{type:`result_success`,subtype:`success`,duration_ms:0,duration_api_ms:0,is_error:!1,num_turns:0,result:``,stop_reason:null,total_cost_usd:0,usage:{...x},modelUsage:{},permission_denials:[],session_id:e,uuid:T()}}var H=class{constructor(e){t(this,`capacity`,void 0),t(this,`ring`,void 0),t(this,`set`,new Set),t(this,`writeIdx`,0),this.capacity=e,this.ring=Array(e)}add(e){if(this.set.has(e))return;let t=this.ring[this.writeIdx];t!==void 0&&this.set.delete(t),this.ring[this.writeIdx]=e,this.set.add(e),this.writeIdx=(this.writeIdx+1)%this.capacity}has(e){return this.set.has(e)}clear(){this.set.clear(),this.ring.fill(void 0),this.writeIdx=0}};export{k as a,L as c,B as i,A as n,V as o,R as r,I as s,H as t};
@@ -0,0 +1 @@
1
+ import{A as e,l as t,t as n,w as r}from"./v4-jw6qOKwQ.js";import{D as i,E as a,G as o,O as s,U as c,l,p as u}from"./debug-IKW-jE7K.js";import{_ as d,c as f,g as p,l as m,m as h}from"./sessionStoragePortable-Cx6JQ5Ye.js";import{n as g,t as _}from"./lazySchema-uxlVVNM1.js";import{dirname as v,join as y}from"path";import{mkdir as b,readFile as x,stat as S,unlink as C,writeFile as w}from"fs/promises";n(),l(),c(),d(),_(),m(),a();var T=50,E=g(()=>r({sessionId:e(),environmentId:e(),source:t([`standalone`,`repl`])}));function D(e){return y(f(),h(e),`bridge-pointer.json`)}async function O(e,t){let n=D(e);try{await b(v(n),{recursive:!0}),await w(n,s(t),`utf8`),u(`[bridge:pointer] wrote ${n}`)}catch(e){u(`[bridge:pointer] write failed: ${e}`,{level:`warn`})}}async function k(e){let t=D(e),n,r;try{r=(await S(t)).mtimeMs,n=await x(t,`utf8`)}catch{return null}let i=E().safeParse(M(n));if(!i.success)return u(`[bridge:pointer] invalid schema, clearing: ${t}`),await j(e),null;let a=Math.max(0,Date.now()-r);return a>144e5?(u(`[bridge:pointer] stale (>4h mtime), clearing: ${t}`),await j(e),null):{...i.data,ageMs:a}}async function A(e){let t=await k(e);if(t)return{pointer:t,dir:e};let n=await p(e);if(n.length<=1)return null;if(n.length>T)return u(`[bridge:pointer] ${n.length} worktrees exceeds fanout cap ${T}, skipping`),null;let r=h(e),i=n.filter(e=>h(e)!==r),a=await Promise.all(i.map(async e=>{let t=await k(e);return t?{pointer:t,dir:e}:null})),o=null;for(let e of a)e&&(!o||e.pointer.ageMs<o.pointer.ageMs)&&(o=e);return o&&u(`[bridge:pointer] fanout found pointer in worktree ${o.dir} (ageMs=${o.pointer.ageMs})`),o}async function j(e){let t=D(e);try{await C(t),u(`[bridge:pointer] cleared ${t}`)}catch(e){o(e)||u(`[bridge:pointer] clear failed: ${e}`,{level:`warn`})}}function M(e){try{return i(e)}catch{return null}}export{j as clearBridgePointer,k as readBridgePointer,A as readBridgePointerAcrossWorktrees,O as writeBridgePointer};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{r as t,t as n}from"./execFileNoThrow-COKYqVQj.js";function r(e){let t;try{t=new URL(e)}catch{throw Error(`Invalid URL format: ${e}`)}if(t.protocol!==`http:`&&t.protocol!==`https:`)throw Error(`Invalid URL protocol: must use http:// or https://, got ${t.protocol}`)}async function i(e){try{let t=process.platform;if(t===`win32`){let{code:t}=await n(`explorer`,[e]);return t===0}let{code:r}=await n(t===`darwin`?`open`:`xdg-open`,[e]);return r===0}catch{return!1}}async function a(e){try{r(e);let t=process.env.BROWSER,i=process.platform;if(i===`win32`){if(t){let{code:r}=await n(t,[`"${e}"`]);return r===0}let{code:r}=await n(`rundll32`,[`url,OpenURL`,e],{});return r===0}else{let{code:r}=await n(t||(i===`darwin`?`open`:`xdg-open`),[e]);return r===0}}catch{return!1}}var o=e((()=>{t()}));export{a as n,i as r,o as t};
@@ -0,0 +1 @@
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{I as n,P as r,bn as i,fi as a,ot as o,t as s,vn as c,xt as l}from"./src-CDCSSo0U2.js";import{t as u}from"./jsx-runtime-Bb4Xn-E0.js";import{Al as d,Ao as f,GT as p,KT as m,TS as h,aw as g,dT as _,iw as v,kl as y,lh as b,lt as x,ob as S,qT as C,sb as w,sh as T,ut as E,zo as D}from"./loadAgentsDir-nzr38hai.js";import{U as O,z as k}from"./debug-IKW-jE7K.js";import{Kt as A}from"./settings-5PQdphqC.js";import{b as j,g as M}from"./config-C7YHKCPV.js";import{st as N}from"./rcDebugLog-BUuD-X1D.js";import{n as P,r as F}from"./sideQuestion-CYdNATPW.js";import{i as I,n as L}from"./modalContext-DFjKLCB6.js";function R({question:e,context:t,onDone:a}){let[s,c]=(0,H.useState)(null),[u,d]=(0,H.useState)(null),[f,p]=(0,H.useState)(0),m=(0,H.useRef)(null),{rows:h}=I(o());i(()=>p(e=>e+1),s||u?null:80);function g(e){if(e.key===`escape`||e.key===`return`||e.key===` `||e.ctrl&&(e.key===`c`||e.key===`d`)){e.preventDefault(),a(void 0,{display:`skip`});return}(e.key===`up`||e.ctrl&&e.key===`p`)&&(e.preventDefault(),m.current?.scrollBy(-3)),(e.key===`down`||e.ctrl&&e.key===`n`)&&(e.preventDefault(),m.current?.scrollBy(K))}(0,H.useEffect)(()=>{let n=v();async function r(){try{let r=await F({question:e,cacheSafeParams:await B(t)});n.signal.aborted||(r.response?c(r.response):d(`No response received`))}catch(e){n.signal.aborted||d(k(e)||`Failed to get response`)}}return r(),()=>{n.abort()}},[e,t]);let _=Math.max(5,h-W-G);return(0,U.jsxs)(n,{flexDirection:`column`,paddingLeft:2,marginTop:1,tabIndex:0,autoFocus:!0,onKeyDown:g,children:[(0,U.jsxs)(n,{children:[(0,U.jsxs)(r,{color:`warning`,bold:!0,children:[`/btw`,` `]}),(0,U.jsx)(r,{dimColor:!0,children:e})]}),(0,U.jsx)(n,{marginTop:1,marginLeft:2,maxHeight:_,children:(0,U.jsx)(l,{ref:m,flexDirection:`column`,flexGrow:1,children:u?(0,U.jsx)(r,{color:`error`,children:u}):s?(0,U.jsx)(T,{children:s}):(0,U.jsxs)(n,{children:[(0,U.jsx)(S,{frame:f,messageColor:`warning`}),(0,U.jsx)(r,{color:`warning`,children:`Answering...`})]})})}),(s||u)&&(0,U.jsx)(n,{marginTop:1,children:(0,U.jsxs)(r,{dimColor:!0,children:[`↑`,`/`,`↓`,` to scroll · Space, Enter, or Escape to dismiss`]})})]})}function z(e){let t=e.at(-1);return t?.type===`assistant`&&t.message.stop_reason===null?e.slice(0,-1):e}async function B(e){let t=f(z(e.messages)),n=y();if(n)return{systemPrompt:n.systemPrompt,userContext:n.userContext,systemContext:n.systemContext,toolUseContext:e,forkContextMessages:t};let[r,i,a]=await Promise.all([x(e.options.tools,e.options.mainLoopModel,[],e.options.mcpClients),m(),p()]);return{systemPrompt:N(r),userContext:i,systemContext:a,toolUseContext:e,forkContextMessages:t}}async function V(e,t,n){let r=n?.trim();return r?(j(e=>({...e,btwUseCount:e.btwUseCount+1})),(0,U.jsx)(R,{question:r,context:t,onDone:e})):(e(`Usage: /btw <your question>`,{display:`system`}),null)}var H,U,W,G,K;e((()=>{a(),H=t(a(),1),c(),b(),w(),A(),E(),L(),C(),h(),s(),g(),M(),O(),d(),D(),P(),_(),U=u(),W=5,G=6,K=3}))();export{V as call};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";function t(){return process.versions.bun!==void 0}function n(){return typeof Bun<`u`&&Array.isArray(Bun.embeddedFiles)&&Bun.embeddedFiles.length>0}var r=e((()=>{}));export{n,t as r,r as t};
@@ -0,0 +1,3 @@
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./defineProperty-C-QyHrDq.js";import{m as i}from"./zod-CuNujUwx.js";import{Sr as a,en as o,l as s,xr as c,zn as l}from"./state-4KQ3kaqz.js";import{Ac as u,Cm as d,Ep as f,Ft as ee,GT as p,JT as m,Jb as h,KT as g,Kp as _,Ky as v,Qi as y,Sp as b,Vi as x,Vt as te,WT as ne,Y as re,Yb as ie,Z as ae,_ as oe,_l as se,aE as ce,cw as le,g as ue,gE as de,hl as fe,iE as pe,kc as me,mE as he,nE as ge,ow as _e,p as ve,qT as ye,qp as be,qy as xe,tE as Se,wm as Ce,yn as we}from"./loadAgentsDir-nzr38hai.js";import{n as Te,t as S}from"./cwd-BuJhkTrc.js";import{U as Ee,_ as De,h as Oe,l as ke,p as C,z as Ae}from"./debug-IKW-jE7K.js";import{g as je,n as Me}from"./settings-5PQdphqC.js";import{c as Ne,g as Pe}from"./config-C7YHKCPV.js";import{T as Fe,_ as Ie,g as Le,r as w,x as Re}from"./git-tyaWOgRL.js";import{n as T,r as ze}from"./execFileNoThrow-COKYqVQj.js";import{o as Be,s as E}from"./log-B3eB4EFv.js";import{i as Ve,n as He}from"./path-BCSE0S-c.js";import{n as Ue,r as D}from"./analytics-BotDBGh0.js";import{a as We,s as Ge}from"./ripgrep-BvDwiKJ3.js";import{i as Ke,t as qe}from"./detectRepository-ReZ0Fz8Z.js";import{r as Je,t as Ye}from"./magicDocs-BqZ0GewA.js";import*as O from"path";import{statSync as Xe}from"fs";function Ze(e,t,n){if(t===0)return n?A:0;let r=e.charCodeAt(t-1);return Qe(r)?rt:$e(r)&&et(e.charCodeAt(t))?it:0}function Qe(e){return e===47||e===92||e===45||e===95||e===46||e===32}function $e(e){return e>=97&&e<=122}function et(e){return e>=65&&e<=90}function k(){return new Promise(e=>setImmediate(e))}function tt(e,t){let n=new Set;for(let r of e){let e=r.length;for(let t=0;t<r.length;t++){let n=r.charCodeAt(t);if(n===47||n===92){e=t;break}}let i=r.slice(0,e);if(i.length>0&&(n.add(i),n.size>=t))break}let r=Array.from(n);return r.sort((e,t)=>{let n=e.length-t.length;return n===0?e<t?-1:+(e>t):n}),r.slice(0,t).map(e=>({path:e,score:0}))}var nt,rt,it,at,A,ot,j,M,N,P,st,ct=e((()=>{n(),nt=16,rt=8,it=6,at=4,A=8,ot=3,j=1,M=100,N=64,P=new Int32Array(N),st=class{constructor(){r(this,`paths`,[]),r(this,`lowerPaths`,[]),r(this,`charBits`,new Int32Array),r(this,`pathLens`,new Uint16Array),r(this,`topLevelCache`,null),r(this,`readyCount`,0)}loadFromFileList(e){let t=new Set,n=[];for(let r of e)r.length>0&&!t.has(r)&&(t.add(r),n.push(r));this.buildIndex(n)}loadFromFileListAsync(e){let t=()=>{};return{queryable:new Promise(e=>{t=e}),done:this.buildAsync(e,t)}}async buildAsync(e,t){let n=new Set,r=[],i=performance.now();for(let t=0;t<e.length;t++){let a=e[t];a.length>0&&!n.has(a)&&(n.add(a),r.push(a)),(t&255)==255&&performance.now()-i>4&&(await k(),i=performance.now())}this.resetArrays(r),i=performance.now();let a=!0;for(let e=0;e<r.length;e++)this.indexPath(e),(e&255)==255&&performance.now()-i>4&&(this.readyCount=e+1,a&&(t(),a=!1),await k(),i=performance.now());this.readyCount=r.length,t()}buildIndex(e){this.resetArrays(e);for(let t=0;t<e.length;t++)this.indexPath(t);this.readyCount=e.length}resetArrays(e){let t=e.length;this.paths=e,this.lowerPaths=Array(t),this.charBits=new Int32Array(t),this.pathLens=new Uint16Array(t),this.readyCount=0,this.topLevelCache=tt(e,M)}indexPath(e){let t=this.paths[e].toLowerCase();this.lowerPaths[e]=t;let n=t.length;this.pathLens[e]=n;let r=0;for(let e=0;e<n;e++){let n=t.charCodeAt(e);n>=97&&n<=122&&(r|=1<<n-97)}this.charBits[e]=r}search(e,t){if(t<=0)return[];if(e.length===0)return this.topLevelCache?this.topLevelCache.slice(0,t):[];let n=e!==e.toLowerCase(),r=n?e:e.toLowerCase(),i=Math.min(r.length,N),a=Array(i),o=0;for(let e=0;e<i;e++){let t=r.charAt(e);a[e]=t;let n=t.charCodeAt(0);n>=97&&n<=122&&(o|=1<<n-97)}let s=i*24+A+32,c=[],l=-1/0,{paths:u,lowerPaths:d,charBits:f,pathLens:ee,readyCount:p}=this;for(let e=0;e<p;e++){if((f[e]&o)!==o)continue;let r=n?u[e]:d[e],p=a[0],m=0,h=[],g=r.indexOf(p);if(g===-1)continue;h[m++]=g;for(let e=g+1;e<r.length;e++){if(r.charCodeAt(e)!==p.charCodeAt(0))continue;let t=r.charCodeAt(e-1);(t===47||t===92||t===45||t===95||t===46||t===32)&&(h[m++]=e)}let _=u[e],v=ee[e],y=Math.max(0,32-(v>>2)),b=-1/0;for(let e=0;e<m;e++){P[0]=h[e];let n=0,o=0,u=P[0],d=!0;for(let e=1;e<i;e++){let t=r.indexOf(a[e],u+1);if(t===-1){d=!1;break}P[e]=t;let i=t-u-1;i===0?o+=at:n+=ot+i*j,u=t}if(!d||c.length===t&&s+o-n+y<=l)continue;let f=i*nt+o-n;f+=Ze(_,P[0],!0);for(let e=1;e<i;e++)f+=Ze(_,P[e],!1);f+=y,f>b&&(b=f)}if(b===-1/0)continue;let x=b;if(c.length<t)c.push({path:_,fuzzScore:x}),c.length===t&&(c.sort((e,t)=>e.fuzzScore-t.fuzzScore),l=c[0].fuzzScore);else if(x>l){let e=0,t=c.length;for(;e<t;){let n=e+t>>1;c[n].fuzzScore<x?e=n+1:t=n}c.splice(e,0,{path:_,fuzzScore:x}),c.shift(),l=c[0].fuzzScore}}c.sort((e,t)=>t.fuzzScore-e.fuzzScore);let m=c.length,h=Math.max(m,1),g=Array(m);for(let e=0;e<m;e++){let t=c[e].path,n=e/h;g[e]={path:t,score:t.includes(`test`)?Math.min(n*1.05,1):n}}return g}}}));function F(){return R||(R=new st),R}function lt(){R=null,z=null,V++,H=null,U=[],W=[],G=[],B.clear(),K=null,q=null,J=0,Y=null,X=null,Z=null}function ut(e){let t=e.length,n=Math.max(1,Math.floor(t/500)),r=-2128831035;for(let i=0;i<t;i+=n){let t=e[i];for(let e=0;e<t.length;e++)r=(r^t.charCodeAt(e))*16777619|0;r=r*16777619|0}if(t>0){let n=e[t-1];for(let e=0;e<n.length;e++)r=(r^n.charCodeAt(e))*16777619|0}return`${t}:${(r>>>0).toString(16)}`}function dt(){let e=w(S());if(!e)return null;try{return Xe(O.join(e,`.git`,`index`)).mtimeMs}catch{return null}}function ft(e,t,n){return n===t?e:e.map(e=>{let r=O.join(t,e);return O.relative(n,r)})}async function pt(e){if(e.length===0||!R||U.length===0)return;let t=await gt(e),n=[...U,...W,...G,...e,...t],r=ut(n);if(r===Z){C(`[FileIndex] skipped index rebuild — merged paths unchanged`);return}await R.loadFromFileListAsync(n).done,Z=r,C(`[FileIndex] rebuilt index with ${U.length} tracked + ${e.length} untracked files`)}async function mt(e,t){let n=`${e}:${t}`;if(q===n)return K;let r=Oe(),i=[`.ignore`,`.rgignore`],a=[...new Set([e,t])],o=(0,Dt.default)(),s=!1,c=a.flatMap(e=>i.map(t=>O.join(e,t))),l=await Promise.all(c.map(e=>r.readFile(e,{encoding:`utf8`}).catch(()=>null)));for(let[e,t]of l.entries())t!==null&&(o.add(t),s=!0,C(`[FileIndex] loaded ignore patterns from ${c[e]}`));let u=s?o:null;return K=u,q=n,u}async function ht(e,t){let n=Date.now();C(`[FileIndex] getFilesUsingGit called`);let r=S(),i=w(r);if(!i)return C(`[FileIndex] not a git repo, returning null`),null;try{let a=Date.now(),o=await T(Le(),[`-c`,`core.quotepath=false`,`ls-files`,`--recurse-submodules`],{timeout:5e3,abortSignal:e,cwd:i});if(C(`[FileIndex] git ls-files (tracked) took ${Date.now()-a}ms`),o.code!==0)return C(`[FileIndex] git ls-files failed (code=${o.code}, stderr=${o.stderr}), falling back to ripgrep`),null;let s=ft(o.stdout.trim().split(`
2
+ `).filter(Boolean),i,r),c=await mt(i,r);if(c){let e=s.length;s=c.filter(s),C(`[FileIndex] applied ignore patterns: ${e} -> ${s.length} files`)}U=s;let l=Date.now()-n;if(C(`[FileIndex] git ls-files: ${s.length} tracked files in ${l}ms`),D(`tengu_file_suggestions_git_ls_files`,{file_count:s.length,tracked_count:s.length,untracked_count:0,duration_ms:l}),!H){let e=t?[`-c`,`core.quotepath=false`,`ls-files`,`--others`,`--exclude-standard`]:[`-c`,`core.quotepath=false`,`ls-files`,`--others`],n=V;H=T(Le(),e,{timeout:1e4,cwd:i}).then(async e=>{if(n===V&&e.code===0){let t=ft(e.stdout.trim().split(`
3
+ `).filter(Boolean),i,r),n=await mt(i,r);if(n&&t.length>0){let e=t.length;t=n.filter(t),C(`[FileIndex] applied ignore patterns to untracked: ${e} -> ${t.length} files`)}C(`[FileIndex] background untracked fetch: ${t.length} files`),pt(t)}}).catch(e=>{C(`[FileIndex] background untracked fetch failed: ${e}`)}).finally(()=>{H=null})}return s}catch(e){return C(`[FileIndex] git ls-files error: ${Ae(e)}`),null}}async function gt(e){let t=new Set,n=performance.now();for(let r=0;r<e.length;r++)_t(e,r,r+1,t),(r&255)==255&&performance.now()-n>4&&(await k(),n=performance.now());return[...t].map(e=>e+O.sep)}function _t(e,t,n,r){for(let i=t;i<n;i++){let t=O.dirname(e[i]);for(;t!==`.`&&!r.has(t);){let e=O.dirname(t);if(e===t)break;r.add(t),t=e}}}async function vt(e){return(await Promise.all(ve.map(t=>oe(t,e)))).flatMap(e=>e.map(e=>e.filePath))}async function yt(e,t){C(`[FileIndex] getProjectFiles called, respectGitignore=${t}`);let n=await ht(e,t);if(n!==null)return C(`[FileIndex] using git ls-files result (${n.length} files)`),n;C(`[FileIndex] git ls-files returned null, falling back to ripgrep`);let r=Date.now(),i=[`--files`,`--follow`,`--hidden`,`--glob`,`!.git/`,`--glob`,`!.svn/`,`--glob`,`!.hg/`,`--glob`,`!.bzr/`,`--glob`,`!.jj/`,`--glob`,`!.sl/`];t||i.push(`--no-ignore-vcs`);let a=(await Ge(i,`.`,e)).map(e=>O.relative(S(),e)),o=Date.now()-r;return C(`[FileIndex] ripgrep: ${a.length} files in ${o}ms`),D(`tengu_file_suggestions_ripgrep`,{file_count:a.length,duration_ms:o}),a}async function bt(){let e=AbortSignal.timeout(1e4),t=F();try{let n=Me(),r=Ne(),i=n.respectGitignore??r.respectGitignore??!0,a=S(),[o,s]=await Promise.all([yt(e,i),vt(a)]);W=s;let c=[...o,...s],l=await gt(c);G=l;let u=[...l,...c],d=ut(u);d===X?C(`[FileIndex] skipped index rebuild — tracked paths unchanged`):(await t.loadFromFileListAsync(u).done,X=d,Z=null)}catch(e){E(e)}return t}function xt(e,t){let n=Math.min(e.length,t.length),r=0;for(;r<n&&e[r]===t[r];)r++;return e.substring(0,r)}function St(e){if(e.length===0)return``;let t=e.map(e=>e.displayText),n=t[0];for(let e=1;e<t.length;e++){let r=t[e];if(n=xt(n,r),n===``)return``}return n}function I(e,t){return{id:`file-${e}`,displayText:e,metadata:t===void 0?void 0:{score:t}}}function Ct(e,t){return e.search(t,Q).map(e=>I(e.path,e.score))}function L(){if(z)return;let e=dt();if(R&&!(e!==null&&e!==Y)&&Date.now()-J<kt)return;let t=V,n=Date.now();F(),z=bt().then(r=>t===V?(z=null,B.emit(),Y=e,J=Date.now(),C(`[FileIndex] cache refresh completed in ${Date.now()-n}ms`),r):r).catch(e=>(C(`[FileIndex] Cache refresh failed: ${Ae(e)}`),E(e),t===V&&(z=null),F()))}async function wt(){let e=Oe(),t=S();try{return(await e.readdir(t)).map(e=>{let n=O.join(t,e.name),r=O.relative(t,n);return e.isDirectory()?r+O.sep:r})}catch(e){return E(e),[]}}async function Tt(e,t=!1){if(!e&&!t)return[];if(Me().fileSuggestion?.type===`command`)return(await te({...ee(),query:e})).slice(0,Q).map(I);if(e===``||e===`.`||e===`./`){let e=await wt();return L(),e.slice(0,Q).map(I)}let n=Date.now();try{let t=z!==null;L();let r=e,i=`.`+O.sep;e.startsWith(i)&&(r=e.substring(2)),r.startsWith(`~`)&&(r=He(r));let a=R?Ct(R,r):[],o=Date.now()-n;return C(`[FileIndex] generateFileSuggestions: ${a.length} results in ${o}ms (${t?`partial`:`full`} index)`),D(`tengu_file_suggestions_query`,{duration_ms:o,cache_hit:!t,result_count:a.length,query_length:e.length}),a}catch(e){return E(e),[]}}function Et(e,t,n,r,i,a){let o=typeof e==`string`?e:e.displayText;i(t.substring(0,r)+o+t.substring(r+n.length)),a(r+o.length)}var Dt,R,z,B,Ot,V,H,U,W,G,K,q,J,Y,X,Z,Q,kt,$=e((()=>{Dt=t(i(),1),ue(),ct(),Ue(),Pe(),Te(),ke(),Ee(),ze(),De(),Ie(),we(),Be(),Ve(),We(),je(),a(),R=null,z=null,B=c(),Ot=B.subscribe,V=0,H=null,U=[],W=[],G=[],K=null,q=null,J=0,Y=null,X=null,Z=null,Q=15,kt=5e3}));function At(e=new Set){let t=e.size>0;g.cache.clear?.(),p.cache.clear?.(),ne.cache.clear?.(),pe.cache.clear?.(),lt(),x(),t||de(),m(null),l(null),se(),u(),ge(`session_start`),h(),v(),process.env.USER_TYPE===`ant`&&import(`./TungstenTool-Cb7gJvq4.js`).then(({clearSessionsWithTungstenUsage:e,resetInitializationState:t})=>{e(),t()}),import(`./attributionHooks-CUAoGkU6.js`).then(({clearAttributionCaches:e})=>e()),qe(),re(),t||_e(),s(e),Re(),b(),Ce(),Ye(),_(),import(`./SearchExtraToolsTool-D3VOFq9R.js`).then(({clearSearchExtraToolsDescriptionCache:e})=>e()),import(`./loadAgentsDir-Dgd-fzNt.js`).then(({clearAgentDefinitionsCache:e})=>e()),import(`./prompt-DIoNqZvO.js`).then(({clearPromptCache:e})=>e())}var jt=e((()=>{o(),y(),ce(),ye(),$(),le(),he(),xe(),fe(),d(),Je(),f(),me(),ae(),Se(),Ke(),Fe(),ie(),be()}));export{Tt as a,L as c,St as i,jt as n,$ as o,Et as r,Ot as s,At as t};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./caches-BtmAri4e.js";e();export{t as clearSessionCaches};
@@ -0,0 +1 @@
1
+ function e(e){let t=new AbortController;function n(){t.abort(),t=new AbortController}function r(){let n=new AbortController,r=()=>n.abort();if(e.aborted||t.signal.aborted)return n.abort(),{signal:n.signal,cleanup:()=>{}};e.addEventListener(`abort`,r,{once:!0});let i=t.signal;return i.addEventListener(`abort`,r,{once:!0}),{signal:n.signal,cleanup:()=>{e.removeEventListener(`abort`,r),i.removeEventListener(`abort`,r)}}}return{signal:r,wake:n}}export{e as t};