@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{a as e}from"./rolldown-runtime-DaDcL9Zw.js";import{l as t,o as n,u as r}from"./envUtils-DSxRz_kt.js";import{en as i,ht as a,nt as o}from"./state-4KQ3kaqz.js";import{Aa as s,Ao as c,Bl as l,Da as u,Ea as d,Fa as f,Fy as p,Il as m,Ma as h,Na as ee,Oa as g,Oo as _,Pa as te,Py as v,Ta as y,Ua as b,Uo as x,Va as S,Ya as ne,ja as C,jr as re,ka as w,mr as ie,zo as T}from"./loadAgentsDir-nzr38hai.js";import{U as ae,l as oe,ot as E,p as D,st as se,z as O}from"./debug-IKW-jE7K.js";import{b as ce,c as le,g as ue}from"./config-C7YHKCPV.js";import{M as k,_ as de,i as A,j as fe,p as pe}from"./git-tyaWOgRL.js";import{g as me,m as j}from"./log-B3eB4EFv.js";import{n as he,r as M}from"./analytics-BotDBGh0.js";import{Hr as N,Lt as P,Ur as F,Vt as ge,ht as _e,kt as I,vn as L,yn as R}from"./model-DfFA3qMO.js";import{O as z,_ as ve,d as ye,k as be,n as B,t as V}from"./rcDebugLog-BUuD-X1D.js";import{a as H,c as U,d as xe,f as Se,o as W,r as G,s as K,u as q}from"./debugUtils-D2981c0Z.js";import{a as Ce,i as J,n as we,o as Y,t as X}from"./bridgeConfig-CCtXe8ak.js";import{a as Z,o as Q,r as Te,s as Ee,t as De}from"./bridgeEnabled--F-6TUi4.js";import{i as Oe,t as ke}from"./assistant-BA9_Mo9U.js";import{t as Ae}from"./capacityWake-CV_x9H8j.js";import{n as je,t as Me}from"./pollConfig-C2Ac8WMU.js";import{i as Ne}from"./trustedDevice-BYCh1ff7.js";import{a as Pe,n as Fe,r as Ie,t as Le}from"./workSecret-C_lv0dRh.js";import{a as Re,i as $,n as ze,t as Be}from"./createSession-DIr4sUp6.js";import{i as Ve,n as He}from"./envLessBridgeConfig-D_Jg4fJy.js";import{n as Ue,o as We}from"./mappers-CWykjGfP.js";import{n as Ge,r as Ke,t as qe}from"./sessionTitle-B8jcexkQ.js";import{a as Je,i as Ye,n as Xe,o as Ze,r as Qe,t as $e}from"./bridgeMessaging-CqbLTDcx.js";import{t as et}from"./HybridTransport-BgV5_7Az.js";import{n as tt,r as nt,t as rt}from"./flushGate-ZFr8yv7F.js";import{hostname as it}from"os";import{randomUUID as at}from"crypto";i(),j(),de(),ue(),F(),ge(),Ce(),p(),Te(),T(),S(),re(),$(),Ve(),Ue(),Ke(),h(),oe(),V(),fe(),he(),E(),U(),m(),z(),ye(),n(),W(),ae(),L(),d();var ot=2e3,st=6e4,ct=900*1e3,lt=0;async function ut(e){let{dir:n,machineName:i,branch:a,gitRepoUrl:o,title:s,baseUrl:c,sessionIngressUrl:d,workerType:f,getAccessToken:p,createSession:m,archiveSession:h,getCurrentTitle:ee=()=>s,toSDKMessages:_=()=>{throw Error(`BridgeCoreParams.toSDKMessages not provided. Pass it if you use writeMessages() or initialMessages — daemon callers that only use writeSdkMessages() never hit this path.`)},onAuth401:te,getPollIntervalConfig:v=()=>je,initialHistoryCap:b=200,initialMessages:x,previouslyFlushedUUIDs:S,onInboundMessage:ne,onPermissionResponse:re,onInterrupt:ie,onSetModel:T,onSetMaxThinkingTokens:ae,onSetPermissionMode:oe,onStateChange:E,onUserMessage:ce,perpetual:le,initialSSESequenceNum:ue=0}=e,de=++lt,{writeBridgePointer:A,clearBridgePointer:fe,readBridgePointer:pe}=await import(`./bridgePointer-W_jdQ8zf.js`),me=le?await pe(n):null,j=me?.source===`repl`?me:null;D(`[bridge:repl] initBridgeCore #${de} starting (initialMessages=${x?.length??0}${j?` perpetual prior=env:${j.environmentId}`:``})`);let he=C({baseUrl:c,getAccessToken:p,runnerVersion:`0.0.1`,onDebug:D,onAuth401:te,getTrustedDeviceToken:Ne}),N=process.env.USER_TYPE===`ant`?w(he):he,P={dir:n,machineName:i,branch:a,gitRepoUrl:o,maxSessions:1,spawnMode:`single-session`,verbose:!1,sandbox:!1,bridgeId:at(),workerType:f,environmentId:at(),reuseEnvironmentId:j?.environmentId,apiBaseUrl:c,sessionIngressUrl:d},F,ge;try{let e=await N.registerBridgeEnvironment(P);F=e.environment_id,ge=e.environment_secret}catch(e){return K(`registration_failed`,`[bridge:repl] Environment registration failed: ${O(e)}`),j&&await fe(n),E?.(`failed`,O(e)),null}D(`[bridge:repl] Environment registered: ${F}`),k(`info`,`bridge_repl_env_registered`),M(`tengu_bridge_repl_env_registered`,{});async function _e(e,t){if(F!==e)return D(`[bridge:repl] Env mismatch (requested ${e}, got ${F}) — cannot reconnect in place`),!1;let n=Se(t),r=n===t?[t]:[t,n];for(let e of r)try{return await N.reconnectSession(F,e),D(`[bridge:repl] Reconnected session ${e} in place on env ${F}`),!0}catch(t){D(`[bridge:repl] reconnectSession(${e}) failed: ${O(t)}`)}return D(`[bridge:repl] reconnectSession exhausted — falling through to fresh session`),!1}let I=j?await _e(j.environmentId,j.sessionId):!1;j&&!I&&await fe(n);let L;if(I&&j){if(L=j.sessionId,D(`[bridge:repl] Perpetual session reused: ${L}`),x&&S)for(let e of x)S.add(e.uuid)}else{let e=await m({environmentId:F,title:s,gitRepoUrl:o,branch:a,signal:AbortSignal.timeout(15e3)});if(!e)return D(`[bridge:repl] Session creation failed, deregistering environment`),M(`tengu_bridge_repl_session_failed`,{}),await N.deregisterEnvironment(F).catch(()=>{}),E?.(`failed`,`Session creation failed`),null;L=e,D(`[bridge:repl] Session created: ${L}`)}await A(n,{sessionId:L,environmentId:F,source:`repl`}),k(`info`,`bridge_repl_session_created`),M(`tengu_bridge_repl_started`,{has_initial_messages:!!(x&&x.length>0),inProtectedNamespace:r()});let R=new Set;if(x)for(let e of x)R.add(e.uuid);let z=new $e(2e3);for(let e of R)z.add(e);let ye=new $e(2e3),V=new AbortController,H=null;ve(e=>{V.signal.aborted||H?.reportMetadata(e)},{replayCurrent:!0});let U=0,W=I?ue:0,G=null,q=null,Ce=Ae(V.signal),J=Ce.wake,we=Ce.signal,Y=new rt,X=!ce,Z=0,Q=null;async function Te(){if(Q)return Q;Q=Ee();try{return await Q}finally{Q=null}}async function Ee(){if(Z++,B(`doReconnect: attempt=${Z}/3 envId=${F} sessionId=${L} workId=${G}`),U++,D(`[bridge:repl] Reconnecting after env lost (attempt ${Z}/3)`),Z>3)return D(`[bridge:repl] Environment reconnect limit reached (3), giving up`),!1;if(H){let e=H.getLastSequenceNum();e>W&&(W=e),H.close(),H=null}if(J(),Y.drop(),G){let e=G;if(await N.stopWork(F,e,!1).catch(()=>{}),G!==e)return D(`[bridge:repl] Poll loop recovered during stopWork await — deferring to it`),Z=0,!0;G=null,q=null}if(V.signal.aborted)return D(`[bridge:repl] Reconnect aborted by teardown`),!1;let e=F;P.reuseEnvironmentId=e;try{let e=await N.registerBridgeEnvironment(P);F=e.environment_id,ge=e.environment_secret}catch(e){return P.reuseEnvironmentId=void 0,D(`[bridge:repl] Environment re-registration failed: ${O(e)}`),!1}if(P.reuseEnvironmentId=void 0,D(`[bridge:repl] Re-registered: requested=${e} got=${F}`),V.signal.aborted)return D(`[bridge:repl] Reconnect aborted after env registration, cleaning up`),await N.deregisterEnvironment(F).catch(()=>{}),!1;if(H!==null)return D(`[bridge:repl] Poll loop recovered during registerBridgeEnvironment await — deferring to it`),Z=0,!0;if(await _e(e,L))return M(`tengu_bridge_repl_reconnected_in_place`,{}),Z=0,!0;if(F!==e&&M(`tengu_bridge_repl_env_expired_fresh_session`,{}),await h(L),V.signal.aborted)return D(`[bridge:repl] Reconnect aborted after archive, cleaning up`),await N.deregisterEnvironment(F).catch(()=>{}),!1;let t=ee(),r=await m({environmentId:F,title:t,gitRepoUrl:o,branch:a,signal:AbortSignal.timeout(15e3)});return r?V.signal.aborted?(D(`[bridge:repl] Reconnect aborted after session creation, cleaning up`),await h(r),!1):(L=r,l(xe(r)).catch(()=>{}),W=0,ye.clear(),X=!ce,D(`[bridge:repl] Re-created session: ${L}`),await A(n,{sessionId:L,environmentId:F,source:`repl`}),S?.clear(),Z=0,!0):(D(`[bridge:repl] Session creation failed during reconnection`),!1)}function De(){return p()}function Oe(){let e=Y.end();if(e.length===0)return;if(!H){D(`[bridge:repl] Cannot drain ${e.length} pending message(s): no transport`);return}for(let t of e)z.add(t.uuid);let t=_(e).map(e=>({...e,session_id:L}));D(`[bridge:repl] Drained ${e.length} pending message(s) after flush`),H.writeBatch(t)}let ke=null;function Me(){ke?.()}function Ie(e){if(B(`handleTransportPermanentClose: code=${e} transport=${H?`exists`:`null`} pollAborted=${V.signal.aborted}`),D(`[bridge:repl] Transport permanently closed: code=${e}`),M(`tengu_bridge_repl_ws_closed`,{code:e}),H){let e=H.getLastSequenceNum();e>W&&(W=e),H=null}J();let t=Y.drop();if(t>0&&D(`[bridge:repl] Dropping ${t} pending message(s) on transport close (code=${e})`,{level:`warn`}),e===1e3){E?.(`failed`,`session ended`),V.abort(),Me();return}E?.(`reconnecting`,`Remote Control connection lost (code ${e})`),D(`[bridge:repl] Transport reconnect budget exhausted (code=${e}), attempting env reconnect`),Te().then(t=>{t||V.signal.aborted||(D(`[bridge:repl] reconnectEnvironmentWithSession resolved false — tearing down`),M(`tengu_bridge_repl_reconnect_failed`,{close_code:e}),E?.(`failed`,`reconnection failed`),Me())})}let Re;process.env.USER_TYPE===`ant`&&process.platform!==`win32`&&(Re=()=>{D(`[bridge:repl] SIGUSR2 received — forcing doReconnect() for testing`),Te()},process.on(`SIGUSR2`,Re));let $=null;process.env.USER_TYPE===`ant`&&g({fireClose:e=>{if(!$){D(`[bridge:debug] fireClose: no transport wired yet`);return}D(`[bridge:debug] fireClose(${e}) — injecting`),$(e)},forceReconnect:()=>{D(`[bridge:debug] forceReconnect — injecting`),Te()},injectFault:u,wakePollLoop:J,describe:()=>`env=${F} session=${L} transport=${H?.getStateLabel()??`null`} workId=${G??`null`}`}),dt({api:N,getCredentials:()=>({environmentId:F,environmentSecret:ge}),signal:V.signal,getPollIntervalConfig:v,onStateChange:E,getWsState:()=>H?.getStateLabel()??`null`,isAtCapacity:()=>H!==null,capacitySignal:we,onFatalError:Me,getHeartbeatInfo:()=>!G||!q?null:{environmentId:F,workId:G,sessionToken:q},onHeartbeatFatal:e=>{if(D(`[bridge:repl] heartbeatWork fatal (status=${e.status}) — tearing down work item for fast re-dispatch`),H){let e=H.getLastSequenceNum();e>W&&(W=e),H.close(),H=null}Y.drop(),G&&N.stopWork(F,G,!1).catch(e=>{D(`[bridge:repl] stopWork after heartbeat fatal: ${O(e)}`)}),G=null,q=null,J(),E?.(`reconnecting`,`Work item lease expired, fetching fresh token`)},async onEnvironmentLost(){return await Te()?{environmentId:F,environmentSecret:ge}:null},onWorkReceived:(e,r,i,a)=>{if(H?.isConnectedStatus()&&D(`[bridge:repl] Work received while transport connected, replacing with fresh token (workId=${i})`),D(`[bridge:repl] Work received: workId=${i} workSessionId=${e} currentSessionId=${L} match=${Pe(e,L)}`),A(n,{sessionId:L,environmentId:F,source:`repl`}),!Pe(e,L)){D(`[bridge:repl] Rejecting foreign session: expected=${L} got=${e}`);return}G=i,q=r;let o=a||t(process.env.CLAUDE_BRIDGE_USE_CCR_V2),s;if(!o){if(s=De(),!s){D(`[bridge:repl] No OAuth token available for session ingress, skipping work`);return}be(s)}if(M(`tengu_bridge_repl_work_received`,{}),H){let e=H;H=null;let t=e.getLastSequenceNum();t>W&&(W=t),e.close()}Y.deactivate();let l=e=>Ye(e,{transport:H,sessionId:L,onInterrupt:ie,onSetModel:T,onSetMaxThinkingTokens:ae,onSetPermissionMode:oe}),u=!1,f=e=>{H=e,e.setOnConnect(()=>{if(H===e){if(D(`[bridge:repl] Ingress transport connected`),M(`tengu_bridge_repl_ws_connected`,{}),!o){let e=De();e&&be(e)}if(He=!1,!u&&x&&x.length>0){u=!0;let t=b,n=x.filter(e=>Je(e)&&!S?.has(e.uuid)),r=t>0&&n.length>t?n.slice(-t):n;r.length<n.length&&(D(`[bridge:repl] Capped initial flush: ${n.length} -> ${r.length} (cap=${t})`),M(`tengu_bridge_repl_history_capped`,{eligible_count:n.length,capped_count:r.length}));let i=_(r);if(i.length>0){D(`[bridge:repl] Flushing ${i.length} initial message(s) via transport`);let t=i.map(e=>({...e,session_id:L})),n=e.droppedBatchCount;e.writeBatch(t).then(()=>{if(e.droppedBatchCount>n){D(`[bridge:repl] Initial flush dropped ${e.droppedBatchCount-n} batch(es) — not marking ${i.length} UUID(s) as flushed`);return}if(S)for(let e of i)e.uuid&&S.add(e.uuid)}).catch(e=>D(`[bridge:repl] Initial flush failed: ${e}`)).finally(()=>{H===e&&(Oe(),E?.(`connected`))})}else Oe(),E?.(`connected`)}else Y.active||E?.(`connected`)}}),e.setOnData(e=>{try{let t=JSON.parse(e);B(`ingress: type=${t.type}${t.type===`control_request`?` subtype=${t.request?.subtype} request_id=${t.request_id}`:``}${t.type===`control_response`?` subtype=${t.response?.subtype} request_id=${t.response?.request_id}`:``}${t.type===`user`?` uuid=${t.uuid}`:``}${t.type===`keep_alive`?``:` len=${e.length}`}`)}catch{B(`ingress (non-JSON): ${String(e).slice(0,200)}`)}Qe(e,z,ye,ne,re,l)}),$=Ie,e.setOnClose(t=>{H===e&&(B(`transport onClose: code=${t} connected=${e.isConnectedStatus()} state=${e.getStateLabel()} seq=${e.getLastSequenceNum()}`),Ie(t))}),!u&&x&&x.length>0&&Y.start(),e.connect()};if(U++,o){let t=Le(c,e),n=U;D(`[bridge:repl] CCR v2: sessionUrl=${t} session=${e} gen=${n}`),nt({sessionUrl:t,ingressToken:r,sessionId:e,initialSequenceNum:W}).then(e=>{if(V.signal.aborted){e.close();return}if(n!==U){D(`[bridge:repl] CCR v2: discarding stale handshake gen=${n} current=${U}`),e.close();return}f(e)},e=>{D(`[bridge:repl] CCR v2: createV2ReplTransport failed: ${O(e)}`,{level:`error`}),M(`tengu_bridge_repl_ccr_v2_init_failed`,{}),n===U&&(G&&(N.stopWork(F,G,!1).catch(e=>{D(`[bridge:repl] stopWork after v2 init failure: ${O(e)}`)}),G=null,q=null),J())})}else{let t=Fe(d,e);D(`[bridge:repl] Ingress URL: ${t}`),D(`[bridge:repl] Creating HybridTransport: session=${e}`);let n=s??``;f(tt(new et(new URL(t),{Authorization:`Bearer ${n}`,"anthropic-version":`2023-06-01`},e,()=>({Authorization:`Bearer ${De()??n}`,"anthropic-version":`2023-06-01`}),{maxConsecutiveFailures:50,isBridge:!0,onBatchDropped:()=>{E?.(`reconnecting`,`Lost sync with Remote Control — events could not be delivered`),J()}})))}}});let ze=le?setInterval(()=>{Q||A(n,{sessionId:L,environmentId:F,source:`repl`})},60*6e4):null;ze?.unref?.();let Be=v().session_keepalive_interval_v2_ms,Ve=Be>0?setInterval(()=>{H&&(D(`[bridge:repl] keep_alive sent`),H.write({type:`keep_alive`}).catch(e=>{D(`[bridge:repl] keep_alive write failed: ${O(e)}`)}))},Be):null;Ve?.unref?.();let He=!1;ke=async()=>{if(He){D(`[bridge:repl] Teardown already in progress, skipping duplicate call env=${F} session=${L}`);return}He=!0;let e=Date.now();if(D(`[bridge:repl] Teardown starting: env=${F} session=${L} workId=${G??`none`} transportState=${H?.getStateLabel()??`null`}`),ze!==null&&clearInterval(ze),Ve!==null&&clearInterval(Ve),Re&&process.off(`SIGUSR2`,Re),process.env.USER_TYPE===`ant`&&(y(),$=null),V.abort(),D(`[bridge:repl] Teardown: poll loop aborted`),H){let e=H.getLastSequenceNum();e>W&&(W=e)}if(le){H=null,Y.drop(),await A(n,{sessionId:L,environmentId:F,source:`repl`}),D(`[bridge:repl] Teardown (perpetual): leaving env=${F} session=${L} alive on server, duration=${Date.now()-e}ms`);return}let t=H;if(H=null,Y.drop(),t){let e={...Ze(L),session_id:L};t.write(e)}let r=G?N.stopWork(F,G,!0).then(()=>{D(`[bridge:repl] Teardown: stopWork completed`)}).catch(e=>{D(`[bridge:repl] Teardown stopWork failed: ${O(e)}`)}):Promise.resolve();await Promise.all([r,h(L)]),t?.close(),D(`[bridge:repl] Teardown: transport closed`),await N.deregisterEnvironment(F).catch(e=>{D(`[bridge:repl] Teardown deregister failed: ${O(e)}`)}),await fe(n),D(`[bridge:repl] Teardown complete: env=${F} duration=${Date.now()-e}ms`)};let Ue=se(()=>ke?.());return D(`[bridge:repl] Ready: env=${F} session=${L}`),E?.(`ready`),{get bridgeSessionId(){return L},get environmentId(){return F},getSSESequenceNum(){let e=H?.getLastSequenceNum()??0;return Math.max(W,e)},sessionIngressUrl:d,writeMessages(e){let t=e.filter(e=>Je(e)&&!R.has(e.uuid)&&!z.has(e.uuid));if(t.length===0)return;if(!X)for(let e of t){let t=Xe(e);if(t!==void 0&&ce?.(t,L)){X=!0;break}}if(Y.enqueue(...t)){D(`[bridge:repl] Queued ${t.length} message(s) during initial flush`);return}if(!H){let e=t.map(e=>e.type).join(`,`);D(`[bridge:repl] Transport not configured, dropping ${t.length} message(s) [${e}] for session=${L}`,{level:`warn`});return}for(let e of t)z.add(e.uuid);D(`[bridge:repl] Sending ${t.length} message(s) via transport`);let n=_(t).map(e=>({...e,session_id:L}));H.writeBatch(n)},writeSdkMessages(e){let t=e.filter(e=>!e.uuid||!z.has(e.uuid));if(t.length===0)return;if(!H){D(`[bridge:repl] Transport not configured, dropping ${t.length} SDK message(s) for session=${L}`,{level:`warn`});return}for(let e of t)e.uuid&&z.add(e.uuid);let n=t.map(e=>({...e,session_id:L}));H.writeBatch(n)},sendControlRequest(e){if(!H){D(`[bridge:repl] Transport not configured, skipping control_request`);return}let t={...e,session_id:L};H.write(t),D(`[bridge:repl] Sent control_request request_id=${e.request_id}`)},sendControlResponse(e){if(!H){D(`[bridge:repl] Transport not configured, skipping control_response`);return}let t={...e,session_id:L};H.write(t),D(`[bridge:repl] Sent control_response`)},sendControlCancelRequest(e){if(!H){D(`[bridge:repl] Transport not configured, skipping control_cancel_request`);return}let t={type:`control_cancel_request`,request_id:e,session_id:L};H.write(t),D(`[bridge:repl] Sent control_cancel_request request_id=${e}`)},sendResult(){if(!H){D(`[bridge:repl] sendResult: skipping, transport not configured session=${L}`);return}H.reportState(`idle`);let e={...Ze(L),session_id:L};H.write(e),D(`[bridge:repl] Sent result for session=${L}`)},async teardown(){Ue(),await ke?.(),D(`[bridge:repl] Torn down`),M(`tengu_bridge_repl_teardown`,{})}}}async function dt({api:e,getCredentials:t,signal:n,onStateChange:r,onWorkReceived:i,onEnvironmentLost:a,getWsState:o,isAtCapacity:c,capacitySignal:l,onFatalError:u,getPollIntervalConfig:d=()=>je,getHeartbeatInfo:p,onHeartbeatFatal:m}){D(`[bridge:repl] Starting work poll loop for env=${t().environmentId}`);let h=0,g=null,_=null,v=0,y=!1;for(;!n.aborted;){let{environmentId:b,environmentSecret:x}=t(),S=d();try{let t=await e.pollForWork(b,x,n,S.reclaim_older_than_ms);if(v=0,h>0&&(D(`[bridge:repl] Poll recovered after ${h} consecutive error(s)`),h=0,g=null,_=null,r?.(`ready`)),!t){let t=y;if(y=!1,c?.()&&l&&!t){let t=S.poll_interval_ms_at_capacity;if(S.non_exclusive_heartbeat_interval_ms>0&&p){M(`tengu_bridge_heartbeat_mode_entered`,{heartbeat_interval_ms:S.non_exclusive_heartbeat_interval_ms});let r=t>0?Date.now()+t:null,i=!1,a=0;for(;!n.aborted&&c()&&(r===null||Date.now()<r);){let t=d();if(t.non_exclusive_heartbeat_interval_ms<=0)break;let n=p();if(!n)break;let r=l();try{await e.heartbeatWork(n.environmentId,n.workId,n.sessionToken)}catch(e){if(D(`[bridge:repl:heartbeat] Failed: ${O(e)}`),e instanceof s){r.cleanup(),M(`tengu_bridge_heartbeat_error`,{status:e.status,error_type:e.status===401||e.status===403?`auth_failed`:`fatal`}),m?(m(e),D(`[bridge:repl:heartbeat] Fatal (status=${e.status}), work state cleared — fast-polling for re-dispatch`)):i=!0;break}}a++,await R(t.non_exclusive_heartbeat_interval_ms,r.signal),r.cleanup()}let o=i?`error`:n.aborted?`shutdown`:c()?r!==null&&Date.now()>=r?`poll_due`:`config_disabled`:`capacity_changed`;if(M(`tengu_bridge_heartbeat_mode_exited`,{reason:o,heartbeat_cycles:a}),!i){o===`poll_due`&&D(`[bridge:repl] Heartbeat poll_due after ${a} cycles — falling through to pollForWork`);continue}}let r=t>0?t:S.non_exclusive_heartbeat_interval_ms;if(r>0){let e=l(),t=Date.now();await R(r,e.signal),e.cleanup();let n=Date.now()-t-r;n>6e4&&(D(`[bridge:repl] At-capacity sleep overran by ${Math.round(n/1e3)}s — process suspension detected, forcing one fast-poll cycle`),M(`tengu_bridge_repl_suspension_detected`,{overrun_ms:n}),y=!0)}}else await R(S.poll_interval_ms_not_at_capacity,n);continue}let a;try{a=Ie(t.secret)}catch(n){D(`[bridge:repl] Failed to decode work secret: ${O(n)}`),M(`tengu_bridge_repl_work_secret_failed`,{}),await e.stopWork(b,t.id,!1).catch(()=>{});continue}D(`[bridge:repl] Acknowledging workId=${t.id}`);try{await e.acknowledgeWork(b,t.id,a.session_ingress_token)}catch(e){D(`[bridge:repl] Acknowledge failed workId=${t.id}: ${O(e)}`)}if(t.data.type===`healthcheck`){D(`[bridge:repl] Healthcheck received`);continue}if(t.data.type===`session`){let e=t.data.id;try{f(e,`session_id`)}catch{D(`[bridge:repl] Invalid session_id in work: ${e}`);continue}i(e,a.session_ingress_token,t.id,a.use_code_sessions===!0),D(`[bridge:repl] Work accepted, continuing poll loop`)}}catch(i){if(n.aborted)break;if(i instanceof s&&i.status===404&&a){let e=t().environmentId;if(b!==e){D(`[bridge:repl] Stale poll error for old env=${b}, current env=${e} — skipping onEnvironmentLost`),h=0,g=null;continue}if(v++,D(`[bridge:repl] Environment deleted, attempting re-registration (attempt ${v}/3)`),M(`tengu_bridge_repl_env_lost`,{attempt:v}),v>3){D(`[bridge:repl] Environment re-registration limit reached (3), giving up`),r?.(`failed`,`Environment deleted and re-registration limit reached`),u?.();break}r?.(`reconnecting`,`environment lost, recreating session`);let i=await a();if(n.aborted)break;if(i){h=0,g=null,r?.(`ready`),D(`[bridge:repl] Re-registered environment: ${i.environmentId}`);continue}r?.(`failed`,`Environment deleted and re-registration failed`),u?.();break}if(i instanceof s){let e=ee(i.errorType),t=te(i);D(`[bridge:repl] Fatal poll error: ${i.message} (status=${i.status}, type=${i.errorType??`unknown`})${t?` (suppressed)`:``}`),M(`tengu_bridge_repl_fatal_error`,{status:i.status,error_type:i.errorType}),k(e?`info`:`error`,`bridge_repl_fatal_error`,{status:i.status,error_type:i.errorType}),t||r?.(`failed`,e?`session expired · /remote-control to reconnect`:i.message),u?.();break}let c=Date.now();_!==null&&c-_>6e4*2&&(D(`[bridge:repl] Detected system sleep (${Math.round((c-_)/1e3)}s gap), resetting poll error budget`),k(`info`,`bridge_repl_poll_sleep_detected`,{gapMs:c-_}),h=0,g=null),_=c,h++,g===null&&(g=c);let l=c-g,f=H(i),m=G(i),y=o?.()??`unknown`;if(D(`[bridge:repl] Poll error (attempt ${h}, elapsed ${Math.round(l/1e3)}s, ws=${y}): ${m}`),M(`tengu_bridge_repl_poll_error`,{status:f,consecutiveErrors:h,elapsedMs:l}),h===1&&r?.(`reconnecting`,m),l>=9e5){D(`[bridge:repl] Poll failures exceeded ${ct/1e3}s (${h} errors), giving up`),k(`info`,`bridge_repl_poll_give_up`),M(`tengu_bridge_repl_poll_give_up`,{consecutiveErrors:h,elapsedMs:l,lastStatus:f}),r?.(`failed`,`connection to server lost`);break}let x=Math.min(ot*2**(h-1),st);if(d().non_exclusive_heartbeat_interval_ms>0){let t=p?.();if(t)try{await e.heartbeatWork(t.environmentId,t.workId,t.sessionToken)}catch{}}await R(x,n)}}D(`[bridge:repl] Work poll loop ended (aborted=${n.aborted}) env=${t().environmentId}`)}oe(),ae(),W(),U();async function ft(t){let{onInboundMessage:n,onPermissionResponse:r,onInterrupt:i,onSetModel:s,onSetMaxThinkingTokens:l,onSetPermissionMode:u,onStateChange:d,initialMessages:f,getMessages:p,previouslyFlushedUUIDs:m,initialName:h,perpetual:ee,outboundOnly:g,tags:te}=t??{};if(q(Q),!await Z())return K(`not_enabled`,`[bridge:repl] Skipping: bridge not enabled`),null;if(!X())return K(`no_oauth`,`[bridge:repl] Skipping: no OAuth tokens`),d?.(`failed`,`/login`),null;if(await ne(),!b(`allow_remote_control`))return K(`policy_denied`,`[bridge:repl] Skipping: allow_remote_control policy not allowed`),d?.(`failed`,`disabled by your organization's policy`),null;if(!J()){let e=le();if(e.bridgeOauthDeadExpiresAt!=null&&(e.bridgeOauthDeadFailCount??0)>=3&&I()?.expiresAt===e.bridgeOauthDeadExpiresAt)return D(`[bridge:repl] Skipping: cross-process backoff (dead token seen ${e.bridgeOauthDeadFailCount} times)`),null;await _e();let t=I();if(t&&t.expiresAt!==null&&t.expiresAt<=Date.now()){K(`oauth_expired_unrefreshable`,`[bridge:repl] Skipping: OAuth token expired and refresh failed (re-login required)`),d?.(`failed`,`/login`);let e=t.expiresAt;return ce(t=>({...t,bridgeOauthDeadExpiresAt:e,bridgeOauthDeadFailCount:t.bridgeOauthDeadExpiresAt===e?(t.bridgeOauthDeadFailCount??0)+1:1})),null}}let y=we(),S=`remote-control-${v()}`,C=!1,re=!1;if(h)S=h,C=!0,re=!0;else{let e=a(),t=e?ie(e):void 0;if(t)S=t,C=!0,re=!0;else if(f&&f.length>0)for(let e=f.length-1;e>=0;e--){let t=f[e];if(t.type!==`user`||t.isMeta||t.toolUseResult||t.isCompactSummary||t.origin&&t.origin.kind!==`human`||x(t))continue;let n=_(t.message.content);if(!n)continue;let r=mt(n);if(r){S=r,C=!0;break}}}let w=0,T,ae=0,oe=(e,t,n)=>{C=!0,S=e,D(`[bridge:repl] derived title from message ${n}: ${e}`),Re(t,e,{baseUrl:y,getAccessToken:X}).catch(()=>{})},E=(e,t)=>{let n=++ae,r=w;Ge(e,AbortSignal.timeout(15e3)).then(e=>{e&&n===ae&&T===t&&!ie(a())&&oe(e,t,r)})},se=(e,t)=>{if(re||ie(a()))return!0;if(T!==void 0&&T!==t&&(w=0),T=t,w++,w===1&&!C){let n=mt(e);n&&oe(n,t,w),E(e,t)}else if(w===3){let n=p?.(),r=n?qe(c(n)):e;E(r,t)}return w>=3},ue=Y()?`self-hosted`:await N();if(!ue)return K(`no_org_uuid`,`[bridge:repl] Skipping: no org UUID`),d?.(`failed`,`/login`),null;if(Ee()&&!ee){let e=await He();if(e)return K(`version_too_old`,`[bridge:repl] Skipping: ${e}`,!0),d?.(`failed`,"run `claude update` to upgrade"),null;D(`[bridge:repl] Using env-less bridge path (tengu_bridge_repl_v2)`);let{initEnvLessBridgeCore:t}=await import(`./remoteBridgeCore-D-wG5jau.js`);return t({baseUrl:y,orgUUID:ue,title:S,getAccessToken:X,onAuth401:P,toSDKMessages:We,initialHistoryCap:200,initialMessages:f,onInboundMessage:n,onUserMessage:se,onPermissionResponse:r,onInterrupt:i,onSetModel:s,onSetMaxThinkingTokens:l,onSetPermissionMode:u,onStateChange:d,outboundOnly:g,tags:te})}let k=De();if(k)return K(`version_too_old`,`[bridge:repl] Skipping: ${k}`),d?.(`failed`,"run `claude update` to upgrade"),null;let de=await A(),fe=await pe(),me=process.env.CLAUDE_BRIDGE_SESSION_INGRESS_URL||y,j=`claude_code`;{let{isAssistantMode:t}=(Oe(),e(ke));t()&&(j=`claude_code_assistant`)}return ut({dir:o(),machineName:it(),branch:de,gitRepoUrl:fe,title:S,baseUrl:y,sessionIngressUrl:me,workerType:j,getAccessToken:X,createSession:e=>ze({...e,events:[],baseUrl:y,getAccessToken:X}),archiveSession:e=>Be(e,{baseUrl:y,getAccessToken:X,timeoutMs:1500}).catch(e=>{D(`[bridge:repl] archiveBridgeSession threw: ${O(e)}`,{level:`error`})}),getCurrentTitle:()=>ie(a())??S,onUserMessage:se,toSDKMessages:We,onAuth401:P,getPollIntervalConfig:Me,initialHistoryCap:200,initialMessages:f,previouslyFlushedUUIDs:m,onInboundMessage:n,onPermissionResponse:r,onInterrupt:i,onSetModel:s,onSetMaxThinkingTokens:l,onSetPermissionMode:u,onStateChange:d,perpetual:ee})}var pt=50;function mt(e){let t=me(e),n=(/^(.*?[.!?])\s/.exec(t)?.[1]??t).replace(/\s+/g,` `).trim();if(n)return n.length>pt?n.slice(0,pt-1)+`…`:n}export{ft as initReplBridge};
@@ -0,0 +1 @@
1
+ import{o as e}from"./rolldown-runtime-DaDcL9Zw.js";import{I as t,P as n,fi as r,kn as i,s as a,t as o}from"./src-CDCSSo0U2.js";import{t as s}from"./jsx-runtime-Bb4Xn-E0.js";import{U as c,l,p as u,z as d}from"./debug-IKW-jE7K.js";import{Jt as f,Zt as p,g as m,n as h,y as g}from"./settings-5PQdphqC.js";import{n as _,r as v}from"./analytics-BotDBGh0.js";import{a as y,n as b,r as x,s as S,t as C}from"./nativeInstaller-GcIk7G2Y.js";import{join as w}from"node:path";import{homedir as T}from"node:os";var E=e(r(),1);_(),o(),l(),p(),c(),C(),m();var D=s();function O(){let e=f.platform===`win32`,t=T();return e?w(t,`.local`,`bin`,`claude.exe`).replace(/\//g,`\\`):`~/.local/bin/claude`}function k({messages:e}){return e.length===0?null:(0,D.jsxs)(t,{flexDirection:`column`,gap:0,marginBottom:1,children:[(0,D.jsx)(t,{children:(0,D.jsxs)(n,{color:`warning`,children:[(0,D.jsx)(a,{status:`warning`,withSpace:!0}),`Setup notes:`]})}),e.map((e,r)=>(0,D.jsx)(t,{marginLeft:2,children:(0,D.jsxs)(n,{dimColor:!0,children:[`• `,e]})},r))]})}function A({onDone:e,force:r,target:i}){let[o,s]=(0,E.useState)({type:`checking`});return(0,E.useEffect)(()=>{async function e(){try{u(`Install: Starting installation process (force=${r}, target=${i})`);let e=i||h()?.autoUpdatesChannel||`latest`;s({type:`installing`,version:e}),u(`Install: Calling installLatest(channelOrVersion=${e}, forceReinstall=${r})`);let t=await S(e,r);if(u(`Install: installLatest returned version=${t.latestVersion}, wasUpdated=${t.wasUpdated}, lockFailed=${t.lockFailed}`),t.lockFailed)throw Error(`Could not install - another process is currently installing Claude. Please try again in a moment.`);t.latestVersion||u(`Install: Failed to retrieve version information during install`,{level:`error`}),t.wasUpdated||u(`Install: Already up to date`),s({type:`setting-up`});let n=await b(!0);u(`Install: Setup launcher completed with ${n.length} messages`),n.length>0&&n.forEach(e=>u(`Install: Setup message: ${e.message}`)),u(`Install: Cleaning up npm installations after successful install`);let{removed:a,errors:o,warnings:c}=await x();a>0&&u(`Cleaned up ${a} npm installation(s)`),o.length>0&&u(`Cleanup errors: ${o.join(`, `)}`);let l=await y();l.length>0&&u(`Shell alias cleanup: ${l.map(e=>e.message).join(`; `)}`),v(`tengu_claude_install_command`,{has_version:+!!t.latestVersion,forced:+!!r}),(i===`latest`||i===`stable`)&&(g(`userSettings`,{autoUpdatesChannel:i}),u(`Install: Saved autoUpdatesChannel=${i} to user settings`));let d=[...c,...l.map(e=>e.message)];n.length>0?(s({type:`set-up`,messages:n.map(e=>e.message)}),setTimeout(s,2e3,{type:`success`,version:t.latestVersion||`current`,setupMessages:[...n.map(e=>e.message),...d]})):(u(`Install: Shell PATH already configured`),s({type:`success`,version:t.latestVersion||`current`,setupMessages:d.length>0?d:void 0}))}catch(e){u(`Install command failed: ${e}`,{level:`error`}),s({type:`error`,message:d(e)})}}e()},[r,i]),(0,E.useEffect)(()=>{o.type===`success`?setTimeout(e,2e3,`Claude Code installation completed successfully`,{display:`system`}):o.type===`error`&&setTimeout(e,3e3,`Claude Code installation failed`,{display:`system`})},[o,e]),(0,D.jsxs)(t,{flexDirection:`column`,marginTop:1,children:[o.type===`checking`&&(0,D.jsx)(n,{color:`claude`,children:`Checking installation status...`}),o.type===`cleaning-npm`&&(0,D.jsx)(n,{color:`warning`,children:`Cleaning up old npm installations...`}),o.type===`installing`&&(0,D.jsxs)(n,{color:`claude`,children:[`Installing Claude Code native build `,o.version,`...`]}),o.type===`setting-up`&&(0,D.jsx)(n,{color:`claude`,children:`Setting up launcher and shell integration...`}),o.type===`set-up`&&(0,D.jsx)(k,{messages:o.messages}),o.type===`success`&&(0,D.jsxs)(t,{flexDirection:`column`,gap:1,children:[(0,D.jsxs)(t,{children:[(0,D.jsx)(a,{status:`success`,withSpace:!0}),(0,D.jsx)(n,{color:`success`,bold:!0,children:`Claude Code successfully installed!`})]}),(0,D.jsxs)(t,{marginLeft:2,flexDirection:`column`,gap:1,children:[o.version!==`current`&&(0,D.jsxs)(t,{children:[(0,D.jsx)(n,{dimColor:!0,children:`Version: `}),(0,D.jsx)(n,{color:`claude`,children:o.version})]}),(0,D.jsxs)(t,{children:[(0,D.jsx)(n,{dimColor:!0,children:`Location: `}),(0,D.jsx)(n,{color:`text`,children:O()})]})]}),(0,D.jsx)(t,{marginLeft:2,flexDirection:`column`,gap:1,children:(0,D.jsxs)(t,{marginTop:1,children:[(0,D.jsx)(n,{dimColor:!0,children:`Next: Run `}),(0,D.jsx)(n,{color:`claude`,bold:!0,children:`claude --help`}),(0,D.jsx)(n,{dimColor:!0,children:` to get started`})]})}),o.setupMessages&&(0,D.jsx)(k,{messages:o.setupMessages})]}),o.type===`error`&&(0,D.jsxs)(t,{flexDirection:`column`,gap:1,children:[(0,D.jsxs)(t,{children:[(0,D.jsx)(a,{status:`error`,withSpace:!0}),(0,D.jsx)(n,{color:`error`,children:`Installation failed`})]}),(0,D.jsx)(n,{color:`error`,children:o.message}),(0,D.jsx)(t,{marginTop:1,children:(0,D.jsx)(n,{dimColor:!0,children:`Try running with --force to override checks`})})]})]})}var j={type:`local-jsx`,name:`install`,description:`Install Claude Code native build`,argumentHint:`[options]`,async call(e,t,n){let r=n.includes(`--force`),a=n.filter(e=>!e.startsWith(`--`))[0],{unmount:o}=await i((0,D.jsx)(A,{onDone:(t,n)=>{o(),e(t,n)},force:r,target:a}))}};export{j as install};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{createHash as t}from"node:crypto";function n(){return i?{minConfidence:i.minConfidence??r.minConfidence,minClusterSize:i.minClusterSize??r.minClusterSize,llm:{...r.llm,...i.llm}}:r}var r,i,a=e((()=>{r={minConfidence:.75,minClusterSize:3,llm:{timeoutMs:1e4,maxCallsPerSession:20,cooldownMs:3e4,failureThreshold:3,circuitCooldownMs:6e4}}}));function o(e,t=new Date().toISOString()){return s({id:e.id??u(e.trigger,e.action,e.scope),...e,createdAt:t,updatedAt:t,status:e.status??`pending`})}function s(e){let t=Array.from(new Set(e.evidence.filter(Boolean)));return{...e,id:e.id||u(e.trigger,e.action),confidence:p(e.confidence),evidence:t.slice(-10),evidenceOutcome:e.evidenceOutcome,observationIds:e.observationIds?Array.from(new Set(e.observationIds)).slice(-20):void 0}}function c(e){return`${JSON.stringify(s(e),null,2)}\n`}function l(e){return s(JSON.parse(e))}function u(e,n,r=`project`){let i=`${e} ${n}`.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-|-$/g,``).slice(0,48),a=t(`sha1`).update(`${r}\n${e}\n${n}`).digest(`hex`).slice(0,10);return`${i||`instinct`}-${a}`}function d(e,t){return{scope:t?.scope??`project`,projectId:t?.projectId??e.projectId,projectName:t?.projectName??e.projectName,source:`session-observation`,evidence:[e.messageText??e.toolOutput??e.toolInput??e.toolName??e.id],observationIds:[e.id]}}function f(e,t){if(e.trigger.toLowerCase()!==t.trigger.toLowerCase())return!1;let n=e.action.toLowerCase(),r=t.action.toLowerCase();return n.includes(`avoid`)!==r.includes(`avoid`)||n.includes(`prefer`)!==r.includes(`prefer`)}function p(e){return Number.isNaN(e)?0:Math.max(0,Math.min(1,Number(e.toFixed(2))))}var m=e((()=>{}));export{f as a,c,m as i,n as l,p as n,s as o,o as r,l as s,d as t,a as u};
@@ -0,0 +1,21 @@
1
+ import{o as e}from"./rolldown-runtime-DaDcL9Zw.js";import{l as t,o as n}from"./envUtils-DSxRz_kt.js";import{n as r,t as i}from"./defineProperty-C-QyHrDq.js";import{E as a,M as o,S as s,b as c,d as l,h as u,i as d,l as f,n as p,p as ee,s as m,v as te,w as h,y as ne}from"./esm-lWlUmoUA.js";import{C as g,S as re,T as ie,b as _,j as ae,w as oe,x as se,y as ce}from"./esm-Cb-L4oAk.js";import{n as v,t as le}from"./esm-Bx6rTxIs.js";import{n as ue,t as de}from"./axios-DaWTGg7G.js";import{Cn as fe,Kn as pe,Lt as y,Q as me,Vn as he,Y as ge,en as _e,mr as ve,z as ye}from"./state-4KQ3kaqz.js";import{E as be,J as xe,O as Se,U as Ce,l as b,ot as we,p as x,s as Te,st as Ee,z as De}from"./debug-IKW-jE7K.js";import{f as Oe,g as ke}from"./settings-5PQdphqC.js";import{b as Ae,c as je,g as Me,n as Ne}from"./config-C7YHKCPV.js";import{d as Pe,f as Fe,o as Ie,s as S}from"./log-B3eB4EFv.js";import{r as Le,t as Re}from"./memoize-BO31Ws9Q.js";import{a as ze,i as Be,o as Ve}from"./platform-EtecGacO.js";import{i as He,n as Ue}from"./startupProfiler-DxRQteII.js";import{Bt as We,Ht as Ge,It as Ke,Kt as qe,Nt as Je,Vt as Ye,ar as Xe,er as Ze,ir as Qe,lr as $e,ur as et}from"./model-DfFA3qMO.js";import{_ as tt,b as nt,h as rt,l as it,o as at,p as ot,u as st,v as ct,y as lt}from"./proxy-Cn2YwITp.js";import{_ as ut,b as dt,c as ft,l as pt,r as mt,v as ht,y as gt}from"./sessionTracing-BuLsL6qA.js";import{A as _t,B as C,C as vt,D as yt,E as bt,I as w,K as xt,L as T,M as St,N as Ct,O as wt,P as E,R as Tt,U as Et,W as D,_ as O,b as Dt,c as Ot,d as kt,h as At,i as jt,k,n as Mt,o as Nt,p as Pt,q as Ft,t as It,u as Lt,v as A,w as j,y as Rt}from"./esm-C8Zkk1Ux.js";var M;(function(e){e[e.DELTA=0]=`DELTA`,e[e.CUMULATIVE=1]=`CUMULATIVE`})(M||(M={}));var N;(function(e){e.COUNTER=`COUNTER`,e.GAUGE=`GAUGE`,e.HISTOGRAM=`HISTOGRAM`,e.UP_DOWN_COUNTER=`UP_DOWN_COUNTER`,e.OBSERVABLE_COUNTER=`OBSERVABLE_COUNTER`,e.OBSERVABLE_GAUGE=`OBSERVABLE_GAUGE`,e.OBSERVABLE_UP_DOWN_COUNTER=`OBSERVABLE_UP_DOWN_COUNTER`})(N||(N={}));var P;(function(e){e[e.HISTOGRAM=0]=`HISTOGRAM`,e[e.EXPONENTIAL_HISTOGRAM=1]=`EXPONENTIAL_HISTOGRAM`,e[e.GAUGE=2]=`GAUGE`,e[e.SUM=3]=`SUM`})(P||(P={}));function zt(e){let t=Object.keys(e);return t.length===0?``:(t=t.sort(),JSON.stringify(t.map(t=>[t,e[t]])))}function Bt(e){return`${e.name}:${e.version??``}:${e.schemaUrl??``}`}var Vt=class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}};function F(e,t){let n,r=new Promise(function(e,r){n=setTimeout(function(){r(new Vt(`Operation timed out.`))},t)});return Promise.race([e,r]).then(e=>(clearTimeout(n),e),e=>{throw clearTimeout(n),e})}function Ht(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function Ut(e,t){let n=0,r=e.length-1,i=e.length;for(;r>=n;){let a=n+Math.trunc((r-n)/2);e[a]<t?n=a+1:(i=a,r=a-1)}return i}function Wt(e,t){return e.toLowerCase()===t.toLowerCase()}var I;(function(e){e[e.DROP=0]=`DROP`,e[e.SUM=1]=`SUM`,e[e.LAST_VALUE=2]=`LAST_VALUE`,e[e.HISTOGRAM=3]=`HISTOGRAM`,e[e.EXPONENTIAL_HISTOGRAM=4]=`EXPONENTIAL_HISTOGRAM`})(I||(I={})),r();var Gt=class{constructor(){i(this,`kind`,I.DROP)}createAccumulation(){}merge(e,t){}diff(e,t){}toMetricData(e,t,n,r){}};r();function Kt(e){let t=e.map(()=>0);return t.push(0),{buckets:{boundaries:e,counts:t},sum:0,count:0,hasMinMax:!1,min:1/0,max:-1/0}}var qt=class{constructor(e,t,n=!0,r=Kt(t)){i(this,`startTime`,void 0),i(this,`_boundaries`,void 0),i(this,`_recordMinMax`,void 0),i(this,`_current`,void 0),this.startTime=e,this._boundaries=t,this._recordMinMax=n,this._current=r}record(e){if(Number.isNaN(e))return;this._current.count+=1,this._current.sum+=e,this._recordMinMax&&(this._current.min=Math.min(e,this._current.min),this._current.max=Math.max(e,this._current.max),this._current.hasMinMax=!0);let t=Ut(this._boundaries,e);this._current.buckets.counts[t]+=1}setStartTime(e){this.startTime=e}toPointValue(){return this._current}},Jt=class{constructor(e,t){i(this,`kind`,I.HISTOGRAM),i(this,`_boundaries`,void 0),i(this,`_recordMinMax`,void 0),this._boundaries=e,this._recordMinMax=t}createAccumulation(e){return new qt(e,this._boundaries,this._recordMinMax)}merge(e,t){let n=e.toPointValue(),r=t.toPointValue(),i=n.buckets.counts,a=r.buckets.counts,o=Array(i.length);for(let e=0;e<i.length;e++)o[e]=i[e]+a[e];let s=1/0,c=-1/0;return this._recordMinMax&&(n.hasMinMax&&r.hasMinMax?(s=Math.min(n.min,r.min),c=Math.max(n.max,r.max)):n.hasMinMax?(s=n.min,c=n.max):r.hasMinMax&&(s=r.min,c=r.max)),new qt(e.startTime,n.buckets.boundaries,this._recordMinMax,{buckets:{boundaries:n.buckets.boundaries,counts:o},count:n.count+r.count,sum:n.sum+r.sum,hasMinMax:this._recordMinMax&&(n.hasMinMax||r.hasMinMax),min:s,max:c})}diff(e,t){let n=e.toPointValue(),r=t.toPointValue(),i=n.buckets.counts,a=r.buckets.counts,o=Array(i.length);for(let e=0;e<i.length;e++)o[e]=a[e]-i[e];return new qt(t.startTime,n.buckets.boundaries,this._recordMinMax,{buckets:{boundaries:n.buckets.boundaries,counts:o},count:r.count-n.count,sum:r.sum-n.sum,hasMinMax:!1,min:1/0,max:-1/0})}toMetricData(e,t,n,r){return{descriptor:e,aggregationTemporality:t,dataPointType:P.HISTOGRAM,dataPoints:n.map(([t,n])=>{let i=n.toPointValue(),a=e.type===N.GAUGE||e.type===N.UP_DOWN_COUNTER||e.type===N.OBSERVABLE_GAUGE||e.type===N.OBSERVABLE_UP_DOWN_COUNTER;return{attributes:t,startTime:n.startTime,endTime:r,value:{min:i.hasMinMax?i.min:void 0,max:i.hasMinMax?i.max:void 0,sum:a?void 0:i.sum,buckets:i.buckets,count:i.count}}})}}};r();var Yt=class e{constructor(e=new Xt,t=0,n=0,r=0){i(this,`backing`,void 0),i(this,`indexBase`,void 0),i(this,`indexStart`,void 0),i(this,`indexEnd`,void 0),this.backing=e,this.indexBase=t,this.indexStart=n,this.indexEnd=r}get offset(){return this.indexStart}get length(){return this.backing.length===0||this.indexEnd===this.indexStart&&this.at(0)===0?0:this.indexEnd-this.indexStart+1}counts(){return Array.from({length:this.length},(e,t)=>this.at(t))}at(e){let t=this.indexBase-this.indexStart;return e<t&&(e+=this.backing.length),e-=t,this.backing.countAt(e)}incrementBucket(e,t){this.backing.increment(e,t)}decrementBucket(e,t){this.backing.decrement(e,t)}trim(){for(let e=0;e<this.length;e++)if(this.at(e)!==0){this.indexStart+=e;break}else if(e===this.length-1){this.indexStart=this.indexEnd=this.indexBase=0;return}for(let e=this.length-1;e>=0;e--)if(this.at(e)!==0){this.indexEnd-=this.length-e-1;break}this._rotate()}downscale(e){this._rotate();let t=1+this.indexEnd-this.indexStart,n=1<<e,r=0,i=0;for(let e=this.indexStart;e<=this.indexEnd;){let a=e%n;a<0&&(a+=n);for(let o=a;o<n&&r<t;o++)this._relocateBucket(i,r),r++,e++;i++}this.indexStart>>=e,this.indexEnd>>=e,this.indexBase=this.indexStart}clone(){return new e(this.backing.clone(),this.indexBase,this.indexStart,this.indexEnd)}_rotate(){let e=this.indexBase-this.indexStart;e!==0&&(e>0?(this.backing.reverse(0,this.backing.length),this.backing.reverse(0,e),this.backing.reverse(e,this.backing.length)):(this.backing.reverse(0,this.backing.length),this.backing.reverse(0,this.backing.length+e)),this.indexBase=this.indexStart)}_relocateBucket(e,t){e!==t&&this.incrementBucket(e,this.backing.emptyBucket(t))}},Xt=class e{constructor(e=[0]){i(this,`_counts`,void 0),this._counts=e}get length(){return this._counts.length}countAt(e){return this._counts[e]}growTo(e,t,n){let r=Array(e).fill(0);r.splice(n,this._counts.length-t,...this._counts.slice(t)),r.splice(0,t,...this._counts.slice(0,t)),this._counts=r}reverse(e,t){let n=Math.floor((e+t)/2)-e;for(let r=0;r<n;r++){let n=this._counts[e+r];this._counts[e+r]=this._counts[t-r-1],this._counts[t-r-1]=n}}emptyBucket(e){let t=this._counts[e];return this._counts[e]=0,t}increment(e,t){this._counts[e]+=t}decrement(e,t){this._counts[e]>=t?this._counts[e]-=t:this._counts[e]=0}clone(){return new e([...this._counts])}},Zt=2146435072,Qt=1048575,$t=1023,en=-1022,tn=$t,nn=2**-1022;function rn(e){let t=new DataView(new ArrayBuffer(8));return t.setFloat64(0,e),((t.getUint32(0)&Zt)>>20)-$t}function an(e){let t=new DataView(new ArrayBuffer(8));t.setFloat64(0,e);let n=t.getUint32(0),r=t.getUint32(4);return(n&Qt)*2**32+r}function on(e,t){return e===0||e===1/0||e===-1/0||Number.isNaN(e)?e:e*2**t}function sn(e){return e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e++,e}var L=class extends Error{};r();var cn=class{constructor(e){i(this,`_shift`,void 0),this._shift=-e}mapToIndex(e){return e<nn?this._minNormalLowerBoundaryIndex():rn(e)+this._rightShift(an(e)-1,52)>>this._shift}lowerBoundary(e){let t=this._minNormalLowerBoundaryIndex();if(e<t)throw new L(`underflow: ${e} is < minimum lower boundary: ${t}`);let n=this._maxNormalLowerBoundaryIndex();if(e>n)throw new L(`overflow: ${e} is > maximum lower boundary: ${n}`);return on(1,e<<this._shift)}get scale(){return this._shift===0?0:-this._shift}_minNormalLowerBoundaryIndex(){let e=en>>this._shift;return this._shift<2&&e--,e}_maxNormalLowerBoundaryIndex(){return tn>>this._shift}_rightShift(e,t){return Math.floor(e*2**-t)}};r();var ln=class{constructor(e){i(this,`_scale`,void 0),i(this,`_scaleFactor`,void 0),i(this,`_inverseFactor`,void 0),this._scale=e,this._scaleFactor=on(Math.LOG2E,e),this._inverseFactor=on(Math.LN2,-e)}mapToIndex(e){if(e<=nn)return this._minNormalLowerBoundaryIndex()-1;if(an(e)===0)return(rn(e)<<this._scale)-1;let t=Math.floor(Math.log(e)*this._scaleFactor),n=this._maxNormalLowerBoundaryIndex();return t>=n?n:t}lowerBoundary(e){let t=this._maxNormalLowerBoundaryIndex();if(e>=t){if(e===t)return 2*Math.exp((e-(1<<this._scale))/this._scaleFactor);throw new L(`overflow: ${e} is > maximum lower boundary: ${t}`)}let n=this._minNormalLowerBoundaryIndex();if(e<=n){if(e===n)return nn;if(e===n-1)return Math.exp((e+(1<<this._scale))/this._scaleFactor)/2;throw new L(`overflow: ${e} is < minimum lower boundary: ${n}`)}return Math.exp(e*this._inverseFactor)}get scale(){return this._scale}_minNormalLowerBoundaryIndex(){return en<<this._scale}_maxNormalLowerBoundaryIndex(){return(tn+1<<this._scale)-1}},un=-10,dn=20,fn=Array.from({length:31},(e,t)=>t>10?new ln(t-10):new cn(t-10));function pn(e){if(e>dn||e<un)throw new L(`expected scale >= ${un} && <= ${dn}, got: ${e}`);return fn[e+10]}p(),r();var R=class e{static combine(t,n){return new e(Math.min(t.low,n.low),Math.max(t.high,n.high))}constructor(e,t){i(this,`low`,void 0),i(this,`high`,void 0),this.low=e,this.high=t}},mn=20,hn=160,gn=2,_n=class e{constructor(e,t=hn,n=!0,r=0,a=0,o=0,s=1/0,c=-1/0,l=new Yt,u=new Yt,d=pn(mn)){i(this,`startTime`,void 0),i(this,`_maxSize`,void 0),i(this,`_recordMinMax`,void 0),i(this,`_sum`,void 0),i(this,`_count`,void 0),i(this,`_zeroCount`,void 0),i(this,`_min`,void 0),i(this,`_max`,void 0),i(this,`_positive`,void 0),i(this,`_negative`,void 0),i(this,`_mapping`,void 0),this.startTime=e,this._maxSize=t,this._recordMinMax=n,this._sum=r,this._count=a,this._zeroCount=o,this._min=s,this._max=c,this._positive=l,this._negative=u,this._mapping=d,this._maxSize<gn&&(m.warn(`Exponential Histogram Max Size set to ${this._maxSize}, \
2
+ changing to the minimum size of: ${gn}`),this._maxSize=gn)}record(e){this.updateByIncrement(e,1)}setStartTime(e){this.startTime=e}toPointValue(){return{hasMinMax:this._recordMinMax,min:this.min,max:this.max,sum:this.sum,positive:{offset:this.positive.offset,bucketCounts:this.positive.counts()},negative:{offset:this.negative.offset,bucketCounts:this.negative.counts()},count:this.count,scale:this.scale,zeroCount:this.zeroCount}}get sum(){return this._sum}get min(){return this._min}get max(){return this._max}get count(){return this._count}get zeroCount(){return this._zeroCount}get scale(){return this._count===this._zeroCount?0:this._mapping.scale}get positive(){return this._positive}get negative(){return this._negative}updateByIncrement(e,t){if(!Number.isNaN(e)){if(e>this._max&&(this._max=e),e<this._min&&(this._min=e),this._count+=t,e===0){this._zeroCount+=t;return}this._sum+=e*t,e>0?this._updateBuckets(this._positive,e,t):this._updateBuckets(this._negative,-e,t)}}merge(e){this._count===0?(this._min=e.min,this._max=e.max):e.count!==0&&(e.min<this.min&&(this._min=e.min),e.max>this.max&&(this._max=e.max)),this.startTime=e.startTime,this._sum+=e.sum,this._count+=e.count,this._zeroCount+=e.zeroCount;let t=this._minScale(e);this._downscale(this.scale-t),this._mergeBuckets(this.positive,e,e.positive,t),this._mergeBuckets(this.negative,e,e.negative,t)}diff(e){this._min=1/0,this._max=-1/0,this._sum-=e.sum,this._count-=e.count,this._zeroCount-=e.zeroCount;let t=this._minScale(e);this._downscale(this.scale-t),this._diffBuckets(this.positive,e,e.positive,t),this._diffBuckets(this.negative,e,e.negative,t)}clone(){return new e(this.startTime,this._maxSize,this._recordMinMax,this._sum,this._count,this._zeroCount,this._min,this._max,this.positive.clone(),this.negative.clone(),this._mapping)}_updateBuckets(e,t,n){let r=this._mapping.mapToIndex(t),i=!1,a=0,o=0;if(e.length===0?(e.indexStart=r,e.indexEnd=e.indexStart,e.indexBase=e.indexStart):r<e.indexStart&&e.indexEnd-r>=this._maxSize?(i=!0,o=r,a=e.indexEnd):r>e.indexEnd&&r-e.indexStart>=this._maxSize&&(i=!0,o=e.indexStart,a=r),i){let e=this._changeScale(a,o);this._downscale(e),r=this._mapping.mapToIndex(t)}this._incrementIndexBy(e,r,n)}_incrementIndexBy(e,t,n){if(n===0)return;if(e.length===0&&(e.indexStart=e.indexEnd=e.indexBase=t),t<e.indexStart){let n=e.indexEnd-t;n>=e.backing.length&&this._grow(e,n+1),e.indexStart=t}else if(t>e.indexEnd){let n=t-e.indexStart;n>=e.backing.length&&this._grow(e,n+1),e.indexEnd=t}let r=t-e.indexBase;r<0&&(r+=e.backing.length),e.incrementBucket(r,n)}_grow(e,t){let n=e.backing.length,r=e.indexBase-e.indexStart,i=n-r,a=sn(t);a>this._maxSize&&(a=this._maxSize);let o=a-r;e.backing.growTo(a,i,o)}_changeScale(e,t){let n=0;for(;e-t>=this._maxSize;)e>>=1,t>>=1,n++;return n}_downscale(e){if(e===0)return;if(e<0)throw Error(`impossible change of scale: ${this.scale}`);let t=this._mapping.scale-e;this._positive.downscale(e),this._negative.downscale(e),this._mapping=pn(t)}_minScale(e){let t=Math.min(this.scale,e.scale),n=R.combine(this._highLowAtScale(this.positive,this.scale,t),this._highLowAtScale(e.positive,e.scale,t)),r=R.combine(this._highLowAtScale(this.negative,this.scale,t),this._highLowAtScale(e.negative,e.scale,t));return Math.min(t-this._changeScale(n.high,n.low),t-this._changeScale(r.high,r.low))}_highLowAtScale(e,t,n){if(e.length===0)return new R(0,-1);let r=t-n;return new R(e.indexStart>>r,e.indexEnd>>r)}_mergeBuckets(e,t,n,r){let i=n.offset,a=t.scale-r;for(let t=0;t<n.length;t++)this._incrementIndexBy(e,i+t>>a,n.at(t))}_diffBuckets(e,t,n,r){let i=n.offset,a=t.scale-r;for(let t=0;t<n.length;t++){let r=(i+t>>a)-e.indexBase;r<0&&(r+=e.backing.length),e.decrementBucket(r,n.at(t))}e.trim()}},vn=class{constructor(e,t){i(this,`kind`,I.EXPONENTIAL_HISTOGRAM),i(this,`_maxSize`,void 0),i(this,`_recordMinMax`,void 0),this._maxSize=e,this._recordMinMax=t}createAccumulation(e){return new _n(e,this._maxSize,this._recordMinMax)}merge(e,t){let n=t.clone();return n.merge(e),n}diff(e,t){let n=t.clone();return n.diff(e),n}toMetricData(e,t,n,r){return{descriptor:e,aggregationTemporality:t,dataPointType:P.EXPONENTIAL_HISTOGRAM,dataPoints:n.map(([t,n])=>{let i=n.toPointValue(),a=e.type===N.GAUGE||e.type===N.UP_DOWN_COUNTER||e.type===N.OBSERVABLE_GAUGE||e.type===N.OBSERVABLE_UP_DOWN_COUNTER;return{attributes:t,startTime:n.startTime,endTime:r,value:{min:i.hasMinMax?i.min:void 0,max:i.hasMinMax?i.max:void 0,sum:a?void 0:i.sum,positive:{offset:i.positive.offset,bucketCounts:i.positive.bucketCounts},negative:{offset:i.negative.offset,bucketCounts:i.negative.bucketCounts},count:i.count,scale:i.scale,zeroCount:i.zeroCount}}})}}};A(),r();var yn=class{constructor(e,t=0,n=[0,0]){i(this,`startTime`,void 0),i(this,`_current`,void 0),i(this,`sampleTime`,void 0),this.startTime=e,this._current=t,this.sampleTime=n}record(e){this._current=e,this.sampleTime=E(Date.now())}setStartTime(e){this.startTime=e}toPointValue(){return this._current}},bn=class{constructor(){i(this,`kind`,I.LAST_VALUE)}createAccumulation(e){return new yn(e)}merge(e,t){let n=k(t.sampleTime)>=k(e.sampleTime)?t:e;return new yn(e.startTime,n.toPointValue(),n.sampleTime)}diff(e,t){let n=k(t.sampleTime)>=k(e.sampleTime)?t:e;return new yn(t.startTime,n.toPointValue(),n.sampleTime)}toMetricData(e,t,n,r){return{descriptor:e,aggregationTemporality:t,dataPointType:P.GAUGE,dataPoints:n.map(([e,t])=>({attributes:e,startTime:t.startTime,endTime:r,value:t.toPointValue()}))}}};r();var z=class{constructor(e,t,n=0,r=!1){i(this,`startTime`,void 0),i(this,`monotonic`,void 0),i(this,`_current`,void 0),i(this,`reset`,void 0),this.startTime=e,this.monotonic=t,this._current=n,this.reset=r}record(e){this.monotonic&&e<0||(this._current+=e)}setStartTime(e){this.startTime=e}toPointValue(){return this._current}},xn=class{constructor(e){i(this,`kind`,I.SUM),i(this,`monotonic`,void 0),this.monotonic=e}createAccumulation(e){return new z(e,this.monotonic)}merge(e,t){let n=e.toPointValue(),r=t.toPointValue();return t.reset?new z(t.startTime,this.monotonic,r,t.reset):new z(e.startTime,this.monotonic,n+r)}diff(e,t){let n=e.toPointValue(),r=t.toPointValue();return this.monotonic&&n>r?new z(t.startTime,this.monotonic,r,!0):new z(t.startTime,this.monotonic,r-n)}toMetricData(e,t,n,r){return{descriptor:e,aggregationTemporality:t,dataPointType:P.SUM,dataPoints:n.map(([e,t])=>({attributes:e,startTime:t.startTime,endTime:r,value:t.toPointValue()})),isMonotonic:this.monotonic}}};p(),r();var Sn=class e{createAggregator(t){return e.DEFAULT_INSTANCE}};i(Sn,`DEFAULT_INSTANCE`,new Gt);var Cn=class e{createAggregator(t){switch(t.type){case N.COUNTER:case N.OBSERVABLE_COUNTER:case N.HISTOGRAM:return e.MONOTONIC_INSTANCE;default:return e.NON_MONOTONIC_INSTANCE}}};i(Cn,`MONOTONIC_INSTANCE`,new xn(!0)),i(Cn,`NON_MONOTONIC_INSTANCE`,new xn(!1));var wn=class e{createAggregator(t){return e.DEFAULT_INSTANCE}};i(wn,`DEFAULT_INSTANCE`,new bn);var Tn=class e{createAggregator(t){return e.DEFAULT_INSTANCE}};i(Tn,`DEFAULT_INSTANCE`,new Jt([0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4],!0));var En=class{constructor(e,t=!0){if(i(this,`_boundaries`,void 0),i(this,`_recordMinMax`,void 0),e==null)throw Error(`ExplicitBucketHistogramAggregation should be created with explicit boundaries, if a single bucket histogram is required, please pass an empty array`);e=e.concat(),e=e.sort((e,t)=>e-t);let n=e.lastIndexOf(-1/0),r=e.indexOf(1/0);r===-1&&(r=void 0),this._boundaries=e.slice(n+1,r),this._recordMinMax=t}createAggregator(e){return new Jt(this._boundaries,this._recordMinMax)}},Dn=class{constructor(e=160,t=!0){i(this,`_maxSize`,void 0),i(this,`_recordMinMax`,void 0),this._maxSize=e,this._recordMinMax=t}createAggregator(e){return new vn(this._maxSize,this._recordMinMax)}},On=class{_resolve(e){switch(e.type){case N.COUNTER:case N.UP_DOWN_COUNTER:case N.OBSERVABLE_COUNTER:case N.OBSERVABLE_UP_DOWN_COUNTER:return An;case N.GAUGE:case N.OBSERVABLE_GAUGE:return jn;case N.HISTOGRAM:return e.advice.explicitBucketBoundaries?new En(e.advice.explicitBucketBoundaries):Mn}return m.warn(`Unable to recognize instrument type: ${e.type}`),kn}createAggregator(e){return this._resolve(e).createAggregator(e)}},kn=new Sn,An=new Cn,jn=new wn,Mn=new Tn;new Dn;var Nn=new On,B;(function(e){e[e.DEFAULT=0]=`DEFAULT`,e[e.DROP=1]=`DROP`,e[e.SUM=2]=`SUM`,e[e.LAST_VALUE=3]=`LAST_VALUE`,e[e.EXPLICIT_BUCKET_HISTOGRAM=4]=`EXPLICIT_BUCKET_HISTOGRAM`,e[e.EXPONENTIAL_HISTOGRAM=5]=`EXPONENTIAL_HISTOGRAM`})(B||(B={}));function Pn(e){switch(e.type){case B.DEFAULT:return Nn;case B.DROP:return kn;case B.SUM:return An;case B.LAST_VALUE:return jn;case B.EXPONENTIAL_HISTOGRAM:{let t=e;return new Dn(t.options?.maxSize,t.options?.recordMinMax)}case B.EXPLICIT_BUCKET_HISTOGRAM:{let t=e;return t.options==null?Mn:new En(t.options?.boundaries,t.options?.recordMinMax)}default:throw Error(`Unsupported Aggregation`)}}var Fn=e=>({type:B.DEFAULT}),In=e=>M.CUMULATIVE,Ln=`otel.component.name`,Rn=`otel.component.type`,zn=`periodic_metric_reader`,Bn=`otel.sdk.metric_reader.collection.duration`,Vn=`error.type`;r();var Hn=new Map,Un=class{constructor(e,t){i(this,`collectionDuration`,void 0),i(this,`standardAttrs`,void 0);let n=Hn.get(e)??0;Hn.set(e,n+1),this.standardAttrs={[Rn]:e,[Ln]:`${e}/${n}`},this.collectionDuration=t.createHistogram(Bn,{unit:`s`,description:`The duration of the collect operation of the metric reader.`,advice:{explicitBucketBoundaries:[]}})}recordCollection(e,t){let n=t?{...this.standardAttrs,[Vn]:t}:this.standardAttrs;this.collectionDuration.record(e,n)}},Wn=`2.9.0`;p(),A(),r();var Gn=class{constructor(e){i(this,`_shutdown`,!1),i(this,`_metricProducers`,void 0),i(this,`_sdkMetricProducer`,void 0),i(this,`_selfObsMetrics`,void 0),i(this,`_aggregationTemporalitySelector`,void 0),i(this,`_aggregationSelector`,void 0),i(this,`_cardinalitySelector`,void 0),i(this,`_otelComponentType`,void 0),this._aggregationSelector=e?.aggregationSelector??Fn,this._aggregationTemporalitySelector=e?.aggregationTemporalitySelector??In,this._metricProducers=e?.metricProducers??[],this._cardinalitySelector=e?.cardinalitySelector,this._otelComponentType=e?.otelComponentType??this.constructor.name,this._selfObsMetrics=new Un(this._otelComponentType,a())}setMetricProducer(e){if(this._sdkMetricProducer)throw Error(`MetricReader can not be bound to a MeterProvider again.`);this._sdkMetricProducer=e,this.onInitialized()}_setSelfObsMeterProvider(e){let t=e.getMeter(`@opentelemetry/sdk-metrics`,Wn);this._selfObsMetrics=new Un(this._otelComponentType,t)}selectAggregation(e){return this._aggregationSelector(e)}selectAggregationTemporality(e){return this._aggregationTemporalitySelector(e)}selectCardinalityLimit(e){return this._cardinalitySelector?this._cardinalitySelector(e):2e3}onInitialized(){}async collect(e){if(this._sdkMetricProducer===void 0)throw Error(`MetricReader is not bound to a MetricProducer`);if(this._shutdown)throw Error(`MetricReader is shutdown`);let t=yt(),[n,...r]=await Promise.all([this._sdkMetricProducer.collect({timeoutMillis:e?.timeoutMillis}),...this._metricProducers.map(t=>t.collect({timeoutMillis:e?.timeoutMillis}))]),i=yt(),a=n.errors.concat(r.flatMap(e=>e.errors)),o=_t(wt(t,i));return this._selfObsMetrics.recordCollection(o,a.length>0?a[0].name??`collect_error`:void 0),{resourceMetrics:{resource:n.resourceMetrics.resource,scopeMetrics:n.resourceMetrics.scopeMetrics.concat(r.flatMap(e=>e.resourceMetrics.scopeMetrics))},errors:a}}async shutdown(e){if(this._shutdown){m.error(`Cannot call shutdown twice.`);return}e?.timeoutMillis==null?await this.onShutdown():await F(this.onShutdown(),e.timeoutMillis),this._shutdown=!0}async forceFlush(e){if(this._shutdown){m.warn(`Cannot forceFlush on already shutdown MetricReader.`);return}if(e?.timeoutMillis==null){await this.onForceFlush();return}await F(this.onForceFlush(),e.timeoutMillis)}};function Kn(e,t){if(!Number.isInteger(t)||t<=0)throw Error(`maxExportBatchSize must be a positive integer`);let n=[],r=0,i=[];function a(){i.length>0&&(n.push({resource:e.resource,scopeMetrics:i}),i=[],r=0)}for(let n of e.scopeMetrics){let e=null;for(let o of n.metrics){let s=o.dataPoints;if(s.length===0){e||(e={scope:n.scope,metrics:[]},i.push(e)),e.metrics.push(o);continue}let c=0;for(;c<s.length;){let l=t-r,u=Math.min(l,s.length-c);e||(e={scope:n.scope,metrics:[]},i.push(e));let d={...o,dataPoints:s.slice(c,c+u)};e.metrics.push(d),c+=u,r+=u,r===t&&(a(),e=null)}}}return a(),n}p(),A(),r();var qn=class extends Gn{constructor(e){let{exporter:t,exportIntervalMillis:n=6e4,metricProducers:r,cardinalityLimits:a,maxExportBatchSize:o}=e,{exportTimeoutMillis:s=3e4}=e;if(super({aggregationSelector:t.selectAggregation?.bind(t),aggregationTemporalitySelector:t.selectAggregationTemporality?.bind(t),otelComponentType:zn,metricProducers:r,cardinalitySelector:e=>{let t={default:2e3,...a};switch(e){case N.COUNTER:return t.counter??t.default;case N.GAUGE:return t.gauge??t.default;case N.HISTOGRAM:return t.histogram??t.default;case N.OBSERVABLE_COUNTER:return t.observableCounter??t.default;case N.OBSERVABLE_UP_DOWN_COUNTER:return t.observableUpDownCounter??t.default;case N.OBSERVABLE_GAUGE:return t.observableGauge??t.default;case N.UP_DOWN_COUNTER:return t.upDownCounter??t.default;default:return t.default}}}),i(this,`_interval`,void 0),i(this,`_exporter`,void 0),i(this,`_exportInterval`,void 0),i(this,`_exportTimeout`,void 0),i(this,`_maxExportBatchSize`,void 0),i(this,`_ongoingExportPromise`,null),n<=0)throw Error(`exportIntervalMillis must be greater than 0`);if(s<=0)throw Error(`exportTimeoutMillis must be greater than 0`);if(o!==void 0&&(!Number.isInteger(o)||o<=0))throw Error(`maxExportBatchSize must be a positive integer`);if(n<s){if(`exportIntervalMillis`in e&&`exportTimeoutMillis`in e)throw Error(`exportIntervalMillis must be greater than or equal to exportTimeoutMillis`);m.info(`Timeout of ${s} exceeds the interval of ${n}. Clamping timeout to interval duration.`),s=n}this._exportInterval=n,this._exportTimeout=s,this._exporter=t,this._maxExportBatchSize=o}async _runOnce(){try{await this._doRun()}catch(e){C(e)}}async _doRun(){if(this._ongoingExportPromise){m.debug(`PeriodicExportingMetricReader: export already in progress, skipping`);return}let e=async()=>{let{resourceMetrics:e,errors:t}=await this.collect({timeoutMillis:this._exportTimeout});if(t.length>0&&m.error(`PeriodicExportingMetricReader: metrics collection errors`,...t),e.resource.asyncAttributesPending)try{await e.resource.waitForAsyncAttributes?.()}catch(e){m.debug(`Error while resolving async portion of resource: `,e),C(e)}if(e.scopeMetrics.length===0)return;let n=this._maxExportBatchSize?Kn(e,this._maxExportBatchSize):[e],r=null;for(let e of n)try{let t=await F(Rt._export(this._exporter,e),this._exportTimeout);t.code!==j.SUCCESS&&(r=Error(`PeriodicExportingMetricReader: metrics export failed (error ${t.error})`))}catch(e){if(e instanceof Vt){m.error(`PeriodicExportingMetricReader: metrics export timed out after ${this._exportTimeout}ms`);break}else m.error(`PeriodicExportingMetricReader: metrics export threw error`,e),r=e instanceof Error?e:Error(String(e))}if(r)throw r};this._ongoingExportPromise=e();try{await this._ongoingExportPromise}finally{this._ongoingExportPromise=null}}onInitialized(){this._interval=setInterval(()=>{this._runOnce()},this._exportInterval),typeof this._interval!=`number`&&this._interval.unref()}async onForceFlush(){await this._awaitOngoingExport(),this._ongoingExportPromise?await this._awaitOngoingExport():await this._runOnce(),await this._exporter.forceFlush()}async _awaitOngoingExport(){if(this._ongoingExportPromise){m.debug(`PeriodicExportingMetricReader: export already in progress, awaiting ongoing export`);try{await this._ongoingExportPromise}catch{}}}async onShutdown(){this._interval&&clearInterval(this._interval),await this.onForceFlush(),await this._exporter.shutdown()}};A(),r();var Jn=class e{constructor(e){i(this,`_shutdown`,!1),i(this,`_temporalitySelector`,void 0),this._temporalitySelector=e?.temporalitySelector??In}export(t,n){if(this._shutdown){n({code:j.FAILED});return}return e._sendMetrics(t,n)}forceFlush(){return Promise.resolve()}selectAggregationTemporality(e){return this._temporalitySelector(e)}shutdown(){return this._shutdown=!0,Promise.resolve()}static _sendMetrics(e,t){for(let t of e.scopeMetrics)for(let e of t.metrics)console.dir({descriptor:e.descriptor,dataPointType:e.dataPointType,dataPoints:e.dataPoints},{depth:null});t({code:j.SUCCESS})}};r();var Yn=class{constructor(){i(this,`_registeredViews`,[])}addView(e){this._registeredViews.push(e)}findViews(e,t){return this._registeredViews.filter(n=>this._matchInstrument(n.instrumentSelector,e)&&this._matchMeter(n.meterSelector,t))}_matchInstrument(e,t){return(e.getType()===void 0||t.type===e.getType())&&e.getNameFilter().match(t.name)&&e.getUnitFilter().match(t.unit)}_matchMeter(e,t){return e.getNameFilter().match(t.name)&&(t.version===void 0||e.getVersionFilter().match(t.version))&&(t.schemaUrl===void 0||e.getSchemaUrlFilter().match(t.schemaUrl))}};p();function V(e,t,n){return $n(e)||m.warn(`Invalid metric name: "${e}". The metric name should be a ASCII string with a length no greater than 255 characters.`),{name:e,type:t,description:n?.description??``,unit:n?.unit??``,valueType:n?.valueType??h.DOUBLE,advice:n?.advice??{}}}function Xn(e,t){return{name:e.name??t.name,description:e.description??t.description,type:t.type,unit:t.unit,valueType:t.valueType,advice:t.advice}}function Zn(e,t){return Wt(e.name,t.name)&&e.unit===t.unit&&e.type===t.type&&e.valueType===t.valueType}var Qn=/^[a-z][a-z0-9_.\-/]{0,254}$/i;function $n(e){return Qn.test(e)}p(),r();var H=class{constructor(e,t){i(this,`_writableMetricStorage`,void 0),i(this,`_descriptor`,void 0),this._writableMetricStorage=e,this._descriptor=t}_record(e,t={},n){if(typeof e!=`number`){m.warn(`non-number value provided to metric ${this._descriptor.name}: ${e}`);return}this._descriptor.valueType===h.INT&&!Number.isInteger(e)&&(m.warn(`INT value type cannot accept a floating-point value for ${this._descriptor.name}, ignoring the fractional digits.`),e=Math.trunc(e),!Number.isInteger(e))||this._writableMetricStorage.record(e,t,n,Date.now())}},er=class extends H{add(e,t,n){this._record(e,t,n)}},tr=class extends H{add(e,t,n){if(e<0){m.warn(`negative value provided to counter ${this._descriptor.name}: ${e}`);return}this._record(e,t,n)}},nr=class extends H{record(e,t,n){this._record(e,t,n)}},rr=class extends H{record(e,t,n){if(e<0){m.warn(`negative value provided to histogram ${this._descriptor.name}: ${e}`);return}this._record(e,t,n)}},U=class{constructor(e,t,n){i(this,`_metricStorages`,void 0),i(this,`_descriptor`,void 0),i(this,`_observableRegistry`,void 0),this._descriptor=e,this._metricStorages=t,this._observableRegistry=n}addCallback(e){this._observableRegistry.addCallback(e,this)}removeCallback(e){this._observableRegistry.removeCallback(e,this)}},ir=class extends U{},ar=class extends U{},or=class extends U{};function sr(e){return e instanceof U}r();var cr=class{constructor(e){i(this,`_meterSharedState`,void 0),this._meterSharedState=e}createGauge(e,t){let n=V(e,N.GAUGE,t);return new nr(this._meterSharedState.registerMetricStorage(n),n)}createHistogram(e,t){let n=V(e,N.HISTOGRAM,t);return new rr(this._meterSharedState.registerMetricStorage(n),n)}createCounter(e,t){let n=V(e,N.COUNTER,t);return new tr(this._meterSharedState.registerMetricStorage(n),n)}createUpDownCounter(e,t){let n=V(e,N.UP_DOWN_COUNTER,t);return new er(this._meterSharedState.registerMetricStorage(n),n)}createObservableGauge(e,t){let n=V(e,N.OBSERVABLE_GAUGE,t);return new ar(n,this._meterSharedState.registerAsyncMetricStorage(n),this._meterSharedState.observableRegistry)}createObservableCounter(e,t){let n=V(e,N.OBSERVABLE_COUNTER,t);return new ir(n,this._meterSharedState.registerAsyncMetricStorage(n),this._meterSharedState.observableRegistry)}createObservableUpDownCounter(e,t){let n=V(e,N.OBSERVABLE_UP_DOWN_COUNTER,t);return new or(n,this._meterSharedState.registerAsyncMetricStorage(n),this._meterSharedState.observableRegistry)}addBatchObservableCallback(e,t){this._meterSharedState.observableRegistry.addBatchCallback(e,t)}removeBatchObservableCallback(e,t){this._meterSharedState.observableRegistry.removeBatchCallback(e,t)}};r();var lr=class{constructor(e){i(this,`_instrumentDescriptor`,void 0),this._instrumentDescriptor=e}getInstrumentDescriptor(){return this._instrumentDescriptor}updateDescription(e){this._instrumentDescriptor=V(this._instrumentDescriptor.name,this._instrumentDescriptor.type,{description:e,valueType:this._instrumentDescriptor.valueType,unit:this._instrumentDescriptor.unit,advice:this._instrumentDescriptor.advice})}};r();var ur=class{constructor(e){i(this,`_valueMap`,new Map),i(this,`_keyMap`,new Map),i(this,`_hash`,void 0),this._hash=e}get(e,t){return t??(t=this._hash(e)),this._valueMap.get(t)}getOrDefault(e,t){let n=this._hash(e);if(this._valueMap.has(n))return this._valueMap.get(n);let r=t();return this._keyMap.has(n)||this._keyMap.set(n,e),this._valueMap.set(n,r),r}set(e,t,n){n??(n=this._hash(e)),this._keyMap.has(n)||this._keyMap.set(n,e),this._valueMap.set(n,t)}has(e,t){return t??(t=this._hash(e)),this._valueMap.has(t)}*keys(){let e=this._keyMap.entries(),t=e.next();for(;t.done!==!0;)yield[t.value[1],t.value[0]],t=e.next()}*entries(){let e=this._valueMap.entries(),t=e.next();for(;t.done!==!0;)yield[this._keyMap.get(t.value[0]),t.value[1],t.value[0]],t=e.next()}get size(){return this._valueMap.size}},W=class extends ur{constructor(){super(zt)}};A(),r();var dr=class{constructor(e,t){i(this,`_activeCollectionStorage`,new W),i(this,`_cumulativeMemoStorage`,new W),i(this,`_cardinalityLimit`,void 0),i(this,`_overflowAttributes`,{"otel.metric.overflow":!0}),i(this,`_overflowHashCode`,void 0),i(this,`_aggregator`,void 0),this._aggregator=e,this._cardinalityLimit=(t??2e3)-1,this._overflowHashCode=zt(this._overflowAttributes)}record(e,t,n){let r=this._activeCollectionStorage.get(t);if(!r){let i=E(n);if(this._activeCollectionStorage.size>=this._cardinalityLimit){this._activeCollectionStorage.getOrDefault(this._overflowAttributes,()=>this._aggregator.createAccumulation(i))?.record(e);return}r=this._aggregator.createAccumulation(i),this._activeCollectionStorage.set(t,r)}r?.record(e)}batchCumulate(e,t){for(let[n,r,i]of e.entries()){let e=n,a=i,o=this._aggregator.createAccumulation(t);o?.record(r);let s=o;if(this._cumulativeMemoStorage.has(e,a)){let t=this._cumulativeMemoStorage.get(e,a);s=this._aggregator.diff(t,o)}else if(this._cumulativeMemoStorage.size>=this._cardinalityLimit&&(e=this._overflowAttributes,a=this._overflowHashCode,this._cumulativeMemoStorage.has(e,a))){let t=this._cumulativeMemoStorage.get(e,a);s=this._aggregator.diff(t,o)}if(this._activeCollectionStorage.has(e,a)){let t=this._activeCollectionStorage.get(e,a);s=this._aggregator.merge(t,s)}this._cumulativeMemoStorage.set(e,o,a),this._activeCollectionStorage.set(e,s,a)}}collect(){let e=this._activeCollectionStorage;return this._activeCollectionStorage=new W,e}};r();var fr=class e{constructor(e,t){i(this,`_aggregator`,void 0),i(this,`_unreportedAccumulations`,new Map),i(this,`_reportHistory`,new Map),this._aggregator=e,t.forEach(e=>{this._unreportedAccumulations.set(e,[])})}buildMetrics(t,n,r,i){this._stashAccumulations(r);let a=this._getMergedUnreportedAccumulations(t),o=a,s;if(this._reportHistory.has(t)){let n=this._reportHistory.get(t),r=n.collectionTime;s=n.aggregationTemporality,o=s===M.CUMULATIVE?e.merge(n.accumulations,a,this._aggregator):e.calibrateStartTime(n.accumulations,a,r)}else s=t.selectAggregationTemporality(n.type);this._reportHistory.set(t,{accumulations:o,collectionTime:i,aggregationTemporality:s});let c=pr(o);if(c.length!==0)return this._aggregator.toMetricData(n,s,c,i)}_stashAccumulations(e){let t=this._unreportedAccumulations.keys();for(let n of t){let t=this._unreportedAccumulations.get(n);t===void 0&&(t=[],this._unreportedAccumulations.set(n,t)),t.push(e)}}_getMergedUnreportedAccumulations(t){let n=new W,r=this._unreportedAccumulations.get(t);if(this._unreportedAccumulations.set(t,[]),r===void 0)return n;for(let t of r)n=e.merge(n,t,this._aggregator);return n}static merge(e,t,n){let r=e,i=t.entries(),a=i.next();for(;a.done!==!0;){let[t,o,s]=a.value;if(e.has(t,s)){let i=e.get(t,s),a=n.merge(i,o);r.set(t,a,s)}else r.set(t,o,s);a=i.next()}return r}static calibrateStartTime(e,t,n){for(let[r,i]of e.keys())t.get(r,i)?.setStartTime(n);return t}};function pr(e){return Array.from(e.entries())}r();var mr=class extends lr{constructor(e,t,n,r,a){super(e),i(this,`_aggregationCardinalityLimit`,void 0),i(this,`_deltaMetricStorage`,void 0),i(this,`_temporalMetricStorage`,void 0),i(this,`_attributesProcessor`,void 0),this._aggregationCardinalityLimit=a,this._deltaMetricStorage=new dr(t,this._aggregationCardinalityLimit),this._temporalMetricStorage=new fr(t,r),this._attributesProcessor=n}record(e,t){if(this._attributesProcessor===void 0){this._deltaMetricStorage.batchCumulate(e,t);return}let n=new W;for(let[t,r]of e.entries())n.set(this._attributesProcessor.process(t),r);this._deltaMetricStorage.batchCumulate(n,t)}collect(e,t){let n=this._deltaMetricStorage.collect();return this._temporalMetricStorage.buildMetrics(e,this._instrumentDescriptor,n,t)}};function hr(e,t){let n=``;return e.unit!==t.unit&&(n+=`\t- Unit '${e.unit}' does not match '${t.unit}'\n`),e.type!==t.type&&(n+=`\t- Type '${e.type}' does not match '${t.type}'\n`),e.valueType!==t.valueType&&(n+=`\t- Value Type '${e.valueType}' does not match '${t.valueType}'\n`),e.description!==t.description&&(n+=`\t- Description '${e.description}' does not match '${t.description}'\n`),n}function gr(e,t){return`\t- use valueType '${e.valueType}' on instrument creation or use an instrument name other than '${t.name}'`}function _r(e,t){return`\t- use unit '${e.unit}' on instrument creation or use an instrument name other than '${t.name}'`}function vr(e,t){let n={name:t.name,type:t.type,unit:t.unit},r=JSON.stringify(n);return`\t- create a new view with a name other than '${e.name}' and InstrumentSelector '${r}'`}function yr(e,t){let n={name:t.name,type:t.type,unit:t.unit},r=JSON.stringify(n);return`\t- create a new view with a name other than '${e.name}' and InstrumentSelector '${r}'
3
+ \t- OR - create a new view with the name ${e.name} and description '${e.description}' and InstrumentSelector ${r}
4
+ \t- OR - create a new view with the name ${t.name} and description '${e.description}' and InstrumentSelector ${r}`}function br(e,t){return e.valueType===t.valueType?e.unit===t.unit?e.type===t.type?e.description===t.description?``:yr(e,t):vr(e,t):_r(e,t):gr(e,t)}p(),r();var xr=class e{constructor(){i(this,`_sharedRegistry`,new Map),i(this,`_perCollectorRegistry`,new Map)}static create(){return new e}getStorages(e){let t=[];for(let e of this._sharedRegistry.values())t=t.concat(e);let n=this._perCollectorRegistry.get(e);if(n!=null)for(let e of n.values())t=t.concat(e);return t}register(e){this._registerStorage(e,this._sharedRegistry)}registerForCollector(e,t){let n=this._perCollectorRegistry.get(e);n??(n=new Map,this._perCollectorRegistry.set(e,n)),this._registerStorage(t,n)}findOrUpdateCompatibleStorage(e){let t=this._sharedRegistry.get(e.name);return t===void 0?null:this._findOrUpdateCompatibleStorage(e,t)}findOrUpdateCompatibleCollectorStorage(e,t){let n=this._perCollectorRegistry.get(e);if(n===void 0)return null;let r=n.get(t.name);return r===void 0?null:this._findOrUpdateCompatibleStorage(t,r)}_registerStorage(e,t){let n=e.getInstrumentDescriptor(),r=t.get(n.name);if(r===void 0){t.set(n.name,[e]);return}r.push(e)}_findOrUpdateCompatibleStorage(e,t){let n=null;for(let r of t){let t=r.getInstrumentDescriptor();Zn(t,e)?(t.description!==e.description&&(e.description.length>t.description.length&&r.updateDescription(e.description),m.warn(`A view or instrument with the name `,e.name,` has already been registered, but has a different description and is incompatible with another registered view.
5
+ `,`Details:
6
+ `,hr(t,e),`The longer description will be used.
7
+ To resolve the conflict:`,br(t,e))),n=r):m.warn(`A view or instrument with the name `,e.name,` has already been registered and is incompatible with another registered view.
8
+ `,`Details:
9
+ `,hr(t,e),`To resolve the conflict:
10
+ `,br(t,e))}return n}};p(),r();var Sr=class{constructor(e){i(this,`_backingStorages`,void 0),i(this,`hasAttributeProcessor`,void 0),this._backingStorages=e,this.hasAttributeProcessor=e.some(e=>e.hasAttributeProcessor)}record(e,t,n,r){this.hasAttributeProcessor&&n===void 0&&(n=f.active());let i=this._backingStorages;for(let a=0;a<i.length;a++)i[a].record(e,t,n,r)}};p(),r();var Cr=class{constructor(e,t){i(this,`_buffer`,new W),i(this,`_instrumentName`,void 0),i(this,`_valueType`,void 0),this._instrumentName=e,this._valueType=t}observe(e,t={}){if(typeof e!=`number`){m.warn(`non-number value provided to metric ${this._instrumentName}: ${e}`);return}this._valueType===h.INT&&!Number.isInteger(e)&&(m.warn(`INT value type cannot accept a floating-point value for ${this._instrumentName}, ignoring the fractional digits.`),e=Math.trunc(e),!Number.isInteger(e))||this._buffer.set(t,e)}},wr=class{constructor(){i(this,`_buffer`,new Map)}observe(e,t,n={}){if(!sr(e))return;let r=this._buffer.get(e);if(r??(r=new W,this._buffer.set(e,r)),typeof t!=`number`){m.warn(`non-number value provided to metric ${e._descriptor.name}: ${t}`);return}e._descriptor.valueType===h.INT&&!Number.isInteger(t)&&(m.warn(`INT value type cannot accept a floating-point value for ${e._descriptor.name}, ignoring the fractional digits.`),t=Math.trunc(t),!Number.isInteger(t))||r.set(n,t)}};p(),r();var Tr=class{constructor(){i(this,`_callbacks`,[]),i(this,`_batchCallbacks`,[])}addCallback(e,t){this._findCallback(e,t)>=0||this._callbacks.push({callback:e,instrument:t})}removeCallback(e,t){let n=this._findCallback(e,t);n<0||this._callbacks.splice(n,1)}addBatchCallback(e,t){let n=new Set(t.filter(sr));if(n.size===0){m.error(`BatchObservableCallback is not associated with valid instruments`,t);return}this._findBatchCallback(e,n)>=0||this._batchCallbacks.push({callback:e,instruments:n})}removeBatchCallback(e,t){let n=new Set(t.filter(sr)),r=this._findBatchCallback(e,n);r<0||this._batchCallbacks.splice(r,1)}async observe(e,t){let n=this._observeCallbacks(e,t),r=this._observeBatchCallbacks(e,t);return(await Promise.allSettled([...n,...r])).filter(e=>e.status===`rejected`).map(e=>e.reason)}_observeCallbacks(e,t){return this._callbacks.map(async({callback:n,instrument:r})=>{let i=new Cr(r._descriptor.name,r._descriptor.valueType),a=Promise.resolve(n(i));t!=null&&(a=F(a,t)),await a,r._metricStorages.forEach(t=>{t.record(i._buffer,e)})})}_observeBatchCallbacks(e,t){return this._batchCallbacks.map(async({callback:n,instruments:r})=>{let i=new wr,a=Promise.resolve(n(i));t!=null&&(a=F(a,t)),await a,r.forEach(t=>{let n=i._buffer.get(t);n!=null&&t._metricStorages.forEach(t=>{t.record(n,e)})})})}_findCallback(e,t){return this._callbacks.findIndex(n=>n.callback===e&&n.instrument===t)}_findBatchCallback(e,t){return this._batchCallbacks.findIndex(n=>n.callback===e&&Ht(n.instruments,t))}};p(),r();var Er=class extends lr{constructor(e,t,n,r,a){super(e),i(this,`_aggregationCardinalityLimit`,void 0),i(this,`_deltaMetricStorage`,void 0),i(this,`_temporalMetricStorage`,void 0),i(this,`_attributesProcessor`,void 0),i(this,`hasAttributeProcessor`,void 0),this._aggregationCardinalityLimit=a,this._deltaMetricStorage=new dr(t,this._aggregationCardinalityLimit),this._temporalMetricStorage=new fr(t,r),this._attributesProcessor=n,this.hasAttributeProcessor=n!==void 0}record(e,t,n,r){this._attributesProcessor!==void 0&&(t=this._attributesProcessor.process(t,n??f.active())),this._deltaMetricStorage.record(e,t,r)}collect(e,t){let n=this._deltaMetricStorage.collect();return this._temporalMetricStorage.buildMetrics(e,this._instrumentDescriptor,n,t)}};r();var Dr=class{constructor(e,t){i(this,`metricStorageRegistry`,new xr),i(this,`observableRegistry`,new Tr),i(this,`meter`,void 0),i(this,`_meterProviderSharedState`,void 0),i(this,`_instrumentationScope`,void 0),this.meter=new cr(this),this._meterProviderSharedState=e,this._instrumentationScope=t}registerMetricStorage(e){let t=this._registerMetricStorage(e,Er);return t.length===1?t[0]:new Sr(t)}registerAsyncMetricStorage(e){return this._registerMetricStorage(e,mr)}async collect(e,t,n){let r=await this.observableRegistry.observe(t,n?.timeoutMillis),i=this.metricStorageRegistry.getStorages(e);if(i.length===0)return null;let a=[];return i.forEach(n=>{let r=n.collect(e,t);r!=null&&a.push(r)}),a.length===0?{errors:r}:{scopeMetrics:{scope:this._instrumentationScope,metrics:a},errors:r}}_registerMetricStorage(e,t){let n=this._meterProviderSharedState.viewRegistry.findViews(e,this._instrumentationScope).map(n=>{let r=Xn(n,e),i=this.metricStorageRegistry.findOrUpdateCompatibleStorage(r);if(i!=null)return i;let a=new t(r,n.aggregation.createAggregator(r),n.attributesProcessor,this._meterProviderSharedState.metricCollectors,n.aggregationCardinalityLimit);return this.metricStorageRegistry.register(a),a});if(n.length===0){let r=this._meterProviderSharedState.selectAggregations(e.type).map(([n,r])=>{let i=this.metricStorageRegistry.findOrUpdateCompatibleCollectorStorage(n,e);if(i!=null)return i;let a=r.createAggregator(e),o=n.selectCardinalityLimit(e.type),s=new t(e,a,void 0,[n],o);return this.metricStorageRegistry.registerForCollector(n,s),s});n=n.concat(r)}return n}};r();var Or=class{constructor(e){i(this,`viewRegistry`,new Yn),i(this,`metricCollectors`,[]),i(this,`meterSharedStates`,new Map),i(this,`resource`,void 0),this.resource=e}getMeterSharedState(e){let t=Bt(e),n=this.meterSharedStates.get(t);return n??(n=new Dr(this,e),this.meterSharedStates.set(t,n)),n}selectAggregations(e){let t=[];for(let n of this.metricCollectors)t.push([n,Pn(n.selectAggregation(e))]);return t}};A(),r();var kr=class{constructor(e,t){i(this,`_sharedState`,void 0),i(this,`_metricReader`,void 0),this._sharedState=e,this._metricReader=t}async collect(e){let t=E(Date.now()),n=[],r=[],i=Array.from(this._sharedState.meterSharedStates.values()).map(async i=>{let a=await i.collect(this,t,e);a?.scopeMetrics!=null&&n.push(a.scopeMetrics),a?.errors!=null&&r.push(...a.errors)});return await Promise.all(i),{resourceMetrics:{resource:this._sharedState.resource,scopeMetrics:n},errors:r}}async forceFlush(e){await this._metricReader.forceFlush(e)}async shutdown(e){await this._metricReader.shutdown(e)}selectAggregationTemporality(e){return this._metricReader.selectAggregationTemporality(e)}selectAggregation(e){return this._metricReader.selectAggregation(e)}selectCardinalityLimit(e){return this._metricReader.selectCardinalityLimit?.(e)??2e3}};r();var Ar=/[\^$\\.+?()[\]{}|]/g,jr=class e{constructor(t){i(this,`_matchAll`,void 0),i(this,`_regexp`,void 0),t===`*`?(this._matchAll=!0,this._regexp=/.*/):(this._matchAll=!1,this._regexp=new RegExp(e.escapePattern(t)))}match(e){return this._matchAll?!0:this._regexp.test(e)}static escapePattern(e){return`^${e.replace(Ar,`\\$&`).replace(`*`,`.*`)}$`}static hasWildcard(e){return e.includes(`*`)}},G=class{constructor(e){i(this,`_matchAll`,void 0),i(this,`_pattern`,void 0),this._matchAll=e===void 0,this._pattern=e}match(e){return!!(this._matchAll||e===this._pattern)}};r();var Mr=class{process(e,t){return e}},Nr=class{constructor(e){i(this,`_processors`,void 0),this._processors=e}process(e,t){let n=e;for(let e of this._processors)n=e.process(n,t);return n}};function Pr(){return Ir}function Fr(e){return new Nr(e)}var Ir=new Mr;r();var Lr=class{constructor(e){i(this,`_nameFilter`,void 0),i(this,`_type`,void 0),i(this,`_unitFilter`,void 0),this._nameFilter=new jr(e?.name??`*`),this._type=e?.type,this._unitFilter=new G(e?.unit)}getType(){return this._type}getNameFilter(){return this._nameFilter}getUnitFilter(){return this._unitFilter}};r();var Rr=class{constructor(e){i(this,`_nameFilter`,void 0),i(this,`_versionFilter`,void 0),i(this,`_schemaUrlFilter`,void 0),this._nameFilter=new G(e?.name),this._versionFilter=new G(e?.version),this._schemaUrlFilter=new G(e?.schemaUrl)}getNameFilter(){return this._nameFilter}getVersionFilter(){return this._versionFilter}getSchemaUrlFilter(){return this._schemaUrlFilter}};r();function zr(e){return e.instrumentName==null&&e.instrumentType==null&&e.instrumentUnit==null&&e.meterName==null&&e.meterVersion==null&&e.meterSchemaUrl==null}function Br(e){if(zr(e))throw Error(`Cannot create view with no selector arguments supplied`);if(e.name!=null&&(e?.instrumentName==null||jr.hasWildcard(e.instrumentName)))throw Error(`Views with a specified name must be declared with an instrument selector that selects at most one instrument per meter.`)}var Vr=class{constructor(e){i(this,`name`,void 0),i(this,`description`,void 0),i(this,`aggregation`,void 0),i(this,`attributesProcessor`,void 0),i(this,`instrumentSelector`,void 0),i(this,`meterSelector`,void 0),i(this,`aggregationCardinalityLimit`,void 0),Br(e),e.attributesProcessors==null?this.attributesProcessor=Pr():this.attributesProcessor=Fr(e.attributesProcessors),this.name=e.name,this.description=e.description,this.aggregation=Pn(e.aggregation??{type:B.DEFAULT}),this.instrumentSelector=new Lr({name:e.instrumentName,type:e.instrumentType,unit:e.instrumentUnit}),this.meterSelector=new Rr({name:e.meterName,version:e.meterVersion,schemaUrl:e.meterSchemaUrl}),this.aggregationCardinalityLimit=e.aggregationCardinalityLimit}};p(),Ot(),r();var Hr=class{constructor(e){if(i(this,`_sharedState`,void 0),i(this,`_shutdown`,!1),this._sharedState=new Or(e?.resource??At()),e?.views!=null&&e.views.length>0)for(let t of e.views)this._sharedState.viewRegistry.addView(new Vr(t));if(e?.readers!=null&&e.readers.length>0)for(let t of e.readers){let n=new kr(this._sharedState,t);t.setMetricProducer(n),this._sharedState.metricCollectors.push(n),e.sdkMetricsEnabled&&t instanceof Gn&&t._setSelfObsMeterProvider(this)}}getMeter(e,t=``,n={}){return this._shutdown?(m.warn(`A shutdown MeterProvider cannot provide a Meter`),a()):this._sharedState.getMeterSharedState({name:e,version:t,schemaUrl:n.schemaUrl}).meter}async shutdown(e){if(this._shutdown){m.warn(`shutdown may only be called once per MeterProvider`);return}this._shutdown=!0,await Promise.all(this._sharedState.metricCollectors.map(t=>t.shutdown(e)))}async forceFlush(e){if(this._shutdown){m.warn(`invalid attempt to force flush after MeterProvider shutdown`);return}await Promise.all(this._sharedState.metricCollectors.map(t=>t.forceFlush(e)))}},Ur=`exception`,Wr=Symbol.for(`nodejs.util.inspect.custom`);function Gr(e){let t={};for(let[n,r]of e.getRawAttributes())typeof r?.then!=`function`&&r!=null&&(t[n]??(t[n]=r));return t}function Kr(e,t,n,r,i){if(typeof n==`number`&&n<0){let t=`[${e}]`;return r?.stylize?r.stylize(t,`special`):t}return typeof i!=`function`||!r?t:`${e} ${i(t,{...r,depth:r.depth==null?r.depth:r.depth-1})}`}p(),A(),ce(),r();var qr=class{constructor(e){i(this,`_spanContext`,void 0),i(this,`kind`,void 0),i(this,`parentSpanContext`,void 0),i(this,`attributes`,{}),i(this,`links`,[]),i(this,`events`,[]),i(this,`startTime`,void 0),i(this,`resource`,void 0),i(this,`instrumentationScope`,void 0),i(this,`_droppedAttributesCount`,0),i(this,`_droppedEventsCount`,0),i(this,`_droppedLinksCount`,0),i(this,`_attributesCount`,0),i(this,`name`,void 0),i(this,`status`,{code:l.UNSET}),i(this,`endTime`,[0,0]),i(this,`_ended`,!1),i(this,`_duration`,[-1,-1]),i(this,`_spanProcessor`,void 0),i(this,`_spanLimits`,void 0),i(this,`_attributeValueLengthLimit`,void 0),i(this,`_recordEndMetrics`,void 0),i(this,`_performanceStartTime`,void 0),i(this,`_performanceOffset`,void 0),i(this,`_startTimeProvided`,void 0);let t=Date.now();if(this._spanContext=e.spanContext,this._performanceStartTime=w.now(),this._performanceOffset=t-(this._performanceStartTime+w.timeOrigin),this._startTimeProvided=e.startTime!=null,this._spanLimits=e.spanLimits,this._attributeValueLengthLimit=this._spanLimits.attributeValueLengthLimit??0,this._spanProcessor=e.spanProcessor,this.name=e.name,this.parentSpanContext=e.parentSpanContext,this.kind=e.kind,e.links)for(let t of e.links)this.addLink(t);this.startTime=this._getTime(e.startTime??t),this.resource=e.resource,this.instrumentationScope=e.scope,this._recordEndMetrics=e.recordEndMetrics,e.attributes!=null&&this.setAttributes(e.attributes),this._spanProcessor.onStart(this,e.context)}spanContext(){return this._spanContext}setAttribute(e,t){if(t==null||this._isSpanEnded())return this;if(e.length===0)return m.warn(`Invalid attribute key: ${e}`),this;if(!Et(t))return m.warn(`Invalid attribute value set for key: ${e}`),this;let{attributeCountLimit:n}=this._spanLimits,r=!Object.prototype.hasOwnProperty.call(this.attributes,e);return n!==void 0&&this._attributesCount>=n&&r?(this._droppedAttributesCount++,this):(this.attributes[e]=this._truncateToSize(t),r&&this._attributesCount++,this)}setAttributes(e){for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&this.setAttribute(t,e[t]);return this}addEvent(e,t,n){if(this._isSpanEnded())return this;let{eventCountLimit:r}=this._spanLimits;if(r===0)return m.warn(`No events allowed.`),this._droppedEventsCount++,this;r!==void 0&&this.events.length>=r&&(this._droppedEventsCount===0&&m.debug(`Dropping extra events.`),this.events.shift(),this._droppedEventsCount++),St(t)&&(St(n)||(n=t),t=void 0);let i=D(t),{attributePerEventCountLimit:a}=this._spanLimits,o={},s=0,c=0;for(let e in i){if(!Object.prototype.hasOwnProperty.call(i,e))continue;let t=i[e];if(a!==void 0&&c>=a){s++;continue}o[e]=this._truncateToSize(t),c++}return this.events.push({name:e,attributes:o,time:this._getTime(n),droppedAttributesCount:s}),this}addLink(e){if(this._isSpanEnded())return this;let{linkCountLimit:t}=this._spanLimits;if(t===0)return this._droppedLinksCount++,this;t!==void 0&&this.links.length>=t&&(this._droppedLinksCount===0&&m.debug(`Dropping extra links.`),this.links.shift(),this._droppedLinksCount++);let{attributePerLinkCountLimit:n}=this._spanLimits,r=D(e.attributes),i={},a=0,o=0;for(let e in r){if(!Object.prototype.hasOwnProperty.call(r,e))continue;let t=r[e];if(n!==void 0&&o>=n){a++;continue}i[e]=this._truncateToSize(t),o++}let s={context:e.context};return o>0&&(s.attributes=i),a>0&&(s.droppedAttributesCount=a),this.links.push(s),this}addLinks(e){for(let t of e)this.addLink(t);return this}setStatus(e){if(this._isSpanEnded()||e.code===l.UNSET||this.status.code===l.OK)return this;let t={code:e.code};return e.code===l.ERROR&&(typeof e.message==`string`?t.message=e.message:e.message!=null&&m.warn(`Dropping invalid status.message of type '${typeof e.message}', expected 'string'`)),this.status=t,this}updateName(e){return this._isSpanEnded()||(this.name=e),this}end(e){if(this._isSpanEnded()){m.error(`${this.name} ${this._spanContext.traceId}-${this._spanContext.spanId} - You can only call end() on a span once.`);return}this.endTime=this._getTime(e),this._duration=wt(this.startTime,this.endTime),this._duration[0]<0&&(m.warn(`Inconsistent start and end time, startTime > endTime. Setting span duration to 0ms.`,this.startTime,this.endTime),this.endTime=this.startTime.slice(),this._duration=[0,0]),this._droppedEventsCount>0&&m.warn(`Dropped ${this._droppedEventsCount} events because eventCountLimit reached`),this._droppedLinksCount>0&&m.warn(`Dropped ${this._droppedLinksCount} links because linkCountLimit reached`),this._spanProcessor.onEnding&&this._spanProcessor.onEnding(this),this._recordEndMetrics?.(),this._ended=!0,this._spanProcessor.onEnd(this)}_getTime(e){if(typeof e==`number`&&e<=w.now())return yt(e+this._performanceOffset);if(typeof e==`number`)return E(e);if(e instanceof Date)return E(e.getTime());if(Ct(e))return e;if(this._startTimeProvided)return E(Date.now());let t=w.now()-this._performanceStartTime;return bt(this.startTime,E(t))}isRecording(){return this._ended===!1}recordException(e,t){let n={};typeof e==`string`?n[se]=e:e&&(e.code?n[g]=e.code.toString():e.name&&(n[g]=e.name),e.message&&(n[se]=e.message),e.stack&&(n[re]=e.stack)),n[`exception.type`]||n[`exception.message`]?this.addEvent(Ur,n,t):m.warn(`Failed to record an exception ${e}`)}get duration(){return this._duration}get ended(){return this._ended}get droppedAttributesCount(){return this._droppedAttributesCount}get droppedEventsCount(){return this._droppedEventsCount}get droppedLinksCount(){return this._droppedLinksCount}_isSpanEnded(){if(this._ended){let e=Error(`Operation attempted on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`);m.warn(`Cannot execute the operation on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`,e)}return this._ended}_truncateToLimitUtil(e,t){return e.length<=t?e:e.substring(0,t)}_truncateToSize(e){let t=this._attributeValueLengthLimit;return t<=0?(m.warn(`Attribute value limit must be positive, got ${t}`),e):typeof e==`string`?this._truncateToLimitUtil(e,t):Array.isArray(e)?e.map(e=>typeof e==`string`?this._truncateToLimitUtil(e,t):e):e}[Wr](e,t,n){return Kr(`SpanImpl`,{name:this.name,kind:this.kind,spanContext:this._spanContext,parentSpanContext:this.parentSpanContext,status:this.status,startTime:this.startTime,endTime:this.endTime,duration:this._duration,ended:this._ended,attributes:this.attributes,events:this.events,links:this.links,droppedAttributesCount:this._droppedAttributesCount,droppedEventsCount:this._droppedEventsCount,droppedLinksCount:this._droppedLinksCount,instrumentationScope:this.instrumentationScope,resource:{attributes:Gr(this.resource)}},e,t,n)}},K;(function(e){e[e.NOT_RECORD=0]=`NOT_RECORD`,e[e.RECORD=1]=`RECORD`,e[e.RECORD_AND_SAMPLED=2]=`RECORD_AND_SAMPLED`})(K||(K={}));var Jr=`otel.component.name`,Yr=`otel.component.type`,Xr=`otel.span.parent.origin`,Zr=`otel.span.sampling_result`,Qr=`otel.sdk.processor.span.processed`,$r=`otel.sdk.processor.span.queue.capacity`,ei=`otel.sdk.processor.span.queue.size`,ti=`otel.sdk.span.live`,ni=`otel.sdk.span.started`,ri=`batching_span_processor`;r();var ii=class{constructor(e){i(this,`startedSpans`,void 0),i(this,`liveSpans`,void 0),this.startedSpans=e.createCounter(ni,{unit:`{span}`,description:`The number of created spans.`}),this.liveSpans=e.createUpDownCounter(ti,{unit:`{span}`,description:`The number of currently live spans.`})}startSpan(e,t){let n=oi(t);if(this.startedSpans.add(1,{[Xr]:ai(e),[Zr]:n}),t===K.NOT_RECORD)return()=>{};let r={[Zr]:n};return this.liveSpans.add(1,r),()=>{this.liveSpans.add(-1,r)}}};function ai(e){return e?e.isRemote?`remote`:`local`:`none`}function oi(e){switch(e){case K.RECORD_AND_SAMPLED:return`RECORD_AND_SAMPLE`;case K.RECORD:return`RECORD_ONLY`;case K.NOT_RECORD:return`DROP`}}var si=`2.9.0`;p(),A(),r();var ci=class{constructor(e,t){i(this,`_sampler`,void 0),i(this,`_spanLimits`,void 0),i(this,`_idGenerator`,void 0),i(this,`instrumentationScope`,void 0),i(this,`_resource`,void 0),i(this,`_spanProcessor`,void 0),i(this,`_tracerMetrics`,void 0),this.instrumentationScope=e,this._sampler=t.sampler,this._spanLimits=t.spanLimits,this._resource=t.resource,this._idGenerator=t.idGenerator,this._spanProcessor=t.spanProcessor;let n=t.meterProvider.getMeter(`@opentelemetry/sdk-trace`,si);this._tracerMetrics=new ii(n)}startSpan(e,t={},n=f.active()){t.root&&(n=d.deleteSpan(n));let r=d.getSpan(n);if(xt(n))return m.debug(`Instrumentation suppressed, returning Noop Span`),d.wrapSpanContext(c);let i=r?.spanContext(),a=this._idGenerator.generateSpanId(),o,l,p;!i||!d.isSpanContextValid(i)?l=this._idGenerator.generateTraceId():(l=i.traceId,p=i.traceState,o=i);let te=t.kind??ee.INTERNAL,h=(t.links??[]).map(e=>({context:e.context,attributes:D(e.attributes)})),ne=D(t.attributes),g=this._sampler.shouldSample(n,l,e,te,ne,h),re=this._tracerMetrics.startSpan(i,g.decision);p=g.traceState??p;let ie=g.decision===u.RECORD_AND_SAMPLED?s.SAMPLED:s.NONE,_={traceId:l,spanId:a,traceFlags:ie,traceState:p};if(g.decision===u.NOT_RECORD)return m.debug(`Recording is off, propagating context in a non-recording span`),d.wrapSpanContext(_);let ae=D(Object.assign(ne,g.attributes));return new qr({resource:this._resource,scope:this.instrumentationScope,context:n,spanContext:_,name:e,kind:te,links:h,parentSpanContext:o,attributes:ae,startTime:t.startTime,spanProcessor:this._spanProcessor,spanLimits:this._spanLimits,recordEndMetrics:re})}startActiveSpan(e,t,n,r){let i,a,o;if(arguments.length<2)return;arguments.length===2?o=t:arguments.length===3?(i=t,o=n):(i=t,a=n,o=r);let s=a??f.active(),c=this.startSpan(e,i,s),l=d.setSpan(s,c);return f.with(l,o,void 0,c)}[Wr](e,t,n){return Kr(`Tracer`,{instrumentationScope:this.instrumentationScope,resource:{attributes:Gr(this._resource)},spanLimits:this._spanLimits},e,t,n)}};A(),r();var li=class{constructor(e){i(this,`_spanProcessors`,void 0),this._spanProcessors=e}forceFlush(){let e=[];for(let t of this._spanProcessors)e.push(t.forceFlush());return new Promise(t=>{Promise.all(e).then(()=>{t()}).catch(e=>{C(e||Error(`MultiSpanProcessor: forceFlush failed`)),t()})})}onStart(e,t){for(let n of this._spanProcessors)n.onStart(e,t)}onEnding(e){for(let t of this._spanProcessors)t.onEnding&&t.onEnding(e)}onEnd(e){for(let t of this._spanProcessors)t.onEnd(e)}shutdown(){let e=[];for(let t of this._spanProcessors)e.push(t.shutdown());return new Promise((t,n)=>{Promise.all(e).then(()=>{t()},n)})}},q=class{shouldSample(){return{decision:K.NOT_RECORD}}toString(){return`AlwaysOffSampler`}},J=class{shouldSample(){return{decision:K.RECORD_AND_SAMPLED}}toString(){return`AlwaysOnSampler`}};p(),A(),r();var Y=class{constructor(e){i(this,`_root`,void 0),i(this,`_remoteParentSampled`,void 0),i(this,`_remoteParentNotSampled`,void 0),i(this,`_localParentSampled`,void 0),i(this,`_localParentNotSampled`,void 0),this._root=e.root,this._root||(C(Error(`ParentBasedSampler must have a root sampler configured`)),this._root=new J),this._remoteParentSampled=e.remoteParentSampled??new J,this._remoteParentNotSampled=e.remoteParentNotSampled??new q,this._localParentSampled=e.localParentSampled??new J,this._localParentNotSampled=e.localParentNotSampled??new q}shouldSample(e,t,n,r,i,a){let o=d.getSpanContext(e);return!o||!te(o)?this._root.shouldSample(e,t,n,r,i,a):o.isRemote?o.traceFlags&s.SAMPLED?this._remoteParentSampled.shouldSample(e,t,n,r,i,a):this._remoteParentNotSampled.shouldSample(e,t,n,r,i,a):o.traceFlags&s.SAMPLED?this._localParentSampled.shouldSample(e,t,n,r,i,a):this._localParentNotSampled.shouldSample(e,t,n,r,i,a)}toString(){return`ParentBased{root=${this._root.toString()}, remoteParentSampled=${this._remoteParentSampled.toString()}, remoteParentNotSampled=${this._remoteParentNotSampled.toString()}, localParentSampled=${this._localParentSampled.toString()}, localParentNotSampled=${this._localParentNotSampled.toString()}}`}};ce(),r();var ui=new Map,di=class{constructor(e,t,n){i(this,`processedSpans`,void 0),i(this,`queueSize`,void 0),i(this,`queueSizeCallback`,void 0),i(this,`standardAttrs`,void 0),i(this,`droppedAttrs`,void 0);let r=ui.get(e)??0;if(ui.set(e,r+1),this.standardAttrs={[Yr]:e,[Jr]:`${e}/${r}`},this.droppedAttrs={...this.standardAttrs,[_]:`queue_full`},this.processedSpans=t.createCounter(Qr,{unit:`{span}`,description:`The number of spans for which the processing has finished, either successful or failed.`}),n){let{capacity:e,getQueueSize:r}=n;t.createUpDownCounter($r,{unit:`{span}`,description:`The maximum number of spans the queue of a given instance of an SDK span processor can hold.`}).add(e,this.standardAttrs),this.queueSize=t.createObservableUpDownCounter(ei,{unit:`{span}`,description:`The number of spans in the queue of a given instance of an SDK span processor.`}),this.queueSizeCallback=e=>e.observe(r(),this.standardAttrs),this.queueSize.addCallback(this.queueSizeCallback)}}dropSpans(e){this.processedSpans.add(e,this.droppedAttrs)}finishSpans(e,t){if(!t){this.processedSpans.add(e,this.standardAttrs);return}let n={...this.standardAttrs,[_]:t.name};this.processedSpans.add(e,n)}shutdown(){this.queueSize&&this.queueSizeCallback&&this.queueSize.removeCallback(this.queueSizeCallback)}};p(),A(),r();var fi=class{constructor(e){i(this,`_maxExportBatchSize`,void 0),i(this,`_maxQueueSize`,void 0),i(this,`_scheduledDelayMillis`,void 0),i(this,`_exportTimeoutMillis`,void 0),i(this,`_exporter`,void 0),i(this,`_metrics`,void 0),i(this,`_isExporting`,!1),i(this,`_finishedSpans`,[]),i(this,`_timer`,void 0),i(this,`_shutdownOnce`,void 0),i(this,`_droppedSpansCount`,0),this._exporter=e.exporter,this._maxExportBatchSize=e.maxExportBatchSize??512,this._maxQueueSize=e.maxQueueSize??2048,this._scheduledDelayMillis=e.scheduledDelayMillis??5e3,this._exportTimeoutMillis=e.exportTimeoutMillis??3e4,this._shutdownOnce=new Dt(this._shutdown,this),this._maxExportBatchSize>this._maxQueueSize&&(m.warn(`BatchSpanProcessor: maxExportBatchSize must be smaller or equal to maxQueueSize, setting maxExportBatchSize to match maxQueueSize`),this._maxExportBatchSize=this._maxQueueSize);let t=e.selfObsMeterProvider?e.selfObsMeterProvider.getMeter(`@opentelemetry/sdk-trace`):a();this._metrics=new di(ri,t,{capacity:this._maxQueueSize,getQueueSize:()=>this._finishedSpans.length})}forceFlush(){return this._shutdownOnce.isCalled?this._shutdownOnce.promise:this._flushAll()}onStart(e,t){}onEnd(e){this._shutdownOnce.isCalled||(e.spanContext().traceFlags&s.SAMPLED)!==0&&this._addToBuffer(e)}shutdown(){return this._shutdownOnce.call()}_shutdown(){return Promise.resolve().then(()=>this.onShutdown()).then(()=>this._flushAll()).then(()=>(this._metrics.shutdown(),this._exporter.shutdown()))}_addToBuffer(e){if(this._finishedSpans.length>=this._maxQueueSize){this._droppedSpansCount===0&&m.debug(`maxQueueSize reached, dropping spans`),this._droppedSpansCount++,this._metrics.dropSpans(1);return}this._droppedSpansCount>0&&(m.warn(`Dropped ${this._droppedSpansCount} spans because maxQueueSize reached`),this._droppedSpansCount=0),this._finishedSpans.push(e),this._maybeStartTimer()}_flushAll(){return new Promise((e,t)=>{let n=[],r=Math.ceil(this._finishedSpans.length/this._maxExportBatchSize);for(let e=0,t=r;e<t;e++)n.push(this._flushOneBatch());Promise.all(n).then(()=>{e()}).catch(t)})}_flushOneBatch(){return this._clearTimer(),this._finishedSpans.length===0?Promise.resolve():new Promise((e,t)=>{let n=setTimeout(()=>{t(Error(`Timeout`))},this._exportTimeoutMillis);f.with(Ft(f.active()),()=>{let r;this._finishedSpans.length<=this._maxExportBatchSize?(r=this._finishedSpans,this._finishedSpans=[]):r=this._finishedSpans.splice(0,this._maxExportBatchSize);let i=()=>this._exporter.export(r,i=>{clearTimeout(n),this._metrics.finishSpans(r.length,i.error),i.code===j.SUCCESS?e():t(i.error??Error(`BatchSpanProcessor: span export failed`))}),a=null;for(let e=0,t=r.length;e<t;e++){let t=r[e];t.resource.asyncAttributesPending&&t.resource.waitForAsyncAttributes&&(a??(a=[]),a.push(t.resource.waitForAsyncAttributes()))}a===null?i():Promise.all(a).then(i,e=>{C(e),t(e)})})})}_maybeStartTimer(){if(this._isExporting)return;let e=()=>{this._isExporting=!0,this._flushOneBatch().finally(()=>{this._isExporting=!1,this._finishedSpans.length>0&&(this._clearTimer(),this._maybeStartTimer())}).catch(e=>{this._isExporting=!1,C(e)})};if(this._finishedSpans.length>=this._maxExportBatchSize)return e();this._timer===void 0&&(this._timer=setTimeout(()=>e(),this._scheduledDelayMillis),typeof this._timer!=`number`&&this._timer.unref())}_clearTimer(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}},pi=class extends fi{onShutdown(){}};r();var mi=8,hi=16,gi=class{constructor(){i(this,`generateTraceId`,_i(hi)),i(this,`generateSpanId`,_i(mi))}},X=Buffer.allocUnsafe(hi);function _i(e){return function(){for(let t=0;t<e/4;t++)X.writeUInt32BE(Math.random()*2**32>>>0,t*4);for(let t=0;t<e&&!(X[t]>0);t++)t===e-1&&(X[e-1]=1);return X.toString(`hex`,0,e)}}p(),Ot(),r();var Z;(function(e){e[e.resolved=0]=`resolved`,e[e.timeout=1]=`timeout`,e[e.error=2]=`error`,e[e.unresolved=3]=`unresolved`})(Z||(Z={}));var vi=class{constructor(e={}){i(this,`_resource`,void 0),i(this,`_activeSpanProcessor`,void 0),i(this,`_forceFlushTimeoutMillis`,void 0),i(this,`_tracerOptions`,void 0),i(this,`_tracers`,new Map),this._forceFlushTimeoutMillis=e.forceFlushTimeoutMillis??3e4,this._resource=e.resource??At();let t=e.spanProcessors??[];this._activeSpanProcessor=new li(t),this._tracerOptions={resource:this._resource,sampler:e.sampler??new Y({root:new J}),spanLimits:{attributeCountLimit:e.spanLimits?.attributeCountLimit??128,attributeValueLengthLimit:e.spanLimits?.attributeValueLengthLimit??1/0,eventCountLimit:e.spanLimits?.eventCountLimit??128,linkCountLimit:e.spanLimits?.linkCountLimit??128,attributePerEventCountLimit:e.spanLimits?.attributePerEventCountLimit??128,attributePerLinkCountLimit:e.spanLimits?.attributePerLinkCountLimit??128},idGenerator:e.idGenerator||new gi,spanProcessor:this._activeSpanProcessor,meterProvider:e.meterProvider??{getMeter(){return a()}}}}getTracer(e,t,n){let r=`${e}@${t||``}:${n?.schemaUrl||``}`;return this._tracers.has(r)||this._tracers.set(r,new ci({name:e,version:t,schemaUrl:n?.schemaUrl},this._tracerOptions)),this._tracers.get(r)}forceFlush(){let e=this._forceFlushTimeoutMillis,t=this._activeSpanProcessor._spanProcessors.map(t=>new Promise(n=>{let r,i=setTimeout(()=>{n(Error(`Span processor did not completed within timeout period of ${e} ms`)),r=Z.timeout},e);t.forceFlush().then(()=>{clearTimeout(i),r!==Z.timeout&&(r=Z.resolved,n(r))}).catch(e=>{clearTimeout(i),r=Z.error,n(e)})}));return new Promise((e,n)=>{Promise.all(t).then(t=>{let r=t.filter(e=>e!==Z.resolved);r.length>0?n(r):e()}).catch(e=>n([e]))})}shutdown(){return this._activeSpanProcessor.shutdown()}[Wr](e,t,n){let r=this._activeSpanProcessor._spanProcessors;return Kr(`TracerProvider`,{resource:{attributes:Gr(this._resource)},tracers:Array.from(this._tracers.keys()),spanProcessors:r.map(e=>e.constructor?.name??`SpanProcessor`)},e,t,n)}};A();var yi=class{export(e,t){return this._sendSpans(e,t)}shutdown(){return this._sendSpans([]),this.forceFlush()}forceFlush(){return Promise.resolve()}_exportInfo(e){return{resource:{attributes:e.resource.attributes},instrumentationScope:e.instrumentationScope,traceId:e.spanContext().traceId,parentSpanContext:e.parentSpanContext,traceState:e.spanContext().traceState?.serialize(),name:e.name,id:e.spanContext().spanId,kind:e.kind,timestamp:k(e.startTime),duration:k(e.duration),attributes:e.attributes,status:e.status,events:e.events,links:e.links}}_sendSpans(e,t){for(let t of e)console.dir(this._exportInfo(t),{depth:3});if(t)return t({code:j.SUCCESS})}};p(),r();var bi=class{constructor(e=0){i(this,`_ratio`,void 0),i(this,`_upperBound`,void 0),this._ratio=this._normalize(e),this._upperBound=Math.floor(this._ratio*4294967295)}shouldSample(e,t){return{decision:ne(t)&&this._accumulate(t)<this._upperBound?K.RECORD_AND_SAMPLED:K.NOT_RECORD}}toString(){return`TraceIdRatioBased{${this._ratio}}`}_normalize(e){return typeof e!=`number`||isNaN(e)?0:e>=1?1:e<=0?0:e}_accumulate(e){let t=0;for(let n=0;n<32;n+=8){let r=0;for(let t=0;t<8;t++){let i=e.charCodeAt(n+t),a=i<58?i-48:i<71?i-55:i-87;r=r<<4|a}t=(t^r)>>>0}return t}};p(),A();var Q;(function(e){e.AlwaysOff=`always_off`,e.AlwaysOn=`always_on`,e.ParentBasedAlwaysOff=`parentbased_always_off`,e.ParentBasedAlwaysOn=`parentbased_always_on`,e.ParentBasedTraceIdRatio=`parentbased_traceidratio`,e.TraceIdRatio=`traceidratio`})(Q||(Q={}));var $=1;function xi(){return{sampler:Si(),forceFlushTimeoutMillis:3e4,generalLimits:{attributeValueLengthLimit:T(`OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT`)??1/0,attributeCountLimit:T(`OTEL_ATTRIBUTE_COUNT_LIMIT`)??128},spanLimits:{attributeValueLengthLimit:T(`OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT`)??1/0,attributeCountLimit:T(`OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT`)??128,linkCountLimit:T(`OTEL_SPAN_LINK_COUNT_LIMIT`)??128,eventCountLimit:T(`OTEL_SPAN_EVENT_COUNT_LIMIT`)??128,attributePerEventCountLimit:T(`OTEL_SPAN_ATTRIBUTE_PER_EVENT_COUNT_LIMIT`)??128,attributePerLinkCountLimit:T(`OTEL_SPAN_ATTRIBUTE_PER_LINK_COUNT_LIMIT`)??128}}}function Si(){let e=Tt(`OTEL_TRACES_SAMPLER`)??Q.ParentBasedAlwaysOn;switch(e){case Q.AlwaysOn:return new J;case Q.AlwaysOff:return new q;case Q.ParentBasedAlwaysOn:return new Y({root:new J});case Q.ParentBasedAlwaysOff:return new Y({root:new q});case Q.TraceIdRatio:return new bi(Ci());case Q.ParentBasedTraceIdRatio:return new Y({root:new bi(Ci())});default:return m.error(`OTEL_TRACES_SAMPLER value "${e}" invalid, defaulting to "${Q.ParentBasedAlwaysOn}".`),new Y({root:new J})}}function Ci(){let e=T(`OTEL_TRACES_SAMPLER_ARG`);return e==null?(m.error(`OTEL_TRACES_SAMPLER_ARG is blank, defaulting to ${$}.`),$):e<0||e>1?(m.error(`OTEL_TRACES_SAMPLER_ARG=${e} was given, but it is out of range ([0..1]), defaulting to ${$}.`),$):e}A();function wi(e){let t=Object.assign({},e.spanLimits);return t.attributeCountLimit=e.spanLimits?.attributeCountLimit??e.generalLimits?.attributeCountLimit??T(`OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT`)??T(`OTEL_ATTRIBUTE_COUNT_LIMIT`)??128,t.attributeValueLengthLimit=e.spanLimits?.attributeValueLengthLimit??e.generalLimits?.attributeValueLengthLimit??T(`OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT`)??T(`OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT`)??1/0,Object.assign({},e,{spanLimits:t})}A();var Ti=class extends vi{constructor(e={}){let t=vt({},xi(),wi(e));delete t.generalLimits,super(t)}};A();var Ei=class extends pi{constructor(e,t){t||(t={});for(let[e,n]of[[`maxExportBatchSize`,`OTEL_BSP_MAX_EXPORT_BATCH_SIZE`],[`maxQueueSize`,`OTEL_BSP_MAX_QUEUE_SIZE`],[`scheduledDelayMillis`,`OTEL_BSP_SCHEDULE_DELAY`],[`exportTimeoutMillis`,`OTEL_BSP_EXPORT_TIMEOUT`]])if(t[e]===void 0){let r=T(n);r!==void 0&&(t[e]=r)}super({exporter:e,...t})}};n(),le(),_e(),we(),be(),Ve(),Ue(),ke(),nt(),ct(),rt(),it(),It(),ut(),de(),Ye(),Me(),b(),Ce(),Qe(),Ie(),Re(),Pe(),et();var Di=3600*1e3,Oi=1440*60*1e3;async function ki(){let e=Ze();if(e.error)throw Error(`Auth error: ${e.error}`);let t={"Content-Type":`application/json`,"User-Agent":$e(),...e.headers};return(await ue.get(`https://api.anthropic.com/api/claude_code/organizations/metrics_enabled`,{headers:t,timeout:5e3})).data}async function Ai(){if(Fe())return{enabled:!1,hasError:!1};try{let e=await Xe(ki,{also403Revoked:!0});return x(`Metrics opt-out API response: enabled=${e.metrics_logging_enabled}`),{enabled:e.metrics_logging_enabled,hasError:!1}}catch(e){return x(`Failed to check metrics opt-out status: ${De(e)}`),S(e),{enabled:!1,hasError:!0}}}var ji=Le(Ai,Di);async function Mi(){let e=await ji();if(e.hasError)return e;let t=je().metricsStatusCache;return t!==void 0&&t.enabled===e.enabled&&Date.now()-t.timestamp<Oi||Ae(t=>({...t,metricsStatusCache:{enabled:e.enabled,timestamp:Date.now()}})),e}async function Ni(){if(qe()&&!We())return{enabled:!1,hasError:!1};let e=je().metricsStatusCache;return e?(Date.now()-e.timestamp>Oi&&Mi().catch(S),{enabled:e.enabled,hasError:!1}):Mi()}A(),de(),Ye(),Me(),b(),Ce(),Qe(),Ie(),et(),r();var Pi=class{constructor(e={}){i(this,`endpoint`,void 0),i(this,`timeout`,void 0),i(this,`pendingExports`,[]),i(this,`isShutdown`,!1),process.env.USER_TYPE===`ant`&&process.env.ANT_CLAUDE_CODE_METRICS_ENDPOINT?this.endpoint=process.env.ANT_CLAUDE_CODE_METRICS_ENDPOINT+`/api/claude_code/metrics`:this.endpoint=`https://api.anthropic.com/api/claude_code/metrics`,this.timeout=e.timeout||5e3}async export(e,t){if(this.isShutdown){t({code:j.FAILED,error:Error(`Exporter has been shutdown`)});return}let n=this.doExport(e,t);this.pendingExports.push(n),n.finally(()=>{let e=this.pendingExports.indexOf(n);e>-1&&this.pendingExports.splice(e,1)})}async doExport(e,t){try{if(!(Ne()||ye())){x(`BigQuery metrics export: trust not established, skipping`),t({code:j.SUCCESS});return}if(!(await Ni()).enabled){x(`Metrics export disabled by organization setting`),t({code:j.SUCCESS});return}let n=this.transformMetricsForInternal(e),r=Ze();if(r.error){x(`Metrics export failed: ${r.error}`),t({code:j.FAILED,error:Error(r.error)});return}let i={"Content-Type":`application/json`,"User-Agent":$e(),...r.headers},a=await ue.post(this.endpoint,n,{timeout:this.timeout,headers:i});x(`BigQuery metrics exported successfully`),x(`BigQuery API Response: ${Se(a.data,null,2)}`),t({code:j.SUCCESS})}catch(e){x(`BigQuery metrics export failed: ${De(e)}`),S(e),t({code:j.FAILED,error:xe(e)})}}transformMetricsForInternal(e){let t=e.resource.attributes,n={"service.name":t[`service.name`]||`claude-code`,"service.version":t[`service.version`]||`unknown`,"os.type":t[`os.type`]||`unknown`,"os.version":t[`os.version`]||`unknown`,"host.arch":t[`host.arch`]||`unknown`,"aggregation.temporality":this.selectAggregationTemporality()===M.DELTA?`delta`:`cumulative`};if(t[`wsl.version`]&&(n[`wsl.version`]=t[`wsl.version`]),qe()){n[`user.customer_type`]=`claude_ai`;let e=Ke();e&&(n[`user.subscription_type`]=e)}else n[`user.customer_type`]=`api`;return{resource_attributes:n,metrics:e.scopeMetrics.flatMap(e=>e.metrics.map(e=>({name:e.descriptor.name,description:e.descriptor.description,unit:e.descriptor.unit,data_points:this.extractDataPoints(e)})))}}extractDataPoints(e){return(e.dataPoints||[]).filter(e=>typeof e.value==`number`).map(e=>({attributes:this.convertAttributes(e.attributes),value:e.value,timestamp:this.hrTimeToISOString(e.endTime||e.startTime||[Date.now()/1e3,0])}))}async shutdown(){this.isShutdown=!0,await this.forceFlush(),x(`BigQuery metrics exporter shutdown complete`)}async forceFlush(){await Promise.all(this.pendingExports),x(`BigQuery metrics exporter flush complete`)}convertAttributes(e){let t={};if(e)for(let[n,r]of Object.entries(e))r!=null&&(t[n]=String(r));return t}hrTimeToISOString(e){let[t,n]=e;return new Date(t*1e3+n/1e6).toISOString()}selectAggregationTemporality(){return M.DELTA}};b(),Ie();var Fi=class{error(e,...t){S(Error(e)),x(`[3P telemetry] OTEL diag error: ${e}`,{level:`error`})}warn(e,...t){S(Error(e)),x(`[3P telemetry] OTEL diag warn: ${e}`,{level:`warn`})}info(e,...t){}debug(e,...t){}verbose(e,...t){}};p(),Ot(),ce(),_e(),Ye(),b(),Ce(),be(),gt(),ft();var Ii=6e4,Li=5e3,Ri=5e3,zi=class extends Error{};function Bi(e,t){return new Promise((n,r)=>{setTimeout((e,t)=>e(new zi(t)),e,r,t).unref()})}function Vi(){process.env.USER_TYPE===`ant`&&(process.env.ANT_OTEL_METRICS_EXPORTER&&(process.env.OTEL_METRICS_EXPORTER=process.env.ANT_OTEL_METRICS_EXPORTER),process.env.ANT_OTEL_LOGS_EXPORTER&&(process.env.OTEL_LOGS_EXPORTER=process.env.ANT_OTEL_LOGS_EXPORTER),process.env.ANT_OTEL_TRACES_EXPORTER&&(process.env.OTEL_TRACES_EXPORTER=process.env.ANT_OTEL_TRACES_EXPORTER),process.env.ANT_OTEL_EXPORTER_OTLP_PROTOCOL&&(process.env.OTEL_EXPORTER_OTLP_PROTOCOL=process.env.ANT_OTEL_EXPORTER_OTLP_PROTOCOL),process.env.ANT_OTEL_EXPORTER_OTLP_ENDPOINT&&(process.env.OTEL_EXPORTER_OTLP_ENDPOINT=process.env.ANT_OTEL_EXPORTER_OTLP_ENDPOINT),process.env.ANT_OTEL_EXPORTER_OTLP_HEADERS&&(process.env.OTEL_EXPORTER_OTLP_HEADERS=process.env.ANT_OTEL_EXPORTER_OTLP_HEADERS)),process.env.OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE||(process.env.OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE=`delta`)}function Hi(e){return(e||``).trim().split(`,`).filter(Boolean).map(e=>e.trim()).filter(e=>e!==`none`)}async function Ui(){let t=Hi(process.env.OTEL_METRICS_EXPORTER),n=parseInt(process.env.OTEL_METRIC_EXPORT_INTERVAL||Ii.toString(),10),r=[];for(let n of t)if(n===`console`){let e=new Jn,t=e.export.bind(e);e.export=(e,n)=>(e.resource&&e.resource.attributes&&(x(`
11
+ === Resource Attributes ===`),x(Se(e.resource.attributes)),x(`===========================
12
+ `)),t(e,n)),r.push(e)}else if(n===`otlp`){let t=process.env.OTEL_EXPORTER_OTLP_METRICS_PROTOCOL?.trim()||process.env.OTEL_EXPORTER_OTLP_PROTOCOL?.trim(),n=$i();switch(t){case`grpc`:{let{OTLPMetricExporter:t}=await import(`./src-PM8NIIu_.js`).then(t=>e(t.default,1));r.push(new t);break}case`http/json`:{let{OTLPMetricExporter:e}=await import(`./esm-IYgGg4wR.js`);r.push(new e(n));break}case`http/protobuf`:{let{OTLPMetricExporter:e}=await import(`./esm-BYnFh4pG.js`);r.push(new e(n));break}default:throw Error(`Unknown protocol set in OTEL_EXPORTER_OTLP_METRICS_PROTOCOL or OTEL_EXPORTER_OTLP_PROTOCOL env var: ${t}`)}}else if(n===`prometheus`){let{PrometheusExporter:t}=await import(`./src-CgZmCiiH.js`).then(t=>e(t.default,1));r.push(new t)}else throw Error(`Unknown exporter type set in OTEL_EXPORTER_OTLP_METRICS_PROTOCOL or OTEL_EXPORTER_OTLP_PROTOCOL env var: ${n}`);return r.map(e=>`export`in e?new qn({exporter:e,exportIntervalMillis:n}):e)}async function Wi(){let t=Hi(process.env.OTEL_LOGS_EXPORTER),n=process.env.OTEL_EXPORTER_OTLP_LOGS_PROTOCOL?.trim()||process.env.OTEL_EXPORTER_OTLP_PROTOCOL?.trim(),r=process.env.OTEL_EXPORTER_OTLP_ENDPOINT;x(`[3P telemetry] getOtlpLogExporters: types=${Se(t)}, protocol=${n}, endpoint=${r}`);let i=[];for(let r of t)if(r===`console`)i.push(new jt);else if(r===`otlp`){let t=$i();switch(n){case`grpc`:{let{OTLPLogExporter:t}=await import(`./src-DQOX_xI1.js`).then(t=>e(t.default,1));i.push(new t);break}case`http/json`:{let{OTLPLogExporter:e}=await import(`./esm-DklLYEuz.js`);i.push(new e(t));break}case`http/protobuf`:{let{OTLPLogExporter:e}=await import(`./esm-CXM9jqO_.js`);i.push(new e(t));break}default:throw Error(`Unknown protocol set in OTEL_EXPORTER_OTLP_LOGS_PROTOCOL or OTEL_EXPORTER_OTLP_PROTOCOL env var: ${n}`)}}else throw Error(`Unknown exporter type set in OTEL_LOGS_EXPORTER env var: ${r}`);return i}async function Gi(){let t=Hi(process.env.OTEL_TRACES_EXPORTER),n=[];for(let r of t)if(r===`console`)n.push(new yi);else if(r===`otlp`){let t=process.env.OTEL_EXPORTER_OTLP_TRACES_PROTOCOL?.trim()||process.env.OTEL_EXPORTER_OTLP_PROTOCOL?.trim(),r=$i();switch(t){case`grpc`:{let{OTLPTraceExporter:t}=await import(`./src-Dt5IJd3C.js`).then(t=>e(t.default,1));n.push(new t);break}case`http/json`:{let{OTLPTraceExporter:e}=await import(`./esm-DhRjocaU.js`);n.push(new e(r));break}case`http/protobuf`:{let{OTLPTraceExporter:e}=await import(`./esm-CXczu_-W.js`);n.push(new e(r));break}default:throw Error(`Unknown protocol set in OTEL_EXPORTER_OTLP_TRACES_PROTOCOL or OTEL_EXPORTER_OTLP_PROTOCOL env var: ${t}`)}}else throw Error(`Unknown exporter type set in OTEL_TRACES_EXPORTER env var: ${r}`);return n}function Ki(){return t(process.env.CLAUDE_CODE_ENABLE_TELEMETRY)}function qi(){return new qn({exporter:new Pi,exportIntervalMillis:300*1e3})}function Ji(){let e=Ke(),t=qe()&&(e===`enterprise`||e===`team`);return Ge()||t}async function Yi(e){let t=process.env.BETA_TRACING_ENDPOINT;if(!t)return;let[{OTLPTraceExporter:n},{OTLPLogExporter:r}]=await Promise.all([import(`./esm-DhRjocaU.js`),import(`./esm-DklLYEuz.js`)]),i={url:`${t}/v1/traces`},a={url:`${t}/v1/logs`},o=new Ti({resource:e,spanProcessors:[new Ei(new n(i),{scheduledDelayMillis:Ri})]});d.setGlobalTracerProvider(o),ve(o);let s=new Nt({resource:e,processors:[new Mt(new r(a),{scheduledDelayMillis:Li})]});v.setGlobalLoggerProvider(s),he(s),fe(v.getLogger(`com.anthropic.claude_code.events`,`0.0.1`)),process.on(`beforeExit`,async()=>{await s?.forceFlush(),await o?.forceFlush()}),process.on(`exit`,()=>{s?.forceFlush(),o?.forceFlush()})}async function Xi(){if(He(`telemetry_init_start`),Vi(),Te())for(let e of[`OTEL_METRICS_EXPORTER`,`OTEL_LOGS_EXPORTER`,`OTEL_TRACES_EXPORTER`]){let t=process.env[e];t?.includes(`console`)&&(process.env[e]=t.split(`,`).map(e=>e.trim()).filter(e=>e!==`console`).join(`,`))}m.setLogger(new Fi,o.ERROR),dt();let e=[],t=Ki();x(`[3P telemetry] isTelemetryEnabled=${t} (CLAUDE_CODE_ENABLE_TELEMETRY=${process.env.CLAUDE_CODE_ENABLE_TELEMETRY})`),t&&e.push(...await Ui()),Ji()&&e.push(qi());let n=Be(),r={[oe]:`claude-code`,[ie]:`0.0.1`};if(n===`wsl`){let e=ze();e&&(r[`wsl.version`]=e)}let i=O(r),a=O(Lt.detect().attributes||{}),s=kt.detect(),c=O(s.attributes?.[`host.arch`]?{[ae]:s.attributes[ae]}:{}),l=O(Pt.detect().attributes||{}),u=i.merge(a).merge(c).merge(l);if(ht()){Yi(u).catch(e=>x(`Beta tracing init failed: ${e}`,{level:`error`}));let t=new Hr({resource:u,views:[],readers:e});return pe(t),Ee(async()=>{let e=parseInt(process.env.CLAUDE_CODE_OTEL_SHUTDOWN_TIMEOUT_MS||`2000`,10);try{mt();let n=ge(),r=y(),i=[t.shutdown()];n&&i.push(n.forceFlush().then(()=>n.shutdown())),r&&i.push(r.forceFlush().then(()=>r.shutdown())),await Promise.race([Promise.all(i),Bi(e,`OpenTelemetry shutdown timeout`)])}catch{}}),t.getMeter(`com.anthropic.claude_code`,`0.0.1`)}let f=new Hr({resource:u,views:[],readers:e});if(pe(f),t){let e=await Wi();if(x(`[3P telemetry] Created ${e.length} log exporter(s)`),e.length>0){let t=new Nt({resource:u,processors:e.map(e=>new Mt(e,{scheduledDelayMillis:parseInt(process.env.OTEL_LOGS_EXPORT_INTERVAL||Li.toString(),10)}))});v.setGlobalLoggerProvider(t),he(t),fe(v.getLogger(`com.anthropic.claude_code.events`,`0.0.1`)),x(`[3P telemetry] Event logger set successfully`),process.on(`beforeExit`,async()=>{await t?.forceFlush(),await y()?.forceFlush()}),process.on(`exit`,()=>{t?.forceFlush(),y()?.forceFlush()})}}if(t&&pt()){let e=await Gi();if(e.length>0){let t=new Ti({resource:u,spanProcessors:e.map(e=>new Ei(e,{scheduledDelayMillis:parseInt(process.env.OTEL_TRACES_EXPORT_INTERVAL||Ri.toString(),10)}))});d.setGlobalTracerProvider(t),ve(t)}}return Ee(async()=>{let e=parseInt(process.env.CLAUDE_CODE_OTEL_SHUTDOWN_TIMEOUT_MS||`2000`,10);try{mt();let t=[f.shutdown()],n=ge();n&&t.push(n.shutdown());let r=y();r&&t.push(r.shutdown()),await Promise.race([Promise.all(t),Bi(e,`OpenTelemetry shutdown timeout`)])}catch(t){throw t instanceof Error&&t.message.includes(`timeout`)&&x(`
13
+ OpenTelemetry telemetry flush timed out after ${e}ms
14
+
15
+ To resolve this issue, you can:
16
+ 1. Increase the timeout by setting CLAUDE_CODE_OTEL_SHUTDOWN_TIMEOUT_MS env var (e.g., 5000 for 5 seconds)
17
+ 2. Check if your OpenTelemetry backend is experiencing scalability issues
18
+ 3. Disable OpenTelemetry by unsetting CLAUDE_CODE_ENABLE_TELEMETRY env var
19
+
20
+ Current timeout: ${e}ms
21
+ `,{level:`error`}),t}}),f.getMeter(`com.anthropic.claude_code`,`0.0.1`)}async function Zi(){let e=me();if(!e)return;let t=parseInt(process.env.CLAUDE_CODE_OTEL_FLUSH_TIMEOUT_MS||`5000`,10);try{let n=[e.forceFlush()],r=ge();r&&n.push(r.forceFlush());let i=y();i&&n.push(i.forceFlush()),await Promise.race([Promise.all(n),Bi(t,`OpenTelemetry flush timeout`)]),x(`Telemetry flushed successfully`)}catch(e){e instanceof zi?x(`Telemetry flush timed out after ${t}ms. Some metrics may not be exported.`,{level:`warn`}):x(`Telemetry flush failed: ${De(e)}`,{level:`error`})}}function Qi(){let e={},t=process.env.OTEL_EXPORTER_OTLP_HEADERS;if(t)for(let n of t.split(`,`)){let[t,...r]=n.split(`=`);t&&r.length>0&&(e[t.trim()]=r.join(`=`).trim())}return e}function $i(){let e=at(),t=ot(),n=Oe(),r={},i=Qi();n?.otelHeadersHelper?r.headers=async()=>{let e=Je();return{...i,...e}}:Object.keys(i).length>0&&(r.headers=async()=>i);let a=process.env.OTEL_EXPORTER_OTLP_ENDPOINT;if(!e||a&&st(a)){let e=tt();return(t||e)&&(r.httpAgentOptions={...t,...e&&{ca:e}}),r}let o=tt();return r.httpAgentOptions=n=>t||o?new lt(e,{...t&&{cert:t.cert,key:t.key,passphrase:t.passphrase},...o&&{ca:o}}):new lt(e),r}export{Zi as flushTelemetry,Xi as initializeTelemetry};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";function t(){return c||(c=new Intl.Segmenter(void 0,{granularity:`grapheme`})),c}function n(e){return e?t().segment(e)[Symbol.iterator]().next().value?.segment??``:``}function r(e){if(!e)return``;let n=``;for(let{segment:r}of t().segment(e))n=r;return n}function i(){return l||(l=new Intl.Segmenter(void 0,{granularity:`word`})),l}function a(e,t){let n=`${e}:${t}`,r=u.get(n);return r||(r=new Intl.RelativeTimeFormat(`en`,{style:e,numeric:t}),u.set(n,r)),r}function o(){return d||(d=Intl.DateTimeFormat().resolvedOptions().timeZone),d}function s(){if(f===null)try{let e=Intl.DateTimeFormat().resolvedOptions().locale;f=new Intl.Locale(e).language}catch{f=void 0}return f}var c,l,u,d,f,p=e((()=>{c=null,l=null,u=new Map,d=null,f=null}));export{o as a,r as c,s as i,t as n,i as o,a as r,p as s,n as t};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";var t,n=e((()=>{t=typeof global==`object`&&global&&global.Object===Object&&global})),r,i,a=e((()=>{n(),r=typeof self==`object`&&self&&self.Object===Object&&self,i=t||r||Function(`return this`)()})),o,s=e((()=>{a(),o=i.Symbol}));function c(e){var t=u.call(e,f),n=e[f];try{e[f]=void 0;var r=!0}catch{}var i=d.call(e);return r&&(t?e[f]=n:delete e[f]),i}var l,u,d,f,p=e((()=>{s(),l=Object.prototype,u=l.hasOwnProperty,d=l.toString,f=o?o.toStringTag:void 0}));function m(e){return h.call(e)}var h,g=e((()=>{h=Object.prototype.toString}));function _(e){return e==null?e===void 0?y:v:b&&b in Object(e)?c(e):m(e)}var v,y,b,x=e((()=>{s(),p(),g(),v=`[object Null]`,y=`[object Undefined]`,b=o?o.toStringTag:void 0}));function S(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}var C=e((()=>{}));export{o as a,i as c,x as i,t as l,S as n,s as o,_ as r,a as s,C as t,n as u};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{i as t,r as n}from"./isObject-C6qM3WEW.js";function r(e){return typeof e==`object`&&!!e}var i=e((()=>{}));function a(e){return typeof e==`symbol`||r(e)&&n(e)==o}var o,s=e((()=>{t(),i(),o=`[object Symbol]`}));export{r as i,a as n,i as r,s as t};
@@ -0,0 +1,2 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";async function t(e,t,n){let r=n?n.trim().split(/\s+/):[],i=r[0]||`list`,a=[],o=console.log,s=console.error;console.log=(...e)=>a.push(e.map(String).join(` `)),console.error=(...e)=>a.push(e.map(String).join(` `));try{let{templatesMain:e}=await import(`./templateJobs-CIv_ysje.js`);await e([i,...r.slice(1)])}finally{console.log=o,console.error=s}return e(a.join(`
2
+ `)||`Done.`,{display:`system`}),null}e((()=>{}))();export{t as call};
@@ -0,0 +1,8 @@
1
+ import{t as e}from"./rolldown-runtime-DaDcL9Zw.js";var t=e(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}})),n=e(((e,t)=>{(function(e){var n,r=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,i=Math.ceil,a=Math.floor,o=`[BigNumber Error] `,s=o+`Number primitive has more than 15 significant digits: `,c=0x5af3107a4000,l=14,u=9007199254740991,d=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,0xe8d4a51000,0x9184e72a000],f=1e7,p=1e9;function m(e){var t,n,S,C=L.prototype={constructor:L,toString:null,valueOf:null},w=new L(1),T=20,E=4,D=-7,O=21,k=-1e7,A=1e7,j=!1,M=1,N=0,P={prefix:``,groupSize:3,secondaryGroupSize:0,groupSeparator:`,`,decimalSeparator:`.`,fractionGroupSize:0,fractionGroupSeparator:`\xA0`,suffix:``},F=`0123456789abcdefghijklmnopqrstuvwxyz`,I=!0;function L(e,t){var i,o,c,d,f,p,m,h,g=this;if(!(g instanceof L))return new L(e,t);if(t==null){if(e&&e._isBigNumber===!0){g.s=e.s,!e.c||e.e>A?g.c=g.e=null:e.e<k?g.c=[g.e=0]:(g.e=e.e,g.c=e.c.slice());return}if((p=typeof e==`number`)&&e*0==0){if(g.s=1/e<0?(e=-e,-1):1,e===~~e){for(d=0,f=e;f>=10;f/=10,d++);d>A?g.c=g.e=null:(g.e=d,g.c=[e]);return}h=String(e)}else{if(!r.test(h=String(e)))return S(g,h,p);g.s=h.charCodeAt(0)==45?(h=h.slice(1),-1):1}(d=h.indexOf(`.`))>-1&&(h=h.replace(`.`,``)),(f=h.search(/e/i))>0?(d<0&&(d=f),d+=+h.slice(f+1),h=h.substring(0,f)):d<0&&(d=h.length)}else{if(v(t,2,F.length,`Base`),t==10&&I)return g=new L(e),V(g,T+g.e+1,E);if(h=String(e),p=typeof e==`number`){if(e*0!=0)return S(g,h,p,t);if(g.s=1/e<0?(h=h.slice(1),-1):1,L.DEBUG&&h.replace(/^0\.0*|\./,``).length>15)throw Error(s+e)}else g.s=h.charCodeAt(0)===45?(h=h.slice(1),-1):1;for(i=F.slice(0,t),d=f=0,m=h.length;f<m;f++)if(i.indexOf(o=h.charAt(f))<0){if(o==`.`){if(f>d){d=m;continue}}else if(!c&&(h==h.toUpperCase()&&(h=h.toLowerCase())||h==h.toLowerCase()&&(h=h.toUpperCase()))){c=!0,f=-1,d=0;continue}return S(g,String(e),p,t)}p=!1,h=n(h,t,10,g.s),(d=h.indexOf(`.`))>-1?h=h.replace(`.`,``):d=h.length}for(f=0;h.charCodeAt(f)===48;f++);for(m=h.length;h.charCodeAt(--m)===48;);if(h=h.slice(f,++m)){if(m-=f,p&&L.DEBUG&&m>15&&(e>u||e!==a(e)))throw Error(s+g.s*e);if((d=d-f-1)>A)g.c=g.e=null;else if(d<k)g.c=[g.e=0];else{if(g.e=d,g.c=[],f=(d+1)%l,d<0&&(f+=l),f<m){for(f&&g.c.push(+h.slice(0,f)),m-=l;f<m;)g.c.push(+h.slice(f,f+=l));f=l-(h=h.slice(f)).length}else f-=m;for(;f--;h+=`0`);g.c.push(+h)}}else g.c=[g.e=0]}L.clone=m,L.ROUND_UP=0,L.ROUND_DOWN=1,L.ROUND_CEIL=2,L.ROUND_FLOOR=3,L.ROUND_HALF_UP=4,L.ROUND_HALF_DOWN=5,L.ROUND_HALF_EVEN=6,L.ROUND_HALF_CEIL=7,L.ROUND_HALF_FLOOR=8,L.EUCLID=9,L.config=L.set=function(e){var t,n;if(e!=null)if(typeof e==`object`){if(e.hasOwnProperty(t=`DECIMAL_PLACES`)&&(n=e[t],v(n,0,p,t),T=n),e.hasOwnProperty(t=`ROUNDING_MODE`)&&(n=e[t],v(n,0,8,t),E=n),e.hasOwnProperty(t=`EXPONENTIAL_AT`)&&(n=e[t],n&&n.pop?(v(n[0],-p,0,t),v(n[1],0,p,t),D=n[0],O=n[1]):(v(n,-p,p,t),D=-(O=n<0?-n:n))),e.hasOwnProperty(t=`RANGE`))if(n=e[t],n&&n.pop)v(n[0],-p,-1,t),v(n[1],1,p,t),k=n[0],A=n[1];else if(v(n,-p,p,t),n)k=-(A=n<0?-n:n);else throw Error(o+t+` cannot be zero: `+n);if(e.hasOwnProperty(t=`CRYPTO`))if(n=e[t],n===!!n)if(n)if(typeof crypto<`u`&&crypto&&(crypto.getRandomValues||crypto.randomBytes))j=n;else throw j=!n,Error(o+`crypto unavailable`);else j=n;else throw Error(o+t+` not true or false: `+n);if(e.hasOwnProperty(t=`MODULO_MODE`)&&(n=e[t],v(n,0,9,t),M=n),e.hasOwnProperty(t=`POW_PRECISION`)&&(n=e[t],v(n,0,p,t),N=n),e.hasOwnProperty(t=`FORMAT`))if(n=e[t],typeof n==`object`)P=n;else throw Error(o+t+` not an object: `+n);if(e.hasOwnProperty(t=`ALPHABET`))if(n=e[t],typeof n==`string`&&!/^.?$|[+\-.\s]|(.).*\1/.test(n))I=n.slice(0,10)==`0123456789`,F=n;else throw Error(o+t+` invalid: `+n)}else throw Error(o+`Object expected: `+e);return{DECIMAL_PLACES:T,ROUNDING_MODE:E,EXPONENTIAL_AT:[D,O],RANGE:[k,A],CRYPTO:j,MODULO_MODE:M,POW_PRECISION:N,FORMAT:P,ALPHABET:F}},L.isBigNumber=function(e){if(!e||e._isBigNumber!==!0)return!1;if(!L.DEBUG)return!0;var t,n,r=e.c,i=e.e,s=e.s;out:if({}.toString.call(r)==`[object Array]`){if((s===1||s===-1)&&i>=-p&&i<=p&&i===a(i)){if(r[0]===0){if(i===0&&r.length===1)return!0;break out}if(t=(i+1)%l,t<1&&(t+=l),String(r[0]).length==t){for(t=0;t<r.length;t++)if(n=r[t],n<0||n>=c||n!==a(n))break out;if(n!==0)return!0}}}else if(r===null&&i===null&&(s===null||s===1||s===-1))return!0;throw Error(o+`Invalid BigNumber: `+e)},L.maximum=L.max=function(){return z(arguments,-1)},L.minimum=L.min=function(){return z(arguments,1)},L.random=(function(){var e=9007199254740992,t=Math.random()*e&2097151?function(){return a(Math.random()*e)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(e){var n,r,s,c,u,f=0,m=[],h=new L(w);if(e==null?e=T:v(e,0,p),c=i(e/l),j)if(crypto.getRandomValues){for(n=crypto.getRandomValues(new Uint32Array(c*=2));f<c;)u=n[f]*131072+(n[f+1]>>>11),u>=9e15?(r=crypto.getRandomValues(new Uint32Array(2)),n[f]=r[0],n[f+1]=r[1]):(m.push(u%0x5af3107a4000),f+=2);f=c/2}else if(crypto.randomBytes){for(n=crypto.randomBytes(c*=7);f<c;)u=(n[f]&31)*281474976710656+n[f+1]*1099511627776+n[f+2]*4294967296+n[f+3]*16777216+(n[f+4]<<16)+(n[f+5]<<8)+n[f+6],u>=9e15?crypto.randomBytes(7).copy(n,f):(m.push(u%0x5af3107a4000),f+=7);f=c/7}else throw j=!1,Error(o+`crypto unavailable`);if(!j)for(;f<c;)u=t(),u<9e15&&(m[f++]=u%0x5af3107a4000);for(c=m[--f],e%=l,c&&e&&(u=d[l-e],m[f]=a(c/u)*u);m[f]===0;m.pop(),f--);if(f<0)m=[s=0];else{for(s=-1;m[0]===0;m.splice(0,1),s-=l);for(f=1,u=m[0];u>=10;u/=10,f++);f<l&&(s-=l-f)}return h.e=s,h.c=m,h}})(),L.sum=function(){for(var e=1,t=arguments,n=new L(t[0]);e<t.length;)n=n.plus(t[e++]);return n},n=(function(){var e=`0123456789`;function n(e,t,n,r){for(var i,a=[0],o,s=0,c=e.length;s<c;){for(o=a.length;o--;a[o]*=t);for(a[0]+=r.indexOf(e.charAt(s++)),i=0;i<a.length;i++)a[i]>n-1&&(a[i+1]??(a[i+1]=0),a[i+1]+=a[i]/n|0,a[i]%=n)}return a.reverse()}return function(r,i,a,o,s){var c,l,u,d,f,p,m,h,_=r.indexOf(`.`),v=T,y=E;for(_>=0&&(d=N,N=0,r=r.replace(`.`,``),h=new L(i),p=h.pow(r.length-_),N=d,h.c=n(x(g(p.c),p.e,`0`),10,a,e),h.e=h.c.length),m=n(r,i,a,s?(c=F,e):(c=e,F)),u=d=m.length;m[--d]==0;m.pop());if(!m[0])return c.charAt(0);if(_<0?--u:(p.c=m,p.e=u,p.s=o,p=t(p,h,v,y,a),m=p.c,f=p.r,u=p.e),l=u+v+1,_=m[l],d=a/2,f=f||l<0||m[l+1]!=null,f=y<4?(_!=null||f)&&(y==0||y==(p.s<0?3:2)):_>d||_==d&&(y==4||f||y==6&&m[l-1]&1||y==(p.s<0?8:7)),l<1||!m[0])r=f?x(c.charAt(1),-v,c.charAt(0)):c.charAt(0);else{if(m.length=l,f)for(--a;++m[--l]>a;)m[l]=0,l||(++u,m=[1].concat(m));for(d=m.length;!m[--d];);for(_=0,r=``;_<=d;r+=c.charAt(m[_++]));r=x(r,u,c.charAt(0))}return r}})(),t=(function(){function e(e,t,n){var r,i,a,o,s=0,c=e.length,l=t%f,u=t/f|0;for(e=e.slice();c--;)a=e[c]%f,o=e[c]/f|0,r=u*a+o*l,i=l*a+r%f*f+s,s=(i/n|0)+(r/f|0)+u*o,e[c]=i%n;return s&&(e=[s].concat(e)),e}function t(e,t,n,r){var i,a;if(n!=r)a=n>r?1:-1;else for(i=a=0;i<n;i++)if(e[i]!=t[i]){a=e[i]>t[i]?1:-1;break}return a}function n(e,t,n,r){for(var i=0;n--;)e[n]-=i,i=+(e[n]<t[n]),e[n]=i*r+e[n]-t[n];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(r,i,o,s,u){var d,f,p,m,g,_,v,y,b,x,S,C,w,T,E,D,O,k=r.s==i.s?1:-1,A=r.c,j=i.c;if(!A||!A[0]||!j||!j[0])return new L(!r.s||!i.s||(A?j&&A[0]==j[0]:!j)?NaN:A&&A[0]==0||!j?k*0:k/0);for(y=new L(k),b=y.c=[],f=r.e-i.e,k=o+f+1,u||(u=c,f=h(r.e/l)-h(i.e/l),k=k/l|0),p=0;j[p]==(A[p]||0);p++);if(j[p]>(A[p]||0)&&f--,k<0)b.push(1),m=!0;else{for(T=A.length,D=j.length,p=0,k+=2,g=a(u/(j[0]+1)),g>1&&(j=e(j,g,u),A=e(A,g,u),D=j.length,T=A.length),w=D,x=A.slice(0,D),S=x.length;S<D;x[S++]=0);O=j.slice(),O=[0].concat(O),E=j[0],j[1]>=u/2&&E++;do{if(g=0,d=t(j,x,D,S),d<0){if(C=x[0],D!=S&&(C=C*u+(x[1]||0)),g=a(C/E),g>1)for(g>=u&&(g=u-1),_=e(j,g,u),v=_.length,S=x.length;t(_,x,v,S)==1;)g--,n(_,D<v?O:j,v,u),v=_.length,d=1;else g==0&&(d=g=1),_=j.slice(),v=_.length;if(v<S&&(_=[0].concat(_)),n(x,_,S,u),S=x.length,d==-1)for(;t(j,x,D,S)<1;)g++,n(x,D<S?O:j,S,u),S=x.length}else d===0&&(g++,x=[0]);b[p++]=g,x[0]?x[S++]=A[w]||0:(x=[A[w]],S=1)}while((w++<T||x[0]!=null)&&k--);m=x[0]!=null,b[0]||b.splice(0,1)}if(u==c){for(p=1,k=b[0];k>=10;k/=10,p++);V(y,o+(y.e=p+f*l-1)+1,s,m)}else y.e=f,y.r=+m;return y}})();function R(e,t,n,r){var i,a,o,s,c;if(n==null?n=E:v(n,0,8),!e.c)return e.toString();if(i=e.c[0],o=e.e,t==null)c=g(e.c),c=r==1||r==2&&(o<=D||o>=O)?b(c,o):x(c,o,`0`);else if(e=V(new L(e),t,n),a=e.e,c=g(e.c),s=c.length,r==1||r==2&&(t<=a||a<=D)){for(;s<t;c+=`0`,s++);c=b(c,a)}else if(t-=o+(r===2&&a>o),c=x(c,a,`0`),a+1>s){if(--t>0)for(c+=`.`;t--;c+=`0`);}else if(t+=a-s,t>0)for(a+1==s&&(c+=`.`);t--;c+=`0`);return e.s<0&&i?`-`+c:c}function z(e,t){for(var n,r,i=1,a=new L(e[0]);i<e.length;i++)r=new L(e[i]),(!r.s||(n=_(a,r))===t||n===0&&a.s===t)&&(a=r);return a}function B(e,t,n){for(var r=1,i=t.length;!t[--i];t.pop());for(i=t[0];i>=10;i/=10,r++);return(n=r+n*l-1)>A?e.c=e.e=null:n<k?e.c=[e.e=0]:(e.e=n,e.c=t),e}S=(function(){var e=/^(-?)0([xbo])(?=\w[\w.]*$)/i,t=/^([^.]+)\.$/,n=/^\.([^.]+)$/,r=/^-?(Infinity|NaN)$/,i=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(a,s,c,l){var u,d=c?s:s.replace(i,``);if(r.test(d))a.s=isNaN(d)?null:d<0?-1:1;else{if(!c&&(d=d.replace(e,function(e,t,n){return u=(n=n.toLowerCase())==`x`?16:n==`b`?2:8,!l||l==u?t:e}),l&&(u=l,d=d.replace(t,`$1`).replace(n,`0.$1`)),s!=d))return new L(d,u);if(L.DEBUG)throw Error(o+`Not a`+(l?` base `+l:``)+` number: `+s);a.s=null}a.c=a.e=null}})();function V(e,t,n,r){var o,s,u,f,p,m,h,g=e.c,_=d;if(g){out:{for(o=1,f=g[0];f>=10;f/=10,o++);if(s=t-o,s<0)s+=l,u=t,p=g[m=0],h=a(p/_[o-u-1]%10);else if(m=i((s+1)/l),m>=g.length)if(r){for(;g.length<=m;g.push(0));p=h=0,o=1,s%=l,u=s-l+1}else break out;else{for(p=f=g[m],o=1;f>=10;f/=10,o++);s%=l,u=s-l+o,h=u<0?0:a(p/_[o-u-1]%10)}if(r=r||t<0||g[m+1]!=null||(u<0?p:p%_[o-u-1]),r=n<4?(h||r)&&(n==0||n==(e.s<0?3:2)):h>5||h==5&&(n==4||r||n==6&&(s>0?u>0?p/_[o-u]:0:g[m-1])%10&1||n==(e.s<0?8:7)),t<1||!g[0])return g.length=0,r?(t-=e.e+1,g[0]=_[(l-t%l)%l],e.e=-t||0):g[0]=e.e=0,e;if(s==0?(g.length=m,f=1,m--):(g.length=m+1,f=_[l-s],g[m]=u>0?a(p/_[o-u]%_[u])*f:0),r)for(;;)if(m==0){for(s=1,u=g[0];u>=10;u/=10,s++);for(u=g[0]+=f,f=1;u>=10;u/=10,f++);s!=f&&(e.e++,g[0]==c&&(g[0]=1));break}else{if(g[m]+=f,g[m]!=c)break;g[m--]=0,f=1}for(s=g.length;g[--s]===0;g.pop());}e.e>A?e.c=e.e=null:e.e<k&&(e.c=[e.e=0])}return e}function H(e){var t,n=e.e;return n===null?e.toString():(t=g(e.c),t=n<=D||n>=O?b(t,n):x(t,n,`0`),e.s<0?`-`+t:t)}return C.absoluteValue=C.abs=function(){var e=new L(this);return e.s<0&&(e.s=1),e},C.comparedTo=function(e,t){return _(this,new L(e,t))},C.decimalPlaces=C.dp=function(e,t){var n,r,i,a=this;if(e!=null)return v(e,0,p),t==null?t=E:v(t,0,8),V(new L(a),e+a.e+1,t);if(!(n=a.c))return null;if(r=((i=n.length-1)-h(this.e/l))*l,i=n[i])for(;i%10==0;i/=10,r--);return r<0&&(r=0),r},C.dividedBy=C.div=function(e,n){return t(this,new L(e,n),T,E)},C.dividedToIntegerBy=C.idiv=function(e,n){return t(this,new L(e,n),0,1)},C.exponentiatedBy=C.pow=function(e,t){var n,r,s,c,u,d,f,p,m,h=this;if(e=new L(e),e.c&&!e.isInteger())throw Error(o+`Exponent not an integer: `+H(e));if(t!=null&&(t=new L(t)),d=e.e>14,!h.c||!h.c[0]||h.c[0]==1&&!h.e&&h.c.length==1||!e.c||!e.c[0])return m=new L(H(h)**(d?e.s*(2-y(e)):+H(e))),t?m.mod(t):m;if(f=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new L(NaN);r=!f&&h.isInteger()&&t.isInteger(),r&&(h=h.mod(t))}else if(e.e>9&&(h.e>0||h.e<-1||(h.e==0?h.c[0]>1||d&&h.c[1]>=24e7:h.c[0]<8e13||d&&h.c[0]<=9999975e7)))return c=h.s<0&&y(e)?-0:0,h.e>-1&&(c=1/c),new L(f?1/c:c);else N&&(c=i(N/l+2));for(d?(n=new L(.5),f&&(e.s=1),p=y(e)):(s=Math.abs(+H(e)),p=s%2),m=new L(w);;){if(p){if(m=m.times(h),!m.c)break;c?m.c.length>c&&(m.c.length=c):r&&(m=m.mod(t))}if(s){if(s=a(s/2),s===0)break;p=s%2}else if(e=e.times(n),V(e,e.e+1,1),e.e>14)p=y(e);else{if(s=+H(e),s===0)break;p=s%2}h=h.times(h),c?h.c&&h.c.length>c&&(h.c.length=c):r&&(h=h.mod(t))}return r?m:(f&&(m=w.div(m)),t?m.mod(t):c?V(m,N,E,u):m)},C.integerValue=function(e){var t=new L(this);return e==null?e=E:v(e,0,8),V(t,t.e+1,e)},C.isEqualTo=C.eq=function(e,t){return _(this,new L(e,t))===0},C.isFinite=function(){return!!this.c},C.isGreaterThan=C.gt=function(e,t){return _(this,new L(e,t))>0},C.isGreaterThanOrEqualTo=C.gte=function(e,t){return(t=_(this,new L(e,t)))===1||t===0},C.isInteger=function(){return!!this.c&&h(this.e/l)>this.c.length-2},C.isLessThan=C.lt=function(e,t){return _(this,new L(e,t))<0},C.isLessThanOrEqualTo=C.lte=function(e,t){return(t=_(this,new L(e,t)))===-1||t===0},C.isNaN=function(){return!this.s},C.isNegative=function(){return this.s<0},C.isPositive=function(){return this.s>0},C.isZero=function(){return!!this.c&&this.c[0]==0},C.minus=function(e,t){var n,r,i,a,o=this,s=o.s;if(e=new L(e,t),t=e.s,!s||!t)return new L(NaN);if(s!=t)return e.s=-t,o.plus(e);var u=o.e/l,d=e.e/l,f=o.c,p=e.c;if(!u||!d){if(!f||!p)return f?(e.s=-t,e):new L(p?o:NaN);if(!f[0]||!p[0])return p[0]?(e.s=-t,e):new L(f[0]?o:E==3?-0:0)}if(u=h(u),d=h(d),f=f.slice(),s=u-d){for((a=s<0)?(s=-s,i=f):(d=u,i=p),i.reverse(),t=s;t--;i.push(0));i.reverse()}else for(r=(a=(s=f.length)<(t=p.length))?s:t,s=t=0;t<r;t++)if(f[t]!=p[t]){a=f[t]<p[t];break}if(a&&(i=f,f=p,p=i,e.s=-e.s),t=(r=p.length)-(n=f.length),t>0)for(;t--;f[n++]=0);for(t=c-1;r>s;){if(f[--r]<p[r]){for(n=r;n&&!f[--n];f[n]=t);--f[n],f[r]+=c}f[r]-=p[r]}for(;f[0]==0;f.splice(0,1),--d);return f[0]?B(e,f,d):(e.s=E==3?-1:1,e.c=[e.e=0],e)},C.modulo=C.mod=function(e,n){var r,i,a=this;return e=new L(e,n),!a.c||!e.s||e.c&&!e.c[0]?new L(NaN):!e.c||a.c&&!a.c[0]?new L(a):(M==9?(i=e.s,e.s=1,r=t(a,e,0,3),e.s=i,r.s*=i):r=t(a,e,0,M),e=a.minus(r.times(e)),!e.c[0]&&M==1&&(e.s=a.s),e)},C.multipliedBy=C.times=function(e,t){var n,r,i,a,o,s,u,d,p,m,g,_,v,y,b,x=this,S=x.c,C=(e=new L(e,t)).c;if(!S||!C||!S[0]||!C[0])return!x.s||!e.s||S&&!S[0]&&!C||C&&!C[0]&&!S?e.c=e.e=e.s=null:(e.s*=x.s,!S||!C?e.c=e.e=null:(e.c=[0],e.e=0)),e;for(r=h(x.e/l)+h(e.e/l),e.s*=x.s,u=S.length,m=C.length,u<m&&(v=S,S=C,C=v,i=u,u=m,m=i),i=u+m,v=[];i--;v.push(0));for(y=c,b=f,i=m;--i>=0;){for(n=0,g=C[i]%b,_=C[i]/b|0,o=u,a=i+o;a>i;)d=S[--o]%b,p=S[o]/b|0,s=_*d+p*g,d=g*d+s%b*b+v[a]+n,n=(d/y|0)+(s/b|0)+_*p,v[a--]=d%y;v[a]=n}return n?++r:v.splice(0,1),B(e,v,r)},C.negated=function(){var e=new L(this);return e.s=-e.s||null,e},C.plus=function(e,t){var n,r=this,i=r.s;if(e=new L(e,t),t=e.s,!i||!t)return new L(NaN);if(i!=t)return e.s=-t,r.minus(e);var a=r.e/l,o=e.e/l,s=r.c,u=e.c;if(!a||!o){if(!s||!u)return new L(i/0);if(!s[0]||!u[0])return u[0]?e:new L(s[0]?r:i*0)}if(a=h(a),o=h(o),s=s.slice(),i=a-o){for(i>0?(o=a,n=u):(i=-i,n=s),n.reverse();i--;n.push(0));n.reverse()}for(i=s.length,t=u.length,i-t<0&&(n=u,u=s,s=n,t=i),i=0;t;)i=(s[--t]=s[t]+u[t]+i)/c|0,s[t]=c===s[t]?0:s[t]%c;return i&&(s=[i].concat(s),++o),B(e,s,o)},C.precision=C.sd=function(e,t){var n,r,i,a=this;if(e!=null&&e!==!!e)return v(e,1,p),t==null?t=E:v(t,0,8),V(new L(a),e,t);if(!(n=a.c))return null;if(i=n.length-1,r=i*l+1,i=n[i]){for(;i%10==0;i/=10,r--);for(i=n[0];i>=10;i/=10,r++);}return e&&a.e+1>r&&(r=a.e+1),r},C.shiftedBy=function(e){return v(e,-u,u),this.times(`1e`+e)},C.squareRoot=C.sqrt=function(){var e,n,r,i,a,o=this,s=o.c,c=o.s,l=o.e,u=T+4,d=new L(`0.5`);if(c!==1||!s||!s[0])return new L(!c||c<0&&(!s||s[0])?NaN:s?o:1/0);if(c=Math.sqrt(+H(o)),c==0||c==1/0?(n=g(s),(n.length+l)%2==0&&(n+=`0`),c=Math.sqrt(+n),l=h((l+1)/2)-(l<0||l%2),c==1/0?n=`5e`+l:(n=c.toExponential(),n=n.slice(0,n.indexOf(`e`)+1)+l),r=new L(n)):r=new L(c+``),r.c[0]){for(l=r.e,c=l+u,c<3&&(c=0);;)if(a=r,r=d.times(a.plus(t(o,a,u,1))),g(a.c).slice(0,c)===(n=g(r.c)).slice(0,c))if(r.e<l&&--c,n=n.slice(c-3,c+1),n==`9999`||!i&&n==`4999`){if(!i&&(V(a,a.e+T+2,0),a.times(a).eq(o))){r=a;break}u+=4,c+=4,i=1}else{(!+n||!+n.slice(1)&&n.charAt(0)==`5`)&&(V(r,r.e+T+2,1),e=!r.times(r).eq(o));break}}return V(r,r.e+T+1,E,e)},C.toExponential=function(e,t){return e!=null&&(v(e,0,p),e++),R(this,e,t,1)},C.toFixed=function(e,t){return e!=null&&(v(e,0,p),e=e+this.e+1),R(this,e,t)},C.toFormat=function(e,t,n){var r,i=this;if(n==null)e!=null&&t&&typeof t==`object`?(n=t,t=null):e&&typeof e==`object`?(n=e,e=t=null):n=P;else if(typeof n!=`object`)throw Error(o+`Argument not an object: `+n);if(r=i.toFixed(e,t),i.c){var a,s=r.split(`.`),c=+n.groupSize,l=+n.secondaryGroupSize,u=n.groupSeparator||``,d=s[0],f=s[1],p=i.s<0,m=p?d.slice(1):d,h=m.length;if(l&&(a=c,c=l,l=a,h-=a),c>0&&h>0){for(a=h%c||c,d=m.substr(0,a);a<h;a+=c)d+=u+m.substr(a,c);l>0&&(d+=u+m.slice(a)),p&&(d=`-`+d)}r=f?d+(n.decimalSeparator||``)+((l=+n.fractionGroupSize)?f.replace(RegExp(`\\d{`+l+`}\\B`,`g`),`$&`+(n.fractionGroupSeparator||``)):f):d}return(n.prefix||``)+r+(n.suffix||``)},C.toFraction=function(e){var n,r,i,a,s,c,u,f,p,m,h,_,v=this,y=v.c;if(e!=null&&(u=new L(e),!u.isInteger()&&(u.c||u.s!==1)||u.lt(w)))throw Error(o+`Argument `+(u.isInteger()?`out of range: `:`not an integer: `)+H(u));if(!y)return new L(v);for(n=new L(w),p=r=new L(w),i=f=new L(w),_=g(y),s=n.e=_.length-v.e-1,n.c[0]=d[(c=s%l)<0?l+c:c],e=!e||u.comparedTo(n)>0?s>0?n:p:u,c=A,A=1/0,u=new L(_),f.c[0]=0;m=t(u,n,0,1),a=r.plus(m.times(i)),a.comparedTo(e)!=1;)r=i,i=a,p=f.plus(m.times(a=p)),f=a,n=u.minus(m.times(a=n)),u=a;return a=t(e.minus(r),i,0,1),f=f.plus(a.times(p)),r=r.plus(a.times(i)),f.s=p.s=v.s,s*=2,h=t(p,i,s,E).minus(v).abs().comparedTo(t(f,r,s,E).minus(v).abs())<1?[p,i]:[f,r],A=c,h},C.toNumber=function(){return+H(this)},C.toPrecision=function(e,t){return e!=null&&v(e,1,p),R(this,e,t,2)},C.toString=function(e){var t,r=this,i=r.s,a=r.e;return a===null?i?(t=`Infinity`,i<0&&(t=`-`+t)):t=`NaN`:(e==null?t=a<=D||a>=O?b(g(r.c),a):x(g(r.c),a,`0`):e===10&&I?(r=V(new L(r),T+a+1,E),t=x(g(r.c),r.e,`0`)):(v(e,2,F.length,`Base`),t=n(x(g(r.c),a,`0`),10,e,i,!0)),i<0&&r.c[0]&&(t=`-`+t)),t},C.valueOf=C.toJSON=function(){return H(this)},C._isBigNumber=!0,e!=null&&L.set(e),L}function h(e){var t=e|0;return e>0||e===t?t:t-1}function g(e){for(var t,n,r=1,i=e.length,a=e[0]+``;r<i;){for(t=e[r++]+``,n=l-t.length;n--;t=`0`+t);a+=t}for(i=a.length;a.charCodeAt(--i)===48;);return a.slice(0,i+1||1)}function _(e,t){var n,r,i=e.c,a=t.c,o=e.s,s=t.s,c=e.e,l=t.e;if(!o||!s)return null;if(n=i&&!i[0],r=a&&!a[0],n||r)return n?r?0:-s:o;if(o!=s)return o;if(n=o<0,r=c==l,!i||!a)return r?0:!i^n?1:-1;if(!r)return c>l^n?1:-1;for(s=(c=i.length)<(l=a.length)?c:l,o=0;o<s;o++)if(i[o]!=a[o])return i[o]>a[o]^n?1:-1;return c==l?0:c>l^n?1:-1}function v(e,t,n,r){if(e<t||e>n||e!==a(e))throw Error(o+(r||`Argument`)+(typeof e==`number`?e<t||e>n?` out of range: `:` not an integer: `:` not a primitive number: `)+String(e))}function y(e){var t=e.c.length-1;return h(e.e/l)==t&&e.c[t]%2!=0}function b(e,t){return(e.length>1?e.charAt(0)+`.`+e.slice(1):e)+(t<0?`e`:`e+`)+t}function x(e,t,n){var r,i;if(t<0){for(i=n+`.`;++t;i+=n);e=i+e}else if(r=e.length,++t>r){for(i=n,t-=r;--t;i+=n);e+=i}else t<r&&(e=e.slice(0,t)+`.`+e.slice(t));return e}n=m(),n.default=n.BigNumber=n,typeof define==`function`&&define.amd?define(function(){return n}):t!==void 0&&t.exports?t.exports=n:(e||(e=typeof self<`u`&&self?self:window),e.BigNumber=n)})(e)})),r=e(((e,t)=>{var r=n(),i=t.exports;(function(){var e=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,t,n,a={"\b":`\\b`," ":`\\t`,"\n":`\\n`,"\f":`\\f`,"\r":`\\r`,'"':`\\"`,"\\":`\\\\`},o;function s(t){return e.lastIndex=0,e.test(t)?`"`+t.replace(e,function(e){var t=a[e];return typeof t==`string`?t:`\\u`+(`0000`+e.charCodeAt(0).toString(16)).slice(-4)})+`"`:`"`+t+`"`}function c(e,i){var a,l,u,d,f=t,p,m=i[e],h=m!=null&&(m instanceof r||r.isBigNumber(m));switch(m&&typeof m==`object`&&typeof m.toJSON==`function`&&(m=m.toJSON(e)),typeof o==`function`&&(m=o.call(i,e,m)),typeof m){case`string`:return h?m:s(m);case`number`:return isFinite(m)?String(m):`null`;case`boolean`:case`null`:case`bigint`:return String(m);case`object`:if(!m)return`null`;if(t+=n,p=[],Object.prototype.toString.apply(m)===`[object Array]`){for(d=m.length,a=0;a<d;a+=1)p[a]=c(a,m)||`null`;return u=p.length===0?`[]`:t?`[
2
+ `+t+p.join(`,
3
+ `+t)+`
4
+ `+f+`]`:`[`+p.join(`,`)+`]`,t=f,u}if(o&&typeof o==`object`)for(d=o.length,a=0;a<d;a+=1)typeof o[a]==`string`&&(l=o[a],u=c(l,m),u&&p.push(s(l)+(t?`: `:`:`)+u));else Object.keys(m).forEach(function(e){var n=c(e,m);n&&p.push(s(e)+(t?`: `:`:`)+n)});return u=p.length===0?`{}`:t?`{
5
+ `+t+p.join(`,
6
+ `+t)+`
7
+ `+f+`}`:`{`+p.join(`,`)+`}`,t=f,u}}typeof i.stringify!=`function`&&(i.stringify=function(e,r,i){var a;if(t=``,n=``,typeof i==`number`)for(a=0;a<i;a+=1)n+=` `;else typeof i==`string`&&(n=i);if(o=r,r&&typeof r!=`function`&&(typeof r!=`object`||typeof r.length!=`number`))throw Error(`JSON.stringify`);return c(``,{"":e})})})()})),i=e(((e,t)=>{var r=null,i=/(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])/,a=/(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)/;t.exports=function(e){var t={strict:!1,storeAsString:!1,alwaysParseAsBig:!1,useNativeBigInt:!1,protoAction:`error`,constructorAction:`error`};if(e!=null){if(e.strict===!0&&(t.strict=!0),e.storeAsString===!0&&(t.storeAsString=!0),t.alwaysParseAsBig=e.alwaysParseAsBig===!0&&e.alwaysParseAsBig,t.useNativeBigInt=e.useNativeBigInt===!0&&e.useNativeBigInt,e.constructorAction!==void 0)if(e.constructorAction===`error`||e.constructorAction===`ignore`||e.constructorAction===`preserve`)t.constructorAction=e.constructorAction;else throw Error(`Incorrect value for constructorAction option, must be "error", "ignore" or undefined but passed ${e.constructorAction}`);if(e.protoAction!==void 0)if(e.protoAction===`error`||e.protoAction===`ignore`||e.protoAction===`preserve`)t.protoAction=e.protoAction;else throw Error(`Incorrect value for protoAction option, must be "error", "ignore" or undefined but passed ${e.protoAction}`)}var o,s,c={'"':`"`,"\\":`\\`,"/":`/`,b:`\b`,f:`\f`,n:`
8
+ `,r:`\r`,t:` `},l,u=function(e){throw{name:`SyntaxError`,message:e,at:o,text:l}},d=function(e){return e&&e!==s&&u(`Expected '`+e+`' instead of '`+s+`'`),s=l.charAt(o),o+=1,s},f=function(){var e,i=``;for(s===`-`&&(i=`-`,d(`-`));s>=`0`&&s<=`9`;)i+=s,d();if(s===`.`)for(i+=`.`;d()&&s>=`0`&&s<=`9`;)i+=s;if(s===`e`||s===`E`)for(i+=s,d(),(s===`-`||s===`+`)&&(i+=s,d());s>=`0`&&s<=`9`;)i+=s,d();if(e=+i,!isFinite(e))u(`Bad number`);else return r??(r=n()),i.length>15?t.storeAsString?i:t.useNativeBigInt?BigInt(i):new r(i):t.alwaysParseAsBig?t.useNativeBigInt?BigInt(e):new r(e):e},p=function(){var e,t,n=``,r;if(s===`"`)for(var i=o;d();){if(s===`"`)return o-1>i&&(n+=l.substring(i,o-1)),d(),n;if(s===`\\`){if(o-1>i&&(n+=l.substring(i,o-1)),d(),s===`u`){for(r=0,t=0;t<4&&(e=parseInt(d(),16),isFinite(e));t+=1)r=r*16+e;n+=String.fromCharCode(r)}else if(typeof c[s]==`string`)n+=c[s];else break;i=o}}u(`Bad string`)},m=function(){for(;s&&s<=` `;)d()},h=function(){switch(s){case`t`:return d(`t`),d(`r`),d(`u`),d(`e`),!0;case`f`:return d(`f`),d(`a`),d(`l`),d(`s`),d(`e`),!1;case`n`:return d(`n`),d(`u`),d(`l`),d(`l`),null}u(`Unexpected '`+s+`'`)},g,_=function(){var e=[];if(s===`[`){if(d(`[`),m(),s===`]`)return d(`]`),e;for(;s;){if(e.push(g()),m(),s===`]`)return d(`]`),e;d(`,`),m()}}u(`Bad array`)},v=function(){var e,n=Object.create(null);if(s===`{`){if(d(`{`),m(),s===`}`)return d(`}`),n;for(;s;){if(e=p(),m(),d(`:`),t.strict===!0&&Object.hasOwnProperty.call(n,e)&&u(`Duplicate key "`+e+`"`),i.test(e)===!0?t.protoAction===`error`?u(`Object contains forbidden prototype property`):t.protoAction===`ignore`?g():n[e]=g():a.test(e)===!0?t.constructorAction===`error`?u(`Object contains forbidden constructor property`):t.constructorAction===`ignore`?g():n[e]=g():n[e]=g(),m(),s===`}`)return d(`}`),n;d(`,`),m()}}u(`Bad object`)};return g=function(){switch(m(),s){case`{`:return v();case`[`:return _();case`"`:return p();case`-`:return f();default:return s>=`0`&&s<=`9`?f():h()}},function(e,t){var n;return l=e+``,o=0,s=` `,n=g(),m(),s&&u(`Syntax error`),typeof t==`function`?(function e(n,r){var i,a=n[r];return a&&typeof a==`object`&&Object.keys(a).forEach(function(t){i=e(a,t),i===void 0?delete a[t]:a[t]=i}),t.call(n,r,a)})({"":n},``):n}}})),a=e(((e,t)=>{var n=r().stringify,a=i();t.exports=function(e){return{parse:a(e),stringify:n}},t.exports.parse=a(),t.exports.stringify=n}));export{t as n,a as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./rolldown-runtime-DaDcL9Zw.js";var t=e((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),n=e(((e,n)=>{n.exports=t()}));export{n as t};
@@ -0,0 +1,3 @@
1
+ import{i as e,t}from"./rolldown-runtime-DaDcL9Zw.js";var n=t(((t,n)=>{var r=e(`buffer`),i=r.Buffer;function a(e,t){for(var n in e)t[n]=e[n]}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?n.exports=r:(a(r,t),t.Buffer=o);function o(e,t,n){return i(e,t,n)}o.prototype=Object.create(i.prototype),a(i,o),o.from=function(e,t,n){if(typeof e==`number`)throw TypeError(`Argument must not be a number`);return i(e,t,n)},o.alloc=function(e,t,n){if(typeof e!=`number`)throw TypeError(`Argument must be a number`);var r=i(e);return t===void 0?r.fill(0):typeof n==`string`?r.fill(t,n):r.fill(t),r},o.allocUnsafe=function(e){if(typeof e!=`number`)throw TypeError(`Argument must be a number`);return i(e)},o.allocUnsafeSlow=function(e){if(typeof e!=`number`)throw TypeError(`Argument must be a number`);return r.SlowBuffer(e)}})),r=t(((e,t)=>{function n(e){return(e/8|0)+(e%8==0?0:1)}var r={ES256:n(256),ES384:n(384),ES512:n(521)};function i(e){var t=r[e];if(t)return t;throw Error(`Unknown algorithm "`+e+`"`)}t.exports=i})),i=t(((e,t)=>{var i=n().Buffer,a=r(),o=128,s=0,c=32,l=16,u=2,d=l|c|s<<6,f=u|s<<6;function p(e){return e.replace(/=/g,``).replace(/\+/g,`-`).replace(/\//g,`_`)}function m(e){if(i.isBuffer(e))return e;if(typeof e==`string`)return i.from(e,`base64`);throw TypeError(`ECDSA signature must be a Base64 string or a Buffer`)}function h(e,t){e=m(e);var n=a(t),r=n+1,s=e.length,c=0;if(e[c++]!==d)throw Error(`Could not find expected "seq"`);var l=e[c++];if(l===(o|1)&&(l=e[c++]),s-c<l)throw Error(`"seq" specified length of "`+l+`", only "`+(s-c)+`" remaining`);if(e[c++]!==f)throw Error(`Could not find expected "int" for "r"`);var u=e[c++];if(s-c-2<u)throw Error(`"r" specified length of "`+u+`", only "`+(s-c-2)+`" available`);if(r<u)throw Error(`"r" specified length of "`+u+`", max of "`+r+`" is acceptable`);var h=c;if(c+=u,e[c++]!==f)throw Error(`Could not find expected "int" for "s"`);var g=e[c++];if(s-c!==g)throw Error(`"s" specified length of "`+g+`", expected "`+(s-c)+`"`);if(r<g)throw Error(`"s" specified length of "`+g+`", max of "`+r+`" is acceptable`);var _=c;if(c+=g,c!==s)throw Error(`Expected to consume entire buffer, but "`+(s-c)+`" bytes remain`);var v=n-u,y=n-g,b=i.allocUnsafe(v+u+y+g);for(c=0;c<v;++c)b[c]=0;e.copy(b,c,h+Math.max(-v,0),h+u),c=n;for(var x=c;c<x+y;++c)b[c]=0;return e.copy(b,c,_+Math.max(-y,0),_+g),b=b.toString(`base64`),b=p(b),b}function g(e,t,n){for(var r=0;t+r<n&&e[t+r]===0;)++r;return e[t+r]>=o&&--r,r}function _(e,t){e=m(e);var n=a(t),r=e.length;if(r!==n*2)throw TypeError(`"`+t+`" signatures must be "`+n*2+`" bytes, saw "`+r+`"`);var s=g(e,0,n),c=g(e,n,e.length),l=n-s,u=n-c,p=2+l+1+1+u,h=p<o,_=i.allocUnsafe((h?2:3)+p),v=0;return _[v++]=d,h?_[v++]=p:(_[v++]=o|1,_[v++]=p&255),_[v++]=f,_[v++]=l,s<0?(_[v++]=0,v+=e.copy(_,v,0,n)):v+=e.copy(_,v,s,n),_[v++]=f,_[v++]=u,c<0?(_[v++]=0,e.copy(_,v,n)):e.copy(_,v,n+c),_}t.exports={derToJose:h,joseToDer:_}})),a=t(((t,r)=>{var i=n().Buffer,a=e(`stream`),o=e(`util`);function s(e){if(this.buffer=null,this.writable=!0,this.readable=!0,!e)return this.buffer=i.alloc(0),this;if(typeof e.pipe==`function`)return this.buffer=i.alloc(0),e.pipe(this),this;if(e.length||typeof e==`object`)return this.buffer=e,this.writable=!1,process.nextTick(function(){this.emit(`end`,e),this.readable=!1,this.emit(`close`)}.bind(this)),this;throw TypeError(`Unexpected data type (`+typeof e+`)`)}o.inherits(s,a),s.prototype.write=function(e){this.buffer=i.concat([this.buffer,i.from(e)]),this.emit(`data`,e)},s.prototype.end=function(e){e&&this.write(e),this.emit(`end`,e),this.emit(`close`),this.writable=!1,this.readable=!1},r.exports=s})),o=t(((t,n)=>{var r=e(`buffer`).Buffer,i=e(`buffer`).SlowBuffer;n.exports=a;function a(e,t){if(!r.isBuffer(e)||!r.isBuffer(t)||e.length!==t.length)return!1;for(var n=0,i=0;i<e.length;i++)n|=e[i]^t[i];return n===0}a.install=function(){r.prototype.equal=i.prototype.equal=function(e){return a(this,e)}};var o=r.prototype.equal,s=i.prototype.equal;a.restore=function(){r.prototype.equal=o,i.prototype.equal=s}})),s=t(((t,r)=>{var a=n().Buffer,s=e(`crypto`),c=i(),l=e(`util`),u=`"%s" is not a valid algorithm.
2
+ Supported algorithms are:
3
+ "HS256", "HS384", "HS512", "RS256", "RS384", "RS512", "PS256", "PS384", "PS512", "ES256", "ES384", "ES512" and "none".`,d=`secret must be a string or buffer`,f=`key must be a string or a buffer`,p=`key must be a string, a buffer or an object`,m=typeof s.createPublicKey==`function`;m&&(f+=` or a KeyObject`,d+=`or a KeyObject`);function h(e){if(!a.isBuffer(e)&&typeof e!=`string`&&(!m||typeof e!=`object`||typeof e.type!=`string`||typeof e.asymmetricKeyType!=`string`||typeof e.export!=`function`))throw b(f)}function g(e){if(!a.isBuffer(e)&&typeof e!=`string`&&typeof e!=`object`)throw b(p)}function _(e){if(!a.isBuffer(e)){if(typeof e==`string`)return e;if(!m||typeof e!=`object`||e.type!==`secret`||typeof e.export!=`function`)throw b(d)}}function v(e){return e.replace(/=/g,``).replace(/\+/g,`-`).replace(/\//g,`_`)}function y(e){e=e.toString();var t=4-e.length%4;if(t!==4)for(var n=0;n<t;++n)e+=`=`;return e.replace(/\-/g,`+`).replace(/_/g,`/`)}function b(e){var t=[].slice.call(arguments,1),n=l.format.bind(l,e).apply(null,t);return TypeError(n)}function x(e){return a.isBuffer(e)||typeof e==`string`}function S(e){return x(e)||(e=JSON.stringify(e)),e}function C(e){return function(t,n){_(n),t=S(t);var r=s.createHmac(`sha`+e,n);return v((r.update(t),r.digest(`base64`)))}}var w,T=`timingSafeEqual`in s?function(e,t){return e.byteLength===t.byteLength&&s.timingSafeEqual(e,t)}:function(e,t){return w||(w=o()),w(e,t)};function E(e){return function(t,n,r){var i=C(e)(t,r);return T(a.from(n),a.from(i))}}function D(e){return function(t,n){g(n),t=S(t);var r=s.createSign(`RSA-SHA`+e);return v((r.update(t),r.sign(n,`base64`)))}}function O(e){return function(t,n,r){h(r),t=S(t),n=y(n);var i=s.createVerify(`RSA-SHA`+e);return i.update(t),i.verify(r,n,`base64`)}}function k(e){return function(t,n){g(n),t=S(t);var r=s.createSign(`RSA-SHA`+e);return v((r.update(t),r.sign({key:n,padding:s.constants.RSA_PKCS1_PSS_PADDING,saltLength:s.constants.RSA_PSS_SALTLEN_DIGEST},`base64`)))}}function A(e){return function(t,n,r){h(r),t=S(t),n=y(n);var i=s.createVerify(`RSA-SHA`+e);return i.update(t),i.verify({key:r,padding:s.constants.RSA_PKCS1_PSS_PADDING,saltLength:s.constants.RSA_PSS_SALTLEN_DIGEST},n,`base64`)}}function j(e){var t=D(e);return function(){var n=t.apply(null,arguments);return n=c.derToJose(n,`ES`+e),n}}function M(e){var t=O(e);return function(n,r,i){return r=c.joseToDer(r,`ES`+e).toString(`base64`),t(n,r,i)}}function N(){return function(){return``}}function P(){return function(e,t){return t===``}}r.exports=function(e){var t={hs:C,rs:D,ps:k,es:j,none:N},n={hs:E,rs:O,ps:A,es:M,none:P},r=e.match(/^(RS|PS|ES|HS)(256|384|512)$|^(none)$/);if(!r)throw b(u,e);var i=(r[1]||r[3]).toLowerCase(),a=r[2];return{sign:t[i](a),verify:n[i](a)}}})),c=t(((t,n)=>{var r=e(`buffer`).Buffer;n.exports=function(e){return typeof e==`string`?e:typeof e==`number`||r.isBuffer(e)?e.toString():JSON.stringify(e)}})),l=t(((t,r)=>{var i=n().Buffer,o=a(),l=s(),u=e(`stream`),d=c(),f=e(`util`);function p(e,t){return i.from(e,t).toString(`base64`).replace(/=/g,``).replace(/\+/g,`-`).replace(/\//g,`_`)}function m(e,t,n){n=n||`utf8`;var r=p(d(e),`binary`),i=p(d(t),n);return f.format(`%s.%s`,r,i)}function h(e){var t=e.header,n=e.payload,r=e.secret||e.privateKey,i=e.encoding,a=l(t.alg),o=m(t,n,i),s=a.sign(o,r);return f.format(`%s.%s`,o,s)}function g(e){var t=e.secret;if(t=t??e.privateKey,t=t??e.key,/^hs/i.test(e.header.alg)===!0&&t==null)throw TypeError(`secret must be a string or buffer or a KeyObject`);var n=new o(t);this.readable=!0,this.header=e.header,this.encoding=e.encoding,this.secret=this.privateKey=this.key=n,this.payload=new o(e.payload),this.secret.once(`close`,function(){!this.payload.writable&&this.readable&&this.sign()}.bind(this)),this.payload.once(`close`,function(){!this.secret.writable&&this.readable&&this.sign()}.bind(this))}f.inherits(g,u),g.prototype.sign=function(){try{var e=h({header:this.header,payload:this.payload.buffer,secret:this.secret.buffer,encoding:this.encoding});return this.emit(`done`,e),this.emit(`data`,e),this.emit(`end`),this.readable=!1,e}catch(e){this.readable=!1,this.emit(`error`,e),this.emit(`close`)}},g.sign=h,r.exports=g})),u=t(((t,r)=>{var i=n().Buffer,o=a(),l=s(),u=e(`stream`),d=c(),f=e(`util`),p=/^[a-zA-Z0-9\-_]+?\.[a-zA-Z0-9\-_]+?\.([a-zA-Z0-9\-_]+)?$/;function m(e){return Object.prototype.toString.call(e)===`[object Object]`}function h(e){if(m(e))return e;try{return JSON.parse(e)}catch{return}}function g(e){var t=e.split(`.`,1)[0];return h(i.from(t,`base64`).toString(`binary`))}function _(e){return e.split(`.`,2).join(`.`)}function v(e){return e.split(`.`)[2]}function y(e,t){t=t||`utf8`;var n=e.split(`.`)[1];return i.from(n,`base64`).toString(t)}function b(e){return p.test(e)&&!!g(e)}function x(e,t,n){if(!t){var r=Error(`Missing algorithm parameter for jws.verify`);throw r.code=`MISSING_ALGORITHM`,r}e=d(e);var i=v(e),a=_(e);return l(t).verify(a,i,n)}function S(e,t){if(t=t||{},e=d(e),!b(e))return null;var n=g(e);if(!n)return null;var r=y(e);return(n.typ===`JWT`||t.json)&&(r=JSON.parse(r,t.encoding)),{header:n,payload:r,signature:v(e)}}function C(e){e=e||{};var t=e.secret;if(t=t??e.publicKey,t=t??e.key,/^hs/i.test(e.algorithm)===!0&&t==null)throw TypeError(`secret must be a string or buffer or a KeyObject`);var n=new o(t);this.readable=!0,this.algorithm=e.algorithm,this.encoding=e.encoding,this.secret=this.publicKey=this.key=n,this.signature=new o(e.signature),this.secret.once(`close`,function(){!this.signature.writable&&this.readable&&this.verify()}.bind(this)),this.signature.once(`close`,function(){!this.secret.writable&&this.readable&&this.verify()}.bind(this))}f.inherits(C,u),C.prototype.verify=function(){try{var e=x(this.signature.buffer,this.algorithm,this.key.buffer),t=S(this.signature.buffer,this.encoding);return this.emit(`done`,e,t),this.emit(`data`,e),this.emit(`end`),this.readable=!1,e}catch(e){this.readable=!1,this.emit(`error`,e),this.emit(`close`)}},C.decode=S,C.isValid=b,C.verify=x,r.exports=C})),d=t((e=>{var t=l(),n=u();e.ALGORITHMS=[`HS256`,`HS384`,`HS512`,`RS256`,`RS384`,`RS512`,`PS256`,`PS384`,`PS512`,`ES256`,`ES384`,`ES512`],e.sign=t.sign,e.verify=n.verify,e.decode=n.decode,e.isValid=n.isValid,e.createSign=function(e){return new t(e)},e.createVerify=function(e){return new n(e)}}));export{i as n,d as t};
@@ -0,0 +1 @@
1
+ import{D as e,E as t,U as n,l as r,p as i,z as a}from"./debug-IKW-jE7K.js";import{M as o,j as s}from"./git-tyaWOgRL.js";import{n as c,r as l}from"./analytics-BotDBGh0.js";c(),r(),s(),n(),t();function u(e){if(e<6e4)return`${Math.round(e/1e3)}s`;let t=Math.floor(e/6e4),n=Math.round(e%6e4/1e3);return n>0?`${t}m ${n}s`:`${t}m`}function d(t){let n=(t.startsWith(`sk-ant-si-`)?t.slice(10):t).split(`.`);if(n.length!==3||!n[1])return null;try{return e(Buffer.from(n[1],`base64url`).toString(`utf8`))}catch{return null}}function f(e){let t=d(e);return typeof t==`object`&&t&&`exp`in t&&typeof t.exp==`number`?t.exp:null}var p=300*1e3,m=1800*1e3,h=3,g=6e4;function _({getAccessToken:e,onRefresh:t,label:n,refreshBufferMs:r=p}){let s=new Map,c=new Map,d=new Map;function _(e){let t=(d.get(e)??0)+1;return d.set(e,t),t}function v(e,t){let a=f(t);if(!a){i(`[${n}:token] Could not decode JWT expiry for sessionId=${e}, token prefix=${t.slice(0,15)}…, keeping existing timer`);return}let o=s.get(e);o&&clearTimeout(o);let c=_(e),l=new Date(a*1e3).toISOString(),d=a*1e3-Date.now()-r;if(d<=0){i(`[${n}:token] Token for sessionId=${e} expires=${l} (past or within buffer), refreshing immediately`),b(e,c);return}i(`[${n}:token] Scheduled token refresh for sessionId=${e} in ${u(d)} (expires=${l}, buffer=${r/1e3}s)`);let p=setTimeout(b,d,e,c);s.set(e,p)}function y(e,t){let a=s.get(e);a&&clearTimeout(a);let o=_(e),c=Math.max(t*1e3-r,3e4);i(`[${n}:token] Scheduled token refresh for sessionId=${e} in ${u(c)} (expires_in=${t}s, buffer=${r/1e3}s)`);let l=setTimeout(b,c,e,o);s.set(e,l)}async function b(r,f){let p;try{p=await e()}catch(e){i(`[${n}:token] getAccessToken threw for sessionId=${r}: ${a(e)}`,{level:`error`})}if(d.get(r)!==f){i(`[${n}:token] doRefresh for sessionId=${r} stale (gen ${f} vs ${d.get(r)}), skipping`);return}if(!p){let e=(c.get(r)??0)+1;if(c.set(r,e),i(`[${n}:token] No OAuth token available for refresh, sessionId=${r} (failure ${e}/${h})`,{level:`error`}),o(`error`,`bridge_token_refresh_no_oauth`),e<h){let e=setTimeout(b,g,r,f);s.set(r,e)}return}c.delete(r),i(`[${n}:token] Refreshing token for sessionId=${r}: new token prefix=${p.slice(0,15)}…`),l(`tengu_bridge_token_refreshed`,{}),t(r,p);let _=setTimeout(b,m,r,f);s.set(r,_),i(`[${n}:token] Scheduled follow-up refresh for sessionId=${r} in ${u(m)}`)}function x(e){_(e);let t=s.get(e);t&&(clearTimeout(t),s.delete(e)),c.delete(e)}function S(){for(let e of d.keys())_(e);for(let e of s.values())clearTimeout(e);s.clear(),c.clear()}return{schedule:v,scheduleFromExpiresIn:y,cancel:x,cancelAll:S}}export{f as n,_ as t};
@@ -0,0 +1,2 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Xx as t,Yx as n,Zx as r,aS as i,eS as a,iS as o,nS as s,rS as c}from"./loadAgentsDir-nzr38hai.js";import{B as l,E as u,O as d,U as f}from"./debug-IKW-jE7K.js";import{r as p,t as m}from"./promptEditor-foiayhdY.js";import{dirname as h}from"path";import{mkdir as g,writeFile as _}from"fs/promises";function v(e){let t=new Set(a.map(e=>c(e.key)));return e.map(e=>{let n={};for(let[r,i]of Object.entries(e.bindings))t.has(c(r))||(n[r]=i);return{context:e.context,bindings:n}}).filter(e=>Object.keys(e.bindings).length>0)}function y(){return d({$schema:`https://www.schemastore.org/claude-code-keybindings.json`,$docs:`https://code.claude.com/docs/en/keybindings`,bindings:v(o)},null,2)+`
2
+ `}var b=e((()=>{u(),i(),s()}));async function x(){if(!r())return{type:`text`,value:`Keybinding customization is not enabled. This feature is currently in preview.`};let e=n(),t=!1;await g(h(e),{recursive:!0});try{await _(e,y(),{encoding:`utf-8`,flag:`wx`})}catch(e){if(l(e)===`EEXIST`)t=!0;else throw e}let i=await m(e);return i.error?{type:`text`,value:`${t?`Opened`:`Created`} ${e}. Could not open in editor: ${i.error}`}:{type:`text`,value:t?`Opened ${e} in your editor.`:`Created ${e} with template. Opened in your editor.`}}e((()=>{t(),b(),f(),p()}))();export{x as call};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{c as t,g as n}from"./config-C7YHKCPV.js";import{i as r,s as i}from"./intl-cKc-V6Mq.js";function a(){let e=t().preferredLanguage??`auto`;return e===`en`||e===`zh`?e:r()===`zh`?`zh`:`en`}var o=e((()=>{n(),i()}));export{o as n,a as t};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./language-BuRSO2sR.js";e();export{t as getResolvedLanguage};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./defineProperty-C-QyHrDq.js";import{n as r,t as i}from"./axios-DaWTGg7G.js";import{I as a,P as o,fi as s,t as c}from"./src-CDCSSo0U2.js";import{t as l}from"./jsx-runtime-Bb4Xn-E0.js";import{n as u,r as d}from"./analytics-BotDBGh0.js";import{l as f,u as p}from"./oauth-BqJqV-2M.js";import{o as m,u as h}from"./api-TgV7fl9V.js";import{n as g,r as _,t as v}from"./cron-3LntnnhJ.js";import{n as y,r as b}from"./hostGuard-Dh296c6q.js";import{n as x,t as S}from"./launchCommand-1qkTCKpf.js";function C(e){return new Promise(t=>setTimeout(t,e))}async function w(){let e;try{e=(await h()).apiKey}catch(e){let t=e instanceof Error?e.message:String(e);throw new F(t,501)}return y(T()),{"x-api-key":e,"anthropic-version":`2023-06-01`,"anthropic-beta":N,"content-type":`application/json`}}function T(){return`${f().BASE_API_URL}/v1/agents`}function E(e){if(r.isAxiosError(e)){let t=e.response?.status??0;if(t===401)return new F(`Authentication failed. Please run /login to re-authenticate.`,401);if(t===403)return new F(`Subscription required. Scheduled agents require a Claude Pro/Max/Team subscription.`,403);if(t===404)return new F(`Agent not found.`,404);if(t===429){let t=e.response?.headers?.[`retry-after`]??``,n=t?` Retry after ${t}s.`:``;return new F(`Rate limit exceeded.${n}`,429)}let n=(e.response?.data)?.error?.message??e.message;return new F(n,t)}return e instanceof F?e:new F(e instanceof Error?e.message:String(e),0)}function D(e){if(!e)return null;let t=Number(e);if(!Number.isNaN(t)&&t>=0)return t*1e3;let n=Date.parse(e);return Number.isNaN(n)?null:Math.max(0,n-Date.now())}async function O(e){let t;for(let n=0;n<P;n++)try{return await e()}catch(e){let i=E(e);if(i.statusCode>=500){t=i,n<P-1&&await C(D(r.isAxiosError(e)?e.response?.headers?.[`retry-after`]:void 0)??500*2**n);continue}throw i}throw t??new F(`Request failed after retries`,0)}async function k(){return O(async()=>{let e=await w();return(await r.get(T(),{headers:e})).data.data??[]})}async function A(e,t){return O(async()=>{let n=await w();return(await r.post(T(),{cron_expr:e,prompt:t,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone??`UTC`},{headers:n})).data})}async function j(e){return O(async()=>{let t=await w();await r.delete(`${T()}/${e}`,{headers:t})})}async function M(e){return O(async()=>{let t=await w();return(await r.post(`${T()}/${e}/run`,{},{headers:t})).data})}var N,P,F,I=e((()=>{i(),p(),b(),m(),t(),N=`managed-agents-2026-04-01`,P=3,F=class extends Error{constructor(e,t){super(e),n(this,`statusCode`,void 0),this.statusCode=t,this.name=`AgentsApiError`}}}));function L({agent:e}){let t=v(e.cron_expr,{utc:!0}),n=e.next_run?new Date(e.next_run).toLocaleString():`—`;return(0,z.jsxs)(a,{flexDirection:`column`,marginBottom:1,children:[(0,z.jsxs)(a,{children:[(0,z.jsx)(o,{bold:!0,children:e.id}),(0,z.jsx)(o,{dimColor:!0,children:` · `}),(0,z.jsx)(o,{color:`suggestion`,children:e.status})]}),(0,z.jsxs)(o,{children:[`Schedule: `,t]}),(0,z.jsxs)(o,{dimColor:!0,children:[`Prompt: `,e.prompt]}),(0,z.jsxs)(o,{dimColor:!0,children:[`Next run: `,n]})]})}function R(e){if(e.mode===`list`)return e.agents.length===0?(0,z.jsx)(a,{children:(0,z.jsx)(o,{dimColor:!0,children:`No scheduled agents. Use /agents-platform create <cron> <prompt> to create one.`})}):(0,z.jsxs)(a,{flexDirection:`column`,children:[(0,z.jsx)(a,{marginBottom:1,children:(0,z.jsxs)(o,{bold:!0,children:[`Scheduled Agents (`,e.agents.length,`)`]})}),e.agents.map(e=>(0,z.jsx)(L,{agent:e},e.id))]});if(e.mode===`created`){let t=v(e.agent.cron_expr,{utc:!0});return(0,z.jsxs)(a,{flexDirection:`column`,children:[(0,z.jsx)(a,{children:(0,z.jsx)(o,{bold:!0,color:`success`,children:`Agent created`})}),(0,z.jsxs)(o,{children:[`ID: `,e.agent.id]}),(0,z.jsxs)(o,{children:[`Schedule: `,t]}),(0,z.jsxs)(o,{children:[`Prompt: `,e.agent.prompt]}),(0,z.jsxs)(o,{dimColor:!0,children:[`Status: `,e.agent.status]})]})}return e.mode===`deleted`?(0,z.jsx)(a,{children:(0,z.jsxs)(o,{color:`success`,children:[`Agent `,e.id,` deleted.`]})}):e.mode===`ran`?(0,z.jsxs)(a,{flexDirection:`column`,children:[(0,z.jsx)(a,{children:(0,z.jsxs)(o,{color:`success`,children:[`Agent `,e.id,` triggered.`]})}),(0,z.jsxs)(o,{dimColor:!0,children:[`Run ID: `,e.runId]})]}):(0,z.jsx)(a,{children:(0,z.jsx)(o,{color:`error`,children:e.message})})}var z,B=e((()=>{s(),c(),g(),z=l()}));function V(e){let t=e.trim().split(/\s+/);return t.length<6?null:{cron:t.slice(0,5).join(` `),prompt:t.slice(5).join(` `)}}function H(e){let t=e.trim();if(t===``||t===`list`)return{action:`list`};let n=t.indexOf(` `),r=n===-1?t:t.slice(0,n),i=n===-1?``:t.slice(n+1).trim();if(r===`create`){if(!i)return{action:`invalid`,reason:`create requires a cron expression and prompt, e.g. create "0 9 * * 1" Run daily standup`};let e=V(i);if(!e)return{action:`invalid`,reason:`create requires at least 5 cron fields followed by a prompt, e.g. create "0 9 * * 1" Run daily standup`};let{cron:t,prompt:n}=e;return n.trim()?{action:`create`,cron:t,prompt:n.trim()}:{action:`invalid`,reason:`prompt cannot be empty`}}if(r===`delete`){if(!i)return{action:`invalid`,reason:`delete requires an agent id`};let e=i.split(/\s+/)[0];return e?{action:`delete`,id:e}:{action:`invalid`,reason:`delete requires an agent id`}}if(r===`run`){if(!i)return{action:`invalid`,reason:`run requires an agent id`};let e=i.split(/\s+/)[0];return e?{action:`run`,id:e}:{action:`invalid`,reason:`run requires an agent id`}}return{action:`invalid`,reason:`Unknown sub-command "${r}". Use: list | create CRON PROMPT | delete ID | run ID`}}var U=e((()=>{}));async function W(e,t){if(e.action===`list`){d(`tengu_agents_platform_list`,{});try{let e=await k();return t(e.length===0?`No scheduled agents found.`:`${e.length} scheduled agent(s).`,{display:`system`}),{mode:`list`,agents:e}}catch(e){let n=e instanceof Error?e.message:String(e);return d(`tengu_agents_platform_failed`,{reason:n}),t(`Failed to list agents: ${n}`,{display:`system`}),{mode:`error`,message:n}}}if(e.action===`create`){let{cron:n,prompt:r}=e;if(!_(n)){let e=`Invalid cron expression: "${n}". Expected 5 fields (minute hour day month weekday).`;return d(`tengu_agents_platform_failed`,{reason:e}),t(e,{display:`system`}),null}d(`tengu_agents_platform_create`,{cron:n});try{let e=await A(n,r);return t(`Agent created: ${e.id}`,{display:`system`}),{mode:`created`,agent:e}}catch(e){let n=e instanceof Error?e.message:String(e);return d(`tengu_agents_platform_failed`,{reason:n}),t(`Failed to create agent: ${n}`,{display:`system`}),{mode:`error`,message:n}}}if(e.action===`delete`){let{id:n}=e;d(`tengu_agents_platform_delete`,{id:n});try{return await j(n),t(`Agent ${n} deleted.`,{display:`system`}),{mode:`deleted`,id:n}}catch(e){let r=e instanceof Error?e.message:String(e);return d(`tengu_agents_platform_failed`,{reason:r}),t(`Failed to delete agent ${n}: ${r}`,{display:`system`}),{mode:`error`,message:r}}}let{id:n}=e;d(`tengu_agents_platform_run`,{id:n});try{let e=await M(n);return t(`Agent ${n} triggered. Run ID: ${e.run_id}`,{display:`system`}),{mode:`ran`,id:n,runId:e.run_id}}catch(e){let r=e instanceof Error?e.message:String(e);return d(`tengu_agents_platform_failed`,{reason:r}),t(`Failed to run agent ${n}: ${r}`,{display:`system`}),{mode:`error`,message:r}}}var G;e((()=>{u(),g(),I(),B(),U(),S(),G=x({commandName:`agents-platform`,parseArgs:e=>{d(`tengu_agents_platform_started`,{args:e});let t=H(e);return t.action===`invalid`?(d(`tengu_agents_platform_failed`,{reason:t.reason}),{action:`invalid`,reason:`Usage: /agents-platform list | create CRON PROMPT | delete ID | run ID\n${t.reason}`}):t},dispatch:W,View:R,errorView:e=>null})}))();export{G as callAgentsPlatform};
@@ -0,0 +1 @@
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{fi as n}from"./src-CDCSSo0U2.js";function r(e){return async(t,n,r)=>{let o=e.parseArgs(r??``);if(i(o))return t(`Invalid args: ${o.reason}`,{display:`system`}),e.errorView(o.reason);try{let r=await e.dispatch(o,t,n);return r===null?null:a.createElement(e.View,r)}catch(n){let r=n instanceof Error?n.message:String(n);return e.onDispatchError?.(n),t(`${e.commandName} failed: ${r}`,{display:`system`}),e.errorView(r)}}}function i(e){return typeof e==`object`&&!!e&&`action`in e&&e.action===`invalid`}var a,o=e((()=>{a=t(n(),1)}));export{r as n,o as t};
@@ -0,0 +1,3 @@
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{I as n,P as r,fi as i,hn as a,t as o,y as s}from"./src-CDCSSo0U2.js";import{t as c}from"./jsx-runtime-Bb4Xn-E0.js";import{Cd as l,Dd as u,Ed as d,Od as f,Sd as p,Td as m,bd as h,ex as g,tx as _,wd as v,xd as y,yd as b}from"./loadAgentsDir-nzr38hai.js";import{n as x,t as S}from"./launchCommand-1qkTCKpf.js";function C(e){return e.mode===`list`?e.stores.length===0?(0,w.jsx)(n,{children:(0,w.jsx)(r,{dimColor:!0,children:`No memory stores found. Use /local-memory create <store> to create one.`})}):(0,w.jsxs)(n,{flexDirection:`column`,children:[(0,w.jsx)(n,{marginBottom:1,children:(0,w.jsxs)(r,{bold:!0,children:[`Local Memory Stores (`,e.stores.length,`)`]})}),e.stores.map(e=>(0,w.jsxs)(n,{children:[(0,w.jsx)(r,{children:` `}),(0,w.jsx)(r,{color:`success`,children:`◆`}),(0,w.jsxs)(r,{children:[` `,e]})]},e))]}):e.mode===`created`?(0,w.jsxs)(n,{children:[(0,w.jsx)(r,{color:`success`,children:`✓`}),(0,w.jsx)(r,{children:` Store created: `}),(0,w.jsx)(r,{bold:!0,children:e.store})]}):e.mode===`stored`?(0,w.jsxs)(n,{children:[(0,w.jsx)(r,{color:`success`,children:`✓`}),(0,w.jsx)(r,{children:` Stored entry `}),(0,w.jsx)(r,{bold:!0,children:e.key}),(0,w.jsx)(r,{children:` in `}),(0,w.jsx)(r,{bold:!0,children:e.store})]}):e.mode===`fetched`?(0,w.jsxs)(n,{flexDirection:`column`,children:[(0,w.jsxs)(n,{marginBottom:1,children:[(0,w.jsx)(r,{bold:!0,children:e.store}),(0,w.jsx)(r,{dimColor:!0,children:`/`}),(0,w.jsx)(r,{bold:!0,children:e.key})]}),(0,w.jsx)(n,{children:(0,w.jsx)(r,{children:e.value})})]}):e.mode===`not-found`?(0,w.jsxs)(n,{children:[(0,w.jsx)(r,{color:`error`,children:`Not found: `}),(0,w.jsx)(r,{bold:!0,children:e.store}),e.key?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(r,{dimColor:!0,children:`/`}),(0,w.jsx)(r,{bold:!0,children:e.key})]}):null]}):e.mode===`entries`?e.keys.length===0?(0,w.jsxs)(n,{children:[(0,w.jsx)(r,{dimColor:!0,children:`No entries in `}),(0,w.jsx)(r,{bold:!0,children:e.store}),(0,w.jsxs)(r,{dimColor:!0,children:[`. Use /local-memory store `,e.store,` <key> <value> to add one.`]})]}):(0,w.jsxs)(n,{flexDirection:`column`,children:[(0,w.jsxs)(n,{marginBottom:1,children:[(0,w.jsx)(r,{bold:!0,children:e.store}),(0,w.jsxs)(r,{dimColor:!0,children:[` (`,e.keys.length,` entries)`]})]}),e.keys.map(e=>(0,w.jsxs)(n,{children:[(0,w.jsx)(r,{children:` `}),(0,w.jsx)(r,{color:`success`,children:`·`}),(0,w.jsxs)(r,{children:[` `,e]})]},e))]}):e.mode===`archived`?(0,w.jsxs)(n,{children:[(0,w.jsx)(r,{color:`success`,children:`✓`}),(0,w.jsx)(r,{children:` Archived store: `}),(0,w.jsx)(r,{bold:!0,children:e.store}),(0,w.jsxs)(r,{dimColor:!0,children:[` (renamed to `,e.store,`.archived)`]})]}):(0,w.jsx)(n,{children:(0,w.jsxs)(r,{color:`error`,children:[`Error: `,e.message]})})}var w,T=e((()=>{i(),o(),w=c()}));function E(e){let t=e.trim();if(t===``||t===`list`)return{action:`list`};let n=t.split(/\s+/),r=n[0];if(r===`list`)return{action:`list`};if(r===`create`){let e=n[1];return e?{action:`create`,store:e}:{action:`invalid`,reason:`create requires a store name. ${D}`}}if(r===`store`){let e=n[1],t=n[2];if(!e)return{action:`invalid`,reason:`store requires a store name. ${D}`};if(!t)return{action:`invalid`,reason:`store requires a key. ${D}`};let r=n.slice(3).join(` `);return r?{action:`store`,store:e,key:t,value:r}:{action:`invalid`,reason:`store requires a value. ${D}`}}if(r===`fetch`){let e=n[1],t=n[2];return e?t?{action:`fetch`,store:e,key:t}:{action:`invalid`,reason:`fetch requires a key. ${D}`}:{action:`invalid`,reason:`fetch requires a store name. ${D}`}}if(r===`entries`){let e=n[1];return e?{action:`entries`,store:e}:{action:`invalid`,reason:`entries requires a store name. ${D}`}}if(r===`archive`){let e=n[1];return e?{action:`archive`,store:e}:{action:`invalid`,reason:`archive requires a store name. ${D}`}}return{action:`invalid`,reason:`Unknown sub-command "${r}". ${D}`}}var D,O=e((()=>{D=`Usage: /local-memory list | create STORE | store STORE KEY VALUE | fetch STORE KEY | entries STORE | archive STORE`}));function k(e){return e.length===0?`No memory stores found.`:[`Local Memory Stores`,...e.map(e=>`- ${e}`)].join(`
2
+ `)}function A(e,t){return t.length===0?`No entries in "${e}".`:[`Entries in "${e}"`,...t.map(e=>`- ${e}`)].join(`
3
+ `)}function j({onDone:e}){let[t,i]=N.useState({kind:`menu`}),[o,c]=N.useState(0),[u,p]=N.useState(``),[_,x]=N.useState(0),[S,C]=N.useState(null),w=N.useCallback(e=>{i(e),p(``),x(0),C(null)},[]),T=N.useCallback(t=>e(t,{display:`system`}),[e]),E=N.useCallback((e,t,n,r,i={})=>{try{if(e===`list`){T(k(m()));return}if(e===`about`){T(F);return}if(!t){C(`Internal: missing store`);return}if(e===`create`){h(t),T(`Store created: ${t}`);return}if(e===`entries`){let e=v(t);T(A(t,e));return}if(e===`archive`){b(t),T(`Archived store: ${t}`);return}if(e===`fetch`){if(!n){C(`Internal: missing key`);return}let e=y(t,n);if(e===null){T(`Entry not found: ${t}/${n}`);return}T(`Entry fetched: ${t}/${n}\n\n${e}`);return}if(e===`store`){if(!n||r===void 0){C(`Internal: missing key or value`);return}if(!i.confirmedOverwrite&&y(t,n)!==null){w({kind:`confirm-overwrite`,store:t,key:n,value:r});return}d(t,n,r),T(`Stored ${t}/${n} (${r.length} chars)`);return}}catch(e){C(e instanceof Error?e.message:String(e))}},[T,w]);if(a((e,n)=>{if(t.kind!==`menu`)return;if(n.upArrow){c(e=>Math.max(0,e-1));return}if(n.downArrow){c(e=>Math.min(L.length-1,e+1));return}if(n.return){let e=L[o];if(!e)return;if(e.kind===`list`||e.kind===`about`){E(e.kind,void 0,void 0,void 0);return}w({kind:`collect-store`,action:e.kind});return}let r=Number(e);Number.isInteger(r)&&r>=1&&r<=L.length&&c(r-1)},{isActive:t.kind===`menu`}),a((e,n)=>{if(t.kind!==`confirm-archive`&&t.kind!==`confirm-overwrite`)return;if(n.escape){w({kind:`menu`});return}let r=e.toLowerCase();r===`y`||n.return?t.kind===`confirm-archive`?E(`archive`,t.store,void 0,void 0):E(`store`,t.store,t.key,t.value,{confirmedOverwrite:!0}):r===`n`&&w({kind:`menu`})},{isActive:t.kind===`confirm-archive`||t.kind===`confirm-overwrite`}),a((e,n)=>{if(!(t.kind!==`collect-store`&&t.kind!==`collect-key`&&t.kind!==`collect-value`)&&n.escape){if(t.kind===`collect-value`){w({kind:`collect-key`,action:t.action,store:t.store});return}if(t.kind===`collect-key`){w({kind:`collect-store`,action:t.action});return}w({kind:`menu`})}},{isActive:t.kind===`collect-store`||t.kind===`collect-key`||t.kind===`collect-value`}),t.kind===`menu`)return(0,P.jsx)(s,{title:`Local Memory`,subtitle:`${L.length} actions`,onCancel:()=>T(`Local memory panel dismissed`),color:`background`,hideInputGuide:!0,children:(0,P.jsxs)(n,{flexDirection:`column`,children:[L.map((e,t)=>(0,P.jsxs)(n,{flexDirection:`row`,children:[(0,P.jsx)(r,{children:`${t===o?`›`:` `} ${e.label}`.padEnd(I)}),(0,P.jsx)(r,{dimColor:!0,children:e.description})]},e.kind)),(0,P.jsx)(n,{marginTop:1,children:(0,P.jsx)(r,{dimColor:!0,children:`↑/↓ or 1-7 select · Enter run · Esc close`})})]})});if(t.kind===`confirm-archive`)return(0,P.jsx)(s,{title:`Confirm Archive`,onCancel:()=>w({kind:`menu`}),color:`warning`,hideInputGuide:!0,children:(0,P.jsxs)(n,{flexDirection:`column`,children:[(0,P.jsxs)(r,{children:[`Archive store "`,t.store,`"? This renames it to *.archived.`]}),(0,P.jsx)(n,{marginTop:1,children:(0,P.jsx)(r,{dimColor:!0,children:`y/Enter = archive · n/Esc = cancel`})})]})});if(t.kind===`confirm-overwrite`)return(0,P.jsx)(s,{title:`Confirm Overwrite`,onCancel:()=>w({kind:`menu`}),color:`warning`,hideInputGuide:!0,children:(0,P.jsxs)(n,{flexDirection:`column`,children:[(0,P.jsxs)(r,{children:[`Entry "`,t.store,`/`,t.key,`" already exists. Overwrite with new value (`,t.value.length,` chars)?`]}),(0,P.jsx)(n,{marginTop:1,children:(0,P.jsx)(r,{dimColor:!0,children:`y/Enter = overwrite · n/Esc = cancel`})})]})});let D=t.kind===`collect-store`?`STORE NAME`:t.kind===`collect-key`?`KEY NAME`:`VALUE`,O=t.kind===`collect-store`?`e.g. my-notes`:t.kind===`collect-key`?`e.g. todo-2026-05-08`:`free text`;return(0,P.jsx)(s,{title:`Local Memory · ${t.kind.replace(`collect-`,``).toUpperCase()}`,onCancel:()=>w({kind:`menu`}),color:`background`,hideInputGuide:!0,children:(0,P.jsxs)(n,{flexDirection:`column`,children:[(0,P.jsx)(n,{children:(0,P.jsx)(r,{dimColor:!0,children:D})}),(0,P.jsxs)(n,{children:[(0,P.jsx)(r,{children:`> `}),(0,P.jsx)(g,{value:u,onChange:e=>{p(e),C(null)},cursorOffset:_,onChangeCursorOffset:x,onSubmit:e=>{let n=e.trim();if(t.kind===`collect-store`){if(!n){C(`Store name required`);return}if(!l(n)){C(`Invalid store name (no /, \\, :, null byte, or leading dot; max 255 chars)`);return}t.action===`create`||t.action===`entries`||t.action===`archive`?t.action===`archive`?w({kind:`confirm-archive`,store:n}):E(t.action,n,void 0,void 0):w({kind:`collect-key`,action:t.action,store:n});return}if(t.kind===`collect-key`){if(!n){C(`Key required`);return}if(!f(n)){C(`Invalid key (allowed: letters/digits/._- only; no leading dot; not a Windows reserved name)`);return}t.action===`fetch`?E(`fetch`,t.store,n,void 0):w({kind:`collect-value`,action:`store`,store:t.store,key:n});return}t.kind===`collect-value`&&E(`store`,t.store,t.key,e)},placeholder:O,columns:70,showCursor:!0})]}),S!==null&&(0,P.jsx)(n,{marginTop:0,children:(0,P.jsxs)(r,{color:`warning`,children:[`✗ `,S]})}),(0,P.jsx)(n,{marginTop:1,children:(0,P.jsx)(r,{dimColor:!0,children:`Enter = next · Esc = back`})})]})})}async function M(e,t){if(e.action===`list`)return t(k(m()),{display:`system`}),null;if(e.action===`create`){let{store:n}=e;return h(n),t(`Store created: ${n}`,{display:`system`}),null}if(e.action===`store`){let{store:n,key:r,value:i}=e;return d(n,r,i),t(`Stored entry "${r}" in store "${n}".`,{display:`system`}),null}if(e.action===`fetch`){let{store:n,key:r}=e,i=y(n,r);return i===null?(t(`Entry not found: ${n}/${r}`,{display:`system`}),null):(t(`Entry fetched: ${n}/${r}\n${i}`,{display:`system`}),null)}if(e.action===`entries`){let{store:n}=e;return t(A(n,v(n)),{display:`system`}),null}if(e.action===`archive`){let{store:n}=e;return b(n),t(`Archived store: ${n}`,{display:`system`}),null}return t(F,{display:`system`}),null}var N,P,F,I,L,R,z;e((()=>{N=t(i(),1),o(),p(),u(),_(),T(),O(),S(),P=c(),F=`Usage: /local-memory list | create STORE | store STORE KEY VALUE | fetch STORE KEY | entries STORE | archive STORE`,I=26,L=[{kind:`list`,label:`List`,description:`Show all stores`},{kind:`create`,label:`Create`,description:`Create a new memory store`},{kind:`store`,label:`Store`,description:`Write an entry: store name + key + value`},{kind:`fetch`,label:`Fetch`,description:`Read an entry by store name + key`},{kind:`entries`,label:`Entries`,description:`List entry keys in a store`},{kind:`archive`,label:`Archive`,description:`Archive a store (rename to *.archived)`},{kind:`about`,label:`About`,description:`Show command syntax`}],R=x({commandName:`local-memory`,parseArgs:e=>{let t=E(e);return t.action===`invalid`?{action:`invalid`,reason:`${F}\n${t.reason}`}:t},dispatch:M,View:C,errorView:e=>N.createElement(C,{mode:`error`,message:e})}),z=async(e,t,n)=>(n??``).trim()===``?(0,P.jsx)(j,{onDone:e}):R(e,t,n)}))();export{z as callLocalMemory};
@@ -0,0 +1,3 @@
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{I as n,P as r,fi as i,hn as a,t as o,y as s}from"./src-CDCSSo0U2.js";import{t as c}from"./jsx-runtime-Bb4Xn-E0.js";import{Dd as l,Od as u,_d as d,ex as f,gd as p,hd as m,md as h,pd as g,tx as _,vd as v}from"./loadAgentsDir-nzr38hai.js";import{n as y,t as b}from"./launchCommand-1qkTCKpf.js";function x(e){return e.mode===`list`?e.keys.length===0?(0,S.jsx)(n,{children:(0,S.jsx)(r,{dimColor:!0,children:`No secrets stored. Use /local-vault set <key> <value> to add one.`})}):(0,S.jsxs)(n,{flexDirection:`column`,children:[(0,S.jsx)(n,{marginBottom:1,children:(0,S.jsxs)(r,{bold:!0,children:[`Local Vault Keys (`,e.keys.length,`)`]})}),e.keys.map(e=>(0,S.jsxs)(n,{children:[(0,S.jsx)(r,{children:` `}),(0,S.jsx)(r,{color:`success`,children:`●`}),(0,S.jsxs)(r,{children:[` `,e]})]},e))]}):e.mode===`set-ok`?(0,S.jsxs)(n,{children:[(0,S.jsx)(r,{color:`success`,children:`✓`}),(0,S.jsx)(r,{children:` Secret stored: `}),(0,S.jsx)(r,{bold:!0,children:e.key}),(0,S.jsx)(r,{dimColor:!0,children:` = [REDACTED]`})]}):e.mode===`get-masked`?(0,S.jsxs)(n,{flexDirection:`column`,children:[(0,S.jsxs)(n,{children:[(0,S.jsx)(r,{bold:!0,children:e.key}),(0,S.jsx)(r,{dimColor:!0,children:`: `}),(0,S.jsx)(r,{children:e.masked})]}),(0,S.jsx)(n,{marginTop:1,children:(0,S.jsxs)(r,{dimColor:!0,children:[`Use /local-vault get `,e.key,` --reveal to see the full value.`]})})]}):e.mode===`get-revealed`?(0,S.jsxs)(n,{flexDirection:`column`,children:[(0,S.jsxs)(n,{children:[(0,S.jsx)(r,{bold:!0,children:e.key}),(0,S.jsx)(r,{dimColor:!0,children:`: `}),(0,S.jsx)(r,{color:`warning`,children:e.value})]}),(0,S.jsx)(n,{marginTop:1,children:(0,S.jsx)(r,{dimColor:!0,color:`warning`,children:`⚠ Secret revealed in terminal — clear scrollback if this session is shared.`})})]}):e.mode===`not-found`?(0,S.jsxs)(n,{children:[(0,S.jsx)(r,{color:`error`,children:`Key not found: `}),(0,S.jsx)(r,{bold:!0,children:e.key})]}):e.mode===`deleted`?(0,S.jsxs)(n,{children:[(0,S.jsx)(r,{color:`success`,children:`✓`}),(0,S.jsx)(r,{children:` Deleted: `}),(0,S.jsx)(r,{bold:!0,children:e.key})]}):(0,S.jsx)(n,{children:(0,S.jsxs)(r,{color:`error`,children:[`Error: `,e.message]})})}var S,C=e((()=>{i(),o(),S=c()}));function w(e){let t=e.trim();if(t===``||t===`list`)return{action:`list`};let n=t.split(/\s+/),r=n[0];if(r===`list`)return{action:`list`};if(r===`set`){let e=n[1];if(!e)return{action:`invalid`,reason:`set requires a key name. ${T}`};if(E.test(e))return{action:`invalid`,reason:`Key name must not start with "-" or a hyphen-like character (reserved for flags). ${T}`};let t=n.slice(2).join(` `);return t?{action:`set`,key:e,value:t}:{action:`invalid`,reason:`set requires a value. ${T}`}}if(r===`get`){let e=[`--reveal`],t=n.filter(t=>!e.includes(t))[1];return t?{action:`get`,key:t,reveal:n.includes(`--reveal`)}:{action:`invalid`,reason:`get requires a key name. ${T}`}}if(r===`delete`){let e=n[1];return e?{action:`delete`,key:e}:{action:`invalid`,reason:`delete requires a key name. ${T}`}}return{action:`invalid`,reason:`Unknown sub-command "${r}". ${T}`}}var T,E,D=e((()=>{T=`Usage: /local-vault list | set KEY VALUE | get KEY [--reveal] | delete KEY`,E=/^[-‐-―−﹘﹣-]/}));function O(e){return e.length===0?`No secrets stored.`:[`Local Vault Keys`,...e.map(e=>`- ${e}`)].join(`
2
+ `)}function k({onDone:e}){let[t,i]=j.useState({kind:`menu`}),[o,c]=j.useState(0),[l,m]=j.useState(``),[_,y]=j.useState(0),[b,x]=j.useState(null),[S,C]=j.useState(!1),w=j.useCallback(e=>{i(e),m(``),y(0),x(null)},[]),T=j.useCallback(t=>e(t,{display:`system`}),[e]);a((e,n)=>{if(t.kind!==`menu`||S)return;if(n.upArrow){c(e=>Math.max(0,e-1));return}if(n.downArrow){c(e=>Math.min(F.length-1,e+1));return}if(n.return){let e=F[o];if(!e)return;if(e.kind===`about`){T(N);return}if(e.kind===`list`){C(!0),p().then(e=>{T(O(e))});return}w({kind:`collect-key`,action:e.kind});return}let r=Number(e);Number.isInteger(r)&&r>=1&&r<=F.length&&c(r-1)},{isActive:t.kind===`menu`&&!S}),a((e,n)=>{if(t.kind!==`confirm-overwrite`&&t.kind!==`confirm-delete`)return;if(n.escape){w({kind:`menu`});return}let r=e.toLowerCase();if(r===`y`||n.return)if(t.kind===`confirm-delete`){C(!0);let e=t.key;g(e).then(t=>{T(t?`Deleted: ${e}`:`Key not found: ${e}`)})}else{C(!0);let e=t.key,n=t.value;v(e,n).then(()=>T(`Secret stored: ${e} = [REDACTED]`)).catch(t=>T(`Failed to store ${e}: ${t instanceof Error?t.message:String(t)}`))}else r===`n`&&w({kind:`menu`})},{isActive:(t.kind===`confirm-overwrite`||t.kind===`confirm-delete`)&&!S}),a((e,n)=>{if(!(t.kind!==`collect-key`&&t.kind!==`collect-value`)&&n.escape){if(t.kind===`collect-value`){w({kind:`collect-key`,action:`set`});return}w({kind:`menu`})}},{isActive:(t.kind===`collect-key`||t.kind===`collect-value`)&&!S});let E=e=>{let n=e.trim();if(!n){x(`Key required`);return}if(!u(n)){x(`Invalid key (allowed: letters/digits/._- only; no leading dot; not a Windows reserved name)`);return}if(t.kind===`collect-key`){if(t.action===`get`){C(!0),h(n).then(e=>{T(e===null?`Key not found: ${n}`:`Key found: ${n} = ${d(e)}`)});return}if(t.action===`delete`){w({kind:`confirm-delete`,key:n});return}if(t.action===`set`){w({kind:`collect-value`,key:n});return}}},D=e=>{if(t.kind!==`collect-value`)return;if(e.length===0){x(`Secret value cannot be empty`);return}let n=t.key;C(!0),h(n).then(t=>{if(t!==null){C(!1),w({kind:`confirm-overwrite`,key:n,value:e});return}return v(n,e).then(()=>T(`Secret stored: ${n} = [REDACTED]`))}).catch(e=>T(`Failed to store ${n}: ${e instanceof Error?e.message:String(e)}`))};if(t.kind===`menu`)return(0,M.jsx)(s,{title:`Local Vault`,subtitle:`${F.length} actions`,onCancel:()=>T(`Local vault panel dismissed`),color:`background`,hideInputGuide:!0,children:(0,M.jsxs)(n,{flexDirection:`column`,children:[F.map((e,t)=>(0,M.jsxs)(n,{flexDirection:`row`,children:[(0,M.jsx)(r,{children:`${t===o?`›`:` `} ${e.label}`.padEnd(P)}),(0,M.jsx)(r,{dimColor:!0,children:e.description})]},e.kind)),S&&(0,M.jsx)(n,{marginTop:1,children:(0,M.jsx)(r,{dimColor:!0,children:`Working...`})}),(0,M.jsx)(n,{marginTop:1,children:(0,M.jsx)(r,{dimColor:!0,children:`↑/↓ or 1-5 select · Enter run · Esc close`})})]})});if(t.kind===`confirm-delete`)return(0,M.jsx)(s,{title:`Confirm Delete`,onCancel:()=>w({kind:`menu`}),color:`warning`,hideInputGuide:!0,children:(0,M.jsxs)(n,{flexDirection:`column`,children:[(0,M.jsxs)(r,{children:[`Delete secret "`,t.key,`"? This cannot be undone.`]}),(0,M.jsx)(n,{marginTop:1,children:(0,M.jsx)(r,{dimColor:!0,children:`y/Enter = delete · n/Esc = cancel`})}),S&&(0,M.jsx)(r,{dimColor:!0,children:`Deleting...`})]})});if(t.kind===`confirm-overwrite`)return(0,M.jsx)(s,{title:`Confirm Overwrite`,onCancel:()=>w({kind:`menu`}),color:`warning`,hideInputGuide:!0,children:(0,M.jsxs)(n,{flexDirection:`column`,children:[(0,M.jsxs)(r,{children:[`Secret "`,t.key,`" already exists. Overwrite? Old value is lost.`]}),(0,M.jsx)(n,{marginTop:1,children:(0,M.jsx)(r,{dimColor:!0,children:`y/Enter = overwrite · n/Esc = cancel`})}),S&&(0,M.jsx)(r,{dimColor:!0,children:`Storing...`})]})});let k=t.kind===`collect-key`?`KEY NAME`:`SECRET VALUE`,A=t.kind===`collect-key`?`e.g. github-token`:`(masked input — value never displayed)`,I=t.kind===`collect-key`?E:D,L=t.kind===`collect-value`;return(0,M.jsx)(s,{title:`Local Vault · ${t.kind===`collect-key`?`KEY`:`VALUE`}`,onCancel:()=>w({kind:`menu`}),color:`background`,hideInputGuide:!0,children:(0,M.jsxs)(n,{flexDirection:`column`,children:[(0,M.jsx)(n,{children:(0,M.jsx)(r,{dimColor:!0,children:k})}),(0,M.jsxs)(n,{children:[(0,M.jsx)(r,{children:`> `}),(0,M.jsx)(f,{value:l,onChange:e=>{m(e),x(null)},cursorOffset:_,onChangeCursorOffset:y,onSubmit:I,placeholder:A,columns:70,showCursor:!0,mask:L?`*`:void 0})]}),b!==null&&(0,M.jsx)(n,{marginTop:0,children:(0,M.jsxs)(r,{color:`warning`,children:[`✗ `,b]})}),S&&(0,M.jsx)(n,{marginTop:0,children:(0,M.jsx)(r,{dimColor:!0,children:`Working...`})}),(0,M.jsx)(n,{marginTop:1,children:(0,M.jsx)(r,{dimColor:!0,children:`Enter = next · Esc = back`})})]})})}async function A(e,t){if(e.action===`list`)return t(O(await p()),{display:`system`}),null;if(e.action===`set`){let{key:n,value:r}=e;return await v(n,r),t(`Secret stored: ${n} = [REDACTED]`,{display:`system`}),null}if(e.action===`get`){let{key:n,reveal:r}=e,i=await h(n);return i===null?(t(`Key not found: ${n}`,{display:`system`}),null):r?(t([`Secret revealed for: ${n}`,`Warning: secret revealed in terminal.`,`${n} = ${i}`].join(`
3
+ `),{display:`system`}),null):(t(`Key found: ${n} = ${d(i)}`,{display:`system`}),null)}if(e.action===`delete`){let{key:n}=e;return await g(n)?(t(`Deleted: ${n}`,{display:`system`}),null):(t(`Key not found: ${n}`,{display:`system`}),null)}return t(N,{display:`system`}),null}var j,M,N,P,F,I,L;e((()=>{j=t(i(),1),o(),m(),l(),_(),C(),D(),b(),M=c(),N=`Usage: /local-vault list | set KEY VALUE | get KEY [--reveal] | delete KEY`,P=26,F=[{kind:`list`,label:`List`,description:`Show stored secret keys`},{kind:`set`,label:`Set`,description:`Store a secret: KEY + VALUE (input is masked)`},{kind:`get`,label:`Get`,description:`Look up a secret (returns masked preview)`},{kind:`delete`,label:`Delete`,description:`Delete a stored secret by KEY`},{kind:`about`,label:`About`,description:`Show command syntax`}],I=y({commandName:`local-vault`,parseArgs:e=>{let t=w(e);return t.action===`invalid`?{action:`invalid`,reason:`${N}\n${t.reason}`}:t},dispatch:A,View:x,errorView:e=>j.createElement(x,{mode:`error`,message:e})}),L=async(e,t,n)=>(n??``).trim()===``?(0,M.jsx)(k,{onDone:e}):I(e,t,n)}))();export{L as callLocalVault};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./defineProperty-C-QyHrDq.js";import{n as r,t as i}from"./axios-DaWTGg7G.js";import{I as a,P as o,fi as s,t as c}from"./src-CDCSSo0U2.js";import{t as l}from"./jsx-runtime-Bb4Xn-E0.js";import{n as u,r as d}from"./analytics-BotDBGh0.js";import{l as f,u as p}from"./oauth-BqJqV-2M.js";import{o as m,u as h}from"./api-TgV7fl9V.js";import{n as g,r as _}from"./hostGuard-Dh296c6q.js";import{n as v,t as y}from"./launchCommand-1qkTCKpf.js";function b(e){return new Promise(t=>setTimeout(t,e))}async function x(){let e;try{e=(await h()).apiKey}catch(e){let t=e instanceof Error?e.message:String(e);throw new z(t,501)}return g(S()),{"x-api-key":e,"anthropic-version":`2023-06-01`,"anthropic-beta":L,"content-type":`application/json`}}function S(){return`${f().BASE_API_URL}/v1/memory_stores`}function C(e){if(r.isAxiosError(e)){let t=e.response?.status??0;if(t===401)return new z(`Authentication failed. Please run /login to re-authenticate.`,401);if(t===403)return new z(`Subscription required. Memory stores require a Claude Pro/Max/Team subscription.`,403);if(t===404)return new z(`Memory store or memory not found.`,404);if(t===429){let t=e.response?.headers?.[`retry-after`]??``,n=t?` Retry after ${t}s.`:``;return new z(`Rate limit exceeded.${n}`,429)}let n=(e.response?.data)?.error?.message??e.message;return new z(n,t)}return e instanceof z?e:new z(e instanceof Error?e.message:String(e),0)}function w(e){if(!e)return null;let t=Number(e);if(!Number.isNaN(t)&&t>=0)return t*1e3;let n=Date.parse(e);return Number.isNaN(n)?null:Math.max(0,n-Date.now())}async function T(e){let t;for(let n=0;n<R;n++)try{return await e()}catch(e){let i=C(e);if(i.statusCode>=500){t=i,n<R-1&&await b(w(r.isAxiosError(e)?e.response?.headers?.[`retry-after`]:void 0)??500*2**n);continue}throw i}throw t??new z(`Request failed after retries`,0)}async function E(){return T(async()=>{let e=await x();return(await r.get(S(),{headers:e})).data.data??[]})}async function D(e,t){return T(async()=>{let n=await x(),i={name:e};return t&&(i.namespace=t),(await r.post(S(),i,{headers:n})).data})}async function O(e){return T(async()=>{let t=await x();return(await r.get(`${S()}/${e}`,{headers:t})).data})}async function k(e){return T(async()=>{let t=await x();return(await r.post(`${S()}/${e}/archive`,{},{headers:t})).data})}async function A(e){return T(async()=>{let t=await x();return(await r.get(`${S()}/${e}/memories`,{headers:t})).data.data??[]})}async function j(e,t){return T(async()=>{let n=await x(),i={content:t};return(await r.post(`${S()}/${e}/memories`,i,{headers:n})).data})}async function M(e,t){return T(async()=>{let n=await x();return(await r.get(`${S()}/${e}/memories/${t}`,{headers:n})).data})}async function N(e,t,n){return T(async()=>{let i=await x(),a={content:n};return(await r.patch(`${S()}/${e}/memories/${t}`,a,{headers:i})).data})}async function P(e,t){return T(async()=>{let n=await x();await r.delete(`${S()}/${e}/memories/${t}`,{headers:n})})}async function F(e){return T(async()=>{let t=await x();return(await r.get(`${S()}/${e}/memory_versions`,{headers:t})).data.data??[]})}async function I(e,t){return T(async()=>{let n=await x();return(await r.post(`${S()}/${e}/memory_versions/${t}/redact`,{},{headers:n})).data})}var L,R,z,B=e((()=>{i(),p(),_(),m(),t(),L=`managed-agents-2026-04-01`,R=3,z=class extends Error{constructor(e,t){super(e),n(this,`statusCode`,void 0),this.statusCode=t,this.name=`MemoryStoresApiError`}}}));function V({store:e}){let t=!!e.archived_at,n=e.created_at?new Date(e.created_at).toLocaleString():`—`;return(0,U.jsxs)(a,{flexDirection:`column`,marginBottom:1,children:[(0,U.jsxs)(a,{children:[(0,U.jsx)(o,{bold:!0,children:e.memory_store_id}),(0,U.jsx)(o,{dimColor:!0,children:` · `}),(0,U.jsx)(o,{color:t?`warning`:`success`,children:t?`archived`:`active`}),e.namespace?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(o,{dimColor:!0,children:` · ns: `}),(0,U.jsx)(o,{children:e.namespace})]}):null]}),(0,U.jsxs)(o,{children:[`Name: `,e.name]}),(0,U.jsxs)(o,{dimColor:!0,children:[`Created: `,n]})]})}function H(e){if(e.mode===`list`)return e.stores.length===0?(0,U.jsx)(a,{children:(0,U.jsx)(o,{dimColor:!0,children:`No memory stores found. Use /memory-stores create <name> to create one.`})}):(0,U.jsxs)(a,{flexDirection:`column`,children:[(0,U.jsx)(a,{marginBottom:1,children:(0,U.jsxs)(o,{bold:!0,children:[`Memory Stores (`,e.stores.length,`)`]})}),e.stores.map(e=>(0,U.jsx)(V,{store:e},e.memory_store_id))]});if(e.mode===`detail`){let{store:t}=e,n=!!t.archived_at,r=t.created_at?new Date(t.created_at).toLocaleString():`—`,i=t.archived_at?new Date(t.archived_at).toLocaleString():null;return(0,U.jsxs)(a,{flexDirection:`column`,children:[(0,U.jsx)(a,{marginBottom:1,children:(0,U.jsxs)(o,{bold:!0,children:[`Memory Store: `,t.memory_store_id]})}),(0,U.jsxs)(o,{children:[`Name: `,t.name]}),t.namespace?(0,U.jsxs)(o,{children:[`Namespace: `,t.namespace]}):null,(0,U.jsxs)(o,{children:[`Status:`,` `,(0,U.jsx)(o,{color:n?`warning`:`success`,children:n?`archived`:`active`})]}),(0,U.jsxs)(o,{dimColor:!0,children:[`Created: `,r]}),i?(0,U.jsxs)(o,{dimColor:!0,children:[`Archived: `,i]}):null]})}if(e.mode===`created`){let{store:t}=e;return(0,U.jsxs)(a,{flexDirection:`column`,children:[(0,U.jsx)(a,{children:(0,U.jsx)(o,{bold:!0,color:`success`,children:`Memory store created`})}),(0,U.jsxs)(o,{children:[`ID: `,t.memory_store_id]}),(0,U.jsxs)(o,{children:[`Name: `,t.name]}),t.namespace?(0,U.jsxs)(o,{children:[`Namespace: `,t.namespace]}):null]})}if(e.mode===`archived`){let{store:t}=e,n=t.archived_at?new Date(t.archived_at).toLocaleString():`—`;return(0,U.jsxs)(a,{flexDirection:`column`,children:[(0,U.jsx)(a,{children:(0,U.jsx)(o,{bold:!0,color:`warning`,children:`Memory store archived`})}),(0,U.jsxs)(o,{children:[`ID: `,t.memory_store_id]}),(0,U.jsxs)(o,{dimColor:!0,children:[`Archived at: `,n]})]})}if(e.mode===`memory-list`){let{storeId:t,memories:n}=e;return n.length===0?(0,U.jsx)(a,{children:(0,U.jsxs)(o,{dimColor:!0,children:[`No memories in store `,t,`. Use /memory-stores create-memory `,t,` <content> to add one.`]})}):(0,U.jsxs)(a,{flexDirection:`column`,children:[(0,U.jsx)(a,{marginBottom:1,children:(0,U.jsxs)(o,{bold:!0,children:[`Memories in `,t,` (`,n.length,`)`]})}),n.map(e=>(0,U.jsxs)(a,{flexDirection:`column`,marginBottom:1,children:[(0,U.jsx)(o,{bold:!0,children:e.memory_id}),(0,U.jsx)(o,{dimColor:!0,children:e.content.length>80?`${e.content.slice(0,80)}…`:e.content})]},e.memory_id))]})}if(e.mode===`memory-detail`){let{memory:t}=e,n=t.created_at?new Date(t.created_at).toLocaleString():`—`,r=t.updated_at?new Date(t.updated_at).toLocaleString():`—`;return(0,U.jsxs)(a,{flexDirection:`column`,children:[(0,U.jsx)(a,{marginBottom:1,children:(0,U.jsxs)(o,{bold:!0,children:[`Memory: `,t.memory_id]})}),(0,U.jsxs)(o,{children:[`Store: `,t.memory_store_id]}),(0,U.jsxs)(o,{children:[`Content: `,t.content]}),(0,U.jsxs)(o,{dimColor:!0,children:[`Created: `,n]}),(0,U.jsxs)(o,{dimColor:!0,children:[`Updated: `,r]})]})}if(e.mode===`memory-created`){let{memory:t}=e;return(0,U.jsxs)(a,{flexDirection:`column`,children:[(0,U.jsx)(a,{children:(0,U.jsx)(o,{bold:!0,color:`success`,children:`Memory created`})}),(0,U.jsxs)(o,{children:[`ID: `,t.memory_id]}),(0,U.jsxs)(o,{children:[`Store: `,t.memory_store_id]}),(0,U.jsxs)(o,{dimColor:!0,children:[`Content: `,t.content]})]})}if(e.mode===`memory-updated`){let{memory:t}=e;return(0,U.jsxs)(a,{flexDirection:`column`,children:[(0,U.jsx)(a,{children:(0,U.jsx)(o,{bold:!0,color:`success`,children:`Memory updated`})}),(0,U.jsxs)(o,{children:[`ID: `,t.memory_id]}),(0,U.jsxs)(o,{dimColor:!0,children:[`Content: `,t.content]})]})}if(e.mode===`memory-deleted`)return(0,U.jsx)(a,{children:(0,U.jsxs)(o,{color:`success`,children:[`Memory `,e.memoryId,` deleted from store `,e.storeId,`.`]})});if(e.mode===`versions`){let{storeId:t,versions:n}=e;return n.length===0?(0,U.jsx)(a,{children:(0,U.jsxs)(o,{dimColor:!0,children:[`No memory versions found for store `,t,`.`]})}):(0,U.jsxs)(a,{flexDirection:`column`,children:[(0,U.jsx)(a,{marginBottom:1,children:(0,U.jsxs)(o,{bold:!0,children:[`Memory Versions in `,t,` (`,n.length,`)`]})}),n.map(e=>{let t=e.created_at?new Date(e.created_at).toLocaleString():`—`,n=!!e.redacted_at;return(0,U.jsxs)(a,{flexDirection:`column`,marginBottom:1,children:[(0,U.jsxs)(a,{children:[(0,U.jsx)(o,{bold:!0,children:e.version_id}),n?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(o,{dimColor:!0,children:` · `}),(0,U.jsx)(o,{color:`warning`,children:`redacted`})]}):null]}),(0,U.jsxs)(o,{dimColor:!0,children:[`Created: `,t]})]},e.version_id)})]})}if(e.mode===`redacted`){let{version:t}=e,n=t.redacted_at?new Date(t.redacted_at).toLocaleString():`—`;return(0,U.jsxs)(a,{flexDirection:`column`,children:[(0,U.jsx)(a,{children:(0,U.jsx)(o,{bold:!0,color:`warning`,children:`Version redacted`})}),(0,U.jsxs)(o,{children:[`ID: `,t.version_id]}),(0,U.jsxs)(o,{dimColor:!0,children:[`Redacted at: `,n]})]})}return(0,U.jsx)(a,{children:(0,U.jsx)(o,{color:`error`,children:e.message})})}var U,W=e((()=>{s(),c(),U=l()}));function G(e){let t=e.trim();if(t===``||t===`list`)return{action:`list`};let n=t.indexOf(` `),r=n===-1?t:t.slice(0,n),i=n===-1?``:t.slice(n+1).trim();if(r===`get`){if(!i)return{action:`invalid`,reason:`get requires a store id`};let e=i.split(/\s+/)[0];return e?{action:`get`,id:e}:{action:`invalid`,reason:`get requires a store id`}}if(r===`create`)return i?{action:`create`,name:i}:{action:`invalid`,reason:`create requires a store name, e.g. create "My Work Store"`};if(r===`archive`){if(!i)return{action:`invalid`,reason:`archive requires a store id`};let e=i.split(/\s+/)[0];return e?{action:`archive`,id:e}:{action:`invalid`,reason:`archive requires a store id`}}if(r===`memories`){if(!i)return{action:`invalid`,reason:`memories requires a store id`};let e=i.split(/\s+/)[0];return e?{action:`memories`,storeId:e}:{action:`invalid`,reason:`memories requires a store id`}}if(r===`create-memory`){let e=i.split(/\s+/);if(e.length<2||!e[0])return{action:`invalid`,reason:`create-memory requires a store id and content, e.g. create-memory ms_123 "The content"`};let t=e[0],n=e.slice(1).join(` `);return n.trim()?{action:`create-memory`,storeId:t,content:n.trim()}:{action:`invalid`,reason:`create-memory requires non-empty content`}}if(r===`get-memory`){let e=i.split(/\s+/);return e.length<2||!e[0]||!e[1]?{action:`invalid`,reason:`get-memory requires a store id and memory id, e.g. get-memory ms_123 mem_456`}:{action:`get-memory`,storeId:e[0],memoryId:e[1]}}if(r===`update-memory`){let e=i.split(/\s+/);if(e.length<3||!e[0]||!e[1])return{action:`invalid`,reason:`update-memory requires store id, memory id, and content, e.g. update-memory ms_123 mem_456 "New content"`};let t=e[0],n=e[1],r=e.slice(2).join(` `);return r.trim()?{action:`update-memory`,storeId:t,memoryId:n,content:r.trim()}:{action:`invalid`,reason:`update-memory requires non-empty content`}}if(r===`delete-memory`){let e=i.split(/\s+/);return e.length<2||!e[0]||!e[1]?{action:`invalid`,reason:`delete-memory requires a store id and memory id, e.g. delete-memory ms_123 mem_456`}:{action:`delete-memory`,storeId:e[0],memoryId:e[1]}}if(r===`versions`){if(!i)return{action:`invalid`,reason:`versions requires a store id`};let e=i.split(/\s+/)[0];return e?{action:`versions`,storeId:e}:{action:`invalid`,reason:`versions requires a store id`}}if(r===`redact`){let e=i.split(/\s+/);return e.length<2||!e[0]||!e[1]?{action:`invalid`,reason:`redact requires a store id and version id, e.g. redact ms_123 ver_456`}:{action:`redact`,storeId:e[0],versionId:e[1]}}return{action:`invalid`,reason:`Unknown sub-command "${r}". ${K}`}}var K,q=e((()=>{K=`Usage: /memory-stores list | get ID | create NAME | archive ID | memories STORE_ID | create-memory STORE_ID CONTENT | get-memory STORE_ID MEMORY_ID | update-memory STORE_ID MEMORY_ID CONTENT | delete-memory STORE_ID MEMORY_ID | versions STORE_ID | redact STORE_ID VERSION_ID`}));async function J(e,t){if(e.action===`list`){d(`tengu_memory_stores_list`,{});try{let e=await E();return t(e.length===0?`No memory stores found.`:`${e.length} memory store(s).`,{display:`system`}),{mode:`list`,stores:e}}catch(e){let n=e instanceof Error?e.message:String(e);return d(`tengu_memory_stores_failed`,{reason:n}),t(`Failed to list memory stores: ${n}`,{display:`system`}),{mode:`error`,message:n}}}if(e.action===`get`){let{id:n}=e;d(`tengu_memory_stores_get`,{id:n});try{let e=await O(n);return t(`Memory store ${n} fetched.`,{display:`system`}),{mode:`detail`,store:e}}catch(e){let r=e instanceof Error?e.message:String(e);return d(`tengu_memory_stores_failed`,{reason:r}),t(`Failed to get memory store ${n}: ${r}`,{display:`system`}),{mode:`error`,message:r}}}if(e.action===`create`){let{name:n}=e;d(`tengu_memory_stores_create`,{name:n});try{let e=await D(n);return t(`Memory store created: ${e.memory_store_id}`,{display:`system`}),{mode:`created`,store:e}}catch(e){let n=e instanceof Error?e.message:String(e);return d(`tengu_memory_stores_failed`,{reason:n}),t(`Failed to create memory store: ${n}`,{display:`system`}),{mode:`error`,message:n}}}if(e.action===`archive`){let{id:n}=e;d(`tengu_memory_stores_archive`,{id:n});try{let e=await k(n);return t(`Memory store ${n} archived.`,{display:`system`}),{mode:`archived`,store:e}}catch(e){let r=e instanceof Error?e.message:String(e);return d(`tengu_memory_stores_failed`,{reason:r}),t(`Failed to archive memory store ${n}: ${r}`,{display:`system`}),{mode:`error`,message:r}}}if(e.action===`memories`){let{storeId:n}=e;d(`tengu_memory_stores_list_memories`,{storeId:n});try{let e=await A(n);return t(e.length===0?`No memories in store ${n}.`:`${e.length} memory(ies) in store ${n}.`,{display:`system`}),{mode:`memory-list`,storeId:n,memories:e}}catch(e){let r=e instanceof Error?e.message:String(e);return d(`tengu_memory_stores_failed`,{reason:r}),t(`Failed to list memories in store ${n}: ${r}`,{display:`system`}),{mode:`error`,message:r}}}if(e.action===`create-memory`){let{storeId:n,content:r}=e;d(`tengu_memory_stores_create_memory`,{storeId:n});try{let e=await j(n,r);return t(`Memory created: ${e.memory_id}`,{display:`system`}),{mode:`memory-created`,memory:e}}catch(e){let r=e instanceof Error?e.message:String(e);return d(`tengu_memory_stores_failed`,{reason:r}),t(`Failed to create memory in store ${n}: ${r}`,{display:`system`}),{mode:`error`,message:r}}}if(e.action===`get-memory`){let{storeId:n,memoryId:r}=e;d(`tengu_memory_stores_get_memory`,{storeId:n});try{let e=await M(n,r);return t(`Memory ${r} fetched.`,{display:`system`}),{mode:`memory-detail`,memory:e}}catch(e){let n=e instanceof Error?e.message:String(e);return d(`tengu_memory_stores_failed`,{reason:n}),t(`Failed to get memory ${r}: ${n}`,{display:`system`}),{mode:`error`,message:n}}}if(e.action===`update-memory`){let{storeId:n,memoryId:r,content:i}=e;d(`tengu_memory_stores_update_memory`,{storeId:n});try{let e=await N(n,r,i);return t(`Memory ${r} updated.`,{display:`system`}),{mode:`memory-updated`,memory:e}}catch(e){let n=e instanceof Error?e.message:String(e);return d(`tengu_memory_stores_failed`,{reason:n}),t(`Failed to update memory ${r}: ${n}`,{display:`system`}),{mode:`error`,message:n}}}if(e.action===`delete-memory`){let{storeId:n,memoryId:r}=e;d(`tengu_memory_stores_delete_memory`,{storeId:n});try{return await P(n,r),t(`Memory ${r} deleted.`,{display:`system`}),{mode:`memory-deleted`,storeId:n,memoryId:r}}catch(e){let n=e instanceof Error?e.message:String(e);return d(`tengu_memory_stores_failed`,{reason:n}),t(`Failed to delete memory ${r}: ${n}`,{display:`system`}),{mode:`error`,message:n}}}if(e.action===`versions`){let{storeId:n}=e;d(`tengu_memory_stores_versions`,{storeId:n});try{let e=await F(n);return t(e.length===0?`No memory versions found for store ${n}.`:`${e.length} version(s) in store ${n}.`,{display:`system`}),{mode:`versions`,storeId:n,versions:e}}catch(e){let r=e instanceof Error?e.message:String(e);return d(`tengu_memory_stores_failed`,{reason:r}),t(`Failed to list versions for store ${n}: ${r}`,{display:`system`}),{mode:`error`,message:r}}}let{storeId:n,versionId:r}=e;d(`tengu_memory_stores_redact`,{storeId:n});try{let e=await I(n,r);return t(`Version ${r} redacted.`,{display:`system`}),{mode:`redacted`,version:e}}catch(e){let n=e instanceof Error?e.message:String(e);return d(`tengu_memory_stores_failed`,{reason:n}),t(`Failed to redact version ${r}: ${n}`,{display:`system`}),{mode:`error`,message:n}}}var Y,X;e((()=>{u(),B(),W(),q(),y(),Y=`Usage: /memory-stores list | get ID | create NAME | archive ID | memories STORE_ID | create-memory STORE_ID CONTENT | get-memory STORE_ID MEMORY_ID | update-memory STORE_ID MEMORY_ID CONTENT | delete-memory STORE_ID MEMORY_ID | versions STORE_ID | redact STORE_ID VERSION_ID`,X=v({commandName:`memory-stores`,parseArgs:e=>{d(`tengu_memory_stores_started`,{args:e});let t=G(e);return t.action===`invalid`?(d(`tengu_memory_stores_failed`,{reason:t.reason}),{action:`invalid`,reason:`${Y}\n${t.reason}`}):t},dispatch:J,View:H,errorView:e=>null})}))();export{X as callMemoryStores};