@jshookmcp/jshook 0.3.0 → 0.3.2

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 (346) hide show
  1. package/LICENSE +661 -661
  2. package/README.md +32 -49
  3. package/README.zh.md +32 -47
  4. package/dist/AntiCheatDetector-B6d4Qe9D.mjs +1 -0
  5. package/dist/BrowserSessionCoordinator-BJ-HOxo0.mjs +1 -0
  6. package/dist/CacheAdapters-CsNtQIR8.mjs +1 -0
  7. package/dist/CodeInjector-Cll_7bLJ.mjs +1 -0
  8. package/dist/ConsoleMonitor-CxDJV15E.mjs +306 -0
  9. package/dist/DOMInspector-C19J4zeq.mjs +95 -0
  10. package/dist/DarwinAPI-ZfQdpLNI.mjs +1 -0
  11. package/dist/DetailedDataManager-DmQ1LT-W.mjs +1 -0
  12. package/dist/EventBus-DL8iLA09.mjs +1 -0
  13. package/dist/EvidenceGraphBridge-BtbwXsLC.mjs +1 -0
  14. package/dist/ExtensionManager-BD724zkO.mjs +1 -0
  15. package/dist/ExtensionManager.tools-oVMJgPcN.mjs +1 -0
  16. package/dist/FingerprintManager-DT0EAUEo.mjs +1 -0
  17. package/dist/HardwareBreakpoint-BUfPdp0f.mjs +1 -0
  18. package/dist/HeapAnalyzer-B_aqY8oj.mjs +1 -0
  19. package/dist/{HookGeneratorBuilders.core.generators.storage-CTbB4Lcx.mjs → HookGeneratorBuilders.core.generators.storage-DzD6dIJd.mjs} +66 -101
  20. package/dist/InstrumentationSession-D_G1ZPyd.mjs +1 -0
  21. package/dist/MCPServer.search.handlers.domain-BbS-6LnX.mjs +1 -0
  22. package/dist/MemoryController-X1XNSn1n.mjs +2 -0
  23. package/dist/MemoryScanSession-DG_F-PjE.mjs +1 -0
  24. package/dist/MemoryScanner-g1_L1ub5.mjs +1 -0
  25. package/dist/NativeMemoryManager.impl-DniBe2wf.mjs +1 -0
  26. package/dist/NativeMemoryManager.utils-BHy1P_jM.mjs +1 -0
  27. package/dist/NetworkMonitor-B_-au6aV.mjs +185 -0
  28. package/dist/PEAnalyzer-yWQaGrcx.mjs +1 -0
  29. package/dist/PageController-Dfsm1_o7.mjs +1 -0
  30. package/dist/PointerChainEngine-BhCUkmxY.mjs +1 -0
  31. package/dist/PrerequisiteError-BjCQA-gK.mjs +1 -0
  32. package/dist/ProcessRegistry-C-bN48oR.mjs +1 -0
  33. package/dist/ResponseBuilder-BfWP-uaT.mjs +1 -0
  34. package/dist/ReverseEvidenceGraph-BhSYYdiI.mjs +2 -0
  35. package/dist/RingBuffer-Dm54ELKT.mjs +1 -0
  36. package/dist/ScriptManager-LWGPTdvD.mjs +7 -0
  37. package/dist/ServerRuntimeState-D2bWHqEE.mjs +1 -0
  38. package/dist/Speedhack-yseDPSZ9.mjs +1 -0
  39. package/dist/StealthVerifier-BmcxfwSF.mjs +1 -0
  40. package/dist/StructureAnalyzer-C5lpuZkg.mjs +2 -0
  41. package/dist/ToolCatalog-CYdD9F5f.mjs +1 -0
  42. package/dist/ToolError-DWU_z7gp.mjs +1 -0
  43. package/dist/ToolProbe-C7ZU2x7M.mjs +1 -0
  44. package/dist/ToolRegistry-C5oB8KP8.mjs +1 -0
  45. package/dist/ToolRouter.policy-CfhJczkt.mjs +4 -0
  46. package/dist/TraceRecorder-BiJWBXHX.mjs +272 -0
  47. package/dist/VersionDetector-CHT36Az0.mjs +9 -0
  48. package/dist/Win32API-eUCF57l_.mjs +1 -0
  49. package/dist/Win32Debug-CYrIQBvr.mjs +1 -0
  50. package/dist/WorkflowEngine-D876meOO.mjs +1 -0
  51. package/dist/analysis-D4swdMvq.mjs +6 -0
  52. package/dist/{antidebug-BRKeyt27.mjs → antidebug-7L3ygj_9.mjs} +8 -259
  53. package/dist/apk-packer-BqXcInnX.mjs +1 -0
  54. package/dist/artifactRetention-BCPQASm7.mjs +1 -0
  55. package/dist/artifacts-CkodUM4j.mjs +1 -0
  56. package/dist/authorization-schema-BOFwSXUN.mjs +1 -0
  57. package/dist/betterSqlite3-Brtq-SIQ.mjs +1 -0
  58. package/dist/binary-instrument-DU7V6TUM.mjs +7 -0
  59. package/dist/binary-secrets-PdMVoyt0.mjs +1 -0
  60. package/dist/bind-helpers-m2U8glkF.mjs +1 -0
  61. package/dist/boringssl-inspector-BBaJwwkU.mjs +2 -0
  62. package/dist/browser-Qqco2rOT.mjs +11 -0
  63. package/dist/capabilities-CyXuKUl1.mjs +1 -0
  64. package/dist/chunk-C_pMuVsO.mjs +1 -0
  65. package/dist/collector-Bpl6qy2L.mjs +1 -0
  66. package/dist/concurrency-DCr8WQ2M.mjs +1 -0
  67. package/dist/constants-BYj8Xek8.mjs +1 -0
  68. package/dist/coordination-CWXW1o8K.mjs +1 -0
  69. package/dist/dart-inspector-7AkPeZ_Q.mjs +0 -0
  70. package/dist/debugger-DyALjYMk.mjs +1 -0
  71. package/dist/definitions-BWxBke3r.mjs +1 -0
  72. package/dist/definitions-BYwATKc-.mjs +1 -0
  73. package/dist/definitions-B_83XfNQ.mjs +1 -0
  74. package/dist/definitions-Bf3H1EwV.mjs +1 -0
  75. package/dist/definitions-BftdXgXI.mjs +1 -0
  76. package/dist/definitions-Bio5XJYy.mjs +1 -0
  77. package/dist/definitions-C3qNgSn1.mjs +1 -0
  78. package/dist/definitions-CB6vmOer.mjs +1 -0
  79. package/dist/definitions-CMZRSy3k.mjs +1 -0
  80. package/dist/definitions-CQd7yCQH.mjs +1 -0
  81. package/dist/definitions-CT8ln6GQ.mjs +1 -0
  82. package/dist/definitions-Cenu6mxo.mjs +1 -0
  83. package/dist/definitions-D4g-MS10.mjs +1 -0
  84. package/dist/definitions-D5wl_8HN.mjs +1 -0
  85. package/dist/definitions-DAQm1Xar.mjs +1 -0
  86. package/dist/definitions-DP1vgxEY.mjs +1 -0
  87. package/dist/definitions-DxFNRQNK2.mjs +1 -0
  88. package/dist/definitions-Ibci7e_L.mjs +1 -0
  89. package/dist/definitions-OeLvmlQy.mjs +1 -0
  90. package/dist/definitions-RZYGD_Ey.mjs +1 -0
  91. package/dist/definitions-Tls8c0A0.mjs +1 -0
  92. package/dist/definitions-bybDvnG0.mjs +26 -0
  93. package/dist/definitions-l7TjdE6V.mjs +1 -0
  94. package/dist/encoding-ycOaz8Vr.mjs +2 -0
  95. package/dist/ensure-browser-core-DxWC-NTp.mjs +1 -0
  96. package/dist/evidence-graph-bridge-CV_UdYqj.mjs +1 -0
  97. package/dist/factory-CKr4fAE1.mjs +1 -0
  98. package/dist/flat-target-session-DvcQX7J5.mjs +1 -0
  99. package/dist/formatAddress-vLA_hOJt.mjs +1 -0
  100. package/dist/graphql-B2TiPEow.mjs +62 -0
  101. package/dist/handlers-0yKLRIfo.mjs +2 -0
  102. package/dist/handlers-8zN_vBIz.mjs +1 -0
  103. package/dist/handlers-B62K4FTc.mjs +1 -0
  104. package/dist/handlers-BpDlVVVU.mjs +1 -0
  105. package/dist/handlers-CMJK7m1c.mjs +31 -0
  106. package/dist/handlers-D2ZOul9p.mjs +54 -0
  107. package/dist/handlers-D5E40ssn.mjs +5 -0
  108. package/dist/handlers-DGbdQAgD.mjs +4 -0
  109. package/dist/handlers-DHO3rjsW.mjs +1 -0
  110. package/dist/handlers-FJ80VzUI.mjs +2 -0
  111. package/dist/handlers-VHWrxbM_.mjs +1 -0
  112. package/dist/handlers-l8QIKqBj.mjs +2 -0
  113. package/dist/handlers-mPFiNPe8.mjs +302 -0
  114. package/dist/{handlers-Dz9PYsCa.mjs → handlers-yo_xYzT8.mjs} +118 -904
  115. package/dist/handlers.impl-D9Hh8Bgl.mjs +1 -0
  116. package/dist/hooks-D4XLfgtV.mjs +600 -0
  117. package/dist/index.mjs +13 -5240
  118. package/dist/jadx-search-B_Yse0Zh.mjs +5 -0
  119. package/dist/logger-sBC6IdRT.mjs +1 -0
  120. package/dist/maintenance-BUpIukhg.mjs +1 -0
  121. package/dist/manifest-0Jpt_AQa.mjs +1 -0
  122. package/dist/manifest-B3fZbSWR.mjs +1 -0
  123. package/dist/manifest-B7NB2rh2.mjs +1 -0
  124. package/dist/manifest-BDi4nbH1.mjs +1 -0
  125. package/dist/manifest-BLDfkE7n.mjs +1 -0
  126. package/dist/manifest-BcXbB4gf.mjs +1 -0
  127. package/dist/manifest-Bdnc_vrc.mjs +1 -0
  128. package/dist/manifest-BuYKgCnp.mjs +1 -0
  129. package/dist/manifest-CBfNnGPV.mjs +1 -0
  130. package/dist/manifest-CPS1Xv69.mjs +1 -0
  131. package/dist/manifest-CQH9FhwI.mjs +1 -0
  132. package/dist/manifest-CRryuZF4.mjs +1 -0
  133. package/dist/manifest-CctIumog.mjs +1 -0
  134. package/dist/manifest-CvTe5ZGV2.mjs +1 -0
  135. package/dist/manifest-D-5GH0DV.mjs +1 -0
  136. package/dist/manifest-D3Ssf3IC.mjs +1 -0
  137. package/dist/manifest-D5ck3NvC.mjs +1 -0
  138. package/dist/manifest-D9jUUJAu.mjs +1 -0
  139. package/dist/manifest-DCx6w2XV.mjs +1 -0
  140. package/dist/manifest-DG19q-Ld.mjs +1 -0
  141. package/dist/manifest-DLMlD0Zc.mjs +1 -0
  142. package/dist/manifest-DYpn8w_h.mjs +1 -0
  143. package/dist/manifest-DYzWI8Xs.mjs +1 -0
  144. package/dist/manifest-D_obs5F4.mjs +1 -0
  145. package/dist/manifest-DujQqEQR.mjs +2 -0
  146. package/dist/manifest-DwL2ik8P.mjs +1 -0
  147. package/dist/manifest-ItF5P8A12.mjs +1 -0
  148. package/dist/manifest-KZphqIyX.mjs +1 -0
  149. package/dist/manifest-LG42zPLY2.mjs +1 -0
  150. package/dist/manifest-LLdI5m4T.mjs +1 -0
  151. package/dist/manifest-QYbQXJn0.mjs +1 -0
  152. package/dist/manifest-RcpX_MyZ.mjs +123 -0
  153. package/dist/manifest-YgVd8Sgz.mjs +1 -0
  154. package/dist/manifest-Zy7Odg5J.mjs +1 -0
  155. package/dist/manifest-ff1H7Pdp.mjs +1 -0
  156. package/dist/manifest-iuhF6pTL2.mjs +1 -0
  157. package/dist/manifest-nXHmtMSp2.mjs +1 -0
  158. package/dist/manifest-xWfu6iLo.mjs +1 -0
  159. package/dist/manifest-yC16OhL2.mjs +1 -0
  160. package/dist/manifest-ztWJoXy4.mjs +1 -0
  161. package/dist/matchesWildcardPattern-BAG6LvX5.mjs +1 -0
  162. package/dist/modules-BPBcSaM-.mjs +333 -0
  163. package/dist/mojo-ipc-BhwsdVUW.mjs +9 -0
  164. package/dist/native/scripts/linux/enum-windows.sh +12 -12
  165. package/dist/native/scripts/macos/enum-windows.applescript +22 -22
  166. package/dist/native-j8l473zn.mjs +961 -0
  167. package/dist/network-T0VRwNPd.mjs +7 -0
  168. package/dist/outputPaths-B4Ic4RZh.mjs +2 -0
  169. package/dist/parse-args-Bw413PlW.mjs +1 -0
  170. package/dist/platform-CzaQtISh.mjs +93 -0
  171. package/dist/playwright-cdp-fallback-DqFdx9-s.mjs +1 -0
  172. package/dist/process-CWhsCWrf.mjs +2 -0
  173. package/dist/proxy-DZFlDsG3.mjs +2 -0
  174. package/dist/registry-DH4sc1dt.mjs +1 -0
  175. package/dist/renderer-pid-9tJnZ_9N.mjs +1 -0
  176. package/dist/response-C7rKQst4.mjs +1 -0
  177. package/dist/search-defaults-lYBVn_3L.mjs +1 -0
  178. package/dist/server/plugin-api.d.mts +19 -36
  179. package/dist/server/plugin-api.mjs +1 -293
  180. package/dist/shared-state-board-BSjXLUV1.mjs +1 -0
  181. package/dist/sourcemap-Dh3Ai_ur.mjs +1 -0
  182. package/dist/ssrf-policy-CsIJGkpd.mjs +1 -0
  183. package/dist/streaming-BcJ0B6ao.mjs +1 -0
  184. package/dist/tool-builder-qif8M9-K.mjs +1 -0
  185. package/dist/transform-DOxzeWPB.mjs +103 -0
  186. package/dist/types-D9EiE5o9.mjs +1 -0
  187. package/dist/types-Fz69RzbZ.mjs +1 -0
  188. package/dist/wasm-CZ_HTfKR.mjs +174 -0
  189. package/dist/webcrack-C1iYG_EX.mjs +46 -0
  190. package/dist/workflow-BdwQmARn.mjs +101 -0
  191. package/package.json +55 -82
  192. package/src/native/scripts/linux/enum-windows.sh +12 -12
  193. package/src/native/scripts/macos/enum-windows.applescript +22 -22
  194. package/dist/AntiCheatDetector-CqGDXmfc.mjs +0 -350
  195. package/dist/CacheAdapters-jJFy20G-.mjs +0 -80
  196. package/dist/CodeInjector-BdjRfNx7.mjs +0 -150
  197. package/dist/ConsoleMonitor-DykL3IAw.mjs +0 -2269
  198. package/dist/DarwinAPI-ETyy0xyo.mjs +0 -363
  199. package/dist/DetailedDataManager-HT49OrvF.mjs +0 -217
  200. package/dist/EventBus-DFKvADm3.mjs +0 -141
  201. package/dist/EvidenceGraphBridge-318Oi0Lf.mjs +0 -153
  202. package/dist/ExtensionManager-BDMsY2Dz.mjs +0 -721
  203. package/dist/FingerprintManager-BN4UQWnX.mjs +0 -96
  204. package/dist/HardwareBreakpoint-Cc2AFq1Y.mjs +0 -239
  205. package/dist/HeapAnalyzer-DruMgsgj.mjs +0 -284
  206. package/dist/InstrumentationSession-DLH0vd-z.mjs +0 -244
  207. package/dist/MemoryController-CMtviNW_.mjs +0 -167
  208. package/dist/MemoryScanSession-ITgb_NMi.mjs +0 -278
  209. package/dist/MemoryScanner-CiL7Z3ey.mjs +0 -428
  210. package/dist/NativeMemoryManager.impl-D9Lkovvn.mjs +0 -485
  211. package/dist/NativeMemoryManager.utils-BBlAixF5.mjs +0 -165
  212. package/dist/PEAnalyzer-DMQ44gen.mjs +0 -385
  213. package/dist/PageController-BPJNqqBN.mjs +0 -431
  214. package/dist/PointerChainEngine-K7wN8Z-w.mjs +0 -325
  215. package/dist/PrerequisiteError-TuyZIs6n.mjs +0 -20
  216. package/dist/ProcessRegistry-zGg12QbE.mjs +0 -74
  217. package/dist/ResponseBuilder-CJXWmWNw.mjs +0 -143
  218. package/dist/ReverseEvidenceGraph-C02-gXOh.mjs +0 -269
  219. package/dist/ScriptManager-ZuWD-0Jg.mjs +0 -3003
  220. package/dist/Speedhack-D-z0umeT.mjs +0 -156
  221. package/dist/StealthVerifier-BWmPgQsv.mjs +0 -135
  222. package/dist/StructureAnalyzer-Cav5AVSL.mjs +0 -429
  223. package/dist/ToolCatalog-5OJdMiF0.mjs +0 -582
  224. package/dist/ToolError-jh9whhMd.mjs +0 -15
  225. package/dist/ToolProbe-DbCFGyrg.mjs +0 -45
  226. package/dist/ToolRegistry-B9krbTtI.mjs +0 -180
  227. package/dist/ToolRouter.policy-BGDAGyeH.mjs +0 -344
  228. package/dist/TraceRecorder-B41Z5XBj.mjs +0 -1286
  229. package/dist/VersionDetector-K3V4vGsw.mjs +0 -104
  230. package/dist/Win32API-C2kjj0ze.mjs +0 -346
  231. package/dist/Win32Debug-CKrGOTpo.mjs +0 -274
  232. package/dist/WorkflowEngine-DJ6M4opp.mjs +0 -569
  233. package/dist/analysis-BHeJW2Nb.mjs +0 -1234
  234. package/dist/artifactRetention-CPXkUJXp.mjs +0 -598
  235. package/dist/artifacts-DkfosXH3.mjs +0 -59
  236. package/dist/authorization-schema-DRqyJMSk.mjs +0 -31
  237. package/dist/betterSqlite3-DLSBZodi.mjs +0 -74
  238. package/dist/binary-instrument--V3MAhJ4.mjs +0 -971
  239. package/dist/bind-helpers-ClV34xdn.mjs +0 -42
  240. package/dist/boringssl-inspector-Bo_LOLaS.mjs +0 -180
  241. package/dist/browser-Dx3_S2cG.mjs +0 -4369
  242. package/dist/capabilities-CcHlvWgK.mjs +0 -33
  243. package/dist/chunk-CjcI7cDX.mjs +0 -15
  244. package/dist/concurrency-Drev_Vz9.mjs +0 -41
  245. package/dist/constants-CDZLOoVv.mjs +0 -534
  246. package/dist/coordination-DgItD9DL.mjs +0 -259
  247. package/dist/debugger-RS3RSAqs.mjs +0 -1288
  248. package/dist/definitions-BEoYofW5.mjs +0 -47
  249. package/dist/definitions-BRaefg3u.mjs +0 -365
  250. package/dist/definitions-BbkvZkiv.mjs +0 -96
  251. package/dist/definitions-BtWSHJ3o.mjs +0 -17
  252. package/dist/definitions-C1gCHO0i.mjs +0 -43
  253. package/dist/definitions-CDOg_b-l.mjs +0 -138
  254. package/dist/definitions-CVPD9hzZ.mjs +0 -54
  255. package/dist/definitions-Cea8Lgl7.mjs +0 -94
  256. package/dist/definitions-DAgIyjxM.mjs +0 -10
  257. package/dist/definitions-DJA27nsL.mjs +0 -66
  258. package/dist/definitions-DKPFU3LW.mjs +0 -25
  259. package/dist/definitions-DPRpZQ96.mjs +0 -47
  260. package/dist/definitions-DUE5gmdn.mjs +0 -18
  261. package/dist/definitions-DYVjOtxa.mjs +0 -26
  262. package/dist/definitions-DcYLVLCo.mjs +0 -37
  263. package/dist/definitions-Pp5LI2H4.mjs +0 -27
  264. package/dist/definitions-j9KdHVNR.mjs +0 -14
  265. package/dist/definitions-uzkjBwa7.mjs +0 -258
  266. package/dist/definitions-va-AnLuQ.mjs +0 -28
  267. package/dist/encoding-DJeqHmpd.mjs +0 -1079
  268. package/dist/evidence-graph-bridge-DcYizFk2.mjs +0 -136
  269. package/dist/factory-C90tBff6.mjs +0 -575
  270. package/dist/flat-target-session-Dgax2Cy3.mjs +0 -29
  271. package/dist/formatAddress-nnMvEohD.mjs +0 -17
  272. package/dist/graphql-CoHrhweh.mjs +0 -1197
  273. package/dist/handlers-4jmR0nMs.mjs +0 -898
  274. package/dist/handlers-BAHPxcch.mjs +0 -789
  275. package/dist/handlers-BOs9b907.mjs +0 -2600
  276. package/dist/handlers-BWXEy6ef.mjs +0 -917
  277. package/dist/handlers-Bndn6QvE.mjs +0 -111
  278. package/dist/handlers-BqC4bD4s.mjs +0 -681
  279. package/dist/handlers-BtYq60bM2.mjs +0 -276
  280. package/dist/handlers-BzgcB4iv.mjs +0 -799
  281. package/dist/handlers-CRyRWj2b.mjs +0 -859
  282. package/dist/handlers-CVv2H1uq.mjs +0 -592
  283. package/dist/handlers-Dl5a7JS4.mjs +0 -572
  284. package/dist/handlers-Dx2d7jt7.mjs +0 -2537
  285. package/dist/handlers-HujRKC3b.mjs +0 -661
  286. package/dist/handlers.impl-XWXkQfyi.mjs +0 -807
  287. package/dist/hooks-B1B8NRHL.mjs +0 -898
  288. package/dist/logger-Dh_xb7_2.mjs +0 -93
  289. package/dist/maintenance-PRMkLVRW.mjs +0 -835
  290. package/dist/manifest-67Bok-Si.mjs +0 -58
  291. package/dist/manifest-6lNTMZAB2.mjs +0 -87
  292. package/dist/manifest-B2duEHiH.mjs +0 -90
  293. package/dist/manifest-B6EY9Vm8.mjs +0 -57
  294. package/dist/manifest-B6nKSbyY.mjs +0 -95
  295. package/dist/manifest-BL8AQNPF.mjs +0 -106
  296. package/dist/manifest-BSZvJJmV.mjs +0 -47
  297. package/dist/manifest-BU7qzUyX.mjs +0 -418
  298. package/dist/manifest-Bl62e8WK.mjs +0 -49
  299. package/dist/manifest-Bo5cXjdt.mjs +0 -82
  300. package/dist/manifest-BpS4gtUK.mjs +0 -1347
  301. package/dist/manifest-Bv65_e2W.mjs +0 -101
  302. package/dist/manifest-BytNIF4Z.mjs +0 -117
  303. package/dist/manifest-C-xtsjS3.mjs +0 -81
  304. package/dist/manifest-CDYl7OhA.mjs +0 -66
  305. package/dist/manifest-CRZ3xmkD.mjs +0 -61
  306. package/dist/manifest-CoW6u4Tp.mjs +0 -132
  307. package/dist/manifest-Cq5zN_8A.mjs +0 -50
  308. package/dist/manifest-D7YZM_2e.mjs +0 -194
  309. package/dist/manifest-DE_VrAeQ.mjs +0 -314
  310. package/dist/manifest-DGsXSCpT.mjs +0 -39
  311. package/dist/manifest-DJ2vfEuW.mjs +0 -156
  312. package/dist/manifest-DPXDYhEu.mjs +0 -80
  313. package/dist/manifest-Dd4fQb0a.mjs +0 -322
  314. package/dist/manifest-Deq6opGg.mjs +0 -223
  315. package/dist/manifest-DfJTafJK.mjs +0 -37
  316. package/dist/manifest-DgOdgN_j.mjs +0 -50
  317. package/dist/manifest-DlbMW4v4.mjs +0 -47
  318. package/dist/manifest-DmVfbH0w.mjs +0 -374
  319. package/dist/manifest-Dog6Ddjr.mjs +0 -109
  320. package/dist/manifest-DvgU5FWb.mjs +0 -58
  321. package/dist/manifest-HsfDBs7j.mjs +0 -50
  322. package/dist/manifest-I8oQHvCG.mjs +0 -186
  323. package/dist/manifest-NvH_a-av.mjs +0 -786
  324. package/dist/manifest-cEJU1v0Z.mjs +0 -129
  325. package/dist/manifest-wOl5XLB12.mjs +0 -112
  326. package/dist/modules-tZozf0LQ.mjs +0 -10635
  327. package/dist/mojo-ipc-DXNEXEqb.mjs +0 -640
  328. package/dist/network-CPVvwvFg.mjs +0 -3852
  329. package/dist/outputPaths-um7lCRY3.mjs +0 -1141
  330. package/dist/parse-args-B4cY5Vx5.mjs +0 -39
  331. package/dist/platform-CYeFoTWp.mjs +0 -2161
  332. package/dist/process-BTbgcVc6.mjs +0 -1306
  333. package/dist/proxy-r8YN6nP1.mjs +0 -192
  334. package/dist/registry-Bl8ZQW61.mjs +0 -34
  335. package/dist/response-CWhh2aLo.mjs +0 -34
  336. package/dist/shared-state-board-BoZnSoj-.mjs +0 -586
  337. package/dist/sourcemap-BIDHUVXy.mjs +0 -934
  338. package/dist/ssrf-policy-Dsqd-DTX.mjs +0 -166
  339. package/dist/streaming-Dal6utPp.mjs +0 -725
  340. package/dist/tool-builder-BHJp32mV.mjs +0 -186
  341. package/dist/transform-DRVgGG90.mjs +0 -1011
  342. package/dist/types-Bx92KJfT.mjs +0 -4
  343. package/dist/types-DDBWs9UP.mjs +0 -37
  344. package/dist/wasm-BYx5UOeG.mjs +0 -1044
  345. package/dist/webcrack-Be0_FccV.mjs +0 -747
  346. package/dist/workflow-BpuKEtvn.mjs +0 -725
