openclaw-multi-auto 1.5.1 → 1.5.4

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 (301) hide show
  1. package/dist/{accounts-L9ByEpnP.js → accounts-C9HcPI9h.js} +2 -2
  2. package/dist/{accounts-BOzyfwW4.js → accounts-C_lW3Ag9.js} +2 -2
  3. package/dist/{accounts-yfBeCZtS.js → accounts-Tgelvk0C.js} +17 -17
  4. package/dist/{active-listener-D1yqT1cw.js → active-listener-BEdprTkn.js} +2 -2
  5. package/dist/{api-key-rotation-DtsNS2Nb.js → api-key-rotation-BJpKWXy0.js} +2 -2
  6. package/dist/{audio-preflight-DoPfNXDz.js → audio-preflight-BMvgEQ5j.js} +32 -32
  7. package/dist/{audio-preflight-5FEeDooz.js → audio-preflight-DDBLZBdb.js} +4 -4
  8. package/dist/{audio-transcription-runner-B-UvoDjZ.js → audio-transcription-runner-DZbSWT9E.js} +1 -1
  9. package/dist/{audio-transcription-runner-CzjuH3uL.js → audio-transcription-runner-gLFfz8fr.js} +12 -12
  10. package/dist/{audit-membership-runtime-DWyHWAHM.js → audit-membership-runtime-Dntemq07.js} +4 -4
  11. package/dist/build-info.json +3 -3
  12. package/dist/bundled/boot-md/handler.js +51 -51
  13. package/dist/bundled/bootstrap-extra-files/handler.js +6 -6
  14. package/dist/bundled/command-logger/handler.js +2 -2
  15. package/dist/bundled/session-memory/handler.js +51 -51
  16. package/dist/canvas-host/a2ui/.bundle.hash +1 -1
  17. package/dist/{channel-activity-xHOMiarp.js → channel-activity-BDnjYF7B.js} +3 -3
  18. package/dist/{chrome-D45SyhQL.js → chrome-CMU2WVFh.js} +8 -8
  19. package/dist/{chrome-DlhJHqj8.js → chrome-DxxEKrY7.js} +26 -26
  20. package/dist/{commands-registry-V1zZ5pPC.js → commands-registry-D5qXbFJn.js} +4 -4
  21. package/dist/{deliver-B9cys0EZ.js → deliver-BXVcFIHL.js} +1 -1
  22. package/dist/{deliver-CApVJA_l.js → deliver-DbdywYJE.js} +21 -21
  23. package/dist/deliver-runtime-BFs7iAZF.js +36 -0
  24. package/dist/{deliver-runtime-DhaQJ0pI.js → deliver-runtime-DTaIS-1i.js} +3 -3
  25. package/dist/deps-send-discord.runtime-DZUccI6Z.js +26 -0
  26. package/dist/deps-send-imessage.runtime-CF3OpoqY.js +25 -0
  27. package/dist/deps-send-signal.runtime-Cw4-ozeO.js +24 -0
  28. package/dist/deps-send-slack.runtime-BDsDhS1P.js +22 -0
  29. package/dist/deps-send-telegram.runtime-D_4xVasO.js +27 -0
  30. package/dist/{deps-send-whatsapp.runtime-DvTL2tzN.js → deps-send-whatsapp.runtime-CIZqFAqb.js} +7 -7
  31. package/dist/deps-send-whatsapp.runtime-DK8jqd14.js +60 -0
  32. package/dist/{diagnostic-Bn4PZjMZ.js → diagnostic-Co6Kghr-.js} +2 -2
  33. package/dist/{errors-CCLeFWAg.js → errors-xt401nuk.js} +1 -1
  34. package/dist/extensionAPI.js +6 -6
  35. package/dist/{fetch-BlJWzEP6.js → fetch-DuraYswo.js} +5 -5
  36. package/dist/{fetch-guard-ChYBwfiy.js → fetch-guard-DWr0d00H.js} +2 -2
  37. package/dist/{frontmatter-CvaMP376.js → frontmatter-BkTfEZ93.js} +3 -3
  38. package/dist/{fs-safe-0jAo_Whb.js → fs-safe-CTYUrIgQ.js} +4 -4
  39. package/dist/{github-copilot-token-D13V9YBz.js → github-copilot-token-BDioPmd6.js} +7 -7
  40. package/dist/{image-DAOPwVXi.js → image-BCVLo0qw.js} +1 -1
  41. package/dist/{image-B3Mz7N5I.js → image-eT7Y-nP5.js} +6 -6
  42. package/dist/{image-ops-CehkHxmW.js → image-ops-BuUnEOE0.js} +2 -2
  43. package/dist/image-runtime-BcAK3n8a.js +29 -0
  44. package/dist/{image-runtime-wlCLVvVv.js → image-runtime-DtCKpMPZ.js} +3 -3
  45. package/dist/{ir-DAP-B-Xw.js → ir-B83looB-.js} +8 -8
  46. package/dist/{legacy-names-TyzbVqa_.js → legacy-names-DOC03BkU.js} +1 -1
  47. package/dist/llm-slug-generator.js +51 -51
  48. package/dist/{logger-DMZQQtxK.js → logger-BfjWMCSD.js} +7 -7
  49. package/dist/{login-DiCctRo1.js → login-CrIwcrVI.js} +5 -5
  50. package/dist/{login-qr-MUbXgjtd.js → login-qr-BpPDZdl_.js} +10 -10
  51. package/dist/{manager-BW_NSIMl.js → manager-1bvuGrNR.js} +13 -13
  52. package/dist/manager-runtime-FO1Sx3W8.js +18 -0
  53. package/dist/{model-selection-idoqPmw0.js → model-selection-Dna0Gz1k.js} +43 -43
  54. package/dist/{outbound-C2kanETZ.js → outbound-ChDjtuD6.js} +6 -6
  55. package/dist/{outbound-attachment-DBrYWX8h.js → outbound-attachment-DqHlD21U.js} +2 -2
  56. package/dist/{path-alias-guards-DqXRZmsL.js → path-alias-guards-BzvdLvTI.js} +1 -1
  57. package/dist/{paths-CCxysrzL.js → paths-Bkr-BCxW.js} +4 -4
  58. package/dist/{paths-C6TxBCvO.js → paths-Cvc9EM8Y.js} +5 -5
  59. package/dist/{pi-embedded-bcjMe3wj.js → pi-embedded-BQQa91aA.js} +167 -167
  60. package/dist/{pi-embedded-DYU79yGe.js → pi-embedded-CgQ_W6Xs.js} +24 -24
  61. package/dist/{pi-embedded-helpers-D5yyGEvA.js → pi-embedded-helpers-CLXm10bV.js} +52 -52
  62. package/dist/{pi-embedded-helpers-uTRAmQ4n.js → pi-embedded-helpers-CwuBTKza.js} +3 -3
  63. package/dist/{pi-model-discovery-BGgOlX8N.js → pi-model-discovery-Dymwdjt0.js} +7 -7
  64. package/dist/pi-model-discovery-runtime-BeY4EUPp.js +11 -0
  65. package/dist/{pi-tools.before-tool-call.runtime-BuLxSyx9.js → pi-tools.before-tool-call.runtime-Cwab_5W1.js} +9 -9
  66. package/dist/plugin-sdk/{accounts-C3m65--E.js → accounts-BJAXxY46.js} +2 -2
  67. package/dist/plugin-sdk/{accounts-CNCCkdEF.js → accounts-C1j7HSL0.js} +3 -3
  68. package/dist/plugin-sdk/{accounts-BslAlVYS.js → accounts-DyFCXtHv.js} +2 -2
  69. package/dist/plugin-sdk/{active-listener-CkPnMUkB.js → active-listener-CftX5jLD.js} +2 -2
  70. package/dist/plugin-sdk/{api-key-rotation-BXnNsojA.js → api-key-rotation-8nyyt1kx.js} +2 -2
  71. package/dist/plugin-sdk/{audio-preflight-CtO4fFvp.js → audio-preflight-C_aSAPR1.js} +26 -26
  72. package/dist/plugin-sdk/{audio-transcription-runner-DnxvOS1-.js → audio-transcription-runner-CB53F7_7.js} +11 -11
  73. package/dist/plugin-sdk/{audit-membership-runtime-BpfoSk8M.js → audit-membership-runtime-BXndI4LG.js} +2 -2
  74. package/dist/plugin-sdk/{channel-activity-WJYxcJ3S.js → channel-activity-C5y8AgAV.js} +3 -3
  75. package/dist/plugin-sdk/{channel-web-dO5k3ubM.js → channel-web-DBTRO03V.js} +18 -18
  76. package/dist/plugin-sdk/{chrome-CjNTuJML.js → chrome-f00sZkDX.js} +6 -6
  77. package/dist/plugin-sdk/{commands-registry-CdYjoI0i.js → commands-registry-BJ_NxG2F.js} +4 -4
  78. package/dist/plugin-sdk/{common-oYc5vPFl.js → common-Cf27Jwxu.js} +2 -2
  79. package/dist/plugin-sdk/{config-B1z-UxQ3.js → config-CHQrpx-Q.js} +7 -7
  80. package/dist/plugin-sdk/{deliver-D5_6T567.js → deliver-DNEuetST.js} +10 -10
  81. package/dist/plugin-sdk/deliver-runtime-BFdqklJM.js +32 -0
  82. package/dist/plugin-sdk/deps-send-discord.runtime-DuqpYwU0.js +23 -0
  83. package/dist/plugin-sdk/deps-send-imessage.runtime-CZ2rS8Lb.js +22 -0
  84. package/dist/plugin-sdk/deps-send-signal.runtime-BdqiWhIh.js +21 -0
  85. package/dist/plugin-sdk/deps-send-slack.runtime-04s36qiC.js +19 -0
  86. package/dist/plugin-sdk/deps-send-telegram.runtime-LE5tkPvr.js +24 -0
  87. package/dist/plugin-sdk/deps-send-whatsapp.runtime-Bz57lobC.js +57 -0
  88. package/dist/plugin-sdk/{diagnostic-Bxxu0ig-.js → diagnostic-LYUUmjJ5.js} +2 -2
  89. package/dist/plugin-sdk/{errors-B3cHyZZA.js → errors-CtMWwS2Z.js} +1 -1
  90. package/dist/plugin-sdk/{fetch-guard-Dcgod0tg.js → fetch-guard-CxYB5Kg6.js} +2 -2
  91. package/dist/plugin-sdk/{fs-safe-BaKqI3G4.js → fs-safe-DtfhxbrI.js} +3 -3
  92. package/dist/plugin-sdk/{image-B2mQW9Rb.js → image-BwjYjRHx.js} +6 -6
  93. package/dist/plugin-sdk/{image-ops-Cbzr4U9l.js → image-ops-BnZKcbd6.js} +2 -2
  94. package/dist/plugin-sdk/image-runtime-B8twoubs.js +25 -0
  95. package/dist/plugin-sdk/{ir-ZEmrTr4J.js → ir-Z4hX67TJ.js} +7 -7
  96. package/dist/plugin-sdk/{local-roots-CIPRxA-4.js → local-roots-KhjQw04O.js} +4 -4
  97. package/dist/plugin-sdk/{logger-CvPFVOgT.js → logger-DHIIvMxj.js} +2 -2
  98. package/dist/plugin-sdk/{login-CCTew9bt.js → login-C31642Ld.js} +4 -4
  99. package/dist/plugin-sdk/{login-qr-BI3Vi_wJ.js → login-qr--y2SG_Ue.js} +5 -5
  100. package/dist/plugin-sdk/{manager-BEoYPn7R.js → manager-2UZBMCc7.js} +8 -8
  101. package/dist/plugin-sdk/manager-runtime-CMeLwose.js +15 -0
  102. package/dist/plugin-sdk/mattermost.js +3 -3
  103. package/dist/plugin-sdk/{outbound-ByOw1K6W.js → outbound-Ba0QUI5h.js} +5 -5
  104. package/dist/plugin-sdk/{outbound-attachment-BzVhxRRw.js → outbound-attachment-B1Laso-8.js} +2 -2
  105. package/dist/plugin-sdk/{path-alias-guards-sWayacde.js → path-alias-guards-C7Vm5DZ1.js} +1 -1
  106. package/dist/plugin-sdk/{paths-Dpg3qxcl.js → paths-DopV9PQG.js} +1 -1
  107. package/dist/plugin-sdk/{pi-embedded-helpers-DIxXkGJf.js → pi-embedded-helpers-DnA_OCzP.js} +16 -16
  108. package/dist/plugin-sdk/{pi-model-discovery-DM_2uFtj.js → pi-model-discovery-DdPqXk8f.js} +1 -1
  109. package/dist/plugin-sdk/pi-model-discovery-runtime-D8CJhtJY.js +8 -0
  110. package/dist/plugin-sdk/{pi-tools.before-tool-call.runtime-w1dqL_ty.js → pi-tools.before-tool-call.runtime-DxFHiLUE.js} +4 -4
  111. package/dist/plugin-sdk/{plugins-C4USiH29.js → plugins-CbCt4osF.js} +4 -4
  112. package/dist/plugin-sdk/{proxy-env-ET-rp8eg.js → proxy-env-C63mMdas.js} +1 -1
  113. package/dist/{proxy-fetch-CCjEYbFm.js → plugin-sdk/proxy-fetch-Ch95c_Y2.js} +1 -1
  114. package/dist/plugin-sdk/{pw-ai-CyOt3RDA.js → pw-ai-DpJk62D4.js} +9 -9
  115. package/dist/plugin-sdk/{qmd-manager-BySdoVR7.js → qmd-manager-Ca-iSfEE.js} +7 -7
  116. package/dist/plugin-sdk/{query-expansion-C6uS-7lj.js → query-expansion-B_Xe41Ab.js} +4 -4
  117. package/dist/plugin-sdk/{redact-Bvxt1T_Q.js → redact-hp9TOulW.js} +1 -1
  118. package/dist/plugin-sdk/{reply-CTCSeQqW.js → reply-CovBlFea.js} +73 -73
  119. package/dist/plugin-sdk/{resolve-outbound-target-Bw8YNANu.js → resolve-outbound-target-BbrHgyUk.js} +2 -2
  120. package/dist/plugin-sdk/{run-with-concurrency-C_KCHwvf.js → run-with-concurrency-BR1DXa8T.js} +1 -1
  121. package/dist/plugin-sdk/runtime-whatsapp-login.runtime-SkO91TZH.js +10 -0
  122. package/dist/plugin-sdk/runtime-whatsapp-outbound.runtime-B0VWK5hm.js +19 -0
  123. package/dist/plugin-sdk/{send-C0w6xP2x.js → send-BTztm3D2.js} +6 -6
  124. package/dist/plugin-sdk/{send-qPyNGSe4.js → send-BXpXBwM_.js} +13 -13
  125. package/dist/plugin-sdk/{send-BZ6nYFZr.js → send-BvAtLLPl.js} +5 -5
  126. package/dist/plugin-sdk/{send-CFf-1V89.js → send-CWJUuG0i.js} +8 -8
  127. package/dist/plugin-sdk/{send-CY-Qfwia.js → send-EcglC4cG.js} +7 -7
  128. package/dist/plugin-sdk/{session-COrvpvUQ.js → session-k256LJZT.js} +3 -3
  129. package/dist/plugin-sdk/{skill-commands-DZqhtmiv.js → skill-commands-DoRqLzxm.js} +4 -4
  130. package/dist/plugin-sdk/{skills-Cw_vXEJb.js → skills-QudILG6e.js} +6 -6
  131. package/dist/plugin-sdk/slash-commands.runtime-DS6vCNSL.js +13 -0
  132. package/dist/plugin-sdk/slash-dispatch.runtime-BXrxb2wd.js +52 -0
  133. package/dist/plugin-sdk/slash-skill-commands.runtime-Bd6qQ2oT.js +16 -0
  134. package/dist/plugin-sdk/{store-CMHj6IIw.js → store-BbDQw3g6.js} +2 -2
  135. package/dist/plugin-sdk/subagent-registry-runtime-1uwQbuXj.js +52 -0
  136. package/dist/plugin-sdk/{tables-CSqrHsKL.js → tables-BhvloMKN.js} +1 -1
  137. package/dist/plugin-sdk/{thinking-DOnsR_A8.js → thinking-URzkT-3p.js} +7 -7
  138. package/dist/plugin-sdk/{tokens-BDr0Z9o3.js → tokens-B1PW5Ayy.js} +1 -1
  139. package/dist/plugin-sdk/{tool-images-eEfOVkzf.js → tool-images-xpqbP6RR.js} +2 -2
  140. package/dist/plugin-sdk/web-B74yhL2N.js +56 -0
  141. package/dist/plugin-sdk/{whatsapp-actions-xcleMoMv.js → whatsapp-actions-RcZ6vp61.js} +17 -17
  142. package/dist/plugin-sdk/whatsapp.js +50 -50
  143. package/dist/{plugins-CWkRQYDj.js → plugins-4Rj4OjLY.js} +11 -11
  144. package/dist/{proxy-env-Cq5gdrbj.js → proxy-env-DlmzDx8x.js} +1 -1
  145. package/dist/{plugin-sdk/proxy-fetch-uDXGKG3Z.js → proxy-fetch-B2pEfjbR.js} +1 -1
  146. package/dist/{pw-ai-GcYO6HPE.js → pw-ai-CmphSzHx.js} +1 -1
  147. package/dist/{pw-ai-CDQDCfUa.js → pw-ai-DNMjFMqH.js} +14 -14
  148. package/dist/{qmd-manager-BsYsO9Ii.js → qmd-manager-BtIKUaO9.js} +10 -10
  149. package/dist/{query-expansion-DtLc3wjL.js → query-expansion-CX-1fS52.js} +6 -6
  150. package/dist/{redact-ClbcYG1J.js → redact-COik8ET1.js} +1 -1
  151. package/dist/{run-with-concurrency-D_ZpbgEG.js → run-with-concurrency-BgYfgkXT.js} +4 -4
  152. package/dist/runtime-whatsapp-login.runtime-DUb55byQ.js +13 -0
  153. package/dist/runtime-whatsapp-outbound.runtime-Bii_xSfI.js +22 -0
  154. package/dist/{send-Dx2RkUOZ.js → send-6lz6rNVP.js} +6 -6
  155. package/dist/{send-vmONuVgL.js → send-BHTiZcH3.js} +26 -26
  156. package/dist/{send-Bj776ESJ.js → send-L7gRiwyd.js} +7 -7
  157. package/dist/{send-DcxmcFi_.js → send-PE6cwoTe.js} +8 -8
  158. package/dist/{send-BQERFNyo.js → send-dfu6_rgf.js} +5 -5
  159. package/dist/{session-A4QhBRvH.js → session-D8ImowSs.js} +8 -8
  160. package/dist/{skill-commands-CMzBZKG2.js → skill-commands-DNqJ-kwn.js} +9 -9
  161. package/dist/{skills-CE_iqvM5.js → skills-7ODkHQYp.js} +22 -22
  162. package/dist/slash-commands.runtime-CVw6566g.js +16 -0
  163. package/dist/{slash-dispatch.runtime-Dh053pQK.js → slash-dispatch.runtime-131yup2e.js} +6 -6
  164. package/dist/slash-dispatch.runtime-B9Ygtzi4.js +56 -0
  165. package/dist/slash-skill-commands.runtime-DxZ4z5h6.js +20 -0
  166. package/dist/{store--eR1R_UX.js → store-D89wDcz9.js} +2 -2
  167. package/dist/subagent-registry-runtime-DL1Wv7nA.js +56 -0
  168. package/dist/{subagent-registry-runtime-DSi5mnCQ.js → subagent-registry-runtime-DbSf_Je6.js} +6 -6
  169. package/dist/{subsystem-Di1z8l0Z.js → subsystem-B45WV3qB.js} +14 -14
  170. package/dist/{tables-d739Y1xW.js → tables-mE4cJBN2.js} +1 -1
  171. package/dist/{target-errors-CBI2Ga0y.js → target-errors-mnlwhAjP.js} +2 -2
  172. package/dist/{thinking-DXYisHiZ.js → thinking-BeGmb5k6.js} +7 -7
  173. package/dist/{tokens-DxnY9ui_.js → tokens-q32vI39c.js} +1 -1
  174. package/dist/{tool-images-2cBx1W8h.js → tool-images-RZdHiZcG.js} +2 -2
  175. package/dist/{web-NWKn8ABz.js → web-Btj-e8kN.js} +55 -55
  176. package/dist/{web-1hWJDzNA.js → web-MR9d7KyB.js} +6 -6
  177. package/dist/{whatsapp-actions-iEArE_Ez.js → whatsapp-actions-BHbJJyqw.js} +21 -21
  178. package/dist/{workspace-CUVC6GX1.js → workspace-U-DyR64O.js} +20 -20
  179. package/package.json +1 -1
  180. package/scripts/create-instance.sh +1 -37
  181. package/scripts/npm_publish.sh +0 -65
  182. package/scripts/npm_publish_backup.sh +185 -0
  183. package/dist/deliver-runtime-D1z-h5eg.js +0 -36
  184. package/dist/deps-send-discord.runtime-DnbhTFX9.js +0 -26
  185. package/dist/deps-send-imessage.runtime-BOiQ6mDx.js +0 -25
  186. package/dist/deps-send-signal.runtime-CTcl388M.js +0 -24
  187. package/dist/deps-send-slack.runtime-CCqBz4Kg.js +0 -22
  188. package/dist/deps-send-telegram.runtime-DGSKTCpH.js +0 -27
  189. package/dist/deps-send-whatsapp.runtime-Dz_4fi2D.js +0 -60
  190. package/dist/image-runtime-DWjhow2W.js +0 -29
  191. package/dist/manager-runtime-BN6VevdC.js +0 -18
  192. package/dist/pi-model-discovery-runtime-Bwmi4Ev8.js +0 -11
  193. package/dist/plugin-sdk/deliver-runtime-C5dgvvga.js +0 -32
  194. package/dist/plugin-sdk/deps-send-discord.runtime-Dg4N7PHJ.js +0 -23
  195. package/dist/plugin-sdk/deps-send-imessage.runtime-0OEwzMQm.js +0 -22
  196. package/dist/plugin-sdk/deps-send-signal.runtime-BM1jRt3G.js +0 -21
  197. package/dist/plugin-sdk/deps-send-slack.runtime-1E3BYRdF.js +0 -19
  198. package/dist/plugin-sdk/deps-send-telegram.runtime-DNCxIflA.js +0 -24
  199. package/dist/plugin-sdk/deps-send-whatsapp.runtime-OLwr-9c8.js +0 -57
  200. package/dist/plugin-sdk/image-runtime-BFm45j49.js +0 -25
  201. package/dist/plugin-sdk/manager-runtime-DxclHQ4U.js +0 -15
  202. package/dist/plugin-sdk/pi-model-discovery-runtime-BuzvkvNR.js +0 -8
  203. package/dist/plugin-sdk/runtime-whatsapp-login.runtime-BxgRDkhc.js +0 -10
  204. package/dist/plugin-sdk/runtime-whatsapp-outbound.runtime-elOqrkfg.js +0 -19
  205. package/dist/plugin-sdk/slash-commands.runtime-D67JLweo.js +0 -13
  206. package/dist/plugin-sdk/slash-dispatch.runtime-DvcpvCJ0.js +0 -52
  207. package/dist/plugin-sdk/slash-skill-commands.runtime-BM1x3azR.js +0 -16
  208. package/dist/plugin-sdk/subagent-registry-runtime-1lbDyRzz.js +0 -52
  209. package/dist/plugin-sdk/web-BLyT64pW.js +0 -56
  210. package/dist/runtime-whatsapp-login.runtime-IeylZEl4.js +0 -13
  211. package/dist/runtime-whatsapp-outbound.runtime-ClBRuLsq.js +0 -22
  212. package/dist/slash-commands.runtime-Cpn2tYW4.js +0 -16
  213. package/dist/slash-dispatch.runtime-CWbpp23S.js +0 -56
  214. package/dist/slash-skill-commands.runtime-DKMvvdDW.js +0 -20
  215. package/dist/subagent-registry-runtime-DEVpAaAP.js +0 -56
  216. package/extensions/page-action-cache/dist/actions-executor.d.ts +0 -62
  217. package/extensions/page-action-cache/dist/actions-executor.d.ts.map +0 -1
  218. package/extensions/page-action-cache/dist/actions-executor.js +0 -339
  219. package/extensions/page-action-cache/dist/actions-executor.js.map +0 -1
  220. package/extensions/page-action-cache/dist/cache-invalidator.d.ts +0 -70
  221. package/extensions/page-action-cache/dist/cache-invalidator.d.ts.map +0 -1
  222. package/extensions/page-action-cache/dist/cache-invalidator.js +0 -212
  223. package/extensions/page-action-cache/dist/cache-invalidator.js.map +0 -1
  224. package/extensions/page-action-cache/dist/cache-store.d.ts +0 -80
  225. package/extensions/page-action-cache/dist/cache-store.d.ts.map +0 -1
  226. package/extensions/page-action-cache/dist/cache-store.js +0 -361
  227. package/extensions/page-action-cache/dist/cache-store.js.map +0 -1
  228. package/extensions/page-action-cache/dist/cache-strategy.d.ts +0 -65
  229. package/extensions/page-action-cache/dist/cache-strategy.d.ts.map +0 -1
  230. package/extensions/page-action-cache/dist/cache-strategy.js +0 -237
  231. package/extensions/page-action-cache/dist/cache-strategy.js.map +0 -1
  232. package/extensions/page-action-cache/dist/hooks-entry.d.ts +0 -18
  233. package/extensions/page-action-cache/dist/hooks-entry.d.ts.map +0 -1
  234. package/extensions/page-action-cache/dist/hooks-entry.js +0 -27
  235. package/extensions/page-action-cache/dist/hooks-entry.js.map +0 -1
  236. package/extensions/page-action-cache/dist/hooks.d.ts +0 -10
  237. package/extensions/page-action-cache/dist/hooks.d.ts.map +0 -1
  238. package/extensions/page-action-cache/dist/hooks.js +0 -277
  239. package/extensions/page-action-cache/dist/hooks.js.map +0 -1
  240. package/extensions/page-action-cache/dist/index.d.ts +0 -24
  241. package/extensions/page-action-cache/dist/index.d.ts.map +0 -1
  242. package/extensions/page-action-cache/dist/index.js +0 -34
  243. package/extensions/page-action-cache/dist/index.js.map +0 -1
  244. package/extensions/page-action-cache/dist/scenario-recognizer.d.ts +0 -45
  245. package/extensions/page-action-cache/dist/scenario-recognizer.d.ts.map +0 -1
  246. package/extensions/page-action-cache/dist/scenario-recognizer.js +0 -213
  247. package/extensions/page-action-cache/dist/scenario-recognizer.js.map +0 -1
  248. package/extensions/page-action-cache/dist/security-policy.d.ts +0 -62
  249. package/extensions/page-action-cache/dist/security-policy.d.ts.map +0 -1
  250. package/extensions/page-action-cache/dist/security-policy.js +0 -219
  251. package/extensions/page-action-cache/dist/security-policy.js.map +0 -1
  252. package/extensions/page-action-cache/dist/tools.d.ts +0 -209
  253. package/extensions/page-action-cache/dist/tools.d.ts.map +0 -1
  254. package/extensions/page-action-cache/dist/tools.js +0 -383
  255. package/extensions/page-action-cache/dist/tools.js.map +0 -1
  256. package/extensions/page-action-cache/dist/types.d.ts +0 -336
  257. package/extensions/page-action-cache/dist/types.d.ts.map +0 -1
  258. package/extensions/page-action-cache/dist/types.js +0 -8
  259. package/extensions/page-action-cache/dist/types.js.map +0 -1
  260. package/extensions/page-action-cache/dist/ux-enhancer.d.ts +0 -60
  261. package/extensions/page-action-cache/dist/ux-enhancer.d.ts.map +0 -1
  262. package/extensions/page-action-cache/dist/ux-enhancer.js +0 -218
  263. package/extensions/page-action-cache/dist/ux-enhancer.js.map +0 -1
  264. package/extensions/page-action-cache/dist/variable-resolver.d.ts +0 -28
  265. package/extensions/page-action-cache/dist/variable-resolver.d.ts.map +0 -1
  266. package/extensions/page-action-cache/dist/variable-resolver.js +0 -201
  267. package/extensions/page-action-cache/dist/variable-resolver.js.map +0 -1
  268. package/extensions/page-action-cache/docs/API.md +0 -555
  269. package/extensions/page-action-cache/docs/IMPLEMENTATION.md +0 -1792
  270. package/extensions/page-action-cache/docs/INTEGRATION.md +0 -387
  271. package/extensions/page-action-cache/docs/README.md +0 -183
  272. package/extensions/page-action-cache/index.ts +0 -118
  273. package/extensions/page-action-cache/node_modules/.bin/nlc +0 -21
  274. package/extensions/page-action-cache/node_modules/.bin/node-llama-cpp +0 -21
  275. package/extensions/page-action-cache/node_modules/.bin/openclaw +0 -21
  276. package/extensions/page-action-cache/node_modules/.bin/tsc +0 -21
  277. package/extensions/page-action-cache/node_modules/.bin/tsserver +0 -21
  278. package/extensions/page-action-cache/node_modules/.bin/vitest +0 -21
  279. package/extensions/page-action-cache/openclaw.plugin.json +0 -208
  280. package/extensions/page-action-cache/package.json +0 -74
  281. package/extensions/page-action-cache/scripts/npm_publish.sh +0 -80
  282. package/extensions/page-action-cache/skills/page-action-cache/SKILL.md +0 -216
  283. package/extensions/page-action-cache/src/actions-executor.ts +0 -441
  284. package/extensions/page-action-cache/src/cache-invalidator.ts +0 -271
  285. package/extensions/page-action-cache/src/cache-store.ts +0 -457
  286. package/extensions/page-action-cache/src/cache-strategy.ts +0 -327
  287. package/extensions/page-action-cache/src/hooks-entry.ts +0 -114
  288. package/extensions/page-action-cache/src/hooks.ts +0 -332
  289. package/extensions/page-action-cache/src/index.ts +0 -104
  290. package/extensions/page-action-cache/src/scenario-recognizer.ts +0 -259
  291. package/extensions/page-action-cache/src/security-policy.ts +0 -268
  292. package/extensions/page-action-cache/src/tools.ts +0 -437
  293. package/extensions/page-action-cache/src/types.ts +0 -482
  294. package/extensions/page-action-cache/src/ux-enhancer.ts +0 -266
  295. package/extensions/page-action-cache/src/variable-resolver.ts +0 -258
  296. package/extensions/page-action-cache/tests/actions-executor.test.ts +0 -424
  297. package/extensions/page-action-cache/tests/cache-store.test.ts +0 -267
  298. package/extensions/page-action-cache/tests/integration-test.ts +0 -62
  299. package/extensions/page-action-cache/tests/scenario-recognizer.test.ts +0 -140
  300. package/extensions/page-action-cache/tests/variable-resolver.test.ts +0 -187
  301. package/extensions/page-action-cache/tsconfig.json +0 -39
