@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{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{Kr as t,qr as n}from"./src-CDCSSo0U2.js";import{en as r,ht as i}from"./state-4KQ3kaqz.js";import{My as a,Oy as o,po as s,zo as c}from"./loadAgentsDir-nzr38hai.js";import{Y as l}from"./log-B3eB4EFv.js";import{Vt as u}from"./prompt-Bef63FhB.js";import{randomUUID as d}from"crypto";function f(e){return e.flatMap(e=>{if(!e)return[];switch(e.type){case`assistant`:return[{type:`assistant`,message:e.message,uuid:e.uuid,requestId:void 0,timestamp:new Date().toISOString()}];case`user`:return[{type:`user`,message:e.message,uuid:e.uuid??d(),timestamp:e.timestamp??new Date().toISOString(),isMeta:e.isSynthetic}];default:return[]}})}function p(e){let t=e.preservedSegment;return{trigger:e.trigger,pre_tokens:e.preTokens,...t&&{preserved_segment:{head_uuid:t.headUuid,anchor_uuid:t.anchorUuid,tail_uuid:t.tailUuid}}}}function m(e){let t=e,n=t.preserved_segment;return{trigger:t.trigger,preTokens:t.pre_tokens,...n&&{preservedSegment:{headUuid:n.head_uuid,anchorUuid:n.anchor_uuid,tailUuid:n.tail_uuid}}}}function h(e){return e.flatMap(e=>{if(!e)return[];switch(e.type){case`assistant`:return[{type:`assistant`,message:v(e),session_id:i(),parent_tool_use_id:null,uuid:e.uuid,error:e?.error}];case`user`:return[{type:`user`,message:e.message,session_id:i(),parent_tool_use_id:null,uuid:e.uuid,timestamp:e.timestamp,isSynthetic:e.isMeta||e.isVisibleInTranscriptOnly,...e.toolUseResult===void 0?{}:{tool_use_result:e.toolUseResult}}];case`system`:return e.subtype===`compact_boundary`&&e.compactMetadata?[{type:`system`,subtype:`compact_boundary`,session_id:i(),uuid:e.uuid,compact_metadata:p(e.compactMetadata)}]:e.subtype===`local_command`&&(e.content.includes(`<local-command-stdout>`)||e.content.includes(`<local-command-stderr>`))?[g(e.content,e.uuid)]:[];default:return[]}})}function g(e,t){let r=s({content:n(e).replace(/<local-command-stdout>([\s\S]*?)<\/local-command-stdout>/,`$1`).replace(/<local-command-stderr>([\s\S]*?)<\/local-command-stderr>/,`$1`).trim()});return{type:`assistant`,content:r.message?.content,message:r.message,parent_tool_use_id:null,session_id:i(),uuid:t}}function _(e){if(e)return{type:`rate_limit`,status:e.status,...e.resetsAt!==void 0&&{resetsAt:e.resetsAt},...e.rateLimitType!==void 0&&{rateLimitType:e.rateLimitType},...e.utilization!==void 0&&{utilization:e.utilization},...e.overageStatus!==void 0&&{overageStatus:e.overageStatus},...e.overageResetsAt!==void 0&&{overageResetsAt:e.overageResetsAt},...e.overageDisabledReason!==void 0&&{overageDisabledReason:e.overageDisabledReason},...e.isUsingOverage!==void 0&&{isUsingOverage:e.isUsingOverage},...e.surpassedThreshold!==void 0&&{surpassedThreshold:e.surpassedThreshold}}}function v(e){let t=e.message.content;if(!Array.isArray(t))return e.message;let n=t.map(e=>{if(e.type!==`tool_use`)return e;if(e.name===`ExitPlanMode`){let t=o();if(t)return{...e,input:{...e.input,plan:t}}}return e});return{...e.message,content:n}}var y=e((()=>{r(),l(),u(),t(),c(),a()}));export{p as a,f as i,y as n,h as o,g as r,_ as s,m as t};
@@ -0,0 +1,2 @@
1
+ import{G as e,Gp as t,Ia as n,La as r,Rd as i,TC as a,W as o,Wp as s,Xu as c,Yu as l,aw as u,iw as d,nl as f,po as p,tl as m,wC as h,zd as g,zo as _}from"./loadAgentsDir-nzr38hai.js";import{E as v,O as y}from"./debug-IKW-jE7K.js";import{o as b,s as x}from"./log-B3eB4EFv.js";import{_ as S,u as C}from"./model-DfFA3qMO.js";import{Cn as w,Sn as T,xn as E}from"./prompt-Bef63FhB.js";import{a as D,o as O}from"./fileStateCache-DDW5toIs.js";import{I as k,K as A,f as j}from"./stdio-W_Kokrkh.js";import{n as M,t as N}from"./stdio-4S7b8Uhx.js";A(),a(),n(),w(),c(),u(),O(),b(),_(),S(),e(),s(),v(),g(),m();var P=[r];async function F(e,n,r){let a=D(100);t(e);let s=new M({name:`claude/tengu`,version:`0.0.1`},{capabilities:{tools:{}}});s.setRequestHandler(k,async()=>{let e=T(),t=l(e);return{tools:await Promise.all(t.map(async n=>{let r;if(n.outputSchema){let e=f(n.outputSchema);typeof e==`object`&&e&&`type`in e&&e.type===`object`&&(r=e)}return{...n,description:await n.prompt({getToolPermissionContext:async()=>e,tools:t,agents:[]}),inputSchema:f(n.inputSchema),outputSchema:r}}))}}),s.setRequestHandler(j,async({params:{name:e,arguments:t}})=>{let s=l(T()),c=E(s,e);if(!c)throw Error(`Tool ${e} not found`);let u={abortController:d(),options:{commands:P,tools:s,mainLoopModel:C(),thinkingConfig:{type:`disabled`},mcpClients:[],mcpResources:{},isNonInteractiveSession:!0,debug:n,verbose:r,agentDefinitions:{activeAgents:[],allAgents:[]}},getAppState:()=>h(),setAppState:()=>{},messages:[],readFileState:a,setInProgressToolUseIDs:()=>{},setResponseLength:()=>{},updateFileHistoryState:()=>{},updateAttributionState:()=>{}};try{if(!c.isEnabled())throw Error(`Tool ${e} is not enabled`);let n=await c.validateInput?.(t??{},u);if(n&&!n.result)throw Error(`Tool ${e} input is invalid: ${`message`in n?n.message:String(n)}`);let r=await c.call(t??{},u,o,p({content:[]}));return{content:[{type:`text`,text:typeof r==`string`?r:y(r.data)}]}}catch(e){return x(e),{isError:!0,content:[{type:`text`,text:(e instanceof Error?i(e):[String(e)]).filter(Boolean).join(`
2
+ `).trim()||`Error`}]}}});async function c(){let e=new N;await s.connect(e)}return await c()}export{F as startMCPServer};
@@ -0,0 +1,6 @@
1
+ import{o as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./p-map-HKDr3iDo.js";import{D as r,H as i,I as a,P as o,T as s,fi as c,j as ee,kn as l,t as u,y as d}from"./src-CDCSSo0U2.js";import{t as f}from"./jsx-runtime-Bb4Xn-E0.js";import{B_ as p,ES as m,F_ as h,Fb as te,G_ as g,H_ as _,Hb as v,Ib as y,Jy as b,M_ as x,OS as S,U_ as ne,Vb as re,Y_ as C,Yy as ie,a_ as ae,ag as oe,b_ as w,cS as se,dg as T,e_ as E,j_ as D,lS as O,lg as k,n_ as A,r_ as j,s_ as M,t_ as N,x_ as P}from"./loadAgentsDir-nzr38hai.js";import{K as F,U as I}from"./debug-IKW-jE7K.js";import{c as L,g as R,o as z,y as B}from"./config-C7YHKCPV.js";import{n as V,o as H}from"./process-gEbdy6uY.js";import{i as U,o as W}from"./platform-EtecGacO.js";import{s as ce,u as G}from"./types-a7X-tJpJ.js";import{n as le,r as K}from"./analytics-BotDBGh0.js";import{l as q,o as ue}from"./stringUtils-CvXbHQRH.js";import{n as J,t as Y}from"./exit-BOhGfSlm.js";import{stat as de}from"fs/promises";import{cwd as fe}from"process";n();var X=e(c(),1);S(),V(),u(),g(),ue(),v(),y();var Z=f();function pe({servers:e,scope:t,onDone:n}){let c=Object.keys(e),[l,u]=(0,X.useState)({});(0,X.useEffect)(()=>{p().then(({servers:e})=>u(e))},[]);let f=c.filter(e=>l[e]!==void 0);async function g(n){let r=0;for(let i of n){let n=e[i];if(n){let e=i;if(l[e]!==void 0){let t=1;for(;l[`${i}_${t}`]!==void 0;)t++;e=`${i}_${t}`}await h(e,n,t),r++}}v(r)}let[_]=i(),v=(0,X.useCallback)(e=>{H(e>0?`\n${ee(`success`,_)(`Successfully imported ${e} MCP ${q(e,`server`)} to ${t} config.`)}\n`:`
2
+ No servers were imported.`),n(),m()},[_,t,n]),y=(0,X.useCallback)(()=>{v(0)},[v]);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(d,{title:`Import MCP Servers from Claude Desktop`,subtitle:`Found ${c.length} MCP ${q(c.length,`server`)} in Claude Desktop.`,color:`success`,onCancel:y,hideInputGuide:!0,children:[f.length>0&&(0,Z.jsx)(o,{color:`warning`,children:`Note: Some servers already exist with the same name. If selected, they will be imported with a numbered suffix.`}),(0,Z.jsx)(o,{children:`Please select the servers you want to import:`}),(0,Z.jsx)(te,{options:c.map(e=>({label:`${e}${f.includes(e)?` (already exists)`:``}`,value:e})),defaultValue:c.filter(e=>!f.includes(e)),onSubmit:g,onCancel:y,hideIndexes:!0})]}),(0,Z.jsx)(a,{paddingX:1,children:(0,Z.jsx)(o,{dimColor:!0,italic:!0,children:(0,Z.jsxs)(s,{children:[(0,Z.jsx)(r,{shortcut:`Space`,action:`select`}),(0,Z.jsx)(r,{shortcut:`Enter`,action:`confirm`}),(0,Z.jsx)(re,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})})]})}u(),ie(),le(),j(),T(),g(),x(),O(),R(),I(),S(),ce(),W();async function Q(e,t){try{let n=await oe(e,t);return n.type===`connected`?`✓ Connected`:n.type===`needs-auth`?`! Needs authentication`:`✗ Failed to connect`}catch{return`✗ Connection error`}}async function me({debug:e,verbose:t}){let n=fe();K(`tengu_mcp_start`,{});try{await de(n)}catch(e){throw F(e)&&Y(`Error: Directory ${n} does not exist`),e}try{let{setup:r}=await import(`./setup-BKEnSLR9.js`);await r(n,`default`,!1,!1,void 0,!1);let{startMCPServer:i}=await import(`./mcp-CSFPAfaW.js`);await i(n,e??!1,t??!1)}catch(e){Y(`Error: Failed to start MCP server: ${e}`)}}async function he(e,t){let n=_(e),r=()=>{n&&(n.type===`sse`||n.type===`http`)&&(N(e,n),E(e,n))};try{if(t.scope){let n=P(t.scope);K(`tengu_mcp_delete`,{name:e,scope:n}),await C(e,n),r(),process.stdout.write(`Removed MCP server ${e} from ${n} config\n`),J(`File modified: ${w(n)}`)}let n=z(),i=L(),{servers:a}=ne(`project`),o=!!a[e],s=[];if(n.mcpServers?.[e]&&s.push(`local`),o&&s.push(`project`),i.mcpServers?.[e]&&s.push(`user`),s.length===0)Y(`No MCP server found with name: "${e}"`);else if(s.length===1){let t=s[0];K(`tengu_mcp_delete`,{name:e,scope:t}),await C(e,t),r(),process.stdout.write(`Removed MCP server "${e}" from ${t} config\n`),J(`File modified: ${w(t)}`)}else process.stderr.write(`MCP server "${e}" exists in multiple scopes:\n`),s.forEach(e=>{process.stderr.write(` - ${D(e)} (${w(e)})\n`)}),process.stderr.write(`
3
+ To remove from a specific scope, use:
4
+ `),s.forEach(t=>{process.stderr.write(` claude mcp remove "${e}" -s ${t}\n`)}),Y()}catch(e){Y(e.message)}}async function ge(){K(`tengu_mcp_list`,{});let{servers:e}=await p();if(Object.keys(e).length===0)console.log("No MCP servers configured. Use `claude mcp add` to add a server.");else{console.log(`Checking MCP server health...
5
+ `);let n=await t(Object.entries(e),async([e,t])=>({name:e,server:t,status:await Q(e,t)}),{concurrency:k()});for(let{name:e,server:t,status:r}of n)if(t.type===`sse`)console.log(`${e}: ${t.url} (SSE) - ${r}`);else if(t.type===`http`)console.log(`${e}: ${t.url} (HTTP) - ${r}`);else if(t.type===`claudeai-proxy`)console.log(`${e}: ${t.url} - ${r}`);else if(!t.type||t.type===`stdio`){let n=t,i=Array.isArray(n.args)?n.args:[];console.log(`${e}: ${n.command} ${i.join(` `)} - ${r}`)}}await m(0)}async function $(e){K(`tengu_mcp_get`,{name:e});let t=_(e);t||Y(`No MCP server found with name: ${e}`),console.log(`${e}:`),console.log(` Scope: ${D(t.scope)}`);let n=await Q(e,t);if(console.log(` Status: ${n}`),t.type===`sse`){if(console.log(` Type: sse`),console.log(` URL: ${t.url}`),t.headers){console.log(` Headers:`);for(let[e,n]of Object.entries(t.headers))console.log(` ${e}: ${n}`)}if(t.oauth?.clientId||t.oauth?.callbackPort){let n=[];t.oauth.clientId&&(n.push(`client_id configured`),A(e,t)?.clientSecret&&n.push(`client_secret configured`)),t.oauth.callbackPort&&n.push(`callback_port ${t.oauth.callbackPort}`),console.log(` OAuth: ${n.join(`, `)}`)}}else if(t.type===`http`){if(console.log(` Type: http`),console.log(` URL: ${t.url}`),t.headers){console.log(` Headers:`);for(let[e,n]of Object.entries(t.headers))console.log(` ${e}: ${n}`)}if(t.oauth?.clientId||t.oauth?.callbackPort){let n=[];t.oauth.clientId&&(n.push(`client_id configured`),A(e,t)?.clientSecret&&n.push(`client_secret configured`)),t.oauth.callbackPort&&n.push(`callback_port ${t.oauth.callbackPort}`),console.log(` OAuth: ${n.join(`, `)}`)}}else if(t.type===`stdio`){console.log(` Type: stdio`),console.log(` Command: ${t.command}`);let e=Array.isArray(t.args)?t.args:[];if(console.log(` Args: ${e.join(` `)}`),t.env){console.log(` Environment:`);for(let[e,n]of Object.entries(t.env))console.log(` ${e}=${n}`)}}console.log(`\nTo remove this server, run: claude mcp remove "${e}" -s ${t.scope}`),await m(0)}async function _e(e,t,n){try{let r=P(n.scope),i=G(t),a=n.clientSecret&&i&&typeof i==`object`&&`type`in i&&(i.type===`sse`||i.type===`http`)&&`url`in i&&typeof i.url==`string`&&`oauth`in i&&i.oauth&&typeof i.oauth==`object`&&`clientId`in i.oauth?await ae():void 0;await h(e,i,r);let o=i&&typeof i==`object`&&`type`in i?String(i.type||`stdio`):`stdio`;a&&i&&typeof i==`object`&&`type`in i&&(i.type===`sse`||i.type===`http`)&&`url`in i&&typeof i.url==`string`&&M(e,{type:i.type,url:i.url},a),K(`tengu_mcp_add`,{scope:r,source:`json`,type:o}),J(`Added ${o} MCP server ${e} to ${r} config`)}catch(e){Y(e.message)}}async function ve(e){try{let t=P(e.scope);K(`tengu_mcp_add`,{scope:t,platform:U(),source:`desktop`});let{readClaudeDesktopMcpServers:n}=await import(`./claudeDesktop-aUMx06RK.js`),r=await n();Object.keys(r).length===0&&J(`No MCP servers found in Claude Desktop configuration or configuration file does not exist.`);let{unmount:i}=await l((0,Z.jsx)(se,{children:(0,Z.jsx)(b,{children:(0,Z.jsx)(pe,{servers:r,scope:t,onDone:()=>{i()}})})}),{exitOnCtrlC:!0})}catch(e){Y(e.message)}}async function ye(){K(`tengu_mcp_reset_mcpjson_choices`,{}),B(e=>({...e,enabledMcpjsonServers:[],disabledMcpjsonServers:[],enableAllProjectMcpServers:!1})),J(`All project-scoped (.mcp.json) server approvals and rejections have been reset.
6
+ You will be prompted for approval next time you start Claude Code.`)}export{ve as mcpAddFromDesktopHandler,_e as mcpAddJsonHandler,$ as mcpGetHandler,ge as mcpListHandler,he as mcpRemoveHandler,ye as mcpResetChoicesHandler,me as mcpServeHandler};
@@ -0,0 +1 @@
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,t as r}from"./figures-5ThXQEtq.js";import{D as i,Gt as a,H as o,I as s,Lt as c,P as l,T as u,Wt as d,fi as f,j as p,t as m,y as h}from"./src-CDCSSo0U2.js";import{t as g}from"./jsx-runtime-Bb4Xn-E0.js";import{$g as _,$y as v,D_ as y,Hb as b,M_ as x,Mb as S,Nb as C,Qg as w,Vb as T,b_ as E,dS as D,i_ as O,k_ as k,lS as A,r_ as j,tb as ee,uS as M}from"./loadAgentsDir-nzr38hai.js";import{l as te,u as ne}from"./debug-IKW-jE7K.js";import{l as re,n as ie,o as ae}from"./stringUtils-CvXbHQRH.js";import{D as oe,O as se}from"./rcDebugLog-BUuD-X1D.js";import{u as ce}from"./referral-DP_GshTS.js";import{i as le,n as N,r as ue}from"./MCPConnectionManager-BX0LMz9J.js";import{n as de,t as fe}from"./McpParsingWarnings-WQrWJeWP.js";import{a as pe,c as P,i as F,l as me,n as he,o as I,r as ge,s as _e,t as ve,u as L}from"./PluginSettings-BD9JLV9-.js";function ye({agentServer:e,onCancel:t,onComplete:n}){let[a]=o(),[f,m]=(0,R.useState)(!1),[g,_]=(0,R.useState)(null),[y,b]=(0,R.useState)(null),x=(0,R.useRef)(null);(0,R.useEffect)(()=>()=>x.current?.abort(),[]),d(`confirm:no`,(0,R.useCallback)(()=>{f&&(x.current?.abort(),x.current=null,m(!1),b(null))},[f]),{context:`Confirmation`,isActive:f});let S=(0,R.useCallback)(async()=>{if(!e.needsAuth||!e.url)return;m(!0),_(null);let t=new AbortController;x.current=t;try{let r={type:e.transport,url:e.url};await O(e.name,r,b,t.signal),n?.(`Authentication successful for ${e.name}. The server will connect when the agent runs.`)}catch(e){e instanceof Error&&!(e instanceof w)&&_(e.message)}finally{m(!1),x.current=null}},[e,n]),E=ie(String(e.name));if(f)return(0,z.jsxs)(s,{flexDirection:`column`,gap:1,padding:1,children:[(0,z.jsxs)(l,{color:`claude`,children:[`Authenticating with `,e.name,`…`]}),(0,z.jsxs)(s,{children:[(0,z.jsx)(v,{}),(0,z.jsx)(l,{children:` A browser window will open for authentication`})]}),y&&(0,z.jsxs)(s,{flexDirection:`column`,children:[(0,z.jsx)(l,{dimColor:!0,children:`If your browser doesn't open automatically, copy this URL manually:`}),(0,z.jsx)(c,{url:y})]}),(0,z.jsx)(s,{marginLeft:3,children:(0,z.jsxs)(l,{dimColor:!0,children:[`Return here after authenticating in your browser.`,` `,(0,z.jsx)(T,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]})})]});let D=[];return e.needsAuth&&D.push({label:e.isAuthenticated?`Re-authenticate`:`Authenticate`,value:`auth`}),D.push({label:`Back`,value:`back`}),(0,z.jsxs)(h,{title:`${E} MCP Server`,subtitle:`agent-only`,onCancel:t,inputGuide:e=>e.pending?(0,z.jsxs)(l,{children:[`Press `,e.keyName,` again to exit`]}):(0,z.jsxs)(u,{children:[(0,z.jsx)(i,{shortcut:`↑↓`,action:`navigate`}),(0,z.jsx)(i,{shortcut:`Enter`,action:`confirm`}),(0,z.jsx)(T,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`go back`})]}),children:[(0,z.jsxs)(s,{flexDirection:`column`,gap:0,children:[(0,z.jsxs)(s,{children:[(0,z.jsx)(l,{bold:!0,children:`Type: `}),(0,z.jsx)(l,{dimColor:!0,children:e.transport})]}),e.url&&(0,z.jsxs)(s,{children:[(0,z.jsx)(l,{bold:!0,children:`URL: `}),(0,z.jsx)(l,{dimColor:!0,children:e.url})]}),e.command&&(0,z.jsxs)(s,{children:[(0,z.jsx)(l,{bold:!0,children:`Command: `}),(0,z.jsx)(l,{dimColor:!0,children:e.command})]}),(0,z.jsxs)(s,{children:[(0,z.jsx)(l,{bold:!0,children:`Used by: `}),(0,z.jsx)(l,{dimColor:!0,children:e.sourceAgents.join(`, `)})]}),(0,z.jsxs)(s,{marginTop:1,children:[(0,z.jsx)(l,{bold:!0,children:`Status: `}),(0,z.jsxs)(l,{children:[p(`inactive`,a)(r.radioOff),` not connected (agent-only)`]})]}),e.needsAuth&&(0,z.jsxs)(s,{children:[(0,z.jsx)(l,{bold:!0,children:`Auth: `}),e.isAuthenticated?(0,z.jsxs)(l,{children:[p(`success`,a)(r.tick),` authenticated`]}):(0,z.jsxs)(l,{children:[p(`warning`,a)(r.triangleUpOutline),` may need authentication`]})]})]}),(0,z.jsx)(s,{children:(0,z.jsx)(l,{dimColor:!0,children:`This server connects only when running the agent.`})}),g&&(0,z.jsx)(s,{children:(0,z.jsxs)(l,{color:`error`,children:[`Error: `,g]})}),(0,z.jsx)(s,{children:(0,z.jsx)(C,{options:D,onChange:async e=>{switch(e){case`auth`:await S();break;case`back`:t();break}},onCancel:t})})]})}var R,z,B=e((()=>{n(),R=t(f(),1),m(),ce(),j(),ae(),b(),S(),ee(),z=g()}));function V(e){switch(e){case`project`:return{label:`Project MCPs`,path:E(e)};case`user`:return{label:`User MCPs`,path:E(e)};case`local`:return{label:`Local MCPs`,path:E(e)};case`enterprise`:return{label:`Enterprise MCPs`};case`dynamic`:return{label:`Built-in MCPs`,path:`always available`};default:return{label:e}}}function be(e){let t=new Map;for(let n of e){let e=n.scope;t.has(e)||t.set(e,[]),t.get(e).push(n)}for(let[,e]of t)e.sort((e,t)=>e.name.localeCompare(t.name));return t}function xe({servers:e,agentServers:t=[],onSelectServer:n,onSelectAgentServer:d,onComplete:f}){let[m]=o(),[g,_]=(0,H.useState)(0),v=H.useMemo(()=>be(e.filter(e=>e.client.config.type!==`claudeai-proxy`)),[e]),y=H.useMemo(()=>e.filter(e=>e.client.config.type===`claudeai-proxy`).sort((e,t)=>e.name.localeCompare(t.name)),[e]),b=H.useMemo(()=>(v.get(`dynamic`)??[]).sort((e,t)=>e.name.localeCompare(t.name)),[v]),x=V(`dynamic`),S=H.useMemo(()=>{let e=[];for(let t of W){let n=v.get(t)??[];for(let t of n)e.push({type:`server`,server:t})}for(let t of y)e.push({type:`server`,server:t});for(let n of t)e.push({type:`agent-server`,agentServer:n});for(let t of b)e.push({type:`server`,server:t});return e},[v,y,t,b]),C=(0,H.useCallback)(()=>{f(`MCP dialog dismissed`,{display:`system`})},[f]);a({"confirm:previous":()=>_(e=>e===0?S.length-1:e-1),"confirm:next":()=>_(e=>e===S.length-1?0:e+1),"confirm:yes":(0,H.useCallback)(()=>{let e=S[g];e&&(e.type===`server`?n(e.server):e.type===`agent-server`&&d&&d(e.agentServer))},[S,g,n,d]),"confirm:no":C},{context:`Confirmation`});let w=e=>S.findIndex(t=>t.type===`server`&&t.server===e),E=e=>S.findIndex(t=>t.type===`agent-server`&&t.agentServer===e),D=ne(),O=e.some(e=>e.client.type===`failed`);if(e.length===0&&t.length===0)return null;let k=e=>{let t=w(e),n=g===t,i=``,a=``;if(e.client.type===`disabled`)i=p(`inactive`,m)(r.radioOff),a=`disabled`;else if(e.client.type===`connected`)i=p(`success`,m)(r.tick),a=`connected`;else if(e.client.type===`pending`){i=p(`inactive`,m)(r.radioOff);let{reconnectAttempt:t,maxReconnectAttempts:n}=e.client;a=t&&n?`reconnecting (${t}/${n})…`:`connecting…`}else e.client.type===`needs-auth`?(i=p(`warning`,m)(r.triangleUpOutline),a=`needs authentication`):(i=p(`error`,m)(r.cross),a=`failed`);return(0,U.jsxs)(s,{children:[(0,U.jsx)(l,{color:n?`suggestion`:void 0,children:n?`${r.pointer} `:` `}),(0,U.jsx)(l,{color:n?`suggestion`:void 0,children:e.name}),(0,U.jsxs)(l,{dimColor:!n,children:[` · `,i,` `]}),(0,U.jsx)(l,{dimColor:!n,children:a})]},`${e.name}-${t}`)},A=e=>{let t=E(e),n=g===t,i=e.needsAuth?p(`warning`,m)(r.triangleUpOutline):p(`inactive`,m)(r.radioOff),a=e.needsAuth?`may need auth`:`agent-only`;return(0,U.jsxs)(s,{children:[(0,U.jsx)(l,{color:n?`suggestion`:void 0,children:n?`${r.pointer} `:` `}),(0,U.jsx)(l,{color:n?`suggestion`:void 0,children:e.name}),(0,U.jsxs)(l,{dimColor:!n,children:[` · `,i,` `]}),(0,U.jsx)(l,{dimColor:!n,children:a})]},`agent-${e.name}-${t}`)},j=e.length+t.length;return(0,U.jsxs)(s,{flexDirection:`column`,children:[(0,U.jsx)(fe,{}),(0,U.jsx)(h,{title:`Manage MCP servers`,subtitle:`${j} ${re(j,`server`)}`,onCancel:C,hideInputGuide:!0,children:(0,U.jsxs)(s,{flexDirection:`column`,children:[W.map(e=>{let t=v.get(e);if(!t||t.length===0)return null;let n=V(e);return(0,U.jsxs)(s,{flexDirection:`column`,marginBottom:1,children:[(0,U.jsxs)(s,{paddingLeft:2,children:[(0,U.jsx)(l,{bold:!0,children:n.label}),n.path&&(0,U.jsxs)(l,{dimColor:!0,children:[` (`,n.path,`)`]})]}),t.map(e=>k(e))]},e)}),y.length>0&&(0,U.jsxs)(s,{flexDirection:`column`,marginBottom:1,children:[(0,U.jsx)(s,{paddingLeft:2,children:(0,U.jsx)(l,{bold:!0,children:`claude.ai`})}),y.map(e=>k(e))]}),t.length>0&&(0,U.jsxs)(s,{flexDirection:`column`,marginBottom:1,children:[(0,U.jsx)(s,{paddingLeft:2,children:(0,U.jsx)(l,{bold:!0,children:`Agent MCPs`})}),[...new Set(t.flatMap(e=>e.sourceAgents))].map(e=>(0,U.jsxs)(s,{flexDirection:`column`,marginTop:1,children:[(0,U.jsx)(s,{paddingLeft:2,children:(0,U.jsxs)(l,{dimColor:!0,children:[`@`,e]})}),t.filter(t=>t.sourceAgents.includes(e)).map(e=>A(e))]},e))]}),b.length>0&&(0,U.jsxs)(s,{flexDirection:`column`,marginBottom:1,children:[(0,U.jsxs)(s,{paddingLeft:2,children:[(0,U.jsx)(l,{bold:!0,children:x.label}),x.path&&(0,U.jsxs)(l,{dimColor:!0,children:[` (`,x.path,`)`]})]}),b.map(e=>k(e))]}),(0,U.jsxs)(s,{flexDirection:`column`,children:[O&&(0,U.jsx)(l,{dimColor:!0,children:D?`※ Error logs shown inline with --debug`:`※ Run claude --debug to see error logs`}),(0,U.jsxs)(l,{dimColor:!0,children:[(0,U.jsx)(c,{url:`https://code.claude.com/docs/en/mcp`,children:`https://code.claude.com/docs/en/mcp`}),` for help`]})]})]})}),(0,U.jsx)(s,{paddingX:1,children:(0,U.jsx)(l,{dimColor:!0,italic:!0,children:(0,U.jsxs)(u,{children:[(0,U.jsx)(i,{shortcut:`↑↓`,action:`navigate`}),(0,U.jsx)(i,{shortcut:`Enter`,action:`confirm`}),(0,U.jsx)(T,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`cancel`})]})})})]})}var H,U,W,G=e((()=>{n(),H=t(f(),1),m(),ce(),x(),te(),ae(),b(),de(),U=g(),W=[`project`,`local`,`user`,`enterprise`]}));function Se({serverName:e,onComplete:t}){let[n]=o(),i=D(),a=ue(),[c,u]=(0,K.useState)(!0),[d,f]=(0,K.useState)(null);return(0,K.useEffect)(()=>{async function n(){try{if(!i.getState().mcp.clients.find(t=>t.name===e)){f(`MCP server "${e}" not found`),u(!1),t(`MCP server "${e}" not found`);return}switch((await a(e)).client.type){case`connected`:u(!1),t(`Successfully reconnected to ${e}`);break;case`needs-auth`:f(`${e} requires authentication`),u(!1),t(`${e} requires authentication. Use /mcp to authenticate.`);break;case`pending`:case`failed`:case`disabled`:f(`Failed to reconnect to ${e}`),u(!1),t(`Failed to reconnect to ${e}`);break}}catch(e){let n=e instanceof Error?e.message:String(e);f(n),u(!1),t(`Error: ${n}`)}}n()},[e,a,i,t]),c?(0,q.jsxs)(s,{flexDirection:`column`,gap:1,padding:1,children:[(0,q.jsxs)(l,{color:`text`,children:[`Reconnecting to `,(0,q.jsx)(l,{bold:!0,children:e})]}),(0,q.jsxs)(s,{children:[(0,q.jsx)(v,{}),(0,q.jsx)(l,{children:` Establishing connection to MCP server`})]})]}):d?(0,q.jsxs)(s,{flexDirection:`column`,gap:1,padding:1,children:[(0,q.jsxs)(s,{children:[(0,q.jsxs)(l,{children:[p(`error`,n)(r.cross),` `]}),(0,q.jsxs)(l,{color:`error`,children:[`Failed to reconnect to `,e]})]}),(0,q.jsxs)(l,{dimColor:!0,children:[`Error: `,d]})]}):null}var K,q,J=e((()=>{n(),K=t(f(),1),m(),N(),A(),ee(),q=g()}));function Y({onComplete:e}){let t=M(e=>e.mcp),n=M(e=>e.agentDefinitions),r=t.clients,[i,a]=X.useState({type:`list`}),[o,s]=X.useState([]),c=(0,X.useMemo)(()=>y(n.allAgents),[n.allAgents]),l=X.useMemo(()=>r.filter(e=>e.name!==`ide`).sort((e,t)=>e.name.localeCompare(t.name)),[r]);switch(X.useEffect(()=>{let e=!1;async function n(){let n=await Promise.all(l.map(async e=>{let n=e.config.scope,r=e.config.type===`sse`,i=e.config.type===`http`,a=e.config.type===`claudeai-proxy`,o;if(r||i){let n=await new _(e.name,e.config).tokens(),r=oe()!==null&&e.type===`connected`,i=e.type===`connected`&&k(t.tools,e.name).length>0;o=!!n||r||i}let s={name:e.name,client:e,scope:n};return a?{...s,transport:`claudeai-proxy`,isAuthenticated:!1,config:e.config}:r?{...s,transport:`sse`,isAuthenticated:o,config:e.config}:i?{...s,transport:`http`,isAuthenticated:o,config:e.config}:{...s,transport:`stdio`,config:e.config}}));e||s(n)}return n(),()=>{e=!0}},[l,t.tools]),(0,X.useEffect)(()=>{o.length===0&&l.length>0||o.length===0&&c.length===0&&e("No MCP servers configured. Please run /doctor if this is unexpected. Otherwise, run `claude mcp --help` or visit https://code.claude.com/docs/en/mcp to learn more.")},[o.length,l.length,c.length,e]),i.type){case`list`:return(0,Z.jsx)(xe,{servers:o,agentServers:c,onSelectServer:e=>a({type:`server-menu`,server:e}),onSelectAgentServer:e=>a({type:`agent-server-menu`,agentServer:e}),onComplete:e,defaultTab:i.defaultTab});case`server-menu`:{let n=k(t.tools,i.server.name),r=i.server.transport===`claudeai-proxy`?`claude.ai`:`Claude Code`;return i.server.transport===`stdio`?(0,Z.jsx)(_e,{server:i.server,serverToolsCount:n.length,onViewTools:()=>a({type:`server-tools`,server:i.server}),onCancel:()=>a({type:`list`,defaultTab:r}),onComplete:e}):(0,Z.jsx)(me,{server:i.server,serverToolsCount:n.length,onViewTools:()=>a({type:`server-tools`,server:i.server}),onCancel:()=>a({type:`list`,defaultTab:r}),onComplete:e})}case`server-tools`:return(0,Z.jsx)(ge,{server:i.server,onSelectTool:(e,t)=>a({type:`server-tool-detail`,server:i.server,toolIndex:t}),onBack:()=>a({type:`server-menu`,server:i.server})});case`server-tool-detail`:{let e=k(t.tools,i.server.name)[i.toolIndex];return e?(0,Z.jsx)(pe,{tool:e,server:i.server,onBack:()=>a({type:`server-tools`,server:i.server})}):(a({type:`server-tools`,server:i.server}),null)}case`agent-server-menu`:return(0,Z.jsx)(ye,{agentServer:i.agentServer,onCancel:()=>a({type:`list`,defaultTab:`Agents`}),onComplete:e})}}var X,Z,Ce=e((()=>{X=t(f(),1),j(),x(),A(),se(),B(),G(),L(),P(),I(),F(),Z=g()})),we=e((()=>{B(),G(),J(),L(),Ce(),P(),I(),F()}));function Te({action:e,target:t,onComplete:n}){let r=M(e=>e.mcp.clients),i=le(),a=(0,Q.useRef)(!1);return(0,Q.useEffect)(()=>{if(a.current)return;a.current=!0;let o=e===`enable`,s=r.filter(e=>e.name!==`ide`),c=t===`all`?s.filter(e=>o?e.type===`disabled`:e.type!==`disabled`):s.filter(e=>e.name===t);if(c.length===0){n(t===`all`?`All MCP servers are already ${o?`enabled`:`disabled`}`:`MCP server "${t}" not found`);return}for(let e of c)i(e.name);n(t===`all`?`${o?`Enabled`:`Disabled`} ${c.length} MCP server(s)`:`MCP server "${t}" ${o?`enabled`:`disabled`}`)},[e,t,r,i,n]),null}async function Ee(e,t,n){if(n){let t=n.trim().split(/\s+/);if(t[0]===`no-redirect`)return(0,$.jsx)(Y,{onComplete:e});if(t[0]===`reconnect`&&t[1])return(0,$.jsx)(Se,{serverName:t.slice(1).join(` `),onComplete:e});if(t[0]===`enable`||t[0]===`disable`)return(0,$.jsx)(Te,{action:t[0],target:t.length>1?t.slice(1).join(` `):`all`,onComplete:e})}return process.env.USER_TYPE===`ant`?(0,$.jsx)(ve,{onComplete:e,args:`manage`,showMcpRedirectMessage:!0}):(0,$.jsx)(Y,{onComplete:e})}var Q,$;e((()=>{Q=t(f(),1),we(),J(),N(),A(),he(),$=g()}))();export{Ee as call};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{c as t,i as n,n as r,r as i,s as a,t as o}from"./isObject-C6qM3WEW.js";function s(e){if(!r(e))return!1;var t=i(e);return t==l||t==u||t==c||t==d}var c,l,u,d,f=e((()=>{n(),o(),c=`[object AsyncFunction]`,l=`[object Function]`,u=`[object GeneratorFunction]`,d=`[object Proxy]`})),p,m=e((()=>{a(),p=t[`__core-js_shared__`]}));function ee(e){return!!h&&h in e}var h,te=e((()=>{m(),h=function(){var e=/[^.]+$/.exec(p&&p.keys&&p.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}()}));function g(e){if(e!=null){try{return _.call(e)}catch{}try{return e+``}catch{}}return``}var _,v=e((()=>{_=Function.prototype.toString}));function ne(e){return!r(e)||ee(e)?!1:(s(e)?T:b).test(g(e))}var y,b,x,S,C,w,T,re=e((()=>{f(),te(),o(),v(),y=/[\\^$.*+?()[\]{}|]/g,b=/^\[object .+?Constructor\]$/,x=Function.prototype,S=Object.prototype,C=x.toString,w=S.hasOwnProperty,T=RegExp(`^`+C.call(w).replace(y,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`)}));function ie(e,t){return e?.[t]}var ae=e((()=>{}));function E(e,t){var n=ie(e,t);return ne(n)?n:void 0}var D=e((()=>{re(),ae()})),O,k=e((()=>{D(),O=E(Object,`create`)}));function oe(){this.__data__=O?O(null):{},this.size=0}var se=e((()=>{k()}));function ce(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}var le=e((()=>{}));function ue(e){var t=this.__data__;if(O){var n=t[e];return n===A?void 0:n}return j.call(t,e)?t[e]:void 0}var A,j,de=e((()=>{k(),A=`__lodash_hash_undefined__`,j=Object.prototype.hasOwnProperty}));function fe(e){var t=this.__data__;return O?t[e]!==void 0:M.call(t,e)}var M,pe=e((()=>{k(),M=Object.prototype.hasOwnProperty}));function me(e,t){var n=this.__data__;return this.size+=+!this.has(e),n[e]=O&&t===void 0?N:t,this}var N,he=e((()=>{k(),N=`__lodash_hash_undefined__`}));function P(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}var F=e((()=>{se(),le(),de(),pe(),he(),P.prototype.clear=oe,P.prototype.delete=ce,P.prototype.get=ue,P.prototype.has=fe,P.prototype.set=me}));function I(){this.__data__=[],this.size=0}var L=e((()=>{}));function R(e,t){return e===t||e!==e&&t!==t}var z=e((()=>{}));function B(e,t){for(var n=e.length;n--;)if(R(e[n][0],t))return n;return-1}var V=e((()=>{z()}));function ge(e){var t=this.__data__,n=B(t,e);return n<0?!1:(n==t.length-1?t.pop():H.call(t,n,1),--this.size,!0)}var H,_e=e((()=>{V(),H=Array.prototype.splice}));function ve(e){var t=this.__data__,n=B(t,e);return n<0?void 0:t[n][1]}var ye=e((()=>{V()}));function be(e){return B(this.__data__,e)>-1}var xe=e((()=>{V()}));function Se(e,t){var n=this.__data__,r=B(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}var Ce=e((()=>{V()}));function U(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}var W=e((()=>{L(),_e(),ye(),xe(),Ce(),U.prototype.clear=I,U.prototype.delete=ge,U.prototype.get=ve,U.prototype.has=be,U.prototype.set=Se})),G,K=e((()=>{D(),a(),G=E(t,`Map`)}));function we(){this.size=0,this.__data__={hash:new P,map:new(G||U),string:new P}}var Te=e((()=>{F(),W(),K()}));function Ee(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}var De=e((()=>{}));function q(e,t){var n=e.__data__;return Ee(t)?n[typeof t==`string`?`string`:`hash`]:n.map}var J=e((()=>{De()}));function Oe(e){var t=q(this,e).delete(e);return this.size-=+!!t,t}var ke=e((()=>{J()}));function Ae(e){return q(this,e).get(e)}var je=e((()=>{J()}));function Y(e){return q(this,e).has(e)}var Me=e((()=>{J()}));function Ne(e,t){var n=q(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}var Pe=e((()=>{J()}));function X(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}var Z=e((()=>{Te(),ke(),je(),Me(),Pe(),X.prototype.clear=we,X.prototype.delete=Oe,X.prototype.get=Ae,X.prototype.has=Y,X.prototype.set=Ne}));function Q(e,t){if(typeof e!=`function`||t!=null&&typeof t!=`function`)throw TypeError($);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],a=n.cache;if(a.has(i))return a.get(i);var o=e.apply(this,r);return n.cache=a.set(i,o)||a,o};return n.cache=new(Q.Cache||X),n}var $,Fe=e((()=>{Z(),$=`Expected a function`,Q.Cache=X}));export{G as a,W as c,E as d,D as f,s as g,f as h,Z as i,R as l,g as m,Q as n,K as o,v as p,X as r,U as s,Fe as t,z as u};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{E as t,O as n}from"./debug-IKW-jE7K.js";import{o as r,s as i}from"./log-B3eB4EFv.js";import{n as a,t as o}from"./index.min-D75yiGLN.js";function s(e,t=300*1e3){let r=new Map,a=new Map,o=async(...o)=>{let s=n(o),c=r.get(s),l=Date.now();if(!c){let t=a.get(s);if(t)return t;let n=e(...o);a.set(s,n);try{let e=await n;return a.get(s)===n&&r.set(s,{value:e,timestamp:l,refreshing:!1}),e}finally{a.get(s)===n&&a.delete(s)}}if(c&&l-c.timestamp>t&&!c.refreshing){c.refreshing=!0;let t=c;return e(...o).then(e=>{r.get(s)===t&&r.set(s,{value:e,timestamp:Date.now(),refreshing:!1})}).catch(e=>{i(e),r.get(s)===t&&r.delete(s)}),c.value}return r.get(s).value};return o.cache={clear:()=>{r.clear(),a.clear()}},o}function c(e,t,n=100){let r=new o({max:n}),i=(...n)=>{let i=t(...n),a=r.get(i);if(a!==void 0)return a;let o=e(...n);return r.set(i,o),o};return i.cache={clear:()=>r.clear(),size:()=>r.size,delete:e=>r.delete(e),get:e=>r.peek(e),has:e=>r.has(e)},i}var l=e((()=>{a(),r(),t()}));export{c as n,s as r,l as t};
@@ -0,0 +1 @@
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,o as r}from"./envUtils-DSxRz_kt.js";import{I as i,Lt as a,P as o,Wt as s,_ as c,di as l,fi as u,t as d,ui as ee,y as f}from"./src-CDCSSo0U2.js";import{t as p}from"./jsx-runtime-Bb4Xn-E0.js";import{en as m,nt as h}from"./state-4KQ3kaqz.js";import{$T as g,Mb as _,Nb as te,Un as v,Vn as ne,XT as y,au as b,hf as re,lS as x,mf as S,ou as C,tE as w,uS as T}from"./loadAgentsDir-nzr38hai.js";import{n as E,t as D}from"./cwd-BuJhkTrc.js";import{B as O,U as k}from"./debug-IKW-jE7K.js";import{g as A,y as j}from"./settings-5PQdphqC.js";import{I as M,P as N,j as ie}from"./config-C7YHKCPV.js";import{_ as P,r as F}from"./git-tyaWOgRL.js";import{o as I,s as L}from"./log-B3eB4EFv.js";import{f as R,l as ae}from"./file-D1cN3LMK.js";import{n as oe,r as z}from"./analytics-BotDBGh0.js";import{b as se,h as ce}from"./startupProfiler-DxRQteII.js";import{u as B}from"./referral-DP_GshTS.js";import{r as V,t as H}from"./browser-Bd7GeBH1.js";import{n as U,t as W}from"./useExitOnCtrlCDWithKeybindings-yAroCqu4.js";import{r as le,t as ue}from"./promptEditor-foiayhdY.js";import{homedir as de}from"os";import{join as G,relative as fe}from"path";import{mkdir as K,writeFile as pe}from"fs/promises";function me(e){return F(e)!==null}var he=e((()=>{P()}));function ge({onSelect:e,onCancel:t}){let r=(0,q.use)(g()),a=G(n(),`CLAUDE.md`),l=G(h(),`CLAUDE.md`),u=r.some(e=>e.path===a),d=r.some(e=>e.path===l),f=[...r.filter(e=>e.type!==`AutoMem`).map(e=>({...e,exists:!0})),...u?[]:[{path:a,type:`User`,content:``,exists:!1}],...d?[]:[{path:l,type:`Project`,content:``,exists:!1}]],p=new Map,m=f.map(e=>{let t=ae(e.path),n=e.exists?``:` (new)`,r=e.parent?(p.get(e.parent)??0)+1:0;p.set(e.path,r);let i=r>0?` `.repeat(r-1):``,o;o=e.type===`User`&&!e.isNested&&e.path===a?`User memory`:e.type===`Project`&&!e.isNested&&e.path===l?`Project memory`:r>0?`${i}L ${t}${n}`:`${t}`;let s,c=me(h());return s=e.type===`User`&&!e.isNested?`Saved in ~/.claude/CLAUDE.md`:e.type===`Project`&&!e.isNested&&e.path===l?`${c?`Checked in at`:`Saved in`} ./CLAUDE.md`:e.parent?`@-imported`:e.isNested?`dynamically loaded`:``,{label:o,value:e.path,description:s}}),_=[],v=T(e=>e.agentDefinitions);if(M()){_.push({label:`Open auto-memory folder`,value:`${X}${ie()}`,description:``});for(let e of v.activeAgents)if(e.memory){let t=ne(e.agentType,e.memory);_.push({label:`Open ${ee.bold(e.agentType)} agent memory`,value:`${X}${t}`,description:`${e.memory} scope`})}}m.push(..._);let y=Y&&m.some(e=>e.value===Y)?Y:m[0]?.value||``,[b,x]=(0,q.useState)(M),[S,w]=(0,q.useState)(C),[E]=(0,q.useState)(M),D=T(e=>Object.values(e.tasks).some(e=>e.type===`dream`&&e.status===`running`)),[O,k]=(0,q.useState)(null);(0,q.useEffect)(()=>{E&&re().then(k)},[E,D]);let A=D?`running`:O===null?``:O===0?`never`:`last ran ${ce(new Date(O))}`,[N,P]=(0,q.useState)(null),F=N!==null,I=+!!E;function L(){let e=!b;j(`userSettings`,{autoMemoryEnabled:e}),x(e),z(`tengu_auto_memory_toggled`,{enabled:e})}function R(){let e=!S;j(`userSettings`,{autoDreamEnabled:e}),w(e),z(`tengu_auto_dream_toggled`,{enabled:e})}return U(),s(`confirm:no`,t,{context:`Confirmation`}),s(`confirm:yes`,()=>{N===0?L():N===1&&R()},{context:`Confirmation`,isActive:F}),s(`select:next`,()=>{P(e=>e!==null&&e<I?e+1:null)},{context:`Select`,isActive:F}),s(`select:previous`,()=>{P(e=>e!==null&&e>0?e-1:e)},{context:`Select`,isActive:F}),(0,J.jsxs)(i,{flexDirection:`column`,width:`100%`,children:[(0,J.jsxs)(i,{flexDirection:`column`,marginBottom:1,children:[(0,J.jsx)(c,{isFocused:N===0,children:(0,J.jsxs)(o,{children:[`Auto-memory: `,b?`on`:`off`]})}),E&&(0,J.jsx)(c,{isFocused:N===1,styled:!1,children:(0,J.jsxs)(o,{color:N===1?`suggestion`:void 0,children:[`Auto-dream: `,S?`on`:`off`,A&&(0,J.jsxs)(o,{dimColor:!0,children:[` · `,A]}),!D&&S&&(0,J.jsx)(o,{dimColor:!0,children:` · /dream to run`})]})})]}),(0,J.jsx)(te,{defaultFocusValue:y,options:m,isDisabled:F,onChange:t=>{if(t.startsWith(X)){let e=t.slice(15);K(e,{recursive:!0}).catch(()=>{}).then(()=>V(e));return}Y=t,e(t)},onCancel:t,onUpFromFirstItem:()=>P(I)})]})}var q,J,Y,X,_e=e((()=>{l(),u(),q=t(u(),1),m(),W(),d(),B(),N(),oe(),b(),S(),x(),v(),H(),w(),r(),R(),se(),he(),A(),_(),J=p(),X=`__open_folder__`}));function ve(e){let t=de(),n=D(),r=e.startsWith(t)?`~`+e.slice(t.length):null,i=e.startsWith(n)?`./`+fe(n,e):null;return r&&i?r.length<=i.length?r:i:r||i||e}var ye=e((()=>{u(),d(),E(),p()}));function be({onDone:e}){let t=async t=>{try{t.includes(n())&&await K(n(),{recursive:!0});try{await pe(t,``,{encoding:`utf8`,flag:`wx`})}catch(e){if(O(e)!==`EEXIST`)throw e}await ue(t);let r=`default`,i=``;process.env.VISUAL?(r=`$VISUAL`,i=process.env.VISUAL):process.env.EDITOR&&(r=`$EDITOR`,i=process.env.EDITOR);let a=r==="default"?``:`Using ${r}="${i}".`,o=a?`> ${a} To change editor, set $EDITOR or $VISUAL environment variable.`:`> To use a different editor, set the $EDITOR or $VISUAL environment variable.`;e(`Opened memory file at ${ve(t)}\n\n${o}`,{display:`system`})}catch(t){L(t),e(`Error opening memory file: ${t}`)}},r=()=>{e(`Cancelled memory editing`,{display:`system`})};return(0,Q.jsx)(f,{title:`Memory`,onCancel:r,color:`remember`,children:(0,Q.jsxs)(i,{flexDirection:`column`,children:[(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(ge,{onSelect:t,onCancel:r})}),(0,Q.jsx)(i,{marginTop:1,children:(0,Q.jsxs)(o,{dimColor:!0,children:[`Learn more: `,(0,Q.jsx)(a,{url:`https://code.claude.com/docs/en/memory`})]})})]})})}var Z,Q,$;e((()=>{Z=t(u(),1),d(),_e(),ye(),w(),r(),k(),I(),le(),Q=p(),$=async e=>(y(),await g(),(0,Q.jsx)(be,{onDone:e}))}))();export{$ as call};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./memoize-BK3gG5ob.js";import{l as r,o as i}from"./envUtils-DSxRz_kt.js";import{C as a,H as o,R as s,en as c,ht as l,rt as u}from"./state-4KQ3kaqz.js";import{E as d,O as f,U as p,l as ee}from"./debug-IKW-jE7K.js";import{Jt as m,Xt as h,Zt as g,qt as te}from"./settings-5PQdphqC.js";import{_ as ne,m as re}from"./git-tyaWOgRL.js";import{r as ie,t as ae}from"./execFileNoThrow-COKYqVQj.js";import{a as _,n as oe,o as se,r as v}from"./platform-EtecGacO.js";import{It as y,Kt as ce,Mn as le,Vt as ue,_ as de,jn as b,u as x}from"./model-DfFA3qMO.js";import{i as fe,t as pe}from"./genericProcessUtils-F1Qcb1sO.js";import{extname as me}from"path";import{stat as he}from"fs/promises";import{AsyncLocalStorage as ge}from"async_hooks";function _e(){return process.platform===`linux`&&r(process.env.CLAUDE_CODE_BUBBLEWRAP)}function ve(){return process.platform===`linux`?T??!1:!1}async function S(){if(E!==void 0)return E;if(process.platform===`darwin`)return E=null,null;try{let e=await pe(process.pid,10);for(let t of e){let e=t.toLowerCase();for(let t of te)if(e.includes(t))return E=t,t}}catch{}return E=null,null}async function ye(){return process.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`&&m.platform!==`darwin`?await S()||`pycharm`:m.terminal}function be(){return process.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`&&m.platform!==`darwin`?E===void 0?`pycharm`:E||`pycharm`:m.terminal}async function C(){process.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`&&await S()}var w,T,E,D,O=e((()=>{n(),g(),i(),ie(),fe(),w=t(async()=>{if(process.platform!==`linux`)return!1;let{code:e}=await ae(`test`,[`-f`,`/.dockerenv`]);return e===0}),T=null,process.platform===`linux`&&he(`/lib/libc.musl-${process.arch===`x64`?`x86_64`:`aarch64`}.so.1`).then(()=>{T=!0},()=>{T=!1}),D={...m,terminal:be(),getIsDocker:w,getIsBubblewrapSandbox:_e,isMuslEnvironment:ve,getTerminalWithJetBrainsDetectionAsync:ye,initJetBrainsDetection:C}}));function k(e){return A?.has(e)??!1}var A,j=e((()=>{ee(),p()}));function M(){return P.getStore()}function N(e,t){return P.run(e,t)}function xe(e){return e?.agentType===`subagent`}function Se(){let e=M();if(!(!xe(e)||!e.subagentName))return e.isBuiltIn?e.subagentName:`user-defined`}function Ce(){let e=M();if(!(!e?.invokingRequestId||e.invocationEmitted))return e.invocationEmitted=!0,{invokingRequestId:e.invokingRequestId,invocationKind:e.invocationKind}}var P,F=e((()=>{P=new ge}));function we(e){return e.startsWith(`mcp__`)?`mcp_tool`:e}function I(){return r(process.env.OTEL_LOG_TOOL_DETAILS)}function Te(e,t){return!!(process.env.CLAUDE_CODE_ENTRYPOINT===`local-agent`||e===`claudeai-proxy`||t&&k(t))}function Ee(e,t,n){let r=L(e);return!r||!B.has(r.serverName)&&!Te(t,n)?{}:{mcpServerName:r.serverName,mcpToolName:r.mcpToolName}}function L(e){if(!e.startsWith(`mcp__`))return;let t=e.split(`__`);if(t.length<3)return;let n=t[1],r=t.slice(2).join(`__`);if(!(!n||!r))return{serverName:n,mcpToolName:r}}function De(e,t){if(e===`Skill`&&typeof t==`object`&&t&&`skill`in t&&typeof t.skill==`string`)return t.skill}function R(e,t=0){if(typeof e==`string`)return e.length>V?`${e.slice(0,H)}…[${e.length} chars]`:e;if(typeof e==`number`||typeof e==`boolean`||e==null)return e;if(t>=G)return`<nested>`;if(Array.isArray(e)){let n=e.slice(0,W).map(e=>R(e,t+1));return e.length>W&&n.push(`…[${e.length} items]`),n}if(typeof e==`object`){let n=Object.entries(e).filter(([e])=>!e.startsWith(`_`)),r=n.slice(0,W).map(([e,n])=>[e,R(n,t+1)]);return n.length>W&&r.push([`…`,`${n.length} keys`]),Object.fromEntries(r)}return String(e)}function Oe(e){if(!I())return;let t=f(R(e));return t.length>U&&(t=t.slice(0,U)+`…[truncated]`),t}function z(e){let t=me(e).toLowerCase();if(!t||t===`.`)return;let n=t.slice(1);return n.length>K?`other`:n}function ke(e,t){if(!e.includes(`.`)&&!t)return;let n,r=new Set;if(t){let e=z(t);e&&(r.add(e),n=e)}for(let t of e.split(J)){if(!t)continue;let e=t.split(Y);if(e.length<2)continue;let i=e[0],a=i.lastIndexOf(`/`),o=a>=0?i.slice(a+1):i;if(q.has(o))for(let t=1;t<e.length;t++){let i=e[t];if(i.charCodeAt(0)===45)continue;let a=z(i);a&&!r.has(a)&&(r.add(a),n=n?n+`,`+a:a)}}if(n)return n}function Ae(){let e=M();if(e)return{agentId:e.agentId,parentSessionId:e.parentSessionId,agentType:e.agentType};let t=process.env.CLAUDE_CODE_AGENT_ID,n=process.env.CLAUDE_CODE_PARENT_SESSION_ID,r=t?`standalone`:void 0;if(t||r||n)return{...t?{agentId:t}:{},...r?{agentType:r}:{},...n?{parentSessionId:n}:{}};let i=u();return i?{parentSessionId:i}:{}}function je(){try{let e=process.memoryUsage(),t=process.cpuUsage(),n=Date.now(),r;if(Q&&$){let e=n-$;e>0&&(r=(t.user-Q.user+(t.system-Q.system))/(e*1e3)*100)}return Q=t,$=n,{uptime:process.uptime(),rss:e.rss,heapTotal:e.heapTotal,heapUsed:e.heapUsed,external:e.external,arrayBuffers:e.arrayBuffers,constrainedMemory:process.constrainedMemory(),cpuUsage:t,cpuPercent:r}}catch{return}}async function Me(e={}){let t=e.model?String(e.model):x(),n=typeof e.betas==`string`?e.betas:b(t).join(`,`),[r,i]=await Promise.all([Z(),re()]),c=je();return{model:t,sessionId:l(),userType:process.env.USER_TYPE||``,...n.length>0?{betas:n}:{},envContext:r,...process.env.CLAUDE_CODE_ENTRYPOINT&&{entrypoint:process.env.CLAUDE_CODE_ENTRYPOINT},...process.env.CLAUDE_AGENT_SDK_VERSION&&{agentSdkVersion:process.env.CLAUDE_AGENT_SDK_VERSION},isInteractive:String(s()),clientType:a(),...c&&{processMetrics:c},sweBenchRunId:process.env.SWE_BENCH_RUN_ID||``,sweBenchInstanceId:process.env.SWE_BENCH_INSTANCE_ID||``,sweBenchTaskId:process.env.SWE_BENCH_TASK_ID||``,...Ae(),...y()&&{subscriptionType:y()},...o()?{kairosActive:!0}:{},...i&&{rh:i}}}function Ne(e,t,n={}){let{envContext:r,processMetrics:i,rh:a,kairosActive:o,skillMode:s,observerMode:c,...l}=e,u={platform:r.platform,platform_raw:r.platformRaw,arch:r.arch,node_version:r.nodeVersion,terminal:r.terminal||`unknown`,package_managers:r.packageManagers,runtimes:r.runtimes,is_running_with_bun:r.isRunningWithBun,is_ci:r.isCi,is_claubbit:r.isClaubbit,is_claude_code_remote:r.isClaudeCodeRemote,is_local_agent_mode:r.isLocalAgentMode,is_conductor:r.isConductor,is_github_action:r.isGithubAction,is_claude_code_action:r.isClaudeCodeAction,is_claude_ai_auth:r.isClaudeAiAuth,version:r.version,build_time:r.buildTime,deployment_environment:r.deploymentEnvironment};r.remoteEnvironmentType&&(u.remote_environment_type=r.remoteEnvironmentType),r.claudeCodeContainerId&&(u.claude_code_container_id=r.claudeCodeContainerId),r.claudeCodeRemoteSessionId&&(u.claude_code_remote_session_id=r.claudeCodeRemoteSessionId),r.tags&&(u.tags=r.tags.split(`,`).map(e=>e.trim()).filter(Boolean)),r.githubEventName&&(u.github_event_name=r.githubEventName),r.githubActionsRunnerEnvironment&&(u.github_actions_runner_environment=r.githubActionsRunnerEnvironment),r.githubActionsRunnerOs&&(u.github_actions_runner_os=r.githubActionsRunnerOs),r.githubActionRef&&(u.github_action_ref=r.githubActionRef),r.wslVersion&&(u.wsl_version=r.wslVersion),r.linuxDistroId&&(u.linux_distro_id=r.linuxDistroId),r.linuxDistroVersion&&(u.linux_distro_version=r.linuxDistroVersion),r.linuxKernel&&(u.linux_kernel=r.linuxKernel),r.vcs&&(u.vcs=r.vcs),r.versionBase&&(u.version_base=r.versionBase);let d={session_id:l.sessionId,model:l.model,user_type:l.userType,is_interactive:l.isInteractive===`true`,client_type:l.clientType};if(l.betas&&(d.betas=l.betas),l.entrypoint&&(d.entrypoint=l.entrypoint),l.agentSdkVersion&&(d.agent_sdk_version=l.agentSdkVersion),l.sweBenchRunId&&(d.swe_bench_run_id=l.sweBenchRunId),l.sweBenchInstanceId&&(d.swe_bench_instance_id=l.sweBenchInstanceId),l.sweBenchTaskId&&(d.swe_bench_task_id=l.sweBenchTaskId),l.agentId&&(d.agent_id=l.agentId),l.parentSessionId&&(d.parent_session_id=l.parentSessionId),l.agentType&&(d.agent_type=l.agentType),t.githubActionsMetadata){let e=t.githubActionsMetadata;u.github_actions_metadata={actor_id:e.actorId,repository_id:e.repositoryId,repository_owner_id:e.repositoryOwnerId}}let p;return(t.accountUuid||t.organizationUuid)&&(p={account_uuid:t.accountUuid,organization_uuid:t.organizationUuid}),{env:u,...i&&{process:Buffer.from(f(i)).toString(`base64`)},...p&&{auth:p},core:d,additional:{...a&&{rh:a},...o&&{is_assistant_mode:!0},...s&&{skill_mode:s},...c&&{observer_mode:c},...n}}}var B,V,H,U,W,G,K,q,J,Y,X,Z,Q,$,Pe=e((()=>{n(),g(),O(),le(),de(),c(),i(),j(),ue(),ne(),se(),F(),d(),B=new Set,V=512,H=128,U=4*1024,W=20,G=2,K=10,q=new Set([`rm`,`mv`,`cp`,`touch`,`mkdir`,`chmod`,`chown`,`cat`,`head`,`tail`,`sort`,`stat`,`diff`,`wc`,`grep`,`rg`,`sed`]),J=/\s*(?:&&|\|\||[;|])\s*/,Y=/\s+/,X=t(()=>{let e=`0.0.1`.match(/^\d+\.\d+\.\d+(?:-[a-z]+)?/);return e?e[0]:void 0}),Z=t(async()=>{let[e,t,n,i]=await Promise.all([m.getPackageManagers(),m.getRuntimes(),v(),oe()]);return{platform:h(),platformRaw:process.env.CLAUDE_CODE_HOST_PLATFORM||process.platform,arch:m.arch,nodeVersion:m.nodeVersion,terminal:D.terminal,packageManagers:e.join(`,`),runtimes:t.join(`,`),isRunningWithBun:m.isRunningWithBun(),isCi:r(process.env.CI),isClaubbit:r(process.env.CLAUBBIT),isClaudeCodeRemote:r(process.env.CLAUDE_CODE_REMOTE),isLocalAgentMode:process.env.CLAUDE_CODE_ENTRYPOINT===`local-agent`,isConductor:m.isConductor(),...process.env.CLAUDE_CODE_REMOTE_ENVIRONMENT_TYPE&&{remoteEnvironmentType:process.env.CLAUDE_CODE_REMOTE_ENVIRONMENT_TYPE},...process.env.CLAUDE_CODE_CONTAINER_ID&&{claudeCodeContainerId:process.env.CLAUDE_CODE_CONTAINER_ID},...process.env.CLAUDE_CODE_REMOTE_SESSION_ID&&{claudeCodeRemoteSessionId:process.env.CLAUDE_CODE_REMOTE_SESSION_ID},...process.env.CLAUDE_CODE_TAGS&&{tags:process.env.CLAUDE_CODE_TAGS},isGithubAction:r(process.env.GITHUB_ACTIONS),isClaudeCodeAction:r(process.env.CLAUDE_CODE_ACTION),isClaudeAiAuth:ce(),version:`0.0.1`,versionBase:X(),buildTime:`2026-07-12T13:57:24.344Z`,deploymentEnvironment:m.detectDeploymentEnvironment(),...r(process.env.GITHUB_ACTIONS)&&{githubEventName:process.env.GITHUB_EVENT_NAME,githubActionsRunnerEnvironment:process.env.RUNNER_ENVIRONMENT,githubActionsRunnerOs:process.env.RUNNER_OS,githubActionRef:process.env.GITHUB_ACTION_PATH?.includes(`claude-code-action/`)?process.env.GITHUB_ACTION_PATH.split(`claude-code-action/`)[1]:void 0},..._()&&{wslVersion:_()},...n??{},...i.length>0?{vcs:i.join(`,`)}:{}}}),Q=null,$=null}));export{D as _,z as a,I as c,Ne as d,Ce as f,N as g,F as h,Me as i,Ee as l,Se as m,De as n,ke as o,M as p,Oe as r,Pe as s,L as t,we as u,C as v,O as y};
@@ -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(){return(0,a.useContext)(o)!==null}function i(e){let t=(0,a.useContext)(o);return t?{rows:t.rows,columns:t.columns}:e}var a,o,s=e((()=>{a=t(n(),1),o=(0,a.createContext)(null)}));export{i,s as n,r,o as t};
@@ -0,0 +1,2 @@
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{I as n,P as r,fi as i,t as a}from"./src-CDCSSo0U2.js";import{t as o}from"./jsx-runtime-Bb4Xn-E0.js";import{Nb as s,Pb as c,dt as l,ft as u,mt as d,pt as f}from"./loadAgentsDir-nzr38hai.js";function p({onDone:e}){let t=f(),i=l(),a=(0,m.useMemo)(()=>t.map(e=>({label:(0,h.jsxs)(r,{children:[e.icon,` `,e.name,` `,(0,h.jsxs)(r,{dimColor:!0,children:[`(`,e.slug,`) — `,e.description]})]}),value:e.slug})),[t]);function o(n){d(n);let r=t.find(e=>e.slug===n);e(`${r?.icon} Mode switched to: ${r?.name} (${r?.slug}) — ${r?.description}`,{display:`system`})}function c(){e(`Mode selection cancelled.`,{display:`system`})}return(0,h.jsxs)(n,{flexDirection:`column`,children:[(0,h.jsxs)(n,{marginBottom:1,flexDirection:`column`,children:[(0,h.jsx)(r,{color:`remember`,bold:!0,children:`Select mode`}),(0,h.jsx)(r,{dimColor:!0,children:`Arrow keys to navigate, Enter to select, Esc to cancel.`})]}),(0,h.jsx)(s,{defaultValue:i,options:a,onChange:o,onCancel:c,visibleOptionCount:t.length})]})}var m,h,g;e((()=>{m=t(i(),1),a(),c(),u(),h=o(),g=async(e,t,n)=>{let r=n?.trim().toLowerCase();if(r){let t=f(),n=t.find(e=>e.slug===r);if(!n){e(`Unknown mode: "${r}"\n\nAvailable modes:\n${t.map(e=>`${e.icon} ${e.slug} — ${e.description}`).join(`
2
+ `)}`,{display:`system`});return}d(r),e(`${n.icon} Mode switched to: ${n.name} (${n.slug}) — ${n.description}`,{display:`system`});return}return(0,h.jsx)(p,{onDone:e})}}))();export{g as call};
@@ -0,0 +1 @@
1
+ import{_ as e,u as t}from"./model-DfFA3qMO.js";e();export{t as getMainLoopModel};
@@ -0,0 +1 @@
1
+ import{n as e,o as t}from"./rolldown-runtime-DaDcL9Zw.js";import{di as n,fi as r,ui as i}from"./src-CDCSSo0U2.js";import{t as a}from"./jsx-runtime-Bb4Xn-E0.js";import{Ad as o,fS as s,gh as c,hh as l,kd as u,lS as d,mh as f,uS as p}from"./loadAgentsDir-nzr38hai.js";import{D as m,E as h,Y as g}from"./log-B3eB4EFv.js";import{n as _,r as v}from"./analytics-BotDBGh0.js";import{F as y,I as b,N as x,P as S,_ as C,at as w,b as T,it as E,nt as D,q as O,s as k,tt as A,w as j}from"./model-DfFA3qMO.js";import{i as M,n as N,r as P,t as F}from"./extraUsage-BYZdi44Y.js";function I({onDone:e}){let t=p(e=>e.mainLoopModel),n=p(e=>e.mainLoopModelForSession),r=p(e=>e.fastMode),a=s();function o(){v(`tengu_model_command_menu`,{action:`cancel`});let n=H(t);e(`Kept model as ${i.bold(n)}`,{display:`system`})}function c(n,o){v(`tengu_model_command_menu`,{action:n,from_model:t,to_model:n}),a(e=>({...e,mainLoopModel:n,mainLoopModelForSession:null}));let s=`Set model to ${i.bold(H(n))}`;o!==void 0&&(s+=` with ${i.bold(o)} effort`);let c;E()&&(O(),!w(n)&&r?(a(e=>({...e,fastMode:!1})),c=!1):w(n)&&D()&&r&&(s+=` · Fast mode ON`,c=!0)),N(n,c===!0,T())&&(s+=` · Billed as extra usage`),c===!1&&(s+=` · Fast mode OFF`),e(s)}return(0,W.jsx)(P,{initial:t,sessionModel:n,onSelect:c,onCancel:o,isStandaloneCommand:!0,showFastModeNotice:E()&&r&&w(t)&&D()})}function L({args:e,onDone:t}){let n=p(e=>e.fastMode),r=s(),a=e==="default"?null:e;return U.useEffect(()=>{async function e(){if(a&&!S(a)){t(`Model '${a}' is not available. Your organization restricts model selection.`,{display:`system`});return}if(a&&z(a)){t(`Opus 4.7 with 1M context is not available for your account. Learn more: https://code.claude.com/docs/en/model-config#extended-context-with-1m`,{display:`system`});return}if(a&&B(a)){t(`Sonnet 4.6 with 1M context is not available for your account. Learn more: https://code.claude.com/docs/en/model-config#extended-context-with-1m`,{display:`system`});return}if(!a){s(null);return}if(R(a)){s(a);return}try{let{valid:e,error:n}=await o(a);e?s(a):t(n||`Model '${a}' not found`,{display:`system`})}catch(e){t(`Failed to validate model: ${e.message}`,{display:`system`})}}function s(e){r(t=>({...t,mainLoopModel:e,mainLoopModelForSession:null}));let a=`Set model to ${i.bold(H(e))}`,o;E()&&(O(),!w(e)&&n?(r(e=>({...e,fastMode:!1})),o=!1):w(e)&&n&&(a+=` · Fast mode ON`,o=!0)),N(e,o===!0,T())&&(a+=` · Billed as extra usage`),o===!1&&(a+=` · Fast mode OFF`),t(a)}e()},[a,t,r]),null}function R(e){return y.includes(e.toLowerCase().trim())}function z(e){let t=e.toLowerCase();return!f()&&!T()&&t.includes(`opus`)&&t.includes(`[1m]`)}function B(e){let t=e.toLowerCase();return!l()&&(t.includes(`sonnet[1m]`)||t.includes(`sonnet-4-6[1m]`))}function V({onDone:e}){let t=p(e=>e.mainLoopModel),n=p(e=>e.mainLoopModelForSession),r=p(e=>e.effortValue),a=H(t),o=r===void 0?``:` (effort: ${r})`;return e(n?`Current model: ${i.bold(H(n))} (session override from plan mode)\nBase model: ${a}${o}`:`Current model: ${a}${o}`),null}function H(e){let t=j(e??k());return e===null?`${t} (default)`:t}var U,W,G;e((()=>{n(),U=t(r(),1),M(),g(),_(),d(),F(),A(),b(),c(),C(),x(),u(),W=a(),G=async(e,t,n)=>{if(n=n?.trim()||``,m.includes(n))return v(`tengu_model_command_inline_help`,{args:n}),(0,W.jsx)(V,{onDone:e});if(h.includes(n)){e(`Run /model to open the model selection menu, or /model [modelName] to set the model.`,{display:`system`});return}return n?(v(`tengu_model_command_inline`,{args:n}),(0,W.jsx)(L,{args:n,onDone:e})):(0,W.jsx)(I,{onDone:e})}}))();export{G as call};
@@ -0,0 +1 @@
1
+ import{n as e,o as t,r as n}from"./rolldown-runtime-DaDcL9Zw.js";import{n as r,t as i}from"./memoize-BK3gG5ob.js";import{d as a,i as o,l as s,n as c,o as l,s as u,t as d}from"./envUtils-DSxRz_kt.js";import{n as ee,t as te}from"./defineProperty-C-QyHrDq.js";import{n as f,t as p}from"./axios-DaWTGg7G.js";import{di as ne,ui as re}from"./src-CDCSSo0U2.js";import{A as ie,C as ae,p as oe,t as se,w as ce}from"./v4-jw6qOKwQ.js";import{$ as le,H as ue,Jr as de,On as fe,Sr as pe,X as me,Xn as he,Yr as ge,_n as _e,en as m,ht as ve,pt as ye,qn as be,sn as xe,tt as Se,xr as Ce,y as we,z as h}from"./state-4KQ3kaqz.js";import{A as Te,B as Ee,D as De,E as Oe,G as ke,O as Ae,U as je,X as Me,Y as Ne,_ as Pe,d as Fe,f as Ie,h as Le,l as g,p as _,z as v}from"./debug-IKW-jE7K.js";import{Kt as Re,c as y,f as b,g as ze,n as Be,y as Ve}from"./settings-5PQdphqC.js";import{C as He,b as x,c as S,g as Ue,n as C,w as We}from"./config-C7YHKCPV.js";import{a as Ge,c as Ke,i as qe,o as Je,r as Ye,s as Xe,t as Ze}from"./execFileNoThrow-COKYqVQj.js";import{d as Qe,f as $e,o as et,s as w}from"./log-B3eB4EFv.js";import{r as tt,t as nt}from"./memoize-BO31Ws9Q.js";import{s as rt,u as it}from"./types-a7X-tJpJ.js";import{n as at,r as T}from"./analytics-BotDBGh0.js";import{n as ot,t as st}from"./lazySchema-uxlVVNM1.js";import{l as E,n as ct,r as lt,s as ut,t as dt,u as D}from"./oauth-BqJqV-2M.js";import{n as ft,t as pt}from"./bundledMode--fG1S62b.js";import{n as mt,o as ht}from"./stringUtils-CvXbHQRH.js";import{a as gt,i as _t,l as vt}from"./proxy-Cn2YwITp.js";import{userInfo as yt}from"os";import{join as bt}from"path";import{chmodSync as xt,mkdirSync as St,readFileSync as Ct,writeFileSync as wt}from"fs";import{createHash as Tt,randomUUID as Et}from"crypto";import{mkdir as Dt,stat as Ot,writeFile as kt}from"fs/promises";import{exec as At,execFile as jt}from"child_process";import{AsyncLocalStorage as Mt}from"async_hooks";function Nt(){return process.env.USER_TYPE,null}function Pt(){return process.env.USER_TYPE===`ant`?Nt()?.antModels??[]:[]}function Ft(e){if(process.env.USER_TYPE!==`ant`||e===void 0)return;let t=e.toLowerCase();return Pt().find(n=>n.alias===e||t.includes(n.model.toLowerCase()))}var It=e((()=>{}));function Lt(e){let t=[],n=!1;async function r(){if(!n&&t.length!==0){for(n=!0;t.length>0;){let{args:n,resolve:r,reject:i,context:a}=t.shift();try{r(await e.apply(a,n))}catch(e){i(e)}}n=!1,t.length>0&&r()}}return function(...e){return new Promise((n,i)=>{t.push({args:e,resolve:n,reject:i,context:this}),r()})}}var Rt=e((()=>{}));function zt(e,t){return e.find(e=>e.includes(t))??null}async function Bt(){let{BedrockClient:e}=await import(`./dist-es-yHGBqhBe.js`),t=d(),n=s(process.env.CLAUDE_CODE_SKIP_BEDROCK_AUTH),r={region:t,...process.env.ANTHROPIC_BEDROCK_BASE_URL&&{endpoint:process.env.ANTHROPIC_BEDROCK_BASE_URL},...await _t(),...n&&{requestHandler:new(await(import(`./dist-es-C7vygWzp.js`))).NodeHttpHandler,httpAuthSchemes:[{schemeId:`smithy.api#noAuth`,identityProvider:()=>async()=>({}),signer:new(await(import(`./dist-es-gUzZ_7Vf.js`))).NoAuthSigner}],httpAuthSchemeProvider:()=>[{schemeId:`smithy.api#noAuth`}]}};if(!n&&!process.env.AWS_BEARER_TOKEN_BEDROCK){let e=await W();e&&(r.credentials={accessKeyId:e.accessKeyId,secretAccessKey:e.secretAccessKey,sessionToken:e.sessionToken})}return new e(r)}async function Vt(){let{BedrockRuntimeClient:e}=await import(`./dist-es-Gt_DpXlP.js`),t=d(),n=s(process.env.CLAUDE_CODE_SKIP_BEDROCK_AUTH),r={region:t,...process.env.ANTHROPIC_BEDROCK_BASE_URL&&{endpoint:process.env.ANTHROPIC_BEDROCK_BASE_URL},...await _t(),...n&&{requestHandler:new(await(import(`./dist-es-C7vygWzp.js`))).NodeHttpHandler,httpAuthSchemes:[{schemeId:`smithy.api#noAuth`,identityProvider:()=>async()=>({}),signer:new(await(import(`./dist-es-gUzZ_7Vf.js`))).NoAuthSigner}],httpAuthSchemeProvider:()=>[{schemeId:`smithy.api#noAuth`}]}};if(!n&&!process.env.AWS_BEARER_TOKEN_BEDROCK){let e=await W();e&&(r.credentials={accessKeyId:e.accessKeyId,secretAccessKey:e.secretAccessKey,sessionToken:e.sessionToken})}return new e(r)}function Ht(e){return e.startsWith(`anthropic.`)}function Ut(e){if(!e.startsWith(`arn:`))return e;let t=e.lastIndexOf(`/`);return t===-1?e:e.substring(t+1)}function Wt(e){let t=Ut(e);for(let e of Jt)if(t.startsWith(`${e}.anthropic.`))return e}function Gt(e,t){let n=Wt(e);return n?e.replace(`${n}.`,`${t}.`):Ht(e)?`${t}.${e}`:e}var Kt,qt,Jt,Yt=e((()=>{i(),K(),l(),et(),vt(),Kt=r(async function(){let[e,{ListInferenceProfilesCommand:t}]=await Promise.all([Bt(),import(`./dist-es-yHGBqhBe.js`)]),n=[],r;try{do{let i=new t({...r&&{nextToken:r},typeEquals:`SYSTEM_DEFINED`}),a=await e.send(i);a.inferenceProfileSummaries&&n.push(...a.inferenceProfileSummaries),r=a.nextToken}while(r);return n.filter(e=>e.inferenceProfileId?.includes(`anthropic`)).map(e=>e.inferenceProfileId).filter(Boolean)}catch(e){throw w(e),e}}),qt=r(async function(e){try{let[t,{GetInferenceProfileCommand:n}]=await Promise.all([Bt(),import(`./dist-es-yHGBqhBe.js`)]),r=new n({inferenceProfileIdentifier:e}),i=await t.send(r);if(!i.models||i.models.length===0)return null;let a=i.models[0];if(!a?.modelArn)return null;let o=a.modelArn.lastIndexOf(`/`);return o>=0?a.modelArn.substring(o+1):a.modelArn}catch(e){return w(e),null}}),Jt=[`us`,`eu`,`apac`,`global`]})),Xt,Zt,Qt,$t,en,tn,nn,rn,an,on,sn,cn,ln,un,dn=e((()=>{Xt={firstParty:`claude-3-7-sonnet-20250219`,bedrock:`us.anthropic.claude-3-7-sonnet-20250219-v1:0`,vertex:`claude-3-7-sonnet@20250219`,foundry:`claude-3-7-sonnet`,openai:`claude-3-7-sonnet-20250219`,gemini:`claude-3-7-sonnet-20250219`,grok:`claude-3-7-sonnet-20250219`},Zt={firstParty:`claude-3-5-sonnet-20241022`,bedrock:`anthropic.claude-3-5-sonnet-20241022-v2:0`,vertex:`claude-3-5-sonnet-v2@20241022`,foundry:`claude-3-5-sonnet`,openai:`claude-3-5-sonnet-20241022`,gemini:`claude-3-5-sonnet-20241022`,grok:`claude-3-5-sonnet-20241022`},Qt={firstParty:`claude-3-5-haiku-20241022`,bedrock:`us.anthropic.claude-3-5-haiku-20241022-v1:0`,vertex:`claude-3-5-haiku@20241022`,foundry:`claude-3-5-haiku`,openai:`claude-3-5-haiku-20241022`,gemini:`claude-3-5-haiku-20241022`,grok:`claude-3-5-haiku-20241022`},$t={firstParty:`claude-haiku-4-5-20251001`,bedrock:`us.anthropic.claude-haiku-4-5-20251001-v1:0`,vertex:`claude-haiku-4-5@20251001`,foundry:`claude-haiku-4-5`,openai:`claude-haiku-4-5-20251001`,gemini:`claude-haiku-4-5-20251001`,grok:`claude-haiku-4-5-20251001`},en={firstParty:`claude-sonnet-4-20250514`,bedrock:`us.anthropic.claude-sonnet-4-20250514-v1:0`,vertex:`claude-sonnet-4@20250514`,foundry:`claude-sonnet-4`,openai:`claude-sonnet-4-20250514`,gemini:`claude-sonnet-4-20250514`,grok:`claude-sonnet-4-20250514`},tn={firstParty:`claude-sonnet-4-5-20250929`,bedrock:`us.anthropic.claude-sonnet-4-5-20250929-v1:0`,vertex:`claude-sonnet-4-5@20250929`,foundry:`claude-sonnet-4-5`,openai:`claude-sonnet-4-5-20250929`,gemini:`claude-sonnet-4-5-20250929`,grok:`claude-sonnet-4-5-20250929`},nn={firstParty:`claude-opus-4-20250514`,bedrock:`us.anthropic.claude-opus-4-20250514-v1:0`,vertex:`claude-opus-4@20250514`,foundry:`claude-opus-4`,openai:`claude-opus-4-20250514`,gemini:`claude-opus-4-20250514`,grok:`claude-opus-4-20250514`},rn={firstParty:`claude-opus-4-1-20250805`,bedrock:`us.anthropic.claude-opus-4-1-20250805-v1:0`,vertex:`claude-opus-4-1@20250805`,foundry:`claude-opus-4-1`,openai:`claude-opus-4-1-20250805`,gemini:`claude-opus-4-1-20250805`,grok:`claude-opus-4-1-20250805`},an={firstParty:`claude-opus-4-5-20251101`,bedrock:`us.anthropic.claude-opus-4-5-20251101-v1:0`,vertex:`claude-opus-4-5@20251101`,foundry:`claude-opus-4-5`,openai:`claude-opus-4-5-20251101`,gemini:`claude-opus-4-5-20251101`,grok:`claude-opus-4-5-20251101`},on={firstParty:`claude-opus-4-6`,bedrock:`us.anthropic.claude-opus-4-6-v1`,vertex:`claude-opus-4-6`,foundry:`claude-opus-4-6`,openai:`claude-opus-4-6`,gemini:`claude-opus-4-6`,grok:`claude-opus-4-6`},sn={firstParty:`claude-opus-4-7`,bedrock:`us.anthropic.claude-opus-4-7-v1`,vertex:`claude-opus-4-7`,foundry:`claude-opus-4-7`,openai:`claude-opus-4-7`,gemini:`claude-opus-4-7`,grok:`claude-opus-4-7`},cn={firstParty:`claude-sonnet-4-6`,bedrock:`us.anthropic.claude-sonnet-4-6`,vertex:`claude-sonnet-4-6`,foundry:`claude-sonnet-4-6`,openai:`claude-sonnet-4-6`,gemini:`claude-sonnet-4-6`,grok:`claude-sonnet-4-6`},ln={haiku35:Qt,haiku45:$t,sonnet35:Zt,sonnet37:Xt,sonnet40:en,sonnet45:tn,sonnet46:cn,opus40:nn,opus41:rn,opus45:an,opus46:on,opus47:sn},Object.values(ln).map(e=>e.firstParty),un=Object.fromEntries(Object.entries(ln).map(([e,t])=>[t.firstParty,e]))}));function O(e=Be()){let t=e.modelType;return t===`openai`?`openai`:t===`gemini`?`gemini`:t===`grok`?`grok`:s(process.env.CLAUDE_CODE_USE_BEDROCK)?`bedrock`:s(process.env.CLAUDE_CODE_USE_VERTEX)?`vertex`:s(process.env.CLAUDE_CODE_USE_FOUNDRY)?`foundry`:s(process.env.CLAUDE_CODE_USE_OPENAI)?`openai`:s(process.env.CLAUDE_CODE_USE_GEMINI)?`gemini`:s(process.env.CLAUDE_CODE_USE_GROK)?`grok`:`firstParty`}function fn(){return O()}function pn(){let e=process.env.ANTHROPIC_BASE_URL;if(!e)return!0;try{let t=new URL(e).host,n=[`api.anthropic.com`];return process.env.USER_TYPE===`ant`&&n.push(`api-staging.anthropic.com`),n.includes(t)}catch{return!1}}var k=e((()=>{ze(),l()}));function mn(e){let t={};for(let n of bn)t[n]=ln[n][e];return t}async function hn(){let e=mn(`bedrock`),t;try{t=await Kt()}catch(t){return w(t),e}if(!t?.length)return e;let n={};for(let r of bn){let i=ln[r].firstParty;n[r]=zt(t,i)||e[r]}return n}function gn(e){let t=Be().modelOverrides;if(!t)return e;let n={...e};for(let[e,r]of Object.entries(t)){let t=un[e];t&&r&&(n[t]=r)}return n}function _n(e){let t;try{t=Be().modelOverrides}catch{return e}if(!t)return e;for(let[n,r]of Object.entries(t))if(r===e)return n;return e}function vn(){if(le()===null){if(O()!==`bedrock`){be(mn(O()));return}xn()}}function A(){let e=le();return e===null?(vn(),gn(mn(O()))):gn(e)}async function yn(){if(le()===null){if(O()!==`bedrock`){be(mn(O()));return}await xn()}}var bn,xn,Sn=e((()=>{m(),et(),Rt(),ze(),Yt(),dn(),k(),bn=Object.keys(ln),xn=Lt(async()=>{if(le()===null)try{be(await hn())}catch(e){w(e)}})}));function Cn(){if(s(process.env.DISABLE_COST_WARNINGS)||B())return!1;let e=Ma(),t=R()!==null;if(!e.hasToken&&!t)return!1;let n=S(),r=n.oauthAccount?.organizationRole,i=n.oauthAccount?.workspaceRole;return!r||!i?!1:[`admin`,`billing`].includes(r)||[`workspace_admin`,`workspace_billing`].includes(i)}function wn(e){En=e}function Tn(){if(En!==null)return En;if(!B())return!1;let e=V();if(e===`max`||e===`pro`)return!0;let t=S().oauthAccount?.organizationRole;return!!t&&[`admin`,`billing`,`owner`,`primary_owner`].includes(t)}var En,Dn=e((()=>{K(),Ue(),l(),En=null}));function On(){return process.env.USER_TYPE===`ant`?process.env.CLAUDE_MOCK_HEADERLESS_429?process.env.CLAUDE_MOCK_HEADERLESS_429:j?Rn:null:null}function kn(){return!j||process.env.USER_TYPE!==`ant`||Object.keys(Ln).length===0?null:Ln}function An(){Ln={},Hn=[],zn=null,Bn=null,M=null,Rn=null,wn(null),j=!1}function jn(e){let t=kn();if(!t)return e;let n=new globalThis.Headers(e);return Object.entries(t).forEach(([e,t])=>{t!==void 0&&n.set(e,t)}),n}function Mn(){return process.env.USER_TYPE===`ant`?j||!!process.env.CLAUDE_MOCK_HEADERLESS_429:!1}function Nn(){return!j||process.env.USER_TYPE!==`ant`?null:zn||Vn}function Pn(){return j&&zn!==null&&process.env.USER_TYPE===`ant`}function Fn(){return Bn!==null}function In(e){if(Bn===null||!e)return null;if(M!==null&&Date.now()>=M)return An(),null;M===null&&(M=Date.now()+Bn);let t=M-Date.now(),n={...Ln};return n[`retry-after`]=String(Math.max(1,Math.ceil(t/1e3))),n}var Ln,j,Rn,zn,Bn,M,Vn,Hn,Un=e((()=>{Dn(),Ln={},j=!1,Rn=null,zn=null,Bn=null,M=null,Vn=`max`}));async function Wn(){let e=S().oauthAccount?.accountUuid,t=R();if(!e||!t)return;let n=`${E().BASE_API_URL}/api/claude_cli_profile`;try{return(await f.get(n,{headers:{"x-api-key":t,"anthropic-beta":ut},params:{account_uuid:e},timeout:1e4})).data}catch(e){w(e)}}async function Gn(e){let t=`${E().BASE_API_URL}/api/oauth/profile`;try{return(await f.get(t,{headers:{Authorization:`Bearer ${e}`,"Content-Type":`application/json`},timeout:1e4})).data}catch(e){w(e)}}var Kn=e((()=>{p(),D(),K(),Ue(),et()}));function qn(e){return!!e?.includes(ct)}function Jn(e){return e?.split(` `).filter(Boolean)??[]}function Yn({codeChallenge:e,state:t,port:n,isManual:r,loginWithClaudeAi:i,inferenceOnly:a,orgUUID:o,loginHint:s,loginMethod:c}){let l=i?E().CLAUDE_AI_AUTHORIZE_URL:E().CONSOLE_AUTHORIZE_URL,u=new URL(l);u.searchParams.append(`code`,`true`),u.searchParams.append(`client_id`,E().CLIENT_ID),u.searchParams.append(`response_type`,`code`),u.searchParams.append(`redirect_uri`,r?E().MANUAL_REDIRECT_URL:`http://localhost:${n}/callback`);let d=a?[ct]:dt;return u.searchParams.append(`scope`,d.join(` `)),u.searchParams.append(`code_challenge`,e),u.searchParams.append(`code_challenge_method`,`S256`),u.searchParams.append(`state`,t),o&&u.searchParams.append(`orgUUID`,o),s&&u.searchParams.append(`login_hint`,s),c&&u.searchParams.append(`login_method`,c),u.toString()}async function Xn(e,t,n,r,i=!1,a){let o={grant_type:`authorization_code`,code:e,redirect_uri:i?E().MANUAL_REDIRECT_URL:`http://localhost:${r}/callback`,client_id:E().CLIENT_ID,code_verifier:n,state:t};a!==void 0&&(o.expires_in=a);let s=await f.post(E().TOKEN_URL,o,{headers:{"Content-Type":`application/json`},timeout:15e3});if(s.status!==200)throw Error(s.status===401?`Authentication failed: Invalid authorization code`:`Token exchange failed (${s.status}): ${s.statusText}`);return T(`tengu_oauth_token_exchange_success`,{}),s.data}async function Zn(e,{scopes:t}={}){let n={grant_type:`refresh_token`,refresh_token:e,client_id:E().CLIENT_ID,scope:(t?.length?t:lt).join(` `)};try{let t=await f.post(E().TOKEN_URL,n,{headers:{"Content-Type":`application/json`},timeout:15e3});if(t.status!==200)throw Error(`Token refresh failed: ${t.statusText}`);let r=t.data,{access_token:i,refresh_token:a=e,expires_in:o}=r,s=Date.now()+o*1e3,c=Jn(r.scope);T(`tengu_oauth_token_refresh_success`,{});let l=S(),u=G(),d=l.oauthAccount?.billingType!==void 0&&l.oauthAccount?.accountCreatedAt!==void 0&&l.oauthAccount?.subscriptionCreatedAt!==void 0&&u?.subscriptionType!=null&&u?.rateLimitTier!=null?null:await tr(i);if(d&&l.oauthAccount){let e={};d.displayName!==void 0&&(e.displayName=d.displayName),typeof d.hasExtraUsageEnabled==`boolean`&&(e.hasExtraUsageEnabled=d.hasExtraUsageEnabled),d.billingType!==null&&(e.billingType=d.billingType),d.accountCreatedAt!==void 0&&(e.accountCreatedAt=d.accountCreatedAt),d.subscriptionCreatedAt!==void 0&&(e.subscriptionCreatedAt=d.subscriptionCreatedAt),Object.keys(e).length>0&&x(t=>({...t,oauthAccount:t.oauthAccount?{...t.oauthAccount,...e}:t.oauthAccount}))}return{accessToken:i,refreshToken:a,expiresAt:s,scopes:c,subscriptionType:d?.subscriptionType??u?.subscriptionType??null,rateLimitTier:d?.rateLimitTier??u?.rateLimitTier??null,profile:d?.rawProfile,tokenAccount:r.account?{uuid:r.account.uuid,emailAddress:r.account.email_address,organizationUuid:r.organization?.uuid}:void 0}}catch(e){let t=f.isAxiosError(e)&&e.response?.data?JSON.stringify(e.response.data):void 0;throw T(`tengu_oauth_token_refresh_failure`,{error:e.message,...t&&{responseBody:t}}),e}}async function Qn(e){let t=await f.get(E().ROLES_URL,{headers:{Authorization:`Bearer ${e}`}});if(t.status!==200)throw Error(`Failed to fetch user roles: ${t.statusText}`);let n=t.data;if(!S().oauthAccount)throw Error(`OAuth account information not found in config`);x(e=>({...e,oauthAccount:e.oauthAccount?{...e.oauthAccount,organizationRole:n.organization_role,workspaceRole:n.workspace_role,organizationName:n.organization_name}:e.oauthAccount})),T(`tengu_oauth_roles_stored`,{org_role:n.organization_role})}async function $n(e){try{let t=await f.post(E().API_KEY_URL,null,{headers:{Authorization:`Bearer ${e}`}}),n=t.data?.raw_key;return n?(await so(n),T(`tengu_oauth_api_key`,{status:`success`,statusCode:t.status}),n):null}catch(e){throw T(`tengu_oauth_api_key`,{status:`failure`,error:e instanceof Error?e.message:String(e)}),e}}function er(e){return e!==null&&Date.now()+300*1e3>=e}async function tr(e){let t=await Gn(e),n=t?.organization?.organization_type,r=null;switch(n){case`claude_max`:r=`max`;break;case`claude_pro`:r=`pro`;break;case`claude_enterprise`:r=`enterprise`;break;case`claude_team`:r=`team`;break;default:r=null;break}let i={subscriptionType:r,rateLimitTier:t?.organization?.rate_limit_tier??null,hasExtraUsageEnabled:t?.organization?.has_extra_usage_enabled??null,billingType:t?.organization?.billing_type??null};return t?.account?.display_name&&(i.displayName=t.account.display_name),t?.account?.created_at&&(i.accountCreatedAt=t.account.created_at),t?.organization?.subscription_created_at&&(i.subscriptionCreatedAt=t.organization.subscription_created_at),T(`tengu_oauth_profile_fetch_success`,{}),{...i,rawProfile:t}}async function nr(){let e=S().oauthAccount?.organizationUuid;if(e)return e;let t=G()?.accessToken;return t===void 0||!bo()?null:(await Gn(t))?.organization?.uuid||null}async function rr(){let e=process.env.CLAUDE_CODE_ACCOUNT_UUID,t=process.env.CLAUDE_CODE_USER_EMAIL,n=process.env.CLAUDE_CODE_ORGANIZATION_UUID,r=!!(e&&t&&n);e&&t&&n&&(S().oauthAccount||ir({accountUuid:e,emailAddress:t,organizationUuid:n})),await vo();let i=S();if(i.oauthAccount&&i.oauthAccount.billingType!==void 0&&i.oauthAccount.accountCreatedAt!==void 0&&i.oauthAccount.subscriptionCreatedAt!==void 0||!B()||!bo())return!1;let a=G();if(a?.accessToken){let e=await Gn(a.accessToken);if(e)return r&&_(`OAuth profile fetch succeeded, overriding env var account info`,{level:`info`}),ir({accountUuid:e.account.uuid,emailAddress:e.account.email,organizationUuid:e.organization.uuid,displayName:e.account.display_name||void 0,hasExtraUsageEnabled:e.organization.has_extra_usage_enabled??!1,billingType:e.organization.billing_type??void 0,accountCreatedAt:e.account.created_at,subscriptionCreatedAt:e.organization.subscription_created_at??void 0}),!0}return!1}function ir({accountUuid:e,emailAddress:t,organizationUuid:n,displayName:r,hasExtraUsageEnabled:i,billingType:a,accountCreatedAt:o,subscriptionCreatedAt:s}){let c={accountUuid:e,emailAddress:t,organizationUuid:n,hasExtraUsageEnabled:i,billingType:a,accountCreatedAt:o,subscriptionCreatedAt:s};r&&(c.displayName=r),x(e=>e.oauthAccount?.accountUuid===c.accountUuid&&e.oauthAccount?.emailAddress===c.emailAddress&&e.oauthAccount?.organizationUuid===c.organizationUuid&&e.oauthAccount?.displayName===c.displayName&&e.oauthAccount?.hasExtraUsageEnabled===c.hasExtraUsageEnabled&&e.oauthAccount?.billingType===c.billingType&&e.oauthAccount?.accountCreatedAt===c.accountCreatedAt&&e.oauthAccount?.subscriptionCreatedAt===c.subscriptionCreatedAt?e:{...e,oauthAccount:c})}var ar=e((()=>{p(),at(),D(),K(),Ue(),g(),Kn()}));function or(e,t,n){if(s(process.env.CLAUDE_CODE_REMOTE))try{St(dr,{recursive:!0,mode:448}),wt(e,t,{encoding:`utf8`,mode:384}),_(`Persisted ${n} to ${e} for subprocess access`)}catch(e){_(`Failed to persist ${n} to disk (non-fatal): ${v(e)}`,{level:`error`})}}function sr(e,t){try{let n=Le().readFileSync(e,{encoding:`utf8`}).trim();return n?(_(`Read ${t} from well-known file ${e}`),n):null}catch(n){return ke(n)||_(`Failed to read ${t} from ${e}: ${v(n)}`,{level:`debug`}),null}}function cr({envVar:e,wellKnownPath:t,label:n,getCached:r,setCached:i}){let a=r();if(a!==void 0)return a;let o=process.env[e];if(!o){let e=sr(t,n);return i(e),e}let s=parseInt(o,10);if(Number.isNaN(s))return _(`${e} must be a valid file descriptor number, got: ${o}`,{level:`error`}),i(null),null;try{let e=Le(),r=process.platform===`darwin`||process.platform===`freebsd`?`/dev/fd/${s}`:`/proc/self/fd/${s}`,a=e.readFileSync(r,{encoding:`utf8`}).trim();return a?(_(`Successfully read ${n} from file descriptor ${s}`),i(a),or(t,a,n),a):(_(`File descriptor contained empty ${n}`,{level:`error`}),i(null),null)}catch(e){_(`Failed to read ${n} from file descriptor ${s}: ${v(e)}`,{level:`error`});let r=sr(t,n);return i(r),r}}function lr(){return cr({envVar:`CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR`,wellKnownPath:fr,label:`OAuth token`,getCached:Se,setCached:he})}function ur(){return cr({envVar:`CLAUDE_CODE_API_KEY_FILE_DESCRIPTOR`,wellKnownPath:pr,label:`API key`,getCached:we,setCached:_e})}var dr,fr,pr,mr,hr=e((()=>{m(),g(),l(),je(),Pe(),dr=`/home/claude/.claude/remote`,fr=`${dr}/.oauth_token`,pr=`${dr}/.api_key`,mr=`${dr}/.session_ingress_token`}));function N(e=``){let t=c(),n=process.env.CLAUDE_CONFIG_DIR?`-${Tt(`sha256`).update(t).digest(`hex`).substring(0,8)}`:``;return`Claude Code${E().OAUTH_FILE_SUFFIX}${e}${n}`}function gr(){try{return process.env.USER||yt().username}catch{return`claude-code-user`}}function P(){F.cache={data:null,cachedAt:0},F.generation++,F.readInFlight=null}function _r(e){if(F.cache.cachedAt!==0)return;let t=null;if(e)try{t=JSON.parse(e)}catch{return}F.cache={data:t,cachedAt:Date.now()}}var vr,F,yr=e((()=>{D(),l(),vr=`-credentials`,F={cache:{data:null,cachedAt:0},generation:0,readInFlight:null}}));async function br(){if(process.platform===`darwin`&&(await Je(`security delete-generic-password -a $USER -s "${N()}"`,{shell:!0,reject:!1})).exitCode!==0)throw Error(`Failed to delete keychain entry`)}function xr(e){return e.slice(-20)}var Sr=e((()=>{Ke(),yr()}));function Cr(e){return e?.name===`CredentialsProviderError`}function wr(e){if(!e||typeof e!=`object`)return!1;let t=e;if(!t.Credentials||typeof t.Credentials!=`object`)return!1;let n=t.Credentials;return typeof n.AccessKeyId==`string`&&typeof n.SecretAccessKey==`string`&&typeof n.SessionToken==`string`&&n.AccessKeyId.length>0&&n.SecretAccessKey.length>0&&n.SessionToken.length>0}async function Tr(){let{STSClient:e,GetCallerIdentityCommand:t}=await import(`./dist-es-C-OjW2Ao.js`);await new e().send(new t({}))}async function Er(){try{_(`Clearing AWS credential provider cache`);let{fromIni:e}=await import(`./dist-es-CIULjvtA2.js`);await e({ignoreCache:!0})(),_(`AWS credential provider cache refreshed`)}catch{_(`Failed to clear AWS credential cache (this is expected if no credentials are configured)`)}}var Dr=e((()=>{g()})),Or,kr=e((()=>{pe(),ee(),Or=class e{constructor(){te(this,`status`,{isAuthenticating:!1,output:[]}),te(this,`changed`,Ce()),te(this,`subscribe`,this.changed.subscribe)}static getInstance(){return e.instance||(e.instance=new e),e.instance}getStatus(){return{...this.status,output:[...this.status.output]}}startAuthentication(){this.status={isAuthenticating:!0,output:[]},this.changed.emit(this.getStatus())}addOutput(e){this.status.output.push(e),this.changed.emit(this.getStatus())}setError(e){this.status.error=e,this.changed.emit(this.getStatus())}endAuthentication(e){e?this.status={isAuthenticating:!1,output:[]}:this.status.isAuthenticating=!1,this.changed.emit(this.getStatus())}static reset(){e.instance&&(e.instance.changed.clear(),e.instance=null)}},te(Or,`instance`,null)})),Ar,jr,Mr,Nr,Pr,Fr,Ir,Lr,Rr,zr,Br,Vr,Hr,Ur,Wr,Gr,Kr=e((()=>{Ar=`claude-code-20250219`,jr=`interleaved-thinking-2025-05-14`,Mr=`context-1m-2025-08-07`,Nr=`context-management-2025-06-27`,Pr=`structured-outputs-2025-12-15`,Fr=`tool-search-tool-2025-10-19`,Ir=`effort-2025-11-24`,Lr=`task-budgets-2026-03-13`,Rr=`prompt-caching-scope-2026-01-05`,zr=`fast-mode-2026-02-01`,Br=`redact-thinking-2026-02-12`,Vr=`afk-mode-2026-01-31`,Hr=process.env.USER_TYPE===`ant`?`cli-internal-2026-02-09`:``,Ur=`advisor-tool-2026-03-01`,Wr=new Set([jr,Mr,Fr]),Gr=new Set([Ar,jr,Nr])}));function qr(e,t){return de(e,t)}var Jr=e((()=>{ge()}));function Yr(){return`claude-code/0.0.1`}var Xr=e((()=>{}));function Zr(){return $r.getStore()?.workload}function Qr(e,t){return $r.run({workload:e},t)}var $r,ei=e((()=>{$r=new Mt}));function ti(){let e=process.env.CLAUDE_AGENT_SDK_VERSION?`, agent-sdk/${process.env.CLAUDE_AGENT_SDK_VERSION}`:``,t=process.env.CLAUDE_AGENT_SDK_CLIENT_APP?`, client-app/${process.env.CLAUDE_AGENT_SDK_CLIENT_APP}`:``,n=Zr(),r=n?`, workload/${n}`:``;return`claude-cli/0.0.1 (${process.env.USER_TYPE}, ${process.env.CLAUDE_CODE_ENTRYPOINT??`cli`}${e}${t}${r})`}function ni(){let e=[];return process.env.CLAUDE_CODE_ENTRYPOINT&&e.push(process.env.CLAUDE_CODE_ENTRYPOINT),process.env.CLAUDE_AGENT_SDK_VERSION&&e.push(`agent-sdk/${process.env.CLAUDE_AGENT_SDK_VERSION}`),process.env.CLAUDE_AGENT_SDK_CLIENT_APP&&e.push(`client-app/${process.env.CLAUDE_AGENT_SDK_CLIENT_APP}`),`claude-code/0.0.1${e.length>0?` (${e.join(`, `)})`:``}`}function ri(){return`Claude-User (${Yr()}; +https://support.anthropic.com/)`}function ii(){if(B()){let e=G();return e?.accessToken?{headers:{Authorization:`Bearer ${e.accessToken}`,"anthropic-beta":ut}}:{headers:{},error:`No OAuth token available`}}let e=R();return e?{headers:{"x-api-key":e}}:{headers:{},error:`No API key available`}}async function ai(e,t){try{return await e()}catch(n){if(!f.isAxiosError(n))throw n;let r=n.response?.status;if(!(r===401||t?.also403Revoked&&r===403&&typeof n.response?.data==`string`&&n.response.data.includes(`OAuth token has been revoked`)))throw n;let i=G()?.accessToken;if(!i)throw n;return await ho(i),await e()}}var oi=e((()=>{p(),D(),K(),Xr(),ei()}));function si(){return{error:(e,...t)=>console.error(`[Anthropic SDK ERROR]`,e,...t),warn:(e,...t)=>console.error(`[Anthropic SDK WARN]`,e,...t),info:(e,...t)=>console.error(`[Anthropic SDK INFO]`,e,...t),debug:(e,...t)=>console.error(`[Anthropic SDK DEBUG]`,e,...t)}}async function ci({apiKey:e,maxRetries:n,model:r,fetchOverride:i,source:a}){let c=process.env.CLAUDE_CODE_CONTAINER_ID,l=process.env.CLAUDE_CODE_REMOTE_SESSION_ID,u=process.env.CLAUDE_AGENT_SDK_CLIENT_APP,ee=ui(),te={"x-app":`cli`,"User-Agent":ti(),"X-Claude-Code-Session-Id":ve(),...ee,...c?{"x-claude-remote-container-id":c}:{},...l?{"x-claude-remote-session-id":l}:{},...u?{"x-client-app":u}:{},...process.env.ANTHROPIC_AUTH_NONCE?{"x-auth-nonce":process.env.ANTHROPIC_AUTH_NONCE}:{}};_(`[API:request] Creating client, ANTHROPIC_CUSTOM_HEADERS present: ${!!process.env.ANTHROPIC_CUSTOM_HEADERS}, has Authorization header: ${!!ee.Authorization}`),s(process.env.CLAUDE_CODE_ADDITIONAL_PROTECTION)&&(te[`x-anthropic-additional-protection`]=`true`),_(`[API:auth] OAuth token check starting`),await vo(),_(`[API:auth] OAuth token check complete`),B()||await li(te,h());let f=di(i,a),p={defaultHeaders:te,maxRetries:n,timeout:parseInt(process.env.API_TIMEOUT_MS||`600000`,10),dangerouslyAllowBrowser:!0,fetchOptions:gt({forAnthropicAPI:!0}),...f&&{fetch:f}};if(s(process.env.CLAUDE_CODE_USE_BEDROCK)){let{BedrockClient:e}=await import(`./bedrockClient-DxE_mHFI.js`),t=r===hc()&&process.env.ANTHROPIC_SMALL_FAST_MODEL_AWS_REGION?process.env.ANTHROPIC_SMALL_FAST_MODEL_AWS_REGION:d(),n={...p,awsRegion:t,...s(process.env.CLAUDE_CODE_SKIP_BEDROCK_AUTH)&&{skipAuth:!0},...Fe()&&{logger:si()}};if(process.env.AWS_BEARER_TOKEN_BEDROCK)n.skipAuth=!0,n.defaultHeaders={...n.defaultHeaders,Authorization:`Bearer ${process.env.AWS_BEARER_TOKEN_BEDROCK}`};else if(!s(process.env.CLAUDE_CODE_SKIP_BEDROCK_AUTH)){let e=await W();e&&(n.awsAccessKey=e.accessKeyId,n.awsSecretKey=e.secretAccessKey,n.awsSessionToken=e.sessionToken)}return new e(n)}if(s(process.env.CLAUDE_CODE_USE_FOUNDRY)){let{AnthropicFoundry:e}=await import(`./foundry-sdk-BdeF2aBu.js`),t;if(!process.env.ANTHROPIC_FOUNDRY_API_KEY)if(s(process.env.CLAUDE_CODE_SKIP_FOUNDRY_AUTH))t=()=>Promise.resolve(``);else{let{DefaultAzureCredential:e,getBearerTokenProvider:n}=await import(`./esm-CGx9qY3q.js`);t=n(new e,`https://cognitiveservices.azure.com/.default`)}return new e({...p,...t&&{azureADTokenProvider:t},...Fe()&&{logger:si()}})}if(s(process.env.CLAUDE_CODE_USE_VERTEX)){s(process.env.CLAUDE_CODE_SKIP_VERTEX_AUTH)||await qo();let[{AnthropicVertex:e},{GoogleAuth:n}]=await Promise.all([import(`./vertex-sdk-DjXcZ2J7.js`),import(`./src-CiJCsqUl.js`).then(e=>t(e.default,1))]),i=process.env.GCLOUD_PROJECT||process.env.GOOGLE_CLOUD_PROJECT||process.env.gcloud_project||process.env.google_cloud_project,a=process.env.GOOGLE_APPLICATION_CREDENTIALS||process.env.google_application_credentials,c=s(process.env.CLAUDE_CODE_SKIP_VERTEX_AUTH)?{getClient:()=>({getRequestHeaders:()=>({})})}:new n({scopes:[`https://www.googleapis.com/auth/cloud-platform`],...i||a?{}:{projectId:process.env.ANTHROPIC_VERTEX_PROJECT_ID}});return new e({...p,region:o(r),googleAuth:c,...Fe()&&{logger:si()}})}return new Me({apiKey:B()?null:e||R(),authToken:B()?G()?.accessToken:void 0,...process.env.USER_TYPE===`ant`&&s(process.env.USE_STAGING_OAUTH)?{baseURL:E().BASE_API_URL}:{},...p,...Fe()&&{logger:si()}})}async function li(e,t){let n=process.env.ANTHROPIC_AUTH_TOKEN||await Ha(t);n&&(e.Authorization=`Bearer ${n}`)}function ui(){let e={},t=process.env.ANTHROPIC_CUSTOM_HEADERS;if(!t)return e;let n=t.split(/\n|\r\n/);for(let t of n){if(!t.trim())continue;let n=t.indexOf(`:`);if(n===-1)continue;let r=t.slice(0,n).trim(),i=t.slice(n+1).trim();r&&(e[r]=i)}return e}function di(e,t){let n=e??globalThis.fetch,r=O()===`firstParty`&&pn();return(e,i)=>{let a=new Headers(i?.headers);r&&!a.has(`x-client-request-id`)&&a.set(fi,Et());try{let n=e instanceof Request?e.url:String(e),r=a.get(fi);_(`[API REQUEST] ${new URL(n).pathname}${r?` ${fi}=${r}`:``} source=${t??`unknown`}`)}catch{}return n(e,{...i,headers:a})}}var fi,pi=e((()=>{Ne(),K(),oi(),$(),k(),vt(),m(),D(),g(),l(),fi=`x-client-request-id`}));function mi(){return bt(c(),`cache`)}function hi(){return bt(mi(),`model-capabilities.json`)}function gi(){return!(O()!==`firstParty`||!pn())}function _i(e){return[...e].sort((e,t)=>t.id.length-e.id.length||e.id.localeCompare(t.id))}function vi(e){if(!gi())return;let t=Si(hi());if(!t||t.length===0)return;let n=e.toLowerCase();return t.find(e=>e.id.toLowerCase()===n)||t.find(e=>n.includes(e.id.toLowerCase()))}async function yi(){if(gi()&&!$e())try{let e=await ci({maxRetries:1}),t=B()?[ut]:void 0,n=[];for await(let r of e.models.list({betas:t})){let e=bi().safeParse(r);e.success&&n.push(e.data)}if(n.length===0)return;let r=hi(),i=_i(n);if(qr(Si(r),i)){_(`[modelCapabilities] cache unchanged, skipping write`);return}await Dt(mi(),{recursive:!0}),await kt(r,Ae({models:i,timestamp:Date.now()}),{encoding:`utf-8`,mode:384}),Si.cache.delete(r),_(`[modelCapabilities] cached ${i.length} models`)}catch(e){_(`[modelCapabilities] fetch failed: ${e instanceof Error?e.message:`unknown`}`)}}var bi,xi,Si,Ci=e((()=>{Jr(),i(),se(),D(),pi(),K(),g(),l(),rt(),st(),Qe(),Oe(),k(),bi=ot(()=>ce({id:ie(),max_input_tokens:ae().optional(),max_tokens:ae().optional()}).strip()),xi=ot(()=>ce({models:oe(bi()),timestamp:ae()})),Si=r(e=>{try{let t=Ct(e,`utf-8`),n=xi().safeParse(it(t,!1));return n.success?n.data.models:null}catch{return null}},e=>e)}));function wi(){return s(process.env.CLAUDE_CODE_DISABLE_1M_CONTEXT)}function I(e){return!wi()&&/\[1m\]/i.test(e)}function Ti(e){if(wi())return!1;let t=Z(e);return t.includes(`claude-sonnet-4`)||t.includes(`opus-4-6`)||t.includes(`opus-4-7`)}function Ei(e,t){if(process.env.USER_TYPE===`ant`&&process.env.CLAUDE_CODE_MAX_CONTEXT_TOKENS){let e=parseInt(process.env.CLAUDE_CODE_MAX_CONTEXT_TOKENS,10);if(!isNaN(e)&&e>0)return e}if(I(e))return 1e6;let n=vi(e);if(n?.max_input_tokens&&n.max_input_tokens>=1e5)return n.max_input_tokens>2e5&&wi()?ji:n.max_input_tokens;if(t?.includes(`context-1m-2025-08-07`)&&Ti(e)||Di(e))return 1e6;if(process.env.USER_TYPE===`ant`){let t=Ft(e);if(t?.contextWindow)return t.contextWindow}return ji}function Di(e){return wi()||I(e)||!Z(e).includes(`sonnet-4-6`)?!1:S().clientDataCache?.coral_reef_sonnet===`true`}function Oi(e,t){if(!e)return{used:null,remaining:null};let n=e.input_tokens+e.cache_creation_input_tokens+e.cache_read_input_tokens;if(n===0)return{used:null,remaining:null};let r=Math.round(n/t*100),i=Math.min(100,Math.max(0,r));return{used:i,remaining:100-i}}function ki(e){let t,n;if(process.env.USER_TYPE===`ant`){let r=Ft(e.toLowerCase());if(r)return t=r.defaultMaxTokens??Ni,n=r.upperMaxTokensLimit??Pi,{default:t,upperLimit:n}}let r=Z(e);r.includes(`opus-4-7`)||r.includes(`opus-4-6`)?(t=64e3,n=128e3):r.includes(`sonnet-4-6`)?(t=32e3,n=128e3):r.includes(`opus-4-5`)||r.includes(`sonnet-4`)||r.includes(`haiku-4`)?(t=32e3,n=64e3):r.includes(`opus-4-1`)||r.includes(`opus-4`)?(t=32e3,n=32e3):r.includes(`claude-3-opus`)?(t=4096,n=4096):r.includes(`claude-3-sonnet`)?(t=8192,n=8192):r.includes(`claude-3-haiku`)?(t=4096,n=4096):r.includes(`3-5-sonnet`)||r.includes(`3-5-haiku`)?(t=8192,n=8192):r.includes(`3-7-sonnet`)?(t=32e3,n=64e3):(t=Ni,n=Pi);let i=vi(e);return i?.max_tokens&&i.max_tokens>=4096&&(n=i.max_tokens,t=Math.min(t,n)),{default:t,upperLimit:n}}function Ai(e){return ki(e).upperLimit-1}var ji,Mi,Ni,Pi,Fi,Ii=e((()=>{Kr(),Ue(),l(),$(),It(),Ci(),ji=2e5,Mi=2e4,Ni=32e3,Pi=64e3,Fi=8e3})),Li,Ri,zi,Bi=e((()=>{i(),k(),Li=[{modelEnvVar:`ANTHROPIC_DEFAULT_OPUS_MODEL`,capabilitiesEnvVar:`ANTHROPIC_DEFAULT_OPUS_MODEL_SUPPORTED_CAPABILITIES`},{modelEnvVar:`ANTHROPIC_DEFAULT_SONNET_MODEL`,capabilitiesEnvVar:`ANTHROPIC_DEFAULT_SONNET_MODEL_SUPPORTED_CAPABILITIES`},{modelEnvVar:`ANTHROPIC_DEFAULT_HAIKU_MODEL`,capabilitiesEnvVar:`ANTHROPIC_DEFAULT_HAIKU_MODEL_SUPPORTED_CAPABILITIES`}],Ri=[{modelEnvVar:`OPENAI_DEFAULT_OPUS_MODEL`,capabilitiesEnvVar:`OPENAI_DEFAULT_OPUS_MODEL_SUPPORTED_CAPABILITIES`},{modelEnvVar:`OPENAI_DEFAULT_SONNET_MODEL`,capabilitiesEnvVar:`OPENAI_DEFAULT_SONNET_MODEL_SUPPORTED_CAPABILITIES`},{modelEnvVar:`OPENAI_DEFAULT_HAIKU_MODEL`,capabilitiesEnvVar:`OPENAI_DEFAULT_HAIKU_MODEL_SUPPORTED_CAPABILITIES`}],zi=r((e,t)=>{if(O()===`firstParty`)return;let n=e.toLowerCase(),r=O()===`openai`?Ri:Li;for(let e of r){let r=process.env[e.modelEnvVar],i=process.env[e.capabilitiesEnvVar];if(!(!r||i===void 0)&&n===r.toLowerCase())return i.toLowerCase().split(`,`).map(e=>e.trim()).includes(t)}},(e,t)=>`${e.toLowerCase()}:${t}`)}));function Vi(e){let t=[],n=[];for(let r of e)Zi.includes(r)?t.push(r):n.push(r);return{allowed:t,disallowed:n}}function Hi(e){if(!e||e.length===0)return;if(B()){console.warn(`Warning: Custom betas are only available for API key users. Ignoring provided betas.`);return}let{allowed:t,disallowed:n}=Vi(e);for(let e of n)console.warn(`Warning: Beta header '${e}' is not allowed. Only the following betas are supported: ${Zi.join(`, `)}`);return t.length>0?t:void 0}function Ui(e){let t=zi(e,`interleaved_thinking`);if(t!==void 0)return t;let n=Z(e),r=O();return r===`foundry`?!0:r===`firstParty`?!n.includes(`claude-3-`):n.includes(`claude-opus-4`)||n.includes(`claude-sonnet-4`)}function Wi(e){let t=Z(e),n=O();return n===`foundry`?!0:n===`firstParty`?!t.includes(`claude-3-`):t.includes(`claude-opus-4`)||t.includes(`claude-sonnet-4`)||t.includes(`claude-haiku-4`)}function Gi(e){let t=Z(e),n=O();return n!==`firstParty`&&n!==`foundry`?!1:t.includes(`claude-sonnet-4-6`)||t.includes(`claude-sonnet-4-5`)||t.includes(`claude-opus-4-1`)||t.includes(`claude-opus-4-5`)||t.includes(`claude-opus-4-6`)||t.includes(`claude-opus-4-7`)||t.includes(`claude-haiku-4-5`)}function Ki(e){return!0}function qi(){return(O()===`firstParty`||O()===`foundry`)&&!s(process.env.CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS)&&pn()}function Ji(){return O()===`firstParty`&&!s(process.env.CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS)}function Yi(e,t){let n=[...$i(e)];t?.isAgenticQuery&&(n.includes(`claude-code-20250219`)||n.push(Ar),process.env.USER_TYPE===`ant`&&process.env.CLAUDE_CODE_ENTRYPOINT===`cli`&&Hr&&!n.includes(Hr)&&n.push(Hr));let r=ye();return!r||r.length===0?n:[...n,...r.filter(e=>!n.includes(e))]}function Xi(){Qi.cache?.clear?.(),$i.cache?.clear?.(),ea.cache?.clear?.()}var Zi,Qi,$i,ea,ta=e((()=>{i(),m(),Kr(),D(),K(),Ii(),l(),$(),Bi(),k(),ze(),Zi=[Mr],Qi=r(e=>{let t=[],n=Z(e).includes(`haiku`);O();let r=qi();n||(t.push(Ar),process.env.USER_TYPE===`ant`&&process.env.CLAUDE_CODE_ENTRYPOINT===`cli`&&Hr&&t.push(Hr)),B()&&t.push(ut),I(e)&&t.push(Mr),!s(process.env.DISABLE_INTERLEAVED_THINKING)&&Ui(e)&&t.push(jr),r&&Ui(e)&&!h()&&Be().showThinkingSummaries!==!0&&t.push(Br);let i=s(process.env.USE_API_CONTEXT_MANAGEMENT)||Wi(e),a=Wi(e);return qi()&&(i||a)&&t.push(Nr),r&&Gi(e),process.env.USER_TYPE,r&&t.push(Rr),process.env.ANTHROPIC_BETAS&&t.push(...process.env.ANTHROPIC_BETAS.split(`,`).map(e=>e.trim()).filter(Boolean)),t}),$i=r(e=>{let t=Qi(e);return O()===`bedrock`?t.filter(e=>!Wr.has(e)):t}),ea=r(e=>Qi(e).filter(e=>Wr.has(e)))}));function na(e,t){return{name:`${e.name}-with-${t.name}-fallback`,read(){return e.read()??(t.read()||{})},async readAsync(){return await e.readAsync()??(await t.readAsync()||{})},update(n){let r=e.read(),i=e.update(n);if(i.success)return r===null&&t.delete(),i;let a=t.update(n);return a.success?(r!==null&&e.delete(),{success:!0,warning:a.warning}):{success:!1}},delete(){let n=e.delete(),r=t.delete();return n||r}}}var ra=e((()=>{}));async function ia(){try{let e=N(vr),{stdout:t,code:n}=await Ze(`security`,[`find-generic-password`,`-a`,gr(),`-w`,`-s`,e],{useCwd:!1,preserveOutputOnError:!1});if(n===0&&t)return De(t.trim())}catch{}return null}function aa(){if(ca!==void 0)return ca;if(process.platform!==`darwin`)return ca=!1,!1;try{ca=Xe(`security`,[`show-keychain-info`],{reject:!1,stdio:[`ignore`,`pipe`,`pipe`]}).exitCode===36}catch{ca=!1}return ca}var oa,sa,ca,la=e((()=>{Ke(),g(),Ye(),Ge(),Oe(),yr(),oa=4032,sa={name:`keychain`,read(){let e=F.cache;if(Date.now()-e.cachedAt<3e4)return e.data;try{let e=N(vr),t=qe(`security find-generic-password -a "${gr()}" -w -s "${e}"`);if(t){let e=De(t);return F.cache={data:e,cachedAt:Date.now()},e}}catch{}return e.data===null?(F.cache={data:null,cachedAt:Date.now()},null):(_(`[keychain] read failed; serving stale cache`,{level:`warn`}),F.cache={data:e.data,cachedAt:Date.now()},e.data)},async readAsync(){let e=F.cache;if(Date.now()-e.cachedAt<3e4)return e.data;if(F.readInFlight)return F.readInFlight;let t=F.generation,n=ia().then(n=>{if(t===F.generation){n===null&&e.data!==null&&_(`[keychain] readAsync failed; serving stale cache`,{level:`warn`});let t=n??e.data;return F.cache={data:t,cachedAt:Date.now()},F.readInFlight=null,t}return n});return F.readInFlight=n,n},update(e){P();try{let t=N(vr),n=gr(),r=Ae(e),i=Buffer.from(r,`utf-8`).toString(`hex`),a=`add-generic-password -U -a "${n}" -s "${t}" -X "${i}"\n`,o;return a.length<=oa?o=Xe(`security`,[`-i`],{input:a,stdio:[`pipe`,`pipe`,`pipe`],reject:!1}):(_(`Keychain payload (${r.length}B JSON) exceeds security -i stdin limit; using argv`,{level:`warn`}),o=Xe(`security`,[`add-generic-password`,`-U`,`-a`,n,`-s`,t,`-X`,i],{stdio:[`ignore`,`pipe`,`pipe`],reject:!1})),o.exitCode===0?(F.cache={data:e,cachedAt:Date.now()},{success:!0}):{success:!1}}catch{return{success:!1}}},delete(){P();try{let e=N(vr);return qe(`security delete-generic-password -a "${gr()}" -s "${e}"`),!0}catch{return!1}}}}));function ua(){let e=c();return{storageDir:e,storagePath:bt(e,`.credentials.json`)}}var da,fa=e((()=>{l(),je(),Pe(),Oe(),da={name:`plaintext`,read(){let{storagePath:e}=ua();try{return De(Le().readFileSync(e,{encoding:`utf8`}))}catch{return null}},async readAsync(){let{storagePath:e}=ua();try{return De(await Le().readFile(e,{encoding:`utf8`}))}catch{return null}},update(e){try{let{storageDir:t,storagePath:n}=ua();try{Le().mkdirSync(t)}catch(e){if(Ee(e)!==`EEXIST`)throw e}return Te(n,Ae(e),{encoding:`utf8`,flush:!1}),xt(n,384),{success:!0,warning:`Warning: Storing credentials in plaintext.`}}catch{return{success:!1}}},delete(){let{storagePath:e}=ua();try{return Le().unlinkSync(e),!0}catch(e){return Ee(e)===`ENOENT`}}}}));function pa(){return process.platform===`darwin`?na(sa,da):da}var ma=e((()=>{ra(),la(),fa()}));function ha(e){return new Promise(t=>{jt(`security`,[`find-generic-password`,`-a`,gr(),`-w`,`-s`,e],{encoding:`utf-8`,timeout:ba},(e,n)=>{t({stdout:e?null:n?.trim()||null,timedOut:!!(e&&`killed`in e&&e.killed)})})})}function ga(){if(process.platform!==`darwin`||Sa||u())return;let e=ha(N(vr)),t=ha(N());Sa=Promise.all([e,t]).then(([e,t])=>{e.timedOut||_r(e.stdout),t.timedOut||(xa={stdout:t.stdout})})}async function _a(){Sa&&await Sa}function va(){return xa}function ya(){xa=null}var ba,xa,Sa,Ca=e((()=>{l(),yr(),ba=1e4,xa=null,Sa=null}));function wa(e,t,n){return new Promise((r,i)=>{if(t?.aborted){n?.throwOnAbort||n?.abortError?i(n.abortError?.()??Error(`aborted`)):r();return}let a=setTimeout((e,t,n)=>{e?.removeEventListener(`abort`,t),n()},e,t,o,r);function o(){clearTimeout(a),n?.throwOnAbort||n?.abortError?i(n.abortError?.()??Error(`aborted`)):r()}t?.addEventListener(`abort`,o,{once:!0}),n?.unref&&a.unref()})}var Ta=e((()=>{}));function Ea(){return Oa}function Da(){Oa.clear()}var Oa,ka=e((()=>{Oa=new Map})),Aa=n({calculateApiKeyHelperTTL:()=>Ba,checkAndRefreshOAuthTokenIfNeeded:()=>vo,checkGcpCredentialsValid:()=>eo,clearApiKeyHelperCache:()=>Ka,clearAwsCredentialsCache:()=>Za,clearGcpCredentialsCache:()=>ro,clearOAuthTokenCache:()=>po,getAccountInformation:()=>Ro,getAnthropicApiKey:()=>R,getAnthropicApiKeyWithSource:()=>Pa,getApiKeyFromApiKeyHelper:()=>Ha,getApiKeyFromApiKeyHelperCached:()=>Ga,getApiKeyFromConfigOrMacOSKeychain:()=>Jo,getApiKeyHelperElapsedMs:()=>Va,getAuthTokenSource:()=>Ma,getClaudeAIOAuthTokens:()=>G,getClaudeAIOAuthTokensAsync:()=>_o,getConfiguredApiKeyHelper:()=>z,getOauthAccountInfo:()=>So,getOtelHeadersFromHelper:()=>Fo,getRateLimitTier:()=>Ao,getSubscriptionName:()=>jo,getSubscriptionType:()=>V,handleOAuth401Error:()=>ho,hasAnthropicApiKeyAuth:()=>Na,hasOpusAccess:()=>wo,hasProfileScope:()=>bo,is1PApiCustomer:()=>xo,isAnthropicAuthEnabled:()=>L,isAwsAuthRefreshFromProjectSettings:()=>La,isAwsCredentialExportFromProjectSettings:()=>za,isClaudeAISubscriber:()=>B,isConsumerSubscriber:()=>Lo,isCustomApiKeyApproved:()=>co,isEnterpriseSubscriber:()=>Oo,isGcpAuthRefreshFromProjectSettings:()=>$a,isMaxSubscriber:()=>To,isOtelHeadersHelperFromProjectOrLocalSettings:()=>Po,isOverageProvisioningAllowed:()=>Co,isProSubscriber:()=>ko,isTeamPremiumSubscriber:()=>Do,isTeamSubscriber:()=>Eo,isUsing3PServices:()=>Mo,prefetchApiKeyFromApiKeyHelperIfSafe:()=>qa,prefetchAwsCredentialsAndBedRockInfoIfSafe:()=>ao,prefetchGcpCredentialsIfSafe:()=>io,refreshAndGetAwsCredentials:()=>W,refreshAwsAuth:()=>Ya,refreshGcpAuth:()=>no,refreshGcpCredentialsIfNeeded:()=>qo,removeApiKey:()=>lo,saveApiKey:()=>so,saveOAuthTokensIfNeeded:()=>fo,validateForceLoginOrg:()=>zo});function ja(){return s(process.env.CLAUDE_CODE_REMOTE)||process.env.CLAUDE_CODE_ENTRYPOINT===`claude-desktop`}function L(){if(u())return!1;if(process.env.ANTHROPIC_UNIX_SOCKET)return!!process.env.CLAUDE_CODE_OAUTH_TOKEN;let e=b()||{},t=s(process.env.CLAUDE_CODE_USE_BEDROCK)||s(process.env.CLAUDE_CODE_USE_VERTEX)||s(process.env.CLAUDE_CODE_USE_FOUNDRY)||e.modelType===`openai`||e.modelType===`gemini`||!!process.env.OPENAI_BASE_URL||!!process.env.GEMINI_BASE_URL,n=e.apiKeyHelper,r=process.env.ANTHROPIC_AUTH_TOKEN||n||process.env.CLAUDE_CODE_API_KEY_FILE_DESCRIPTOR,{source:i}=Pa({skipRetrievingKeyFromApiKeyHelper:!0}),a=i===`ANTHROPIC_API_KEY`||i===`apiKeyHelper`;return!(t||r&&!ja()||a&&!ja())}function Ma(){if(u())return z()?{source:`apiKeyHelper`,hasToken:!0}:{source:`none`,hasToken:!1};if(process.env.ANTHROPIC_AUTH_TOKEN&&!ja())return{source:`ANTHROPIC_AUTH_TOKEN`,hasToken:!0};if(process.env.CLAUDE_CODE_OAUTH_TOKEN)return{source:`CLAUDE_CODE_OAUTH_TOKEN`,hasToken:!0};if(lr())return process.env.CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR?{source:`CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR`,hasToken:!0}:{source:`CCR_OAUTH_TOKEN_FILE`,hasToken:!0};if(z()&&!ja())return{source:`apiKeyHelper`,hasToken:!0};let e=G();return qn(e?.scopes)&&e?.accessToken?{source:`claude.ai`,hasToken:!0}:{source:`none`,hasToken:!1}}function R(){let{key:e}=Pa();return e}function Na(){let{key:e,source:t}=Pa({skipRetrievingKeyFromApiKeyHelper:!0});return e!==null&&t!==`none`}function Pa(e={}){if(u())return process.env.ANTHROPIC_API_KEY?{key:process.env.ANTHROPIC_API_KEY,source:`ANTHROPIC_API_KEY`}:z()?{key:e.skipRetrievingKeyFromApiKeyHelper?null:Ga(),source:`apiKeyHelper`}:{key:null,source:`none`};let t=a()?void 0:process.env.ANTHROPIC_API_KEY;if(xe()&&t)return{key:t,source:`ANTHROPIC_API_KEY`};if(s(process.env.CI)){let e=ur();if(e)return{key:e,source:`ANTHROPIC_API_KEY`};if(!t&&!process.env.CLAUDE_CODE_OAUTH_TOKEN&&!process.env.CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR)throw Error(`ANTHROPIC_API_KEY or CLAUDE_CODE_OAUTH_TOKEN env var is required`);return t?{key:t,source:`ANTHROPIC_API_KEY`}:{key:null,source:`none`}}if(t&&S().customApiKeyResponses?.approved?.includes(xr(t)))return{key:t,source:`ANTHROPIC_API_KEY`};let n=ur();return n?{key:n,source:`ANTHROPIC_API_KEY`}:z()?e.skipRetrievingKeyFromApiKeyHelper?{key:null,source:`apiKeyHelper`}:{key:Ga(),source:`apiKeyHelper`}:Jo()||{key:null,source:`none`}}function z(){return u()?y(`flagSettings`)?.apiKeyHelper:(b()||{}).apiKeyHelper}function Fa(){let e=z();if(!e)return!1;let t=y(`projectSettings`),n=y(`localSettings`);return t?.apiKeyHelper===e||n?.apiKeyHelper===e}function Ia(){return(b()||{}).awsAuthRefresh}function La(){let e=Ia();if(!e)return!1;let t=y(`projectSettings`),n=y(`localSettings`);return t?.awsAuthRefresh===e||n?.awsAuthRefresh===e}function Ra(){return(b()||{}).awsCredentialExport}function za(){let e=Ra();if(!e)return!1;let t=y(`projectSettings`),n=y(`localSettings`);return t?.awsCredentialExport===e||n?.awsCredentialExport===e}function Ba(){let e=process.env.CLAUDE_CODE_API_KEY_HELPER_TTL_MS;if(e){let t=parseInt(e,10);if(!Number.isNaN(t)&&t>=0)return t;_(`Found CLAUDE_CODE_API_KEY_HELPER_TTL_MS env var, but it was not a valid number. Got ${e}`,{level:`error`})}return Bo}function Va(){let e=U?.startedAt;return e?Date.now()-e:0}async function Ha(e){if(!z())return null;let t=Ba();return H?(Date.now()-H.timestamp<t||U||(U={promise:Ua(e,!1,Vo),startedAt:null}),H.value):(U||(U={promise:Ua(e,!0,Vo),startedAt:Date.now()}),U.promise)}async function Ua(e,t,n){try{let t=await Wa(e);return n===Vo&&t!==null&&(H={value:t,timestamp:Date.now()}),t}catch(e){if(n!==Vo)return` `;let r=e instanceof Error?e.message:String(e);return console.error(re.red(`apiKeyHelper failed: ${r}`)),_(`Error getting API key from apiKeyHelper: ${r}`,{level:`error`}),!t&&H&&H.value!==` `?(H={...H,timestamp:Date.now()},H.value):(H={value:` `,timestamp:Date.now()},` `)}finally{n===Vo&&(U=null)}}async function Wa(e){let t=z();if(!t)return null;if(Fa()&&!C()&&!e)return Ie(`apiKeyHelper invoked before trust check`,Error(`Security: apiKeyHelper executed before workspace trust is confirmed. If you see this message, post in .`)),T(`tengu_apiKeyHelper_missing_trust11`,{}),null;let n=await Je(t,{shell:!0,timeout:600*1e3,reject:!1});if(n.failed){let e=n.timedOut?`timed out`:`exited ${n.exitCode}`,t=n.stderr?.trim();throw Error(t?`${e}: ${t}`:e)}let r=n.stdout?.trim();if(!r)throw Error(`did not return a value`);return r}function Ga(){return H?.value??null}function Ka(){Vo++,H=null,U=null}function qa(e){Fa()&&!C()||Ha(e)}async function Ja(){let e=Ia();if(!e)return!1;if(La()&&!C()&&!h())return Ie(`awsAuthRefresh invoked before trust check`,Error(`Security: awsAuthRefresh executed before workspace trust is confirmed. If you see this message, post in .`)),T(`tengu_awsAuthRefresh_missing_trust`,{}),!1;try{return _(`Fetching AWS caller identity for AWS auth refresh command`),await Tr(),_(`Fetched AWS caller identity, skipping AWS auth refresh command`),!1}catch{return Ya(e)}}function Ya(e){_(`Running AWS auth refresh command`);let t=Or.getInstance();return t.startAuthentication(),new Promise(n=>{let r=At(e,{timeout:Uo});r.stdout.on(`data`,e=>{let n=e.toString().trim();n&&(t.addOutput(n),_(n,{level:`debug`}))}),r.stderr.on(`data`,e=>{let n=e.toString().trim();n&&(t.setError(n),_(n,{level:`error`}))}),r.on(`close`,(e,r)=>{if(e===0)_(`AWS auth refresh completed successfully`),t.endAuthentication(!0),n(!0);else{let e=r===`SIGTERM`?re.red(`AWS auth refresh timed out after 3 minutes. Run your auth command manually in a separate terminal.`):re.red(`Error running awsAuthRefresh (in settings or ~/.claude.json):`);console.error(e),t.endAuthentication(!1),n(!1)}})})}async function Xa(){let e=Ra();if(!e)return null;if(za()&&!C()&&!h())return Ie(`awsCredentialExport invoked before trust check`,Error(`Security: awsCredentialExport executed before workspace trust is confirmed. If you see this message, post in .`)),T(`tengu_awsCredentialExport_missing_trust`,{}),null;try{return _(`Fetching AWS caller identity for credential export command`),await Tr(),_(`Fetched AWS caller identity, skipping AWS credential export command`),null}catch{try{_(`Running AWS credential export command`);let t=await Je(e,{shell:!0,reject:!1});if(t.exitCode!==0||!t.stdout)throw Error(`awsCredentialExport did not return a valid value`);let n=De(t.stdout.trim());if(!wr(n))throw Error(`awsCredentialExport did not return valid AWS STS output structure`);return _(`AWS credentials retrieved from awsCredentialExport`),{accessKeyId:n.Credentials.AccessKeyId,secretAccessKey:n.Credentials.SecretAccessKey,sessionToken:n.Credentials.SessionToken}}catch(e){let t=re.red(`Error getting AWS credentials from awsCredentialExport (in settings or ~/.claude.json):`);return e instanceof Error?console.error(t,e.message):console.error(t,e),null}}}function Za(){W.cache.clear()}function Qa(){return(b()||{}).gcpAuthRefresh}function $a(){let e=Qa();if(!e)return!1;let t=y(`projectSettings`),n=y(`localSettings`);return t?.gcpAuthRefresh===e||n?.gcpAuthRefresh===e}async function eo(){try{let{GoogleAuth:e}=await import(`./src-CiJCsqUl.js`).then(e=>t(e.default,1)),n=new e({scopes:[`https://www.googleapis.com/auth/cloud-platform`]}),r=(async()=>{await(await n.getClient()).getAccessToken()})(),i=wa(Wo).then(()=>{throw new ts(`GCP credentials check timed out`)});return await Promise.race([r,i]),!0}catch{return!1}}async function to(){let e=Qa();if(!e)return!1;if($a()&&!C()&&!h())return Ie(`gcpAuthRefresh invoked before trust check`,Error(`Security: gcpAuthRefresh executed before workspace trust is confirmed. If you see this message, post in .`)),T(`tengu_gcpAuthRefresh_missing_trust`,{}),!1;try{if(_(`Checking GCP credentials validity for auth refresh`),await eo())return _(`GCP credentials are valid, skipping auth refresh command`),!1}catch{}return no(e)}function no(e){_(`Running GCP auth refresh command`);let t=Or.getInstance();return t.startAuthentication(),new Promise(n=>{let r=At(e,{timeout:Ko});r.stdout.on(`data`,e=>{let n=e.toString().trim();n&&(t.addOutput(n),_(n,{level:`debug`}))}),r.stderr.on(`data`,e=>{let n=e.toString().trim();n&&(t.setError(n),_(n,{level:`error`}))}),r.on(`close`,(e,r)=>{if(e===0)_(`GCP auth refresh completed successfully`),t.endAuthentication(!0),n(!0);else{let e=r===`SIGTERM`?re.red(`GCP auth refresh timed out after 3 minutes. Run your auth command manually in a separate terminal.`):re.red(`Error running gcpAuthRefresh (in settings or ~/.claude.json):`);console.error(e),t.endAuthentication(!1),n(!1)}})})}function ro(){qo.cache.clear()}function io(){Qa()&&($a()&&!C()&&!h()||qo())}function ao(){let e=Ia(),t=Ra();!e&&!t||(La()||za())&&!C()&&!h()||(W(),A())}function oo(e){return/^[a-zA-Z0-9-_]+$/.test(e)}async function so(e){if(!oo(e))throw Error(`Invalid API key format. API key must contain only alphanumeric characters, dashes, and underscores.`);await uo();let t=!1;if(process.platform===`darwin`)try{let n=N();await Je(`security`,[`-i`],{input:`add-generic-password -U -a "${gr()}" -s "${n}" -X "${Buffer.from(e,`utf-8`).toString(`hex`)}"\n`,reject:!1}),T(`tengu_api_key_saved_to_keychain`,{}),t=!0}catch(e){w(e),T(`tengu_api_key_keychain_error`,{error:v(e)}),T(`tengu_api_key_saved_to_config`,{})}else T(`tengu_api_key_saved_to_config`,{});let n=xr(e);x(r=>{let i=r.customApiKeyResponses?.approved??[];return{...r,primaryApiKey:t?r.primaryApiKey:e,customApiKeyResponses:{...r.customApiKeyResponses,approved:i.includes(n)?i:[...i,n],rejected:r.customApiKeyResponses?.rejected??[]}}}),Jo.cache.clear?.(),ya()}function co(e){let t=S(),n=xr(e);return t.customApiKeyResponses?.approved?.includes(n)??!1}async function lo(){await uo(),x(e=>({...e,primaryApiKey:void 0})),Jo.cache.clear?.(),ya()}async function uo(){try{await br()}catch(e){w(e)}}function fo(e){if(!qn(e.scopes))return T(`tengu_oauth_tokens_not_claude_ai`,{}),{success:!0};if(!e.refreshToken||!e.expiresAt)return T(`tengu_oauth_tokens_inference_only`,{}),{success:!0};let t=pa(),n=t.name;try{let r=t.read()||{},i=r.claudeAiOauth;r.claudeAiOauth={accessToken:e.accessToken,refreshToken:e.refreshToken,expiresAt:e.expiresAt,scopes:e.scopes,subscriptionType:e.subscriptionType??i?.subscriptionType??null,rateLimitTier:e.rateLimitTier??i?.rateLimitTier??null};let a=t.update(r);return a.success?T(`tengu_oauth_tokens_saved`,{storageBackend:n}):T(`tengu_oauth_tokens_save_failed`,{storageBackend:n}),G.cache?.clear?.(),Xi(),Da(),a}catch(e){return w(e),T(`tengu_oauth_tokens_save_exception`,{storageBackend:n,error:v(e)}),{success:!1,warning:`Failed to save OAuth tokens`}}}function po(){G.cache?.clear?.(),P()}async function mo(){try{let{mtimeMs:e}=await Ot(bt(c(),`.credentials.json`));e!==Yo&&(Yo=e,po())}catch{G.cache?.clear?.()}}function ho(e){let t=Xo.get(e);if(t)return t;let n=go(e).finally(()=>{Xo.delete(e)});return Xo.set(e,n),n}async function go(e){po();let t=await _o();return t?.refreshToken?t.accessToken===e?vo(0,!0):(T(`tengu_oauth_401_recovered_from_keychain`,{}),!0):!1}async function _o(){if(u())return null;if(process.env.CLAUDE_CODE_OAUTH_TOKEN||lr())return G();try{let e=(await pa().readAsync())?.claudeAiOauth;return e?.accessToken?e:null}catch(e){return w(e),null}}function vo(e=0,t=!1){return e===0&&!t?Zo||(Zo=yo(e,t).finally(()=>{Zo=null}),Zo):yo(e,t)}async function yo(e,t){await mo();let n=G();if(!t&&(!n?.refreshToken||!er(n.expiresAt))||!n?.refreshToken||!qn(n.scopes))return!1;G.cache?.clear?.(),P();let r=await _o();if(!r?.refreshToken||!er(r.expiresAt))return!1;let i=c();await Dt(i,{recursive:!0});let a;try{T(`tengu_oauth_token_refresh_lock_acquiring`,{}),a=await We(i),T(`tengu_oauth_token_refresh_lock_acquired`,{})}catch(n){return n.code===`ELOCKED`?e<5?(T(`tengu_oauth_token_refresh_lock_retry`,{retryCount:e+1}),await wa(1e3+Math.random()*1e3),yo(e+1,t)):(T(`tengu_oauth_token_refresh_lock_retry_limit_reached`,{maxRetries:5}),!1):(w(n),T(`tengu_oauth_token_refresh_lock_error`,{error:v(n)}),!1)}try{G.cache?.clear?.(),P();let e=await _o();return!e?.refreshToken||!er(e.expiresAt)?(T(`tengu_oauth_token_refresh_race_resolved`,{}),!1):(T(`tengu_oauth_token_refresh_starting`,{}),fo(await Zn(e.refreshToken,{scopes:qn(e.scopes)?void 0:e.scopes})),G.cache?.clear?.(),P(),!0)}catch(e){w(e),G.cache?.clear?.(),P();let t=await _o();return t&&!er(t.expiresAt)?(T(`tengu_oauth_token_refresh_race_recovered`,{}),!0):!1}finally{T(`tengu_oauth_token_refresh_lock_releasing`,{}),await a(),T(`tengu_oauth_token_refresh_lock_released`,{})}}function B(){return L()?qn(G()?.scopes):!1}function bo(){return G()?.scopes?.includes(`user:profile`)??!1}function xo(){return!(s(process.env.CLAUDE_CODE_USE_BEDROCK)||s(process.env.CLAUDE_CODE_USE_VERTEX)||s(process.env.CLAUDE_CODE_USE_FOUNDRY)||B())}function So(){return L()?S().oauthAccount:void 0}function Co(){let e=So()?.billingType;return!(!B()||!e||e!==`stripe_subscription`&&e!==`stripe_subscription_contracted`&&e!==`apple_subscription`&&e!==`google_play_subscription`)}function wo(){let e=V();return e===`max`||e===`enterprise`||e===`team`||e===`pro`||e===null}function V(){if(Pn())return Nn();if(!L())return null;let e=G();return e?e.subscriptionType??null:null}function To(){return V()===`max`}function Eo(){return V()===`team`}function Do(){return V()===`team`&&Ao()===`default_claude_max_5x`}function Oo(){return V()===`enterprise`}function ko(){return V()===`pro`}function Ao(){if(!L())return null;let e=G();return e?e.rateLimitTier??null:null}function jo(){switch(V()){case`enterprise`:return`Claude Enterprise`;case`team`:return`Claude Team`;case`max`:return`Claude Max`;case`pro`:return`Claude Pro`;default:return`Claude API`}}function Mo(){return!!(s(process.env.CLAUDE_CODE_USE_BEDROCK)||s(process.env.CLAUDE_CODE_USE_VERTEX)||s(process.env.CLAUDE_CODE_USE_FOUNDRY)||s(process.env.CLAUDE_CODE_USE_OPENAI)||s(process.env.CLAUDE_CODE_USE_GEMINI)||s(process.env.CLAUDE_CODE_USE_GROK))}function No(){return(b()||{}).otelHeadersHelper}function Po(){let e=No();if(!e)return!1;let t=y(`projectSettings`),n=y(`localSettings`);return t?.otelHeadersHelper===e||n?.otelHeadersHelper===e}function Fo(){let e=No();if(!e)return{};let t=parseInt(process.env.CLAUDE_CODE_OTEL_HEADERS_HELPER_DEBOUNCE_MS||es.toString(),10);if(Qo&&Date.now()-$o<t)return Qo;if(Po()&&!C())return{};try{let t=qe(e,{timeout:3e4})?.toString().trim();if(!t)throw Error(`otelHeadersHelper did not return a valid value`);let n=De(t);if(typeof n!=`object`||!n||Array.isArray(n))throw Error(`otelHeadersHelper must return a JSON object with string key-value pairs`);for(let[e,t]of Object.entries(n))if(typeof t!=`string`)throw Error(`otelHeadersHelper returned non-string value for key "${e}": ${typeof t}`);return Qo=n,$o=Date.now(),Qo}catch(e){throw w(Error(`Error getting OpenTelemetry headers from otelHeadersHelper (in settings): ${v(e)}`)),e}}function Io(e){return e===`max`||e===`pro`}function Lo(){let e=V();return B()&&e!==null&&Io(e)}function Ro(){if(O()!==`firstParty`)return;let{source:e}=Ma(),t={};e===`CLAUDE_CODE_OAUTH_TOKEN`||e===`CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR`?t.tokenSource=e:B()?t.subscription=jo():t.tokenSource=e;let{key:n,source:r}=Pa();if(n&&(t.apiKeySource=r),e===`claude.ai`||r===`/login managed key`){let e=So()?.organizationName;e&&(t.organization=e)}let i=So()?.emailAddress;return(e===`claude.ai`||r===`/login managed key`)&&i&&(t.email=i),t}async function zo(){if(process.env.ANTHROPIC_UNIX_SOCKET||!L())return{valid:!0};let e=y(`policySettings`)?.forceLoginOrgUUID;if(!e)return{valid:!0};await vo();let t=G();if(!t)return{valid:!0};let{source:n}=Ma(),r=n===`CLAUDE_CODE_OAUTH_TOKEN`||n===`CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR`,i=await Gn(t.accessToken);if(!i)return{valid:!1,message:`Unable to verify organization for the current authentication token.\nThis machine requires organization ${e} but the profile could not be fetched.\nThis may be a network error, or the token may lack the user:profile scope required for\nverification (tokens from 'claude setup-token' do not include this scope).\nTry again, or obtain a full-scope token via 'claude auth login'.`};let a=i.organization.uuid;return a===e?{valid:!0}:r?{valid:!1,message:`The ${n===`CLAUDE_CODE_OAUTH_TOKEN`?`CLAUDE_CODE_OAUTH_TOKEN`:`CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR`} environment variable provides a token for a\ndifferent organization than required by this machine's managed settings.\n\nRequired organization: ${e}\nToken organization: ${a}\n\nRemove the environment variable or obtain a token for the correct organization.`}:{valid:!1,message:`Your authentication token belongs to organization ${a},\nbut this machine requires organization ${e}.\n\nPlease log in with the correct organization: claude auth login`}}var Bo,H,U,Vo,Ho,Uo,W,Wo,Go,Ko,qo,Jo,G,Yo,Xo,Zo,Qo,$o,es,ts,K=e((()=>{ne(),Ke(),i(),D(),at(),Sn(),k(),m(),Un(),ar(),Kn(),hr(),Sr(),Dr(),kr(),ta(),Ue(),g(),l(),je(),Ye(),He(),et(),nt(),ma(),Ca(),yr(),ze(),Ta(),Oe(),ka(),Bo=300*1e3,H=null,U=null,Vo=0,Ho=3600*1e3,Uo=180*1e3,W=tt(async()=>{let e=await Ja(),t=await Xa();return(e||t)&&await Er(),t},Ho),Wo=5e3,Go=3600*1e3,Ko=180*1e3,qo=tt(async()=>await to(),Go),Jo=r(()=>{if(u())return null;if(process.platform===`darwin`){let e=va();if(e){if(e.stdout)return{key:e.stdout,source:`/login managed key`}}else{let e=N();try{let t=qe(`security find-generic-password -a $USER -w -s "${e}"`);if(t)return{key:t,source:`/login managed key`}}catch(e){w(e)}}}let e=S();return e.primaryApiKey?{key:e.primaryApiKey,source:`/login managed key`}:null}),G=r(()=>{if(u())return null;if(process.env.CLAUDE_CODE_OAUTH_TOKEN)return{accessToken:process.env.CLAUDE_CODE_OAUTH_TOKEN,refreshToken:null,expiresAt:null,scopes:[`user:inference`],subscriptionType:null,rateLimitTier:null};let e=lr();if(e)return{accessToken:e,refreshToken:null,expiresAt:null,scopes:[`user:inference`],subscriptionType:null,rateLimitTier:null};try{let e=pa().read()?.claudeAiOauth;return e?.accessToken?e:null}catch(e){return w(e),null}}),Yo=0,Xo=new Map,Zo=null,Qo=null,$o=0,es=1740*1e3,ts=class extends Error{}}));function q(){return!s(process.env.CLAUDE_CODE_DISABLE_FAST_MODE)}function ns(){return q()?is()===null:!1}function rs(e,t){switch(e){case`free`:return t===`oauth`?`Fast mode requires a paid subscription`:`Fast mode unavailable during evaluation. Please purchase credits.`;case`preference`:return`Fast mode has been disabled by your organization`;case`extra_usage_disabled`:return`Fast mode requires extra usage billing · /extra-usage to enable`;case`network_error`:return`Fast mode unavailable due to network connectivity issues`;case`unknown`:return`Fast mode is currently unavailable`}}function is(){if(!q())return`Fast mode is not available`;if(ft(),h()&&xe()&&!ue()&&!y(`flagSettings`)?.fastMode){let e=`Fast mode is not available in the Agent SDK`;return _(`Fast mode unavailable: ${e}`),e}if(O()!==`firstParty`){let e=`Fast mode is not available on Bedrock, Vertex, or Foundry`;return _(`Fast mode unavailable: ${e}`),e}if(J.status===`disabled`){if((J.reason===`network_error`||J.reason===`unknown`)&&s(process.env.CLAUDE_CODE_SKIP_FAST_MODE_NETWORK_ERRORS))return null;let e=G()===null?`api-key`:`oauth`,t=rs(J.reason,e);return _(`Fast mode unavailable: ${t}`),t}return null}function as(){return`opus`+(kc()?`[1m]`:``)}function os(e){if(!q()||!ns()||!ss(e))return!1;let t=Be();return!t.fastModePerSessionOptIn&&t.fastMode===!0}function ss(e){if(!q())return!1;let t=Q(e??wc());return t.toLowerCase().includes(`opus-4-7`)||t.toLowerCase().includes(`opus-4-6`)}function cs(){return xs.status===`cooldown`&&Date.now()>=xs.resetAt&&(q()&&!Ss&&(_(`Fast mode cooldown expired, re-enabling fast mode`),Ss=!0,ws.emit()),xs={status:`active`}),xs}function ls(e,t){if(!q())return;xs={status:`cooldown`,resetAt:e,reason:t},Ss=!1;let n=e-Date.now();_(`Fast mode cooldown triggered (${t}), duration ${Math.round(n/1e3)}s`),T(`tengu_fast_mode_fallback_triggered`,{cooldown_duration_ms:n,cooldown_reason:t}),Cs.emit(e,t)}function us(){xs={status:`active`}}function ds(){J.status!==`disabled`&&(J={status:`disabled`,reason:`preference`},Ve(`userSettings`,{fastMode:void 0}),x(e=>({...e,penguinModeOrgEnabled:!1})),ks.emit(!1))}function fs(e){switch(e){case`out_of_credits`:return`Fast mode disabled · extra usage credits exhausted`;case`org_level_disabled`:case`org_service_level_disabled`:return`Fast mode disabled · extra usage disabled by your organization`;case`org_level_disabled_until`:return`Fast mode disabled · extra usage spending cap reached`;case`member_level_disabled`:return`Fast mode disabled · extra usage disabled for your account`;case`seat_tier_level_disabled`:case`seat_tier_zero_credit_limit`:case`member_zero_credit_limit`:return`Fast mode disabled · extra usage not available for your plan`;case`overage_not_provisioned`:case`no_limits_configured`:return`Fast mode requires extra usage billing · /extra-usage to enable`;default:return`Fast mode disabled · extra usage not available`}}function ps(e){return e===`org_level_disabled_until`||e===`out_of_credits`}function ms(e){let t=fs(e);_(`Fast mode overage rejection: ${e??`unknown`} — ${t}`),T(`tengu_fast_mode_overage_rejected`,{overage_disabled_reason:e??`unknown`}),ps(e)||(Ve(`userSettings`,{fastMode:void 0}),x(e=>({...e,penguinModeOrgEnabled:!1}))),Ds.emit(t)}function hs(){return cs().status===`cooldown`}function gs(e,t){let n=q()&&ns()&&!!t&&ss(e);return n&&hs()?`cooldown`:n?`on`:`off`}async function _s(e){let t=`${E().BASE_API_URL}/api/claude_code_penguin_mode`,n=`accessToken`in e?{Authorization:`Bearer ${e.accessToken}`,"anthropic-beta":ut}:{"x-api-key":e.apiKey};return(await f.get(t,{headers:n})).data}function vs(){if(!q()||J.status!==`pending`)return;let e=process.env.USER_TYPE===`ant`,t=S().penguinModeOrgEnabled===!0;J=e||t?{status:`enabled`}:{status:`disabled`,reason:`unknown`}}async function ys(){if($e()||!q())return;if(Ns)return _(`Fast mode prefetch in progress, returning in-flight promise`),Ns;let e=R();if(!(G()?.accessToken&&bo())&&!e){let e=process.env.USER_TYPE===`ant`,t=S().penguinModeOrgEnabled===!0;J=e||t?{status:`enabled`}:{status:`disabled`,reason:`preference`};return}let t=Date.now();if(t-Ms<js){_(`Skipping fast mode prefetch, fetched recently`);return}Ms=t;let n=async()=>{let t=G(),n=t?.accessToken&&bo()?{accessToken:t.accessToken}:e?{apiKey:e}:null;if(!n)throw Error(`No auth available`);return _s(n)};async function r(){try{let e;try{e=await n()}catch(t){if(f.isAxiosError(t)&&(t.response?.status===401||t.response?.status===403&&typeof t.response?.data==`string`&&t.response.data.includes(`OAuth token has been revoked`))){let r=G()?.accessToken;if(r)await ho(r),e=await n();else throw t}else throw t}let t=J.status===`pending`?S().penguinModeOrgEnabled:J.status===`enabled`;J=e.enabled?{status:`enabled`}:{status:`disabled`,reason:e.disabled_reason??`preference`},t!==e.enabled&&(e.enabled||Ve(`userSettings`,{fastMode:void 0}),x(t=>({...t,penguinModeOrgEnabled:e.enabled})),ks.emit(e.enabled)),_(`Org fast mode: ${e.enabled?`enabled`:`disabled (${e.disabled_reason??`preference`})`}`)}catch(e){let t=process.env.USER_TYPE===`ant`,n=S().penguinModeOrgEnabled===!0;J=t||n?{status:`enabled`}:{status:`disabled`,reason:`network_error`},_(`Failed to fetch org fast mode status, defaulting to ${J.status===`enabled`?`enabled (cached)`:`disabled (network_error)`}: ${e}`,{level:`error`}),T(`tengu_org_penguin_mode_fetch_failed`,{})}finally{Ns=null}}return Ns=r(),Ns}var bs,xs,Ss,Cs,ws,Ts,Es,Ds,Os,J,ks,As,js,Ms,Ns,Ps=e((()=>{p(),D(),m(),at(),K(),pt(),Ue(),g(),l(),$(),k(),Qe(),ze(),pe(),bs=`Opus 4.7`,xs={status:`active`},Ss=!1,Cs=Ce(),ws=Ce(),Ts=Cs.subscribe,Es=ws.subscribe,Ds=Ce(),Os=Ds.subscribe,J={status:`pending`},ks=Ce(),As=ks.subscribe,js=3e4,Ms=0,Ns=null}));function Fs(e){return q()&&e?Ks:Gs}function Is(e,t){return t.input_tokens/1e6*e.inputTokens+t.output_tokens/1e6*e.outputTokens+(t.cache_read_input_tokens??0)/1e6*e.promptCacheReadTokens+(t.cache_creation_input_tokens??0)/1e6*e.promptCacheWriteTokens+(t.server_tool_use?.web_search_requests??0)*e.webSearchRequests}function Ls(e,t){let n=Z(e);return n===X(on.firstParty)?Fs(t.speed===`fast`):Xs[n]||(Rs(e,n),Xs[Z(wc())]??Ys)}function Rs(e,t){T(`tengu_unknown_model_cost`,{model:e,shortName:t}),fe()}function zs(e,t){return Is(Ls(e,t),t)}function Bs(e,t){return zs(e,{input_tokens:t.inputTokens,output_tokens:t.outputTokens,cache_read_input_tokens:t.cacheReadInputTokens,cache_creation_input_tokens:t.cacheCreationInputTokens})}function Vs(e){return Number.isInteger(e)?`$${e}`:`$${e.toFixed(2)}`}function Hs(e){return`${Vs(e.inputTokens)}/${Vs(e.outputTokens)} per Mtok`}var Us,Ws,Gs,Ks,qs,Js,Ys,Xs,Zs=e((()=>{at(),m(),Ps(),dn(),$(),Us={inputTokens:3,outputTokens:15,promptCacheWriteTokens:3.75,promptCacheReadTokens:.3,webSearchRequests:.01},Ws={inputTokens:15,outputTokens:75,promptCacheWriteTokens:18.75,promptCacheReadTokens:1.5,webSearchRequests:.01},Gs={inputTokens:5,outputTokens:25,promptCacheWriteTokens:6.25,promptCacheReadTokens:.5,webSearchRequests:.01},Ks={inputTokens:30,outputTokens:150,promptCacheWriteTokens:37.5,promptCacheReadTokens:3,webSearchRequests:.01},qs={inputTokens:.8,outputTokens:4,promptCacheWriteTokens:1,promptCacheReadTokens:.08,webSearchRequests:.01},Js={inputTokens:1,outputTokens:5,promptCacheWriteTokens:1.25,promptCacheReadTokens:.1,webSearchRequests:.01},Ys=Gs,Xs={[X(Qt.firstParty)]:qs,[X($t.firstParty)]:Js,[X(Zt.firstParty)]:Us,[X(Xt.firstParty)]:Us,[X(en.firstParty)]:Us,[X(tn.firstParty)]:Us,[X(cn.firstParty)]:Us,[X(nn.firstParty)]:Ws,[X(rn.firstParty)]:Ws,[X(an.firstParty)]:Gs,[X(on.firstParty)]:Gs}}));function Qs(e){return ec.includes(e)}function $s(e){return tc.includes(e)}var ec,tc,nc=e((()=>{ec=[`sonnet`,`opus`,`haiku`,`best`,`sonnet[1m]`,`opus[1m]`,`opusplan`],tc=[`sonnet`,`opus`,`haiku`]}));function rc(e,t){return e.includes(t)?!0:Qs(e)?Q(e).toLowerCase().includes(t):!1}function ic(e,t){return e.startsWith(t)?e.length===t.length||e[t.length]===`-`:!1}function ac(e,t){let n=Qs(e)?Q(e).toLowerCase():e;return!!(ic(n,t)||!t.startsWith(`claude-`)&&ic(n,`claude-${t}`))}function oc(e,t){for(let n of t){if($s(n))continue;let t=n.indexOf(e);if(t===-1)continue;let r=t+e.length;if(r===n.length||n[r]===`-`)return!0}return!1}function sc(e){let{availableModels:t}=b()||{};if(!t)return!0;if(t.length===0)return!1;let n=_n(e).trim().toLowerCase(),r=t.map(e=>e.trim().toLowerCase());if(r.includes(n)&&(!$s(n)||!oc(n,r)))return!0;for(let e of r)if($s(e)&&!oc(e,r)&&rc(n,e))return!0;if(Qs(n)){let e=Q(n).toLowerCase();if(r.includes(e))return!0}for(let e of r)if(!$s(e)&&Qs(e)&&Q(e).toLowerCase()===n)return!0;for(let e of r)if(!$s(e)&&!Qs(e)&&ac(n,e))return!0;return!1}var cc=e((()=>{ze(),nc(),$(),Sn()}));function lc(){return process.env.OPENAI_AUTH_MODE===`chatgpt`}function uc(e){let t=e.toLowerCase().replace(/\[1m\]$/,``);return pc.some(e=>e.value.toLowerCase()===t)}var dc,fc,pc,mc=e((()=>{dc=`gpt-5.5`,fc=`gpt-5.4-mini`,pc=[{value:`gpt-5.5`,label:`GPT-5.5`,description:`Frontier model for complex coding, research, and real-world work`},{value:`gpt-5.4`,label:`GPT-5.4`,description:`Strong model for everyday coding`},{value:`gpt-5.4-mini`,label:`GPT-5.4-Mini`,description:`Small, fast, and cost-efficient model for simpler coding tasks`},{value:`gpt-5.3-codex`,label:`GPT-5.3-Codex`,description:`Coding-optimized model`},{value:`gpt-5.3-codex-spark`,label:`GPT-5.3-Codex-Spark`,description:`Ultra-fast coding model`},{value:`gpt-5.2`,label:`GPT-5.2`,description:`Optimized for professional work and long-running agents`}]}));function hc(){let e=O();return e===`openai`&&lc()?process.env.OPENAI_SMALL_FAST_MODEL??`gpt-5.4-mini`:e===`openai`&&process.env.OPENAI_SMALL_FAST_MODEL?process.env.OPENAI_SMALL_FAST_MODEL:e===`gemini`&&process.env.GEMINI_SMALL_FAST_MODEL?process.env.GEMINI_SMALL_FAST_MODEL:process.env.ANTHROPIC_SMALL_FAST_MODEL||Sc()}function gc(e){return e===A().opus40||e===A().opus41||e===A().opus45||e===A().opus46||e===A().opus47}function _c(){let e,t=me();if(t!==void 0)e=t;else{let t=b()||{};e=process.env.ANTHROPIC_MODEL||t.model||void 0}if(!(e&&!sc(e)))return e}function vc(){let e=_c();return e==null?Tc():Q(e)}function yc(){return Y()}function bc(){let e=O();if(e===`openai`)return process.env.OPENAI_MODEL;if(e===`gemini`)return process.env.GEMINI_MODEL;if(e===`grok`)return process.env.GROK_MODEL}function Y(){let e=O();return e===`openai`&&lc()?dc:e===`openai`&&process.env.OPENAI_DEFAULT_OPUS_MODEL?process.env.OPENAI_DEFAULT_OPUS_MODEL:e===`gemini`&&process.env.GEMINI_DEFAULT_OPUS_MODEL?process.env.GEMINI_DEFAULT_OPUS_MODEL:process.env.ANTHROPIC_DEFAULT_OPUS_MODEL?process.env.ANTHROPIC_DEFAULT_OPUS_MODEL:bc()||A().opus47}function xc(){let e=O();return e===`openai`&&lc()?dc:e===`openai`&&process.env.OPENAI_DEFAULT_SONNET_MODEL?process.env.OPENAI_DEFAULT_SONNET_MODEL:e===`gemini`&&process.env.GEMINI_DEFAULT_SONNET_MODEL?process.env.GEMINI_DEFAULT_SONNET_MODEL:process.env.ANTHROPIC_DEFAULT_SONNET_MODEL?process.env.ANTHROPIC_DEFAULT_SONNET_MODEL:bc()||(e===`firstParty`?A().sonnet46:A().sonnet45)}function Sc(){let e=O();return e===`openai`&&lc()?fc:e===`openai`&&process.env.OPENAI_DEFAULT_HAIKU_MODEL?process.env.OPENAI_DEFAULT_HAIKU_MODEL:e===`gemini`&&process.env.GEMINI_DEFAULT_HAIKU_MODEL?process.env.GEMINI_DEFAULT_HAIKU_MODEL:process.env.ANTHROPIC_DEFAULT_HAIKU_MODEL?process.env.ANTHROPIC_DEFAULT_HAIKU_MODEL:bc()||A().haiku45}function Cc(e){let{permissionMode:t,mainLoopModel:n,exceeds200kTokens:r=!1}=e;return _c()===`opusplan`&&t===`plan`&&!r?Y():_c()===`haiku`&&t===`plan`?xc():n}function wc(){return process.env.USER_TYPE===`ant`?Nt()?.defaultModel??Y()+`[1m]`:To()||Do()?Y()+(kc()?`[1m]`:``):xc()}function Tc(){return Q(wc())}function X(e){if(e=e.toLowerCase(),e.includes(`claude-opus-4-7`))return`claude-opus-4-7`;if(e.includes(`claude-opus-4-6`))return`claude-opus-4-6`;if(e.includes(`claude-opus-4-5`))return`claude-opus-4-5`;if(e.includes(`claude-opus-4-1`))return`claude-opus-4-1`;if(e.includes(`claude-opus-4`))return`claude-opus-4`;if(e.includes(`claude-sonnet-4-6`))return`claude-sonnet-4-6`;if(e.includes(`claude-sonnet-4-5`))return`claude-sonnet-4-5`;if(e.includes(`claude-sonnet-4`))return`claude-sonnet-4`;if(e.includes(`claude-haiku-4-5`))return`claude-haiku-4-5`;if(e.includes(`claude-3-7-sonnet`))return`claude-3-7-sonnet`;if(e.includes(`claude-3-5-sonnet`))return`claude-3-5-sonnet`;if(e.includes(`claude-3-5-haiku`))return`claude-3-5-haiku`;if(e.includes(`claude-3-opus`))return`claude-3-opus`;if(e.includes(`claude-3-sonnet`))return`claude-3-sonnet`;if(e.includes(`claude-3-haiku`))return`claude-3-haiku`;let t=e.match(/(claude-(\d+-\d+-)?\w+)/);return t&&t[1]?t[1]:e}function Z(e){return X(_n(e))}function Ec(e=!1){return To()||Do()?kc()?`Opus 4.7 with 1M context · Most capable for complex work${e?Oc(!0):``}`:`Opus 4.7 · Most capable for complex work${e?Oc(!0):``}`:`Sonnet 4.6 · Best for everyday tasks`}function Dc(e){return e===`opusplan`?`Opus 4.7 in plan mode, else Sonnet 4.6`:Nc(Q(e))}function Oc(e){if(O()!==`firstParty`)return``;let t=Hs(Fs(e));return` ·${e?` (↯)`:``} ${t}`}function kc(){return!(wi()||ko()||O()!==`firstParty`||!pn()||B()&&V()===null)}function Ac(e){return e===`opusplan`?`Opus Plan`:Qs(e)?mt(e):Nc(e)}function jc(e){switch(e){case A().opus47:return`Opus 4.7`;case A().opus47+`[1m]`:return`Opus 4.7 (1M context)`;case A().opus46:return`Opus 4.6`;case A().opus46+`[1m]`:return`Opus 4.6 (1M context)`;case A().opus45:return`Opus 4.5`;case A().opus41:return`Opus 4.1`;case A().opus40:return`Opus 4`;case A().sonnet46+`[1m]`:return`Sonnet 4.6 (1M context)`;case A().sonnet46:return`Sonnet 4.6`;case A().sonnet45+`[1m]`:return`Sonnet 4.5 (1M context)`;case A().sonnet45:return`Sonnet 4.5`;case A().sonnet40:return`Sonnet 4`;case A().sonnet40+`[1m]`:return`Sonnet 4 (1M context)`;case A().sonnet37:return`Sonnet 3.7`;case A().sonnet35:return`Sonnet 3.5`;case A().haiku45:return`Haiku 4.5`;case A().haiku35:return`Haiku 3.5`;default:return null}}function Mc(e){let[t=``,...n]=e.split(`-`);return[t.slice(0,3)+`*`.repeat(Math.max(0,t.length-3)),...n].join(`-`)}function Nc(e){let t=jc(e);if(t)return t;if(process.env.USER_TYPE===`ant`){let t=Q(e),n=Ft(e);return n?Mc(n.model.replace(/\[1m\]$/i,``))+(I(t)?`[1m]`:``):t===e?t:`${e} (${t})`}return e}function Q(e){let t=e.trim(),n=t.toLowerCase(),r=I(n),i=r?n.replace(/\[1m]$/i,``).trim():n;if(Qs(i))switch(i){case`opusplan`:return xc()+(r?`[1m]`:``);case`sonnet`:return xc()+(r?`[1m]`:``);case`haiku`:return Sc()+(r?`[1m]`:``);case`opus`:return Y()+(r?`[1m]`:``);case`best`:return yc();default:}if(O()===`firstParty`&&Fc(i)&&Ic())return Y()+(r?`[1m]`:``);if(process.env.USER_TYPE===`ant`){let e=I(n),t=Ft(n.replace(/\[1m]$/i,``).trim());if(t){let n=e?`[1m]`:``;return t.model+n}}return r?t.replace(/\[1m\]$/i,``).trim()+`[1m]`:t}function Pc(e,t){return I(e)||!I(t)?e:Ti(Q(e))?e+`[1m]`:e}function Fc(e){return Bc.includes(e)}function Ic(){return!s(process.env.CLAUDE_CODE_DISABLE_LEGACY_MODEL_REMAP)}function Lc(e){if(e===null)return process.env.USER_TYPE===`ant`?`Default for Ants (${Dc(wc())})`:B()?`Default (${Ec()})`:`Default (${Tc()})`;let t=Q(e);return e===t?t:`${e} (${t})`}function Rc(e){if(O()===`foundry`)return;let t=e.toLowerCase().includes(`[1m]`),n=Z(e);if(n.includes(`claude-opus-4-7`))return t?`Opus 4.7 (with 1M context)`:`Opus 4.7`;if(n.includes(`claude-opus-4-6`))return t?`Opus 4.6 (with 1M context)`:`Opus 4.6`;if(n.includes(`claude-opus-4-5`))return`Opus 4.5`;if(n.includes(`claude-opus-4-1`))return`Opus 4.1`;if(n.includes(`claude-opus-4`))return`Opus 4`;if(n.includes(`claude-sonnet-4-6`))return t?`Sonnet 4.6 (with 1M context)`:`Sonnet 4.6`;if(n.includes(`claude-sonnet-4-5`))return t?`Sonnet 4.5 (with 1M context)`:`Sonnet 4.5`;if(n.includes(`claude-sonnet-4`))return t?`Sonnet 4 (with 1M context)`:`Sonnet 4`;if(n.includes(`claude-3-7-sonnet`))return`Claude 3.7 Sonnet`;if(n.includes(`claude-3-5-sonnet`))return`Claude 3.5 Sonnet`;if(n.includes(`claude-haiku-4-5`))return`Haiku 4.5`;if(n.includes(`claude-3-5-haiku`))return`Claude 3.5 Haiku`}function zc(e){return e.replace(/\[(1|2)m\]/gi,``)}var Bc,$=e((()=>{m(),It(),K(),Ii(),l(),Sn(),Zs(),ze(),k(),Re(),cc(),nc(),ht(),mc(),Bc=[`claude-opus-4-20250514`,`claude-opus-4-1-20250805`,`claude-opus-4-0`,`claude-opus-4-1`]}));export{ms as $,pi as $n,jn as $r,Co as $t,mc as A,Yi as An,xr as Ar,_o as At,Xs as B,Mi as Bn,Qn as Br,bo as Bt,Q as C,Lt as Ci,pa as Cn,Gr as Cr,Pa as Ct,Pc as D,Ft as Di,Xi as Dn,Dr,Va as Dt,Ac as E,It as Ei,aa as En,kr as Er,Jo as Et,ec as F,qi as Fn,or as Fr,jo as Ft,Zs as G,Di as Gn,Jn as Gr,za as Gt,zs as H,Ei as Hn,nr as Hr,xo as Ht,nc as I,Ji as In,sr as Ir,V as It,as as J,wi as Jn,qn as Jr,co as Jt,bs as K,I as Kn,rr as Kr,B as Kt,qs as L,zi as Ln,Yn as Lr,ho as Lt,uc as M,ta as Mn,yr as Mr,So as Mt,cc as N,Ki as Nn,mr as Nr,Fo as Nt,dc as O,Hi as On,Cr as Or,Ma as Ot,sc as P,Gi as Pn,hr as Pr,Ao as Pt,os as Q,ci as Qn,Kn as Qr,Po as Qt,Js as R,Bi as Rn,$n as Rr,Na as Rt,zc as S,Rt as Si,ga as Sn,Lr as Sr,R as St,Nc as T,Pt as Ti,la as Tn,Or as Tr,Ga as Tt,Hs as U,Ai as Un,ar as Ur,L as Ut,Bs as V,Oi as Vn,tr as Vr,K as Vt,Fs as W,ki as Wn,er as Wr,La as Wt,gs as X,yi as Xn,Wn as Xr,$a as Xt,cs as Y,Ci as Yn,ir as Yr,Oo as Yt,is as Z,fi as Zn,Gn as Zr,To as Zt,$ as _,Vt as _i,ka as _n,Ir as _r,Ka as _t,Sc as a,Mn as ai,ao as an,ai as ar,ss as at,kc as b,Yt as bi,_a as bn,Br as br,po as bt,Y as c,Dn as ci,Ya as cn,Qr as cr,Os as ct,Rc as d,Sn as di,lo as dn,Jr as dr,vs as dt,In as ei,ko as en,ii as er,ds as et,Oc as f,O as fi,so as fn,qr as fr,ls as ft,_c as g,Gt as gi,Ea as gn,Nr as gr,eo as gt,hc as h,pn as hi,Da as hn,Mr as hr,vo as ht,Ec as i,Fn as ii,qa as in,oi as ir,q as it,lc as j,$i as jn,P as jr,z as jt,pc as k,ea as kn,Sr as kr,G as kt,xc as l,yn as li,no as ln,Yr as lr,As as lt,Cc as m,k as mi,zo as mn,Vr as mr,Ba as mt,yc as n,kn as ni,Eo as nn,ti as nr,ns as nt,Tc as o,Tn as oi,io as on,Zr as or,Es as ot,jc as p,fn as pi,fo as pn,Ur as pr,Aa as pt,us as q,Ii as qn,Zn as qr,Lo as qt,Z as r,Un as ri,Mo as rn,ri as rr,hs as rt,wc as s,Cn as si,W as sn,ei as sr,Ts as st,X as t,On as ti,Do as tn,ni as tr,Ps as tt,vc as u,A as ui,qo as un,Xr as ur,ys as ut,Ic as v,Wt as vi,Ta as vn,zr as vr,Za as vt,Dc as w,Nt as wi,ma as wn,Kr as wr,Ha as wt,Lc as x,Ht as xi,Ca as xn,Pr as xr,Ro as xt,gc as y,qt as yi,wa as yn,Rr as yr,ro as yt,Us as z,Fi as zn,Xn as zr,wo as zt};
@@ -0,0 +1,2 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{a as t,i as n,n as r,t as i}from"./from-CgDRRLiX.js";function a(e){let t=e.match(/\bfilename=("(.*?)"|([^()<>@,;:\\"/[\]?={}\s\t]+))($|;\s)/i);if(!t)return;let n=t[2]||t[3]||``,r=n.slice(n.lastIndexOf(`\\`)+1);return r=r.replace(/%22/g,`"`),r=r.replace(/&#(\d{4});/g,(e,t)=>String.fromCharCode(t)),r}async function o(e,n){if(!/multipart/i.test(n))throw TypeError(`Failed to fetch`);let i=n.match(/boundary=(?:"([^"]+)"|([^;]+))/i);if(!i)throw TypeError(`no or bad content-type header, no multipart boundary`);let o=new b(i[1]||i[2]),s,c,l,u,d,f,p=[],m=new r,h=e=>{l+=y.decode(e,{stream:!0})},g=e=>{p.push(e)},_=()=>{let e=new t(p,f,{type:d});m.append(u,e)},v=()=>{m.append(u,l)},y=new TextDecoder(`utf-8`);y.decode(),o.onPartBegin=function(){o.onPartData=h,o.onPartEnd=v,s=``,c=``,l=``,u=``,d=``,f=null,p.length=0},o.onHeaderField=function(e){s+=y.decode(e,{stream:!0})},o.onHeaderValue=function(e){c+=y.decode(e,{stream:!0})},o.onHeaderEnd=function(){if(c+=y.decode(),s=s.toLowerCase(),s===`content-disposition`){let e=c.match(/\bname=("([^"]*)"|([^()<>@,;:\\"/[\]?={}\s\t]+))/i);e&&(u=e[2]||e[3]||``),f=a(c),f&&(o.onPartData=g,o.onPartEnd=_)}else s===`content-type`&&(d=c);c=``,s=``};for await(let t of e)o.write(t);return o.end(),m}var s,c,l,u,d,f,p,m,h,g,_,v,y,b;e((()=>{i(),n(),s=0,c={START_BOUNDARY:s++,HEADER_FIELD_START:s++,HEADER_FIELD:s++,HEADER_VALUE_START:s++,HEADER_VALUE:s++,HEADER_VALUE_ALMOST_DONE:s++,HEADERS_ALMOST_DONE:s++,PART_DATA_START:s++,PART_DATA:s++,END:s++},l=1,u={PART_BOUNDARY:l,LAST_BOUNDARY:l*=2},d=10,f=13,p=32,m=45,h=58,g=97,_=122,v=e=>e|32,y=()=>{},b=class{constructor(e){this.index=0,this.flags=0,this.onHeaderEnd=y,this.onHeaderField=y,this.onHeadersEnd=y,this.onHeaderValue=y,this.onPartBegin=y,this.onPartData=y,this.onPartEnd=y,this.boundaryChars={},e=`\r
2
+ --`+e;let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n),this.boundaryChars[t[n]]=!0;this.boundary=t,this.lookbehind=new Uint8Array(this.boundary.length+8),this.state=c.START_BOUNDARY}write(e){let t=0,n=e.length,r=this.index,{lookbehind:i,boundary:a,boundaryChars:o,index:s,state:l,flags:y}=this,b=this.boundary.length,x=b-1,S=e.length,C,w,T=e=>{this[e+`Mark`]=t},E=e=>{delete this[e+`Mark`]},D=(e,t,n,r)=>{(t===void 0||t!==n)&&this[e](r&&r.subarray(t,n))},O=(n,r)=>{let i=n+`Mark`;i in this&&(r?(D(n,this[i],t,e),delete this[i]):(D(n,this[i],e.length,e),this[i]=0))};for(t=0;t<n;t++)switch(C=e[t],l){case c.START_BOUNDARY:if(s===a.length-2){if(C===m)y|=u.LAST_BOUNDARY;else if(C!==f)return;s++;break}else if(s-1==a.length-2){if(y&u.LAST_BOUNDARY&&C===m)l=c.END,y=0;else if(!(y&u.LAST_BOUNDARY)&&C===d)s=0,D(`onPartBegin`),l=c.HEADER_FIELD_START;else return;break}C!==a[s+2]&&(s=-2),C===a[s+2]&&s++;break;case c.HEADER_FIELD_START:l=c.HEADER_FIELD,T(`onHeaderField`),s=0;case c.HEADER_FIELD:if(C===f){E(`onHeaderField`),l=c.HEADERS_ALMOST_DONE;break}if(s++,C===m)break;if(C===h){if(s===1)return;O(`onHeaderField`,!0),l=c.HEADER_VALUE_START;break}if(w=v(C),w<g||w>_)return;break;case c.HEADER_VALUE_START:if(C===p)break;T(`onHeaderValue`),l=c.HEADER_VALUE;case c.HEADER_VALUE:C===f&&(O(`onHeaderValue`,!0),D(`onHeaderEnd`),l=c.HEADER_VALUE_ALMOST_DONE);break;case c.HEADER_VALUE_ALMOST_DONE:if(C!==d)return;l=c.HEADER_FIELD_START;break;case c.HEADERS_ALMOST_DONE:if(C!==d)return;D(`onHeadersEnd`),l=c.PART_DATA_START;break;case c.PART_DATA_START:l=c.PART_DATA,T(`onPartData`);case c.PART_DATA:if(r=s,s===0){for(t+=x;t<S&&!(e[t]in o);)t+=b;t-=x,C=e[t]}if(s<a.length)a[s]===C?(s===0&&O(`onPartData`,!0),s++):s=0;else if(s===a.length)s++,C===f?y|=u.PART_BOUNDARY:C===m?y|=u.LAST_BOUNDARY:s=0;else if(s-1===a.length)if(y&u.PART_BOUNDARY){if(s=0,C===d){y&=~u.PART_BOUNDARY,D(`onPartEnd`),D(`onPartBegin`),l=c.HEADER_FIELD_START;break}}else y&u.LAST_BOUNDARY&&C===m?(D(`onPartEnd`),l=c.END,y=0):s=0;if(s>0)i[s-1]=C;else if(r>0){let e=new Uint8Array(i.buffer,i.byteOffset,i.byteLength);D(`onPartData`,0,r,e),r=0,T(`onPartData`),t--}break;case c.END:break;default:throw Error(`Unexpected state entered: ${l}`)}O(`onHeaderField`),O(`onHeaderValue`),O(`onPartData`),this.index=s,this.state=l,this.flags=y}end(){if(this.state===c.HEADER_FIELD_START&&this.index===0||this.state===c.PART_DATA&&this.index===this.boundary.length)this.onPartEnd();else if(this.state!==c.END)throw Error(`MultipartParser.end(): stream ended unexpectedly`)}}}))();export{o as toFormData};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{l as t,o as n}from"./envUtils-DSxRz_kt.js";import{n as r,t as i}from"./axios-DaWTGg7G.js";import{A as a,B as o,E as s,G as c,J as l,O as u,U as d,_ as f,h as p,l as m,ot as ee,p as h,st as te,z as g}from"./debug-IKW-jE7K.js";import{Jt as ne,Zt as re}from"./settings-5PQdphqC.js";import{C as ie,S as ae,b as oe,c as _,g as se,w as v}from"./config-C7YHKCPV.js";import{n as y,r as b}from"./execFileNoThrow-COKYqVQj.js";import{o as x,s as S}from"./log-B3eB4EFv.js";import{n as C,r as w}from"./analytics-BotDBGh0.js";import{vn as ce,yn as le}from"./model-DfFA3qMO.js";import{_ as ue,y as de}from"./metadata-BRLJvh61.js";import{n as fe,r as pe,t as me}from"./semver-BMRJYn3q.js";import{C as he,S as ge,_ as _e,a as T,b as ve,c as ye,d as be,g as xe,h as Se,i as Ce,l as we,n as Te,o as E,p as Ee,s as De,t as Oe,v as D,x as ke,y as Ae}from"./pidLock-CBJDnBG_.js";import{a as je,i as Me,n as Ne,r as Pe,t as Fe}from"./xdg-DcF9ejUM.js";import{homedir as O}from"os";import{basename as Ie,delimiter as Le,dirname as k,join as A,resolve as j}from"path";import{constants as Re}from"fs";import{createHash as ze}from"crypto";import{access as M,chmod as N,copyFile as P,mkdir as F,readdir as I,readlink as L,rename as R,rm as z,rmdir as Be,stat as B,symlink as Ve,unlink as V,writeFile as He}from"fs/promises";async function Ue(e=`latest`){let t=Date.now(),{stdout:n,code:r,stderr:i}=await y(`npm`,[`view`,`@${e}`,`version`,`--prefer-online`,`--registry`,U],{timeout:3e4,preserveOutputOnError:!0}),a=Date.now()-t;if(r!==0){w(`tengu_version_check_failure`,{latency_ms:a,source_npm:!0,exit_code:r});let e=Error(`npm view failed with code ${r}: ${i}`);throw S(e),e}return w(`tengu_version_check_success`,{latency_ms:a,source_npm:!0}),h(`npm view @${e} version: ${n}`),n.trim()}async function We(e=`latest`,t,n){let i=Date.now();try{let a=await r.get(`${t}/${e}`,{timeout:3e4,responseType:`text`,...n});return w(`tengu_version_check_success`,{latency_ms:Date.now()-i}),a.data.trim()}catch(n){let a=Date.now()-i,o=n instanceof Error?n.message:String(n),s;r.isAxiosError(n)&&n.response&&(s=n.response.status),w(`tengu_version_check_failure`,{latency_ms:a,http_status:s,is_timeout:o.includes(`timeout`)});let c=Error(`Failed to fetch version from ${t}/${e}: ${o}`);throw S(c),c}}async function Ge(e){if(/^v?\d+\.\d+\.\d+(-\S+)?$/.test(e)){let t=e.startsWith(`v`)?e.slice(1):e;if(/^99\.99\./.test(t))throw Error(`Version ${t} is not available for installation. Use 'stable' or 'latest'.`);return t}let t=e;if(t!==`stable`&&t!==`latest`)throw Error(`Invalid channel: ${e}. Use 'stable' or 'latest'`);return process.env.USER_TYPE===`ant`?Ue(t===`stable`?`stable`:`latest`):We(t,H)}async function Ke(e,t){let n=p();await n.rm(t,{recursive:!0,force:!0});let r=W(),i=`-${r}`;h(`Fetching integrity hash for ${i}@${e}`);let{stdout:o,code:s,stderr:c}=await y(`npm`,[`view`,`${i}@${e}`,`dist.integrity`,`--registry`,U],{timeout:3e4,preserveOutputOnError:!0});if(s!==0)throw Error(`npm view integrity failed with code ${s}: ${c}`);let l=o.trim();if(!l)throw Error(`Failed to fetch integrity hash for ${i}@${e}`);h(`Got integrity hash for ${r}: ${l}`),await n.mkdir(t);let d={name:`claude-native-installer`,version:`0.0.1`,dependencies:{"":e}},f={name:`claude-native-installer`,version:`0.0.1`,lockfileVersion:3,requires:!0,packages:{"":{name:`claude-native-installer`,version:`0.0.1`,dependencies:{"":e}},"node_modules/":{version:e,optionalDependencies:{[i]:e}},[`node_modules/${i}`]:{version:e,integrity:l}}};a(A(t,`package.json`),u(d,null,2),{encoding:`utf8`,flush:!0}),a(A(t,`package-lock.json`),u(f,null,2),{encoding:`utf8`,flush:!0});let m=await y(`npm`,[`ci`,`--prefer-online`,`--registry`,U],{timeout:6e4,preserveOutputOnError:!0,cwd:t});if(m.code!==0)throw Error(`npm ci failed with code ${m.code}: ${m.stderr}`);h(`Successfully downloaded and verified @${e}`)}function qe(){return Number(process.env.CLAUDE_CODE_STALL_TIMEOUT_MS_FOR_TESTING)||Ze}async function Je(e,t,n,i={}){let a;for(let o=1;o<=3;o++){let s=new AbortController,c,u=()=>{c&&(clearTimeout(c),c=void 0)},d=()=>{u(),c=setTimeout(e=>e.abort(),qe(),s)};try{d();let a=await r.get(e,{timeout:5*6e4,responseType:`arraybuffer`,signal:s.signal,onDownloadProgress:()=>{d()},...i});u();let o=ze(`sha256`);o.update(a.data);let c=o.digest(`hex`);if(c!==t)throw Error(`Checksum mismatch: expected ${t}, got ${c}`);await He(n,Buffer.from(a.data)),await N(n,493);return}catch(e){u();let t=r.isCancel(e);if(a=t?new Qe:l(e),t&&o<3){h(`Download stalled on attempt ${o}/3, retrying...`),await le(1e3);continue}throw a}}throw a??Error(`Download failed after all retries`)}async function Ye(e,t,n,i){let a=p();await a.rm(t,{recursive:!0,force:!0});let o=W(),s=Date.now();w(`tengu_binary_download_attempt`,{});let c;try{c=(await r.get(`${n}/${e}/manifest.json`,{timeout:1e4,responseType:`json`,...i})).data}catch(t){let i=Date.now()-s,a=t instanceof Error?t.message:String(t),o;throw r.isAxiosError(t)&&t.response&&(o=t.response.status),w(`tengu_binary_manifest_fetch_failure`,{latency_ms:i,http_status:o,is_timeout:a.includes(`timeout`)}),S(Error(`Failed to fetch manifest from ${n}/${e}/manifest.json: ${a}`)),t}let l=c.platforms[o];if(!l)throw w(`tengu_binary_platform_not_found`,{}),Error(`Platform ${o} not found in manifest for version ${e}`);let u=l.checksum,d=G(o),f=`${n}/${e}/${o}/${d}`;await a.mkdir(t);let m=A(t,d);try{await Je(f,u,m,i||{}),w(`tengu_binary_download_success`,{latency_ms:Date.now()-s})}catch(e){let t=Date.now()-s,n=e instanceof Error?e.message:String(e),i;throw r.isAxiosError(e)&&e.response&&(i=e.response.status),w(`tengu_binary_download_failure`,{latency_ms:t,http_status:i,is_timeout:n.includes(`timeout`),is_checksum_mismatch:n.includes(`Checksum mismatch`)}),S(Error(`Failed to download binary from ${f}: ${n}`)),e}}async function Xe(e,t){return process.env.USER_TYPE===`ant`?(await Ke(e,t),`npm`):(await Ye(e,t,H),`binary`)}var H,U,Ze,Qe,$e=e((()=>{i(),C(),m(),d(),b(),f(),x(),ce(),s(),$(),H=`https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases`,U=`https://artifactory.infra.ant.dev/artifactory/api/npm/npm-all/`,Ze=6e4,Qe=class extends Error{constructor(){super(`Download stalled: no data received for 60 seconds`),this.name=`StallTimeoutError`}}}));function W(){let e=ne.platform,t=process.arch===`x64`?`x64`:process.arch===`arm64`?`arm64`:null;if(!t){let e=Error(`Unsupported architecture: ${process.arch}`);throw h(`Native installer does not support architecture: ${process.arch}`,{level:`error`}),e}return e===`linux`&&ue.isMuslEnvironment()?`linux-${t}-musl`:`${e}-${t}`}function G(e){return e.startsWith(`win32`)?`claude.exe`:`claude`}function K(){let e=G(W());return{versions:A(Pe(),`claude`,`versions`),staging:A(Ne(),`claude`,`staging`),locks:A(Me(),`claude`,`locks`),executable:A(Fe(),e)}}async function q(e){try{let t=await B(e);return!t.isFile()||t.size===0?!1:(await M(e,Re.X_OK),!0)}catch{return!1}}async function J(e){let t=K(),n=[t.versions,t.staging,t.locks];await Promise.all(n.map(e=>F(e,{recursive:!0}))),await F(k(t.executable),{recursive:!0});let r=A(t.versions,e);try{await B(r)}catch{await He(r,``,{encoding:`utf8`})}return{stagingPath:A(t.staging,e),installPath:r}}async function et(e,t,n=0){let r=K(),i=Y(r,e);if(await F(r.locks,{recursive:!0}),E()){let r=0,a=n+1,o=n>0?1e3:100,s=n>0?5e3:500;for(;r<a;){if(await ye(e,i,async()=>{try{await t()}catch(e){throw S(e),e}}))return w(`tengu_version_lock_acquired`,{is_pid_based:!0,is_lifetime_lock:!1,attempts:r+1}),!0;r++,r<a&&await le(Math.min(o*2**(r-1),s))}return w(`tengu_version_lock_failed`,{is_pid_based:!0,is_lifetime_lock:!1,attempts:a}),X(e,Error(`Lock held by another process`)),!1}let a=null;try{try{a=await v(e,{stale:Z,retries:{retries:n,minTimeout:n>0?1e3:100,maxTimeout:n>0?5e3:500},lockfilePath:i,onCompromised:e=>{h(`NON-FATAL: Version lock was compromised during operation: ${e.message}`,{level:`info`})}})}catch(t){return w(`tengu_version_lock_failed`,{is_pid_based:!1,is_lifetime_lock:!1}),X(e,t),!1}try{return await t(),w(`tengu_version_lock_acquired`,{is_pid_based:!1,is_lifetime_lock:!1}),!0}catch(e){throw S(e),e}}finally{a&&await a()}}async function tt(e,t){await F(k(t),{recursive:!0});let n=`${t}.tmp.${process.pid}.${Date.now()}`;try{await P(e,n),await N(n,493),await R(n,t),h(`Atomically installed binary to ${t}`)}catch(e){try{await V(n)}catch{}throw e}}async function nt(e,t){try{let n=A(e,`node_modules`,`@anthropic-ai`),r=(await I(n)).find(e=>e.startsWith(`claude-cli-native-`));if(!r)throw w(`tengu_native_install_package_failure`,{stage_find_package:!0,error_package_not_found:!0}),Error(`Could not find platform-specific native package`);let i=A(n,r,`cli`);try{await B(i)}catch{throw w(`tengu_native_install_package_failure`,{stage_binary_exists:!0,error_binary_not_found:!0}),Error(`Native binary not found in staged package`)}await tt(i,t),await z(e,{recursive:!0,force:!0}),w(`tengu_native_install_package_success`,{})}catch(e){let t=g(e);throw!t.includes(`Could not find platform-specific`)&&!t.includes(`Native binary not found`)&&w(`tengu_native_install_package_failure`,{stage_atomic_move:!0,error_move_failed:!0}),S(l(e)),e}}async function rt(e,t){try{let n=A(e,G(W()));try{await B(n)}catch{throw w(`tengu_native_install_binary_failure`,{stage_binary_exists:!0,error_binary_not_found:!0}),Error(`Staged binary not found`)}await tt(n,t),await z(e,{recursive:!0,force:!0}),w(`tengu_native_install_binary_success`,{})}catch(e){throw g(e).includes(`Staged binary not found`)||w(`tengu_native_install_binary_failure`,{stage_atomic_move:!0,error_move_failed:!0}),S(l(e)),e}}async function it(e,t,n){n===`npm`?await nt(e,t):await rt(e,t)}async function at(e,n){let{stagingPath:r,installPath:i}=await J(e),{executable:a}=K(),o=t(process.env.ENABLE_LOCKLESS_UPDATES)?`${r}.${process.pid}.${Date.now()}`:r,s=!await ot(e)||n;if(s?(h(n?`Force reinstalling native installer version ${e}`:`Downloading native installer version ${e}`),await it(o,i,await Xe(e,o))):h(`Version ${e} already installed, updating symlink`),await ct(a),await lt(a,i),!await q(a)){let e=!1;try{await B(i),e=!0}catch{}throw Error(`Failed to create executable at ${a}. Source file exists: ${e}. Check write permissions to ${a}.`)}return s}async function ot(e){let{installPath:t}=await J(e);return q(t)}async function st(e,n=!1){let r=Date.now(),i=await Ge(e),{executable:a}=K();if(h(`Checking for native installer update to version ${i}`),!n){let e=await Ee();if(e&&me(i,e)){if(h(`Native installer: maxVersion ${e} is set, capping update from ${i} to ${e}`),fe(`0.0.1`,e))return h(`Native installer: current version 0.0.1 is already at or above maxVersion ${e}, skipping update`),w(`tengu_native_update_skipped_max_version`,{latency_ms:Date.now()-r,max_version:e,available_version:i}),{success:!0,latestVersion:i};i=e}}if(!n&&i===`0.0.1`&&await ot(i)&&await q(a))return h(`Found ${i} at ${a}, skipping install`),w(`tengu_native_update_complete`,{latency_ms:Date.now()-r,was_new_install:!1,was_force_reinstall:!1,was_already_running:!0}),{success:!0,latestVersion:i};if(!n&&xe(i))return w(`tengu_native_update_skipped_minimum_version`,{latency_ms:Date.now()-r,target_version:i}),{success:!0,latestVersion:i};let o=!1,s;if(t(process.env.ENABLE_LOCKLESS_UPDATES))o=await at(i,n),s=Date.now()-r;else{let{installPath:e}=await J(i);n&&await ht(e);let t=await et(e,async()=>{o=await at(i,n)},3);if(s=Date.now()-r,!t){let t=K(),n;if(E()){let r=Y(t,e);T(r)&&(n=De(r)?.pid)}return w(`tengu_native_update_lock_failed`,{latency_ms:s,lock_holder_pid:n}),{success:!1,latestVersion:i,lockFailed:!0,lockHolderPid:n}}}return w(`tengu_native_update_complete`,{latency_ms:s,was_new_install:o,was_force_reinstall:n}),h(`Successfully updated to version ${i}`),{success:!0,latestVersion:i}}async function ct(e){try{await Be(e),h(`Removed empty directory at ${e}`)}catch(t){let n=o(t);n!==`ENOTDIR`&&n!==`ENOENT`&&n!==`ENOTEMPTY`&&h(`Could not remove directory at ${e}: ${t}`)}}async function lt(e,t){if(W().startsWith(`win32`))try{await F(k(e),{recursive:!0});let n;try{n=await B(e)}catch{}if(n){try{let e=await B(t);if(n.size===e.size)return!1}catch{}let r=`${e}.old.${Date.now()}`;await R(e,r);try{await P(t,e);try{await V(r)}catch{}}catch(t){try{await R(r,e)}catch(e){let n=Error(`Failed to restore old executable: ${e}`,{cause:t});throw S(n),n}throw t}}else try{await P(t,e)}catch(e){throw c(e)?Error(`Source file does not exist: ${t}`):e}return!0}catch(n){return S(Error(`Failed to copy executable from ${t} to ${e}: ${n}`)),!1}let n=k(e);try{await F(n,{recursive:!0}),h(`Created directory ${n} for symlink`)}catch(e){return S(Error(`Failed to create directory ${n}: ${e}`)),!1}try{let n=!1;try{await B(e),n=!0}catch{}if(n){try{let n=await L(e);if(j(k(e),n)===j(t))return!1}catch{}await V(e)}}catch(e){S(Error(`Failed to check/remove existing symlink: ${e}`))}let r=`${e}.tmp.${process.pid}.${Date.now()}`;try{return await Ve(t,r),await R(r,e),h(`Atomically updated symlink ${e} -> ${t}`),!0}catch(n){try{await V(r)}catch{}return S(Error(`Failed to create symlink from ${e} to ${t}: ${n}`)),!1}}async function ut(e=!1){if(t(process.env.DISABLE_INSTALLATION_CHECKS))return[];let n=await we();if(n===`development`)return[];let r=_();if(!(e||n===`native`||r.installMethod===`native`))return[];let i=K(),a=[],o=k(i.executable),s=j(o),l=W().startsWith(`win32`);try{await M(o)}catch{a.push({message:`installMethod is native, but directory ${o} does not exist`,userActionRequired:!0,type:`error`})}if(l)await q(i.executable)||a.push({message:`installMethod is native, but claude command is missing or invalid at ${i.executable}`,userActionRequired:!0,type:`error`});else try{let e=await L(i.executable);await q(j(k(i.executable),e))||a.push({message:`Claude symlink points to missing or invalid binary: ${e}`,userActionRequired:!0,type:`error`})}catch(e){c(e)?a.push({message:`installMethod is native, but claude command not found at ${i.executable}`,userActionRequired:!0,type:`error`}):await q(i.executable)||a.push({message:`${i.executable} exists but is not a valid Claude binary`,userActionRequired:!0,type:`error`})}if(!(process.env.PATH||``).split(Le).some(e=>{try{let t=j(e);return l?t.toLowerCase()===s.toLowerCase():t===s}catch{return!1}}))if(l){let e=o.replace(/\//g,`\\`);a.push({message:`Native installation exists but ${e} is not in your PATH. Add it by opening: System Properties → Environment Variables → Edit User PATH → New → Add the path above. Then restart your terminal.`,userActionRequired:!0,type:`path`})}else{let e=ge(),t=D()[e],n=t?t.replace(O(),`~`):`your shell config file`;a.push({message:`Native installation exists but ~/.local/bin is not in your PATH. Run:\n\necho 'export PATH="$HOME/.local/bin:$PATH"' >> ${n} && source ${n}`,userActionRequired:!0,type:`path`})}return a}function dt(e,t=!1){if(t)return ft(e,t);if(Q)return h(`installLatest: joining in-flight call`),Q;let n=ft(e,t);Q=n;let r=()=>{Q=null};return n.then(r,r),n}async function ft(e,t=!1){let n=await st(e,t);return n.success?(_().installMethod!==`native`&&(oe(e=>({...e,installMethod:`native`,autoUpdates:!1,autoUpdatesProtectedForNative:!0})),h(`Native installer: Set installMethod to "native" and disabled legacy auto-updater for protection`)),gt(),{latestVersion:n.latestVersion,wasUpdated:n.success,lockFailed:!1}):{latestVersion:null,wasUpdated:!1,lockFailed:n.lockFailed,lockHolderPid:n.lockHolderPid}}async function pt(e){try{let t=await L(e),n=j(k(e),t);if(await q(n))return n}catch{}return null}function Y(e,t){let n=Ie(t);return A(e.locks,`${n}.lock`)}async function mt(){let e=K();if(!process.execPath.includes(e.versions))return;let t=j(process.execPath);try{let n=Y(e,t);if(await F(e.locks,{recursive:!0}),E()){if(!await Oe(t,n)){w(`tengu_version_lock_failed`,{is_pid_based:!0,is_lifetime_lock:!0}),X(t,Error(`Lock already held by another process`));return}w(`tengu_version_lock_acquired`,{is_pid_based:!0,is_lifetime_lock:!0}),h(`Acquired PID lock on running version: ${t}`)}else{let e;try{e=await v(t,{stale:Z,retries:0,lockfilePath:n,onCompromised:e=>{h(`NON-FATAL: Lock on running version was compromised: ${e.message}`,{level:`info`})}}),w(`tengu_version_lock_acquired`,{is_pid_based:!1,is_lifetime_lock:!0}),h(`Acquired mtime-based lock on running version: ${t}`),te(async()=>{try{await e?.()}catch{}})}catch(e){if(c(e)){h(`Cannot lock current version - file does not exist: ${t}`,{level:`info`});return}w(`tengu_version_lock_failed`,{is_pid_based:!1,is_lifetime_lock:!0}),X(t,e);return}}}catch(e){if(c(e)){h(`Cannot lock current version - file does not exist: ${t}`,{level:`info`});return}h(`NON-FATAL: Failed to lock current version during execution ${g(e)}`,{level:`info`})}}function X(e,t){S(Error(`NON-FATAL: Lock acquisition failed for ${e} (expected in multi-process scenarios)`,{cause:t}))}async function ht(e){let t=Y(K(),e);try{await V(t),h(`Force-removed lock file at ${t}`)}catch(e){h(`Failed to force-remove lock file: ${g(e)}`)}}async function gt(){await Promise.resolve();let e=K(),t=Date.now()-36e5;if(W().startsWith(`win32`)){let t=k(e.executable);try{let e=await I(t),n=0;for(let r of e)if(/^claude\.exe\.old\.\d+$/.test(r))try{await V(A(t,r)),n++}catch{}n>0&&h(`Cleaned up ${n} old Windows executables on startup`)}catch(e){c(e)||h(`Failed to clean up old Windows executables: ${e}`)}}try{let n=await I(e.staging),r=0;for(let i of n){let n=A(e.staging,i);try{(await B(n)).mtime.getTime()<t&&(await z(n,{recursive:!0,force:!0}),r++,h(`Cleaned up old staging directory: ${i}`))}catch{}}r>0&&(h(`Cleaned up ${r} orphaned staging directories`),w(`tengu_native_staging_cleanup`,{cleaned_count:r}))}catch(e){c(e)||h(`Failed to clean up staging directories: ${e}`)}if(E()){let t=Te(e.locks);t>0&&(h(`Cleaned up ${t} stale version locks`),w(`tengu_native_stale_locks_cleanup`,{cleaned_count:t}))}let n;try{n=await I(e.versions)}catch(e){c(e)||h(`Failed to readdir versions directory: ${e}`);return}let r=[],i=0;for(let a of n){let n=A(e.versions,a);if(/\.tmp\.\d+\.\d+$/.test(a)){try{(await B(n)).mtime.getTime()<t&&(await V(n),i++,h(`Cleaned up orphaned temp install file: ${a}`))}catch{}continue}try{let e=await B(n);if(!e.isFile()||process.platform!==`win32`&&e.size>0&&!(e.mode&73))continue;r.push({name:a,path:n,resolvedPath:j(n),mtime:e.mtime})}catch{}}if(i>0&&(h(`Cleaned up ${i} orphaned temp install files`),w(`tengu_native_temp_files_cleanup`,{cleaned_count:i})),r.length!==0)try{let t=process.execPath,n=new Set;t&&t.includes(e.versions)&&n.add(j(t));let i=await pt(e.executable);i&&n.add(i);for(let t of r){if(n.has(t.resolvedPath))continue;let r=Y(e,t.resolvedPath),i=!1;if(E())i=T(r);else try{i=await ae(t.resolvedPath,{stale:Z,lockfilePath:r})}catch{i=!1}i&&(n.add(t.resolvedPath),h(`Protecting locked version from cleanup: ${t.name}`))}let a=r.filter(e=>!n.has(e.resolvedPath)).sort((e,t)=>t.mtime.getTime()-e.mtime.getTime()).slice(2);if(a.length===0){w(`tengu_native_version_cleanup`,{total_count:r.length,deleted_count:0,protected_count:n.size,retained_count:2,lock_failed_count:0,error_count:0});return}let o=0,s=0,c=0;await Promise.all(a.map(async e=>{try{await et(e.path,async()=>{await V(e.path)})?o++:(s++,h(`Skipping deletion of ${e.name} - locked by another process`))}catch(t){c++,S(Error(`Failed to delete version ${e.name}: ${t}`))}})),w(`tengu_native_version_cleanup`,{total_count:r.length,deleted_count:o,protected_count:n.size,retained_count:2,lock_failed_count:s,error_count:c})}catch(e){c(e)||S(Error(`Version cleanup failed: ${e}`))}}async function _t(){let e=[],t=D();for(let[n,r]of Object.entries(t))try{let t=await ve(r);if(!t)continue;let{filtered:i,hadAlias:a}=_e(t);a&&(await ke(r,i),e.push({message:`Removed claude alias from ${r}. Run: unalias claude`,userActionRequired:!0,type:`alias`}),h(`Cleaned up claude alias from ${n} config`))}catch(t){S(t),e.push({message:`Failed to clean up ${r}: ${t}`,userActionRequired:!1,type:`error`})}return e}async function vt(e){try{let t=await y(`npm`,[`config`,`get`,`prefix`]);if(t.code!==0||!t.stdout)return{success:!1,error:`Failed to get npm global prefix`};let n=t.stdout.trim(),r=!1;async function i(e,t){try{return await V(e),h(`Manually removed ${t}: ${e}`),!0}catch{return!1}}if(W().startsWith(`win32`)){let e=A(n,`claude.cmd`),t=A(n,`claude.ps1`),a=A(n,`claude`);await i(e,`bin script`)&&(r=!0),await i(t,`PowerShell script`)&&(r=!0),await i(a,`bin executable`)&&(r=!0)}else await i(A(n,`bin`,`claude`),`bin symlink`)&&(r=!0);return r?(h(`Successfully removed ${e} manually`),{success:!0,warning:`${e} executables removed, but node_modules directory was left intact for safety. You may manually delete it later at: ${W().startsWith(`win32`)?A(n,`node_modules`,e):A(n,`lib`,`node_modules`,e)}`}):{success:!1}}catch(e){return h(`Manual removal failed: ${e}`,{level:`error`}),{success:!1,error:`Manual removal failed: ${e}`}}}async function yt(e){let{code:t,stderr:n}=await y(`npm`,[`uninstall`,`-g`,e],{cwd:process.cwd()});if(t===0)return h(`Removed global npm installation of ${e}`),{success:!0};if(n&&!n.includes(`npm ERR! code E404`)){if(n.includes(`npm error code ENOTEMPTY`)){h(`Failed to uninstall global npm package ${e}: ${n}`,{level:`error`}),h(`Attempting manual removal due to ENOTEMPTY error`);let t=await vt(e);if(t.success)return{success:!0,warning:t.warning};if(t.error)return{success:!1,error:`Failed to remove global npm installation of ${e}: ${n}. Manual removal also failed: ${t.error}`}}return h(`Failed to uninstall global npm package ${e}: ${n}`,{level:`error`}),{success:!1,error:`Failed to remove global npm installation of ${e}: ${n}`}}return{success:!1}}async function bt(){let e=[],t=[],n=0,r=await yt(`@anthropic-ai/claude-code`);r.success?(n++,r.warning&&t.push(r.warning)):r.error&&e.push(r.error);let i=A(O(),`.claude`,`local`);try{await z(i,{recursive:!0}),n++,h(`Removed local installation at ${i}`)}catch(t){c(t)||(e.push(`Failed to remove ${i}: ${t}`),h(`Failed to remove local installation: ${t}`,{level:`error`}))}return{removed:n,errors:e,warnings:t}}var Z,Q,$=e((()=>{C(),Se(),ee(),se(),m(),be(),re(),de(),n(),d(),b(),he(),ie(),x(),pe(),Ae(),ce(),je(),$e(),Ce(),Z=10080*60*1e3,Q=null})),xt=e((()=>{$()}));export{_t as a,mt as c,gt as i,ut as n,$ as o,bt as r,dt as s,xt as t};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{l as t,o as n}from"./envUtils-DSxRz_kt.js";function r(){if(process.env.USER_TYPE===`ant`){if(t(process.env.USE_LOCAL_OAUTH))return`local`;if(t(process.env.USE_STAGING_OAUTH))return`staging`}return`prod`}function i(){if(process.env.CLAUDE_CODE_CUSTOM_OAUTH_URL)return`-custom-oauth`;switch(r()){case`local`:return`-local-oauth`;case`staging`:return`-staging-oauth`;case`prod`:return``}}function a(){let e=process.env.CLAUDE_LOCAL_OAUTH_API_BASE?.replace(/\/$/,``)??`http://localhost:8000`,t=process.env.CLAUDE_LOCAL_OAUTH_APPS_BASE?.replace(/\/$/,``)??`http://localhost:4000`,n=process.env.CLAUDE_LOCAL_OAUTH_CONSOLE_BASE?.replace(/\/$/,``)??`http://localhost:3000`;return{BASE_API_URL:e,CONSOLE_AUTHORIZE_URL:`${n}/oauth/authorize`,CLAUDE_AI_AUTHORIZE_URL:`${t}/oauth/authorize`,CLAUDE_AI_ORIGIN:t,TOKEN_URL:`${e}/v1/oauth/token`,API_KEY_URL:`${e}/api/oauth/claude_cli/create_api_key`,ROLES_URL:`${e}/api/oauth/claude_cli/roles`,CONSOLE_SUCCESS_URL:`${n}/buy_credits?returnUrl=/oauth/code/success%3Fapp%3Dclaude-code`,CLAUDEAI_SUCCESS_URL:`${n}/oauth/code/success?app=claude-code`,MANUAL_REDIRECT_URL:`${n}/oauth/code/callback`,CLIENT_ID:`22422756-60c9-4084-8eb7-27705fd5cf9a`,OAUTH_FILE_SUFFIX:`-local-oauth`,MCP_PROXY_URL:`http://localhost:8205`,MCP_PROXY_PATH:`/v1/toolbox/shttp/mcp/{server_id}`}}function o(){let e=(()=>{switch(r()){case`local`:return a();case`staging`:return g??m;case`prod`:return m}})(),t=process.env.CLAUDE_CODE_CUSTOM_OAUTH_URL;if(t){let n=t.replace(/\/$/,``);if(!_.includes(n))throw Error(`CLAUDE_CODE_CUSTOM_OAUTH_URL is not an approved endpoint.`);e={...e,BASE_API_URL:n,CONSOLE_AUTHORIZE_URL:`${n}/oauth/authorize`,CLAUDE_AI_AUTHORIZE_URL:`${n}/oauth/authorize`,CLAUDE_AI_ORIGIN:n,TOKEN_URL:`${n}/v1/oauth/token`,API_KEY_URL:`${n}/api/oauth/claude_cli/create_api_key`,ROLES_URL:`${n}/api/oauth/claude_cli/roles`,CONSOLE_SUCCESS_URL:`${n}/oauth/code/success?app=claude-code`,CLAUDEAI_SUCCESS_URL:`${n}/oauth/code/success?app=claude-code`,MANUAL_REDIRECT_URL:`${n}/oauth/code/callback`,OAUTH_FILE_SUFFIX:`-custom-oauth`}}let n=process.env.CLAUDE_CODE_OAUTH_CLIENT_ID;return n&&(e={...e,CLIENT_ID:n}),e}var s,c,l,u,d,f,p,m,h,g,_,v=e((()=>{n(),s=`user:inference`,c=`user:profile`,l=`org:create_api_key`,u=`oauth-2025-04-20`,d=[l,c],f=[c,s,`user:sessions:claude_code`,`user:mcp_servers`,`user:file_upload`],p=Array.from(new Set([...d,...f])),m={BASE_API_URL:`https://api.anthropic.com`,CONSOLE_AUTHORIZE_URL:`https://platform.claude.com/oauth/authorize`,CLAUDE_AI_AUTHORIZE_URL:`https://claude.com/cai/oauth/authorize`,CLAUDE_AI_ORIGIN:`https://claude.ai`,TOKEN_URL:`https://platform.claude.com/v1/oauth/token`,API_KEY_URL:`https://api.anthropic.com/api/oauth/claude_cli/create_api_key`,ROLES_URL:`https://api.anthropic.com/api/oauth/claude_cli/roles`,CONSOLE_SUCCESS_URL:`https://platform.claude.com/buy_credits?returnUrl=/oauth/code/success%3Fapp%3Dclaude-code`,CLAUDEAI_SUCCESS_URL:`https://platform.claude.com/oauth/code/success?app=claude-code`,MANUAL_REDIRECT_URL:`https://platform.claude.com/oauth/code/callback`,CLIENT_ID:`9d1c250a-e61b-44d9-88ed-5944d1962f5e`,OAUTH_FILE_SUFFIX:``,MCP_PROXY_URL:`https://mcp-proxy.anthropic.com`,MCP_PROXY_PATH:`/v1/mcp/{server_id}`},h=`https://claude.ai/oauth/claude-code-client-metadata`,g=process.env.USER_TYPE===`ant`?{BASE_API_URL:`https://api-staging.anthropic.com`,CONSOLE_AUTHORIZE_URL:`https://platform.staging.ant.dev/oauth/authorize`,CLAUDE_AI_AUTHORIZE_URL:`https://claude-ai.staging.ant.dev/oauth/authorize`,CLAUDE_AI_ORIGIN:`https://claude-ai.staging.ant.dev`,TOKEN_URL:`https://platform.staging.ant.dev/v1/oauth/token`,API_KEY_URL:`https://api-staging.anthropic.com/api/oauth/claude_cli/create_api_key`,ROLES_URL:`https://api-staging.anthropic.com/api/oauth/claude_cli/roles`,CONSOLE_SUCCESS_URL:`https://platform.staging.ant.dev/buy_credits?returnUrl=/oauth/code/success%3Fapp%3Dclaude-code`,CLAUDEAI_SUCCESS_URL:`https://platform.staging.ant.dev/oauth/code/success?app=claude-code`,MANUAL_REDIRECT_URL:`https://platform.staging.ant.dev/oauth/code/callback`,CLIENT_ID:`22422756-60c9-4084-8eb7-27705fd5cf9a`,OAUTH_FILE_SUFFIX:`-staging-oauth`,MCP_PROXY_URL:`https://mcp-proxy-staging.anthropic.com`,MCP_PROXY_PATH:`/v1/mcp/{server_id}`}:void 0,_=[`https://beacon.claude-ai.staging.ant.dev`,`https://claude.fedstart.com`,`https://claude-staging.fedstart.com`]}));export{d as a,i as c,c as i,o as l,s as n,h as o,f as r,u as s,p as t,v as u};
@@ -0,0 +1 @@
1
+ import{l as e,u as t}from"./oauth-BqJqV-2M.js";t();export{e as getOauthConfig};
@@ -0,0 +1,4 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{dirname as t,join as n}from"node:path";import{createHash as r,randomUUID as i}from"node:crypto";import{mkdir as a,readFile as o,rename as s,stat as c,writeFile as l}from"node:fs/promises";function u(e){return e?.rootDir?e.rootDir:process.env.CLAUDE_SKILL_LEARNING_HOME?process.env.CLAUDE_SKILL_LEARNING_HOME:n(process.env.HOME??process.cwd(),`.claude`,`skill-learning`)}function d(e){let t=u(e),r=e?.project;return!r||r.scope===`global`||r.projectId===`global`?n(t,`global`,`observations.jsonl`):n(t,`projects`,r.projectId,`observations.jsonl`)}function f(e,t=D){if(e===void 0)return;let n=e;for(let e of j)n=n.replace(e,e=>{let t=e.split(/[:=]/,1)[0];return/[:=]/.test(e)?`${t}: ${A}`:A});if(n.length<=t)return n;let r=E(n),i=n.slice(0,t);return n.includes(A)&&!i.includes(A)&&(i=`${A} ${i}`),`${i}\n[TRUNCATED length=${n.length} sha256=${r}]`}function p(e,t){let n=t?.maxFieldLength??D,r={...e,toolInput:f(e.toolInput,n),toolOutput:f(e.toolOutput,n),messageText:f(e.messageText,n)},i=[r.event,r.toolName??``,r.toolInput??``,r.toolOutput??``,r.messageText??``].join(`
2
+ `);return{...r,contentHash:E(i)}}async function m(e,n){let r=d(n);await a(t(r),{recursive:!0}),await v(n);let i=p(e,n),o=JSON.stringify(i);return Buffer.byteLength(o)>M||await l(r,`${o}\n`,{flag:`a`}),i}async function h(e){let t=d(e),n=``;try{n=await o(t,`utf8`)}catch(e){if(e.code===`ENOENT`)return[];throw e}let r=[];for(let e of n.split(/\r?\n/))if(e.trim())try{r.push(JSON.parse(e))}catch{}return r}async function g(e,t){let n=await o(e,`utf8`),r=[];for(let e of n.split(/\r?\n/)){if(!e.trim())continue;let n=JSON.parse(e);for(let e of y(n,t))r.push(await m(e,t))}return r}async function _(e){let t=d(e),n=e?.maxAgeDays??k,r=Date.now()-n*24*60*60*1e3,i=``;try{i=await o(t,`utf8`)}catch(e){if(e.code===`ENOENT`)return 0;throw e}let a=[],c=0;for(let e of i.split(/\r?\n/))if(e.trim())try{let t=JSON.parse(e),n=Date.parse(t.timestamp);if(!Number.isNaN(n)&&n<r){c+=1;continue}a.push(e)}catch{a.push(e)}if(c===0)return 0;let u=`${t}.tmp-${process.pid}-${Date.now()}`;return await l(u,a.length?`${a.join(`
3
+ `)}\n`:``),await s(u,t),c}async function v(e){let r=d(e),i=e?.archiveThresholdBytes??O,o;try{o=await c(r)}catch(e){if(e.code===`ENOENT`)return null;throw e}if(o.size<i)return null;let l=n(t(r),`observations.archive`);await a(l,{recursive:!0});let u=n(l,`observations-${new Date().toISOString().replace(/[:.]/g,`-`)}.jsonl`);return await s(r,u),u}function y(e,t){let n=t?.project,r={sessionId:e.sessionId??`unknown-session`,projectId:n?.projectId??`global`,projectName:n?.projectName??`global`,cwd:e.cwd??n?.cwd??process.cwd(),timestamp:e.timestamp??new Date().toISOString(),source:`transcript`},i=e.message?.role??e.type,a=e.message?.content,o=[];if(e.tool_name&&o.push({...r,id:T(),event:`tool_complete`,toolName:e.tool_name,toolInput:w(e.tool_input),toolOutput:w(e.tool_response),outcome:C(e.tool_response)}),i===`user`){let e=S(a);if(e.length>0){for(let t of e)o.push({...r,id:T(),event:`tool_complete`,toolName:t.name,toolOutput:t.output,outcome:t.isError?`failure`:`success`});return o}return o.push({...r,id:T(),event:`user_message`,messageText:b(a)}),o}if(i===`assistant`){let e=x(a);for(let t of e)o.push({...r,id:T(),event:`tool_start`,toolName:t.name,toolInput:t.input});let t=b(a);t.trim()&&o.push({...r,id:T(),event:`assistant_message`,messageText:t})}return o}function b(e){return typeof e==`string`?e:Array.isArray(e)?e.map(e=>{if(typeof e==`string`)return e;if(!e||typeof e!=`object`)return``;let t=e;return typeof t.text==`string`?t.text:``}).filter(Boolean).join(`
4
+ `):w(e)??``}function x(e){return Array.isArray(e)?e.flatMap(e=>{if(!e||typeof e!=`object`)return[];let t=e;return t.type===`tool_use`?[{name:String(t.name??`unknown_tool`),input:w(t.input)}]:[]}):[]}function S(e){return Array.isArray(e)?e.flatMap(e=>{if(!e||typeof e!=`object`)return[];let t=e;return t.type===`tool_result`?[{name:String(t.name??t.tool_name??`unknown_tool`),output:w(t.content),isError:t.is_error===!0}]:[]}):[]}function C(e){let t=w(e)?.toLowerCase()??``;return t.includes(`interrupted`)||t.includes(`aborted`)?`interrupted`:t.includes(`error`)||t.includes(`exception`)||t.includes(`failed`)?`failure`:`success`}function w(e){if(e!=null)return typeof e==`string`?e:JSON.stringify(e)}function T(){return typeof crypto<`u`&&`randomUUID`in crypto?crypto.randomUUID():i()}function E(e){return r(`sha256`).update(e).digest(`hex`)}var D,O,k,A,j,M,N=e((()=>{D=5e3,O=1e6,k=30,A=`[REDACTED]`,j=[/\b(?:sk|sk-ant|sk-proj|xox[baprs])-[A-Za-z0-9_-]{12,}\b/g,/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g,/\b(?:api[_-]?key|token|secret|password|authorization)\b\s*[:=]\s*["']?[^"',\s}]+/gi,/\bBearer\s+[A-Za-z0-9._~+/=-]{12,}\b/gi],M=64*1024}));export{_ as a,f as c,N as i,w as l,u as n,h as o,g as r,p as s,m as t};
@@ -0,0 +1 @@
1
+ import{Un as e,en as t}from"./state-4KQ3kaqz.js";import{_a as n,ya as r}from"./loadAgentsDir-nzr38hai.js";import{J as i,U as a}from"./debug-IKW-jE7K.js";import{Ft as o,Ht as s,Rt as c}from"./settings-5PQdphqC.js";import{b as l,c as u,g as d}from"./config-C7YHKCPV.js";import{o as f,s as p}from"./log-B3eB4EFv.js";import{Vt as m,_t as h,vt as g,yt as _}from"./model-DfFA3qMO.js";import{d as v,m as y,p as b}from"./rcDebugLog-BUuD-X1D.js";t(),m(),d(),a(),f(),r(),o(),v();function x(e){return t=>({...t,...typeof e.permission_mode==`string`?{toolPermissionContext:{...t.toolPermissionContext,mode:c(e.permission_mode)}}:{},...typeof e.is_ultraplan_mode==`boolean`?{isUltraplanMode:e.is_ultraplan_mode}:{}})}function S({newState:t,oldState:r}){let a=r.toolPermissionContext.mode,o=t.toolPermissionContext.mode;if(a!==o){let e=s(a),n=s(o);e!==n&&y({permission_mode:n,is_ultraplan_mode:n===`plan`&&t.isUltraplanMode&&!r.isUltraplanMode?!0:null}),b(o)}if(t.mainLoopModel!==r.mainLoopModel&&e(t.mainLoopModel),t.expandedView!==r.expandedView){let e=t.expandedView===`tasks`;u().showExpandedTodos!==e&&l(t=>({...t,showExpandedTodos:e}))}if(t.verbose!==r.verbose&&u().verbose!==t.verbose){let e=t.verbose;l(t=>({...t,verbose:e}))}if(process.env.USER_TYPE===`ant`&&t.tungstenPanelVisible!==r.tungstenPanelVisible&&t.tungstenPanelVisible!==void 0&&u().tungstenPanelVisible!==t.tungstenPanelVisible){let e=t.tungstenPanelVisible;l(t=>({...t,tungstenPanelVisible:e}))}if(t.settings!==r.settings)try{h(),g(),_(),t.settings.env!==r.settings.env&&n()}catch(e){p(i(e))}}export{S as n,x as t};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{promisify as t}from"node:util";import n from"node:process";import r from"node:path";import i,{execFile as a}from"node:child_process";import o from"node:fs";import s from"node:os";import c,{constants as l}from"node:fs/promises";import{fileURLToPath as u}from"node:url";import{Buffer as d}from"node:buffer";function ee(){try{return o.statSync(`/.dockerenv`),!0}catch{return!1}}function te(){try{return o.readFileSync(`/proc/self/cgroup`,`utf8`).includes(`docker`)}catch{return!1}}function f(){return p===void 0&&(p=ee()||te()),p}var p,ne=e((()=>{}));function m(){return h===void 0&&(h=g()||f()),h}var h,g,_=e((()=>{ne(),g=()=>{try{return o.statSync(`/run/.containerenv`),!0}catch{return!1}}})),v,y,b=e((()=>{_(),v=()=>{if(n.platform!==`linux`)return!1;if(s.release().toLowerCase().includes(`microsoft`))return!m();try{if(o.readFileSync(`/proc/version`,`utf8`).toLowerCase().includes(`microsoft`))return!m()}catch{}return o.existsSync(`/proc/sys/fs/binfmt_misc/WSLInterop`)||o.existsSync(`/run/WSL`)?!m():!1},y=n.env.__IS_WSL_TEST__?v:v()})),x,S,C,re=e((()=>{b(),x=(()=>{let e=`/mnt/`,t;return async function(){if(t)return t;let n=`/etc/wsl.conf`,r=!1;try{await c.access(n,l.F_OK),r=!0}catch{}if(!r)return e;let i=await c.readFile(n,{encoding:`utf8`}),a=/(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(i);return a?(t=a.groups.mountPoint.trim(),t=t.endsWith(`/`)?t:`${t}/`,t):e}})(),S=async()=>`${await x()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`,C=async()=>y?S():`${n.env.SYSTEMROOT||n.env.windir||String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`}));function w(e,t,n){let r=n=>Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0});return Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){let e=n();return r(e),e},set(e){r(e)}}),e}var T=e((()=>{}));async function E(){if(n.platform!==`darwin`)throw Error(`macOS only`);let{stdout:e}=await D(`defaults`,[`read`,`com.apple.LaunchServices/com.apple.launchservices.secure`,`LSHandlers`]),t=/LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(e)?.groups.id??`com.apple.Safari`;return t===`com.apple.safari`?`com.apple.Safari`:t}var D,O=e((()=>{D=t(a)}));async function k(e,{humanReadableOutput:t=!0,signal:r}={}){if(n.platform!==`darwin`)throw Error(`macOS only`);let i=t?[]:[`-ss`],a={};r&&(a.signal=r);let{stdout:o}=await A(`osascript`,[`-e`,e,i],a);return o.trim()}var A,j=e((()=>{A=t(a)}));async function M(e){return k(`tell application "Finder" to set app_path to application file id "${e}" as string\ntell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}var N=e((()=>{j()}));async function P(e=F){let{stdout:t}=await e(`reg`,[`QUERY`,` HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice`,`/v`,`ProgId`]),n=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(t);if(!n)throw new L(`Cannot find Windows browser in stdout: ${JSON.stringify(t)}`);let{id:r}=n.groups,i=r.lastIndexOf(`.`),a=r.lastIndexOf(`-`),o=i===-1?void 0:r.slice(0,i),s=a===-1?void 0:r.slice(0,a);return I[r]??I[o]??I[s]??{name:r,id:r}}var F,I,L,R=e((()=>{F=t(a),I={MSEdgeHTM:{name:`Edge`,id:`com.microsoft.edge`},MSEdgeBHTML:{name:`Edge Beta`,id:`com.microsoft.edge.beta`},MSEdgeDHTML:{name:`Edge Dev`,id:`com.microsoft.edge.dev`},AppXq0fevzme2pys62n3e0fbqa7peapykr8v:{name:`Edge`,id:`com.microsoft.edge.old`},ChromeHTML:{name:`Chrome`,id:`com.google.chrome`},ChromeBHTML:{name:`Chrome Beta`,id:`com.google.chrome.beta`},ChromeDHTML:{name:`Chrome Dev`,id:`com.google.chrome.dev`},ChromiumHTM:{name:`Chromium`,id:`org.chromium.Chromium`},BraveHTML:{name:`Brave`,id:`com.brave.Browser`},BraveBHTML:{name:`Brave Beta`,id:`com.brave.Browser.beta`},BraveDHTML:{name:`Brave Dev`,id:`com.brave.Browser.dev`},BraveSSHTM:{name:`Brave Nightly`,id:`com.brave.Browser.nightly`},FirefoxURL:{name:`Firefox`,id:`org.mozilla.firefox`},OperaStable:{name:`Opera`,id:`com.operasoftware.Opera`},VivaldiHTM:{name:`Vivaldi`,id:`com.vivaldi.Vivaldi`},"IE.HTTP":{name:`Internet Explorer`,id:`com.microsoft.ie`}},new Map(Object.entries(I)),L=class extends Error{}}));async function z(){if(n.platform===`darwin`){let e=await E();return{name:await M(e),id:e}}if(n.platform===`linux`){let{stdout:e}=await B(`xdg-mime`,[`query`,`default`,`x-scheme-handler/http`]),t=e.trim();return{name:V(t.replace(/.desktop$/,``).replace(`-`,` `)),id:t}}if(n.platform===`win32`)return P();throw Error(`Only macOS, Linux, and Windows are supported`)}var B,V,H=e((()=>{O(),N(),R(),B=t(a),V=e=>e.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,e=>e.toUpperCase())}));async function ie(){let e=await C(),t=String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`,n=d.from(t,`utf16le`).toString(`base64`),{stdout:r}=await G(e,[`-NoProfile`,`-NonInteractive`,`-ExecutionPolicy`,`Bypass`,`-EncodedCommand`,n],{encoding:`utf8`}),i=r.trim(),a={ChromeHTML:`com.google.chrome`,BraveHTML:`com.brave.Browser`,MSEdgeHTM:`com.microsoft.edge`,FirefoxURL:`org.mozilla.firefox`};return a[i]?{id:a[i]}:{}}function U(e){if(typeof e==`string`||Array.isArray(e))return e;let{[Y]:t}=e;if(!t)throw Error(`${Y} is not supported`);return t}function W({[J]:e},{wsl:t}){if(t&&y)return U(t);if(!e)throw Error(`${J} is not supported`);return U(e)}var G,K,q,J,Y,X,Z,Q,$;e((()=>{re(),T(),H(),_(),G=t(i.execFile),K=r.dirname(u(import.meta.url)),q=r.join(K,`xdg-open`),{platform:J,arch:Y}=n,X=async(e,t)=>{let n;for(let r of e)try{return await t(r)}catch(e){n=e}throw n},Z=async e=>{if(e={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...e},Array.isArray(e.app))return X(e.app,t=>Z({...e,app:t}));let{name:t,arguments:r=[]}=e.app??{};if(r=[...r],Array.isArray(t))return X(t,t=>Z({...e,app:{name:t,arguments:r}}));if(t===`browser`||t===`browserPrivate`){let n={"com.google.chrome":`chrome`,"google-chrome.desktop":`chrome`,"com.brave.Browser":`brave`,"org.mozilla.firefox":`firefox`,"firefox.desktop":`firefox`,"com.microsoft.msedge":`edge`,"com.microsoft.edge":`edge`,"com.microsoft.edgemac":`edge`,"microsoft-edge.desktop":`edge`},i={chrome:`--incognito`,brave:`--incognito`,firefox:`--private-window`,edge:`--inPrivate`},a=y?await ie():await z();if(a.id in n){let o=n[a.id];return t===`browserPrivate`&&r.push(i[o]),Z({...e,app:{name:$[o],arguments:r}})}throw Error(`${a.name} is not supported as a default browser`)}let a,o=[],s={};if(J===`darwin`)a=`open`,e.wait&&o.push(`--wait-apps`),e.background&&o.push(`--background`),e.newInstance&&o.push(`--new`),t&&o.push(`-a`,t);else if(J===`win32`||y&&!m()&&!t){a=await C(),o.push(`-NoProfile`,`-NonInteractive`,`-ExecutionPolicy`,`Bypass`,`-EncodedCommand`),y||(s.windowsVerbatimArguments=!0);let n=[`Start`];e.wait&&n.push(`-Wait`),t?(n.push(`"\`"${t}\`""`),e.target&&r.push(e.target)):e.target&&n.push(`"${e.target}"`),r.length>0&&(r=r.map(e=>`"\`"${e}\`""`),n.push(`-ArgumentList`,r.join(`,`))),e.target=d.from(n.join(` `),`utf16le`).toString(`base64`)}else{if(t)a=t;else{let e=!K||K===`/`,t=!1;try{await c.access(q,l.X_OK),t=!0}catch{}a=n.versions.electron??(J===`android`||e||!t)?`xdg-open`:q}r.length>0&&o.push(...r),e.wait||(s.stdio=`ignore`,s.detached=!0)}J===`darwin`&&r.length>0&&o.push(`--args`,...r),e.target&&o.push(e.target);let u=i.spawn(a,o,s);return e.wait?new Promise((t,n)=>{u.once(`error`,n),u.once(`close`,r=>{if(!e.allowNonzeroExitCode&&r>0){n(Error(`Exited with code ${r}`));return}t(u)})}):(u.unref(),u)},Q=(e,t)=>{if(typeof e!=`string`)throw TypeError("Expected a `target`");return Z({...t,target:e})},$={},w($,`chrome`,()=>W({darwin:`google chrome`,win32:`chrome`,linux:[`google-chrome`,`google-chrome-stable`,`chromium`]},{wsl:{ia32:`/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe`,x64:[`/mnt/c/Program Files/Google/Chrome/Application/chrome.exe`,`/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe`]}})),w($,`brave`,()=>W({darwin:`brave browser`,win32:`brave`,linux:[`brave-browser`,`brave`]},{wsl:{ia32:`/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe`,x64:[`/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe`,`/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe`]}})),w($,`firefox`,()=>W({darwin:`firefox`,win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:`firefox`},{wsl:`/mnt/c/Program Files/Mozilla Firefox/firefox.exe`})),w($,`edge`,()=>W({darwin:`microsoft edge`,win32:`msedge`,linux:[`microsoft-edge`,`microsoft-edge-dev`]},{wsl:`/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe`})),w($,`browser`,()=>`browser`),w($,`browserPrivate`,()=>`browserPrivate`)}))();export{Q as default};
@@ -0,0 +1,10 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{c as t,l as n,o as r}from"./envUtils-DSxRz_kt.js";import{Jo as i,Ko as a,Rh as o,So as s,Xc as c,Yc as l,Zc as u,at as d,ct as f,fo as p,np as ee,op as m,zh as h,zo as g}from"./loadAgentsDir-nzr38hai.js";import{l as _,p as v}from"./debug-IKW-jE7K.js";import{G as y,H as te,Wn as ne,qn as b}from"./model-DfFA3qMO.js";import{Cn as x,Sn as re,i as ie,r as S,t as C,wn as w}from"./prompt-Bef63FhB.js";import{B as T,F as E,L as D,P as O,R as k,ot as ae}from"./rcDebugLog-BUuD-X1D.js";import{n as oe,t as A}from"./openaiShared-G2-w4gJt.js";import{homedir as j}from"os";import{join as M}from"path";import{randomUUID as N}from"crypto";import{chmod as P,mkdir as se,readFile as ce,writeFile as le}from"fs/promises";function F(){return M(I(),q)}function I(){return(process.env.CLAUDE_CONFIG_DIR??M(j(),`.claude`)).normalize(`NFC`)}function L(){return M(process.env.CODEX_HOME??M(process.env.HOME??``,`.codex`),`auth.json`)}function R(e){return typeof e==`string`&&e.length>0?e:void 0}function z(e){try{let t=JSON.parse(e);return t&&typeof t==`object`?t:null}catch{return null}}function B(e){let[,t]=e.split(`.`);if(!t)return null;try{let e=t.replace(/-/g,`+`).replace(/_/g,`/`),n=e.padEnd(e.length+(4-e.length%4)%4,`=`);return z(Buffer.from(n,`base64`).toString(`utf8`))}catch{return null}}function V(e){let t=B(e),n=t?.[`https://api.openai.com/auth`];return n&&typeof n==`object`?n:t??{}}function H(e){let t=B(e)?.exp;return typeof t==`number`?t*1e3:null}function U(e){if(e.accountId)return e.accountId;for(let t of[e.idToken,e.accessToken]){if(!t)continue;let e=V(t),n=R(e.chatgpt_account_id)??R(e.chatgpt_account_user_id)??R(e.account_id);if(n)return n}}async function W(e){try{let t=await ce(e,`utf8`),n=JSON.parse(t),r=n.tokens,i=r?.id_token,a=r?.access_token,o=r?.refresh_token;return!i||!a||!o?null:{idToken:i,accessToken:a,refreshToken:o,accountId:U({idToken:i,accessToken:a,accountId:r.account_id}),lastRefresh:n.last_refresh}}catch{return null}}async function ue(e){let t=F();await se(I(),{recursive:!0});let n={auth_mode:`chatgpt`,tokens:{id_token:e.idToken,access_token:e.accessToken,refresh_token:e.refreshToken,account_id:U(e)},last_refresh:new Date().toISOString()};await le(t,`${JSON.stringify(n,null,2)}\n`,{mode:384}),await P(t,384).catch(()=>void 0)}async function de(e,t){let n=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:t});if(!n.ok){let e=await n.text().catch(()=>``);throw Error(`ChatGPT token request failed (${n.status})${e?`: ${e}`:``}`)}return await n.json()}async function fe(e){let t=new URLSearchParams({grant_type:`refresh_token`,refresh_token:e.refreshToken,client_id:K,scope:`openid profile email offline_access api.connectors.read api.connectors.invoke`}),n=await de(`${G}/oauth/token`,t);return{idToken:n.id_token,accessToken:n.access_token,refreshToken:n.refresh_token??e.refreshToken,accountId:U({idToken:n.id_token,accessToken:n.access_token,accountId:e.accountId})}}function pe(){return process.env.OPENAI_AUTH_MODE===`chatgpt`}async function me(){let e=await W(F());if(e||(e=await W(L()),e&&v(`[OpenAI] Using ChatGPT auth from Codex auth.json`)),!e)throw Error(`ChatGPT account is not logged in. Run /login and select ChatGPT account with subscription.`);let t=H(e.accessToken);return t!==null&&t<=Date.now()+J&&(e=await fe(e),await ue(e)),{accessToken:e.accessToken,accountId:e.accountId??U(e)}}var G,K,q,J,Y=e((()=>{_(),G=`https://auth.openai.com`,K=`app_EMoamEEZ73f0CkXaXp7hrann`,q=`openai-chatgpt-auth.json`,J=300*1e3}));function X(e){return typeof e==`string`?e:Array.isArray(e)?e.map(e=>{if(!e||typeof e!=`object`)return``;let t=e;return typeof t.text==`string`?t.text:``}).filter(Boolean).join(`
2
+ `):``}function he(e){if(typeof e==`string`)return e;if(!Array.isArray(e))return X(e);let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;if(e.type===`text`&&typeof e.text==`string`)t.push({type:`input_text`,text:e.text});else if(e.type===`image_url`){let n=e.image_url;typeof n?.url==`string`&&t.push({type:`input_image`,image_url:n.url})}}return t.length>0?t:X(e)}function ge(e){let t=[],n=[];for(let r of e){if(!r||typeof r!=`object`)continue;let e=r,i=e.role;if(i===`system`||i===`developer`){let t=X(e.content);t&&n.push(t);continue}if(i===`tool`){let n=e.tool_call_id;typeof n==`string`&&t.push({type:`function_call_output`,call_id:n,output:X(e.content)});continue}if(i===`assistant`){let n=X(e.content);n&&t.push({role:`assistant`,content:n});let r=e.tool_calls;if(Array.isArray(r))for(let e of r){if(!e||typeof e!=`object`)continue;let n=e,r=n.function,i=typeof n.id==`string`?n.id:void 0,a=typeof r?.name==`string`?r.name:void 0;!i||!a||t.push({type:`function_call`,call_id:i,name:a,arguments:typeof r?.arguments==`string`?r.arguments:`{}`})}continue}i===`user`&&t.push({role:`user`,content:he(e.content)})}return{input:t,instructions:n.length>0?n.join(`
3
+
4
+ `):void 0}}function _e(e){let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n.function,r=typeof e?.name==`string`?e.name:void 0;r&&t.push({type:`function`,name:r,description:typeof e?.description==`string`?e.description:``,parameters:e?.parameters&&typeof e.parameters==`object`?e.parameters:{type:`object`,properties:{}},strict:!1})}return t}function ve(e){if(e===`required`)return`required`;if(e===`auto`)return`auto`;if(!e||typeof e!=`object`)return e;let t=e,n=t.function;return t.type===`function`&&typeof n?.name==`string`?{type:`function`,name:n.name}:e}function ye(e){let{input:t,instructions:n}=ge(e.messages),r=_e(e.tools);return{model:e.model,stream:!0,store:!1,input:t,...n?{instructions:n}:{},...r.length>0?{tools:r}:{},...e.toolChoice?{tool_choice:ve(e.toolChoice)}:{},...e.reasoningEffort?{reasoning:{effort:e.reasoningEffort}}:{},parallel_tool_calls:!0}}async function*be(e){if(!e.body)throw Error(`ChatGPT response did not include a body`);let t=e.body.getReader(),n=new TextDecoder,r=``;for(;;){let{done:e,value:i}=await t.read();if(e)break;r+=n.decode(i,{stream:!0});let a=r.indexOf(`
5
+
6
+ `);for(;a>=0;){let e=r.slice(0,a);r=r.slice(a+2);let t=e.split(/\r?\n/).filter(e=>e.startsWith(`data:`)).map(e=>e.slice(5).trimStart()).join(`
7
+ `);if(t&&t!==`[DONE]`){let e=JSON.parse(t);e&&typeof e==`object`&&(yield e)}a=r.indexOf(`
8
+
9
+ `)}}}function xe(e){let t=e?.usage,n=t?.input_tokens_details;return{input_tokens:typeof t?.input_tokens==`number`?t.input_tokens:0,output_tokens:typeof t?.output_tokens==`number`?t.output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:typeof n?.cached_tokens==`number`?n.cached_tokens:0}}function Se(e){return e?.status===`incomplete`?`max_tokens`:`end_turn`}async function*Z(e,t){let n=`msg_${N().replace(/-/g,``).slice(0,24)}`,r=new Map,i=!1,a=-1,o=!1,s=!1,c=async function*(){i||(i=!0,yield{type:`message_start`,message:{id:n,type:`message`,role:`assistant`,content:[],model:t,stop_reason:null,stop_sequence:null,usage:{input_tokens:0,output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:0}}})};for await(let t of e){for await(let e of c())yield e;let e=t.type;if(e===`response.output_text.delta`){o||(s&&(yield{type:`content_block_stop`,index:a},s=!1),a++,o=!0,yield{type:`content_block_start`,index:a,content_block:{type:`text`,text:``}}),yield{type:`content_block_delta`,index:a,delta:{type:`text_delta`,text:String(t.delta??``)}};continue}if(e===`response.reasoning_text.delta`){s||(o&&(yield{type:`content_block_stop`,index:a},o=!1),a++,s=!0,yield{type:`content_block_start`,index:a,content_block:{type:`thinking`,thinking:``,signature:``}}),yield{type:`content_block_delta`,index:a,delta:{type:`thinking_delta`,thinking:String(t.delta??``)}};continue}if(e===`response.output_item.added`){let e=t.item,n=typeof t.output_index==`number`?t.output_index:-1;if(e?.type===`function_call`&&n>=0){o&&(yield{type:`content_block_stop`,index:a},o=!1),s&&(yield{type:`content_block_stop`,index:a},s=!1),a++;let t=String(e.call_id??e.id??`call_${n}`),i=String(e.name??``);r.set(n,{contentIndex:a,open:!0,name:i,id:t}),yield{type:`content_block_start`,index:a,content_block:{type:`tool_use`,id:t,name:i,input:{}}}}continue}if(e===`response.function_call_arguments.delta`){let e=typeof t.output_index==`number`?t.output_index:-1,n=r.get(e);n&&(yield{type:`content_block_delta`,index:n.contentIndex,delta:{type:`input_json_delta`,partial_json:String(t.delta??``)}});continue}if(e===`response.output_item.done`){let e=typeof t.output_index==`number`?t.output_index:-1,n=r.get(e);n?.open&&(yield{type:`content_block_stop`,index:n.contentIndex},n.open=!1);continue}if(e===`response.error`){let e=t.error;throw Error(String(e?.message??`ChatGPT Responses API error`))}if(e===`response.failed`){let e=t.response?.error;throw Error(String(e?.message??`ChatGPT Responses API failed`))}if(e===`response.completed`||e===`response.incomplete`){o&&(yield{type:`content_block_stop`,index:a},o=!1),s&&(yield{type:`content_block_stop`,index:a},s=!1);let e=t.response;yield{type:`message_delta`,delta:{stop_reason:Se(e),stop_sequence:null},usage:xe(e)},yield{type:`message_stop`}}}}async function Ce(e){let t=await me(),n=e.fetchOverride??globalThis.fetch,r={Authorization:`Bearer ${t.accessToken}`,"Content-Type":`application/json`,Accept:`text/event-stream`,"OpenAI-Beta":`responses=experimental`,Origin:`https://chatgpt.com`,Referer:`https://chatgpt.com/`,originator:`claude-code-best`};t.accountId&&(r[`ChatGPT-Account-Id`]=t.accountId);let i=await n(`https://chatgpt.com/backend-api/codex/responses`,{method:`POST`,headers:r,body:JSON.stringify(e.request),signal:e.signal});if(!i.ok){let e=await i.text().catch(()=>``);throw Error(`ChatGPT Responses API request failed (${i.status})${e?`: ${e.slice(0,500)}`:``}`)}return be(i)}var we=e((()=>{Y()}));function Te(e){if(t(process.env.OPENAI_ENABLE_THINKING))return!1;if(n(process.env.OPENAI_ENABLE_THINKING))return!0;let r=e.toLowerCase();return r.includes(`deepseek`)||r.includes(`mimo`)}function Ee(e,t){return t??(process.env.OPENAI_MAX_TOKENS&&parseInt(process.env.OPENAI_MAX_TOKENS,10)||void 0)??(process.env.CLAUDE_CODE_MAX_OUTPUT_TOKENS&&parseInt(process.env.CLAUDE_CODE_MAX_OUTPUT_TOKENS,10)||void 0)??e}function De(e){let{model:t,messages:n,tools:r,toolChoice:i,enableThinking:a,maxTokens:o,temperatureOverride:s}=e;return{model:t,messages:n,max_tokens:o,...r.length>0&&{tools:r,...i&&{tool_choice:i}},stream:!0,stream_options:{include_usage:!0},...a&&{thinking:{type:`enabled`},enable_thinking:!0,chat_template_kwargs:{thinking:!0,enable_thinking:!0}},...!a&&s!==void 0&&{temperature:s}}}var Oe=e((()=>{r()}));function Q(e){if(e===`low`)return`low`;if(e===`medium`)return`medium`;if(e===`high`)return`high`;if(e===`xhigh`||e===`max`)return`xhigh`;if(typeof e==`number`)return`high`}function ke(e){let t=process.env.CLAUDE_CODE_EFFORT_LEVEL?.toLowerCase();if(!(t===`auto`||t===`unset`))return Q(t)??Q(e)??`medium`}function Ae(e,t,n,r){if(!r||c())return e;let i=t.filter(e=>n.has(e.name)).map(C).sort().join(`
10
+ `);return i?[s({content:`<available-deferred-tools>\n${i}\n</available-deferred-tools>`,isMeta:!0}),...e]:e}function je(e){return e.type===`assistant`||e.type===`user`}function $(e){let{partialMessage:t,contentBlocks:n,tools:r,agentId:i,usage:o,stopReason:s,maxTokens:c}=e,l=[],u=Object.keys(n).sort((e,t)=>Number(e)-Number(t)).map(e=>n[Number(e)]).filter(Boolean);return u.length>0&&t&&l.push({message:{...t,content:a(u,r,i),usage:o,stop_reason:s,stop_sequence:null},requestId:void 0,type:`assistant`,uuid:N(),timestamp:new Date().toISOString()}),s===`max_tokens`&&l.push(p({content:`Output truncated: response exceeded the ${c} token limit. Set OPENAI_MAX_TOKENS or CLAUDE_CODE_MAX_OUTPUT_TOKENS to override.`,apiError:`max_output_tokens`,error:`max_output_tokens`})),l}async function*Me(e,t,n,r,a){try{let s=ae(a.model),c=i(e,n),l=await u(a.model,n,a.getToolPermissionContext||(async()=>re()),a.agents||[],a.querySource),d=new Set;if(l)for(let e of n)ie(e)&&d.add(e.name);let p=n;l&&d.size>0&&(p=n.filter(e=>!!(!d.has(e.name)||w(e,`SearchExtraTools`))));let m=(await Promise.all(p.map(e=>f(e,{getToolPermissionContext:a.getToolPermissionContext,tools:n,agents:a.agents,allowedAgentTypes:a.allowedAgentTypes,model:a.model,deferLoading:l&&d.has(e.name)})))).filter(e=>{let t=e;return t.type!==`advisor_20260301`&&t.type!==`computer_20250124`}),h=Te(s),g=T(Ae(c.filter(je),n,d,l),t,{enableThinking:h}),_=k(m),y=D(a.toolChoice),b=ke(a.effortValue);if(l){let e=p.filter(e=>d.has(e.name)).length;v(`[OpenAI] Tool search enabled: ${e}/${d.size} deferred tools included, total tools=${_.length}`)}else v(`[OpenAI] Tool search disabled, total tools=${_.length}`);let{upperLimit:x}=ne(s),S=Ee(x,a.maxOutputTokensOverride);v(`[OpenAI] Calling model=${s}, messages=${g.length}, tools=${_.length}, thinking=${h}`);let C=pe()?Z(await Ce({request:ye({model:s,messages:g,tools:_,toolChoice:y,reasoningEffort:b}),signal:r,fetchOverride:a.fetchOverride}),s):E(await o({maxRetries:0,fetchOverride:a.fetchOverride,source:a.querySource}).chat.completions.create(De({model:s,messages:g,tools:_,toolChoice:y,enableThinking:h,maxTokens:S,temperatureOverride:a.temperatureOverride}),{signal:r}),s),O={},A=null,j=null,M={input_tokens:0,output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:0},N=0,P=Date.now();for await(let e of C){switch(e.type){case`message_start`:A=e.message,N=Date.now()-P,e.message.usage&&(M={...M,...e.message.usage});break;case`content_block_start`:{let t=e.index,n=e.content_block;n.type===`tool_use`?O[t]={...n,input:``}:n.type===`text`?O[t]={...n,text:``}:n.type===`thinking`?O[t]={...n,thinking:``,signature:``}:O[t]={...n};break}case`content_block_delta`:{let t=e.index,n=e.delta,r=O[t];if(!r)break;n.type===`text_delta`?r.text=(r.text||``)+n.text:n.type===`input_json_delta`?r.input=(r.input||``)+n.partial_json:n.type===`thinking_delta`?r.thinking=(r.thinking||``)+n.thinking:n.type===`signature_delta`&&(r.signature=n.signature);break}case`content_block_stop`:break;case`message_delta`:{let t=e.usage;t&&(M=oe(M,t)),e.delta.stop_reason!=null&&(j=e.delta.stop_reason);break}case`message_stop`:if(A){for(let e of $({partialMessage:A,contentBlocks:O,tools:n,agentId:a.agentId,usage:M,stopReason:j,maxTokens:S}))yield e;A=null}M.input_tokens+M.output_tokens>0&&ee(te(s,M),M,a.model);break}yield{type:`stream_event`,event:e,...e.type===`message_start`?{ttftMs:N}:void 0}}if(A)for(let e of $({partialMessage:A,contentBlocks:O,tools:n,agentId:a.agentId,usage:M,stopReason:j,maxTokens:S}))yield e}catch(e){let t=e instanceof Error?e.message:String(e);v(`[OpenAI] Error: ${t}`,{level:`error`}),yield p({content:`API Error: ${t}`,apiError:`api_error`,error:e instanceof Error?e:Error(String(e))})}}e((()=>{h(),A(),O(),Y(),we(),g(),d(),x(),_(),m(),y(),Oe(),b(),l(),S()}))();export{Me as queryModelOpenAI};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";function t(e,t){return{input_tokens:t.input_tokens??e.input_tokens,output_tokens:t.output_tokens??e.output_tokens,cache_creation_input_tokens:t.cache_creation_input_tokens!==void 0&&t.cache_creation_input_tokens>0?t.cache_creation_input_tokens:e.cache_creation_input_tokens,cache_read_input_tokens:t.cache_read_input_tokens!==void 0&&t.cache_read_input_tokens>0?t.cache_read_input_tokens:e.cache_read_input_tokens}}var n=e((()=>{}));export{t as n,n as t};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";async function t(e){e(`/output-style has been deprecated. Use /config to change your output style, or set it in your settings file. Changes take effect on the next session.`,{display:`system`})}e((()=>{}))();export{t as call};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";import{n as t,t as n}from"./axios-DaWTGg7G.js";import{b as r,c as i,g as a}from"./config-C7YHKCPV.js";import{d as o,f as s,o as c,s as l}from"./log-B3eB4EFv.js";import{l as u,u as d}from"./oauth-BqJqV-2M.js";import{Mt as f,Vt as p}from"./model-DfFA3qMO.js";import{a as m,l as h,o as g}from"./api-TgV7fl9V.js";async function _(){try{let{accessToken:e,orgUUID:n}=await h(),r=`${u().BASE_API_URL}/api/oauth/organizations/${n}/overage_credit_grant`;return(await t.get(r,{headers:m(e)})).data}catch(e){return l(e),null}}function v(){let e=f()?.organizationUuid;if(!e)return null;let t=i().overageCreditGrantCache?.[e];return!t||Date.now()-t.timestamp>S?null:t.info}function y(){let e=f()?.organizationUuid;if(!e)return;let t=i().overageCreditGrantCache;!t||!(e in t)||r(t=>{let n={...t.overageCreditGrantCache};return delete n[e],{...t,overageCreditGrantCache:n}})}async function b(){if(s())return;let e=f()?.organizationUuid;if(!e)return;let t=await _();t&&r(n=>{let r=n.overageCreditGrantCache?.[e],i=r?.info,a=i&&i.available===t.available&&i.eligible===t.eligible&&i.granted===t.granted&&i.amount_minor_units===t.amount_minor_units&&i.currency===t.currency;if(a&&r&&Date.now()-r.timestamp<=S)return n;let o={info:a?i:t,timestamp:Date.now()};return{...n,overageCreditGrantCache:{...n.overageCreditGrantCache,[e]:o}}})}function x(e){if(e.amount_minor_units==null||!e.currency)return null;if(e.currency.toUpperCase()===`USD`){let t=e.amount_minor_units/100;return Number.isInteger(t)?`$${t}`:`$${t.toFixed(2)}`}return null}var S,C=e((()=>{n(),d(),p(),a(),c(),o(),g(),S=3600*1e3}));export{b as a,y as i,v as n,C as r,x as t};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./p-map-HKDr3iDo.js";t();export{e as default};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DaDcL9Zw.js";async function t(e,t,{concurrency:r=1/0,stopOnError:i=!0,signal:a}={}){return new Promise((o,s)=>{if(e[Symbol.iterator]===void 0&&e[Symbol.asyncIterator]===void 0)throw TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof e})`);if(typeof t!=`function`)throw TypeError(`Mapper function is required`);if(!(Number.isSafeInteger(r)&&r>=1||r===1/0))throw TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${r}\` (${typeof r})`);let c=[],l=[],u=new Map,d=!1,f=!1,p=!1,m=0,h=0,g=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),_=()=>{b(a.reason)},v=()=>{a?.removeEventListener(`abort`,_)},y=e=>{o(e),v()},b=e=>{d=!0,f=!0,s(e),v()};a&&(a.aborted&&b(a.reason),a.addEventListener(`abort`,_,{once:!0}));let x=async()=>{if(f)return;let e=await g.next(),r=h;if(h++,e.done){if(p=!0,m===0&&!f){if(!i&&l.length>0){b(AggregateError(l));return}if(f=!0,u.size===0){y(c);return}let e=[];for(let[t,r]of c.entries())u.get(t)!==n&&e.push(r);y(e)}return}m++,(async()=>{try{let i=await e.value;if(f)return;let a=await t(i,r);a===n&&u.set(r,a),c[r]=a,m--,await x()}catch(e){if(i)b(e);else{l.push(e),m--;try{await x()}catch(e){b(e)}}}})()};(async()=>{for(let e=0;e<r;e++){try{await x()}catch(e){b(e);break}if(p||d)break}})()})}var n,r=e((()=>{n=Symbol(`skip`)}));export{t as n,n as r,r as t};