@cc-monitoring/proxy-core 0.2.3 → 0.3.0

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 (326) hide show
  1. package/dist/docs/404.html +1 -1
  2. package/dist/docs/assets/{app.6_CicOIJ.js → app.Dc46Hlqp.js} +1 -1
  3. package/dist/docs/assets/chunks/{@localSearchIndexroot.CHyuB7c8.js → @localSearchIndexroot.BN6hB8Jr.js} +1 -1
  4. package/dist/docs/assets/chunks/{VPLocalSearchBox.ZMWZsg8z.js → VPLocalSearchBox.Snq5jR6J.js} +1 -1
  5. package/dist/docs/assets/chunks/{theme.BkvhsjzH.js → theme.XLtxGM-l.js} +2 -2
  6. package/dist/docs/index.html +2 -2
  7. package/dist/docs/overview.html +2 -2
  8. package/dist/docs/packages-utils.html +2 -2
  9. package/dist/docs/proxy-admin/env-and-build.html +2 -2
  10. package/dist/docs/proxy-admin/index.html +2 -2
  11. package/dist/docs/proxy-admin/layout-and-menu.html +2 -2
  12. package/dist/docs/proxy-admin/pages.html +2 -2
  13. package/dist/docs/proxy-admin/routing-and-auth.html +2 -2
  14. package/dist/docs/proxy-admin/services-and-mock.html +2 -2
  15. package/dist/docs/proxy-cli/api-layer.html +2 -2
  16. package/dist/docs/proxy-cli/app-shell.html +2 -2
  17. package/dist/docs/proxy-cli/components-common.html +2 -2
  18. package/dist/docs/proxy-cli/components-config.html +2 -2
  19. package/dist/docs/proxy-cli/components-requests.html +2 -2
  20. package/dist/docs/proxy-cli/components-stats.html +2 -2
  21. package/dist/docs/proxy-cli/components-status.html +2 -2
  22. package/dist/docs/proxy-cli/data-hooks.html +2 -2
  23. package/dist/docs/proxy-cli/index.html +2 -2
  24. package/dist/docs/proxy-cli/utils-and-i18n.html +2 -2
  25. package/dist/docs/proxy-core/chat-api.html +2 -2
  26. package/dist/docs/proxy-core/cli.html +2 -2
  27. package/dist/docs/proxy-core/config.html +2 -2
  28. package/dist/docs/proxy-core/data-layer.html +2 -2
  29. package/dist/docs/proxy-core/entry.html +2 -2
  30. package/dist/docs/proxy-core/index.html +2 -2
  31. package/dist/docs/proxy-core/pm2.html +2 -2
  32. package/dist/docs/proxy-core/providers.html +2 -2
  33. package/dist/docs/proxy-core/proxy.html +2 -2
  34. package/dist/docs/proxy-core/stats.html +2 -2
  35. package/dist/docs/proxy-core/tool.html +2 -2
  36. package/dist/docs/proxy-core/ui-routes.html +2 -2
  37. package/dist/docs/proxy-core/utilities.html +2 -2
  38. package/dist/docs/quickstart.html +2 -2
  39. package/dist/docs/request-flow.html +2 -2
  40. package/dist/server/__tests__/server.test.js +9 -1
  41. package/dist/server/__tests__/ui-route.test.js +8 -0
  42. package/dist/server/ui-route.js +113 -7
  43. package/dist/ui/assets/{1c-HTPXddJd.js → 1c-Bx3CHH-I.js} +1 -1
  44. package/dist/ui/assets/{abnf-bINSkl_m.js → abnf-NN4-iXDM.js} +1 -1
  45. package/dist/ui/assets/{abnfDiagram-VRR7QNED-ClDzCbvw.js → abnfDiagram-VRR7QNED-CXFZgDk7.js} +1 -1
  46. package/dist/ui/assets/{accesslog-BAnIWzpe.js → accesslog-Bq9x4vSZ.js} +1 -1
  47. package/dist/ui/assets/{actionscript-DVcm6F_C.js → actionscript-CeaB6gjT.js} +1 -1
  48. package/dist/ui/assets/{ada-Cxn-QX4j.js → ada-DObFDSC6.js} +1 -1
  49. package/dist/ui/assets/{angelscript-BAwAPvBQ.js → angelscript-4pIbuWPH.js} +1 -1
  50. package/dist/ui/assets/{apache-CjjovgUx.js → apache-w0LzP4me.js} +1 -1
  51. package/dist/ui/assets/{applescript-VUcyXoVh.js → applescript-DXpD6Cc9.js} +1 -1
  52. package/dist/ui/assets/{arc-3Nou_aku.js → arc-Dtt1H4m8.js} +1 -1
  53. package/dist/ui/assets/{arcade-Dz2VAk7O.js → arcade-D_zU9Djr.js} +1 -1
  54. package/dist/ui/assets/{architectureDiagram-ZJ3FMSHR-DhwSsCdN.js → architectureDiagram-ZJ3FMSHR-C0E_eQDM.js} +1 -1
  55. package/dist/ui/assets/{arduino-B-Ptb1K1.js → arduino-BnmN_xp_.js} +1 -1
  56. package/dist/ui/assets/{armasm-DU_6qZlW.js → armasm-CH_xJaHf.js} +1 -1
  57. package/dist/ui/assets/{asciidoc-DYbYiWKT.js → asciidoc-BlvZZ-hO.js} +1 -1
  58. package/dist/ui/assets/{aspectj-CmdNkqAs.js → aspectj-DP5DdFKQ.js} +1 -1
  59. package/dist/ui/assets/{autohotkey-if9QUvYo.js → autohotkey-Cy7dy_B1.js} +1 -1
  60. package/dist/ui/assets/{autoit-DGU3G1s6.js → autoit-BmQwjQdM.js} +1 -1
  61. package/dist/ui/assets/{avrasm-1zsEtPJ6.js → avrasm-fcPy4w1X.js} +1 -1
  62. package/dist/ui/assets/{awk-CvmeshSq.js → awk-AlcwGSdk.js} +1 -1
  63. package/dist/ui/assets/{axapta-CbJGb5cN.js → axapta-NyMN6Mvz.js} +1 -1
  64. package/dist/ui/assets/{bash-CFXg_i2e.js → bash-Bn3yyTUs.js} +1 -1
  65. package/dist/ui/assets/{basic-6atic5cT.js → basic-gp9eOjjv.js} +1 -1
  66. package/dist/ui/assets/{blockDiagram-677ZJIJ3-BKXinDkB.js → blockDiagram-677ZJIJ3-BHAadGGo.js} +1 -1
  67. package/dist/ui/assets/{bnf-DydAtPHV.js → bnf-DRAiK-_J.js} +1 -1
  68. package/dist/ui/assets/{brainfuck-CnHx1vO0.js → brainfuck-IYgPavhh.js} +1 -1
  69. package/dist/ui/assets/{coq-BShzwzh7.js → c-Dht0EgwX.js} +1 -1
  70. package/dist/ui/assets/{c-like-XpQV9S6j.js → c-like-B7T39dtK.js} +1 -1
  71. package/dist/ui/assets/{c4Diagram-LMCZKHZV-D5EmWl5d.js → c4Diagram-LMCZKHZV-4cXT8R9f.js} +1 -1
  72. package/dist/ui/assets/{cal-D-orUuBW.js → cal-DmXm_WLX.js} +1 -1
  73. package/dist/ui/assets/{capnproto-TdI6NT8O.js → capnproto-Cb-rKd-Z.js} +1 -1
  74. package/dist/ui/assets/{ceylon-Dji8eqtG.js → ceylon-Bn2aNwEq.js} +1 -1
  75. package/dist/ui/assets/channel-BgAIihW-.js +1 -0
  76. package/dist/ui/assets/{chunk-2Q5K7J3B-CaIvwVWl.js → chunk-2Q5K7J3B-B3N_AddF.js} +1 -1
  77. package/dist/ui/assets/{chunk-32BRIVSS-C7oMpoeu.js → chunk-32BRIVSS-CW7iU3gE.js} +1 -1
  78. package/dist/ui/assets/{chunk-5VM5RSS4-BQ0aVGl-.js → chunk-5VM5RSS4-M8Ep3dJD.js} +1 -1
  79. package/dist/ui/assets/{chunk-EX3LRPZG-D-_EqojZ.js → chunk-EX3LRPZG-t2hCXH-v.js} +1 -1
  80. package/dist/ui/assets/{chunk-JWPE2WC7-B0OLx2rk.js → chunk-JWPE2WC7-rQK8maXo.js} +1 -1
  81. package/dist/ui/assets/{chunk-MOJQB5TN-Be8IXTUE.js → chunk-MOJQB5TN-BpU7vp3L.js} +1 -1
  82. package/dist/ui/assets/{chunk-RYQCIY6F-DceCW2mS.js → chunk-RYQCIY6F-CJVNOulR.js} +1 -1
  83. package/dist/ui/assets/{chunk-V7JOEXUC-Cbhq5qgO.js → chunk-V7JOEXUC-B--maww3.js} +1 -1
  84. package/dist/ui/assets/{chunk-VR4S4FIN-D6WJuaS1.js → chunk-VR4S4FIN-QJ5u9nSh.js} +1 -1
  85. package/dist/ui/assets/{chunk-XXDRQBXY-CKrih4pC.js → chunk-XXDRQBXY-BcM9JOXa.js} +1 -1
  86. package/dist/ui/assets/classDiagram-OUVF2IWQ-0fsnUoNI.js +1 -0
  87. package/dist/ui/assets/classDiagram-v2-EOCWNBFH-0fsnUoNI.js +1 -0
  88. package/dist/ui/assets/{clean-0frlVN_A.js → clean-BCfhFoON.js} +1 -1
  89. package/dist/ui/assets/{clojure-D0q_yQDf.js → clojure-DtnBj8eB.js} +1 -1
  90. package/dist/ui/assets/{clojure-repl-DgYhEzOe.js → clojure-repl-D8X-urCW.js} +1 -1
  91. package/dist/ui/assets/{cmake-WF5tF5xU.js → cmake-BH2RXBgt.js} +1 -1
  92. package/dist/ui/assets/{coffeescript-CyWYgeyv.js → coffeescript-CuoLiQ_d.js} +1 -1
  93. package/dist/ui/assets/{c-DarYnPBd.js → coq-BYVsAo31.js} +1 -1
  94. package/dist/ui/assets/{cos-C5i3_TIB.js → cos-t-cDfrf6.js} +1 -1
  95. package/dist/ui/assets/{cose-bilkent-JH36ORCC-BCwilS6I.js → cose-bilkent-JH36ORCC-CYip_9u7.js} +1 -1
  96. package/dist/ui/assets/{cpp-F1mRQFyw.js → cpp-Cgv0dQ7g.js} +1 -1
  97. package/dist/ui/assets/{crmsh-BAkHUu-B.js → crmsh-7pr1Pq_e.js} +1 -1
  98. package/dist/ui/assets/{crystal-CwUaomfj.js → crystal-BHZFifeV.js} +1 -1
  99. package/dist/ui/assets/{csharp-B1gHIdjK.js → csharp-CVMfBRGF.js} +1 -1
  100. package/dist/ui/assets/{csp-CblCTMvV.js → csp-NEBRDuZY.js} +1 -1
  101. package/dist/ui/assets/{css-CXg7kJV3.js → css-B0fbMkoQ.js} +1 -1
  102. package/dist/ui/assets/{cynefin-VYW2F7L2-BdgMlR5e.js → cynefin-VYW2F7L2-CycR2u2l.js} +1 -1
  103. package/dist/ui/assets/{cynefinDiagram-TSTJHNR4-Bozdux8p.js → cynefinDiagram-TSTJHNR4-CvXYb5em.js} +1 -1
  104. package/dist/ui/assets/{d-Cs5yNCaM.js → d-AzA6F7Ab.js} +1 -1
  105. package/dist/ui/assets/{dagre-VKFMJZFB-tI_mjNMn.js → dagre-VKFMJZFB-6NuSYMRG.js} +1 -1
  106. package/dist/ui/assets/{dart-BqgylVkh.js → dart-D0VXSwKi.js} +1 -1
  107. package/dist/ui/assets/{delphi-CbnfHpIi.js → delphi-B-bkLmCx.js} +1 -1
  108. package/dist/ui/assets/{diagram-FQU43EPY-DmyL3OJT.js → diagram-FQU43EPY-CNNW_5O7.js} +1 -1
  109. package/dist/ui/assets/{diagram-G47NLZAW-BEi9GZlZ.js → diagram-G47NLZAW-C60bRph-.js} +1 -1
  110. package/dist/ui/assets/{diagram-NH7WQ7WH-Bct44Oh1.js → diagram-NH7WQ7WH-CwERNWac.js} +1 -1
  111. package/dist/ui/assets/{diagram-OA4YK3LP-VWAgZxPK.js → diagram-OA4YK3LP-9XSTmf1Z.js} +1 -1
  112. package/dist/ui/assets/{diagram-WEI45ONY-CxcHsE6q.js → diagram-WEI45ONY-h8K41_YA.js} +1 -1
  113. package/dist/ui/assets/{diff-CMJ2hGQW.js → diff-Ch9RlEn8.js} +1 -1
  114. package/dist/ui/assets/{django-Cq_XIhVZ.js → django-C00rhzcB.js} +1 -1
  115. package/dist/ui/assets/{dns-CJs3z6-E.js → dns-C5MKVde0.js} +1 -1
  116. package/dist/ui/assets/{dockerfile-ehs0ogry.js → dockerfile-BpRaVDMB.js} +1 -1
  117. package/dist/ui/assets/{dos-DXOYESf1.js → dos-CjQOJ_vn.js} +1 -1
  118. package/dist/ui/assets/{dsconfig-Cs2hs3Bl.js → dsconfig-3zd3UkyN.js} +1 -1
  119. package/dist/ui/assets/{dts-Dk8yoweb.js → dts-Bb6PtK5T.js} +1 -1
  120. package/dist/ui/assets/{dust-BMK9e-Ss.js → dust-BEJKezIa.js} +1 -1
  121. package/dist/ui/assets/{ebnf-DlyBI5m6.js → ebnf-5-TvfsoC.js} +1 -1
  122. package/dist/ui/assets/{ebnfDiagram-CCIWWBDH-DBp9JHEq.js → ebnfDiagram-CCIWWBDH-CRmIjeas.js} +1 -1
  123. package/dist/ui/assets/{elixir-BThlsblT.js → elixir-B6gSEyen.js} +1 -1
  124. package/dist/ui/assets/{elm-DrmZwmcc.js → elm-rR0aqyyf.js} +1 -1
  125. package/dist/ui/assets/{erDiagram-Q63AITRT-BhK4NKvx.js → erDiagram-Q63AITRT-DS3jYOq8.js} +1 -1
  126. package/dist/ui/assets/{erb-BQM7j3K9.js → erb-DUu22Jxg.js} +1 -1
  127. package/dist/ui/assets/{erlang-CuUaWEXv.js → erlang-C0m-R-6W.js} +1 -1
  128. package/dist/ui/assets/{erlang-repl-DB0uphao.js → erlang-repl-B7O2MhlI.js} +1 -1
  129. package/dist/ui/assets/{excel-DmsuWUss.js → excel-CIqnqFs1.js} +1 -1
  130. package/dist/ui/assets/{fix-D-Uzxpz_.js → fix-Ds9tcTzQ.js} +1 -1
  131. package/dist/ui/assets/{flix-B_7EHWiA.js → flix-ByzuevTB.js} +1 -1
  132. package/dist/ui/assets/{flowDiagram-23GEKE2U-DtMG1G-h.js → flowDiagram-23GEKE2U-B9F3S_Hl.js} +1 -1
  133. package/dist/ui/assets/{fortran-Djp5tH9W.js → fortran-DieSVGx5.js} +1 -1
  134. package/dist/ui/assets/{fsharp-Pj_2ZEa4.js → fsharp-DGP8m6H3.js} +1 -1
  135. package/dist/ui/assets/{gams-B2i3v2ec.js → gams-BiLGBohb.js} +1 -1
  136. package/dist/ui/assets/{ganttDiagram-NO4QXBWP-C7M-JA0W.js → ganttDiagram-NO4QXBWP-CHiCWnJt.js} +1 -1
  137. package/dist/ui/assets/{gauss-DaV8sHLU.js → gauss-Btl1fjJ0.js} +1 -1
  138. package/dist/ui/assets/{gcode-0Jvrh6HY.js → gcode-DWl2YoL_.js} +1 -1
  139. package/dist/ui/assets/{gherkin-DoOl28D6.js → gherkin-D42ESIJ2.js} +1 -1
  140. package/dist/ui/assets/{gitGraphDiagram-IHSO6WYX-D3HB5mow.js → gitGraphDiagram-IHSO6WYX-0pEKZnJg.js} +1 -1
  141. package/dist/ui/assets/{glsl-DEbk7rH5.js → glsl-Dx1QhGIM.js} +1 -1
  142. package/dist/ui/assets/{gml-CBcqXBNV.js → gml-f0noEVTB.js} +1 -1
  143. package/dist/ui/assets/{go-DqesmqF8.js → go-DXT6c-0g.js} +1 -1
  144. package/dist/ui/assets/{golo-9U1oO0b5.js → golo-D3NuJxTg.js} +1 -1
  145. package/dist/ui/assets/{gradle-DZliBXTY.js → gradle-CUsTLc_e.js} +1 -1
  146. package/dist/ui/assets/{groovy-Dys3GQwv.js → groovy-BIkOcIpQ.js} +1 -1
  147. package/dist/ui/assets/{haml-CrtAODl1.js → haml-C5jI7YVN.js} +1 -1
  148. package/dist/ui/assets/{handlebars-CueXuqSj.js → handlebars-UOvbWwDx.js} +1 -1
  149. package/dist/ui/assets/{haskell-CRungOQt.js → haskell-DuO_Av2n.js} +1 -1
  150. package/dist/ui/assets/{haxe-aMz7L4gD.js → haxe-C0Cg5Hjh.js} +1 -1
  151. package/dist/ui/assets/{hsp-Cw75yqGb.js → hsp-CTDajZig.js} +1 -1
  152. package/dist/ui/assets/{htmlbars-e_mpUZNH.js → htmlbars-_ITuCkOs.js} +1 -1
  153. package/dist/ui/assets/{http-Di7E_m1o.js → http-Dr26PHfb.js} +1 -1
  154. package/dist/ui/assets/{hy-CwlvsNj6.js → hy-B-ThgV4T.js} +1 -1
  155. package/dist/ui/assets/index-C0fxlU9d.css +10 -0
  156. package/dist/ui/assets/{index-BdSumlU0.js → index-CpQr158p.js} +3 -3
  157. package/dist/ui/assets/{index-BVM6YOjH.js → index-CwcnuNUs.js} +256 -256
  158. package/dist/ui/assets/{infoDiagram-FWYZ7A6U-_r-6eAzx.js → infoDiagram-FWYZ7A6U-ClKPOdlx.js} +1 -1
  159. package/dist/ui/assets/{inform7-dwg1imm1.js → inform7-D7JYYkX9.js} +1 -1
  160. package/dist/ui/assets/{ini-DEXL1rCA.js → ini-BZwCkFAf.js} +1 -1
  161. package/dist/ui/assets/{irpf90-Ccs_8Sp-.js → irpf90-omMve0rd.js} +1 -1
  162. package/dist/ui/assets/{isbl-B9d1nYmL.js → isbl-C4xosfum.js} +1 -1
  163. package/dist/ui/assets/{ishikawaDiagram-FXEZZL3T-lNCezpU4.js → ishikawaDiagram-FXEZZL3T-PtbNBMgh.js} +1 -1
  164. package/dist/ui/assets/{java-5fv2smM6.js → java-CWjWDe7Q.js} +1 -1
  165. package/dist/ui/assets/{javascript-TAWm0NK8.js → javascript-C3dxrGuA.js} +1 -1
  166. package/dist/ui/assets/{jboss-cli-dM1kcsbR.js → jboss-cli-CJE7m0Y-.js} +1 -1
  167. package/dist/ui/assets/{journeyDiagram-5HDEW3XC-CBYHux8i.js → journeyDiagram-5HDEW3XC-DgK9V4yg.js} +1 -1
  168. package/dist/ui/assets/{json-CtCzm6jF.js → json-DFUiNV7v.js} +1 -1
  169. package/dist/ui/assets/{julia-Co7H3kzk.js → julia-CUTHpx8X.js} +1 -1
  170. package/dist/ui/assets/{julia-repl-BT1ar5VS.js → julia-repl-_ZaQqdrz.js} +1 -1
  171. package/dist/ui/assets/{kanban-definition-HUTT4EX6-B8x8eQyo.js → kanban-definition-HUTT4EX6-BFrDfKdv.js} +1 -1
  172. package/dist/ui/assets/{kotlin-W6mVKIj9.js → kotlin-CrYjQYp8.js} +1 -1
  173. package/dist/ui/assets/{lasso-DJG4luGz.js → lasso-CAiVg9m2.js} +1 -1
  174. package/dist/ui/assets/{latex-DbBOxO7u.js → latex-BkxnXIrT.js} +1 -1
  175. package/dist/ui/assets/{ldif-CVS189JA.js → ldif-CBOqxiN7.js} +1 -1
  176. package/dist/ui/assets/{leaf-eYNiXTKP.js → leaf-CbBZyOGH.js} +1 -1
  177. package/dist/ui/assets/{less-DxhvWM95.js → less-Ca6uLPP0.js} +1 -1
  178. package/dist/ui/assets/{lisp-SC7AwnXC.js → lisp-0Cm7_Bzv.js} +1 -1
  179. package/dist/ui/assets/{livecodeserver-CR2eHihF.js → livecodeserver-B7ka0vFT.js} +1 -1
  180. package/dist/ui/assets/{livescript-DBZ-GaVK.js → livescript-CGmWmcLd.js} +1 -1
  181. package/dist/ui/assets/{llvm-BzURO4tt.js → llvm-DCVMvkrH.js} +1 -1
  182. package/dist/ui/assets/{lsl-DGoJxEUu.js → lsl-PVrTScpn.js} +1 -1
  183. package/dist/ui/assets/{lua-qgG9gdiw.js → lua-BTo3z2Ux.js} +1 -1
  184. package/dist/ui/assets/{makefile-D0kZ6SOe.js → makefile-DJGh9r9C.js} +1 -1
  185. package/dist/ui/assets/{markdown-DRQWgMxk.js → markdown-BOloL-q7.js} +1 -1
  186. package/dist/ui/assets/{mathematica-DIBvZyEZ.js → mathematica-CtMMQM2V.js} +1 -1
  187. package/dist/ui/assets/{matlab-BNg0BR0b.js → matlab-Bfg_AWdR.js} +1 -1
  188. package/dist/ui/assets/{maxima-Bpga3G1G.js → maxima-B2cdS7BY.js} +1 -1
  189. package/dist/ui/assets/{mel-CMOJa9Mg.js → mel-BvfPvpYI.js} +1 -1
  190. package/dist/ui/assets/{mercury-uvrRzupw.js → mercury-B6KgNIai.js} +1 -1
  191. package/dist/ui/assets/{mindmap-definition-LN4V7U3C-DK8j_8Ap.js → mindmap-definition-LN4V7U3C-BkeXo5If.js} +1 -1
  192. package/dist/ui/assets/{mipsasm-p1gWpDuw.js → mipsasm-Csras-cD.js} +1 -1
  193. package/dist/ui/assets/{mizar-DV1ENOOU.js → mizar-C3WDI1-X.js} +1 -1
  194. package/dist/ui/assets/{mojolicious-tg5XQSro.js → mojolicious-MnD2Whic.js} +1 -1
  195. package/dist/ui/assets/{monkey-D8mYa31Q.js → monkey-DLvUPYTI.js} +1 -1
  196. package/dist/ui/assets/{moonscript-1d_rtlyv.js → moonscript-B0XEb3R3.js} +1 -1
  197. package/dist/ui/assets/{n1ql-C5srRxme.js → n1ql-BMRF54sY.js} +1 -1
  198. package/dist/ui/assets/{nginx-xS1muaWm.js → nginx-DqUyeHb8.js} +1 -1
  199. package/dist/ui/assets/{nim-CGGiMQfp.js → nim-3xwg8mOL.js} +1 -1
  200. package/dist/ui/assets/{nix-C77HsR7m.js → nix-ByTkLdcH.js} +1 -1
  201. package/dist/ui/assets/{node-repl-CSeYusSM.js → node-repl-sGSuIUFG.js} +1 -1
  202. package/dist/ui/assets/{nsis-BffC7mSW.js → nsis-Dng5mFSM.js} +1 -1
  203. package/dist/ui/assets/{objectivec-WpjnmlJB.js → objectivec-DSQ8vb7n.js} +1 -1
  204. package/dist/ui/assets/{ocaml-CHUkJkjB.js → ocaml-BHOhEgRu.js} +1 -1
  205. package/dist/ui/assets/{openscad-BvImqFT0.js → openscad-DcUxQ-FQ.js} +1 -1
  206. package/dist/ui/assets/{oxygene-BMBykbf5.js → oxygene-DNlmqhsR.js} +1 -1
  207. package/dist/ui/assets/{parser3-lRbuZW0M.js → parser3-DIR98Q6n.js} +1 -1
  208. package/dist/ui/assets/{pegDiagram-2B236MQR-C4DWmrja.js → pegDiagram-2B236MQR-BrXp_1_9.js} +1 -1
  209. package/dist/ui/assets/{perl-B0DjfKoO.js → perl-16cY7fyu.js} +1 -1
  210. package/dist/ui/assets/{pf-Aor6NyYJ.js → pf-KrAq2BW7.js} +1 -1
  211. package/dist/ui/assets/{pgsql-CVKcjjNR.js → pgsql-BV1Z2bjp.js} +1 -1
  212. package/dist/ui/assets/{php-CZ7geHZt.js → php-FGjYSZqs.js} +1 -1
  213. package/dist/ui/assets/{php-template-DiFuW2dF.js → php-template-B1OW86WT.js} +1 -1
  214. package/dist/ui/assets/{pieDiagram-ENE6RG2P-BO7AmF5j.js → pieDiagram-ENE6RG2P-Bh0bhWSa.js} +1 -1
  215. package/dist/ui/assets/{plaintext-DcvmOuNc.js → plaintext-Cvn_UgSv.js} +1 -1
  216. package/dist/ui/assets/{pony-DGPeAcOc.js → pony-CRWnA3MR.js} +1 -1
  217. package/dist/ui/assets/{powershell-DsrPyJdK.js → powershell-Cwn155MZ.js} +1 -1
  218. package/dist/ui/assets/{processing-Co2VRXN1.js → processing-BS6-1lrQ.js} +1 -1
  219. package/dist/ui/assets/{profile-D4PjpLUf.js → profile-C45OLQrv.js} +1 -1
  220. package/dist/ui/assets/{prolog-DEbkeg9r.js → prolog-C5YafSzY.js} +1 -1
  221. package/dist/ui/assets/{properties-Cxqcuj1s.js → properties-BULd-Zhg.js} +1 -1
  222. package/dist/ui/assets/{protobuf-C-zdlrww.js → protobuf-Qf1IuG5l.js} +1 -1
  223. package/dist/ui/assets/{puppet-BPX3SrOx.js → puppet-93XdQvnn.js} +1 -1
  224. package/dist/ui/assets/{purebasic-BdQnNJS3.js → purebasic-DlYNScQP.js} +1 -1
  225. package/dist/ui/assets/{python-D067_Gj8.js → python-D-Do6-F0.js} +1 -1
  226. package/dist/ui/assets/{python-repl-DCqNVlc0.js → python-repl-DGutP04w.js} +1 -1
  227. package/dist/ui/assets/{q-kABXYW-8.js → q-lmgfrySy.js} +1 -1
  228. package/dist/ui/assets/{qml-Iao-Whg7.js → qml-BbjX_mSU.js} +1 -1
  229. package/dist/ui/assets/{quadrantDiagram-ABIIQ3AL-DetQn-0l.js → quadrantDiagram-ABIIQ3AL-B891FOO8.js} +1 -1
  230. package/dist/ui/assets/{r-BnwpapnO.js → r--x8NzO9N.js} +1 -1
  231. package/dist/ui/assets/{railroadDiagram-RFXS5EU6-DFaFKHAH.js → railroadDiagram-RFXS5EU6-R3O-GKNe.js} +1 -1
  232. package/dist/ui/assets/{reasonml-Cn_Y03uT.js → reasonml-DwHsAflh.js} +1 -1
  233. package/dist/ui/assets/{requirementDiagram-TGXJPOKE-Dg1LrT-T.js → requirementDiagram-TGXJPOKE-D4l_xEXt.js} +1 -1
  234. package/dist/ui/assets/{rib-ByAqQn0v.js → rib-DMJNtDwV.js} +1 -1
  235. package/dist/ui/assets/{roboconf-BJPu6NC5.js → roboconf-BNNGTvHr.js} +1 -1
  236. package/dist/ui/assets/{routeros-CL3Jm0Zq.js → routeros-BF7SVruD.js} +1 -1
  237. package/dist/ui/assets/{rsl-DaXy7KaD.js → rsl-1EHeIZqp.js} +1 -1
  238. package/dist/ui/assets/{ruby-DI6awte_.js → ruby-B-v_BYYp.js} +1 -1
  239. package/dist/ui/assets/{ruleslanguage-DoTVEZE9.js → ruleslanguage-GFeEMSdK.js} +1 -1
  240. package/dist/ui/assets/{rust-ULEd75wO.js → rust-ApqGtMhh.js} +1 -1
  241. package/dist/ui/assets/{sankeyDiagram-HTMAVEWB-DQtFl110.js → sankeyDiagram-HTMAVEWB-Dc-2lhBq.js} +1 -1
  242. package/dist/ui/assets/{sas-f7ATFuJk.js → sas-YkxX6N9_.js} +1 -1
  243. package/dist/ui/assets/{scala-Dha1zro2.js → scala-BpHi86GZ.js} +1 -1
  244. package/dist/ui/assets/{scheme-BcaFHKeF.js → scheme-D889qY8Y.js} +1 -1
  245. package/dist/ui/assets/{scilab-CIiiyD4z.js → scilab-C3l-bcRx.js} +1 -1
  246. package/dist/ui/assets/{scss-CkBomL0n.js → scss-D0iGASxm.js} +1 -1
  247. package/dist/ui/assets/{sequenceDiagram-DBY2YBRQ-DIbNQtCn.js → sequenceDiagram-DBY2YBRQ-DvppgciC.js} +1 -1
  248. package/dist/ui/assets/{shell-Cxu8Py1z.js → shell-PUnaEPCO.js} +1 -1
  249. package/dist/ui/assets/{sizeCapture-X5ZJPWSS-Cj7PglQv.js → sizeCapture-X5ZJPWSS-DhvIbxXs.js} +1 -1
  250. package/dist/ui/assets/{smali-C4EYyWYz.js → smali-Du_dF9hl.js} +1 -1
  251. package/dist/ui/assets/{smalltalk-BlPTprP4.js → smalltalk-CSr2Gc1v.js} +1 -1
  252. package/dist/ui/assets/{sml-DEPzhlr4.js → sml-D3zkvzP2.js} +1 -1
  253. package/dist/ui/assets/{sqf-CRu3asu9.js → sqf-BZQ34qEZ.js} +1 -1
  254. package/dist/ui/assets/{sql-DK-YfQqg.js → sql-BFKScMsf.js} +1 -1
  255. package/dist/ui/assets/{sql_more-BuMEOcjj.js → sql_more-C2Lc_Qqq.js} +1 -1
  256. package/dist/ui/assets/{stan-DMr13kyD.js → stan-CzY8VdxU.js} +1 -1
  257. package/dist/ui/assets/{stata-Bt6E2zQi.js → stata-9GxyhPpV.js} +1 -1
  258. package/dist/ui/assets/{stateDiagram-2N3HPSRC-Bk-gF72D.js → stateDiagram-2N3HPSRC-CM63y6f0.js} +1 -1
  259. package/dist/ui/assets/stateDiagram-v2-6OUMAXLB-OA9dcuA9.js +1 -0
  260. package/dist/ui/assets/{step21-Bi954ur4.js → step21-BpK_Zw3v.js} +1 -1
  261. package/dist/ui/assets/{stylus-CQwwMaLm.js → stylus-DQ4k28M4.js} +1 -1
  262. package/dist/ui/assets/{subunit-BkixDEMH.js → subunit-C6ciOPNF.js} +1 -1
  263. package/dist/ui/assets/{swift-DS1DWNAE.js → swift-CJfqqSbT.js} +1 -1
  264. package/dist/ui/assets/{swimlanes-5IMT3BWC-C-AZKO5z.js → swimlanes-5IMT3BWC-DS6_HNF7.js} +2 -2
  265. package/dist/ui/assets/swimlanesDiagram-G3AALYLV-BLEnJU_R.js +8 -0
  266. package/dist/ui/assets/{taggerscript-DZHi1hoc.js → taggerscript-VouMmJ_v.js} +1 -1
  267. package/dist/ui/assets/{tap-CXxSD8bM.js → tap-wXCy18ot.js} +1 -1
  268. package/dist/ui/assets/{tcl-CdoAAMbn.js → tcl-ewDOmCFX.js} +1 -1
  269. package/dist/ui/assets/{thrift-DM086HVt.js → thrift-BfFA03rE.js} +1 -1
  270. package/dist/ui/assets/{timeline-definition-FHXFAJF6-DcrcjFwq.js → timeline-definition-FHXFAJF6-Dz2m6S6x.js} +1 -1
  271. package/dist/ui/assets/{tp-Y-w3S3ES.js → tp-HGBcpNf9.js} +1 -1
  272. package/dist/ui/assets/{twig-C5c_nAus.js → twig-nrQZ0pw8.js} +1 -1
  273. package/dist/ui/assets/{typescript-fc7SMhJu.js → typescript-B7tNYFEQ.js} +1 -1
  274. package/dist/ui/assets/{vala-BV-GlwLI.js → vala-BIjQtoo6.js} +1 -1
  275. package/dist/ui/assets/{vbnet-BIqQmnKr.js → vbnet-Bbspccm6.js} +1 -1
  276. package/dist/ui/assets/{vbscript-h186Lnrz.js → vbscript-C45_QgOy.js} +1 -1
  277. package/dist/ui/assets/{vbscript-html-DcuP7lTb.js → vbscript-html-DlF2QBc7.js} +1 -1
  278. package/dist/ui/assets/{vennDiagram-L72KCM5P-Dnh11y2e.js → vennDiagram-L72KCM5P-BPEphYtX.js} +1 -1
  279. package/dist/ui/assets/{verilog-Cbgb_XnR.js → verilog-BSitd8W0.js} +1 -1
  280. package/dist/ui/assets/{vhdl-COP7w5IC.js → vhdl-C1bbeiC4.js} +1 -1
  281. package/dist/ui/assets/{vim-COGwKzgS.js → vim-DchwbT8X.js} +1 -1
  282. package/dist/ui/assets/{wardleyDiagram-EHGQE667-BeiD8fPz.js → wardleyDiagram-EHGQE667-BttTCoBT.js} +1 -1
  283. package/dist/ui/assets/{x86asm-BdBqPPf4.js → x86asm-vARxMUvn.js} +1 -1
  284. package/dist/ui/assets/{xl-BmCQT7Vj.js → xl-dx63vvXo.js} +1 -1
  285. package/dist/ui/assets/{xml-DM0NxGiJ.js → xml-BUnj27wL.js} +1 -1
  286. package/dist/ui/assets/{xquery-BUaYHDJM.js → xquery-T7gpnf0e.js} +1 -1
  287. package/dist/ui/assets/{xychartDiagram-FW5EYKEG-CnwvTrkm.js → xychartDiagram-FW5EYKEG-BfrNhdrG.js} +1 -1
  288. package/dist/ui/assets/{yaml-DMs8lGDt.js → yaml-xRgQKzeL.js} +1 -1
  289. package/dist/ui/assets/{zephir-BvjoPdmg.js → zephir-Yu6l5qJj.js} +1 -1
  290. package/dist/ui/index.html +2 -2
  291. package/dist/utils/__tests__/knowledge-store.test.js +86 -5
  292. package/dist/utils/__tests__/pi-browser-tools.test.d.ts +1 -0
  293. package/dist/utils/__tests__/pi-browser-tools.test.js +30 -0
  294. package/dist/utils/__tests__/pi-crawl-tools.test.d.ts +1 -0
  295. package/dist/utils/__tests__/pi-crawl-tools.test.js +315 -0
  296. package/dist/utils/__tests__/pi-dedup-reconcile.test.d.ts +1 -0
  297. package/dist/utils/__tests__/pi-dedup-reconcile.test.js +89 -0
  298. package/dist/utils/__tests__/pi-dedup.test.d.ts +1 -0
  299. package/dist/utils/__tests__/pi-dedup.test.js +106 -0
  300. package/dist/utils/__tests__/pi-learn-orchestrator.test.d.ts +1 -0
  301. package/dist/utils/__tests__/pi-learn-orchestrator.test.js +885 -0
  302. package/dist/utils/__tests__/pi-runtime-json.test.d.ts +1 -0
  303. package/dist/utils/__tests__/pi-runtime-json.test.js +11 -0
  304. package/dist/utils/__tests__/web-crawler.test.d.ts +1 -0
  305. package/dist/utils/__tests__/web-crawler.test.js +69 -0
  306. package/dist/utils/knowledge-store.d.ts +2 -0
  307. package/dist/utils/knowledge-store.js +32 -6
  308. package/dist/utils/pi-browser-tools.d.ts +2 -0
  309. package/dist/utils/pi-browser-tools.js +9 -2
  310. package/dist/utils/pi-crawl-tools.d.ts +62 -0
  311. package/dist/utils/pi-crawl-tools.js +298 -0
  312. package/dist/utils/pi-dedup.d.ts +62 -0
  313. package/dist/utils/pi-dedup.js +218 -0
  314. package/dist/utils/pi-learn-orchestrator.d.ts +44 -0
  315. package/dist/utils/pi-learn-orchestrator.js +431 -0
  316. package/dist/utils/pi-runtime.d.ts +23 -1
  317. package/dist/utils/pi-runtime.js +255 -68
  318. package/dist/utils/web-crawler.d.ts +13 -0
  319. package/dist/utils/web-crawler.js +64 -0
  320. package/package.json +1 -1
  321. package/dist/ui/assets/channel-BdcV3Ykv.js +0 -1
  322. package/dist/ui/assets/classDiagram-OUVF2IWQ-CAZR5rAv.js +0 -1
  323. package/dist/ui/assets/classDiagram-v2-EOCWNBFH-CAZR5rAv.js +0 -1
  324. package/dist/ui/assets/index-WPLwx8h5.css +0 -10
  325. package/dist/ui/assets/stateDiagram-v2-6OUMAXLB-BFJCYsLY.js +0 -1
  326. package/dist/ui/assets/swimlanesDiagram-G3AALYLV-BZd1Gt4_.js +0 -8