@@ -1,4 +1,4 @@
1
- import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
1
+ import { CallToolResult, Tool } from "@modelcontextprotocol/sdk/types.js";
2
2
 
3
3
  //#region packages/extension-sdk/src/workflow.d.ts
4
4
  interface RetryPolicy {
@@ -102,10 +102,11 @@ interface PluginLifecycleContext {
102
102
  getRuntimeData<T = unknown>(key: string): T | undefined;
103
103
  }
104
104
  type ExtensionToolHandler = (args: ToolArgs$1, ctx: PluginLifecycleContext) => Promise<ToolResponse>;
105
+ type ExtensionToolInputSchema = Tool['inputSchema'];
105
106
  interface ExtensionToolDefinition {
106
107
  name: string;
107
108
  description: string;
108
- schema: Record<string, unknown>;
109
+ schema: ExtensionToolInputSchema;
109
110
  handler: ExtensionToolHandler;
110
111
  profiles?: ToolProfileId[];
111
112
  }
@@ -113,32 +114,24 @@ type ExtensionWorkflowDefinition = WorkflowContract;
113
114
  declare const jsonResponse: (payload: Record<string, unknown>) => ToolResponse;
114
115
  declare const errorResponse: (tool: string, error: unknown, extra?: Record<string, unknown>) => ToolResponse;
115
116
  declare class ExtensionBuilder {
116
- private readonly _id;
117
- private readonly _version;
118
- private _name;
119
- private _description;
120
- private _author;
121
- private _sourceRepo;
122
- private _compatibleCore;
123
- private _profiles;
124
- private _tools;
125
- private _workflows;
126
- private _allowCommands;
127
- private _allowHosts;
128
- private _allowTools;
129
- private _metrics;
130
- private _configDefaults;
131
- private _onLoadHandler?;
132
- private _onValidateHandler?;
133
- private _onActivateHandler?;
134
- private _onDeactivateHandler?;
117
+ private readonly idValue;
118
+ private readonly versionValue;
119
+ private compatibleCoreValue;
120
+ private profilesValue;
121
+ private toolsValue;
122
+ private workflowsValue;
123
+ private allowedCommandsValue;
124
+ private allowedHostsValue;
125
+ private allowedToolsValue;
126
+ private metricsValue;
127
+ private configDefaultsValue;
128
+ private onLoadHandlerValue?;
129
+ private onValidateHandlerValue?;
130
+ private onActivateHandlerValue?;
131
+ private onDeactivateHandlerValue?;
135
132
  constructor(id: string, version: string);
136
133
  get id(): string;
137
134
  get version(): string;
138
- get pluginName(): string;
139
- get pluginDescription(): string;
140
- get pluginAuthor(): string;
141
- get pluginSourceRepo(): string;
142
135
  get compatibleCoreRange(): string;
143
136
  get profiles(): ToolProfileId[];
144
137
  get tools(): ExtensionToolDefinition[];
@@ -158,24 +151,14 @@ declare class ExtensionBuilder {
158
151
  }) | undefined;
159
152
  get onActivateHandler(): ((ctx: PluginLifecycleContext) => Promise<void> | void) | undefined;
160
153
  get onDeactivateHandler(): ((ctx: PluginLifecycleContext) => Promise<void> | void) | undefined;
161
- name(n: string): this;
162
- description(desc: string): this;
163
- author(a: string): this;
164
- sourceRepo(url: string): this;
165
154
  compatibleCore(range: string): this;
166
- mergeMetadata(meta: {
167
- name?: string;
168
- description?: string;
169
- author?: string;
170
- source_repo?: string;
171
- }): this;
172
155
  profile(p: ToolProfileId | ToolProfileId[]): this;
173
156
  allowCommand(cmd: string | string[]): this;
174
157
  allowHost(host: string | string[]): this;
175
158
  allowTool(tool: string | string[]): this;
176
159
  metric(m: string | string[]): this;
177
160
  configDefault(key: string, value: unknown): this;
178
- tool(name: string, desc: string, schema: Record<string, unknown>, handler: ExtensionToolHandler, profiles?: ToolProfileId[]): this;
161
+ tool(name: string, desc: string, schema: Record<string, object>, handler: ExtensionToolHandler, profiles?: ToolProfileId[]): this;
179
162
  workflow(workflow: ExtensionWorkflowDefinition | ExtensionWorkflowDefinition[]): this;
180
163
  onLoad(h: (ctx: PluginLifecycleContext) => Promise<void> | void): this;
181
164
  onValidate(h: (ctx: PluginLifecycleContext) => Promise<{
@@ -1,293 +1 @@
1
- import { existsSync } from "node:fs";
2
- import { join } from "node:path";
3
- import { fileURLToPath, pathToFileURL } from "node:url";
4
- import "node:fs/promises";
5
- import dotenv from "dotenv";
6
- import { execFile } from "node:child_process";
7
- import { promisify } from "node:util";
8
- //#region src/server/extensions/plugin-config.ts
9
- function normalizeSegment(value) {
10
- return value.trim().replace(/[^a-zA-Z0-9]+/g, "_").replace(/^_+|_+$/g, "").toUpperCase();
11
- }
12
- function envCandidates(pluginId, key) {
13
- const pluginSegment = normalizeSegment(pluginId);
14
- const keySegment = normalizeSegment(key);
15
- return [`PLUGIN_${pluginSegment}_${keySegment}`, `PLUGINS_${pluginSegment}_${keySegment}`];
16
- }
17
- function parseBoolean(raw) {
18
- if (raw === void 0) return void 0;
19
- const value = raw.trim().toLowerCase();
20
- if ([
21
- "1",
22
- "true",
23
- "yes",
24
- "on"
25
- ].includes(value)) return true;
26
- if ([
27
- "0",
28
- "false",
29
- "no",
30
- "off"
31
- ].includes(value)) return false;
32
- }
33
- function getPluginBooleanConfig(ctx, pluginId, key, fallback) {
34
- for (const candidate of envCandidates(pluginId, key)) {
35
- const parsed = parseBoolean(process.env[candidate]);
36
- if (parsed !== void 0) return parsed;
37
- }
38
- return ctx.getConfig(`plugins.${pluginId}.${key}`, fallback);
39
- }
40
- const VALID_BOOST_TIERS = new Set([
41
- "search",
42
- "workflow",
43
- "full"
44
- ]);
45
- /**
46
- * Resolve the minimum boost tier at which a plugin's tools are auto-registered.
47
- * Checks PLUGIN_<ID>_BOOST_DOMAIN, then MCP_DEFAULT_PLUGIN_BOOST_TIER, then 'full'.
48
- */
49
- function getPluginBoostTier(pluginId) {
50
- for (const candidate of envCandidates(pluginId, "BOOST_DOMAIN")) {
51
- const raw = process.env[candidate]?.trim().toLowerCase();
52
- if (raw && VALID_BOOST_TIERS.has(raw)) return raw;
53
- }
54
- const globalDefault = process.env.MCP_DEFAULT_PLUGIN_BOOST_TIER?.trim().toLowerCase();
55
- if (globalDefault && VALID_BOOST_TIERS.has(globalDefault)) return globalDefault;
56
- return "full";
57
- }
58
- //#endregion
59
- //#region src/server/extensions/plugin-env.ts
60
- const loadedEnvPaths = /* @__PURE__ */ new Set();
61
- function toManifestUrl(manifestLocation) {
62
- return manifestLocation.startsWith("file:") ? new URL(manifestLocation) : pathToFileURL(manifestLocation);
63
- }
64
- /**
65
- * Load plugin-local `.env` once per plugin directory.
66
- *
67
- * Main process `.env` is loaded by core config bootstrap first, so this only
68
- * adds per-plugin overrides without clobbering existing values.
69
- */
70
- function loadPluginEnv(manifestLocation) {
71
- const envPath = join(fileURLToPath(new URL(".", toManifestUrl(manifestLocation))), ".env");
72
- if (loadedEnvPaths.has(envPath)) return;
73
- if (existsSync(envPath)) dotenv.config({
74
- path: envPath,
75
- override: false
76
- });
77
- loadedEnvPaths.add(envPath);
78
- }
79
- promisify(execFile);
80
- function toTextResponse(payload) {
81
- return { content: [{
82
- type: "text",
83
- text: JSON.stringify(payload, null, 2)
84
- }] };
85
- }
86
- function toErrorResponse(tool, error, extra = {}) {
87
- return toTextResponse({
88
- success: false,
89
- tool,
90
- error: error instanceof Error ? error.message : String(error),
91
- ...extra
92
- });
93
- }
94
- //#endregion
95
- //#region packages/extension-sdk/src/plugin.ts
96
- /** Build a success JSON response for an MCP tool. Alias of `toTextResponse`. */
97
- const jsonResponse = toTextResponse;
98
- /** Build an error JSON response for an MCP tool. Alias of `toErrorResponse`. */
99
- const errorResponse = toErrorResponse;
100
- var ExtensionBuilder = class {
101
- _id;
102
- _version;
103
- _name = "";
104
- _description = "";
105
- _author = "";
106
- _sourceRepo = "";
107
- _compatibleCore = ">=0.1.0";
108
- _profiles = ["full"];
109
- _tools = [];
110
- _workflows = [];
111
- _allowCommands = [];
112
- _allowHosts = [];
113
- _allowTools = [];
114
- _metrics = [];
115
- _configDefaults = {};
116
- _onLoadHandler;
117
- _onValidateHandler;
118
- _onActivateHandler;
119
- _onDeactivateHandler;
120
- constructor(id, version) {
121
- this._id = id;
122
- this._version = version;
123
- }
124
- get id() {
125
- return this._id;
126
- }
127
- get version() {
128
- return this._version;
129
- }
130
- get pluginName() {
131
- return this._name;
132
- }
133
- get pluginDescription() {
134
- return this._description;
135
- }
136
- get pluginAuthor() {
137
- return this._author;
138
- }
139
- get pluginSourceRepo() {
140
- return this._sourceRepo;
141
- }
142
- get compatibleCoreRange() {
143
- return this._compatibleCore;
144
- }
145
- get profiles() {
146
- return this._profiles;
147
- }
148
- get tools() {
149
- return this._tools;
150
- }
151
- get workflows() {
152
- return this._workflows;
153
- }
154
- get allowedCommands() {
155
- return this._allowCommands;
156
- }
157
- get allowedHosts() {
158
- return this._allowHosts;
159
- }
160
- get allowedTools() {
161
- return this._allowTools;
162
- }
163
- get declaredMetrics() {
164
- return this._metrics;
165
- }
166
- get configDefaults() {
167
- return this._configDefaults;
168
- }
169
- get onLoadHandler() {
170
- return this._onLoadHandler;
171
- }
172
- get onValidateHandler() {
173
- return this._onValidateHandler;
174
- }
175
- get onActivateHandler() {
176
- return this._onActivateHandler;
177
- }
178
- get onDeactivateHandler() {
179
- return this._onDeactivateHandler;
180
- }
181
- name(n) {
182
- this._name = n;
183
- return this;
184
- }
185
- description(desc) {
186
- this._description = desc;
187
- return this;
188
- }
189
- author(a) {
190
- this._author = a;
191
- return this;
192
- }
193
- sourceRepo(url) {
194
- this._sourceRepo = url;
195
- return this;
196
- }
197
- compatibleCore(range) {
198
- this._compatibleCore = range;
199
- return this;
200
- }
201
- /**
202
- * Merge external metadata (e.g. from meta.yaml) into the builder.
203
- * Only fills in fields that the builder chain has NOT explicitly set
204
- * (i.e. still at their default empty-string value).
205
- */
206
- mergeMetadata(meta) {
207
- if (!this._name && meta.name) this._name = meta.name;
208
- if (!this._description && meta.description) this._description = meta.description;
209
- if (!this._author && meta.author) this._author = meta.author;
210
- if (!this._sourceRepo && meta.source_repo) this._sourceRepo = meta.source_repo;
211
- return this;
212
- }
213
- profile(p) {
214
- this._profiles = Array.isArray(p) ? p : [p];
215
- return this;
216
- }
217
- allowCommand(cmd) {
218
- this._allowCommands.push(...Array.isArray(cmd) ? cmd : [cmd]);
219
- return this;
220
- }
221
- allowHost(host) {
222
- this._allowHosts.push(...Array.isArray(host) ? host : [host]);
223
- return this;
224
- }
225
- allowTool(tool) {
226
- this._allowTools.push(...Array.isArray(tool) ? tool : [tool]);
227
- return this;
228
- }
229
- metric(m) {
230
- this._metrics.push(...Array.isArray(m) ? m : [m]);
231
- return this;
232
- }
233
- configDefault(key, value) {
234
- this._configDefaults[key] = value;
235
- return this;
236
- }
237
- /**
238
- * Register a tool exposed by this extension.
239
- *
240
- * @param name Unique tool name (must not collide with built-in tools).
241
- * @param desc Human-readable description shown to the AI model.
242
- * @param schema JSON-Schema **properties** object — the builder automatically
243
- * wraps it in `{ type: 'object', properties: … }`, so you only
244
- * need to pass the inner properties map.
245
- * Example: `{ text: { type: 'string', description: 'Input' } }`
246
- * @param handler Async function `(args, ctx) => ToolResponse`.
247
- * @param profiles Optional profile tiers for this specific tool (defaults to extension-level profiles).
248
- */
249
- tool(name, desc, schema, handler, profiles) {
250
- this._tools.push({
251
- name,
252
- description: desc,
253
- schema: {
254
- type: "object",
255
- properties: schema
256
- },
257
- handler,
258
- profiles
259
- });
260
- return this;
261
- }
262
- /**
263
- * Register one or more workflow contracts exposed by this extension.
264
- *
265
- * These workflows are registered by the core extension manager alongside
266
- * standalone workflow roots, while still preserving plugin ownership.
267
- */
268
- workflow(workflow) {
269
- this._workflows.push(...Array.isArray(workflow) ? workflow : [workflow]);
270
- return this;
271
- }
272
- onLoad(h) {
273
- this._onLoadHandler = h;
274
- return this;
275
- }
276
- onValidate(h) {
277
- this._onValidateHandler = h;
278
- return this;
279
- }
280
- onActivate(h) {
281
- this._onActivateHandler = h;
282
- return this;
283
- }
284
- onDeactivate(h) {
285
- this._onDeactivateHandler = h;
286
- return this;
287
- }
288
- };
289
- function createExtension(id, version) {
290
- return new ExtensionBuilder(id, version);
291
- }
292
- //#endregion
293
- export { createExtension, errorResponse, getPluginBooleanConfig, getPluginBoostTier, jsonResponse, loadPluginEnv };
1
+ import{existsSync as e}from"node:fs";import{join as t}from"node:path";import{fileURLToPath as n,pathToFileURL as r}from"node:url";import"node:fs/promises";import i from"dotenv";import{execFile as a}from"node:child_process";import{promisify as o}from"node:util";function s(e){return e.trim().replace(/[^a-zA-Z0-9]+/g,`_`).replace(/^_+|_+$/g,``).toUpperCase()}function c(e,t){let n=s(e),r=s(t);return[`PLUGIN_${n}_${r}`,`PLUGINS_${n}_${r}`]}function l(e){if(e===void 0)return;let t=e.trim().toLowerCase();if([`1`,`true`,`yes`,`on`].includes(t))return!0;if([`0`,`false`,`no`,`off`].includes(t))return!1}function u(e,t,n,r){for(let e of c(t,n)){let t=l(process.env[e]);if(t!==void 0)return t}return e.getConfig(`plugins.${t}.${n}`,r)}const d=new Set([`search`,`workflow`,`full`]);function f(e){for(let t of c(e,`BOOST_DOMAIN`)){let e=process.env[t]?.trim().toLowerCase();if(e&&d.has(e))return e}let t=process.env.MCP_DEFAULT_PLUGIN_BOOST_TIER?.trim().toLowerCase();return t&&d.has(t)?t:`full`}const p=new Set;function m(e){return e.startsWith(`file:`)?new URL(e):r(e)}function h(r){let a=t(n(new URL(`.`,m(r))),`.env`);p.has(a)||(e(a)&&i.config({path:a,override:!1}),p.add(a))}o(a);function g(e){return{content:[{type:`text`,text:JSON.stringify(e,null,2)}]}}function _(e,t,n={}){return g({success:!1,tool:e,error:t instanceof Error?t.message:String(t),...n})}const v=g,y=_;var b=class{idValue;versionValue;compatibleCoreValue=`>=0.1.0`;profilesValue=[`full`];toolsValue=[];workflowsValue=[];allowedCommandsValue=[];allowedHostsValue=[];allowedToolsValue=[];metricsValue=[];configDefaultsValue={};onLoadHandlerValue;onValidateHandlerValue;onActivateHandlerValue;onDeactivateHandlerValue;constructor(e,t){this.idValue=e,this.versionValue=t}get id(){return this.idValue}get version(){return this.versionValue}get compatibleCoreRange(){return this.compatibleCoreValue}get profiles(){return this.profilesValue}get tools(){return this.toolsValue}get workflows(){return this.workflowsValue}get allowedCommands(){return this.allowedCommandsValue}get allowedHosts(){return this.allowedHostsValue}get allowedTools(){return this.allowedToolsValue}get declaredMetrics(){return this.metricsValue}get configDefaults(){return this.configDefaultsValue}get onLoadHandler(){return this.onLoadHandlerValue}get onValidateHandler(){return this.onValidateHandlerValue}get onActivateHandler(){return this.onActivateHandlerValue}get onDeactivateHandler(){return this.onDeactivateHandlerValue}compatibleCore(e){return this.compatibleCoreValue=e,this}profile(e){return this.profilesValue=Array.isArray(e)?e:[e],this}allowCommand(e){return this.allowedCommandsValue.push(...Array.isArray(e)?e:[e]),this}allowHost(e){return this.allowedHostsValue.push(...Array.isArray(e)?e:[e]),this}allowTool(e){return this.allowedToolsValue.push(...Array.isArray(e)?e:[e]),this}metric(e){return this.metricsValue.push(...Array.isArray(e)?e:[e]),this}configDefault(e,t){return this.configDefaultsValue[e]=t,this}tool(e,t,n,r,i){return this.toolsValue.push({name:e,description:t,schema:{type:`object`,properties:n},handler:r,profiles:i}),this}workflow(e){return this.workflowsValue.push(...Array.isArray(e)?e:[e]),this}onLoad(e){return this.onLoadHandlerValue=e,this}onValidate(e){return this.onValidateHandlerValue=e,this}onActivate(e){return this.onActivateHandlerValue=e,this}onDeactivate(e){return this.onDeactivateHandlerValue=e,this}};function x(e,t){return new b(e,t)}export{x as createExtension,y as errorResponse,u as getPluginBooleanConfig,f as getPluginBoostTier,v as jsonResponse,h as loadPluginEnv};
@@ -0,0 +1 @@
1
+ import{t as e}from"./response-C7rKQst4.mjs";import{t}from"./ToolError-DWU_z7gp.mjs";import{a as n,i as r,r as i,s as a,t as o}from"./parse-args-Bw413PlW.mjs";import"./definitions-BftdXgXI.mjs";import{randomUUID as s}from"node:crypto";function c(e){return e.replace(/[.+?^${}()|[\]\\]/g,`\\$&`)}function l(e,t){return t?RegExp(`^${t.split(`*`).map(e=>c(e)).join(`.*`)}$`).test(e):!0}var u=class{state=new Map;history=new Map;watches=new Map;maxHistoryPerKey=100;maxWatches=200;watchIdleTtlMs=30*6e4;mutationSeq=0;lastPersistedSeq=0;persistNotifier;pruneExpiredWatches(){let e=Date.now(),t=0;for(let[n,r]of this.watches)r.expiresAt<e&&(this.watches.delete(n),t++);if(this.watches.size>this.maxWatches){let e=[...this.watches.entries()].toSorted((e,t)=>e[1].lastChecked-t[1].lastChecked),n=this.watches.size-this.maxWatches;for(let r=0;r<n;r++){let n=e[r];n&&(this.watches.delete(n[0]),t++)}}return t}setPersistNotifier(e){this.persistNotifier=e}markDirty(){this.mutationSeq++,this.persistNotifier?.()}recordChange(e,t){this.markDirty();let n=this.history.get(e);n||(n=[],this.history.set(e,n)),n.push(t),n.length>this.maxHistoryPerKey&&n.splice(0,n.length-this.maxHistoryPerKey)}deleteEntry(e){let t=this.state.get(e);t&&(this.state.delete(e),this.recordChange(e,{id:s().slice(0,8),key:t.key,namespace:t.namespace,action:`delete`,oldValue:t.value,timestamp:Date.now()}))}isExpired(e){return!!(e.expiresAt&&Date.now()>e.expiresAt)}cleanupExpired(){let e=Date.now(),t=0;for(let[n,r]of this.state.entries())r.expiresAt&&e>r.expiresAt&&(this.state.delete(n),this.recordChange(n,{id:s().slice(0,8),key:r.key,namespace:r.namespace,action:`expire`,oldValue:r.value,timestamp:e}),t++);return t}getSnapshotSeq(){return this.mutationSeq}getLastPersistedSeq(){return this.lastPersistedSeq}markPersisted(){this.lastPersistedSeq=this.mutationSeq}isPersistDirty(){return this.mutationSeq!==this.lastPersistedSeq}exportSnapshot(){return{schemaVersion:1,savedAt:new Date().toISOString(),entries:[...this.state.entries()],history:[...this.history.entries()]}}restoreSnapshot(e){if(!e||typeof e!=`object`)return;let t=e;if(t.schemaVersion!==1)return;let n=Date.now();if(this.state.clear(),this.history.clear(),t.entries)for(let[e,r]of t.entries)r.expiresAt&&n>r.expiresAt||this.state.set(e,r);if(t.history)for(let[e,n]of t.history)this.history.set(e,n);this.mutationSeq=this.state.size,this.lastPersistedSeq=this.mutationSeq}},d=class{store;constructor(e){this.store=e}async handleSet(e){let t=a(e,`key`);if(!t)throw Error(`key must be a non-empty string`);let r=e.value,o=n(e,`namespace`,`default`),c=i(e,`ttlSeconds`),l=`${o}:${t}`,u=Date.now(),d=this.store.state.get(l),f=d?.version??0,p=d?.value,m={key:t,value:r,namespace:o,createdAt:d?.createdAt??u,updatedAt:u,ttlSeconds:c,expiresAt:c?u+c*1e3:void 0,version:f+1};return this.store.state.set(l,m),this.store.recordChange(l,{id:s().slice(0,8),key:t,namespace:o,action:`set`,oldValue:p,newValue:r,timestamp:u}),{success:!0,key:t,namespace:o,version:m.version,expiresAt:m.expiresAt?new Date(m.expiresAt).toISOString():void 0}}async handleGet(e){let t=a(e,`key`);if(!t)throw Error(`key must be a non-empty string`);let r=n(e,`namespace`,`default`),i=`${r}:${t}`,o=this.store.state.get(i);return o?this.store.isExpired(o)?(this.store.deleteEntry(i),{found:!1,key:t,namespace:r,expired:!0}):{found:!0,key:t,namespace:r,value:o.value,version:o.version,createdAt:new Date(o.createdAt).toISOString(),updatedAt:new Date(o.updatedAt).toISOString(),ttlSeconds:o.ttlSeconds,expiresAt:o.expiresAt?new Date(o.expiresAt).toISOString():void 0}:{found:!1,key:t,namespace:r}}async handleDelete(e){let t=a(e,`key`);if(!t)throw Error(`key must be a non-empty string`);let r=n(e,`namespace`,`default`),i=`${r}:${t}`;return this.store.state.get(i)?(this.store.deleteEntry(i),{deleted:!0,key:t,namespace:r}):{deleted:!1,key:t,namespace:r,reason:`not_found`}}async handleList(e){let t=n(e,`namespace`),r=o(e,`includeValues`,!1),i=[],a=[];for(let e of this.store.state.values())if(!(t&&e.namespace!==t)){if(this.store.isExpired(e)){a.push(`${e.namespace}:${e.key}`);continue}i.push({key:e.key,namespace:e.namespace,version:e.version,updatedAt:new Date(e.updatedAt).toISOString(),...r?{value:e.value}:{}})}for(let e of a)this.store.deleteEntry(e);return i.sort((e,t)=>e.namespace===t.namespace?e.key.localeCompare(t.key):e.namespace.localeCompare(t.namespace)),{entries:i,total:i.length,namespaces:[...new Set(i.map(e=>e.namespace))]}}async handleClear(e){let t=n(e,`namespace`),r=n(e,`keyPattern`),i=[];for(let[e,n]of this.store.state.entries())t&&n.namespace!==t||l(n.key,r)&&i.push(e);for(let e of i)this.store.deleteEntry(e);return{cleared:i.length,namespace:t??`all`,pattern:r}}async handleStats(){let e=Date.now(),t={},n=0;for(let[,r]of this.store.state.entries()){if(r.expiresAt&&e>r.expiresAt){n++;continue}t[r.namespace]=(t[r.namespace]??0)+1}let r=0;for(let e of this.store.history.values())r+=e.length;return{totalEntries:Object.values(t).reduce((e,t)=>e+t,0),entriesByNamespace:t,expiredEntries:n,totalWatches:this.store.watches.size,historySize:r}}},f=class{store;constructor(e){this.store=e}async handleWatch(e){let t=a(e,`key`);if(!t)throw Error(`key must be a non-empty string`);let r=n(e,`namespace`,`default`),o=i(e,`pollIntervalMs`,1e3);this.store.pruneExpiredWatches();let c=`watch_${s().slice(0,8)}`,u=t.includes(`*`),d=Date.now(),f={id:c,key:t,namespace:r,pattern:u,pollIntervalMs:o,lastChecked:d,lastVersion:{},createdAt:d,expiresAt:d+this.store.watchIdleTtlMs},p=`${r}:`;for(let[e,n]of this.store.state.entries())e.startsWith(p)&&(u?l(n.key,t)&&(f.lastVersion[n.key]=n.version):n.key===t&&(f.lastVersion[n.key]=n.version));return this.store.watches.set(c,f),{watchId:c,key:t,namespace:r,pattern:u,pollIntervalMs:o,initialKeys:Object.keys(f.lastVersion)}}async handleUnwatch(e){let t=a(e,`watchId`),n=this.store.watches.get(t);return n?(this.store.watches.delete(t),{removed:!0,watchId:t,wasWatching:n.key}):{removed:!1,watchId:t,reason:`not_found`}}async handlePoll(e){let t=a(e,`watchId`),n=this.store.watches.get(t);if(!n)throw Error(`Watch "${t}" not found`);let r=Date.now(),i=[],o=`${n.namespace}:`;if(n.pattern){for(let[e,t]of this.store.state.entries())if(e.startsWith(o)&&l(t.key,n.key)){let e=n.lastVersion[t.key];e===void 0?i.push({key:t.key,namespace:t.namespace,action:`created`}):t.version>e&&i.push({key:t.key,namespace:t.namespace,action:`changed`}),n.lastVersion[t.key]=t.version}for(let e of Object.keys(n.lastVersion))!this.store.state.has(`${n.namespace}:${e}`)&&l(e,n.key)&&(i.push({key:e,namespace:n.namespace,action:`deleted`}),delete n.lastVersion[e])}else{let e=`${n.namespace}:${n.key}`,t=this.store.state.get(e),r=n.lastVersion[n.key];!t&&r!==void 0?(i.push({key:n.key,namespace:n.namespace,action:`deleted`}),delete n.lastVersion[n.key]):t&&(r===void 0?i.push({key:t.key,namespace:t.namespace,action:`created`}):t.version>r&&i.push({key:t.key,namespace:t.namespace,action:`changed`}),n.lastVersion[n.key]=t.version)}return n.lastChecked=r,n.expiresAt=r+this.store.watchIdleTtlMs,{watchId:t,changes:i,hasChanges:i.length>0,checkedAt:new Date(r).toISOString()}}},p=class{store;constructor(e){this.store=e}async handleHistory(e){let t=a(e,`key`),r=n(e,`namespace`,`default`),o=i(e,`limit`,50),s=`${r}:${t}`,c=this.store.history.get(s)??[],l=[...c].toSorted((e,t)=>t.timestamp-e.timestamp).slice(0,o);return{key:t,namespace:r,history:l.map(e=>({...e,timestamp:new Date(e.timestamp).toISOString()})),total:c.length,returned:l.length}}async handleExport(e){let t=n(e,`namespace`),r=n(e,`keyPattern`),i=Date.now(),a={};for(let[e,n]of this.store.state.entries())t&&n.namespace!==t||l(n.key,r)&&(n.expiresAt&&i>n.expiresAt||(a[n.key]=n.value));return{data:a,count:Object.keys(a).length,namespace:t??`all`,exportedAt:new Date(i).toISOString()}}async handleImport(e){let t=r(e,`data`),i=n(e,`namespace`,`default`),a=o(e,`overwrite`,!1);if(!t)throw Error(`data must be an object`);let c=[],l=[],u=[];for(let[e,n]of Object.entries(t)){let t=`${i}:${e}`,r=this.store.state.get(t);if(r&&!a){l.push(e);continue}r&&a&&u.push(e);let o=Date.now(),d={key:e,value:n,namespace:i,createdAt:r?.createdAt??o,updatedAt:o,version:(r?.version??0)+1};this.store.state.set(t,d),this.store.recordChange(t,{id:s().slice(0,8),key:e,namespace:i,action:`set`,oldValue:r?.value,newValue:n,timestamp:o,source:`import`}),c.push(e)}return{imported:c.length,skipped:l.length,overwritten:u.length,total:Object.keys(t).length,keys:c}}},m=class{store;storeHandlers;watchHandlers;ioHandlers;constructor(){this.store=new u,this.storeHandlers=new d(this.store),this.watchHandlers=new f(this.store),this.ioHandlers=new p(this.store)}setPersistNotifier(e){this.store.setPersistNotifier(e)}handleSet(e){return this.storeHandlers.handleSet(e)}handleGet(e){return this.storeHandlers.handleGet(e)}handleDelete(e){return this.storeHandlers.handleDelete(e)}handleList(e){return this.storeHandlers.handleList(e)}handleWatchDispatch(e){let t=String(e.action??``);return t===`stop`?this.watchHandlers.handleUnwatch(e):t===`poll`?this.watchHandlers.handlePoll(e):this.watchHandlers.handleWatch(e)}handleIODispatch(e){return String(e.action??``)===`import`?this.ioHandlers.handleImport(e):this.ioHandlers.handleExport(e)}handleWatch(e){return this.watchHandlers.handleWatch(e)}handleUnwatch(e){return this.watchHandlers.handleUnwatch(e)}handlePoll(e){return this.watchHandlers.handlePoll(e)}handleHistory(e){return this.ioHandlers.handleHistory(e)}handleExport(e){return this.ioHandlers.handleExport(e)}handleImport(e){return this.ioHandlers.handleImport(e)}handleClear(e){return this.storeHandlers.handleClear(e)}handleDispatch(n){let r=String(n.action??``);switch(r){case`set`:return this.storeHandlers.handleSet(n);case`get`:return this.storeHandlers.handleGet(n);case`delete`:return this.storeHandlers.handleDelete(n);case`list`:return this.storeHandlers.handleList(n);case`history`:return this.ioHandlers.handleHistory(n);case`clear`:return this.storeHandlers.handleClear(n);default:return Promise.resolve(e(new t(`VALIDATION`,`Invalid action: "${r}". Expected one of: set, get, delete, list, history, clear`,{toolName:`state_board`})))}}handleStats(){return this.storeHandlers.handleStats()}cleanupExpired(){return this.store.cleanupExpired()}getStore(){return this.store}};export{m as SharedStateBoardHandlers};
@@ -0,0 +1 @@
1
+ import{Br as e,zr as t}from"./constants-BYj8Xek8.mjs";import{i as n}from"./artifacts-CkodUM4j.mjs";import{s as r}from"./PageController-Dfsm1_o7.mjs";import{n as i,t as a}from"./flat-target-session-DvcQX7J5.mjs";import"./definitions-BYwATKc-.mjs";import{dirname as o,resolve as s}from"node:path";import{mkdir as c,writeFile as l}from"node:fs/promises";const u=new Map(Array.from(`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`).map((e,t)=>[e,t]));function d(e){let t=(e&1)==1,n=e>>1;return t?-n:n}function f(e){let t=[],n=0;for(;n<e.length;){let r=0,i=0,a=!0;for(;a;){let t=e.charAt(n);if(!t)throw Error(`Unexpected end of VLQ segment: "${e}"`);n+=1;let o=u.get(t);if(o===void 0)throw Error(`Invalid VLQ base64 char "${t}" in segment "${e}"`);a=(o&32)!=0;let s=o&31;r+=s<<i,i+=5}t.push(d(r))}return t}function p(e){let t=[],n=0;for(;n<e.length;){let r=0,i=0,a=!0;for(;a;){let t=e.charAt(n);if(!t)throw Error(`Unexpected end of VLQ segment: "${e}"`);n+=1;let o=u.get(t);if(o===void 0)throw Error(`Invalid VLQ base64 char "${t}" in segment "${e}"`);a=(o&32)!=0;let s=o&31;r+=s<<i,i+=5}t.push(r)}return t}function m(e){if(!e)return[];let t=[],n=0,r=0,i=0,a=0,o=e.split(`;`);for(let e=0;e<o.length;e+=1){let s=o[e]??``,c=0;if(!s)continue;let l=s.split(`,`);for(let o of l){if(!o)continue;let s=f(o),l=s[0];if(l===void 0)continue;c+=l;let u={generatedLine:e+1,generatedColumn:c};s.length>=4&&(n+=s[1]??0,r+=s[2]??0,i+=s[3]??0,u.sourceIndex=n,u.originalLine=r+1,u.originalColumn=i,s.length>=5&&(a+=s[4]??0,u.nameIndex=a)),t.push(u)}}return t}function h(e){if(!e)return{mappingsCount:0,segmentCount:0};let t=0,n=0,r=!1;for(let i=0;i<e.length;i++){let a=e[i];a===`;`?(r&&t++,r=!1):a===`,`?n++:r||(r=!0,n++)}return r&&t++,{mappingsCount:t,segmentCount:n}}function g(e){return{content:[{type:`text`,text:JSON.stringify(e,null,2)}]}}function _(e,t){return g({success:!1,tool:e,error:t instanceof Error?t.message:String(t)})}function v(e){return typeof e==`object`&&e?e:{}}function y(e){return typeof e==`string`?e:void 0}function b(e){return/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(e)}function x(e,t){return typeof e==`boolean`?e:t}function S(e,t){if(typeof e!=`string`||e.trim().length===0)throw Error(`${t} is required`);return e.trim()}function C(e){if(typeof e!=`string`)return;let t=e.trim();return t.length>0?t:void 0}async function w(e){if(e.detach)try{await e.detach()}catch{}}async function T(e,t,n){try{await e.send(t,n)}catch{}}async function E(e){await new Promise(t=>setTimeout(()=>t(),e))}var D=class{state;constructor(e){this.state=e}async handleExtensionListInstalled(e){let t=await(await this.state.collector.getActivePage()).createCDPSession();try{return g((await this.getExtensionTargets(t)).map(e=>({extensionId:e.extensionId,name:e.name,type:e.type,url:e.url})))}catch(e){return _(`extension_list_installed`,e)}finally{await w(t)}}async handleExtensionExecuteInContext(e){let t=S(e.extensionId,`extensionId`),n=S(e.code,`code`),r=x(e.returnByValue,!0),o=await(await this.state.collector.getActivePage()).createCDPSession(),s=null;try{let e=await this.getExtensionTargets(o,t);if(e.length===0)throw Error(`No background target found for extension: ${t}`);let i=this.pickPreferredExtensionTarget(e);s=await a(o,i.targetId);let c=await this.evaluateInAttachedTarget(s,n,r);return g({extensionId:t,target:{type:i.type,url:i.url,name:i.name},result:c.result,exceptionDetails:c.exceptionDetails})}catch(e){return _(`extension_execute_in_context`,e)}finally{s&&await i(o,s).catch(()=>void 0),await w(o)}}async getExtensionTargets(e,t){let n=v(await e.send(`Target.getTargets`)),r=Array.isArray(n.targetInfos)?n.targetInfos:[],i=new Set([`service_worker`,`background_page`]),a=[];for(let e of r){let n=v(e),r=y(n.targetId),o=y(n.type),s=y(n.url);if(!r||!o||!s||!i.has(o))continue;let c=this.extractExtensionId(s);if(!c||t&&c!==t)continue;let l=y(n.title)??``;a.push({targetId:r,extensionId:c,name:l||c,type:o,url:s})}return a.sort((e,t)=>{let n=e.type===`service_worker`?0:1,r=t.type===`service_worker`?0:1;return n===r?e.extensionId.localeCompare(t.extensionId):n-r}),a}pickPreferredExtensionTarget(e){return e.find(e=>e.type===`service_worker`)??e[0]}extractExtensionId(e){return e.match(/^chrome-extension:\/\/([a-p]{32})(?:\/|$)/i)?.[1]??null}async evaluateInAttachedTarget(e,t,n){let r=v(await e.send(`Runtime.evaluate`,{expression:t,returnByValue:n,awaitPromise:!0})),i=v(r.result);return{result:n&&i.value!==void 0?i.value:Object.keys(i).length>0?i:null,exceptionDetails:r.exceptionDetails===void 0?null:r.exceptionDetails}}};function O(e,t,n){return A(e,t,n).then(e=>{let t=m(e.map.mappings),n=new Set(t.map(e=>e.generatedLine));return{resolvedUrl:e.resolvedUrl,map:e.map,mappings:t,mappingsCount:n.size,segmentCount:t.length}})}function k(e,t,n){return A(e,t,n).then(e=>{let{mappingsCount:t,segmentCount:n}=h(e.map.mappings);return{resolvedUrl:e.resolvedUrl,map:e.map,mappingsCount:t,segmentCount:n}})}async function A(e,t,n){let r=F(e,t??``),i=``;i=r.startsWith(`data:`)?P(r):await M(r,n);let a;try{a=JSON.parse(i)}catch{throw Error(`Invalid SourceMap JSON: ${r}`)}return{resolvedUrl:r,map:j(a)}}function j(e){let t=v(e);if(t.version!==3)throw Error(`Only SourceMap version 3 is supported`);let n=y(t.mappings);if(n===void 0)throw Error(`SourceMap.mappings is required`);let r=(Array.isArray(t.sources)?t.sources:[]).map(e=>y(e)).filter(e=>typeof e==`string`),i=(Array.isArray(t.names)?t.names:[]).map(e=>y(e)).filter(e=>typeof e==`string`),a=y(t.sourceRoot),o;return Array.isArray(t.sourcesContent)&&(o=t.sourcesContent.map(e=>typeof e==`string`?e:null)),{version:3,sources:r,sourcesContent:o,mappings:n,names:i,sourceRoot:a}}async function M(e,t){N(e);{let t=new AbortController,n=setTimeout(()=>t.abort(),1e4);try{let n=await fetch(e,{signal:t.signal});if(!n.ok)throw Error(`HTTP ${n.status} ${n.statusText}`);return await n.text()}catch(t){if(t.name===`AbortError`)throw Error(`SourceMap fetch timed out after 10s: ${e}`,{cause:t})}finally{clearTimeout(n)}}let n=await r(await t.getActivePage(),async e=>{let t=new AbortController,n=setTimeout(()=>t.abort(),1e4);try{let n=await fetch(e,{signal:t.signal});return n.ok?await n.text():`__FETCH_ERROR__HTTP ${n.status} ${n.statusText}`}catch(e){return`__FETCH_ERROR__${e instanceof Error?e.message:String(e)}`}finally{clearTimeout(n)}},e);if(typeof n!=`string`)throw Error(`Failed to fetch SourceMap content`);if(n.startsWith(`__FETCH_ERROR__`))throw Error(n.slice(15)||`Failed to fetch SourceMap content`);return n}function N(e){let t;try{t=new URL(e)}catch{throw Error(`Invalid URL: ${e}`)}if(t.protocol!==`http:`&&t.protocol!==`https:`)throw Error(`Blocked: unsupported protocol "${t.protocol}"`);let n=t.hostname.toLowerCase(),r=[/^127\./,/^10\./,/^172\.(1[6-9]|2\d|3[01])\./,/^192\.168\./,/^0\./,/^169\.254\./,/^\[?::1\]?$/,/^\[?fe80:/i,/^\[?fc00:/i,/^\[?fd/i];if([`localhost`,`metadata.google.internal`,`metadata`].includes(n))throw Error(`SSRF blocked: hostname "${n}" is not allowed`);for(let e of r)if(e.test(n))throw Error(`SSRF blocked: protected/reserved IP "${n}" is not allowed`)}function P(e){let t=e.indexOf(`,`);if(t===-1)throw Error(`Invalid data URI source map`);let n=e.slice(0,t),r=e.slice(t+1);return/;base64/i.test(n)?Buffer.from(r,`base64`).toString(`utf-8`):decodeURIComponent(r)}function F(e,t){let n=e.trim();if(!n)return``;if(n.startsWith(`data:`)||b(n)||!t)return n;try{return new URL(n,t).toString()}catch{return n}}function I(e){let t=e.slice(-8192),n=/(?:\/\/[@#]\s*sourceMappingURL=([^\s]+)|\/\*[@#]\s*sourceMappingURL=([^*]+)\*\/)/g,r,i=null;for(;r=n.exec(t),r;){let e=(r[1]??r[2]??``).trim();e&&(i=e)}return i}function L(e,t){if(!e)return t;if(!t)return e;if(b(t)||t.startsWith(`/`))return t;if(b(e))try{let n=e.endsWith(`/`)?e:`${e}/`;return new URL(t,n).toString()}catch{return`${e.replace(/\/+$/g,``)}/${t.replace(/^\/+/g,``)}`}return`${e.replace(/\/+$/g,``)}/${t.replace(/^\/+/g,``)}`}function R(e,t){let n=e.trim();if(!n)return`source_${t+1}.js`;if(n.startsWith(`webpack://`)&&(n=n.slice(10)),n.startsWith(`data:`))return`inline/source_${t+1}.txt`;if(b(n))try{let e=new URL(n);n=`${e.hostname}${e.pathname}`}catch{n=n.replace(/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//,``)}n=n.replace(/[?#].*$/g,``),n=n.replace(/^[A-Za-z]:[\\/]/,``),n=n.replace(/^\/+/,``);let r=n.split(/[\\/]+/).map(e=>z(e)).filter(e=>e!==``&&e!==`.`&&e!==`..`);return r.length===0?`source_${t+1}.js`:r.join(`/`)}function z(e){let t=Array.from(e,e=>{let t=e.codePointAt(0);return t!==void 0&&(t<=31||`<>:"|?*`.includes(e))?`_`:e}).join(``).replace(/\s+/g,` `).trim();return!t||t===`.`||t===`..`?`_`:t}function B(e){return e.replace(/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//,``).replace(/[^a-zA-Z0-9_-]/g,`_`).replace(/_+/g,`_`).replace(/^_|_$/g,``).slice(0,48)}function V(e){let t=0;for(let n of e)n&&(t+=1+V(n.children));return t}var H=class{state;constructor(e){this.state=e}async handleSourcemapDiscover(t){let n=x(t.includeInline,!0),r=await(await this.state.collector.getActivePage()).createCDPSession(),i=new Map,a=e=>{let t=v(e),n=y(t.scriptId);if(!n)return;let r=y(t.url)??``,a=y(t.sourceMapURL)??``,o=i.get(n),s=a?F(a,r):o?.sourceMapUrl??``;i.set(n,{scriptId:n,scriptUrl:r||o?.scriptUrl||``,sourceMapUrl:s,isInline:s.startsWith(`data:`)})};try{r.on?.(`Debugger.scriptParsed`,a),await r.send(`Debugger.enable`),await E(e);for(let e of i.values())if(!e.sourceMapUrl&&!(!e.scriptId||!e.scriptUrl))try{let t=y(v(await r.send(`Debugger.getScriptSource`,{scriptId:e.scriptId})).scriptSource);if(!t)continue;let n=I(t);if(!n)continue;let i=F(n,e.scriptUrl);e.sourceMapUrl=i,e.isInline=i.startsWith(`data:`)}catch{continue}return g(Array.from(i.values()).filter(e=>e.sourceMapUrl.length>0).filter(e=>n||!e.isInline).toSorted((e,t)=>{let n=`${e.scriptUrl}|${e.scriptId}`,r=`${t.scriptUrl}|${t.scriptId}`;return n.localeCompare(r)}).map(e=>({scriptUrl:e.scriptUrl,sourceMapUrl:e.sourceMapUrl,isInline:e.isInline,scriptId:e.scriptId})))}catch(e){return _(`sourcemap_discover`,e)}finally{r.off?.(`Debugger.scriptParsed`,a),await T(r,`Debugger.disable`),await w(r)}}async handleSourcemapFetchAndParse(e){try{let t=await O(S(e.sourceMapUrl,`sourceMapUrl`),C(e.scriptUrl),this.state.collector),n={sources:t.map.sources,mappingsCount:t.mappingsCount,segmentCount:t.segmentCount};return Array.isArray(t.map.sourcesContent)&&(n.sourcesContent=t.map.sourcesContent),g(n)}catch(e){return _(`sourcemap_fetch_and_parse`,e)}}async handleSourcemapCoverage(e){try{let t=S(e.sourceMapUrl,`sourceMapUrl`),n=await O(t,C(e.scriptUrl),this.state.collector),r=new Map,i=new Map,a=0;for(let e=0;e<n.mappings.length;e+=1){let t=n.mappings[e];if(!t)continue;let o=n.mappings[e+1],s=1;if(o&&o.generatedLine===t.generatedLine&&(s=Math.max(o.generatedColumn-t.generatedColumn,1)),t?.sourceIndex===void 0){a+=s;continue}r.set(t.sourceIndex,(r.get(t.sourceIndex)??0)+s),i.set(t.sourceIndex,(i.get(t.sourceIndex)??0)+1)}let o=n.map.sources.map((e,t)=>{let a=r.get(t)??0,o=i.get(t)??0,s=n.map.sourcesContent?.[t],c=typeof s==`string`?Buffer.byteLength(s,`utf-8`):null,l=c===null?null:Math.max(c-a,0),u=c&&c>0?Number((a/c*100).toFixed(2)):null;return{source:e,generatedSegments:o,mappedBytes:a,coveredBytes:a,unmappedBytes:l,coveragePercent:u,coveredPercent:u,sourceContentBytes:c}}),s=o.reduce((e,t)=>e+(typeof t.coveredBytes==`number`?t.coveredBytes:0),0);return g({sourceMapUrl:t,resolvedUrl:n.resolvedUrl,totalMappings:n.segmentCount,mappedSourceCount:o.filter(e=>e.generatedSegments>0).length,coveredBytes:s,uncoveredGeneratedBytes:a,buckets:[{source:`[unmapped]`,generatedSegments:n.mappings.filter(e=>e.sourceIndex===void 0).length,coveredBytes:a}],sources:o})}catch(e){return _(`sourcemap_coverage`,e)}}async handleSourcemapLookup(e){try{let t=S(e.sourceMapUrl,`sourceMapUrl`),n=C(e.scriptUrl),r=Number(e.line),i=Number(e.column);if(!Number.isInteger(r)||r<1)throw Error(`line must be a positive integer`);if(!Number.isFinite(i)||i<0)throw Error(`column must be a non-negative number`);let a=await O(t,n,this.state.collector),o=a.mappings.find(e=>e.generatedLine===r&&e.generatedColumn===i);if(!o){let e=a.mappings.filter(e=>e.generatedLine===r&&e.generatedColumn<=i);o=e.length>0?e[e.length-1]:void 0}if(!o||o.sourceIndex===void 0)return g({success:!1,sourceMapUrl:t,resolvedUrl:a.resolvedUrl,generated:{line:r,column:i},error:`No original source mapping found for generated position`});let s=o.sourceIndex;return g({success:!0,sourceMapUrl:t,resolvedUrl:a.resolvedUrl,generated:{line:r,column:i},original:{source:a.map.sources[s]??null,line:o.originalLine??null,column:o.originalColumn??null,name:typeof o.nameIndex==`number`?a.map.names[o.nameIndex]??null:null,sourceIndex:s},matchType:o.generatedLine===r&&o.generatedColumn===i?`exact`:`closest-preceding`})}catch(e){return _(`sourcemap_lookup`,e)}}async handleSourcemapReconstructTree(e){try{let t=S(e.sourceMapUrl,`sourceMapUrl`),r=C(e.outputDir),i=await k(t,void 0,this.state.collector),a=await n({category:`reports`,toolName:`sourcemap-tree`,target:B(i.resolvedUrl),ext:`tmp`,...r?{customDir:r}:{}}),u=a.absolutePath.replace(/\.tmp$/i,``),d=a.displayPath.replace(/\.tmp$/i,``);await c(u,{recursive:!0});let f=[],p=0;for(let e=0;e<i.map.sources.length;e+=1){let t=i.map.sources[e]??``,n=L(i.map.sourceRoot,t),r=R(n,e),a=s(u,r),d=i.map.sourcesContent&&e<i.map.sourcesContent.length?i.map.sourcesContent[e]:null,m=typeof d==`string`?d:`/* source content missing in source map: ${n} */\n`;try{await c(o(a),{recursive:!0}),await l(a,m,`utf-8`),f.push(r)}catch{p+=1}}return g({outputDir:d,totalSources:i.map.sources.length,writtenFiles:f.length,skippedFiles:p,files:f})}catch(e){return _(`sourcemap_reconstruct_tree`,e)}}async handleSourcemapParseV4(e){let n=S(e.sourceMapUrl,`sourceMapUrl`),r=x(e.extractScopes,!0),i=x(e.extractDebugIds,!0);try{let a=await M(n,this.state.collector),o=JSON.parse(a),s=Array.isArray(o.names)?o.names.filter(e=>typeof e==`string`):[],c=Array.isArray(o.sources)?o.sources.filter(e=>typeof e==`string`):[],l={version:o.version,sources:c.length,names:s.length,mappings:typeof o.mappings==`string`?o.mappings.length:0,hasFile:typeof o.file==`string`,hasSourceRoot:typeof o.sourceRoot==`string`},u={success:!0,sourceMapUrl:n,version:o.version,v3Baseline:l};if(i&&typeof o.debugId==`string`){let e=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(o.debugId);u.debugId=o.debugId,u.debugIdValid=e}let d=typeof o.scopes==`string`?o.scopes:typeof o.x_scopes==`string`?o.x_scopes:void 0;if(r&&d)try{let e=U(d,s,c);u.isV4=!0,u.scopes=e,u.scopeCount=V(e.originalScopes),u.generatedRangeCount=e.generatedRanges.length}catch(e){u.success=!1,u.scopeDecodeError=e instanceof Error?e.message:String(e),u.rawScopesField=d.substring(0,t)+(d.length>t?`...`:``),u.isV4=!0}let f={};return o.x_scopeLines&&(f.x_scopeLines=o.x_scopeLines),o.x_namesIdx&&(f.x_namesIdx=o.x_namesIdx),o.x_computedBases&&(f.x_computedBases=o.x_computedBases),Object.keys(f).length>0&&(u.extensions=f),!d&&!o.debugId&&Object.keys(f).length===0&&(u.isV4=!1,u.note=`No v4 fields (scopes/debugId) found. This source map is v3 only.`),e.compareV3===!0&&(u.comparison={v3Only:[`version`,`sources`,`names`,`mappings`,`file`,`sourceRoot`],v4Only:Object.keys(u).filter(e=>![`success`,`sourceMapUrl`,`version`,`v3Baseline`,`comparison`].includes(e))}),g(u)}catch(e){return _(`sourcemap_parse_v4`,e)}}};function U(e,t,n){let r=e.split(`,`),i={value:0},a=[],o=0,s=0,c=0,l=0,u=0,d=0,m=e=>e>0&&e<=t.length?t[e-1]:void 0;function h(e){return e>=0&&e<r.length?r[e]:void 0}function g(e,n){let l=h(i.value++);if(!l?.startsWith(`B`))throw Error(`expected original scope start 'B', got "${l}"`);let u=p(l.slice(1)),d=f(l.slice(1)),m=0,_=u[m++]??0,v=n.line+(u[m++]??0),y=u[m++]??0,b=v===n.line?n.column+y:y,x;_&1&&(o+=d[m++]??0,x=t[o]);let S;_&2&&(s+=d[m++]??0,S=t[s]);let C={index:a.length,sourceIndex:e,start:{line:v,column:b},end:{line:v,column:b},name:x,kind:S,isStackFrame:(_&4)!=0,variables:[],children:[]};a.push(C);let w={line:v,column:b};for(;i.value<r.length;){let n=r[i.value]??``;if(n.startsWith(`D`)){i.value++;let e=f(n.slice(1));for(let n of e)c+=n,C.variables.push(t[c]??`<name:${c}>`);continue}if(n.startsWith(`B`)){let t=g(e,w);w={...t.end},C.children.push(t);continue}break}let T=h(i.value++);if(!T?.startsWith(`C`))throw Error(`expected original scope end 'C', got "${T}"`);let E=p(T.slice(1)),D=w.line+(E[0]??0),O=E[1]??0;return C.end={line:D,column:D===w.line?w.column+O:O},C}function _(e){let t=h(i.value++);if(!t?.startsWith(`E`))throw Error(`expected generated range start 'E', got "${t}"`);let n=p(t.slice(1)),a=f(t.slice(1)),o=0,s=n[o++]??0,c=(s&1)!=0,g=e.line+(c?n[o++]??0:0),v=n[o++]??0,y=g===e.line?e.column+v:v,b;s&2&&(d+=a[o++]??0,b=d);let x={start:{line:g,column:y},end:{line:g,column:y},isStackFrame:(s&4)!=0,isHidden:(s&8)!=0,definitionIndex:b,children:[]},S=new Map,C=0,w={line:g,column:y};for(;i.value<r.length;){let e=r[i.value]??``;if(e.startsWith(`G`)){i.value++,x.bindings=p(e.slice(1)).map(e=>m(e));continue}if(e.startsWith(`H`)){i.value++;let t=p(e.slice(1));x.bindings||=[];let n=0;C+=t[n++]??0;let r=C,a=[],o=S.get(r)??{line:x.start.line,column:x.start.column};for(;n<t.length;){let e=m(t[n++]??0),r=t[n++]??0,i=o.line+r,s=t[n++]??0,c=i===o.line?o.column+s:s;a.push({from:{line:i,column:c},expression:e}),o={line:i,column:c}}for(S.set(r,o);x.bindings.length<=r;)x.bindings.push(void 0);x.bindings[r]=a;continue}if(e.startsWith(`I`)){i.value++;let t=p(e.slice(1));x.callsite={sourceIndex:t[0]??0,line:t[1]??0,column:t[2]??0};continue}if(e.startsWith(`E`)){let e=_(w);w={...e.end},x.children.push(e);continue}break}let T=h(i.value++);if(!T?.startsWith(`F`))throw Error(`expected generated range end 'F', got "${T}"`);let E=p(T.slice(1)),D=E.length===2,O=w.line+(D?E[0]??0:0),k=E[+!!D]??0,A=O===w.line?w.column+k:k;return x.end={line:O,column:A},l=O,u=A,x}let v=Array.from({length:n.length},()=>null);for(let e=0;e<n.length&&i.value<r.length;e++){if((r[i.value]??``)===``){i.value++;continue}if(!(r[i.value]??``).startsWith(`B`))break;v[e]=g(e,{line:0,column:0}),(r[i.value]??``)===``&&i.value++}let y=[];for(;i.value<r.length;){if((r[i.value]??``)===``){i.value++;continue}y.push(_({line:l,column:u}))}return{originalScopes:v,generatedRanges:y}}var W=class{collector;extension;sourcemap;constructor(e){this.collector=e;let t={collector:e};this.extension=new D(t),this.sourcemap=new H(t)}handleExtensionListInstalled(e){return this.extension.handleExtensionListInstalled(e)}handleExtensionExecuteInContext(e){return this.extension.handleExtensionExecuteInContext(e)}handleSourcemapDiscover(e){return this.sourcemap.handleSourcemapDiscover(e)}handleSourcemapFetchAndParse(e){return this.sourcemap.handleSourcemapFetchAndParse(e)}handleSourcemapCoverage(e){return this.sourcemap.handleSourcemapCoverage(e)}handleSourcemapLookup(e){return this.sourcemap.handleSourcemapLookup(e)}handleSourcemapReconstructTree(e){return this.sourcemap.handleSourcemapReconstructTree(e)}handleSourcemapParseV4(e){return this.sourcemap.handleSourcemapParseV4(e)}};export{W as SourcemapToolHandlers};
@@ -0,0 +1 @@
1
+ import{BlockList as e,isIP as t}from"node:net";import{lookup as n}from"node:dns/promises";const r=new e,i=new e,a=[[`0.0.0.0`,8],[`10.0.0.0`,8],[`100.64.0.0`,10],[`127.0.0.0`,8],[`169.254.0.0`,16],[`172.16.0.0`,12],[`192.168.0.0`,16]],o=[[`::`,128],[`::1`,128],[`::ffff:0:0`,96],[`::ffff:0:0:0`,96],[`64:ff9b::`,96],[`100::`,64],[`fc00::`,7],[`fe80::`,10]];for(let[e,t]of a)r.addSubnet(e,t,`ipv4`);for(let[e,t]of o)i.addSubnet(e,t,`ipv6`);function s(e){return e.trim().replace(/^\[|\]$/g,``).toLowerCase()}function c(e){let n=t(e);return n===4?`ipv4`:n===6?`ipv6`:null}function l(e){if(typeof e!=`string`)return{expiresAt:null,expiresAtMs:null};let t=e.trim();if(t.length===0)return{expiresAt:null,expiresAtMs:null};let n=Date.parse(t);if(!Number.isFinite(n))throw Error(`Invalid authorization expiry "${e}"`);return{expiresAt:t,expiresAtMs:n}}function u(e,t,n){let r=[];for(let i of e){let e=i.trim();if(e.length===0)continue;let a=e.lastIndexOf(`/`);if(a<=0||a===e.length-1)throw Error(`Invalid authorization CIDR "${i}"`);let o=e.slice(0,a).trim(),l=e.slice(a+1).trim(),u=Number(l),d=c(o);if(!Number.isInteger(u)||!d||d===`ipv4`&&(u<0||u>32)||d===`ipv6`&&(u<0||u>128))throw Error(`Invalid authorization CIDR "${i}"`);d===`ipv4`?t.addSubnet(o,u,d):n.addSubnet(o,u,d),r.push(`${s(o)}/${u}`)}return r}function d(e,t){if(!e||!t)return!1;let n=s(t);if(e.allowedHosts.has(n))return!0;let r=c(n);return r?r===`ipv4`?e.ipv4AllowBlockList.check(n,r):e.ipv6AllowBlockList.check(n,r):!1}function f(){return process.env.ALLOW_LOCAL_SSRF===`true`}function p(e){let t=s(e);return t===`localhost`||t===`127.0.0.1`||t===`::1`}function m(e){let t=s(e);if(t===`localhost`)return!0;let n=c(t);return n?n===`ipv4`?r.check(t,n):i.check(t,n):!1}function h(t){if(!t)return;let n=new Set((t.allowedHosts??[]).map(e=>s(e)).filter(e=>e.length>0)),r=new e,i=new e,a=u(t.allowedCidrs??[],r,i),{expiresAt:o,expiresAtMs:c}=l(t.expiresAt),d=typeof t.reason==`string`?t.reason.trim():``;return{allowedHosts:n,allowedCidrs:a,allowPrivateNetwork:t.allowPrivateNetwork===!0,allowInsecureHttp:t.allowInsecureHttp===!0,expiresAt:o,expiresAtMs:c,reason:d.length>0?d:null,ipv4AllowBlockList:r,ipv6AllowBlockList:i}}function g(e){return e?e.allowedHosts.size>0||e.allowedCidrs.length>0:!1}function _(e,t=Date.now()){return!e||e.expiresAtMs===null?!1:t>e.expiresAtMs}async function v(e){let t=new URL(e),r=s(t.hostname),i=c(r)!==null;if(i)return{parsedUrl:t,hostname:r,resolvedAddress:r,isIpLiteral:i};if(r===`localhost`)return{parsedUrl:t,hostname:r,resolvedAddress:`127.0.0.1`,isIpLiteral:i};let{address:a}=await n(r);return{parsedUrl:t,hostname:r,resolvedAddress:s(a),isIpLiteral:i}}function y(e,t){return e?d(e,t.hostname)||d(e,t.resolvedAddress):!1}async function b(e,t){try{let n=h(t);if(_(n))return!0;let r=new URL(e);if(!n&&f())return!1;let i=await v(r.toString());return m(i.hostname)||m(i.resolvedAddress??``)?n?.allowPrivateNetwork?!y(n,i):!0:!1}catch{return!0}}export{p as a,b as c,f as i,v as l,g as n,_ as o,y as r,m as s,h as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./logger-sBC6IdRT.mjs";import{Ci as t,wi as n}from"./constants-BYj8Xek8.mjs";import{t as r}from"./RingBuffer-Dm54ELKT.mjs";import{o as i,s as a}from"./PageController-Dfsm1_o7.mjs";import"./definitions-RZYGD_Ey.mjs";function o(e){return{collector:e,wsSession:null,wsListeners:null,wsConfig:{enabled:!1,maxFrames:1e3},wsFramesByRequest:new Map,wsFrameOrder:new r(1e3),wsConnections:new Map,sseConfig:{maxEvents:2e3}}}function s(e){return{content:[{type:`text`,text:JSON.stringify(e,null,2)}]}}function c(e){if(typeof e!=`string`)return;let t=e.trim();return t.length>0?t:void 0}function l(e,t){let n;if(typeof e==`number`&&Number.isFinite(e))n=e;else if(typeof e==`string`){let t=Number(e.trim());Number.isFinite(t)&&(n=t)}return n===void 0&&(n=t.defaultValue),t.integer&&(n=Math.trunc(n)),n<t.min&&(n=t.min),n>t.max&&(n=t.max),n}function u(e){return e===`sent`||e===`received`||e===`all`?e:`all`}function d(e){try{return{regex:new RegExp(e)}}catch(e){return{error:e instanceof Error?e.message:String(e)}}}const f=e=>typeof e==`object`&&e?e:void 0,p=(e,t)=>{let n=f(e)?.[t];return typeof n==`string`?n:void 0},m=(e,t)=>{let n=f(e)?.[t];return typeof n==`number`?n:void 0},h=(e,t)=>{let n=f(e)?.[t];return f(n)};var g=class{s;constructor(e){this.s=e}async teardownWsSession(){if(this.s.wsSession&&this.s.wsListeners){try{this.s.wsSession.off(`Network.webSocketCreated`,this.s.wsListeners.created)}catch(t){e.debug(`[ws-teardown] Failed to remove webSocketCreated listener`,t)}try{this.s.wsSession.off(`Network.webSocketClosed`,this.s.wsListeners.closed)}catch(t){e.debug(`[ws-teardown] Failed to remove webSocketClosed listener`,t)}try{this.s.wsSession.off(`Network.webSocketHandshakeResponseReceived`,this.s.wsListeners.handshake)}catch(t){e.debug(`[ws-teardown] Failed to remove handshakeResponseReceived listener`,t)}try{this.s.wsSession.off(`Network.webSocketFrameSent`,this.s.wsListeners.frameSent)}catch(t){e.debug(`[ws-teardown] Failed to remove webSocketFrameSent listener`,t)}try{this.s.wsSession.off(`Network.webSocketFrameReceived`,this.s.wsListeners.frameReceived)}catch(t){e.debug(`[ws-teardown] Failed to remove webSocketFrameReceived listener`,t)}}if(this.s.wsSession)try{await this.s.wsSession.detach()}catch(t){e.debug(`[ws-teardown] Failed to detach CDP session`,t)}this.s.wsSession=null,this.s.wsListeners=null}handleWsFrame(e,r){let i=p(r,`requestId`);if(!i)return;if(!this.s.wsConnections.get(i)){if(this.s.wsConfig.urlFilter)return;this.s.wsConnections.set(i,{requestId:i,url:`unknown`,status:`open`,framesCount:0,createdTimestamp:Date.now()/1e3})}let a=this.s.wsConnections.get(i);if(!a||this.s.wsConfig.urlFilter&&a.url!==`unknown`&&!this.s.wsConfig.urlFilter.test(a.url))return;let o=h(r,`response`),s=m(o,`opcode`)??-1,c=p(o,`payloadData`)??``,l=c.length>t?`${c.slice(0,t)}…`:c,u=c.length>n?c.slice(0,n):c,d={requestId:i,timestamp:m(r,`timestamp`)??Date.now()/1e3,direction:e,opcode:s,payloadLength:c.length,payloadPreview:l,payloadSample:u,isBinary:s===2};this.appendWsFrame(i,d)}appendWsFrame(e,t){let n=this.s.wsFramesByRequest.get(e)??[];n.push(t),this.s.wsFramesByRequest.set(e,n);let r=this.s.wsConnections.get(e);r&&(r.framesCount+=1,r.status===`connecting`&&(r.status=`open`)),this.s.wsFrameOrder.push({requestId:e,frame:t}),this.enforceWsFrameLimit()}enforceWsFrameLimit(){for(;this.s.wsFrameOrder.length>this.s.wsConfig.maxFrames;){let e=this.s.wsFrameOrder.shift();if(!e)break;let t=this.s.wsFramesByRequest.get(e.requestId);t&&t.length>0&&(t.shift(),t.length===0?this.s.wsFramesByRequest.delete(e.requestId):this.s.wsFramesByRequest.set(e.requestId,t));let n=this.s.wsConnections.get(e.requestId);n&&(n.framesCount=Math.max(0,n.framesCount-1))}}getWsFrameStats(){let e=0,t=0;for(let n of this.s.wsFrameOrder)n.frame.direction===`sent`?e+=1:t+=1;return{total:this.s.wsFrameOrder.length,sent:e,received:t}}async handleWsMonitorEnable(e){let t=l(e.maxFrames,{defaultValue:1e3,min:1,max:2e4,integer:!0}),n=c(e.urlFilter),i;if(n){let e=d(n);if(e.error)return s({success:!1,error:`Invalid urlFilter regex: ${e.error}`});i=e.regex}await this.teardownWsSession(),this.s.wsFramesByRequest.clear(),this.s.wsFrameOrder=new r(t),this.s.wsConnections.clear();let a=await(await this.s.collector.getActivePage()).createCDPSession();await a.send(`Network.enable`);let o={created:e=>{let t=p(e,`requestId`),n=p(e,`url`);if(!t||!n||i&&!i.test(n))return;let r=this.s.wsConnections.get(t);this.s.wsConnections.set(t,{requestId:t,url:n,status:r?.status??`connecting`,framesCount:r?.framesCount??0,createdTimestamp:r?.createdTimestamp??Date.now()/1e3,closedTimestamp:r?.closedTimestamp,handshakeStatus:r?.handshakeStatus})},closed:e=>{let t=p(e,`requestId`);if(!t)return;let n=this.s.wsConnections.get(t);if(!n)return;n.status=`closed`;let r=m(e,`timestamp`);n.closedTimestamp=r===void 0?Date.now()/1e3:r},handshake:e=>{let t=p(e,`requestId`);if(!t)return;let n=this.s.wsConnections.get(t);if(!n)return;let r=m(h(e,`response`),`status`);r!==void 0&&(n.handshakeStatus=r,n.status=r>=100&&r<400?`open`:`error`)},frameSent:e=>{this.handleWsFrame(`sent`,e)},frameReceived:e=>{this.handleWsFrame(`received`,e)}};return a.on(`Network.webSocketCreated`,o.created),a.on(`Network.webSocketClosed`,o.closed),a.on(`Network.webSocketHandshakeResponseReceived`,o.handshake),a.on(`Network.webSocketFrameSent`,o.frameSent),a.on(`Network.webSocketFrameReceived`,o.frameReceived),this.s.wsSession=a,this.s.wsListeners=o,this.s.wsConfig={enabled:!0,maxFrames:t,urlFilterRaw:n,urlFilter:i},s({success:!0,message:`WebSocket monitor enabled`,config:{maxFrames:t,urlFilter:n??null},stats:{trackedConnections:this.s.wsConnections.size,capturedFrames:this.s.wsFrameOrder.length}})}async handleWsMonitorDisable(e){let t=this.getWsFrameStats(),n=Array.from(this.s.wsConnections.values()),r={success:!0,message:`WebSocket monitor disabled`,config:{maxFrames:this.s.wsConfig.maxFrames,urlFilter:this.s.wsConfig.urlFilterRaw??null},summary:{trackedConnections:n.length,activeConnections:n.filter(e=>e.status===`open`||e.status===`connecting`).length,closedConnections:n.filter(e=>e.status===`closed`).length,totalFrames:t.total,sentFrames:t.sent,receivedFrames:t.received}};return await this.teardownWsSession(),this.s.wsConfig={...this.s.wsConfig,enabled:!1},s(r)}async handleWsGetFrames(e){let t=u(e.direction),n=l(e.limit,{defaultValue:100,min:1,max:5e3,integer:!0}),r=l(e.offset,{defaultValue:0,min:0,max:2**53-1,integer:!0}),i=c(e.payloadFilter),a;if(i){let e=d(i);if(e.error)return s({success:!1,error:`Invalid payloadFilter regex: ${e.error}`});a=e.regex}let o=this.s.wsFrameOrder.toArray().map(e=>e.frame).filter(e=>t===`all`?!0:e.direction===t).filter(e=>a?a.test(e.payloadSample):!0),f=o.slice(r,r+n).map(e=>({requestId:e.requestId,timestamp:e.timestamp,direction:e.direction,opcode:e.opcode,payloadLength:e.payloadLength,payloadPreview:e.payloadPreview,isBinary:e.isBinary}));return s({success:!0,monitorEnabled:this.s.wsConfig.enabled,filters:{direction:t,payloadFilter:i??null},page:{offset:r,limit:n,returned:f.length,totalAfterFilter:o.length,hasMore:r+f.length<o.length,nextOffset:r+f.length<o.length?r+f.length:null},frames:f})}async handleWsGetConnections(e){let t=Array.from(this.s.wsConnections.values()).toSorted((e,t)=>e.createdTimestamp-t.createdTimestamp).map(e=>({requestId:e.requestId,url:e.url,status:e.status,framesCount:e.framesCount}));return s({success:!0,monitorEnabled:this.s.wsConfig.enabled,total:t.length,connections:t})}};function _(e){let t=window;t.__jshookSSEMonitor||={enabled:!0,patched:!1,maxEvents:e.maxEvents,urlFilterRaw:e.urlFilterRaw,events:[],sources:{}};let n=t.__jshookSSEMonitor;n.enabled=!0,n.maxEvents=e.maxEvents,n.urlFilterRaw=e.urlFilterRaw,n.events.length>n.maxEvents&&(n.events=n.events.slice(-n.maxEvents));let r=e=>{if(!n.urlFilterRaw)return!0;try{return new RegExp(n.urlFilterRaw).test(e)}catch{return!0}},i=e=>{if(typeof e==`string`)return e;if(e==null)return``;if(typeof e==`object`)try{return JSON.stringify(e)}catch{return`[unserializable]`}return String(e)},a=(e,t,a,o)=>{if(!n.enabled||!r(e))return;let s=i(a),c={sourceUrl:e,eventType:t,dataPreview:s.length>200?`${s.slice(0,200)}…`:s,dataLength:s.length,lastEventId:o,timestamp:Date.now()};for(n.events.push(c);n.events.length>n.maxEvents;)n.events.shift();let l=n.sources[e]??{url:e,status:`connecting`,eventCount:0};l.eventCount+=1,l.lastEventTimestamp=c.timestamp,n.sources[e]=l};if(t.EventSource===void 0)return{success:!1,error:`EventSource is not available in current page context`};if(!n.patched){let e=t.EventSource,i=function(t,i){let o=String(t),s=new e(t,i);if(r(o)){let e=n.sources[o]??{url:o,status:`connecting`,eventCount:0};n.sources[o]=e}s.addEventListener(`open`,()=>{let e=n.sources[o];e&&(e.status=`open`),a(o,`open`,``,null)}),s.addEventListener(`error`,()=>{let e=n.sources[o];e&&(e.status=`error`),a(o,`error`,``,null)}),s.addEventListener(`message`,e=>{let t=typeof e.lastEventId==`string`&&e.lastEventId.length>0?e.lastEventId:null;a(o,e.type||`message`,e.data,t)});let c=s.addEventListener.bind(s),l=(e,t,n)=>{c(e,t,n)};return Object.defineProperty(s,`addEventListener`,{value:(e,t,n)=>{if(e!==`message`&&e!==`open`&&e!==`error`&&t){l(e,n=>{let r=n,i=typeof r.lastEventId==`string`&&r.lastEventId.length>0?r.lastEventId:null;a(o,e,r.data,i),typeof t==`function`?t.call(s,n):t.handleEvent(n)},n);return}l(e,t,n)},configurable:!0,writable:!0}),s};i.prototype=e.prototype;try{Object.defineProperty(i,`CONNECTING`,{value:e.CONNECTING}),Object.defineProperty(i,`OPEN`,{value:e.OPEN}),Object.defineProperty(i,`CLOSED`,{value:e.CLOSED})}catch{}t.EventSource=i,n.originalEventSource=e,n.patched=!0}return{success:!0,message:`SSE monitor enabled`,patched:n.patched,urlFilter:n.urlFilterRaw,maxEvents:n.maxEvents,existingEvents:n.events.length}}var v=class{s;constructor(e){this.s=e}async enableSseInterceptor(e,t,n){let r=await this.s.collector.getActivePage();return n?.persistent?(await i(r,_,{maxEvents:e,urlFilterRaw:t}),{success:!0,message:`SSE monitor enabled (persistent — survives navigations)`,patched:!0,urlFilter:t,maxEvents:e,existingEvents:0}):await a(r,_,{maxEvents:e,urlFilterRaw:t})}async handleSseMonitorEnable(e){let t=l(e.maxEvents,{defaultValue:2e3,min:1,max:5e4,integer:!0}),n=c(e.urlFilter);if(n){let e=d(n);if(e.error)return s({success:!1,error:`Invalid urlFilter regex: ${e.error}`})}let r=e.persistent===!0,i=await this.enableSseInterceptor(t,n,{persistent:r});return i.success?(this.s.sseConfig={maxEvents:t,urlFilterRaw:n},s({success:!0,message:i.message,patched:i.patched,config:{maxEvents:this.s.sseConfig.maxEvents,urlFilter:this.s.sseConfig.urlFilterRaw??null},existingEvents:i.existingEvents})):s(i)}async handleSseGetEvents(e){let t=c(e.sourceUrl),n=c(e.eventType),r=l(e.limit,{defaultValue:100,min:1,max:5e3,integer:!0}),i=l(e.offset,{defaultValue:0,min:0,max:2**53-1,integer:!0});return s(await a(await this.s.collector.getActivePage(),e=>{let t=window.__jshookSSEMonitor;if(!t)return{success:!1,message:`SSE monitor is not enabled. Call sse_monitor_enable first.`};let n=t.events;e.sourceUrl&&(n=n.filter(t=>t.sourceUrl===e.sourceUrl)),e.eventType&&(n=n.filter(t=>t.eventType===e.eventType));let r=n.length,i=n.slice(e.offset,e.offset+e.limit);return{success:!0,filters:{sourceUrl:e.sourceUrl??null,eventType:e.eventType??null},page:{offset:e.offset,limit:e.limit,returned:i.length,totalAfterFilter:r,hasMore:e.offset+i.length<r,nextOffset:e.offset+i.length<r?e.offset+i.length:null},monitor:{enabled:t.enabled,patched:t.patched,maxEvents:t.maxEvents,urlFilter:t.urlFilterRaw??null,sourceCount:Object.keys(t.sources).length},events:i}},{sourceUrl:t,eventType:n,limit:r,offset:i}))}},y=class{collector;state;ws;sse;get wsConnections(){return this.state.wsConnections}get wsFrameOrder(){return this.state.wsFrameOrder}get wsConfig(){return this.state.wsConfig}get wsFramesByRequest(){return this.state.wsFramesByRequest}get sseConfig(){return this.state.sseConfig}constructor(e){this.collector=e,this.state=o(e),this.ws=new g(this.state),this.sse=new v(this.state)}handleWsMonitorDispatch=e=>String(e.action??``)===`disable`?this.ws.handleWsMonitorDisable(e):this.ws.handleWsMonitorEnable(e);handleWsMonitorEnable=e=>this.ws.handleWsMonitorEnable(e);handleWsMonitorDisable=e=>this.ws.handleWsMonitorDisable(e);handleWsGetFrames=e=>this.ws.handleWsGetFrames(e);handleWsGetConnections=e=>this.ws.handleWsGetConnections(e);handleSseMonitorEnable=e=>this.sse.handleSseMonitorEnable(e);handleSseGetEvents=e=>this.sse.handleSseGetEvents(e)};export{y as StreamingToolHandlers};
@@ -0,0 +1 @@
1
+ function e(e){return{name:e,description:``,properties:{},required:[],annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},asyncTask:!1,autocompleteHandlers:{},outputSchema:void 0}}function t(e){return e?.default===void 0?{}:{default:e.default}}function n(e,t){return{...e,...t}}function r(e,t,r){return n(e,{properties:{...e.properties,[t]:r}})}function i(e,t){return n(e,{required:[...e.required,...t]})}function a(e,t){return n(e,{annotations:{...e.annotations,...t}})}function o(e){return{name:e.name,description:e.description,inputSchema:{type:`object`,properties:e.properties,...e.required.length>0?{required:[...e.required]}:{}},annotations:{readOnlyHint:e.annotations.readOnlyHint,destructiveHint:e.annotations.destructiveHint,idempotentHint:e.annotations.idempotentHint,openWorldHint:e.annotations.openWorldHint},...e.asyncTask?{execution:{taskSupport:`optional`}}:{},...Object.keys(e.autocompleteHandlers).length>0?{autocompleteHandlers:e.autocompleteHandlers}:{},...e.outputSchema?{outputSchema:e.outputSchema}:{}}}function s(e,c){let l=e=>{let t=s(e,c);return c&&(c.latest=t),t},u={desc(t){return l(n(e,{description:t}))},string(n,i,a){let o={type:`string`,description:i,...t(a)};return a?.pattern&&(o.pattern=a.pattern),l(r(e,n,o))},number(n,i,a){let o={type:`number`,description:i,...t(a)};return a?.minimum!==void 0&&(o.minimum=a.minimum),a?.maximum!==void 0&&(o.maximum=a.maximum),l(r(e,n,o))},integer(n,i,a){let o={type:`integer`,description:i,...t(a)};return a?.minimum!==void 0&&(o.minimum=a.minimum),a?.maximum!==void 0&&(o.maximum=a.maximum),l(r(e,n,o))},boolean(n,i,a){return l(r(e,n,{type:`boolean`,description:i,...t(a)}))},enum(n,i,a,o){return l(r(e,n,{type:`string`,enum:i,description:a,...t(o)}))},array(t,n,i){return l(r(e,t,{type:`array`,items:n,description:i}))},object(t,n,i,a){return l(r(e,t,{type:`object`,properties:n,description:i,...a?.required?{required:a.required}:{}}))},prop(t,n){return l(r(e,t,n))},required(...t){return l(i(e,t))},requiredOpenWorld(...e){return this.required(...e).openWorld()},readOnly(){return l(a(e,{readOnlyHint:!0}))},destructive(){return l(a(e,{destructiveHint:!0}))},idempotent(){return l(a(e,{idempotentHint:!0}))},openWorld(){return l(a(e,{openWorldHint:!0}))},query(){return this.readOnly().idempotent()},resettable(){return this.destructive().idempotent()},asyncTask(){return l(n(e,{asyncTask:!0}))},autocomplete(t,r){return l(n(e,{autocompleteHandlers:{...e.autocompleteHandlers,[t]:r}}))},outputSchema(t){return l(n(e,{outputSchema:t}))},build(){return o(e)}};return c&&!c.latest&&(c.latest=u),u}function c(t,n){let r={},i=s(e(t),r);return(n(i)??r.latest??i).build()}export{c as t};