@noxsoft/anima 2.0.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 (1570) hide show
  1. package/CHANGELOG.md +2065 -0
  2. package/LICENSE +23 -0
  3. package/README.md +47 -0
  4. package/anima.mjs +56 -0
  5. package/dist/accounts-Cc5E4IDO.js +260 -0
  6. package/dist/accounts-CcVrwKqv.js +259 -0
  7. package/dist/acp-cli-BbvR4dNz.js +1081 -0
  8. package/dist/acp-cli-CePIi7gD.js +1084 -0
  9. package/dist/agent-CSrGrAg1.js +725 -0
  10. package/dist/agent-NgeWEcBM.js +725 -0
  11. package/dist/agent-events-UF0DxwKS.js +182 -0
  12. package/dist/agent-scope-BVf4aSwY.js +112 -0
  13. package/dist/agent-scope-OZi7lb8S.js +452 -0
  14. package/dist/agent-scope-V1bi9OYL.js +452 -0
  15. package/dist/agents-Bw06WthM.js +809 -0
  16. package/dist/agents.config-Dvo2ULxs.js +182 -0
  17. package/dist/agents.config-d6H0_3oj.js +182 -0
  18. package/dist/argv-DqUHKf0o.js +73 -0
  19. package/dist/audit-Buja3mbS.js +2401 -0
  20. package/dist/audit-CWIz6mM7.js +2401 -0
  21. package/dist/auth-91o2YM96.js +648 -0
  22. package/dist/auth-choice-7dFCqblU.js +2681 -0
  23. package/dist/auth-choice-S_0K9gpl.js +2681 -0
  24. package/dist/auth-health-CctpRTdC.js +149 -0
  25. package/dist/auth-health-DoHai4eD.js +149 -0
  26. package/dist/auth-lZ26wsbN.js +639 -0
  27. package/dist/auth-profiles-Cz2rxrav.js +2690 -0
  28. package/dist/auth-profiles-_5BsNObq.js +1565 -0
  29. package/dist/banner-ieAUufx9.js +294 -0
  30. package/dist/boolean-Ce2-qkSB.js +30 -0
  31. package/dist/boolean-Wzu0-e0P.js +30 -0
  32. package/dist/brew-CVZkr0GU.js +46 -0
  33. package/dist/brew-DAdyX1_1.js +46 -0
  34. package/dist/browser-cli-D_qgYDik.js +1679 -0
  35. package/dist/browser-cli-DldrdaCW.js +1676 -0
  36. package/dist/budget-ChKARYPY.js +132 -0
  37. package/dist/budget-Dspr6N_e.js +132 -0
  38. package/dist/build-info.json +5 -0
  39. package/dist/bundled/boot-md/HOOK.md +19 -0
  40. package/dist/bundled/boot-md/handler.js +861 -0
  41. package/dist/bundled/bootstrap-extra-files/HOOK.md +53 -0
  42. package/dist/bundled/bootstrap-extra-files/handler.js +39 -0
  43. package/dist/bundled/command-logger/HOOK.md +122 -0
  44. package/dist/bundled/command-logger/handler.js +55 -0
  45. package/dist/bundled/session-memory/HOOK.md +109 -0
  46. package/dist/bundled/session-memory/handler.js +128 -0
  47. package/dist/call-DPzNR_Qi.js +282 -0
  48. package/dist/call-ktoEhkOQ.js +282 -0
  49. package/dist/canvas-host/a2ui/.bundle.hash +1 -0
  50. package/dist/canvas-host/a2ui/a2ui.bundle.js +19040 -0
  51. package/dist/canvas-host/a2ui/index.html +307 -0
  52. package/dist/catalog-BAayBt1L.js +185 -0
  53. package/dist/catalog-BNsf97BM.js +185 -0
  54. package/dist/channel-options-C3GV4Fgg.js +33 -0
  55. package/dist/channel-options-DJ4GNfwk.js +32 -0
  56. package/dist/channel-selection-CujyiWGM.js +51 -0
  57. package/dist/channel-selection-DfGpCyh2.js +51 -0
  58. package/dist/channel-web-D42mzlCJ.js +2162 -0
  59. package/dist/channels-cli-BAtARz4A.js +1306 -0
  60. package/dist/channels-cli-Ddo_tIRR.js +1304 -0
  61. package/dist/channels-status-issues-DBc1pU_R.js +18 -0
  62. package/dist/channels-status-issues-DjO9MHIG.js +18 -0
  63. package/dist/chrome-Bi6iZ5sG.js +1601 -0
  64. package/dist/chrome-DNSv7Cpy.js +1629 -0
  65. package/dist/chrome-DScZx4Lk.js +1601 -0
  66. package/dist/chunk-mxPVo000.js +348 -0
  67. package/dist/clack-prompter-B0kl7shw.js +92 -0
  68. package/dist/clack-prompter-B1YxZdRy.js +92 -0
  69. package/dist/cli/daemon-cli.js +9 -0
  70. package/dist/cli-D3hUnL_G.js +101 -0
  71. package/dist/cli-DDwD6VgH.js +99 -0
  72. package/dist/cli-session-CP7ZH2-6.js +5463 -0
  73. package/dist/cli-session-oXJQpenl.js +5408 -0
  74. package/dist/cli-utils-BTBABPX9.js +40 -0
  75. package/dist/cli-utils-DtAxdCte.js +40 -0
  76. package/dist/client-C1avc0vD.js +1692 -0
  77. package/dist/client-CC94YZrT.js +1692 -0
  78. package/dist/clipboard-B2fBy8tG.js +31 -0
  79. package/dist/clipboard-BbGnZskJ.js +31 -0
  80. package/dist/command-format-Clp46jkj.js +38 -0
  81. package/dist/command-format-DELazozB.js +52 -0
  82. package/dist/command-format-SkzzRqR1.js +52 -0
  83. package/dist/command-options-CSbuuqHr.js +8 -0
  84. package/dist/command-options-Cp1tf96a.js +8 -0
  85. package/dist/command-registry-DDGudZEQ.js +248 -0
  86. package/dist/commands-CRcFD5MO.js +509 -0
  87. package/dist/commands-Dh40OpQL.js +509 -0
  88. package/dist/commands-registry-Bd0xbvwG.js +766 -0
  89. package/dist/commands-registry-DYfRSVF3.js +766 -0
  90. package/dist/common-D6bu0zHC.js +287 -0
  91. package/dist/common-zW9Y2P1B.js +287 -0
  92. package/dist/completion-cli-B9Cn374l.js +431 -0
  93. package/dist/completion-cli-BEHghUFx.js +432 -0
  94. package/dist/config-Bmm8tmZF.js +6523 -0
  95. package/dist/config-CHc5qzaI.js +5704 -0
  96. package/dist/config-Co6UXXF5.js +11 -0
  97. package/dist/config-Xm0j9LUa.js +5705 -0
  98. package/dist/config-cli-9ZbCHoV8.js +247 -0
  99. package/dist/config-cli-sxuGl29N.js +244 -0
  100. package/dist/config-guard-BwRD-b9Z.js +93 -0
  101. package/dist/config-guard-Dy7wyhAX.js +76 -0
  102. package/dist/config-sync-Bllc1TJ4.js +89 -0
  103. package/dist/config-sync-mfuOoGHl.js +89 -0
  104. package/dist/configure-CCyVzQZ7.js +1006 -0
  105. package/dist/configure-Nntbxt4t.js +1008 -0
  106. package/dist/constants-BwBn5CGe.js +65 -0
  107. package/dist/constants-O8yBqCBv.js +65 -0
  108. package/dist/context-DKaQYnCH.js +60 -0
  109. package/dist/control-service-BeOtZCCS.js +72 -0
  110. package/dist/control-service-vyKJ-XUp.js +72 -0
  111. package/dist/cron-cli-BasqtsJ0.js +451 -0
  112. package/dist/cron-cli-C8XzIpyX.js +448 -0
  113. package/dist/daemon-cli-cwL2GI5i.js +565 -0
  114. package/dist/daemon-cli-sjDh2xbf.js +566 -0
  115. package/dist/daemon-cli.js +13117 -0
  116. package/dist/daemon-runtime-BuMT6nck.js +460 -0
  117. package/dist/daemon-runtime-CTvi3m4D.js +460 -0
  118. package/dist/dangerous-tools-5ObDWy1N.js +32 -0
  119. package/dist/dangerous-tools-Jwr7jqNw.js +32 -0
  120. package/dist/deliver-D6cdhg5m.js +1097 -0
  121. package/dist/deliver-DlNDKlA4.js +1162 -0
  122. package/dist/deliver-bC6iI_rv.js +1097 -0
  123. package/dist/delivery-queue-B6IHz4Ry.js +220 -0
  124. package/dist/delivery-queue-TnQykYsg.js +220 -0
  125. package/dist/deps-C9kDG-Ru.js +42 -0
  126. package/dist/devices-cli-BE-Nib4Y.js +198 -0
  127. package/dist/devices-cli-GyPlNRyd.js +195 -0
  128. package/dist/diagnostics-Dj75aEHN.js +35 -0
  129. package/dist/diagnostics-DlIw6fqD.js +35 -0
  130. package/dist/directory-cli-BEaIvWkc.js +246 -0
  131. package/dist/directory-cli-CZ_-DP5Z.js +243 -0
  132. package/dist/dispatcher-Bkcui7jz.js +100 -0
  133. package/dist/dispatcher-C1B6cT_7.js +100 -0
  134. package/dist/display-A8k-mxv8.js +171 -0
  135. package/dist/display-BDOsXu8F.js +171 -0
  136. package/dist/dns-cli-BUzpVoMv.js +200 -0
  137. package/dist/dns-cli-DstQOMQt.js +197 -0
  138. package/dist/dock-DbxBBv30.js +753 -0
  139. package/dist/dock-cPBY4qGl.js +753 -0
  140. package/dist/docs-cli-BWp6p-Tq.js +161 -0
  141. package/dist/docs-cli-x22FnZfL.js +159 -0
  142. package/dist/doctor-B5HFw-nC.js +1813 -0
  143. package/dist/doctor-DnEyqGcQ.js +1815 -0
  144. package/dist/doctor-completion-BMEPXgVg.js +92 -0
  145. package/dist/doctor-completion-usPeH2ol.js +92 -0
  146. package/dist/doctor-config-flow-CS0WFnjL.js +1232 -0
  147. package/dist/doctor-config-flow-Cs4O_Kmq.js +1232 -0
  148. package/dist/engine-DgK9s3lk.js +561 -0
  149. package/dist/engine-ZSd5I5JN.js +561 -0
  150. package/dist/entry.js +1560 -0
  151. package/dist/env-0lJfCPsw.js +32 -0
  152. package/dist/errors-A_GqUU6B.js +26 -0
  153. package/dist/errors-CHow2wtt.js +37 -0
  154. package/dist/errors-Cojm0Kl7.js +37 -0
  155. package/dist/exec-BenD3A5l.js +1167 -0
  156. package/dist/exec-BizYYQgP.js +255 -0
  157. package/dist/exec-Bv3pyjeM.js +255 -0
  158. package/dist/exec-approvals-BP9AhCSw.js +1221 -0
  159. package/dist/exec-approvals-CdLmKX2R.js +1221 -0
  160. package/dist/exec-approvals-cli-25CGlFNw.js +368 -0
  161. package/dist/exec-approvals-cli-BXZ-hOlT.js +371 -0
  162. package/dist/extensionAPI.js +8542 -0
  163. package/dist/format-CjKG6raZ.js +20 -0
  164. package/dist/format-Mq6iU0_5.js +20 -0
  165. package/dist/format-duration-Cm3xh8xz.js +58 -0
  166. package/dist/format-duration-DhWzz_5b.js +58 -0
  167. package/dist/format-relative-C6kUHuOj.js +55 -0
  168. package/dist/format-relative-sy9iviQN.js +55 -0
  169. package/dist/frontmatter-YijVi0FQ.js +204 -0
  170. package/dist/gateway-cli-B9uc0RCI.js +19971 -0
  171. package/dist/gateway-cli-D8Qz7kCf.js +19972 -0
  172. package/dist/gateway-rpc-Ch9mCYEB.js +28 -0
  173. package/dist/gateway-rpc-DBhcdLFs.js +28 -0
  174. package/dist/github-copilot-auth-D6ZErYqa.js +1418 -0
  175. package/dist/github-copilot-auth-DGmyWJms.js +1418 -0
  176. package/dist/gmail-setup-utils-BPo_LkKI.js +428 -0
  177. package/dist/gmail-setup-utils-D3Yqgor7.js +428 -0
  178. package/dist/health-DsTZaAzV.js +1258 -0
  179. package/dist/health-V6dGthLA.js +1253 -0
  180. package/dist/health-format-CdP99j3Y.js +208 -0
  181. package/dist/health-format-JEChH08S.js +208 -0
  182. package/dist/heartbeat-visibility-CkL00WRR.js +98 -0
  183. package/dist/heartbeat-visibility-Cmni9671.js +98 -0
  184. package/dist/help-format-DUBI91Ti.js +17 -0
  185. package/dist/help-format-Dl4bsrLI.js +17 -0
  186. package/dist/helpers-9N2Q5aZj.js +25 -0
  187. package/dist/helpers-DLgbkcEn.js +25 -0
  188. package/dist/helpers-ZKNRexvX.js +10 -0
  189. package/dist/helpers-eJFa4K6r.js +10 -0
  190. package/dist/hooks-cli-Cu0D0fPS.js +993 -0
  191. package/dist/hooks-cli-E63uffR6.js +991 -0
  192. package/dist/hooks-status-B-e96dZj.js +356 -0
  193. package/dist/hooks-status-C_9sE0ox.js +356 -0
  194. package/dist/image-ops-Dlt3T7th.js +541 -0
  195. package/dist/image-ops-omlvdfah.js +541 -0
  196. package/dist/index.js +499 -0
  197. package/dist/init-Bm04RagW.js +122 -0
  198. package/dist/init-CaJBf4p1.js +122 -0
  199. package/dist/input-provenance-BgwBljRz.js +35 -0
  200. package/dist/input-provenance-DJBdpeKk.js +35 -0
  201. package/dist/input-provenance-iu26y0GH.js +35 -0
  202. package/dist/installs-C2iMRBVz.js +383 -0
  203. package/dist/installs-D-cPGdCw.js +383 -0
  204. package/dist/internal-hooks-DFTIurVM.js +77 -0
  205. package/dist/ipv4-C5QxzriV.js +1964 -0
  206. package/dist/ipv4-TxR9wQCQ.js +1964 -0
  207. package/dist/is-main-Dt9DTcH1.js +25 -0
  208. package/dist/is-main-cB3p7uob.js +25 -0
  209. package/dist/lanes-CNxj3tit.js +232 -0
  210. package/dist/legacy-names-CKU7tKQR.js +8 -0
  211. package/dist/lifecycle-core-B_7XRcvF.js +388 -0
  212. package/dist/lifecycle-core-By83PVAK.js +387 -0
  213. package/dist/links-BfjHVTB_.js +15 -0
  214. package/dist/links-DPGe0OHw.js +15 -0
  215. package/dist/llm-slug-generator.js +62 -0
  216. package/dist/loader-6Qkyybg1.js +87 -0
  217. package/dist/loader-Dmc0KyQK.js +87 -0
  218. package/dist/logging-54nXj81z.js +1 -0
  219. package/dist/logging-BdnOSVPD.js +1 -0
  220. package/dist/logging-DB6BQmhi.js +15 -0
  221. package/dist/logging-mcb66J0p.js +15 -0
  222. package/dist/login--8D8kyRy.js +61 -0
  223. package/dist/login-C-ugYHKt.js +61 -0
  224. package/dist/login-CX5Q2fYl.js +59 -0
  225. package/dist/login-qr-BLmGvITg.js +321 -0
  226. package/dist/login-qr-BNtuXLKL.js +323 -0
  227. package/dist/login-qr-PcyTC7Ra.js +326 -0
  228. package/dist/logs-cli-BEQVkiXp.js +245 -0
  229. package/dist/logs-cli-CIqiVMkY.js +242 -0
  230. package/dist/manager-Bsy9ifug.js +3244 -0
  231. package/dist/manager-CDgcZ51c.js +3246 -0
  232. package/dist/manager-D7QQ5XrE.js +3244 -0
  233. package/dist/manifest-registry-CW1zCyRF.js +748 -0
  234. package/dist/manifest-registry-D4lM2RdV.js +748 -0
  235. package/dist/markdown-tables-BT1X6jqH.js +347 -0
  236. package/dist/markdown-tables-DHgOK2vI.js +348 -0
  237. package/dist/media-THyainiE.js +1342 -0
  238. package/dist/memory-cli-BmIyAOZm.js +869 -0
  239. package/dist/memory-cli-BoXdfCLT.js +868 -0
  240. package/dist/message-channel-dSTVVCyX.js +110 -0
  241. package/dist/message-channel-w4F2b2F6.js +110 -0
  242. package/dist/migrate-BR6iAIjO.js +157 -0
  243. package/dist/migrate-D0EcMs0f.js +157 -0
  244. package/dist/mime-B1ZoR53M.js +145 -0
  245. package/dist/mime-Bm1xTtpY.js +145 -0
  246. package/dist/mime-C1RlpUSs.js +145 -0
  247. package/dist/model-param-b-C4BL7w0Z.js +16 -0
  248. package/dist/model-param-b-DPwyNGn8.js +16 -0
  249. package/dist/model-selection-BnEobs_z.js +2692 -0
  250. package/dist/models-KLd8Evmq.js +2545 -0
  251. package/dist/models-cli-D4UFQLid.js +258 -0
  252. package/dist/models-cli-DJHs5rJF.js +2739 -0
  253. package/dist/net-B5lXhYLV.js +218 -0
  254. package/dist/net-CDi_lJMH.js +88 -0
  255. package/dist/node-cli-BNCJUkgA.js +1319 -0
  256. package/dist/node-cli-C7S0vk0_.js +1322 -0
  257. package/dist/node-match-8XZnaid6.js +34 -0
  258. package/dist/node-match-B3Osv-5C.js +34 -0
  259. package/dist/node-service-BFxHJsno.js +67 -0
  260. package/dist/node-service-DUnan4uK.js +67 -0
  261. package/dist/nodes-cli-DOXhYgc8.js +1200 -0
  262. package/dist/nodes-cli-wvPZ3HwH.js +1197 -0
  263. package/dist/nodes-screen-1YiLkqr5.js +234 -0
  264. package/dist/nodes-screen-DZeD8hE5.js +234 -0
  265. package/dist/normalize-Dlcj9D3K.js +52 -0
  266. package/dist/normalize-GDK8JTNW.js +52 -0
  267. package/dist/note-Bi8Wb8DV.js +73 -0
  268. package/dist/note-uiuPxhyX.js +73 -0
  269. package/dist/npm-registry-spec-B-XIShkB.js +351 -0
  270. package/dist/npm-registry-spec-za3itb5Y.js +351 -0
  271. package/dist/onboard-DiTRW6CH.js +1165 -0
  272. package/dist/onboard-channels-BgruIpyg.js +672 -0
  273. package/dist/onboard-channels-gyq0VHHp.js +672 -0
  274. package/dist/onboard-helpers-BEaUind0.js +365 -0
  275. package/dist/onboard-helpers-f5Zprayl.js +365 -0
  276. package/dist/onboard-lH3XPWAK.js +1166 -0
  277. package/dist/onboarding-D0FOkXGt.js +910 -0
  278. package/dist/onboarding-kQVgbiIR.js +911 -0
  279. package/dist/openclaw-root-0yHXtO35.js +88 -0
  280. package/dist/openclaw-root-C85WMnVV.js +88 -0
  281. package/dist/orchestrator-CYTk7mq6.js +355 -0
  282. package/dist/orchestrator-J6ELnJXl.js +355 -0
  283. package/dist/outbound-BEq0qbPR.js +214 -0
  284. package/dist/outbound-BSVD-rjk.js +2062 -0
  285. package/dist/outbound-DXijk0db.js +214 -0
  286. package/dist/outbound-send-deps-ANnAhImn.js +14 -0
  287. package/dist/outbound-send-deps-BNGPU7jV.js +55 -0
  288. package/dist/pairing-cli-DKUyb6eK.js +118 -0
  289. package/dist/pairing-cli-ET2p_mXH.js +121 -0
  290. package/dist/pairing-store-CGYSwICJ.js +388 -0
  291. package/dist/pairing-store-DqQPqRMe.js +388 -0
  292. package/dist/parse-6-2MDhdT.js +23 -0
  293. package/dist/parse-CpunmTOS.js +23 -0
  294. package/dist/parse-log-line-Bqh1SSzC.js +44 -0
  295. package/dist/parse-log-line-DUZCjXbl.js +44 -0
  296. package/dist/parse-port-BKB9Exlg.js +12 -0
  297. package/dist/parse-port-DrfvwwiL.js +12 -0
  298. package/dist/parse-timeout-Di_tcEmi.js +16 -0
  299. package/dist/parse-timeout-vVlESvju.js +16 -0
  300. package/dist/path-env-Bu6k0jDQ.js +89 -0
  301. package/dist/path-env-C0zQSjw8.js +89 -0
  302. package/dist/paths-BTc4nk-6.js +126 -0
  303. package/dist/paths-BgUi2Z2G.js +54 -0
  304. package/dist/paths-C6VCWKo3.js +238 -0
  305. package/dist/paths-CCxa0o9c.js +222 -0
  306. package/dist/paths-CxRf2rBG.js +129 -0
  307. package/dist/paths-DcVEkYX5.js +54 -0
  308. package/dist/paths-hcX1Gqg5.js +129 -0
  309. package/dist/pi-auth-json-BzX-qyRo.js +82 -0
  310. package/dist/pi-auth-json-eesA38iW.js +78 -0
  311. package/dist/pi-auth-json-uEDdgg8K.js +80 -0
  312. package/dist/pi-embedded-C1Nl7L89.js +22 -0
  313. package/dist/pi-model-discovery-BkqhoPls.js +20 -0
  314. package/dist/pi-model-discovery-CQOWUAmK.js +3 -0
  315. package/dist/pi-model-discovery-DsRqYJLy.js +20 -0
  316. package/dist/pi-tools.policy-D9AUlreI.js +200 -0
  317. package/dist/pi-tools.policy-DRDm3v-2.js +200 -0
  318. package/dist/plugin-auto-enable-C-JwYMlZ.js +282 -0
  319. package/dist/plugin-auto-enable-DLIDBBfi.js +282 -0
  320. package/dist/plugin-registry-Bp8mivr-.js +32 -0
  321. package/dist/plugin-registry-CP7KgCvC.js +32 -0
  322. package/dist/plugin-sdk/account-id.d.ts +1 -0
  323. package/dist/plugin-sdk/account-id.js +15 -0
  324. package/dist/plugin-sdk/agents/agent-paths.d.ts +6 -0
  325. package/dist/plugin-sdk/agents/agent-scope.d.ts +37 -0
  326. package/dist/plugin-sdk/agents/anima-tools.d.ts +1 -0
  327. package/dist/plugin-sdk/agents/apply-patch-update.d.ts +10 -0
  328. package/dist/plugin-sdk/agents/apply-patch.d.ts +35 -0
  329. package/dist/plugin-sdk/agents/auth-profiles/constants.d.ts +20 -0
  330. package/dist/plugin-sdk/agents/auth-profiles/display.d.ts +7 -0
  331. package/dist/plugin-sdk/agents/auth-profiles/doctor.d.ts +8 -0
  332. package/dist/plugin-sdk/agents/auth-profiles/external-cli-sync.d.ts +7 -0
  333. package/dist/plugin-sdk/agents/auth-profiles/oauth.d.ts +12 -0
  334. package/dist/plugin-sdk/agents/auth-profiles/order.d.ts +8 -0
  335. package/dist/plugin-sdk/agents/auth-profiles/paths.d.ts +4 -0
  336. package/dist/plugin-sdk/agents/auth-profiles/profiles.d.ts +23 -0
  337. package/dist/plugin-sdk/agents/auth-profiles/repair.d.ts +14 -0
  338. package/dist/plugin-sdk/agents/auth-profiles/session-override.d.ts +18 -0
  339. package/dist/plugin-sdk/agents/auth-profiles/store.d.ts +10 -0
  340. package/dist/plugin-sdk/agents/auth-profiles/types.d.ts +60 -0
  341. package/dist/plugin-sdk/agents/auth-profiles/usage.d.ts +47 -0
  342. package/dist/plugin-sdk/agents/auth-profiles.d.ts +11 -0
  343. package/dist/plugin-sdk/agents/bash-process-registry.d.ts +70 -0
  344. package/dist/plugin-sdk/agents/bash-tools.d.ts +4 -0
  345. package/dist/plugin-sdk/agents/bash-tools.exec-runtime.d.ts +73 -0
  346. package/dist/plugin-sdk/agents/bash-tools.exec.d.ts +55 -0
  347. package/dist/plugin-sdk/agents/bash-tools.process.d.ts +7 -0
  348. package/dist/plugin-sdk/agents/bash-tools.shared.d.ts +48 -0
  349. package/dist/plugin-sdk/agents/bedrock-discovery.d.ts +9 -0
  350. package/dist/plugin-sdk/agents/bootstrap-files.d.ts +25 -0
  351. package/dist/plugin-sdk/agents/bootstrap-hooks.d.ts +10 -0
  352. package/dist/plugin-sdk/agents/channel-tools.d.ts +27 -0
  353. package/dist/plugin-sdk/agents/chutes-oauth.d.ts +46 -0
  354. package/dist/plugin-sdk/agents/cli-backends.d.ts +8 -0
  355. package/dist/plugin-sdk/agents/cli-credentials.d.ts +83 -0
  356. package/dist/plugin-sdk/agents/cli-runner/helpers.d.ts +76 -0
  357. package/dist/plugin-sdk/agents/cli-runner.d.ts +41 -0
  358. package/dist/plugin-sdk/agents/cli-session.d.ts +3 -0
  359. package/dist/plugin-sdk/agents/cloudflare-ai-gateway.d.ts +22 -0
  360. package/dist/plugin-sdk/agents/context.d.ts +1 -0
  361. package/dist/plugin-sdk/agents/current-time.d.ts +17 -0
  362. package/dist/plugin-sdk/agents/date-time.d.ts +13 -0
  363. package/dist/plugin-sdk/agents/defaults.d.ts +3 -0
  364. package/dist/plugin-sdk/agents/docs-path.d.ts +6 -0
  365. package/dist/plugin-sdk/agents/failover-error.d.ts +33 -0
  366. package/dist/plugin-sdk/agents/glob-pattern.d.ts +18 -0
  367. package/dist/plugin-sdk/agents/huggingface-models.d.ts +17 -0
  368. package/dist/plugin-sdk/agents/identity-avatar.d.ts +15 -0
  369. package/dist/plugin-sdk/agents/identity-file.d.ts +12 -0
  370. package/dist/plugin-sdk/agents/identity.d.ts +25 -0
  371. package/dist/plugin-sdk/agents/lanes.d.ts +3 -0
  372. package/dist/plugin-sdk/agents/memory-search.d.ts +66 -0
  373. package/dist/plugin-sdk/agents/minimax-vlm.d.ts +7 -0
  374. package/dist/plugin-sdk/agents/model-alias-lines.d.ts +2 -0
  375. package/dist/plugin-sdk/agents/model-auth.d.ts +36 -0
  376. package/dist/plugin-sdk/agents/model-catalog.d.ts +25 -0
  377. package/dist/plugin-sdk/agents/model-fallback.d.ts +40 -0
  378. package/dist/plugin-sdk/agents/model-selection.d.ts +94 -0
  379. package/dist/plugin-sdk/agents/models-config.d.ts +13 -0
  380. package/dist/plugin-sdk/agents/models-config.providers.d.ts +37 -0
  381. package/dist/plugin-sdk/agents/ollama-stream.d.ts +45 -0
  382. package/dist/plugin-sdk/agents/openclaw-tools.d.ts +46 -0
  383. package/dist/plugin-sdk/agents/pi-auth-json.d.ts +14 -0
  384. package/dist/plugin-sdk/agents/pi-embedded-helpers.d.ts +7 -0
  385. package/dist/plugin-sdk/agents/pi-embedded-runner/model.d.ts +1 -0
  386. package/dist/plugin-sdk/agents/pi-embedded-runner/run/params.d.ts +5 -0
  387. package/dist/plugin-sdk/agents/pi-embedded-runner.d.ts +25 -0
  388. package/dist/plugin-sdk/agents/pi-embedded-utils.d.ts +7 -0
  389. package/dist/plugin-sdk/agents/pi-embedded.d.ts +25 -0
  390. package/dist/plugin-sdk/agents/pi-model-discovery.d.ts +4 -0
  391. package/dist/plugin-sdk/agents/pi-settings.d.ts +19 -0
  392. package/dist/plugin-sdk/agents/pi-tools.abort.d.ts +2 -0
  393. package/dist/plugin-sdk/agents/pi-tools.before-tool-call.d.ts +29 -0
  394. package/dist/plugin-sdk/agents/pi-tools.d.ts +69 -0
  395. package/dist/plugin-sdk/agents/pi-tools.policy.d.ts +37 -0
  396. package/dist/plugin-sdk/agents/pi-tools.read.d.ts +44 -0
  397. package/dist/plugin-sdk/agents/pi-tools.schema.d.ts +3 -0
  398. package/dist/plugin-sdk/agents/pi-tools.types.d.ts +2 -0
  399. package/dist/plugin-sdk/agents/pty-dsr.d.ts +5 -0
  400. package/dist/plugin-sdk/agents/pty-keys.d.ts +13 -0
  401. package/dist/plugin-sdk/agents/sandbox/browser-bridges.d.ts +7 -0
  402. package/dist/plugin-sdk/agents/sandbox/browser.d.ts +12 -0
  403. package/dist/plugin-sdk/agents/sandbox/config-hash.d.ts +17 -0
  404. package/dist/plugin-sdk/agents/sandbox/config.d.ts +26 -0
  405. package/dist/plugin-sdk/agents/sandbox/constants.d.ts +19 -0
  406. package/dist/plugin-sdk/agents/sandbox/context.d.ts +12 -0
  407. package/dist/plugin-sdk/agents/sandbox/docker.d.ts +40 -0
  408. package/dist/plugin-sdk/agents/sandbox/fs-bridge.d.ts +56 -0
  409. package/dist/plugin-sdk/agents/sandbox/fs-paths.d.ts +28 -0
  410. package/dist/plugin-sdk/agents/sandbox/manage.d.ts +13 -0
  411. package/dist/plugin-sdk/agents/sandbox/prune.d.ts +3 -0
  412. package/dist/plugin-sdk/agents/sandbox/registry.d.ts +31 -0
  413. package/dist/plugin-sdk/agents/sandbox/runtime-status.d.ts +18 -0
  414. package/dist/plugin-sdk/agents/sandbox/shared.d.ts +4 -0
  415. package/dist/plugin-sdk/agents/sandbox/tool-policy.d.ts +4 -0
  416. package/dist/plugin-sdk/agents/sandbox/types.d.ts +76 -0
  417. package/dist/plugin-sdk/agents/sandbox/types.docker.d.ts +25 -0
  418. package/dist/plugin-sdk/agents/sandbox/workspace.d.ts +1 -0
  419. package/dist/plugin-sdk/agents/sandbox-paths.d.ts +23 -0
  420. package/dist/plugin-sdk/agents/sandbox.d.ts +8 -0
  421. package/dist/plugin-sdk/agents/schema/clean-for-gemini.d.ts +2 -0
  422. package/dist/plugin-sdk/agents/schema/typebox.d.ts +14 -0
  423. package/dist/plugin-sdk/agents/session-slug.d.ts +1 -0
  424. package/dist/plugin-sdk/agents/session-write-lock.d.ts +21 -0
  425. package/dist/plugin-sdk/agents/shell-utils.d.ts +7 -0
  426. package/dist/plugin-sdk/agents/skills/bundled-dir.d.ts +7 -0
  427. package/dist/plugin-sdk/agents/skills/config.d.ts +13 -0
  428. package/dist/plugin-sdk/agents/skills/env-overrides.d.ts +10 -0
  429. package/dist/plugin-sdk/agents/skills/frontmatter.d.ts +6 -0
  430. package/dist/plugin-sdk/agents/skills/plugin-skills.d.ts +5 -0
  431. package/dist/plugin-sdk/agents/skills/refresh.d.ts +19 -0
  432. package/dist/plugin-sdk/agents/skills/serialize.d.ts +1 -0
  433. package/dist/plugin-sdk/agents/skills/types.d.ts +80 -0
  434. package/dist/plugin-sdk/agents/skills/workspace.d.ts +49 -0
  435. package/dist/plugin-sdk/agents/skills.d.ts +7 -0
  436. package/dist/plugin-sdk/agents/subagent-announce-queue.d.ts +23 -0
  437. package/dist/plugin-sdk/agents/subagent-announce.d.ts +34 -0
  438. package/dist/plugin-sdk/agents/subagent-depth.d.ts +11 -0
  439. package/dist/plugin-sdk/agents/subagent-registry.d.ts +62 -0
  440. package/dist/plugin-sdk/agents/subagent-registry.store.d.ts +5 -0
  441. package/dist/plugin-sdk/agents/synthetic-models.d.ts +160 -0
  442. package/dist/plugin-sdk/agents/system-prompt-params.d.ts +30 -0
  443. package/dist/plugin-sdk/agents/system-prompt-report.d.ts +20 -0
  444. package/dist/plugin-sdk/agents/system-prompt.d.ts +78 -0
  445. package/dist/plugin-sdk/agents/timeout.d.ts +8 -0
  446. package/dist/plugin-sdk/agents/together-models.d.ts +4 -0
  447. package/dist/plugin-sdk/agents/tool-images.d.ts +19 -0
  448. package/dist/plugin-sdk/agents/tool-policy-pipeline.d.ts +27 -0
  449. package/dist/plugin-sdk/agents/tool-policy.d.ts +39 -0
  450. package/dist/plugin-sdk/agents/tool-summaries.d.ts +2 -0
  451. package/dist/plugin-sdk/agents/tools/agent-step.d.ts +15 -0
  452. package/dist/plugin-sdk/agents/tools/agents-list-tool.d.ts +6 -0
  453. package/dist/plugin-sdk/agents/tools/browser-tool.d.ts +5 -0
  454. package/dist/plugin-sdk/agents/tools/browser-tool.schema.d.ts +50 -0
  455. package/dist/plugin-sdk/agents/tools/canvas-tool.d.ts +2 -0
  456. package/dist/plugin-sdk/agents/tools/common.d.ts +56 -0
  457. package/dist/plugin-sdk/agents/tools/cron-tool.d.ts +6 -0
  458. package/dist/plugin-sdk/agents/tools/discord-actions-guild.d.ts +4 -0
  459. package/dist/plugin-sdk/agents/tools/discord-actions-messaging.d.ts +4 -0
  460. package/dist/plugin-sdk/agents/tools/discord-actions-moderation.d.ts +4 -0
  461. package/dist/plugin-sdk/agents/tools/discord-actions-presence.d.ts +4 -0
  462. package/dist/plugin-sdk/agents/tools/discord-actions.d.ts +3 -0
  463. package/dist/plugin-sdk/agents/tools/gateway-tool.d.ts +6 -0
  464. package/dist/plugin-sdk/agents/tools/gateway.d.ts +14 -0
  465. package/dist/plugin-sdk/agents/tools/image-tool.d.ts +35 -0
  466. package/dist/plugin-sdk/agents/tools/image-tool.helpers.d.ts +21 -0
  467. package/dist/plugin-sdk/agents/tools/memory-tool.d.ts +10 -0
  468. package/dist/plugin-sdk/agents/tools/message-tool.d.ts +18 -0
  469. package/dist/plugin-sdk/agents/tools/nodes-tool.d.ts +6 -0
  470. package/dist/plugin-sdk/agents/tools/nodes-utils.d.ts +20 -0
  471. package/dist/plugin-sdk/agents/tools/session-status-tool.d.ts +6 -0
  472. package/dist/plugin-sdk/agents/tools/sessions-announce-target.d.ts +5 -0
  473. package/dist/plugin-sdk/agents/tools/sessions-helpers.d.ts +90 -0
  474. package/dist/plugin-sdk/agents/tools/sessions-history-tool.d.ts +5 -0
  475. package/dist/plugin-sdk/agents/tools/sessions-list-tool.d.ts +5 -0
  476. package/dist/plugin-sdk/agents/tools/sessions-send-helpers.d.ts +34 -0
  477. package/dist/plugin-sdk/agents/tools/sessions-send-tool.a2a.d.ts +12 -0
  478. package/dist/plugin-sdk/agents/tools/sessions-send-tool.d.ts +7 -0
  479. package/dist/plugin-sdk/agents/tools/sessions-spawn-tool.d.ts +15 -0
  480. package/dist/plugin-sdk/agents/tools/slack-actions.d.ts +15 -0
  481. package/dist/plugin-sdk/agents/tools/subagents-tool.d.ts +4 -0
  482. package/dist/plugin-sdk/agents/tools/telegram-actions.d.ts +9 -0
  483. package/dist/plugin-sdk/agents/tools/tts-tool.d.ts +7 -0
  484. package/dist/plugin-sdk/agents/tools/web-fetch-utils.d.ts +18 -0
  485. package/dist/plugin-sdk/agents/tools/web-fetch.d.ts +25 -0
  486. package/dist/plugin-sdk/agents/tools/web-search.d.ts +71 -0
  487. package/dist/plugin-sdk/agents/tools/web-shared.d.ts +17 -0
  488. package/dist/plugin-sdk/agents/tools/web-tools.d.ts +2 -0
  489. package/dist/plugin-sdk/agents/tools/whatsapp-actions.d.ts +3 -0
  490. package/dist/plugin-sdk/agents/usage.d.ts +45 -0
  491. package/dist/plugin-sdk/agents/venice-models.d.ts +238 -0
  492. package/dist/plugin-sdk/agents/workspace-dir.d.ts +2 -0
  493. package/dist/plugin-sdk/agents/workspace-run.d.ts +18 -0
  494. package/dist/plugin-sdk/agents/workspace-templates.d.ts +6 -0
  495. package/dist/plugin-sdk/agents/workspace.d.ts +34 -0
  496. package/dist/plugin-sdk/auto-reply/chunk.d.ts +45 -0
  497. package/dist/plugin-sdk/auto-reply/command-auth.d.ts +17 -0
  498. package/dist/plugin-sdk/auto-reply/command-detection.d.ts +13 -0
  499. package/dist/plugin-sdk/auto-reply/commands-args.d.ts +3 -0
  500. package/dist/plugin-sdk/auto-reply/commands-registry.d.ts +54 -0
  501. package/dist/plugin-sdk/auto-reply/commands-registry.data.d.ts +3 -0
  502. package/dist/plugin-sdk/auto-reply/commands-registry.types.d.ts +66 -0
  503. package/dist/plugin-sdk/auto-reply/dispatch.d.ts +32 -0
  504. package/dist/plugin-sdk/auto-reply/envelope.d.ts +58 -0
  505. package/dist/plugin-sdk/auto-reply/group-activation.d.ts +6 -0
  506. package/dist/plugin-sdk/auto-reply/heartbeat-reply-payload.d.ts +2 -0
  507. package/dist/plugin-sdk/auto-reply/heartbeat.d.ts +26 -0
  508. package/dist/plugin-sdk/auto-reply/inbound-debounce.d.ts +16 -0
  509. package/dist/plugin-sdk/auto-reply/media-note.d.ts +2 -0
  510. package/dist/plugin-sdk/auto-reply/model.d.ts +8 -0
  511. package/dist/plugin-sdk/auto-reply/reply/abort.d.ts +22 -0
  512. package/dist/plugin-sdk/auto-reply/reply/agent-runner-execution.d.ts +49 -0
  513. package/dist/plugin-sdk/auto-reply/reply/agent-runner-helpers.d.ts +17 -0
  514. package/dist/plugin-sdk/auto-reply/reply/agent-runner-memory.d.ts +20 -0
  515. package/dist/plugin-sdk/auto-reply/reply/agent-runner-payloads.d.ts +25 -0
  516. package/dist/plugin-sdk/auto-reply/reply/agent-runner-utils.d.ts +30 -0
  517. package/dist/plugin-sdk/auto-reply/reply/agent-runner.d.ts +38 -0
  518. package/dist/plugin-sdk/auto-reply/reply/bash-command.d.ts +19 -0
  519. package/dist/plugin-sdk/auto-reply/reply/block-reply-coalescer.d.ts +15 -0
  520. package/dist/plugin-sdk/auto-reply/reply/block-reply-pipeline.d.ts +31 -0
  521. package/dist/plugin-sdk/auto-reply/reply/block-streaming.d.ts +22 -0
  522. package/dist/plugin-sdk/auto-reply/reply/body.d.ts +10 -0
  523. package/dist/plugin-sdk/auto-reply/reply/commands-allowlist.d.ts +2 -0
  524. package/dist/plugin-sdk/auto-reply/reply/commands-approve.d.ts +2 -0
  525. package/dist/plugin-sdk/auto-reply/reply/commands-bash.d.ts +2 -0
  526. package/dist/plugin-sdk/auto-reply/reply/commands-compact.d.ts +2 -0
  527. package/dist/plugin-sdk/auto-reply/reply/commands-config.d.ts +3 -0
  528. package/dist/plugin-sdk/auto-reply/reply/commands-context-report.d.ts +3 -0
  529. package/dist/plugin-sdk/auto-reply/reply/commands-context.d.ts +12 -0
  530. package/dist/plugin-sdk/auto-reply/reply/commands-core.d.ts +2 -0
  531. package/dist/plugin-sdk/auto-reply/reply/commands-info.d.ts +10 -0
  532. package/dist/plugin-sdk/auto-reply/reply/commands-models.d.ts +23 -0
  533. package/dist/plugin-sdk/auto-reply/reply/commands-plugin.d.ts +13 -0
  534. package/dist/plugin-sdk/auto-reply/reply/commands-session.d.ts +7 -0
  535. package/dist/plugin-sdk/auto-reply/reply/commands-status.d.ts +25 -0
  536. package/dist/plugin-sdk/auto-reply/reply/commands-subagents.d.ts +13 -0
  537. package/dist/plugin-sdk/auto-reply/reply/commands-tts.d.ts +2 -0
  538. package/dist/plugin-sdk/auto-reply/reply/commands-types.d.ts +60 -0
  539. package/dist/plugin-sdk/auto-reply/reply/commands.d.ts +4 -0
  540. package/dist/plugin-sdk/auto-reply/reply/config-commands.d.ts +15 -0
  541. package/dist/plugin-sdk/auto-reply/reply/config-value.d.ts +4 -0
  542. package/dist/plugin-sdk/auto-reply/reply/debug-commands.d.ts +16 -0
  543. package/dist/plugin-sdk/auto-reply/reply/directive-handling.auth.d.ts +19 -0
  544. package/dist/plugin-sdk/auto-reply/reply/directive-handling.d.ts +6 -0
  545. package/dist/plugin-sdk/auto-reply/reply/directive-handling.fast-lane.d.ts +7 -0
  546. package/dist/plugin-sdk/auto-reply/reply/directive-handling.impl.d.ts +3 -0
  547. package/dist/plugin-sdk/auto-reply/reply/directive-handling.model-picker.d.ts +13 -0
  548. package/dist/plugin-sdk/auto-reply/reply/directive-handling.model.d.ts +42 -0
  549. package/dist/plugin-sdk/auto-reply/reply/directive-handling.params.d.ts +51 -0
  550. package/dist/plugin-sdk/auto-reply/reply/directive-handling.parse.d.ts +62 -0
  551. package/dist/plugin-sdk/auto-reply/reply/directive-handling.persist.d.ts +37 -0
  552. package/dist/plugin-sdk/auto-reply/reply/directive-handling.queue-validation.d.ts +10 -0
  553. package/dist/plugin-sdk/auto-reply/reply/directive-handling.shared.d.ts +16 -0
  554. package/dist/plugin-sdk/auto-reply/reply/directive-parsing.d.ts +5 -0
  555. package/dist/plugin-sdk/auto-reply/reply/directives.d.ts +38 -0
  556. package/dist/plugin-sdk/auto-reply/reply/dispatch-from-config.d.ts +16 -0
  557. package/dist/plugin-sdk/auto-reply/reply/dispatcher-registry.d.ts +24 -0
  558. package/dist/plugin-sdk/auto-reply/reply/elevated-unavailable.d.ts +8 -0
  559. package/dist/plugin-sdk/auto-reply/reply/exec/directive.d.ts +20 -0
  560. package/dist/plugin-sdk/auto-reply/reply/exec.d.ts +1 -0
  561. package/dist/plugin-sdk/auto-reply/reply/followup-runner.d.ts +16 -0
  562. package/dist/plugin-sdk/auto-reply/reply/get-reply-directives-apply.d.ts +64 -0
  563. package/dist/plugin-sdk/auto-reply/reply/get-reply-directives-utils.d.ts +2 -0
  564. package/dist/plugin-sdk/auto-reply/reply/get-reply-directives.d.ts +92 -0
  565. package/dist/plugin-sdk/auto-reply/reply/get-reply-inline-actions.d.ts +59 -0
  566. package/dist/plugin-sdk/auto-reply/reply/get-reply-run.d.ts +69 -0
  567. package/dist/plugin-sdk/auto-reply/reply/get-reply.d.ts +4 -0
  568. package/dist/plugin-sdk/auto-reply/reply/groups.d.ts +26 -0
  569. package/dist/plugin-sdk/auto-reply/reply/history.d.ts +72 -0
  570. package/dist/plugin-sdk/auto-reply/reply/inbound-context.d.ts +8 -0
  571. package/dist/plugin-sdk/auto-reply/reply/inbound-dedupe.d.ts +8 -0
  572. package/dist/plugin-sdk/auto-reply/reply/inbound-meta.d.ts +3 -0
  573. package/dist/plugin-sdk/auto-reply/reply/inbound-text.d.ts +1 -0
  574. package/dist/plugin-sdk/auto-reply/reply/line-directives.d.ts +22 -0
  575. package/dist/plugin-sdk/auto-reply/reply/memory-flush.d.ts +23 -0
  576. package/dist/plugin-sdk/auto-reply/reply/mentions.d.ts +19 -0
  577. package/dist/plugin-sdk/auto-reply/reply/model-selection.d.ts +64 -0
  578. package/dist/plugin-sdk/auto-reply/reply/normalize-reply.d.ts +13 -0
  579. package/dist/plugin-sdk/auto-reply/reply/provider-dispatcher.d.ts +19 -0
  580. package/dist/plugin-sdk/auto-reply/reply/queue/cleanup.d.ts +6 -0
  581. package/dist/plugin-sdk/auto-reply/reply/queue/directive.d.ts +15 -0
  582. package/dist/plugin-sdk/auto-reply/reply/queue/drain.d.ts +2 -0
  583. package/dist/plugin-sdk/auto-reply/reply/queue/enqueue.d.ts +3 -0
  584. package/dist/plugin-sdk/auto-reply/reply/queue/normalize.d.ts +3 -0
  585. package/dist/plugin-sdk/auto-reply/reply/queue/settings.d.ts +2 -0
  586. package/dist/plugin-sdk/auto-reply/reply/queue/state.d.ts +19 -0
  587. package/dist/plugin-sdk/auto-reply/reply/queue/types.d.ts +84 -0
  588. package/dist/plugin-sdk/auto-reply/reply/queue.d.ts +8 -0
  589. package/dist/plugin-sdk/auto-reply/reply/reply-delivery.d.ts +27 -0
  590. package/dist/plugin-sdk/auto-reply/reply/reply-directives.d.ts +14 -0
  591. package/dist/plugin-sdk/auto-reply/reply/reply-dispatcher.d.ts +52 -0
  592. package/dist/plugin-sdk/auto-reply/reply/reply-elevated.d.ts +16 -0
  593. package/dist/plugin-sdk/auto-reply/reply/reply-inline.d.ts +8 -0
  594. package/dist/plugin-sdk/auto-reply/reply/reply-payloads.d.ts +22 -0
  595. package/dist/plugin-sdk/auto-reply/reply/reply-tags.d.ts +6 -0
  596. package/dist/plugin-sdk/auto-reply/reply/reply-threading.d.ts +9 -0
  597. package/dist/plugin-sdk/auto-reply/reply/response-prefix-template.d.ts +51 -0
  598. package/dist/plugin-sdk/auto-reply/reply/route-reply.d.ts +56 -0
  599. package/dist/plugin-sdk/auto-reply/reply/session-reset-model.d.ts +24 -0
  600. package/dist/plugin-sdk/auto-reply/reply/session-reset-prompt.d.ts +1 -0
  601. package/dist/plugin-sdk/auto-reply/reply/session-run-accounting.d.ts +11 -0
  602. package/dist/plugin-sdk/auto-reply/reply/session-updates.d.ts +34 -0
  603. package/dist/plugin-sdk/auto-reply/reply/session-usage.d.ts +21 -0
  604. package/dist/plugin-sdk/auto-reply/reply/session.d.ts +26 -0
  605. package/dist/plugin-sdk/auto-reply/reply/stage-sandbox-media.d.ts +9 -0
  606. package/dist/plugin-sdk/auto-reply/reply/subagents-utils.d.ts +7 -0
  607. package/dist/plugin-sdk/auto-reply/reply/typing-mode.d.ts +27 -0
  608. package/dist/plugin-sdk/auto-reply/reply/typing.d.ts +18 -0
  609. package/dist/plugin-sdk/auto-reply/reply/untrusted-context.d.ts +1 -0
  610. package/dist/plugin-sdk/auto-reply/reply.d.ts +6 -0
  611. package/dist/plugin-sdk/auto-reply/send-policy.d.ts +6 -0
  612. package/dist/plugin-sdk/auto-reply/skill-commands.d.ts +18 -0
  613. package/dist/plugin-sdk/auto-reply/status.d.ts +55 -0
  614. package/dist/plugin-sdk/auto-reply/templating.d.ts +152 -0
  615. package/dist/plugin-sdk/auto-reply/thinking.d.ts +22 -0
  616. package/dist/plugin-sdk/auto-reply/tokens.d.ts +3 -0
  617. package/dist/plugin-sdk/auto-reply/types.d.ts +61 -0
  618. package/dist/plugin-sdk/browser/bridge-auth-registry.d.ts +8 -0
  619. package/dist/plugin-sdk/browser/bridge-server.d.ts +18 -0
  620. package/dist/plugin-sdk/browser/cdp.d.ts +123 -0
  621. package/dist/plugin-sdk/browser/cdp.helpers.d.ts +13 -0
  622. package/dist/plugin-sdk/browser/chrome.d.ts +20 -0
  623. package/dist/plugin-sdk/browser/chrome.executables.d.ts +9 -0
  624. package/dist/plugin-sdk/browser/chrome.profile-decoration.d.ts +10 -0
  625. package/dist/plugin-sdk/browser/client-actions-core.d.ts +144 -0
  626. package/dist/plugin-sdk/browser/client-actions-observe.d.ts +68 -0
  627. package/dist/plugin-sdk/browser/client-actions-state.d.ts +90 -0
  628. package/dist/plugin-sdk/browser/client-actions-types.d.ts +18 -0
  629. package/dist/plugin-sdk/browser/client-actions.d.ts +4 -0
  630. package/dist/plugin-sdk/browser/client-fetch.d.ts +20 -0
  631. package/dist/plugin-sdk/browser/client.d.ts +147 -0
  632. package/dist/plugin-sdk/browser/config.d.ts +39 -0
  633. package/dist/plugin-sdk/browser/constants.d.ts +8 -0
  634. package/dist/plugin-sdk/browser/control-auth.d.ts +13 -0
  635. package/dist/plugin-sdk/browser/control-service.d.ts +5 -0
  636. package/dist/plugin-sdk/browser/csrf.d.ts +8 -0
  637. package/dist/plugin-sdk/browser/extension-relay.d.ts +15 -0
  638. package/dist/plugin-sdk/browser/http-auth.d.ts +5 -0
  639. package/dist/plugin-sdk/browser/paths.d.ts +27 -0
  640. package/dist/plugin-sdk/browser/profiles-service.d.ts +25 -0
  641. package/dist/plugin-sdk/browser/profiles.d.ts +30 -0
  642. package/dist/plugin-sdk/browser/proxy-files.d.ts +7 -0
  643. package/dist/plugin-sdk/browser/pw-ai-module.d.ts +6 -0
  644. package/dist/plugin-sdk/browser/pw-ai-state.d.ts +2 -0
  645. package/dist/plugin-sdk/browser/pw-ai.d.ts +2 -0
  646. package/dist/plugin-sdk/browser/pw-role-snapshot.d.ts +35 -0
  647. package/dist/plugin-sdk/browser/pw-session.d.ts +160 -0
  648. package/dist/plugin-sdk/browser/pw-tools-core.activity.d.ts +21 -0
  649. package/dist/plugin-sdk/browser/pw-tools-core.d.ts +8 -0
  650. package/dist/plugin-sdk/browser/pw-tools-core.downloads.d.ts +34 -0
  651. package/dist/plugin-sdk/browser/pw-tools-core.interactions.d.ts +114 -0
  652. package/dist/plugin-sdk/browser/pw-tools-core.responses.d.ts +13 -0
  653. package/dist/plugin-sdk/browser/pw-tools-core.shared.d.ts +6 -0
  654. package/dist/plugin-sdk/browser/pw-tools-core.snapshot.d.ts +64 -0
  655. package/dist/plugin-sdk/browser/pw-tools-core.state.d.ts +46 -0
  656. package/dist/plugin-sdk/browser/pw-tools-core.storage.d.ts +47 -0
  657. package/dist/plugin-sdk/browser/pw-tools-core.trace.d.ts +12 -0
  658. package/dist/plugin-sdk/browser/resolved-config-refresh.d.ts +12 -0
  659. package/dist/plugin-sdk/browser/routes/agent.act.d.ts +3 -0
  660. package/dist/plugin-sdk/browser/routes/agent.act.shared.d.ts +10 -0
  661. package/dist/plugin-sdk/browser/routes/agent.d.ts +3 -0
  662. package/dist/plugin-sdk/browser/routes/agent.debug.d.ts +3 -0
  663. package/dist/plugin-sdk/browser/routes/agent.shared.d.ts +9 -0
  664. package/dist/plugin-sdk/browser/routes/agent.snapshot.d.ts +3 -0
  665. package/dist/plugin-sdk/browser/routes/agent.storage.d.ts +3 -0
  666. package/dist/plugin-sdk/browser/routes/basic.d.ts +3 -0
  667. package/dist/plugin-sdk/browser/routes/dispatcher.d.ts +16 -0
  668. package/dist/plugin-sdk/browser/routes/index.d.ts +3 -0
  669. package/dist/plugin-sdk/browser/routes/path-output.d.ts +1 -0
  670. package/dist/plugin-sdk/browser/routes/tabs.d.ts +3 -0
  671. package/dist/plugin-sdk/browser/routes/types.d.ts +20 -0
  672. package/dist/plugin-sdk/browser/routes/utils.d.ts +15 -0
  673. package/dist/plugin-sdk/browser/screenshot.d.ts +9 -0
  674. package/dist/plugin-sdk/browser/server-context.d.ts +4 -0
  675. package/dist/plugin-sdk/browser/server-context.types.d.ts +79 -0
  676. package/dist/plugin-sdk/browser/server-middleware.d.ts +6 -0
  677. package/dist/plugin-sdk/browser/target-id.d.ts +11 -0
  678. package/dist/plugin-sdk/browser/trash.d.ts +1 -0
  679. package/dist/plugin-sdk/channel-web.d.ts +6 -0
  680. package/dist/plugin-sdk/channels/account-summary.d.ts +17 -0
  681. package/dist/plugin-sdk/channels/ack-reactions.d.ts +29 -0
  682. package/dist/plugin-sdk/channels/allowlist-match.d.ts +15 -0
  683. package/dist/plugin-sdk/channels/allowlists/resolve-utils.d.ts +20 -0
  684. package/dist/plugin-sdk/channels/channel-config.d.ts +39 -0
  685. package/dist/plugin-sdk/channels/chat-type.d.ts +2 -0
  686. package/dist/plugin-sdk/channels/command-gating.d.ts +20 -0
  687. package/dist/plugin-sdk/channels/conversation-label.d.ts +2 -0
  688. package/dist/plugin-sdk/channels/dock.d.ts +36 -0
  689. package/dist/plugin-sdk/channels/location.d.ts +21 -0
  690. package/dist/plugin-sdk/channels/logging.d.ts +20 -0
  691. package/dist/plugin-sdk/channels/mention-gating.d.ts +27 -0
  692. package/dist/plugin-sdk/channels/plugins/actions/discord/handle-action.d.ts +3 -0
  693. package/dist/plugin-sdk/channels/plugins/actions/discord/handle-action.guild-admin.d.ts +9 -0
  694. package/dist/plugin-sdk/channels/plugins/actions/discord.d.ts +2 -0
  695. package/dist/plugin-sdk/channels/plugins/actions/signal.d.ts +2 -0
  696. package/dist/plugin-sdk/channels/plugins/actions/telegram.d.ts +2 -0
  697. package/dist/plugin-sdk/channels/plugins/agent-tools/whatsapp-login.d.ts +2 -0
  698. package/dist/plugin-sdk/channels/plugins/allowlist-match.d.ts +2 -0
  699. package/dist/plugin-sdk/channels/plugins/bluebubbles-actions.d.ts +48 -0
  700. package/dist/plugin-sdk/channels/plugins/channel-config.d.ts +2 -0
  701. package/dist/plugin-sdk/channels/plugins/config-helpers.d.ts +14 -0
  702. package/dist/plugin-sdk/channels/plugins/config-schema.d.ts +3 -0
  703. package/dist/plugin-sdk/channels/plugins/config-writes.d.ts +7 -0
  704. package/dist/plugin-sdk/channels/plugins/directory-config.d.ts +16 -0
  705. package/dist/plugin-sdk/channels/plugins/group-mentions.d.ts +28 -0
  706. package/dist/plugin-sdk/channels/plugins/helpers.d.ts +8 -0
  707. package/dist/plugin-sdk/channels/plugins/index.d.ts +8 -0
  708. package/dist/plugin-sdk/channels/plugins/media-limits.d.ts +9 -0
  709. package/dist/plugin-sdk/channels/plugins/message-action-names.d.ts +2 -0
  710. package/dist/plugin-sdk/channels/plugins/message-actions.d.ts +7 -0
  711. package/dist/plugin-sdk/channels/plugins/normalize/discord.d.ts +2 -0
  712. package/dist/plugin-sdk/channels/plugins/normalize/imessage.d.ts +2 -0
  713. package/dist/plugin-sdk/channels/plugins/normalize/signal.d.ts +2 -0
  714. package/dist/plugin-sdk/channels/plugins/normalize/slack.d.ts +2 -0
  715. package/dist/plugin-sdk/channels/plugins/normalize/telegram.d.ts +2 -0
  716. package/dist/plugin-sdk/channels/plugins/normalize/whatsapp.d.ts +2 -0
  717. package/dist/plugin-sdk/channels/plugins/onboarding/channel-access.d.ts +31 -0
  718. package/dist/plugin-sdk/channels/plugins/onboarding/discord.d.ts +2 -0
  719. package/dist/plugin-sdk/channels/plugins/onboarding/helpers.d.ts +3 -0
  720. package/dist/plugin-sdk/channels/plugins/onboarding/imessage.d.ts +2 -0
  721. package/dist/plugin-sdk/channels/plugins/onboarding/signal.d.ts +3 -0
  722. package/dist/plugin-sdk/channels/plugins/onboarding/slack.d.ts +2 -0
  723. package/dist/plugin-sdk/channels/plugins/onboarding/telegram.d.ts +2 -0
  724. package/dist/plugin-sdk/channels/plugins/onboarding/whatsapp.d.ts +2 -0
  725. package/dist/plugin-sdk/channels/plugins/onboarding-types.d.ts +77 -0
  726. package/dist/plugin-sdk/channels/plugins/outbound/load.d.ts +2 -0
  727. package/dist/plugin-sdk/channels/plugins/pairing-message.d.ts +1 -0
  728. package/dist/plugin-sdk/channels/plugins/pairing.d.ts +16 -0
  729. package/dist/plugin-sdk/channels/plugins/setup-helpers.d.ts +13 -0
  730. package/dist/plugin-sdk/channels/plugins/status-issues/bluebubbles.d.ts +2 -0
  731. package/dist/plugin-sdk/channels/plugins/status-issues/discord.d.ts +2 -0
  732. package/dist/plugin-sdk/channels/plugins/status-issues/shared.d.ts +11 -0
  733. package/dist/plugin-sdk/channels/plugins/status-issues/telegram.d.ts +2 -0
  734. package/dist/plugin-sdk/channels/plugins/status-issues/whatsapp.d.ts +2 -0
  735. package/dist/plugin-sdk/channels/plugins/types.adapters.d.ts +297 -0
  736. package/dist/plugin-sdk/channels/plugins/types.core.d.ts +329 -0
  737. package/dist/plugin-sdk/channels/plugins/types.d.ts +6 -0
  738. package/dist/plugin-sdk/channels/plugins/types.plugin.d.ts +53 -0
  739. package/dist/plugin-sdk/channels/plugins/whatsapp-heartbeat.d.ts +11 -0
  740. package/dist/plugin-sdk/channels/registry.d.ts +16 -0
  741. package/dist/plugin-sdk/channels/reply-prefix.d.ts +24 -0
  742. package/dist/plugin-sdk/channels/sender-label.d.ts +9 -0
  743. package/dist/plugin-sdk/channels/session.d.ts +18 -0
  744. package/dist/plugin-sdk/channels/typing.d.ts +12 -0
  745. package/dist/plugin-sdk/channels/web/index.d.ts +1 -0
  746. package/dist/plugin-sdk/cli/cli-name.d.ts +3 -0
  747. package/dist/plugin-sdk/cli/cli-utils.d.ts +19 -0
  748. package/dist/plugin-sdk/cli/command-format.d.ts +1 -0
  749. package/dist/plugin-sdk/cli/deps.d.ts +18 -0
  750. package/dist/plugin-sdk/cli/memory-cli.d.ts +12 -0
  751. package/dist/plugin-sdk/cli/nodes-camera.d.ts +32 -0
  752. package/dist/plugin-sdk/cli/nodes-canvas.d.ts +10 -0
  753. package/dist/plugin-sdk/cli/nodes-run.d.ts +3 -0
  754. package/dist/plugin-sdk/cli/nodes-screen.d.ts +18 -0
  755. package/dist/plugin-sdk/cli/parse-bytes.d.ts +4 -0
  756. package/dist/plugin-sdk/cli/parse-duration.d.ts +4 -0
  757. package/dist/plugin-sdk/cli/parse-timeout.d.ts +1 -0
  758. package/dist/plugin-sdk/cli/profile-utils.d.ts +2 -0
  759. package/dist/plugin-sdk/cli/progress.d.ts +24 -0
  760. package/dist/plugin-sdk/cli/prompt.d.ts +1 -0
  761. package/dist/plugin-sdk/cli/wait.d.ts +1 -0
  762. package/dist/plugin-sdk/commands/agent/types.d.ts +77 -0
  763. package/dist/plugin-sdk/commands/daemon-runtime.d.ts +8 -0
  764. package/dist/plugin-sdk/commands/health.d.ts +63 -0
  765. package/dist/plugin-sdk/commands/oauth-flow.d.ts +21 -0
  766. package/dist/plugin-sdk/commands/onboard-helpers.d.ts +82 -0
  767. package/dist/plugin-sdk/commands/onboard-types.d.ts +76 -0
  768. package/dist/plugin-sdk/commands/signal-install.d.ts +30 -0
  769. package/dist/plugin-sdk/compat/legacy-names.d.ts +8 -0
  770. package/dist/plugin-sdk/config/agent-dirs.d.ts +14 -0
  771. package/dist/plugin-sdk/config/agent-limits.d.ts +5 -0
  772. package/dist/plugin-sdk/config/backup-rotation.d.ts +5 -0
  773. package/dist/plugin-sdk/config/cache-utils.d.ts +6 -0
  774. package/dist/plugin-sdk/config/config-paths.d.ts +10 -0
  775. package/dist/plugin-sdk/config/config.d.ts +7 -0
  776. package/dist/plugin-sdk/config/defaults.d.ts +18 -0
  777. package/dist/plugin-sdk/config/env-preserve.d.ts +25 -0
  778. package/dist/plugin-sdk/config/env-substitution.d.ts +36 -0
  779. package/dist/plugin-sdk/config/env-vars.d.ts +3 -0
  780. package/dist/plugin-sdk/config/group-policy.d.ts +47 -0
  781. package/dist/plugin-sdk/config/includes.d.ts +32 -0
  782. package/dist/plugin-sdk/config/io.d.ts +55 -0
  783. package/dist/plugin-sdk/config/legacy-migrate.d.ts +5 -0
  784. package/dist/plugin-sdk/config/legacy.d.ts +6 -0
  785. package/dist/plugin-sdk/config/legacy.migrations.d.ts +1 -0
  786. package/dist/plugin-sdk/config/legacy.migrations.part-1.d.ts +2 -0
  787. package/dist/plugin-sdk/config/legacy.migrations.part-2.d.ts +2 -0
  788. package/dist/plugin-sdk/config/legacy.migrations.part-3.d.ts +2 -0
  789. package/dist/plugin-sdk/config/legacy.rules.d.ts +2 -0
  790. package/dist/plugin-sdk/config/legacy.shared.d.ts +19 -0
  791. package/dist/plugin-sdk/config/markdown-tables.d.ts +7 -0
  792. package/dist/plugin-sdk/config/merge-config.d.ts +7 -0
  793. package/dist/plugin-sdk/config/merge-patch.d.ts +5 -0
  794. package/dist/plugin-sdk/config/normalize-paths.d.ts +8 -0
  795. package/dist/plugin-sdk/config/paths.d.ts +57 -0
  796. package/dist/plugin-sdk/config/port-defaults.d.ts +13 -0
  797. package/dist/plugin-sdk/config/runtime-overrides.d.ts +15 -0
  798. package/dist/plugin-sdk/config/sessions/delivery-info.d.ts +12 -0
  799. package/dist/plugin-sdk/config/sessions/group.d.ts +11 -0
  800. package/dist/plugin-sdk/config/sessions/main-session.d.ts +43 -0
  801. package/dist/plugin-sdk/config/sessions/metadata.d.ts +16 -0
  802. package/dist/plugin-sdk/config/sessions/paths.d.ts +21 -0
  803. package/dist/plugin-sdk/config/sessions/reset.d.ts +43 -0
  804. package/dist/plugin-sdk/config/sessions/session-key.d.ts +8 -0
  805. package/dist/plugin-sdk/config/sessions/store.d.ts +99 -0
  806. package/dist/plugin-sdk/config/sessions/transcript.d.ts +18 -0
  807. package/dist/plugin-sdk/config/sessions/types.d.ts +156 -0
  808. package/dist/plugin-sdk/config/sessions.d.ts +10 -0
  809. package/dist/plugin-sdk/config/talk.d.ts +11 -0
  810. package/dist/plugin-sdk/config/telegram-custom-commands.d.ts +24 -0
  811. package/dist/plugin-sdk/config/types.agent-defaults.d.ts +260 -0
  812. package/dist/plugin-sdk/config/types.agents.d.ts +80 -0
  813. package/dist/plugin-sdk/config/types.anima.d.ts +1 -0
  814. package/dist/plugin-sdk/config/types.approvals.d.ts +26 -0
  815. package/dist/plugin-sdk/config/types.auth.d.ts +28 -0
  816. package/dist/plugin-sdk/config/types.base.d.ts +172 -0
  817. package/dist/plugin-sdk/config/types.browser.d.ts +41 -0
  818. package/dist/plugin-sdk/config/types.channels.d.ts +48 -0
  819. package/dist/plugin-sdk/config/types.cron.d.ts +11 -0
  820. package/dist/plugin-sdk/config/types.d.ts +30 -0
  821. package/dist/plugin-sdk/config/types.discord.d.ts +188 -0
  822. package/dist/plugin-sdk/config/types.gateway.d.ts +288 -0
  823. package/dist/plugin-sdk/config/types.googlechat.d.ts +100 -0
  824. package/dist/plugin-sdk/config/types.hooks.d.ts +128 -0
  825. package/dist/plugin-sdk/config/types.imessage.d.ts +71 -0
  826. package/dist/plugin-sdk/config/types.irc.d.ts +96 -0
  827. package/dist/plugin-sdk/config/types.memory.d.ts +45 -0
  828. package/dist/plugin-sdk/config/types.messages.d.ts +121 -0
  829. package/dist/plugin-sdk/config/types.models.d.ts +54 -0
  830. package/dist/plugin-sdk/config/types.msteams.d.ts +101 -0
  831. package/dist/plugin-sdk/config/types.node-host.d.ts +10 -0
  832. package/dist/plugin-sdk/config/types.openclaw.d.ts +114 -0
  833. package/dist/plugin-sdk/config/types.plugins.d.ts +32 -0
  834. package/dist/plugin-sdk/config/types.queue.d.ts +14 -0
  835. package/dist/plugin-sdk/config/types.sandbox.d.ts +78 -0
  836. package/dist/plugin-sdk/config/types.signal.d.ts +86 -0
  837. package/dist/plugin-sdk/config/types.skills.d.ts +28 -0
  838. package/dist/plugin-sdk/config/types.slack.d.ts +150 -0
  839. package/dist/plugin-sdk/config/types.telegram.d.ts +163 -0
  840. package/dist/plugin-sdk/config/types.tools.d.ts +467 -0
  841. package/dist/plugin-sdk/config/types.tts.d.ts +78 -0
  842. package/dist/plugin-sdk/config/types.whatsapp.d.ts +142 -0
  843. package/dist/plugin-sdk/config/validation.d.ts +37 -0
  844. package/dist/plugin-sdk/config/version.d.ts +8 -0
  845. package/dist/plugin-sdk/config/zod-schema.agent-defaults.d.ts +249 -0
  846. package/dist/plugin-sdk/config/zod-schema.agent-runtime.d.ts +856 -0
  847. package/dist/plugin-sdk/config/zod-schema.agents.d.ts +504 -0
  848. package/dist/plugin-sdk/config/zod-schema.allowdeny.d.ts +13 -0
  849. package/dist/plugin-sdk/config/zod-schema.approvals.d.ts +15 -0
  850. package/dist/plugin-sdk/config/zod-schema.channels.d.ts +6 -0
  851. package/dist/plugin-sdk/config/zod-schema.core.d.ts +683 -0
  852. package/dist/plugin-sdk/config/zod-schema.d.ts +3401 -0
  853. package/dist/plugin-sdk/config/zod-schema.hooks.d.ts +79 -0
  854. package/dist/plugin-sdk/config/zod-schema.providers-core.d.ts +3233 -0
  855. package/dist/plugin-sdk/config/zod-schema.providers-whatsapp.d.ts +231 -0
  856. package/dist/plugin-sdk/config/zod-schema.providers.d.ts +1900 -0
  857. package/dist/plugin-sdk/config/zod-schema.sensitive.d.ts +2 -0
  858. package/dist/plugin-sdk/config/zod-schema.session.d.ts +203 -0
  859. package/dist/plugin-sdk/cron/delivery.d.ts +9 -0
  860. package/dist/plugin-sdk/cron/normalize.d.ts +9 -0
  861. package/dist/plugin-sdk/cron/parse.d.ts +1 -0
  862. package/dist/plugin-sdk/cron/payload-migration.d.ts +3 -0
  863. package/dist/plugin-sdk/cron/schedule.d.ts +2 -0
  864. package/dist/plugin-sdk/cron/service/jobs.d.ts +21 -0
  865. package/dist/plugin-sdk/cron/service/locked.d.ts +2 -0
  866. package/dist/plugin-sdk/cron/service/normalize.d.ts +17 -0
  867. package/dist/plugin-sdk/cron/service/ops.d.ts +43 -0
  868. package/dist/plugin-sdk/cron/service/state.d.ts +121 -0
  869. package/dist/plugin-sdk/cron/service/store.d.ts +9 -0
  870. package/dist/plugin-sdk/cron/service/timer.d.ts +25 -0
  871. package/dist/plugin-sdk/cron/service.d.ts +48 -0
  872. package/dist/plugin-sdk/cron/session-reaper.d.ts +35 -0
  873. package/dist/plugin-sdk/cron/store.d.ts +6 -0
  874. package/dist/plugin-sdk/cron/types.d.ts +95 -0
  875. package/dist/plugin-sdk/daemon/constants.d.ts +30 -0
  876. package/dist/plugin-sdk/discord/accounts.d.ts +9 -0
  877. package/dist/plugin-sdk/discord/audit.d.ts +2 -0
  878. package/dist/plugin-sdk/discord/directory-live.d.ts +4 -0
  879. package/dist/plugin-sdk/discord/monitor/allow-list.d.ts +1 -0
  880. package/dist/plugin-sdk/discord/monitor/gateway-registry.d.ts +3 -0
  881. package/dist/plugin-sdk/discord/monitor/presence-cache.d.ts +1 -0
  882. package/dist/plugin-sdk/discord/monitor.d.ts +3 -0
  883. package/dist/plugin-sdk/discord/pluralkit.d.ts +1 -0
  884. package/dist/plugin-sdk/discord/probe.d.ts +3 -0
  885. package/dist/plugin-sdk/discord/resolve-channels.d.ts +1 -0
  886. package/dist/plugin-sdk/discord/resolve-users.d.ts +1 -0
  887. package/dist/plugin-sdk/discord/send.d.ts +6 -0
  888. package/dist/plugin-sdk/discord/targets.d.ts +2 -0
  889. package/dist/plugin-sdk/gateway/auth-rate-limit.d.ts +59 -0
  890. package/dist/plugin-sdk/gateway/auth.d.ts +48 -0
  891. package/dist/plugin-sdk/gateway/call.d.ts +51 -0
  892. package/dist/plugin-sdk/gateway/chat-abort.d.ts +44 -0
  893. package/dist/plugin-sdk/gateway/chat-sanitize.d.ts +4 -0
  894. package/dist/plugin-sdk/gateway/client.d.ts +63 -0
  895. package/dist/plugin-sdk/gateway/control-ui-shared.d.ts +9 -0
  896. package/dist/plugin-sdk/gateway/device-auth.d.ts +12 -0
  897. package/dist/plugin-sdk/gateway/exec-approval-manager.d.ts +44 -0
  898. package/dist/plugin-sdk/gateway/net.d.ts +57 -0
  899. package/dist/plugin-sdk/gateway/node-registry.d.ts +60 -0
  900. package/dist/plugin-sdk/gateway/protocol/client-info.d.ts +58 -0
  901. package/dist/plugin-sdk/gateway/protocol/index.d.ts +661 -0
  902. package/dist/plugin-sdk/gateway/protocol/schema/agent.d.ts +86 -0
  903. package/dist/plugin-sdk/gateway/protocol/schema/agents-models-skills.d.ts +152 -0
  904. package/dist/plugin-sdk/gateway/protocol/schema/channels.d.ts +126 -0
  905. package/dist/plugin-sdk/gateway/protocol/schema/config.d.ts +51 -0
  906. package/dist/plugin-sdk/gateway/protocol/schema/cron.d.ts +353 -0
  907. package/dist/plugin-sdk/gateway/protocol/schema/devices.d.ts +38 -0
  908. package/dist/plugin-sdk/gateway/protocol/schema/error-codes.d.ts +14 -0
  909. package/dist/plugin-sdk/gateway/protocol/schema/exec-approvals.d.ts +163 -0
  910. package/dist/plugin-sdk/gateway/protocol/schema/frames.d.ts +164 -0
  911. package/dist/plugin-sdk/gateway/protocol/schema/logs-chat.d.ts +45 -0
  912. package/dist/plugin-sdk/gateway/protocol/schema/nodes.d.ts +64 -0
  913. package/dist/plugin-sdk/gateway/protocol/schema/primitives.d.ts +4 -0
  914. package/dist/plugin-sdk/gateway/protocol/schema/protocol-schemas.d.ts +3 -0
  915. package/dist/plugin-sdk/gateway/protocol/schema/sessions.d.ts +76 -0
  916. package/dist/plugin-sdk/gateway/protocol/schema/snapshot.d.ts +64 -0
  917. package/dist/plugin-sdk/gateway/protocol/schema/types.d.ts +124 -0
  918. package/dist/plugin-sdk/gateway/protocol/schema/wizard.d.ts +86 -0
  919. package/dist/plugin-sdk/gateway/protocol/schema.d.ts +16 -0
  920. package/dist/plugin-sdk/gateway/server/ws-types.d.ts +9 -0
  921. package/dist/plugin-sdk/gateway/server-channels.d.ts +24 -0
  922. package/dist/plugin-sdk/gateway/server-methods/types.d.ts +98 -0
  923. package/dist/plugin-sdk/gateway/server-shared.d.ts +7 -0
  924. package/dist/plugin-sdk/gateway/session-utils.d.ts +71 -0
  925. package/dist/plugin-sdk/gateway/session-utils.fs.d.ts +33 -0
  926. package/dist/plugin-sdk/gateway/session-utils.types.d.ts +84 -0
  927. package/dist/plugin-sdk/globals.d.ts +11 -0
  928. package/dist/plugin-sdk/hooks/internal-hooks.d.ts +95 -0
  929. package/dist/plugin-sdk/hooks/types.d.ts +62 -0
  930. package/dist/plugin-sdk/imessage/accounts.d.ts +8 -0
  931. package/dist/plugin-sdk/imessage/monitor.d.ts +3 -0
  932. package/dist/plugin-sdk/imessage/probe.d.ts +3 -0
  933. package/dist/plugin-sdk/imessage/send.d.ts +1 -0
  934. package/dist/plugin-sdk/imessage/target-parsing-helpers.d.ts +4 -0
  935. package/dist/plugin-sdk/imessage/targets.d.ts +2 -0
  936. package/dist/plugin-sdk/index.d.ts +1 -0
  937. package/dist/plugin-sdk/index.js +27570 -0
  938. package/dist/plugin-sdk/infra/agent-events.d.ts +21 -0
  939. package/dist/plugin-sdk/infra/anima-root.d.ts +1 -0
  940. package/dist/plugin-sdk/infra/archive.d.ts +41 -0
  941. package/dist/plugin-sdk/infra/backoff.d.ts +8 -0
  942. package/dist/plugin-sdk/infra/binaries.d.ts +3 -0
  943. package/dist/plugin-sdk/infra/brew.d.ts +8 -0
  944. package/dist/plugin-sdk/infra/channel-activity.d.ts +18 -0
  945. package/dist/plugin-sdk/infra/channel-summary.d.ts +6 -0
  946. package/dist/plugin-sdk/infra/dedupe.d.ts +11 -0
  947. package/dist/plugin-sdk/infra/device-auth-store.d.ts +18 -0
  948. package/dist/plugin-sdk/infra/device-identity.d.ts +11 -0
  949. package/dist/plugin-sdk/infra/device-pairing.d.ts +96 -0
  950. package/dist/plugin-sdk/infra/diagnostic-events.d.ts +121 -0
  951. package/dist/plugin-sdk/infra/dotenv.d.ts +3 -0
  952. package/dist/plugin-sdk/infra/env.d.ts +11 -0
  953. package/dist/plugin-sdk/infra/errors.d.ts +11 -0
  954. package/dist/plugin-sdk/infra/exec-approvals-allowlist.d.ts +45 -0
  955. package/dist/plugin-sdk/infra/exec-approvals-analysis.d.ts +78 -0
  956. package/dist/plugin-sdk/infra/exec-approvals.d.ts +107 -0
  957. package/dist/plugin-sdk/infra/exec-safety.d.ts +1 -0
  958. package/dist/plugin-sdk/infra/fetch.d.ts +2 -0
  959. package/dist/plugin-sdk/infra/file-lock.d.ts +2 -0
  960. package/dist/plugin-sdk/infra/format-time/format-datetime.d.ts +35 -0
  961. package/dist/plugin-sdk/infra/format-time/format-duration.d.ts +23 -0
  962. package/dist/plugin-sdk/infra/format-time/format-relative.d.ts +39 -0
  963. package/dist/plugin-sdk/infra/git-commit.d.ts +4 -0
  964. package/dist/plugin-sdk/infra/heartbeat-active-hours.d.ts +5 -0
  965. package/dist/plugin-sdk/infra/heartbeat-events-filter.d.ts +3 -0
  966. package/dist/plugin-sdk/infra/heartbeat-events.d.ts +21 -0
  967. package/dist/plugin-sdk/infra/heartbeat-runner.d.ts +45 -0
  968. package/dist/plugin-sdk/infra/heartbeat-visibility.d.ts +17 -0
  969. package/dist/plugin-sdk/infra/heartbeat-wake.d.ts +27 -0
  970. package/dist/plugin-sdk/infra/home-dir.d.ts +7 -0
  971. package/dist/plugin-sdk/infra/http-body.d.ts +46 -0
  972. package/dist/plugin-sdk/infra/json-file.d.ts +2 -0
  973. package/dist/plugin-sdk/infra/net/fetch-guard.d.ts +21 -0
  974. package/dist/plugin-sdk/infra/net/ssrf.d.ts +32 -0
  975. package/dist/plugin-sdk/infra/node-pairing.d.ts +62 -0
  976. package/dist/plugin-sdk/infra/node-shell.d.ts +1 -0
  977. package/dist/plugin-sdk/infra/openclaw-root.d.ts +10 -0
  978. package/dist/plugin-sdk/infra/outbound/abort.d.ts +8 -0
  979. package/dist/plugin-sdk/infra/outbound/channel-adapters.d.ts +6 -0
  980. package/dist/plugin-sdk/infra/outbound/channel-selection.d.ts +11 -0
  981. package/dist/plugin-sdk/infra/outbound/channel-target.d.ts +6 -0
  982. package/dist/plugin-sdk/infra/outbound/deliver.d.ts +77 -0
  983. package/dist/plugin-sdk/infra/outbound/delivery-queue.d.ts +103 -0
  984. package/dist/plugin-sdk/infra/outbound/directory-cache.d.ts +24 -0
  985. package/dist/plugin-sdk/infra/outbound/identity.d.ts +8 -0
  986. package/dist/plugin-sdk/infra/outbound/message-action-params.d.ts +47 -0
  987. package/dist/plugin-sdk/infra/outbound/message-action-runner.d.ts +74 -0
  988. package/dist/plugin-sdk/infra/outbound/message-action-spec.d.ts +5 -0
  989. package/dist/plugin-sdk/infra/outbound/message.d.ts +85 -0
  990. package/dist/plugin-sdk/infra/outbound/outbound-policy.d.ts +31 -0
  991. package/dist/plugin-sdk/infra/outbound/outbound-send-service.d.ts +64 -0
  992. package/dist/plugin-sdk/infra/outbound/outbound-session.d.ts +31 -0
  993. package/dist/plugin-sdk/infra/outbound/payloads.d.ts +16 -0
  994. package/dist/plugin-sdk/infra/outbound/target-errors.d.ts +6 -0
  995. package/dist/plugin-sdk/infra/outbound/target-normalization.d.ts +4 -0
  996. package/dist/plugin-sdk/infra/outbound/target-resolver.d.ts +53 -0
  997. package/dist/plugin-sdk/infra/outbound/targets.d.ts +65 -0
  998. package/dist/plugin-sdk/infra/outbound/tool-payload.d.ts +2 -0
  999. package/dist/plugin-sdk/infra/pairing-files.d.ts +11 -0
  1000. package/dist/plugin-sdk/infra/pairing-token.d.ts +3 -0
  1001. package/dist/plugin-sdk/infra/path-prepend.d.ts +5 -0
  1002. package/dist/plugin-sdk/infra/ports-format.d.ts +5 -0
  1003. package/dist/plugin-sdk/infra/ports-inspect.d.ts +2 -0
  1004. package/dist/plugin-sdk/infra/ports-lsof.d.ts +2 -0
  1005. package/dist/plugin-sdk/infra/ports-types.d.ts +17 -0
  1006. package/dist/plugin-sdk/infra/ports.d.ts +14 -0
  1007. package/dist/plugin-sdk/infra/provider-usage.auth.d.ts +11 -0
  1008. package/dist/plugin-sdk/infra/provider-usage.d.ts +4 -0
  1009. package/dist/plugin-sdk/infra/provider-usage.fetch.antigravity.d.ts +2 -0
  1010. package/dist/plugin-sdk/infra/provider-usage.fetch.claude.d.ts +2 -0
  1011. package/dist/plugin-sdk/infra/provider-usage.fetch.codex.d.ts +2 -0
  1012. package/dist/plugin-sdk/infra/provider-usage.fetch.copilot.d.ts +2 -0
  1013. package/dist/plugin-sdk/infra/provider-usage.fetch.d.ts +7 -0
  1014. package/dist/plugin-sdk/infra/provider-usage.fetch.gemini.d.ts +2 -0
  1015. package/dist/plugin-sdk/infra/provider-usage.fetch.minimax.d.ts +2 -0
  1016. package/dist/plugin-sdk/infra/provider-usage.fetch.shared.d.ts +1 -0
  1017. package/dist/plugin-sdk/infra/provider-usage.fetch.zai.d.ts +2 -0
  1018. package/dist/plugin-sdk/infra/provider-usage.format.d.ts +13 -0
  1019. package/dist/plugin-sdk/infra/provider-usage.load.d.ts +12 -0
  1020. package/dist/plugin-sdk/infra/provider-usage.shared.d.ts +8 -0
  1021. package/dist/plugin-sdk/infra/provider-usage.types.d.ts +17 -0
  1022. package/dist/plugin-sdk/infra/restart-sentinel.d.ts +50 -0
  1023. package/dist/plugin-sdk/infra/restart.d.ts +61 -0
  1024. package/dist/plugin-sdk/infra/retry.d.ts +21 -0
  1025. package/dist/plugin-sdk/infra/session-cost-usage.d.ts +45 -0
  1026. package/dist/plugin-sdk/infra/session-cost-usage.types.d.ts +153 -0
  1027. package/dist/plugin-sdk/infra/session-maintenance-warning.d.ts +10 -0
  1028. package/dist/plugin-sdk/infra/shell-env.d.ts +33 -0
  1029. package/dist/plugin-sdk/infra/skills-remote.d.ts +25 -0
  1030. package/dist/plugin-sdk/infra/system-events.d.ts +18 -0
  1031. package/dist/plugin-sdk/infra/tailnet.d.ts +7 -0
  1032. package/dist/plugin-sdk/infra/tailscale.d.ts +34 -0
  1033. package/dist/plugin-sdk/infra/tls/fingerprint.d.ts +1 -0
  1034. package/dist/plugin-sdk/infra/tls/gateway.d.ts +16 -0
  1035. package/dist/plugin-sdk/infra/tmp-anima-dir.d.ts +1 -0
  1036. package/dist/plugin-sdk/infra/tmp-openclaw-dir.d.ts +18 -0
  1037. package/dist/plugin-sdk/infra/unhandled-rejections.d.ts +15 -0
  1038. package/dist/plugin-sdk/infra/warning-filter.d.ts +7 -0
  1039. package/dist/plugin-sdk/infra/ws.d.ts +2 -0
  1040. package/dist/plugin-sdk/infra/wsl.d.ts +11 -0
  1041. package/dist/plugin-sdk/line/accounts.d.ts +9 -0
  1042. package/dist/plugin-sdk/line/config-schema.d.ts +1 -0
  1043. package/dist/plugin-sdk/line/flex-templates.d.ts +14 -0
  1044. package/dist/plugin-sdk/line/markdown-to-line.d.ts +6 -0
  1045. package/dist/plugin-sdk/line/monitor.d.ts +3 -0
  1046. package/dist/plugin-sdk/line/probe.d.ts +3 -0
  1047. package/dist/plugin-sdk/line/send.d.ts +14 -0
  1048. package/dist/plugin-sdk/line/template-messages.d.ts +1 -0
  1049. package/dist/plugin-sdk/line/types.d.ts +6 -0
  1050. package/dist/plugin-sdk/link-understanding/apply.d.ts +10 -0
  1051. package/dist/plugin-sdk/link-understanding/defaults.d.ts +2 -0
  1052. package/dist/plugin-sdk/link-understanding/detect.d.ts +3 -0
  1053. package/dist/plugin-sdk/link-understanding/format.d.ts +4 -0
  1054. package/dist/plugin-sdk/link-understanding/runner.d.ts +11 -0
  1055. package/dist/plugin-sdk/logger.d.ts +6 -0
  1056. package/dist/plugin-sdk/logging/config.d.ts +4 -0
  1057. package/dist/plugin-sdk/logging/console.d.ts +23 -0
  1058. package/dist/plugin-sdk/logging/diagnostic-session-state.d.ts +17 -0
  1059. package/dist/plugin-sdk/logging/diagnostic.d.ts +56 -0
  1060. package/dist/plugin-sdk/logging/levels.d.ts +4 -0
  1061. package/dist/plugin-sdk/logging/logger.d.ts +42 -0
  1062. package/dist/plugin-sdk/logging/redact-identifier.d.ts +4 -0
  1063. package/dist/plugin-sdk/logging/redact.d.ts +9 -0
  1064. package/dist/plugin-sdk/logging/state.d.ts +18 -0
  1065. package/dist/plugin-sdk/logging/subsystem.d.ts +18 -0
  1066. package/dist/plugin-sdk/logging.d.ts +10 -0
  1067. package/dist/plugin-sdk/markdown/fences.d.ts +10 -0
  1068. package/dist/plugin-sdk/markdown/frontmatter.d.ts +2 -0
  1069. package/dist/plugin-sdk/markdown/ir.d.ts +32 -0
  1070. package/dist/plugin-sdk/markdown/render.d.ts +18 -0
  1071. package/dist/plugin-sdk/markdown/tables.d.ts +2 -0
  1072. package/dist/plugin-sdk/markdown/whatsapp.d.ts +14 -0
  1073. package/dist/plugin-sdk/media/audio-tags.d.ts +10 -0
  1074. package/dist/plugin-sdk/media/audio.d.ts +19 -0
  1075. package/dist/plugin-sdk/media/base64.d.ts +1 -0
  1076. package/dist/plugin-sdk/media/constants.d.ts +7 -0
  1077. package/dist/plugin-sdk/media/fetch.d.ts +23 -0
  1078. package/dist/plugin-sdk/media/image-ops.d.ts +39 -0
  1079. package/dist/plugin-sdk/media/input-files.d.ts +81 -0
  1080. package/dist/plugin-sdk/media/mime.d.ts +16 -0
  1081. package/dist/plugin-sdk/media/parse.d.ts +8 -0
  1082. package/dist/plugin-sdk/media/png-encode.d.ts +8 -0
  1083. package/dist/plugin-sdk/media/read-response-with-limit.d.ts +7 -0
  1084. package/dist/plugin-sdk/media/sniff-mime-from-base64.d.ts +1 -0
  1085. package/dist/plugin-sdk/media/store.d.ts +28 -0
  1086. package/dist/plugin-sdk/media-understanding/apply.d.ts +19 -0
  1087. package/dist/plugin-sdk/media-understanding/attachments.d.ts +43 -0
  1088. package/dist/plugin-sdk/media-understanding/concurrency.d.ts +1 -0
  1089. package/dist/plugin-sdk/media-understanding/defaults.d.ts +14 -0
  1090. package/dist/plugin-sdk/media-understanding/errors.d.ts +6 -0
  1091. package/dist/plugin-sdk/media-understanding/format.d.ts +7 -0
  1092. package/dist/plugin-sdk/media-understanding/output-extract.d.ts +2 -0
  1093. package/dist/plugin-sdk/media-understanding/providers/image.d.ts +1 -0
  1094. package/dist/plugin-sdk/media-understanding/providers/index.d.ts +8 -0
  1095. package/dist/plugin-sdk/media-understanding/providers/shared.d.ts +4 -0
  1096. package/dist/plugin-sdk/media-understanding/resolve.d.ts +44 -0
  1097. package/dist/plugin-sdk/media-understanding/runner.d.ts +35 -0
  1098. package/dist/plugin-sdk/media-understanding/runner.entries.d.ts +33 -0
  1099. package/dist/plugin-sdk/media-understanding/scope.d.ts +9 -0
  1100. package/dist/plugin-sdk/media-understanding/types.d.ts +93 -0
  1101. package/dist/plugin-sdk/media-understanding/video.d.ts +2 -0
  1102. package/dist/plugin-sdk/memory/backend-config.d.ts +49 -0
  1103. package/dist/plugin-sdk/memory/batch-gemini.d.ts +55 -0
  1104. package/dist/plugin-sdk/memory/batch-http.d.ts +6 -0
  1105. package/dist/plugin-sdk/memory/batch-openai.d.ts +45 -0
  1106. package/dist/plugin-sdk/memory/batch-output.d.ts +23 -0
  1107. package/dist/plugin-sdk/memory/batch-voyage.d.ts +46 -0
  1108. package/dist/plugin-sdk/memory/embedding-chunk-limits.d.ts +3 -0
  1109. package/dist/plugin-sdk/memory/embedding-input-limits.d.ts +2 -0
  1110. package/dist/plugin-sdk/memory/embedding-model-limits.d.ts +2 -0
  1111. package/dist/plugin-sdk/memory/embeddings-gemini.d.ts +13 -0
  1112. package/dist/plugin-sdk/memory/embeddings-openai.d.ts +13 -0
  1113. package/dist/plugin-sdk/memory/embeddings-voyage.d.ts +13 -0
  1114. package/dist/plugin-sdk/memory/embeddings.d.ts +44 -0
  1115. package/dist/plugin-sdk/memory/hybrid.d.ts +34 -0
  1116. package/dist/plugin-sdk/memory/index.d.ts +3 -0
  1117. package/dist/plugin-sdk/memory/internal.d.ts +38 -0
  1118. package/dist/plugin-sdk/memory/manager-embedding-ops.d.ts +32 -0
  1119. package/dist/plugin-sdk/memory/manager-search.d.ts +60 -0
  1120. package/dist/plugin-sdk/memory/manager-sync-ops.d.ts +40 -0
  1121. package/dist/plugin-sdk/memory/manager.d.ts +75 -0
  1122. package/dist/plugin-sdk/memory/memory-schema.d.ts +10 -0
  1123. package/dist/plugin-sdk/memory/node-llama.d.ts +8 -0
  1124. package/dist/plugin-sdk/memory/qmd-manager.d.ts +109 -0
  1125. package/dist/plugin-sdk/memory/qmd-query-parser.d.ts +8 -0
  1126. package/dist/plugin-sdk/memory/qmd-scope.d.ts +4 -0
  1127. package/dist/plugin-sdk/memory/search-manager.d.ts +11 -0
  1128. package/dist/plugin-sdk/memory/session-files.d.ts +14 -0
  1129. package/dist/plugin-sdk/memory/sqlite-vec.d.ts +9 -0
  1130. package/dist/plugin-sdk/memory/sqlite.d.ts +1 -0
  1131. package/dist/plugin-sdk/memory/types.d.ts +94 -0
  1132. package/dist/plugin-sdk/pairing/pairing-messages.d.ts +6 -0
  1133. package/dist/plugin-sdk/pairing/pairing-store.d.ts +46 -0
  1134. package/dist/plugin-sdk/pi-model-discovery-Dw3A6oXH.js +37 -0
  1135. package/dist/plugin-sdk/plugin-sdk/account-id.d.ts +1 -0
  1136. package/dist/plugin-sdk/plugin-sdk/allow-from.d.ts +4 -0
  1137. package/dist/plugin-sdk/plugin-sdk/config-paths.d.ts +6 -0
  1138. package/dist/plugin-sdk/plugin-sdk/file-lock.d.ts +16 -0
  1139. package/dist/plugin-sdk/plugin-sdk/index.d.ts +123 -0
  1140. package/dist/plugin-sdk/plugin-sdk/onboarding.d.ts +11 -0
  1141. package/dist/plugin-sdk/plugin-sdk/text-chunking.d.ts +1 -0
  1142. package/dist/plugin-sdk/plugins/bundled-dir.d.ts +1 -0
  1143. package/dist/plugin-sdk/plugins/commands.d.ts +83 -0
  1144. package/dist/plugin-sdk/plugins/config-schema.d.ts +2 -0
  1145. package/dist/plugin-sdk/plugins/config-state.d.ts +33 -0
  1146. package/dist/plugin-sdk/plugins/discovery.d.ts +22 -0
  1147. package/dist/plugin-sdk/plugins/hook-runner-global.d.ts +37 -0
  1148. package/dist/plugin-sdk/plugins/hooks.d.ts +42 -0
  1149. package/dist/plugin-sdk/plugins/http-path.d.ts +1 -0
  1150. package/dist/plugin-sdk/plugins/http-registry.d.ts +13 -0
  1151. package/dist/plugin-sdk/plugins/loader.d.ts +14 -0
  1152. package/dist/plugin-sdk/plugins/manifest-registry.d.ts +33 -0
  1153. package/dist/plugin-sdk/plugins/manifest.d.ts +64 -0
  1154. package/dist/plugin-sdk/plugins/registry.d.ts +130 -0
  1155. package/dist/plugin-sdk/plugins/runtime/index.d.ts +3 -0
  1156. package/dist/plugin-sdk/plugins/runtime/native-deps.d.ts +8 -0
  1157. package/dist/plugin-sdk/plugins/runtime/types.d.ts +317 -0
  1158. package/dist/plugin-sdk/plugins/runtime.d.ts +5 -0
  1159. package/dist/plugin-sdk/plugins/schema-validator.d.ts +10 -0
  1160. package/dist/plugin-sdk/plugins/slots.d.ts +24 -0
  1161. package/dist/plugin-sdk/plugins/tools.d.ts +13 -0
  1162. package/dist/plugin-sdk/plugins/types.d.ts +411 -0
  1163. package/dist/plugin-sdk/polls.d.ts +31 -0
  1164. package/dist/plugin-sdk/process/command-queue.d.ts +51 -0
  1165. package/dist/plugin-sdk/process/exec.d.ts +26 -0
  1166. package/dist/plugin-sdk/process/lanes.d.ts +6 -0
  1167. package/dist/plugin-sdk/process/spawn-utils.d.ts +26 -0
  1168. package/dist/plugin-sdk/providers/github-copilot-token.d.ts +8 -0
  1169. package/dist/plugin-sdk/providers/qwen-portal-oauth.d.ts +8 -0
  1170. package/dist/plugin-sdk/routing/bindings.d.ts +11 -0
  1171. package/dist/plugin-sdk/routing/resolve-route.d.ts +42 -0
  1172. package/dist/plugin-sdk/routing/session-key.d.ts +48 -0
  1173. package/dist/plugin-sdk/runtime.d.ts +7 -0
  1174. package/dist/plugin-sdk/security/external-content.d.ts +67 -0
  1175. package/dist/plugin-sdk/security/secret-equal.d.ts +1 -0
  1176. package/dist/plugin-sdk/sessions/input-provenance.d.ts +16 -0
  1177. package/dist/plugin-sdk/sessions/level-overrides.d.ts +10 -0
  1178. package/dist/plugin-sdk/sessions/model-overrides.d.ts +14 -0
  1179. package/dist/plugin-sdk/sessions/send-policy.d.ts +11 -0
  1180. package/dist/plugin-sdk/sessions/session-key-utils.d.ts +11 -0
  1181. package/dist/plugin-sdk/sessions/session-label.d.ts +9 -0
  1182. package/dist/plugin-sdk/sessions/transcript-events.d.ts +7 -0
  1183. package/dist/plugin-sdk/shared/chat-envelope.d.ts +2 -0
  1184. package/dist/plugin-sdk/shared/config-eval.d.ts +5 -0
  1185. package/dist/plugin-sdk/shared/device-auth.d.ts +13 -0
  1186. package/dist/plugin-sdk/shared/frontmatter.d.ts +7 -0
  1187. package/dist/plugin-sdk/shared/node-match.d.ts +8 -0
  1188. package/dist/plugin-sdk/shared/subagents-format.d.ts +15 -0
  1189. package/dist/plugin-sdk/shared/text/reasoning-tags.d.ts +6 -0
  1190. package/dist/plugin-sdk/signal/accounts.d.ts +9 -0
  1191. package/dist/plugin-sdk/signal/format.d.ts +9 -0
  1192. package/dist/plugin-sdk/signal/identity.d.ts +3 -0
  1193. package/dist/plugin-sdk/signal/index.d.ts +3 -0
  1194. package/dist/plugin-sdk/signal/probe.d.ts +3 -0
  1195. package/dist/plugin-sdk/signal/reaction-level.d.ts +1 -0
  1196. package/dist/plugin-sdk/signal/send-reactions.d.ts +2 -0
  1197. package/dist/plugin-sdk/signal/send.d.ts +1 -0
  1198. package/dist/plugin-sdk/slack/accounts.d.ts +11 -0
  1199. package/dist/plugin-sdk/slack/actions.d.ts +17 -0
  1200. package/dist/plugin-sdk/slack/client.d.ts +1 -0
  1201. package/dist/plugin-sdk/slack/directory-live.d.ts +4 -0
  1202. package/dist/plugin-sdk/slack/index.d.ts +3 -0
  1203. package/dist/plugin-sdk/slack/message-actions.d.ts +2 -0
  1204. package/dist/plugin-sdk/slack/monitor/allow-list.d.ts +1 -0
  1205. package/dist/plugin-sdk/slack/probe.d.ts +3 -0
  1206. package/dist/plugin-sdk/slack/resolve-channels.d.ts +1 -0
  1207. package/dist/plugin-sdk/slack/resolve-users.d.ts +1 -0
  1208. package/dist/plugin-sdk/slack/send.d.ts +5 -0
  1209. package/dist/plugin-sdk/slack/targets.d.ts +2 -0
  1210. package/dist/plugin-sdk/slack/threading-tool-context.d.ts +1 -0
  1211. package/dist/plugin-sdk/telegram/accounts.d.ts +9 -0
  1212. package/dist/plugin-sdk/telegram/audit.d.ts +4 -0
  1213. package/dist/plugin-sdk/telegram/bot/helpers.d.ts +1 -0
  1214. package/dist/plugin-sdk/telegram/bot/types.d.ts +5 -0
  1215. package/dist/plugin-sdk/telegram/inline-buttons.d.ts +2 -0
  1216. package/dist/plugin-sdk/telegram/model-buttons.d.ts +5 -0
  1217. package/dist/plugin-sdk/telegram/monitor.d.ts +3 -0
  1218. package/dist/plugin-sdk/telegram/outbound-params.d.ts +2 -0
  1219. package/dist/plugin-sdk/telegram/probe.d.ts +6 -0
  1220. package/dist/plugin-sdk/telegram/reaction-level.d.ts +1 -0
  1221. package/dist/plugin-sdk/telegram/send.d.ts +10 -0
  1222. package/dist/plugin-sdk/telegram/sticker-cache.d.ts +2 -0
  1223. package/dist/plugin-sdk/telegram/targets.d.ts +1 -0
  1224. package/dist/plugin-sdk/telegram/token.d.ts +1 -0
  1225. package/dist/plugin-sdk/terminal/ansi.d.ts +2 -0
  1226. package/dist/plugin-sdk/terminal/health-style.d.ts +1 -0
  1227. package/dist/plugin-sdk/terminal/links.d.ts +6 -0
  1228. package/dist/plugin-sdk/terminal/palette.d.ts +10 -0
  1229. package/dist/plugin-sdk/terminal/progress-line.d.ts +3 -0
  1230. package/dist/plugin-sdk/terminal/prompt-style.d.ts +3 -0
  1231. package/dist/plugin-sdk/terminal/restore.d.ts +17 -0
  1232. package/dist/plugin-sdk/terminal/theme.d.ts +15 -0
  1233. package/dist/plugin-sdk/tts/tts-core.d.ts +52 -0
  1234. package/dist/plugin-sdk/tts/tts.d.ts +179 -0
  1235. package/dist/plugin-sdk/utils/account-id.d.ts +1 -0
  1236. package/dist/plugin-sdk/utils/boolean.d.ts +5 -0
  1237. package/dist/plugin-sdk/utils/delivery-context.d.ts +29 -0
  1238. package/dist/plugin-sdk/utils/directive-tags.d.ts +16 -0
  1239. package/dist/plugin-sdk/utils/fetch-timeout.d.ts +13 -0
  1240. package/dist/plugin-sdk/utils/message-channel.d.ts +27 -0
  1241. package/dist/plugin-sdk/utils/normalize-secret-input.d.ts +11 -0
  1242. package/dist/plugin-sdk/utils/provider-utils.d.ts +9 -0
  1243. package/dist/plugin-sdk/utils/queue-helpers.d.ts +41 -0
  1244. package/dist/plugin-sdk/utils/shell-argv.d.ts +1 -0
  1245. package/dist/plugin-sdk/utils/transcript-tools.d.ts +8 -0
  1246. package/dist/plugin-sdk/utils/usage-format.d.ts +26 -0
  1247. package/dist/plugin-sdk/utils.d.ts +67 -0
  1248. package/dist/plugin-sdk/version.d.ts +4 -0
  1249. package/dist/plugin-sdk/web/accounts.d.ts +39 -0
  1250. package/dist/plugin-sdk/web/active-listener.d.ts +25 -0
  1251. package/dist/plugin-sdk/web/auth-store.d.ts +25 -0
  1252. package/dist/plugin-sdk/web/auto-reply/constants.d.ts +1 -0
  1253. package/dist/plugin-sdk/web/auto-reply/deliver-reply.d.ts +18 -0
  1254. package/dist/plugin-sdk/web/auto-reply/heartbeat-runner.d.ts +20 -0
  1255. package/dist/plugin-sdk/web/auto-reply/loggers.d.ts +4 -0
  1256. package/dist/plugin-sdk/web/auto-reply/mentions.d.ts +19 -0
  1257. package/dist/plugin-sdk/web/auto-reply/monitor/ack-reaction.d.ts +13 -0
  1258. package/dist/plugin-sdk/web/auto-reply/monitor/broadcast.d.ts +16 -0
  1259. package/dist/plugin-sdk/web/auto-reply/monitor/commands.d.ts +2 -0
  1260. package/dist/plugin-sdk/web/auto-reply/monitor/echo.d.ts +17 -0
  1261. package/dist/plugin-sdk/web/auto-reply/monitor/group-activation.d.ts +9 -0
  1262. package/dist/plugin-sdk/web/auto-reply/monitor/group-gating.d.ts +29 -0
  1263. package/dist/plugin-sdk/web/auto-reply/monitor/group-members.d.ts +6 -0
  1264. package/dist/plugin-sdk/web/auto-reply/monitor/last-route.d.ts +15 -0
  1265. package/dist/plugin-sdk/web/auto-reply/monitor/message-line.d.ts +11 -0
  1266. package/dist/plugin-sdk/web/auto-reply/monitor/on-message.d.ts +24 -0
  1267. package/dist/plugin-sdk/web/auto-reply/monitor/peer.d.ts +2 -0
  1268. package/dist/plugin-sdk/web/auto-reply/monitor/process-message.d.ts +40 -0
  1269. package/dist/plugin-sdk/web/auto-reply/monitor.d.ts +5 -0
  1270. package/dist/plugin-sdk/web/auto-reply/session-snapshot.d.ts +17 -0
  1271. package/dist/plugin-sdk/web/auto-reply/types.d.ts +28 -0
  1272. package/dist/plugin-sdk/web/auto-reply/util.d.ts +2 -0
  1273. package/dist/plugin-sdk/web/auto-reply.d.ts +1 -0
  1274. package/dist/plugin-sdk/web/auto-reply.impl.d.ts +6 -0
  1275. package/dist/plugin-sdk/web/inbound/access-control.d.ts +24 -0
  1276. package/dist/plugin-sdk/web/inbound/dedupe.d.ts +2 -0
  1277. package/dist/plugin-sdk/web/inbound/extract.d.ts +13 -0
  1278. package/dist/plugin-sdk/web/inbound/media.d.ts +7 -0
  1279. package/dist/plugin-sdk/web/inbound/monitor.d.ts +30 -0
  1280. package/dist/plugin-sdk/web/inbound/send-api.d.ts +22 -0
  1281. package/dist/plugin-sdk/web/inbound/types.d.ts +41 -0
  1282. package/dist/plugin-sdk/web/inbound.d.ts +4 -0
  1283. package/dist/plugin-sdk/web/login-qr.d.ts +19 -0
  1284. package/dist/plugin-sdk/web/login.d.ts +3 -0
  1285. package/dist/plugin-sdk/web/media.d.ts +38 -0
  1286. package/dist/plugin-sdk/web/outbound.d.ts +23 -0
  1287. package/dist/plugin-sdk/web/qr-image.d.ts +4 -0
  1288. package/dist/plugin-sdk/web/reconnect.d.ts +12 -0
  1289. package/dist/plugin-sdk/web/session.d.ts +14 -0
  1290. package/dist/plugin-sdk/web/vcard.d.ts +6 -0
  1291. package/dist/plugin-sdk/whatsapp/normalize.d.ts +2 -0
  1292. package/dist/plugin-sdk/whatsapp/resolve-outbound-target.d.ts +1 -0
  1293. package/dist/plugin-sdk/wizard/prompts.d.ts +42 -0
  1294. package/dist/plugin-sdk/wizard/session.d.ts +42 -0
  1295. package/dist/plugins-B362e77G.js +168 -0
  1296. package/dist/plugins-CDJw924T.js +38 -0
  1297. package/dist/plugins-CmSUIUNi.js +38 -0
  1298. package/dist/plugins-cli-CtFRTC2I.js +734 -0
  1299. package/dist/plugins-cli-D1lvqLG9.js +736 -0
  1300. package/dist/polls-CItfB1H8.js +1343 -0
  1301. package/dist/ports-BVLMN1Sr.js +96 -0
  1302. package/dist/ports-CqLSlU6Z.js +317 -0
  1303. package/dist/ports-D94CwCrv.js +344 -0
  1304. package/dist/ports-D_NHthOz.js +96 -0
  1305. package/dist/program-Bve7k4jO.js +176 -0
  1306. package/dist/program-context-8lqacY-M.js +496 -0
  1307. package/dist/program-context-Bvn8046-.js +17 -0
  1308. package/dist/progress-Bek_GyWS.js +133 -0
  1309. package/dist/progress-CbZ2D53A.js +133 -0
  1310. package/dist/prompt-style-DKy6qQxR.js +9 -0
  1311. package/dist/prompt-style-lu0clOOE.js +9 -0
  1312. package/dist/prompts-BI__va99.js +10 -0
  1313. package/dist/prompts-_dDWkCAz.js +10 -0
  1314. package/dist/pw-ai-BLVMuSLv.js +1867 -0
  1315. package/dist/pw-ai-DZJWEF_f.js +1865 -0
  1316. package/dist/pw-ai-dzf-ptcn.js +1868 -0
  1317. package/dist/qmd-manager-B0FWDi1x.js +938 -0
  1318. package/dist/qmd-manager-CrDrpgh3.js +937 -0
  1319. package/dist/qmd-manager-DepEoASu.js +935 -0
  1320. package/dist/queue-2CW7pnm1.js +209 -0
  1321. package/dist/queue-DhjMEG_Q.js +209 -0
  1322. package/dist/redact-BHmk44DI.js +97 -0
  1323. package/dist/redact-ClVwO7Nn.js +97 -0
  1324. package/dist/register.agent-CE_8JbTE.js +265 -0
  1325. package/dist/register.agent-CGRdcftb.js +1003 -0
  1326. package/dist/register.anima-B4NPeesF.js +167 -0
  1327. package/dist/register.anima-hNCtQ_jl.js +167 -0
  1328. package/dist/register.configure-3prVPXwx.js +101 -0
  1329. package/dist/register.configure-Dqm2IveL.js +103 -0
  1330. package/dist/register.maintenance-BSIx4eNS.js +543 -0
  1331. package/dist/register.maintenance-DDeG6CHa.js +543 -0
  1332. package/dist/register.message-DcYPDzYr.js +657 -0
  1333. package/dist/register.message-RbFrjbch.js +660 -0
  1334. package/dist/register.onboard-BBJK_0_C.js +170 -0
  1335. package/dist/register.onboard-BrcWHC9j.js +170 -0
  1336. package/dist/register.setup-ByvEHxYQ.js +175 -0
  1337. package/dist/register.setup-CNwO5Yq3.js +175 -0
  1338. package/dist/register.status-health-sessions-CGT7bn4C.js +142 -0
  1339. package/dist/register.status-health-sessions-QK6iQSJc.js +313 -0
  1340. package/dist/register.subclis-Bd8eE94r.js +255 -0
  1341. package/dist/registry-BiekeB9q.js +116 -0
  1342. package/dist/registry-qI6V4gqU.js +116 -0
  1343. package/dist/reply-Clj5jcM5.js +32212 -0
  1344. package/dist/reply-DnH1Ueoz.js +32212 -0
  1345. package/dist/reply-prefix-D2NxVzGZ.js +100 -0
  1346. package/dist/reply-prefix-DPpz_mEi.js +100 -0
  1347. package/dist/requirements-BzZxj2Wu.js +107 -0
  1348. package/dist/requirements-DIW1svgA.js +107 -0
  1349. package/dist/rolldown-runtime-Cbj13DAv.js +20 -0
  1350. package/dist/routes-CXpne1-p.js +1820 -0
  1351. package/dist/routes-DtRwwTy6.js +1820 -0
  1352. package/dist/rpc-BBB_Fbes.js +70 -0
  1353. package/dist/rpc-CMEWfcci.js +70 -0
  1354. package/dist/run-main-DOXNrnL2.js +371 -0
  1355. package/dist/runtime-guard-BSUFiAQV.js +60 -0
  1356. package/dist/runtime-guard-DeOXA_86.js +60 -0
  1357. package/dist/sandbox-Bk0ZXcag.js +859 -0
  1358. package/dist/sandbox-D3CFkNeF.js +858 -0
  1359. package/dist/sandbox-cli-BCnnmQ03.js +458 -0
  1360. package/dist/sandbox-cli-Ctpa2Isy.js +461 -0
  1361. package/dist/secret-equal-B268kALC.js +13 -0
  1362. package/dist/secret-equal-Dghy3xsA.js +13 -0
  1363. package/dist/security-cli-BiiLLcQV.js +462 -0
  1364. package/dist/security-cli-DOZmLENS.js +465 -0
  1365. package/dist/send-BTA6qupx.js +10 -0
  1366. package/dist/send-BhAfdGII.js +10 -0
  1367. package/dist/send-C2t9xpXI.js +10 -0
  1368. package/dist/send-C6ccOW_U.js +10 -0
  1369. package/dist/send-CP74DxzJ.js +28 -0
  1370. package/dist/send-CS3G_YWr.js +10 -0
  1371. package/dist/send-D5JnqErc.js +10 -0
  1372. package/dist/send-DEMhcauI.js +32 -0
  1373. package/dist/send-DF8KJImx.js +28 -0
  1374. package/dist/send-DVW0CcHX.js +32 -0
  1375. package/dist/send-DigO-i9j.js +28 -0
  1376. package/dist/send-DqMLjD9Z.js +10 -0
  1377. package/dist/send-Dz2BDHll.js +32 -0
  1378. package/dist/send-ga9udK1_.js +10 -0
  1379. package/dist/send-oDz9NATu.js +10 -0
  1380. package/dist/server-context-BznDS2td.js +824 -0
  1381. package/dist/server-context-CXnE2F7d.js +824 -0
  1382. package/dist/server-node-events-Cu6Qkjor.js +231 -0
  1383. package/dist/server-node-events-Cv8MuF1g.js +233 -0
  1384. package/dist/service-BNVpYcQe.js +642 -0
  1385. package/dist/service-D56aMXUB.js +642 -0
  1386. package/dist/service-audit-DBsygs7y.js +488 -0
  1387. package/dist/service-audit-DKWJcTu4.js +488 -0
  1388. package/dist/session-CXcl3Xrp.js +181 -0
  1389. package/dist/session-DUFuU29j.js +179 -0
  1390. package/dist/session-M_uCxF0U.js +181 -0
  1391. package/dist/session-cost-usage-BwiTZuKl.js +600 -0
  1392. package/dist/session-cost-usage-DT9YNXTJ.js +600 -0
  1393. package/dist/session-key-BGiG_JcT.js +198 -0
  1394. package/dist/session-key-DxcgHezu.js +198 -0
  1395. package/dist/sessions-B8GUAiF6.js +1296 -0
  1396. package/dist/sessions-D0Zd1CND.js +1296 -0
  1397. package/dist/sessions-D0spLCm7.js +187 -0
  1398. package/dist/sessions-XvkHLXt4.js +2038 -0
  1399. package/dist/shared-CEHU0exQ.js +77 -0
  1400. package/dist/shared-Cgly1vPb.js +66 -0
  1401. package/dist/shared-DAHxpviD.js +77 -0
  1402. package/dist/shared-JOo05hST.js +66 -0
  1403. package/dist/shell-argv-CAq1mLa2.js +72 -0
  1404. package/dist/shell-argv-Ce41guJv.js +72 -0
  1405. package/dist/skill-scanner-CkaVLABv.js +263 -0
  1406. package/dist/skill-scanner-Coo4QoCd.js +263 -0
  1407. package/dist/skills-B-G7UHOa.js +808 -0
  1408. package/dist/skills-B5LQx4lT.js +807 -0
  1409. package/dist/skills-cli-DF9XJ2_0.js +286 -0
  1410. package/dist/skills-cli-eLBluVoD.js +289 -0
  1411. package/dist/skills-status-Clq9ZnYu.js +166 -0
  1412. package/dist/skills-status-JQluhU-P.js +166 -0
  1413. package/dist/sqlite-BukcjdJa.js +321 -0
  1414. package/dist/sqlite-CGcOZZ0C.js +368 -0
  1415. package/dist/sqlite-Ck6f9KWc.js +453 -0
  1416. package/dist/start-BvsoGNHJ.js +354 -0
  1417. package/dist/start-CF_Cp6YC.js +353 -0
  1418. package/dist/status-BKGJ7VPQ.js +27 -0
  1419. package/dist/status-BZip7mx9.js +27 -0
  1420. package/dist/status-BqYq_J5J.js +2132 -0
  1421. package/dist/status-CMnlcBVc.js +21 -0
  1422. package/dist/status-CXQrTLri.js +2137 -0
  1423. package/dist/status-tDZPwewW.js +21 -0
  1424. package/dist/status.update-CWiod7o_.js +79 -0
  1425. package/dist/status.update-D1PyrhoB.js +79 -0
  1426. package/dist/subagent-registry-CpSZ2RSO.js +2760 -0
  1427. package/dist/subagent-registry-DkCXRdwf.js +2759 -0
  1428. package/dist/subagent-registry-MPrTYaEB.js +14 -0
  1429. package/dist/subsystem-Dowf8fSU.js +860 -0
  1430. package/dist/system-cli-4Urk9KV1.js +79 -0
  1431. package/dist/system-cli-CgMzkg8R.js +82 -0
  1432. package/dist/system-run-command-DGk7dwQP.js +93 -0
  1433. package/dist/system-run-command-X9lDJIy0.js +93 -0
  1434. package/dist/systemd-BSrHDyeU.js +452 -0
  1435. package/dist/systemd-By5xdSB4.js +452 -0
  1436. package/dist/systemd-hints-BtjL_5Rh.js +36 -0
  1437. package/dist/systemd-hints-sJmr6cjb.js +36 -0
  1438. package/dist/systemd-linger-BNz8PXPF.js +75 -0
  1439. package/dist/systemd-linger-D5vLilKH.js +75 -0
  1440. package/dist/table-BL0lJzsm.js +279 -0
  1441. package/dist/table-DoiRPsn0.js +279 -0
  1442. package/dist/tailnet-CuiNECdL.js +42 -0
  1443. package/dist/tailnet-__ODlBOT.js +42 -0
  1444. package/dist/templates-DJ0ii6X2.js +47 -0
  1445. package/dist/templates-DPTs18po.js +47 -0
  1446. package/dist/thinking-BLU0jXR8.js +204 -0
  1447. package/dist/thinking-BXEswx1X.js +204 -0
  1448. package/dist/timeout-CswI_K-U.js +232 -0
  1449. package/dist/tokens-C-X7wDKj.js +14 -0
  1450. package/dist/tokens-DkvqA72p.js +14 -0
  1451. package/dist/transcript-events-C1hdue6u.js +17 -0
  1452. package/dist/transcript-events-C8Tqw4td.js +17 -0
  1453. package/dist/transcript-events-DW_H__a1.js +17 -0
  1454. package/dist/transcript-tools-DtE5di1q.js +108 -0
  1455. package/dist/transcript-tools-DuyYOkUq.js +108 -0
  1456. package/dist/trash-BJLK1vMn.js +23 -0
  1457. package/dist/trash-_x5UZ94k.js +23 -0
  1458. package/dist/tui-Cj25a9wc.js +3894 -0
  1459. package/dist/tui-Iv4T-9gg.js +3894 -0
  1460. package/dist/tui-cli-BkJxFa_n.js +50 -0
  1461. package/dist/tui-cli-DeFmBtZ7.js +47 -0
  1462. package/dist/update-DZRKbMjq.js +317 -0
  1463. package/dist/update-LFgxHHPd.js +317 -0
  1464. package/dist/update-check-CWc7YXmc.js +400 -0
  1465. package/dist/update-check-IhlWaui6.js +400 -0
  1466. package/dist/update-cli-qGGlL5Lg.js +1105 -0
  1467. package/dist/update-cli-rMqhSUMc.js +1105 -0
  1468. package/dist/update-runner-BT77y3bz.js +894 -0
  1469. package/dist/update-runner-DvzFqFJf.js +894 -0
  1470. package/dist/usage-BeZuVAY4.js +4516 -0
  1471. package/dist/usage-format-BAirWUSO.js +36 -0
  1472. package/dist/usage-format-CpORtVCG.js +36 -0
  1473. package/dist/utils-Bsw__U-F.js +243 -0
  1474. package/dist/utils-C9sj30YY.js +239 -0
  1475. package/dist/warning-filter.js +48 -0
  1476. package/dist/web-DEx7MMYq.js +2203 -0
  1477. package/dist/web-DHSoj6bL.js +46842 -0
  1478. package/dist/web-DI0g5K4c.js +63 -0
  1479. package/dist/webhooks-cli-sfLRE89X.js +319 -0
  1480. package/dist/webhooks-cli-xtZBlaD1.js +316 -0
  1481. package/dist/whatsapp-actions-DIREhxrq.js +49 -0
  1482. package/dist/whatsapp-actions-TGHl9p4i.js +45 -0
  1483. package/dist/whatsapp-actions-dBHozeuk.js +53 -0
  1484. package/dist/widearea-dns-B6ocX23x.js +127 -0
  1485. package/dist/widearea-dns-NsEUNYwz.js +127 -0
  1486. package/dist/workspace-Dcfoy5JJ.js +649 -0
  1487. package/dist/ws-COSqlEPx.js +218 -0
  1488. package/dist/ws-log-N8R5MvGE.js +267 -0
  1489. package/dist/ws-log-gwFxPxj5.js +267 -0
  1490. package/dist/wsl-CqyuRvtM.js +26 -0
  1491. package/dist/wsl-ymJYvc9Q.js +26 -0
  1492. package/package.json +209 -0
  1493. package/skills/1password/SKILL.md +70 -0
  1494. package/skills/1password/references/cli-examples.md +29 -0
  1495. package/skills/1password/references/get-started.md +17 -0
  1496. package/skills/animahub/SKILL.md +77 -0
  1497. package/skills/apple-notes/SKILL.md +77 -0
  1498. package/skills/apple-reminders/SKILL.md +96 -0
  1499. package/skills/audit/SKILL.md +68 -0
  1500. package/skills/bear-notes/SKILL.md +107 -0
  1501. package/skills/blogwatcher/SKILL.md +69 -0
  1502. package/skills/blucli/SKILL.md +47 -0
  1503. package/skills/bluebubbles/SKILL.md +131 -0
  1504. package/skills/camsnap/SKILL.md +45 -0
  1505. package/skills/canvas/SKILL.md +198 -0
  1506. package/skills/coding-agent/SKILL.md +284 -0
  1507. package/skills/deploy/SKILL.md +45 -0
  1508. package/skills/discord/SKILL.md +160 -0
  1509. package/skills/eightctl/SKILL.md +50 -0
  1510. package/skills/food-order/SKILL.md +48 -0
  1511. package/skills/gemini/SKILL.md +43 -0
  1512. package/skills/gifgrep/SKILL.md +79 -0
  1513. package/skills/github/SKILL.md +77 -0
  1514. package/skills/gog/SKILL.md +116 -0
  1515. package/skills/goplaces/SKILL.md +52 -0
  1516. package/skills/healthcheck/SKILL.md +245 -0
  1517. package/skills/himalaya/SKILL.md +257 -0
  1518. package/skills/himalaya/references/configuration.md +184 -0
  1519. package/skills/himalaya/references/message-composition.md +199 -0
  1520. package/skills/imsg/SKILL.md +74 -0
  1521. package/skills/mcporter/SKILL.md +61 -0
  1522. package/skills/model-usage/SKILL.md +69 -0
  1523. package/skills/model-usage/references/codexbar-cli.md +33 -0
  1524. package/skills/model-usage/scripts/model_usage.py +310 -0
  1525. package/skills/nano-banana-pro/SKILL.md +58 -0
  1526. package/skills/nano-banana-pro/scripts/generate_image.py +184 -0
  1527. package/skills/nano-pdf/SKILL.md +38 -0
  1528. package/skills/notion/SKILL.md +172 -0
  1529. package/skills/obsidian/SKILL.md +81 -0
  1530. package/skills/openai-image-gen/SKILL.md +89 -0
  1531. package/skills/openai-image-gen/scripts/gen.py +240 -0
  1532. package/skills/openai-whisper/SKILL.md +38 -0
  1533. package/skills/openai-whisper-api/SKILL.md +52 -0
  1534. package/skills/openai-whisper-api/scripts/transcribe.sh +85 -0
  1535. package/skills/openhue/SKILL.md +51 -0
  1536. package/skills/oracle/SKILL.md +125 -0
  1537. package/skills/ordercli/SKILL.md +78 -0
  1538. package/skills/peekaboo/SKILL.md +190 -0
  1539. package/skills/review/SKILL.md +58 -0
  1540. package/skills/sag/SKILL.md +87 -0
  1541. package/skills/session-logs/SKILL.md +115 -0
  1542. package/skills/sherpa-onnx-tts/SKILL.md +103 -0
  1543. package/skills/sherpa-onnx-tts/bin/sherpa-onnx-tts +178 -0
  1544. package/skills/skill-creator/SKILL.md +370 -0
  1545. package/skills/skill-creator/license.txt +202 -0
  1546. package/skills/skill-creator/scripts/init_skill.py +378 -0
  1547. package/skills/skill-creator/scripts/package_skill.py +111 -0
  1548. package/skills/skill-creator/scripts/quick_validate.py +101 -0
  1549. package/skills/slack/SKILL.md +144 -0
  1550. package/skills/songsee/SKILL.md +49 -0
  1551. package/skills/sonoscli/SKILL.md +46 -0
  1552. package/skills/spotify-player/SKILL.md +64 -0
  1553. package/skills/summarize/SKILL.md +87 -0
  1554. package/skills/things-mac/SKILL.md +86 -0
  1555. package/skills/tmux/SKILL.md +135 -0
  1556. package/skills/tmux/scripts/find-sessions.sh +112 -0
  1557. package/skills/tmux/scripts/wait-for-text.sh +83 -0
  1558. package/skills/trello/SKILL.md +95 -0
  1559. package/skills/video-frames/SKILL.md +46 -0
  1560. package/skills/video-frames/scripts/frame.sh +81 -0
  1561. package/skills/voice-call/SKILL.md +45 -0
  1562. package/skills/wacli/SKILL.md +72 -0
  1563. package/skills/weather/SKILL.md +54 -0
  1564. package/templates/BRAIN.md +65 -0
  1565. package/templates/GUT.md +44 -0
  1566. package/templates/HEART.md +51 -0
  1567. package/templates/MEMORY.md +66 -0
  1568. package/templates/SHADOW.md +68 -0
  1569. package/templates/SOUL.md +38 -0
  1570. package/templates/SPIRIT.md +43 -0
