@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,799 +0,0 @@
1
- import { kr as WEBHOOK_PROCESS_TIMEOUT_MS } from "./constants-CDZLOoVv.mjs";
2
- import { n as asJsonResponse } from "./response-CWhh2aLo.mjs";
3
- import { i as getProjectRoot, r as getExtensionRegistryDir } from "./outputPaths-um7lCRY3.mjs";
4
- import { a as argString, i as argObject, s as argStringRequired } from "./parse-args-B4cY5Vx5.mjs";
5
- import http from "node:http";
6
- import { existsSync, mkdirSync, readFileSync, readdirSync } from "node:fs";
7
- import path from "node:path";
8
- import { fileURLToPath, pathToFileURL } from "node:url";
9
- import { mkdir, writeFile } from "node:fs/promises";
10
- import { EventEmitter } from "node:events";
11
- //#region src/modules/extension-registry/PluginRegistry.ts
12
- function isRecord$2(value) {
13
- return value !== null && typeof value === "object" && !Array.isArray(value);
14
- }
15
- function sanitizeId(value) {
16
- const normalized = value.trim().toLowerCase().replace(/\//g, "-").replace(/(?!^@)[^a-z0-9@_-]+/g, "-");
17
- return normalized.length > 0 ? normalized : `plugin-${Date.now()}`;
18
- }
19
- function toStoredPluginManifest(value) {
20
- if (!isRecord$2(value)) return null;
21
- const { id, name, version, entry, permissions, status } = value;
22
- if (typeof id !== "string" || typeof name !== "string" || typeof version !== "string" || typeof entry !== "string" || status !== "loaded" && status !== "unloaded") return null;
23
- return {
24
- id,
25
- name,
26
- version,
27
- entry,
28
- permissions: Array.isArray(permissions) ? permissions.filter((permission) => typeof permission === "string") : [],
29
- status
30
- };
31
- }
32
- var PluginRegistry = class {
33
- rootDir;
34
- legacyPluginRoots;
35
- useLegacyScanApi;
36
- registryFile;
37
- moduleCacheDir;
38
- installedPlugins = /* @__PURE__ */ new Map();
39
- loadedPlugins = /* @__PURE__ */ new Map();
40
- constructor(rootDirOrContext = getExtensionRegistryDir(), pluginRoots = []) {
41
- const resolvedRootDir = typeof rootDirOrContext === "string" ? rootDirOrContext : getExtensionRegistryDir();
42
- this.useLegacyScanApi = typeof rootDirOrContext !== "string";
43
- this.rootDir = resolvedRootDir;
44
- this.registryFile = path.join(resolvedRootDir, "plugins.json");
45
- this.moduleCacheDir = path.join(resolvedRootDir, "modules");
46
- this.legacyPluginRoots = pluginRoots.length > 0 ? pluginRoots : process.env["JSHOOKMCP_PLUGIN_ROOT"] ? [process.env["JSHOOKMCP_PLUGIN_ROOT"]] : [];
47
- if (this.useLegacyScanApi) return;
48
- this.initializeFromDisk();
49
- }
50
- async register(plugin) {
51
- const pluginId = sanitizeId(plugin.id || plugin.name);
52
- const manifest = {
53
- id: pluginId,
54
- name: plugin.name,
55
- version: plugin.version,
56
- entry: plugin.entry,
57
- permissions: plugin.permissions ? [...plugin.permissions] : [],
58
- status: this.loadedPlugins.has(pluginId) ? "loaded" : "unloaded"
59
- };
60
- this.installedPlugins.set(pluginId, manifest);
61
- await this.persist();
62
- return pluginId;
63
- }
64
- async unregister(pluginId) {
65
- await this.unloadPlugin(pluginId);
66
- this.installedPlugins.delete(pluginId);
67
- await this.persist();
68
- }
69
- listInstalled() {
70
- return [...this.installedPlugins.values()].map((plugin) => ({
71
- id: plugin.id,
72
- name: plugin.name,
73
- version: plugin.version,
74
- status: plugin.status,
75
- permissions: [...plugin.permissions]
76
- })).toSorted((left, right) => left.name.localeCompare(right.name));
77
- }
78
- async loadPlugin(pluginId) {
79
- const manifest = this.installedPlugins.get(pluginId);
80
- if (!manifest) throw new Error(`Plugin not found: ${pluginId}`);
81
- const existing = this.loadedPlugins.get(pluginId);
82
- if (existing) return {
83
- manifest: this.toPublicManifest(existing.manifest),
84
- exports: existing.exports
85
- };
86
- const importUrl = pathToFileURL(await this.resolveEntryPath(manifest));
87
- importUrl.searchParams.set("ts", String(Date.now()));
88
- const moduleExports = await import(importUrl.href);
89
- const exportsRecord = isRecord$2(moduleExports) ? moduleExports : {};
90
- manifest.status = "loaded";
91
- this.loadedPlugins.set(pluginId, {
92
- manifest,
93
- exports: exportsRecord
94
- });
95
- await this.persist();
96
- return {
97
- manifest: this.toPublicManifest(manifest),
98
- exports: exportsRecord
99
- };
100
- }
101
- async unloadPlugin(pluginId) {
102
- const manifest = this.installedPlugins.get(pluginId);
103
- if (!manifest) return;
104
- this.loadedPlugins.delete(pluginId);
105
- manifest.status = "unloaded";
106
- await this.persist();
107
- }
108
- initializeFromDisk() {
109
- if (!existsSync(this.rootDir)) mkdirSync(this.rootDir, { recursive: true });
110
- if (!existsSync(this.moduleCacheDir)) mkdirSync(this.moduleCacheDir, { recursive: true });
111
- if (!existsSync(this.registryFile)) return;
112
- const content = readFileSync(this.registryFile, "utf8");
113
- if (!content.trim()) return;
114
- const parsed = JSON.parse(content);
115
- if (!Array.isArray(parsed)) return;
116
- for (const item of parsed) {
117
- const manifest = toStoredPluginManifest(item);
118
- if (manifest) this.installedPlugins.set(manifest.id, manifest);
119
- }
120
- }
121
- async persist() {
122
- await mkdir(this.rootDir, { recursive: true });
123
- await mkdir(this.moduleCacheDir, { recursive: true });
124
- await writeFile(this.registryFile, JSON.stringify([...this.installedPlugins.values()], null, 2), "utf8");
125
- }
126
- async resolveEntryPath(manifest) {
127
- if (manifest.entry.startsWith("http://") || manifest.entry.startsWith("https://")) return this.downloadRemoteModule(manifest.id, manifest.entry);
128
- if (manifest.entry.startsWith("file://")) return fileURLToPath(new URL(manifest.entry));
129
- return path.isAbsolute(manifest.entry) ? manifest.entry : path.resolve(getProjectRoot(), manifest.entry);
130
- }
131
- async downloadRemoteModule(pluginId, url) {
132
- const response = await fetch(url);
133
- if (!response.ok) throw new Error(`Failed to download plugin module: ${response.status} ${response.statusText}`);
134
- const source = await response.text();
135
- const outputPath = path.join(this.moduleCacheDir, `${sanitizeId(pluginId)}.mjs`);
136
- await mkdir(this.moduleCacheDir, { recursive: true });
137
- await writeFile(outputPath, source, "utf8");
138
- return outputPath;
139
- }
140
- toPublicManifest(manifest) {
141
- return {
142
- id: manifest.id,
143
- name: manifest.name,
144
- version: manifest.version,
145
- entry: manifest.entry,
146
- permissions: [...manifest.permissions]
147
- };
148
- }
149
- listPlugins() {
150
- const plugins = [];
151
- for (const root of this.legacyPluginRoots) {
152
- if (!existsSync(root)) continue;
153
- const entries = readdirSync(root, { withFileTypes: true });
154
- for (const entry of entries) {
155
- if (!entry.isDirectory() || entry.name.startsWith(".")) continue;
156
- const packageJsonPath = path.join(root, entry.name, "package.json");
157
- if (!existsSync(packageJsonPath)) continue;
158
- try {
159
- const manifest = JSON.parse(readFileSync(packageJsonPath, "utf8"));
160
- const plugin = this.toLegacyPluginInfo(manifest);
161
- if (plugin) plugins.push(plugin);
162
- } catch {
163
- continue;
164
- }
165
- }
166
- }
167
- return plugins;
168
- }
169
- searchPlugins(query) {
170
- const normalized = query.trim().toLowerCase();
171
- if (!normalized) return this.listPlugins();
172
- return this.listPlugins().filter((plugin) => {
173
- return plugin.name.toLowerCase().includes(normalized) || (plugin.description ?? "").toLowerCase().includes(normalized) || (plugin.capabilities ?? []).some((capability) => capability.toLowerCase().includes(normalized)) || (plugin.dependencies ?? []).some((dependency) => dependency.toLowerCase().includes(normalized));
174
- });
175
- }
176
- async installPlugin(source) {
177
- if (/^https:\/\/github\.com\/.+\.git$/u.test(source) || /^git@github\.com:.+\.git$/u.test(source)) return {
178
- id: "git-plugin",
179
- name: source.split("/").pop()?.replace(/\.git$/u, "") ?? "plugin",
180
- version: "0.0.0"
181
- };
182
- if (source.includes("://") || source.startsWith("git@") || source === "invalid-url") throw new Error("Invalid git URL");
183
- if (source.startsWith("/") || source.includes("\\")) {
184
- const packageJsonPath = path.join(source, "package.json");
185
- if (!existsSync(packageJsonPath)) throw new Error("No package.json");
186
- const manifest = JSON.parse(readFileSync(packageJsonPath, "utf8"));
187
- const plugin = this.toLegacyPluginInfo(manifest);
188
- if (!plugin) throw new Error("No package.json");
189
- return plugin;
190
- }
191
- for (const root of this.legacyPluginRoots) {
192
- const packageJsonPath = path.join(root, source, "package.json");
193
- if (!existsSync(packageJsonPath)) continue;
194
- const manifest = JSON.parse(readFileSync(packageJsonPath, "utf8"));
195
- const plugin = this.toLegacyPluginInfo(manifest);
196
- if (plugin) return plugin;
197
- }
198
- throw new Error("Plugin not found");
199
- }
200
- getPluginInfo(pluginId) {
201
- return this.listPlugins().find((plugin) => plugin.id === pluginId || plugin.name === pluginId);
202
- }
203
- getPluginDependencies(pluginId) {
204
- return this.getPluginInfo(pluginId)?.dependencies ?? [];
205
- }
206
- async uninstallPlugin(_pluginId) {}
207
- toLegacyPluginInfo(manifest) {
208
- if (typeof manifest["name"] !== "string") return null;
209
- const dependencies = isRecord$2(manifest["dependencies"]) ? Object.keys(manifest["dependencies"]) : [];
210
- return {
211
- id: sanitizeId(manifest["name"]),
212
- name: manifest["name"],
213
- version: typeof manifest["version"] === "string" ? manifest["version"] : "0.0.0",
214
- description: typeof manifest["description"] === "string" ? manifest["description"] : void 0,
215
- capabilities: Array.isArray(manifest["capabilities"]) ? manifest["capabilities"].filter((value) => typeof value === "string") : void 0,
216
- dependencies
217
- };
218
- }
219
- };
220
- //#endregion
221
- //#region src/modules/extension-registry/WebhookBridge.ts
222
- function isRecord$1(value) {
223
- return value !== null && typeof value === "object" && !Array.isArray(value);
224
- }
225
- function toWebhookRecord(value) {
226
- if (!isRecord$1(value)) return null;
227
- const { id, url, events, active } = value;
228
- if (typeof id !== "string" || typeof url !== "string" || !Array.isArray(events) || typeof active !== "boolean") return null;
229
- return {
230
- id,
231
- url,
232
- events: events.filter((event) => typeof event === "string"),
233
- active
234
- };
235
- }
236
- var WebhookBridge = class {
237
- rootDir;
238
- storageFile;
239
- webhooks = /* @__PURE__ */ new Map();
240
- constructor(rootDir = getExtensionRegistryDir()) {
241
- this.rootDir = rootDir;
242
- this.storageFile = path.join(rootDir, "webhooks.json");
243
- this.initializeFromDisk();
244
- }
245
- async registerWebhook(url, events) {
246
- new URL(url);
247
- const record = {
248
- id: `webhook-${Date.now()}-${this.webhooks.size + 1}`,
249
- url,
250
- events: [...new Set(events.filter((event) => event.trim().length > 0))],
251
- active: true
252
- };
253
- this.webhooks.set(record.id, record);
254
- await this.persist();
255
- return record.id;
256
- }
257
- async sendEvent(event, payload) {
258
- const deliveries = [...this.webhooks.values()].filter((record) => record.active && (record.events.includes(event) || record.events.includes("*")));
259
- for (const record of deliveries) {
260
- const response = await fetch(record.url, {
261
- method: "POST",
262
- headers: { "content-type": "application/json" },
263
- body: JSON.stringify({
264
- event,
265
- payload,
266
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
267
- })
268
- });
269
- if (!response.ok) throw new Error(`Webhook delivery failed for ${record.url}: ${response.status} ${response.statusText}`);
270
- }
271
- }
272
- listWebhooks() {
273
- return [...this.webhooks.values()].map((record) => ({
274
- id: record.id,
275
- url: record.url,
276
- events: [...record.events],
277
- active: record.active
278
- }));
279
- }
280
- /**
281
- * Register an external callback URL for a webhook endpoint.
282
- * Used when webhook({ action: "create" }) registers an endpoint — the URL is stored
283
- * here so emitEvent() can forward events to external callbacks.
284
- */
285
- registerExternalCallback(endpointId, url) {
286
- const existing = this.webhooks.get(endpointId);
287
- if (existing) {
288
- existing.url = url;
289
- return;
290
- }
291
- this.webhooks.set(endpointId, {
292
- id: endpointId,
293
- url,
294
- events: ["*"],
295
- active: true
296
- });
297
- }
298
- initializeFromDisk() {
299
- if (!existsSync(this.rootDir)) mkdirSync(this.rootDir, { recursive: true });
300
- if (!existsSync(this.storageFile)) return;
301
- const content = readFileSync(this.storageFile, "utf8");
302
- if (!content.trim()) return;
303
- const parsed = JSON.parse(content);
304
- if (!Array.isArray(parsed)) return;
305
- for (const item of parsed) {
306
- const record = toWebhookRecord(item);
307
- if (record) this.webhooks.set(record.id, record);
308
- }
309
- }
310
- async persist() {
311
- await mkdir(this.rootDir, { recursive: true });
312
- await writeFile(this.storageFile, JSON.stringify([...this.webhooks.values()], null, 2), "utf8");
313
- }
314
- };
315
- //#endregion
316
- //#region src/server/webhook/CommandQueue.impl.ts
317
- function cloneCommand(command) {
318
- return { ...command };
319
- }
320
- function normalizeTimestamp() {
321
- return (/* @__PURE__ */ new Date()).toISOString();
322
- }
323
- var CommandQueueImpl = class extends EventEmitter {
324
- maxQueueSize;
325
- commands = /* @__PURE__ */ new Map();
326
- order = [];
327
- maxRetries;
328
- retryDelay;
329
- processTimeout;
330
- nextId = 1;
331
- constructor(options = {}) {
332
- super();
333
- this.maxQueueSize = typeof options.maxQueueSize === "number" ? options.maxQueueSize : 1e3;
334
- this.maxRetries = typeof options.maxRetries === "number" ? options.maxRetries : 3;
335
- this.retryDelay = typeof options.retryDelay === "number" ? options.retryDelay : 0;
336
- this.processTimeout = typeof options.processTimeout === "number" ? options.processTimeout : WEBHOOK_PROCESS_TIMEOUT_MS;
337
- }
338
- enqueue(command) {
339
- if (this.order.length >= this.maxQueueSize) throw new Error(`Command queue is full (${this.maxQueueSize})`);
340
- const id = `cmd-${this.nextId}`;
341
- this.nextId += 1;
342
- const createdAt = normalizeTimestamp();
343
- const entry = {
344
- id,
345
- endpointId: command.endpointId,
346
- event: command.event,
347
- payload: command.payload,
348
- status: "pending",
349
- retries: 0,
350
- createdAt,
351
- updatedAt: createdAt
352
- };
353
- this.commands.set(id, entry);
354
- this.order.push(id);
355
- this.emit("enqueued", cloneCommand(entry));
356
- return id;
357
- }
358
- dequeue(filter) {
359
- if (!filter) {
360
- const firstPending = this.getCommandsByFilter({ status: "pending" })[0];
361
- return firstPending ? cloneCommand(firstPending) : void 0;
362
- }
363
- return this.getCommandsByFilter(filter).map(cloneCommand);
364
- }
365
- getStatus(id) {
366
- const command = this.commands.get(id);
367
- if (!command) return "failed";
368
- if (command.status === "processed") return "completed";
369
- return command.status;
370
- }
371
- retry(id) {
372
- const command = this.commands.get(id);
373
- if (!command) throw new Error(`Command ${id} not found`);
374
- if (command.status !== "failed") throw new Error(`Command ${id} is not in failed state`);
375
- command.status = "pending";
376
- command.retries = 0;
377
- command.lastError = void 0;
378
- command.updatedAt = normalizeTimestamp();
379
- }
380
- getCommand(id) {
381
- return this.commands.get(id);
382
- }
383
- getCommandsByFilter(filter) {
384
- const normalizedStatus = filter.status === "completed" ? "processed" : filter.status;
385
- const results = [];
386
- for (const id of this.order) {
387
- const command = this.commands.get(id);
388
- if (!command) continue;
389
- if (normalizedStatus && command.status !== normalizedStatus) continue;
390
- if (filter.endpointId && command.endpointId !== filter.endpointId) continue;
391
- results.push(command);
392
- }
393
- return results;
394
- }
395
- updateStatus(id, status, lastError) {
396
- const command = this.commands.get(id);
397
- if (!command) throw new Error(`Command ${id} not found`);
398
- command.status = status;
399
- command.updatedAt = normalizeTimestamp();
400
- command.lastError = lastError;
401
- return command;
402
- }
403
- };
404
- var CommandQueue = class extends CommandQueueImpl {
405
- async process(id, handler) {
406
- const command = this.getCommand(id);
407
- if (!command) throw new Error(`Command ${id} not found`);
408
- if (command.status === "processed") throw new Error(`Command ${id} already processed`);
409
- if (command.status === "failed") throw new Error(`Command ${id} already processed with failure`);
410
- if (command.status === "processing") throw new Error(`Command ${id} is already processing`);
411
- this.updateStatus(id, "processing");
412
- let finalStatus = "processed";
413
- let lastError;
414
- try {
415
- await Promise.race([Promise.resolve(handler(cloneCommand(command))), new Promise((_, reject) => {
416
- setTimeout(() => {
417
- reject(/* @__PURE__ */ new Error("Process timeout"));
418
- }, this.processTimeout);
419
- })]);
420
- } catch (error) {
421
- lastError = error instanceof Error ? error.message : String(error);
422
- if (command.retries + 1 >= this.maxRetries) finalStatus = "failed";
423
- else finalStatus = "pending";
424
- }
425
- if (lastError !== void 0 && this.retryDelay > 0) setTimeout(() => {}, this.retryDelay);
426
- if (finalStatus === "processed") {
427
- const processed = this.updateStatus(id, "processed");
428
- this.emit("processed", cloneCommand(processed));
429
- } else if (finalStatus === "pending") {
430
- command.retries += 1;
431
- const retried = this.updateStatus(id, "pending", lastError);
432
- this.emit("retried", cloneCommand(retried));
433
- throw lastError !== void 0 ? new Error(lastError) : /* @__PURE__ */ new Error("retry");
434
- } else {
435
- const failed = this.updateStatus(id, "failed", lastError);
436
- this.emit("failed", cloneCommand(failed));
437
- throw lastError !== void 0 ? new Error(lastError) : /* @__PURE__ */ new Error("failed");
438
- }
439
- }
440
- async retry(id) {
441
- super.retry(id);
442
- }
443
- exportState() {
444
- const results = [];
445
- for (const id of this.order) {
446
- const command = this.commands.get(id);
447
- if (command) results.push(cloneCommand(command));
448
- }
449
- return results;
450
- }
451
- importState(commands) {
452
- this.commands.clear();
453
- this.order.length = 0;
454
- let maxId = 0;
455
- for (const command of commands) {
456
- const entry = cloneCommand(command);
457
- this.commands.set(entry.id, entry);
458
- this.order.push(entry.id);
459
- const match = /^cmd-(\d+)$/.exec(entry.id);
460
- if (match && match[1]) {
461
- const num = parseInt(match[1], 10);
462
- if (num > maxId) maxId = num;
463
- }
464
- }
465
- if (maxId > 0) this.nextId = maxId + 1;
466
- }
467
- };
468
- //#endregion
469
- //#region src/server/webhook/WebhookServer.impl.ts
470
- function isWebhookEvent(value) {
471
- return value === "tool_called" || value === "domain_activated" || value === "evidence_added" || value === "workflow_completed";
472
- }
473
- function parseJsonBody(rawBody) {
474
- if (rawBody.length === 0) return {};
475
- try {
476
- return JSON.parse(rawBody);
477
- } catch {
478
- return { rawBody };
479
- }
480
- }
481
- var WebhookServerImpl = class extends EventEmitter {
482
- endpoints = /* @__PURE__ */ new Map();
483
- eventHandlers = /* @__PURE__ */ new Map();
484
- port;
485
- commandQueue;
486
- stats = {
487
- eventsRegistered: 0,
488
- webhooksSent: 0
489
- };
490
- server;
491
- nextEndpointId = 1;
492
- constructor(options = {}) {
493
- super();
494
- this.port = typeof options.port === "number" ? options.port : 18789;
495
- this.commandQueue = options.commandQueue;
496
- }
497
- registerEndpoint(config) {
498
- const id = `ep-${this.nextEndpointId}`;
499
- this.nextEndpointId += 1;
500
- this.endpoints.set(id, {
501
- id,
502
- path: config.path,
503
- method: config.method ?? "POST",
504
- secret: config.secret
505
- });
506
- this.emit("endpointRegistered", id);
507
- return id;
508
- }
509
- removeEndpoint(id) {
510
- if (!this.endpoints.delete(id)) throw new Error(`Endpoint ${id} not found`);
511
- this.emit("endpointRemoved", id);
512
- }
513
- listEndpoints() {
514
- return [...this.endpoints.values()].map((endpoint) => ({ ...endpoint }));
515
- }
516
- getPort() {
517
- return this.port;
518
- }
519
- isRunning() {
520
- return this.server !== void 0;
521
- }
522
- registerEvent(event, handler) {
523
- const handlers = this.eventHandlers.get(event) ?? [];
524
- handlers.push(handler);
525
- this.eventHandlers.set(event, handlers);
526
- this.stats.eventsRegistered += 1;
527
- }
528
- start() {
529
- if (this.server) throw new Error("Webhook server already started");
530
- this.server = http.createServer((request, response) => {
531
- this.handleRequest(request, response);
532
- });
533
- this.server.listen(this.port);
534
- this.emit("started", this.port);
535
- }
536
- async stop() {
537
- if (!this.server) return;
538
- const server = this.server;
539
- this.server = void 0;
540
- await new Promise((resolve, reject) => {
541
- server.close((error) => {
542
- if (error) {
543
- reject(error);
544
- return;
545
- }
546
- resolve();
547
- });
548
- });
549
- this.emit("stopped");
550
- }
551
- async sendWebhook(url, event, payload) {
552
- await fetch(url, {
553
- method: "POST",
554
- headers: { "content-type": "application/json" },
555
- body: JSON.stringify({
556
- event,
557
- payload
558
- })
559
- });
560
- this.stats.webhooksSent += 1;
561
- this.stats.lastSentAt = (/* @__PURE__ */ new Date()).toISOString();
562
- }
563
- getStats() {
564
- return { ...this.stats };
565
- }
566
- async handleRequest(request, response) {
567
- const method = request.method ?? "GET";
568
- const url = request.url ?? "/";
569
- const endpoint = [...this.endpoints.values()].find((item) => item.path === url && item.method === method);
570
- if (!endpoint) {
571
- response.statusCode = 404;
572
- response.end("not found");
573
- return;
574
- }
575
- if (endpoint.secret) {
576
- if (request.headers["x-webhook-secret"] !== endpoint.secret) {
577
- response.statusCode = 401;
578
- response.end("unauthorized");
579
- return;
580
- }
581
- }
582
- const chunks = [];
583
- await new Promise((resolve, reject) => {
584
- request.setEncoding("utf8");
585
- request.on("data", (chunk) => {
586
- chunks.push(chunk);
587
- });
588
- request.on("end", () => {
589
- resolve();
590
- });
591
- request.on("error", (error) => {
592
- reject(error);
593
- });
594
- });
595
- const payload = parseJsonBody(chunks.join(""));
596
- if (this.commandQueue) this.commandQueue.enqueue({
597
- endpointId: endpoint.id,
598
- payload
599
- });
600
- if (payload && typeof payload === "object" && "event" in payload && typeof payload.event === "string") await this.invokeEventHandlers(payload.event, payload);
601
- response.setHeader("content-type", "application/json");
602
- response.end(JSON.stringify({
603
- ok: true,
604
- endpointId: endpoint.id
605
- }));
606
- }
607
- async invokeEventHandlers(eventName, payload) {
608
- if (!isWebhookEvent(eventName)) return;
609
- const handlers = this.eventHandlers.get(eventName) ?? [];
610
- for (const handler of handlers) await Promise.resolve(handler(payload));
611
- }
612
- };
613
- var WebhookServer = class extends WebhookServerImpl {};
614
- //#endregion
615
- //#region src/server/domains/extension-registry/handlers.impl.ts
616
- function isRecord(value) {
617
- return value !== null && typeof value === "object" && !Array.isArray(value);
618
- }
619
- function isCallable(value) {
620
- return typeof value === "function";
621
- }
622
- var ExtensionRegistryHandlers = class {
623
- webhookServer;
624
- commandQueue;
625
- constructor(registry, webhook) {
626
- this.registry = registry;
627
- this.webhook = webhook;
628
- }
629
- async handleListInstalled() {
630
- return asJsonResponse({
631
- success: true,
632
- plugins: this.getRegistry().listInstalled()
633
- });
634
- }
635
- async handleExecuteInContext(args) {
636
- const pluginId = argStringRequired(args, "pluginId");
637
- const contextName = argStringRequired(args, "contextName");
638
- const contextArgs = argObject(args, "args") ?? {};
639
- const { manifest, exports } = await this.getRegistry().loadPlugin(pluginId);
640
- const context = this.resolveContext(exports, contextName);
641
- if (!context) throw new Error(`Context "${contextName}" was not found in plugin "${pluginId}"`);
642
- const result = await Promise.resolve(context(contextArgs));
643
- this.emitEvent("extension.executed", {
644
- pluginId,
645
- contextName
646
- });
647
- return asJsonResponse({
648
- success: true,
649
- manifest,
650
- contextName,
651
- result
652
- });
653
- }
654
- async handleReload(args) {
655
- const pluginId = argStringRequired(args, "pluginId");
656
- await this.getRegistry().unloadPlugin(pluginId);
657
- const loaded = await this.getRegistry().loadPlugin(pluginId);
658
- this.emitEvent("extension.reloaded", { pluginId });
659
- return asJsonResponse({
660
- success: true,
661
- pluginId,
662
- manifest: loaded.manifest,
663
- exportedKeys: Object.keys(loaded.exports).toSorted()
664
- });
665
- }
666
- async handleUninstall(args) {
667
- const pluginId = argStringRequired(args, "pluginId");
668
- await this.getRegistry().unregister(pluginId);
669
- this.emitEvent("extension.uninstalled", { pluginId });
670
- return asJsonResponse({
671
- success: true,
672
- pluginId
673
- });
674
- }
675
- async handleWebhookCreate(args) {
676
- const name = argStringRequired(args, "name");
677
- const webhookPath = argStringRequired(args, "path");
678
- const secret = argString(args, "secret");
679
- const events = Array.isArray(args.events) ? args.events.filter((e) => typeof e === "string") : [];
680
- const server = this.getWebhookServer();
681
- if (!server.isRunning()) server.start();
682
- const endpointId = server.registerEndpoint({
683
- path: webhookPath,
684
- method: "POST",
685
- secret: secret ?? void 0
686
- });
687
- const bridge = this.getWebhook();
688
- const baseUrl = `http://localhost:${server.getPort()}${webhookPath}`;
689
- bridge.registerExternalCallback(endpointId, baseUrl);
690
- return asJsonResponse({
691
- success: true,
692
- endpointId,
693
- url: baseUrl,
694
- name,
695
- events
696
- });
697
- }
698
- async handleWebhookList() {
699
- const server = this.getWebhookServer();
700
- return asJsonResponse({
701
- success: true,
702
- endpoints: server.listEndpoints(),
703
- port: server.getPort(),
704
- running: server.isRunning()
705
- });
706
- }
707
- async handleWebhookDelete(args) {
708
- const endpointId = argStringRequired(args, "endpointId");
709
- const server = this.getWebhookServer();
710
- try {
711
- server.removeEndpoint(endpointId);
712
- } catch (err) {
713
- throw new Error(`GRACEFUL: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
714
- }
715
- return asJsonResponse({
716
- success: true,
717
- endpointId
718
- });
719
- }
720
- async handleWebhookCommands(args) {
721
- const endpointId = argStringRequired(args, "endpointId");
722
- const status = argString(args, "status");
723
- const command = argObject(args, "command");
724
- if (command) return asJsonResponse({
725
- success: true,
726
- commandId: this.getCommandQueue().enqueue({
727
- endpointId,
728
- payload: command
729
- }),
730
- status: "pending"
731
- });
732
- const queue = this.getCommandQueue();
733
- const filter = { endpointId };
734
- if (status) filter.status = status;
735
- const commands = queue.dequeue(filter);
736
- return asJsonResponse({
737
- success: true,
738
- endpointId,
739
- commands,
740
- count: Array.isArray(commands) ? commands.length : commands ? 1 : 0
741
- });
742
- }
743
- getWebhookServer() {
744
- if (!this.webhookServer) {
745
- this.commandQueue = new CommandQueue();
746
- this.webhookServer = new WebhookServer({ commandQueue: this.commandQueue });
747
- }
748
- return this.webhookServer;
749
- }
750
- async startWebhookServer() {
751
- const server = this.getWebhookServer();
752
- if (!server.isRunning()) server.start();
753
- }
754
- async stopWebhookServer() {
755
- if (this.webhookServer) {
756
- await this.webhookServer.stop();
757
- this.webhookServer = void 0;
758
- this.commandQueue = void 0;
759
- }
760
- }
761
- getRegistry() {
762
- if (!this.registry) this.registry = new PluginRegistry();
763
- return this.registry;
764
- }
765
- getWebhook() {
766
- if (!this.webhook) this.webhook = new WebhookBridge();
767
- return this.webhook;
768
- }
769
- getCommandQueue() {
770
- if (!this.commandQueue) this.commandQueue = new CommandQueue();
771
- return this.commandQueue;
772
- }
773
- emitEvent(event, payload) {
774
- this.getWebhook().sendEvent(event, payload).catch(() => void 0);
775
- }
776
- resolveContext(exportsRecord, contextName) {
777
- const directContext = exportsRecord[contextName];
778
- if (isCallable(directContext)) return directContext;
779
- const defaultExport = exportsRecord.default;
780
- if (contextName === "default" && isCallable(defaultExport)) return defaultExport;
781
- if (isRecord(defaultExport)) {
782
- const nestedContext = defaultExport[contextName];
783
- if (isCallable(nestedContext)) return nestedContext;
784
- }
785
- return null;
786
- }
787
- async handleWebhookDispatch(args) {
788
- const action = argString(args, "action");
789
- switch (action) {
790
- case "create": return this.handleWebhookCreate(args);
791
- case "list": return this.handleWebhookList();
792
- case "delete": return this.handleWebhookDelete(args);
793
- case "commands": return this.handleWebhookCommands(args);
794
- default: return asJsonResponse({ error: `Invalid action: "${action}". Expected one of: create, list, delete, commands` });
795
- }
796
- }
797
- };
798
- //#endregion
799
- export { ExtensionRegistryHandlers };