@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,917 +0,0 @@
1
- import { fn as SANDBOX_EXEC_TIMEOUT_MS, mn as SANDBOX_MEMORY_LIMIT_MB, pn as SANDBOX_MAX_TIMEOUT_MS } from "./constants-CDZLOoVv.mjs";
2
- import { randomUUID } from "node:crypto";
3
- import { getQuickJS } from "quickjs-emscripten";
4
- //#region src/server/sandbox/SandboxHelpers.ts
5
- /**
6
- * SandboxHelpers — Pre-built pure-JS utility libraries for the sandbox.
7
- *
8
- * These helpers are evaluated inside QuickJS before user code runs,
9
- * providing common utilities (base64, hex, hashing, JSON, array, string)
10
- * without requiring Node.js APIs.
11
- */
12
- /**
13
- * Pure-JS source string that is eval'd inside the sandbox environment.
14
- * All implementations are self-contained with no external dependencies.
15
- */
16
- const SANDBOX_HELPER_SOURCE = `
17
- (function() {
18
- var helpers = {};
19
-
20
- // ── base64 ──
21
- helpers.base64 = {
22
- _chars: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',
23
- encode: function(str) {
24
- var output = '';
25
- var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
26
- var i = 0;
27
- while (i < str.length) {
28
- chr1 = str.charCodeAt(i++);
29
- chr2 = str.charCodeAt(i++);
30
- chr3 = str.charCodeAt(i++);
31
- enc1 = chr1 >> 2;
32
- enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
33
- enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
34
- enc4 = chr3 & 63;
35
- if (isNaN(chr2)) { enc3 = enc4 = 64; }
36
- else if (isNaN(chr3)) { enc4 = 64; }
37
- output += this._chars.charAt(enc1) + this._chars.charAt(enc2) +
38
- this._chars.charAt(enc3) + this._chars.charAt(enc4);
39
- }
40
- return output;
41
- },
42
- decode: function(str) {
43
- var output = '';
44
- var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
45
- var i = 0;
46
- str = str.replace(/[^A-Za-z0-9+/=]/g, '');
47
- while (i < str.length) {
48
- enc1 = this._chars.indexOf(str.charAt(i++));
49
- enc2 = this._chars.indexOf(str.charAt(i++));
50
- enc3 = this._chars.indexOf(str.charAt(i++));
51
- enc4 = this._chars.indexOf(str.charAt(i++));
52
- chr1 = (enc1 << 2) | (enc2 >> 4);
53
- chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
54
- chr3 = ((enc3 & 3) << 6) | enc4;
55
- output += String.fromCharCode(chr1);
56
- if (enc3 !== 64) output += String.fromCharCode(chr2);
57
- if (enc4 !== 64) output += String.fromCharCode(chr3);
58
- }
59
- return output;
60
- }
61
- };
62
-
63
- // ── hex ──
64
- helpers.hex = {
65
- encode: function(str) {
66
- var hex = '';
67
- for (var i = 0; i < str.length; i++) {
68
- hex += ('0' + str.charCodeAt(i).toString(16)).slice(-2);
69
- }
70
- return hex;
71
- },
72
- decode: function(hex) {
73
- var str = '';
74
- for (var i = 0; i < hex.length; i += 2) {
75
- str += String.fromCharCode(parseInt(hex.substr(i, 2), 16));
76
- }
77
- return str;
78
- }
79
- };
80
-
81
- // ── hash (simple djb2/fnv for in-sandbox use; NOT cryptographic!) ──
82
- helpers.hash = {
83
- djb2: function(str) {
84
- var hash = 5381;
85
- for (var i = 0; i < str.length; i++) {
86
- hash = ((hash << 5) + hash) + str.charCodeAt(i);
87
- hash = hash & hash; // Convert to 32-bit
88
- }
89
- return (hash >>> 0).toString(16);
90
- },
91
- fnv1a: function(str) {
92
- var hash = 0x811c9dc5;
93
- for (var i = 0; i < str.length; i++) {
94
- hash ^= str.charCodeAt(i);
95
- hash = Math.imul(hash, 0x01000193);
96
- }
97
- return (hash >>> 0).toString(16);
98
- },
99
- /** Simple MD5 — pure JS implementation */
100
- md5: function(str) {
101
- // Lightweight MD5 for sandbox use
102
- function md5cycle(x, k) {
103
- var a = x[0], b = x[1], c = x[2], d = x[3];
104
- a = ff(a,b,c,d,k[0],7,-680876936);d=ff(d,a,b,c,k[1],12,-389564586);c=ff(c,d,a,b,k[2],17,606105819);b=ff(b,c,d,a,k[3],22,-1044525330);
105
- a=ff(a,b,c,d,k[4],7,-176418897);d=ff(d,a,b,c,k[5],12,1200080426);c=ff(c,d,a,b,k[6],17,-1473231341);b=ff(b,c,d,a,k[7],22,-45705983);
106
- a=ff(a,b,c,d,k[8],7,1770035416);d=ff(d,a,b,c,k[9],12,-1958414417);c=ff(c,d,a,b,k[10],17,-42063);b=ff(b,c,d,a,k[11],22,-1990404162);
107
- a=ff(a,b,c,d,k[12],7,1804603682);d=ff(d,a,b,c,k[13],12,-40341101);c=ff(c,d,a,b,k[14],17,-1502002290);b=ff(b,c,d,a,k[15],22,1236535329);
108
- a=gg(a,b,c,d,k[1],5,-165796510);d=gg(d,a,b,c,k[6],9,-1069501632);c=gg(c,d,a,b,k[11],14,643717713);b=gg(b,c,d,a,k[0],20,-373897302);
109
- a=gg(a,b,c,d,k[5],5,-701558691);d=gg(d,a,b,c,k[10],9,38016083);c=gg(c,d,a,b,k[15],14,-660478335);b=gg(b,c,d,a,k[4],20,-405537848);
110
- a=gg(a,b,c,d,k[9],5,568446438);d=gg(d,a,b,c,k[14],9,-1019803690);c=gg(c,d,a,b,k[3],14,-187363961);b=gg(b,c,d,a,k[8],20,1163531501);
111
- a=gg(a,b,c,d,k[13],5,-1444681467);d=gg(d,a,b,c,k[2],9,-51403784);c=gg(c,d,a,b,k[7],14,1735328473);b=gg(b,c,d,a,k[12],20,-1926607734);
112
- a=hh(a,b,c,d,k[5],4,-378558);d=hh(d,a,b,c,k[8],11,-2022574463);c=hh(c,d,a,b,k[11],16,1839030562);b=hh(b,c,d,a,k[14],23,-35309556);
113
- a=hh(a,b,c,d,k[1],4,-1530992060);d=hh(d,a,b,c,k[4],11,1272893353);c=hh(c,d,a,b,k[7],16,-155497632);b=hh(b,c,d,a,k[10],23,-1094730640);
114
- a=hh(a,b,c,d,k[13],4,681279174);d=hh(d,a,b,c,k[0],11,-358537222);c=hh(c,d,a,b,k[3],16,-722521979);b=hh(b,c,d,a,k[6],23,76029189);
115
- a=hh(a,b,c,d,k[9],4,-640364487);d=hh(d,a,b,c,k[12],11,-421815835);c=hh(c,d,a,b,k[15],16,530742520);b=hh(b,c,d,a,k[2],23,-995338651);
116
- a=ii(a,b,c,d,k[0],6,-198630844);d=ii(d,a,b,c,k[7],10,1126891415);c=ii(c,d,a,b,k[14],15,-1416354905);b=ii(b,c,d,a,k[5],21,-57434055);
117
- a=ii(a,b,c,d,k[12],6,1700485571);d=ii(d,a,b,c,k[3],10,-1894986606);c=ii(c,d,a,b,k[10],15,-1051523);b=ii(b,c,d,a,k[1],21,-2054922799);
118
- a=ii(a,b,c,d,k[8],6,1873313359);d=ii(d,a,b,c,k[15],10,-30611744);c=ii(c,d,a,b,k[6],15,-1560198380);b=ii(b,c,d,a,k[13],21,1309151649);
119
- a=ii(a,b,c,d,k[4],6,-145523070);d=ii(d,a,b,c,k[11],10,-1120210379);c=ii(c,d,a,b,k[2],15,718787259);b=ii(b,c,d,a,k[9],21,-343485551);
120
- x[0]=add32(a,x[0]);x[1]=add32(b,x[1]);x[2]=add32(c,x[2]);x[3]=add32(d,x[3]);
121
- }
122
- function cmn(q,a,b,x,s,t){a=add32(add32(a,q),add32(x,t));return add32((a<<s)|(a>>>(32-s)),b)}
123
- function ff(a,b,c,d,x,s,t){return cmn((b&c)|((~b)&d),a,b,x,s,t)}
124
- function gg(a,b,c,d,x,s,t){return cmn((b&d)|(c&(~d)),a,b,x,s,t)}
125
- function hh(a,b,c,d,x,s,t){return cmn(b^c^d,a,b,x,s,t)}
126
- function ii(a,b,c,d,x,s,t){return cmn(c^(b|(~d)),a,b,x,s,t)}
127
- function add32(a,b){return(a+b)&0xFFFFFFFF}
128
-
129
- var n = str.length;
130
- var state = [1732584193,-271733879,-1732584194,271733878];
131
- var tail = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
132
- var i;
133
- for (i = 64; i <= n; i += 64) {
134
- var blk = [];
135
- for (var j = i - 64; j < i; j += 4) {
136
- blk.push(str.charCodeAt(j)|(str.charCodeAt(j+1)<<8)|(str.charCodeAt(j+2)<<16)|(str.charCodeAt(j+3)<<24));
137
- }
138
- md5cycle(state, blk);
139
- }
140
- for (var j = 0; j < 16; j++) tail[j] = 0;
141
- for (i = i - 64; i < n; i++) {
142
- tail[i>>2] |= str.charCodeAt(i) << ((i%4)<<3);
143
- }
144
- tail[i>>2] |= 0x80 << ((i%4)<<3);
145
- if (i > 55) { md5cycle(state, tail); for (j = 0; j < 16; j++) tail[j] = 0; }
146
- tail[14] = n * 8;
147
- md5cycle(state, tail);
148
-
149
- var hex_chr = '0123456789abcdef';
150
- var s = '';
151
- for (i = 0; i < 4; i++) {
152
- for (j = 0; j < 4; j++) {
153
- s += hex_chr.charAt((state[i] >> (j*8+4)) & 0x0F) + hex_chr.charAt((state[i] >> (j*8)) & 0x0F);
154
- }
155
- }
156
- return s;
157
- },
158
- sha256: function(str) {
159
- // Minimal pure-JS SHA-256
160
- var K = [0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5,0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5,
161
- 0xd807aa98,0x12835b01,0x243185be,0x550c7dc3,0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174,
162
- 0xe49b69c1,0xefbe4786,0x0fc19dc6,0x240ca1cc,0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da,
163
- 0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7,0xc6e00bf3,0xd5a79147,0x06ca6351,0x14292967,
164
- 0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13,0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85,
165
- 0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3,0xd192e819,0xd6990624,0xf40e3585,0x106aa070,
166
- 0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5,0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3,
167
- 0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208,0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2];
168
- function rr(x,n){return(x>>>n)|(x<<(32-n))}
169
- var H=[0x6a09e667,0xbb67ae85,0x3c6ef372,0xa54ff53a,0x510e527f,0x9b05688c,0x1f83d9ab,0x5be0cd19];
170
- var msg=[];
171
- for(var i=0;i<str.length;i++)msg.push(str.charCodeAt(i));
172
- msg.push(0x80);
173
- var l=msg.length;
174
- while(l%64!==56){msg.push(0);l++;}
175
- var bits=str.length*8;
176
- for(i=7;i>=0;i--)msg.push((bits>>>(i*8))&0xff);
177
- for(var offset=0;offset<msg.length;offset+=64){
178
- var W=[];
179
- for(i=0;i<16;i++)W[i]=(msg[offset+i*4]<<24)|(msg[offset+i*4+1]<<16)|(msg[offset+i*4+2]<<8)|msg[offset+i*4+3];
180
- for(i=16;i<64;i++){
181
- var s0=rr(W[i-15],7)^rr(W[i-15],18)^(W[i-15]>>>3);
182
- var s1=rr(W[i-2],17)^rr(W[i-2],19)^(W[i-2]>>>10);
183
- W[i]=(W[i-16]+s0+W[i-7]+s1)|0;
184
- }
185
- var a=H[0],b=H[1],c=H[2],d=H[3],e=H[4],f=H[5],g=H[6],h=H[7];
186
- for(i=0;i<64;i++){
187
- var S1=rr(e,6)^rr(e,11)^rr(e,25);
188
- var ch=(e&f)^((~e)&g);
189
- var t1=(h+S1+ch+K[i]+W[i])|0;
190
- var S0=rr(a,2)^rr(a,13)^rr(a,22);
191
- var maj=(a&b)^(a&c)^(b&c);
192
- var t2=(S0+maj)|0;
193
- h=g;g=f;f=e;e=(d+t1)|0;d=c;c=b;b=a;a=(t1+t2)|0;
194
- }
195
- H[0]=(H[0]+a)|0;H[1]=(H[1]+b)|0;H[2]=(H[2]+c)|0;H[3]=(H[3]+d)|0;
196
- H[4]=(H[4]+e)|0;H[5]=(H[5]+f)|0;H[6]=(H[6]+g)|0;H[7]=(H[7]+h)|0;
197
- }
198
- var hex='';
199
- for(i=0;i<8;i++)for(var j=7;j>=0;j--)hex+='0123456789abcdef'.charAt((H[i]>>>(j*4))&0xf);
200
- return hex;
201
- }
202
- };
203
-
204
- // ── json ──
205
- helpers.json = {
206
- safeParse: function(str) {
207
- try { return { ok: true, value: JSON.parse(str) }; }
208
- catch(e) { return { ok: false, error: e.message }; }
209
- }
210
- };
211
-
212
- // ── array ──
213
- helpers.array = {
214
- chunk: function(arr, size) {
215
- var result = [];
216
- for (var i = 0; i < arr.length; i += size) {
217
- result.push(arr.slice(i, i + size));
218
- }
219
- return result;
220
- },
221
- flatten: function(arr) {
222
- var result = [];
223
- for (var i = 0; i < arr.length; i++) {
224
- if (Array.isArray(arr[i])) {
225
- result = result.concat(this.flatten(arr[i]));
226
- } else {
227
- result.push(arr[i]);
228
- }
229
- }
230
- return result;
231
- },
232
- unique: function(arr) {
233
- var seen = {};
234
- var result = [];
235
- for (var i = 0; i < arr.length; i++) {
236
- var key = JSON.stringify(arr[i]);
237
- if (!seen[key]) {
238
- seen[key] = true;
239
- result.push(arr[i]);
240
- }
241
- }
242
- return result;
243
- }
244
- };
245
-
246
- // ── string ──
247
- helpers.string = {
248
- camelCase: function(s) {
249
- return s.replace(/[-_\\s]+(\\w)/g, function(_, c) { return c.toUpperCase(); })
250
- .replace(/^\\w/, function(c) { return c.toLowerCase(); });
251
- },
252
- snakeCase: function(s) {
253
- return s.replace(/([A-Z])/g, '_$1').toLowerCase()
254
- .replace(/[-\\s]+/g, '_')
255
- .replace(/^_/, '');
256
- },
257
- truncate: function(s, len) {
258
- if (s.length <= len) return s;
259
- return s.slice(0, len - 3) + '...';
260
- }
261
- };
262
-
263
- // Expose to global scope
264
- globalThis.helpers = helpers;
265
- })();
266
- `;
267
- //#endregion
268
- //#region src/server/sandbox/QuickJSSandbox.ts
269
- /**
270
- * QuickJSSandbox — WASM-isolated JavaScript execution engine.
271
- *
272
- * Uses quickjs-emscripten to run untrusted code inside a QuickJS WASM
273
- * runtime. Each `execute()` call spins up a fresh runtime (no state
274
- * leakage across calls) with configurable timeout and memory limits.
275
- *
276
- * Provides stronger isolation than the existing Node.js vm-based
277
- * ExecutionSandbox because the guest code runs inside WebAssembly —
278
- * it cannot reach Node.js APIs, the filesystem, or the network even
279
- * if it escapes the QuickJS VM.
280
- */
281
- const DEFAULT_TIMEOUT_MS = SANDBOX_EXEC_TIMEOUT_MS;
282
- const DEFAULT_MEMORY_LIMIT_BYTES = SANDBOX_MEMORY_LIMIT_MB * 1024 * 1024;
283
- const DEFAULT_MAX_BRIDGE_CALLS = 10;
284
- /**
285
- * Marshal a host value into a QuickJS handle.
286
- *
287
- * Supports primitives, arrays, and plain objects. Anything else
288
- * is converted to its JSON representation (string).
289
- */
290
- function marshalToQuickJS(ctx, value) {
291
- if (value === null || value === void 0) return ctx.undefined;
292
- switch (typeof value) {
293
- case "string": return ctx.newString(value);
294
- case "number": return ctx.newNumber(value);
295
- case "boolean": return value ? ctx.true : ctx.false;
296
- case "object": {
297
- if (Array.isArray(value)) {
298
- const arr = ctx.newArray();
299
- for (let i = 0; i < value.length; i++) {
300
- const elem = marshalToQuickJS(ctx, value[i]);
301
- ctx.setProp(arr, i, elem);
302
- elem.dispose();
303
- }
304
- return arr;
305
- }
306
- const obj = ctx.newObject();
307
- for (const [k, v] of Object.entries(value)) {
308
- const prop = marshalToQuickJS(ctx, v);
309
- ctx.setProp(obj, k, prop);
310
- prop.dispose();
311
- }
312
- return obj;
313
- }
314
- default: return ctx.newString(String(value));
315
- }
316
- }
317
- /**
318
- * Unmarshal a QuickJS handle back to a host value.
319
- */
320
- function unmarshalFromQuickJS(ctx, handle) {
321
- switch (ctx.typeof(handle)) {
322
- case "undefined": return;
323
- case "number": return ctx.getNumber(handle);
324
- case "string": return ctx.getString(handle);
325
- case "boolean": return ctx.dump(handle);
326
- case "object": return ctx.dump(handle);
327
- default: return ctx.dump(handle);
328
- }
329
- }
330
- var QuickJSSandbox = class {
331
- bridge = null;
332
- /**
333
- * Set an optional MCP bridge for host tool invocation from sandbox.
334
- */
335
- setBridge(bridge) {
336
- this.bridge = bridge;
337
- }
338
- /**
339
- * Execute JavaScript code inside a fresh WASM-isolated QuickJS runtime.
340
- *
341
- * Every call creates a new runtime + context, evaluates code, and tears
342
- * it down. There is zero state leakage between calls.
343
- */
344
- async execute(code, options = {}) {
345
- const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
346
- const memoryLimitBytes = options.memoryLimitBytes ?? DEFAULT_MEMORY_LIMIT_BYTES;
347
- const runtime = (await getQuickJS()).newRuntime();
348
- runtime.setMemoryLimit(memoryLimitBytes);
349
- const startTime = Date.now();
350
- let timedOut = false;
351
- runtime.setInterruptHandler(() => {
352
- if (Date.now() - startTime > timeoutMs) {
353
- timedOut = true;
354
- return true;
355
- }
356
- return false;
357
- });
358
- const context = runtime.newContext();
359
- const logs = [];
360
- try {
361
- this.injectConsole(context, logs);
362
- this.injectHelpers(context);
363
- if (this.bridge) this.injectBridge(context, this.bridge, logs);
364
- if (options.globals) this.injectGlobals(context, options.globals);
365
- const result = context.evalCode(code, "sandbox-eval.js");
366
- if (result.error) {
367
- const errorMsg = context.dump(result.error);
368
- result.error.dispose();
369
- if (timedOut) return {
370
- ok: false,
371
- error: "Execution timed out",
372
- timedOut: true,
373
- durationMs: Date.now() - startTime,
374
- logs
375
- };
376
- return {
377
- ok: false,
378
- error: typeof errorMsg === "object" ? JSON.stringify(errorMsg) : String(errorMsg),
379
- timedOut: false,
380
- durationMs: Date.now() - startTime,
381
- logs
382
- };
383
- }
384
- const output = unmarshalFromQuickJS(context, result.value);
385
- result.value.dispose();
386
- return {
387
- ok: true,
388
- output,
389
- timedOut: false,
390
- durationMs: Date.now() - startTime,
391
- logs
392
- };
393
- } catch (err) {
394
- return {
395
- ok: false,
396
- error: err instanceof Error ? err.message : String(err),
397
- timedOut,
398
- durationMs: Date.now() - startTime,
399
- logs
400
- };
401
- } finally {
402
- context.dispose();
403
- runtime.dispose();
404
- }
405
- }
406
- /**
407
- * Execute JavaScript code with multi-round MCP bridge orchestration.
408
- *
409
- * The sandbox script can call `mcp.call(name, args)` which enqueues
410
- * the request. After each evaluation round, pending calls are resolved
411
- * asynchronously on the host side, and results are injected back as
412
- * `__bridgeResults` for the next round.
413
- *
414
- * The script should check `typeof __bridgeResults !== 'undefined'`
415
- * to determine if it's in a continuation round and read prior results.
416
- *
417
- * @param code - JavaScript source to evaluate
418
- * @param bridge - MCPBridge instance for tool dispatch
419
- * @param options - Orchestration options (maxBridgeCalls, bridgeAllowlist, etc.)
420
- */
421
- async executeWithOrchestration(code, bridge, options = {}) {
422
- const maxBridgeCalls = options.maxBridgeCalls ?? DEFAULT_MAX_BRIDGE_CALLS;
423
- const startTime = Date.now();
424
- const allLogs = [];
425
- const allBridgeCalls = [];
426
- if (options.bridgeAllowlist) bridge.setAllowlist(options.bridgeAllowlist);
427
- let bridgeResults = {};
428
- let lastOutput;
429
- let round = 0;
430
- while (round <= maxBridgeCalls) {
431
- const roundGlobals = {
432
- ...options.globals,
433
- __bridgeRound: round
434
- };
435
- if (round > 0) roundGlobals.__bridgeResults = bridgeResults;
436
- const roundResult = await this.executeOneRound(code, bridge, {
437
- ...options,
438
- globals: roundGlobals
439
- });
440
- allLogs.push(...roundResult.logs);
441
- if (!roundResult.ok || roundResult.timedOut) return {
442
- ...roundResult,
443
- logs: allLogs,
444
- durationMs: Date.now() - startTime,
445
- bridgeCallCount: allBridgeCalls.length,
446
- bridgeCalls: allBridgeCalls
447
- };
448
- lastOutput = roundResult.output;
449
- if (!bridge.hasPending()) break;
450
- const pending = bridge.drainPending();
451
- const roundResults = {};
452
- for (const req of pending) try {
453
- const result = await bridge.call(req.toolName, req.args);
454
- roundResults[req.id] = result;
455
- allBridgeCalls.push({
456
- toolName: req.toolName,
457
- args: req.args,
458
- result
459
- });
460
- } catch (err) {
461
- const errorMsg = err instanceof Error ? err.message : String(err);
462
- roundResults[req.id] = {
463
- __error: true,
464
- message: errorMsg
465
- };
466
- allBridgeCalls.push({
467
- toolName: req.toolName,
468
- args: req.args,
469
- result: {
470
- __error: true,
471
- message: errorMsg
472
- }
473
- });
474
- }
475
- bridgeResults = {
476
- ...bridgeResults,
477
- ...roundResults
478
- };
479
- round++;
480
- }
481
- return {
482
- ok: true,
483
- output: lastOutput,
484
- timedOut: false,
485
- durationMs: Date.now() - startTime,
486
- logs: allLogs,
487
- bridgeCallCount: allBridgeCalls.length,
488
- bridgeCalls: allBridgeCalls
489
- };
490
- }
491
- /**
492
- * Run a single evaluation round inside a fresh QuickJS runtime.
493
- * Used internally by executeWithOrchestration.
494
- */
495
- async executeOneRound(code, bridge, options = {}) {
496
- const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
497
- const memoryLimitBytes = options.memoryLimitBytes ?? DEFAULT_MEMORY_LIMIT_BYTES;
498
- const runtime = (await getQuickJS()).newRuntime();
499
- runtime.setMemoryLimit(memoryLimitBytes);
500
- const startTime = Date.now();
501
- let timedOut = false;
502
- runtime.setInterruptHandler(() => {
503
- if (Date.now() - startTime > timeoutMs) {
504
- timedOut = true;
505
- return true;
506
- }
507
- return false;
508
- });
509
- const context = runtime.newContext();
510
- const logs = [];
511
- try {
512
- this.injectConsole(context, logs);
513
- this.injectHelpers(context);
514
- this.injectBridgeForOrchestration(context, bridge, logs);
515
- if (options.globals) this.injectGlobals(context, options.globals);
516
- const result = context.evalCode(code, "sandbox-eval.js");
517
- if (result.error) {
518
- const errorMsg = context.dump(result.error);
519
- result.error.dispose();
520
- if (timedOut) return {
521
- ok: false,
522
- error: "Execution timed out",
523
- timedOut: true,
524
- durationMs: Date.now() - startTime,
525
- logs
526
- };
527
- return {
528
- ok: false,
529
- error: typeof errorMsg === "object" ? JSON.stringify(errorMsg) : String(errorMsg),
530
- timedOut: false,
531
- durationMs: Date.now() - startTime,
532
- logs
533
- };
534
- }
535
- const output = unmarshalFromQuickJS(context, result.value);
536
- result.value.dispose();
537
- return {
538
- ok: true,
539
- output,
540
- timedOut: false,
541
- durationMs: Date.now() - startTime,
542
- logs
543
- };
544
- } catch (err) {
545
- return {
546
- ok: false,
547
- error: err instanceof Error ? err.message : String(err),
548
- timedOut,
549
- durationMs: Date.now() - startTime,
550
- logs
551
- };
552
- } finally {
553
- context.dispose();
554
- runtime.dispose();
555
- }
556
- }
557
- /**
558
- * Inject a `console` object into the sandbox whose `log` method
559
- * pushes stringified arguments into the captured `logs` array.
560
- */
561
- injectConsole(ctx, logs) {
562
- const consoleObj = ctx.newObject();
563
- const logFn = ctx.newFunction("log", (...args) => {
564
- const parts = args.map((a) => {
565
- const val = unmarshalFromQuickJS(ctx, a);
566
- return typeof val === "string" ? val : JSON.stringify(val);
567
- });
568
- logs.push(parts.join(" "));
569
- });
570
- ctx.setProp(consoleObj, "log", logFn);
571
- ctx.setProp(consoleObj, "warn", logFn);
572
- ctx.setProp(consoleObj, "error", logFn);
573
- ctx.setProp(ctx.global, "console", consoleObj);
574
- logFn.dispose();
575
- consoleObj.dispose();
576
- }
577
- /**
578
- * Inject user-supplied global variables into the QuickJS context.
579
- */
580
- injectGlobals(ctx, globals) {
581
- for (const [key, value] of Object.entries(globals)) {
582
- const handle = marshalToQuickJS(ctx, value);
583
- ctx.setProp(ctx.global, key, handle);
584
- handle.dispose();
585
- }
586
- }
587
- /**
588
- * Inject pre-built helper libraries (base64, hex, hash, etc.) into the
589
- * sandbox global scope by evaluating the helper source code.
590
- */
591
- injectHelpers(ctx) {
592
- const result = ctx.evalCode(SANDBOX_HELPER_SOURCE, "sandbox-helpers.js");
593
- if (result.error) {
594
- ctx.dump(result.error);
595
- result.error.dispose();
596
- } else result.value.dispose();
597
- }
598
- /**
599
- * Inject the `mcp` bridge object into the sandbox (legacy sync stub).
600
- *
601
- * Because QuickJS doesn't natively support async host functions in sync
602
- * mode, `mcp.call()` and `mcp.listTools()` are exposed as synchronous
603
- * functions. Bridge calls capture the request; the caller should use
604
- * `MCPBridge.call()` from the host side for actual async dispatch.
605
- *
606
- * For sandbox scripts that need bridge results inline, the host orchestrator
607
- * (AutoCorrectionLoop or handler) resolves bridge calls between executions.
608
- */
609
- injectBridge(ctx, bridge, logs) {
610
- const mcpObj = ctx.newObject();
611
- const callFn = ctx.newFunction("call", (nameHandle, argsHandle) => {
612
- const name = ctx.getString(nameHandle);
613
- const args = ctx.dump(argsHandle) ?? {};
614
- logs.push(`[mcp.call] ${name}(${JSON.stringify(args)})`);
615
- return marshalToQuickJS(ctx, {
616
- pending: true,
617
- tool: name
618
- });
619
- });
620
- const listFn = ctx.newFunction("listTools", () => {
621
- return marshalToQuickJS(ctx, bridge.listAvailableTools());
622
- });
623
- ctx.setProp(mcpObj, "call", callFn);
624
- ctx.setProp(mcpObj, "listTools", listFn);
625
- ctx.setProp(ctx.global, "mcp", mcpObj);
626
- callFn.dispose();
627
- listFn.dispose();
628
- mcpObj.dispose();
629
- }
630
- /**
631
- * Inject the `mcp` bridge object for orchestration mode.
632
- *
633
- * `mcp.call()` enqueues the request via `bridge.enqueue()` and returns
634
- * a `{ __bridgeCall: true, callId }` marker. The orchestration loop
635
- * resolves these calls between rounds and injects results into
636
- * `__bridgeResults[callId]`.
637
- */
638
- injectBridgeForOrchestration(ctx, bridge, logs) {
639
- const mcpObj = ctx.newObject();
640
- const callFn = ctx.newFunction("call", (nameHandle, argsHandle) => {
641
- const name = ctx.getString(nameHandle);
642
- const args = ctx.dump(argsHandle) ?? {};
643
- try {
644
- const callId = bridge.enqueue(name, args);
645
- logs.push(`[mcp.call] enqueued ${name}(${JSON.stringify(args)}) → ${callId}`);
646
- return marshalToQuickJS(ctx, {
647
- __bridgeCall: true,
648
- callId
649
- });
650
- } catch (err) {
651
- const errorMsg = err instanceof Error ? err.message : String(err);
652
- logs.push(`[mcp.call] rejected ${name}: ${errorMsg}`);
653
- return marshalToQuickJS(ctx, {
654
- __bridgeCall: false,
655
- error: errorMsg
656
- });
657
- }
658
- });
659
- const listFn = ctx.newFunction("listTools", () => {
660
- return marshalToQuickJS(ctx, bridge.listAvailableTools());
661
- });
662
- ctx.setProp(mcpObj, "call", callFn);
663
- ctx.setProp(mcpObj, "listTools", listFn);
664
- ctx.setProp(ctx.global, "mcp", mcpObj);
665
- callFn.dispose();
666
- listFn.dispose();
667
- mcpObj.dispose();
668
- }
669
- };
670
- //#endregion
671
- //#region src/server/sandbox/MCPBridge.ts
672
- /**
673
- * MCPBridge — Allows sandboxed scripts to invoke host MCP tools.
674
- *
675
- * The bridge wraps `executeToolWithTracking` and is injected as the
676
- * `mcp` global inside QuickJS. It validates tool names against the
677
- * registered tool set before dispatching, preventing arbitrary
678
- * function calls from the sandbox.
679
- */
680
- var MCPBridge = class {
681
- ctx;
682
- allowlist = null;
683
- pendingCalls = [];
684
- constructor(ctx) {
685
- this.ctx = ctx;
686
- }
687
- /**
688
- * Restrict callable tools to a specific set.
689
- * Pass `null` to allow all registered tools (default).
690
- */
691
- setAllowlist(toolNames) {
692
- this.allowlist = toolNames ? new Set(toolNames) : null;
693
- }
694
- /**
695
- * Enqueue a tool call request from the sandbox.
696
- * Returns a unique callId that the sandbox can use to look up the result.
697
- */
698
- enqueue(toolName, args = {}) {
699
- if (!(this.ctx.selectedTools?.map((t) => t.name) ?? []).includes(toolName)) throw new Error(`Tool "${toolName}" is not a registered MCP tool`);
700
- if (this.allowlist && !this.allowlist.has(toolName)) throw new Error(`Tool "${toolName}" is not in the sandbox allowlist`);
701
- const id = randomUUID().slice(0, 8);
702
- this.pendingCalls.push({
703
- id,
704
- toolName,
705
- args
706
- });
707
- return id;
708
- }
709
- /**
710
- * Drain all pending call requests. Returns the queued calls and clears the queue.
711
- */
712
- drainPending() {
713
- const calls = [...this.pendingCalls];
714
- this.pendingCalls.length = 0;
715
- return calls;
716
- }
717
- /**
718
- * Check whether there are pending calls waiting to be resolved.
719
- */
720
- hasPending() {
721
- return this.pendingCalls.length > 0;
722
- }
723
- /**
724
- * Call a registered MCP tool by name.
725
- *
726
- * @throws Error if tool does not exist or is not in the allowlist.
727
- */
728
- async call(toolName, args = {}) {
729
- if (this.allowlist && !this.allowlist.has(toolName)) throw new Error(`Tool "${toolName}" is not in the sandbox allowlist`);
730
- if (!this.listAvailableTools().includes(toolName)) throw new Error(`Tool "${toolName}" is not a registered MCP tool`);
731
- const response = await this.ctx.executeToolWithTracking(toolName, args);
732
- if (response.content && Array.isArray(response.content)) {
733
- const textParts = [];
734
- for (const item of response.content) if (item.type === "text") textParts.push(item.text);
735
- const combined = textParts.join("\n");
736
- try {
737
- return JSON.parse(combined);
738
- } catch {
739
- return combined;
740
- }
741
- }
742
- return response;
743
- }
744
- /**
745
- * Return the names of all tools callable from the sandbox.
746
- */
747
- listAvailableTools() {
748
- const allTools = this.ctx.selectedTools.map((t) => t.name);
749
- if (this.allowlist) return allTools.filter((n) => this.allowlist.has(n));
750
- return allTools;
751
- }
752
- };
753
- //#endregion
754
- //#region src/server/sandbox/SessionScratchpad.ts
755
- /**
756
- * SessionScratchpad — Per-session key/value store for sandbox scripts.
757
- *
758
- * Values persist across script executions within the same session.
759
- * All values are serialized/deserialized via JSON to prevent live
760
- * object references leaking across sandbox contexts.
761
- */
762
- var SessionScratchpad = class {
763
- store = /* @__PURE__ */ new Map();
764
- /**
765
- * Set a value for a key in a session's scratchpad.
766
- * Value is JSON-serialized for safety.
767
- */
768
- set(sessionId, key, value) {
769
- let session = this.store.get(sessionId);
770
- if (!session) {
771
- session = /* @__PURE__ */ new Map();
772
- this.store.set(sessionId, session);
773
- }
774
- session.set(key, JSON.stringify(value));
775
- }
776
- /**
777
- * Get a value by key from a session's scratchpad.
778
- * Returns undefined if key doesn't exist.
779
- */
780
- get(sessionId, key) {
781
- const session = this.store.get(sessionId);
782
- if (!session) return void 0;
783
- const raw = session.get(key);
784
- if (raw === void 0) return void 0;
785
- try {
786
- return JSON.parse(raw);
787
- } catch {
788
- return raw;
789
- }
790
- }
791
- /**
792
- * Get all key/value pairs for a session.
793
- */
794
- getAll(sessionId) {
795
- const session = this.store.get(sessionId);
796
- if (!session) return {};
797
- const result = {};
798
- for (const [k, v] of session) try {
799
- result[k] = JSON.parse(v);
800
- } catch {
801
- result[k] = v;
802
- }
803
- return result;
804
- }
805
- /**
806
- * Get all keys for a session.
807
- */
808
- keys(sessionId) {
809
- const session = this.store.get(sessionId);
810
- if (!session) return [];
811
- return Array.from(session.keys());
812
- }
813
- /**
814
- * Clear all state for a specific session.
815
- */
816
- clear(sessionId) {
817
- this.store.delete(sessionId);
818
- }
819
- /**
820
- * Clear all sessions (server shutdown).
821
- */
822
- clearAll() {
823
- this.store.clear();
824
- }
825
- };
826
- //#endregion
827
- //#region src/server/sandbox/AutoCorrectionLoop.ts
828
- /**
829
- * Execute code in the sandbox with automatic retry on error.
830
- *
831
- * @param sandbox - QuickJSSandbox instance
832
- * @param code - JavaScript source to execute
833
- * @param options - Sandbox execution options
834
- * @param maxRetries - Maximum number of retries (default 2)
835
- * @returns Result from the final execution attempt
836
- */
837
- async function executeWithRetry(sandbox, code, options = {}, maxRetries = 2) {
838
- let lastResult = null;
839
- let currentCode = code;
840
- for (let attempt = 0; attempt <= maxRetries; attempt++) {
841
- lastResult = await sandbox.execute(currentCode, options);
842
- if (lastResult.ok) return {
843
- ...lastResult,
844
- retryCount: attempt
845
- };
846
- if (lastResult.timedOut) return {
847
- ...lastResult,
848
- retryCount: attempt
849
- };
850
- if (attempt < maxRetries) currentCode = `/* Previous error (attempt ${attempt + 1}): ${lastResult.error ?? "unknown error"} */\n${code}`;
851
- }
852
- return {
853
- ...lastResult,
854
- retryCount: maxRetries
855
- };
856
- }
857
- //#endregion
858
- //#region src/server/domains/sandbox/handlers.ts
859
- /**
860
- * SandboxToolHandlers — Handles sandbox domain MCP tool calls.
861
- */
862
- var SandboxToolHandlers = class {
863
- ctx;
864
- scratchpad = new SessionScratchpad();
865
- constructor(ctx) {
866
- this.ctx = ctx;
867
- }
868
- async handleExecuteSandboxScript(args) {
869
- const code = args.code;
870
- const sessionId = args.sessionId ?? void 0;
871
- const timeoutMs = args.timeoutMs ?? void 0;
872
- const autoCorrect = args.autoCorrect ?? false;
873
- if (!code || typeof code !== "string") return { content: [{
874
- type: "text",
875
- text: JSON.stringify({
876
- ok: false,
877
- error: "code parameter is required"
878
- })
879
- }] };
880
- const sandbox = new QuickJSSandbox();
881
- const bridge = new MCPBridge(this.ctx);
882
- sandbox.setBridge(bridge);
883
- const options = {};
884
- if (timeoutMs !== void 0) {
885
- const MAX_TIMEOUT = SANDBOX_MAX_TIMEOUT_MS;
886
- options.timeoutMs = Math.min(Math.max(1, Number.isFinite(timeoutMs) ? timeoutMs : 0), MAX_TIMEOUT);
887
- }
888
- if (sessionId) {
889
- options.sessionId = sessionId;
890
- const scratchpadState = this.scratchpad.getAll(sessionId);
891
- options.globals = {
892
- ...options.globals,
893
- __scratchpad: scratchpadState
894
- };
895
- }
896
- let result;
897
- if (autoCorrect) result = await executeWithRetry(sandbox, code, options);
898
- else result = await sandbox.execute(code, options);
899
- if (sessionId && result.ok && result.output && typeof result.output === "object") {
900
- const output = result.output;
901
- if (output.__scratchpad && typeof output.__scratchpad === "object") for (const [k, v] of Object.entries(output.__scratchpad)) this.scratchpad.set(sessionId, k, v);
902
- }
903
- return { content: [{
904
- type: "text",
905
- text: [
906
- `**Status:** ${result.ok ? "✓ Success" : "✗ Failed"}`,
907
- result.timedOut ? "**Timed out:** yes" : "",
908
- `**Duration:** ${result.durationMs}ms`,
909
- result.logs.length > 0 ? `**Console output:**\n\`\`\`\n${result.logs.join("\n")}\n\`\`\`` : "",
910
- result.output !== void 0 ? `**Result:** ${JSON.stringify(result.output)}` : "",
911
- result.error ? `**Error:** ${result.error}` : ""
912
- ].filter(Boolean).join("\n")
913
- }] };
914
- }
915
- };
916
- //#endregion
917
- export { SandboxToolHandlers };