claude-code-best 2.5.0 → 2.6.0

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 (614) hide show
  1. package/dist/chunks/AddWorkspaceDirectory-Cj5bvJgD.js +1 -0
  2. package/dist/chunks/App-2tgSv9lb.js +1 -0
  3. package/dist/chunks/ApproveApiKey-DWa-XTLb.js +1 -0
  4. package/dist/chunks/ApproveApiKey-SIUwkD8j.js +1 -0
  5. package/dist/chunks/AssistantSessionChooser-DF9eeJZS.js +1 -0
  6. package/dist/chunks/BackgroundTasksDialog-DXJdube9.js +2 -0
  7. package/dist/chunks/BypassPermissionsModeDialog-BOSW4Zdy.js +1 -0
  8. package/dist/chunks/ClaudeInChromeOnboarding-BW4XHmkw.js +1 -0
  9. package/dist/chunks/ClaudeMdExternalIncludesDialog-B8oAAHSI.js +1 -0
  10. package/dist/chunks/ClaudeMdExternalIncludesDialog-Bz0JyaOG.js +1 -0
  11. package/dist/chunks/ConsoleOAuthFlow-DYhmGSkx.js +1 -0
  12. package/dist/chunks/DesktopHandoff-CcsM_OAS.js +1 -0
  13. package/dist/chunks/DevChannelsDialog-DXRgY00D.js +1 -0
  14. package/dist/chunks/Dialog-DYFGqyDs.js +1 -0
  15. package/dist/chunks/DiffDialog-PvNZfZby.js +3 -0
  16. package/dist/chunks/Doctor--B1HUENo.js +1 -0
  17. package/dist/chunks/Doctor-CE_jL9jC.js +3 -0
  18. package/dist/chunks/ExitFlow-C4ybxKPn.js +2 -0
  19. package/dist/chunks/Feedback-B5rPGl_C.js +2 -0
  20. package/dist/chunks/Grove-C2YjB3zL.js +1 -0
  21. package/dist/chunks/Grove-CKVpREDU.js +11 -0
  22. package/dist/chunks/HybridTransport-Byjvz-DL.js +4 -0
  23. package/dist/chunks/ITermBackend-Co9XpeS4.js +1 -0
  24. package/dist/chunks/InProcessTransport-DB52dh4f.js +1 -0
  25. package/dist/chunks/InvalidConfigDialog-CNsqbNU3.js +1 -0
  26. package/dist/chunks/InvalidSettingsDialog-ClnZaN6b.js +1 -0
  27. package/dist/chunks/ListItem-OFARanN7.js +1 -0
  28. package/dist/chunks/MCPConnectionManager-CDsa79pu.js +1 -0
  29. package/dist/chunks/McpParsingWarnings-DZkzoeZf.js +1 -0
  30. package/dist/chunks/MessageSelector-CkeGQPNM.js +3 -0
  31. package/dist/chunks/Messages-PfbzLYOU.js +11 -0
  32. package/dist/chunks/Onboarding-BwoGQB4g.js +1 -0
  33. package/dist/chunks/OverageCreditUpsell-Q5g2YjQw.js +1 -0
  34. package/dist/chunks/PermissionDialog-5MlJf7ew.js +1 -0
  35. package/dist/chunks/PluginSettings-B2ASJ0Rx.js +17 -0
  36. package/dist/chunks/PressEnterToContinue-BdA9zDGs.js +1 -0
  37. package/dist/chunks/PromptInputFooterSuggestions-D4lMVCqj.js +1 -0
  38. package/dist/chunks/PromptInputHelpMenu-BvLtS6an.js +1 -0
  39. package/dist/chunks/QueryEngine-Av0G5fze.js +1 -0
  40. package/dist/chunks/REPL-DCwqua0C.js +1 -0
  41. package/dist/chunks/REPL-Dh8vzGmF.js +97 -0
  42. package/dist/chunks/RemoteCallout-BV_hoz98.js +1 -0
  43. package/dist/chunks/RemoteSessionManager-Cxoy1ud2.js +2 -0
  44. package/dist/chunks/ResumeConversation-B3WuB8rs.js +1 -0
  45. package/dist/chunks/SSETransport-pIm26VJq.js +4 -0
  46. package/dist/chunks/SearchBox-DfOmUoaI.js +1 -0
  47. package/dist/chunks/SearchExtraToolsTool-D70C-cmA.js +1 -0
  48. package/dist/chunks/SentryErrorBoundary-B6EWoJml.js +2 -0
  49. package/dist/chunks/SentryErrorBoundary-oJUBarGg.js +1 -0
  50. package/dist/chunks/Settings-CreAhCsb.js +2 -0
  51. package/dist/chunks/TeleportProgress-DPzGpyyM.js +1 -0
  52. package/dist/chunks/TeleportRepoMismatchDialog-DqWQX6j8.js +1 -0
  53. package/dist/chunks/TeleportResumeWrapper-DPSO0S49.js +1 -0
  54. package/dist/chunks/ThemePicker-DueihHcy.js +1 -0
  55. package/dist/chunks/TmuxBackend-BNaZNAeP.js +9 -0
  56. package/dist/chunks/TrustDialog-CIzAlGn9.js +1 -0
  57. package/dist/chunks/TungstenTool-C5IqKVr0.js +1 -0
  58. package/dist/chunks/TungstenTool-V-Bwqlx3.js +1 -0
  59. package/dist/chunks/ValidationErrorsList-1k1qbsRo.js +2 -0
  60. package/dist/chunks/WelcomeV2-CR6TtXXM.js +1 -0
  61. package/dist/chunks/WindowsTerminalBackend-C5SeTXqC.js +2 -0
  62. package/dist/chunks/add-dir-DAMizKzF.js +1 -0
  63. package/dist/chunks/agentDisplay-B9z7i8b_.js +1 -0
  64. package/dist/chunks/agents-D5u0p1UC.js +103 -0
  65. package/dist/chunks/agents-DCh_gEvJ.js +2 -0
  66. package/dist/chunks/ajv-B_OpU_Uh.js +8 -0
  67. package/dist/chunks/analytics-DqMQntaB.js +1 -0
  68. package/dist/chunks/ant-DRJq-cEg.js +1 -0
  69. package/dist/chunks/api-B6URs6nc.js +1 -0
  70. package/dist/chunks/api-Dz_3z1kl.js +1 -0
  71. package/dist/chunks/asciicast-aoKFhc7C.js +1 -0
  72. package/dist/chunks/asciicast-o5Zg4dJt.js +4 -0
  73. package/dist/chunks/assistant-BRGDWkKB.js +1 -0
  74. package/dist/chunks/assistant-tPxOUa-Z.js +1 -0
  75. package/dist/chunks/assistant-zVegFdAO.js +1 -0
  76. package/dist/chunks/attributionHooks-PygdohOh.js +1 -0
  77. package/dist/chunks/attributionTrailer-BpvhXgRP.js +1 -0
  78. package/dist/chunks/auth-CqURlg4d.js +1 -0
  79. package/dist/chunks/auth-D4isgfuK.js +1 -0
  80. package/dist/chunks/autoMode-DVt4K4I2.js +45 -0
  81. package/dist/chunks/autoModeDenials-Cp6VFdsm.js +1 -0
  82. package/dist/chunks/autonomy-BZzW8QJZ.js +1 -0
  83. package/dist/chunks/autonomy-Ffv0QIyl.js +19 -0
  84. package/dist/chunks/autonomyPanel-MwuzDvv_.js +1 -0
  85. package/dist/chunks/axios-DLnc2dVy.js +1 -0
  86. package/dist/chunks/axios-DhfaybwJ.js +12 -0
  87. package/dist/chunks/backgroundHousekeeping-CYnAG60-.js +17 -0
  88. package/dist/chunks/backgroundHousekeeping-DUmxC6h0.js +1 -0
  89. package/dist/chunks/banner-CVXH2xts.js +2 -0
  90. package/dist/chunks/base64-js-DIVSFswY.js +1 -0
  91. package/dist/chunks/bedrockClient-qi1-JCOK.js +15 -0
  92. package/dist/chunks/bg-DK0E4ZtW.js +9 -0
  93. package/dist/chunks/bg-Dbh5z3Y8.js +1 -0
  94. package/dist/chunks/branch-DXefFdDE.js +3 -0
  95. package/dist/chunks/break-cache-ByJ7U2Ts.js +8 -0
  96. package/dist/chunks/bridge-qr4GQW_c.js +2 -0
  97. package/dist/chunks/bridgeConfig-CJ-KznTS.js +1 -0
  98. package/dist/chunks/bridgeConfig-CNbOKpAg.js +1 -0
  99. package/dist/chunks/bridgeEnabled-5vsPrjuq.js +1 -0
  100. package/dist/chunks/bridgeEnabled-BUJTCUHY.js +1 -0
  101. package/dist/chunks/bridgeMain-BimZwc2P.js +68 -0
  102. package/dist/chunks/bridgeMain-DYL4fl6A.js +1 -0
  103. package/dist/chunks/bridgeMessaging-BiE0CTqq.js +1 -0
  104. package/dist/chunks/bridgePointer-FvAMj3re.js +1 -0
  105. package/dist/chunks/browser-fLRXxIsQ.js +1 -0
  106. package/dist/chunks/btw-FpimqEqk.js +1 -0
  107. package/dist/chunks/buddy-BA3Cr067.js +3 -0
  108. package/dist/chunks/bundledMode-kSQejuY4.js +1 -0
  109. package/dist/chunks/bypassPermissionsKillswitch-CSC9p8mO.js +1 -0
  110. package/dist/chunks/caches-BUBkfP2Q.js +3 -0
  111. package/dist/chunks/caches-CTfNpKhW.js +1 -0
  112. package/dist/chunks/capacityWake-BXlUpptF.js +1 -0
  113. package/dist/chunks/ccrClient-BOxUn9EJ.js +1 -0
  114. package/dist/chunks/ccshareResume-DWLjTF22.js +1 -0
  115. package/dist/chunks/changeDetector-Y9KV5LgG.js +1 -0
  116. package/dist/chunks/channelNotification-CC7Xb06W.js +1 -0
  117. package/dist/chunks/channelNotification-l3EXKDNB.js +1 -0
  118. package/dist/chunks/chokidar-BcI3rIKm.js +1 -0
  119. package/dist/chunks/chokidar-SzksMqYp.js +1 -0
  120. package/dist/chunks/chrome-BnKyWWQL.js +1 -0
  121. package/dist/chunks/chromeNativeHost-4U39yLtd.js +1 -0
  122. package/dist/chunks/chunk-DR8-3Aex.js +1 -0
  123. package/dist/chunks/classPrivateFieldSet2-EAQNhHs8.js +1 -0
  124. package/dist/chunks/claudeDesktop-D0S1eq1F.js +1 -0
  125. package/dist/chunks/cleanup-Bg_gFgcj.js +1 -0
  126. package/dist/chunks/clear-OUVFUt8Z.js +1 -0
  127. package/dist/chunks/cliLaunch-BQa48gsr.js +1 -0
  128. package/dist/chunks/client-B47ZvTMo.js +1 -0
  129. package/dist/chunks/client-CPn1wQyc.js +7 -0
  130. package/dist/chunks/client-_sjL0I7A.js +35 -0
  131. package/dist/chunks/color-D5MCzz9h.js +1 -0
  132. package/dist/chunks/color-convert-ULbeSgNC.js +1 -0
  133. package/dist/chunks/commands-FJGWgQsa.js +1 -0
  134. package/dist/chunks/commitAttribution-BFshsh2H.js +2 -0
  135. package/dist/chunks/commitAttribution-DSv9FggK.js +1 -0
  136. package/dist/chunks/common-B379wT22.js +1 -0
  137. package/dist/chunks/common-B_BC3eMY.js +1 -0
  138. package/dist/chunks/common-CMCv4N_v.js +1 -0
  139. package/dist/chunks/compact-DWNaf1wR.js +3 -0
  140. package/dist/chunks/companion-CyK_Dr1U.js +1 -0
  141. package/dist/chunks/completionCache-DHfUBBMH.js +1 -0
  142. package/dist/chunks/completionCache-DORrtxkS.js +4 -0
  143. package/dist/chunks/computerUseLock-BjoDJH2h.js +1 -0
  144. package/dist/chunks/config-BdCuh6eA.js +1 -0
  145. package/dist/chunks/config-DNz6Eitr.js +1 -0
  146. package/dist/chunks/connectHeadless-CwsFt-Mh.js +1 -0
  147. package/dist/chunks/constants-41VpZw2G.js +1 -0
  148. package/dist/chunks/context-BOjdTj0i.js +1 -0
  149. package/dist/chunks/context-noninteractive-Bd2HO-vU.js +1 -0
  150. package/dist/chunks/context-noninteractive-k2ibficU.js +54 -0
  151. package/dist/chunks/controlMessageCompat-BJhFiS7u.js +1 -0
  152. package/dist/chunks/conversation-BP0phkOY.js +1 -0
  153. package/dist/chunks/conversation-Ci8O_eZ-.js +1 -0
  154. package/dist/chunks/copy-B0VUJ2rH.js +7 -0
  155. package/dist/chunks/createSSHSession-DqmkCS_k.js +6 -0
  156. package/dist/chunks/createSession-B9MhWusY.js +1 -0
  157. package/dist/chunks/createSession-CJEsHz58.js +1 -0
  158. package/dist/chunks/cron-DiW7eIPP.js +1 -0
  159. package/dist/chunks/cronJitterConfig-BzPaa52I.js +6 -0
  160. package/dist/chunks/crossProjectResume-tWsqBUHc.js +40 -0
  161. package/dist/chunks/cwd--iizewsn.js +1 -0
  162. package/dist/chunks/cwd-BgpSJxd7.js +1 -0
  163. package/dist/chunks/daemon-VYRit6Aq.js +2 -0
  164. package/dist/chunks/dangerousBackend-BU_PHGR2.js +1 -0
  165. package/dist/chunks/datadog-Bd1s_VFj.js +1 -0
  166. package/dist/chunks/datadog-DJowkWhh.js +1 -0
  167. package/dist/chunks/debug-DM5ezCBS.js +1 -0
  168. package/dist/chunks/debug-UI3T040K.js +5 -0
  169. package/dist/chunks/debugUtils-BBMFODKH.js +1 -0
  170. package/dist/chunks/defineProperty-80gRi2ZW.js +1 -0
  171. package/dist/chunks/desktop-BDowrzvG.js +1 -0
  172. package/dist/chunks/detached-D300jlhj.js +5 -0
  173. package/dist/chunks/detect-libc-DNuQfUvI.js +1 -0
  174. package/dist/chunks/detectRepository-CBk3S2zv.js +1 -0
  175. package/dist/chunks/detectRepository-DCTvg4p0.js +1 -0
  176. package/dist/chunks/detection-CQsNad64.js +1 -0
  177. package/dist/chunks/detection-DJ-vTbBf.js +1 -0
  178. package/dist/chunks/diff-auU5sUOw.js +1 -0
  179. package/dist/chunks/directoryCompletion-DP_4B1GL.js +1 -0
  180. package/dist/chunks/dist-CanSxOZ1.js +5 -0
  181. package/dist/chunks/dist-Cg1a1Exw.js +29 -0
  182. package/dist/chunks/dist-Q7YNoZ0H.js +20 -0
  183. package/dist/chunks/dist-es-4z5T3Jzm.js +1 -0
  184. package/dist/chunks/dist-es-B2jg52tM2.js +1 -0
  185. package/dist/chunks/dist-es-B6OXHQ1S.js +1 -0
  186. package/dist/chunks/dist-es-B8NEy5hc.js +1 -0
  187. package/dist/chunks/dist-es-BVGppqE4.js +1 -0
  188. package/dist/chunks/dist-es-Bcw5GZko.js +1 -0
  189. package/dist/chunks/dist-es-BoIJpncb.js +9 -0
  190. package/dist/chunks/dist-es-Bu_Fshi1.js +1 -0
  191. package/dist/chunks/dist-es-C-1vn4OP2.js +1 -0
  192. package/dist/chunks/dist-es-C41b_0B5.js +1 -0
  193. package/dist/chunks/dist-es-CCZYybbG2.js +1 -0
  194. package/dist/chunks/dist-es-CLK1mey-.js +1 -0
  195. package/dist/chunks/dist-es-CQz2aNf72.js +1 -0
  196. package/dist/chunks/dist-es-CSfI8B8l.js +1 -0
  197. package/dist/chunks/dist-es-CUZBYppo.js +1 -0
  198. package/dist/chunks/dist-es-CZkzHpjF.js +1 -0
  199. package/dist/chunks/dist-es-Cbf0_D8d.js +5 -0
  200. package/dist/chunks/dist-es-ChHe-SVL.js +1 -0
  201. package/dist/chunks/dist-es-ClYOf0My.js +1 -0
  202. package/dist/chunks/dist-es-D-kJbj4A2.js +1 -0
  203. package/dist/chunks/dist-es-D1LN6CJd.js +1 -0
  204. package/dist/chunks/dist-es-DC1sC3ph.js +1 -0
  205. package/dist/chunks/dist-es-DGn8uOwQ2.js +1 -0
  206. package/dist/chunks/dist-es-DK5fTeKM2.js +1 -0
  207. package/dist/chunks/dist-es-DN7otr6F.js +1 -0
  208. package/dist/chunks/dist-es-DPM0mPK5.js +1 -0
  209. package/dist/chunks/dist-es-DqZAh3nG.js +1 -0
  210. package/dist/chunks/dist-es-DuAZyxJ02.js +5 -0
  211. package/dist/chunks/dist-es-HVQrM0oE.js +1 -0
  212. package/dist/chunks/dist-es-OVleIB54.js +1 -0
  213. package/dist/chunks/dist-es-UAs0rdXg.js +1 -0
  214. package/dist/chunks/dist-es-WvMMuHmx2.js +1 -0
  215. package/dist/chunks/dist-es-fjXft-jH.js +1 -0
  216. package/dist/chunks/dist-es-hdN_ShpZ.js +3 -0
  217. package/dist/chunks/dist-es-neiUvMJb.js +1 -0
  218. package/dist/chunks/dist-es-yMYpDtui2.js +1 -0
  219. package/dist/chunks/dist-es-zjcbuB72.js +1 -0
  220. package/dist/chunks/distRoot-CcxmnzqQ.js +1 -0
  221. package/dist/chunks/doctor-bKPp6AeL.js +1 -0
  222. package/dist/chunks/earlyInput-JGJo1zcC.js +1 -0
  223. package/dist/chunks/earlyInput-tRkbxFv2.js +2 -0
  224. package/dist/chunks/effort-BQj2QnnA.js +9 -0
  225. package/dist/chunks/entry-CUu6-QhT.js +14 -0
  226. package/dist/chunks/env-chR0gV31.js +1 -0
  227. package/dist/chunks/envLessBridgeConfig-CixkwbRF.js +1 -0
  228. package/dist/chunks/envLessBridgeConfig-Ju4W58xf.js +1 -0
  229. package/dist/chunks/envUtils-BWeoiL4Y.js +1 -0
  230. package/dist/chunks/escHotkey-Cyz0yyh1.js +259 -0
  231. package/dist/chunks/esm--xjzB1hI.js +1 -0
  232. package/dist/chunks/esm-B2HIF0XY.js +1 -0
  233. package/dist/chunks/esm-BGQPWnJy.js +1 -0
  234. package/dist/chunks/esm-C-1qL9Mn.js +1 -0
  235. package/dist/chunks/esm-C3jcs1DH.js +1 -0
  236. package/dist/chunks/esm-C97WL9nC.js +1 -0
  237. package/dist/chunks/esm-CIL-SKM8.js +1 -0
  238. package/dist/chunks/esm-CJlBxjtx.js +1 -0
  239. package/dist/chunks/esm-CsGLyWmS.js +56 -0
  240. package/dist/chunks/esm-DQHmDm-H.js +1 -0
  241. package/dist/chunks/esm-DcdOXSzi.js +1 -0
  242. package/dist/chunks/esm-DhNYgGTV.js +1 -0
  243. package/dist/chunks/esm-DxPW7qPs.js +1 -0
  244. package/dist/chunks/esm-FBUWr3vI.js +1 -0
  245. package/dist/chunks/esm-QgL6y---.js +10 -0
  246. package/dist/chunks/esm-v0kPjgVS.js +1 -0
  247. package/dist/chunks/esm-vIn-YV_h.js +1 -0
  248. package/dist/chunks/event-streams-BV7ngMXu.js +1 -0
  249. package/dist/chunks/eventLoopStallDetector-Dnh1fc31.js +1 -0
  250. package/dist/chunks/execAsync-BkA6ogic.js +1 -0
  251. package/dist/chunks/execFileNoThrow-CuQN1sz8.js +1 -0
  252. package/dist/chunks/execSyncWrapper-C2XQnFVo.js +1 -0
  253. package/dist/chunks/execa-CGue6Z3n.js +34 -0
  254. package/dist/chunks/executor-4EeD8GNm.js +1561 -0
  255. package/dist/chunks/executor-BHEuNh5F.js +1 -0
  256. package/dist/chunks/exit-DijkO8eo.js +1 -0
  257. package/dist/chunks/exit-_obETqBv.js +2 -0
  258. package/dist/chunks/export-DA-bBZkX.js +2 -0
  259. package/dist/chunks/exportRenderer-3y4tGdSB.js +1 -0
  260. package/dist/chunks/extra-usage-CS6VwKJt.js +1 -0
  261. package/dist/chunks/extra-usage-DGHEQOrY.js +1 -0
  262. package/dist/chunks/extra-usage-core-DOgT4u4i.js +1 -0
  263. package/dist/chunks/extra-usage-noninteractive-DYnfiRlV.js +1 -0
  264. package/dist/chunks/extraUsage-CfxgfpX_.js +1 -0
  265. package/dist/chunks/extractMemories-jvjCvtpC.js +1 -0
  266. package/dist/chunks/fast-Bbtx_Bs1.js +1 -0
  267. package/dist/chunks/fast-CzRUJBTK.js +1 -0
  268. package/dist/chunks/featureCheck-Cm0YNDXO.js +1 -0
  269. package/dist/chunks/featureCheck-p7OeCYzj.js +1 -0
  270. package/dist/chunks/feedback-FoXtdHAV.js +1 -0
  271. package/dist/chunks/figures-gfT9mM8P.js +1 -0
  272. package/dist/chunks/fileStateCache-C7-TxF8G.js +1 -0
  273. package/dist/chunks/files-DYvAZGxp.js +2 -0
  274. package/dist/chunks/firstPartyEventLogger-KIwaBY-E.js +1 -0
  275. package/dist/chunks/flushGate-C2Icy43G.js +1 -0
  276. package/dist/chunks/foundry-sdk-BFN5VDFQ.js +1 -0
  277. package/dist/chunks/fpsMetrics-DeezdcwV.js +1 -0
  278. package/dist/chunks/fuse-Ch_OAlm3.js +1 -0
  279. package/dist/chunks/gates-CbQLZHtm.js +1 -0
  280. package/dist/chunks/gates-DSI3vpwO.js +1 -0
  281. package/dist/chunks/gemini-BrNJGX4k.js +1 -0
  282. package/dist/chunks/generateRecap-B0fvSCjo.js +1 -0
  283. package/dist/chunks/generateSessionName-DvRYa39O.js +1 -0
  284. package/dist/chunks/genericProcessUtils-BGvcwuPt.js +23 -0
  285. package/dist/chunks/getMachineId-bsd-BMtYGBUL.js +1 -0
  286. package/dist/chunks/getMachineId-darwin-CiLdFH7z.js +2 -0
  287. package/dist/chunks/getMachineId-linux-Cr27rIeY.js +1 -0
  288. package/dist/chunks/getMachineId-unsupported-ceiBLwAN.js +1 -0
  289. package/dist/chunks/getMachineId-win-DFTmsQHq.js +1 -0
  290. package/dist/chunks/git-CN3qtTb_.js +6 -0
  291. package/dist/chunks/git-D23Mzu_K.js +1 -0
  292. package/dist/chunks/githubRepoPathMapping-Dut3d6nn.js +1 -0
  293. package/dist/chunks/graceful-fs-Cgc0rjGF.js +2 -0
  294. package/dist/chunks/grok-Ftoheab3.js +1 -0
  295. package/dist/chunks/growthbook-BynnuVTn.js +1 -0
  296. package/dist/chunks/hash-BRmOQc3c.js +1 -0
  297. package/dist/chunks/heapdump-hQ_w0LPC.js +5 -0
  298. package/dist/chunks/help-DQsHHv6r.js +1 -0
  299. package/dist/chunks/hooks-BLLL4iPv.js +1 -0
  300. package/dist/chunks/hooks-BhVDc8yb.js +79 -0
  301. package/dist/chunks/hostAdapter-D1eWmmhu.js +1 -0
  302. package/dist/chunks/hostGuard-zim_4F9V.js +1 -0
  303. package/dist/chunks/httpAuthSchemes-Wq4XWeLL.js +13 -0
  304. package/dist/chunks/ide-CPmMXLL-.js +2 -0
  305. package/dist/chunks/inboundAttachments-Bmf6vYsE.js +1 -0
  306. package/dist/chunks/inboundAttachments-D-p91z3w.js +1 -0
  307. package/dist/chunks/index.min-BJnb9GQI.js +1 -0
  308. package/dist/chunks/initReplBridge-BiHXpDEY.js +1 -0
  309. package/dist/chunks/insights-CTlTyvjj.js +822 -0
  310. package/dist/chunks/install-IPuD3Lq8.js +1 -0
  311. package/dist/chunks/install-github-app-Bmu_sA9e.js +147 -0
  312. package/dist/chunks/install-slack-app-Rfl81Jqo.js +1 -0
  313. package/dist/chunks/instinctParser-DHMa8xa0.js +1 -0
  314. package/dist/chunks/instrumentation-DWwmOmr0.js +12 -0
  315. package/dist/chunks/intl-Pse97ORk.js +1 -0
  316. package/dist/chunks/isObject-DaxDnPKm.js +1 -0
  317. package/dist/chunks/isSymbol-Dp3irZaY.js +1 -0
  318. package/dist/chunks/job-BXEt0izn.js +2 -0
  319. package/dist/chunks/json-bigint-OxRwRvup.js +8 -0
  320. package/dist/chunks/jsx-runtime-D-D469L8.js +1 -0
  321. package/dist/chunks/jws-2vqRyZtR.js +3 -0
  322. package/dist/chunks/jwtUtils-CpXwh_du.js +1 -0
  323. package/dist/chunks/keybindings-DRDgVvqz.js +2 -0
  324. package/dist/chunks/lang-D3ZHlfT6.js +1 -0
  325. package/dist/chunks/language-B_-BfBT4.js +1 -0
  326. package/dist/chunks/language-DcSjogBx.js +1 -0
  327. package/dist/chunks/launchAgentsPlatform-BPm_VMln.js +1 -0
  328. package/dist/chunks/launchAutofixPr-D2qac07g.js +2 -0
  329. package/dist/chunks/launchCommand-Du91jxMC.js +1 -0
  330. package/dist/chunks/launchLocalMemory-D_hBbXKE.js +3 -0
  331. package/dist/chunks/launchLocalVault-CPzNWvQ9.js +3 -0
  332. package/dist/chunks/launchMemoryStores-Djq2KhKb.js +1 -0
  333. package/dist/chunks/launchOnboarding-Bh6E7vdc.js +8 -0
  334. package/dist/chunks/launchSchedule-C988bQ-5.js +1 -0
  335. package/dist/chunks/launchSkillStore-DqrP6Gme.js +1 -0
  336. package/dist/chunks/launchTeleport-DFhybaq_.js +3 -0
  337. package/dist/chunks/launchVault-p_CSK4ZQ.js +1 -0
  338. package/dist/chunks/lazySchema-2sOku3cX.js +1 -0
  339. package/dist/chunks/lib-B4Q0Nrpb.js +14 -0
  340. package/dist/chunks/lib-Ca3QWJjN.js +2 -0
  341. package/dist/chunks/lib-inCisXen.js +8 -0
  342. package/dist/chunks/loadAgentsDir-Ci5mr0vm.js +4601 -0
  343. package/dist/chunks/loadAgentsDir-vB1QEZ7H.js +1 -0
  344. package/dist/chunks/loadPluginHooks-xYCEZ6t5.js +1 -0
  345. package/dist/chunks/loadSso-sDs471GC.js +1 -0
  346. package/dist/chunks/localSearch-DtVqtfvk.js +1 -0
  347. package/dist/chunks/localSearch-Vpn6W5aY.js +1 -0
  348. package/dist/chunks/lockfile-DBwdlC3K.js +1 -0
  349. package/dist/chunks/log-CzsijfHZ.js +1 -0
  350. package/dist/chunks/login-D-N78G6r.js +1 -0
  351. package/dist/chunks/login-D9IWjvza.js +1 -0
  352. package/dist/chunks/logoV2Utils-SAulcC5x.js +1 -0
  353. package/dist/chunks/logout-CFggVS-9.js +1 -0
  354. package/dist/chunks/magicDocs-BfoeYhin.js +57 -0
  355. package/dist/chunks/main-C6be1KFk.js +31 -0
  356. package/dist/chunks/main-DhMlhVj3.js +1108 -0
  357. package/dist/chunks/mappers-uIrAj-Wd.js +1 -0
  358. package/dist/chunks/mcp-CAYGNxCb.js +1 -0
  359. package/dist/chunks/mcp-COQap0SM.js +6 -0
  360. package/dist/chunks/mcp-DlM0OC6R.js +2 -0
  361. package/dist/chunks/mcpServer-1SnOWb8_.js +1 -0
  362. package/dist/chunks/mcpServer-DXvS3v4x.js +1 -0
  363. package/dist/chunks/memoize-DNnuA2aU.js +1 -0
  364. package/dist/chunks/memoize-DxwLawI2.js +1 -0
  365. package/dist/chunks/memory-XccPLQLt.js +1 -0
  366. package/dist/chunks/mobile-umu5P0cM.js +2 -0
  367. package/dist/chunks/modalContext-CmSKRyea.js +1 -0
  368. package/dist/chunks/model-CbiDGGJU.js +1 -0
  369. package/dist/chunks/model-DdbcxKub.js +1 -0
  370. package/dist/chunks/normalization-Cox8C0dP.js +1 -0
  371. package/dist/chunks/oauth-CdZEzMww.js +1 -0
  372. package/dist/chunks/oauth-CmensepG.js +1 -0
  373. package/dist/chunks/observationStore-tvkldXUo.js +4 -0
  374. package/dist/chunks/onChangeAppState-Dp0JIXd8.js +1 -0
  375. package/dist/chunks/open-CDditBQ-.js +1 -0
  376. package/dist/chunks/openai-6KcHd4Hw.js +10 -0
  377. package/dist/chunks/openaiShared-D5lOejS1.js +16 -0
  378. package/dist/chunks/output-style-XDb9-2Kk.js +1 -0
  379. package/dist/chunks/overageCreditGrant-DYiB4sr-.js +1 -0
  380. package/dist/chunks/p-map-9Ud1LOrJ.js +1 -0
  381. package/dist/chunks/p-map-D7WEmnBE.js +1 -0
  382. package/dist/chunks/package-BhL7chzt.js +1 -0
  383. package/dist/chunks/panel-ByW1omJn.js +1 -0
  384. package/dist/chunks/panel-Bz_8td5D.js +1 -0
  385. package/dist/chunks/parseConnectUrl-BS6i9JPo.js +1 -0
  386. package/dist/chunks/parser-CmngCwjB.js +1 -0
  387. package/dist/chunks/parser-SWIZo39J.js +1 -0
  388. package/dist/chunks/passes-Cbc6T_Tj.js +1 -0
  389. package/dist/chunks/path-C4kbwvSH.js +1 -0
  390. package/dist/chunks/paths-Q2255dD7.js +39 -0
  391. package/dist/chunks/permissions-BLzPHh_3.js +3 -0
  392. package/dist/chunks/permissions-DXLfdE7b.js +1 -0
  393. package/dist/chunks/permissions-Ps_D01ZB.js +1 -0
  394. package/dist/chunks/pipeTransport-D7NIp3aA.js +1 -0
  395. package/dist/chunks/plan-DloFVJK7.js +1 -0
  396. package/dist/chunks/platform-CuyedWpe.js +2 -0
  397. package/dist/chunks/plist-BO4ZqMZc.js +6 -0
  398. package/dist/chunks/plugin-XR9IBPMM.js +1 -0
  399. package/dist/chunks/pluginAutoupdate-Cr9hP0zG.js +1 -0
  400. package/dist/chunks/pluginBlocklist-CM9uP8CY.js +1 -0
  401. package/dist/chunks/pluginCliCommands-BQkrvES5.js +1 -0
  402. package/dist/chunks/pluginFlagging-CJ1--2Kw.js +1 -0
  403. package/dist/chunks/pluginOperations-B0rLuSvo.js +2 -0
  404. package/dist/chunks/pluginStartupCheck-Bjdc8zhz.js +1 -0
  405. package/dist/chunks/pluginStartupCheck-Cu2ezD51.js +1 -0
  406. package/dist/chunks/plugins-BgOP_8TX.js +4 -0
  407. package/dist/chunks/policyLimits-CKy_gTEt.js +1 -0
  408. package/dist/chunks/pollConfig-DhptuhFw.js +1 -0
  409. package/dist/chunks/poller-Ds0Y6Cir.js +1 -0
  410. package/dist/chunks/poor-DF0aqXDx.js +1 -0
  411. package/dist/chunks/poorMode-C5Frra4j.js +1 -0
  412. package/dist/chunks/poorMode-DJvjO2nW.js +1 -0
  413. package/dist/chunks/postCommitAttribution-Ehmwzzuq.js +1 -0
  414. package/dist/chunks/print-CPtR0KTa.js +39 -0
  415. package/dist/chunks/privacy-settings-e-7lc7Un.js +1 -0
  416. package/dist/chunks/process-CWupreF6.js +1 -0
  417. package/dist/chunks/process-DMKLUQIO.js +1 -0
  418. package/dist/chunks/processBashCommand-D5dC6Mya.js +1 -0
  419. package/dist/chunks/processSlashCommand-DHRUtZ-C.js +6 -0
  420. package/dist/chunks/projectContext-0fpRKUeH.js +1 -0
  421. package/dist/chunks/projectContext-eXMSfgdZ.js +1 -0
  422. package/dist/chunks/prompt-4tea6NJQ.js +54 -0
  423. package/dist/chunks/prompt-CQC-mh6u.js +1 -0
  424. package/dist/chunks/prompt-DEPUnJdB.js +222 -0
  425. package/dist/chunks/prompt-DawxLANl.js +1 -0
  426. package/dist/chunks/promptEditor-Ci-h04-5.js +4 -0
  427. package/dist/chunks/protocolHandler-DhqM32qE.js +13 -0
  428. package/dist/chunks/protocols-CAyQOlkr.js +7 -0
  429. package/dist/chunks/proxy-CfZp-wce.js +99 -0
  430. package/dist/chunks/rate-limit-options-B0l29Zx8.js +1 -0
  431. package/dist/chunks/rcDebugLog-BbPkkigY.js +11 -0
  432. package/dist/chunks/referral-ByevBJrE.js +1 -0
  433. package/dist/chunks/refresh-B_CwwIRX.js +1 -0
  434. package/dist/chunks/registerProtocol-DzhaQH02.js +36 -0
  435. package/dist/chunks/registry-DkHA4cRu.js +1 -0
  436. package/dist/chunks/release-notes-CZthYkei.js +4 -0
  437. package/dist/chunks/releaseNotes-CwKpIsyd.js +2 -0
  438. package/dist/chunks/reload-plugins-DxWfXvrN.js +1 -0
  439. package/dist/chunks/remote-env-BiRLWIrh.js +1 -0
  440. package/dist/chunks/remoteBridgeCore-nz1fPY1U.js +1 -0
  441. package/dist/chunks/remoteControlServer-FzLUxh2B.js +3 -0
  442. package/dist/chunks/rename-DmGuyncE.js +1 -0
  443. package/dist/chunks/renderOptions-BiyC2rj1.js +1 -0
  444. package/dist/chunks/resume-7GeU7RMS.js +2 -0
  445. package/dist/chunks/rewind-CXplHgh_.js +1 -0
  446. package/dist/chunks/rollback-DbSpxmJE.js +11 -0
  447. package/dist/chunks/runtimeObserver-Duod-ign.js +10 -0
  448. package/dist/chunks/runtimeObserver-OgM9ZYxZ.js +1 -0
  449. package/dist/chunks/sandbox-adapter-CxkhKgaa.js +1 -0
  450. package/dist/chunks/sandbox-toggle-Cc96R6Ox.js +1 -0
  451. package/dist/chunks/sanitization-CYp-9DbE.js +1 -0
  452. package/dist/chunks/satisfies-BaHgd_ie.js +1 -0
  453. package/dist/chunks/schemas-BGAvj1T4.js +40 -0
  454. package/dist/chunks/sdk-DEtgRZvI.js +1 -0
  455. package/dist/chunks/sdkHeapDumpMonitor--fevrC5z.js +1 -0
  456. package/dist/chunks/searchExtraTools-DQ6e601b.js +1 -0
  457. package/dist/chunks/semver-Cq33BYay.js +1 -0
  458. package/dist/chunks/semver-Tw0AFar5.js +1 -0
  459. package/dist/chunks/sentry-BUHYuYGj.js +13 -0
  460. package/dist/chunks/server-C5XZSlto.js +1 -0
  461. package/dist/chunks/server-DzOdtq8A.js +1 -0
  462. package/dist/chunks/serverBanner-WlSYP-f8.js +1 -0
  463. package/dist/chunks/serverLog-DtsUvDiY.js +1 -0
  464. package/dist/chunks/session-DgLqm7ZI.js +2 -0
  465. package/dist/chunks/sessionDataUploader-Ctjo1bgR.js +1 -0
  466. package/dist/chunks/sessionDiscovery-DgNea6qa.js +1 -0
  467. package/dist/chunks/sessionFileAccessHooks-7Svz-7S-.js +1 -0
  468. package/dist/chunks/sessionManager-Dw72ZUTg.js +1 -0
  469. package/dist/chunks/sessionMemory-DIrR3zvb.js +1 -0
  470. package/dist/chunks/sessionMemory-_dmj8lcH.js +1 -0
  471. package/dist/chunks/sessionMemoryUtils-BdQtSkRx.js +1 -0
  472. package/dist/chunks/sessionObserver-CuWMVPlT.js +20 -0
  473. package/dist/chunks/sessionObserver-_adufOGQ.js +1 -0
  474. package/dist/chunks/sessionStorage-W7okgAlQ.js +1 -0
  475. package/dist/chunks/sessionStoragePortable-BI9q2WcJ.js +3 -0
  476. package/dist/chunks/sessionTitle-DzkMzHer.js +14 -0
  477. package/dist/chunks/sessionTracing-DTjmc0EF.js +11 -0
  478. package/dist/chunks/settingsSync-CfYDkakY.js +1 -0
  479. package/dist/chunks/setup-BKUG46jQ.js +9 -0
  480. package/dist/chunks/setup-CmLngvpJ.js +1 -0
  481. package/dist/chunks/setup-TqJ7-Nxh.js +2 -0
  482. package/dist/chunks/shadowedRuleDetection-DesT0yKM.js +1 -0
  483. package/dist/chunks/shellQuote-DgjT8KBA.js +1 -0
  484. package/dist/chunks/sideQuestion-BAq0YyKY.js +20 -0
  485. package/dist/chunks/signin-QEeYpJZw.js +1 -0
  486. package/dist/chunks/sink-B3uP8Cf8.js +1 -0
  487. package/dist/chunks/sink-CaWMZBw_.js +1 -0
  488. package/dist/chunks/sinks-COcy5GnB.js +2 -0
  489. package/dist/chunks/sinks-oFfsKySL.js +1 -0
  490. package/dist/chunks/skill-learning-DOIMPtWE.js +5 -0
  491. package/dist/chunks/skillChangeDetector-CA_Tdx8N.js +1 -0
  492. package/dist/chunks/skillGapStore-CWuw1dYh.js +1 -0
  493. package/dist/chunks/skillGapStore-DpEoKhn-.js +5 -0
  494. package/dist/chunks/skillGenerator-9y3Q4YoO.js +8 -0
  495. package/dist/chunks/skillLearning-BhM09bQD.js +1 -0
  496. package/dist/chunks/skillLearning-_o2D06yM.js +1 -0
  497. package/dist/chunks/skillPanel-Dt24mZTZ.js +28 -0
  498. package/dist/chunks/skillSearchPanel-gaXN64Fu.js +21 -0
  499. package/dist/chunks/skills-Dx3dMHYk.js +1 -0
  500. package/dist/chunks/slashCommandParsing-Cari0pNg.js +1 -0
  501. package/dist/chunks/sleep-8Eb9j_Ly.js +1 -0
  502. package/dist/chunks/sprites-5OAB-Ui2.js +1 -0
  503. package/dist/chunks/src-BIPP3_mo.js +26 -0
  504. package/dist/chunks/src-BJz1KAd_.js +6 -0
  505. package/dist/chunks/src-BRAdBA8A.js +1 -0
  506. package/dist/chunks/src-BRC_BuUP.js +1 -0
  507. package/dist/chunks/src-BaB-bpCj.js +5 -0
  508. package/dist/chunks/src-BlLavFUS.js +7 -0
  509. package/dist/chunks/src-C5yhFG0C.js +19 -0
  510. package/dist/chunks/src-CI_jaaBj.js +2 -0
  511. package/dist/chunks/src-CRsA-Z4y.js +1 -0
  512. package/dist/chunks/src-CYLfL70h.js +1 -0
  513. package/dist/chunks/src-DJXCzwyJ.js +1 -0
  514. package/dist/chunks/src-DJXKJavk.js +1 -0
  515. package/dist/chunks/src-Di342QoJ.js +53 -0
  516. package/dist/chunks/src-DsMd9Q9e.js +2 -0
  517. package/dist/chunks/src-DzH9IdOo.js +1 -0
  518. package/dist/chunks/src-hdbPEvzO.js +9 -0
  519. package/dist/chunks/src-poaoYkuc.js +1 -0
  520. package/dist/chunks/src-x7u_sB6m.js +1 -0
  521. package/dist/chunks/sso-oidc-BX1MlBX0.js +1 -0
  522. package/dist/chunks/startupProfiler-DnXZaX4A.js +3 -0
  523. package/dist/chunks/startupProfiler-SOE--nM9.js +1 -0
  524. package/dist/chunks/state-B2GIOsTB.js +1 -0
  525. package/dist/chunks/state-Ce1HlR-H.js +1 -0
  526. package/dist/chunks/state-sIHsFpDu.js +1 -0
  527. package/dist/chunks/staticRender-Br64h1E1.js +1 -0
  528. package/dist/chunks/stats-TUExo9iU.js +1 -0
  529. package/dist/chunks/status-Dghaz1my.js +1 -0
  530. package/dist/chunks/statusNoticeHelpers-DVZSSXeK.js +1 -0
  531. package/dist/chunks/stdio-BEEzuxaZ.js +1 -0
  532. package/dist/chunks/stdio-D4cT86R0.js +3 -0
  533. package/dist/chunks/stickers-2K05wjSp.js +1 -0
  534. package/dist/chunks/store-DhI7Lcan.js +1 -0
  535. package/dist/chunks/sts-BDFJ-6QE.js +1 -0
  536. package/dist/chunks/subprocessEnv-CggQWZCx.js +1 -0
  537. package/dist/chunks/subprocessEnv-DV6q6o6w.js +1 -0
  538. package/dist/chunks/supports-color-lkzOMQ6u.js +1 -0
  539. package/dist/chunks/systemPromptSections-BcN_XBTx.js +1 -0
  540. package/dist/chunks/systemPromptSections-DB93ZNWP.js +1 -0
  541. package/dist/chunks/systemTheme-dDbitcxB.js +1 -0
  542. package/dist/chunks/tag-ZcVkzFjz.js +11 -0
  543. package/dist/chunks/tasks-DbB33ekt.js +1 -0
  544. package/dist/chunks/teamHelpers-BmN9nKz-.js +1 -0
  545. package/dist/chunks/teamHelpers-yeTNtZbb.js +1 -0
  546. package/dist/chunks/teammate-DMYOtLTK.js +1 -0
  547. package/dist/chunks/teammateModeSnapshot-CPjJJDL1.js +1 -0
  548. package/dist/chunks/teammateModeSnapshot-CsNIJTKi.js +1 -0
  549. package/dist/chunks/teleport-JHgpwZIh.js +1 -0
  550. package/dist/chunks/templateJobs-Db630FZD.js +12 -0
  551. package/dist/chunks/terminalSetup-DJqWE8fc.js +33 -0
  552. package/dist/chunks/terminalSetup-ygKHrVKR.js +1 -0
  553. package/dist/chunks/theme-MmfFhdTD.js +1 -0
  554. package/dist/chunks/thinkback-CrNirB0V.js +1 -0
  555. package/dist/chunks/thinkback-Quc7KPmi.js +1 -0
  556. package/dist/chunks/thinkback-play-CQ1s7oqg.js +1 -0
  557. package/dist/chunks/tmux-CvbhsfwG.js +1 -0
  558. package/dist/chunks/toolEventObserver-BqMplcIk.js +1 -0
  559. package/dist/chunks/toolEventObserver-DBq2XBYY.js +1 -0
  560. package/dist/chunks/toolPool-BkCtTKXz.js +1 -0
  561. package/dist/chunks/toolPool-C7bOwJfR.js +1 -0
  562. package/dist/chunks/trustedDevice-C9Zevohz.js +1 -0
  563. package/dist/chunks/trustedDevice-DEuQUTbz.js +1 -0
  564. package/dist/chunks/tui-BVc2q4Xv.js +6 -0
  565. package/dist/chunks/turndown.es-Bv06VjMb.js +69 -0
  566. package/dist/chunks/types-CQ1wrnQ0.js +1 -0
  567. package/dist/chunks/types-Csi32ZXh.js +17 -0
  568. package/dist/chunks/types-RJTEOuIt.js +3 -0
  569. package/dist/chunks/udsClient-BvG_Jip0.js +1 -0
  570. package/dist/chunks/ultrareviewCommand-DrlfRrXq.js +3 -0
  571. package/dist/chunks/undercover-CBeHiWUd.js +1 -0
  572. package/dist/chunks/undercover-DKn95mh9.js +31 -0
  573. package/dist/chunks/up-D-U4wUCe.js +12 -0
  574. package/dist/chunks/updateCCB-CJ7dCUan.js +11 -0
  575. package/dist/chunks/upgrade-Degqbu8S.js +1 -0
  576. package/dist/chunks/upgrade-ucJ-lnlY.js +1 -0
  577. package/dist/chunks/upload-pTZQCPLt.js +1 -0
  578. package/dist/chunks/upstreamproxy-DcLeL2XX.js +11 -0
  579. package/dist/chunks/usage-D96a7Cke.js +1 -0
  580. package/dist/chunks/usage-DVQMUMcC.js +1 -0
  581. package/dist/chunks/useKeybinding-FsOnjW6T.js +1 -0
  582. package/dist/chunks/useMainLoopModel-B7ch2o9K.js +1 -0
  583. package/dist/chunks/useManagePlugins-BfGzHMvO.js +1 -0
  584. package/dist/chunks/useMergedTools-TemEvCrX.js +1 -0
  585. package/dist/chunks/useSearchInput-B-V4kIa-.js +1 -0
  586. package/dist/chunks/useSettingsErrors-B2JGz1s8.js +1 -0
  587. package/dist/chunks/useVoice-BuwYDm2U.js +1 -0
  588. package/dist/chunks/util-CeIKZmj9.js +1 -0
  589. package/dist/chunks/utils-CwhszpkT.js +1 -0
  590. package/dist/chunks/v4-f1i_CNUT.js +1 -0
  591. package/dist/chunks/validatePlugin-BlVho93x.js +1 -0
  592. package/dist/chunks/vertex-sdk-CSGw3fvU.js +9 -0
  593. package/dist/chunks/vim-DUZQCWUP.js +1 -0
  594. package/dist/chunks/voice-BkRIHZiM.js +2 -0
  595. package/dist/chunks/voice-DXiiy8HX.js +8 -0
  596. package/dist/chunks/voiceModeEnabled-CPQUE3PU.js +1 -0
  597. package/dist/chunks/voiceModeEnabled-DB8GCzAF.js +1 -0
  598. package/dist/chunks/voiceStreamSTT-DgoDscHn.js +1 -0
  599. package/dist/chunks/voiceStreamSTT-Dr_wH1Kh.js +1 -0
  600. package/dist/chunks/which-DqSAIvp2.js +1 -0
  601. package/dist/chunks/windowsPaths-C9CigqoF.js +1 -0
  602. package/dist/chunks/windowsPaths-swxCp7bX.js +2 -0
  603. package/dist/chunks/workSecret-mS2OrpxF.js +1 -0
  604. package/dist/chunks/workerRegistry-CT7_kjvY.js +1 -0
  605. package/dist/chunks/worktree-DU3xtwKW.js +1 -0
  606. package/dist/chunks/worktreeModeEnabled-Db6b_Iy_.js +1 -0
  607. package/dist/chunks/worktreeModeEnabled-THQb19xR.js +1 -0
  608. package/dist/chunks/wrapper-BSK0MCQH.js +1 -0
  609. package/dist/chunks/wrapper-D5qL1aQL.js +6 -0
  610. package/dist/chunks/xdg-CBxMmQux.js +1 -0
  611. package/dist/chunks/xml-DD_ldd3X.js +1 -0
  612. package/dist/chunks/zod-DT6hytkp.js +1 -0
  613. package/dist/cli.js +1 -10978
  614. package/package.json +1 -1
