@jshookmcp/jshook 0.2.9 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (316) hide show
  1. package/README.md +25 -50
  2. package/README.zh.md +25 -48
  3. package/dist/AntiCheatDetector-CGVGNfy5.mjs +1 -0
  4. package/dist/CacheAdapters-CdAxBmVW.mjs +1 -0
  5. package/dist/CodeInjector-BlgyqTOk.mjs +1 -0
  6. package/dist/ConsoleMonitor-Dkqc0HNi.mjs +490 -0
  7. package/dist/DOMInspector-BYY_EJ0C.mjs +95 -0
  8. package/dist/DarwinAPI-DC4HGGLl.mjs +1 -0
  9. package/dist/DetailedDataManager-BniBJlVv.mjs +1 -0
  10. package/dist/EventBus-DgciURGg.mjs +1 -0
  11. package/dist/EvidenceGraphBridge-BIfgB7HP.mjs +1 -0
  12. package/dist/ExtensionManager-erMpqcLk.mjs +1 -0
  13. package/dist/FingerprintManager-N7BZqjxP.mjs +1 -0
  14. package/dist/HardwareBreakpoint-OcJqNFVc.mjs +1 -0
  15. package/dist/HeapAnalyzer-CqAxZzeS.mjs +1 -0
  16. package/dist/{HookGeneratorBuilders.core.generators.storage-CtcdK78Q.mjs → HookGeneratorBuilders.core.generators.storage-Bf1fbrNK.mjs} +66 -174
  17. package/dist/InstrumentationSession-DxXs0sCp.mjs +1 -0
  18. package/dist/MCPServer.search.handlers.domain-DVbWL1bT.mjs +1 -0
  19. package/dist/MemoryController-BaqstM5w.mjs +2 -0
  20. package/dist/MemoryScanSession-CaxAjZJf.mjs +1 -0
  21. package/dist/MemoryScanner-BLYnMJy6.mjs +1 -0
  22. package/dist/NativeMemoryManager.impl-CI554XbY.mjs +1 -0
  23. package/dist/NativeMemoryManager.utils-DM4NC3FE.mjs +1 -0
  24. package/dist/PEAnalyzer-DJyaJTQJ.mjs +1 -0
  25. package/dist/PageController-D9jVkH0i.mjs +1 -0
  26. package/dist/PointerChainEngine-5nF9eNlu.mjs +1 -0
  27. package/dist/PrerequisiteError-Bl3dK8XA.mjs +1 -0
  28. package/dist/ProcessRegistry-Hf12LlR9.mjs +1 -0
  29. package/dist/ResponseBuilder-B2lu4KEl.mjs +1 -0
  30. package/dist/ReverseEvidenceGraph-B931HeoW.mjs +2 -0
  31. package/dist/ScriptManager-fgqiALgj.mjs +7 -0
  32. package/dist/Speedhack-l6s8L2Qw.mjs +1 -0
  33. package/dist/StealthVerifier-Dhbj4B4P.mjs +1 -0
  34. package/dist/StructureAnalyzer-A-WamfYE.mjs +2 -0
  35. package/dist/ToolCatalog-D_IKl1Hu.mjs +1 -0
  36. package/dist/ToolError-DWU_z7gp.mjs +1 -0
  37. package/dist/ToolProbe-xsfALmN3.mjs +1 -0
  38. package/dist/ToolRegistry-B0Zs-phN.mjs +1 -0
  39. package/dist/ToolRouter.policy-CFHoN_Lw.mjs +4 -0
  40. package/dist/TraceRecorder-Dd8jLXpi.mjs +272 -0
  41. package/dist/VersionDetector-DMoUWyNm.mjs +9 -0
  42. package/dist/Win32API-Bhi5xFBe.mjs +1 -0
  43. package/dist/Win32Debug-CQteFL4F.mjs +1 -0
  44. package/dist/WorkflowEngine-CxEp2WXH.mjs +1 -0
  45. package/dist/analysis-BuR-NgX8.mjs +5 -0
  46. package/dist/{antidebug-CqDTB_uk.mjs → antidebug-BOTZH6-0.mjs} +8 -259
  47. package/dist/artifactRetention-NBdncOEW.mjs +1 -0
  48. package/dist/artifacts-B5xQuEa_.mjs +1 -0
  49. package/dist/authorization-schema-B40obG1A.mjs +1 -0
  50. package/dist/betterSqlite3-CGaxz4AX.mjs +1 -0
  51. package/dist/binary-instrument-Cf9qqLlM.mjs +7 -0
  52. package/dist/bind-helpers-BlAOQrFQ.mjs +1 -0
  53. package/dist/boringssl-inspector-BST5vtKx.mjs +2 -0
  54. package/dist/browser-C4Le3xqA.mjs +11 -0
  55. package/dist/capabilities-DbYCv-HF.mjs +1 -0
  56. package/dist/chunk-C_pMuVsO.mjs +1 -0
  57. package/dist/collector-CKO8RPK8.mjs +1 -0
  58. package/dist/concurrency-CcK46d0h.mjs +1 -0
  59. package/dist/constants-Cp6hBrrx.mjs +1 -0
  60. package/dist/coordination-BbijHEHH.mjs +1 -0
  61. package/dist/debugger-CRJq_krh.mjs +1 -0
  62. package/dist/definitions-BGobEDQa.mjs +1 -0
  63. package/dist/definitions-BGwNSkVm.mjs +1 -0
  64. package/dist/definitions-BbxOUiP-.mjs +1 -0
  65. package/dist/definitions-CCP9gphV.mjs +1 -0
  66. package/dist/definitions-CIO9O-Sw.mjs +1 -0
  67. package/dist/definitions-CYFbewnd.mjs +1 -0
  68. package/dist/definitions-CdWEuIkI.mjs +1 -0
  69. package/dist/definitions-CoQFbggH.mjs +1 -0
  70. package/dist/definitions-CuJRsJ6N.mjs +1 -0
  71. package/dist/definitions-DI9YXsJk.mjs +1 -0
  72. package/dist/definitions-DJklW2sS.mjs +1 -0
  73. package/dist/definitions-DZ8uKusP.mjs +1 -0
  74. package/dist/definitions-Dds_zrWx.mjs +1 -0
  75. package/dist/definitions-Dgrg7f3D.mjs +1 -0
  76. package/dist/definitions-DtE0XLrT.mjs +1 -0
  77. package/dist/definitions-LaYTuwQd.mjs +26 -0
  78. package/dist/definitions-NoVp_9Pm.mjs +1 -0
  79. package/dist/definitions-OvGsfxdt.mjs +1 -0
  80. package/dist/definitions-jXPaVy4P.mjs +1 -0
  81. package/dist/encoding-DGcr6Aj_.mjs +2 -0
  82. package/dist/ensure-browser-core-Buls24LQ.mjs +1 -0
  83. package/dist/evidence-graph-bridge-B0yhGPcs.mjs +1 -0
  84. package/dist/factory-Cx_1LorX.mjs +1 -0
  85. package/dist/flat-target-session-CO5g78k3.mjs +1 -0
  86. package/dist/formatAddress-C7j2fDlM.mjs +1 -0
  87. package/dist/graphql-HLf3MS8H.mjs +62 -0
  88. package/dist/handlers-BLMa4X7l.mjs +54 -0
  89. package/dist/handlers-BP12ZsWc.mjs +4 -0
  90. package/dist/handlers-BZoPla6E.mjs +1 -0
  91. package/dist/handlers-BggKiVx9.mjs +2 -0
  92. package/dist/handlers-D3iev8g1.mjs +1 -0
  93. package/dist/handlers-D49r1-1P.mjs +1 -0
  94. package/dist/handlers-DCE45Ww8.mjs +2 -0
  95. package/dist/handlers-DW5AbYs5.mjs +5 -0
  96. package/dist/handlers-De5u62Ga2.mjs +1 -0
  97. package/dist/handlers-DmQzIc44.mjs +31 -0
  98. package/dist/handlers-DnJRGp7t.mjs +302 -0
  99. package/dist/handlers-Dv_runVv.mjs +2 -0
  100. package/dist/handlers-S9Ws0IGy.mjs +2 -0
  101. package/dist/{handlers-Bl8zkwz1.mjs → handlers-pVNpaw4A.mjs} +144 -841
  102. package/dist/handlers.impl-CD2_kOcC.mjs +1 -0
  103. package/dist/hooks-DDKppogd.mjs +600 -0
  104. package/dist/index.mjs +12 -5225
  105. package/dist/logger-sBC6IdRT.mjs +1 -0
  106. package/dist/maintenance-CutEO84j.mjs +1 -0
  107. package/dist/manifest-BFGxlDRh.mjs +123 -0
  108. package/dist/manifest-BPuE6oH2.mjs +1 -0
  109. package/dist/manifest-BXry5N09.mjs +1 -0
  110. package/dist/manifest-BeP_zJGb2.mjs +1 -0
  111. package/dist/manifest-C0g67k6U.mjs +1 -0
  112. package/dist/manifest-C1nZkTkO.mjs +1 -0
  113. package/dist/manifest-C7qV1z7F.mjs +1 -0
  114. package/dist/manifest-CDeUZGUZ.mjs +1 -0
  115. package/dist/manifest-CDiCtaQT.mjs +1 -0
  116. package/dist/manifest-CFn0359q2.mjs +1 -0
  117. package/dist/manifest-CGq4NpqH2.mjs +1 -0
  118. package/dist/manifest-CJMGt7Qy.mjs +1 -0
  119. package/dist/manifest-CRIJq4Hs.mjs +1 -0
  120. package/dist/manifest-C_hEIjSx.mjs +1 -0
  121. package/dist/manifest-CeQmtQOY.mjs +1 -0
  122. package/dist/manifest-Cq0j7GZt.mjs +1 -0
  123. package/dist/manifest-CtPmHAdn.mjs +1 -0
  124. package/dist/manifest-Cx2IVMUY.mjs +1 -0
  125. package/dist/manifest-D16xPXro.mjs +1 -0
  126. package/dist/manifest-D44TaRJU.mjs +1 -0
  127. package/dist/manifest-D610kxZr.mjs +2 -0
  128. package/dist/manifest-DC-SMF6b.mjs +1 -0
  129. package/dist/manifest-DD3rtxvV.mjs +1 -0
  130. package/dist/manifest-DKUorv5M.mjs +1 -0
  131. package/dist/manifest-DMJlcsTR.mjs +1 -0
  132. package/dist/manifest-DWUUWBz0.mjs +1 -0
  133. package/dist/manifest-De-6Wf2R.mjs +1 -0
  134. package/dist/manifest-Dgh0uDW-.mjs +1 -0
  135. package/dist/manifest-Dm0o3i2U.mjs +1 -0
  136. package/dist/manifest-DsVh7Y4U.mjs +1 -0
  137. package/dist/manifest-DtEFSRaq.mjs +1 -0
  138. package/dist/manifest-H-EpAyZQ.mjs +1 -0
  139. package/dist/manifest-ais9Afrw.mjs +1 -0
  140. package/dist/manifest-tmb54wmA.mjs +1 -0
  141. package/dist/manifest-yu2xiQqe.mjs +1 -0
  142. package/dist/manifest-zrbrpKCC.mjs +1 -0
  143. package/dist/matchesWildcardPattern-BGqLSmEs.mjs +1 -0
  144. package/dist/modules-p-PUNv9r.mjs +332 -0
  145. package/dist/mojo-ipc-VGlv3Qyp.mjs +9 -0
  146. package/dist/network-BjZ1Y-GB.mjs +7 -0
  147. package/dist/outputPaths-BonGThuc.mjs +2 -0
  148. package/dist/parse-args-Cuk7-xUt.mjs +1 -0
  149. package/dist/platform-C446Lf97.mjs +93 -0
  150. package/dist/playwright-cdp-fallback-BwVR-_T3.mjs +1 -0
  151. package/dist/process-C9f2A5zk.mjs +962 -0
  152. package/dist/proxy-CvRepxgV.mjs +1 -0
  153. package/dist/registry-DUHIPE-v.mjs +1 -0
  154. package/dist/response-C7rKQst4.mjs +1 -0
  155. package/dist/search-defaults-D2bY-rzH.mjs +1 -0
  156. package/dist/server/plugin-api.mjs +1 -293
  157. package/dist/shared-state-board-Cyg-xh_k.mjs +1 -0
  158. package/dist/sourcemap-D6Q1UuAp.mjs +1 -0
  159. package/dist/ssrf-policy-T96MR3r6.mjs +1 -0
  160. package/dist/streaming-CTX58tbb.mjs +1 -0
  161. package/dist/tool-builder-CI9914Tf.mjs +1 -0
  162. package/dist/transform-Cv9P2vVD.mjs +103 -0
  163. package/dist/types-CuyefmGT.mjs +1 -0
  164. package/dist/types-DtThH00r.mjs +1 -0
  165. package/dist/wasm-DaJa8J0V.mjs +174 -0
  166. package/dist/webcrack-CsLLJIs9.mjs +46 -0
  167. package/dist/workflow-CYIXtrWD.mjs +101 -0
  168. package/package.json +12 -7
  169. package/dist/AntiCheatDetector-BNk-EoBt.mjs +0 -244
  170. package/dist/CacheAdapters-CDe5WPSV.mjs +0 -80
  171. package/dist/CodeInjector-Cq8q01kp.mjs +0 -150
  172. package/dist/ConsoleMonitor-CPVQW1Y-.mjs +0 -2201
  173. package/dist/DarwinAPI-BNPxu0RH.mjs +0 -363
  174. package/dist/DetailedDataManager-BQQcxh64.mjs +0 -217
  175. package/dist/EventBus-DgPmwpeu.mjs +0 -141
  176. package/dist/EvidenceGraphBridge-SFesNera.mjs +0 -153
  177. package/dist/ExtensionManager-CWYgw0YW.mjs +0 -714
  178. package/dist/FingerprintManager-gzWtkKuf.mjs +0 -96
  179. package/dist/HardwareBreakpoint-B9gZCdFP.mjs +0 -239
  180. package/dist/HeapAnalyzer-BLDH0dCv.mjs +0 -284
  181. package/dist/InstrumentationSession-CvPC7Jwy.mjs +0 -244
  182. package/dist/MemoryController-CbVdCIJF.mjs +0 -167
  183. package/dist/MemoryScanSession-BsDZbLYm.mjs +0 -278
  184. package/dist/MemoryScanner-Bcpml6II.mjs +0 -425
  185. package/dist/NativeMemoryManager.impl-dZtA1ZGn.mjs +0 -482
  186. package/dist/NativeMemoryManager.utils-B-FjA2mJ.mjs +0 -165
  187. package/dist/PEAnalyzer-D1lzJ_VG.mjs +0 -385
  188. package/dist/PageController-Bqm2kZ_X.mjs +0 -417
  189. package/dist/PointerChainEngine-BOhyVsjx.mjs +0 -322
  190. package/dist/PrerequisiteError-Dl33Svkz.mjs +0 -20
  191. package/dist/ResponseBuilder-D3iFYx2N.mjs +0 -143
  192. package/dist/ReverseEvidenceGraph-Dlsk94LC.mjs +0 -269
  193. package/dist/ScriptManager-aHHq0X7U.mjs +0 -3000
  194. package/dist/Speedhack-CqdIFlQl.mjs +0 -156
  195. package/dist/StealthVerifier-Bo4T3bz8.mjs +0 -135
  196. package/dist/StructureAnalyzer-DhFaPvRO.mjs +0 -426
  197. package/dist/ToolCatalog-C0JGZoOm.mjs +0 -582
  198. package/dist/ToolError-jh9whhMd.mjs +0 -15
  199. package/dist/ToolProbe-oC7aPrkv.mjs +0 -45
  200. package/dist/ToolRegistry-BjaF4oNz.mjs +0 -131
  201. package/dist/ToolRouter.policy-BWV67ZK-.mjs +0 -304
  202. package/dist/TraceRecorder-DgxyVbdQ.mjs +0 -519
  203. package/dist/VersionDetector-CwVLVdDM.mjs +0 -104
  204. package/dist/Win32API-CePkipZY.mjs +0 -340
  205. package/dist/Win32Debug-BvKs-gxc.mjs +0 -274
  206. package/dist/WorkflowEngine-CuvkZtWu.mjs +0 -598
  207. package/dist/analysis-CL9uACt9.mjs +0 -463
  208. package/dist/artifactRetention-CFEprwPw.mjs +0 -591
  209. package/dist/artifacts-Bk2-_uPq.mjs +0 -59
  210. package/dist/betterSqlite3-0pqusHHH.mjs +0 -74
  211. package/dist/binary-instrument-CXfpx6fT.mjs +0 -979
  212. package/dist/bind-helpers-xFfRF-qm.mjs +0 -22
  213. package/dist/boringssl-inspector-BH2D3VKc.mjs +0 -180
  214. package/dist/browser-BpOr5PEx.mjs +0 -4082
  215. package/dist/chunk-CjcI7cDX.mjs +0 -15
  216. package/dist/concurrency-Bt0yv1kJ.mjs +0 -41
  217. package/dist/constants-B0OANIBL.mjs +0 -519
  218. package/dist/coordination-qUbyF8KU.mjs +0 -259
  219. package/dist/debugger-gnKxRSN0.mjs +0 -1271
  220. package/dist/definitions-6M-eejaT.mjs +0 -53
  221. package/dist/definitions-B18eyf0B.mjs +0 -18
  222. package/dist/definitions-B3QdlrHv.mjs +0 -34
  223. package/dist/definitions-B4rAvHNZ.mjs +0 -63
  224. package/dist/definitions-BB_4jnmy.mjs +0 -37
  225. package/dist/definitions-BMfYXoNC.mjs +0 -43
  226. package/dist/definitions-Beid2EB3.mjs +0 -27
  227. package/dist/definitions-C1UvM5Iy.mjs +0 -126
  228. package/dist/definitions-CXEI7QC72.mjs +0 -216
  229. package/dist/definitions-C_4r7Fo-2.mjs +0 -14
  230. package/dist/definitions-CkFDALoa.mjs +0 -26
  231. package/dist/definitions-Cke7zEb8.mjs +0 -94
  232. package/dist/definitions-ClJLzsJQ.mjs +0 -25
  233. package/dist/definitions-Cq-zroAU.mjs +0 -28
  234. package/dist/definitions-Cy3Sl6gV.mjs +0 -34
  235. package/dist/definitions-D3VsGcvz.mjs +0 -47
  236. package/dist/definitions-DVGfrn7y.mjs +0 -96
  237. package/dist/definitions-LKpC3-nL.mjs +0 -9
  238. package/dist/definitions-bAhHQJq9.mjs +0 -359
  239. package/dist/encoding-Bvz5jLRv.mjs +0 -1065
  240. package/dist/evidence-graph-bridge-C_fv9PuC.mjs +0 -135
  241. package/dist/factory-DxlGh9Xf.mjs +0 -575
  242. package/dist/formatAddress-DVkj9kpI.mjs +0 -17
  243. package/dist/graphql-DYWzJ29s.mjs +0 -1026
  244. package/dist/handlers-9sAbfIg-.mjs +0 -2552
  245. package/dist/handlers-C67ktuRN.mjs +0 -710
  246. package/dist/handlers-C87g8oCe.mjs +0 -276
  247. package/dist/handlers-CTsDAO6p.mjs +0 -681
  248. package/dist/handlers-Cgyg6c0U.mjs +0 -645
  249. package/dist/handlers-D6j6yka7.mjs +0 -2124
  250. package/dist/handlers-DdFzXLvF.mjs +0 -446
  251. package/dist/handlers-DeLOCd5m.mjs +0 -799
  252. package/dist/handlers-DlCJN4Td.mjs +0 -757
  253. package/dist/handlers-DxGIq15_2.mjs +0 -917
  254. package/dist/handlers-U6L4xhuF.mjs +0 -585
  255. package/dist/handlers-tB9Mp9ZK.mjs +0 -84
  256. package/dist/handlers-tiy7EIBp.mjs +0 -572
  257. package/dist/handlers.impl-DS0d9fUw.mjs +0 -761
  258. package/dist/hooks-CzCWByww.mjs +0 -898
  259. package/dist/logger-Dh_xb7_2.mjs +0 -93
  260. package/dist/maintenance-P7ePRXQC.mjs +0 -830
  261. package/dist/manifest-2ToTpjv8.mjs +0 -106
  262. package/dist/manifest-3g71z6Bg.mjs +0 -79
  263. package/dist/manifest-82baTv4U.mjs +0 -45
  264. package/dist/manifest-B3QVVeBS.mjs +0 -82
  265. package/dist/manifest-BB2J8IMJ.mjs +0 -149
  266. package/dist/manifest-BKbgbSiY.mjs +0 -60
  267. package/dist/manifest-Bcf-TJzH.mjs +0 -848
  268. package/dist/manifest-BmtZzQiQ2.mjs +0 -45
  269. package/dist/manifest-Bnd7kqEY.mjs +0 -55
  270. package/dist/manifest-BqQX6OQC2.mjs +0 -65
  271. package/dist/manifest-BqrQ4Tpj.mjs +0 -81
  272. package/dist/manifest-Br4RPFt5.mjs +0 -370
  273. package/dist/manifest-C5qDjysN.mjs +0 -107
  274. package/dist/manifest-C9RT5nk32.mjs +0 -34
  275. package/dist/manifest-CAhOuvSl.mjs +0 -204
  276. package/dist/manifest-CBYWCUBJ.mjs +0 -51
  277. package/dist/manifest-CFADCRa1.mjs +0 -37
  278. package/dist/manifest-CQVhavRF.mjs +0 -114
  279. package/dist/manifest-CT7zZBV1.mjs +0 -48
  280. package/dist/manifest-CV12bcrF.mjs +0 -121
  281. package/dist/manifest-CXsRWjjI.mjs +0 -224
  282. package/dist/manifest-CZLUCfG02.mjs +0 -95
  283. package/dist/manifest-D6phHKFd.mjs +0 -131
  284. package/dist/manifest-DCyjf4n2.mjs +0 -294
  285. package/dist/manifest-DHsnKgP6.mjs +0 -60
  286. package/dist/manifest-Df_dliIe.mjs +0 -55
  287. package/dist/manifest-Dh8WBmEW.mjs +0 -129
  288. package/dist/manifest-DhKRAT8_.mjs +0 -92
  289. package/dist/manifest-DlpTj4ic2.mjs +0 -193
  290. package/dist/manifest-DrbmZcFl2.mjs +0 -253
  291. package/dist/manifest-DuwHjUa5.mjs +0 -70
  292. package/dist/manifest-DzwvxPJX.mjs +0 -38
  293. package/dist/manifest-NXctwWQq.mjs +0 -68
  294. package/dist/manifest-Sc_0JQ13.mjs +0 -418
  295. package/dist/manifest-gZ4s_UtG.mjs +0 -96
  296. package/dist/manifest-qSleDqdO.mjs +0 -1023
  297. package/dist/modules-C184v-S9.mjs +0 -11365
  298. package/dist/mojo-ipc-B_H61Afw.mjs +0 -525
  299. package/dist/network-671Cw6hV.mjs +0 -3346
  300. package/dist/outputPaths-B1uGmrWZ.mjs +0 -1145
  301. package/dist/parse-args-BlRjqlkL.mjs +0 -39
  302. package/dist/platform-WmNn8Sxb.mjs +0 -2070
  303. package/dist/process-QcbIy5Zq.mjs +0 -1401
  304. package/dist/proxy-DqNs0bAd.mjs +0 -170
  305. package/dist/registry-D-6e18lB.mjs +0 -34
  306. package/dist/response-BQVP-xUn.mjs +0 -28
  307. package/dist/shared-state-board-DV-dpHFJ.mjs +0 -586
  308. package/dist/sourcemap-Dq8ez8vS.mjs +0 -650
  309. package/dist/ssrf-policy-ZaUfvhq7.mjs +0 -166
  310. package/dist/streaming-BUQ0VJsg.mjs +0 -725
  311. package/dist/tool-builder-DCbIC5Eo.mjs +0 -186
  312. package/dist/transform-CiYJfNX0.mjs +0 -1007
  313. package/dist/types-Bx92KJfT.mjs +0 -4
  314. package/dist/types-CPhOReNX.mjs +0 -37
  315. package/dist/wasm-DQTnHDs4.mjs +0 -531
  316. package/dist/workflow-f3xJOcjx.mjs +0 -725