@@ -0,0 +1,3244 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-Cbj13DAv.js";
2
+ import { s as resolveStateDir } from "./paths-CCxa0o9c.js";
3
+ import { D as clampNumber$1, E as clampInt, K as truncateUtf16Safe, U as sleep, l as createSubsystemLogger, z as resolveUserPath } from "./exec-BenD3A5l.js";
4
+ import { n as resolveAgentConfig, r as resolveAgentDir$1, s as resolveAgentWorkspaceDir } from "./agent-scope-BVf4aSwY.js";
5
+ import { D as resolveApiKeyForProvider, E as requireApiKey, I as isTruthyEnvValue } from "./auth-profiles-_5BsNObq.js";
6
+ import { o as resolveSessionTranscriptsDirForAgent } from "./paths-BTc4nk-6.js";
7
+ import { n as onSessionTranscriptUpdate } from "./transcript-events-DW_H__a1.js";
8
+ import { n as formatErrorMessage } from "./errors-A_GqUU6B.js";
9
+ import { a as buildFileEntry, c as ensureDir, d as listMemoryFiles, f as normalizeExtraMemoryPaths, h as runWithConcurrency, i as sessionPathForFile, l as hashText, m as remapChunkLines, n as buildSessionEntry, o as chunkMarkdown, p as parseEmbedding, r as listSessionFilesForAgent, s as cosineSimilarity, t as requireNodeSqlite, u as isMemoryPath } from "./sqlite-Ck6f9KWc.js";
10
+ import fs from "node:fs/promises";
11
+ import os from "node:os";
12
+ import path from "node:path";
13
+ import fs$1 from "node:fs";
14
+ import { randomUUID } from "node:crypto";
15
+ import chokidar from "chokidar";
16
+ import { createInterface } from "node:readline";
17
+ import { Readable } from "node:stream";
18
+
19
+ //#region src/agents/memory-search.ts
20
+ const DEFAULT_OPENAI_MODEL = "text-embedding-3-small";
21
+ const DEFAULT_GEMINI_MODEL = "gemini-embedding-001";
22
+ const DEFAULT_VOYAGE_MODEL = "voyage-4-large";
23
+ const DEFAULT_CHUNK_TOKENS = 400;
24
+ const DEFAULT_CHUNK_OVERLAP = 80;
25
+ const DEFAULT_WATCH_DEBOUNCE_MS = 1500;
26
+ const DEFAULT_SESSION_DELTA_BYTES = 1e5;
27
+ const DEFAULT_SESSION_DELTA_MESSAGES = 50;
28
+ const DEFAULT_MAX_RESULTS = 6;
29
+ const DEFAULT_MIN_SCORE = .35;
30
+ const DEFAULT_HYBRID_ENABLED = true;
31
+ const DEFAULT_HYBRID_VECTOR_WEIGHT = .7;
32
+ const DEFAULT_HYBRID_TEXT_WEIGHT = .3;
33
+ const DEFAULT_HYBRID_CANDIDATE_MULTIPLIER = 4;
34
+ const DEFAULT_CACHE_ENABLED = true;
35
+ const DEFAULT_SOURCES = ["memory"];
36
+ function normalizeSources(sources, sessionMemoryEnabled) {
37
+ const normalized = /* @__PURE__ */ new Set();
38
+ const input = sources?.length ? sources : DEFAULT_SOURCES;
39
+ for (const source of input) {
40
+ if (source === "memory") normalized.add("memory");
41
+ if (source === "sessions" && sessionMemoryEnabled) normalized.add("sessions");
42
+ }
43
+ if (normalized.size === 0) normalized.add("memory");
44
+ return Array.from(normalized);
45
+ }
46
+ function resolveStorePath(agentId, raw) {
47
+ const stateDir = resolveStateDir(process.env, os.homedir);
48
+ const fallback = path.join(stateDir, "memory", `${agentId}.sqlite`);
49
+ if (!raw) return fallback;
50
+ return resolveUserPath(raw.includes("{agentId}") ? raw.replaceAll("{agentId}", agentId) : raw);
51
+ }
52
+ function mergeConfig(defaults, overrides, agentId) {
53
+ const enabled = overrides?.enabled ?? defaults?.enabled ?? true;
54
+ const sessionMemory = overrides?.experimental?.sessionMemory ?? defaults?.experimental?.sessionMemory ?? false;
55
+ const provider = overrides?.provider ?? defaults?.provider ?? "auto";
56
+ const defaultRemote = defaults?.remote;
57
+ const overrideRemote = overrides?.remote;
58
+ const includeRemote = Boolean(overrideRemote?.baseUrl || overrideRemote?.apiKey || overrideRemote?.headers || defaultRemote?.baseUrl || defaultRemote?.apiKey || defaultRemote?.headers) || provider === "openai" || provider === "gemini" || provider === "voyage" || provider === "auto";
59
+ const batch = {
60
+ enabled: overrideRemote?.batch?.enabled ?? defaultRemote?.batch?.enabled ?? false,
61
+ wait: overrideRemote?.batch?.wait ?? defaultRemote?.batch?.wait ?? true,
62
+ concurrency: Math.max(1, overrideRemote?.batch?.concurrency ?? defaultRemote?.batch?.concurrency ?? 2),
63
+ pollIntervalMs: overrideRemote?.batch?.pollIntervalMs ?? defaultRemote?.batch?.pollIntervalMs ?? 2e3,
64
+ timeoutMinutes: overrideRemote?.batch?.timeoutMinutes ?? defaultRemote?.batch?.timeoutMinutes ?? 60
65
+ };
66
+ const remote = includeRemote ? {
67
+ baseUrl: overrideRemote?.baseUrl ?? defaultRemote?.baseUrl,
68
+ apiKey: overrideRemote?.apiKey ?? defaultRemote?.apiKey,
69
+ headers: overrideRemote?.headers ?? defaultRemote?.headers,
70
+ batch
71
+ } : void 0;
72
+ const fallback = overrides?.fallback ?? defaults?.fallback ?? "none";
73
+ const modelDefault = provider === "gemini" ? DEFAULT_GEMINI_MODEL : provider === "openai" ? DEFAULT_OPENAI_MODEL : provider === "voyage" ? DEFAULT_VOYAGE_MODEL : void 0;
74
+ const model = overrides?.model ?? defaults?.model ?? modelDefault ?? "";
75
+ const local = {
76
+ modelPath: overrides?.local?.modelPath ?? defaults?.local?.modelPath,
77
+ modelCacheDir: overrides?.local?.modelCacheDir ?? defaults?.local?.modelCacheDir
78
+ };
79
+ const sources = normalizeSources(overrides?.sources ?? defaults?.sources, sessionMemory);
80
+ const rawPaths = [...defaults?.extraPaths ?? [], ...overrides?.extraPaths ?? []].map((value) => value.trim()).filter(Boolean);
81
+ const extraPaths = Array.from(new Set(rawPaths));
82
+ const vector = {
83
+ enabled: overrides?.store?.vector?.enabled ?? defaults?.store?.vector?.enabled ?? true,
84
+ extensionPath: overrides?.store?.vector?.extensionPath ?? defaults?.store?.vector?.extensionPath
85
+ };
86
+ const store = {
87
+ driver: overrides?.store?.driver ?? defaults?.store?.driver ?? "sqlite",
88
+ path: resolveStorePath(agentId, overrides?.store?.path ?? defaults?.store?.path),
89
+ vector
90
+ };
91
+ const chunking = {
92
+ tokens: overrides?.chunking?.tokens ?? defaults?.chunking?.tokens ?? DEFAULT_CHUNK_TOKENS,
93
+ overlap: overrides?.chunking?.overlap ?? defaults?.chunking?.overlap ?? DEFAULT_CHUNK_OVERLAP
94
+ };
95
+ const sync = {
96
+ onSessionStart: overrides?.sync?.onSessionStart ?? defaults?.sync?.onSessionStart ?? true,
97
+ onSearch: overrides?.sync?.onSearch ?? defaults?.sync?.onSearch ?? true,
98
+ watch: overrides?.sync?.watch ?? defaults?.sync?.watch ?? true,
99
+ watchDebounceMs: overrides?.sync?.watchDebounceMs ?? defaults?.sync?.watchDebounceMs ?? DEFAULT_WATCH_DEBOUNCE_MS,
100
+ intervalMinutes: overrides?.sync?.intervalMinutes ?? defaults?.sync?.intervalMinutes ?? 0,
101
+ sessions: {
102
+ deltaBytes: overrides?.sync?.sessions?.deltaBytes ?? defaults?.sync?.sessions?.deltaBytes ?? DEFAULT_SESSION_DELTA_BYTES,
103
+ deltaMessages: overrides?.sync?.sessions?.deltaMessages ?? defaults?.sync?.sessions?.deltaMessages ?? DEFAULT_SESSION_DELTA_MESSAGES
104
+ }
105
+ };
106
+ const query = {
107
+ maxResults: overrides?.query?.maxResults ?? defaults?.query?.maxResults ?? DEFAULT_MAX_RESULTS,
108
+ minScore: overrides?.query?.minScore ?? defaults?.query?.minScore ?? DEFAULT_MIN_SCORE
109
+ };
110
+ const hybrid = {
111
+ enabled: overrides?.query?.hybrid?.enabled ?? defaults?.query?.hybrid?.enabled ?? DEFAULT_HYBRID_ENABLED,
112
+ vectorWeight: overrides?.query?.hybrid?.vectorWeight ?? defaults?.query?.hybrid?.vectorWeight ?? DEFAULT_HYBRID_VECTOR_WEIGHT,
113
+ textWeight: overrides?.query?.hybrid?.textWeight ?? defaults?.query?.hybrid?.textWeight ?? DEFAULT_HYBRID_TEXT_WEIGHT,
114
+ candidateMultiplier: overrides?.query?.hybrid?.candidateMultiplier ?? defaults?.query?.hybrid?.candidateMultiplier ?? DEFAULT_HYBRID_CANDIDATE_MULTIPLIER
115
+ };
116
+ const cache = {
117
+ enabled: overrides?.cache?.enabled ?? defaults?.cache?.enabled ?? DEFAULT_CACHE_ENABLED,
118
+ maxEntries: overrides?.cache?.maxEntries ?? defaults?.cache?.maxEntries
119
+ };
120
+ const overlap = clampNumber$1(chunking.overlap, 0, Math.max(0, chunking.tokens - 1));
121
+ const minScore = clampNumber$1(query.minScore, 0, 1);
122
+ const vectorWeight = clampNumber$1(hybrid.vectorWeight, 0, 1);
123
+ const textWeight = clampNumber$1(hybrid.textWeight, 0, 1);
124
+ const sum = vectorWeight + textWeight;
125
+ const normalizedVectorWeight = sum > 0 ? vectorWeight / sum : DEFAULT_HYBRID_VECTOR_WEIGHT;
126
+ const normalizedTextWeight = sum > 0 ? textWeight / sum : DEFAULT_HYBRID_TEXT_WEIGHT;
127
+ const candidateMultiplier = clampInt(hybrid.candidateMultiplier, 1, 20);
128
+ const deltaBytes = clampInt(sync.sessions.deltaBytes, 0, Number.MAX_SAFE_INTEGER);
129
+ const deltaMessages = clampInt(sync.sessions.deltaMessages, 0, Number.MAX_SAFE_INTEGER);
130
+ return {
131
+ enabled,
132
+ sources,
133
+ extraPaths,
134
+ provider,
135
+ remote,
136
+ experimental: { sessionMemory },
137
+ fallback,
138
+ model,
139
+ local,
140
+ store,
141
+ chunking: {
142
+ tokens: Math.max(1, chunking.tokens),
143
+ overlap
144
+ },
145
+ sync: {
146
+ ...sync,
147
+ sessions: {
148
+ deltaBytes,
149
+ deltaMessages
150
+ }
151
+ },
152
+ query: {
153
+ ...query,
154
+ minScore,
155
+ hybrid: {
156
+ enabled: Boolean(hybrid.enabled),
157
+ vectorWeight: normalizedVectorWeight,
158
+ textWeight: normalizedTextWeight,
159
+ candidateMultiplier
160
+ }
161
+ },
162
+ cache: {
163
+ enabled: Boolean(cache.enabled),
164
+ maxEntries: typeof cache.maxEntries === "number" && Number.isFinite(cache.maxEntries) ? Math.max(1, Math.floor(cache.maxEntries)) : void 0
165
+ }
166
+ };
167
+ }
168
+ function resolveMemorySearchConfig(cfg, agentId) {
169
+ const defaults = cfg.agents?.defaults?.memorySearch;
170
+ const overrides = resolveAgentConfig(cfg, agentId)?.memorySearch;
171
+ const resolved = mergeConfig(defaults, overrides, agentId);
172
+ if (!resolved.enabled) return null;
173
+ return resolved;
174
+ }
175
+
176
+ //#endregion
177
+ //#region src/memory/embeddings-gemini.ts
178
+ const DEFAULT_GEMINI_BASE_URL = "https://generativelanguage.googleapis.com/v1beta";
179
+ const DEFAULT_GEMINI_EMBEDDING_MODEL$1 = "gemini-embedding-001";
180
+ const GEMINI_MAX_INPUT_TOKENS = { "text-embedding-004": 2048 };
181
+ const debugEmbeddings$1 = isTruthyEnvValue(process.env.ANIMA_DEBUG_MEMORY_EMBEDDINGS);
182
+ const log$4 = createSubsystemLogger("memory/embeddings");
183
+ const debugLog$1 = (message, meta) => {
184
+ if (!debugEmbeddings$1) return;
185
+ const suffix = meta ? ` ${JSON.stringify(meta)}` : "";
186
+ log$4.raw(`${message}${suffix}`);
187
+ };
188
+ function resolveRemoteApiKey(remoteApiKey) {
189
+ const trimmed = remoteApiKey?.trim();
190
+ if (!trimmed) return;
191
+ if (trimmed === "GOOGLE_API_KEY" || trimmed === "GEMINI_API_KEY") return process.env[trimmed]?.trim();
192
+ return trimmed;
193
+ }
194
+ function normalizeGeminiModel(model) {
195
+ const trimmed = model.trim();
196
+ if (!trimmed) return DEFAULT_GEMINI_EMBEDDING_MODEL$1;
197
+ const withoutPrefix = trimmed.replace(/^models\//, "");
198
+ if (withoutPrefix.startsWith("gemini/")) return withoutPrefix.slice(7);
199
+ if (withoutPrefix.startsWith("google/")) return withoutPrefix.slice(7);
200
+ return withoutPrefix;
201
+ }
202
+ function normalizeGeminiBaseUrl(raw) {
203
+ const trimmed = raw.replace(/\/+$/, "");
204
+ const openAiIndex = trimmed.indexOf("/openai");
205
+ if (openAiIndex > -1) return trimmed.slice(0, openAiIndex);
206
+ return trimmed;
207
+ }
208
+ function buildGeminiModelPath(model) {
209
+ return model.startsWith("models/") ? model : `models/${model}`;
210
+ }
211
+ async function createGeminiEmbeddingProvider(options) {
212
+ const client = await resolveGeminiEmbeddingClient(options);
213
+ const baseUrl = client.baseUrl.replace(/\/$/, "");
214
+ const embedUrl = `${baseUrl}/${client.modelPath}:embedContent`;
215
+ const batchUrl = `${baseUrl}/${client.modelPath}:batchEmbedContents`;
216
+ const embedQuery = async (text) => {
217
+ if (!text.trim()) return [];
218
+ const res = await fetch(embedUrl, {
219
+ method: "POST",
220
+ headers: client.headers,
221
+ body: JSON.stringify({
222
+ content: { parts: [{ text }] },
223
+ taskType: "RETRIEVAL_QUERY"
224
+ })
225
+ });
226
+ if (!res.ok) {
227
+ const payload = await res.text();
228
+ throw new Error(`gemini embeddings failed: ${res.status} ${payload}`);
229
+ }
230
+ return (await res.json()).embedding?.values ?? [];
231
+ };
232
+ const embedBatch = async (texts) => {
233
+ if (texts.length === 0) return [];
234
+ const requests = texts.map((text) => ({
235
+ model: client.modelPath,
236
+ content: { parts: [{ text }] },
237
+ taskType: "RETRIEVAL_DOCUMENT"
238
+ }));
239
+ const res = await fetch(batchUrl, {
240
+ method: "POST",
241
+ headers: client.headers,
242
+ body: JSON.stringify({ requests })
243
+ });
244
+ if (!res.ok) {
245
+ const payload = await res.text();
246
+ throw new Error(`gemini embeddings failed: ${res.status} ${payload}`);
247
+ }
248
+ const payload = await res.json();
249
+ const embeddings = Array.isArray(payload.embeddings) ? payload.embeddings : [];
250
+ return texts.map((_, index) => embeddings[index]?.values ?? []);
251
+ };
252
+ return {
253
+ provider: {
254
+ id: "gemini",
255
+ model: client.model,
256
+ maxInputTokens: GEMINI_MAX_INPUT_TOKENS[client.model],
257
+ embedQuery,
258
+ embedBatch
259
+ },
260
+ client
261
+ };
262
+ }
263
+ async function resolveGeminiEmbeddingClient(options) {
264
+ const remote = options.remote;
265
+ const remoteApiKey = resolveRemoteApiKey(remote?.apiKey);
266
+ const remoteBaseUrl = remote?.baseUrl?.trim();
267
+ const apiKey = remoteApiKey ? remoteApiKey : requireApiKey(await resolveApiKeyForProvider({
268
+ provider: "google",
269
+ cfg: options.config,
270
+ agentDir: options.agentDir
271
+ }), "google");
272
+ const providerConfig = options.config.models?.providers?.google;
273
+ const rawBaseUrl = remoteBaseUrl || providerConfig?.baseUrl?.trim() || DEFAULT_GEMINI_BASE_URL;
274
+ const baseUrl = normalizeGeminiBaseUrl(rawBaseUrl);
275
+ const headerOverrides = Object.assign({}, providerConfig?.headers, remote?.headers);
276
+ const headers = {
277
+ "Content-Type": "application/json",
278
+ "x-goog-api-key": apiKey,
279
+ ...headerOverrides
280
+ };
281
+ const model = normalizeGeminiModel(options.model);
282
+ const modelPath = buildGeminiModelPath(model);
283
+ debugLog$1("memory embeddings: gemini client", {
284
+ rawBaseUrl,
285
+ baseUrl,
286
+ model,
287
+ modelPath,
288
+ embedEndpoint: `${baseUrl}/${modelPath}:embedContent`,
289
+ batchEndpoint: `${baseUrl}/${modelPath}:batchEmbedContents`
290
+ });
291
+ return {
292
+ baseUrl,
293
+ headers,
294
+ model,
295
+ modelPath
296
+ };
297
+ }
298
+
299
+ //#endregion
300
+ //#region src/memory/embeddings-openai.ts
301
+ const DEFAULT_OPENAI_EMBEDDING_MODEL$1 = "text-embedding-3-small";
302
+ const DEFAULT_OPENAI_BASE_URL = "https://api.openai.com/v1";
303
+ const OPENAI_MAX_INPUT_TOKENS = {
304
+ "text-embedding-3-small": 8192,
305
+ "text-embedding-3-large": 8192,
306
+ "text-embedding-ada-002": 8191
307
+ };
308
+ function normalizeOpenAiModel(model) {
309
+ const trimmed = model.trim();
310
+ if (!trimmed) return DEFAULT_OPENAI_EMBEDDING_MODEL$1;
311
+ if (trimmed.startsWith("openai/")) return trimmed.slice(7);
312
+ return trimmed;
313
+ }
314
+ async function createOpenAiEmbeddingProvider(options) {
315
+ const client = await resolveOpenAiEmbeddingClient(options);
316
+ const url = `${client.baseUrl.replace(/\/$/, "")}/embeddings`;
317
+ const embed = async (input) => {
318
+ if (input.length === 0) return [];
319
+ const res = await fetch(url, {
320
+ method: "POST",
321
+ headers: client.headers,
322
+ body: JSON.stringify({
323
+ model: client.model,
324
+ input
325
+ })
326
+ });
327
+ if (!res.ok) {
328
+ const text = await res.text();
329
+ throw new Error(`openai embeddings failed: ${res.status} ${text}`);
330
+ }
331
+ return ((await res.json()).data ?? []).map((entry) => entry.embedding ?? []);
332
+ };
333
+ return {
334
+ provider: {
335
+ id: "openai",
336
+ model: client.model,
337
+ maxInputTokens: OPENAI_MAX_INPUT_TOKENS[client.model],
338
+ embedQuery: async (text) => {
339
+ const [vec] = await embed([text]);
340
+ return vec ?? [];
341
+ },
342
+ embedBatch: embed
343
+ },
344
+ client
345
+ };
346
+ }
347
+ async function resolveOpenAiEmbeddingClient(options) {
348
+ const remote = options.remote;
349
+ const remoteApiKey = remote?.apiKey?.trim();
350
+ const remoteBaseUrl = remote?.baseUrl?.trim();
351
+ const apiKey = remoteApiKey ? remoteApiKey : requireApiKey(await resolveApiKeyForProvider({
352
+ provider: "openai",
353
+ cfg: options.config,
354
+ agentDir: options.agentDir
355
+ }), "openai");
356
+ const providerConfig = options.config.models?.providers?.openai;
357
+ const baseUrl = remoteBaseUrl || providerConfig?.baseUrl?.trim() || DEFAULT_OPENAI_BASE_URL;
358
+ const headerOverrides = Object.assign({}, providerConfig?.headers, remote?.headers);
359
+ return {
360
+ baseUrl,
361
+ headers: {
362
+ "Content-Type": "application/json",
363
+ Authorization: `Bearer ${apiKey}`,
364
+ ...headerOverrides
365
+ },
366
+ model: normalizeOpenAiModel(options.model)
367
+ };
368
+ }
369
+
370
+ //#endregion
371
+ //#region src/memory/embeddings-voyage.ts
372
+ const DEFAULT_VOYAGE_EMBEDDING_MODEL$1 = "voyage-4-large";
373
+ const DEFAULT_VOYAGE_BASE_URL = "https://api.voyageai.com/v1";
374
+ const VOYAGE_MAX_INPUT_TOKENS = {
375
+ "voyage-3": 32e3,
376
+ "voyage-3-lite": 16e3,
377
+ "voyage-code-3": 32e3
378
+ };
379
+ function normalizeVoyageModel(model) {
380
+ const trimmed = model.trim();
381
+ if (!trimmed) return DEFAULT_VOYAGE_EMBEDDING_MODEL$1;
382
+ if (trimmed.startsWith("voyage/")) return trimmed.slice(7);
383
+ return trimmed;
384
+ }
385
+ async function createVoyageEmbeddingProvider(options) {
386
+ const client = await resolveVoyageEmbeddingClient(options);
387
+ const url = `${client.baseUrl.replace(/\/$/, "")}/embeddings`;
388
+ const embed = async (input, input_type) => {
389
+ if (input.length === 0) return [];
390
+ const body = {
391
+ model: client.model,
392
+ input
393
+ };
394
+ if (input_type) body.input_type = input_type;
395
+ const res = await fetch(url, {
396
+ method: "POST",
397
+ headers: client.headers,
398
+ body: JSON.stringify(body)
399
+ });
400
+ if (!res.ok) {
401
+ const text = await res.text();
402
+ throw new Error(`voyage embeddings failed: ${res.status} ${text}`);
403
+ }
404
+ return ((await res.json()).data ?? []).map((entry) => entry.embedding ?? []);
405
+ };
406
+ return {
407
+ provider: {
408
+ id: "voyage",
409
+ model: client.model,
410
+ maxInputTokens: VOYAGE_MAX_INPUT_TOKENS[client.model],
411
+ embedQuery: async (text) => {
412
+ const [vec] = await embed([text], "query");
413
+ return vec ?? [];
414
+ },
415
+ embedBatch: async (texts) => embed(texts, "document")
416
+ },
417
+ client
418
+ };
419
+ }
420
+ async function resolveVoyageEmbeddingClient(options) {
421
+ const remote = options.remote;
422
+ const remoteApiKey = remote?.apiKey?.trim();
423
+ const remoteBaseUrl = remote?.baseUrl?.trim();
424
+ const apiKey = remoteApiKey ? remoteApiKey : requireApiKey(await resolveApiKeyForProvider({
425
+ provider: "voyage",
426
+ cfg: options.config,
427
+ agentDir: options.agentDir
428
+ }), "voyage");
429
+ const providerConfig = options.config.models?.providers?.voyage;
430
+ const baseUrl = remoteBaseUrl || providerConfig?.baseUrl?.trim() || DEFAULT_VOYAGE_BASE_URL;
431
+ const headerOverrides = Object.assign({}, providerConfig?.headers, remote?.headers);
432
+ return {
433
+ baseUrl,
434
+ headers: {
435
+ "Content-Type": "application/json",
436
+ Authorization: `Bearer ${apiKey}`,
437
+ ...headerOverrides
438
+ },
439
+ model: normalizeVoyageModel(options.model)
440
+ };
441
+ }
442
+
443
+ //#endregion
444
+ //#region src/memory/node-llama.ts
445
+ async function importNodeLlamaCpp() {
446
+ return import("node-llama-cpp");
447
+ }
448
+
449
+ //#endregion
450
+ //#region src/memory/embeddings.ts
451
+ function sanitizeAndNormalizeEmbedding(vec) {
452
+ const sanitized = vec.map((value) => Number.isFinite(value) ? value : 0);
453
+ const magnitude = Math.sqrt(sanitized.reduce((sum, value) => sum + value * value, 0));
454
+ if (magnitude < 1e-10) return sanitized;
455
+ return sanitized.map((value) => value / magnitude);
456
+ }
457
+ const REMOTE_EMBEDDING_PROVIDER_IDS = [
458
+ "openai",
459
+ "gemini",
460
+ "voyage"
461
+ ];
462
+ const DEFAULT_LOCAL_MODEL = "hf:ggml-org/embeddinggemma-300m-qat-q8_0-GGUF/embeddinggemma-300m-qat-Q8_0.gguf";
463
+ function canAutoSelectLocal(options) {
464
+ const modelPath = options.local?.modelPath?.trim();
465
+ if (!modelPath) return false;
466
+ if (/^(hf:|https?:)/i.test(modelPath)) return false;
467
+ const resolved = resolveUserPath(modelPath);
468
+ try {
469
+ return fs$1.statSync(resolved).isFile();
470
+ } catch {
471
+ return false;
472
+ }
473
+ }
474
+ function isMissingApiKeyError(err) {
475
+ return formatErrorMessage(err).includes("No API key found for provider");
476
+ }
477
+ async function createLocalEmbeddingProvider(options) {
478
+ const modelPath = options.local?.modelPath?.trim() || DEFAULT_LOCAL_MODEL;
479
+ const modelCacheDir = options.local?.modelCacheDir?.trim();
480
+ const { getLlama, resolveModelFile, LlamaLogLevel } = await importNodeLlamaCpp();
481
+ let llama = null;
482
+ let embeddingModel = null;
483
+ let embeddingContext = null;
484
+ const ensureContext = async () => {
485
+ if (!llama) llama = await getLlama({ logLevel: LlamaLogLevel.error });
486
+ if (!embeddingModel) {
487
+ const resolved = await resolveModelFile(modelPath, modelCacheDir || void 0);
488
+ embeddingModel = await llama.loadModel({ modelPath: resolved });
489
+ }
490
+ if (!embeddingContext) embeddingContext = await embeddingModel.createEmbeddingContext();
491
+ return embeddingContext;
492
+ };
493
+ return {
494
+ id: "local",
495
+ model: modelPath,
496
+ embedQuery: async (text) => {
497
+ const embedding = await (await ensureContext()).getEmbeddingFor(text);
498
+ return sanitizeAndNormalizeEmbedding(Array.from(embedding.vector));
499
+ },
500
+ embedBatch: async (texts) => {
501
+ const ctx = await ensureContext();
502
+ return await Promise.all(texts.map(async (text) => {
503
+ const embedding = await ctx.getEmbeddingFor(text);
504
+ return sanitizeAndNormalizeEmbedding(Array.from(embedding.vector));
505
+ }));
506
+ }
507
+ };
508
+ }
509
+ async function createEmbeddingProvider$1(options) {
510
+ const requestedProvider = options.provider;
511
+ const fallback = options.fallback;
512
+ const createProvider = async (id) => {
513
+ if (id === "local") return { provider: await createLocalEmbeddingProvider(options) };
514
+ if (id === "gemini") {
515
+ const { provider, client } = await createGeminiEmbeddingProvider(options);
516
+ return {
517
+ provider,
518
+ gemini: client
519
+ };
520
+ }
521
+ if (id === "voyage") {
522
+ const { provider, client } = await createVoyageEmbeddingProvider(options);
523
+ return {
524
+ provider,
525
+ voyage: client
526
+ };
527
+ }
528
+ const { provider, client } = await createOpenAiEmbeddingProvider(options);
529
+ return {
530
+ provider,
531
+ openAi: client
532
+ };
533
+ };
534
+ const formatPrimaryError = (err, provider) => provider === "local" ? formatLocalSetupError(err) : formatErrorMessage(err);
535
+ if (requestedProvider === "auto") {
536
+ const missingKeyErrors = [];
537
+ let localError = null;
538
+ if (canAutoSelectLocal(options)) try {
539
+ return {
540
+ ...await createProvider("local"),
541
+ requestedProvider
542
+ };
543
+ } catch (err) {
544
+ localError = formatLocalSetupError(err);
545
+ }
546
+ for (const provider of REMOTE_EMBEDDING_PROVIDER_IDS) try {
547
+ return {
548
+ ...await createProvider(provider),
549
+ requestedProvider
550
+ };
551
+ } catch (err) {
552
+ const message = formatPrimaryError(err, provider);
553
+ if (isMissingApiKeyError(err)) {
554
+ missingKeyErrors.push(message);
555
+ continue;
556
+ }
557
+ throw new Error(message, { cause: err });
558
+ }
559
+ const details = [...missingKeyErrors, localError].filter(Boolean);
560
+ if (details.length > 0) throw new Error(details.join("\n\n"));
561
+ throw new Error("No embeddings provider available.");
562
+ }
563
+ try {
564
+ return {
565
+ ...await createProvider(requestedProvider),
566
+ requestedProvider
567
+ };
568
+ } catch (primaryErr) {
569
+ const reason = formatPrimaryError(primaryErr, requestedProvider);
570
+ if (fallback && fallback !== "none" && fallback !== requestedProvider) try {
571
+ return {
572
+ ...await createProvider(fallback),
573
+ requestedProvider,
574
+ fallbackFrom: requestedProvider,
575
+ fallbackReason: reason
576
+ };
577
+ } catch (fallbackErr) {
578
+ throw new Error(`${reason}\n\nFallback to ${fallback} failed: ${formatErrorMessage(fallbackErr)}`, { cause: fallbackErr });
579
+ }
580
+ throw new Error(reason, { cause: primaryErr });
581
+ }
582
+ }
583
+ function isNodeLlamaCppMissing(err) {
584
+ if (!(err instanceof Error)) return false;
585
+ if (err.code === "ERR_MODULE_NOT_FOUND") return err.message.includes("node-llama-cpp");
586
+ return false;
587
+ }
588
+ function formatLocalSetupError(err) {
589
+ const detail = formatErrorMessage(err);
590
+ const missing = isNodeLlamaCppMissing(err);
591
+ return [
592
+ "Local embeddings unavailable.",
593
+ missing ? "Reason: optional dependency node-llama-cpp is missing (or failed to install)." : detail ? `Reason: ${detail}` : void 0,
594
+ missing && detail ? `Detail: ${detail}` : null,
595
+ "To enable local embeddings:",
596
+ "1) Use Node 22 LTS (recommended for installs/updates)",
597
+ missing ? "2) Reinstall Anima (this should install node-llama-cpp): npm i -g anima@latest" : null,
598
+ "3) If you use pnpm: pnpm approve-builds (select node-llama-cpp), then pnpm rebuild node-llama-cpp",
599
+ ...REMOTE_EMBEDDING_PROVIDER_IDS.map((provider) => `Or set agents.defaults.memorySearch.provider = "${provider}" (remote).`)
600
+ ].filter(Boolean).join("\n");
601
+ }
602
+
603
+ //#endregion
604
+ //#region src/memory/hybrid.ts
605
+ function buildFtsQuery(raw) {
606
+ const tokens = raw.match(/[A-Za-z0-9_]+/g)?.map((t) => t.trim()).filter(Boolean) ?? [];
607
+ if (tokens.length === 0) return null;
608
+ return tokens.map((t) => `"${t.replaceAll("\"", "")}"`).join(" AND ");
609
+ }
610
+ function bm25RankToScore(rank) {
611
+ return 1 / (1 + (Number.isFinite(rank) ? Math.max(0, rank) : 999));
612
+ }
613
+ function mergeHybridResults(params) {
614
+ const byId = /* @__PURE__ */ new Map();
615
+ for (const r of params.vector) byId.set(r.id, {
616
+ id: r.id,
617
+ path: r.path,
618
+ startLine: r.startLine,
619
+ endLine: r.endLine,
620
+ source: r.source,
621
+ snippet: r.snippet,
622
+ vectorScore: r.vectorScore,
623
+ textScore: 0
624
+ });
625
+ for (const r of params.keyword) {
626
+ const existing = byId.get(r.id);
627
+ if (existing) {
628
+ existing.textScore = r.textScore;
629
+ if (r.snippet && r.snippet.length > 0) existing.snippet = r.snippet;
630
+ } else byId.set(r.id, {
631
+ id: r.id,
632
+ path: r.path,
633
+ startLine: r.startLine,
634
+ endLine: r.endLine,
635
+ source: r.source,
636
+ snippet: r.snippet,
637
+ vectorScore: 0,
638
+ textScore: r.textScore
639
+ });
640
+ }
641
+ return Array.from(byId.values()).map((entry) => {
642
+ const score = params.vectorWeight * entry.vectorScore + params.textWeight * entry.textScore;
643
+ return {
644
+ path: entry.path,
645
+ startLine: entry.startLine,
646
+ endLine: entry.endLine,
647
+ score,
648
+ snippet: entry.snippet,
649
+ source: entry.source
650
+ };
651
+ }).toSorted((a, b) => b.score - a.score);
652
+ }
653
+
654
+ //#endregion
655
+ //#region src/memory/batch-gemini.ts
656
+ const GEMINI_BATCH_MAX_REQUESTS = 5e4;
657
+ const debugEmbeddings = isTruthyEnvValue(process.env.ANIMA_DEBUG_MEMORY_EMBEDDINGS);
658
+ const log$3 = createSubsystemLogger("memory/embeddings");
659
+ const debugLog = (message, meta) => {
660
+ if (!debugEmbeddings) return;
661
+ const suffix = meta ? ` ${JSON.stringify(meta)}` : "";
662
+ log$3.raw(`${message}${suffix}`);
663
+ };
664
+ function getGeminiBaseUrl(gemini) {
665
+ return gemini.baseUrl?.replace(/\/$/, "") ?? "";
666
+ }
667
+ function getGeminiHeaders(gemini, params) {
668
+ const headers = gemini.headers ? { ...gemini.headers } : {};
669
+ if (params.json) {
670
+ if (!headers["Content-Type"] && !headers["content-type"]) headers["Content-Type"] = "application/json";
671
+ } else {
672
+ delete headers["Content-Type"];
673
+ delete headers["content-type"];
674
+ }
675
+ return headers;
676
+ }
677
+ function getGeminiUploadUrl(baseUrl) {
678
+ if (baseUrl.includes("/v1beta")) return baseUrl.replace(/\/v1beta\/?$/, "/upload/v1beta");
679
+ return `${baseUrl.replace(/\/$/, "")}/upload`;
680
+ }
681
+ function splitGeminiBatchRequests(requests) {
682
+ if (requests.length <= GEMINI_BATCH_MAX_REQUESTS) return [requests];
683
+ const groups = [];
684
+ for (let i = 0; i < requests.length; i += GEMINI_BATCH_MAX_REQUESTS) groups.push(requests.slice(i, i + GEMINI_BATCH_MAX_REQUESTS));
685
+ return groups;
686
+ }
687
+ function buildGeminiUploadBody(params) {
688
+ const boundary = `anima-${hashText(params.displayName)}`;
689
+ const jsonPart = JSON.stringify({ file: {
690
+ displayName: params.displayName,
691
+ mimeType: "application/jsonl"
692
+ } });
693
+ const delimiter = `--${boundary}\r\n`;
694
+ const closeDelimiter = `--${boundary}--\r\n`;
695
+ const parts = [
696
+ `${delimiter}Content-Type: application/json; charset=UTF-8\r\n\r\n${jsonPart}\r\n`,
697
+ `${delimiter}Content-Type: application/jsonl; charset=UTF-8\r\n\r\n${params.jsonl}\r\n`,
698
+ closeDelimiter
699
+ ];
700
+ return {
701
+ body: new Blob([parts.join("")], { type: "multipart/related" }),
702
+ contentType: `multipart/related; boundary=${boundary}`
703
+ };
704
+ }
705
+ async function submitGeminiBatch(params) {
706
+ const baseUrl = getGeminiBaseUrl(params.gemini);
707
+ const uploadPayload = buildGeminiUploadBody({
708
+ jsonl: params.requests.map((request) => JSON.stringify({
709
+ key: request.custom_id,
710
+ request: {
711
+ content: request.content,
712
+ task_type: request.taskType
713
+ }
714
+ })).join("\n"),
715
+ displayName: `memory-embeddings-${hashText(String(Date.now()))}`
716
+ });
717
+ const uploadUrl = `${getGeminiUploadUrl(baseUrl)}/files?uploadType=multipart`;
718
+ debugLog("memory embeddings: gemini batch upload", {
719
+ uploadUrl,
720
+ baseUrl,
721
+ requests: params.requests.length
722
+ });
723
+ const fileRes = await fetch(uploadUrl, {
724
+ method: "POST",
725
+ headers: {
726
+ ...getGeminiHeaders(params.gemini, { json: false }),
727
+ "Content-Type": uploadPayload.contentType
728
+ },
729
+ body: uploadPayload.body
730
+ });
731
+ if (!fileRes.ok) {
732
+ const text = await fileRes.text();
733
+ throw new Error(`gemini batch file upload failed: ${fileRes.status} ${text}`);
734
+ }
735
+ const filePayload = await fileRes.json();
736
+ const fileId = filePayload.name ?? filePayload.file?.name;
737
+ if (!fileId) throw new Error("gemini batch file upload failed: missing file id");
738
+ const batchBody = { batch: {
739
+ displayName: `memory-embeddings-${params.agentId}`,
740
+ inputConfig: { file_name: fileId }
741
+ } };
742
+ const batchEndpoint = `${baseUrl}/${params.gemini.modelPath}:asyncBatchEmbedContent`;
743
+ debugLog("memory embeddings: gemini batch create", {
744
+ batchEndpoint,
745
+ fileId
746
+ });
747
+ const batchRes = await fetch(batchEndpoint, {
748
+ method: "POST",
749
+ headers: getGeminiHeaders(params.gemini, { json: true }),
750
+ body: JSON.stringify(batchBody)
751
+ });
752
+ if (batchRes.ok) return await batchRes.json();
753
+ const text = await batchRes.text();
754
+ if (batchRes.status === 404) throw new Error("gemini batch create failed: 404 (asyncBatchEmbedContent not available for this model/baseUrl). Disable remote.batch.enabled or switch providers.");
755
+ throw new Error(`gemini batch create failed: ${batchRes.status} ${text}`);
756
+ }
757
+ async function fetchGeminiBatchStatus(params) {
758
+ const statusUrl = `${getGeminiBaseUrl(params.gemini)}/${params.batchName.startsWith("batches/") ? params.batchName : `batches/${params.batchName}`}`;
759
+ debugLog("memory embeddings: gemini batch status", { statusUrl });
760
+ const res = await fetch(statusUrl, { headers: getGeminiHeaders(params.gemini, { json: true }) });
761
+ if (!res.ok) {
762
+ const text = await res.text();
763
+ throw new Error(`gemini batch status failed: ${res.status} ${text}`);
764
+ }
765
+ return await res.json();
766
+ }
767
+ async function fetchGeminiFileContent(params) {
768
+ const downloadUrl = `${getGeminiBaseUrl(params.gemini)}/${params.fileId.startsWith("files/") ? params.fileId : `files/${params.fileId}`}:download`;
769
+ debugLog("memory embeddings: gemini batch download", { downloadUrl });
770
+ const res = await fetch(downloadUrl, { headers: getGeminiHeaders(params.gemini, { json: true }) });
771
+ if (!res.ok) {
772
+ const text = await res.text();
773
+ throw new Error(`gemini batch file content failed: ${res.status} ${text}`);
774
+ }
775
+ return await res.text();
776
+ }
777
+ function parseGeminiBatchOutput(text) {
778
+ if (!text.trim()) return [];
779
+ return text.split("\n").map((line) => line.trim()).filter(Boolean).map((line) => JSON.parse(line));
780
+ }
781
+ async function waitForGeminiBatch(params) {
782
+ const start = Date.now();
783
+ let current = params.initial;
784
+ while (true) {
785
+ const status = current ?? await fetchGeminiBatchStatus({
786
+ gemini: params.gemini,
787
+ batchName: params.batchName
788
+ });
789
+ const state = status.state ?? "UNKNOWN";
790
+ if ([
791
+ "SUCCEEDED",
792
+ "COMPLETED",
793
+ "DONE"
794
+ ].includes(state)) {
795
+ const outputFileId = status.outputConfig?.file ?? status.outputConfig?.fileId ?? status.metadata?.output?.responsesFile;
796
+ if (!outputFileId) throw new Error(`gemini batch ${params.batchName} completed without output file`);
797
+ return { outputFileId };
798
+ }
799
+ if ([
800
+ "FAILED",
801
+ "CANCELLED",
802
+ "CANCELED",
803
+ "EXPIRED"
804
+ ].includes(state)) {
805
+ const message = status.error?.message ?? "unknown error";
806
+ throw new Error(`gemini batch ${params.batchName} ${state}: ${message}`);
807
+ }
808
+ if (!params.wait) throw new Error(`gemini batch ${params.batchName} still ${state}; wait disabled`);
809
+ if (Date.now() - start > params.timeoutMs) throw new Error(`gemini batch ${params.batchName} timed out after ${params.timeoutMs}ms`);
810
+ params.debug?.(`gemini batch ${params.batchName} ${state}; waiting ${params.pollIntervalMs}ms`);
811
+ await new Promise((resolve) => setTimeout(resolve, params.pollIntervalMs));
812
+ current = void 0;
813
+ }
814
+ }
815
+ async function runGeminiEmbeddingBatches(params) {
816
+ if (params.requests.length === 0) return /* @__PURE__ */ new Map();
817
+ const groups = splitGeminiBatchRequests(params.requests);
818
+ const byCustomId = /* @__PURE__ */ new Map();
819
+ const tasks = groups.map((group, groupIndex) => async () => {
820
+ const batchInfo = await submitGeminiBatch({
821
+ gemini: params.gemini,
822
+ requests: group,
823
+ agentId: params.agentId
824
+ });
825
+ const batchName = batchInfo.name ?? "";
826
+ if (!batchName) throw new Error("gemini batch create failed: missing batch name");
827
+ params.debug?.("memory embeddings: gemini batch created", {
828
+ batchName,
829
+ state: batchInfo.state,
830
+ group: groupIndex + 1,
831
+ groups: groups.length,
832
+ requests: group.length
833
+ });
834
+ if (!params.wait && batchInfo.state && ![
835
+ "SUCCEEDED",
836
+ "COMPLETED",
837
+ "DONE"
838
+ ].includes(batchInfo.state)) throw new Error(`gemini batch ${batchName} submitted; enable remote.batch.wait to await completion`);
839
+ const completed = batchInfo.state && [
840
+ "SUCCEEDED",
841
+ "COMPLETED",
842
+ "DONE"
843
+ ].includes(batchInfo.state) ? { outputFileId: batchInfo.outputConfig?.file ?? batchInfo.outputConfig?.fileId ?? batchInfo.metadata?.output?.responsesFile ?? "" } : await waitForGeminiBatch({
844
+ gemini: params.gemini,
845
+ batchName,
846
+ wait: params.wait,
847
+ pollIntervalMs: params.pollIntervalMs,
848
+ timeoutMs: params.timeoutMs,
849
+ debug: params.debug,
850
+ initial: batchInfo
851
+ });
852
+ if (!completed.outputFileId) throw new Error(`gemini batch ${batchName} completed without output file`);
853
+ const outputLines = parseGeminiBatchOutput(await fetchGeminiFileContent({
854
+ gemini: params.gemini,
855
+ fileId: completed.outputFileId
856
+ }));
857
+ const errors = [];
858
+ const remaining = new Set(group.map((request) => request.custom_id));
859
+ for (const line of outputLines) {
860
+ const customId = line.key ?? line.custom_id ?? line.request_id;
861
+ if (!customId) continue;
862
+ remaining.delete(customId);
863
+ if (line.error?.message) {
864
+ errors.push(`${customId}: ${line.error.message}`);
865
+ continue;
866
+ }
867
+ if (line.response?.error?.message) {
868
+ errors.push(`${customId}: ${line.response.error.message}`);
869
+ continue;
870
+ }
871
+ const embedding = line.embedding?.values ?? line.response?.embedding?.values ?? [];
872
+ if (embedding.length === 0) {
873
+ errors.push(`${customId}: empty embedding`);
874
+ continue;
875
+ }
876
+ byCustomId.set(customId, embedding);
877
+ }
878
+ if (errors.length > 0) throw new Error(`gemini batch ${batchName} failed: ${errors.join("; ")}`);
879
+ if (remaining.size > 0) throw new Error(`gemini batch ${batchName} missing ${remaining.size} embedding responses`);
880
+ });
881
+ params.debug?.("memory embeddings: gemini batch submit", {
882
+ requests: params.requests.length,
883
+ groups: groups.length,
884
+ wait: params.wait,
885
+ concurrency: params.concurrency,
886
+ pollIntervalMs: params.pollIntervalMs,
887
+ timeoutMs: params.timeoutMs
888
+ });
889
+ await runWithConcurrency(tasks, params.concurrency);
890
+ return byCustomId;
891
+ }
892
+
893
+ //#endregion
894
+ //#region src/infra/retry.ts
895
+ const DEFAULT_RETRY_CONFIG = {
896
+ attempts: 3,
897
+ minDelayMs: 300,
898
+ maxDelayMs: 3e4,
899
+ jitter: 0
900
+ };
901
+ const asFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value) ? value : void 0;
902
+ const clampNumber = (value, fallback, min, max) => {
903
+ const next = asFiniteNumber(value);
904
+ if (next === void 0) return fallback;
905
+ const floor = typeof min === "number" ? min : Number.NEGATIVE_INFINITY;
906
+ const ceiling = typeof max === "number" ? max : Number.POSITIVE_INFINITY;
907
+ return Math.min(Math.max(next, floor), ceiling);
908
+ };
909
+ function resolveRetryConfig(defaults = DEFAULT_RETRY_CONFIG, overrides) {
910
+ const attempts = Math.max(1, Math.round(clampNumber(overrides?.attempts, defaults.attempts, 1)));
911
+ const minDelayMs = Math.max(0, Math.round(clampNumber(overrides?.minDelayMs, defaults.minDelayMs, 0)));
912
+ return {
913
+ attempts,
914
+ minDelayMs,
915
+ maxDelayMs: Math.max(minDelayMs, Math.round(clampNumber(overrides?.maxDelayMs, defaults.maxDelayMs, 0))),
916
+ jitter: clampNumber(overrides?.jitter, defaults.jitter, 0, 1)
917
+ };
918
+ }
919
+ function applyJitter(delayMs, jitter) {
920
+ if (jitter <= 0) return delayMs;
921
+ const offset = (Math.random() * 2 - 1) * jitter;
922
+ return Math.max(0, Math.round(delayMs * (1 + offset)));
923
+ }
924
+ async function retryAsync(fn, attemptsOrOptions = 3, initialDelayMs = 300) {
925
+ if (typeof attemptsOrOptions === "number") {
926
+ const attempts = Math.max(1, Math.round(attemptsOrOptions));
927
+ let lastErr;
928
+ for (let i = 0; i < attempts; i += 1) try {
929
+ return await fn();
930
+ } catch (err) {
931
+ lastErr = err;
932
+ if (i === attempts - 1) break;
933
+ await sleep(initialDelayMs * 2 ** i);
934
+ }
935
+ throw lastErr ?? /* @__PURE__ */ new Error("Retry failed");
936
+ }
937
+ const options = attemptsOrOptions;
938
+ const resolved = resolveRetryConfig(DEFAULT_RETRY_CONFIG, options);
939
+ const maxAttempts = resolved.attempts;
940
+ const minDelayMs = resolved.minDelayMs;
941
+ const maxDelayMs = Number.isFinite(resolved.maxDelayMs) && resolved.maxDelayMs > 0 ? resolved.maxDelayMs : Number.POSITIVE_INFINITY;
942
+ const jitter = resolved.jitter;
943
+ const shouldRetry = options.shouldRetry ?? (() => true);
944
+ let lastErr;
945
+ for (let attempt = 1; attempt <= maxAttempts; attempt += 1) try {
946
+ return await fn();
947
+ } catch (err) {
948
+ lastErr = err;
949
+ if (attempt >= maxAttempts || !shouldRetry(err, attempt)) break;
950
+ const retryAfterMs = options.retryAfterMs?.(err);
951
+ const baseDelay = typeof retryAfterMs === "number" && Number.isFinite(retryAfterMs) ? Math.max(retryAfterMs, minDelayMs) : minDelayMs * 2 ** (attempt - 1);
952
+ let delay = Math.min(baseDelay, maxDelayMs);
953
+ delay = applyJitter(delay, jitter);
954
+ delay = Math.min(Math.max(delay, minDelayMs), maxDelayMs);
955
+ options.onRetry?.({
956
+ attempt,
957
+ maxAttempts,
958
+ delayMs: delay,
959
+ err,
960
+ label: options.label
961
+ });
962
+ await sleep(delay);
963
+ }
964
+ throw lastErr ?? /* @__PURE__ */ new Error("Retry failed");
965
+ }
966
+
967
+ //#endregion
968
+ //#region src/memory/batch-http.ts
969
+ async function postJsonWithRetry(params) {
970
+ return await (await retryAsync(async () => {
971
+ const res = await fetch(params.url, {
972
+ method: "POST",
973
+ headers: params.headers,
974
+ body: JSON.stringify(params.body)
975
+ });
976
+ if (!res.ok) {
977
+ const text = await res.text();
978
+ const err = /* @__PURE__ */ new Error(`${params.errorPrefix}: ${res.status} ${text}`);
979
+ err.status = res.status;
980
+ throw err;
981
+ }
982
+ return res;
983
+ }, {
984
+ attempts: 3,
985
+ minDelayMs: 300,
986
+ maxDelayMs: 2e3,
987
+ jitter: .2,
988
+ shouldRetry: (err) => {
989
+ const status = err.status;
990
+ return status === 429 || typeof status === "number" && status >= 500;
991
+ }
992
+ })).json();
993
+ }
994
+
995
+ //#endregion
996
+ //#region src/memory/batch-output.ts
997
+ function applyEmbeddingBatchOutputLine(params) {
998
+ const customId = params.line.custom_id;
999
+ if (!customId) return;
1000
+ params.remaining.delete(customId);
1001
+ const errorMessage = params.line.error?.message;
1002
+ if (errorMessage) {
1003
+ params.errors.push(`${customId}: ${errorMessage}`);
1004
+ return;
1005
+ }
1006
+ const response = params.line.response;
1007
+ if ((response?.status_code ?? 0) >= 400) {
1008
+ const messageFromObject = response?.body && typeof response.body === "object" ? response.body.error?.message : void 0;
1009
+ const messageFromString = typeof response?.body === "string" ? response.body : void 0;
1010
+ params.errors.push(`${customId}: ${messageFromObject ?? messageFromString ?? "unknown error"}`);
1011
+ return;
1012
+ }
1013
+ const embedding = (response?.body && typeof response.body === "object" ? response.body.data ?? [] : [])[0]?.embedding ?? [];
1014
+ if (embedding.length === 0) {
1015
+ params.errors.push(`${customId}: empty embedding`);
1016
+ return;
1017
+ }
1018
+ params.byCustomId.set(customId, embedding);
1019
+ }
1020
+
1021
+ //#endregion
1022
+ //#region src/memory/batch-openai.ts
1023
+ const OPENAI_BATCH_ENDPOINT = "/v1/embeddings";
1024
+ const OPENAI_BATCH_COMPLETION_WINDOW = "24h";
1025
+ const OPENAI_BATCH_MAX_REQUESTS = 5e4;
1026
+ function getOpenAiBaseUrl(openAi) {
1027
+ return openAi.baseUrl?.replace(/\/$/, "") ?? "";
1028
+ }
1029
+ function getOpenAiHeaders(openAi, params) {
1030
+ const headers = openAi.headers ? { ...openAi.headers } : {};
1031
+ if (params.json) {
1032
+ if (!headers["Content-Type"] && !headers["content-type"]) headers["Content-Type"] = "application/json";
1033
+ } else {
1034
+ delete headers["Content-Type"];
1035
+ delete headers["content-type"];
1036
+ }
1037
+ return headers;
1038
+ }
1039
+ function splitOpenAiBatchRequests(requests) {
1040
+ if (requests.length <= OPENAI_BATCH_MAX_REQUESTS) return [requests];
1041
+ const groups = [];
1042
+ for (let i = 0; i < requests.length; i += OPENAI_BATCH_MAX_REQUESTS) groups.push(requests.slice(i, i + OPENAI_BATCH_MAX_REQUESTS));
1043
+ return groups;
1044
+ }
1045
+ async function submitOpenAiBatch(params) {
1046
+ const baseUrl = getOpenAiBaseUrl(params.openAi);
1047
+ const jsonl = params.requests.map((request) => JSON.stringify(request)).join("\n");
1048
+ const form = new FormData();
1049
+ form.append("purpose", "batch");
1050
+ form.append("file", new Blob([jsonl], { type: "application/jsonl" }), `memory-embeddings.${hashText(String(Date.now()))}.jsonl`);
1051
+ const fileRes = await fetch(`${baseUrl}/files`, {
1052
+ method: "POST",
1053
+ headers: getOpenAiHeaders(params.openAi, { json: false }),
1054
+ body: form
1055
+ });
1056
+ if (!fileRes.ok) {
1057
+ const text = await fileRes.text();
1058
+ throw new Error(`openai batch file upload failed: ${fileRes.status} ${text}`);
1059
+ }
1060
+ const filePayload = await fileRes.json();
1061
+ if (!filePayload.id) throw new Error("openai batch file upload failed: missing file id");
1062
+ return await postJsonWithRetry({
1063
+ url: `${baseUrl}/batches`,
1064
+ headers: getOpenAiHeaders(params.openAi, { json: true }),
1065
+ body: {
1066
+ input_file_id: filePayload.id,
1067
+ endpoint: OPENAI_BATCH_ENDPOINT,
1068
+ completion_window: OPENAI_BATCH_COMPLETION_WINDOW,
1069
+ metadata: {
1070
+ source: "anima-memory",
1071
+ agent: params.agentId
1072
+ }
1073
+ },
1074
+ errorPrefix: "openai batch create failed"
1075
+ });
1076
+ }
1077
+ async function fetchOpenAiBatchStatus(params) {
1078
+ const baseUrl = getOpenAiBaseUrl(params.openAi);
1079
+ const res = await fetch(`${baseUrl}/batches/${params.batchId}`, { headers: getOpenAiHeaders(params.openAi, { json: true }) });
1080
+ if (!res.ok) {
1081
+ const text = await res.text();
1082
+ throw new Error(`openai batch status failed: ${res.status} ${text}`);
1083
+ }
1084
+ return await res.json();
1085
+ }
1086
+ async function fetchOpenAiFileContent(params) {
1087
+ const baseUrl = getOpenAiBaseUrl(params.openAi);
1088
+ const res = await fetch(`${baseUrl}/files/${params.fileId}/content`, { headers: getOpenAiHeaders(params.openAi, { json: true }) });
1089
+ if (!res.ok) {
1090
+ const text = await res.text();
1091
+ throw new Error(`openai batch file content failed: ${res.status} ${text}`);
1092
+ }
1093
+ return await res.text();
1094
+ }
1095
+ function parseOpenAiBatchOutput(text) {
1096
+ if (!text.trim()) return [];
1097
+ return text.split("\n").map((line) => line.trim()).filter(Boolean).map((line) => JSON.parse(line));
1098
+ }
1099
+ async function readOpenAiBatchError(params) {
1100
+ try {
1101
+ const first = parseOpenAiBatchOutput(await fetchOpenAiFileContent({
1102
+ openAi: params.openAi,
1103
+ fileId: params.errorFileId
1104
+ })).find((line) => line.error?.message || line.response?.body?.error);
1105
+ return first?.error?.message ?? (typeof first?.response?.body?.error?.message === "string" ? first?.response?.body?.error?.message : void 0);
1106
+ } catch (err) {
1107
+ const message = err instanceof Error ? err.message : String(err);
1108
+ return message ? `error file unavailable: ${message}` : void 0;
1109
+ }
1110
+ }
1111
+ async function waitForOpenAiBatch(params) {
1112
+ const start = Date.now();
1113
+ let current = params.initial;
1114
+ while (true) {
1115
+ const status = current ?? await fetchOpenAiBatchStatus({
1116
+ openAi: params.openAi,
1117
+ batchId: params.batchId
1118
+ });
1119
+ const state = status.status ?? "unknown";
1120
+ if (state === "completed") {
1121
+ if (!status.output_file_id) throw new Error(`openai batch ${params.batchId} completed without output file`);
1122
+ return {
1123
+ outputFileId: status.output_file_id,
1124
+ errorFileId: status.error_file_id ?? void 0
1125
+ };
1126
+ }
1127
+ if ([
1128
+ "failed",
1129
+ "expired",
1130
+ "cancelled",
1131
+ "canceled"
1132
+ ].includes(state)) {
1133
+ const detail = status.error_file_id ? await readOpenAiBatchError({
1134
+ openAi: params.openAi,
1135
+ errorFileId: status.error_file_id
1136
+ }) : void 0;
1137
+ const suffix = detail ? `: ${detail}` : "";
1138
+ throw new Error(`openai batch ${params.batchId} ${state}${suffix}`);
1139
+ }
1140
+ if (!params.wait) throw new Error(`openai batch ${params.batchId} still ${state}; wait disabled`);
1141
+ if (Date.now() - start > params.timeoutMs) throw new Error(`openai batch ${params.batchId} timed out after ${params.timeoutMs}ms`);
1142
+ params.debug?.(`openai batch ${params.batchId} ${state}; waiting ${params.pollIntervalMs}ms`);
1143
+ await new Promise((resolve) => setTimeout(resolve, params.pollIntervalMs));
1144
+ current = void 0;
1145
+ }
1146
+ }
1147
+ async function runOpenAiEmbeddingBatches(params) {
1148
+ if (params.requests.length === 0) return /* @__PURE__ */ new Map();
1149
+ const groups = splitOpenAiBatchRequests(params.requests);
1150
+ const byCustomId = /* @__PURE__ */ new Map();
1151
+ const tasks = groups.map((group, groupIndex) => async () => {
1152
+ const batchInfo = await submitOpenAiBatch({
1153
+ openAi: params.openAi,
1154
+ requests: group,
1155
+ agentId: params.agentId
1156
+ });
1157
+ if (!batchInfo.id) throw new Error("openai batch create failed: missing batch id");
1158
+ params.debug?.("memory embeddings: openai batch created", {
1159
+ batchId: batchInfo.id,
1160
+ status: batchInfo.status,
1161
+ group: groupIndex + 1,
1162
+ groups: groups.length,
1163
+ requests: group.length
1164
+ });
1165
+ if (!params.wait && batchInfo.status !== "completed") throw new Error(`openai batch ${batchInfo.id} submitted; enable remote.batch.wait to await completion`);
1166
+ const completed = batchInfo.status === "completed" ? {
1167
+ outputFileId: batchInfo.output_file_id ?? "",
1168
+ errorFileId: batchInfo.error_file_id ?? void 0
1169
+ } : await waitForOpenAiBatch({
1170
+ openAi: params.openAi,
1171
+ batchId: batchInfo.id,
1172
+ wait: params.wait,
1173
+ pollIntervalMs: params.pollIntervalMs,
1174
+ timeoutMs: params.timeoutMs,
1175
+ debug: params.debug,
1176
+ initial: batchInfo
1177
+ });
1178
+ if (!completed.outputFileId) throw new Error(`openai batch ${batchInfo.id} completed without output file`);
1179
+ const outputLines = parseOpenAiBatchOutput(await fetchOpenAiFileContent({
1180
+ openAi: params.openAi,
1181
+ fileId: completed.outputFileId
1182
+ }));
1183
+ const errors = [];
1184
+ const remaining = new Set(group.map((request) => request.custom_id));
1185
+ for (const line of outputLines) applyEmbeddingBatchOutputLine({
1186
+ line,
1187
+ remaining,
1188
+ errors,
1189
+ byCustomId
1190
+ });
1191
+ if (errors.length > 0) throw new Error(`openai batch ${batchInfo.id} failed: ${errors.join("; ")}`);
1192
+ if (remaining.size > 0) throw new Error(`openai batch ${batchInfo.id} missing ${remaining.size} embedding responses`);
1193
+ });
1194
+ params.debug?.("memory embeddings: openai batch submit", {
1195
+ requests: params.requests.length,
1196
+ groups: groups.length,
1197
+ wait: params.wait,
1198
+ concurrency: params.concurrency,
1199
+ pollIntervalMs: params.pollIntervalMs,
1200
+ timeoutMs: params.timeoutMs
1201
+ });
1202
+ await runWithConcurrency(tasks, params.concurrency);
1203
+ return byCustomId;
1204
+ }
1205
+
1206
+ //#endregion
1207
+ //#region src/memory/batch-voyage.ts
1208
+ const VOYAGE_BATCH_ENDPOINT = "/v1/embeddings";
1209
+ const VOYAGE_BATCH_COMPLETION_WINDOW = "12h";
1210
+ const VOYAGE_BATCH_MAX_REQUESTS = 5e4;
1211
+ function getVoyageBaseUrl(client) {
1212
+ return client.baseUrl?.replace(/\/$/, "") ?? "";
1213
+ }
1214
+ function getVoyageHeaders(client, params) {
1215
+ const headers = client.headers ? { ...client.headers } : {};
1216
+ if (params.json) {
1217
+ if (!headers["Content-Type"] && !headers["content-type"]) headers["Content-Type"] = "application/json";
1218
+ } else {
1219
+ delete headers["Content-Type"];
1220
+ delete headers["content-type"];
1221
+ }
1222
+ return headers;
1223
+ }
1224
+ function splitVoyageBatchRequests(requests) {
1225
+ if (requests.length <= VOYAGE_BATCH_MAX_REQUESTS) return [requests];
1226
+ const groups = [];
1227
+ for (let i = 0; i < requests.length; i += VOYAGE_BATCH_MAX_REQUESTS) groups.push(requests.slice(i, i + VOYAGE_BATCH_MAX_REQUESTS));
1228
+ return groups;
1229
+ }
1230
+ async function submitVoyageBatch(params) {
1231
+ const baseUrl = getVoyageBaseUrl(params.client);
1232
+ const jsonl = params.requests.map((request) => JSON.stringify(request)).join("\n");
1233
+ const form = new FormData();
1234
+ form.append("purpose", "batch");
1235
+ form.append("file", new Blob([jsonl], { type: "application/jsonl" }), `memory-embeddings.${hashText(String(Date.now()))}.jsonl`);
1236
+ const fileRes = await fetch(`${baseUrl}/files`, {
1237
+ method: "POST",
1238
+ headers: getVoyageHeaders(params.client, { json: false }),
1239
+ body: form
1240
+ });
1241
+ if (!fileRes.ok) {
1242
+ const text = await fileRes.text();
1243
+ throw new Error(`voyage batch file upload failed: ${fileRes.status} ${text}`);
1244
+ }
1245
+ const filePayload = await fileRes.json();
1246
+ if (!filePayload.id) throw new Error("voyage batch file upload failed: missing file id");
1247
+ return await postJsonWithRetry({
1248
+ url: `${baseUrl}/batches`,
1249
+ headers: getVoyageHeaders(params.client, { json: true }),
1250
+ body: {
1251
+ input_file_id: filePayload.id,
1252
+ endpoint: VOYAGE_BATCH_ENDPOINT,
1253
+ completion_window: VOYAGE_BATCH_COMPLETION_WINDOW,
1254
+ request_params: {
1255
+ model: params.client.model,
1256
+ input_type: "document"
1257
+ },
1258
+ metadata: {
1259
+ source: "anima-memory",
1260
+ agent: params.agentId
1261
+ }
1262
+ },
1263
+ errorPrefix: "voyage batch create failed"
1264
+ });
1265
+ }
1266
+ async function fetchVoyageBatchStatus(params) {
1267
+ const baseUrl = getVoyageBaseUrl(params.client);
1268
+ const res = await fetch(`${baseUrl}/batches/${params.batchId}`, { headers: getVoyageHeaders(params.client, { json: true }) });
1269
+ if (!res.ok) {
1270
+ const text = await res.text();
1271
+ throw new Error(`voyage batch status failed: ${res.status} ${text}`);
1272
+ }
1273
+ return await res.json();
1274
+ }
1275
+ async function readVoyageBatchError(params) {
1276
+ try {
1277
+ const baseUrl = getVoyageBaseUrl(params.client);
1278
+ const res = await fetch(`${baseUrl}/files/${params.errorFileId}/content`, { headers: getVoyageHeaders(params.client, { json: true }) });
1279
+ if (!res.ok) {
1280
+ const text = await res.text();
1281
+ throw new Error(`voyage batch error file content failed: ${res.status} ${text}`);
1282
+ }
1283
+ const text = await res.text();
1284
+ if (!text.trim()) return;
1285
+ const first = text.split("\n").map((line) => line.trim()).filter(Boolean).map((line) => JSON.parse(line)).find((line) => line.error?.message || line.response?.body?.error);
1286
+ return first?.error?.message ?? (typeof first?.response?.body?.error?.message === "string" ? first?.response?.body?.error?.message : void 0);
1287
+ } catch (err) {
1288
+ const message = err instanceof Error ? err.message : String(err);
1289
+ return message ? `error file unavailable: ${message}` : void 0;
1290
+ }
1291
+ }
1292
+ async function waitForVoyageBatch(params) {
1293
+ const start = Date.now();
1294
+ let current = params.initial;
1295
+ while (true) {
1296
+ const status = current ?? await fetchVoyageBatchStatus({
1297
+ client: params.client,
1298
+ batchId: params.batchId
1299
+ });
1300
+ const state = status.status ?? "unknown";
1301
+ if (state === "completed") {
1302
+ if (!status.output_file_id) throw new Error(`voyage batch ${params.batchId} completed without output file`);
1303
+ return {
1304
+ outputFileId: status.output_file_id,
1305
+ errorFileId: status.error_file_id ?? void 0
1306
+ };
1307
+ }
1308
+ if ([
1309
+ "failed",
1310
+ "expired",
1311
+ "cancelled",
1312
+ "canceled"
1313
+ ].includes(state)) {
1314
+ const detail = status.error_file_id ? await readVoyageBatchError({
1315
+ client: params.client,
1316
+ errorFileId: status.error_file_id
1317
+ }) : void 0;
1318
+ const suffix = detail ? `: ${detail}` : "";
1319
+ throw new Error(`voyage batch ${params.batchId} ${state}${suffix}`);
1320
+ }
1321
+ if (!params.wait) throw new Error(`voyage batch ${params.batchId} still ${state}; wait disabled`);
1322
+ if (Date.now() - start > params.timeoutMs) throw new Error(`voyage batch ${params.batchId} timed out after ${params.timeoutMs}ms`);
1323
+ params.debug?.(`voyage batch ${params.batchId} ${state}; waiting ${params.pollIntervalMs}ms`);
1324
+ await new Promise((resolve) => setTimeout(resolve, params.pollIntervalMs));
1325
+ current = void 0;
1326
+ }
1327
+ }
1328
+ async function runVoyageEmbeddingBatches(params) {
1329
+ if (params.requests.length === 0) return /* @__PURE__ */ new Map();
1330
+ const groups = splitVoyageBatchRequests(params.requests);
1331
+ const byCustomId = /* @__PURE__ */ new Map();
1332
+ const tasks = groups.map((group, groupIndex) => async () => {
1333
+ const batchInfo = await submitVoyageBatch({
1334
+ client: params.client,
1335
+ requests: group,
1336
+ agentId: params.agentId
1337
+ });
1338
+ if (!batchInfo.id) throw new Error("voyage batch create failed: missing batch id");
1339
+ params.debug?.("memory embeddings: voyage batch created", {
1340
+ batchId: batchInfo.id,
1341
+ status: batchInfo.status,
1342
+ group: groupIndex + 1,
1343
+ groups: groups.length,
1344
+ requests: group.length
1345
+ });
1346
+ if (!params.wait && batchInfo.status !== "completed") throw new Error(`voyage batch ${batchInfo.id} submitted; enable remote.batch.wait to await completion`);
1347
+ const completed = batchInfo.status === "completed" ? {
1348
+ outputFileId: batchInfo.output_file_id ?? "",
1349
+ errorFileId: batchInfo.error_file_id ?? void 0
1350
+ } : await waitForVoyageBatch({
1351
+ client: params.client,
1352
+ batchId: batchInfo.id,
1353
+ wait: params.wait,
1354
+ pollIntervalMs: params.pollIntervalMs,
1355
+ timeoutMs: params.timeoutMs,
1356
+ debug: params.debug,
1357
+ initial: batchInfo
1358
+ });
1359
+ if (!completed.outputFileId) throw new Error(`voyage batch ${batchInfo.id} completed without output file`);
1360
+ const baseUrl = getVoyageBaseUrl(params.client);
1361
+ const contentRes = await fetch(`${baseUrl}/files/${completed.outputFileId}/content`, { headers: getVoyageHeaders(params.client, { json: true }) });
1362
+ if (!contentRes.ok) {
1363
+ const text = await contentRes.text();
1364
+ throw new Error(`voyage batch file content failed: ${contentRes.status} ${text}`);
1365
+ }
1366
+ const errors = [];
1367
+ const remaining = new Set(group.map((request) => request.custom_id));
1368
+ if (contentRes.body) {
1369
+ const reader = createInterface({
1370
+ input: Readable.fromWeb(contentRes.body),
1371
+ terminal: false
1372
+ });
1373
+ for await (const rawLine of reader) {
1374
+ if (!rawLine.trim()) continue;
1375
+ applyEmbeddingBatchOutputLine({
1376
+ line: JSON.parse(rawLine),
1377
+ remaining,
1378
+ errors,
1379
+ byCustomId
1380
+ });
1381
+ }
1382
+ }
1383
+ if (errors.length > 0) throw new Error(`voyage batch ${batchInfo.id} failed: ${errors.join("; ")}`);
1384
+ if (remaining.size > 0) throw new Error(`voyage batch ${batchInfo.id} missing ${remaining.size} embedding responses`);
1385
+ });
1386
+ params.debug?.("memory embeddings: voyage batch submit", {
1387
+ requests: params.requests.length,
1388
+ groups: groups.length,
1389
+ wait: params.wait,
1390
+ concurrency: params.concurrency,
1391
+ pollIntervalMs: params.pollIntervalMs,
1392
+ timeoutMs: params.timeoutMs
1393
+ });
1394
+ await runWithConcurrency(tasks, params.concurrency);
1395
+ return byCustomId;
1396
+ }
1397
+
1398
+ //#endregion
1399
+ //#region src/memory/embedding-input-limits.ts
1400
+ function estimateUtf8Bytes(text) {
1401
+ if (!text) return 0;
1402
+ return Buffer.byteLength(text, "utf8");
1403
+ }
1404
+ function splitTextToUtf8ByteLimit(text, maxUtf8Bytes) {
1405
+ if (maxUtf8Bytes <= 0) return [text];
1406
+ if (estimateUtf8Bytes(text) <= maxUtf8Bytes) return [text];
1407
+ const parts = [];
1408
+ let cursor = 0;
1409
+ while (cursor < text.length) {
1410
+ let low = cursor + 1;
1411
+ let high = Math.min(text.length, cursor + maxUtf8Bytes);
1412
+ let best = cursor;
1413
+ while (low <= high) {
1414
+ const mid = Math.floor((low + high) / 2);
1415
+ if (estimateUtf8Bytes(text.slice(cursor, mid)) <= maxUtf8Bytes) {
1416
+ best = mid;
1417
+ low = mid + 1;
1418
+ } else high = mid - 1;
1419
+ }
1420
+ if (best <= cursor) best = Math.min(text.length, cursor + 1);
1421
+ if (best < text.length && best > cursor && text.charCodeAt(best - 1) >= 55296 && text.charCodeAt(best - 1) <= 56319 && text.charCodeAt(best) >= 56320 && text.charCodeAt(best) <= 57343) best -= 1;
1422
+ const part = text.slice(cursor, best);
1423
+ if (!part) break;
1424
+ parts.push(part);
1425
+ cursor = best;
1426
+ }
1427
+ return parts;
1428
+ }
1429
+
1430
+ //#endregion
1431
+ //#region src/memory/embedding-model-limits.ts
1432
+ const DEFAULT_EMBEDDING_MAX_INPUT_TOKENS = 8192;
1433
+ const KNOWN_EMBEDDING_MAX_INPUT_TOKENS = {
1434
+ "openai:text-embedding-3-small": 8192,
1435
+ "openai:text-embedding-3-large": 8192,
1436
+ "openai:text-embedding-ada-002": 8191,
1437
+ "gemini:text-embedding-004": 2048,
1438
+ "voyage:voyage-3": 32e3,
1439
+ "voyage:voyage-3-lite": 16e3,
1440
+ "voyage:voyage-code-3": 32e3
1441
+ };
1442
+ function resolveEmbeddingMaxInputTokens(provider) {
1443
+ if (typeof provider.maxInputTokens === "number") return provider.maxInputTokens;
1444
+ const known = KNOWN_EMBEDDING_MAX_INPUT_TOKENS[`${provider.id}:${provider.model}`.toLowerCase()];
1445
+ if (typeof known === "number") return known;
1446
+ if (provider.id.toLowerCase() === "gemini") return 2048;
1447
+ return DEFAULT_EMBEDDING_MAX_INPUT_TOKENS;
1448
+ }
1449
+
1450
+ //#endregion
1451
+ //#region src/memory/embedding-chunk-limits.ts
1452
+ function enforceEmbeddingMaxInputTokens(provider, chunks) {
1453
+ const maxInputTokens = resolveEmbeddingMaxInputTokens(provider);
1454
+ const out = [];
1455
+ for (const chunk of chunks) {
1456
+ if (estimateUtf8Bytes(chunk.text) <= maxInputTokens) {
1457
+ out.push(chunk);
1458
+ continue;
1459
+ }
1460
+ for (const text of splitTextToUtf8ByteLimit(chunk.text, maxInputTokens)) out.push({
1461
+ startLine: chunk.startLine,
1462
+ endLine: chunk.endLine,
1463
+ text,
1464
+ hash: hashText(text)
1465
+ });
1466
+ }
1467
+ return out;
1468
+ }
1469
+
1470
+ //#endregion
1471
+ //#region src/memory/manager-embedding-ops.ts
1472
+ const VECTOR_TABLE$2 = "chunks_vec";
1473
+ const FTS_TABLE$2 = "chunks_fts";
1474
+ const EMBEDDING_CACHE_TABLE$2 = "embedding_cache";
1475
+ const EMBEDDING_BATCH_MAX_TOKENS = 8e3;
1476
+ const EMBEDDING_INDEX_CONCURRENCY = 4;
1477
+ const EMBEDDING_RETRY_MAX_ATTEMPTS = 3;
1478
+ const EMBEDDING_RETRY_BASE_DELAY_MS = 500;
1479
+ const EMBEDDING_RETRY_MAX_DELAY_MS = 8e3;
1480
+ const BATCH_FAILURE_LIMIT$1 = 2;
1481
+ const EMBEDDING_QUERY_TIMEOUT_REMOTE_MS = 6e4;
1482
+ const EMBEDDING_QUERY_TIMEOUT_LOCAL_MS = 5 * 6e4;
1483
+ const EMBEDDING_BATCH_TIMEOUT_REMOTE_MS = 2 * 6e4;
1484
+ const EMBEDDING_BATCH_TIMEOUT_LOCAL_MS = 10 * 6e4;
1485
+ const vectorToBlob$1 = (embedding) => Buffer.from(new Float32Array(embedding).buffer);
1486
+ const log$2 = createSubsystemLogger("memory");
1487
+ var MemoryManagerEmbeddingOps = class {
1488
+ buildEmbeddingBatches(chunks) {
1489
+ const batches = [];
1490
+ let current = [];
1491
+ let currentTokens = 0;
1492
+ for (const chunk of chunks) {
1493
+ const estimate = estimateUtf8Bytes(chunk.text);
1494
+ if (current.length > 0 && currentTokens + estimate > EMBEDDING_BATCH_MAX_TOKENS) {
1495
+ batches.push(current);
1496
+ current = [];
1497
+ currentTokens = 0;
1498
+ }
1499
+ if (current.length === 0 && estimate > EMBEDDING_BATCH_MAX_TOKENS) {
1500
+ batches.push([chunk]);
1501
+ continue;
1502
+ }
1503
+ current.push(chunk);
1504
+ currentTokens += estimate;
1505
+ }
1506
+ if (current.length > 0) batches.push(current);
1507
+ return batches;
1508
+ }
1509
+ loadEmbeddingCache(hashes) {
1510
+ if (!this.cache.enabled) return /* @__PURE__ */ new Map();
1511
+ if (hashes.length === 0) return /* @__PURE__ */ new Map();
1512
+ const unique = [];
1513
+ const seen = /* @__PURE__ */ new Set();
1514
+ for (const hash of hashes) {
1515
+ if (!hash) continue;
1516
+ if (seen.has(hash)) continue;
1517
+ seen.add(hash);
1518
+ unique.push(hash);
1519
+ }
1520
+ if (unique.length === 0) return /* @__PURE__ */ new Map();
1521
+ const out = /* @__PURE__ */ new Map();
1522
+ const baseParams = [
1523
+ this.provider.id,
1524
+ this.provider.model,
1525
+ this.providerKey
1526
+ ];
1527
+ const batchSize = 400;
1528
+ for (let start = 0; start < unique.length; start += batchSize) {
1529
+ const batch = unique.slice(start, start + batchSize);
1530
+ const placeholders = batch.map(() => "?").join(", ");
1531
+ const rows = this.db.prepare(`SELECT hash, embedding FROM ${EMBEDDING_CACHE_TABLE$2}\n WHERE provider = ? AND model = ? AND provider_key = ? AND hash IN (${placeholders})`).all(...baseParams, ...batch);
1532
+ for (const row of rows) out.set(row.hash, parseEmbedding(row.embedding));
1533
+ }
1534
+ return out;
1535
+ }
1536
+ upsertEmbeddingCache(entries) {
1537
+ if (!this.cache.enabled) return;
1538
+ if (entries.length === 0) return;
1539
+ const now = Date.now();
1540
+ const stmt = this.db.prepare(`INSERT INTO ${EMBEDDING_CACHE_TABLE$2} (provider, model, provider_key, hash, embedding, dims, updated_at)\n VALUES (?, ?, ?, ?, ?, ?, ?)\n ON CONFLICT(provider, model, provider_key, hash) DO UPDATE SET\n embedding=excluded.embedding,\n dims=excluded.dims,\n updated_at=excluded.updated_at`);
1541
+ for (const entry of entries) {
1542
+ const embedding = entry.embedding ?? [];
1543
+ stmt.run(this.provider.id, this.provider.model, this.providerKey, entry.hash, JSON.stringify(embedding), embedding.length, now);
1544
+ }
1545
+ }
1546
+ pruneEmbeddingCacheIfNeeded() {
1547
+ if (!this.cache.enabled) return;
1548
+ const max = this.cache.maxEntries;
1549
+ if (!max || max <= 0) return;
1550
+ const count = this.db.prepare(`SELECT COUNT(*) as c FROM ${EMBEDDING_CACHE_TABLE$2}`).get()?.c ?? 0;
1551
+ if (count <= max) return;
1552
+ const excess = count - max;
1553
+ this.db.prepare(`DELETE FROM ${EMBEDDING_CACHE_TABLE$2}\n WHERE rowid IN (\n SELECT rowid FROM ${EMBEDDING_CACHE_TABLE$2}\n ORDER BY updated_at ASC\n LIMIT ?\n )`).run(excess);
1554
+ }
1555
+ async embedChunksInBatches(chunks) {
1556
+ if (chunks.length === 0) return [];
1557
+ const cached = this.loadEmbeddingCache(chunks.map((chunk) => chunk.hash));
1558
+ const embeddings = Array.from({ length: chunks.length }, () => []);
1559
+ const missing = [];
1560
+ for (let i = 0; i < chunks.length; i += 1) {
1561
+ const chunk = chunks[i];
1562
+ const hit = chunk?.hash ? cached.get(chunk.hash) : void 0;
1563
+ if (hit && hit.length > 0) embeddings[i] = hit;
1564
+ else if (chunk) missing.push({
1565
+ index: i,
1566
+ chunk
1567
+ });
1568
+ }
1569
+ if (missing.length === 0) return embeddings;
1570
+ const missingChunks = missing.map((m) => m.chunk);
1571
+ const batches = this.buildEmbeddingBatches(missingChunks);
1572
+ const toCache = [];
1573
+ let cursor = 0;
1574
+ for (const batch of batches) {
1575
+ const batchEmbeddings = await this.embedBatchWithRetry(batch.map((chunk) => chunk.text));
1576
+ for (let i = 0; i < batch.length; i += 1) {
1577
+ const item = missing[cursor + i];
1578
+ const embedding = batchEmbeddings[i] ?? [];
1579
+ if (item) {
1580
+ embeddings[item.index] = embedding;
1581
+ toCache.push({
1582
+ hash: item.chunk.hash,
1583
+ embedding
1584
+ });
1585
+ }
1586
+ }
1587
+ cursor += batch.length;
1588
+ }
1589
+ this.upsertEmbeddingCache(toCache);
1590
+ return embeddings;
1591
+ }
1592
+ computeProviderKey() {
1593
+ if (this.provider.id === "openai" && this.openAi) {
1594
+ const entries = Object.entries(this.openAi.headers).filter(([key]) => key.toLowerCase() !== "authorization").toSorted(([a], [b]) => a.localeCompare(b)).map(([key, value]) => [key, value]);
1595
+ return hashText(JSON.stringify({
1596
+ provider: "openai",
1597
+ baseUrl: this.openAi.baseUrl,
1598
+ model: this.openAi.model,
1599
+ headers: entries
1600
+ }));
1601
+ }
1602
+ if (this.provider.id === "gemini" && this.gemini) {
1603
+ const entries = Object.entries(this.gemini.headers).filter(([key]) => {
1604
+ const lower = key.toLowerCase();
1605
+ return lower !== "authorization" && lower !== "x-goog-api-key";
1606
+ }).toSorted(([a], [b]) => a.localeCompare(b)).map(([key, value]) => [key, value]);
1607
+ return hashText(JSON.stringify({
1608
+ provider: "gemini",
1609
+ baseUrl: this.gemini.baseUrl,
1610
+ model: this.gemini.model,
1611
+ headers: entries
1612
+ }));
1613
+ }
1614
+ return hashText(JSON.stringify({
1615
+ provider: this.provider.id,
1616
+ model: this.provider.model
1617
+ }));
1618
+ }
1619
+ async embedChunksWithBatch(chunks, entry, source) {
1620
+ if (this.provider.id === "openai" && this.openAi) return this.embedChunksWithOpenAiBatch(chunks, entry, source);
1621
+ if (this.provider.id === "gemini" && this.gemini) return this.embedChunksWithGeminiBatch(chunks, entry, source);
1622
+ if (this.provider.id === "voyage" && this.voyage) return this.embedChunksWithVoyageBatch(chunks, entry, source);
1623
+ return this.embedChunksInBatches(chunks);
1624
+ }
1625
+ collectCachedEmbeddings(chunks) {
1626
+ const cached = this.loadEmbeddingCache(chunks.map((chunk) => chunk.hash));
1627
+ const embeddings = Array.from({ length: chunks.length }, () => []);
1628
+ const missing = [];
1629
+ for (let i = 0; i < chunks.length; i += 1) {
1630
+ const chunk = chunks[i];
1631
+ const hit = chunk?.hash ? cached.get(chunk.hash) : void 0;
1632
+ if (hit && hit.length > 0) embeddings[i] = hit;
1633
+ else if (chunk) missing.push({
1634
+ index: i,
1635
+ chunk
1636
+ });
1637
+ }
1638
+ return {
1639
+ embeddings,
1640
+ missing
1641
+ };
1642
+ }
1643
+ buildBatchCustomId(params) {
1644
+ return hashText(`${params.source}:${params.entry.path}:${params.chunk.startLine}:${params.chunk.endLine}:${params.chunk.hash}:${params.index}`);
1645
+ }
1646
+ buildBatchRequests(params) {
1647
+ const requests = [];
1648
+ const mapping = /* @__PURE__ */ new Map();
1649
+ for (const item of params.missing) {
1650
+ const chunk = item.chunk;
1651
+ const customId = this.buildBatchCustomId({
1652
+ source: params.source,
1653
+ entry: params.entry,
1654
+ chunk,
1655
+ index: item.index
1656
+ });
1657
+ mapping.set(customId, {
1658
+ index: item.index,
1659
+ hash: chunk.hash
1660
+ });
1661
+ const built = params.build(chunk);
1662
+ requests.push({
1663
+ custom_id: customId,
1664
+ ...built
1665
+ });
1666
+ }
1667
+ return {
1668
+ requests,
1669
+ mapping
1670
+ };
1671
+ }
1672
+ applyBatchEmbeddings(params) {
1673
+ const toCache = [];
1674
+ for (const [customId, embedding] of params.byCustomId.entries()) {
1675
+ const mapped = params.mapping.get(customId);
1676
+ if (!mapped) continue;
1677
+ params.embeddings[mapped.index] = embedding;
1678
+ toCache.push({
1679
+ hash: mapped.hash,
1680
+ embedding
1681
+ });
1682
+ }
1683
+ this.upsertEmbeddingCache(toCache);
1684
+ }
1685
+ async embedChunksWithVoyageBatch(chunks, entry, source) {
1686
+ const voyage = this.voyage;
1687
+ if (!voyage) return this.embedChunksInBatches(chunks);
1688
+ if (chunks.length === 0) return [];
1689
+ const { embeddings, missing } = this.collectCachedEmbeddings(chunks);
1690
+ if (missing.length === 0) return embeddings;
1691
+ const { requests, mapping } = this.buildBatchRequests({
1692
+ missing,
1693
+ entry,
1694
+ source,
1695
+ build: (chunk) => ({ body: { input: chunk.text } })
1696
+ });
1697
+ const batchResult = await this.runBatchWithFallback({
1698
+ provider: "voyage",
1699
+ run: async () => await runVoyageEmbeddingBatches({
1700
+ client: voyage,
1701
+ agentId: this.agentId,
1702
+ requests,
1703
+ wait: this.batch.wait,
1704
+ concurrency: this.batch.concurrency,
1705
+ pollIntervalMs: this.batch.pollIntervalMs,
1706
+ timeoutMs: this.batch.timeoutMs,
1707
+ debug: (message, data) => log$2.debug(message, {
1708
+ ...data,
1709
+ source,
1710
+ chunks: chunks.length
1711
+ })
1712
+ }),
1713
+ fallback: async () => await this.embedChunksInBatches(chunks)
1714
+ });
1715
+ if (Array.isArray(batchResult)) return batchResult;
1716
+ this.applyBatchEmbeddings({
1717
+ byCustomId: batchResult,
1718
+ mapping,
1719
+ embeddings
1720
+ });
1721
+ return embeddings;
1722
+ }
1723
+ async embedChunksWithOpenAiBatch(chunks, entry, source) {
1724
+ const openAi = this.openAi;
1725
+ if (!openAi) return this.embedChunksInBatches(chunks);
1726
+ if (chunks.length === 0) return [];
1727
+ const { embeddings, missing } = this.collectCachedEmbeddings(chunks);
1728
+ if (missing.length === 0) return embeddings;
1729
+ const { requests, mapping } = this.buildBatchRequests({
1730
+ missing,
1731
+ entry,
1732
+ source,
1733
+ build: (chunk) => ({
1734
+ method: "POST",
1735
+ url: OPENAI_BATCH_ENDPOINT,
1736
+ body: {
1737
+ model: this.openAi?.model ?? this.provider.model,
1738
+ input: chunk.text
1739
+ }
1740
+ })
1741
+ });
1742
+ const batchResult = await this.runBatchWithFallback({
1743
+ provider: "openai",
1744
+ run: async () => await runOpenAiEmbeddingBatches({
1745
+ openAi,
1746
+ agentId: this.agentId,
1747
+ requests,
1748
+ wait: this.batch.wait,
1749
+ concurrency: this.batch.concurrency,
1750
+ pollIntervalMs: this.batch.pollIntervalMs,
1751
+ timeoutMs: this.batch.timeoutMs,
1752
+ debug: (message, data) => log$2.debug(message, {
1753
+ ...data,
1754
+ source,
1755
+ chunks: chunks.length
1756
+ })
1757
+ }),
1758
+ fallback: async () => await this.embedChunksInBatches(chunks)
1759
+ });
1760
+ if (Array.isArray(batchResult)) return batchResult;
1761
+ this.applyBatchEmbeddings({
1762
+ byCustomId: batchResult,
1763
+ mapping,
1764
+ embeddings
1765
+ });
1766
+ return embeddings;
1767
+ }
1768
+ async embedChunksWithGeminiBatch(chunks, entry, source) {
1769
+ const gemini = this.gemini;
1770
+ if (!gemini) return this.embedChunksInBatches(chunks);
1771
+ if (chunks.length === 0) return [];
1772
+ const { embeddings, missing } = this.collectCachedEmbeddings(chunks);
1773
+ if (missing.length === 0) return embeddings;
1774
+ const { requests, mapping } = this.buildBatchRequests({
1775
+ missing,
1776
+ entry,
1777
+ source,
1778
+ build: (chunk) => ({
1779
+ content: { parts: [{ text: chunk.text }] },
1780
+ taskType: "RETRIEVAL_DOCUMENT"
1781
+ })
1782
+ });
1783
+ const batchResult = await this.runBatchWithFallback({
1784
+ provider: "gemini",
1785
+ run: async () => await runGeminiEmbeddingBatches({
1786
+ gemini,
1787
+ agentId: this.agentId,
1788
+ requests,
1789
+ wait: this.batch.wait,
1790
+ concurrency: this.batch.concurrency,
1791
+ pollIntervalMs: this.batch.pollIntervalMs,
1792
+ timeoutMs: this.batch.timeoutMs,
1793
+ debug: (message, data) => log$2.debug(message, {
1794
+ ...data,
1795
+ source,
1796
+ chunks: chunks.length
1797
+ })
1798
+ }),
1799
+ fallback: async () => await this.embedChunksInBatches(chunks)
1800
+ });
1801
+ if (Array.isArray(batchResult)) return batchResult;
1802
+ this.applyBatchEmbeddings({
1803
+ byCustomId: batchResult,
1804
+ mapping,
1805
+ embeddings
1806
+ });
1807
+ return embeddings;
1808
+ }
1809
+ async embedBatchWithRetry(texts) {
1810
+ if (texts.length === 0) return [];
1811
+ let attempt = 0;
1812
+ let delayMs = EMBEDDING_RETRY_BASE_DELAY_MS;
1813
+ while (true) try {
1814
+ const timeoutMs = this.resolveEmbeddingTimeout("batch");
1815
+ log$2.debug("memory embeddings: batch start", {
1816
+ provider: this.provider.id,
1817
+ items: texts.length,
1818
+ timeoutMs
1819
+ });
1820
+ return await this.withTimeout(this.provider.embedBatch(texts), timeoutMs, `memory embeddings batch timed out after ${Math.round(timeoutMs / 1e3)}s`);
1821
+ } catch (err) {
1822
+ const message = err instanceof Error ? err.message : String(err);
1823
+ if (!this.isRetryableEmbeddingError(message) || attempt >= EMBEDDING_RETRY_MAX_ATTEMPTS) throw err;
1824
+ const waitMs = Math.min(EMBEDDING_RETRY_MAX_DELAY_MS, Math.round(delayMs * (1 + Math.random() * .2)));
1825
+ log$2.warn(`memory embeddings rate limited; retrying in ${waitMs}ms`);
1826
+ await new Promise((resolve) => setTimeout(resolve, waitMs));
1827
+ delayMs *= 2;
1828
+ attempt += 1;
1829
+ }
1830
+ }
1831
+ isRetryableEmbeddingError(message) {
1832
+ return /(rate[_ ]limit|too many requests|429|resource has been exhausted|5\d\d|cloudflare)/i.test(message);
1833
+ }
1834
+ resolveEmbeddingTimeout(kind) {
1835
+ const isLocal = this.provider.id === "local";
1836
+ if (kind === "query") return isLocal ? EMBEDDING_QUERY_TIMEOUT_LOCAL_MS : EMBEDDING_QUERY_TIMEOUT_REMOTE_MS;
1837
+ return isLocal ? EMBEDDING_BATCH_TIMEOUT_LOCAL_MS : EMBEDDING_BATCH_TIMEOUT_REMOTE_MS;
1838
+ }
1839
+ async embedQueryWithTimeout(text) {
1840
+ const timeoutMs = this.resolveEmbeddingTimeout("query");
1841
+ log$2.debug("memory embeddings: query start", {
1842
+ provider: this.provider.id,
1843
+ timeoutMs
1844
+ });
1845
+ return await this.withTimeout(this.provider.embedQuery(text), timeoutMs, `memory embeddings query timed out after ${Math.round(timeoutMs / 1e3)}s`);
1846
+ }
1847
+ async withTimeout(promise, timeoutMs, message) {
1848
+ if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) return await promise;
1849
+ let timer = null;
1850
+ const timeoutPromise = new Promise((_, reject) => {
1851
+ timer = setTimeout(() => reject(new Error(message)), timeoutMs);
1852
+ });
1853
+ try {
1854
+ return await Promise.race([promise, timeoutPromise]);
1855
+ } finally {
1856
+ if (timer) clearTimeout(timer);
1857
+ }
1858
+ }
1859
+ async withBatchFailureLock(fn) {
1860
+ let release;
1861
+ const wait = this.batchFailureLock;
1862
+ this.batchFailureLock = new Promise((resolve) => {
1863
+ release = resolve;
1864
+ });
1865
+ await wait;
1866
+ try {
1867
+ return await fn();
1868
+ } finally {
1869
+ release();
1870
+ }
1871
+ }
1872
+ async resetBatchFailureCount() {
1873
+ await this.withBatchFailureLock(async () => {
1874
+ if (this.batchFailureCount > 0) log$2.debug("memory embeddings: batch recovered; resetting failure count");
1875
+ this.batchFailureCount = 0;
1876
+ this.batchFailureLastError = void 0;
1877
+ this.batchFailureLastProvider = void 0;
1878
+ });
1879
+ }
1880
+ async recordBatchFailure(params) {
1881
+ return await this.withBatchFailureLock(async () => {
1882
+ if (!this.batch.enabled) return {
1883
+ disabled: true,
1884
+ count: this.batchFailureCount
1885
+ };
1886
+ const increment = params.forceDisable ? BATCH_FAILURE_LIMIT$1 : Math.max(1, params.attempts ?? 1);
1887
+ this.batchFailureCount += increment;
1888
+ this.batchFailureLastError = params.message;
1889
+ this.batchFailureLastProvider = params.provider;
1890
+ const disabled = params.forceDisable || this.batchFailureCount >= BATCH_FAILURE_LIMIT$1;
1891
+ if (disabled) this.batch.enabled = false;
1892
+ return {
1893
+ disabled,
1894
+ count: this.batchFailureCount
1895
+ };
1896
+ });
1897
+ }
1898
+ isBatchTimeoutError(message) {
1899
+ return /timed out|timeout/i.test(message);
1900
+ }
1901
+ async runBatchWithTimeoutRetry(params) {
1902
+ try {
1903
+ return await params.run();
1904
+ } catch (err) {
1905
+ const message = err instanceof Error ? err.message : String(err);
1906
+ if (this.isBatchTimeoutError(message)) {
1907
+ log$2.warn(`memory embeddings: ${params.provider} batch timed out; retrying once`);
1908
+ try {
1909
+ return await params.run();
1910
+ } catch (retryErr) {
1911
+ retryErr.batchAttempts = 2;
1912
+ throw retryErr;
1913
+ }
1914
+ }
1915
+ throw err;
1916
+ }
1917
+ }
1918
+ async runBatchWithFallback(params) {
1919
+ if (!this.batch.enabled) return await params.fallback();
1920
+ try {
1921
+ const result = await this.runBatchWithTimeoutRetry({
1922
+ provider: params.provider,
1923
+ run: params.run
1924
+ });
1925
+ await this.resetBatchFailureCount();
1926
+ return result;
1927
+ } catch (err) {
1928
+ const message = err instanceof Error ? err.message : String(err);
1929
+ const attempts = err.batchAttempts ?? 1;
1930
+ const forceDisable = /asyncBatchEmbedContent not available/i.test(message);
1931
+ const failure = await this.recordBatchFailure({
1932
+ provider: params.provider,
1933
+ message,
1934
+ attempts,
1935
+ forceDisable
1936
+ });
1937
+ const suffix = failure.disabled ? "disabling batch" : "keeping batch enabled";
1938
+ log$2.warn(`memory embeddings: ${params.provider} batch failed (${failure.count}/${BATCH_FAILURE_LIMIT$1}); ${suffix}; falling back to non-batch embeddings: ${message}`);
1939
+ return await params.fallback();
1940
+ }
1941
+ }
1942
+ getIndexConcurrency() {
1943
+ return this.batch.enabled ? this.batch.concurrency : EMBEDDING_INDEX_CONCURRENCY;
1944
+ }
1945
+ async indexFile(entry, options) {
1946
+ const content = options.content ?? await fs.readFile(entry.absPath, "utf-8");
1947
+ const chunks = enforceEmbeddingMaxInputTokens(this.provider, chunkMarkdown(content, this.settings.chunking).filter((chunk) => chunk.text.trim().length > 0));
1948
+ if (options.source === "sessions" && "lineMap" in entry) remapChunkLines(chunks, entry.lineMap);
1949
+ const embeddings = this.batch.enabled ? await this.embedChunksWithBatch(chunks, entry, options.source) : await this.embedChunksInBatches(chunks);
1950
+ const sample = embeddings.find((embedding) => embedding.length > 0);
1951
+ const vectorReady = sample ? await this.ensureVectorReady(sample.length) : false;
1952
+ const now = Date.now();
1953
+ if (vectorReady) try {
1954
+ this.db.prepare(`DELETE FROM ${VECTOR_TABLE$2} WHERE id IN (SELECT id FROM chunks WHERE path = ? AND source = ?)`).run(entry.path, options.source);
1955
+ } catch {}
1956
+ if (this.fts.enabled && this.fts.available) try {
1957
+ this.db.prepare(`DELETE FROM ${FTS_TABLE$2} WHERE path = ? AND source = ? AND model = ?`).run(entry.path, options.source, this.provider.model);
1958
+ } catch {}
1959
+ this.db.prepare(`DELETE FROM chunks WHERE path = ? AND source = ?`).run(entry.path, options.source);
1960
+ for (let i = 0; i < chunks.length; i++) {
1961
+ const chunk = chunks[i];
1962
+ const embedding = embeddings[i] ?? [];
1963
+ const id = hashText(`${options.source}:${entry.path}:${chunk.startLine}:${chunk.endLine}:${chunk.hash}:${this.provider.model}`);
1964
+ this.db.prepare(`INSERT INTO chunks (id, path, source, start_line, end_line, hash, model, text, embedding, updated_at)
1965
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
1966
+ ON CONFLICT(id) DO UPDATE SET
1967
+ hash=excluded.hash,
1968
+ model=excluded.model,
1969
+ text=excluded.text,
1970
+ embedding=excluded.embedding,
1971
+ updated_at=excluded.updated_at`).run(id, entry.path, options.source, chunk.startLine, chunk.endLine, chunk.hash, this.provider.model, chunk.text, JSON.stringify(embedding), now);
1972
+ if (vectorReady && embedding.length > 0) {
1973
+ try {
1974
+ this.db.prepare(`DELETE FROM ${VECTOR_TABLE$2} WHERE id = ?`).run(id);
1975
+ } catch {}
1976
+ this.db.prepare(`INSERT INTO ${VECTOR_TABLE$2} (id, embedding) VALUES (?, ?)`).run(id, vectorToBlob$1(embedding));
1977
+ }
1978
+ if (this.fts.enabled && this.fts.available) this.db.prepare(`INSERT INTO ${FTS_TABLE$2} (text, id, path, source, model, start_line, end_line)\n VALUES (?, ?, ?, ?, ?, ?, ?)`).run(chunk.text, id, entry.path, options.source, this.provider.model, chunk.startLine, chunk.endLine);
1979
+ }
1980
+ this.db.prepare(`INSERT INTO files (path, source, hash, mtime, size) VALUES (?, ?, ?, ?, ?)
1981
+ ON CONFLICT(path) DO UPDATE SET
1982
+ source=excluded.source,
1983
+ hash=excluded.hash,
1984
+ mtime=excluded.mtime,
1985
+ size=excluded.size`).run(entry.path, options.source, entry.hash, entry.mtimeMs, entry.size);
1986
+ }
1987
+ };
1988
+ const memoryManagerEmbeddingOps = MemoryManagerEmbeddingOps.prototype;
1989
+
1990
+ //#endregion
1991
+ //#region src/memory/manager-search.ts
1992
+ const vectorToBlob = (embedding) => Buffer.from(new Float32Array(embedding).buffer);
1993
+ async function searchVector(params) {
1994
+ if (params.queryVec.length === 0 || params.limit <= 0) return [];
1995
+ if (await params.ensureVectorReady(params.queryVec.length)) return params.db.prepare(`SELECT c.id, c.path, c.start_line, c.end_line, c.text,
1996
+ c.source,
1997
+ vec_distance_cosine(v.embedding, ?) AS dist
1998
+ FROM ${params.vectorTable} v\n JOIN chunks c ON c.id = v.id\n WHERE c.model = ?${params.sourceFilterVec.sql}\n ORDER BY dist ASC\n LIMIT ?`).all(vectorToBlob(params.queryVec), params.providerModel, ...params.sourceFilterVec.params, params.limit).map((row) => ({
1999
+ id: row.id,
2000
+ path: row.path,
2001
+ startLine: row.start_line,
2002
+ endLine: row.end_line,
2003
+ score: 1 - row.dist,
2004
+ snippet: truncateUtf16Safe(row.text, params.snippetMaxChars),
2005
+ source: row.source
2006
+ }));
2007
+ return listChunks({
2008
+ db: params.db,
2009
+ providerModel: params.providerModel,
2010
+ sourceFilter: params.sourceFilterChunks
2011
+ }).map((chunk) => ({
2012
+ chunk,
2013
+ score: cosineSimilarity(params.queryVec, chunk.embedding)
2014
+ })).filter((entry) => Number.isFinite(entry.score)).toSorted((a, b) => b.score - a.score).slice(0, params.limit).map((entry) => ({
2015
+ id: entry.chunk.id,
2016
+ path: entry.chunk.path,
2017
+ startLine: entry.chunk.startLine,
2018
+ endLine: entry.chunk.endLine,
2019
+ score: entry.score,
2020
+ snippet: truncateUtf16Safe(entry.chunk.text, params.snippetMaxChars),
2021
+ source: entry.chunk.source
2022
+ }));
2023
+ }
2024
+ function listChunks(params) {
2025
+ return params.db.prepare(`SELECT id, path, start_line, end_line, text, embedding, source
2026
+ FROM chunks
2027
+ WHERE model = ?${params.sourceFilter.sql}`).all(params.providerModel, ...params.sourceFilter.params).map((row) => ({
2028
+ id: row.id,
2029
+ path: row.path,
2030
+ startLine: row.start_line,
2031
+ endLine: row.end_line,
2032
+ text: row.text,
2033
+ embedding: parseEmbedding(row.embedding),
2034
+ source: row.source
2035
+ }));
2036
+ }
2037
+ async function searchKeyword(params) {
2038
+ if (params.limit <= 0) return [];
2039
+ const ftsQuery = params.buildFtsQuery(params.query);
2040
+ if (!ftsQuery) return [];
2041
+ return params.db.prepare(`SELECT id, path, source, start_line, end_line, text,\n bm25(${params.ftsTable}) AS rank\n FROM ${params.ftsTable}\n WHERE ${params.ftsTable} MATCH ? AND model = ?${params.sourceFilter.sql}\n ORDER BY rank ASC\n LIMIT ?`).all(ftsQuery, params.providerModel, ...params.sourceFilter.params, params.limit).map((row) => {
2042
+ const textScore = params.bm25RankToScore(row.rank);
2043
+ return {
2044
+ id: row.id,
2045
+ path: row.path,
2046
+ startLine: row.start_line,
2047
+ endLine: row.end_line,
2048
+ score: textScore,
2049
+ textScore,
2050
+ snippet: truncateUtf16Safe(row.text, params.snippetMaxChars),
2051
+ source: row.source
2052
+ };
2053
+ });
2054
+ }
2055
+
2056
+ //#endregion
2057
+ //#region src/memory/memory-schema.ts
2058
+ function ensureMemoryIndexSchema(params) {
2059
+ params.db.exec(`
2060
+ CREATE TABLE IF NOT EXISTS meta (
2061
+ key TEXT PRIMARY KEY,
2062
+ value TEXT NOT NULL
2063
+ );
2064
+ `);
2065
+ params.db.exec(`
2066
+ CREATE TABLE IF NOT EXISTS files (
2067
+ path TEXT PRIMARY KEY,
2068
+ source TEXT NOT NULL DEFAULT 'memory',
2069
+ hash TEXT NOT NULL,
2070
+ mtime INTEGER NOT NULL,
2071
+ size INTEGER NOT NULL
2072
+ );
2073
+ `);
2074
+ params.db.exec(`
2075
+ CREATE TABLE IF NOT EXISTS chunks (
2076
+ id TEXT PRIMARY KEY,
2077
+ path TEXT NOT NULL,
2078
+ source TEXT NOT NULL DEFAULT 'memory',
2079
+ start_line INTEGER NOT NULL,
2080
+ end_line INTEGER NOT NULL,
2081
+ hash TEXT NOT NULL,
2082
+ model TEXT NOT NULL,
2083
+ text TEXT NOT NULL,
2084
+ embedding TEXT NOT NULL,
2085
+ updated_at INTEGER NOT NULL
2086
+ );
2087
+ `);
2088
+ params.db.exec(`
2089
+ CREATE TABLE IF NOT EXISTS ${params.embeddingCacheTable} (
2090
+ provider TEXT NOT NULL,
2091
+ model TEXT NOT NULL,
2092
+ provider_key TEXT NOT NULL,
2093
+ hash TEXT NOT NULL,
2094
+ embedding TEXT NOT NULL,
2095
+ dims INTEGER,
2096
+ updated_at INTEGER NOT NULL,
2097
+ PRIMARY KEY (provider, model, provider_key, hash)
2098
+ );
2099
+ `);
2100
+ params.db.exec(`CREATE INDEX IF NOT EXISTS idx_embedding_cache_updated_at ON ${params.embeddingCacheTable}(updated_at);`);
2101
+ let ftsAvailable = false;
2102
+ let ftsError;
2103
+ if (params.ftsEnabled) try {
2104
+ params.db.exec(`CREATE VIRTUAL TABLE IF NOT EXISTS ${params.ftsTable} USING fts5(\n text,\n id UNINDEXED,\n path UNINDEXED,\n source UNINDEXED,\n model UNINDEXED,\n start_line UNINDEXED,\n end_line UNINDEXED\n);`);
2105
+ ftsAvailable = true;
2106
+ } catch (err) {
2107
+ const message = err instanceof Error ? err.message : String(err);
2108
+ ftsAvailable = false;
2109
+ ftsError = message;
2110
+ }
2111
+ ensureColumn(params.db, "files", "source", "TEXT NOT NULL DEFAULT 'memory'");
2112
+ ensureColumn(params.db, "chunks", "source", "TEXT NOT NULL DEFAULT 'memory'");
2113
+ params.db.exec(`CREATE INDEX IF NOT EXISTS idx_chunks_path ON chunks(path);`);
2114
+ params.db.exec(`CREATE INDEX IF NOT EXISTS idx_chunks_source ON chunks(source);`);
2115
+ return {
2116
+ ftsAvailable,
2117
+ ...ftsError ? { ftsError } : {}
2118
+ };
2119
+ }
2120
+ function ensureColumn(db, table, column, definition) {
2121
+ if (db.prepare(`PRAGMA table_info(${table})`).all().some((row) => row.name === column)) return;
2122
+ db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
2123
+ }
2124
+
2125
+ //#endregion
2126
+ //#region src/memory/sqlite-vec.ts
2127
+ async function loadSqliteVecExtension(params) {
2128
+ try {
2129
+ const sqliteVec = await import("sqlite-vec");
2130
+ const resolvedPath = params.extensionPath?.trim() ? params.extensionPath.trim() : void 0;
2131
+ const extensionPath = resolvedPath ?? sqliteVec.getLoadablePath();
2132
+ params.db.enableLoadExtension(true);
2133
+ if (resolvedPath) params.db.loadExtension(extensionPath);
2134
+ else sqliteVec.load(params.db);
2135
+ return {
2136
+ ok: true,
2137
+ extensionPath
2138
+ };
2139
+ } catch (err) {
2140
+ return {
2141
+ ok: false,
2142
+ error: err instanceof Error ? err.message : String(err)
2143
+ };
2144
+ }
2145
+ }
2146
+
2147
+ //#endregion
2148
+ //#region src/memory/manager-sync-ops.ts
2149
+ const META_KEY = "memory_index_meta_v1";
2150
+ const VECTOR_TABLE$1 = "chunks_vec";
2151
+ const FTS_TABLE$1 = "chunks_fts";
2152
+ const EMBEDDING_CACHE_TABLE$1 = "embedding_cache";
2153
+ const SESSION_DIRTY_DEBOUNCE_MS = 5e3;
2154
+ const SESSION_DELTA_READ_CHUNK_BYTES = 64 * 1024;
2155
+ const VECTOR_LOAD_TIMEOUT_MS = 3e4;
2156
+ const IGNORED_MEMORY_WATCH_DIR_NAMES = new Set([
2157
+ ".git",
2158
+ "node_modules",
2159
+ ".pnpm-store",
2160
+ ".venv",
2161
+ "venv",
2162
+ ".tox",
2163
+ "__pycache__"
2164
+ ]);
2165
+ const log$1 = createSubsystemLogger("memory");
2166
+ function shouldIgnoreMemoryWatchPath(watchPath) {
2167
+ return path.normalize(watchPath).split(path.sep).map((segment) => segment.trim().toLowerCase()).some((segment) => IGNORED_MEMORY_WATCH_DIR_NAMES.has(segment));
2168
+ }
2169
+ var MemoryManagerSyncOps = class {
2170
+ async ensureVectorReady(dimensions) {
2171
+ if (!this.vector.enabled) return false;
2172
+ if (!this.vectorReady) this.vectorReady = this.withTimeout(this.loadVectorExtension(), VECTOR_LOAD_TIMEOUT_MS, `sqlite-vec load timed out after ${Math.round(VECTOR_LOAD_TIMEOUT_MS / 1e3)}s`);
2173
+ let ready = false;
2174
+ try {
2175
+ ready = await this.vectorReady;
2176
+ } catch (err) {
2177
+ const message = err instanceof Error ? err.message : String(err);
2178
+ this.vector.available = false;
2179
+ this.vector.loadError = message;
2180
+ this.vectorReady = null;
2181
+ log$1.warn(`sqlite-vec unavailable: ${message}`);
2182
+ return false;
2183
+ }
2184
+ if (ready && typeof dimensions === "number" && dimensions > 0) this.ensureVectorTable(dimensions);
2185
+ return ready;
2186
+ }
2187
+ async loadVectorExtension() {
2188
+ if (this.vector.available !== null) return this.vector.available;
2189
+ if (!this.vector.enabled) {
2190
+ this.vector.available = false;
2191
+ return false;
2192
+ }
2193
+ try {
2194
+ const resolvedPath = this.vector.extensionPath?.trim() ? resolveUserPath(this.vector.extensionPath) : void 0;
2195
+ const loaded = await loadSqliteVecExtension({
2196
+ db: this.db,
2197
+ extensionPath: resolvedPath
2198
+ });
2199
+ if (!loaded.ok) throw new Error(loaded.error ?? "unknown sqlite-vec load error");
2200
+ this.vector.extensionPath = loaded.extensionPath;
2201
+ this.vector.available = true;
2202
+ return true;
2203
+ } catch (err) {
2204
+ const message = err instanceof Error ? err.message : String(err);
2205
+ this.vector.available = false;
2206
+ this.vector.loadError = message;
2207
+ log$1.warn(`sqlite-vec unavailable: ${message}`);
2208
+ return false;
2209
+ }
2210
+ }
2211
+ ensureVectorTable(dimensions) {
2212
+ if (this.vector.dims === dimensions) return;
2213
+ if (this.vector.dims && this.vector.dims !== dimensions) this.dropVectorTable();
2214
+ this.db.exec(`CREATE VIRTUAL TABLE IF NOT EXISTS ${VECTOR_TABLE$1} USING vec0(\n id TEXT PRIMARY KEY,\n embedding FLOAT[${dimensions}]\n)`);
2215
+ this.vector.dims = dimensions;
2216
+ }
2217
+ dropVectorTable() {
2218
+ try {
2219
+ this.db.exec(`DROP TABLE IF EXISTS ${VECTOR_TABLE$1}`);
2220
+ } catch (err) {
2221
+ const message = err instanceof Error ? err.message : String(err);
2222
+ log$1.debug(`Failed to drop ${VECTOR_TABLE$1}: ${message}`);
2223
+ }
2224
+ }
2225
+ buildSourceFilter(alias) {
2226
+ const sources = Array.from(this.sources);
2227
+ if (sources.length === 0) return {
2228
+ sql: "",
2229
+ params: []
2230
+ };
2231
+ return {
2232
+ sql: ` AND ${alias ? `${alias}.source` : "source"} IN (${sources.map(() => "?").join(", ")})`,
2233
+ params: sources
2234
+ };
2235
+ }
2236
+ openDatabase() {
2237
+ const dbPath = resolveUserPath(this.settings.store.path);
2238
+ return this.openDatabaseAtPath(dbPath);
2239
+ }
2240
+ openDatabaseAtPath(dbPath) {
2241
+ ensureDir(path.dirname(dbPath));
2242
+ const { DatabaseSync } = requireNodeSqlite();
2243
+ return new DatabaseSync(dbPath, { allowExtension: this.settings.store.vector.enabled });
2244
+ }
2245
+ seedEmbeddingCache(sourceDb) {
2246
+ if (!this.cache.enabled) return;
2247
+ try {
2248
+ const rows = sourceDb.prepare(`SELECT provider, model, provider_key, hash, embedding, dims, updated_at FROM ${EMBEDDING_CACHE_TABLE$1}`).all();
2249
+ if (!rows.length) return;
2250
+ const insert = this.db.prepare(`INSERT INTO ${EMBEDDING_CACHE_TABLE$1} (provider, model, provider_key, hash, embedding, dims, updated_at)
2251
+ VALUES (?, ?, ?, ?, ?, ?, ?)
2252
+ ON CONFLICT(provider, model, provider_key, hash) DO UPDATE SET
2253
+ embedding=excluded.embedding,
2254
+ dims=excluded.dims,
2255
+ updated_at=excluded.updated_at`);
2256
+ this.db.exec("BEGIN");
2257
+ for (const row of rows) insert.run(row.provider, row.model, row.provider_key, row.hash, row.embedding, row.dims, row.updated_at);
2258
+ this.db.exec("COMMIT");
2259
+ } catch (err) {
2260
+ try {
2261
+ this.db.exec("ROLLBACK");
2262
+ } catch {}
2263
+ throw err;
2264
+ }
2265
+ }
2266
+ async swapIndexFiles(targetPath, tempPath) {
2267
+ const backupPath = `${targetPath}.backup-${randomUUID()}`;
2268
+ await this.moveIndexFiles(targetPath, backupPath);
2269
+ try {
2270
+ await this.moveIndexFiles(tempPath, targetPath);
2271
+ } catch (err) {
2272
+ await this.moveIndexFiles(backupPath, targetPath);
2273
+ throw err;
2274
+ }
2275
+ await this.removeIndexFiles(backupPath);
2276
+ }
2277
+ async moveIndexFiles(sourceBase, targetBase) {
2278
+ for (const suffix of [
2279
+ "",
2280
+ "-wal",
2281
+ "-shm"
2282
+ ]) {
2283
+ const source = `${sourceBase}${suffix}`;
2284
+ const target = `${targetBase}${suffix}`;
2285
+ try {
2286
+ await fs.rename(source, target);
2287
+ } catch (err) {
2288
+ if (err.code !== "ENOENT") throw err;
2289
+ }
2290
+ }
2291
+ }
2292
+ async removeIndexFiles(basePath) {
2293
+ await Promise.all([
2294
+ "",
2295
+ "-wal",
2296
+ "-shm"
2297
+ ].map((suffix) => fs.rm(`${basePath}${suffix}`, { force: true })));
2298
+ }
2299
+ ensureSchema() {
2300
+ const result = ensureMemoryIndexSchema({
2301
+ db: this.db,
2302
+ embeddingCacheTable: EMBEDDING_CACHE_TABLE$1,
2303
+ ftsTable: FTS_TABLE$1,
2304
+ ftsEnabled: this.fts.enabled
2305
+ });
2306
+ this.fts.available = result.ftsAvailable;
2307
+ if (result.ftsError) {
2308
+ this.fts.loadError = result.ftsError;
2309
+ log$1.warn(`fts unavailable: ${result.ftsError}`);
2310
+ }
2311
+ }
2312
+ ensureWatcher() {
2313
+ if (!this.sources.has("memory") || !this.settings.sync.watch || this.watcher) return;
2314
+ const watchPaths = new Set([
2315
+ path.join(this.workspaceDir, "MEMORY.md"),
2316
+ path.join(this.workspaceDir, "memory.md"),
2317
+ path.join(this.workspaceDir, "memory", "**", "*.md")
2318
+ ]);
2319
+ const additionalPaths = normalizeExtraMemoryPaths(this.workspaceDir, this.settings.extraPaths);
2320
+ for (const entry of additionalPaths) try {
2321
+ const stat = fs$1.lstatSync(entry);
2322
+ if (stat.isSymbolicLink()) continue;
2323
+ if (stat.isDirectory()) {
2324
+ watchPaths.add(path.join(entry, "**", "*.md"));
2325
+ continue;
2326
+ }
2327
+ if (stat.isFile() && entry.toLowerCase().endsWith(".md")) watchPaths.add(entry);
2328
+ } catch {}
2329
+ this.watcher = chokidar.watch(Array.from(watchPaths), {
2330
+ ignoreInitial: true,
2331
+ ignored: (watchPath) => shouldIgnoreMemoryWatchPath(String(watchPath)),
2332
+ awaitWriteFinish: {
2333
+ stabilityThreshold: this.settings.sync.watchDebounceMs,
2334
+ pollInterval: 100
2335
+ }
2336
+ });
2337
+ const markDirty = () => {
2338
+ this.dirty = true;
2339
+ this.scheduleWatchSync();
2340
+ };
2341
+ this.watcher.on("add", markDirty);
2342
+ this.watcher.on("change", markDirty);
2343
+ this.watcher.on("unlink", markDirty);
2344
+ }
2345
+ ensureSessionListener() {
2346
+ if (!this.sources.has("sessions") || this.sessionUnsubscribe) return;
2347
+ this.sessionUnsubscribe = onSessionTranscriptUpdate((update) => {
2348
+ if (this.closed) return;
2349
+ const sessionFile = update.sessionFile;
2350
+ if (!this.isSessionFileForAgent(sessionFile)) return;
2351
+ this.scheduleSessionDirty(sessionFile);
2352
+ });
2353
+ }
2354
+ scheduleSessionDirty(sessionFile) {
2355
+ this.sessionPendingFiles.add(sessionFile);
2356
+ if (this.sessionWatchTimer) return;
2357
+ this.sessionWatchTimer = setTimeout(() => {
2358
+ this.sessionWatchTimer = null;
2359
+ this.processSessionDeltaBatch().catch((err) => {
2360
+ log$1.warn(`memory session delta failed: ${String(err)}`);
2361
+ });
2362
+ }, SESSION_DIRTY_DEBOUNCE_MS);
2363
+ }
2364
+ async processSessionDeltaBatch() {
2365
+ if (this.sessionPendingFiles.size === 0) return;
2366
+ const pending = Array.from(this.sessionPendingFiles);
2367
+ this.sessionPendingFiles.clear();
2368
+ let shouldSync = false;
2369
+ for (const sessionFile of pending) {
2370
+ const delta = await this.updateSessionDelta(sessionFile);
2371
+ if (!delta) continue;
2372
+ const bytesThreshold = delta.deltaBytes;
2373
+ const messagesThreshold = delta.deltaMessages;
2374
+ const bytesHit = bytesThreshold <= 0 ? delta.pendingBytes > 0 : delta.pendingBytes >= bytesThreshold;
2375
+ const messagesHit = messagesThreshold <= 0 ? delta.pendingMessages > 0 : delta.pendingMessages >= messagesThreshold;
2376
+ if (!bytesHit && !messagesHit) continue;
2377
+ this.sessionsDirtyFiles.add(sessionFile);
2378
+ this.sessionsDirty = true;
2379
+ delta.pendingBytes = bytesThreshold > 0 ? Math.max(0, delta.pendingBytes - bytesThreshold) : 0;
2380
+ delta.pendingMessages = messagesThreshold > 0 ? Math.max(0, delta.pendingMessages - messagesThreshold) : 0;
2381
+ shouldSync = true;
2382
+ }
2383
+ if (shouldSync) this.sync({ reason: "session-delta" }).catch((err) => {
2384
+ log$1.warn(`memory sync failed (session-delta): ${String(err)}`);
2385
+ });
2386
+ }
2387
+ async updateSessionDelta(sessionFile) {
2388
+ const thresholds = this.settings.sync.sessions;
2389
+ if (!thresholds) return null;
2390
+ let stat;
2391
+ try {
2392
+ stat = await fs.stat(sessionFile);
2393
+ } catch {
2394
+ return null;
2395
+ }
2396
+ const size = stat.size;
2397
+ let state = this.sessionDeltas.get(sessionFile);
2398
+ if (!state) {
2399
+ state = {
2400
+ lastSize: 0,
2401
+ pendingBytes: 0,
2402
+ pendingMessages: 0
2403
+ };
2404
+ this.sessionDeltas.set(sessionFile, state);
2405
+ }
2406
+ const deltaBytes = Math.max(0, size - state.lastSize);
2407
+ if (deltaBytes === 0 && size === state.lastSize) return {
2408
+ deltaBytes: thresholds.deltaBytes,
2409
+ deltaMessages: thresholds.deltaMessages,
2410
+ pendingBytes: state.pendingBytes,
2411
+ pendingMessages: state.pendingMessages
2412
+ };
2413
+ if (size < state.lastSize) {
2414
+ state.lastSize = size;
2415
+ state.pendingBytes += size;
2416
+ if (thresholds.deltaMessages > 0 && (thresholds.deltaBytes <= 0 || state.pendingBytes < thresholds.deltaBytes)) state.pendingMessages += await this.countNewlines(sessionFile, 0, size);
2417
+ } else {
2418
+ state.pendingBytes += deltaBytes;
2419
+ if (thresholds.deltaMessages > 0 && (thresholds.deltaBytes <= 0 || state.pendingBytes < thresholds.deltaBytes)) state.pendingMessages += await this.countNewlines(sessionFile, state.lastSize, size);
2420
+ state.lastSize = size;
2421
+ }
2422
+ this.sessionDeltas.set(sessionFile, state);
2423
+ return {
2424
+ deltaBytes: thresholds.deltaBytes,
2425
+ deltaMessages: thresholds.deltaMessages,
2426
+ pendingBytes: state.pendingBytes,
2427
+ pendingMessages: state.pendingMessages
2428
+ };
2429
+ }
2430
+ async countNewlines(absPath, start, end) {
2431
+ if (end <= start) return 0;
2432
+ const handle = await fs.open(absPath, "r");
2433
+ try {
2434
+ let offset = start;
2435
+ let count = 0;
2436
+ const buffer = Buffer.alloc(SESSION_DELTA_READ_CHUNK_BYTES);
2437
+ while (offset < end) {
2438
+ const toRead = Math.min(buffer.length, end - offset);
2439
+ const { bytesRead } = await handle.read(buffer, 0, toRead, offset);
2440
+ if (bytesRead <= 0) break;
2441
+ for (let i = 0; i < bytesRead; i += 1) if (buffer[i] === 10) count += 1;
2442
+ offset += bytesRead;
2443
+ }
2444
+ return count;
2445
+ } finally {
2446
+ await handle.close();
2447
+ }
2448
+ }
2449
+ resetSessionDelta(absPath, size) {
2450
+ const state = this.sessionDeltas.get(absPath);
2451
+ if (!state) return;
2452
+ state.lastSize = size;
2453
+ state.pendingBytes = 0;
2454
+ state.pendingMessages = 0;
2455
+ }
2456
+ isSessionFileForAgent(sessionFile) {
2457
+ if (!sessionFile) return false;
2458
+ const sessionsDir = resolveSessionTranscriptsDirForAgent(this.agentId);
2459
+ const resolvedFile = path.resolve(sessionFile);
2460
+ const resolvedDir = path.resolve(sessionsDir);
2461
+ return resolvedFile.startsWith(`${resolvedDir}${path.sep}`);
2462
+ }
2463
+ ensureIntervalSync() {
2464
+ const minutes = this.settings.sync.intervalMinutes;
2465
+ if (!minutes || minutes <= 0 || this.intervalTimer) return;
2466
+ const ms = minutes * 60 * 1e3;
2467
+ this.intervalTimer = setInterval(() => {
2468
+ this.sync({ reason: "interval" }).catch((err) => {
2469
+ log$1.warn(`memory sync failed (interval): ${String(err)}`);
2470
+ });
2471
+ }, ms);
2472
+ }
2473
+ scheduleWatchSync() {
2474
+ if (!this.sources.has("memory") || !this.settings.sync.watch) return;
2475
+ if (this.watchTimer) clearTimeout(this.watchTimer);
2476
+ this.watchTimer = setTimeout(() => {
2477
+ this.watchTimer = null;
2478
+ this.sync({ reason: "watch" }).catch((err) => {
2479
+ log$1.warn(`memory sync failed (watch): ${String(err)}`);
2480
+ });
2481
+ }, this.settings.sync.watchDebounceMs);
2482
+ }
2483
+ shouldSyncSessions(params, needsFullReindex = false) {
2484
+ if (!this.sources.has("sessions")) return false;
2485
+ if (params?.force) return true;
2486
+ const reason = params?.reason;
2487
+ if (reason === "session-start" || reason === "watch") return false;
2488
+ if (needsFullReindex) return true;
2489
+ return this.sessionsDirty && this.sessionsDirtyFiles.size > 0;
2490
+ }
2491
+ async syncMemoryFiles(params) {
2492
+ const files = await listMemoryFiles(this.workspaceDir, this.settings.extraPaths);
2493
+ const fileEntries = await Promise.all(files.map(async (file) => buildFileEntry(file, this.workspaceDir)));
2494
+ log$1.debug("memory sync: indexing memory files", {
2495
+ files: fileEntries.length,
2496
+ needsFullReindex: params.needsFullReindex,
2497
+ batch: this.batch.enabled,
2498
+ concurrency: this.getIndexConcurrency()
2499
+ });
2500
+ const activePaths = new Set(fileEntries.map((entry) => entry.path));
2501
+ if (params.progress) {
2502
+ params.progress.total += fileEntries.length;
2503
+ params.progress.report({
2504
+ completed: params.progress.completed,
2505
+ total: params.progress.total,
2506
+ label: this.batch.enabled ? "Indexing memory files (batch)..." : "Indexing memory files…"
2507
+ });
2508
+ }
2509
+ await runWithConcurrency(fileEntries.map((entry) => async () => {
2510
+ const record = this.db.prepare(`SELECT hash FROM files WHERE path = ? AND source = ?`).get(entry.path, "memory");
2511
+ if (!params.needsFullReindex && record?.hash === entry.hash) {
2512
+ if (params.progress) {
2513
+ params.progress.completed += 1;
2514
+ params.progress.report({
2515
+ completed: params.progress.completed,
2516
+ total: params.progress.total
2517
+ });
2518
+ }
2519
+ return;
2520
+ }
2521
+ await this.indexFile(entry, { source: "memory" });
2522
+ if (params.progress) {
2523
+ params.progress.completed += 1;
2524
+ params.progress.report({
2525
+ completed: params.progress.completed,
2526
+ total: params.progress.total
2527
+ });
2528
+ }
2529
+ }), this.getIndexConcurrency());
2530
+ const staleRows = this.db.prepare(`SELECT path FROM files WHERE source = ?`).all("memory");
2531
+ for (const stale of staleRows) {
2532
+ if (activePaths.has(stale.path)) continue;
2533
+ this.db.prepare(`DELETE FROM files WHERE path = ? AND source = ?`).run(stale.path, "memory");
2534
+ try {
2535
+ this.db.prepare(`DELETE FROM ${VECTOR_TABLE$1} WHERE id IN (SELECT id FROM chunks WHERE path = ? AND source = ?)`).run(stale.path, "memory");
2536
+ } catch {}
2537
+ this.db.prepare(`DELETE FROM chunks WHERE path = ? AND source = ?`).run(stale.path, "memory");
2538
+ if (this.fts.enabled && this.fts.available) try {
2539
+ this.db.prepare(`DELETE FROM ${FTS_TABLE$1} WHERE path = ? AND source = ? AND model = ?`).run(stale.path, "memory", this.provider.model);
2540
+ } catch {}
2541
+ }
2542
+ }
2543
+ async syncSessionFiles(params) {
2544
+ const files = await listSessionFilesForAgent(this.agentId);
2545
+ const activePaths = new Set(files.map((file) => sessionPathForFile(file)));
2546
+ const indexAll = params.needsFullReindex || this.sessionsDirtyFiles.size === 0;
2547
+ log$1.debug("memory sync: indexing session files", {
2548
+ files: files.length,
2549
+ indexAll,
2550
+ dirtyFiles: this.sessionsDirtyFiles.size,
2551
+ batch: this.batch.enabled,
2552
+ concurrency: this.getIndexConcurrency()
2553
+ });
2554
+ if (params.progress) {
2555
+ params.progress.total += files.length;
2556
+ params.progress.report({
2557
+ completed: params.progress.completed,
2558
+ total: params.progress.total,
2559
+ label: this.batch.enabled ? "Indexing session files (batch)..." : "Indexing session files…"
2560
+ });
2561
+ }
2562
+ await runWithConcurrency(files.map((absPath) => async () => {
2563
+ if (!indexAll && !this.sessionsDirtyFiles.has(absPath)) {
2564
+ if (params.progress) {
2565
+ params.progress.completed += 1;
2566
+ params.progress.report({
2567
+ completed: params.progress.completed,
2568
+ total: params.progress.total
2569
+ });
2570
+ }
2571
+ return;
2572
+ }
2573
+ const entry = await buildSessionEntry(absPath);
2574
+ if (!entry) {
2575
+ if (params.progress) {
2576
+ params.progress.completed += 1;
2577
+ params.progress.report({
2578
+ completed: params.progress.completed,
2579
+ total: params.progress.total
2580
+ });
2581
+ }
2582
+ return;
2583
+ }
2584
+ const record = this.db.prepare(`SELECT hash FROM files WHERE path = ? AND source = ?`).get(entry.path, "sessions");
2585
+ if (!params.needsFullReindex && record?.hash === entry.hash) {
2586
+ if (params.progress) {
2587
+ params.progress.completed += 1;
2588
+ params.progress.report({
2589
+ completed: params.progress.completed,
2590
+ total: params.progress.total
2591
+ });
2592
+ }
2593
+ this.resetSessionDelta(absPath, entry.size);
2594
+ return;
2595
+ }
2596
+ await this.indexFile(entry, {
2597
+ source: "sessions",
2598
+ content: entry.content
2599
+ });
2600
+ this.resetSessionDelta(absPath, entry.size);
2601
+ if (params.progress) {
2602
+ params.progress.completed += 1;
2603
+ params.progress.report({
2604
+ completed: params.progress.completed,
2605
+ total: params.progress.total
2606
+ });
2607
+ }
2608
+ }), this.getIndexConcurrency());
2609
+ const staleRows = this.db.prepare(`SELECT path FROM files WHERE source = ?`).all("sessions");
2610
+ for (const stale of staleRows) {
2611
+ if (activePaths.has(stale.path)) continue;
2612
+ this.db.prepare(`DELETE FROM files WHERE path = ? AND source = ?`).run(stale.path, "sessions");
2613
+ try {
2614
+ this.db.prepare(`DELETE FROM ${VECTOR_TABLE$1} WHERE id IN (SELECT id FROM chunks WHERE path = ? AND source = ?)`).run(stale.path, "sessions");
2615
+ } catch {}
2616
+ this.db.prepare(`DELETE FROM chunks WHERE path = ? AND source = ?`).run(stale.path, "sessions");
2617
+ if (this.fts.enabled && this.fts.available) try {
2618
+ this.db.prepare(`DELETE FROM ${FTS_TABLE$1} WHERE path = ? AND source = ? AND model = ?`).run(stale.path, "sessions", this.provider.model);
2619
+ } catch {}
2620
+ }
2621
+ }
2622
+ createSyncProgress(onProgress) {
2623
+ const state = {
2624
+ completed: 0,
2625
+ total: 0,
2626
+ label: void 0,
2627
+ report: (update) => {
2628
+ if (update.label) state.label = update.label;
2629
+ const label = update.total > 0 && state.label ? `${state.label} ${update.completed}/${update.total}` : state.label;
2630
+ onProgress({
2631
+ completed: update.completed,
2632
+ total: update.total,
2633
+ label
2634
+ });
2635
+ }
2636
+ };
2637
+ return state;
2638
+ }
2639
+ async runSync(params) {
2640
+ const progress = params?.progress ? this.createSyncProgress(params.progress) : void 0;
2641
+ if (progress) progress.report({
2642
+ completed: progress.completed,
2643
+ total: progress.total,
2644
+ label: "Loading vector extension…"
2645
+ });
2646
+ const vectorReady = await this.ensureVectorReady();
2647
+ const meta = this.readMeta();
2648
+ const needsFullReindex = params?.force || !meta || meta.model !== this.provider.model || meta.provider !== this.provider.id || meta.providerKey !== this.providerKey || meta.chunkTokens !== this.settings.chunking.tokens || meta.chunkOverlap !== this.settings.chunking.overlap || vectorReady && !meta?.vectorDims;
2649
+ try {
2650
+ if (needsFullReindex) {
2651
+ if (process.env.ANIMA_TEST_FAST === "1" && process.env.ANIMA_TEST_MEMORY_UNSAFE_REINDEX === "1") await this.runUnsafeReindex({
2652
+ reason: params?.reason,
2653
+ force: params?.force,
2654
+ progress: progress ?? void 0
2655
+ });
2656
+ else await this.runSafeReindex({
2657
+ reason: params?.reason,
2658
+ force: params?.force,
2659
+ progress: progress ?? void 0
2660
+ });
2661
+ return;
2662
+ }
2663
+ const shouldSyncMemory = this.sources.has("memory") && (params?.force || needsFullReindex || this.dirty);
2664
+ const shouldSyncSessions = this.shouldSyncSessions(params, needsFullReindex);
2665
+ if (shouldSyncMemory) {
2666
+ await this.syncMemoryFiles({
2667
+ needsFullReindex,
2668
+ progress: progress ?? void 0
2669
+ });
2670
+ this.dirty = false;
2671
+ }
2672
+ if (shouldSyncSessions) {
2673
+ await this.syncSessionFiles({
2674
+ needsFullReindex,
2675
+ progress: progress ?? void 0
2676
+ });
2677
+ this.sessionsDirty = false;
2678
+ this.sessionsDirtyFiles.clear();
2679
+ } else if (this.sessionsDirtyFiles.size > 0) this.sessionsDirty = true;
2680
+ else this.sessionsDirty = false;
2681
+ } catch (err) {
2682
+ const reason = err instanceof Error ? err.message : String(err);
2683
+ if (this.shouldFallbackOnError(reason) && await this.activateFallbackProvider(reason)) {
2684
+ await this.runSafeReindex({
2685
+ reason: params?.reason ?? "fallback",
2686
+ force: true,
2687
+ progress: progress ?? void 0
2688
+ });
2689
+ return;
2690
+ }
2691
+ throw err;
2692
+ }
2693
+ }
2694
+ shouldFallbackOnError(message) {
2695
+ return /embedding|embeddings|batch/i.test(message);
2696
+ }
2697
+ resolveBatchConfig() {
2698
+ const batch = this.settings.remote?.batch;
2699
+ return {
2700
+ enabled: Boolean(batch?.enabled && (this.openAi && this.provider.id === "openai" || this.gemini && this.provider.id === "gemini" || this.voyage && this.provider.id === "voyage")),
2701
+ wait: batch?.wait ?? true,
2702
+ concurrency: Math.max(1, batch?.concurrency ?? 2),
2703
+ pollIntervalMs: batch?.pollIntervalMs ?? 2e3,
2704
+ timeoutMs: (batch?.timeoutMinutes ?? 60) * 60 * 1e3
2705
+ };
2706
+ }
2707
+ async activateFallbackProvider(reason) {
2708
+ const fallback = this.settings.fallback;
2709
+ if (!fallback || fallback === "none" || fallback === this.provider.id) return false;
2710
+ if (this.fallbackFrom) return false;
2711
+ const fallbackFrom = this.provider.id;
2712
+ const fallbackModel = fallback === "gemini" ? DEFAULT_GEMINI_EMBEDDING_MODEL : fallback === "openai" ? DEFAULT_OPENAI_EMBEDDING_MODEL : fallback === "voyage" ? DEFAULT_VOYAGE_EMBEDDING_MODEL : this.settings.model;
2713
+ const fallbackResult = await createEmbeddingProvider({
2714
+ config: this.cfg,
2715
+ agentDir: resolveAgentDir(this.cfg, this.agentId),
2716
+ provider: fallback,
2717
+ remote: this.settings.remote,
2718
+ model: fallbackModel,
2719
+ fallback: "none",
2720
+ local: this.settings.local
2721
+ });
2722
+ this.fallbackFrom = fallbackFrom;
2723
+ this.fallbackReason = reason;
2724
+ this.provider = fallbackResult.provider;
2725
+ this.openAi = fallbackResult.openAi;
2726
+ this.gemini = fallbackResult.gemini;
2727
+ this.voyage = fallbackResult.voyage;
2728
+ this.providerKey = this.computeProviderKey();
2729
+ this.batch = this.resolveBatchConfig();
2730
+ log$1.warn(`memory embeddings: switched to fallback provider (${fallback})`, { reason });
2731
+ return true;
2732
+ }
2733
+ async runSafeReindex(params) {
2734
+ const dbPath = resolveUserPath(this.settings.store.path);
2735
+ const tempDbPath = `${dbPath}.tmp-${randomUUID()}`;
2736
+ const tempDb = this.openDatabaseAtPath(tempDbPath);
2737
+ const originalDb = this.db;
2738
+ let originalDbClosed = false;
2739
+ const originalState = {
2740
+ ftsAvailable: this.fts.available,
2741
+ ftsError: this.fts.loadError,
2742
+ vectorAvailable: this.vector.available,
2743
+ vectorLoadError: this.vector.loadError,
2744
+ vectorDims: this.vector.dims,
2745
+ vectorReady: this.vectorReady
2746
+ };
2747
+ const restoreOriginalState = () => {
2748
+ if (originalDbClosed) this.db = this.openDatabaseAtPath(dbPath);
2749
+ else this.db = originalDb;
2750
+ this.fts.available = originalState.ftsAvailable;
2751
+ this.fts.loadError = originalState.ftsError;
2752
+ this.vector.available = originalDbClosed ? null : originalState.vectorAvailable;
2753
+ this.vector.loadError = originalState.vectorLoadError;
2754
+ this.vector.dims = originalState.vectorDims;
2755
+ this.vectorReady = originalDbClosed ? null : originalState.vectorReady;
2756
+ };
2757
+ this.db = tempDb;
2758
+ this.vectorReady = null;
2759
+ this.vector.available = null;
2760
+ this.vector.loadError = void 0;
2761
+ this.vector.dims = void 0;
2762
+ this.fts.available = false;
2763
+ this.fts.loadError = void 0;
2764
+ this.ensureSchema();
2765
+ let nextMeta = null;
2766
+ try {
2767
+ this.seedEmbeddingCache(originalDb);
2768
+ const shouldSyncMemory = this.sources.has("memory");
2769
+ const shouldSyncSessions = this.shouldSyncSessions({
2770
+ reason: params.reason,
2771
+ force: params.force
2772
+ }, true);
2773
+ if (shouldSyncMemory) {
2774
+ await this.syncMemoryFiles({
2775
+ needsFullReindex: true,
2776
+ progress: params.progress
2777
+ });
2778
+ this.dirty = false;
2779
+ }
2780
+ if (shouldSyncSessions) {
2781
+ await this.syncSessionFiles({
2782
+ needsFullReindex: true,
2783
+ progress: params.progress
2784
+ });
2785
+ this.sessionsDirty = false;
2786
+ this.sessionsDirtyFiles.clear();
2787
+ } else if (this.sessionsDirtyFiles.size > 0) this.sessionsDirty = true;
2788
+ else this.sessionsDirty = false;
2789
+ nextMeta = {
2790
+ model: this.provider.model,
2791
+ provider: this.provider.id,
2792
+ providerKey: this.providerKey,
2793
+ chunkTokens: this.settings.chunking.tokens,
2794
+ chunkOverlap: this.settings.chunking.overlap
2795
+ };
2796
+ if (this.vector.available && this.vector.dims) nextMeta.vectorDims = this.vector.dims;
2797
+ this.writeMeta(nextMeta);
2798
+ this.pruneEmbeddingCacheIfNeeded();
2799
+ this.db.close();
2800
+ originalDb.close();
2801
+ originalDbClosed = true;
2802
+ await this.swapIndexFiles(dbPath, tempDbPath);
2803
+ this.db = this.openDatabaseAtPath(dbPath);
2804
+ this.vectorReady = null;
2805
+ this.vector.available = null;
2806
+ this.vector.loadError = void 0;
2807
+ this.ensureSchema();
2808
+ this.vector.dims = nextMeta.vectorDims;
2809
+ } catch (err) {
2810
+ try {
2811
+ this.db.close();
2812
+ } catch {}
2813
+ await this.removeIndexFiles(tempDbPath);
2814
+ restoreOriginalState();
2815
+ throw err;
2816
+ }
2817
+ }
2818
+ async runUnsafeReindex(params) {
2819
+ this.resetIndex();
2820
+ const shouldSyncMemory = this.sources.has("memory");
2821
+ const shouldSyncSessions = this.shouldSyncSessions({
2822
+ reason: params.reason,
2823
+ force: params.force
2824
+ }, true);
2825
+ if (shouldSyncMemory) {
2826
+ await this.syncMemoryFiles({
2827
+ needsFullReindex: true,
2828
+ progress: params.progress
2829
+ });
2830
+ this.dirty = false;
2831
+ }
2832
+ if (shouldSyncSessions) {
2833
+ await this.syncSessionFiles({
2834
+ needsFullReindex: true,
2835
+ progress: params.progress
2836
+ });
2837
+ this.sessionsDirty = false;
2838
+ this.sessionsDirtyFiles.clear();
2839
+ } else if (this.sessionsDirtyFiles.size > 0) this.sessionsDirty = true;
2840
+ else this.sessionsDirty = false;
2841
+ const nextMeta = {
2842
+ model: this.provider.model,
2843
+ provider: this.provider.id,
2844
+ providerKey: this.providerKey,
2845
+ chunkTokens: this.settings.chunking.tokens,
2846
+ chunkOverlap: this.settings.chunking.overlap
2847
+ };
2848
+ if (this.vector.available && this.vector.dims) nextMeta.vectorDims = this.vector.dims;
2849
+ this.writeMeta(nextMeta);
2850
+ this.pruneEmbeddingCacheIfNeeded();
2851
+ }
2852
+ resetIndex() {
2853
+ this.db.exec(`DELETE FROM files`);
2854
+ this.db.exec(`DELETE FROM chunks`);
2855
+ if (this.fts.enabled && this.fts.available) try {
2856
+ this.db.exec(`DELETE FROM ${FTS_TABLE$1}`);
2857
+ } catch {}
2858
+ this.dropVectorTable();
2859
+ this.vector.dims = void 0;
2860
+ this.sessionsDirtyFiles.clear();
2861
+ }
2862
+ readMeta() {
2863
+ const row = this.db.prepare(`SELECT value FROM meta WHERE key = ?`).get(META_KEY);
2864
+ if (!row?.value) return null;
2865
+ try {
2866
+ return JSON.parse(row.value);
2867
+ } catch {
2868
+ return null;
2869
+ }
2870
+ }
2871
+ writeMeta(meta) {
2872
+ const value = JSON.stringify(meta);
2873
+ this.db.prepare(`INSERT INTO meta (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value=excluded.value`).run(META_KEY, value);
2874
+ }
2875
+ };
2876
+ const memoryManagerSyncOps = MemoryManagerSyncOps.prototype;
2877
+
2878
+ //#endregion
2879
+ //#region src/memory/manager.ts
2880
+ var manager_exports = /* @__PURE__ */ __exportAll({ MemoryIndexManager: () => MemoryIndexManager });
2881
+ const SNIPPET_MAX_CHARS = 700;
2882
+ const VECTOR_TABLE = "chunks_vec";
2883
+ const FTS_TABLE = "chunks_fts";
2884
+ const EMBEDDING_CACHE_TABLE = "embedding_cache";
2885
+ const BATCH_FAILURE_LIMIT = 2;
2886
+ const log = createSubsystemLogger("memory");
2887
+ const INDEX_CACHE = /* @__PURE__ */ new Map();
2888
+ var MemoryIndexManager = class MemoryIndexManager {
2889
+ static async get(params) {
2890
+ const { cfg, agentId } = params;
2891
+ const settings = resolveMemorySearchConfig(cfg, agentId);
2892
+ if (!settings) return null;
2893
+ const workspaceDir = resolveAgentWorkspaceDir(cfg, agentId);
2894
+ const key = `${agentId}:${workspaceDir}:${JSON.stringify(settings)}`;
2895
+ const existing = INDEX_CACHE.get(key);
2896
+ if (existing) return existing;
2897
+ const manager = new MemoryIndexManager({
2898
+ cacheKey: key,
2899
+ cfg,
2900
+ agentId,
2901
+ workspaceDir,
2902
+ settings,
2903
+ providerResult: await createEmbeddingProvider$1({
2904
+ config: cfg,
2905
+ agentDir: resolveAgentDir$1(cfg, agentId),
2906
+ provider: settings.provider,
2907
+ remote: settings.remote,
2908
+ model: settings.model,
2909
+ fallback: settings.fallback,
2910
+ local: settings.local
2911
+ }),
2912
+ purpose: params.purpose
2913
+ });
2914
+ INDEX_CACHE.set(key, manager);
2915
+ return manager;
2916
+ }
2917
+ constructor(params) {
2918
+ this.batchFailureCount = 0;
2919
+ this.batchFailureLock = Promise.resolve();
2920
+ this.vectorReady = null;
2921
+ this.watcher = null;
2922
+ this.watchTimer = null;
2923
+ this.sessionWatchTimer = null;
2924
+ this.sessionUnsubscribe = null;
2925
+ this.intervalTimer = null;
2926
+ this.closed = false;
2927
+ this.dirty = false;
2928
+ this.sessionsDirty = false;
2929
+ this.sessionsDirtyFiles = /* @__PURE__ */ new Set();
2930
+ this.sessionPendingFiles = /* @__PURE__ */ new Set();
2931
+ this.sessionDeltas = /* @__PURE__ */ new Map();
2932
+ this.sessionWarm = /* @__PURE__ */ new Set();
2933
+ this.syncing = null;
2934
+ this.cacheKey = params.cacheKey;
2935
+ this.cfg = params.cfg;
2936
+ this.agentId = params.agentId;
2937
+ this.workspaceDir = params.workspaceDir;
2938
+ this.settings = params.settings;
2939
+ this.provider = params.providerResult.provider;
2940
+ this.requestedProvider = params.providerResult.requestedProvider;
2941
+ this.fallbackFrom = params.providerResult.fallbackFrom;
2942
+ this.fallbackReason = params.providerResult.fallbackReason;
2943
+ this.openAi = params.providerResult.openAi;
2944
+ this.gemini = params.providerResult.gemini;
2945
+ this.voyage = params.providerResult.voyage;
2946
+ this.sources = new Set(params.settings.sources);
2947
+ this.db = this.openDatabase();
2948
+ this.providerKey = this.computeProviderKey();
2949
+ this.cache = {
2950
+ enabled: params.settings.cache.enabled,
2951
+ maxEntries: params.settings.cache.maxEntries
2952
+ };
2953
+ this.fts = {
2954
+ enabled: params.settings.query.hybrid.enabled,
2955
+ available: false
2956
+ };
2957
+ this.ensureSchema();
2958
+ this.vector = {
2959
+ enabled: params.settings.store.vector.enabled,
2960
+ available: null,
2961
+ extensionPath: params.settings.store.vector.extensionPath
2962
+ };
2963
+ const meta = this.readMeta();
2964
+ if (meta?.vectorDims) this.vector.dims = meta.vectorDims;
2965
+ this.ensureWatcher();
2966
+ this.ensureSessionListener();
2967
+ this.ensureIntervalSync();
2968
+ const statusOnly = params.purpose === "status";
2969
+ this.dirty = this.sources.has("memory") && (statusOnly ? !meta : true);
2970
+ this.batch = this.resolveBatchConfig();
2971
+ }
2972
+ async warmSession(sessionKey) {
2973
+ if (!this.settings.sync.onSessionStart) return;
2974
+ const key = sessionKey?.trim() || "";
2975
+ if (key && this.sessionWarm.has(key)) return;
2976
+ this.sync({ reason: "session-start" }).catch((err) => {
2977
+ log.warn(`memory sync failed (session-start): ${String(err)}`);
2978
+ });
2979
+ if (key) this.sessionWarm.add(key);
2980
+ }
2981
+ async search(query, opts) {
2982
+ this.warmSession(opts?.sessionKey);
2983
+ if (this.settings.sync.onSearch && (this.dirty || this.sessionsDirty)) this.sync({ reason: "search" }).catch((err) => {
2984
+ log.warn(`memory sync failed (search): ${String(err)}`);
2985
+ });
2986
+ const cleaned = query.trim();
2987
+ if (!cleaned) return [];
2988
+ const minScore = opts?.minScore ?? this.settings.query.minScore;
2989
+ const maxResults = opts?.maxResults ?? this.settings.query.maxResults;
2990
+ const hybrid = this.settings.query.hybrid;
2991
+ const candidates = Math.min(200, Math.max(1, Math.floor(maxResults * hybrid.candidateMultiplier)));
2992
+ const keywordResults = hybrid.enabled ? await this.searchKeyword(cleaned, candidates).catch(() => []) : [];
2993
+ const queryVec = await this.embedQueryWithTimeout(cleaned);
2994
+ const vectorResults = queryVec.some((v) => v !== 0) ? await this.searchVector(queryVec, candidates).catch(() => []) : [];
2995
+ if (!hybrid.enabled) return vectorResults.filter((entry) => entry.score >= minScore).slice(0, maxResults);
2996
+ return this.mergeHybridResults({
2997
+ vector: vectorResults,
2998
+ keyword: keywordResults,
2999
+ vectorWeight: hybrid.vectorWeight,
3000
+ textWeight: hybrid.textWeight
3001
+ }).filter((entry) => entry.score >= minScore).slice(0, maxResults);
3002
+ }
3003
+ async searchVector(queryVec, limit) {
3004
+ return (await searchVector({
3005
+ db: this.db,
3006
+ vectorTable: VECTOR_TABLE,
3007
+ providerModel: this.provider.model,
3008
+ queryVec,
3009
+ limit,
3010
+ snippetMaxChars: SNIPPET_MAX_CHARS,
3011
+ ensureVectorReady: async (dimensions) => await this.ensureVectorReady(dimensions),
3012
+ sourceFilterVec: this.buildSourceFilter("c"),
3013
+ sourceFilterChunks: this.buildSourceFilter()
3014
+ })).map((entry) => entry);
3015
+ }
3016
+ buildFtsQuery(raw) {
3017
+ return buildFtsQuery(raw);
3018
+ }
3019
+ async searchKeyword(query, limit) {
3020
+ if (!this.fts.enabled || !this.fts.available) return [];
3021
+ const sourceFilter = this.buildSourceFilter();
3022
+ return (await searchKeyword({
3023
+ db: this.db,
3024
+ ftsTable: FTS_TABLE,
3025
+ providerModel: this.provider.model,
3026
+ query,
3027
+ limit,
3028
+ snippetMaxChars: SNIPPET_MAX_CHARS,
3029
+ sourceFilter,
3030
+ buildFtsQuery: (raw) => this.buildFtsQuery(raw),
3031
+ bm25RankToScore
3032
+ })).map((entry) => entry);
3033
+ }
3034
+ mergeHybridResults(params) {
3035
+ return mergeHybridResults({
3036
+ vector: params.vector.map((r) => ({
3037
+ id: r.id,
3038
+ path: r.path,
3039
+ startLine: r.startLine,
3040
+ endLine: r.endLine,
3041
+ source: r.source,
3042
+ snippet: r.snippet,
3043
+ vectorScore: r.score
3044
+ })),
3045
+ keyword: params.keyword.map((r) => ({
3046
+ id: r.id,
3047
+ path: r.path,
3048
+ startLine: r.startLine,
3049
+ endLine: r.endLine,
3050
+ source: r.source,
3051
+ snippet: r.snippet,
3052
+ textScore: r.textScore
3053
+ })),
3054
+ vectorWeight: params.vectorWeight,
3055
+ textWeight: params.textWeight
3056
+ }).map((entry) => entry);
3057
+ }
3058
+ async sync(params) {
3059
+ if (this.syncing) return this.syncing;
3060
+ this.syncing = this.runSync(params).finally(() => {
3061
+ this.syncing = null;
3062
+ });
3063
+ return this.syncing ?? Promise.resolve();
3064
+ }
3065
+ async readFile(params) {
3066
+ const rawPath = params.relPath.trim();
3067
+ if (!rawPath) throw new Error("path required");
3068
+ const absPath = path.isAbsolute(rawPath) ? path.resolve(rawPath) : path.resolve(this.workspaceDir, rawPath);
3069
+ const relPath = path.relative(this.workspaceDir, absPath).replace(/\\/g, "/");
3070
+ const allowedWorkspace = relPath.length > 0 && !relPath.startsWith("..") && !path.isAbsolute(relPath) && isMemoryPath(relPath);
3071
+ let allowedAdditional = false;
3072
+ if (!allowedWorkspace && this.settings.extraPaths.length > 0) {
3073
+ const additionalPaths = normalizeExtraMemoryPaths(this.workspaceDir, this.settings.extraPaths);
3074
+ for (const additionalPath of additionalPaths) try {
3075
+ const stat = await fs.lstat(additionalPath);
3076
+ if (stat.isSymbolicLink()) continue;
3077
+ if (stat.isDirectory()) {
3078
+ if (absPath === additionalPath || absPath.startsWith(`${additionalPath}${path.sep}`)) {
3079
+ allowedAdditional = true;
3080
+ break;
3081
+ }
3082
+ continue;
3083
+ }
3084
+ if (stat.isFile()) {
3085
+ if (absPath === additionalPath && absPath.endsWith(".md")) {
3086
+ allowedAdditional = true;
3087
+ break;
3088
+ }
3089
+ }
3090
+ } catch {}
3091
+ }
3092
+ if (!allowedWorkspace && !allowedAdditional) throw new Error("path required");
3093
+ if (!absPath.endsWith(".md")) throw new Error("path required");
3094
+ const stat = await fs.lstat(absPath);
3095
+ if (stat.isSymbolicLink() || !stat.isFile()) throw new Error("path required");
3096
+ const content = await fs.readFile(absPath, "utf-8");
3097
+ if (!params.from && !params.lines) return {
3098
+ text: content,
3099
+ path: relPath
3100
+ };
3101
+ const lines = content.split("\n");
3102
+ const start = Math.max(1, params.from ?? 1);
3103
+ const count = Math.max(1, params.lines ?? lines.length);
3104
+ return {
3105
+ text: lines.slice(start - 1, start - 1 + count).join("\n"),
3106
+ path: relPath
3107
+ };
3108
+ }
3109
+ status() {
3110
+ const sourceFilter = this.buildSourceFilter();
3111
+ const files = this.db.prepare(`SELECT COUNT(*) as c FROM files WHERE 1=1${sourceFilter.sql}`).get(...sourceFilter.params);
3112
+ const chunks = this.db.prepare(`SELECT COUNT(*) as c FROM chunks WHERE 1=1${sourceFilter.sql}`).get(...sourceFilter.params);
3113
+ const sourceCounts = (() => {
3114
+ const sources = Array.from(this.sources);
3115
+ if (sources.length === 0) return [];
3116
+ const bySource = /* @__PURE__ */ new Map();
3117
+ for (const source of sources) bySource.set(source, {
3118
+ files: 0,
3119
+ chunks: 0
3120
+ });
3121
+ const fileRows = this.db.prepare(`SELECT source, COUNT(*) as c FROM files WHERE 1=1${sourceFilter.sql} GROUP BY source`).all(...sourceFilter.params);
3122
+ for (const row of fileRows) {
3123
+ const entry = bySource.get(row.source) ?? {
3124
+ files: 0,
3125
+ chunks: 0
3126
+ };
3127
+ entry.files = row.c ?? 0;
3128
+ bySource.set(row.source, entry);
3129
+ }
3130
+ const chunkRows = this.db.prepare(`SELECT source, COUNT(*) as c FROM chunks WHERE 1=1${sourceFilter.sql} GROUP BY source`).all(...sourceFilter.params);
3131
+ for (const row of chunkRows) {
3132
+ const entry = bySource.get(row.source) ?? {
3133
+ files: 0,
3134
+ chunks: 0
3135
+ };
3136
+ entry.chunks = row.c ?? 0;
3137
+ bySource.set(row.source, entry);
3138
+ }
3139
+ return sources.map((source) => Object.assign({ source }, bySource.get(source)));
3140
+ })();
3141
+ return {
3142
+ backend: "builtin",
3143
+ files: files?.c ?? 0,
3144
+ chunks: chunks?.c ?? 0,
3145
+ dirty: this.dirty || this.sessionsDirty,
3146
+ workspaceDir: this.workspaceDir,
3147
+ dbPath: this.settings.store.path,
3148
+ provider: this.provider.id,
3149
+ model: this.provider.model,
3150
+ requestedProvider: this.requestedProvider,
3151
+ sources: Array.from(this.sources),
3152
+ extraPaths: this.settings.extraPaths,
3153
+ sourceCounts,
3154
+ cache: this.cache.enabled ? {
3155
+ enabled: true,
3156
+ entries: this.db.prepare(`SELECT COUNT(*) as c FROM ${EMBEDDING_CACHE_TABLE}`).get()?.c ?? 0,
3157
+ maxEntries: this.cache.maxEntries
3158
+ } : {
3159
+ enabled: false,
3160
+ maxEntries: this.cache.maxEntries
3161
+ },
3162
+ fts: {
3163
+ enabled: this.fts.enabled,
3164
+ available: this.fts.available,
3165
+ error: this.fts.loadError
3166
+ },
3167
+ fallback: this.fallbackReason ? {
3168
+ from: this.fallbackFrom ?? "local",
3169
+ reason: this.fallbackReason
3170
+ } : void 0,
3171
+ vector: {
3172
+ enabled: this.vector.enabled,
3173
+ available: this.vector.available ?? void 0,
3174
+ extensionPath: this.vector.extensionPath,
3175
+ loadError: this.vector.loadError,
3176
+ dims: this.vector.dims
3177
+ },
3178
+ batch: {
3179
+ enabled: this.batch.enabled,
3180
+ failures: this.batchFailureCount,
3181
+ limit: BATCH_FAILURE_LIMIT,
3182
+ wait: this.batch.wait,
3183
+ concurrency: this.batch.concurrency,
3184
+ pollIntervalMs: this.batch.pollIntervalMs,
3185
+ timeoutMs: this.batch.timeoutMs,
3186
+ lastError: this.batchFailureLastError,
3187
+ lastProvider: this.batchFailureLastProvider
3188
+ }
3189
+ };
3190
+ }
3191
+ async probeVectorAvailability() {
3192
+ if (!this.vector.enabled) return false;
3193
+ return this.ensureVectorReady();
3194
+ }
3195
+ async probeEmbeddingAvailability() {
3196
+ try {
3197
+ await this.embedBatchWithRetry(["ping"]);
3198
+ return { ok: true };
3199
+ } catch (err) {
3200
+ return {
3201
+ ok: false,
3202
+ error: err instanceof Error ? err.message : String(err)
3203
+ };
3204
+ }
3205
+ }
3206
+ async close() {
3207
+ if (this.closed) return;
3208
+ this.closed = true;
3209
+ if (this.watchTimer) {
3210
+ clearTimeout(this.watchTimer);
3211
+ this.watchTimer = null;
3212
+ }
3213
+ if (this.sessionWatchTimer) {
3214
+ clearTimeout(this.sessionWatchTimer);
3215
+ this.sessionWatchTimer = null;
3216
+ }
3217
+ if (this.intervalTimer) {
3218
+ clearInterval(this.intervalTimer);
3219
+ this.intervalTimer = null;
3220
+ }
3221
+ if (this.watcher) {
3222
+ await this.watcher.close();
3223
+ this.watcher = null;
3224
+ }
3225
+ if (this.sessionUnsubscribe) {
3226
+ this.sessionUnsubscribe();
3227
+ this.sessionUnsubscribe = null;
3228
+ }
3229
+ this.db.close();
3230
+ INDEX_CACHE.delete(this.cacheKey);
3231
+ }
3232
+ };
3233
+ function applyPrototypeMixins(target, ...sources) {
3234
+ for (const source of sources) for (const name of Object.getOwnPropertyNames(source)) {
3235
+ if (name === "constructor") continue;
3236
+ const descriptor = Object.getOwnPropertyDescriptor(source, name);
3237
+ if (!descriptor) continue;
3238
+ Object.defineProperty(target, name, descriptor);
3239
+ }
3240
+ }
3241
+ applyPrototypeMixins(MemoryIndexManager.prototype, memoryManagerSyncOps, memoryManagerEmbeddingOps);
3242
+
3243
+ //#endregion
3244
+ export { resolveMemorySearchConfig as n, manager_exports as t };