@jshookmcp/jshook 0.2.9 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (316) hide show
  1. package/README.md +25 -50
  2. package/README.zh.md +25 -48
  3. package/dist/AntiCheatDetector-CGVGNfy5.mjs +1 -0
  4. package/dist/CacheAdapters-CdAxBmVW.mjs +1 -0
  5. package/dist/CodeInjector-BlgyqTOk.mjs +1 -0
  6. package/dist/ConsoleMonitor-Dkqc0HNi.mjs +490 -0
  7. package/dist/DOMInspector-BYY_EJ0C.mjs +95 -0
  8. package/dist/DarwinAPI-DC4HGGLl.mjs +1 -0
  9. package/dist/DetailedDataManager-BniBJlVv.mjs +1 -0
  10. package/dist/EventBus-DgciURGg.mjs +1 -0
  11. package/dist/EvidenceGraphBridge-BIfgB7HP.mjs +1 -0
  12. package/dist/ExtensionManager-erMpqcLk.mjs +1 -0
  13. package/dist/FingerprintManager-N7BZqjxP.mjs +1 -0
  14. package/dist/HardwareBreakpoint-OcJqNFVc.mjs +1 -0
  15. package/dist/HeapAnalyzer-CqAxZzeS.mjs +1 -0
  16. package/dist/{HookGeneratorBuilders.core.generators.storage-CtcdK78Q.mjs → HookGeneratorBuilders.core.generators.storage-Bf1fbrNK.mjs} +66 -174
  17. package/dist/InstrumentationSession-DxXs0sCp.mjs +1 -0
  18. package/dist/MCPServer.search.handlers.domain-DVbWL1bT.mjs +1 -0
  19. package/dist/MemoryController-BaqstM5w.mjs +2 -0
  20. package/dist/MemoryScanSession-CaxAjZJf.mjs +1 -0
  21. package/dist/MemoryScanner-BLYnMJy6.mjs +1 -0
  22. package/dist/NativeMemoryManager.impl-CI554XbY.mjs +1 -0
  23. package/dist/NativeMemoryManager.utils-DM4NC3FE.mjs +1 -0
  24. package/dist/PEAnalyzer-DJyaJTQJ.mjs +1 -0
  25. package/dist/PageController-D9jVkH0i.mjs +1 -0
  26. package/dist/PointerChainEngine-5nF9eNlu.mjs +1 -0
  27. package/dist/PrerequisiteError-Bl3dK8XA.mjs +1 -0
  28. package/dist/ProcessRegistry-Hf12LlR9.mjs +1 -0
  29. package/dist/ResponseBuilder-B2lu4KEl.mjs +1 -0
  30. package/dist/ReverseEvidenceGraph-B931HeoW.mjs +2 -0
  31. package/dist/ScriptManager-fgqiALgj.mjs +7 -0
  32. package/dist/Speedhack-l6s8L2Qw.mjs +1 -0
  33. package/dist/StealthVerifier-Dhbj4B4P.mjs +1 -0
  34. package/dist/StructureAnalyzer-A-WamfYE.mjs +2 -0
  35. package/dist/ToolCatalog-D_IKl1Hu.mjs +1 -0
  36. package/dist/ToolError-DWU_z7gp.mjs +1 -0
  37. package/dist/ToolProbe-xsfALmN3.mjs +1 -0
  38. package/dist/ToolRegistry-B0Zs-phN.mjs +1 -0
  39. package/dist/ToolRouter.policy-CFHoN_Lw.mjs +4 -0
  40. package/dist/TraceRecorder-Dd8jLXpi.mjs +272 -0
  41. package/dist/VersionDetector-DMoUWyNm.mjs +9 -0
  42. package/dist/Win32API-Bhi5xFBe.mjs +1 -0
  43. package/dist/Win32Debug-CQteFL4F.mjs +1 -0
  44. package/dist/WorkflowEngine-CxEp2WXH.mjs +1 -0
  45. package/dist/analysis-BuR-NgX8.mjs +5 -0
  46. package/dist/{antidebug-CqDTB_uk.mjs → antidebug-BOTZH6-0.mjs} +8 -259
  47. package/dist/artifactRetention-NBdncOEW.mjs +1 -0
  48. package/dist/artifacts-B5xQuEa_.mjs +1 -0
  49. package/dist/authorization-schema-B40obG1A.mjs +1 -0
  50. package/dist/betterSqlite3-CGaxz4AX.mjs +1 -0
  51. package/dist/binary-instrument-Cf9qqLlM.mjs +7 -0
  52. package/dist/bind-helpers-BlAOQrFQ.mjs +1 -0
  53. package/dist/boringssl-inspector-BST5vtKx.mjs +2 -0
  54. package/dist/browser-C4Le3xqA.mjs +11 -0
  55. package/dist/capabilities-DbYCv-HF.mjs +1 -0
  56. package/dist/chunk-C_pMuVsO.mjs +1 -0
  57. package/dist/collector-CKO8RPK8.mjs +1 -0
  58. package/dist/concurrency-CcK46d0h.mjs +1 -0
  59. package/dist/constants-Cp6hBrrx.mjs +1 -0
  60. package/dist/coordination-BbijHEHH.mjs +1 -0
  61. package/dist/debugger-CRJq_krh.mjs +1 -0
  62. package/dist/definitions-BGobEDQa.mjs +1 -0
  63. package/dist/definitions-BGwNSkVm.mjs +1 -0
  64. package/dist/definitions-BbxOUiP-.mjs +1 -0
  65. package/dist/definitions-CCP9gphV.mjs +1 -0
  66. package/dist/definitions-CIO9O-Sw.mjs +1 -0
  67. package/dist/definitions-CYFbewnd.mjs +1 -0
  68. package/dist/definitions-CdWEuIkI.mjs +1 -0
  69. package/dist/definitions-CoQFbggH.mjs +1 -0
  70. package/dist/definitions-CuJRsJ6N.mjs +1 -0
  71. package/dist/definitions-DI9YXsJk.mjs +1 -0
  72. package/dist/definitions-DJklW2sS.mjs +1 -0
  73. package/dist/definitions-DZ8uKusP.mjs +1 -0
  74. package/dist/definitions-Dds_zrWx.mjs +1 -0
  75. package/dist/definitions-Dgrg7f3D.mjs +1 -0
  76. package/dist/definitions-DtE0XLrT.mjs +1 -0
  77. package/dist/definitions-LaYTuwQd.mjs +26 -0
  78. package/dist/definitions-NoVp_9Pm.mjs +1 -0
  79. package/dist/definitions-OvGsfxdt.mjs +1 -0
  80. package/dist/definitions-jXPaVy4P.mjs +1 -0
  81. package/dist/encoding-DGcr6Aj_.mjs +2 -0
  82. package/dist/ensure-browser-core-Buls24LQ.mjs +1 -0
  83. package/dist/evidence-graph-bridge-B0yhGPcs.mjs +1 -0
  84. package/dist/factory-Cx_1LorX.mjs +1 -0
  85. package/dist/flat-target-session-CO5g78k3.mjs +1 -0
  86. package/dist/formatAddress-C7j2fDlM.mjs +1 -0
  87. package/dist/graphql-HLf3MS8H.mjs +62 -0
  88. package/dist/handlers-BLMa4X7l.mjs +54 -0
  89. package/dist/handlers-BP12ZsWc.mjs +4 -0
  90. package/dist/handlers-BZoPla6E.mjs +1 -0
  91. package/dist/handlers-BggKiVx9.mjs +2 -0
  92. package/dist/handlers-D3iev8g1.mjs +1 -0
  93. package/dist/handlers-D49r1-1P.mjs +1 -0
  94. package/dist/handlers-DCE45Ww8.mjs +2 -0
  95. package/dist/handlers-DW5AbYs5.mjs +5 -0
  96. package/dist/handlers-De5u62Ga2.mjs +1 -0
  97. package/dist/handlers-DmQzIc44.mjs +31 -0
  98. package/dist/handlers-DnJRGp7t.mjs +302 -0
  99. package/dist/handlers-Dv_runVv.mjs +2 -0
  100. package/dist/handlers-S9Ws0IGy.mjs +2 -0
  101. package/dist/{handlers-Bl8zkwz1.mjs → handlers-pVNpaw4A.mjs} +144 -841
  102. package/dist/handlers.impl-CD2_kOcC.mjs +1 -0
  103. package/dist/hooks-DDKppogd.mjs +600 -0
  104. package/dist/index.mjs +12 -5225
  105. package/dist/logger-sBC6IdRT.mjs +1 -0
  106. package/dist/maintenance-CutEO84j.mjs +1 -0
  107. package/dist/manifest-BFGxlDRh.mjs +123 -0
  108. package/dist/manifest-BPuE6oH2.mjs +1 -0
  109. package/dist/manifest-BXry5N09.mjs +1 -0
  110. package/dist/manifest-BeP_zJGb2.mjs +1 -0
  111. package/dist/manifest-C0g67k6U.mjs +1 -0
  112. package/dist/manifest-C1nZkTkO.mjs +1 -0
  113. package/dist/manifest-C7qV1z7F.mjs +1 -0
  114. package/dist/manifest-CDeUZGUZ.mjs +1 -0
  115. package/dist/manifest-CDiCtaQT.mjs +1 -0
  116. package/dist/manifest-CFn0359q2.mjs +1 -0
  117. package/dist/manifest-CGq4NpqH2.mjs +1 -0
  118. package/dist/manifest-CJMGt7Qy.mjs +1 -0
  119. package/dist/manifest-CRIJq4Hs.mjs +1 -0
  120. package/dist/manifest-C_hEIjSx.mjs +1 -0
  121. package/dist/manifest-CeQmtQOY.mjs +1 -0
  122. package/dist/manifest-Cq0j7GZt.mjs +1 -0
  123. package/dist/manifest-CtPmHAdn.mjs +1 -0
  124. package/dist/manifest-Cx2IVMUY.mjs +1 -0
  125. package/dist/manifest-D16xPXro.mjs +1 -0
  126. package/dist/manifest-D44TaRJU.mjs +1 -0
  127. package/dist/manifest-D610kxZr.mjs +2 -0
  128. package/dist/manifest-DC-SMF6b.mjs +1 -0
  129. package/dist/manifest-DD3rtxvV.mjs +1 -0
  130. package/dist/manifest-DKUorv5M.mjs +1 -0
  131. package/dist/manifest-DMJlcsTR.mjs +1 -0
  132. package/dist/manifest-DWUUWBz0.mjs +1 -0
  133. package/dist/manifest-De-6Wf2R.mjs +1 -0
  134. package/dist/manifest-Dgh0uDW-.mjs +1 -0
  135. package/dist/manifest-Dm0o3i2U.mjs +1 -0
  136. package/dist/manifest-DsVh7Y4U.mjs +1 -0
  137. package/dist/manifest-DtEFSRaq.mjs +1 -0
  138. package/dist/manifest-H-EpAyZQ.mjs +1 -0
  139. package/dist/manifest-ais9Afrw.mjs +1 -0
  140. package/dist/manifest-tmb54wmA.mjs +1 -0
  141. package/dist/manifest-yu2xiQqe.mjs +1 -0
  142. package/dist/manifest-zrbrpKCC.mjs +1 -0
  143. package/dist/matchesWildcardPattern-BGqLSmEs.mjs +1 -0
  144. package/dist/modules-p-PUNv9r.mjs +332 -0
  145. package/dist/mojo-ipc-VGlv3Qyp.mjs +9 -0
  146. package/dist/network-BjZ1Y-GB.mjs +7 -0
  147. package/dist/outputPaths-BonGThuc.mjs +2 -0
  148. package/dist/parse-args-Cuk7-xUt.mjs +1 -0
  149. package/dist/platform-C446Lf97.mjs +93 -0
  150. package/dist/playwright-cdp-fallback-BwVR-_T3.mjs +1 -0
  151. package/dist/process-C9f2A5zk.mjs +962 -0
  152. package/dist/proxy-CvRepxgV.mjs +1 -0
  153. package/dist/registry-DUHIPE-v.mjs +1 -0
  154. package/dist/response-C7rKQst4.mjs +1 -0
  155. package/dist/search-defaults-D2bY-rzH.mjs +1 -0
  156. package/dist/server/plugin-api.mjs +1 -293
  157. package/dist/shared-state-board-Cyg-xh_k.mjs +1 -0
  158. package/dist/sourcemap-D6Q1UuAp.mjs +1 -0
  159. package/dist/ssrf-policy-T96MR3r6.mjs +1 -0
  160. package/dist/streaming-CTX58tbb.mjs +1 -0
  161. package/dist/tool-builder-CI9914Tf.mjs +1 -0
  162. package/dist/transform-Cv9P2vVD.mjs +103 -0
  163. package/dist/types-CuyefmGT.mjs +1 -0
  164. package/dist/types-DtThH00r.mjs +1 -0
  165. package/dist/wasm-DaJa8J0V.mjs +174 -0
  166. package/dist/webcrack-CsLLJIs9.mjs +46 -0
  167. package/dist/workflow-CYIXtrWD.mjs +101 -0
  168. package/package.json +12 -7
  169. package/dist/AntiCheatDetector-BNk-EoBt.mjs +0 -244
  170. package/dist/CacheAdapters-CDe5WPSV.mjs +0 -80
  171. package/dist/CodeInjector-Cq8q01kp.mjs +0 -150
  172. package/dist/ConsoleMonitor-CPVQW1Y-.mjs +0 -2201
  173. package/dist/DarwinAPI-BNPxu0RH.mjs +0 -363
  174. package/dist/DetailedDataManager-BQQcxh64.mjs +0 -217
  175. package/dist/EventBus-DgPmwpeu.mjs +0 -141
  176. package/dist/EvidenceGraphBridge-SFesNera.mjs +0 -153
  177. package/dist/ExtensionManager-CWYgw0YW.mjs +0 -714
  178. package/dist/FingerprintManager-gzWtkKuf.mjs +0 -96
  179. package/dist/HardwareBreakpoint-B9gZCdFP.mjs +0 -239
  180. package/dist/HeapAnalyzer-BLDH0dCv.mjs +0 -284
  181. package/dist/InstrumentationSession-CvPC7Jwy.mjs +0 -244
  182. package/dist/MemoryController-CbVdCIJF.mjs +0 -167
  183. package/dist/MemoryScanSession-BsDZbLYm.mjs +0 -278
  184. package/dist/MemoryScanner-Bcpml6II.mjs +0 -425
  185. package/dist/NativeMemoryManager.impl-dZtA1ZGn.mjs +0 -482
  186. package/dist/NativeMemoryManager.utils-B-FjA2mJ.mjs +0 -165
  187. package/dist/PEAnalyzer-D1lzJ_VG.mjs +0 -385
  188. package/dist/PageController-Bqm2kZ_X.mjs +0 -417
  189. package/dist/PointerChainEngine-BOhyVsjx.mjs +0 -322
  190. package/dist/PrerequisiteError-Dl33Svkz.mjs +0 -20
  191. package/dist/ResponseBuilder-D3iFYx2N.mjs +0 -143
  192. package/dist/ReverseEvidenceGraph-Dlsk94LC.mjs +0 -269
  193. package/dist/ScriptManager-aHHq0X7U.mjs +0 -3000
  194. package/dist/Speedhack-CqdIFlQl.mjs +0 -156
  195. package/dist/StealthVerifier-Bo4T3bz8.mjs +0 -135
  196. package/dist/StructureAnalyzer-DhFaPvRO.mjs +0 -426
  197. package/dist/ToolCatalog-C0JGZoOm.mjs +0 -582
  198. package/dist/ToolError-jh9whhMd.mjs +0 -15
  199. package/dist/ToolProbe-oC7aPrkv.mjs +0 -45
  200. package/dist/ToolRegistry-BjaF4oNz.mjs +0 -131
  201. package/dist/ToolRouter.policy-BWV67ZK-.mjs +0 -304
  202. package/dist/TraceRecorder-DgxyVbdQ.mjs +0 -519
  203. package/dist/VersionDetector-CwVLVdDM.mjs +0 -104
  204. package/dist/Win32API-CePkipZY.mjs +0 -340
  205. package/dist/Win32Debug-BvKs-gxc.mjs +0 -274
  206. package/dist/WorkflowEngine-CuvkZtWu.mjs +0 -598
  207. package/dist/analysis-CL9uACt9.mjs +0 -463
  208. package/dist/artifactRetention-CFEprwPw.mjs +0 -591
  209. package/dist/artifacts-Bk2-_uPq.mjs +0 -59
  210. package/dist/betterSqlite3-0pqusHHH.mjs +0 -74
  211. package/dist/binary-instrument-CXfpx6fT.mjs +0 -979
  212. package/dist/bind-helpers-xFfRF-qm.mjs +0 -22
  213. package/dist/boringssl-inspector-BH2D3VKc.mjs +0 -180
  214. package/dist/browser-BpOr5PEx.mjs +0 -4082
  215. package/dist/chunk-CjcI7cDX.mjs +0 -15
  216. package/dist/concurrency-Bt0yv1kJ.mjs +0 -41
  217. package/dist/constants-B0OANIBL.mjs +0 -519
  218. package/dist/coordination-qUbyF8KU.mjs +0 -259
  219. package/dist/debugger-gnKxRSN0.mjs +0 -1271
  220. package/dist/definitions-6M-eejaT.mjs +0 -53
  221. package/dist/definitions-B18eyf0B.mjs +0 -18
  222. package/dist/definitions-B3QdlrHv.mjs +0 -34
  223. package/dist/definitions-B4rAvHNZ.mjs +0 -63
  224. package/dist/definitions-BB_4jnmy.mjs +0 -37
  225. package/dist/definitions-BMfYXoNC.mjs +0 -43
  226. package/dist/definitions-Beid2EB3.mjs +0 -27
  227. package/dist/definitions-C1UvM5Iy.mjs +0 -126
  228. package/dist/definitions-CXEI7QC72.mjs +0 -216
  229. package/dist/definitions-C_4r7Fo-2.mjs +0 -14
  230. package/dist/definitions-CkFDALoa.mjs +0 -26
  231. package/dist/definitions-Cke7zEb8.mjs +0 -94
  232. package/dist/definitions-ClJLzsJQ.mjs +0 -25
  233. package/dist/definitions-Cq-zroAU.mjs +0 -28
  234. package/dist/definitions-Cy3Sl6gV.mjs +0 -34
  235. package/dist/definitions-D3VsGcvz.mjs +0 -47
  236. package/dist/definitions-DVGfrn7y.mjs +0 -96
  237. package/dist/definitions-LKpC3-nL.mjs +0 -9
  238. package/dist/definitions-bAhHQJq9.mjs +0 -359
  239. package/dist/encoding-Bvz5jLRv.mjs +0 -1065
  240. package/dist/evidence-graph-bridge-C_fv9PuC.mjs +0 -135
  241. package/dist/factory-DxlGh9Xf.mjs +0 -575
  242. package/dist/formatAddress-DVkj9kpI.mjs +0 -17
  243. package/dist/graphql-DYWzJ29s.mjs +0 -1026
  244. package/dist/handlers-9sAbfIg-.mjs +0 -2552
  245. package/dist/handlers-C67ktuRN.mjs +0 -710
  246. package/dist/handlers-C87g8oCe.mjs +0 -276
  247. package/dist/handlers-CTsDAO6p.mjs +0 -681
  248. package/dist/handlers-Cgyg6c0U.mjs +0 -645
  249. package/dist/handlers-D6j6yka7.mjs +0 -2124
  250. package/dist/handlers-DdFzXLvF.mjs +0 -446
  251. package/dist/handlers-DeLOCd5m.mjs +0 -799
  252. package/dist/handlers-DlCJN4Td.mjs +0 -757
  253. package/dist/handlers-DxGIq15_2.mjs +0 -917
  254. package/dist/handlers-U6L4xhuF.mjs +0 -585
  255. package/dist/handlers-tB9Mp9ZK.mjs +0 -84
  256. package/dist/handlers-tiy7EIBp.mjs +0 -572
  257. package/dist/handlers.impl-DS0d9fUw.mjs +0 -761
  258. package/dist/hooks-CzCWByww.mjs +0 -898
  259. package/dist/logger-Dh_xb7_2.mjs +0 -93
  260. package/dist/maintenance-P7ePRXQC.mjs +0 -830
  261. package/dist/manifest-2ToTpjv8.mjs +0 -106
  262. package/dist/manifest-3g71z6Bg.mjs +0 -79
  263. package/dist/manifest-82baTv4U.mjs +0 -45
  264. package/dist/manifest-B3QVVeBS.mjs +0 -82
  265. package/dist/manifest-BB2J8IMJ.mjs +0 -149
  266. package/dist/manifest-BKbgbSiY.mjs +0 -60
  267. package/dist/manifest-Bcf-TJzH.mjs +0 -848
  268. package/dist/manifest-BmtZzQiQ2.mjs +0 -45
  269. package/dist/manifest-Bnd7kqEY.mjs +0 -55
  270. package/dist/manifest-BqQX6OQC2.mjs +0 -65
  271. package/dist/manifest-BqrQ4Tpj.mjs +0 -81
  272. package/dist/manifest-Br4RPFt5.mjs +0 -370
  273. package/dist/manifest-C5qDjysN.mjs +0 -107
  274. package/dist/manifest-C9RT5nk32.mjs +0 -34
  275. package/dist/manifest-CAhOuvSl.mjs +0 -204
  276. package/dist/manifest-CBYWCUBJ.mjs +0 -51
  277. package/dist/manifest-CFADCRa1.mjs +0 -37
  278. package/dist/manifest-CQVhavRF.mjs +0 -114
  279. package/dist/manifest-CT7zZBV1.mjs +0 -48
  280. package/dist/manifest-CV12bcrF.mjs +0 -121
  281. package/dist/manifest-CXsRWjjI.mjs +0 -224
  282. package/dist/manifest-CZLUCfG02.mjs +0 -95
  283. package/dist/manifest-D6phHKFd.mjs +0 -131
  284. package/dist/manifest-DCyjf4n2.mjs +0 -294
  285. package/dist/manifest-DHsnKgP6.mjs +0 -60
  286. package/dist/manifest-Df_dliIe.mjs +0 -55
  287. package/dist/manifest-Dh8WBmEW.mjs +0 -129
  288. package/dist/manifest-DhKRAT8_.mjs +0 -92
  289. package/dist/manifest-DlpTj4ic2.mjs +0 -193
  290. package/dist/manifest-DrbmZcFl2.mjs +0 -253
  291. package/dist/manifest-DuwHjUa5.mjs +0 -70
  292. package/dist/manifest-DzwvxPJX.mjs +0 -38
  293. package/dist/manifest-NXctwWQq.mjs +0 -68
  294. package/dist/manifest-Sc_0JQ13.mjs +0 -418
  295. package/dist/manifest-gZ4s_UtG.mjs +0 -96
  296. package/dist/manifest-qSleDqdO.mjs +0 -1023
  297. package/dist/modules-C184v-S9.mjs +0 -11365
  298. package/dist/mojo-ipc-B_H61Afw.mjs +0 -525
  299. package/dist/network-671Cw6hV.mjs +0 -3346
  300. package/dist/outputPaths-B1uGmrWZ.mjs +0 -1145
  301. package/dist/parse-args-BlRjqlkL.mjs +0 -39
  302. package/dist/platform-WmNn8Sxb.mjs +0 -2070
  303. package/dist/process-QcbIy5Zq.mjs +0 -1401
  304. package/dist/proxy-DqNs0bAd.mjs +0 -170
  305. package/dist/registry-D-6e18lB.mjs +0 -34
  306. package/dist/response-BQVP-xUn.mjs +0 -28
  307. package/dist/shared-state-board-DV-dpHFJ.mjs +0 -586
  308. package/dist/sourcemap-Dq8ez8vS.mjs +0 -650
  309. package/dist/ssrf-policy-ZaUfvhq7.mjs +0 -166
  310. package/dist/streaming-BUQ0VJsg.mjs +0 -725
  311. package/dist/tool-builder-DCbIC5Eo.mjs +0 -186
  312. package/dist/transform-CiYJfNX0.mjs +0 -1007
  313. package/dist/types-Bx92KJfT.mjs +0 -4
  314. package/dist/types-CPhOReNX.mjs +0 -37
  315. package/dist/wasm-DQTnHDs4.mjs +0 -531
  316. package/dist/workflow-f3xJOcjx.mjs +0 -725