@@ -1,598 +0,0 @@
1
- import { t as __exportAll } from "./chunk-CjcI7cDX.mjs";
2
- import { t as logger } from "./logger-Dh_xb7_2.mjs";
3
- import { a as getEffectivePrerequisites, c as getRoutingState } from "./ToolRouter.policy-BWV67ZK-.mjs";
4
- import { randomUUID } from "node:crypto";
5
- //#region src/server/workflows/WorkflowRunStore.ts
6
- var WorkflowRunStore = class {
7
- runs = /* @__PURE__ */ new Map();
8
- lastSuccess = /* @__PURE__ */ new Map();
9
- recordSuccess(result) {
10
- const entry = {
11
- workflowId: result.workflowId,
12
- runId: result.runId,
13
- startedAt: result.startedAt,
14
- finishedAt: result.finishedAt,
15
- durationMs: result.durationMs,
16
- status: "success",
17
- stepResultKeys: Object.keys(result.stepResults)
18
- };
19
- this.runs.set(result.runId, entry);
20
- this.lastSuccess.set(result.workflowId, result);
21
- logger.debug(`workflow run recorded: ${result.runId} (${result.workflowId})`);
22
- }
23
- recordError(workflowId, runId, startedAt, error) {
24
- const entry = {
25
- workflowId,
26
- runId,
27
- startedAt,
28
- finishedAt: (/* @__PURE__ */ new Date()).toISOString(),
29
- durationMs: Date.now() - new Date(startedAt).getTime(),
30
- status: "error",
31
- stepResultKeys: []
32
- };
33
- this.runs.set(runId, entry);
34
- logger.debug(`workflow run error: ${runId} (${workflowId}): ${error}`);
35
- }
36
- getRun(runId) {
37
- return this.runs.get(runId);
38
- }
39
- getLastSuccess(workflowId) {
40
- return this.lastSuccess.get(workflowId);
41
- }
42
- listRuns(workflowId) {
43
- const entries = [...this.runs.values()];
44
- if (workflowId) return entries.filter((e) => e.workflowId === workflowId);
45
- return entries;
46
- }
47
- clear() {
48
- this.runs.clear();
49
- this.lastSuccess.clear();
50
- }
51
- };
52
- //#endregion
53
- //#region src/server/workflows/WorkflowEngine.ts
54
- var WorkflowEngine_exports = /* @__PURE__ */ __exportAll({ executeExtensionWorkflow: () => executeExtensionWorkflow });
55
- /**
56
- * WorkflowDataBus — cross-node data bus for dynamic parameter passing.
57
- *
58
- * Supports expression templates like "${get-requests.scriptId}" to reference
59
- * outputs from previous steps.
60
- */
61
- var WorkflowDataBus = class {
62
- store = /* @__PURE__ */ new Map();
63
- set(key, value) {
64
- this.store.set(key, value);
65
- }
66
- get(key) {
67
- return this.store.get(key);
68
- }
69
- /**
70
- * Get a value at a specific path within a stored object.
71
- * @param key - The key in the store
72
- * @param path - Dot-separated path (e.g., "content.0.text")
73
- */
74
- getValueAtPath(key, path) {
75
- const value = this.store.get(key);
76
- if (!value || typeof value !== "object") return value;
77
- const obj = parseToolPayload(value) || value;
78
- return path.split(".").reduce((current, segment) => {
79
- if (current && typeof current === "object") {
80
- const arrayMatch = segment.match(/^(\d+)$/);
81
- if (arrayMatch && Array.isArray(current)) return current[Number(arrayMatch[1])];
82
- return current[segment];
83
- }
84
- }, obj);
85
- }
86
- /**
87
- * Resolve expression templates like "${stepId.fieldPath}".
88
- * If the value is not an expression, returns it as-is.
89
- */
90
- resolve(template) {
91
- const match = template.match(/^\$\{(.+)\}$/);
92
- if (!match || !match[1]) return template;
93
- const ref = match[1];
94
- const dotIndex = ref.indexOf(".");
95
- if (dotIndex === -1) return this.store.get(ref);
96
- const stepId = ref.slice(0, dotIndex);
97
- const fieldPath = ref.slice(dotIndex + 1);
98
- return this.getValueAtPath(stepId, fieldPath);
99
- }
100
- };
101
- var PreflightError = class extends Error {
102
- constructor(warnings) {
103
- super(`Workflow preflight failed with ${warnings.length} unsatisfied prerequisite(s)`);
104
- this.warnings = warnings;
105
- this.name = "PreflightError";
106
- }
107
- };
108
- const globalRunStore = new WorkflowRunStore();
109
- function extractConfigValue(config, path, fallback) {
110
- const segments = path.split(".").filter(Boolean);
111
- let current = config;
112
- for (const segment of segments) {
113
- if (!current || typeof current !== "object") return fallback;
114
- current = current[segment];
115
- }
116
- return current ?? fallback;
117
- }
118
- function sleep(ms) {
119
- return new Promise((resolve) => setTimeout(resolve, ms));
120
- }
121
- async function withTimeout(promise, timeoutMs, label) {
122
- if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) return promise;
123
- return new Promise((resolve, reject) => {
124
- const timeoutId = setTimeout(() => reject(/* @__PURE__ */ new Error(`${label} timed out after ${timeoutMs}ms`)), timeoutMs);
125
- promise.then((value) => {
126
- clearTimeout(timeoutId);
127
- resolve(value);
128
- }, (error) => {
129
- clearTimeout(timeoutId);
130
- reject(error);
131
- });
132
- });
133
- }
134
- function parseToolPayload(response) {
135
- if (!response || typeof response !== "object") return void 0;
136
- const text = response.content?.find((item) => item.type === "text")?.text;
137
- if (typeof text !== "string") return void 0;
138
- try {
139
- const parsed = JSON.parse(text);
140
- return parsed && typeof parsed === "object" ? parsed : void 0;
141
- } catch {
142
- return;
143
- }
144
- }
145
- function responseIndicatesFailure(response) {
146
- if (!response || typeof response !== "object") return void 0;
147
- if (response.isError) return "Tool returned MCP error response";
148
- const payload = parseToolPayload(response);
149
- if (payload?.success === false) return typeof payload.error === "string" ? payload.error : "Tool reported success=false";
150
- }
151
- function collectSuccessStats(value) {
152
- if (Array.isArray(value)) return value.reduce((acc, item) => {
153
- const next = collectSuccessStats(item);
154
- acc.success += next.success;
155
- acc.failure += next.failure;
156
- return acc;
157
- }, {
158
- success: 0,
159
- failure: 0
160
- });
161
- if (!value || typeof value !== "object") return {
162
- success: 0,
163
- failure: 0
164
- };
165
- const obj = value;
166
- if (Array.isArray(obj["__order"])) return obj["__order"].reduce((acc, key) => {
167
- const next = collectSuccessStats(obj[key]);
168
- acc.success += next.success;
169
- acc.failure += next.failure;
170
- return acc;
171
- }, {
172
- success: 0,
173
- failure: 0
174
- });
175
- const payload = parseToolPayload(value);
176
- if (payload?.success === true) return {
177
- success: 1,
178
- failure: 0
179
- };
180
- /* istanbul ignore next */
181
- if (payload?.success === false) return {
182
- success: 0,
183
- failure: 1
184
- };
185
- if ("error" in value) return {
186
- success: 0,
187
- failure: 1
188
- };
189
- return {
190
- success: 0,
191
- failure: 0
192
- };
193
- }
194
- function resolveInputFrom(mapping, dataBus) {
195
- const resolved = {};
196
- for (const [targetKey, sourceRef] of Object.entries(mapping)) {
197
- const template = sourceRef.startsWith("${") ? sourceRef : `\${${sourceRef}}`;
198
- resolved[targetKey] = dataBus.resolve(template);
199
- }
200
- return resolved;
201
- }
202
- /**
203
- * Recursively resolve expression templates in input values.
204
- * Handles nested objects and arrays.
205
- */
206
- function resolveInputValues(input, dataBus) {
207
- if (!input) return {};
208
- const resolved = {};
209
- for (const [key, value] of Object.entries(input)) resolved[key] = resolveValue(value, dataBus);
210
- return resolved;
211
- }
212
- function resolveValue(value, dataBus) {
213
- if (typeof value === "string") return dataBus.resolve(value);
214
- if (Array.isArray(value)) return value.map((item) => resolveValue(item, dataBus));
215
- if (value && typeof value === "object") {
216
- const resolved = {};
217
- for (const [k, v] of Object.entries(value)) resolved[k] = resolveValue(v, dataBus);
218
- return resolved;
219
- }
220
- return value;
221
- }
222
- async function runToolNode(ctx, node, overrides, executionContext) {
223
- const fromResolved = node.inputFrom ? resolveInputFrom(node.inputFrom, executionContext.dataBus) : {};
224
- const mergedInput = {
225
- ...node.input ? resolveInputValues(node.input, executionContext.dataBus) : {},
226
- ...fromResolved,
227
- ...overrides?.[node.id]
228
- };
229
- const runAttempt = async () => {
230
- const response = await withTimeout(ctx.executeToolWithTracking(node.toolName, mergedInput), node.timeoutMs ?? 0, `Workflow tool node "${node.id}"`);
231
- const failure = responseIndicatesFailure(response);
232
- if (failure) throw new Error(failure);
233
- executionContext.dataBus.set(node.id, response);
234
- return response;
235
- };
236
- const retry = node.retry;
237
- if (!retry) return runAttempt();
238
- let attempt = 0;
239
- let backoffMs = retry.backoffMs;
240
- while (attempt < retry.maxAttempts) try {
241
- return await runAttempt();
242
- } catch (error) {
243
- attempt += 1;
244
- if (attempt >= retry.maxAttempts) throw error;
245
- await sleep(backoffMs);
246
- backoffMs = Math.max(0, Math.floor(backoffMs * (retry.multiplier ?? 1)));
247
- }
248
- throw new Error(`Workflow tool node "${node.id}" exhausted retries`);
249
- }
250
- async function runParallelNode(ctx, node, executionContext, options) {
251
- const concurrency = Math.max(1, node.maxConcurrency ?? 4);
252
- const keyedResults = { __order: [] };
253
- let nextIndex = 0;
254
- let stopped = false;
255
- const worker = async () => {
256
- while (true) {
257
- if (stopped) return;
258
- const currentIndex = nextIndex;
259
- nextIndex += 1;
260
- if (currentIndex >= node.steps.length) return;
261
- const step = node.steps[currentIndex];
262
- /* istanbul ignore next */
263
- if (!step) return;
264
- try {
265
- const result = await executeNode(ctx, step, executionContext, options);
266
- keyedResults[step.id] = result;
267
- keyedResults.__order.push(step.id);
268
- } catch (error) {
269
- if (node.failFast) {
270
- stopped = true;
271
- throw error;
272
- }
273
- keyedResults[step.id] = {
274
- success: false,
275
- error: error instanceof Error ? error.message : String(error)
276
- };
277
- keyedResults.__order.push(step.id);
278
- }
279
- }
280
- };
281
- await Promise.all(Array.from({ length: Math.min(concurrency, node.steps.length) }, () => worker()));
282
- return keyedResults;
283
- }
284
- /**
285
- * Get a variable value from workflow context by key path.
286
- * Supports dot notation for nested access within step results.
287
- */
288
- function getWorkflowVariable(stepResults, keyPath) {
289
- if (stepResults.has(keyPath)) return stepResults.get(keyPath);
290
- const segments = keyPath.split(".");
291
- const stepId = segments[0];
292
- const fieldSegments = segments.slice(1);
293
- if (!stepId || !stepResults.has(stepId)) return;
294
- let current = stepResults.get(stepId);
295
- if (current && typeof current === "object") {
296
- const payload = parseToolPayload(current);
297
- if (payload) current = payload;
298
- }
299
- for (const segment of fieldSegments) if (current && typeof current === "object") {
300
- const arrayMatch = segment.match(/^(\d+)$/);
301
- if (arrayMatch && Array.isArray(current)) {
302
- current = current[Number(arrayMatch[1])];
303
- continue;
304
- }
305
- current = current[segment];
306
- } else return;
307
- return current;
308
- }
309
- async function evaluatePredicate(node, ctx) {
310
- if (node.predicateFn) return await node.predicateFn(ctx);
311
- if (node.predicateId === "always_true") return true;
312
- if (node.predicateId === "always_false") return false;
313
- if (node.predicateId === "any_step_failed") return [...ctx.stepResults.values()].some((value) => collectSuccessStats(value).failure > 0);
314
- const successRateMatch = node.predicateId.match(/success_rate_gte_(\d+)/i);
315
- if (successRateMatch) {
316
- const threshold = Number(successRateMatch[1]);
317
- const aggregate = [...ctx.stepResults.values()].reduce((acc, value) => {
318
- const next = collectSuccessStats(value);
319
- acc.success += next.success;
320
- acc.failure += next.failure;
321
- return acc;
322
- }, {
323
- success: 0,
324
- failure: 0
325
- });
326
- const total = aggregate.success + aggregate.failure;
327
- if (total === 0) return false;
328
- return aggregate.success / total >= threshold / 100;
329
- }
330
- const equalsMatch = node.predicateId.match(/^variable_equals_(.+?)_(.+)$/);
331
- if (equalsMatch && equalsMatch[1] && equalsMatch[2]) {
332
- const keyPath = equalsMatch[1];
333
- const expectedValue = equalsMatch[2];
334
- return deepEquals(getWorkflowVariable(ctx.stepResults, keyPath), expectedValue);
335
- }
336
- const containsMatch = node.predicateId.match(/^variable_contains_(.+?)_(.+)$/);
337
- if (containsMatch && containsMatch[1] && containsMatch[2]) {
338
- const keyPath = containsMatch[1];
339
- const substring = containsMatch[2];
340
- const value = getWorkflowVariable(ctx.stepResults, keyPath);
341
- if (typeof value !== "string" && !Array.isArray(value)) return false;
342
- return String(value).includes(substring);
343
- }
344
- const matchesMatch = node.predicateId.match(/^variable_matches_(.+?)_(.+)$/);
345
- if (matchesMatch && matchesMatch[1] && matchesMatch[2]) {
346
- const keyPath = matchesMatch[1];
347
- const pattern = matchesMatch[2];
348
- const value = getWorkflowVariable(ctx.stepResults, keyPath);
349
- if (typeof value !== "string") return false;
350
- try {
351
- return new RegExp(pattern).test(value);
352
- } catch {
353
- return false;
354
- }
355
- }
356
- throw new Error(`Unknown workflow predicateId "${node.predicateId}"`);
357
- }
358
- /**
359
- * Deep equality check for two values.
360
- */
361
- function deepEquals(a, b) {
362
- if (a === b) return true;
363
- if (typeof a !== typeof b) return false;
364
- if (a && b && typeof a === "object" && typeof b === "object") {
365
- if (Array.isArray(a) !== Array.isArray(b)) return false;
366
- if (Array.isArray(a)) {
367
- const arrA = a;
368
- const arrB = b;
369
- return arrA.length === arrB.length && arrA.every((v, i) => deepEquals(v, arrB[i]));
370
- }
371
- const keysA = Object.keys(a);
372
- const keysB = Object.keys(b);
373
- if (keysA.length !== keysB.length) return false;
374
- return keysA.every((key) => deepEquals(a[key], b[key]));
375
- }
376
- return false;
377
- }
378
- async function executeNode(ctx, node, executionContext, options) {
379
- executionContext.emitSpan("workflow.node.start", {
380
- nodeId: node.id,
381
- kind: node.kind
382
- });
383
- let result;
384
- switch (node.kind) {
385
- case "tool":
386
- result = await runToolNode(ctx, node, options.nodeInputOverrides, executionContext);
387
- break;
388
- case "sequence": {
389
- const sequenceNode = node;
390
- const items = [];
391
- for (const step of sequenceNode.steps) items.push(await executeNode(ctx, step, executionContext, options));
392
- result = items;
393
- break;
394
- }
395
- case "parallel":
396
- result = await runParallelNode(ctx, node, executionContext, options);
397
- break;
398
- case "branch": {
399
- const branchNode = node;
400
- const selected = await evaluatePredicate(branchNode, executionContext) ? branchNode.whenTrue : branchNode.whenFalse;
401
- if (selected) result = await executeNode(ctx, selected, executionContext, options);
402
- else result = void 0;
403
- break;
404
- }
405
- case "fallback": {
406
- const fallbackNode = node;
407
- try {
408
- result = await executeNode(ctx, fallbackNode.primary, executionContext, options);
409
- } catch (error) {
410
- executionContext.emitSpan("workflow.node.fallback", {
411
- nodeId: fallbackNode.id,
412
- primaryNodeId: fallbackNode.primary.id,
413
- fallbackNodeId: fallbackNode.fallback.id,
414
- error: error instanceof Error ? error.message : String(error)
415
- });
416
- result = await executeNode(ctx, fallbackNode.fallback, executionContext, options);
417
- }
418
- break;
419
- }
420
- default: throw new Error(`Unsupported workflow node kind: ${node.kind}`);
421
- }
422
- executionContext.stepResults.set(node.id, result);
423
- executionContext.emitSpan("workflow.node.finish", {
424
- nodeId: node.id,
425
- kind: node.kind
426
- });
427
- return result;
428
- }
429
- /** Recursively collect all ToolNode instances from a workflow graph. */
430
- function collectToolNodes(node) {
431
- switch (node.kind) {
432
- case "tool": return [node];
433
- case "sequence":
434
- case "parallel": return node.steps.flatMap((step) => collectToolNodes(step));
435
- case "branch": return [...collectToolNodes(node.whenTrue), ...node.whenFalse ? collectToolNodes(node.whenFalse) : []];
436
- case "fallback": {
437
- const fallbackNode = node;
438
- return [...collectToolNodes(fallbackNode.primary), ...collectToolNodes(fallbackNode.fallback)];
439
- }
440
- default: return [];
441
- }
442
- }
443
- /**
444
- * Collect unsatisfied prerequisites for all tool nodes in the workflow graph.
445
- * Returns an array of warnings (not errors — preflight is warn-only mode).
446
- */
447
- function getEvidenceState(ctx) {
448
- try {
449
- const evidenceGraph = ctx.getDomainInstance("evidenceGraph");
450
- return evidenceGraph ? {
451
- hasGraph: true,
452
- nodeCount: evidenceGraph.nodeCount,
453
- edgeCount: evidenceGraph.edgeCount
454
- } : {
455
- hasGraph: false,
456
- nodeCount: 0,
457
- edgeCount: 0
458
- };
459
- } catch {
460
- return {
461
- hasGraph: false,
462
- nodeCount: 0,
463
- edgeCount: 0
464
- };
465
- }
466
- }
467
- function collectUnsatisfiedPrerequisites(graph, routingState) {
468
- const prerequisites = getEffectivePrerequisites();
469
- const warnings = [];
470
- for (const toolNode of collectToolNodes(graph)) {
471
- const toolPrerequisites = prerequisites[toolNode.toolName] ?? [];
472
- for (const prerequisite of toolPrerequisites) {
473
- if (prerequisite.check(routingState)) continue;
474
- warnings.push({
475
- nodeId: toolNode.id,
476
- toolName: toolNode.toolName,
477
- condition: prerequisite.condition,
478
- fix: prerequisite.fix
479
- });
480
- }
481
- }
482
- return warnings;
483
- }
484
- async function executeExtensionWorkflow(ctx, workflow, options = {}) {
485
- const runId = randomUUID();
486
- const profile = options.profile ?? String(ctx.baseTier ?? "workflow");
487
- const startedAt = (/* @__PURE__ */ new Date()).toISOString();
488
- const startedAtMs = Date.now();
489
- const metrics = [];
490
- const spans = [];
491
- const stepResults = /* @__PURE__ */ new Map();
492
- const dataBus = new WorkflowDataBus();
493
- const mergedConfig = options.config ? {
494
- ...ctx.config,
495
- ...options.config
496
- } : ctx.config;
497
- const executionContext = {
498
- workflowRunId: runId,
499
- profile,
500
- stepResults,
501
- dataBus,
502
- invokeTool(toolName, args) {
503
- return ctx.executeToolWithTracking(toolName, args);
504
- },
505
- emitSpan(name, attrs) {
506
- spans.push({
507
- name,
508
- attrs,
509
- at: (/* @__PURE__ */ new Date()).toISOString()
510
- });
511
- },
512
- emitMetric(name, value, type, attrs) {
513
- metrics.push({
514
- name,
515
- value,
516
- type,
517
- attrs,
518
- at: (/* @__PURE__ */ new Date()).toISOString()
519
- });
520
- },
521
- getConfig(path, fallback) {
522
- return extractConfigValue(mergedConfig, path, fallback);
523
- }
524
- };
525
- try {
526
- await workflow.onStart?.(executionContext);
527
- const graph = workflow.build(executionContext);
528
- const preflightMode = options.preflightMode ?? "warn";
529
- let preflightWarnings = [];
530
- if (preflightMode === "skip") executionContext.emitSpan("workflow.preflight", {
531
- mode: preflightMode,
532
- skipped: true,
533
- evidenceState: getEvidenceState(ctx),
534
- warningCount: 0
535
- });
536
- else try {
537
- const routingState = await getRoutingState(ctx);
538
- const evidenceState = getEvidenceState(ctx);
539
- preflightWarnings = collectUnsatisfiedPrerequisites(graph, routingState);
540
- executionContext.emitSpan("workflow.preflight", {
541
- mode: preflightMode,
542
- routingState,
543
- evidenceState,
544
- warningCount: preflightWarnings.length,
545
- warnings: preflightWarnings
546
- });
547
- if (preflightMode === "strict" && preflightWarnings.length > 0) throw new PreflightError(preflightWarnings);
548
- } catch (error) {
549
- if (error instanceof PreflightError) throw error;
550
- executionContext.emitSpan("workflow.preflight", {
551
- mode: preflightMode,
552
- warningCount: 0,
553
- skipped: true,
554
- error: error instanceof Error ? error.message : String(error),
555
- evidenceState: getEvidenceState(ctx)
556
- });
557
- }
558
- const result = await withTimeout(executeNode(ctx, graph, executionContext, options), options.timeoutMs ?? workflow.timeoutMs ?? 0, `Workflow "${workflow.id}"`);
559
- await workflow.onFinish?.(executionContext, result);
560
- try {
561
- const evidenceGraph = typeof ctx.getDomainInstance === "function" ? ctx.getDomainInstance("evidenceGraph") : void 0;
562
- if (evidenceGraph && evidenceGraph.nodeCount > 0) {
563
- stepResults.set("__evidenceSnapshot", evidenceGraph.exportJson());
564
- executionContext.emitSpan("workflow.evidence.auto-export", {
565
- nodeCount: evidenceGraph.nodeCount,
566
- edgeCount: evidenceGraph.edgeCount
567
- });
568
- }
569
- } catch (exportError) {
570
- executionContext.emitSpan("workflow.evidence.auto-export", {
571
- skipped: true,
572
- error: exportError instanceof Error ? exportError.message : String(exportError)
573
- });
574
- }
575
- const runResult = {
576
- workflowId: workflow.id,
577
- displayName: workflow.displayName,
578
- runId,
579
- profile,
580
- startedAt,
581
- finishedAt: (/* @__PURE__ */ new Date()).toISOString(),
582
- durationMs: Date.now() - startedAtMs,
583
- result,
584
- stepResults: Object.fromEntries(stepResults.entries()),
585
- metrics,
586
- spans
587
- };
588
- globalRunStore.recordSuccess(runResult);
589
- return runResult;
590
- } catch (error) {
591
- const workflowError = error instanceof Error ? error : new Error(String(error));
592
- globalRunStore.recordError(workflow.id, runId, startedAt, workflowError);
593
- await workflow.onError?.(executionContext, workflowError);
594
- throw workflowError;
595
- }
596
- }
597
- //#endregion
598
- export { executeExtensionWorkflow as n, WorkflowEngine_exports as t };