@@ -1,271 +0,0 @@
1
- /**
2
- * Cache Invalidator
3
- * 缓存失效检测器 - 检测页面变化并失效缓存
4
- */
5
-
6
- import type {
7
- PageViewport,
8
- PageChangeDetection,
9
- PageActionCacheEntry,
10
- DOMHashFeatures,
11
- } from "./types.js";
12
-
13
- // ============================================================================
14
- // Cache Invalidator 类
15
- // ============================================================================
16
-
17
- /**
18
- * 缓存失效检测器
19
- */
20
- export class CacheInvalidator {
21
- /**
22
- * 检测页面是否发生变化
23
- */
24
- async detectPageChange(
25
- html: string,
26
- _url: string,
27
- _viewport: PageViewport,
28
- cachedEntry?: PageActionCacheEntry
29
- ): Promise<PageChangeDetection> {
30
- // 计算当前 DOM hash
31
- const currentHash = this.calculateDOMHash(html);
32
-
33
- if (!cachedEntry || !cachedEntry.pageChangeDetection) {
34
- return {
35
- hasChanged: true,
36
- changeType: "none",
37
- confidence: 0,
38
- domHash: currentHash,
39
- lastCheckedAt: Date.now(),
40
- };
41
- }
42
-
43
- const cachedHash = cachedEntry.pageChangeDetection.domHash;
44
-
45
- // 比较 hash
46
- if (currentHash === cachedHash) {
47
- return {
48
- hasChanged: false,
49
- changeType: "none",
50
- confidence: 100,
51
- domHash: currentHash,
52
- lastCheckedAt: Date.now(),
53
- };
54
- }
55
-
56
- // 检测变化类型
57
- const structureChanged = this.detectStructureChange(html);
58
- const contentChanged = this.detectContentChange(html, cachedEntry);
59
-
60
- if (structureChanged || contentChanged) {
61
- return {
62
- hasChanged: true,
63
- changeType: structureChanged ? "structure" : "content",
64
- confidence: Math.max(
65
- structureChanged ? 80 : 0,
66
- contentChanged ? 80 : 0
67
- ),
68
- domHash: currentHash,
69
- lastCheckedAt: Date.now(),
70
- details: structureChanged
71
- ? "Form/Button count changed"
72
- : "Content hash changed",
73
- };
74
- }
75
-
76
- // hash 不同但结构未变,可能是动态内容
77
- return {
78
- hasChanged: true,
79
- changeType: "content",
80
- confidence: 50, // 低置信度,可能是动态内容
81
- domHash: currentHash,
82
- lastCheckedAt: Date.now(),
83
- details: "Hash changed but structure is similar",
84
- };
85
- }
86
-
87
- /**
88
- * 计算 DOM hash
89
- */
90
- calculateDOMHash(html: string): string {
91
- const features = this.extractDOMFeatures(html);
92
- return this.combineFeaturesHash(features);
93
- }
94
-
95
- /**
96
- * 提取 DOM 特征
97
- */
98
- private extractDOMFeatures(html: string): DOMHashFeatures {
99
- return {
100
- formCount: this.countElements(html, "form"),
101
- buttonCount: this.countElements(html, "button"),
102
- linkCount: this.countElements(html, "a"),
103
- scriptCount: this.countElements(html, "script"),
104
- headingCount:
105
- this.countElements(html, "h1") +
106
- this.countElements(html, "h2") +
107
- this.countElements(html, "h3"),
108
- };
109
- }
110
-
111
- /**
112
- * 计算元素数量
113
- */
114
- private countElements(html: string, tagName: string): number {
115
- const regex = new RegExp(`<${tagName}\\b`, "gi");
116
- return (html.match(regex) || []).length;
117
- }
118
-
119
- /**
120
- * 组合特征为 hash
121
- */
122
- private combineFeaturesHash(features: DOMHashFeatures): string {
123
- const values = [
124
- features.formCount,
125
- features.buttonCount,
126
- features.linkCount,
127
- features.scriptCount,
128
- features.headingCount,
129
- ];
130
-
131
- // 简单 hash 算法
132
- let hash = 0;
133
- for (const value of values) {
134
- hash = ((hash << 5) - hash + value) | 0;
135
- }
136
- return hash.toString(16);
137
- }
138
-
139
- /**
140
- * 检测结构变化
141
- */
142
- private detectStructureChange(html: string): boolean {
143
- // 检查表单和按钮数量是否发生显著变化
144
- const features = this.extractDOMFeatures(html);
145
-
146
- // 如果表单数量变化,认为是结构变化
147
- // 这里简化处理,实际应该与缓存条目比较
148
- const hasForm = features.formCount > 0;
149
-
150
- return !hasForm;
151
- }
152
-
153
- /**
154
- * 检测内容变化
155
- */
156
- private detectContentChange(
157
- html: string,
158
- cachedEntry: PageActionCacheEntry
159
- ): boolean {
160
- // 简化处理:检查 HTML 长度变化
161
- const lengthChanged = Math.abs(html.length - (cachedEntry.actions.length * 100)) > 500;
162
-
163
- return lengthChanged;
164
- }
165
-
166
- /**
167
- * 判断是否应该失效缓存
168
- */
169
- shouldInvalidate(
170
- entry: PageActionCacheEntry,
171
- changeResult: PageChangeDetection,
172
- threshold: number = 80
173
- ): boolean {
174
- // 根据页面类型和置信度决定是否失效
175
- const pageType = entry.pageType || "mixed";
176
-
177
- if (pageType === "static") {
178
- // 静态页面:高置信度时失效
179
- return changeResult.hasChanged && changeResult.confidence >= threshold;
180
- } else if (pageType === "dynamic") {
181
- // 动态页面:只在结构变化时失效
182
- return (
183
- changeResult.hasChanged && changeResult.changeType === "structure"
184
- );
185
- } else {
186
- // 混合页面:中等置信度时失效
187
- return (
188
- changeResult.hasChanged && changeResult.confidence >= threshold - 10
189
- );
190
- }
191
- }
192
-
193
- /**
194
- * 创建渐进式失效器
195
- */
196
- createProgressiveInvalidator(): ProgressiveInvalidator {
197
- return new ProgressiveInvalidator();
198
- }
199
- }
200
-
201
- // ============================================================================
202
- // Progressive Invalidator 类
203
- // ============================================================================
204
-
205
- /**
206
- * 渐进式失效:保留多版本
207
- */
208
- export class ProgressiveInvalidator {
209
- private versions: Map<string, string[]> = new Map();
210
-
211
- /**
212
- * 添加版本
213
- */
214
- addVersion(entry: PageActionCacheEntry, versionId: string): void {
215
- const key = entry.key;
216
-
217
- if (!this.versions.has(key)) {
218
- this.versions.set(key, []);
219
- }
220
-
221
- const versions = this.versions.get(key)!;
222
- versions.push(versionId);
223
-
224
- // 只保留最近的 N 个版本(默认 3 个)
225
- if (versions.length > 3) {
226
- versions.shift();
227
- }
228
- }
229
-
230
- /**
231
- * 获取版本列表
232
- */
233
- getVersions(key: string): string[] {
234
- return this.versions.get(key) || [];
235
- }
236
-
237
- /**
238
- * 生成版本标识
239
- */
240
- generateVersion(entry: PageActionCacheEntry): string {
241
- const time = new Date(entry.createdAt).toISOString().slice(0, 10); // YYYY-MM-DD
242
- const pageType = entry.pageType || "unknown";
243
-
244
- return `${pageType}-${entry.scenario}-${time}`;
245
- }
246
-
247
- /**
248
- * 清理旧版本
249
- */
250
- cleanupOldVersions(key: string, maxVersions: number = 3): void {
251
- const versions = this.getVersions(key);
252
-
253
- if (versions.length > maxVersions) {
254
- const toKeep = versions.slice(-maxVersions);
255
- this.versions.set(key, toKeep);
256
- }
257
- }
258
- }
259
-
260
- // ============================================================================
261
- // 单例
262
- // ============================================================================
263
-
264
- let cacheInvalidatorInstance: CacheInvalidator | null = null;
265
-
266
- export function getCacheInvalidator(): CacheInvalidator {
267
- if (!cacheInvalidatorInstance) {
268
- cacheInvalidatorInstance = new CacheInvalidator();
269
- }
270
- return cacheInvalidatorInstance;
271
- }
@@ -1,457 +0,0 @@
1
- /**
2
- * Page Action Cache Store
3
- * 管理页面操作缓存的存储
4
- */
5
-
6
- import fs from "node:fs";
7
- import path from "node:path";
8
- import { createHash } from "node:crypto";
9
- import type {
10
- PageActionCacheEntry,
11
- PageActionCacheStore,
12
- PageViewport,
13
- CacheStats,
14
- ScenarioMatch,
15
- } from "./types.js";
16
-
17
- // ============================================================================
18
- // 配置
19
- // ============================================================================
20
-
21
- const CACHE_DIR = path.join(
22
- process.env.HOME || process.env.USERPROFILE || ".",
23
- ".openclaw",
24
- "cache",
25
- "page-actions"
26
- );
27
-
28
- const CACHE_FILE = path.join(CACHE_DIR, "cache.json");
29
- const CACHE_VERSION = 1;
30
-
31
- const DEFAULT_TTL = {
32
- L3: 7 * 24 * 60 * 60 * 1000, // 7 天
33
- L2: 3 * 24 * 60 * 60 * 1000, // 3 天
34
- L1: 30 * 60 * 1000, // 30 分钟
35
- };
36
-
37
- // ============================================================================
38
- // CacheStore 类
39
- // ============================================================================
40
-
41
- /**
42
- * 缓存存储管理器
43
- */
44
- export class CacheStore {
45
- private store: PageActionCacheStore;
46
-
47
- constructor() {
48
- this.store = this.load();
49
- }
50
-
51
- // -------------------------------------------------------------------------
52
- // 初始化和加载
53
- // -------------------------------------------------------------------------
54
-
55
- private load(): PageActionCacheStore {
56
- try {
57
- if (fs.existsSync(CACHE_FILE)) {
58
- const data = fs.readFileSync(CACHE_FILE, "utf-8");
59
- const loaded = JSON.parse(data) as PageActionCacheStore;
60
-
61
- // 版本检查
62
- if (loaded.version !== CACHE_VERSION) {
63
- console.warn(
64
- `[CacheStore] Cache version mismatch (expected ${CACHE_VERSION}, got ${loaded.version}), clearing cache`
65
- );
66
- return this.createEmptyStore();
67
- }
68
-
69
- return loaded;
70
- }
71
- } catch (error) {
72
- console.error(`[CacheStore] Failed to load cache:`, error);
73
- }
74
-
75
- return this.createEmptyStore();
76
- }
77
-
78
- private createEmptyStore(): PageActionCacheStore {
79
- return {
80
- version: CACHE_VERSION,
81
- entries: {},
82
- scenarios: new Map<string, ScenarioMatch>(),
83
- stats: {
84
- totalEntries: 0,
85
- totalHits: 0,
86
- totalMisses: 0,
87
- hitRate: 0,
88
- l3Hits: 0,
89
- l2Hits: 0,
90
- l1Hits: 0,
91
- scenarioMatches: 0,
92
- llmClassifications: 0,
93
- learnedAssociations: 0,
94
- savedTokens: 0,
95
- savedTime: 0,
96
- avgExecutionTime: 0,
97
- userConfirmations: 0,
98
- userForcedRefreshes: 0,
99
- cacheErrors: 0,
100
- },
101
- };
102
- }
103
-
104
- private ensureCacheDir(): void {
105
- if (!fs.existsSync(CACHE_DIR)) {
106
- fs.mkdirSync(CACHE_DIR, { recursive: true });
107
- }
108
- }
109
-
110
- // -------------------------------------------------------------------------
111
- // 保存
112
- // -------------------------------------------------------------------------
113
-
114
- private save(): void {
115
- try {
116
- this.ensureCacheDir();
117
-
118
- // 序列化(处理 Map)
119
- const serialized = {
120
- ...this.store,
121
- scenarios: Array.from(this.store.scenarios.entries()),
122
- };
123
-
124
- fs.writeFileSync(CACHE_FILE, JSON.stringify(serialized, null, 2));
125
- } catch (error) {
126
- console.error(`[CacheStore] Failed to save cache:`, error);
127
- }
128
- }
129
-
130
- private scheduleSave(): void {
131
- // 防抖保存(100ms)
132
- if (this._saveTimeout) {
133
- clearTimeout(this._saveTimeout);
134
- }
135
- this._saveTimeout = setTimeout(() => this.save(), 100);
136
- }
137
-
138
- private _saveTimeout: NodeJS.Timeout | null = null;
139
-
140
- // -------------------------------------------------------------------------
141
- // 缓存键生成
142
- // -------------------------------------------------------------------------
143
-
144
- private generateKey(url: string, viewport: PageViewport): string {
145
- const normalizedUrl = this.normalizeUrl(url);
146
- const viewportStr = `${viewport.width}x${viewport.height}`;
147
- const hash = createHash("md5")
148
- .update(`${normalizedUrl}:${viewportStr}`)
149
- .digest("hex");
150
- return hash || `fallback-${Date.now()}`; // 确保 hash 不为空
151
- }
152
-
153
- private normalizeUrl(url: string): string {
154
- try {
155
- const parsed = new URL(url);
156
- // 移除查询参数和哈希(可根据配置调整)
157
- parsed.search = "";
158
- parsed.hash = "";
159
- return parsed.toString();
160
- } catch {
161
- return url;
162
- }
163
- }
164
-
165
- // -------------------------------------------------------------------------
166
- // 基本操作
167
- // -------------------------------------------------------------------------
168
-
169
- /**
170
- * 设置缓存条目
171
- */
172
- set(
173
- url: string,
174
- viewport: PageViewport,
175
- actions: any[],
176
- metadata: {
177
- scenario: string;
178
- cacheLevel: "L3" | "L2" | "L1";
179
- variables?: Record<string, string>;
180
- description?: string;
181
- pageType?: "static" | "dynamic" | "mixed";
182
- }
183
- ): string {
184
- const key = this.generateKey(url, viewport);
185
- const now = Date.now();
186
- const ttl = DEFAULT_TTL[metadata.cacheLevel];
187
-
188
- const entry: PageActionCacheEntry = {
189
- key,
190
- url: this.normalizeUrl(url),
191
- viewport,
192
- cacheLevel: metadata.cacheLevel,
193
- scenario: metadata.scenario,
194
- description: metadata.description || `Cached ${metadata.scenario} actions`,
195
- variables: metadata.variables,
196
- actions,
197
- createdAt: now,
198
- lastAccessTime: now,
199
- accessCount: 0,
200
- expiresAt: now + ttl,
201
- pageChangeDetection: {
202
- hasChanged: false,
203
- changeType: "none",
204
- confidence: 100,
205
- domHash: "",
206
- lastCheckedAt: now,
207
- },
208
- source: "llm",
209
- version: 1,
210
- successCount: 0,
211
- failCount: 0,
212
- avgExecutionTime: 0,
213
- pageType: metadata.pageType || "mixed",
214
- };
215
-
216
- this.store.entries[key] = entry;
217
- this.store.stats.totalEntries++;
218
-
219
- this.scheduleSave();
220
- return key;
221
- }
222
-
223
- /**
224
- * 获取缓存条目
225
- */
226
- get(url: string, viewport: PageViewport): PageActionCacheEntry | null {
227
- const key = this.generateKey(url, viewport);
228
- const entry = this.store.entries[key];
229
-
230
- if (!entry) {
231
- this.store.stats.totalMisses++;
232
- this.updateHitRate();
233
- return null;
234
- }
235
-
236
- // 检查过期
237
- if (Date.now() > entry.expiresAt) {
238
- delete this.store.entries[key];
239
- this.store.stats.totalEntries--;
240
- this.store.stats.totalMisses++;
241
- this.updateHitRate();
242
- this.scheduleSave();
243
- return null;
244
- }
245
-
246
- // 更新访问统计
247
- entry.lastAccessTime = Date.now();
248
- entry.accessCount++;
249
-
250
- // 更新层级统计
251
- this.store.stats.totalHits++;
252
- switch (entry.cacheLevel) {
253
- case "L3":
254
- this.store.stats.l3Hits++;
255
- break;
256
- case "L2":
257
- this.store.stats.l2Hits++;
258
- break;
259
- case "L1":
260
- this.store.stats.l1Hits++;
261
- break;
262
- }
263
-
264
- this.updateHitRate();
265
- this.scheduleSave();
266
-
267
- return entry;
268
- }
269
-
270
- /**
271
- * 删除缓存条目
272
- */
273
- delete(url: string, viewport: PageViewport): boolean {
274
- const key = this.generateKey(url, viewport);
275
- const existed = !!this.store.entries[key];
276
-
277
- if (existed) {
278
- delete this.store.entries[key];
279
- this.store.stats.totalEntries--;
280
- this.scheduleSave();
281
- }
282
-
283
- return existed;
284
- }
285
-
286
- /**
287
- * 按模式删除缓存条目
288
- */
289
- deleteByPattern(urlPattern: string): number {
290
- let deleted = 0;
291
-
292
- for (const [key, entry] of Object.entries(this.store.entries)) {
293
- if (entry.url.includes(urlPattern)) {
294
- delete this.store.entries[key];
295
- this.store.stats.totalEntries--;
296
- deleted++;
297
- }
298
- }
299
-
300
- if (deleted > 0) {
301
- this.scheduleSave();
302
- }
303
-
304
- return deleted;
305
- }
306
-
307
- /**
308
- * 清空所有缓存
309
- */
310
- clear(): void {
311
- this.store.entries = {};
312
- this.store.scenarios.clear();
313
- this.store.stats = this.createEmptyStore().stats;
314
- this.scheduleSave();
315
- }
316
-
317
- // -------------------------------------------------------------------------
318
- // 统计更新
319
- // -------------------------------------------------------------------------
320
-
321
- private updateHitRate(): void {
322
- const total = this.store.stats.totalHits + this.store.stats.totalMisses;
323
- this.store.stats.hitRate =
324
- total > 0 ? (this.store.stats.totalHits / total) * 100 : 0;
325
- }
326
-
327
- /**
328
- * 更新执行统计
329
- */
330
- updateExecutionStats(
331
- key: string,
332
- results: Array<{ success: boolean; duration: number }>
333
- ): void {
334
- const entry = this.store.entries[key];
335
- if (!entry) return;
336
-
337
- const successCount = results.filter((r) => r.success).length;
338
- const failCount = results.length - successCount;
339
- const avgDuration =
340
- results.reduce((sum, r) => sum + r.duration, 0) / results.length;
341
-
342
- // 更新统计(加权平均)
343
- const oldCount = entry.successCount + entry.failCount;
344
- const newCount = oldCount + results.length;
345
-
346
- entry.successCount += successCount;
347
- entry.failCount += failCount;
348
- entry.avgExecutionTime =
349
- (entry.avgExecutionTime * oldCount + avgDuration * results.length) /
350
- newCount;
351
-
352
- // 估算节省的 token 和时间
353
- this.store.stats.savedTokens += 5000; // 估算值
354
- this.store.stats.savedTime += 2000; // 估算值(毫秒)
355
-
356
- this.scheduleSave();
357
- }
358
-
359
- // -------------------------------------------------------------------------
360
- // 场景匹配管理
361
- // -------------------------------------------------------------------------
362
-
363
- /**
364
- * 保存场景匹配
365
- */
366
- saveScenarioMatch(match: ScenarioMatch): void {
367
- this.store.scenarios.set(match.scenario, match);
368
- this.store.stats.scenarioMatches++;
369
- this.scheduleSave();
370
- }
371
-
372
- /**
373
- * 获取场景匹配
374
- */
375
- getScenarioMatch(scenario: string): ScenarioMatch | undefined {
376
- return this.store.scenarios.get(scenario);
377
- }
378
-
379
- // -------------------------------------------------------------------------
380
- // 查询方法
381
- // -------------------------------------------------------------------------
382
-
383
- /**
384
- * 获取统计信息
385
- */
386
- getStats(): CacheStats {
387
- return { ...this.store.stats };
388
- }
389
-
390
- /**
391
- * 列出所有缓存条目
392
- */
393
- listEntries(): PageActionCacheEntry[] {
394
- return Object.values(this.store.entries).sort(
395
- (a, b) => b.lastAccessTime - a.lastAccessTime
396
- );
397
- }
398
-
399
- /**
400
- * 获取热门场景
401
- */
402
- getTopScenarios(limit: number = 5): string {
403
- const scenarioCounts = new Map<string, number>();
404
-
405
- for (const entry of Object.values(this.store.entries)) {
406
- const count = scenarioCounts.get(entry.scenario) || 0;
407
- scenarioCounts.set(entry.scenario, count + entry.accessCount);
408
- }
409
-
410
- const sorted = Array.from(scenarioCounts.entries())
411
- .sort((a, b) => b[1] - a[1])
412
- .slice(0, limit);
413
-
414
- return sorted
415
- .map(([scenario, count]) => `- ${scenario}: ${count} 次`)
416
- .join("\n");
417
- }
418
-
419
- // -------------------------------------------------------------------------
420
- // 清理
421
- // -------------------------------------------------------------------------
422
-
423
- /**
424
- * 清理过期缓存
425
- */
426
- cleanupExpired(): number {
427
- const now = Date.now();
428
- let cleaned = 0;
429
-
430
- for (const [key, entry] of Object.entries(this.store.entries)) {
431
- if (now > entry.expiresAt) {
432
- delete this.store.entries[key];
433
- this.store.stats.totalEntries--;
434
- cleaned++;
435
- }
436
- }
437
-
438
- if (cleaned > 0) {
439
- this.scheduleSave();
440
- }
441
-
442
- return cleaned;
443
- }
444
- }
445
-
446
- // ============================================================================
447
- // 单例
448
- // ============================================================================
449
-
450
- let cacheStoreInstance: CacheStore | null = null;
451
-
452
- export function getCacheStore(): CacheStore {
453
- if (!cacheStoreInstance) {
454
- cacheStoreInstance = new CacheStore();
455
- }
456
- return cacheStoreInstance;
457
- }