@@ -1,519 +0,0 @@
1
- import { n as __require } from "./chunk-CjcI7cDX.mjs";
2
- import { i as resolveArtifactPath } from "./artifacts-Bk2-_uPq.mjs";
3
- import { t as formatBetterSqlite3Error } from "./betterSqlite3-0pqusHHH.mjs";
4
- import { randomUUID } from "node:crypto";
5
- //#region src/modules/trace/TraceDB.ts
6
- let Database;
7
- try {
8
- Database = __require("better-sqlite3");
9
- } catch {}
10
- /** Write-modify SQL keywords rejected by the safety filter. */
11
- const WRITE_SQL_PATTERN = /\b(INSERT|UPDATE|DELETE|DROP|ALTER|CREATE|ATTACH|DETACH|REPLACE|PRAGMA)\b/i;
12
- var TraceDB = class {
13
- db;
14
- batchSize;
15
- eventBuffer = [];
16
- memoryBuffer = [];
17
- closed = false;
18
- insertEventStmt;
19
- insertDeltaStmt;
20
- insertSnapshotStmt;
21
- upsertMetadataStmt;
22
- constructor(options) {
23
- this.options = options;
24
- if (!Database) throw new Error(formatBetterSqlite3Error(/* @__PURE__ */ new Error("Cannot find package 'better-sqlite3'")));
25
- try {
26
- this.db = new Database(options.dbPath);
27
- } catch (error) {
28
- throw new Error(formatBetterSqlite3Error(error), { cause: error });
29
- }
30
- this.batchSize = options.batchSize ?? 200;
31
- this.db.pragma("journal_mode = WAL");
32
- this.db.pragma("synchronous = NORMAL");
33
- this.createSchema();
34
- this.prepareStatements();
35
- }
36
- /** Database file path. */
37
- get dbPath() {
38
- return this.options.dbPath;
39
- }
40
- createSchema() {
41
- this.db.exec(`
42
- CREATE TABLE IF NOT EXISTS events (
43
- id INTEGER PRIMARY KEY AUTOINCREMENT,
44
- timestamp REAL NOT NULL,
45
- category TEXT NOT NULL,
46
- event_type TEXT NOT NULL,
47
- data TEXT NOT NULL DEFAULT '{}',
48
- script_id TEXT,
49
- line_number INTEGER
50
- );
51
- CREATE INDEX IF NOT EXISTS idx_events_timestamp ON events(timestamp);
52
- CREATE INDEX IF NOT EXISTS idx_events_category_type ON events(category, event_type);
53
- CREATE INDEX IF NOT EXISTS idx_events_script_id ON events(script_id);
54
-
55
- CREATE TABLE IF NOT EXISTS memory_deltas (
56
- id INTEGER PRIMARY KEY AUTOINCREMENT,
57
- timestamp REAL NOT NULL,
58
- address TEXT NOT NULL,
59
- old_value TEXT NOT NULL,
60
- new_value TEXT NOT NULL,
61
- size INTEGER NOT NULL,
62
- value_type TEXT NOT NULL
63
- );
64
- CREATE INDEX IF NOT EXISTS idx_memory_timestamp ON memory_deltas(timestamp);
65
- CREATE INDEX IF NOT EXISTS idx_memory_address ON memory_deltas(address);
66
-
67
- CREATE TABLE IF NOT EXISTS heap_snapshots (
68
- id INTEGER PRIMARY KEY AUTOINCREMENT,
69
- timestamp REAL NOT NULL,
70
- snapshot_data BLOB,
71
- summary TEXT NOT NULL DEFAULT '{}'
72
- );
73
-
74
- CREATE TABLE IF NOT EXISTS metadata (
75
- key TEXT PRIMARY KEY,
76
- value TEXT NOT NULL
77
- );
78
- `);
79
- }
80
- prepareStatements() {
81
- this.insertEventStmt = this.db.prepare(`
82
- INSERT INTO events (timestamp, category, event_type, data, script_id, line_number)
83
- VALUES (?, ?, ?, ?, ?, ?)
84
- `);
85
- this.insertDeltaStmt = this.db.prepare(`
86
- INSERT INTO memory_deltas (timestamp, address, old_value, new_value, size, value_type)
87
- VALUES (?, ?, ?, ?, ?, ?)
88
- `);
89
- this.insertSnapshotStmt = this.db.prepare(`
90
- INSERT INTO heap_snapshots (timestamp, snapshot_data, summary)
91
- VALUES (?, ?, ?)
92
- `);
93
- this.upsertMetadataStmt = this.db.prepare(`
94
- INSERT INTO metadata (key, value) VALUES (?, ?)
95
- ON CONFLICT(key) DO UPDATE SET value = excluded.value
96
- `);
97
- }
98
- /** Buffer an event for batched insertion. */
99
- insertEvent(event) {
100
- this.ensureOpen();
101
- this.eventBuffer.push(event);
102
- if (this.eventBuffer.length >= this.batchSize) this.flush();
103
- }
104
- /** Buffer a memory delta for batched insertion. */
105
- insertMemoryDelta(delta) {
106
- this.ensureOpen();
107
- this.memoryBuffer.push(delta);
108
- if (this.memoryBuffer.length >= this.batchSize) this.flush();
109
- }
110
- /** Insert a heap snapshot immediately (infrequent, large). */
111
- insertHeapSnapshot(snapshot) {
112
- this.ensureOpen();
113
- this.insertSnapshotStmt.run(snapshot.timestamp, snapshot.snapshotData, snapshot.summary);
114
- }
115
- /** Set or update a metadata key-value pair. */
116
- setMetadata(key, value) {
117
- this.ensureOpen();
118
- this.upsertMetadataStmt.run(key, value);
119
- }
120
- /** Flush all buffered events and memory deltas to disk in a single transaction. */
121
- flush() {
122
- if (this.closed) return;
123
- this.db.transaction(() => {
124
- for (const e of this.eventBuffer) this.insertEventStmt.run(e.timestamp, e.category, e.eventType, e.data, e.scriptId, e.lineNumber);
125
- for (const d of this.memoryBuffer) this.insertDeltaStmt.run(d.timestamp, d.address, d.oldValue, d.newValue, d.size, d.valueType);
126
- })();
127
- this.eventBuffer = [];
128
- this.memoryBuffer = [];
129
- }
130
- /**
131
- * Execute a read-only SQL query against the trace database.
132
- * Write statements are rejected for safety.
133
- */
134
- query(sql) {
135
- this.ensureOpen();
136
- if (WRITE_SQL_PATTERN.test(sql)) throw new Error(`Write operations are not allowed in trace queries. Rejected SQL: ${sql.slice(0, 100)}`);
137
- const stmt = this.db.prepare(sql);
138
- const rows = stmt.all();
139
- if (rows.length === 0) return {
140
- columns: stmt.columns().map((c) => c.name),
141
- rows: [],
142
- rowCount: 0
143
- };
144
- const columns = Object.keys(rows[0]);
145
- return {
146
- columns,
147
- rows: rows.map((row) => columns.map((col) => row[col])),
148
- rowCount: rows.length
149
- };
150
- }
151
- /** Get events within a time range. */
152
- getEventsByTimeRange(start, end) {
153
- this.ensureOpen();
154
- this.flush();
155
- return this.db.prepare(`
156
- SELECT id, timestamp, category, event_type, data, script_id, line_number
157
- FROM events
158
- WHERE timestamp >= ? AND timestamp <= ?
159
- ORDER BY timestamp ASC
160
- `).all(start, end).map((row) => ({
161
- id: row["id"],
162
- timestamp: row["timestamp"],
163
- category: row["category"],
164
- eventType: row["event_type"],
165
- data: row["data"],
166
- scriptId: row["script_id"] ?? null,
167
- lineNumber: row["line_number"] ?? null
168
- }));
169
- }
170
- /** Get memory deltas for a specific address. */
171
- getMemoryDeltasByAddress(address) {
172
- this.ensureOpen();
173
- this.flush();
174
- return this.db.prepare(`
175
- SELECT id, timestamp, address, old_value, new_value, size, value_type
176
- FROM memory_deltas
177
- WHERE address = ?
178
- ORDER BY timestamp ASC
179
- `).all(address).map((row) => ({
180
- id: row["id"],
181
- timestamp: row["timestamp"],
182
- address: row["address"],
183
- oldValue: row["old_value"],
184
- newValue: row["new_value"],
185
- size: row["size"],
186
- valueType: row["value_type"]
187
- }));
188
- }
189
- /** Get all heap snapshots ordered by timestamp. */
190
- getHeapSnapshots() {
191
- this.ensureOpen();
192
- return this.db.prepare(`
193
- SELECT id, timestamp, snapshot_data, summary
194
- FROM heap_snapshots
195
- ORDER BY timestamp ASC
196
- `).all().map((row) => ({
197
- id: row["id"],
198
- timestamp: row["timestamp"],
199
- snapshotData: row["snapshot_data"],
200
- summary: row["summary"]
201
- }));
202
- }
203
- /** Get all metadata as a key-value record. */
204
- getMetadata() {
205
- this.ensureOpen();
206
- const rows = this.db.prepare("SELECT key, value FROM metadata").all();
207
- const result = {};
208
- for (const row of rows) result[row.key] = row.value;
209
- return result;
210
- }
211
- /** Flush buffers and close the database connection. */
212
- close() {
213
- if (this.closed) return;
214
- this.flush();
215
- this.db.close();
216
- this.closed = true;
217
- }
218
- /** Check if the database is closed. */
219
- get isClosed() {
220
- return this.closed;
221
- }
222
- ensureOpen() {
223
- if (this.closed) throw new Error("TraceDB is closed");
224
- }
225
- };
226
- //#endregion
227
- //#region src/modules/trace/TraceRecorder.ts
228
- /**
229
- * TraceRecorder — Event capture engine for time-travel debugging.
230
- *
231
- * Subscribes to EventBus events and CDP session events, capturing them
232
- * into a TraceDB instance. Handles recording lifecycle (start/stop),
233
- * selective CDP domain filtering, and differential memory tracing.
234
- */
235
- /**
236
- * Known CDP events to subscribe to per domain.
237
- * CDP sessions don't support wildcards, so we explicitly list relevant events.
238
- */
239
- const CDP_EVENTS_BY_DOMAIN = {
240
- Debugger: [
241
- "Debugger.paused",
242
- "Debugger.resumed",
243
- "Debugger.scriptParsed"
244
- ],
245
- Runtime: ["Runtime.consoleAPICalled", "Runtime.exceptionThrown"],
246
- Network: [
247
- "Network.requestWillBeSent",
248
- "Network.responseReceived",
249
- "Network.loadingFinished"
250
- ],
251
- Page: ["Page.navigatedWithinDocument", "Page.loadEventFired"]
252
- };
253
- const DEFAULT_CDP_DOMAINS = [
254
- "Debugger",
255
- "Runtime",
256
- "Network",
257
- "Page"
258
- ];
259
- var TraceRecorder = class {
260
- db = null;
261
- state = "idle";
262
- session = null;
263
- eventBusUnsub = null;
264
- cdpListeners = /* @__PURE__ */ new Map();
265
- cdpSession = null;
266
- eventCount = 0;
267
- memoryDeltaCount = 0;
268
- heapSnapshotCount = 0;
269
- /**
270
- * Start recording events into a new trace database.
271
- *
272
- * @param eventBus The server EventBus to subscribe to
273
- * @param cdpSession Optional CDP session for browser event recording
274
- * @param options Recording configuration
275
- * @returns The recording session details
276
- */
277
- async start(eventBus, cdpSession, options) {
278
- if (this.state === "recording") throw new Error("Recording already in progress");
279
- const sessionId = randomUUID();
280
- const { absolutePath } = await resolveArtifactPath({
281
- category: "traces",
282
- toolName: "trace_recorder",
283
- target: sessionId.slice(0, 8),
284
- ext: "db"
285
- });
286
- this.db = new TraceDB({ dbPath: absolutePath });
287
- this.eventCount = 0;
288
- this.memoryDeltaCount = 0;
289
- this.heapSnapshotCount = 0;
290
- const startedAt = Date.now();
291
- this.db.setMetadata("sessionId", sessionId);
292
- this.db.setMetadata("platform", process.platform);
293
- this.db.setMetadata("startedAt", String(startedAt));
294
- this.db.setMetadata("nodeVersion", process.version);
295
- this.eventBusUnsub = eventBus.onAny((wrapped) => {
296
- if (this.state !== "recording" || !this.db) return;
297
- try {
298
- this.db.insertEvent({
299
- timestamp: Date.now(),
300
- category: this.mapEventCategory(String(wrapped.event)),
301
- eventType: String(wrapped.event),
302
- data: JSON.stringify(wrapped.payload ?? {}),
303
- scriptId: null,
304
- lineNumber: null
305
- });
306
- this.eventCount++;
307
- } catch {}
308
- });
309
- this.cdpSession = cdpSession;
310
- if (cdpSession) {
311
- const domains = options?.cdpDomains ?? DEFAULT_CDP_DOMAINS;
312
- for (const domain of domains) {
313
- const events = CDP_EVENTS_BY_DOMAIN[domain];
314
- if (!events) continue;
315
- for (const eventName of events) {
316
- const handler = (params) => {
317
- if (this.state !== "recording" || !this.db) return;
318
- try {
319
- let scriptId = null;
320
- let lineNumber = null;
321
- if (typeof params === "object" && params !== null) {
322
- const p = params;
323
- if ("scriptId" in p) scriptId = String(p["scriptId"]);
324
- if ("lineNumber" in p) lineNumber = Number(p["lineNumber"]) || null;
325
- if (eventName === "Debugger.paused" && Array.isArray(p["callFrames"])) {
326
- const frame = p["callFrames"][0];
327
- if (frame) {
328
- const loc = frame["location"];
329
- if (loc) {
330
- scriptId = String(loc["scriptId"] ?? scriptId);
331
- lineNumber = Number(loc["lineNumber"] ?? lineNumber) || null;
332
- }
333
- }
334
- }
335
- }
336
- this.db.insertEvent({
337
- timestamp: Date.now(),
338
- category: domain.toLowerCase(),
339
- eventType: eventName,
340
- data: JSON.stringify(params ?? {}),
341
- scriptId,
342
- lineNumber
343
- });
344
- this.eventCount++;
345
- } catch {}
346
- };
347
- cdpSession.on(eventName, handler);
348
- this.cdpListeners.set(eventName, handler);
349
- }
350
- }
351
- }
352
- this.session = {
353
- sessionId,
354
- dbPath: absolutePath,
355
- startedAt,
356
- eventCount: 0,
357
- memoryDeltaCount: 0,
358
- heapSnapshotCount: 0
359
- };
360
- this.state = "recording";
361
- return { ...this.session };
362
- }
363
- /**
364
- * Record a memory write delta.
365
- * Silently ignored if not currently recording.
366
- */
367
- recordMemoryDelta(delta) {
368
- if (this.state !== "recording" || !this.db) return;
369
- try {
370
- this.db.insertMemoryDelta(delta);
371
- this.memoryDeltaCount++;
372
- } catch {}
373
- }
374
- /**
375
- * Capture a heap snapshot via CDP HeapProfiler.
376
- * Requires an active CDP session and recording in progress.
377
- */
378
- async captureHeapSnapshot(cdpSession) {
379
- if (this.state !== "recording" || !this.db) throw new Error("Cannot capture heap snapshot: not recording");
380
- const chunks = [];
381
- const chunkHandler = (params) => {
382
- if (typeof params === "object" && params !== null) {
383
- const chunk = params["chunk"];
384
- if (typeof chunk === "string") chunks.push(chunk);
385
- }
386
- };
387
- try {
388
- await cdpSession.send("HeapProfiler.enable");
389
- cdpSession.on("HeapProfiler.addHeapSnapshotChunk", chunkHandler);
390
- await cdpSession.send("HeapProfiler.takeHeapSnapshot", { reportProgress: false });
391
- cdpSession.off("HeapProfiler.addHeapSnapshotChunk", chunkHandler);
392
- const snapshotStr = chunks.join("");
393
- const snapshotBuffer = Buffer.from(snapshotStr, "utf-8");
394
- const summary = this.extractHeapSummary(snapshotStr);
395
- this.db.insertHeapSnapshot({
396
- timestamp: Date.now(),
397
- snapshotData: snapshotBuffer,
398
- summary: JSON.stringify(summary)
399
- });
400
- this.heapSnapshotCount++;
401
- } finally {
402
- await cdpSession.send("HeapProfiler.disable").catch(() => {});
403
- }
404
- }
405
- /**
406
- * Stop recording and finalize the trace database.
407
- * @returns Final session summary with event counts
408
- */
409
- stop() {
410
- if (this.state !== "recording") throw new Error("GRACEFUL: Cannot stop: not currently recording");
411
- if (this.eventBusUnsub) {
412
- this.eventBusUnsub();
413
- this.eventBusUnsub = null;
414
- }
415
- if (this.cdpSession) {
416
- for (const [event, handler] of this.cdpListeners) this.cdpSession.off(event, handler);
417
- this.cdpListeners.clear();
418
- this.cdpSession = null;
419
- }
420
- if (this.db) {
421
- const stoppedAt = Date.now();
422
- this.db.setMetadata("stoppedAt", String(stoppedAt));
423
- this.db.setMetadata("eventCount", String(this.eventCount));
424
- this.db.setMetadata("memoryDeltaCount", String(this.memoryDeltaCount));
425
- this.db.setMetadata("heapSnapshotCount", String(this.heapSnapshotCount));
426
- this.db.close();
427
- if (this.session) {
428
- this.session.stoppedAt = stoppedAt;
429
- this.session.eventCount = this.eventCount;
430
- this.session.memoryDeltaCount = this.memoryDeltaCount;
431
- this.session.heapSnapshotCount = this.heapSnapshotCount;
432
- }
433
- }
434
- this.state = "stopped";
435
- const finalSession = this.session ? { ...this.session } : this.createEmptySession();
436
- this.db = null;
437
- return finalSession;
438
- }
439
- /** Get the current recording state. */
440
- getState() {
441
- return this.state;
442
- }
443
- /** Get the current session details (null if not recording). */
444
- getSession() {
445
- return this.session ? { ...this.session } : null;
446
- }
447
- /** Get the active TraceDB instance (null if not recording). */
448
- getDB() {
449
- return this.db;
450
- }
451
- /**
452
- * Map an EventBus event name to a trace category.
453
- * E.g., 'tool:called' → 'tool', 'debugger:breakpoint_hit' → 'debugger'
454
- */
455
- mapEventCategory(event) {
456
- const colonIdx = event.indexOf(":");
457
- return colonIdx > 0 ? event.substring(0, colonIdx) : "other";
458
- }
459
- /**
460
- * Extract a lightweight summary from a V8 heap snapshot.
461
- * Only parses the minimal structure needed for diffing.
462
- */
463
- extractHeapSummary(snapshotStr) {
464
- try {
465
- const snapshot = JSON.parse(snapshotStr);
466
- const snapshotInfo = snapshot["snapshot"];
467
- if (!snapshotInfo) return {
468
- totalSize: 0,
469
- nodeCount: 0,
470
- objectCounts: {}
471
- };
472
- const meta = snapshotInfo["meta"];
473
- const nodeCount = snapshotInfo["node_count"] ?? 0;
474
- const nodeFields = meta?.["node_fields"];
475
- const nodeTypes = meta?.["node_types"];
476
- const nodes = snapshot["nodes"];
477
- const objectCounts = {};
478
- let totalSize = 0;
479
- if (nodeFields && nodes && nodeTypes) {
480
- const fieldCount = nodeFields.length;
481
- const typeIndex = nodeFields.indexOf("type");
482
- const nameIndex = nodeFields.indexOf("name");
483
- const selfSizeIndex = nodeFields.indexOf("self_size");
484
- const strings = snapshot["strings"] ?? [];
485
- for (let i = 0; i < nodes.length; i += fieldCount) {
486
- const selfSize = selfSizeIndex >= 0 ? nodes[i + selfSizeIndex] ?? 0 : 0;
487
- totalSize += selfSize;
488
- if (nameIndex >= 0) {
489
- const name = strings[nodes[i + nameIndex] ?? 0] ?? `type_${nodes[i + (typeIndex >= 0 ? typeIndex : 0)]}`;
490
- if (name) objectCounts[name] = (objectCounts[name] ?? 0) + 1;
491
- }
492
- }
493
- }
494
- return {
495
- totalSize,
496
- nodeCount,
497
- objectCounts
498
- };
499
- } catch {
500
- return {
501
- totalSize: 0,
502
- nodeCount: 0,
503
- objectCounts: {}
504
- };
505
- }
506
- }
507
- createEmptySession() {
508
- return {
509
- sessionId: "",
510
- dbPath: "",
511
- startedAt: 0,
512
- eventCount: 0,
513
- memoryDeltaCount: 0,
514
- heapSnapshotCount: 0
515
- };
516
- }
517
- };
518
- //#endregion
519
- export { TraceRecorder, TraceDB as t };
@@ -1,104 +0,0 @@
1
- import { t as __exportAll } from "./chunk-CjcI7cDX.mjs";
2
- //#region src/modules/v8-inspector/VersionDetector.ts
3
- var VersionDetector_exports = /* @__PURE__ */ __exportAll({ VersionDetector: () => VersionDetector });
4
- function isRecord(value) {
5
- return typeof value === "object" && value !== null;
6
- }
7
- function isCDPPageLike(value) {
8
- return isRecord(value) && typeof value["createCDPSession"] === "function";
9
- }
10
- function readString(record, key) {
11
- const value = record[key];
12
- return typeof value === "string" ? value : null;
13
- }
14
- function readBooleanResult(value) {
15
- if (typeof value === "boolean") return value;
16
- if (isRecord(value)) {
17
- const nested = value["value"];
18
- return typeof nested === "boolean" ? nested : false;
19
- }
20
- return false;
21
- }
22
- var VersionDetector = class {
23
- constructor(getPage) {
24
- this.getPage = getPage;
25
- }
26
- async detectV8Version() {
27
- const browserVersion = await this.detectBrowserVersion();
28
- if (browserVersion) return browserVersion;
29
- if (typeof process.versions.v8 === "string" && process.versions.v8.length > 0) return this.parseV8Version(process.versions.v8);
30
- return null;
31
- }
32
- parseV8Version(versionString) {
33
- const match = /(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)(?:\.(?<commit>[A-Za-z0-9._-]+))?/u.exec(versionString.trim());
34
- if (!match?.groups) return {
35
- major: 0,
36
- minor: 0,
37
- patch: 0,
38
- commit: ""
39
- };
40
- const major = Number(match.groups["major"] ?? 0);
41
- const minor = Number(match.groups["minor"] ?? 0);
42
- const patch = Number(match.groups["patch"] ?? 0);
43
- return {
44
- major: Number.isFinite(major) ? major : 0,
45
- minor: Number.isFinite(minor) ? minor : 0,
46
- patch: Number.isFinite(patch) ? patch : 0,
47
- commit: match.groups["commit"] ?? ""
48
- };
49
- }
50
- async supportsNativesSyntax() {
51
- if (process.execArgv.includes("--allow-natives-syntax")) return true;
52
- const session = await this.createSession();
53
- if (!session) return false;
54
- try {
55
- const response = await session.send("Runtime.evaluate", {
56
- expression: `
57
- (() => {
58
- try {
59
- return Boolean(new Function("return %HaveSameMap({}, {})")());
60
- } catch (error) {
61
- return false;
62
- }
63
- })()
64
- `,
65
- returnByValue: true,
66
- awaitPromise: false
67
- });
68
- if (!isRecord(response)) return false;
69
- return readBooleanResult(response["result"]);
70
- } catch {
71
- return false;
72
- } finally {
73
- await session.detach().catch(() => void 0);
74
- }
75
- }
76
- async detectBrowserVersion() {
77
- const session = await this.createSession();
78
- if (!session) return null;
79
- try {
80
- const response = await session.send("Browser.getVersion");
81
- if (!isRecord(response)) return null;
82
- const jsVersion = readString(response, "jsVersion");
83
- if (jsVersion) return this.parseV8Version(jsVersion);
84
- const product = readString(response, "product");
85
- return product ? this.parseV8Version(product) : null;
86
- } catch {
87
- return null;
88
- } finally {
89
- await session.detach().catch(() => void 0);
90
- }
91
- }
92
- async createSession() {
93
- if (!this.getPage) return null;
94
- try {
95
- const page = await this.getPage();
96
- if (!isCDPPageLike(page)) return null;
97
- return await page.createCDPSession();
98
- } catch {
99
- return null;
100
- }
101
- }
102
- };
103
- //#endregion
104
- export { VersionDetector_exports as n, VersionDetector as t };