@@ -0,0 +1,28 @@
1
+ import{n as e,o as t}from"./chunk-DR8-3Aex.js";import{Rn as n,b as r,f as i,t as a,x as o,xt as s}from"./src-Di342QoJ.js";import{t as c}from"./jsx-runtime-D-D469L8.js";import{Mx as l,kx as u}from"./loadAgentsDir-Ci5mr0vm.js";import{r as d,t as f}from"./featureCheck-Cm0YNDXO.js";async function p(){let{readObservations:e,loadInstincts:t,resolveProjectContext:n}=await import(`./skillLearning-_o2D06yM.js`),r=n(process.cwd()),[i,a]=await Promise.all([e({project:r}),t({project:r})]);return[`Skill Learning status for ${r.projectName} (${r.projectId})`,`Observations: ${i.length}`,`Instincts: ${a.length}`,``,`Skill Learning: ${d()?`enabled`:`disabled`}`].join(`
2
+ `)}async function m(){let e=[];d()?e.push(`Skill Learning: already enabled`):(process.env.SKILL_LEARNING_ENABLED=`1`,e.push(`Skill Learning: enabled (SKILL_LEARNING_ENABLED=1)`));try{let{initSkillLearning:t}=await import(`./runtimeObserver-OgM9ZYxZ.js`);t(),e.push(`Runtime observer: initialized`)}catch{e.push(`Runtime observer: init skipped (not available)`)}return e.join(`
3
+ `)}async function h(){let e=[];return d()?(process.env.SKILL_LEARNING_ENABLED=`0`,process.env.CLAUDE_SKILL_LEARNING_DISABLE=`1`,e.push(`Skill Learning: disabled (SKILL_LEARNING_ENABLED=0)`)):e.push(`Skill Learning: already disabled`),e.join(`
4
+ `)}function g({onDone:e}){l(`skill-panel`);let[t,n]=(0,v.useState)(0),a=(0,v.useMemo)(()=>[{label:`Status`,description:`Show skill learning status for current project`,run:p},{label:`Start`,description:`Enable skill learning for this session`,run:m},{label:`Stop`,description:`Disable skill learning for this session`,run:h},{label:`About`,description:`Detailed description of skill learning features`,run:()=>Promise.resolve(x)}],[]),c=()=>{let n=a[t];n&&n.run().then(t=>{e(t,{display:`system`})})};return s((e,t)=>{if(t.upArrow){n(e=>Math.max(0,e-1));return}if(t.downArrow){n(e=>Math.min(a.length-1,e+1));return}t.return&&c()}),(0,y.jsx)(i,{title:`Skill Learning`,subtitle:`${a.length} actions`,onCancel:()=>e(`Skill panel dismissed`,{display:`system`}),color:`background`,hideInputGuide:!0,children:(0,y.jsxs)(o,{flexDirection:`column`,children:[a.map((e,n)=>(0,y.jsxs)(o,{flexDirection:`row`,children:[(0,y.jsx)(r,{children:`${n===t?`›`:` `} ${e.label}`.padEnd(b)}),(0,y.jsx)(r,{dimColor:!0,children:e.description})]},e.label)),(0,y.jsx)(o,{marginTop:1,children:(0,y.jsx)(r,{dimColor:!0,children:`↑/↓ select · Enter run · Esc close`})})]})})}async function _(e,t,n){let r=n?.trim()??``;if(r===`start`)return e(await m(),{display:`system`}),null;if(r===`stop`)return e(await h(),{display:`system`}),null;if(r===`about`)return e(x,{display:`system`}),null;if(r===`status`)return e(await p(),{display:`system`}),null;if(r){let{call:t}=await import(`./skill-learning-DOIMPtWE.js`),n=await t(r,{});return n&&typeof n==`object`&&`value`in n&&e(n.value,{display:`system`}),null}return(0,y.jsx)(g,{onDone:e})}var v,y,b,x;e((()=>{v=t(n(),1),a(),u(),f(),y=c(),b=28,x=`# Skill Learning (自动学习)
5
+
6
+ Skill Learning 是一个闭环学习系统,通过观察用户的操作模式自动提取直觉(instinct),
7
+ 并在达到阈值后生成可复用的 skill 文件、agent 和 command。
8
+
9
+ ## 工作流程
10
+ 1. **Observe** — 记录每轮对话中的工具调用、用户纠正、错误解决模式
11
+ 2. **Analyze** — 使用启发式或 LLM 后端分析观察数据,提取 instinct candidate
12
+ 3. **Evolve** — 将高置信度 instinct 聚类,生成 skill/agent/command 候选
13
+ 4. **Lifecycle** — 对生成的 skill 进行去重、版本比较、归档或替换
14
+
15
+ ## 子命令
16
+ - /skill-learning status — 查看当前项目的观察和直觉数量
17
+ - /skill-learning ingest — 从 transcript 导入观察数据
18
+ - /skill-learning evolve — 生成 skill 候选 (--generate 写入磁盘)
19
+ - /skill-learning export — 导出 instinct 为 JSON
20
+ - /skill-learning import — 导入 instinct JSON
21
+ - /skill-learning prune — 清理过期的 pending instinct
22
+ - /skill-learning promote — 将 instinct/gap 提升为全局范围
23
+ - /skill-learning projects — 列出所有已知的项目范围
24
+
25
+ ## 启用方式
26
+ - SKILL_LEARNING_ENABLED=1 或 FEATURE_SKILL_LEARNING=1
27
+ - 状态: ${d()?`已启用`:`未启用`}
28
+ `}))();export{_ as call};
@@ -0,0 +1,21 @@
1
+ import{n as e,o as t}from"./chunk-DR8-3Aex.js";import{Rn as n,b as r,f as i,t as a,x as o,xt as s}from"./src-Di342QoJ.js";import{t as c}from"./jsx-runtime-D-D469L8.js";import{Eh as l,Mx as u,Th as d,kx as f}from"./loadAgentsDir-Ci5mr0vm.js";function p(){return[`Skill Search (自动技能匹配)`,`Status: ${l()?`enabled`:`disabled`}`,``,`When enabled, relevant skills are automatically matched and`,`injected into conversation context each turn.`].join(`
2
+ `)}async function m(){if(l()&&process.env.SKILL_SEARCH_ENABLED!==`0`)return`Skill Search: already enabled`;process.env.SKILL_SEARCH_ENABLED=`1`;let e=[`Skill Search: enabled (SKILL_SEARCH_ENABLED=1)`];try{let{clearSkillIndexCache:t}=await import(`./localSearch-DtVqtfvk.js`);t(),e.push(`Skill index cache: cleared (will rebuild on next search)`)}catch{e.push(`Skill index cache: clear skipped`)}return e.join(`
3
+ `)}async function h(){return l()?(process.env.SKILL_SEARCH_ENABLED=`0`,`Skill Search: disabled (SKILL_SEARCH_ENABLED=0)`):`Skill Search: already disabled`}function g({onDone:e}){u(`skill-search-panel`);let[t,n]=(0,v.useState)(0),a=(0,v.useMemo)(()=>[{label:`Status`,description:`Show whether automatic skill matching is active`,run:()=>Promise.resolve(p())},{label:`Start`,description:`Enable automatic skill matching for this session`,run:m},{label:`Stop`,description:`Disable automatic skill matching for this session`,run:h},{label:`About`,description:`How automatic skill matching works`,run:()=>Promise.resolve(x)}],[]),c=()=>{let n=a[t];n&&n.run().then(t=>{e(t,{display:`system`})})};return s((e,t)=>{if(t.upArrow){n(e=>Math.max(0,e-1));return}if(t.downArrow){n(e=>Math.min(a.length-1,e+1));return}t.return&&c()}),(0,y.jsx)(i,{title:`Skill Search`,subtitle:`${a.length} actions`,onCancel:()=>e(`Skill search panel dismissed`,{display:`system`}),color:`background`,hideInputGuide:!0,children:(0,y.jsxs)(o,{flexDirection:`column`,children:[a.map((e,n)=>(0,y.jsxs)(o,{flexDirection:`row`,children:[(0,y.jsx)(r,{children:`${n===t?`›`:` `} ${e.label}`.padEnd(b)}),(0,y.jsx)(r,{dimColor:!0,children:e.description})]},e.label)),(0,y.jsx)(o,{marginTop:1,children:(0,y.jsx)(r,{dimColor:!0,children:`↑/↓ select · Enter run · Esc close`})})]})})}async function _(e,t,n){let r=n?.trim()??``;return r===`start`?(e(await m(),{display:`system`}),null):r===`stop`?(e(await h(),{display:`system`}),null):r===`about`?(e(x,{display:`system`}),null):r===`status`?(e(p(),{display:`system`}),null):(0,y.jsx)(g,{onDone:e})}var v,y,b,x;e((()=>{v=t(n(),1),a(),f(),d(),y=c(),b=28,x=`# Skill Search (自动技能匹配)
4
+
5
+ Skill Search 控制对话中的自动技能匹配功能。
6
+
7
+ 启用后,Claude Code 会在每轮对话中自动搜索并加载与当前任务最相关的 skill 文件,
8
+ 无需手动指定。搜索基于 TF-IDF 向量余弦相似度,支持英文词干化和 CJK bi-gram 分词。
9
+
10
+ ## 工作原理
11
+ 1. 对话开始时,自动索引 .claude/skills/ 和 ~/.claude/skills/ 下的 Markdown 文件
12
+ 2. 每轮对话根据上下文自动匹配最相关的 skill
13
+ 3. 匹配到的 skill 内容会作为上下文注入,指导 Claude Code 的行为
14
+
15
+ ## 控制方式
16
+ - /skill-search start — 启用自动匹配
17
+ - /skill-search stop — 禁用自动匹配
18
+ - /skill-search status — 查看当前状态
19
+
20
+ 当前状态: ${l()?`已启用`:`未启用`}
21
+ `}))();export{_ as call};
@@ -0,0 +1 @@
1
+ import{n as e,o as t}from"./chunk-DR8-3Aex.js";import{Rn as n,b as r,f as i,t as a,u as o,x as s}from"./src-Di342QoJ.js";import{t as c}from"./jsx-runtime-D-D469L8.js";import{Po as l,ec as u,jo as d,nc as f}from"./paths-Q2255dD7.js";import{b as p,x as m}from"./startupProfiler-DnXZaX4A.js";import{JS as h,Sm as g,Xi as _,YS as v,la as y,wm as b}from"./loadAgentsDir-Ci5mr0vm.js";function x(e,t){let n=t.trim();if(n===``)return e.slice();let r=n.toLowerCase().split(/\s+/);return e.filter(e=>{let t=`${e.name} ${e.description}`.toLowerCase();return r.every(e=>t.includes(e))})}var S=e((()=>{}));function C(e){return e===`plugin`?`plugin`:e===`mcp`?`mcp`:u(e)}function w({onExit:e,commands:t}){let[n,a]=(0,T.useState)(``),c=(0,T.useMemo)(()=>t.filter(e=>e.type===`prompt`&&(e.loadedFrom===`skills`||e.loadedFrom===`commands_DEPRECATED`||e.loadedFrom===`plugin`||e.loadedFrom===`mcp`)),[t]),u=(0,T.useMemo)(()=>x(c.map(e=>({...e,name:y(e),description:e.description??``})),n),[c,n]),d=(0,T.useMemo)(()=>{let e={policySettings:[],userSettings:[],projectSettings:[],localSettings:[],flagSettings:[],plugin:[],mcp:[]};for(let t of u){let n=t.source;n in e&&e[n].push(t)}for(let t of Object.values(e))t.sort((e,t)=>y(e).localeCompare(y(t)));return e},[u]),f=()=>{e(`Skills dialog dismissed`,{display:`system`})};if(c.length===0)return(0,E.jsxs)(i,{title:`Skills`,subtitle:`No skills found`,onCancel:f,hideInputGuide:!0,children:[(0,E.jsx)(r,{dimColor:!0,children:`Create skills in .claude/skills/ or ~/.claude/skills/`}),(0,E.jsx)(r,{dimColor:!0,italic:!0,children:(0,E.jsx)(h,{action:`confirm:no`,context:`Confirmation`,fallback:`Esc`,description:`close`})})]});let m=e=>{switch(e){case`projectSettings`:case`localSettings`:return{label:`local`,color:`yellow`};case`userSettings`:return{label:`global`,color:`cyan`};case`policySettings`:return{label:`managed`,color:`magenta`};default:return}},_=(e,t)=>{let n=`~${p(g(e))}`,i=e.source===`plugin`?e.pluginInfo?.pluginManifest.name:void 0,a=m(e.source);return(0,E.jsxs)(s,{children:[(0,E.jsx)(r,{color:t?`suggestion`:void 0,children:y(e)}),a&&(0,E.jsxs)(r,{color:a.color,children:[` [`,a.label,`]`]}),(0,E.jsxs)(r,{dimColor:!0,children:[i?` · ${i}`:``,` · `,C(e.source),` · `,n,` tokens`]})]})};return(0,E.jsx)(o,{title:`Skills`,placeholder:`Type to filter skills…`,items:(0,T.useMemo)(()=>D.flatMap(e=>d[e]),[d]),getKey:e=>`${e.name}-${e.source}`,visibleCount:12,direction:`down`,onQueryChange:a,onSelect:t=>{e(`/${y(t)}`,{display:`user`})},onCancel:f,emptyMessage:e=>e.trim()?`No skills matching "${e.trim()}"`:`No skills found`,matchLabel:n.trim()===``?`${c.length} ${l(c.length,`skill`)}`:`${u.length}/${c.length} ${l(c.length,`skill`)}`,selectAction:`invoke skill`,renderItem:(e,t)=>_(e,t)})}var T,E,D,O=e((()=>{n(),T=t(n(),1),_(),a(),b(),m(),f(),d(),v(),S(),E=c(),D=[`projectSettings`,`localSettings`,`userSettings`,`flagSettings`,`policySettings`,`plugin`,`mcp`]}));async function k(e,t){return(0,A.jsx)(w,{onExit:e,commands:t.options.commands})}var A;e((()=>{n(),O(),A=c()}))();export{k as call};
@@ -0,0 +1 @@
1
+ import{n as e}from"./chunk-DR8-3Aex.js";function t(e){let t=e.trim();if(!t.startsWith(`/`))return null;let n=t.slice(1).split(` `);if(!n[0])return null;let r=n[0],i=!1,a=1;n.length>1&&n[1]===`(MCP)`&&(r+=` (MCP)`,i=!0,a=2);let o=n.slice(a).join(` `);return{commandName:r,args:o,isMcp:i}}var n=e((()=>{}));export{t as n,n as t};
@@ -0,0 +1 @@
1
+ import{n as e}from"./chunk-DR8-3Aex.js";function t(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 n=e((()=>{}));export{t as n,n as t};
@@ -0,0 +1 @@
1
+ import{n as e}from"./chunk-DR8-3Aex.js";import{C as t,E as n,S as r,T as i,_ as a,b as o,c as s,d as c,f as l,g as u,h as d,l as f,m as p,p as m,u as h,v as g,w as _,x as v,y}from"./companion-CyK_Dr1U.js";function b(e,t=0){let n=C[e.species],r=[...n[t%n.length].map(t=>t.replaceAll(`{E}`,e.eye))];return e.hat!==`none`&&!r[0].trim()&&(r[0]=w[e.hat]),!r[0].trim()&&n.every(e=>!e[0].trim())&&r.shift(),r}function x(e){return C[e].length}function S(e){let g=e.eye;switch(e.species){case d:case a:return`(${g}>`;case f:return`(${g}${g})`;case l:return`=${g}ω${g}=`;case p:return`<${g}~${g}>`;case o:return`~(${g}${g})~`;case v:return`(${g})(${g})`;case r:return`(${g}>)`;case n:return`[${g}_${g}]`;case i:return`${g}(@)`;case u:return`/${g}${g}\\`;case s:return`}${g}.${g}{`;case c:return`(${g}oo${g})`;case h:return`|${g} ${g}|`;case _:return`[${g}${g}]`;case t:return`(${g}..${g})`;case y:return`|${g} ${g}|`;case m:return`(${g}.${g})`}}var C,w,T=e((()=>{g(),C={[d]:[[` `,` __ `,` <({E} )___ `,` ( ._> `," `--´ "],[` `,` __ `,` <({E} )___ `,` ( ._> `," `--´~ "],[` `,` __ `,` <({E} )___ `,` ( .__> `," `--´ "]],[a]:[[` `,` ({E}> `,` || `,` _(__)_ `,` ^^^^ `],[` `,` ({E}> `,` || `,` _(__)_ `,` ^^^^ `],[` `,` ({E}>> `,` || `,` _(__)_ `,` ^^^^ `]],[f]:[[` `,` .----. `,` ( {E} {E} ) `,` ( ) `," `----´ "],[` `,` .------. `,` ( {E} {E} ) `,` ( ) `," `------´ "],[` `,` .--. `,` ({E} {E}) `,` ( ) `," `--´ "]],[l]:[[` `,` /\\_/\\ `,` ( {E} {E}) `,` ( ω ) `,` (")_(") `],[` `,` /\\_/\\ `,` ( {E} {E}) `,` ( ω ) `,` (")_(")~ `],[` `,` /\\-/\\ `,` ( {E} {E}) `,` ( ω ) `,` (")_(") `]],[p]:[[` `,` /^\\ /^\\ `,` < {E} {E} > `,` ( ~~ ) `," `-vvvv-´ "],[` `,` /^\\ /^\\ `,` < {E} {E} > `,` ( ) `," `-vvvv-´ "],[` ~ ~ `,` /^\\ /^\\ `,` < {E} {E} > `,` ( ~~ ) `," `-vvvv-´ "]],[o]:[[` `,` .----. `,` ( {E} {E} ) `,` (______) `,` /\\/\\/\\/\\ `],[` `,` .----. `,` ( {E} {E} ) `,` (______) `,` \\/\\/\\/\\/ `],[` o `,` .----. `,` ( {E} {E} ) `,` (______) `,` /\\/\\/\\/\\ `]],[v]:[[` `,` /\\ /\\ `,` (({E})({E})) `,` ( >< ) `," `----´ "],[` `,` /\\ /\\ `,` (({E})({E})) `,` ( >< ) `,` .----. `],[` `,` /\\ /\\ `,` (({E})(-)) `,` ( >< ) `," `----´ "]],[r]:[[` `,` .---. `,` ({E}>{E}) `,` /( )\\ `," `---´ "],[` `,` .---. `,` ({E}>{E}) `,` |( )| `," `---´ "],[` .---. `,` ({E}>{E}) `,` /( )\\ `," `---´ ",` ~ ~ `]],[n]:[[` `,` _,--._ `,` ( {E} {E} ) `,` /[______]\\ `," `` `` "],[` `,` _,--._ `,` ( {E} {E} ) `,` /[______]\\ `," `` `` "],[` `,` _,--._ `,` ( {E} {E} ) `,` /[======]\\ `," `` `` "]],[i]:[[` `,` {E} .--. `,` \\ ( @ ) `," \\_`--´ ",` ~~~~~~~ `],[` `,` {E} .--. `,` | ( @ ) `," \\_`--´ ",` ~~~~~~~ `],[` `,` {E} .--. `,` \\ ( @ ) `," \\_`--´ ",` ~~~~~~ `]],[u]:[[` `,` .----. `,` / {E} {E} \\ `,` | | `," ~`~``~`~ "],[` `,` .----. `,` / {E} {E} \\ `,` | | `," `~`~~`~` "],[` ~ ~ `,` .----. `,` / {E} {E} \\ `,` | | `," ~~`~~`~~ "]],[s]:[[` `,`}~(______)~{`,`}~({E} .. {E})~{`,` ( .--. ) `,` (_/ \\_) `],[` `,`~}(______){~`,`~}({E} .. {E}){~`,` ( .--. ) `,` (_/ \\_) `],[` `,`}~(______)~{`,`}~({E} .. {E})~{`,` ( -- ) `,` ~_/ \\_~ `]],[c]:[[` `,` n______n `,` ( {E} {E} ) `,` ( oo ) `," `------´ "],[` `,` n______n `,` ( {E} {E} ) `,` ( Oo ) `," `------´ "],[` ~ ~ `,` u______n `,` ( {E} {E} ) `,` ( oo ) `," `------´ "]],[h]:[[` `,` n ____ n `,` | |{E} {E}| | `,` |_| |_| `,` | | `],[` `,` ____ `,` n |{E} {E}| n `,` |_| |_| `,` | | `],[` n n `,` | ____ | `,` | |{E} {E}| | `,` |_| |_| `,` | | `]],[_]:[[` `,` .[||]. `,` [ {E} {E} ] `,` [ ==== ] `," `------´ "],[` `,` .[||]. `,` [ {E} {E} ] `,` [ -==- ] `," `------´ "],[` * `,` .[||]. `,` [ {E} {E} ] `,` [ ==== ] `," `------´ "]],[t]:[[` `,` (\\__/) `,` ( {E} {E} ) `,` =( .. )= `,` (")__(") `],[` `,` (|__/) `,` ( {E} {E} ) `,` =( .. )= `,` (")__(") `],[` `,` (\\__/) `,` ( {E} {E} ) `,` =( . . )= `,` (")__(") `]],[y]:[[` `,` .-o-OO-o-. `,`(__________)`,` |{E} {E}| `,` |____| `],[` `,` .-O-oo-O-. `,`(__________)`,` |{E} {E}| `,` |____| `],[` . o . `,` .-o-OO-o-. `,`(__________)`,` |{E} {E}| `,` |____| `]],[m]:[[` `,` /\\ /\\ `,` ( {E} {E} ) `,` ( .. ) `," `------´ "],[` `,` /\\ /| `,` ( {E} {E} ) `,` ( .. ) `," `------´ "],[` `,` /\\ /\\ `,` ( {E} {E} ) `,` ( .. ) `," `------´~ "]]},w={none:``,crown:` \\^^^/ `,tophat:` [___] `,propeller:` -+- `,halo:` ( ) `,wizard:` /^\\ `,beanie:` (___) `,tinyduck:` ,> `}}));export{x as i,S as n,b as r,T as t};
@@ -0,0 +1,26 @@
1
+ import{B as e,M as t,d as n,n as r,t as i}from"./server-DzOdtq8A.js";import{t as a}from"./lib-B4Q0Nrpb.js";import{n as o,t as s}from"./stdio-BEEzuxaZ.js";import{basename as c,extname as l,join as u}from"node:path";import{chmodSync as d,existsSync as f,mkdirSync as p,readFileSync as m,unlinkSync as ee,writeFileSync as h}from"node:fs";import{homedir as g,tmpdir as te}from"node:os";import{createCipheriv as ne,createDecipheriv as re,createHash as ie,randomBytes as _,randomUUID as v}from"node:crypto";var y={NONE:0,USER:1,BOT:2},b={NONE:0,TEXT:1,IMAGE:2,VOICE:3,FILE:4,VIDEO:5},x={NEW:0,GENERATING:1,FINISH:2},S={IMAGE:1,VIDEO:2,FILE:3,VOICE:4},ae={TYPING:1,CANCEL:2},oe=`0.1.0`;function C(){return{channel_version:oe}}function w(){return _(4).toString(`base64`)}function T(e){let t={"Content-Type":`application/json`,"X-WECHAT-UIN":w()};return e&&(t.AuthorizationType=`ilink_bot_token`,t.Authorization=`Bearer ${e}`),t}async function E(e,t,n,r,i=4e4,a){let o=new AbortController,s=setTimeout(()=>o.abort(),i);a&&a.addEventListener(`abort`,()=>o.abort(),{once:!0});try{let i=await fetch(`${e}${t}`,{method:`POST`,headers:T(r),body:JSON.stringify(n),signal:o.signal});if(!i.ok)throw Error(`HTTP ${i.status}: ${i.statusText}`);return await i.json()}finally{clearTimeout(s)}}async function se(e,t,n,r){let i={get_updates_buf:n,base_info:C()};try{return await E(e,`/ilink/bot/getupdates`,i,t,4e4,r)}catch(e){if(e instanceof Error&&e.name===`AbortError`)return{ret:0,msgs:[],get_updates_buf:n};throw e}}async function D(e,t,n){await E(e,`/ilink/bot/sendmessage`,{msg:n,base_info:C()},t)}async function O(e,t,n){return E(e,`/ilink/bot/getuploadurl`,{...n,base_info:C()},t)}async function k(e,t,n,r){return E(e,`/ilink/bot/getconfig`,{ilink_user_id:n,context_token:r,base_info:C()},t)}async function A(e,t,n){return E(e,`/ilink/bot/sendtyping`,{...n,base_info:C()},t)}var j=`https://ilinkai.weixin.qq.com`,M=`https://novac2c.cdn.weixin.qq.com/c2c`;function N(){let e=process.env.WEIXIN_STATE_DIR||u(g(),`.claude`,`channels`,`weixin`);return f(e)||p(e,{recursive:!0}),e}function P(){return u(N(),`account.json`)}function F(){let e=P();if(!f(e))return null;try{return JSON.parse(m(e,`utf-8`))}catch{return null}}function ce(e){let t=P();h(t,JSON.stringify(e,null,2),`utf-8`),d(t,384)}function le(){let e=P();f(e)&&ee(e)}var ue=a();async function I(e){let t=await(0,ue.toString)(e,{type:`terminal`,errorCorrectionLevel:`L`,small:!0});process.stderr.write(`${t}\n`)}async function L(e){let t=await fetch(`${e}/ilink/bot/get_bot_qrcode?bot_type=3`);if(!t.ok)throw Error(`Failed to get QR code: HTTP ${t.status}`);let n=await t.json();if(!n.qrcode)throw Error(`No qrcode in response`);let r=n.qrcode_img_content||``;return r&&await I(r),{qrcodeUrl:r,qrcodeId:n.qrcode,message:`Scan the QR code with WeChat to connect.`}}async function R(e){let{qrcodeId:t,apiBaseUrl:n,timeoutMs:r=48e4,maxRetries:i=3}=e,a=Date.now()+r,o=t,s=0;for(;Date.now()<a;){try{let e=new AbortController,t=setTimeout(()=>e.abort(),6e4),r=await fetch(`${n}/ilink/bot/get_qrcode_status?qrcode=${encodeURIComponent(o)}`,{headers:{"iLink-App-ClientVersion":`1`},signal:e.signal});if(clearTimeout(t),!r.ok)throw Error(`HTTP ${r.status}`);let a=await r.json();switch(a.status){case`confirmed`:return{connected:!0,token:a.bot_token,accountId:a.ilink_bot_id,baseUrl:a.baseurl,userId:a.ilink_user_id,message:`Connected to WeChat successfully!`};case`scaned`:process.stderr.write(`QR code scanned, waiting for confirmation...
2
+ `);break;case`expired`:if(s+=1,s>=i)return{connected:!1,message:`QR code expired after maximum retries.`};process.stderr.write(`QR code expired, refreshing...
3
+ `),o=(await L(n)).qrcodeId;break;default:break}}catch(e){if(e instanceof Error&&e.name===`AbortError`)continue;throw e}await new Promise(e=>setTimeout(e,1e3))}return{connected:!1,message:`Login timed out.`}}function z(){return u(N(),`access.json`)}function B(){return u(N(),`pending-pairings.json`)}function V(){let e=B();if(!f(e))return{};try{return JSON.parse(m(e,`utf-8`))}catch{return{}}}function H(e){h(B(),JSON.stringify(e,null,2),`utf-8`)}function U(){let e=z();if(!f(e))return{policy:`pairing`,allowFrom:[]};try{return JSON.parse(m(e,`utf-8`))}catch{return{policy:`pairing`,allowFrom:[]}}}function de(e){h(z(),JSON.stringify(e,null,2),`utf-8`)}function fe(e){let t=U();return t.policy===`disabled`?!0:t.allowFrom.includes(e)}function pe(e){let t=V(),n=Date.now();for(let e of Object.keys(t))t[e].expiresAt<n&&delete t[e];for(let[n,r]of Object.entries(t))if(r.userId===e)return H(t),n;let r=String(Math.floor(1e5+Math.random()*9e5));return t[r]={userId:e,expiresAt:n+600*1e3},H(t),r}function me(e){let t=V(),n=t[e];if(!n||n.expiresAt<Date.now())return delete t[e],H(t),null;delete t[e],H(t);let r=U();return r.allowFrom.includes(n.userId)||(r.allowFrom.push(n.userId),de(r)),n.userId}function he(e,t){let n=ne(`aes-128-ecb`,t,null);return Buffer.concat([n.update(e),n.final()])}function ge(e,t){let n=re(`aes-128-ecb`,t,null);return Buffer.concat([n.update(e),n.final()])}function _e(e,t){return`${t}/download?encrypted_query_param=${encodeURIComponent(e)}`}function ve(e,t,n){return`${e}/upload?encrypted_query_param=${encodeURIComponent(t)}&filekey=${encodeURIComponent(n)}`}function ye(e){let t=Buffer.from(e,`base64`);if(t.length===16)return t;if(t.length===32&&/^[0-9a-fA-F]{32}$/.test(t.toString(`ascii`)))return Buffer.from(t.toString(`ascii`),`hex`);throw Error(`Invalid aes_key: expected 16 raw bytes or 32 hex chars, got ${t.length} bytes`)}async function be(e){let t=_e(e.encryptQueryParam,e.cdnBaseUrl),n=await fetch(t);if(!n.ok)throw Error(`CDN download failed: HTTP ${n.status}`);return ge(Buffer.from(await n.arrayBuffer()),ye(e.aesKey))}async function W(e){let t=m(e.filePath),n=t.length,r=ie(`md5`).update(t).digest(`hex`),i=_(16),a=_(16).toString(`hex`),o=he(t,i),s=o.length,l=await O(e.apiBaseUrl,e.token,{filekey:a,media_type:e.mediaType,to_user_id:e.toUserId,rawsize:n,rawfilemd5:r,filesize:s,no_need_thumb:!0,aeskey:i.toString(`hex`)});if(!l.upload_param)throw Error(`No upload_param in response`);let u=ve(e.cdnBaseUrl,l.upload_param,a),d=await fetch(u,{method:`POST`,headers:{"Content-Type":`application/octet-stream`},body:new Uint8Array(o)});if(!d.ok)throw Error(`CDN upload failed: HTTP ${d.status}`);return{encryptQueryParam:d.headers.get(`x-encrypted-param`)||``,aesKey:Buffer.from(i.toString(`hex`)).toString(`base64`),fileSize:s,rawSize:n,fileName:c(e.filePath)}}function xe(e){let t=l(e).toLowerCase();return[`.jpg`,`.jpeg`,`.png`,`.gif`,`.bmp`,`.webp`,`.heic`].includes(t)?S.IMAGE:[`.mp4`,`.mov`,`.avi`,`.mkv`,`.webm`].includes(t)?S.VIDEO:S.FILE}function Se(e){let t=``,n=0;for(;n<e.length;)if(e.startsWith("```",n)){let r=n+3;for(;r<e.length&&e[r]!==`
4
+ `;)r++;r<e.length&&r++;let i=r;for(;r<e.length;){if(e.startsWith("```",r)){for(t+=e.slice(i,r),r+=3;r<e.length&&e[r]!==`
5
+ `;)r++;r<e.length&&r++;break}r++}r>=e.length&&!e.startsWith("```",r-3)&&(t+=e.slice(n)),n=r}else t+=e[n],n++;return t}function G(e){return Se(e).replace(/`([^`]+)`/g,`$1`).replace(/\*\*\*(.+?)\*\*\*/g,`$1`).replace(/\*\*(.+?)\*\*/g,`$1`).replace(/\*(.+?)\*/g,`$1`).replace(/___(.+?)___/g,`$1`).replace(/__(.+?)__/g,`$1`).replace(/_(.+?)_/g,`$1`).replace(/~~(.+?)~~/g,`$1`).replace(/^#{1,6}\s+/gm,``).replace(/\[([^\]]+)\]\(([^)]+)\)/g,`$1 ($2)`).replace(/!\[([^\]]*)\]\([^)]+\)/g,`[$1]`).replace(/^>\s+/gm,``).replace(/^[-*_]{3,}$/gm,`---`).replace(/^[\s]*[-*+]\s+/gm,`- `).replace(/^[\s]*(\d+)\.\s+/gm,`$1. `).replace(/\n{3,}/g,`
6
+
7
+ `).trim()}async function K(e){let t=v();return await D(e.baseUrl,e.token,{to_user_id:e.to,from_user_id:``,client_id:t,message_type:y.BOT,message_state:x.FINISH,context_token:e.contextToken,item_list:[{type:b.TEXT,text_item:{text:G(e.text)}}]}),{messageId:t}}async function Ce(e){let t=``;for(let n of e.items)t=v(),await D(e.baseUrl,e.token,{to_user_id:e.to,from_user_id:``,client_id:t,message_type:y.BOT,message_state:x.FINISH,context_token:e.contextToken,item_list:[n]});return t}async function we(e){let t=xe(e.filePath),n=await W({filePath:e.filePath,toUserId:e.to,mediaType:t,apiBaseUrl:e.baseUrl,token:e.token,cdnBaseUrl:e.cdnBaseUrl}),r={encrypt_query_param:n.encryptQueryParam,aes_key:n.aesKey,encrypt_type:1},i=[];switch(e.text&&i.push({type:b.TEXT,text_item:{text:G(e.text)}}),t){case 1:i.push({type:b.IMAGE,image_item:{media:r,mid_size:n.fileSize}});break;case 2:i.push({type:b.VIDEO,video_item:{media:r,video_size:n.fileSize}});break;default:i.push({type:b.FILE,file_item:{media:r,file_name:n.fileName,len:String(n.rawSize)}});break}return{messageId:await Ce({items:i,to:e.to,baseUrl:e.baseUrl,token:e.token,contextToken:e.contextToken})}}var Te=900*1e3,q=new Map,J=null;function Y(e=Date.now()){for(let[t,n]of q.entries())n.expiresAt<=e&&q.delete(t)}function Ee(e,t){J={chatId:e,contextToken:t,updatedAt:Date.now()}}function De(){return J}function Oe(e,t,n){Y();let r={...e,chatId:t,contextToken:n,createdAt:Date.now(),expiresAt:Date.now()+Te};return q.set(e.request_id.toLowerCase(),r),r}function ke(e,t){Y();let n=e.toLowerCase(),r=q.get(n);return!r||r.chatId!==t?null:(q.delete(n),r)}var Ae=/^\s*(y|yes|n|no)\s+([a-km-z]{5})\s*$/i,X=new Map;function Z(e){return X.get(e)}function Q(){return u(N(),`cursor.txt`)}function je(){let e=Q();return f(e)?m(e,`utf-8`).trim():``}function Me(e){h(Q(),e,`utf-8`)}async function Ne(e,t){let n,r,i=``,a=``;switch(e.type){case b.IMAGE:n=e.image_item?.media?.encrypt_query_param,r=e.image_item?.aeskey?Buffer.from(e.image_item.aeskey,`hex`).toString(`base64`):e.image_item?.media?.aes_key,i=`.jpg`,a=`image`;break;case b.VOICE:n=e.voice_item?.media?.encrypt_query_param,r=e.voice_item?.media?.aes_key,i=`.silk`,a=`voice`;break;case b.FILE:n=e.file_item?.media?.encrypt_query_param,r=e.file_item?.media?.aes_key,i=e.file_item?.file_name?`.${e.file_item.file_name.split(`.`).pop()}`:``,a=`file`;break;case b.VIDEO:n=e.video_item?.media?.encrypt_query_param,r=e.video_item?.media?.aes_key,i=`.mp4`,a=`video`;break;default:return null}if(!n||!r)return null;try{let o=await be({encryptQueryParam:n,aesKey:r,cdnBaseUrl:t}),s=u(te(),`weixin-media`);f(s)||p(s,{recursive:!0});let l=u(s,c(e.file_item?.file_name||`${Date.now()}${i}`));return h(l,o),{path:l,type:a}}catch(e){return process.stderr.write(`[weixin] Failed to download media: ${e}\n`),null}}function Pe(e){let t=e.match(Ae);if(!t)return null;let n=t[1]?.toLowerCase().startsWith(`y`)?`allow`:`deny`,r=t[2]?.toLowerCase();return r?{requestId:r,behavior:n}:null}async function Fe(e){let{baseUrl:t,cdnBaseUrl:n,token:r,onMessage:i,onPermissionResponse:a,abortSignal:o}=e,s=je(),c=0;for(process.stderr.write(`[weixin] Starting message poll loop...
8
+ `);!o.aborted;)try{let e=await se(t,r,s,o);if(e.errcode===-14){process.stderr.write(`[weixin] Session expired (errcode -14). Pausing for 30s...
9
+ `),await new Promise(e=>setTimeout(e,3e4));continue}if(e.ret!==0&&e.ret!==void 0)throw Error(`getUpdates error: ret=${e.ret} errcode=${e.errcode} ${e.errmsg}`);if(c=0,e.get_updates_buf&&(s=e.get_updates_buf,Me(s)),e.msgs&&e.msgs.length>0)for(let o of e.msgs)await Ie(o,{baseUrl:t,cdnBaseUrl:n,token:r,onMessage:i,onPermissionResponse:a})}catch(e){if(o.aborted)break;c+=1,process.stderr.write(`[weixin] Poll error (${c}): ${e instanceof Error?e.message:String(e)}\n`),c>=3?(process.stderr.write(`[weixin] Too many consecutive errors, backing off 30s...
10
+ `),await new Promise(e=>setTimeout(e,3e4)),c=0):await new Promise(e=>setTimeout(e,2e3))}process.stderr.write(`[weixin] Poll loop stopped.
11
+ `)}async function Ie(e,t){if(e.message_type!==y.USER)return;let n=e.from_user_id;if(!n)return;if(e.context_token&&X.set(n,e.context_token),!fe(n)){let r=pe(n);try{await K({to:n,text:`Your pairing code is: ${r}\n\nAsk the operator to confirm:\nccb weixin access pair ${r}`,baseUrl:t.baseUrl,token:t.token,contextToken:e.context_token||``})}catch(e){process.stderr.write(`[weixin] Failed to send pairing code: ${e}\n`)}return}Ee(n,e.context_token);let r=``,i,a;if(e.item_list){for(let n of e.item_list)if(n.type===b.TEXT&&n.text_item?.text)r+=`${r?`
12
+ `:``}${n.text_item.text}`;else if(n.type===b.IMAGE||n.type===b.VOICE||n.type===b.FILE||n.type===b.VIDEO){let e=await Ne(n,t.cdnBaseUrl);e&&(i=e.path,a=e.type),n.type===b.VOICE&&n.voice_item?.text&&(r+=`${r?`
13
+ `:``}[Voice transcription]: ${n.voice_item.text}`)}}if(!(!r&&!i)){if(r&&t.onPermissionResponse){let e=Pe(r);if(e){let r=ke(e.requestId,n);if(r){await t.onPermissionResponse({requestId:r.request_id,behavior:e.behavior,fromUserId:n});return}}}await t.onMessage({fromUserId:n,messageId:String(e.message_id||``),text:r||`(media attachment)`,attachmentPath:i,attachmentType:a})}}r(),o(),e();function Le(e){return[`Claude Code needs your approval.`,``,`Tool: ${e.tool_name}`,`Reason: ${e.description}`,`Input: ${e.input_preview}`,``,`Reply with: yes ${e.request_id}`,`Or deny with: no ${e.request_id}`].join(`
14
+ `)}function Re(e){let r=new i({name:`weixin`,version:e},{capabilities:{experimental:{"claude/channel":{},"claude/channel/permission":{}},tools:{}},instructions:`Messages from WeChat arrive as <channel source="plugin:weixin:weixin" chat_id="..." sender_id="...">. Reply using the reply tool with the chat_id from the channel tag. Use absolute paths for file attachments.`});return r.setRequestHandler(t,async()=>({tools:[{name:`reply`,description:`Reply to a WeChat message. Pass the chat_id from the channel tag.`,inputSchema:{type:`object`,properties:{chat_id:{type:`string`,description:`The chat_id from the channel notification`},text:{type:`string`,description:`The reply text`},files:{type:`array`,items:{type:`string`},description:`Optional absolute file paths to attach`}},required:[`chat_id`,`text`]}},{name:`send_typing`,description:`Send a typing indicator to a WeChat user.`,inputSchema:{type:`object`,properties:{chat_id:{type:`string`,description:`The chat_id (user ID)`}},required:[`chat_id`]}}]})),r.setRequestHandler(n,async e=>{let{name:t,arguments:n}=e.params,r=F();if(!r)return{content:[{type:`text`,text:"WeChat not connected. Run `ccb weixin login` first."}],isError:!0};let i=r.baseUrl||`https://ilinkai.weixin.qq.com`,a=M;switch(t){case`reply`:{let e=typeof n?.chat_id==`string`?n.chat_id:``,t=typeof n?.text==`string`?n.text:``,o=Array.isArray(n?.files)?n.files.filter(e=>typeof e==`string`):void 0;if(!e||!t)return{content:[{type:`text`,text:`Missing chat_id or text parameter.`}],isError:!0};let s=Z(e)||``;try{if(o&&o.length>0){for(let[n,c]of o.entries()){if(!f(c))return{content:[{type:`text`,text:`File not found: ${c}`}],isError:!0};await we({filePath:c,to:e,text:n===0?t:``,baseUrl:i,token:r.token,contextToken:s,cdnBaseUrl:a})}return{content:[{type:`text`,text:`Message sent with attachments.`}]}}return await K({to:e,text:t,baseUrl:i,token:r.token,contextToken:s}),{content:[{type:`text`,text:`Message sent.`}]}}catch(e){return{content:[{type:`text`,text:`Failed to send: ${e}`}],isError:!0}}}case`send_typing`:{let e=typeof n?.chat_id==`string`?n.chat_id:``;if(!e)return{content:[{type:`text`,text:`Missing chat_id parameter.`}],isError:!0};try{let t=Z(e),n=await k(i,r.token,e,t);return n.typing_ticket&&await A(i,r.token,{ilink_user_id:e,typing_ticket:n.typing_ticket,status:ae.TYPING}),{content:[{type:`text`,text:`Typing indicator sent.`}]}}catch(e){return{content:[{type:`text`,text:`Failed to send typing: ${e}`}],isError:!0}}}default:return{content:[{type:`text`,text:`Unknown tool: ${t}`}],isError:!0}}}),r}async function ze(e,t){t.enableConfigs(),t.initializeAnalyticsSink();let n=F();n||(process.stderr.write("[weixin] No account configured. Run `ccb weixin login` to connect your WeChat account.\n"),await Promise.all([t.shutdown1PEventLogging(),t.shutdownDatadog()]),process.exit(1));let r=Re(e),i=new s;t.registerPermissionHandler(r,async e=>{let r=e.channel_context?.chat_id,i=r?{chatId:r,contextToken:Z(r)}:De();if(!i){t.logForDebugging(`[Weixin MCP] No active chat available for permission request ${e.request_id}`);return}try{Oe(e,i.chatId,i.contextToken),await K({to:i.chatId,text:Le(e),baseUrl:a,token:n.token,contextToken:i.contextToken||``})}catch(t){process.stderr.write(`[weixin] Failed to relay permission request ${e.request_id}: ${t}\n`)}}),await r.connect(i);let a=n.baseUrl||`https://ilinkai.weixin.qq.com`,o=new AbortController,c=!1,l=async()=>{c||(c=!0,o.signal.aborted||o.abort(),await Promise.all([t.shutdown1PEventLogging(),t.shutdownDatadog()]),process.exit(0))};process.stdin.on(`end`,()=>void l()),process.stdin.on(`error`,()=>void l()),process.on(`SIGINT`,()=>void l()),process.on(`SIGTERM`,()=>void l()),process.on(`SIGHUP`,()=>void l());let u=process.ppid,d=setInterval(()=>{try{process.kill(u,0)}catch{process.stderr.write(`[weixin] Parent process exited, shutting down...
15
+ `),clearInterval(d),l()}},5e3);t.logForDebugging(`[Weixin MCP] Starting poll loop`),await Fe({baseUrl:a,cdnBaseUrl:M,token:n.token,onMessage:async e=>{await r.notification({method:`notifications/claude/channel`,params:{content:e.text,meta:{chat_id:e.fromUserId,sender_id:e.fromUserId,message_id:e.messageId,...e.attachmentPath&&{attachment_path:e.attachmentPath},...e.attachmentType&&{attachment_type:e.attachmentType}}}})},onPermissionResponse:async e=>{await r.notification({method:`notifications/claude/channel/permission`,params:{request_id:e.requestId,behavior:e.behavior}})},abortSignal:o.signal}),clearInterval(d),await l()}function $(){process.stdout.write([`Usage:`,` ccb weixin serve`,` ccb weixin login`,` ccb weixin login clear`,` ccb weixin access pair <code>`,``,`Session enablement:`,` ccb --channels plugin:weixin@builtin`].join(`
16
+ `)+`
17
+ `)}async function Be(e=!1){if(e){le(),process.stdout.write(`WeChat account cleared.
18
+ `);return}let t=F();if(t){process.stdout.write([`Already connected:`,` User ID: ${t.userId||`unknown`}`,` Connected since: ${t.savedAt}`,``,"Run `ccb weixin login clear` to disconnect.",`Restart Claude Code with:`,` ccb --channels plugin:weixin@builtin`].join(`
19
+ `)+`
20
+ `);return}process.stdout.write(`Starting WeChat QR login...
21
+
22
+ `);let n=await L(j);process.stdout.write(`\nScan the QR code above with WeChat, or open this URL:\n${n.qrcodeUrl||``}\n\n`);let r=await R({qrcodeId:n.qrcodeId,apiBaseUrl:j});(!r.connected||!r.token)&&(process.stderr.write(`Login failed: ${r.message}\n`),process.exit(1)),ce({token:r.token,baseUrl:r.baseUrl||`https://ilinkai.weixin.qq.com`,userId:r.userId,savedAt:new Date().toISOString()}),process.stdout.write([`Connected successfully!`,` User ID: ${r.userId||`unknown`}`,` Base URL: ${r.baseUrl||`https://ilinkai.weixin.qq.com`}`,``,`Restart Claude Code with:`,` ccb --channels plugin:weixin@builtin`].join(`
23
+ `)+`
24
+ `)}function Ve(e){(e[0]!==`pair`||!e[1])&&($(),process.exit(1));let t=me(e[1]);t||(process.stderr.write(`Invalid or expired pairing code.
25
+ `),process.exit(1)),process.stdout.write(`Paired successfully: ${t}\n`)}async function He(e,t,n){let[r,...i]=e;switch(r){case`serve`:t||(process.stderr.write(`[weixin] serve handler not available in this context.
26
+ `),process.exit(1)),await ze(n??`0.0.0`,t);return;case`login`:await Be(i[0]===`clear`);return;case`access`:Ve(i);return;default:$()}}export{He as handleWeixinCli};
@@ -0,0 +1,6 @@
1
+ import{n as e}from"./chunk-DR8-3Aex.js";import{n as t,t as n}from"./defineProperty-80gRi2ZW.js";import{n as r,r as i}from"./wrapper-D5qL1aQL.js";import{B as a,M as o,d as s,n as c,t as l}from"./server-DzOdtq8A.js";import{platform as u}from"os";import{dirname as d}from"path";import{promises as f}from"fs";import{createConnection as p}from"net";function m(e){return e instanceof Error?e:void 0}function h(){return process.platform===`darwin`?`macOS`:process.platform===`win32`?`Windows`:`Linux`}var g=e((()=>{}));function _(e){return`result`in e||`error`in e}function v(e){return`method`in e&&typeof e.method==`string`}function y(e){return new x(e)}var b,x,S=e((()=>{g(),t(),b=class extends Error{constructor(e){super(e),this.name=`SocketConnectionError`}},x=class{constructor(e){n(this,`socket`,null),n(this,`connected`,!1),n(this,`connecting`,!1),n(this,`responseCallback`,null),n(this,`notificationHandler`,null),n(this,`responseBuffer`,Buffer.alloc(0)),n(this,`reconnectAttempts`,0),n(this,`maxReconnectAttempts`,10),n(this,`reconnectDelay`,1e3),n(this,`reconnectTimer`,null),n(this,`context`,void 0),n(this,`disableAutoReconnect`,!1),this.context=e}async connect(){let{serverName:e,logger:t}=this.context;if(this.connecting){t.info(`[${e}] Already connecting, skipping duplicate attempt`);return}this.closeSocket(),this.connecting=!0;let n=this.context.getSocketPath?.()??this.context.socketPath;t.info(`[${e}] Attempting to connect to: ${n}`);try{await this.validateSocketSecurity(n)}catch(n){this.connecting=!1,t.info(`[${e}] Security validation failed:`,m(n));return}this.socket=p(n);let r=setTimeout(()=>{this.connected||(t.info(`[${e}] Connection attempt timed out after 5000ms`),this.closeSocket(),this.scheduleReconnect())},5e3);this.socket.on(`connect`,()=>{clearTimeout(r),this.connected=!0,this.connecting=!1,this.reconnectAttempts=0,t.info(`[${e}] Successfully connected to bridge server`)}),this.socket.on(`data`,n=>{for(this.responseBuffer=Buffer.concat([this.responseBuffer,n]);this.responseBuffer.length>=4;){let n=this.responseBuffer.readUInt32LE(0);if(this.responseBuffer.length<4+n)break;let r=this.responseBuffer.slice(4,4+n);this.responseBuffer=this.responseBuffer.slice(4+n);try{let n=JSON.parse(r.toString(`utf-8`));v(n)?(t.info(`[${e}] Received notification: ${n.method}`),this.notificationHandler&&this.notificationHandler(n)):_(n)?(t.info(`[${e}] Received tool response: ${n}`),this.handleResponse(n)):t.info(`[${e}] Received unknown message: ${n}`)}catch(n){t.info(`[${e}] Failed to parse message:`,m(n))}}}),this.socket.on(`error`,n=>{clearTimeout(r),t.info(`[${e}] Socket error (code: ${n.code}):`,m(n)),this.connected=!1,this.connecting=!1,n.code&&[`ECONNREFUSED`,`ECONNRESET`,`EPIPE`,`ENOENT`,`EOPNOTSUPP`,`ECONNABORTED`].includes(n.code)&&this.scheduleReconnect()}),this.socket.on(`close`,()=>{clearTimeout(r),this.connected=!1,this.connecting=!1,this.scheduleReconnect()})}scheduleReconnect(){let{serverName:e,logger:t}=this.context;if(this.disableAutoReconnect)return;if(this.reconnectTimer){t.info(`[${e}] Reconnect already scheduled, skipping`);return}if(this.reconnectAttempts++,this.reconnectAttempts>100){t.info(`[${e}] Giving up after 100 attempts. Will retry on next tool call.`),this.reconnectAttempts=0;return}let n=Math.min(this.reconnectDelay*1.5**(this.reconnectAttempts-1),3e4);this.reconnectAttempts<=this.maxReconnectAttempts?t.info(`[${e}] Reconnecting in ${Math.round(n)}ms (attempt ${this.reconnectAttempts})`):this.reconnectAttempts%10==0&&t.info(`[${e}] Still polling for native host (attempt ${this.reconnectAttempts})`),this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.connect()},n)}handleResponse(e){if(this.responseCallback){let t=this.responseCallback;this.responseCallback=null,t(e)}}setNotificationHandler(e){this.notificationHandler=e}async ensureConnected(){let{serverName:e}=this.context;return this.connected&&this.socket?!0:(!this.socket&&!this.connecting&&await this.connect(),new Promise((t,n)=>{let r=null,i=setTimeout(()=>{r&&clearTimeout(r),n(new b(`[${e}] Connection attempt timed out after 5000ms`))},5e3),a=()=>{this.connected?(clearTimeout(i),t(!0)):r=setTimeout(a,500)};a()}))}async sendRequest(e,t=3e4){let{serverName:n}=this.context;if(!this.socket)throw new b(`[${n}] Cannot send request: not connected`);let r=this.socket;return new Promise((i,a)=>{let o=setTimeout(()=>{this.responseCallback=null,a(new b(`[${n}] Tool request timed out after ${t}ms`))},t);this.responseCallback=e=>{clearTimeout(o),i(e)};let s=JSON.stringify(e),c=Buffer.from(s,`utf-8`),l=Buffer.allocUnsafe(4);l.writeUInt32LE(c.length,0);let u=Buffer.concat([l,c]);r.write(u)})}async callTool(e,t,n){let r={method:`execute_tool`,params:{client_id:this.context.clientTypeId,tool:e,args:t}};return this.sendRequestWithRetry(r)}async sendRequestWithRetry(e){let{serverName:t,logger:n}=this.context;try{return await this.sendRequest(e)}catch(r){if(!(r instanceof b))throw r;return n.info(`[${t}] Connection error, forcing reconnect and retrying: ${r.message}`),this.closeSocket(),await this.ensureConnected(),await this.sendRequest(e)}}async setPermissionMode(e,t){}isConnected(){return this.connected}closeSocket(){this.socket&&(this.socket.removeAllListeners(),this.socket.end(),this.socket.destroy(),this.socket=null),this.connected=!1,this.connecting=!1}cleanup(){this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.closeSocket(),this.reconnectAttempts=0,this.responseBuffer=Buffer.alloc(0),this.responseCallback=null}disconnect(){this.cleanup()}async validateSocketSecurity(e){let{serverName:t,logger:n}=this.context;if(u()!==`win32`)try{let r=d(e);if((r.split(`/`).pop()||``).startsWith(`claude-mcp-browser-bridge-`))try{let e=await f.stat(r);if(e.isDirectory()){let n=e.mode&511;if(n!==448)throw Error(`[${t}] Insecure socket directory permissions: ${n.toString(8)} (expected 0700). Directory may have been tampered with.`);let r=process.getuid?.();if(r!==void 0&&e.uid!==r)throw Error(`Socket directory not owned by current user (uid: ${r}, dir uid: ${e.uid}). Potential security risk.`)}}catch(e){if(e.code!==`ENOENT`)throw e}let i=await f.stat(e);if(!i.isSocket())throw Error(`[${t}] Path exists but it's not a socket: ${e}`);let a=i.mode&511;if(a!==384)throw Error(`[${t}] Insecure socket permissions: ${a.toString(8)} (expected 0600). Socket may have been tampered with.`);let o=process.getuid?.();if(o!==void 0&&i.uid!==o)throw Error(`Socket not owned by current user (uid: ${o}, socket uid: ${i.uid}). Potential security risk.`);n.info(`[${t}] Socket security validation passed`)}catch(e){if(e.code===`ENOENT`){n.info(`[${t}] Socket not found, will be created by server`);return}throw e}}}}));function C(e){return new E(e)}var w,T,E,D=e((()=>{r(),S(),g(),t(),w=5e3,T=1e4,E=class{constructor(e){n(this,`ws`,null),n(this,`connected`,!1),n(this,`authenticated`,!1),n(this,`connecting`,!1),n(this,`reconnectTimer`,null),n(this,`reconnectAttempts`,0),n(this,`pendingCalls`,new Map),n(this,`notificationHandler`,null),n(this,`context`,void 0),n(this,`permissionMode`,`ask`),n(this,`allowedDomains`,void 0),n(this,`tabsContextCollectionTimeoutMs`,2e3),n(this,`toolCallTimeoutMs`,12e4),n(this,`connectionStartTime`,null),n(this,`connectionEstablishedTime`,null),n(this,`selectedDeviceId`,void 0),n(this,`discoveryComplete`,!1),n(this,`discoveryPromise`,null),n(this,`pendingDiscovery`,null),n(this,`previousSelectedDeviceId`,void 0),n(this,`peerConnectedWaiters`,[]),n(this,`pendingPairingRequestId`,void 0),n(this,`pairingInProgress`,!1),n(this,`persistedDeviceId`,void 0),n(this,`pendingSwitchResolve`,null),this.context=e,e.initialPermissionMode&&(this.permissionMode=e.initialPermissionMode)}async ensureConnected(){let{logger:e,serverName:t}=this.context;return e.info(`[${t}] ensureConnected called, connected=${this.connected}, authenticated=${this.authenticated}, wsState=${this.ws?.readyState}`),this.connected&&this.authenticated&&this.ws?.readyState===i.OPEN?(e.info(`[${t}] Already connected and authenticated`),!0):(this.connecting?e.info(`[${t}] Already connecting, waiting...`):(e.info(`[${t}] Not connecting, starting connection...`),await this.connect()),new Promise(n=>{let r=setTimeout(()=>{e.info(`[${t}] Connection timeout, connected=${this.connected}, authenticated=${this.authenticated}`),n(!1)},1e4),i=()=>{this.connected&&this.authenticated?(e.info(`[${t}] Connection successful`),clearTimeout(r),n(!0)):this.connecting?setTimeout(i,200):(e.info(`[${t}] No longer connecting, giving up`),clearTimeout(r),n(!1))};i()}))}async callTool(e,t,n){let{logger:r,serverName:a,trackEvent:o}=this.context;if(!this.ws||this.ws.readyState!==i.OPEN)throw new b(`[${a}] Bridge not connected`);!this.selectedDeviceId&&!this.discoveryComplete&&(this.discoveryPromise??(this.discoveryPromise=this.discoverAndSelectExtension().finally(()=>{this.discoveryPromise=null})),await this.discoveryPromise);let s=crypto.randomUUID(),c=e===`tabs_context_mcp`,l=Date.now(),u=c?this.tabsContextCollectionTimeoutMs:this.toolCallTimeoutMs;o?.(`chrome_bridge_tool_call_started`,{tool_name:e,tool_use_id:s});let d=n?.permissionMode??this.permissionMode,f=n?.allowedDomains??this.allowedDomains;return new Promise((i,p)=>{let m=setTimeout(()=>{let t=this.pendingCalls.get(s);if(t){this.pendingCalls.delete(s);let n=Date.now()-t.startTime;c&&t.results.length>0?(o?.(`chrome_bridge_tool_call_completed`,{tool_name:e,tool_use_id:s,duration_ms:n}),i(this.mergeTabsResults(t.results))):(r.warn(`[${a}] Tool call timeout: ${e} (${s.slice(0,8)}) after ${n}ms, pending calls: ${this.pendingCalls.size}`),o?.(`chrome_bridge_tool_call_timeout`,{tool_name:e,tool_use_id:s,duration_ms:n,timeout_ms:u}),p(new b(`[${a}] Tool call timed out: ${e}`)))}},u);this.pendingCalls.set(s,{resolve:i,reject:p,timer:m,results:[],isTabsContext:c,onPermissionRequest:n?.onPermissionRequest,startTime:l,toolName:e});let h={type:`tool_call`,tool_use_id:s,client_type:this.context.clientTypeId,tool:e,args:t};this.selectedDeviceId&&(h.target_device_id=this.selectedDeviceId),d&&(h.permission_mode=d),f?.length&&(h.allowed_domains=f),n?.onPermissionRequest&&(h.handle_permission_prompts=!0),r.debug(`[${a}] Sending tool_call: ${e} (${s.slice(0,8)})`),this.ws.send(JSON.stringify(h))})}isConnected(){return this.connected&&this.authenticated&&this.ws?.readyState===i.OPEN}disconnect(){this.cleanup()}setNotificationHandler(e){this.notificationHandler=e}async setPermissionMode(e,t){this.permissionMode=e,this.allowedDomains=t}async discoverAndSelectExtension(){let{logger:e,serverName:t}=this.context;this.persistedDeviceId??(this.persistedDeviceId=this.context.getPersistedDeviceId?.());let n=await this.queryBridgeExtensions();if(n.length===0&&(e.info(`[${t}] No extensions connected, waiting up to ${T}ms for peer_connected`),await this.waitForPeerConnected(T)&&(n=await this.queryBridgeExtensions())),this.discoveryComplete=!0,n.length===0){e.info(`[${t}] No extensions found after waiting`);return}if(n.length===1){let e=n[0];this.isLocalExtension(e)||this.context.onRemoteExtensionWarning?.(e),this.selectExtension(e.deviceId);return}if(this.persistedDeviceId){let r=n.find(e=>e.deviceId===this.persistedDeviceId);if(r){e.info(`[${t}] Auto-connecting to persisted extension: ${r.name||r.deviceId.slice(0,8)}`),this.selectExtension(r.deviceId);return}}this.broadcastPairingRequest(),this.pairingInProgress=!0}async queryBridgeExtensions(){let e=await new Promise(e=>{this.pendingDiscovery={resolve:e,timeout:setTimeout(()=>{this.pendingDiscovery=null,e([])},w)},this.ws?.send(JSON.stringify({type:`list_extensions`}))}),t=new Map;for(let n of e){let e=t.get(n.deviceId);(!e||n.connectedAt>e.connectedAt)&&t.set(n.deviceId,n)}return[...t.values()]}selectExtension(e){let{logger:t,serverName:n}=this.context;this.selectedDeviceId=e,this.previousSelectedDeviceId=void 0,t.info(`[${n}] Selected Chrome extension: ${e.slice(0,8)}...`)}isLocalExtension(e){return e.osPlatform?e.osPlatform===h():!1}waitForPeerConnected(e){return new Promise(t=>{let n=setTimeout(()=>{this.peerConnectedWaiters=this.peerConnectedWaiters.filter(e=>e!==r),t(!1)},e),r=e=>{clearTimeout(n),t(e)};this.peerConnectedWaiters.push(r)})}broadcastPairingRequest(){let e=crypto.randomUUID();this.pendingPairingRequestId=e,this.ws?.send(JSON.stringify({type:`pairing_request`,request_id:e,client_type:this.context.clientTypeId}))}async switchBrowser(){let e=await this.queryBridgeExtensions(),t=this.selectedDeviceId??this.previousSelectedDeviceId;if(e.length===0||e.length===1&&(!t||e[0].deviceId===t))return`no_other_browsers`;this.previousSelectedDeviceId=this.selectedDeviceId,this.selectedDeviceId=void 0,this.discoveryComplete=!1,this.pairingInProgress=!1;let n=crypto.randomUUID();return this.pendingPairingRequestId=n,this.ws?.readyState===i.OPEN?(this.ws.send(JSON.stringify({type:`pairing_request`,request_id:n,client_type:this.context.clientTypeId})),this.pendingSwitchResolve&&this.pendingSwitchResolve(null),new Promise(e=>{let t=setTimeout(()=>{this.pendingPairingRequestId===n&&(this.pendingPairingRequestId=void 0),this.pendingSwitchResolve=null,e(null)},12e4);this.pendingSwitchResolve=n=>{clearTimeout(t),this.pendingSwitchResolve=null,e(n)}})):null}async connect(){let{logger:e,serverName:t,bridgeConfig:n,trackEvent:r}=this.context;if(!n){e.error(`[${t}] No bridge config provided`);return}if(this.connecting)return;this.connecting=!0,this.authenticated=!1,this.connectionStartTime=Date.now(),this.closeSocket();let a,o;if(n.devUserId)a=n.devUserId,e.debug(`[${t}] Using dev user ID for bridge connection`);else{e.debug(`[${t}] Fetching user ID for bridge connection`);let i=await n.getUserId();if(!i){let n=Date.now()-this.connectionStartTime;e.error(`[${t}] No user ID available after ${n}ms`),r?.(`chrome_bridge_connection_failed`,{duration_ms:n,error_type:`no_user_id`,reconnect_attempt:this.reconnectAttempts}),this.connecting=!1,this.context.onAuthenticationError?.();return}if(a=i,e.debug(`[${t}] Fetching OAuth token for bridge connection`),o=await n.getOAuthToken(),!o){let n=Date.now()-this.connectionStartTime;e.error(`[${t}] No OAuth token available after ${n}ms`),r?.(`chrome_bridge_connection_failed`,{duration_ms:n,error_type:`no_oauth_token`,reconnect_attempt:this.reconnectAttempts}),this.connecting=!1,this.context.onAuthenticationError?.();return}}let s=`${n.url}/chrome/${a}`;e.info(`[${t}] Connecting to bridge: ${s}`),r?.(`chrome_bridge_connection_started`,{bridge_url:s});try{this.ws=new i(s)}catch(n){let i=Date.now()-this.connectionStartTime;e.error(`[${t}] Failed to create WebSocket after ${i}ms:`,m(n)),r?.(`chrome_bridge_connection_failed`,{duration_ms:i,error_type:`websocket_error`,reconnect_attempt:this.reconnectAttempts}),this.connecting=!1,this.scheduleReconnect();return}this.ws.on(`open`,()=>{e.info(`[${t}] WebSocket connected, sending connect message`);let r={type:`connect`,client_type:this.context.clientTypeId};n.devUserId?r.dev_user_id=n.devUserId:r.oauth_token=o,this.ws?.send(JSON.stringify(r))}),this.ws.on(`message`,n=>{try{let r=JSON.parse(n.toString());e.debug(`[${t}] Bridge received: ${JSON.stringify(r)}`),this.handleMessage(r)}catch(n){e.error(`[${t}] Failed to parse bridge message:`,m(n))}}),this.ws.on(`close`,n=>{let i=this.connectionEstablishedTime?Date.now()-this.connectionEstablishedTime:0;e.info(`[${t}] Bridge connection closed (code: ${n}, duration: ${i}ms)`),r?.(`chrome_bridge_disconnected`,{close_code:n,duration_since_connect_ms:i,reconnect_attempt:this.reconnectAttempts+1}),this.connected=!1,this.authenticated=!1,this.connecting=!1,this.connectionEstablishedTime=null,this.scheduleReconnect()}),this.ws.on(`error`,n=>{let i=this.connectionStartTime?Date.now()-this.connectionStartTime:0;e.error(`[${t}] Bridge WebSocket error after ${i}ms: ${n.message}`),r?.(`chrome_bridge_connection_failed`,{duration_ms:i,error_type:`websocket_error`,reconnect_attempt:this.reconnectAttempts}),this.connected=!1,this.authenticated=!1,this.connecting=!1})}handleMessage(e){let{logger:t,serverName:n,trackEvent:r}=this.context;switch(e.type){case`paired`:{let e=this.connectionStartTime?Date.now()-this.connectionStartTime:0;t.info(`[${n}] Paired with Chrome extension (duration: ${e}ms)`),this.connected=!0,this.authenticated=!0,this.connecting=!1,this.reconnectAttempts=0,this.connectionEstablishedTime=Date.now(),r?.(`chrome_bridge_connection_succeeded`,{duration_ms:e,status:`paired`});break}case`waiting`:{let e=this.connectionStartTime?Date.now()-this.connectionStartTime:0;t.info(`[${n}] Waiting for Chrome extension to connect (duration: ${e}ms)`),this.connected=!0,this.authenticated=!0,this.connecting=!1,this.reconnectAttempts=0,this.connectionEstablishedTime=Date.now(),r?.(`chrome_bridge_connection_succeeded`,{duration_ms:e,status:`waiting`});break}case`peer_connected`:if(t.info(`[${n}] Chrome extension connected to bridge`),r?.(`chrome_bridge_peer_connected`,null),this.selectedDeviceId||(this.discoveryComplete=!1),this.previousSelectedDeviceId&&e.deviceId===this.previousSelectedDeviceId&&!this.pendingSwitchResolve&&(t.info(`[${n}] Previously selected extension reconnected, auto-reselecting`),this.selectExtension(this.previousSelectedDeviceId),this.previousSelectedDeviceId=void 0),this.peerConnectedWaiters.length>0){let e=this.peerConnectedWaiters;this.peerConnectedWaiters=[];for(let t of e)t(!0)}break;case`peer_disconnected`:t.info(`[${n}] Chrome extension disconnected from bridge`),r?.(`chrome_bridge_peer_disconnected`,null),e.deviceId&&e.deviceId===this.selectedDeviceId&&(t.info(`[${n}] Selected extension disconnected, clearing selection`),this.previousSelectedDeviceId=this.selectedDeviceId,this.selectedDeviceId=void 0,this.discoveryComplete=!1);break;case`extensions_list`:this.pendingDiscovery&&(clearTimeout(this.pendingDiscovery.timeout),this.pendingDiscovery.resolve(e.extensions??[]),this.pendingDiscovery=null);break;case`pairing_response`:{let r=e.request_id,i=e.device_id,a=e.name;this.pendingPairingRequestId===r&&i&&a&&(this.pendingPairingRequestId=void 0,this.pairingInProgress=!1,this.selectExtension(i),this.context.onExtensionPaired?.(i,a),t.info(`[${n}] Paired with "${a}" (${i.slice(0,8)})`),this.pendingSwitchResolve&&(this.pendingSwitchResolve({deviceId:i,name:a}),this.pendingSwitchResolve=null));break}case`ping`:this.ws?.send(JSON.stringify({type:`pong`}));break;case`pong`:break;case`tool_result`:this.handleToolResult(e);break;case`permission_request`:this.handlePermissionRequest(e);break;case`notification`:this.notificationHandler&&this.notificationHandler({method:e.method,params:e.params});break;case`error`:t.warn(`[${n}] Bridge error: ${e.error}`),this.selectedDeviceId&&(this.selectedDeviceId=void 0,this.discoveryComplete=!1);break;default:t.warn(`[${n}] Unrecognized bridge message type: ${e.type}`)}}async handlePermissionRequest(e){let{logger:t,serverName:n}=this.context,r=e.tool_use_id,i=e.request_id;if(!r||!i){t.warn(`[${n}] permission_request missing tool_use_id or request_id`);return}let a=this.pendingCalls.get(r);if(!a?.onPermissionRequest){t.debug(`[${n}] Ignoring permission_request for unknown tool_use_id ${r.slice(0,8)} (not our call)`);return}let o={toolUseId:r,requestId:i,toolType:e.tool_type??`unknown`,url:e.url??``,actionData:e.action_data};try{let e=await a.onPermissionRequest(o);this.sendPermissionResponse(i,e)}catch(e){t.error(`[${n}] Error handling permission request:`,m(e)),this.sendPermissionResponse(i,!1)}}sendPermissionResponse(e,t){if(this.ws?.readyState===i.OPEN){let n={type:`permission_response`,request_id:e,allowed:t};this.selectedDeviceId&&(n.target_device_id=this.selectedDeviceId),this.ws.send(JSON.stringify(n))}}handleToolResult(e){let{logger:t,serverName:n,trackEvent:r}=this.context,i=e.tool_use_id;if(!i){t.warn(`[${n}] Received tool_result without tool_use_id`);return}let a=this.pendingCalls.get(i);if(!a){t.debug(`[${n}] Received tool_result for unknown call: ${i.slice(0,8)}`);return}let o=Date.now()-a.startTime,s=this.normalizeBridgeResponse(e),c=!!e.is_error||`error`in s;if(a.isTabsContext&&!this.selectedDeviceId)a.results.push(s);else{if(clearTimeout(a.timer),this.pendingCalls.delete(i),c){let e=s.error?.content,c=`Unknown error`;if(Array.isArray(e)){let t=e.find(e=>typeof e==`object`&&!!e&&`text`in e);t?.text&&(c=t.text.slice(0,200))}t.warn(`[${n}] Tool call error: ${a.toolName} (${i.slice(0,8)}) after ${o}ms`),r?.(`chrome_bridge_tool_call_error`,{tool_name:a.toolName,tool_use_id:i,duration_ms:o,error_message:c})}else t.debug(`[${n}] Tool call completed: ${a.toolName} (${i.slice(0,8)}) in ${o}ms`),r?.(`chrome_bridge_tool_call_completed`,{tool_name:a.toolName,tool_use_id:i,duration_ms:o});a.resolve(s)}}normalizeBridgeResponse(e){return e.result||e.error?e:e.content?e.is_error?{error:{content:e.content}}:{result:{content:e.content}}:e}mergeTabsResults(e){let t=[];for(let n of e){let e=n.result?.content;if(!(!e||!Array.isArray(e))){for(let n of e)if(n.type===`text`&&n.text)try{let e=JSON.parse(n.text);Array.isArray(e)?t.push(...e):e?.availableTabs&&Array.isArray(e.availableTabs)&&t.push(...e.availableTabs)}catch{}}}if(t.length>0){let e=t.map(e=>{let t=e;return` \u2022 tabId ${t.tabId}: "${t.title}" (${t.url})`}).join(`
2
+ `);return{result:{content:[{type:`text`,text:JSON.stringify({availableTabs:t})},{type:`text`,text:`\n\nTab Context:\n- Available tabs:\n${e}`}]}}}return e[0]}scheduleReconnect(){let{logger:e,serverName:t,trackEvent:n}=this.context;if(this.reconnectTimer)return;if(this.reconnectAttempts++,this.reconnectAttempts>100){e.warn(`[${t}] Giving up bridge reconnection after 100 attempts`),n?.(`chrome_bridge_reconnect_exhausted`,{total_attempts:100}),this.reconnectAttempts=0;return}let r=Math.min(2e3*1.5**(this.reconnectAttempts-1),3e4);(this.reconnectAttempts<=10||this.reconnectAttempts%10==0)&&e.info(`[${t}] Bridge reconnecting in ${Math.round(r)}ms (attempt ${this.reconnectAttempts})`),this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.connect()},r)}closeSocket(){if(this.ws&&(this.ws.removeAllListeners(),this.ws.close(),this.ws=null),this.connected=!1,this.authenticated=!1,this.selectedDeviceId=void 0,this.discoveryComplete=!1,this.pendingPairingRequestId=void 0,this.pairingInProgress=!1,this.pendingSwitchResolve&&(this.pendingSwitchResolve(null),this.pendingSwitchResolve=null),this.pendingDiscovery&&(clearTimeout(this.pendingDiscovery.timeout),this.pendingDiscovery.resolve([]),this.pendingDiscovery=null),this.peerConnectedWaiters.length>0){let e=this.peerConnectedWaiters;this.peerConnectedWaiters=[];for(let t of e)t(!1)}}cleanup(){this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null);for(let[e,t]of this.pendingCalls)clearTimeout(t.timer),t.reject(new b(`Bridge client disconnected`)),this.pendingCalls.delete(e);this.closeSocket(),this.reconnectAttempts=0}}})),O,k=e((()=>{O=[{name:`javascript_tool`,description:`Execute JavaScript code in the context of the current page. The code runs in the page's context and can interact with the DOM, window object, and page variables. Returns the result of the last expression or any thrown errors. If you don't have a valid tab ID, use tabs_context_mcp first to get available tabs.`,inputSchema:{type:`object`,properties:{action:{type:`string`,description:`Must be set to 'javascript_exec'`},text:{type:`string`,description:`The JavaScript code to execute. The code will be evaluated in the page context. The result of the last expression will be returned automatically. Do NOT use 'return' statements - just write the expression you want to evaluate (e.g., 'window.myData.value' not 'return window.myData.value'). You can access and modify the DOM, call page functions, and interact with page variables.`},tabId:{type:`number`,description:`Tab ID to execute the code in. Must be a tab in the current group. Use tabs_context_mcp first if you don't have a valid tab ID.`}},required:[`action`,`text`,`tabId`]}},{name:`read_page`,description:`Get an accessibility tree representation of elements on the page. By default returns all elements including non-visible ones. Output is limited to 50000 characters by default. If the output exceeds this limit, you will receive an error asking you to specify a smaller depth or focus on a specific element using ref_id. Optionally filter for only interactive elements. If you don't have a valid tab ID, use tabs_context_mcp first to get available tabs.`,inputSchema:{type:`object`,properties:{filter:{type:`string`,enum:[`interactive`,`all`],description:`Filter elements: "interactive" for buttons/links/inputs only, "all" for all elements including non-visible ones (default: all elements)`},tabId:{type:`number`,description:`Tab ID to read from. Must be a tab in the current group. Use tabs_context_mcp first if you don't have a valid tab ID.`},depth:{type:`number`,description:`Maximum depth of the tree to traverse (default: 15). Use a smaller depth if output is too large.`},ref_id:{type:`string`,description:`Reference ID of a parent element to read. Will return the specified element and all its children. Use this to focus on a specific part of the page when output is too large.`},max_chars:{type:`number`,description:`Maximum characters for output (default: 50000). Set to a higher value if your client can handle large outputs.`}},required:[`tabId`]}},{name:`find`,description:`Find elements on the page using natural language. Can search for elements by their purpose (e.g., "search bar", "login button") or by text content (e.g., "organic mango product"). Returns up to 20 matching elements with references that can be used with other tools. If more than 20 matches exist, you'll be notified to use a more specific query. If you don't have a valid tab ID, use tabs_context_mcp first to get available tabs.`,inputSchema:{type:`object`,properties:{query:{type:`string`,description:`Natural language description of what to find (e.g., "search bar", "add to cart button", "product title containing organic")`},tabId:{type:`number`,description:`Tab ID to search in. Must be a tab in the current group. Use tabs_context_mcp first if you don't have a valid tab ID.`}},required:[`query`,`tabId`]}},{name:`form_input`,description:`Set values in form elements using element reference ID from the read_page tool. If you don't have a valid tab ID, use tabs_context_mcp first to get available tabs.`,inputSchema:{type:`object`,properties:{ref:{type:`string`,description:`Element reference ID from the read_page tool (e.g., "ref_1", "ref_2")`},value:{type:[`string`,`boolean`,`number`],description:`The value to set. For checkboxes use boolean, for selects use option value or text, for other inputs use appropriate string/number`},tabId:{type:`number`,description:`Tab ID to set form value in. Must be a tab in the current group. Use tabs_context_mcp first if you don't have a valid tab ID.`}},required:[`ref`,`value`,`tabId`]}},{name:`computer`,description:`Use a mouse and keyboard to interact with a web browser, and take screenshots. If you don't have a valid tab ID, use tabs_context_mcp first to get available tabs.
3
+ * Whenever you intend to click on an element like an icon, you should consult a screenshot to determine the coordinates of the element before moving the cursor.
4
+ * If you tried clicking on a program or link but it failed to load, even after waiting, try adjusting your click location so that the tip of the cursor visually falls on the element that you want to click.
5
+ * Make sure to click any buttons, links, icons, etc with the cursor tip in the center of the element. Don't click boxes on their edges unless asked.`,inputSchema:{type:`object`,properties:{action:{type:`string`,enum:[`left_click`,`right_click`,`type`,`screenshot`,`wait`,`scroll`,`key`,`left_click_drag`,`double_click`,`triple_click`,`zoom`,`scroll_to`,`hover`],description:"The action to perform:\n* `left_click`: Click the left mouse button at the specified coordinates.\n* `right_click`: Click the right mouse button at the specified coordinates to open context menus.\n* `double_click`: Double-click the left mouse button at the specified coordinates.\n* `triple_click`: Triple-click the left mouse button at the specified coordinates.\n* `type`: Type a string of text.\n* `screenshot`: Take a screenshot of the screen.\n* `wait`: Wait for a specified number of seconds.\n* `scroll`: Scroll up, down, left, or right at the specified coordinates.\n* `key`: Press a specific keyboard key.\n* `left_click_drag`: Drag from start_coordinate to coordinate.\n* `zoom`: Take a screenshot of a specific region for closer inspection.\n* `scroll_to`: Scroll an element into view using its element reference ID from read_page or find tools.\n* `hover`: Move the mouse cursor to the specified coordinates or element without clicking. Useful for revealing tooltips, dropdown menus, or triggering hover states."},coordinate:{type:`array`,items:{type:`number`},minItems:2,maxItems:2,description:"(x, y): The x (pixels from the left edge) and y (pixels from the top edge) coordinates. Required for `left_click`, `right_click`, `double_click`, `triple_click`, and `scroll`. For `left_click_drag`, this is the end position."},text:{type:`string`,description:'The text to type (for `type` action) or the key(s) to press (for `key` action). For `key` action: Provide space-separated keys (e.g., "Backspace Backspace Delete"). Supports keyboard shortcuts using the platform\'s modifier key (use "cmd" on Mac, "ctrl" on Windows/Linux, e.g., "cmd+a" or "ctrl+a" for select all).'},duration:{type:`number`,minimum:0,maximum:30,description:"The number of seconds to wait. Required for `wait`. Maximum 30 seconds."},scroll_direction:{type:`string`,enum:[`up`,`down`,`left`,`right`],description:"The direction to scroll. Required for `scroll`."},scroll_amount:{type:`number`,minimum:1,maximum:10,description:"The number of scroll wheel ticks. Optional for `scroll`, defaults to 3."},start_coordinate:{type:`array`,items:{type:`number`},minItems:2,maxItems:2,description:"(x, y): The starting coordinates for `left_click_drag`."},region:{type:`array`,items:{type:`number`},minItems:4,maxItems:4,description:"(x0, y0, x1, y1): The rectangular region to capture for `zoom`. Coordinates define a rectangle from top-left (x0, y0) to bottom-right (x1, y1) in pixels from the viewport origin. Required for `zoom` action. Useful for inspecting small UI elements like icons, buttons, or text."},repeat:{type:`number`,minimum:1,maximum:100,description:"Number of times to repeat the key sequence. Only applicable for `key` action. Must be a positive integer between 1 and 100. Default is 1. Useful for navigation tasks like pressing arrow keys multiple times."},ref:{type:`string`,description:'Element reference ID from read_page or find tools (e.g., "ref_1", "ref_2"). Required for `scroll_to` action. Can be used as alternative to `coordinate` for click actions.'},modifiers:{type:`string`,description:`Modifier keys for click actions. Supports: "ctrl", "shift", "alt", "cmd" (or "meta"), "win" (or "windows"). Can be combined with "+" (e.g., "ctrl+shift", "cmd+alt"). Optional.`},tabId:{type:`number`,description:`Tab ID to execute the action on. Must be a tab in the current group. Use tabs_context_mcp first if you don't have a valid tab ID.`}},required:[`action`,`tabId`]}},{name:`navigate`,description:`Navigate to a URL, or go forward/back in browser history. If you don't have a valid tab ID, use tabs_context_mcp first to get available tabs.`,inputSchema:{type:`object`,properties:{url:{type:`string`,description:`The URL to navigate to. Can be provided with or without protocol (defaults to https://). Use "forward" to go forward in history or "back" to go back in history.`},tabId:{type:`number`,description:`Tab ID to navigate. Must be a tab in the current group. Use tabs_context_mcp first if you don't have a valid tab ID.`}},required:[`url`,`tabId`]}},{name:`resize_window`,description:`Resize the current browser window to specified dimensions. Useful for testing responsive designs or setting up specific screen sizes. If you don't have a valid tab ID, use tabs_context_mcp first to get available tabs.`,inputSchema:{type:`object`,properties:{width:{type:`number`,description:`Target window width in pixels`},height:{type:`number`,description:`Target window height in pixels`},tabId:{type:`number`,description:`Tab ID to get the window for. Must be a tab in the current group. Use tabs_context_mcp first if you don't have a valid tab ID.`}},required:[`width`,`height`,`tabId`]}},{name:`gif_creator`,description:`Manage GIF recording and export for browser automation sessions. Control when to start/stop recording browser actions (clicks, scrolls, navigation), then export as an animated GIF with visual overlays (click indicators, action labels, progress bar, watermark). All operations are scoped to the tab's group. When starting recording, take a screenshot immediately after to capture the initial state as the first frame. When stopping recording, take a screenshot immediately before to capture the final state as the last frame. For export, either provide 'coordinate' to drag/drop upload to a page element, or set 'download: true' to download the GIF.`,inputSchema:{type:`object`,properties:{action:{type:`string`,enum:[`start_recording`,`stop_recording`,`export`,`clear`],description:`Action to perform: 'start_recording' (begin capturing), 'stop_recording' (stop capturing but keep frames), 'export' (generate and export GIF), 'clear' (discard frames)`},tabId:{type:`number`,description:`Tab ID to identify which tab group this operation applies to`},download:{type:`boolean`,description:`Always set this to true for the 'export' action only. This causes the gif to be downloaded in the browser.`},filename:{type:`string`,description:`Optional filename for exported GIF (default: 'recording-[timestamp].gif'). For 'export' action only.`},options:{type:`object`,description:`Optional GIF enhancement options for 'export' action. Properties: showClickIndicators (bool), showDragPaths (bool), showActionLabels (bool), showProgressBar (bool), showWatermark (bool), quality (number 1-30). All default to true except quality (default: 10).`,properties:{showClickIndicators:{type:`boolean`,description:`Show orange circles at click locations (default: true)`},showDragPaths:{type:`boolean`,description:`Show red arrows for drag actions (default: true)`},showActionLabels:{type:`boolean`,description:`Show black labels describing actions (default: true)`},showProgressBar:{type:`boolean`,description:`Show orange progress bar at bottom (default: true)`},showWatermark:{type:`boolean`,description:`Show Claude logo watermark (default: true)`},quality:{type:`number`,description:`GIF compression quality, 1-30 (lower = better quality, slower encoding). Default: 10`}}}},required:[`action`,`tabId`]}},{name:`upload_image`,description:`Upload a previously captured screenshot or user-uploaded image to a file input or drag & drop target. Supports two approaches: (1) ref - for targeting specific elements, especially hidden file inputs, (2) coordinate - for drag & drop to visible locations like Google Docs. Provide either ref or coordinate, not both.`,inputSchema:{type:`object`,properties:{imageId:{type:`string`,description:`ID of a previously captured screenshot (from the computer tool's screenshot action) or a user-uploaded image`},ref:{type:`string`,description:`Element reference ID from read_page or find tools (e.g., "ref_1", "ref_2"). Use this for file inputs (especially hidden ones) or specific elements. Provide either ref or coordinate, not both.`},coordinate:{type:`array`,items:{type:`number`},description:`Viewport coordinates [x, y] for drag & drop to a visible location. Use this for drag & drop targets like Google Docs. Provide either ref or coordinate, not both.`},tabId:{type:`number`,description:`Tab ID where the target element is located. This is where the image will be uploaded to.`},filename:{type:`string`,description:`Optional filename for the uploaded file (default: "image.png")`}},required:[`imageId`,`tabId`]}},{name:`get_page_text`,description:`Extract raw text content from the page, prioritizing article content. Ideal for reading articles, blog posts, or other text-heavy pages. Returns plain text without HTML formatting. If you don't have a valid tab ID, use tabs_context_mcp first to get available tabs.`,inputSchema:{type:`object`,properties:{tabId:{type:`number`,description:`Tab ID to extract text from. Must be a tab in the current group. Use tabs_context_mcp first if you don't have a valid tab ID.`}},required:[`tabId`]}},{name:`tabs_context_mcp`,title:`Tabs Context`,description:`Get context information about the current MCP tab group. Returns all tab IDs inside the group if it exists. CRITICAL: You must get the context at least once before using other browser automation tools so you know what tabs exist. Each new conversation should create its own new tab (using tabs_create_mcp) rather than reusing existing tabs, unless the user explicitly asks to use an existing tab.`,inputSchema:{type:`object`,properties:{createIfEmpty:{type:`boolean`,description:`Creates a new MCP tab group if none exists, creates a new Window with a new tab group containing an empty tab (which can be used for this conversation). If a MCP tab group already exists, this parameter has no effect.`}},required:[]}},{name:`tabs_create_mcp`,title:`Tabs Create`,description:`Creates a new empty tab in the MCP tab group. CRITICAL: You must get the context using tabs_context_mcp at least once before using other browser automation tools so you know what tabs exist.`,inputSchema:{type:`object`,properties:{},required:[]}},{name:`update_plan`,description:`Present a plan to the user for approval before taking actions. The user will see the domains you intend to visit and your approach. Once approved, you can proceed with actions on the approved domains without additional permission prompts.`,inputSchema:{type:`object`,properties:{domains:{type:`array`,items:{type:`string`},description:`List of domains you will visit (e.g., ['github.com', 'stackoverflow.com']). These domains will be approved for the session when the user accepts the plan.`},approach:{type:`array`,items:{type:`string`},description:`High-level description of what you will do. Focus on outcomes and key actions, not implementation details. Be concise - aim for 3-7 items.`}},required:[`domains`,`approach`]}},{name:`read_console_messages`,description:`Read browser console messages (console.log, console.error, console.warn, etc.) from a specific tab. Useful for debugging JavaScript errors, viewing application logs, or understanding what's happening in the browser console. Returns console messages from the current domain only. If you don't have a valid tab ID, use tabs_context_mcp first to get available tabs. IMPORTANT: Always provide a pattern to filter messages - without a pattern, you may get too many irrelevant messages.`,inputSchema:{type:`object`,properties:{tabId:{type:`number`,description:`Tab ID to read console messages from. Must be a tab in the current group. Use tabs_context_mcp first if you don't have a valid tab ID.`},onlyErrors:{type:`boolean`,description:`If true, only return error and exception messages. Default is false (return all message types).`},clear:{type:`boolean`,description:`If true, clear the console messages after reading to avoid duplicates on subsequent calls. Default is false.`},pattern:{type:`string`,description:`Regex pattern to filter console messages. Only messages matching this pattern will be returned (e.g., 'error|warning' to find errors and warnings, 'MyApp' to filter app-specific logs). You should always provide a pattern to avoid getting too many irrelevant messages.`},limit:{type:`number`,description:`Maximum number of messages to return. Defaults to 100. Increase only if you need more results.`}},required:[`tabId`]}},{name:`read_network_requests`,description:`Read HTTP network requests (XHR, Fetch, documents, images, etc.) from a specific tab. Useful for debugging API calls, monitoring network activity, or understanding what requests a page is making. Returns all network requests made by the current page, including cross-origin requests. Requests are automatically cleared when the page navigates to a different domain. If you don't have a valid tab ID, use tabs_context_mcp first to get available tabs.`,inputSchema:{type:`object`,properties:{tabId:{type:`number`,description:`Tab ID to read network requests from. Must be a tab in the current group. Use tabs_context_mcp first if you don't have a valid tab ID.`},urlPattern:{type:`string`,description:`Optional URL pattern to filter requests. Only requests whose URL contains this string will be returned (e.g., '/api/' to filter API calls, 'example.com' to filter by domain).`},clear:{type:`boolean`,description:`If true, clear the network requests after reading to avoid duplicates on subsequent calls. Default is false.`},limit:{type:`number`,description:`Maximum number of requests to return. Defaults to 100. Increase only if you need more results.`}},required:[`tabId`]}},{name:`shortcuts_list`,description:`List all available shortcuts and workflows (shortcuts and workflows are interchangeable). Returns shortcuts with their commands, descriptions, and whether they are workflows. Use shortcuts_execute to run a shortcut or workflow.`,inputSchema:{type:`object`,properties:{tabId:{type:`number`,description:`Tab ID to list shortcuts from. Must be a tab in the current group. Use tabs_context_mcp first if you don't have a valid tab ID.`}},required:[`tabId`]}},{name:`shortcuts_execute`,description:`Execute a shortcut or workflow by running it in a new sidepanel window using the current tab (shortcuts and workflows are interchangeable). Use shortcuts_list first to see available shortcuts. This starts the execution and returns immediately - it does not wait for completion.`,inputSchema:{type:`object`,properties:{tabId:{type:`number`,description:`Tab ID to execute the shortcut on. Must be a tab in the current group. Use tabs_context_mcp first if you don't have a valid tab ID.`},shortcutId:{type:`string`,description:`The ID of the shortcut to execute`},command:{type:`string`,description:`The command name of the shortcut to execute (e.g., 'debug', 'summarize'). Do not include the leading slash.`}},required:[`tabId`]}},{name:`switch_browser`,description:`Switch which Chrome browser is used for browser automation. Call this when the user wants to connect to a different Chrome browser. Broadcasts a connection request to all Chrome browsers with the extension installed — the user clicks 'Connect' in the desired browser.`,inputSchema:{type:`object`,properties:{},required:[]}}]}));function A(e){return new j(e)}var j,M=e((()=>{S(),t(),j=class{constructor(e){n(this,`clients`,new Map),n(this,`tabRoutes`,new Map),n(this,`context`,void 0),n(this,`notificationHandler`,null),this.context=e}setNotificationHandler(e){this.notificationHandler=e;for(let t of this.clients.values())t.setNotificationHandler(e)}async ensureConnected(){let{logger:e,serverName:t}=this.context;this.refreshClients();let n=[];for(let e of this.clients.values())e.isConnected()||n.push(e.ensureConnected().catch(()=>!1));n.length>0&&await Promise.all(n);let r=this.getConnectedClients().length;return r===0?(e.info(`[${t}] No connected sockets in pool`),!1):(e.info(`[${t}] Socket pool: ${r} connected`),!0)}async callTool(e,t,n){if(e===`tabs_context_mcp`)return this.callTabsContext(t);let r=t.tabId;if(r!==void 0){let n=this.tabRoutes.get(r);if(n){let r=this.clients.get(n);if(r?.isConnected())return r.callTool(e,t)}}let i=this.getConnectedClients();if(i.length===0)throw new b(`[${this.context.serverName}] No connected sockets available`);return i[0].callTool(e,t)}async setPermissionMode(e,t){let n=this.getConnectedClients();await Promise.all(n.map(n=>n.setPermissionMode(e,t)))}isConnected(){return this.getConnectedClients().length>0}disconnect(){for(let e of this.clients.values())e.disconnect();this.clients.clear(),this.tabRoutes.clear()}getConnectedClients(){return[...this.clients.values()].filter(e=>e.isConnected())}async callTabsContext(e){let{logger:t,serverName:n}=this.context,r=this.getConnectedClients();if(r.length===0)throw new b(`[${n}] No connected sockets available`);if(r.length===1){let t=await r[0].callTool(`tabs_context_mcp`,e);return this.updateTabRoutes(t,this.getSocketPathForClient(r[0])),t}let i=await Promise.allSettled(r.map(async t=>({result:await t.callTool(`tabs_context_mcp`,e),socketPath:this.getSocketPathForClient(t)}))),a=[];this.tabRoutes.clear();for(let e of i){if(e.status!==`fulfilled`){t.info(`[${n}] tabs_context_mcp failed on one socket: ${e.reason}`);continue}let{result:r,socketPath:i}=e.value;this.updateTabRoutes(r,i);let o=this.extractTabs(r);o&&a.push(...o)}if(a.length>0){let e=a.map(e=>{let t=e;return` • tabId ${t.tabId}: "${t.title}" (${t.url})`}).join(`
6
+ `);return{result:{content:[{type:`text`,text:JSON.stringify({availableTabs:a})},{type:`text`,text:`\n\nTab Context:\n- Available tabs:\n${e}`}]}}}for(let e of i)if(e.status===`fulfilled`)return e.value.result;throw new b(`[${n}] All sockets failed for tabs_context_mcp`)}updateTabRoutes(e,t){let n=this.extractTabs(e);if(n){for(let e of n)if(typeof e==`object`&&e&&`tabId`in e){let n=e.tabId;this.tabRoutes.set(n,t)}}}extractTabs(e){if(!e||typeof e!=`object`)return null;let t=e.result?.content;if(!t||!Array.isArray(t))return null;for(let e of t)if(e.type===`text`&&e.text)try{let t=JSON.parse(e.text);if(Array.isArray(t))return t;if(t&&Array.isArray(t.availableTabs))return t.availableTabs}catch{}return null}getSocketPathForClient(e){for(let[t,n]of this.clients.entries())if(n===e)return t;return``}refreshClients(){let e=this.getAvailableSocketPaths(),{logger:t,serverName:n}=this.context;for(let r of e)if(!this.clients.has(r)){t.info(`[${n}] Adding socket to pool: ${r}`);let e=y({...this.context,socketPath:r,getSocketPath:void 0,getSocketPaths:void 0});e.disableAutoReconnect=!0,this.notificationHandler&&e.setNotificationHandler(this.notificationHandler),this.clients.set(r,e)}for(let[r,i]of this.clients.entries())if(!e.includes(r)){t.info(`[${n}] Removing stale socket from pool: ${r}`),i.disconnect(),this.clients.delete(r);for(let[e,t]of this.tabRoutes.entries())t===r&&this.tabRoutes.delete(e)}}getAvailableSocketPaths(){return this.context.getSocketPaths?.()??[]}}}));async function N(e,t,n,r,i){let a=await t.callTool(n,r,i);if(e.logger.silly(`[${e.serverName}] Received result from socket bridge: ${JSON.stringify(a)}`),a==null)return{content:[{type:`text`,text:`Tool execution completed`}]};let{result:o,error:s}=a,c=s||o,l=!!s;if(!c)return{content:[{type:`text`,text:`Tool execution completed`}]};l&&L(c.content)&&e.onAuthenticationError();let{content:u}=c;return u&&Array.isArray(u)?l?{content:u.map(e=>typeof e==`object`&&e&&`type`in e?e:{type:`text`,text:String(e)}),isError:!0}:{content:u.map(e=>{if(typeof e==`object`&&e&&`type`in e&&`source`in e){let t=e;if(t.type===`image`&&typeof t.source==`object`&&t.source!==null&&`data`in t.source)return{type:`image`,data:t.source.data,mimeType:`media_type`in t.source&&t.source.media_type||`image/png`}}return typeof e==`object`&&e&&`type`in e?e:{type:`text`,text:String(e)}}),isError:l}:typeof u==`string`?{content:[{type:`text`,text:u}],isError:l}:(e.logger.warn(`[${e.serverName}] Unexpected result format from socket bridge: ${JSON.stringify(a)}`),{content:[{type:`text`,text:JSON.stringify(a)}],isError:l})}function P(e){return{content:[{type:`text`,text:e.onToolCallDisconnected()}]}}async function F(e,t){let n=[`ask`,`skip_all_permission_checks`,`follow_a_plan`],r=t.mode,i=r&&n.includes(r)?r:`ask`;return e.setPermissionMode&&await e.setPermissionMode(i,t.allowed_domains),{content:[{type:`text`,text:`Permission mode set to: ${i}`}]}}async function I(e,t){if(!e.bridgeConfig)return{content:[{type:`text`,text:`Browser switching is only available with bridge connections.`}],isError:!0};if(!await t.ensureConnected())return P(e);let n=await t.switchBrowser?.()??null;return n===`no_other_browsers`?{content:[{type:`text`,text:`No other browsers available to switch to. Open Chrome with the Claude extension in another browser to switch.`}],isError:!0}:n?{content:[{type:`text`,text:`Connected to browser "${n.name}".`}]}:{content:[{type:`text`,text:`No browser responded within the timeout. Make sure Chrome is open with the Claude extension installed, then try again.`}],isError:!0}}function L(e){return(Array.isArray(e)?e.map(e=>typeof e==`string`?e:typeof e==`object`&&e&&`text`in e&&typeof e.text==`string`?e.text:``).join(` `):String(e)).toLowerCase().includes(`re-authenticated`)}var R,z=e((()=>{S(),g(),R=async(e,t,n,r,i)=>{if(n===`set_permission_mode`)return F(t,r);if(n===`switch_browser`)return I(e,t);try{let a=await t.ensureConnected();return e.logger.silly(`[${e.serverName}] Server is connected: ${a}. Received tool call: ${n} with args: ${JSON.stringify(r)}.`),a?await N(e,t,n,r,i):P(e)}catch(t){return e.logger.info(`[${e.serverName}] Error calling tool:`,m(t)),t instanceof b?P(e):{content:[{type:`text`,text:`Error calling tool, please try again. : ${t instanceof Error?t.message:String(t)}`}],isError:!0}}}}));function B(e){return e.bridgeConfig?C(e):e.getSocketPaths?A(e):y(e)}function V(e,t){let{serverName:n,logger:r}=e,i=t??B(e),a=new l({name:n,version:`1.0.0`},{capabilities:{tools:{},logging:{}}});return a.setRequestHandler(o,async()=>e.isDisabled?.()?{tools:[]}:{tools:e.bridgeConfig?O:O.filter(e=>e.name!==`switch_browser`)}),a.setRequestHandler(s,async t=>(r.info(`[${n}] Executing tool: ${t.params.name}`),R(e,i,t.params.name,t.params.arguments||{}))),i.setNotificationHandler(e=>{r.info(`[${n}] Forwarding MCP notification: ${e.method}`),a.notification({method:e.method,params:e.params}).catch(e=>{r.info(`[${n}] Failed to forward MCP notification: ${e.message}`)})}),a}var H=e((()=>{c(),a(),D(),k(),S(),M(),z()})),U=e((()=>{D(),k(),H(),g()}));export{E as a,m as c,O as i,B as n,C as o,V as r,h as s,U as t};
@@ -0,0 +1 @@
1
+ var e=2048;async function t(e){return n()}function n(){for(let e of[`CLAUDE_CODE_URL_EVENT`,`CLAUDE_CODE_DEEP_LINK_URL`,`CLAUDE_CODE_URL`]){let t=process.env[e];if(r(t))return t}return process.argv.find(r)??null}function r(t){return typeof t==`string`&&t.length<=e&&(t.startsWith(`claude-cli://`)||t.startsWith(`claude://`))}export{t as waitForUrlEvent};
@@ -0,0 +1 @@
1
+ import{a as e,t}from"./chunk-DR8-3Aex.js";import{n,t as r}from"./esm-vIn-YV_h.js";import{t as i}from"./src-C5yhFG0C.js";import{n as a,t as o}from"./esm-DhNYgGTV.js";var s=t((t=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.OTLPMetricExporter=void 0;var s=(a(),e(o)),c=i(),l=(n(),e(r));t.OTLPMetricExporter=class extends s.OTLPMetricExporterBase{constructor(e){super((0,c.createOtlpGrpcExportDelegate)((0,c.convertLegacyOtlpGrpcOptions)(e??{},`METRICS`),l.ProtobufMetricsSerializer,`MetricsExportService`,`/opentelemetry.proto.collector.metrics.v1.MetricsService/Export`),e)}}})),c=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.OTLPMetricExporter=void 0;var t=s();Object.defineProperty(e,`OTLPMetricExporter`,{enumerable:!0,get:function(){return t.OTLPMetricExporter}})}));export default c();export{};
@@ -0,0 +1,5 @@
1
+ import{a as e,i as t,t as n}from"./chunk-DR8-3Aex.js";import{n as r,r as i}from"./supports-color-lkzOMQ6u.js";var a=n(((e,t)=>{var n=1e3,r=n*60,i=r*60,a=i*24,o=a*7,s=a*365.25;t.exports=function(e,t){t=t||{};var n=typeof e;if(n===`string`&&e.length>0)return c(e);if(n===`number`&&isFinite(e))return t.long?u(e):l(e);throw Error(`val is not a non-empty string or a valid number. val=`+JSON.stringify(e))};function c(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var c=parseFloat(t[1]);switch((t[2]||`ms`).toLowerCase()){case`years`:case`year`:case`yrs`:case`yr`:case`y`:return c*s;case`weeks`:case`week`:case`w`:return c*o;case`days`:case`day`:case`d`:return c*a;case`hours`:case`hour`:case`hrs`:case`hr`:case`h`:return c*i;case`minutes`:case`minute`:case`mins`:case`min`:case`m`:return c*r;case`seconds`:case`second`:case`secs`:case`sec`:case`s`:return c*n;case`milliseconds`:case`millisecond`:case`msecs`:case`msec`:case`ms`:return c;default:return}}}}function l(e){var t=Math.abs(e);return t>=a?Math.round(e/a)+`d`:t>=i?Math.round(e/i)+`h`:t>=r?Math.round(e/r)+`m`:t>=n?Math.round(e/n)+`s`:e+`ms`}function u(e){var t=Math.abs(e);return t>=a?d(e,t,a,`day`):t>=i?d(e,t,i,`hour`):t>=r?d(e,t,r,`minute`):t>=n?d(e,t,n,`second`):e+` ms`}function d(e,t,n,r){var i=t>=n*1.5;return Math.round(e/n)+` `+r+(i?`s`:``)}})),o=n(((e,t)=>{function n(e){n.debug=n,n.default=n,n.coerce=l,n.disable=s,n.enable=i,n.enabled=c,n.humanize=a(),n.destroy=u,Object.keys(e).forEach(t=>{n[t]=e[t]}),n.names=[],n.skips=[],n.formatters={};function t(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return n.colors[Math.abs(t)%n.colors.length]}n.selectColor=t;function n(e){let t,i=null,a,o;function s(...e){if(!s.enabled)return;let r=s,i=Number(new Date);r.diff=i-(t||i),r.prev=t,r.curr=i,t=i,e[0]=n.coerce(e[0]),typeof e[0]!=`string`&&e.unshift(`%O`);let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(t,i)=>{if(t===`%%`)return`%`;a++;let o=n.formatters[i];if(typeof o==`function`){let n=e[a];t=o.call(r,n),e.splice(a,1),a--}return t}),n.formatArgs.call(r,e),(r.log||n.log).apply(r,e)}return s.namespace=e,s.useColors=n.useColors(),s.color=n.selectColor(e),s.extend=r,s.destroy=n.destroy,Object.defineProperty(s,`enabled`,{enumerable:!0,configurable:!1,get:()=>i===null?(a!==n.namespaces&&(a=n.namespaces,o=n.enabled(e)),o):i,set:e=>{i=e}}),typeof n.init==`function`&&n.init(s),s}function r(e,t){let r=n(this.namespace+(t===void 0?`:`:t)+e);return r.log=this.log,r}function i(e){n.save(e),n.namespaces=e,n.names=[],n.skips=[];let t=(typeof e==`string`?e:``).trim().replace(/\s+/g,`,`).split(`,`).filter(Boolean);for(let e of t)e[0]===`-`?n.skips.push(e.slice(1)):n.names.push(e)}function o(e,t){let n=0,r=0,i=-1,a=0;for(;n<e.length;)if(r<t.length&&(t[r]===e[n]||t[r]===`*`))t[r]===`*`?(i=r,a=n,r++):(n++,r++);else if(i!==-1)r=i+1,a++,n=a;else return!1;for(;r<t.length&&t[r]===`*`;)r++;return r===t.length}function s(){let e=[...n.names,...n.skips.map(e=>`-`+e)].join(`,`);return n.enable(``),e}function c(e){for(let t of n.skips)if(o(e,t))return!1;for(let t of n.names)if(o(e,t))return!0;return!1}function l(e){return e instanceof Error?e.stack||e.message:e}function u(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return n.enable(n.load()),n}t.exports=n})),s=n(((e,t)=>{e.formatArgs=r,e.save=i,e.load=a,e.useColors=n,e.storage=s(),e.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.colors=`#0000CC.#0000FF.#0033CC.#0033FF.#0066CC.#0066FF.#0099CC.#0099FF.#00CC00.#00CC33.#00CC66.#00CC99.#00CCCC.#00CCFF.#3300CC.#3300FF.#3333CC.#3333FF.#3366CC.#3366FF.#3399CC.#3399FF.#33CC00.#33CC33.#33CC66.#33CC99.#33CCCC.#33CCFF.#6600CC.#6600FF.#6633CC.#6633FF.#66CC00.#66CC33.#9900CC.#9900FF.#9933CC.#9933FF.#99CC00.#99CC33.#CC0000.#CC0033.#CC0066.#CC0099.#CC00CC.#CC00FF.#CC3300.#CC3333.#CC3366.#CC3399.#CC33CC.#CC33FF.#CC6600.#CC6633.#CC9900.#CC9933.#CCCC00.#CCCC33.#FF0000.#FF0033.#FF0066.#FF0099.#FF00CC.#FF00FF.#FF3300.#FF3333.#FF3366.#FF3399.#FF33CC.#FF33FF.#FF6600.#FF6633.#FF9900.#FF9933.#FFCC00.#FFCC33`.split(`.`);function n(){if(typeof window<`u`&&window.process&&(window.process.type===`renderer`||window.process.__nwjs))return!0;if(typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return typeof document<`u`&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<`u`&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<`u`&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function r(e){if(e[0]=(this.useColors?`%c`:``)+this.namespace+(this.useColors?` %c`:` `)+e[0]+(this.useColors?`%c `:` `)+`+`+t.exports.humanize(this.diff),!this.useColors)return;let n=`color: `+this.color;e.splice(1,0,n,`color: inherit`);let r=0,i=0;e[0].replace(/%[a-zA-Z%]/g,e=>{e!==`%%`&&(r++,e===`%c`&&(i=r))}),e.splice(i,0,n)}e.log=console.debug||console.log||(()=>{});function i(t){try{t?e.storage.setItem(`debug`,t):e.storage.removeItem(`debug`)}catch{}}function a(){let t;try{t=e.storage.getItem(`debug`)||e.storage.getItem(`DEBUG`)}catch{}return!t&&typeof process<`u`&&`env`in process&&(t=process.env.DEBUG),t}function s(){try{return localStorage}catch{}}t.exports=o()(e);var{formatters:c}=t.exports;c.j=function(e){try{return JSON.stringify(e)}catch(e){return`[UnexpectedJSONParseError]: `+e.message}}})),c=n(((n,a)=>{var s=t(`tty`),c=t(`util`);n.init=h,n.log=f,n.formatArgs=u,n.save=p,n.load=m,n.useColors=l,n.destroy=c.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),n.colors=[6,2,3,4,5,1];try{let t=(r(),e(i));t&&(t.stderr||t).level>=2&&(n.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}n.inspectOpts=Object.keys(process.env).filter(e=>/^debug_/i.test(e)).reduce((e,t)=>{let n=t.substring(6).toLowerCase().replace(/_([a-z])/g,(e,t)=>t.toUpperCase()),r=process.env[t];return r=/^(yes|on|true|enabled)$/i.test(r)?!0:/^(no|off|false|disabled)$/i.test(r)?!1:r===`null`?null:Number(r),e[n]=r,e},{});function l(){return`colors`in n.inspectOpts?!!n.inspectOpts.colors:s.isatty(process.stderr.fd)}function u(e){let{namespace:t,useColors:n}=this;if(n){let n=this.color,r=`\x1B[3`+(n<8?n:`8;5;`+n),i=` ${r};1m${t} \u001B[0m`;e[0]=i+e[0].split(`
2
+ `).join(`
3
+ `+i),e.push(r+`m+`+a.exports.humanize(this.diff)+`\x1B[0m`)}else e[0]=d()+t+` `+e[0]}function d(){return n.inspectOpts.hideDate?``:new Date().toISOString()+` `}function f(...e){return process.stderr.write(c.formatWithOptions(n.inspectOpts,...e)+`
4
+ `)}function p(e){e?process.env.DEBUG=e:delete process.env.DEBUG}function m(){return process.env.DEBUG}function h(e){e.inspectOpts={};let t=Object.keys(n.inspectOpts);for(let r=0;r<t.length;r++)e.inspectOpts[t[r]]=n.inspectOpts[t[r]]}a.exports=o()(n);var{formatters:g}=a.exports;g.o=function(e){return this.inspectOpts.colors=this.useColors,c.inspect(e,this.inspectOpts).split(`
5
+ `).map(e=>e.trim()).join(` `)},g.O=function(e){return this.inspectOpts.colors=this.useColors,c.inspect(e,this.inspectOpts)}})),l=n(((e,t)=>{typeof process>`u`||process.type===`renderer`||process.browser===!0||process.__nwjs?t.exports=s():t.exports=c()}));export{a as n,l as t};
@@ -0,0 +1,7 @@
1
+ import{n as e}from"./chunk-DR8-3Aex.js";import{B as t,M as n,d as r,n as i,t as a}from"./server-DzOdtq8A.js";import{randomUUID as o}from"node:crypto";function s(e){return e instanceof Error?e:void 0}var c,l=e((()=>{c={clipboardRead:!1,clipboardWrite:!1,systemKeyCombos:!1}}));function u(e){return d.has(e)?`shell`:f.has(e)?`filesystem`:p.has(e)?`system_settings`:null}var d,f,p,m,h=e((()=>{d=new Set([`com.apple.Terminal`,`com.googlecode.iterm2`,`com.microsoft.VSCode`,`dev.warp.Warp-Stable`,`com.github.wez.wezterm`,`io.alacritty`,`net.kovidgoyal.kitty`,`com.jetbrains.intellij`,`com.jetbrains.pycharm`]),f=new Set([`com.apple.finder`]),p=new Set([`com.apple.systempreferences`]),m=new Set([...d,...f,...p])}));function g(e){return e===`browser`||e===`trading`?`read`:e===`terminal`?`click`:`full`}function _(e,t){if(e&&re.has(e))return!0;let n=t.toLowerCase();for(let e of ie)if(n.includes(e))return!0;return!1}function v(e){return ee.has(e)?`browser`:te.has(e)?`terminal`:ne.has(e)?`trading`:null}function y(e){let t=e.toLowerCase();for(let e of se)if(t.includes(e))return`trading`;for(let e of ae)if(t.includes(e))return`browser`;for(let e of oe)if(t.includes(e))return`terminal`;return null}function b(e,t){if(e){let t=v(e);if(t)return t}return y(t)}function x(e,t){return g(b(e,t))}var ee,te,ne,re,ie,ae,oe,se,ce=e((()=>{ee=new Set(`com.apple.Safari,com.apple.SafariTechnologyPreview,com.google.Chrome,com.google.Chrome.beta,com.google.Chrome.dev,com.google.Chrome.canary,com.microsoft.edgemac,com.microsoft.edgemac.Beta,com.microsoft.edgemac.Dev,com.microsoft.edgemac.Canary,org.mozilla.firefox,org.mozilla.firefoxdeveloperedition,org.mozilla.nightly,org.chromium.Chromium,com.brave.Browser,com.brave.Browser.beta,com.brave.Browser.nightly,com.operasoftware.Opera,com.operasoftware.OperaGX,com.operasoftware.OperaDeveloper,com.vivaldi.Vivaldi,company.thebrowser.Browser,company.thebrowser.dia,org.torproject.torbrowser,com.duckduckgo.macos.browser,ru.yandex.desktop.yandex-browser,ai.perplexity.comet,com.sigmaos.sigmaos.macos,com.kagi.kagimacOS`.split(`,`)),te=new Set(`com.apple.Terminal,com.googlecode.iterm2,dev.warp.Warp-Stable,dev.warp.Warp-Beta,com.github.wez.wezterm,org.alacritty,io.alacritty,net.kovidgoyal.kitty,co.zeit.hyper,com.mitchellh.ghostty,org.tabby,com.termius-dmg.mac,com.microsoft.VSCode,com.microsoft.VSCodeInsiders,com.vscodium,com.todesktop.230313mzl4w4u92,com.exafunction.windsurf,dev.zed.Zed,dev.zed.Zed-Preview,com.jetbrains.intellij,com.jetbrains.intellij.ce,com.jetbrains.pycharm,com.jetbrains.pycharm.ce,com.jetbrains.WebStorm,com.jetbrains.CLion,com.jetbrains.goland,com.jetbrains.rubymine,com.jetbrains.PhpStorm,com.jetbrains.datagrip,com.jetbrains.rider,com.jetbrains.AppCode,com.jetbrains.rustrover,com.jetbrains.fleet,com.google.android.studio,com.axosoft.gitkraken,com.sublimetext.4,com.sublimetext.3,org.vim.MacVim,com.neovim.neovim,org.gnu.Emacs,com.apple.dt.Xcode,org.eclipse.platform.ide,org.netbeans.ide,com.microsoft.visual-studio,com.apple.ScriptEditor2,com.apple.Automator,com.apple.shortcuts`.split(`,`)),ne=new Set([`com.webull.desktop.v1`,`com.webull.trade.mac.v1`,`com.tastytrade.desktop`,`com.tradingview.tradingviewapp.desktop`,`com.fidelity.activetrader`,`com.fmr.activetrader`,`com.install4j.5889-6375-8446-2021`,`com.binance.BinanceDesktop`,`com.electron.exodus`,`org.pythonmac.unspecified.Electrum`,`com.ledger.live`,`io.trezor.TrezorSuite`]),re=new Set([`com.apple.TV`,`com.apple.Music`,`com.apple.iBooksX`,`com.apple.podcasts`,`com.spotify.client`,`com.amazon.music`,`com.tidal.desktop`,`com.deezer.deezer-desktop`,`com.pandora.desktop`,`com.electron.pocket-casts`,`au.com.shiftyjelly.PocketCasts`,`tv.plex.desktop`,`tv.plex.htpc`,`tv.plex.plexamp`,`com.amazon.aiv.AIVApp`,`net.kovidgoyal.calibre`,`com.amazon.Kindle`,`com.amazon.Lassen`,`com.kobo.desktop.Kobo`]),ie=`netflix,disney+,hulu,prime video,apple tv,peacock,paramount+,tubi,crunchyroll,vudu,kindle,apple books,kobo,play books,calibre,libby,readium,audible,libro.fm,speechify,spotify,apple music,amazon music,youtube music,tidal,deezer,pandora,pocket casts,naver,reddit,sony music,vegas pro,pitchfork,economist,nytimes`.split(`,`),ae=[`safari`,`chrome`,`firefox`,`microsoft edge`,`brave`,`opera`,`vivaldi`,`chromium`,`arc browser`,`tor browser`,`duckduckgo`,`yandex`,`orion browser`,`comet`,`sigmaos`,`dia browser`],oe=`terminal,iterm,wezterm,alacritty,kitty,ghostty,tabby,termius,script editor,automator,powershell,cmd.exe,command prompt,git bash,conemu,cmder,visual studio code,visual studio,vscode,vs code,vscodium,cursor,windsurf,intellij,pycharm,webstorm,clion,goland,rubymine,phpstorm,datagrip,rider,appcode,rustrover,fleet,android studio,sublime text,macvim,neovim,emacs,xcode,eclipse,netbeans`.split(`,`),se=`bloomberg,ameritrade,thinkorswim,schwab,fidelity,e*trade,interactive brokers,trader workstation,tradestation,webull,robinhood,tastytrade,ninjatrader,tradingview,moomoo,tradezero,prorealtime,plus500,saxotrader,oanda,metatrader,forex.com,avaoptions,ctrader,jforex,iq option,olymp trade,binomo,pocket option,raceoption,expertoption,quotex,naga,morgan stanley,ubs neo,eikon,coinbase,kraken,binance,okx,bybit,phemex,stormgain,crypto.com,electrum,ledger live,trezor,guarda,atomic wallet,bitpay,bisq,koinly,cointracker,blockfi,stripe cli,decentraland,axie infinity,gods unchained`.split(`,`)}));function le(e){let t=e.toLowerCase().split(`+`).map(e=>e.trim()).filter(Boolean),n=[],r=[];for(let e of t){let t=ue[e];t===void 0?r.push(e):n.push(t)}let i=[...new Set(n)];return i.sort((e,t)=>C.indexOf(e)-C.indexOf(t)),{mods:i,keys:r}}function S(e,t){let n=t===`darwin`?de:fe,{mods:r,keys:i}=le(e),a=r.length>0?r.join(`+`)+`+`:``;if(i.length===0)return n.has(r.join(`+`));for(let e of i)if(n.has(a+e))return!0;return!1}var ue,C,de,fe,pe=e((()=>{ue={meta:`meta`,super:`meta`,command:`meta`,cmd:`meta`,windows:`meta`,win:`meta`,ctrl:`ctrl`,control:`ctrl`,lctrl:`ctrl`,lcontrol:`ctrl`,rctrl:`ctrl`,rcontrol:`ctrl`,shift:`shift`,lshift:`shift`,rshift:`shift`,alt:`alt`,option:`alt`},C=[`ctrl`,`alt`,`shift`,`meta`],de=new Set([`meta+q`,`shift+meta+q`,`alt+meta+escape`,`meta+tab`,`meta+space`,`ctrl+meta+q`]),fe=new Set([`ctrl+alt+delete`,`alt+f4`,`alt+tab`,`meta+l`,`meta+d`])}));function me(e,t){return Math.floor((e-1)/t)+1}function he(e,t,n){return me(e,n)*me(t,n)}function ge(e,t,n){let{pxPerToken:r,maxTargetPx:i,maxTargetTokens:a}=n;if(e<=i&&t<=i&&he(e,t,r)<=a)return[e,t];if(t>e){let[r,i]=ge(t,e,n);return[i,r]}let o=e/t,s=e,c=1;for(;;){if(c+1===s)return[c,Math.max(Math.round(c/o),1)];let e=Math.floor((c+s)/2),t=Math.max(Math.round(e/o),1);e<=i&&he(e,t,r)<=a?c=e:s=e}}var _e,ve=e((()=>{_e={pxPerToken:28,maxTargetPx:1568,maxTargetTokens:1568}}));function ye(e,t,n,r,i){if(!e||!t)return null;let a=Math.max(0,Math.min(100,n)),o=Math.max(0,Math.min(100,r)),s=Math.round(a/100*e),c=Math.round(o/100*t),l=Math.floor(i/2),u=Math.max(0,s-l),d=Math.max(0,c-l),f=Math.min(i,e-u),p=Math.min(i,t-d);return f<=0||p<=0?null:{x:u,y:d,width:f,height:p}}function be(e,t,n,r,i,a=w){let o=ye(n.width,n.height,r,i,a);if(!o)return!1;let s=e(t.base64,o),c=e(n.base64,o);return!s||!c?!1:s.equals(c)}async function xe(e,t,n,r,i,a,o=w){if(!t)return{valid:!0,skipped:!0};try{let a=await i();return a?be(e,t,a,n,r,o)?{valid:!0,skipped:!1}:{valid:!1,skipped:!1,warning:`Screen content at the target location changed since the last screenshot. Take a new screenshot before clicking.`}:{valid:!0,skipped:!0}}catch(e){return a.debug(`[pixelCompare] validation error, skipping`,s(e)),{valid:!0,skipped:!0}}}var w,Se=e((()=>{l(),w=9}));function T(e){let t=Buffer.from(e.slice(0,16),`base64`);return t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71?`image/png`:t[0]===255&&t[1]===216&&t[2]===255?`image/jpeg`:t[0]===82&&t[1]===73&&t[2]===70&&t[3]===70&&t[8]===87&&t[9]===69&&t[10]===66&&t[11]===80?`image/webp`:t[0]===71&&t[1]===73&&t[2]===70?`image/gif`:`image/png`}function E(e,t){return{content:[{type:`text`,text:e}],isError:!0,telemetry:t?{error_kind:t}:void 0}}function D(e){return{content:[{type:`text`,text:e}]}}function O(e,t){return{content:[{type:`text`,text:JSON.stringify(e)}],telemetry:t}}function Ce(e){return typeof e==`object`&&e?e:{}}function k(e,t){let n=e[t];return typeof n==`string`?n:Error(`"${t}" must be a string.`)}function A(e,t=`coordinate`){let n=e[t];if(n===void 0)return Error(`${t} is required`);if(!Array.isArray(n)||n.length!==2)return Error(`${t} must be an array of length 2`);let[r,i]=n;return typeof r!=`number`||typeof i!=`number`||r<0||i<0?Error(`${t} must be a tuple of non-negative numbers`):[r,i]}function j(e,t,n,r,i,a){return n===`normalized_0_100`?{x:Math.round(e/100*r.width)+r.originX,y:Math.round(t/100*r.height)+r.originY}:i?{x:Math.round(e*(i.displayWidth/i.width))+i.originX,y:Math.round(t*(i.displayHeight/i.height))+i.originY}:(a.warn(`[computer-use] pixels-mode coordinate received with no prior screenshot; falling back to /scaleFactor. Click may be off if downsample is active.`),{x:Math.round(e/r.scaleFactor)+r.originX,y:Math.round(t/r.scaleFactor)+r.originY})}function we(e,t,n,r){return n===`normalized_0_100`?{xPct:e,yPct:t}:r?{xPct:e/r.width*100,yPct:t/r.height*100}:{xPct:0,yPct:0}}function Te(e,t){let n=e??`full`;return t===`mouse_position`?!0:t===`keyboard`||t===`mouse_full`?n===`full`:n===`click`||n===`full`}async function M(e,t,n){let r=t.getClipboardStash?.();if(!n){if(r===void 0)return;try{await e.executor.writeClipboard(r),t.onClipboardStashChanged?.(void 0)}catch{}return}if(r===void 0)try{let n=await e.executor.readClipboard();t.onClipboardStashChanged?.(n)}catch{t.onClipboardStashChanged?.(``)}try{await e.executor.writeClipboard(``)}catch{}}async function N(e,t,n,r){if(n.hideBeforeAction){let n=await e.executor.prepareForAction(t.allowedApps.map(e=>e.bundleId),t.selectedDisplayId);n.length>0&&t.onAppsHidden?.(n)}if(e.executor.capabilities.screenshotFiltering===`none`)return null;let i=await e.executor.getFrontmostApp(),a=new Map(t.allowedApps.map(e=>[e.bundleId,e.tier])),o=i?a.get(i.bundleId):void 0;if(n.clipboardGuard&&await M(e,t,o===`click`),!i)return null;let{hostBundleId:s}=e.executor.capabilities;if(o!==void 0){if(Te(o,r))return null;if(o===`read`){let e=b(i.bundleId,i.displayName)===`browser`;return E(`"${i.displayName}" is granted at tier "read" — visible in screenshots only, no clicks or typing.`+(e?" Use the Claude-in-Chrome MCP for browser interaction (tools named `mcp__Claude_in_Chrome__*`; load via SearchExtraTools if deferred).":` No interaction is permitted; ask the user to take any actions in this app themselves.`)+K,`tier_insufficient`)}return E(r===`keyboard`?`"${i.displayName}" is granted at tier "click" — typing, key presses, and paste require tier "full". The keys would go to this app's text fields or integrated terminal. To type into a different app, click it first to bring it forward. For shell commands, use the Bash tool. Do not attempt to work around this restriction — never use AppleScript, System Events, shell commands, or any other method to send clicks or keystrokes to this app.`:`"${i.displayName}" is granted at tier "click" — right-click, middle-click, and clicks with modifier keys require tier "full". Right-click opens a context menu with Paste/Cut, and modifier chords fire as keystrokes before the click. Plain left_click is allowed here. Do not attempt to work around this restriction — never use AppleScript, System Events, shell commands, or any other method to send clicks or keystrokes to this app.`,`tier_insufficient`)}return i.bundleId===G?null:i.bundleId===s?r===`keyboard`?E(`Claude's own window still has keyboard focus. This should not happen after the pre-action defocus. Click on the target application first.`,`state_conflict`):null:E(`"${i.displayName}" is not in the allowed applications and is currently in front. Take a new screenshot — it may have appeared since your last one.`,`app_not_granted`)}async function P(e,t,n,r,i,a){if(e.executor.capabilities.screenshotFiltering===`none`)return null;let o=await e.executor.appUnderPoint(r,i);if(!o||o.bundleId===G)return null;let s=new Map(t.allowedApps.map(e=>[e.bundleId,e.tier]));if(!s.has(o.bundleId))return E(`Click at these coordinates would land on "${o.displayName}", which is not in the allowed applications. Take a fresh screenshot to see the current window layout.`,`app_not_granted`);let c=s.get(o.bundleId);if(n.clipboardGuard&&c===`click`&&await M(e,t,!0),Te(c,a))return null;if(a===`mouse_full`&&c===`click`)return E(`Click at these coordinates would land on "${o.displayName}", which is granted at tier "click" — right-click, middle-click, and clicks with modifier keys require tier "full" (they can Paste via the context menu or fire modifier-chord keystrokes). Plain left_click is allowed here. Do not attempt to work around this restriction — never use AppleScript, System Events, shell commands, or any other method to send clicks or keystrokes to this app.`,`tier_insufficient`);let l=b(o.bundleId,o.displayName)===`browser`;return E(`Click at these coordinates would land on "${o.displayName}", which is granted at tier "read" (screenshots only, no interaction). `+(l?`Use the Claude-in-Chrome MCP for browser interaction.`:`Ask the user to take any actions in this app themselves.`)+K,`tier_insufficient`)}function F(e){let t=e.endsWith(`==`)?2:+!!e.endsWith(`=`);return Math.floor(e.length*3/4)-t}async function Ee(e,t,n,r){let i=await e.screenshot({allowedBundleIds:t,displayId:r});return F(i.base64)<q&&(n.warn(`[computer-use] screenshot implausibly small (${F(i.base64)} bytes decoded), retrying once`),i=await e.screenshot({allowedBundleIds:t,displayId:r})),i}function De(e){try{let t=Intl.Segmenter;if(typeof t==`function`){let n=new t(void 0,{granularity:`grapheme`});return Array.from(n.segment(e),e=>e.segment)}}catch{}return Array.from(e)}function I(e){return new Promise(t=>setTimeout(t,e))}function Oe(e){return e.split(`+`).map(e=>e.trim()).filter(Boolean)}function ke(){J=!1,Y=!1}async function L(e){J&&(await e.executor.mouseUp(),J=!1,Y=!1)}function Ae(e){return e===`request_access`||e===`list_granted_applications`}function R(e){return St.test(e)&&!e.includes(` `)}function je(e,t,n){let r=new Map,i=new Map;for(let e of t)i.set(e.bundleId,e),r.set(e.displayName.toLowerCase(),e);return e.map(e=>{let t;if(R(e)&&(t=i.get(e)),t||(t=r.get(e.toLowerCase())),!t){let n=e.toLowerCase().replace(/\.exe$/,``).trim();for(let[e,i]of r)if(e.includes(n)||n.includes(e)){t=i;break}}let a=t?.bundleId,o=a??(R(e)?e:void 0);return{requestedName:e,resolved:t,isSentinel:a?m.has(a):!1,alreadyGranted:a?n.has(a):!1,proposedTier:x(o,t?.displayName??e)}})}async function Me(e,t,n,r){if(!n.onPermissionRequest)return E(`This session was not wired with a permission handler. Computer control is not available here.`,`feature_unavailable`);if(n.getTeachModeActive?.())return E(`Cannot request additional permissions during teach mode — the permission dialog would be hidden. End teach mode (finish the tour or let the turn complete), then call request_access, then start a new tour.`,`teach_mode_conflict`);let i=k(t,`reason`);if(i instanceof Error)return E(i.message,`bad_args`);if(r){let t={requestId:o(),reason:i,apps:[],requestedFlags:{},screenshotFiltering:e.executor.capabilities.screenshotFiltering,tccState:r};await n.onPermissionRequest(t);let a=await e.ensureOsPermissions();if(a.granted)return E(`macOS Accessibility and Screen Recording are now both granted. Call request_access again immediately — the next call will show the app selection list.`);let s=a,c=[];return s.accessibility||c.push(`Accessibility`),s.screenRecording||c.push(`Screen Recording`),E(`macOS ${c.join(` and `)} permission(s) not yet granted. The permission panel has been shown. Once the user grants the missing permission(s), call request_access again.`,`tcc_not_granted`)}let a=t.apps;if(!Array.isArray(a)||!a.every(e=>typeof e==`string`))return E(`"apps" must be an array of strings.`,`bad_args`);let s=a,c={};typeof t.clipboardRead==`boolean`&&(c.clipboardRead=t.clipboardRead),typeof t.clipboardWrite==`boolean`&&(c.clipboardWrite=t.clipboardWrite),typeof t.systemKeyCombos==`boolean`&&(c.systemKeyCombos=t.systemKeyCombos);let{needDialog:l,skipDialogGrants:u,willHide:d,tieredApps:f,userDenied:p,policyDenied:m}=await Pe(e,s,n.allowedApps,new Set(n.userDeniedBundleIds),n.selectedDisplayId),h=[],g=[];if(n.grantFlags,l.length>0||Object.keys(c).length>0){let t={requestId:o(),reason:i,apps:l,requestedFlags:c,screenshotFiltering:e.executor.capabilities.screenshotFiltering,...d.length>0&&{willHide:d,autoUnhideEnabled:e.getAutoUnhideEnabled()}},r=await n.onPermissionRequest(t);h=r.granted,g=r.denied,r.flags}let _=[...u,...h],v=new Set(_.map(e=>e.bundleId)),y=f.filter(e=>v.has(e.bundleId)),b=[];try{b=await Ne(e,_)}catch(t){e.logger.warn(`[computer-use] buildWindowLocations failed: ${String(t)}`)}return O({granted:_,denied:g,...m.length>0&&{policyDenied:{apps:m,guidance:B(m)}},...p.length>0&&{userDenied:{apps:p,guidance:z(p)}},...y.length>0&&{tierGuidance:Fe(y)},screenshotFiltering:e.executor.capabilities.screenshotFiltering,...b.length>0?{windowLocations:b}:{}},{granted_count:h.length,denied_count:g.length,...Ie(y)})}async function Ne(e,t){if(t.length===0)return[];let n=await e.executor.listDisplays();if(n.length<=1)return[];let r=t.map(e=>e.bundleId),i=await e.executor.findWindowDisplays(r),a=new Map(n.map(e=>[e.displayId,e])),o=new Map(i.map(e=>[e.bundleId,e.displayIds])),s=[];for(let e of t){let t=o.get(e.bundleId);!t||t.length===0||s.push({bundleId:e.bundleId,displayName:e.displayName,displays:t.map(e=>{let t=a.get(e);return{id:e,label:t?.label,isPrimary:t?.isPrimary}})})}return s}async function Pe(e,t,n,r,i){let a=new Set(n.map(e=>e.bundleId)),o=je(t,await e.executor.listInstalledApps(),a),s=[],c=[];for(let e of o){let t=e.resolved?.displayName??e.requestedName;_(e.resolved?.bundleId,t)?s.push({requestedName:e.requestedName,displayName:t}):c.push(e)}let l=[],u=[];for(let e of c)e.resolved&&r.has(e.resolved.bundleId)?l.push({requestedName:e.requestedName,displayName:e.resolved.displayName}):u.push(e);let d=[];for(let e of u)e.proposedTier===`full`||!e.resolved||d.push({bundleId:e.resolved.bundleId,displayName:e.resolved.displayName,tier:e.proposedTier});let f=u.filter(e=>e.alreadyGranted),p=u.filter(e=>!e.alreadyGranted);for(let t of p)if(t.resolved)try{t.resolved.iconDataUrl=await e.executor.getAppIcon(t.resolved.path)}catch{}let m=Date.now(),h=f.filter(e=>e.resolved).map(e=>n.find(t=>t.bundleId===e.resolved.bundleId)??{bundleId:e.resolved.bundleId,displayName:e.resolved.displayName,grantedAt:m,tier:e.proposedTier}),g=[...n.map(e=>e.bundleId),...u.filter(e=>e.resolved).map(e=>e.resolved.bundleId)];return{needDialog:p,skipDialogGrants:h,willHide:await e.executor.previewHideSet(g,i),tieredApps:d,userDenied:l,policyDenied:s}}function Fe(e){let t=e.filter(e=>e.tier===`read`&&b(e.bundleId,e.displayName)===`browser`),n=e.filter(e=>e.tier===`read`&&b(e.bundleId,e.displayName)!==`browser`),r=e.filter(e=>e.tier===`click`),i=[];if(t.length>0){let e=t.map(e=>`"${e.displayName}"`).join(`, `);i.push(`${e} ${t.length===1?`is a browser`:`are browsers`} — granted at tier "read" (visible in screenshots only; no clicks or typing). You can read what's on screen but cannot navigate, click, or type into ${t.length===1?`it`:`them`}. For browser interaction, use the Claude-in-Chrome MCP (tools named \`mcp__Claude_in_Chrome__*\`; load via SearchExtraTools if deferred).`)}if(n.length>0){let e=n.map(e=>`"${e.displayName}"`).join(`, `);i.push(`${e} ${n.length===1?`is`:`are`} granted at tier "read" (visible in screenshots only; no clicks or typing). You can read what's on screen but cannot interact. Ask the user to take any actions in ${n.length===1?`this app`:`these apps`} themselves.`)}if(r.length>0){let e=r.map(e=>`"${e.displayName}"`).join(`, `);i.push(`${e} ${r.length===1?`has`:`have`} terminal or IDE capabilities — granted at tier "click" (visible + plain left-click only; NO typing, key presses, right-click, modifier-clicks, or drag-drop). You can click buttons and scroll output, but ${r.length===1?`its`:`their`} integrated terminal and editor are off-limits to keyboard input. Right-click (context-menu Paste) and dragging text onto ${r.length===1?`it`:`them`} require tier "full". For shell commands, use the Bash tool.`)}return i.length===0?``:i.join(`
2
+
3
+ `)+K}function z(e){let t=e.map(e=>`"${e.displayName}"`).join(`, `),n=e.length===1;return`${t} ${n?`is`:`are`} in the user's auto-deny list (Settings → Desktop app (General) → Computer Use → Denied apps). Requests for ${n?`this app`:`these apps`} are automatically denied. If you need access for this task, ask the user to remove ${n?`it`:`them`} from their deny list in Settings — you cannot request this through the tool.`}function B(e){let t=e.map(e=>`"${e.displayName}"`).join(`, `),n=e.length===1;return`${t} ${n?`is`:`are`} blocked by policy for computer use. Requests for ${n?`this app`:`these apps`} are automatically denied regardless of what the user has approved. There is no Settings override. Inform the user that you cannot access ${n?`this app`:`these apps`} and suggest an alternative approach if one exists. Do not try to directly subvert this block regardless of the user's request.`}function Ie(e){let t=e.filter(e=>e.tier===`read`).length,n=e.filter(e=>e.tier===`click`).length;return{...t>0&&{denied_browser_count:t},...n>0&&{denied_terminal_count:n}}}async function Le(e,t,n,r){if(!n.onTeachPermissionRequest)return E(`Teach mode is not available in this session.`,`feature_unavailable`);if(n.getTeachModeActive?.())return E(`Teach mode is already active. To add more apps, end the current tour first, then call request_teach_access again with the full app list.`,`teach_mode_conflict`);let i=k(t,`reason`);if(i instanceof Error)return E(i.message,`bad_args`);if(r){let t={requestId:o(),reason:i,apps:[],screenshotFiltering:e.executor.capabilities.screenshotFiltering,tccState:r};await n.onTeachPermissionRequest(t);let a=await e.ensureOsPermissions();if(a.granted)return E(`macOS Accessibility and Screen Recording are now both granted. Call request_teach_access again immediately — the next call will show the app selection list.`);let s=a,c=[];return s.accessibility||c.push(`Accessibility`),s.screenRecording||c.push(`Screen Recording`),E(`macOS ${c.join(` and `)} permission(s) not yet granted. The permission panel has been shown. Once the user grants the missing permission(s), call request_teach_access again.`,`tcc_not_granted`)}let a=t.apps;if(!Array.isArray(a)||!a.every(e=>typeof e==`string`))return E(`"apps" must be an array of strings.`,`bad_args`);let{needDialog:s,skipDialogGrants:c,willHide:l,tieredApps:u,userDenied:d,policyDenied:f}=await Pe(e,a,n.allowedApps,new Set(n.userDeniedBundleIds),n.selectedDisplayId);if(s.length===0&&c.length===0)return O({granted:[],denied:[],...f.length>0&&{policyDenied:{apps:f,guidance:B(f)}},...d.length>0&&{userDenied:{apps:d,guidance:z(d)}},teachModeActive:!1,screenshotFiltering:e.executor.capabilities.screenshotFiltering},{granted_count:0,denied_count:0});let p={requestId:o(),reason:i,apps:s,screenshotFiltering:e.executor.capabilities.screenshotFiltering,...l.length>0&&{willHide:l,autoUnhideEnabled:e.getAutoUnhideEnabled()}},m=await n.onTeachPermissionRequest(p),h=[...c,...m.granted],g=m.userConsented===!0&&h.length>0;g&&n.onTeachModeActivated?.();let _=new Set(h.map(e=>e.bundleId)),v=u.filter(e=>_.has(e.bundleId));return O({granted:h,denied:m.denied,...f.length>0&&{policyDenied:{apps:f,guidance:B(f)}},...d.length>0&&{userDenied:{apps:d,guidance:z(d)}},...v.length>0&&{tierGuidance:Fe(v)},teachModeActive:g,screenshotFiltering:e.executor.capabilities.screenshotFiltering},{granted_count:m.granted.length,denied_count:m.denied.length,...Ie(v)})}async function Re(e,t,n,r){let i=k(e,`explanation`);if(i instanceof Error)return Error(`${r}: ${i.message}`);let a=k(e,`next_preview`);if(a instanceof Error)return Error(`${r}: ${a.message}`);let o=e.actions;if(!Array.isArray(o))return Error(`${r}: "actions" must be an array (empty is allowed).`);for(let[e,t]of o.entries()){if(typeof t!=`object`||!t)return Error(`${r}: actions[${e}] must be an object`);let n=t.action;if(typeof n!=`string`)return Error(`${r}: actions[${e}].action must be a string`);if(!X.has(n))return Error(`${r}: actions[${e}].action="${n}" is not allowed. Allowed: ${[...X].join(`, `)}.`)}let s;if(e.anchor!==void 0){let i=e.anchor;if(!Array.isArray(i)||i.length!==2||typeof i[0]!=`number`||typeof i[1]!=`number`||!Number.isFinite(i[0])||!Number.isFinite(i[1]))return Error(`${r}: "anchor" must be a [x, y] number tuple or omitted.`);let a=await t.executor.getDisplaySize(n.selectedDisplayId);s=j(i[0],i[1],n.coordinateMode,a,n.lastScreenshot,t.logger)}return{explanation:i,nextPreview:a,anchorLogical:s,actions:o}}async function ze(e,t,n,r){if((await n.onTeachStep({explanation:e.explanation,nextPreview:e.nextPreview,anchorLogical:e.anchorLogical})).action===`exit`)return await L(t),{kind:`exit`};if(n.onTeachWorking?.(),e.actions.length===0)return{kind:`ok`,results:[]};if(r.hideBeforeAction){let e=await t.executor.prepareForAction(n.allowedApps.map(e=>e.bundleId),n.selectedDisplayId);e.length>0&&n.onAppsHidden?.(e)}let i={...r,hideBeforeAction:!1,pixelValidation:!1,autoTargetDisplay:!1},a=[];for(let[r,o]of e.actions.entries()){if(n.isAborted?.())return await L(t),{kind:`exit`};r>0&&await I(10);let s=o.action,{screenshot:c,...l}=await W(s,o,t,n,i),u=yt(l),d={action:s,ok:!l.isError,output:u};if(a.push(d),l.isError)return await L(t),{kind:`action_error`,executed:a.length-1,failed:d,remaining:e.actions.length-a.length,telemetry:l.telemetry}}return{kind:`ok`,results:a}}async function Be(e,t,n,r){let i=await Ke(t,n,r);return i.isError?O(e):{content:[{type:`text`,text:JSON.stringify(e)},...i.content],screenshot:i.screenshot}}async function Ve(e,t,n,r){if(!n.onTeachStep)return E(`Teach mode is not active. Call request_teach_access first.`,`teach_mode_not_active`);let i=await Re(t,e,n,`teach_step`);if(i instanceof Error)return E(i.message,`bad_args`);let a=await ze(i,e,n,r);return a.kind===`exit`?O({exited:!0}):a.kind===`action_error`?O({executed:a.executed,failed:a.failed,remaining:a.remaining},a.telemetry):i.actions.length===0?O({executed:0,results:[]}):Be({executed:a.results.length,results:a.results},e,n,r)}async function He(e,t,n,r){if(!n.onTeachStep)return E(`Teach mode is not active. Call request_teach_access first.`,`teach_mode_not_active`);let i=t.steps;if(!Array.isArray(i)||i.length<1)return E(`"steps" must be a non-empty array.`,`bad_args`);let a=[];for(let[t,r]of i.entries()){if(typeof r!=`object`||!r)return E(`steps[${t}] must be an object`,`bad_args`);let i=await Re(r,e,n,`steps[${t}]`);if(i instanceof Error)return E(i.message,`bad_args`);a.push(i)}let o=[];for(let[t,i]of a.entries()){let a=await ze(i,e,n,r);if(a.kind===`exit`)return O({exited:!0,stepsCompleted:t});if(a.kind===`action_error`)return O({stepsCompleted:t,stepFailed:t,executed:a.executed,failed:a.failed,remaining:a.remaining,results:o},a.telemetry);o.push(a.results)}let s=a.some(e=>e.actions.length>0),c={stepsCompleted:a.length,results:o};return s?Be(c,e,n,r):O(c)}async function Ue(e,t){if(t.length===0)return;let n=await e.executor.listRunningApps(),r=new Map(n.map(e=>[e.bundleId,e.displayName])),i=t.map(e=>r.get(e)??e),a=i.map(e=>`"${e}"`).join(`, `),o=i.length===1;return`${a} ${o?`was`:`were`} open and got hidden before this screenshot (not in the session allowlist). If a previous action was meant to open ${o?`it`:`one of them`}, that's why you don't see it — call request_access to add ${o?`it`:`them`} to the allowlist.`}function We(e){let t=[...e].sort((e,t)=>e.displayId-t.displayId),n=new Map,r=new Map;for(let e of t){let t=e.label??`display ${e.displayId}`,i=(n.get(t)??0)+1;n.set(t,i),r.set(e.displayId,i===1?t:`${t} (${i})`)}return r}async function Ge(e,t,n,r){let i;try{i=await e.executor.listDisplays()}catch(t){e.logger.warn(`[computer-use] listDisplays failed: ${String(t)}`);return}if(i.length<2)return;let a=We(i),o=e=>a.get(e)??`display ${e}`,s=o(t),c=i.filter(e=>e.displayId!==t).map(e=>o(e.displayId)),l=r?` Use switch_display to capture a different monitor.`:``,u=c.length>0?` Other attached monitors: ${c.map(e=>`"${e}"`).join(`, `)}.`+l:``;if(n===void 0||n===0)return`This screenshot was taken on monitor "${s}".`+u;if(n!==t)return`This screenshot was taken on monitor "${s}", which is different from your previous screenshot (taken on "${o(n)}").`+u}async function Ke(e,t,n){if(t.allowedApps.length===0)return E(`No applications are granted for this session. Call request_access first.`,`allowlist_empty`);if(n.autoTargetDisplay){let r=t.allowedApps.map(e=>e.bundleId),i=r.slice().sort().join(`,`),a=i!==t.displayResolvedForApps,o=!t.displayPinnedByModel&&a,s=await e.executor.resolvePrepareCapture({allowedBundleIds:r,preferredDisplayId:t.selectedDisplayId,autoResolve:o,doHide:n.hideBeforeAction});s.captureError===void 0&&F(s.base64)<q&&e.logger.warn(`[computer-use] resolvePrepareCapture result implausibly small (${F(s.base64)} bytes decoded) — possible transient display state`),s.displayId!==t.selectedDisplayId&&(e.logger.debug(`[computer-use] resolver: preferred=${t.selectedDisplayId} resolved=${s.displayId}`),t.onResolvedDisplayUpdated?.(s.displayId)),o&&t.onDisplayResolvedForApps?.(i);let c=[];if(t.lastScreenshot!==void 0&&(c=s.hidden),s.hidden.length>0&&t.onAppsHidden?.(s.hidden),s.captureError!==void 0)return E(s.captureError,`capture_failed`);let l=await Ue(e,c),u={base64:s.base64,width:s.width,height:s.height,displayWidth:s.displayWidth,displayHeight:s.displayHeight,displayId:s.displayId,originX:s.originX,originY:s.originY},d=await Ge(e,u.displayId??0,t.lastScreenshot?.displayId,t.onDisplayPinned!==void 0);return{content:[...d?[{type:`text`,text:d}]:[],...l?[{type:`text`,text:l}]:[],...u.accessibilityText?[{type:`text`,text:`GUI elements in this window:\n${u.accessibilityText}`}]:[],{type:`image`,data:u.base64,mimeType:T(u.base64)}],screenshot:u}}let r=[];if(n.hideBeforeAction){let n=await e.executor.prepareForAction(t.allowedApps.map(e=>e.bundleId),t.selectedDisplayId);t.lastScreenshot!==void 0&&(r=n),n.length>0&&t.onAppsHidden?.(n)}let i=t.allowedApps.map(e=>e.bundleId),a=await Ee(e.executor,i,e.logger,t.selectedDisplayId),o=await Ue(e,r),s=await Ge(e,a.displayId??0,t.lastScreenshot?.displayId,t.onDisplayPinned!==void 0);return{content:[...s?[{type:`text`,text:s}]:[],...o?[{type:`text`,text:o}]:[],...a.accessibilityText?[{type:`text`,text:`GUI elements in this window:\n${a.accessibilityText}`}]:[],{type:`image`,data:a.base64,mimeType:T(a.base64)}],screenshot:a}}async function qe(e,t,n){let r=t.region;if(!Array.isArray(r)||r.length!==4)return E(`region must be an array of length 4: [x0, y0, x1, y1]`,`bad_args`);let[i,a,o,s]=r;if(![i,a,o,s].every(e=>typeof e==`number`&&e>=0))return E(`region values must be non-negative numbers`,`bad_args`);if(o<=i)return E(`region x1 must be greater than x0`,`bad_args`);if(s<=a)return E(`region y1 must be greater than y0`,`bad_args`);let c=n.lastScreenshot;if(!c)return E(`take a screenshot before zooming (region coords are relative to it)`,`state_conflict`);if(o>c.width||s>c.height)return E(`region exceeds screenshot bounds (${c.width}×${c.height})`,`bad_args`);let l=c.displayWidth/c.width,u=c.displayHeight/c.height,d={x:i*l,y:a*u,w:(o-i)*l,h:(s-a)*u},f=n.allowedApps.map(e=>e.bundleId),p=await e.executor.zoom(d,f,c.displayId);return{content:[{type:`image`,data:p.base64,mimeType:T(p.base64)}]}}async function V(e,t,n,r,i,a){J&&(await e.executor.mouseUp(),J=!1,Y=!1);let o=A(t);if(o instanceof Error)return E(o.message,`bad_args`);let[s,c]=o,l;if(t.text!==void 0){if(typeof t.text!=`string`)return E(`text must be a string`,`bad_args`);if(S(t.text,e.executor.capabilities.platform)&&!n.grantFlags.systemKeyCombos)return E(`The modifier chord "${t.text}" would fire a system shortcut. Request the systemKeyCombos grant flag via request_access, or use only modifier keys (shift, ctrl, alt, cmd) in the text parameter.`,`grant_flag_required`);l=Oe(t.text)}let u=i!==`left`||l!==void 0&&l.length>0?`mouse_full`:`mouse`,d=await N(e,n,r,u);if(d)return d;let f=await e.executor.getDisplaySize(n.selectedDisplayId);if(r.pixelValidation){let{xPct:t,yPct:r}=we(s,c,n.coordinateMode,n.lastScreenshot),i=await xe(e.cropRawPatch,n.lastScreenshot,t,r,async()=>{let t=n.allowedApps.map(e=>e.bundleId);try{return await e.executor.screenshot({allowedBundleIds:t,displayId:n.lastScreenshot?.displayId})}catch{return null}},e.logger);if(!i.valid&&i.warning)return D(i.warning)}let{x:p,y:m}=j(s,c,n.coordinateMode,f,n.lastScreenshot,e.logger);return await P(e,n,r,p,m,u)||(await e.executor.click(p,m,i,a,l),D(`Clicked.`))}async function Je(e,t,n,r){let i=k(t,`text`);if(i instanceof Error)return E(i.message,`bad_args`);let a=await N(e,n,r,`keyboard`);if(a)return a;if(i.includes(`
4
+ `)&&n.grantFlags.clipboardWrite&&r.clipboardPasteMultiline)return await e.executor.type(i,{viaClipboard:!0}),D(`Typed (via clipboard).`);let o=De(i);for(let[t,r]of o.entries()){if(n.isAborted?.())return E(`Typing aborted after ${t} of ${o.length} graphemes (user interrupt).`);await I(xt),r===`
5
+ `||r===`\r`||r===`\r
6
+ `?await e.executor.key(`return`):r===` `?await e.executor.key(`tab`):await e.executor.type(r,{viaClipboard:!1})}return D(`Typed ${o.length} grapheme(s).`)}async function Ye(e,t,n,r){let i=k(t,`text`);if(i instanceof Error)return E(`text is required`,`bad_args`);let a;if(t.repeat!==void 0){if(typeof t.repeat!=`number`||!Number.isInteger(t.repeat)||t.repeat<1)return E(`repeat must be a positive integer`,`bad_args`);if(t.repeat>100)return E(`repeat exceeds maximum of 100`,`bad_args`);a=t.repeat}return S(i,e.executor.capabilities.platform)&&!n.grantFlags.systemKeyCombos?E(`"${i}" is a system-level shortcut. Request the \`systemKeyCombos\` grant via request_access to use it.`,`grant_flag_required`):await N(e,n,r,`keyboard`)||(await e.executor.key(i,a),D(`Key pressed.`))}async function Xe(e,t,n,r){let i=A(t);if(i instanceof Error)return E(i.message,`bad_args`);let[a,o]=i,s=t.scroll_direction;if(s!==`up`&&s!==`down`&&s!==`left`&&s!==`right`)return E(`scroll_direction must be 'up', 'down', 'left', or 'right'`,`bad_args`);let c=t.scroll_amount;if(typeof c!=`number`||!Number.isInteger(c)||c<0)return E(`scroll_amount must be a non-negative int`,`bad_args`);if(c>100)return E(`scroll_amount exceeds maximum of 100`,`bad_args`);let l=s===`left`?-c:s===`right`?c:0,u=s===`up`?-c:s===`down`?c:0,d=await N(e,n,r,`mouse`);if(d)return d;let f=await e.executor.getDisplaySize(n.selectedDisplayId),{x:p,y:m}=j(a,o,n.coordinateMode,f,n.lastScreenshot,e.logger);return await P(e,n,r,p,m,J?`mouse_full`:`mouse`)||(J&&(Y=!0),await e.executor.scroll(p,m,l,u),D(`Scrolled.`))}async function Ze(e,t,n,r){J&&(await e.executor.mouseUp(),J=!1,Y=!1);let i=A(t,`coordinate`);if(i instanceof Error)return E(i.message,`bad_args`);let a=i,o;if(t.start_coordinate!==void 0){let e=A(t,`start_coordinate`);if(e instanceof Error)return E(e.message,`bad_args`);o=e}let s=await N(e,n,r,`mouse`);if(s)return s;let c=await e.executor.getDisplaySize(n.selectedDisplayId),l=o===void 0?void 0:j(o[0],o[1],n.coordinateMode,c,n.lastScreenshot,e.logger),u=j(a[0],a[1],n.coordinateMode,c,n.lastScreenshot,e.logger),d=l??await e.executor.getCursorPosition();return await P(e,n,r,d.x,d.y,`mouse`)||await P(e,n,r,u.x,u.y,`mouse_full`)||(await e.executor.drag(l,u),D(`Dragged.`))}async function Qe(e,t,n,r){let i=A(t);if(i instanceof Error)return E(i.message,`bad_args`);let[a,o]=i,s=await N(e,n,r,J?`mouse`:`mouse_position`);if(s)return s;let c=await e.executor.getDisplaySize(n.selectedDisplayId),{x:l,y:u}=j(a,o,n.coordinateMode,c,n.lastScreenshot,e.logger);if(J){let t=await P(e,n,r,l,u,`mouse_full`);if(t)return t}return await e.executor.moveMouse(l,u),J&&(Y=!0),D(`Moved.`)}async function $e(e,t,n){let r=k(t,`app`);if(r instanceof Error)return E(r.message,`bad_args`);let i=new Set(n.allowedApps.map(e=>e.bundleId)),a;if(a=R(r)&&i.has(r)?r:n.allowedApps.find(e=>e.displayName.toLowerCase()===r.toLowerCase())?.bundleId,!a||!i.has(a))return E(`"${r}" is not granted for this session. Call request_access first.`,`app_not_granted`);if(await e.executor.openApp(a),n.onDisplayPinned!==void 0){let t=1;try{t=(await e.executor.listDisplays()).length}catch{}if(t>=2)return D(`Opened "${r}". If it isn't visible in the next screenshot, it may have opened on a different monitor — use switch_display to check.`)}return D(`Opened "${r}".`)}async function H(e,t){if(!e.executor.virtualMouse)return E(`virtual_mouse is only available on Windows with a bound window.`,`feature_unavailable`);let n=k(t,`action`);if(n instanceof Error)return E(n.message,`bad_args`);let r=t.coordinate;if(!Array.isArray(r)||r.length<2)return E(`coordinate [x, y] is required.`,`bad_args`);let i=new Set([`click`,`double_click`,`right_click`,`move`,`drag`,`down`,`up`]);if(!i.has(n))return E(`Invalid action "${n}". Valid: ${[...i].join(`, `)}`,`bad_args`);let a=Array.isArray(t.start_coordinate)?t.start_coordinate:void 0;return await e.executor.virtualMouse({action:n,x:r[0],y:r[1],startX:a?.[0],startY:a?.[1]})?D({click:`Click at (${r[0]},${r[1]})`,double_click:`Double-click at (${r[0]},${r[1]})`,right_click:`Right-click at (${r[0]},${r[1]})`,move:`Moved to (${r[0]},${r[1]})`,drag:`Dragged ${a?`(${a[0]},${a[1]})`:`current`} → (${r[0]},${r[1]})`,down:`Button down at (${r[0]},${r[1]})`,up:`Button up at (${r[0]},${r[1]})`}[n]??n):E(`No window is currently bound.`,`bad_args`)}async function U(e,t){if(!e.executor.virtualKeyboard)return E(`virtual_keyboard is only available on Windows with a bound window.`,`feature_unavailable`);let n=k(t,`action`);if(n instanceof Error)return E(n.message,`bad_args`);let r=k(t,`text`);if(r instanceof Error)return E(r.message,`bad_args`);let i=new Set([`type`,`combo`,`press`,`release`,`hold`]);if(!i.has(n))return E(`Invalid action "${n}". Valid: ${[...i].join(`, `)}`,`bad_args`);let a=typeof t.duration==`number`?t.duration:void 0,o=typeof t.repeat==`number`?t.repeat:void 0;return await e.executor.virtualKeyboard({action:n,text:r,duration:a,repeat:o})?D(`${{type:`Typed "${r.length>40?r.slice(0,40)+`...`:r}"`,combo:`Sent ${r}`,press:`Pressed ${r} (holding)`,release:`Released ${r}`,hold:`Held ${r} for ${a??1}s`}[n]}${o&&o>1?` ×${o}`:``}`):E(`No window is currently bound. Use open_application or bind_window first.`,`bad_args`)}async function et(e,t){if(!e.executor.statusIndicator)return E(`status_indicator is only available on Windows.`,`feature_unavailable`);let n=k(t,`action`);if(n instanceof Error)return E(n.message,`bad_args`);if(![`show`,`hide`,`status`].includes(n))return E(`Invalid action "${n}". Valid: show, hide, status.`,`bad_args`);let r=typeof t.message==`string`?t.message:void 0;if(n===`show`&&!r)return E(`'show' requires a message parameter.`,`bad_args`);let i=await e.executor.statusIndicator(n,r);return D(n===`status`?i.active?`Indicator is active on the bound window.`:`Indicator is not active (no window bound).`:n===`show`?`Indicator showing: "${r}"`:`Indicator hidden.`)}async function tt(e,t){if(!e.executor.mouseWheel)return E(`mouse_wheel is only available on Windows with a bound window.`,`feature_unavailable`);let n=t.coordinate;if(!Array.isArray(n)||n.length<2)return E(`coordinate must be [x, y] array.`,`bad_args`);let r=typeof t.delta==`number`?t.delta:void 0;if(r===void 0)return E(`delta is required (positive=up, negative=down).`,`bad_args`);let i=t.direction===`horizontal`;return await e.executor.mouseWheel(n[0],n[1],r,i)?D(`Mouse wheel: ${i?`horizontal`:`vertical`} scroll ${r>0?`up`:`down`} ${Math.abs(r)} click(s) at (${n[0]},${n[1]}).`):E(`No window is currently bound. Use open_application or bind_window first.`,`bad_args`)}async function nt(e,t){if(!e.executor.activateWindow)return E(`activate_window is only available on Windows with a bound window.`,`feature_unavailable`);let n=typeof t.click_x==`number`?t.click_x:void 0,r=typeof t.click_y==`number`?t.click_y:void 0;return await e.executor.activateWindow(n,r)?D(`Window activated and focused. Ready for input.`):E(`No window is currently bound. Use open_application or bind_window first.`,`bad_args`)}async function rt(e,t){if(!e.executor.respondToPrompt)return E(`prompt_respond is only available on Windows with a bound window.`,`feature_unavailable`);let n=k(t,`response_type`);if(n instanceof Error)return E(n.message,`bad_args`);let r=new Set([`yes`,`no`,`enter`,`escape`,`select`,`type`]);return r.has(n)?n===`select`&&typeof t.arrow_count!=`number`?E(`'select' requires arrow_count parameter.`,`bad_args`):n===`type`&&typeof t.text!=`string`?E(`'type' requires text parameter.`,`bad_args`):await e.executor.respondToPrompt({responseType:n,arrowDirection:typeof t.arrow_direction==`string`?t.arrow_direction:void 0,arrowCount:typeof t.arrow_count==`number`?t.arrow_count:void 0,text:typeof t.text==`string`?t.text:void 0})?D(`Prompt responded: ${{yes:`Sent 'y' + Enter.`,no:`Sent 'n' + Enter.`,enter:`Sent Enter.`,escape:`Sent Escape.`,select:`Navigated ${t.arrow_direction??`down`} ${t.arrow_count??1} time(s) + Enter.`,type:`Typed "${t.text}" + Enter.`}[n]??n}. Take a screenshot to verify.`):E(`No window is currently bound. Use open_application or bind_window first.`,`bad_args`):E(`Invalid response_type "${n}". Valid: ${[...r].join(`, `)}`,`bad_args`)}async function it(e,t){if(!e.executor.openTerminal)return E(`open_terminal is only available on Windows.`,`feature_unavailable`);let n=k(t,`agent`);if(n instanceof Error)return E(n.message,`bad_args`);if(!new Set([`claude`,`codex`,`gemini`,`custom`]).has(n))return E(`Invalid agent "${n}". Valid: claude, codex, gemini, custom.`,`bad_args`);if(n===`custom`&&typeof t.command!=`string`)return E(`agent='custom' requires 'command' parameter.`,`bad_args`);let r=await e.executor.openTerminal({agent:n,command:typeof t.command==`string`?t.command:void 0,terminal:typeof t.terminal==`string`?t.terminal:void 0,workingDirectory:typeof t.working_directory==`string`?t.working_directory:void 0});return r?r.launched?D(`Terminal opened and ${{claude:`Claude Code`,codex:`Codex`,gemini:`Gemini`,custom:t.command}[n]??n} launched.\nWindow: hwnd=${r.hwnd} "${r.title}"\nCommand: '${n===`custom`?t.command:n}' + Enter\nStatus: bound to this terminal. Take a screenshot to verify the agent started.`):D(`Terminal opened (hwnd=${r.hwnd}, "${r.title}") but no command was sent. Window is now bound.`):E(`Failed to open terminal. Windows Terminal (wt.exe) may not be installed.`,`launch_failed`)}async function at(e,t){let n=k(t,`action`);if(n instanceof Error)return E(n.message,`bad_args`);switch(n){case`list`:{if(!e.executor.listVisibleWindows)return E(`bind_window is only available on Windows.`,`feature_unavailable`);let t=await e.executor.listVisibleWindows();if(t.length===0)return D(`No visible windows found.`);let n=t.map(e=>`hwnd=${e.hwnd} pid=${e.pid} "${e.title}"`);return D(`Visible windows (${t.length}):\n${n.join(`
7
+ `)}`)}case`status`:{if(!e.executor.getBindingStatus)return E(`bind_window is only available on Windows.`,`feature_unavailable`);let t=await e.executor.getBindingStatus();if(!t||!t.bound)return D(`No window is currently bound. Use bind_window(action='list') to see available windows, then bind_window(action='bind', title='...') to bind.`);let n=`Bound to: hwnd=${t.hwnd}`;return t.title&&(n+=` "${t.title}"`),t.pid&&(n+=` pid=${t.pid}`),t.rect&&(n+=` rect=(${t.rect.x},${t.rect.y} ${t.rect.width}x${t.rect.height})`),D(n)}case`bind`:{if(!e.executor.bindToWindow)return E(`bind_window is only available on Windows.`,`feature_unavailable`);let n=typeof t.title==`string`?t.title:void 0,r=typeof t.hwnd==`string`?t.hwnd:void 0,i=typeof t.pid==`number`?t.pid:void 0;if(!n&&!r&&!i)return E(`Specify at least one of: title, hwnd, or pid.`,`bad_args`);let a=await e.executor.bindToWindow({hwnd:r,title:n,pid:i});return a?D(`Bound to window: hwnd=${a.hwnd} pid=${a.pid} "${a.title}". All subsequent screenshot/click/type operations target this window.`):E(`No window found matching: ${[n&&`title="${n}"`,r&&`hwnd=${r}`,i&&`pid=${i}`].filter(Boolean).join(`, `)}. Use bind_window(action='list') to see available windows.`,`element_not_found`)}case`unbind`:return e.executor.unbindFromWindow?(await e.executor.unbindFromWindow(),D(`Window binding released. Operations now target the full screen.`)):E(`bind_window is only available on Windows.`,`feature_unavailable`);default:return E(`Unknown bind_window action "${n}". Valid: list, bind, unbind, status.`,`bad_args`)}}async function ot(e,t){if(!e.executor.clickElement)return E(`click_element is only available on Windows with a bound window.`,`feature_unavailable`);let n=typeof t.name==`string`?t.name:void 0,r=typeof t.role==`string`?t.role:void 0,i=typeof t.automationId==`string`?t.automationId:void 0;return!n&&!r&&!i?E(`At least one of name, role, or automationId is required.`,`bad_args`):await e.executor.clickElement({name:n,role:r,automationId:i})?D(`Clicked element: ${[n&&`"${n}"`,r,i].filter(Boolean).join(` `)}`):E(`Element not found: ${[n&&`name="${n}"`,r&&`role=${r}`,i&&`id=${i}`].filter(Boolean).join(`, `)}. Take a screenshot to see current GUI elements.`,`element_not_found`)}async function st(e,t){if(!e.executor.typeIntoElement)return E(`type_into_element is only available on Windows with a bound window.`,`feature_unavailable`);let n=k(t,`text`);if(n instanceof Error)return E(n.message,`bad_args`);let r=typeof t.name==`string`?t.name:void 0,i=typeof t.role==`string`?t.role:void 0,a=typeof t.automationId==`string`?t.automationId:void 0;return await e.executor.typeIntoElement({name:r,role:i,automationId:a},n)?D(`Typed ${n.length} chars into: ${[r&&`"${r}"`,i,a].filter(Boolean).join(` `)}`):E(`Could not type into element: ${[r&&`name="${r}"`,i&&`role=${i}`,a&&`id=${a}`].filter(Boolean).join(`, `)}. The element was not found or doesn't support text input.`,`element_not_found`)}async function ct(e,t){let n=k(t,`action`);if(n instanceof Error)return E(n.message,`bad_args`);let r=new Set([`minimize`,`maximize`,`restore`,`close`,`focus`,`move_offscreen`,`move_resize`,`get_rect`]);if(!r.has(n))return E(`Unknown window_management action "${n}". Valid: ${[...r].join(`, `)}`,`bad_args`);if(!e.executor.manageWindow)return E(`window_management is only available on Windows with a bound window.`,`feature_unavailable`);if(n===`get_rect`){if(!e.executor.getWindowRect)return E(`getWindowRect not available.`,`feature_unavailable`);let t=await e.executor.getWindowRect();return t?D(`Window rect: x=${t.x}, y=${t.y}, width=${t.width}, height=${t.height}`):E(`No window is currently bound. Call open_application first.`,`bad_args`)}if(n===`move_resize`){let r=typeof t.x==`number`?t.x:void 0,i=typeof t.y==`number`?t.y:void 0;if(r===void 0||i===void 0)return E(`move_resize requires x and y parameters.`,`bad_args`);let a=typeof t.width==`number`?t.width:void 0,o=typeof t.height==`number`?t.height:void 0;return await e.executor.manageWindow(n,{x:r,y:i,width:a,height:o})?D(a&&o?`Moved window to (${r}, ${i}) and resized to ${a}×${o}.`:`Moved window to (${r}, ${i}).`):E(`No window is currently bound. Call open_application first.`,`bad_args`)}return await e.executor.manageWindow(n)?D({minimize:`Window minimized (ShowWindow SW_MINIMIZE).`,maximize:`Window maximized (ShowWindow SW_MAXIMIZE).`,restore:`Window restored (ShowWindow SW_RESTORE).`,close:`Window closed (SendMessage WM_CLOSE). The window binding has been released.`,focus:`Window brought to front (SetForegroundWindow).`,move_offscreen:`Window moved offscreen (-32000,-32000). Still usable via SendMessage/PrintWindow.`}[n]??`Action "${n}" completed.`):E(`No window is currently bound. Call open_application first.`,`bad_args`)}async function lt(e,t,n){let r=k(t,`display`);if(r instanceof Error)return E(r.message,`bad_args`);if(!n.onDisplayPinned)return E(`Display switching is not available in this session.`,`feature_unavailable`);if(r.toLowerCase()===`auto`)return n.onDisplayPinned(void 0),D(`Returned to automatic monitor selection. Call screenshot to continue.`);let i;try{i=await e.executor.listDisplays()}catch(e){return E(`Failed to enumerate displays: ${String(e)}`,`display_error`)}if(i.length<2)return E(`Only one monitor is connected. There is nothing to switch to.`,`bad_args`);let a=We(i),o=r.toLowerCase(),s=i.find(e=>a.get(e.displayId)?.toLowerCase()===o);return s?(n.onDisplayPinned(s.displayId),D(`Switched to monitor "${a.get(s.displayId)}". Call screenshot to see it.`)):E(`No monitor named "${r}" is connected. Available monitors: ${i.map(e=>`"${a.get(e.displayId)}"`).join(`, `)}.`,`bad_args`)}function ut(e){return O({allowedApps:e.allowedApps,grantFlags:e.grantFlags})}async function dt(e,t,n){if(!t.grantFlags.clipboardRead)return E("Clipboard read is not granted. Request `clipboardRead` via request_access.",`grant_flag_required`);if(n.clipboardGuard){let n=await e.executor.getFrontmostApp(),r=new Map(t.allowedApps.map(e=>[e.bundleId,e.tier]));await M(e,t,(n?r.get(n.bundleId):void 0)===`click`)}return O({text:await e.executor.readClipboard()})}async function ft(e,t,n,r){if(!n.grantFlags.clipboardWrite)return E("Clipboard write is not granted. Request `clipboardWrite` via request_access.",`grant_flag_required`);let i=k(t,`text`);if(i instanceof Error)return E(i.message,`bad_args`);if(r.clipboardGuard){let t=await e.executor.getFrontmostApp(),r=new Map(n.allowedApps.map(e=>[e.bundleId,e.tier])),i=t?r.get(t.bundleId):void 0;if(t&&i===`click`)return E(`"${t.displayName}" is a tier-"click" app and currently frontmost. write_clipboard is blocked because the next action would clear the clipboard anyway — a UI Paste button in this app cannot be used to inject text. Bring a tier-"full" app forward before writing to the clipboard. Do not attempt to work around this restriction — never use AppleScript, System Events, shell commands, or any other method to send clicks or keystrokes to this app.`,`tier_insufficient`);await M(e,n,i===`click`)}return await e.executor.writeClipboard(i),D(`Clipboard written.`)}async function pt(e){let t=e.duration;return typeof t!=`number`||!Number.isFinite(t)?E(`duration must be a number`,`bad_args`):t<0?E(`duration must be non-negative`,`bad_args`):t>100?E(`duration is too long. Duration is in seconds.`,`bad_args`):(await I(t*1e3),D(`Waited ${t}s.`))}async function mt(e,t){let n=await e.executor.getCursorPosition(),r=t.lastScreenshot;if(r){let e=n.x-r.originX,t=n.y-r.originY;return e<0||e>r.displayWidth||t<0||t>r.displayHeight?O({x:n.x,y:n.y,coordinateSpace:`logical_points`,note:`cursor is on a different monitor than your last screenshot; take a fresh screenshot`}):O({x:Math.round(e*(r.width/r.displayWidth)),y:Math.round(t*(r.height/r.displayHeight)),coordinateSpace:`image_pixels`})}return O({x:n.x,y:n.y,coordinateSpace:`logical_points`,note:`take a screenshot first for image-pixel coordinates`})}async function ht(e,t,n,r){let i=k(t,`text`);if(i instanceof Error)return E(i.message,`bad_args`);let a=t.duration;if(typeof a!=`number`||!Number.isFinite(a))return E(`duration must be a number`,`bad_args`);if(a<0)return E(`duration must be non-negative`,`bad_args`);if(a>100)return E(`duration is too long. Duration is in seconds.`,`bad_args`);if(S(i,e.executor.capabilities.platform)&&!n.grantFlags.systemKeyCombos)return E(`"${i}" is a system-level shortcut. Request the \`systemKeyCombos\` grant via request_access to use it.`,`grant_flag_required`);let o=await N(e,n,r,`keyboard`);if(o)return o;let s=Oe(i);return await e.executor.holdKey(s,a*1e3),D(`Key held.`)}async function gt(e,t,n){if(J)return E(`mouse button already held, call left_mouse_up first`,`state_conflict`);let r=await N(e,t,n,`mouse`);if(r)return r;let i=await e.executor.getCursorPosition();return await P(e,t,n,i.x,i.y,`mouse`)||(await e.executor.mouseDown(),J=!0,Y=!1,D(`Mouse button pressed.`))}async function _t(e,t,n){let r=async t=>(await e.executor.mouseUp(),J=!1,Y=!1,t),i=await N(e,t,n,`mouse`);if(i)return r(i);let a=await e.executor.getCursorPosition(),o=await P(e,t,n,a.x,a.y,Y?`mouse_full`:`mouse`);return o?r(o):(await e.executor.mouseUp(),J=!1,Y=!1,D(`Mouse button released.`))}async function vt(e,t,n,r){let i=t.actions;if(!Array.isArray(i)||i.length===0)return E(`actions must be a non-empty array`,`bad_args`);for(let[e,t]of i.entries()){if(typeof t!=`object`||!t)return E(`actions[${e}] must be an object`,`bad_args`);let n=t.action;if(typeof n!=`string`)return E(`actions[${e}].action must be a string`,`bad_args`);if(!X.has(n))return E(`actions[${e}].action="${n}" is not allowed in a batch. Allowed: ${[...X].join(`, `)}.`,`bad_args`)}if(r.hideBeforeAction){let t=await e.executor.prepareForAction(n.allowedApps.map(e=>e.bundleId),n.selectedDisplayId);t.length>0&&n.onAppsHidden?.(t)}let a={...r,hideBeforeAction:!1,pixelValidation:!1,autoTargetDisplay:!1},o=[];for(let[t,r]of i.entries()){if(n.isAborted?.())return await L(e),E(`Batch aborted after ${o.length} of ${i.length} actions (user interrupt).`);t>0&&await I(10);let s=r,c=s.action,{screenshot:l,...u}=await W(c,s,e,n,a),d=yt(u),f={action:c,ok:!u.isError,output:d};if(o.push(f),u.isError)return await L(e),O({completed:o.slice(0,-1),failed:f,remaining:i.length-o.length},u.telemetry)}return O({completed:o})}function yt(e){let t=e.content[0];return t&&t.type===`text`?t.text:``}async function W(e,t,n,r,i){if(await n.executor.hasBoundWindow?.()===!0&&n.executor.virtualMouse&&n.executor.virtualKeyboard){let r=Array.isArray(t.coordinate)?t.coordinate:void 0;switch(e){case`left_click`:if(r)return H(n,{action:`click`,coordinate:r});break;case`double_click`:if(r)return H(n,{action:`double_click`,coordinate:r});break;case`right_click`:if(r)return H(n,{action:`right_click`,coordinate:r});break;case`mouse_move`:if(r)return H(n,{action:`move`,coordinate:r});break;case`left_click_drag`:if(r)return H(n,{action:`drag`,coordinate:r,start_coordinate:Array.isArray(t.start_coordinate)?t.start_coordinate:void 0});break;case`left_mouse_down`:if(r)return H(n,{action:`down`,coordinate:r});break;case`left_mouse_up`:if(r)return H(n,{action:`up`,coordinate:r});break;case`type`:if(typeof t.text==`string`)return U(n,{action:`type`,text:t.text});break;case`key`:if(typeof t.text==`string`)return U(n,{action:`combo`,text:t.text,repeat:t.repeat});break;case`hold_key`:if(typeof t.text==`string`)return U(n,{action:`hold`,text:t.text,duration:typeof t.duration==`number`?t.duration:1});break;case`scroll`:if(r)return tt(n,{coordinate:r,delta:t.scroll_direction===`up`?t.scroll_amount??3:-(t.scroll_amount??3),direction:t.scroll_direction===`left`||t.scroll_direction===`right`?`horizontal`:`vertical`});break}}switch(e){case`screenshot`:return Ke(n,r,i);case`zoom`:return qe(n,t,r);case`left_click`:return V(n,t,r,i,`left`,1);case`double_click`:return V(n,t,r,i,`left`,2);case`triple_click`:return V(n,t,r,i,`left`,3);case`right_click`:return V(n,t,r,i,`right`,1);case`middle_click`:return V(n,t,r,i,`middle`,1);case`type`:return Je(n,t,r,i);case`key`:return Ye(n,t,r,i);case`scroll`:return Xe(n,t,r,i);case`left_click_drag`:return Ze(n,t,r,i);case`mouse_move`:return Qe(n,t,r,i);case`wait`:return pt(t);case`cursor_position`:return mt(n,r);case`hold_key`:return ht(n,t,r,i);case`left_mouse_down`:return gt(n,r,i);case`left_mouse_up`:return _t(n,r,i);case`open_application`:return $e(n,t,r);case`window_management`:return ct(n,t);case`click_element`:return ot(n,t);case`type_into_element`:return st(n,t);case`open_terminal`:return it(n,t);case`bind_window`:return at(n,t);case`virtual_mouse`:return H(n,t);case`virtual_keyboard`:return U(n,t);case`status_indicator`:return et(n,t);case`mouse_wheel`:return tt(n,t);case`activate_window`:return nt(n,t);case`prompt_respond`:return rt(n,t);case`switch_display`:return lt(n,t,r);case`list_granted_applications`:return ut(r);case`read_clipboard`:return dt(n,r,i);case`write_clipboard`:return ft(n,t,r,i);case`computer_batch`:return vt(n,t,r,i);default:return E(`Unknown tool "${e}".`,`bad_args`)}}async function bt(e,t,n,r){let{logger:i,serverName:a}=e,o=new Set(r.userDeniedBundleIds),c=r.allowedApps.some(e=>e.tier===void 0||o.has(e.bundleId)||_(e.bundleId,e.displayName))?{...r,allowedApps:r.allowedApps.filter(e=>!o.has(e.bundleId)).filter(e=>!_(e.bundleId,e.displayName)).map(e=>e.tier===void 0?{...e,tier:x(e.bundleId,e.displayName)}:e)}:r;if(e.isDisabled())return E(`Computer control is disabled in Settings. Enable it and try again.`,`other`);let l=await e.ensureOsPermissions(),u;if(!l.granted){if(t!==`request_access`&&t!==`request_teach_access`)return E(`Accessibility and Screen Recording permissions are required. Call request_access to show the permission panel.`,`tcc_not_granted`);u={accessibility:l.accessibility,screenRecording:l.screenRecording}}let d=Ae(t),f=c.checkCuLock?.();if(f){if(f.holder!==void 0&&!f.isSelf)return E(`Another Claude session is currently using the computer. Wait for the user to acknowledge it is finished (stop button in the Claude window), or find a non-computer-use approach if one is readily apparent.`,`cu_lock_held`);f.holder===void 0&&!d&&(c.acquireCuLock?.(),ke())}let p=e.getSubGates(),m=Ce(n);i.silly(`[${a}] tool=${t} args=${JSON.stringify(m).slice(0,200)}`);try{return t===`request_access`?await Me(e,m,c,u):t===`request_teach_access`?await Le(e,m,c,u):t===`teach_step`?await Ve(e,m,c,p):t===`teach_batch`?await He(e,m,c,p):await W(t,m,e,c,p)}catch(e){let n=e instanceof Error?e.message:String(e);return i.error(`[${a}] tool=${t} threw: ${n}`,s(e)),E(`Tool "${t}" failed: ${n}`,`executor_threw`)}}var G,K,q,xt,J,Y,St,X,Ct=e((()=>{ce(),pe(),Se(),h(),l(),G=`com.apple.finder`,K=` Do not attempt to work around this restriction — never use AppleScript, System Events, shell commands, or any other method to send clicks or keystrokes to this app.`,q=1024,xt=8,J=!1,Y=!1,St=/^[A-Za-z0-9][\w.-]*\.[A-Za-z0-9][\w.-]*$/,X=new Set([`key`,`type`,`mouse_move`,`left_click`,`left_click_drag`,`right_click`,`middle_click`,`double_click`,`triple_click`,`scroll`,`hold_key`,`screenshot`,`cursor_position`,`left_mouse_down`,`left_mouse_up`,`wait`])}));function wt(e,t,n){let r=Et[t],i=n&&n.length>0?` Available applications on this machine: ${n.join(`, `)}.`:``,a={type:`array`,items:{type:`number`},minItems:2,maxItems:2,description:`(x, y): ${r.x}`},o={type:`string`,description:`Modifier keys to hold during the click (e.g. "shift", "ctrl+shift"). Supports the same syntax as the key tool.`},s=e.screenshotFiltering===`native`?`Take a screenshot of the primary display. Applications not in the session allowlist are excluded at the compositor level — only granted apps and the desktop are visible.`:`Take a screenshot of the primary display. On this platform, screenshots are NOT filtered — all open windows are visible. Input actions targeting apps not in the session allowlist are rejected.`;return[{name:`request_access`,description:`Request user permission to control a set of applications for this session. Must be called before any other tool in this server. The user sees a single dialog listing all requested apps and either allows the whole set or denies it. Call this again mid-session to add more apps; previously granted apps remain granted. Returns the granted apps, denied apps, and screenshot filtering capability.`,inputSchema:{type:`object`,properties:{apps:{type:`array`,items:{type:`string`},description:`Application display names (e.g. "Slack", "Calendar") or bundle identifiers (e.g. "com.tinyspeck.slackmacgap"). Display names are resolved case-insensitively against installed apps.`+i},reason:{type:`string`,description:`One-sentence explanation shown to the user in the approval dialog. Explain the task, not the mechanism.`},clipboardRead:{type:`boolean`,description:`Also request permission to read the user's clipboard (separate checkbox in the dialog).`},clipboardWrite:{type:`boolean`,description:"Also request permission to write the user's clipboard. When granted, multi-line `type` calls use the clipboard fast path."},systemKeyCombos:{type:`boolean`,description:`Also request permission to send system-level key combos (quit app, switch app, lock screen). Without this, those specific combos are blocked.`}},required:[`apps`,`reason`]}},{name:`screenshot`,description:s+` Returns an error if the allowlist is empty. The returned image is what subsequent click coordinates are relative to.`,inputSchema:{type:`object`,properties:{save_to_disk:{type:`boolean`,description:`Save the image to disk so it can be attached to a message for the user. Returns the saved path in the tool result. Only set this when you intend to share the image — screenshots you're just looking at don't need saving.`}},required:[]}},{name:`zoom`,description:`Take a higher-resolution screenshot of a specific region of the last full-screen screenshot. Use this liberally to inspect small text, button labels, or fine UI details that are hard to read in the downsampled full-screen image. IMPORTANT: Coordinates in subsequent click calls always refer to the full-screen screenshot, never the zoomed image. This tool is read-only for inspecting detail.`,inputSchema:{type:`object`,properties:{region:{type:`array`,items:{type:`integer`},minItems:4,maxItems:4,description:`(x0, y0, x1, y1): Rectangle to zoom into, in the coordinate space of the most recent full-screen screenshot. x0,y0 = top-left, x1,y1 = bottom-right.`},save_to_disk:{type:`boolean`,description:`Save the image to disk so it can be attached to a message for the user. Returns the saved path in the tool result. Only set this when you intend to share the image.`}},required:[`region`]}},{name:`left_click`,description:`Left-click at the given coordinates. ${Z}`,inputSchema:{type:`object`,properties:{coordinate:a,text:o},required:[`coordinate`]}},{name:`double_click`,description:`Double-click at the given coordinates. Selects a word in most text editors. ${Z}`,inputSchema:{type:`object`,properties:{coordinate:a,text:o},required:[`coordinate`]}},{name:`triple_click`,description:`Triple-click at the given coordinates. Selects a line in most text editors. ${Z}`,inputSchema:{type:`object`,properties:{coordinate:a,text:o},required:[`coordinate`]}},{name:`right_click`,description:`Right-click at the given coordinates. Opens a context menu in most applications. ${Z}`,inputSchema:{type:`object`,properties:{coordinate:a,text:o},required:[`coordinate`]}},{name:`middle_click`,description:`Middle-click (scroll-wheel click) at the given coordinates. ${Z}`,inputSchema:{type:`object`,properties:{coordinate:a,text:o},required:[`coordinate`]}},{name:`type`,description:`Type text into whatever currently has keyboard focus. ${Z} Newlines are supported. For keyboard shortcuts use \`key\` instead.`,inputSchema:{type:`object`,properties:{text:{type:`string`,description:`Text to type.`}},required:[`text`]}},{name:`key`,description:`Press a key or key combination (e.g. "return", "escape", "cmd+a", "ctrl+shift+tab"). ${Z} System-level combos (quit app, switch app, lock screen) require the \`systemKeyCombos\` grant — without it they return an error. All other combos work.`,inputSchema:{type:`object`,properties:{text:{type:`string`,description:`Modifiers joined with "+", e.g. "cmd+shift+a".`},repeat:{type:`integer`,minimum:1,maximum:100,description:`Number of times to repeat the key press. Default is 1.`}},required:[`text`]}},{name:`scroll`,description:`Scroll at the given coordinates. ${Z}`,inputSchema:{type:`object`,properties:{coordinate:a,scroll_direction:{type:`string`,enum:[`up`,`down`,`left`,`right`],description:`Direction to scroll.`},scroll_amount:{type:`integer`,minimum:0,maximum:100,description:`Number of scroll ticks.`}},required:[`coordinate`,`scroll_direction`,`scroll_amount`]}},{name:`left_click_drag`,description:`Press, move to target, and release. ${Z}`,inputSchema:{type:`object`,properties:{coordinate:{...a,description:`(x, y) end point: ${r.x}`},start_coordinate:{...a,description:`(x, y) start point. If omitted, drags from the current cursor position. ${r.x}`}},required:[`coordinate`]}},{name:`mouse_move`,description:`Move the mouse cursor without clicking. Useful for triggering hover states. ${Z}`,inputSchema:{type:`object`,properties:{coordinate:a},required:[`coordinate`]}},{name:`open_application`,description:`Bring an application to the front, launching it if necessary. The target application must already be in the session allowlist — call request_access first.`,inputSchema:{type:`object`,properties:{app:{type:`string`,description:`Display name (e.g. "Slack") or bundle identifier (e.g. "com.tinyspeck.slackmacgap").`}},required:[`app`]}},...e.platform===`win32`?[{name:`window_management`,description:`Manage the bound application window via Win32 API calls (ShowWindow, SetWindowPos, SendMessage). All operations target the bound HWND directly — NO global shortcuts (Win+Down, Alt+F4, etc.). The window must have been opened via open_application first. Actions: minimize (hide to taskbar), maximize (fill screen), restore (undo min/max), close (graceful WM_CLOSE), focus (bring to front), move_offscreen (move to -32000,-32000 for background operation). Use move_resize to reposition or resize the window to specific coordinates.`,inputSchema:{type:`object`,properties:{action:{type:`string`,enum:[`minimize`,`maximize`,`restore`,`close`,`focus`,`move_offscreen`,`move_resize`,`get_rect`],description:`minimize: ShowWindow(SW_MINIMIZE). maximize: ShowWindow(SW_MAXIMIZE). restore: ShowWindow(SW_RESTORE) — undo minimize or maximize. close: SendMessage(WM_CLOSE) — graceful close. focus: SetForegroundWindow + BringWindowToTop. move_offscreen: SetWindowPos(-32000,-32000) — keeps window usable by SendMessage/PrintWindow but invisible. move_resize: SetWindowPos to specific x,y,width,height. get_rect: GetWindowRect — returns current position and size.`},x:{type:`integer`,description:`X position for move_resize.`},y:{type:`integer`,description:`Y position for move_resize.`},width:{type:`integer`,description:`Width for move_resize.`},height:{type:`integer`,description:`Height for move_resize.`}},required:[`action`]}},{name:`click_element`,description:`Click a GUI element by its accessible name, role, or automationId — no pixel coordinates needed. Uses Windows UI Automation to find the element and InvokePattern to click it. Prefer this over left_click when the element name is visible in the accessibility snapshot. Falls back to BoundingRect center-click if InvokePattern is not supported.`,inputSchema:{type:`object`,properties:{name:{type:`string`,description:`Accessible name of the element (e.g. "Save", "File", "Search..."). Case-insensitive partial match.`},role:{type:`string`,description:`Control type (e.g. "Button", "MenuItem", "Edit", "Link"). Optional — narrows the search.`},automationId:{type:`string`,description:`Exact automationId from the accessibility snapshot. Most precise selector.`}},required:[]}},{name:`type_into_element`,description:`Type text into a named GUI element using Windows UI Automation ValuePattern. Finds the element by name/role/automationId, then sets its value directly — no need to click first or use pixel coordinates. Works on Edit, ComboBox, and other value-holding controls.`,inputSchema:{type:`object`,properties:{name:{type:`string`,description:`Accessible name of the target element.`},role:{type:`string`,description:`Control type (optional, e.g. "Edit").`},automationId:{type:`string`,description:`Exact automationId.`},text:{type:`string`,description:`Text to type/set into the element.`}},required:[`text`]}},{name:`open_terminal`,description:`Open a new terminal window and launch an AI agent CLI. This is a workflow tool that automates: open terminal → type startup command → press Enter → wait → verify. Supported agents: claude (runs 'claude'), codex (runs 'codex'), gemini (runs 'gemini'), or any custom command. After launching, the tool binds to the new terminal window and takes a screenshot to verify the agent started successfully. Use this when the user says: 'open Claude Code', 'start a Codex terminal', 'launch Gemini', etc.`,inputSchema:{type:`object`,properties:{agent:{type:`string`,enum:[`claude`,`codex`,`gemini`,`custom`],description:`Which agent to launch. claude: runs 'claude' command. codex: runs 'codex' command. gemini: runs 'gemini' command. custom: runs the command specified in 'command' parameter.`},command:{type:`string`,description:`Custom command to run in the terminal. Only used when agent='custom'. Example: 'python app.py'`},terminal:{type:`string`,enum:[`wt`,`powershell`,`cmd`],description:`Which terminal to open. Default: 'wt' (Windows Terminal). 'powershell' for PowerShell window, 'cmd' for Command Prompt.`},working_directory:{type:`string`,description:`Working directory for the terminal. If omitted, uses current directory.`}},required:[`agent`]}},{name:`bind_window`,description:`Bind to a specific window for all subsequent operations (screenshot, click, type, etc.). Once bound, screenshots capture only that window via PrintWindow, and all input goes through SendMessageW — no cursor movement, no focus steal, no interference with the user's desktop. Actions: bind (by title, hwnd, or pid), unbind (release binding), status (show current binding), list (show all visible windows). Use 'list' first to see available windows, then 'bind' with a title or hwnd. open_application auto-binds the launched window, but use this tool to bind to already-running windows or switch between windows.`,inputSchema:{type:`object`,properties:{action:{type:`string`,enum:[`bind`,`unbind`,`status`,`list`],description:`bind: Bind to a window (specify title, hwnd, or pid). unbind: Release the current binding, return to full-screen mode. status: Show the currently bound window (hwnd, title, rect). list: List all visible windows with hwnd, pid, and title.`},title:{type:`string`,description:`Window title to search for (partial match, case-insensitive). For 'bind' action.`},hwnd:{type:`string`,description:`Exact window handle from 'list' output. For 'bind' action.`},pid:{type:`integer`,description:`Process ID to find window for. For 'bind' action.`}},required:[`action`]}},{name:`activate_window`,description:`Activate the bound window: bring it to foreground, click to ensure keyboard focus, and optionally send an initial key sequence. Use this before any input operations to guarantee the window is ready to receive keyboard/mouse events. Combines SetForegroundWindow + BringWindowToTop + SendMessage(WM_LBUTTONDOWN) in one call.`,inputSchema:{type:`object`,properties:{click_x:{type:`integer`,description:`X coordinate to click after activation (client-area). If omitted, clicks center of window.`},click_y:{type:`integer`,description:`Y coordinate to click after activation (client-area). If omitted, clicks center of window.`}},required:[]}},{name:`prompt_respond`,description:`Handle interactive CLI/terminal prompts (Yes/No, selection menus, confirmations). Sends a sequence of key events to the bound window to navigate and confirm a prompt. This is a convenience wrapper around bound-window keyboard input for common prompt flows. Typical flows: 1) Yes/No prompt → send 'y' or 'n' + Enter. 2) Arrow-key selection menu → send arrow_down/arrow_up N times + Enter. 3) Text input prompt → type the response + Enter. After responding, take a screenshot to verify the result.`,inputSchema:{type:`object`,properties:{response_type:{type:`string`,enum:[`yes`,`no`,`enter`,`escape`,`select`,`type`],description:`yes: send 'y' + Enter. no: send 'n' + Enter. enter: send Enter only. escape: send Escape (cancel). select: use arrow keys to navigate to an option, then Enter. Requires 'arrow_count'. type: type custom text then Enter. Requires 'text'.`},arrow_direction:{type:`string`,enum:[`up`,`down`],description:`Arrow key direction for 'select' type. Default: 'down'.`},arrow_count:{type:`integer`,description:`Number of arrow key presses for 'select' type. Default: 1.`,minimum:0,maximum:50},text:{type:`string`,description:`Text to type for 'type' response_type.`}},required:[`response_type`]}},{name:`status_indicator`,description:`Control the visual status indicator overlay on the bound window. The indicator is a small floating label at the bottom of the window that shows what Computer Use is doing. It auto-shows during click/type/key/scroll operations, but you can also send custom messages. Actions: show (display a custom message), hide (dismiss), status (check if active).`,inputSchema:{type:`object`,properties:{action:{type:`string`,enum:[`show`,`hide`,`status`],description:`show: display a custom message on the indicator. hide: dismiss the indicator. status: check if indicator is active.`},message:{type:`string`,description:`Custom message to display (for 'show' action). Supports emoji. Auto-fades after 2 seconds.`}},required:[`action`]}},{name:`virtual_keyboard`,description:`Send keyboard input directly to the bound window via SendMessageW — independent of the physical keyboard. The user can keep typing on their own keyboard without interference. Supports: single keys, key combinations (Ctrl+S, Alt+F4), text input, and hold-key operations. All input targets the bound HWND only — no global keyboard events.`,inputSchema:{type:`object`,properties:{action:{type:`string`,enum:[`type`,`combo`,`press`,`release`,`hold`],description:`type: Send text string via WM_CHAR (Unicode, supports Chinese/emoji). combo: Send a key combination like ctrl+s, alt+f4, ctrl+shift+a (press all, release in reverse). press: Press a key down and hold it (pair with 'release'). release: Release a previously pressed key. hold: Press key(s) for a duration then release.`},text:{type:`string`,description:`For 'type': the text to input. For 'combo': key combination string (e.g. 'ctrl+s', 'alt+tab', 'ctrl+shift+a'). For 'press'/'release': single key name (e.g. 'shift', 'ctrl', 'a').`},duration:{type:`number`,description:`For 'hold': seconds to hold the key(s) before releasing. Default: 1.`},repeat:{type:`integer`,description:`Number of times to repeat the action. Default: 1.`,minimum:1,maximum:100}},required:[`action`,`text`]}},{name:`virtual_mouse`,description:`Control a virtual mouse on the bound window via SendMessageW — independent of the physical mouse. The user's real cursor stays free. All operations target the bound HWND only.`,inputSchema:{type:`object`,properties:{action:{type:`string`,enum:[`click`,`double_click`,`right_click`,`move`,`drag`,`down`,`up`],description:`click: left-click at coordinate. double_click: double left-click. right_click: right-click. move: move virtual cursor (visual only, no click). drag: press at start, move to end, release. Requires coordinate (end) and start_coordinate. down: press left button at coordinate (hold). up: release left button at coordinate.`},coordinate:{type:`array`,items:{type:`number`},minItems:2,maxItems:2,description:`(x, y) client-area coordinate on the bound window.`},start_coordinate:{type:`array`,items:{type:`number`},minItems:2,maxItems:2,description:`(x, y) start point for drag. If omitted, drags from current virtual cursor position.`}},required:[`action`,`coordinate`]}},{name:`mouse_wheel`,description:`Scroll inside the bound window using mouse wheel (WM_MOUSEWHEEL / WM_MOUSEHWHEEL). Unlike the generic 'scroll' tool which uses WM_VSCROLL (only works on scrollbar controls), mouse_wheel simulates the physical mouse wheel and works on Excel spreadsheets, web pages, code editors, PDF viewers, and any modern UI. Specify the click point within the window where the scroll should occur — this determines which panel/pane/element receives the scroll.`,inputSchema:{type:`object`,properties:{coordinate:{type:`array`,items:{type:`number`},minItems:2,maxItems:2,description:`(x, y) client-area coordinate where the scroll should occur. Determines which element receives the scroll.`},delta:{type:`integer`,description:`Scroll amount in 'clicks'. Positive = scroll up, negative = scroll down. Each click = 3 lines typically. Use -3 to -5 for page-like scrolling.`},direction:{type:`string`,enum:[`vertical`,`horizontal`],description:`Scroll direction. Default: 'vertical'. Use 'horizontal' for side-scrolling (e.g. wide Excel sheets, timeline views).`}},required:[`coordinate`,`delta`]}}]:[],{name:`switch_display`,description:`Switch which monitor subsequent screenshots capture. Use this when the application you need is on a different monitor than the one shown. The screenshot tool tells you which monitor it captured and lists other attached monitors by name — pass one of those names here. After switching, call screenshot to see the new monitor. Pass "auto" to return to automatic monitor selection.`,inputSchema:{type:`object`,properties:{display:{type:`string`,description:`Monitor name from the screenshot note (e.g. "Built-in Retina Display", "LG UltraFine"), or "auto" to re-enable automatic selection.`}},required:[`display`]}},{name:`list_granted_applications`,description:`List the applications currently in the session allowlist, plus the active grant flags and coordinate mode. No side effects.`,inputSchema:{type:`object`,properties:{},required:[]}},{name:`read_clipboard`,description:"Read the current clipboard contents as text. Requires the `clipboardRead` grant.",inputSchema:{type:`object`,properties:{},required:[]}},{name:`write_clipboard`,description:"Write text to the clipboard. Requires the `clipboardWrite` grant.",inputSchema:{type:`object`,properties:{text:{type:`string`}},required:[`text`]}},{name:`wait`,description:`Wait for a specified duration.`,inputSchema:{type:`object`,properties:{duration:{type:`number`,description:`Duration in seconds (0–100).`}},required:[`duration`]}},{name:`cursor_position`,description:`Get the current mouse cursor position. Returns image-pixel coordinates relative to the most recent screenshot, or logical points if no screenshot has been taken.`,inputSchema:{type:`object`,properties:{},required:[]}},{name:`hold_key`,description:`Press and hold a key or key combination for the specified duration, then release. ${Z} System-level combos require the \`systemKeyCombos\` grant.`,inputSchema:{type:`object`,properties:{text:{type:`string`,description:`Key or chord to hold, e.g. "space", "shift+down".`},duration:{type:`number`,description:`Duration in seconds (0–100).`}},required:[`text`,`duration`]}},{name:`left_mouse_down`,description:`Press the left mouse button at the current cursor position and leave it held. ${Z} Use mouse_move first to position the cursor. Call left_mouse_up to release. Errors if the button is already held.`,inputSchema:{type:`object`,properties:{},required:[]}},{name:`left_mouse_up`,description:`Release the left mouse button at the current cursor position. ${Z} Pairs with left_mouse_down. Safe to call even if the button is not currently held.`,inputSchema:{type:`object`,properties:{},required:[]}},{name:`computer_batch`,description:`Execute a sequence of actions in ONE tool call. Each individual tool call requires a model→API round trip (seconds); batching a predictable sequence eliminates all but one. Use this whenever you can predict the outcome of several actions ahead — e.g. click a field, type into it, press Return. Actions execute sequentially and stop on the first error. ${Z} The frontmost check runs before EACH action inside the batch — if an action opens a non-allowed app, the next action's gate fires and the batch stops there. Mid-batch screenshot actions are allowed for inspection but coordinates in subsequent clicks always refer to the PRE-BATCH full-screen screenshot.`,inputSchema:{type:`object`,properties:{actions:{type:`array`,minItems:1,items:Q,description:`List of actions. Example: [{"action":"left_click","coordinate":[100,200]},{"action":"type","text":"hello"},{"action":"key","text":"Return"}]`}},required:[`actions`]}},...e.teachMode?Tt(r,i):[]]}function Tt(e,t){let n={explanation:{type:`string`,description:`Tooltip body text. Explain what the user is looking at and why it matters. This is the ONLY place the user sees your words — be complete but concise.`},next_preview:{type:`string`,description:`One line describing exactly what will happen when the user clicks Next. Example: "Next: I'll click Create Bucket and type the name." Shown below the explanation in a smaller font.`},anchor:{type:`array`,items:{type:`number`},minItems:2,maxItems:2,description:`(x, y) — where the tooltip arrow points. ${e.x} Omit to center the tooltip with no arrow (for general-context steps).`},actions:{type:`array`,items:Q,description:`Actions to execute when the user clicks Next. Same item schema as computer_batch.actions. Empty array is valid for purely explanatory steps. Actions run sequentially and stop on first error.`}};return[{name:`request_teach_access`,description:`Request permission to guide the user through a task step-by-step with on-screen tooltips. Use this INSTEAD OF request_access when the user wants to LEARN how to do something (phrases like "teach me", "walk me through", "show me how", "help me learn"). On approval the main Claude window hides and a fullscreen tooltip overlay appears. You then call teach_step repeatedly; each call shows one tooltip and waits for the user to click Next. Same app-allowlist semantics as request_access, but no clipboard/system-key flags. Teach mode ends automatically when your turn ends.`,inputSchema:{type:`object`,properties:{apps:{type:`array`,items:{type:`string`},description:`Application display names (e.g. "Slack", "Calendar") or bundle identifiers. Resolved case-insensitively against installed apps.`+t},reason:{type:`string`,description:`What you will be teaching. Shown in the approval dialog as "Claude wants to guide you through {reason}". Keep it short and task-focused.`}},required:[`apps`,`reason`]}},{name:`teach_step`,description:"Show one guided-tour tooltip and wait for the user to click Next. On Next, execute the actions, take a fresh screenshot, and return both — you do NOT need a separate screenshot call between steps. The returned image shows the state after your actions ran; anchor the next teach_step against it. IMPORTANT — the user only sees the tooltip during teach mode. Put ALL narration in `explanation`. Text you emit outside teach_step calls is NOT visible until teach mode ends. Pack as many actions as possible into each step's `actions` array — the user waits through the whole round trip between clicks, so one step that fills a form beats five steps that fill one field each. Returns {exited:true} if the user clicks Exit — do not call teach_step again after that. Take an initial screenshot before your FIRST teach_step to anchor it.",inputSchema:{type:`object`,properties:n,required:[`explanation`,`next_preview`,`actions`]}},{name:`teach_batch`,description:`Queue multiple teach steps in one tool call. Parallels computer_batch: N steps → one model↔API round trip instead of N. Each step still shows a tooltip and waits for the user's Next click, but YOU aren't waiting for a round trip between steps. You can call teach_batch multiple times in one tour — treat each batch as one predictable SEGMENT (typically: all the steps on one page). The returned screenshot shows the state after the batch's final actions; anchor the NEXT teach_batch against it. WITHIN a batch, all anchors and click coordinates refer to the PRE-BATCH screenshot (same invariant as computer_batch) — for steps 2+ in a batch, either omit anchor (centered tooltip) or target elements you know won't have moved. Good pattern: batch 5 tooltips on page A (last step navigates) → read returned screenshot → batch 3 tooltips on page B → done. Returns {exited:true, stepsCompleted:N} if the user clicks Exit — do NOT call again after that; {stepsCompleted, stepFailed, ...} if an action errors mid-batch; otherwise {stepsCompleted, results:[...]} plus a final screenshot. Fall back to individual teach_step calls when you need to react to each intermediate screenshot.`,inputSchema:{type:`object`,properties:{steps:{type:`array`,minItems:1,items:{type:`object`,properties:n,required:[`explanation`,`next_preview`,`actions`]},description:`Ordered steps. Validated upfront — a typo in step 5 errors before any tooltip shows.`}},required:[`steps`]}}]}var Et,Z,Q,Dt=e((()=>{Et={pixels:{x:`Horizontal pixel position read directly from the most recent screenshot image, measured from the left edge. The server handles all scaling.`,y:`Vertical pixel position read directly from the most recent screenshot image, measured from the top edge. The server handles all scaling.`},normalized_0_100:{x:`Horizontal position as a percentage of screen width, 0.0–100.0 (0 = left edge, 100 = right edge).`,y:`Vertical position as a percentage of screen height, 0.0–100.0 (0 = top edge, 100 = bottom edge).`}},Z=`The frontmost application must be in the session allowlist at the time of this call, or this tool returns an error and does nothing.`,Q={type:`object`,properties:{action:{type:`string`,enum:[`key`,`type`,`mouse_move`,`left_click`,`left_click_drag`,`right_click`,`middle_click`,`double_click`,`triple_click`,`scroll`,`hold_key`,`screenshot`,`cursor_position`,`left_mouse_down`,`left_mouse_up`,`wait`],description:`The action to perform.`},coordinate:{type:`array`,items:{type:`number`},minItems:2,maxItems:2,description:`(x, y) for click/mouse_move/scroll/left_click_drag end point.`},start_coordinate:{type:`array`,items:{type:`number`},minItems:2,maxItems:2,description:`(x, y) drag start — left_click_drag only. Omit to drag from current cursor.`},text:{type:`string`,description:`For type: the text. For key/hold_key: the chord string. For click/scroll: modifier keys to hold.`},scroll_direction:{type:`string`,enum:[`up`,`down`,`left`,`right`]},scroll_amount:{type:`integer`,minimum:0,maximum:100},duration:{type:`number`,description:`Seconds (0–100). For hold_key/wait.`},repeat:{type:`integer`,minimum:1,maximum:100,description:`For key: repeat count.`}},required:[`action`]}}));function Ot(e,t,n){let r=new Set(e.map(e=>e.bundleId)),i=[...e,...n.granted.filter(e=>!r.has(e.bundleId))],a=Object.fromEntries(Object.entries(n.flags).filter(([,e])=>e===!0));return{apps:i,flags:{...c,...t,...a}}}function kt(e,t,n){let{logger:r,serverName:i}=e,a,o=n.onPermissionRequest?async(e,t)=>{let a=await n.onPermissionRequest(e,t),{apps:o,flags:s}=Ot(n.getAllowedApps(),n.getGrantFlags(),a);return r.debug(`[${i}] permission result: granted=${a.granted.length} denied=${a.denied.length}`),n.onAllowedAppsChanged?.(o,s),a}:void 0,s=n.onTeachPermissionRequest?async(e,t)=>{let a=await n.onTeachPermissionRequest(e,t);r.debug(`[${i}] teach permission result: granted=${a.granted.length} denied=${a.denied.length}`);let{apps:o}=Ot(n.getAllowedApps(),n.getGrantFlags(),a);return n.onAllowedAppsChanged?.(o,{...c,...n.getGrantFlags()}),a}:void 0;return async(c,l)=>{if(n.checkCuLock){let e=await n.checkCuLock();if(e.holder!==void 0&&!e.isSelf)return{content:[{type:`text`,text:n.formatLockHeldMessage?.(e.holder)??$}],isError:!0,telemetry:{error_kind:`cu_lock_held`}};if(e.holder===void 0&&!Ae(c)){await n.acquireCuLock?.();let e=await n.checkCuLock();if(e.holder!==void 0&&!e.isSelf)return{content:[{type:`text`,text:n.formatLockHeldMessage?.(e.holder)??$}],isError:!0,telemetry:{error_kind:`cu_lock_held`}};ke()}}let u=a?void 0:n.getLastScreenshotDims?.(),d=new AbortController,f={allowedApps:[...n.getAllowedApps()],grantFlags:n.getGrantFlags(),userDeniedBundleIds:n.getUserDeniedBundleIds(),coordinateMode:t,selectedDisplayId:n.getSelectedDisplayId(),displayPinnedByModel:n.getDisplayPinnedByModel?.(),displayResolvedForApps:n.getDisplayResolvedForApps?.(),lastScreenshot:a??(u?{...u,base64:``}:void 0),onPermissionRequest:o?e=>o(e,d.signal):void 0,onTeachPermissionRequest:s?e=>s(e,d.signal):void 0,onAppsHidden:n.onAppsHidden,getClipboardStash:n.getClipboardStash,onClipboardStashChanged:n.onClipboardStashChanged,onResolvedDisplayUpdated:n.onResolvedDisplayUpdated,onDisplayPinned:n.onDisplayPinned,onDisplayResolvedForApps:n.onDisplayResolvedForApps,onTeachModeActivated:n.onTeachModeActivated,onTeachStep:n.onTeachStep,onTeachWorking:n.onTeachWorking,getTeachModeActive:n.getTeachModeActive,checkCuLock:void 0,acquireCuLock:void 0,isAborted:n.isAborted};r.debug(`[${i}] tool=${c} allowedApps=${f.allowedApps.length} coordMode=${t}`);try{let t=await bt(e,c,l,f);if(t.screenshot){a=t.screenshot;let{base64:e,...o}=t.screenshot;r.debug(`[${i}] screenshot dims: ${JSON.stringify(o)}`),n.onScreenshotCaptured?.(o)}return t}finally{d.abort()}}}function At(e,t,i){let{serverName:o,logger:s}=e,c=new a({name:o,version:`0.1.3`},{capabilities:{tools:{},logging:{}}}),l=wt(e.executor.capabilities,t);if(c.setRequestHandler(n,async()=>e.isDisabled()?{tools:[]}:{tools:l}),i){let n=kt(e,t,i);return c.setRequestHandler(r,async e=>{let{screenshot:t,telemetry:r,...i}=await n(e.params.name,e.params.arguments??{});return i}),c}return c.setRequestHandler(r,async e=>(s.warn(`[${o}] tool call "${e.params.name}" reached the stub handler — no session context bound. Per-session state unavailable.`),{content:[{type:`text`,text:`This computer-use server instance is not wired to a session. Per-session app permissions are not available on this code path.`}],isError:!0})),c}var $,jt=e((()=>{i(),t(),Ct(),Dt(),l(),$=`Another Claude session is currently using the computer. Wait for that session to finish, or find a non-computer-use approach.`})),Mt=e((()=>{l(),h(),ce(),pe(),ve(),Ct(),jt(),Dt(),Se()}));export{_e as a,h as c,wt as i,c as l,kt as n,ge as o,At as r,u as s,Mt as t,l as u};