@@ -0,0 +1,315 @@
1
+ import { promises as fsp } from 'node:fs';
2
+ import path from 'node:path';
3
+ import os from 'node:os';
4
+ // Mock ego-browser:默认 navigate / close 均经 runEgoBrowser 子进程
5
+ jest.mock('../pi-browser-tools.js', () => ({
6
+ runEgoBrowser: jest.fn(),
7
+ }));
8
+ import { runEgoBrowser } from '../pi-browser-tools.js';
9
+ import { CrawlGuard, createCrawlTools } from '../pi-crawl-tools.js';
10
+ const mockRunEgoBrowser = runEgoBrowser;
11
+ /** 构造一张 url -> 页面 的图;未登记的 URL navigate 抛错(模拟抓取失败) */
12
+ function makeGraphNav(graph) {
13
+ return async (url) => {
14
+ const page = graph[url];
15
+ if (!page)
16
+ throw new Error(`fixture missing: ${url}`);
17
+ return { ...page };
18
+ };
19
+ }
20
+ let tmpDir;
21
+ const docsDir = () => path.join(tmpDir, 'docs');
22
+ beforeEach(async () => {
23
+ tmpDir = await fsp.mkdtemp(path.join(os.tmpdir(), 'crawl-tools-'));
24
+ mockRunEgoBrowser.mockReset();
25
+ });
26
+ afterEach(async () => {
27
+ await fsp.rm(tmpDir, { recursive: true, force: true });
28
+ });
29
+ describe('CrawlGuard.open', () => {
30
+ it('入口页登记为 depth 0 并返回页面信息', async () => {
31
+ const guard = new CrawlGuard({
32
+ entryUrl: 'https://pi.dev/',
33
+ docsDir: docsDir(),
34
+ slug: 'pi',
35
+ navigate: makeGraphNav({
36
+ 'https://pi.dev/': { title: 'Pi', text: 'A text', links: ['https://pi.dev/b'] },
37
+ }),
38
+ });
39
+ const page = await guard.open();
40
+ expect(page).toEqual({
41
+ url: 'https://pi.dev/',
42
+ title: 'Pi',
43
+ text: 'A text',
44
+ links: ['https://pi.dev/b'],
45
+ });
46
+ expect(guard.savedCount).toBe(0);
47
+ });
48
+ it('入口 URL 非法时抛错', async () => {
49
+ const guard = new CrawlGuard({
50
+ entryUrl: 'not a url',
51
+ docsDir: docsDir(),
52
+ slug: 'pi',
53
+ navigate: makeGraphNav({}),
54
+ });
55
+ await expect(guard.open()).rejects.toThrow();
56
+ });
57
+ it('未注入 navigate 时默认走 runEgoBrowser 并解析 JSON', async () => {
58
+ mockRunEgoBrowser.mockResolvedValue(JSON.stringify({ title: 'T', text: 'X', links: ['https://pi.dev/b'] }));
59
+ const guard = new CrawlGuard({ entryUrl: 'https://pi.dev/', docsDir: docsDir(), slug: 'pi' });
60
+ const page = await guard.open();
61
+ expect(page.title).toBe('T');
62
+ expect(page.text).toBe('X');
63
+ expect(page.links).toEqual(['https://pi.dev/b']);
64
+ // 抓取脚本 timeoutMs 60000,URL 以 JSON 字面量注入
65
+ expect(mockRunEgoBrowser).toHaveBeenCalledWith(expect.any(String), { timeoutMs: 60000 });
66
+ expect(mockRunEgoBrowser.mock.calls[0][0]).toContain(JSON.stringify('https://pi.dev/'));
67
+ expect(mockRunEgoBrowser.mock.calls[0][0]).toContain('await task.newPage()');
68
+ });
69
+ it('浏览器输出 JSON parse 失败时抛错', async () => {
70
+ mockRunEgoBrowser.mockResolvedValue('not-json');
71
+ const guard = new CrawlGuard({ entryUrl: 'https://pi.dev/', docsDir: docsDir(), slug: 'pi' });
72
+ await expect(guard.open()).rejects.toThrow(/parse/);
73
+ });
74
+ });
75
+ describe('CrawlGuard.visit', () => {
76
+ let graph;
77
+ beforeEach(() => {
78
+ graph = {
79
+ 'https://pi.dev/': { title: 'A', text: 'A text', links: ['https://pi.dev/b'] },
80
+ 'https://pi.dev/b': { title: 'B', text: 'B text', links: ['https://pi.dev/c'] },
81
+ 'https://pi.dev/c': { title: 'C', text: 'C text', links: [] },
82
+ };
83
+ });
84
+ it('同站子页推进深度(0 → 1),登记状态并返回页面信息', async () => {
85
+ const guard = new CrawlGuard({ entryUrl: 'https://pi.dev/', docsDir: docsDir(), slug: 'pi', navigate: makeGraphNav(graph) });
86
+ await guard.open();
87
+ const page = await guard.visit('https://pi.dev/b');
88
+ expect(page).toEqual({ url: 'https://pi.dev/b', title: 'B', text: 'B text', links: ['https://pi.dev/c'] });
89
+ // 再访问 c:当前深度 1 + 1 = 2 > maxDepth(1) → 拒绝
90
+ await expect(guard.visit('https://pi.dev/c')).rejects.toThrow(/max-depth/);
91
+ });
92
+ it('跨站链接 throw cross-site', async () => {
93
+ graph['https://pi.dev/'].links.push('https://other.com/x');
94
+ const guard = new CrawlGuard({ entryUrl: 'https://pi.dev/', docsDir: docsDir(), slug: 'pi', navigate: makeGraphNav(graph) });
95
+ await guard.open();
96
+ await expect(guard.visit('https://other.com/x')).rejects.toThrow(/cross-site/);
97
+ });
98
+ it('二进制资源链接 throw', async () => {
99
+ graph['https://pi.dev/'].links.push('https://pi.dev/file.pdf');
100
+ const guard = new CrawlGuard({ entryUrl: 'https://pi.dev/', docsDir: docsDir(), slug: 'pi', navigate: makeGraphNav(graph) });
101
+ await guard.open();
102
+ await expect(guard.visit('https://pi.dev/file.pdf')).rejects.toThrow();
103
+ });
104
+ it('已访问(seen,含纯锚点归一)throw seen', async () => {
105
+ const guard = new CrawlGuard({ entryUrl: 'https://pi.dev/', docsDir: docsDir(), slug: 'pi', navigate: makeGraphNav(graph) });
106
+ await guard.open();
107
+ await expect(guard.visit('https://pi.dev/#section')).rejects.toThrow(/seen/);
108
+ });
109
+ it('maxDepth=0 时任何子页 throw max-depth', async () => {
110
+ const guard = new CrawlGuard({ entryUrl: 'https://pi.dev/', docsDir: docsDir(), slug: 'pi', maxDepth: 0, navigate: makeGraphNav(graph) });
111
+ await guard.open();
112
+ await expect(guard.visit('https://pi.dev/b')).rejects.toThrow(/max-depth/);
113
+ });
114
+ it('maxPages=1 时将达页数上限 throw max-pages', async () => {
115
+ const guard = new CrawlGuard({ entryUrl: 'https://pi.dev/', docsDir: docsDir(), slug: 'pi', maxPages: 1, navigate: makeGraphNav(graph) });
116
+ await guard.open();
117
+ await expect(guard.visit('https://pi.dev/b')).rejects.toThrow(/max-pages/);
118
+ });
119
+ it('BFS 深度:A links=[B,E],visit B(d1) 后再 visit E 仍为 d1(线性深度旧实现会误拒)', async () => {
120
+ const bfsGraph = {
121
+ 'https://pi.dev/': { title: 'A', text: 'A text', links: ['https://pi.dev/b', 'https://pi.dev/e'] },
122
+ 'https://pi.dev/b': { title: 'B', text: 'B text', links: [] },
123
+ 'https://pi.dev/e': { title: 'E', text: 'E text', links: [] },
124
+ };
125
+ const guard = new CrawlGuard({ entryUrl: 'https://pi.dev/', docsDir: docsDir(), slug: 'pi', navigate: makeGraphNav(bfsGraph) });
126
+ await guard.open();
127
+ await guard.visit('https://pi.dev/b');
128
+ // E 由入口 A 链接,真实 BFS 深度=1,必须可访问
129
+ const page = await guard.visit('https://pi.dev/e');
130
+ expect(page.url).toBe('https://pi.dev/e');
131
+ const depthByUrl = guard.depthByUrl;
132
+ expect(depthByUrl.get('https://pi.dev/e')).toBe(1);
133
+ });
134
+ it('A links=[B]、B links=[C]:visit B(d1) 后 C 为 d2 > maxDepth,仍 throw max-depth', async () => {
135
+ const chainGraph = {
136
+ 'https://pi.dev/': { title: 'A', text: 'A text', links: ['https://pi.dev/b'] },
137
+ 'https://pi.dev/b': { title: 'B', text: 'B text', links: ['https://pi.dev/c'] },
138
+ 'https://pi.dev/c': { title: 'C', text: 'C text', links: [] },
139
+ };
140
+ const guard = new CrawlGuard({ entryUrl: 'https://pi.dev/', docsDir: docsDir(), slug: 'pi', navigate: makeGraphNav(chainGraph) });
141
+ await guard.open();
142
+ await guard.visit('https://pi.dev/b');
143
+ await expect(guard.visit('https://pi.dev/c')).rejects.toThrow(/max-depth/);
144
+ });
145
+ it('同一页被 d0 和 d1 两个来源链接时,深度取 min=1', async () => {
146
+ const sharedGraph = {
147
+ 'https://pi.dev/': { title: 'A', text: 'A text', links: ['https://pi.dev/b', 'https://pi.dev/e'] },
148
+ 'https://pi.dev/b': { title: 'B', text: 'B text', links: ['https://pi.dev/e'] },
149
+ 'https://pi.dev/e': { title: 'E', text: 'E text', links: [] },
150
+ };
151
+ const guard = new CrawlGuard({ entryUrl: 'https://pi.dev/', docsDir: docsDir(), slug: 'pi', navigate: makeGraphNav(sharedGraph) });
152
+ await guard.open();
153
+ await guard.visit('https://pi.dev/b');
154
+ // E 同时被 A(d0) 和 B(d1) 链接,取最短来源 → d1
155
+ await guard.visit('https://pi.dev/e');
156
+ const depthByUrl = guard.depthByUrl;
157
+ expect(depthByUrl.get('https://pi.dev/e')).toBe(1);
158
+ });
159
+ it('未被任何已抓页链接的同站 URL → throw not linked(不放行幻觉 URL)', async () => {
160
+ const guard = new CrawlGuard({
161
+ entryUrl: 'https://pi.dev/',
162
+ docsDir: docsDir(),
163
+ slug: 'pi',
164
+ navigate: makeGraphNav({ 'https://pi.dev/': { title: 'A', text: 'A text', links: [] } }),
165
+ });
166
+ await guard.open();
167
+ await expect(guard.visit('https://pi.dev/ghost')).rejects.toThrow(/not linked from any crawled page/);
168
+ });
169
+ it('navigate reject 时 seen 不增加:再次 visit 同 URL 不报 seen(失败页不占名额)', async () => {
170
+ const nav = jest.fn(async (url) => {
171
+ if (url === 'https://pi.dev/b')
172
+ throw new Error('nav boom');
173
+ return { title: 'A', text: 'A text', links: ['https://pi.dev/b'] };
174
+ });
175
+ const guard = new CrawlGuard({ entryUrl: 'https://pi.dev/', docsDir: docsDir(), slug: 'pi', navigate: nav });
176
+ await guard.open();
177
+ await expect(guard.visit('https://pi.dev/b')).rejects.toThrow(/nav boom/);
178
+ // 第二次仍因抓取失败报错,而不是 seen;seen 集合保持只有入口
179
+ await expect(guard.visit('https://pi.dev/b')).rejects.toThrow(/nav boom/);
180
+ const seen = guard.seen;
181
+ expect(seen.size).toBe(1);
182
+ });
183
+ });
184
+ describe('CrawlGuard.saveSource', () => {
185
+ it('按 source-NNN.md 落盘,内容含 Source 头,savedCount 递增', async () => {
186
+ const dir = docsDir();
187
+ const guard = new CrawlGuard({
188
+ entryUrl: 'https://pi.dev/',
189
+ docsDir: dir,
190
+ slug: 'pi',
191
+ navigate: makeGraphNav({
192
+ 'https://pi.dev/': { title: 'A', text: 'A text', links: ['https://pi.dev/b'] },
193
+ 'https://pi.dev/b': { title: 'B', text: 'B text', links: [] },
194
+ }),
195
+ });
196
+ await guard.open();
197
+ expect(guard.saveSource('https://pi.dev/')).toEqual({ savedCount: 1, reused: false });
198
+ await guard.visit('https://pi.dev/b');
199
+ expect(guard.saveSource('https://pi.dev/b')).toEqual({ savedCount: 2, reused: false });
200
+ const sourcesDir = path.join(dir, 'pi', 'sources');
201
+ const f1 = await fsp.readFile(path.join(sourcesDir, 'source-001.md'), 'utf8');
202
+ expect(f1).toBe('Source: https://pi.dev/\n\nA text');
203
+ const f2 = await fsp.readFile(path.join(sourcesDir, 'source-002.md'), 'utf8');
204
+ expect(f2).toBe('Source: https://pi.dev/b\n\nB text');
205
+ });
206
+ it('未抓取过的 URL saveSource throw', async () => {
207
+ const guard = new CrawlGuard({
208
+ entryUrl: 'https://pi.dev/',
209
+ docsDir: docsDir(),
210
+ slug: 'pi',
211
+ navigate: makeGraphNav({ 'https://pi.dev/': { title: 'A', text: 'A', links: [] } }),
212
+ });
213
+ await guard.open();
214
+ expect(() => guard.saveSource('https://pi.dev/ghost')).toThrow(/not crawled/);
215
+ });
216
+ it('同页重复 save_source:不写重复文件、reused=true、savedCount 不重复增', async () => {
217
+ const dir = docsDir();
218
+ const guard = new CrawlGuard({
219
+ entryUrl: 'https://pi.dev/',
220
+ docsDir: dir,
221
+ slug: 'pi',
222
+ navigate: makeGraphNav({ 'https://pi.dev/': { title: 'A', text: 'A text', links: [] } }),
223
+ });
224
+ await guard.open();
225
+ const r1 = guard.saveSource('https://pi.dev/');
226
+ const r2 = guard.saveSource('https://pi.dev/');
227
+ expect(r1).toEqual({ savedCount: 1, reused: false });
228
+ expect(r2).toEqual({ savedCount: 1, reused: true });
229
+ expect(guard.savedCount).toBe(1);
230
+ const files = await fsp.readdir(path.join(dir, 'pi', 'sources'));
231
+ expect(files).toEqual(['source-001.md']);
232
+ });
233
+ it('空正文页 saveSource throw empty page', async () => {
234
+ const guard = new CrawlGuard({
235
+ entryUrl: 'https://pi.dev/',
236
+ docsDir: docsDir(),
237
+ slug: 'pi',
238
+ navigate: makeGraphNav({
239
+ 'https://pi.dev/': { title: 'A', text: 'A text', links: ['https://pi.dev/b'] },
240
+ 'https://pi.dev/b': { title: 'B', text: ' \n ', links: [] },
241
+ }),
242
+ });
243
+ await guard.open();
244
+ await guard.visit('https://pi.dev/b');
245
+ expect(() => guard.saveSource('https://pi.dev/b')).toThrow(/empty page/);
246
+ });
247
+ });
248
+ describe('CrawlGuard.close', () => {
249
+ it('no-op:不起 ego-browser 进程,也不抛错', async () => {
250
+ const guard = new CrawlGuard({
251
+ entryUrl: 'https://pi.dev/',
252
+ docsDir: docsDir(),
253
+ slug: 'pi',
254
+ navigate: makeGraphNav({ 'https://pi.dev/': { title: 'A', text: 'A text', links: [] } }),
255
+ });
256
+ await expect(guard.close()).resolves.toBeUndefined();
257
+ expect(mockRunEgoBrowser).not.toHaveBeenCalled();
258
+ });
259
+ });
260
+ describe('CrawlGuard signal 透传', () => {
261
+ it('open/visit 把 abort signal 转发给 runEgoBrowser', async () => {
262
+ mockRunEgoBrowser.mockResolvedValue(JSON.stringify({ title: 'A', text: 'A text', links: ['https://pi.dev/b'] }));
263
+ const guard = new CrawlGuard({ entryUrl: 'https://pi.dev/', docsDir: docsDir(), slug: 'pi' });
264
+ const signal = new AbortController().signal;
265
+ await guard.open(signal);
266
+ expect(mockRunEgoBrowser).toHaveBeenNthCalledWith(1, expect.any(String), { timeoutMs: 60000, signal });
267
+ await guard.visit('https://pi.dev/b', signal);
268
+ expect(mockRunEgoBrowser).toHaveBeenNthCalledWith(2, expect.any(String), { timeoutMs: 60000, signal });
269
+ });
270
+ it('crawl_open/crawl_visit 的 execute 把 signal 透传给 guard.navigate', async () => {
271
+ const nav = jest.fn(async () => ({ title: 'A', text: 'A text', links: ['https://pi.dev/b'] }));
272
+ const guard = new CrawlGuard({ entryUrl: 'https://pi.dev/', docsDir: docsDir(), slug: 'pi', navigate: nav });
273
+ const tools = createCrawlTools(guard);
274
+ const byName = Object.fromEntries(tools.map((t) => [t.name, t]));
275
+ const signal = new AbortController().signal;
276
+ await byName.crawl_open.execute('id-1', {}, signal, undefined, {});
277
+ expect(nav).toHaveBeenNthCalledWith(1, 'https://pi.dev/', signal);
278
+ await byName.crawl_visit.execute('id-2', { url: 'https://pi.dev/b' }, signal, undefined, {});
279
+ expect(nav).toHaveBeenNthCalledWith(2, 'https://pi.dev/b', signal);
280
+ });
281
+ });
282
+ describe('createCrawlTools', () => {
283
+ function makeGuard() {
284
+ return new CrawlGuard({
285
+ entryUrl: 'https://pi.dev/',
286
+ docsDir: docsDir(),
287
+ slug: 'pi',
288
+ navigate: makeGraphNav({
289
+ 'https://pi.dev/': { title: 'A', text: 'A text', links: ['https://pi.dev/b', 'https://other.com/x'] },
290
+ 'https://pi.dev/b': { title: 'B', text: 'B text', links: [] },
291
+ }),
292
+ });
293
+ }
294
+ it('提供 crawl_open/crawl_visit/save_source/crawl_finish 四个工具', () => {
295
+ const tools = createCrawlTools(makeGuard());
296
+ expect(tools.map((t) => t.name)).toEqual(['crawl_open', 'crawl_visit', 'save_source', 'crawl_finish']);
297
+ });
298
+ it('工具错误以可读文本返回(不抛异常)', async () => {
299
+ mockRunEgoBrowser.mockResolvedValue('closed');
300
+ const guard = makeGuard();
301
+ const tools = createCrawlTools(guard);
302
+ const byName = Object.fromEntries(tools.map((t) => [t.name, t]));
303
+ const textOf = (res) => res.content.map((c) => c.text ?? '').join('\n');
304
+ // execute 签名 5 参(id/params/signal/onUpdate/ctx),测试只需前 2 个
305
+ const call = (tool, params) => tool.execute('id', params, undefined, undefined, undefined);
306
+ const openRes = await call(byName.crawl_open, {});
307
+ expect(textOf(openRes)).toContain('https://pi.dev/');
308
+ const badRes = await call(byName.crawl_visit, { url: 'https://other.com/x' });
309
+ expect(textOf(badRes)).toMatch(/error:.*cross-site/);
310
+ const saveRes = await call(byName.save_source, { url: 'https://pi.dev/' });
311
+ expect(textOf(saveRes)).toContain('"savedCount":1');
312
+ const finishRes = await call(byName.crawl_finish, {});
313
+ expect(textOf(finishRes)).toContain('"finished":true');
314
+ });
315
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,89 @@
1
+ jest.mock('../pi-runtime.js', () => ({ runJsonPrompt: jest.fn() }));
2
+ import { mkdtemp, mkdir, writeFile } from 'fs/promises';
3
+ import os from 'os';
4
+ import path from 'path';
5
+ import { runJsonPrompt } from '../pi-runtime.js';
6
+ import { reconcileTopics, readAllTopics, readTopicDetail, mintSlug } from '../pi-dedup.js';
7
+ const mockJson = runJsonPrompt;
8
+ let tmp;
9
+ beforeEach(async () => {
10
+ tmp = await mkdtemp(path.join(os.tmpdir(), 'pi-dedup-'));
11
+ mockJson.mockReset();
12
+ });
13
+ test('预筛命中 → 调 LLM,match=true 透传 targetSlug/mergedTitle/itemsToAdd', async () => {
14
+ mockJson.mockResolvedValue({ match: true, targetSlug: 'a', mergedTitle: 'M', mergedSummary: 's',
15
+ confidence: 0.62, itemsToAdd: [{ id: 'x', title: 'X', oneLine: 'x' }] });
16
+ const r = await reconcileTopics({ port: 1, docsDir: tmp, wantItems: true,
17
+ candidate: { slug: 'new', title: 'React Hooks', tags: [] },
18
+ targets: [{ slug: 'a', title: 'React Hooks', summary: '', tags: [], chunks: [] }] });
19
+ expect(r.match).toBe(true);
20
+ expect(r.targetSlug).toBe('a');
21
+ expect(r.itemsToAdd).toHaveLength(1);
22
+ });
23
+ test('LLM 抛错(坏 JSON)→ 安全返回 match=false', async () => {
24
+ mockJson.mockRejectedValue(new Error('no json object in response'));
25
+ await expect(reconcileTopics({ port: 1, docsDir: tmp, wantItems: false,
26
+ candidate: { slug: 'new', title: 'T', tags: [] },
27
+ targets: [{ slug: 'a', title: 'T', summary: '', tags: [], chunks: [] }] }))
28
+ .resolves.toMatchObject({ match: false });
29
+ });
30
+ test('正载荷回显候选自身 slug(未提供的目标)→ match=false', async () => {
31
+ mockJson.mockResolvedValue({ match: true, targetSlug: 'new', mergedTitle: 'M',
32
+ mergedSummary: 's', itemsToAdd: [] });
33
+ const r = await reconcileTopics({ port: 1, docsDir: tmp, wantItems: true,
34
+ candidate: { slug: 'new', title: 'React Hooks', tags: [] },
35
+ targets: [{ slug: 'a', title: 'React Hooks', summary: '', tags: [], chunks: [] }] });
36
+ expect(r).toEqual({ match: false });
37
+ });
38
+ test('正载荷缺 mergedTitle → match=false', async () => {
39
+ mockJson.mockResolvedValue({ match: true, targetSlug: 'a', mergedSummary: 's', itemsToAdd: [] });
40
+ const r = await reconcileTopics({ port: 1, docsDir: tmp, wantItems: true,
41
+ candidate: { slug: 'new', title: 'React Hooks', tags: [] },
42
+ targets: [{ slug: 'a', title: 'React Hooks', summary: '', tags: [], chunks: [] }] });
43
+ expect(r).toEqual({ match: false });
44
+ });
45
+ test('空目标 → 不调 LLM,match=false', async () => {
46
+ const r = await reconcileTopics({ port: 1, docsDir: tmp, wantItems: false,
47
+ candidate: { slug: 'new', title: 'zzz', tags: [] }, targets: [] });
48
+ expect(r).toEqual({ match: false });
49
+ expect(mockJson).not.toHaveBeenCalled();
50
+ });
51
+ test('预筛空且目标>20 → 不调 LLM,match=false', async () => {
52
+ const targets = Array.from({ length: 21 }, (_, i) => ({ slug: `s${i}`, title: `Distinct ${i}`, summary: '', tags: [], chunks: [] }));
53
+ const r = await reconcileTopics({ port: 1, docsDir: tmp, wantItems: false,
54
+ candidate: { slug: 'new', title: 'zzzz-noise', tags: [] }, targets });
55
+ expect(r.match).toBe(false);
56
+ expect(mockJson).not.toHaveBeenCalled();
57
+ });
58
+ test('readAllTopics: 返回 index.json 的 topics', async () => {
59
+ await writeFile(path.join(tmp, 'index.json'), JSON.stringify({
60
+ topics: [{ slug: 'a', title: 'A', summary: '', tags: [] }],
61
+ }));
62
+ await expect(readAllTopics(tmp)).resolves.toMatchObject([{ slug: 'a', title: 'A' }]);
63
+ });
64
+ test('readAllTopics: 空/缺失目录返回 []', async () => {
65
+ await expect(readAllTopics(tmp)).resolves.toEqual([]);
66
+ });
67
+ describe('mintSlug', () => {
68
+ test('LLM 返回合法且空闲的 slug → 直接使用', async () => {
69
+ mockJson.mockResolvedValue({ slug: 'react-hooks' });
70
+ await expect(mintSlug({ port: 1, title: 'React Hooks', existing: [] })).resolves.toBe('react-hooks');
71
+ });
72
+ test('LLM 返回非法 slug → 降级 slugFromLabel(title)', async () => {
73
+ mockJson.mockResolvedValue({ slug: 'Bad Slug!' });
74
+ await expect(mintSlug({ port: 1, title: 'Hello World', existing: [] })).resolves.toBe('hello-world');
75
+ });
76
+ test('LLM slug 与 slugFromLabel(title) 均被占 → 追加 -2', async () => {
77
+ mockJson.mockResolvedValue({ slug: 'my-topic' });
78
+ await expect(mintSlug({ port: 1, title: 'My Topic', existing: ['my-topic'] }))
79
+ .resolves.toBe('my-topic-2');
80
+ });
81
+ });
82
+ test('readTopicDetail: 返回 <slug>/index.json 解析结果;缺失返回 null', async () => {
83
+ await mkdir(path.join(tmp, 'a'));
84
+ await writeFile(path.join(tmp, 'a', 'index.json'), JSON.stringify({
85
+ slug: 'a', title: 'A', summary: 's', tags: ['t'], chunks: [],
86
+ }));
87
+ await expect(readTopicDetail(tmp, 'a')).resolves.toMatchObject({ slug: 'a', chunks: [] });
88
+ await expect(readTopicDetail(tmp, 'missing')).resolves.toBeNull();
89
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,106 @@
1
+ jest.mock('../pi-runtime.js', () => ({ runJsonPrompt: jest.fn() }));
2
+ import { findCandidates, mergeTopics, assertNoOldDirs } from '../pi-dedup.js';
3
+ import fs from 'node:fs';
4
+ import os from 'node:os';
5
+ import path from 'node:path';
6
+ // ---- mergeTopics / assertNoOldDirs:真实 tmpDir 手工铺盘 ----
7
+ const pad3 = (n) => String(n).padStart(3, '0');
8
+ // 铺一个 topic:sources 为正文数组(按序 source-NNN);chunks 为 { id?, body }
9
+ function layoutTopic(docsDir, slug, opts = {}) {
10
+ const topicDir = path.join(docsDir, slug);
11
+ fs.mkdirSync(path.join(topicDir, 'sources'), { recursive: true });
12
+ fs.mkdirSync(path.join(topicDir, 'chunks'), { recursive: true });
13
+ for (let i = 0; i < (opts.sources ?? []).length; i++) {
14
+ fs.writeFileSync(path.join(topicDir, 'sources', `source-${pad3(i + 1)}.md`), opts.sources[i]);
15
+ }
16
+ const chunks = (opts.chunks ?? []).map((c, i) => {
17
+ const id = c.id ?? `chunk-${pad3(i + 1)}`;
18
+ fs.writeFileSync(path.join(topicDir, 'chunks', `${id}.md`), c.body);
19
+ return { id, title: id, summary: '', tags: [] };
20
+ });
21
+ fs.writeFileSync(path.join(topicDir, 'index.json'), JSON.stringify({ slug, title: slug, summary: '', tags: [], chunks }));
22
+ }
23
+ function writeRoot(docsDir, slugs) {
24
+ fs.writeFileSync(path.join(docsDir, 'index.json'), JSON.stringify({ topics: slugs.map(slug => ({ slug, title: slug, summary: '', tags: [] })) }));
25
+ }
26
+ function freshTmp() {
27
+ return fs.mkdtempSync(path.join(os.tmpdir(), 'pi-dedup-'));
28
+ }
29
+ test('findCandidates: title 归一相等命中并排前', () => {
30
+ const topics = [
31
+ { slug: 'a', title: 'React Hooks', summary: '', tags: [] },
32
+ { slug: 'b', title: 'Other', summary: '', tags: [] },
33
+ ];
34
+ expect(findCandidates({ title: 'react hooks!', tags: [] }, topics).map(t => t.slug)).toEqual(['a']);
35
+ });
36
+ test('findCandidates: tag 相交命中', () => {
37
+ const topics = [{ slug: 'c', title: 'X', summary: '', tags: ['state-management'] }];
38
+ expect(findCandidates({ title: 'zzz', tags: ['State Management'] }, topics)).toHaveLength(1);
39
+ });
40
+ test('findCandidates: 无命中返回 []', () => {
41
+ expect(findCandidates({ title: 'qqq', tags: [] }, [{ slug: 'd', title: 'rrr', summary: '', tags: [] }])).toEqual([]);
42
+ });
43
+ test('mergeTopics: 两边都有 → sources 续号、chunks 重编号、refs 合并、根 index 移除 src', () => {
44
+ const tmp = freshTmp();
45
+ layoutTopic(tmp, 'dsta', { sources: ['dst source'], chunks: [{ body: 'dst chunk' }] });
46
+ layoutTopic(tmp, 'newb', { sources: ['src source'], chunks: [{ body: 'src c1' }, { body: 'src c2' }] });
47
+ writeRoot(tmp, ['dsta', 'newb', 'other']);
48
+ expect(mergeTopics(tmp, 'newb', 'dsta')).toBe(3);
49
+ expect(fs.readdirSync(path.join(tmp, 'dsta', 'sources')).sort())
50
+ .toEqual(['source-001.md', 'source-002.md']);
51
+ expect(fs.readdirSync(path.join(tmp, 'dsta', 'chunks')).sort())
52
+ .toEqual(['chunk-001.md', 'chunk-002.md', 'chunk-003.md']);
53
+ // src 目录已删;根 index 无 newb,其余保留
54
+ expect(fs.existsSync(path.join(tmp, 'newb'))).toBe(false);
55
+ const root = JSON.parse(fs.readFileSync(path.join(tmp, 'index.json'), 'utf8'));
56
+ expect(root.topics.map((t) => t.slug)).toEqual(['dsta', 'other']);
57
+ // refs 已合并进 dst index
58
+ const dstIndex = JSON.parse(fs.readFileSync(path.join(tmp, 'dsta', 'index.json'), 'utf8'));
59
+ expect(dstIndex.chunks.map((c) => c.id))
60
+ .toEqual(['chunk-001', 'chunk-002', 'chunk-003']);
61
+ });
62
+ test('mergeTopics: src 无 chunks(门1)→ 只移 sources,返回 dst 原 chunk 数', () => {
63
+ const tmp = freshTmp();
64
+ layoutTopic(tmp, 'dsta', { sources: ['dst source'], chunks: [{ body: 'dst chunk' }] });
65
+ layoutTopic(tmp, 'newb', { sources: ['src source 1', 'src source 2'] });
66
+ writeRoot(tmp, ['dsta', 'newb']);
67
+ expect(mergeTopics(tmp, 'newb', 'dsta')).toBe(1);
68
+ expect(fs.readdirSync(path.join(tmp, 'dsta', 'chunks')).sort()).toEqual(['chunk-001.md']);
69
+ expect(fs.readdirSync(path.join(tmp, 'dsta', 'sources')).sort())
70
+ .toEqual(['source-001.md', 'source-002.md', 'source-003.md']);
71
+ });
72
+ test('mergeTopics: dst 无 chunks(门0)→ src chunks 从 chunk-001 起重编号并入', () => {
73
+ const tmp = freshTmp();
74
+ layoutTopic(tmp, 'dsta', {});
75
+ layoutTopic(tmp, 'newb', { chunks: [{ body: 'src c1' }, { body: 'src c2' }] });
76
+ writeRoot(tmp, ['dsta', 'newb']);
77
+ expect(mergeTopics(tmp, 'newb', 'dsta')).toBe(2);
78
+ expect(fs.readdirSync(path.join(tmp, 'dsta', 'chunks')).sort())
79
+ .toEqual(['chunk-001.md', 'chunk-002.md']);
80
+ expect(fs.readFileSync(path.join(tmp, 'dsta', 'chunks', 'chunk-001.md'), 'utf8')).toBe('src c1');
81
+ expect(fs.readFileSync(path.join(tmp, 'dsta', 'chunks', 'chunk-002.md'), 'utf8')).toBe('src c2');
82
+ });
83
+ test('mergeTopics: chunk 正文逐字不变(含花括号与换行)', () => {
84
+ const tmp = freshTmp();
85
+ layoutTopic(tmp, 'dsta', { chunks: [{ body: 'dst chunk' }] });
86
+ const body = '{\n "key": "值 {braces}\n换行"\n}\n最后一行\n';
87
+ layoutTopic(tmp, 'newb', { chunks: [{ body }] });
88
+ writeRoot(tmp, ['dsta', 'newb']);
89
+ mergeTopics(tmp, 'newb', 'dsta');
90
+ // src chunk-001 偏移为 dst chunk-002,正文逐字一致
91
+ expect(fs.readFileSync(path.join(tmp, 'dsta', 'chunks', 'chunk-002.md'), 'utf8')).toBe(body);
92
+ });
93
+ test('mergeTopics: src 与 dst 相同 → 抛错防自合并', () => {
94
+ const tmp = freshTmp();
95
+ layoutTopic(tmp, 't', {});
96
+ writeRoot(tmp, ['t']);
97
+ expect(() => mergeTopics(tmp, 't', 't')).toThrow('mergeTopics: src 与 dst 相同');
98
+ });
99
+ test('assertNoOldDirs: 存在 x.old → 抛精确错误;无 → 不抛', () => {
100
+ const withOld = freshTmp();
101
+ fs.mkdirSync(path.join(withOld, 'x.old'));
102
+ expect(() => assertNoOldDirs(withOld)).toThrow('检测到未清理的旁挂目录 x.old,请手工处理后再学习');
103
+ const clean = freshTmp();
104
+ fs.mkdirSync(path.join(clean, 'normal-slug'));
105
+ expect(() => assertNoOldDirs(clean)).not.toThrow();
106
+ });