@remnic/core 1.1.11 → 1.1.13

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 (1462) hide show
  1. package/README.md +3 -3
  2. package/dist/access-cli.d.ts +2 -1
  3. package/dist/access-cli.js +293 -104
  4. package/dist/access-cli.js.map +1 -1
  5. package/dist/access-http.d.ts +31 -62
  6. package/dist/access-http.js +53 -35
  7. package/dist/access-mcp.d.ts +31 -8
  8. package/dist/access-mcp.js +45 -34
  9. package/dist/access-schema.d.ts +197 -14
  10. package/dist/access-schema.js +16 -5
  11. package/dist/access-service-DcCDmNYC.d.ts +1542 -0
  12. package/dist/access-service.d.ts +30 -9
  13. package/dist/access-service.js +42 -32
  14. package/dist/action-confidence.d.ts +83 -0
  15. package/dist/action-confidence.js +22 -0
  16. package/dist/active-memory-bridge.d.ts +1 -1
  17. package/dist/active-memory-bridge.js +2 -2
  18. package/dist/active-recall.d.ts +1 -1
  19. package/dist/active-recall.js +11 -3
  20. package/dist/active-recall.js.map +1 -1
  21. package/dist/adapters/claude-code.d.ts +24 -0
  22. package/dist/adapters/claude-code.js +9 -0
  23. package/dist/adapters/codex.d.ts +25 -0
  24. package/dist/adapters/codex.js +9 -0
  25. package/dist/adapters/hermes.d.ts +35 -0
  26. package/dist/adapters/hermes.js +9 -0
  27. package/dist/adapters/index.d.ts +6 -0
  28. package/dist/adapters/index.js +26 -0
  29. package/dist/adapters/registry.d.ts +20 -0
  30. package/dist/adapters/registry.js +13 -0
  31. package/dist/adapters/replit.d.ts +28 -0
  32. package/dist/adapters/replit.js +9 -0
  33. package/dist/adapters/types.d.ts +43 -0
  34. package/dist/adapters/types.js +8 -0
  35. package/dist/behavior-learner.d.ts +1 -1
  36. package/dist/behavior-signals.d.ts +1 -1
  37. package/dist/bootstrap.d.ts +23 -6
  38. package/dist/boxes.d.ts +7 -0
  39. package/dist/boxes.js +1 -1
  40. package/dist/briefing.d.ts +5 -3
  41. package/dist/briefing.js +10 -7
  42. package/dist/buffer-surprise-report.d.ts +1 -1
  43. package/dist/buffer-surprise-report.js +1 -1
  44. package/dist/buffer.d.ts +18 -4
  45. package/dist/buffer.js +1 -1
  46. package/dist/calibration.d.ts +1 -1
  47. package/dist/calibration.js +6 -6
  48. package/dist/capsule-cli.d.ts +4 -4
  49. package/dist/capsule-cli.js +1 -1
  50. package/dist/capsule-crypto-5CYAGVC5.js +18 -0
  51. package/dist/capsule-merge-4MGKE7C5.js +189 -0
  52. package/dist/causal-behavior.d.ts +9 -29
  53. package/dist/causal-behavior.js +6 -3
  54. package/dist/causal-behavior.js.map +1 -1
  55. package/dist/causal-chain.js +3 -2
  56. package/dist/causal-consolidation.d.ts +2 -2
  57. package/dist/causal-consolidation.js +28 -17
  58. package/dist/causal-consolidation.js.map +1 -1
  59. package/dist/causal-retrieval.js +3 -3
  60. package/dist/causal-trajectory.js +1 -1
  61. package/dist/chunk-25MQ7IHJ.js +427 -0
  62. package/dist/chunk-25MQ7IHJ.js.map +1 -0
  63. package/dist/chunk-2F2W355T.js +256 -0
  64. package/dist/chunk-2F2W355T.js.map +1 -0
  65. package/dist/chunk-2KI4QFHU.js +228 -0
  66. package/dist/chunk-2KI4QFHU.js.map +1 -0
  67. package/dist/chunk-2PRQG7PV.js +86 -0
  68. package/dist/chunk-2PRQG7PV.js.map +1 -0
  69. package/dist/chunk-2QR3XXIC.js +2272 -0
  70. package/dist/chunk-2QR3XXIC.js.map +1 -0
  71. package/dist/chunk-2WWLHTZY.js +121 -0
  72. package/dist/chunk-326G7DJK.js +2185 -0
  73. package/dist/chunk-326G7DJK.js.map +1 -0
  74. package/dist/chunk-34DQE4KF.js +174 -0
  75. package/dist/chunk-34DQE4KF.js.map +1 -0
  76. package/dist/chunk-3APJ5EVB.js +601 -0
  77. package/dist/chunk-3APJ5EVB.js.map +1 -0
  78. package/dist/chunk-3HPAPHUK.js +51 -0
  79. package/dist/chunk-3HPAPHUK.js.map +1 -0
  80. package/dist/chunk-3JXBXXM2.js +69 -0
  81. package/dist/chunk-3JXBXXM2.js.map +1 -0
  82. package/dist/chunk-3KW65B36.js +681 -0
  83. package/dist/chunk-3KW65B36.js.map +1 -0
  84. package/dist/chunk-3UXOZBHV.js +20 -0
  85. package/dist/chunk-3UXOZBHV.js.map +1 -0
  86. package/dist/chunk-3VAL7ZL2.js +266 -0
  87. package/dist/chunk-3VAL7ZL2.js.map +1 -0
  88. package/dist/chunk-3Y4P7RXM.js +31 -0
  89. package/dist/chunk-3Y4P7RXM.js.map +1 -0
  90. package/dist/chunk-47VWKCAF.js +273 -0
  91. package/dist/chunk-47VWKCAF.js.map +1 -0
  92. package/dist/chunk-4CRG46BG.js +271 -0
  93. package/dist/chunk-4RA3C3EV.js +60 -0
  94. package/dist/chunk-4RA3C3EV.js.map +1 -0
  95. package/dist/chunk-5375UYTQ.js +914 -0
  96. package/dist/chunk-5375UYTQ.js.map +1 -0
  97. package/dist/chunk-56K5QLHX.js +506 -0
  98. package/dist/chunk-56K5QLHX.js.map +1 -0
  99. package/dist/chunk-5NXIJZFX.js +180 -0
  100. package/dist/chunk-5NXIJZFX.js.map +1 -0
  101. package/dist/chunk-5RGLBDQF.js +596 -0
  102. package/dist/chunk-5RGLBDQF.js.map +1 -0
  103. package/dist/chunk-5UZXUTVO.js +9 -0
  104. package/dist/chunk-5UZXUTVO.js.map +1 -0
  105. package/dist/chunk-65PG43EQ.js +105 -0
  106. package/dist/chunk-65PG43EQ.js.map +1 -0
  107. package/dist/chunk-66DHUKLO.js +57 -0
  108. package/dist/chunk-66DHUKLO.js.map +1 -0
  109. package/dist/chunk-6FC5EGNV.js +46 -0
  110. package/dist/chunk-6FC5EGNV.js.map +1 -0
  111. package/dist/chunk-6H2TESSP.js +62 -0
  112. package/dist/chunk-6H2TESSP.js.map +1 -0
  113. package/dist/chunk-6LVVDPJ4.js +32 -0
  114. package/dist/chunk-6LVVDPJ4.js.map +1 -0
  115. package/dist/chunk-6NKAQ74D.js +2237 -0
  116. package/dist/chunk-6NKAQ74D.js.map +1 -0
  117. package/dist/chunk-6RVI47ZR.js +159 -0
  118. package/dist/chunk-6RVI47ZR.js.map +1 -0
  119. package/dist/chunk-7AAT6G4Q.js +5117 -0
  120. package/dist/chunk-7AAT6G4Q.js.map +1 -0
  121. package/dist/chunk-7DTASS5T.js +29 -0
  122. package/dist/chunk-7DTASS5T.js.map +1 -0
  123. package/dist/chunk-7IASACLB.js +596 -0
  124. package/dist/chunk-7MNMYOFP.js +32 -0
  125. package/dist/chunk-7MNMYOFP.js.map +1 -0
  126. package/dist/chunk-7N4KAIGN.js +133 -0
  127. package/dist/chunk-7N4KAIGN.js.map +1 -0
  128. package/dist/chunk-7OZ53EXP.js +101 -0
  129. package/dist/chunk-7OZ53EXP.js.map +1 -0
  130. package/dist/chunk-7XYTQGCC.js +134 -0
  131. package/dist/chunk-7XYTQGCC.js.map +1 -0
  132. package/dist/chunk-A2XUIMJ3.js +341 -0
  133. package/dist/chunk-A2XUIMJ3.js.map +1 -0
  134. package/dist/chunk-AC5LO7IU.js +308 -0
  135. package/dist/chunk-AC5LO7IU.js.map +1 -0
  136. package/dist/chunk-AGZQD76C.js +201 -0
  137. package/dist/chunk-AGZQD76C.js.map +1 -0
  138. package/dist/chunk-AH2JUU6X.js +336 -0
  139. package/dist/chunk-AH2JUU6X.js.map +1 -0
  140. package/dist/chunk-APO3DCMU.js +361 -0
  141. package/dist/chunk-APO3DCMU.js.map +1 -0
  142. package/dist/chunk-BFBF3XEF.js +283 -0
  143. package/dist/chunk-BFBF3XEF.js.map +1 -0
  144. package/dist/chunk-BJ3KMYTB.js +1974 -0
  145. package/dist/chunk-BJ3KMYTB.js.map +1 -0
  146. package/dist/chunk-C5BCH4ZS.js +317 -0
  147. package/dist/chunk-C5BCH4ZS.js.map +1 -0
  148. package/dist/chunk-CHEL3SKB.js +6758 -0
  149. package/dist/chunk-CHEL3SKB.js.map +1 -0
  150. package/dist/chunk-CQZRLNMV.js +1491 -0
  151. package/dist/chunk-CQZRLNMV.js.map +1 -0
  152. package/dist/chunk-D46YSIYX.js +892 -0
  153. package/dist/chunk-D46YSIYX.js.map +1 -0
  154. package/dist/chunk-DB5A3NHS.js +906 -0
  155. package/dist/chunk-DB5A3NHS.js.map +1 -0
  156. package/dist/chunk-DINWEURR.js +648 -0
  157. package/dist/chunk-DINWEURR.js.map +1 -0
  158. package/dist/chunk-DK5LDEQM.js +530 -0
  159. package/dist/chunk-DK5LDEQM.js.map +1 -0
  160. package/dist/chunk-DOM4GKSW.js +34 -0
  161. package/dist/chunk-DOM4GKSW.js.map +1 -0
  162. package/dist/chunk-EDTHC6UD.js +1075 -0
  163. package/dist/chunk-EDTHC6UD.js.map +1 -0
  164. package/dist/chunk-EFJ3MQ4V.js +721 -0
  165. package/dist/chunk-EHRTFRWW.js +89 -0
  166. package/dist/chunk-EHRTFRWW.js.map +1 -0
  167. package/dist/chunk-FAJ7FZYM.js +11 -0
  168. package/dist/chunk-FAJ7FZYM.js.map +1 -0
  169. package/dist/chunk-FBYESMQ2.js +570 -0
  170. package/dist/chunk-FBYESMQ2.js.map +1 -0
  171. package/dist/chunk-FDU6HUUL.js +147 -0
  172. package/dist/chunk-FF4KLI5W.js +99 -0
  173. package/dist/chunk-FF4KLI5W.js.map +1 -0
  174. package/dist/chunk-FIT6DMX6.js +310 -0
  175. package/dist/chunk-FIT6DMX6.js.map +1 -0
  176. package/dist/chunk-FJ43PRLT.js +272 -0
  177. package/dist/chunk-FJ43PRLT.js.map +1 -0
  178. package/dist/chunk-FKFMOY3N.js +32 -0
  179. package/dist/chunk-FKFMOY3N.js.map +1 -0
  180. package/dist/chunk-FLTNHQK6.js +262 -0
  181. package/dist/chunk-FLTNHQK6.js.map +1 -0
  182. package/dist/chunk-GA454ALV.js +12436 -0
  183. package/dist/chunk-GA454ALV.js.map +1 -0
  184. package/dist/chunk-GGKRUQOO.js +228 -0
  185. package/dist/chunk-GIF42EW3.js +63 -0
  186. package/dist/chunk-GIF42EW3.js.map +1 -0
  187. package/dist/chunk-GL6I6MEQ.js +647 -0
  188. package/dist/chunk-H3ME6L6D.js +709 -0
  189. package/dist/chunk-H3ME6L6D.js.map +1 -0
  190. package/dist/chunk-HHLLAQGZ.js +1 -0
  191. package/dist/chunk-HXXBL2KD.js +2040 -0
  192. package/dist/chunk-I5V2VDIW.js +219 -0
  193. package/dist/chunk-I5V2VDIW.js.map +1 -0
  194. package/dist/chunk-I6K5FBRQ.js +35 -0
  195. package/dist/chunk-I6K5FBRQ.js.map +1 -0
  196. package/dist/chunk-ICRIXAP2.js +121 -0
  197. package/dist/chunk-ICRIXAP2.js.map +1 -0
  198. package/dist/chunk-J4EB7DNW.js +11 -0
  199. package/dist/chunk-J4EB7DNW.js.map +1 -0
  200. package/dist/chunk-JLFA7DQG.js +62 -0
  201. package/dist/chunk-JLFA7DQG.js.map +1 -0
  202. package/dist/chunk-KJTKLXTH.js +9 -0
  203. package/dist/chunk-KJTKLXTH.js.map +1 -0
  204. package/dist/chunk-KLAO5DGL.js +917 -0
  205. package/dist/chunk-KLAO5DGL.js.map +1 -0
  206. package/dist/chunk-KNKUID7G.js +183 -0
  207. package/dist/chunk-KOSORCJG.js +624 -0
  208. package/dist/chunk-KOSORCJG.js.map +1 -0
  209. package/dist/chunk-KUJVMMZQ.js +1262 -0
  210. package/dist/chunk-KUJVMMZQ.js.map +1 -0
  211. package/dist/chunk-LCR46JY5.js +123 -0
  212. package/dist/chunk-LCR46JY5.js.map +1 -0
  213. package/dist/chunk-LLQ2LLWF.js +148 -0
  214. package/dist/chunk-LLQ2LLWF.js.map +1 -0
  215. package/dist/chunk-LPMVBPA3.js +236 -0
  216. package/dist/chunk-LT3NLYSI.js +50 -0
  217. package/dist/chunk-LT3NLYSI.js.map +1 -0
  218. package/dist/chunk-LUDTDZLK.js +287 -0
  219. package/dist/chunk-LUDTDZLK.js.map +1 -0
  220. package/dist/chunk-M23FSH32.js +3963 -0
  221. package/dist/chunk-M23FSH32.js.map +1 -0
  222. package/dist/chunk-MC26UJIM.js +118 -0
  223. package/dist/chunk-ME6ESPZU.js +119 -0
  224. package/dist/chunk-ME6ESPZU.js.map +1 -0
  225. package/dist/chunk-MGKYQQYF.js +272 -0
  226. package/dist/chunk-MGKYQQYF.js.map +1 -0
  227. package/dist/chunk-MJFNCJXV.js +66 -0
  228. package/dist/chunk-MJFNCJXV.js.map +1 -0
  229. package/dist/chunk-MSWG7JI6.js +237 -0
  230. package/dist/chunk-MSWG7JI6.js.map +1 -0
  231. package/dist/chunk-MT25YHYH.js +141 -0
  232. package/dist/chunk-MT25YHYH.js.map +1 -0
  233. package/dist/chunk-MT4HVDUZ.js +53 -0
  234. package/dist/chunk-MY6TPVXW.js +219 -0
  235. package/dist/chunk-N2D6GXBM.js +267 -0
  236. package/dist/chunk-N2D6GXBM.js.map +1 -0
  237. package/dist/chunk-NJ3MJQZX.js +46 -0
  238. package/dist/chunk-NJ3MJQZX.js.map +1 -0
  239. package/dist/chunk-NMZY542O.js +335 -0
  240. package/dist/chunk-NMZY542O.js.map +1 -0
  241. package/dist/chunk-NNVTUXEB.js +23 -0
  242. package/dist/chunk-NZL6GGQE.js +375 -0
  243. package/dist/chunk-NZL6GGQE.js.map +1 -0
  244. package/dist/chunk-OAZ5MFUB.js +4124 -0
  245. package/dist/chunk-OAZ5MFUB.js.map +1 -0
  246. package/dist/chunk-OIGNEXKZ.js +237 -0
  247. package/dist/chunk-OIGNEXKZ.js.map +1 -0
  248. package/dist/chunk-OZKZ2TRP.js +3729 -0
  249. package/dist/chunk-OZKZ2TRP.js.map +1 -0
  250. package/dist/chunk-P4NEIHUT.js +108 -0
  251. package/dist/chunk-P7FMDTKL.js +103 -0
  252. package/dist/chunk-P7FMDTKL.js.map +1 -0
  253. package/dist/chunk-PD6O7AXF.js +110 -0
  254. package/dist/chunk-PD6O7AXF.js.map +1 -0
  255. package/dist/chunk-PHK3HARR.js +32 -0
  256. package/dist/chunk-PHK3HARR.js.map +1 -0
  257. package/dist/chunk-PIRJPV5T.js +98 -0
  258. package/dist/chunk-PIRJPV5T.js.map +1 -0
  259. package/dist/chunk-PK7H5L6Y.js +159 -0
  260. package/dist/chunk-PK7H5L6Y.js.map +1 -0
  261. package/dist/chunk-PR5FBTFU.js +233 -0
  262. package/dist/chunk-PR5FBTFU.js.map +1 -0
  263. package/dist/chunk-PU63GXWS.js +174 -0
  264. package/dist/chunk-PU63GXWS.js.map +1 -0
  265. package/dist/chunk-PYPOFEMK.js +294 -0
  266. package/dist/chunk-PYPOFEMK.js.map +1 -0
  267. package/dist/chunk-PZIAX57I.js +124 -0
  268. package/dist/chunk-PZIAX57I.js.map +1 -0
  269. package/dist/chunk-Q7P4WJDP.js +26 -0
  270. package/dist/chunk-Q7P4WJDP.js.map +1 -0
  271. package/dist/chunk-QDZ2RLEC.js +908 -0
  272. package/dist/chunk-QDZ2RLEC.js.map +1 -0
  273. package/dist/chunk-QQUAB63I.js +63 -0
  274. package/dist/chunk-QQUAB63I.js.map +1 -0
  275. package/dist/chunk-QRNI5JBH.js +18 -0
  276. package/dist/chunk-RHY3HH7P.js +601 -0
  277. package/dist/chunk-RHY3HH7P.js.map +1 -0
  278. package/dist/chunk-RK6F44Y6.js +84 -0
  279. package/dist/chunk-RK6F44Y6.js.map +1 -0
  280. package/dist/chunk-RRF5UOBJ.js +91 -0
  281. package/dist/chunk-RXDLTSWT.js +124 -0
  282. package/dist/chunk-RXDLTSWT.js.map +1 -0
  283. package/dist/chunk-RYED3SPJ.js +42 -0
  284. package/dist/chunk-RYED3SPJ.js.map +1 -0
  285. package/dist/chunk-S7KDBTWT.js +106 -0
  286. package/dist/chunk-S7KDBTWT.js.map +1 -0
  287. package/dist/chunk-SEDEKFYQ.js +1 -0
  288. package/dist/chunk-SOAU2OE2.js +125 -0
  289. package/dist/chunk-SOAU2OE2.js.map +1 -0
  290. package/dist/chunk-TECVW3JP.js +36 -0
  291. package/dist/chunk-TECVW3JP.js.map +1 -0
  292. package/dist/chunk-TFO23QT4.js +88 -0
  293. package/dist/chunk-TFO23QT4.js.map +1 -0
  294. package/dist/chunk-TK4UEOSK.js +76 -0
  295. package/dist/chunk-TK4UEOSK.js.map +1 -0
  296. package/dist/chunk-TKWGAOLV.js +122 -0
  297. package/dist/chunk-TKWGAOLV.js.map +1 -0
  298. package/dist/chunk-TMM4S4IJ.js +597 -0
  299. package/dist/chunk-TMM4S4IJ.js.map +1 -0
  300. package/dist/chunk-TMQLARTH.js +188 -0
  301. package/dist/chunk-TMQLARTH.js.map +1 -0
  302. package/dist/chunk-TPDBFYEG.js +130 -0
  303. package/dist/chunk-TPDBFYEG.js.map +1 -0
  304. package/dist/chunk-TPMQ3G6Z.js +145 -0
  305. package/dist/chunk-TPMQ3G6Z.js.map +1 -0
  306. package/dist/chunk-TZOLIGIG.js +61 -0
  307. package/dist/chunk-TZOLIGIG.js.map +1 -0
  308. package/dist/chunk-U3PN77QT.js +113 -0
  309. package/dist/chunk-U3WSW6PZ.js +277 -0
  310. package/dist/chunk-U4SCL7B7.js +640 -0
  311. package/dist/chunk-U4SCL7B7.js.map +1 -0
  312. package/dist/chunk-UWK5OXUJ.js +156 -0
  313. package/dist/chunk-UWK5OXUJ.js.map +1 -0
  314. package/dist/chunk-UWVJF25J.js +74 -0
  315. package/dist/chunk-UXHQAFNA.js +1317 -0
  316. package/dist/chunk-UXHQAFNA.js.map +1 -0
  317. package/dist/chunk-V5OCT34X.js +1 -0
  318. package/dist/chunk-V5OCT34X.js.map +1 -0
  319. package/dist/chunk-VLXA6PI2.js +304 -0
  320. package/dist/chunk-VLXA6PI2.js.map +1 -0
  321. package/dist/chunk-VNO6ZJ35.js +500 -0
  322. package/dist/chunk-VNO6ZJ35.js.map +1 -0
  323. package/dist/chunk-VW676BEI.js +827 -0
  324. package/dist/chunk-VW676BEI.js.map +1 -0
  325. package/dist/chunk-VWT3F4IV.js +2161 -0
  326. package/dist/chunk-VWT3F4IV.js.map +1 -0
  327. package/dist/chunk-W3LR522O.js +2296 -0
  328. package/dist/chunk-W3LR522O.js.map +1 -0
  329. package/dist/chunk-W4L6CZKA.js +96 -0
  330. package/dist/chunk-W4L6CZKA.js.map +1 -0
  331. package/dist/chunk-W4RVMTHR.js +372 -0
  332. package/dist/chunk-W4RVMTHR.js.map +1 -0
  333. package/dist/chunk-WEHSQBFR.js +188 -0
  334. package/dist/chunk-WEHSQBFR.js.map +1 -0
  335. package/dist/chunk-WELDCG6C.js +380 -0
  336. package/dist/chunk-WELDCG6C.js.map +1 -0
  337. package/dist/chunk-WZYKANL3.js +2800 -0
  338. package/dist/chunk-WZYKANL3.js.map +1 -0
  339. package/dist/chunk-XIG5PDM7.js +48 -0
  340. package/dist/chunk-XJNBEDFE.js +193 -0
  341. package/dist/chunk-XJNBEDFE.js.map +1 -0
  342. package/dist/chunk-XVVIG67A.js +291 -0
  343. package/dist/chunk-XVVIG67A.js.map +1 -0
  344. package/dist/chunk-XVZ7B3HG.js +135 -0
  345. package/dist/chunk-YBPYIAA5.js +73 -0
  346. package/dist/chunk-YBPYIAA5.js.map +1 -0
  347. package/dist/chunk-Z734BLO3.js +21 -0
  348. package/dist/chunk-Z734BLO3.js.map +1 -0
  349. package/dist/chunk-ZKSK55RC.js +269 -0
  350. package/dist/chunk-ZKSK55RC.js.map +1 -0
  351. package/dist/chunk-ZTFCYYEZ.js +69 -0
  352. package/dist/chunk-ZTFCYYEZ.js.map +1 -0
  353. package/dist/chunk-ZY2MNJR6.js +329 -0
  354. package/dist/chunk-ZY2MNJR6.js.map +1 -0
  355. package/dist/cli-D3VpkVwB.d.ts +1136 -0
  356. package/dist/cli.d.ts +42 -10
  357. package/dist/cli.js +121 -58
  358. package/dist/codex-cli-fallback.d.ts +1 -0
  359. package/dist/codex-cli-fallback.js +1 -1
  360. package/dist/commitment-ledger.js +1 -1
  361. package/dist/compat/checks.d.ts +5 -0
  362. package/dist/compat/checks.js +11 -0
  363. package/dist/compat/checks.js.map +1 -0
  364. package/dist/compat/types.d.ts +30 -0
  365. package/dist/compat/types.js +1 -0
  366. package/dist/compat/types.js.map +1 -0
  367. package/dist/compounding/engine.d.ts +221 -0
  368. package/dist/compounding/engine.js +32 -0
  369. package/dist/compounding/engine.js.map +1 -0
  370. package/dist/compounding/preference-consolidator.d.ts +92 -0
  371. package/dist/compounding/preference-consolidator.js +553 -0
  372. package/dist/compounding/preference-consolidator.js.map +1 -0
  373. package/dist/compression-optimizer.d.ts +1 -1
  374. package/dist/config.d.ts +5 -3
  375. package/dist/config.js +9 -4
  376. package/dist/conflict-policy-DyJ2wd-h.d.ts +4 -0
  377. package/dist/connectors/codex-materialize-runner.d.ts +64 -0
  378. package/dist/connectors/codex-materialize-runner.js +33 -0
  379. package/dist/connectors/codex-materialize-runner.js.map +1 -0
  380. package/dist/connectors/codex-materialize.d.ts +195 -0
  381. package/dist/connectors/codex-materialize.js +38 -0
  382. package/dist/connectors/codex-materialize.js.map +1 -0
  383. package/dist/connectors/index.d.ts +444 -0
  384. package/dist/connectors/index.js +115 -0
  385. package/dist/connectors/index.js.map +1 -0
  386. package/dist/connectors-cli-CwbyjGR7.d.ts +257 -0
  387. package/dist/connectors-cli.d.ts +1 -1
  388. package/dist/consolidation-provenance-check.d.ts +4 -2
  389. package/dist/consolidation-undo.d.ts +4 -2
  390. package/dist/contradiction/index.d.ts +258 -0
  391. package/dist/contradiction/index.js +43 -0
  392. package/dist/contradiction/index.js.map +1 -0
  393. package/dist/contradiction-review-ATP4S6IC.js +30 -0
  394. package/dist/contradiction-review-ATP4S6IC.js.map +1 -0
  395. package/dist/contradiction-scan-5A4IDZV5.js +13 -0
  396. package/dist/contradiction-scan-5A4IDZV5.js.map +1 -0
  397. package/dist/conversation-index/backend.d.ts +97 -0
  398. package/dist/conversation-index/backend.js +13 -0
  399. package/dist/conversation-index/backend.js.map +1 -0
  400. package/dist/conversation-index/chunker.d.ts +16 -0
  401. package/dist/conversation-index/chunker.js +8 -0
  402. package/dist/conversation-index/chunker.js.map +1 -0
  403. package/dist/conversation-index/cleanup.d.ts +11 -0
  404. package/dist/conversation-index/cleanup.js +9 -0
  405. package/dist/conversation-index/cleanup.js.map +1 -0
  406. package/dist/conversation-index/faiss-adapter.d.ts +6 -0
  407. package/dist/conversation-index/faiss-adapter.js +16 -0
  408. package/dist/conversation-index/faiss-adapter.js.map +1 -0
  409. package/dist/conversation-index/indexer.d.ts +23 -0
  410. package/dist/conversation-index/indexer.js +15 -0
  411. package/dist/conversation-index/indexer.js.map +1 -0
  412. package/dist/conversation-index/search.d.ts +6 -0
  413. package/dist/conversation-index/search.js +11 -0
  414. package/dist/conversation-index/search.js.map +1 -0
  415. package/dist/day-summary.d.ts +1 -1
  416. package/dist/delinearize.d.ts +1 -1
  417. package/dist/direct-answer-wiring.d.ts +1 -1
  418. package/dist/direct-answer-wiring.js +1 -1
  419. package/dist/direct-answer.d.ts +1 -1
  420. package/dist/embedding-fallback.d.ts +1 -1
  421. package/dist/embedding-fallback.js +2 -2
  422. package/dist/enrichment/index.d.ts +163 -0
  423. package/dist/enrichment/index.js +18 -0
  424. package/dist/enrichment/index.js.map +1 -0
  425. package/dist/entity-retrieval.d.ts +4 -2
  426. package/dist/entity-retrieval.js +9 -6
  427. package/dist/entity-schema.d.ts +1 -1
  428. package/dist/evals.js +1 -1
  429. package/dist/event-order-recall.d.ts +17 -0
  430. package/dist/event-order-recall.js +11 -0
  431. package/dist/event-order-recall.js.map +1 -0
  432. package/dist/evidence-pack.d.ts +3 -1
  433. package/dist/evidence-pack.js +5 -3
  434. package/dist/explicit-capture.d.ts +23 -6
  435. package/dist/explicit-capture.js +2 -2
  436. package/dist/explicit-cue-recall.d.ts +4 -1
  437. package/dist/explicit-cue-recall.js +4 -2
  438. package/dist/extraction-judge-telemetry.d.ts +1 -1
  439. package/dist/extraction-judge-training.d.ts +1 -1
  440. package/dist/extraction-judge-training.js +1 -1
  441. package/dist/extraction-judge.d.ts +1 -1
  442. package/dist/extraction.d.ts +1 -1
  443. package/dist/extraction.js +11 -10
  444. package/dist/faiss-adapter-CzPghc4C.d.ts +70 -0
  445. package/dist/fallback-llm.d.ts +4 -1
  446. package/dist/fallback-llm.js +6 -6
  447. package/dist/focused-list-recall.d.ts +17 -0
  448. package/dist/focused-list-recall.js +11 -0
  449. package/dist/focused-list-recall.js.map +1 -0
  450. package/dist/graph-edge-decay-5DI5GUNL.js +207 -0
  451. package/dist/identity-continuity.d.ts +1 -1
  452. package/dist/importance.d.ts +1 -1
  453. package/dist/index-DJ9QWMw-.d.ts +35 -0
  454. package/dist/index.d.ts +107 -715
  455. package/dist/index.js +657 -2611
  456. package/dist/index.js.map +1 -1
  457. package/dist/intent.d.ts +1 -1
  458. package/dist/intent.js +1 -1
  459. package/dist/lcm/archive.d.ts +89 -0
  460. package/dist/lcm/archive.js +12 -0
  461. package/dist/lcm/archive.js.map +1 -0
  462. package/dist/lcm/dag.d.ts +48 -0
  463. package/dist/lcm/dag.js +8 -0
  464. package/dist/lcm/dag.js.map +1 -0
  465. package/dist/lcm/engine.d.ts +116 -0
  466. package/dist/lcm/engine.js +20 -0
  467. package/dist/lcm/engine.js.map +1 -0
  468. package/dist/lcm/index.d.ts +12 -0
  469. package/dist/lcm/index.js +44 -0
  470. package/dist/lcm/index.js.map +1 -0
  471. package/dist/lcm/queue.d.ts +62 -0
  472. package/dist/lcm/queue.js +8 -0
  473. package/dist/lcm/queue.js.map +1 -0
  474. package/dist/lcm/recall.d.ts +20 -0
  475. package/dist/lcm/recall.js +8 -0
  476. package/dist/lcm/recall.js.map +1 -0
  477. package/dist/lcm/schema.d.ts +16 -0
  478. package/dist/lcm/schema.js +14 -0
  479. package/dist/lcm/schema.js.map +1 -0
  480. package/dist/lcm/summarizer.d.ts +38 -0
  481. package/dist/lcm/summarizer.js +12 -0
  482. package/dist/lcm/summarizer.js.map +1 -0
  483. package/dist/lcm/tools.d.ts +29 -0
  484. package/dist/lcm/tools.js +8 -0
  485. package/dist/lcm/tools.js.map +1 -0
  486. package/dist/lifecycle.d.ts +1 -1
  487. package/dist/live-connectors-runner.d.ts +1 -1
  488. package/dist/live-connectors-runner.js +5 -5
  489. package/dist/local-llm.d.ts +8 -4
  490. package/dist/local-llm.js +3 -3
  491. package/dist/maintenance/archive-observations.d.ts +18 -0
  492. package/dist/maintenance/archive-observations.js +8 -0
  493. package/dist/maintenance/archive-observations.js.map +1 -0
  494. package/dist/maintenance/backup-stamp.d.ts +3 -0
  495. package/dist/maintenance/backup-stamp.js +8 -0
  496. package/dist/maintenance/backup-stamp.js.map +1 -0
  497. package/dist/maintenance/memory-governance-cron.d.ts +85 -0
  498. package/dist/maintenance/memory-governance-cron.js +22 -0
  499. package/dist/maintenance/memory-governance-cron.js.map +1 -0
  500. package/dist/maintenance/memory-governance.d.ts +137 -0
  501. package/dist/maintenance/memory-governance.js +40 -0
  502. package/dist/maintenance/memory-governance.js.map +1 -0
  503. package/dist/maintenance/migrate-observations.d.ts +18 -0
  504. package/dist/maintenance/migrate-observations.js +9 -0
  505. package/dist/maintenance/migrate-observations.js.map +1 -0
  506. package/dist/maintenance/observation-ledger-utils.d.ts +10 -0
  507. package/dist/maintenance/observation-ledger-utils.js +10 -0
  508. package/dist/maintenance/observation-ledger-utils.js.map +1 -0
  509. package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +15 -0
  510. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +28 -0
  511. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js.map +1 -0
  512. package/dist/maintenance/rebuild-memory-projection.d.ts +77 -0
  513. package/dist/maintenance/rebuild-memory-projection.js +35 -0
  514. package/dist/maintenance/rebuild-memory-projection.js.map +1 -0
  515. package/dist/maintenance/rebuild-observations.d.ts +17 -0
  516. package/dist/maintenance/rebuild-observations.js +9 -0
  517. package/dist/maintenance/rebuild-observations.js.map +1 -0
  518. package/dist/mcp-memory-inspector-app.d.ts +124 -0
  519. package/dist/mcp-memory-inspector-app.js +20 -0
  520. package/dist/mcp-memory-inspector-app.js.map +1 -0
  521. package/dist/memory-action-policy.d.ts +1 -1
  522. package/dist/memory-cache.d.ts +1 -1
  523. package/dist/memory-lifecycle-ledger-utils.d.ts +1 -1
  524. package/dist/memory-projection-store.d.ts +108 -3
  525. package/dist/memory-projection-store.js +2 -1
  526. package/dist/memory-provenance.d.ts +57 -0
  527. package/dist/memory-provenance.js +13 -0
  528. package/dist/memory-provenance.js.map +1 -0
  529. package/dist/memory-worth-outcomes.d.ts +4 -2
  530. package/dist/migrate/from-engram.d.ts +24 -0
  531. package/dist/migrate/from-engram.js +12 -0
  532. package/dist/migrate/from-engram.js.map +1 -0
  533. package/dist/models-json.d.ts +1 -1
  534. package/dist/namespaces/migrate.d.ts +50 -0
  535. package/dist/namespaces/migrate.js +50 -0
  536. package/dist/namespaces/migrate.js.map +1 -0
  537. package/dist/namespaces/principal.d.ts +17 -0
  538. package/dist/namespaces/principal.js +16 -0
  539. package/dist/namespaces/principal.js.map +1 -0
  540. package/dist/namespaces/search.d.ts +46 -0
  541. package/dist/namespaces/search.js +28 -0
  542. package/dist/namespaces/search.js.map +1 -0
  543. package/dist/namespaces/storage.d.ts +32 -0
  544. package/dist/namespaces/storage.js +28 -0
  545. package/dist/namespaces/storage.js.map +1 -0
  546. package/dist/native-knowledge.d.ts +1 -1
  547. package/dist/network/tailscale.d.ts +41 -0
  548. package/dist/network/tailscale.js +9 -0
  549. package/dist/network/tailscale.js.map +1 -0
  550. package/dist/network/webdav.d.ts +39 -0
  551. package/dist/network/webdav.js +10 -0
  552. package/dist/network/webdav.js.map +1 -0
  553. package/dist/objective-state-writers.d.ts +1 -1
  554. package/dist/objective-state-writers.js +2 -2
  555. package/dist/operator-toolkit.d.ts +4 -2
  556. package/dist/operator-toolkit.js +35 -17
  557. package/dist/opik-exporter.js +2 -2
  558. package/dist/opik-exporter.js.map +1 -1
  559. package/dist/orchestrator-DuWl9Hwx.d.ts +1244 -0
  560. package/dist/orchestrator.d.ts +24 -7
  561. package/dist/orchestrator.js +107 -65
  562. package/dist/path-MR5JPYOP.js +9 -0
  563. package/dist/path-MR5JPYOP.js.map +1 -0
  564. package/dist/patterns-cli.d.ts +1 -1
  565. package/dist/policy-runtime.d.ts +1 -1
  566. package/dist/qmd-recall-cache.d.ts +2 -2
  567. package/dist/qmd.d.ts +103 -4
  568. package/dist/qmd.js +23 -5
  569. package/dist/recall-disclosure-escalation.d.ts +1 -1
  570. package/dist/recall-explain-renderer.d.ts +3 -1
  571. package/dist/recall-explain-renderer.js +5 -3
  572. package/dist/recall-state.d.ts +1 -1
  573. package/dist/recall-tag-filter.d.ts +3 -1
  574. package/dist/recall-xray-cli.d.ts +3 -1
  575. package/dist/recall-xray-cli.js +6 -4
  576. package/dist/recall-xray-renderer.d.ts +3 -1
  577. package/dist/recall-xray-renderer.js +5 -3
  578. package/dist/recall-xray.d.ts +8 -1
  579. package/dist/recall-xray.js +4 -2
  580. package/dist/replay/normalizers/chatgpt.d.ts +6 -0
  581. package/dist/replay/normalizers/chatgpt.js +11 -0
  582. package/dist/replay/normalizers/chatgpt.js.map +1 -0
  583. package/dist/replay/normalizers/claude.d.ts +6 -0
  584. package/dist/replay/normalizers/claude.js +11 -0
  585. package/dist/replay/normalizers/claude.js.map +1 -0
  586. package/dist/replay/normalizers/openclaw.d.ts +6 -0
  587. package/dist/replay/normalizers/openclaw.js +11 -0
  588. package/dist/replay/normalizers/openclaw.js.map +1 -0
  589. package/dist/replay/normalizers/shared.d.ts +16 -0
  590. package/dist/replay/normalizers/shared.js +14 -0
  591. package/dist/replay/normalizers/shared.js.map +1 -0
  592. package/dist/replay/runner.d.ts +35 -0
  593. package/dist/replay/runner.js +16 -0
  594. package/dist/replay/runner.js.map +1 -0
  595. package/dist/replay/types.d.ts +57 -0
  596. package/dist/replay/types.js +19 -0
  597. package/dist/replay/types.js.map +1 -0
  598. package/dist/resolution-B7FNQSSP.js +12 -0
  599. package/dist/resolution-B7FNQSSP.js.map +1 -0
  600. package/dist/resolve-auth-token.d.ts +1 -1
  601. package/dist/resolve-provider-secret.js +2 -2
  602. package/dist/response-guidance-recall.d.ts +18 -0
  603. package/dist/response-guidance-recall.js +11 -0
  604. package/dist/response-guidance-recall.js.map +1 -0
  605. package/dist/resume-bundles.js +7 -5
  606. package/dist/retrieval-agents.d.ts +2 -2
  607. package/dist/retrieval-tiers.d.ts +1 -1
  608. package/dist/routing/engine.d.ts +35 -0
  609. package/dist/routing/engine.js +16 -0
  610. package/dist/routing/engine.js.map +1 -0
  611. package/dist/routing/store.d.ts +27 -0
  612. package/dist/routing/store.js +10 -0
  613. package/dist/routing/store.js.map +1 -0
  614. package/dist/runtime/better-sqlite.d.ts +8 -0
  615. package/dist/runtime/better-sqlite.js +10 -0
  616. package/dist/runtime/better-sqlite.js.map +1 -0
  617. package/dist/runtime/child-process.d.ts +32 -0
  618. package/dist/runtime/child-process.js +10 -0
  619. package/dist/runtime/child-process.js.map +1 -0
  620. package/dist/runtime/env.d.ts +5 -0
  621. package/dist/runtime/env.js +12 -0
  622. package/dist/runtime/env.js.map +1 -0
  623. package/dist/sdk-compat.js +1 -1
  624. package/dist/search/document-scanner.d.ts +22 -0
  625. package/dist/search/document-scanner.js +8 -0
  626. package/dist/search/document-scanner.js.map +1 -0
  627. package/dist/search/embed-helper.d.ts +35 -0
  628. package/dist/search/embed-helper.js +9 -0
  629. package/dist/search/embed-helper.js.map +1 -0
  630. package/dist/search/factory.d.ts +32 -0
  631. package/dist/search/factory.js +29 -0
  632. package/dist/search/factory.js.map +1 -0
  633. package/dist/search/index.d.ts +15 -0
  634. package/dist/search/index.js +50 -0
  635. package/dist/search/index.js.map +1 -0
  636. package/dist/search/lancedb-backend.d.ts +51 -0
  637. package/dist/search/lancedb-backend.js +10 -0
  638. package/dist/search/lancedb-backend.js.map +1 -0
  639. package/dist/search/meilisearch-backend.d.ts +48 -0
  640. package/dist/search/meilisearch-backend.js +10 -0
  641. package/dist/search/meilisearch-backend.js.map +1 -0
  642. package/dist/search/noop-backend.d.ts +26 -0
  643. package/dist/search/noop-backend.js +8 -0
  644. package/dist/search/noop-backend.js.map +1 -0
  645. package/dist/search/orama-backend.d.ts +53 -0
  646. package/dist/search/orama-backend.js +10 -0
  647. package/dist/search/orama-backend.js.map +1 -0
  648. package/dist/search/port.d.ts +61 -0
  649. package/dist/search/port.js +1 -0
  650. package/dist/search/port.js.map +1 -0
  651. package/dist/search/remote-backend.d.ts +39 -0
  652. package/dist/search/remote-backend.js +9 -0
  653. package/dist/search/remote-backend.js.map +1 -0
  654. package/dist/secure-store/index.d.ts +890 -0
  655. package/dist/secure-store/index.js +156 -0
  656. package/dist/secure-store/index.js.map +1 -0
  657. package/dist/semantic-VwGI14Ok.d.ts +69 -0
  658. package/dist/semantic-consolidation-4HkHWgeI.d.ts +180 -0
  659. package/dist/semantic-consolidation.d.ts +3 -3
  660. package/dist/semantic-consolidation.js +15 -8
  661. package/dist/semantic-rule-promotion.js +9 -6
  662. package/dist/semantic-rule-verifier.d.ts +1 -1
  663. package/dist/semantic-rule-verifier.js +10 -7
  664. package/dist/session-observer-bands.d.ts +1 -1
  665. package/dist/session-observer-state.d.ts +1 -1
  666. package/dist/shared-context/manager.d.ts +131 -0
  667. package/dist/shared-context/manager.js +15 -0
  668. package/dist/shared-context/manager.js.map +1 -0
  669. package/dist/signal.d.ts +1 -1
  670. package/dist/skills-registry.js +13 -1
  671. package/dist/skills-registry.js.map +1 -1
  672. package/dist/state-store-VZU2IA53.js +16 -0
  673. package/dist/state-store-VZU2IA53.js.map +1 -0
  674. package/dist/storage-paths.d.ts +9 -0
  675. package/dist/storage-paths.js +20 -0
  676. package/dist/storage-paths.js.map +1 -0
  677. package/dist/storage.d.ts +6 -2
  678. package/dist/storage.js +8 -5
  679. package/dist/summarizer.d.ts +6 -1
  680. package/dist/summarizer.js +11 -10
  681. package/dist/summary-snapshot.d.ts +1 -1
  682. package/dist/summary-snapshot.js +2 -1
  683. package/dist/surfaces/dreams.d.ts +16 -0
  684. package/dist/surfaces/dreams.js +282 -0
  685. package/dist/surfaces/dreams.js.map +1 -0
  686. package/dist/surfaces/heartbeat.d.ts +17 -0
  687. package/dist/surfaces/heartbeat.js +265 -0
  688. package/dist/surfaces/heartbeat.js.map +1 -0
  689. package/dist/targeted-fact-recall.d.ts +17 -0
  690. package/dist/targeted-fact-recall.js +11 -0
  691. package/dist/targeted-fact-recall.js.map +1 -0
  692. package/dist/telemetry-transcript.d.ts +7 -0
  693. package/dist/telemetry-transcript.js +16 -0
  694. package/dist/telemetry-transcript.js.map +1 -0
  695. package/dist/temporal-supersession.d.ts +4 -2
  696. package/dist/temporal-supersession.js +2 -1
  697. package/dist/temporal-validity.d.ts +1 -1
  698. package/dist/threading.d.ts +6 -1
  699. package/dist/threading.js +2 -1
  700. package/dist/tier-migration.d.ts +5 -3
  701. package/dist/tier-routing.d.ts +1 -1
  702. package/dist/tokens.js +2 -2
  703. package/dist/topics.d.ts +1 -1
  704. package/dist/transcript.d.ts +16 -2
  705. package/dist/transcript.js +2 -1
  706. package/dist/transfer/autodetect.d.ts +4 -0
  707. package/dist/transfer/autodetect.js +15 -0
  708. package/dist/transfer/autodetect.js.map +1 -0
  709. package/dist/transfer/backup.d.ts +21 -0
  710. package/dist/transfer/backup.js +17 -0
  711. package/dist/transfer/backup.js.map +1 -0
  712. package/dist/transfer/capsule-export.d.ts +113 -0
  713. package/dist/transfer/capsule-export.js +19 -0
  714. package/dist/transfer/capsule-export.js.map +1 -0
  715. package/dist/transfer/capsule-import.d.ts +124 -0
  716. package/dist/transfer/capsule-import.js +16 -0
  717. package/dist/transfer/capsule-import.js.map +1 -0
  718. package/dist/transfer/constants.d.ts +13 -0
  719. package/dist/transfer/constants.js +12 -0
  720. package/dist/transfer/constants.js.map +1 -0
  721. package/dist/transfer/export-json.d.ts +11 -0
  722. package/dist/transfer/export-json.js +11 -0
  723. package/dist/transfer/export-json.js.map +1 -0
  724. package/dist/transfer/export-md.d.ts +10 -0
  725. package/dist/transfer/export-md.js +13 -0
  726. package/dist/transfer/export-md.js.map +1 -0
  727. package/dist/transfer/export-sqlite.d.ts +9 -0
  728. package/dist/transfer/export-sqlite.js +12 -0
  729. package/dist/transfer/export-sqlite.js.map +1 -0
  730. package/dist/transfer/fs-utils.d.ts +61 -0
  731. package/dist/transfer/fs-utils.js +40 -0
  732. package/dist/transfer/fs-utils.js.map +1 -0
  733. package/dist/transfer/import-json.d.ts +16 -0
  734. package/dist/transfer/import-json.js +13 -0
  735. package/dist/transfer/import-json.js.map +1 -0
  736. package/dist/transfer/import-md.d.ts +14 -0
  737. package/dist/transfer/import-md.js +11 -0
  738. package/dist/transfer/import-md.js.map +1 -0
  739. package/dist/transfer/import-sqlite.d.ts +14 -0
  740. package/dist/transfer/import-sqlite.js +12 -0
  741. package/dist/transfer/import-sqlite.js.map +1 -0
  742. package/dist/transfer/sqlite-schema.d.ts +4 -0
  743. package/dist/transfer/sqlite-schema.js +10 -0
  744. package/dist/transfer/sqlite-schema.js.map +1 -0
  745. package/dist/transfer/types.d.ts +916 -0
  746. package/dist/transfer/types.js +30 -0
  747. package/dist/transfer/types.js.map +1 -0
  748. package/dist/trust-zones.d.ts +3 -2
  749. package/dist/trust-zones.js +1 -1
  750. package/dist/types.d.ts +88 -3
  751. package/dist/types.js +1 -1
  752. package/dist/user-model.d.ts +37 -0
  753. package/dist/user-model.js +28 -0
  754. package/dist/user-model.js.map +1 -0
  755. package/dist/utility-runtime.d.ts +1 -1
  756. package/dist/verified-recall.js +11 -8
  757. package/dist/work/board.d.ts +43 -0
  758. package/dist/work/board.js +14 -0
  759. package/dist/work/board.js.map +1 -0
  760. package/dist/work/boundary.d.ts +8 -0
  761. package/dist/work/boundary.js +14 -0
  762. package/dist/work/boundary.js.map +1 -0
  763. package/dist/work/storage.d.ts +39 -0
  764. package/dist/work/storage.js +11 -0
  765. package/dist/work/storage.js.map +1 -0
  766. package/dist/work/types.d.ts +75 -0
  767. package/dist/work/types.js +1 -0
  768. package/dist/work/types.js.map +1 -0
  769. package/package.json +2767 -6
  770. package/scripts/faiss_index.py +816 -0
  771. package/scripts/faiss_requirements.txt +3 -0
  772. package/skills/remnic-entities/SKILL.md +51 -0
  773. package/skills/remnic-memory-workflow/SKILL.md +61 -0
  774. package/skills/remnic-recall/SKILL.md +51 -0
  775. package/skills/remnic-remember/SKILL.md +56 -0
  776. package/skills/remnic-search/SKILL.md +51 -0
  777. package/skills/remnic-status/SKILL.md +51 -0
  778. package/src/abort-error.test.ts +49 -0
  779. package/src/abort-error.ts +46 -0
  780. package/src/abstraction-nodes.ts +162 -0
  781. package/src/access-audit.test.ts +178 -0
  782. package/src/access-audit.ts +125 -0
  783. package/src/access-cli.test.ts +439 -0
  784. package/src/access-cli.ts +438 -0
  785. package/src/access-http.test.ts +225 -0
  786. package/src/access-http.ts +1899 -0
  787. package/src/access-idempotency.ts +232 -0
  788. package/src/access-mcp.test.ts +568 -0
  789. package/src/access-mcp.ts +3056 -0
  790. package/src/access-schema-pi.test.ts +60 -0
  791. package/src/access-schema.ts +522 -0
  792. package/src/access-service-namespace.test.ts +123 -0
  793. package/src/access-service.ts +5629 -0
  794. package/src/action-confidence.test.ts +206 -0
  795. package/src/action-confidence.ts +466 -0
  796. package/src/active-memory-bridge.test.ts +285 -0
  797. package/src/active-memory-bridge.ts +217 -0
  798. package/src/active-recall.test.ts +484 -0
  799. package/src/active-recall.ts +459 -0
  800. package/src/adapters/claude-code.ts +56 -0
  801. package/src/adapters/codex.ts +57 -0
  802. package/src/adapters/hermes.ts +64 -0
  803. package/src/adapters/index.ts +6 -0
  804. package/src/adapters/registry.ts +41 -0
  805. package/src/adapters/replit.ts +55 -0
  806. package/src/adapters/types.ts +51 -0
  807. package/src/behavior-learner.ts +144 -0
  808. package/src/behavior-signals.ts +73 -0
  809. package/src/binary-lifecycle/backend.ts +117 -0
  810. package/src/binary-lifecycle/index.ts +35 -0
  811. package/src/binary-lifecycle/manifest.ts +79 -0
  812. package/src/binary-lifecycle/pipeline.ts +352 -0
  813. package/src/binary-lifecycle/scanner.ts +89 -0
  814. package/src/binary-lifecycle/types.ts +89 -0
  815. package/src/bootstrap.ts +178 -0
  816. package/src/boxes.ts +521 -0
  817. package/src/briefing.test.ts +1535 -0
  818. package/src/briefing.ts +1382 -0
  819. package/src/buffer-session.test.ts +443 -0
  820. package/src/buffer-surprise-report.ts +176 -0
  821. package/src/buffer-surprise-telemetry.test.ts +606 -0
  822. package/src/buffer-surprise-trigger.test.ts +766 -0
  823. package/src/buffer-surprise.test.ts +339 -0
  824. package/src/buffer-surprise.ts +203 -0
  825. package/src/buffer.ts +900 -0
  826. package/src/bulk-import/cli-command.test.ts +204 -0
  827. package/src/bulk-import/index.ts +34 -0
  828. package/src/bulk-import/pipeline.test.ts +445 -0
  829. package/src/bulk-import/pipeline.ts +178 -0
  830. package/src/bulk-import/registry.test.ts +151 -0
  831. package/src/bulk-import/registry.ts +72 -0
  832. package/src/bulk-import/types.test.ts +272 -0
  833. package/src/bulk-import/types.ts +145 -0
  834. package/src/calibration.ts +394 -0
  835. package/src/capsule-cli.test.ts +398 -0
  836. package/src/capsule-cli.ts +565 -0
  837. package/src/causal-behavior.ts +308 -0
  838. package/src/causal-chain.ts +419 -0
  839. package/src/causal-consolidation.ts +370 -0
  840. package/src/causal-retrieval.ts +286 -0
  841. package/src/causal-trajectory-graph.ts +60 -0
  842. package/src/causal-trajectory.ts +303 -0
  843. package/src/chunking.ts +220 -0
  844. package/src/citations.ts +232 -0
  845. package/src/cli.ts +9403 -0
  846. package/src/codex-cli-fallback.ts +162 -0
  847. package/src/codex-thread-key.ts +1 -0
  848. package/src/coding/access-coding-context.test.ts +197 -0
  849. package/src/coding/coding-branch-scope.test.ts +281 -0
  850. package/src/coding/coding-namespace.test.ts +360 -0
  851. package/src/coding/coding-namespace.ts +412 -0
  852. package/src/coding/coding-orchestrator.test.ts +249 -0
  853. package/src/coding/git-context.test.ts +507 -0
  854. package/src/coding/git-context.ts +336 -0
  855. package/src/coding/mcp-set-coding-context.test.ts +174 -0
  856. package/src/coding/review-context.test.ts +316 -0
  857. package/src/coding/review-context.ts +349 -0
  858. package/src/coding/wire-coding-context.test.ts +468 -0
  859. package/src/commitment-ledger.test.ts +78 -0
  860. package/src/commitment-ledger.ts +337 -0
  861. package/src/compat/checks.test.ts +206 -0
  862. package/src/compat/checks.ts +716 -0
  863. package/src/compat/types.ts +33 -0
  864. package/src/compounding/engine.ts +1686 -0
  865. package/src/compounding/preference-consolidator.ts +778 -0
  866. package/src/compression-optimizer.ts +312 -0
  867. package/src/config.test.ts +930 -0
  868. package/src/config.ts +3807 -0
  869. package/src/connectors/codex/instructions.md +160 -0
  870. package/src/connectors/codex/resources/namespace-cheatsheet.md +48 -0
  871. package/src/connectors/codex-marketplace.ts +500 -0
  872. package/src/connectors/codex-materialize-runner.ts +212 -0
  873. package/src/connectors/codex-materialize.ts +983 -0
  874. package/src/connectors/coerce.ts +62 -0
  875. package/src/connectors/index.test.ts +1570 -0
  876. package/src/connectors/index.ts +3222 -0
  877. package/src/connectors/live/framework.ts +164 -0
  878. package/src/connectors/live/github.test.ts +1218 -0
  879. package/src/connectors/live/github.ts +1068 -0
  880. package/src/connectors/live/gmail.test.ts +1706 -0
  881. package/src/connectors/live/gmail.ts +1293 -0
  882. package/src/connectors/live/google-drive.test.ts +696 -0
  883. package/src/connectors/live/google-drive.ts +724 -0
  884. package/src/connectors/live/index.ts +101 -0
  885. package/src/connectors/live/live-connectors.test.ts +689 -0
  886. package/src/connectors/live/notion.test.ts +1109 -0
  887. package/src/connectors/live/notion.ts +978 -0
  888. package/src/connectors/live/registry.ts +103 -0
  889. package/src/connectors/live/state-store.ts +399 -0
  890. package/src/connectors/live/transient-errors.ts +150 -0
  891. package/src/connectors/weclone-installer.test.ts +850 -0
  892. package/src/connectors-cli.ts +513 -0
  893. package/src/console/state.test.ts +224 -0
  894. package/src/console/state.ts +514 -0
  895. package/src/console/trace.test.ts +813 -0
  896. package/src/console/trace.ts +603 -0
  897. package/src/console/tui.test.ts +582 -0
  898. package/src/console/tui.ts +508 -0
  899. package/src/consolidation-operator.ts +182 -0
  900. package/src/consolidation-provenance-check.ts +551 -0
  901. package/src/consolidation-undo.ts +718 -0
  902. package/src/contradiction/contradiction-judge.test.ts +189 -0
  903. package/src/contradiction/contradiction-judge.ts +333 -0
  904. package/src/contradiction/contradiction-review.ts +574 -0
  905. package/src/contradiction/contradiction-scan.ts +504 -0
  906. package/src/contradiction/contradiction.test.ts +2230 -0
  907. package/src/contradiction/index.ts +37 -0
  908. package/src/contradiction/resolution.ts +383 -0
  909. package/src/conversation-index/backend.ts +323 -0
  910. package/src/conversation-index/chunker.ts +47 -0
  911. package/src/conversation-index/cleanup.ts +53 -0
  912. package/src/conversation-index/faiss-adapter.ts +384 -0
  913. package/src/conversation-index/indexer.test.ts +164 -0
  914. package/src/conversation-index/indexer.ts +192 -0
  915. package/src/conversation-index/search.ts +37 -0
  916. package/src/cross-namespace-budget.test.ts +275 -0
  917. package/src/cross-namespace-budget.ts +365 -0
  918. package/src/cue-anchors.ts +163 -0
  919. package/src/curation/index.ts +544 -0
  920. package/src/dashboard-runtime.ts +337 -0
  921. package/src/day-summary.ts +122 -0
  922. package/src/dedup/index.ts +330 -0
  923. package/src/dedup/semantic.test.ts +1577 -0
  924. package/src/dedup/semantic.ts +148 -0
  925. package/src/delinearize.ts +193 -0
  926. package/src/direct-answer-wiring.test.ts +473 -0
  927. package/src/direct-answer-wiring.ts +180 -0
  928. package/src/direct-answer.test.ts +484 -0
  929. package/src/direct-answer.ts +273 -0
  930. package/src/embedding-fallback.ts +565 -0
  931. package/src/enrichment/audit.ts +89 -0
  932. package/src/enrichment/index.ts +27 -0
  933. package/src/enrichment/pipeline.ts +197 -0
  934. package/src/enrichment/provider-registry.ts +85 -0
  935. package/src/enrichment/types.ts +100 -0
  936. package/src/enrichment/web-search-provider.ts +63 -0
  937. package/src/entity-retrieval.ts +774 -0
  938. package/src/entity-schema.ts +239 -0
  939. package/src/evals.ts +1312 -0
  940. package/src/event-order-recall.test.ts +4164 -0
  941. package/src/event-order-recall.ts +2802 -0
  942. package/src/evidence-pack.test.ts +89 -0
  943. package/src/evidence-pack.ts +388 -0
  944. package/src/explicit-capture.ts +530 -0
  945. package/src/explicit-cue-recall.test.ts +3019 -0
  946. package/src/explicit-cue-recall.ts +5545 -0
  947. package/src/extraction-judge-telemetry.ts +234 -0
  948. package/src/extraction-judge-training.ts +221 -0
  949. package/src/extraction-judge.ts +846 -0
  950. package/src/extraction-timeout.test.ts +265 -0
  951. package/src/extraction.ts +2719 -0
  952. package/src/fallback-llm.test.ts +1060 -0
  953. package/src/fallback-llm.ts +918 -0
  954. package/src/focused-list-recall.test.ts +734 -0
  955. package/src/focused-list-recall.ts +1160 -0
  956. package/src/graph-dashboard-diff.ts +35 -0
  957. package/src/graph-dashboard-key.ts +5 -0
  958. package/src/graph-dashboard-parser.ts +104 -0
  959. package/src/graph-edge-reinforcement.ts +192 -0
  960. package/src/graph-events.ts +151 -0
  961. package/src/graph-recall.test.ts +164 -0
  962. package/src/graph-recall.ts +189 -0
  963. package/src/graph-retrieval.test.ts +809 -0
  964. package/src/graph-retrieval.ts +823 -0
  965. package/src/graph-snapshot.ts +329 -0
  966. package/src/graph.ts +813 -0
  967. package/src/harmonic-retrieval.ts +223 -0
  968. package/src/himem.ts +154 -0
  969. package/src/hygiene.ts +87 -0
  970. package/src/identity-continuity.ts +333 -0
  971. package/src/importance.ts +328 -0
  972. package/src/importers/base.test.ts +294 -0
  973. package/src/importers/base.ts +436 -0
  974. package/src/importers/index.ts +21 -0
  975. package/src/index.ts +1204 -0
  976. package/src/intent.ts +154 -0
  977. package/src/json-extract.ts +85 -0
  978. package/src/json-store.ts +42 -0
  979. package/src/lcm/archive.ts +617 -0
  980. package/src/lcm/dag.ts +199 -0
  981. package/src/lcm/engine.ts +645 -0
  982. package/src/lcm/index.ts +7 -0
  983. package/src/lcm/queue.test.ts +178 -0
  984. package/src/lcm/queue.ts +200 -0
  985. package/src/lcm/recall.ts +117 -0
  986. package/src/lcm/schema.ts +154 -0
  987. package/src/lcm/summarizer.ts +235 -0
  988. package/src/lcm/tools.ts +191 -0
  989. package/src/lcm-engine.test.ts +660 -0
  990. package/src/legacy-hook-compat.test.ts +20 -0
  991. package/src/legacy-hook-compat.ts +45 -0
  992. package/src/lifecycle.ts +289 -0
  993. package/src/live-connectors-runner.ts +385 -0
  994. package/src/local-llm-qos.test.ts +303 -0
  995. package/src/local-llm-thinking.test.ts +292 -0
  996. package/src/local-llm.ts +1464 -0
  997. package/src/logger.ts +49 -0
  998. package/src/maintenance/archive-observations.ts +147 -0
  999. package/src/maintenance/backup-stamp.ts +3 -0
  1000. package/src/maintenance/dreams-ledger.ts +516 -0
  1001. package/src/maintenance/first-start-migration.ts +362 -0
  1002. package/src/maintenance/forget.test.ts +206 -0
  1003. package/src/maintenance/forget.ts +126 -0
  1004. package/src/maintenance/graph-edge-decay.test.ts +409 -0
  1005. package/src/maintenance/graph-edge-decay.ts +394 -0
  1006. package/src/maintenance/memory-governance-cron.ts +447 -0
  1007. package/src/maintenance/memory-governance.ts +1039 -0
  1008. package/src/maintenance/migrate-observations.ts +216 -0
  1009. package/src/maintenance/observation-ledger-utils.ts +54 -0
  1010. package/src/maintenance/pattern-reinforcement.test.ts +875 -0
  1011. package/src/maintenance/pattern-reinforcement.ts +369 -0
  1012. package/src/maintenance/purge.ts +334 -0
  1013. package/src/maintenance/rebuild-memory-lifecycle-ledger.ts +78 -0
  1014. package/src/maintenance/rebuild-memory-projection.ts +1234 -0
  1015. package/src/maintenance/rebuild-observations.ts +178 -0
  1016. package/src/maintenance/tier-stats.test.ts +378 -0
  1017. package/src/maintenance/tier-stats.ts +222 -0
  1018. package/src/mcp-memory-inspector-app.ts +421 -0
  1019. package/src/memory-action-policy.ts +80 -0
  1020. package/src/memory-cache.ts +208 -0
  1021. package/src/memory-extension/claude-code-publisher.ts +51 -0
  1022. package/src/memory-extension/codex-publisher.ts +149 -0
  1023. package/src/memory-extension/hermes-publisher.ts +51 -0
  1024. package/src/memory-extension/index.ts +100 -0
  1025. package/src/memory-extension/shared-instructions.ts +133 -0
  1026. package/src/memory-extension/types.ts +86 -0
  1027. package/src/memory-extension-host/host-discovery.ts +276 -0
  1028. package/src/memory-extension-host/index.ts +14 -0
  1029. package/src/memory-extension-host/render-extensions-block.ts +73 -0
  1030. package/src/memory-extension-host/types.ts +21 -0
  1031. package/src/memory-lifecycle-ledger-utils.ts +116 -0
  1032. package/src/memory-projection-format.ts +11 -0
  1033. package/src/memory-projection-store.ts +951 -0
  1034. package/src/memory-provenance.test.ts +196 -0
  1035. package/src/memory-provenance.ts +484 -0
  1036. package/src/memory-worth-bench.test.ts +71 -0
  1037. package/src/memory-worth-bench.ts +265 -0
  1038. package/src/memory-worth-filter.test.ts +209 -0
  1039. package/src/memory-worth-filter.ts +204 -0
  1040. package/src/memory-worth-frontmatter.test.ts +311 -0
  1041. package/src/memory-worth-outcomes.test.ts +316 -0
  1042. package/src/memory-worth-outcomes.ts +286 -0
  1043. package/src/memory-worth.test.ts +317 -0
  1044. package/src/memory-worth.ts +215 -0
  1045. package/src/message-parts/index.ts +806 -0
  1046. package/src/message-parts/message-parts.test.ts +421 -0
  1047. package/src/migrate/from-engram.ts +789 -0
  1048. package/src/model-registry.ts +313 -0
  1049. package/src/models-json.ts +76 -0
  1050. package/src/namespaces/migrate.ts +187 -0
  1051. package/src/namespaces/path.ts +25 -0
  1052. package/src/namespaces/principal.test.ts +195 -0
  1053. package/src/namespaces/principal.ts +86 -0
  1054. package/src/namespaces/search.test.ts +105 -0
  1055. package/src/namespaces/search.ts +233 -0
  1056. package/src/namespaces/storage.ts +74 -0
  1057. package/src/native-knowledge.ts +1823 -0
  1058. package/src/negative.ts +72 -0
  1059. package/src/network/tailscale.ts +179 -0
  1060. package/src/network/webdav.ts +385 -0
  1061. package/src/objective-state-writers.ts +951 -0
  1062. package/src/objective-state.ts +320 -0
  1063. package/src/onboarding/index.ts +529 -0
  1064. package/src/openai-chat-compat.ts +56 -0
  1065. package/src/operator-toolkit.ts +2132 -0
  1066. package/src/opik-exporter.test.ts +72 -0
  1067. package/src/opik-exporter.ts +587 -0
  1068. package/src/orchestrator-extraction-queue.test.ts +197 -0
  1069. package/src/orchestrator-flush.test.ts +1171 -0
  1070. package/src/orchestrator-pattern-reinforcement.test.ts +128 -0
  1071. package/src/orchestrator-source-attribution.test.ts +701 -0
  1072. package/src/orchestrator.ts +16368 -0
  1073. package/src/page-versioning.ts +450 -0
  1074. package/src/patterns-cli.ts +574 -0
  1075. package/src/peers/index.ts +54 -0
  1076. package/src/peers/migrate-from-identity-anchor.test.ts +291 -0
  1077. package/src/peers/migrate-from-identity-anchor.ts +350 -0
  1078. package/src/peers/peers.test.ts +419 -0
  1079. package/src/peers/profile-reasoner.ts +694 -0
  1080. package/src/peers/storage.ts +1350 -0
  1081. package/src/peers/types.ts +138 -0
  1082. package/src/plugin-id.ts +84 -0
  1083. package/src/policy-runtime.ts +209 -0
  1084. package/src/procedural/procedure-miner.ts +150 -0
  1085. package/src/procedural/procedure-recall.ts +93 -0
  1086. package/src/procedural/procedure-stats.ts +213 -0
  1087. package/src/procedural/procedure-types.ts +132 -0
  1088. package/src/procedural/reinforcement-core.test.ts +132 -0
  1089. package/src/procedural/reinforcement-core.ts +73 -0
  1090. package/src/profiling.test.ts +263 -0
  1091. package/src/profiling.ts +435 -0
  1092. package/src/projection/index.ts +398 -0
  1093. package/src/qmd-recall-cache.test.ts +138 -0
  1094. package/src/qmd-recall-cache.ts +111 -0
  1095. package/src/qmd.test.ts +257 -0
  1096. package/src/qmd.ts +2614 -0
  1097. package/src/reasoning-trace-recall.ts +201 -0
  1098. package/src/reasoning-trace-types.ts +235 -0
  1099. package/src/recall-audit-anomaly.test.ts +246 -0
  1100. package/src/recall-audit-anomaly.ts +297 -0
  1101. package/src/recall-audit.test.ts +51 -0
  1102. package/src/recall-audit.ts +72 -0
  1103. package/src/recall-budget-config.test.ts +87 -0
  1104. package/src/recall-disclosure-escalation.test.ts +196 -0
  1105. package/src/recall-disclosure-escalation.ts +158 -0
  1106. package/src/recall-disclosure-shaping.test.ts +146 -0
  1107. package/src/recall-disclosure.test.ts +214 -0
  1108. package/src/recall-explain-renderer.test.ts +140 -0
  1109. package/src/recall-explain-renderer.ts +356 -0
  1110. package/src/recall-mmr.test.ts +808 -0
  1111. package/src/recall-mmr.ts +607 -0
  1112. package/src/recall-qos.test.ts +85 -0
  1113. package/src/recall-qos.ts +82 -0
  1114. package/src/recall-query-policy.ts +221 -0
  1115. package/src/recall-state.test.ts +233 -0
  1116. package/src/recall-state.ts +456 -0
  1117. package/src/recall-tag-filter.ts +143 -0
  1118. package/src/recall-tokenization.ts +35 -0
  1119. package/src/recall-xray-cli.test.ts +118 -0
  1120. package/src/recall-xray-cli.ts +100 -0
  1121. package/src/recall-xray-disclosure-telemetry.test.ts +183 -0
  1122. package/src/recall-xray-renderer.test.ts +539 -0
  1123. package/src/recall-xray-renderer.ts +487 -0
  1124. package/src/recall-xray.test.ts +503 -0
  1125. package/src/recall-xray.ts +621 -0
  1126. package/src/reconstruct.ts +41 -0
  1127. package/src/release-changelog.ts +35 -0
  1128. package/src/relevance.ts +67 -0
  1129. package/src/replay/normalizers/chatgpt.ts +133 -0
  1130. package/src/replay/normalizers/claude.ts +102 -0
  1131. package/src/replay/normalizers/openclaw.ts +119 -0
  1132. package/src/replay/normalizers/shared.ts +69 -0
  1133. package/src/replay/runner.ts +197 -0
  1134. package/src/replay/types.ts +143 -0
  1135. package/src/rerank.test.ts +48 -0
  1136. package/src/rerank.ts +176 -0
  1137. package/src/resolve-auth-token.test.ts +226 -0
  1138. package/src/resolve-auth-token.ts +151 -0
  1139. package/src/resolve-provider-secret.test.ts +187 -0
  1140. package/src/resolve-provider-secret.ts +410 -0
  1141. package/src/response-guidance-recall.test.ts +3952 -0
  1142. package/src/response-guidance-recall.ts +4431 -0
  1143. package/src/resume-bundles.ts +415 -0
  1144. package/src/retrieval-agents.ts +623 -0
  1145. package/src/retrieval-tiers.ts +25 -0
  1146. package/src/retrieval.ts +104 -0
  1147. package/src/review/index.test.ts +201 -0
  1148. package/src/review/index.ts +536 -0
  1149. package/src/routing/engine.ts +162 -0
  1150. package/src/routing/store.ts +321 -0
  1151. package/src/runtime/better-sqlite.test.ts +32 -0
  1152. package/src/runtime/better-sqlite.ts +76 -0
  1153. package/src/runtime/child-process.ts +67 -0
  1154. package/src/runtime/env.ts +48 -0
  1155. package/src/sanitize.ts +58 -0
  1156. package/src/schemas.ts +449 -0
  1157. package/src/sdk-compat.ts +87 -0
  1158. package/src/search/document-scanner.ts +96 -0
  1159. package/src/search/embed-helper.ts +142 -0
  1160. package/src/search/factory.ts +189 -0
  1161. package/src/search/index.ts +10 -0
  1162. package/src/search/lancedb-backend.ts +342 -0
  1163. package/src/search/meilisearch-backend.ts +232 -0
  1164. package/src/search/noop-backend.ts +57 -0
  1165. package/src/search/orama-backend.ts +358 -0
  1166. package/src/search/port.ts +86 -0
  1167. package/src/search/remote-backend.ts +124 -0
  1168. package/src/secure-store/cipher.ts +271 -0
  1169. package/src/secure-store/cli-handlers.ts +355 -0
  1170. package/src/secure-store/cli-renderer.ts +131 -0
  1171. package/src/secure-store/header.ts +373 -0
  1172. package/src/secure-store/index.ts +137 -0
  1173. package/src/secure-store/kdf.ts +263 -0
  1174. package/src/secure-store/keyring.ts +106 -0
  1175. package/src/secure-store/metadata.ts +394 -0
  1176. package/src/secure-store/passphrase-reader.ts +252 -0
  1177. package/src/secure-store/secure-fs.ts +571 -0
  1178. package/src/secure-store/secure-store.test.ts +755 -0
  1179. package/src/semantic-chunking.ts +545 -0
  1180. package/src/semantic-consolidation.test.ts +182 -0
  1181. package/src/semantic-consolidation.ts +432 -0
  1182. package/src/semantic-rule-promotion.ts +183 -0
  1183. package/src/semantic-rule-verifier.ts +160 -0
  1184. package/src/session-integrity.ts +569 -0
  1185. package/src/session-observer-bands.ts +11 -0
  1186. package/src/session-observer-state.ts +346 -0
  1187. package/src/session-toggles.test.ts +96 -0
  1188. package/src/session-toggles.ts +159 -0
  1189. package/src/shared-context/manager.ts +810 -0
  1190. package/src/signal.ts +84 -0
  1191. package/src/skills-registry.test.ts +277 -0
  1192. package/src/skills-registry.ts +120 -0
  1193. package/src/source-attribution-roundtrip.test.ts +215 -0
  1194. package/src/source-attribution.test.ts +1425 -0
  1195. package/src/source-attribution.ts +639 -0
  1196. package/src/spaces/index.ts +627 -0
  1197. package/src/storage-paths.ts +117 -0
  1198. package/src/storage.ts +6657 -0
  1199. package/src/store-contract.ts +55 -0
  1200. package/src/summarizer.ts +844 -0
  1201. package/src/summary-snapshot.test.ts +681 -0
  1202. package/src/summary-snapshot.ts +238 -0
  1203. package/src/surfaces/dreams.test.ts +394 -0
  1204. package/src/surfaces/dreams.ts +346 -0
  1205. package/src/surfaces/heartbeat.test.ts +415 -0
  1206. package/src/surfaces/heartbeat.ts +325 -0
  1207. package/src/sync/index.ts +308 -0
  1208. package/src/targeted-fact-recall.test.ts +1694 -0
  1209. package/src/targeted-fact-recall.ts +2905 -0
  1210. package/src/taxonomy/default-taxonomy.ts +87 -0
  1211. package/src/taxonomy/index.ts +26 -0
  1212. package/src/taxonomy/resolver-doc-generator.ts +57 -0
  1213. package/src/taxonomy/resolver.ts +184 -0
  1214. package/src/taxonomy/taxonomy-loader.ts +186 -0
  1215. package/src/taxonomy/types.ts +48 -0
  1216. package/src/telemetry-transcript.ts +70 -0
  1217. package/src/temporal-index.ts +890 -0
  1218. package/src/temporal-supersession.test.ts +2703 -0
  1219. package/src/temporal-supersession.ts +493 -0
  1220. package/src/temporal-validity.test.ts +448 -0
  1221. package/src/temporal-validity.ts +123 -0
  1222. package/src/threading.ts +395 -0
  1223. package/src/tier-migration.ts +124 -0
  1224. package/src/tier-routing.ts +102 -0
  1225. package/src/tmt.ts +462 -0
  1226. package/src/tokens.test.ts +178 -0
  1227. package/src/tokens.ts +279 -0
  1228. package/src/topics.ts +147 -0
  1229. package/src/training-export/cli-date-validation.test.ts +258 -0
  1230. package/src/training-export/converter.test.ts +452 -0
  1231. package/src/training-export/converter.ts +319 -0
  1232. package/src/training-export/date-parse.ts +117 -0
  1233. package/src/training-export/index.ts +26 -0
  1234. package/src/training-export/registry.test.ts +85 -0
  1235. package/src/training-export/registry.ts +57 -0
  1236. package/src/training-export/types.ts +31 -0
  1237. package/src/transcript.ts +1179 -0
  1238. package/src/transfer/autodetect.ts +30 -0
  1239. package/src/transfer/backup.ts +138 -0
  1240. package/src/transfer/capsule-crypto.ts +485 -0
  1241. package/src/transfer/capsule-encrypt.test.ts +690 -0
  1242. package/src/transfer/capsule-export.ts +543 -0
  1243. package/src/transfer/capsule-fork.ts +375 -0
  1244. package/src/transfer/capsule-import.ts +564 -0
  1245. package/src/transfer/capsule-merge.ts +433 -0
  1246. package/src/transfer/conflict-policy.ts +16 -0
  1247. package/src/transfer/constants.ts +13 -0
  1248. package/src/transfer/exclusions.ts +37 -0
  1249. package/src/transfer/export-json.ts +65 -0
  1250. package/src/transfer/export-md.ts +59 -0
  1251. package/src/transfer/export-sqlite.ts +52 -0
  1252. package/src/transfer/fs-utils.ts +269 -0
  1253. package/src/transfer/import-json.ts +108 -0
  1254. package/src/transfer/import-md.ts +84 -0
  1255. package/src/transfer/import-sqlite.ts +100 -0
  1256. package/src/transfer/integrity.ts +71 -0
  1257. package/src/transfer/sqlite-schema.ts +16 -0
  1258. package/src/transfer/types.ts +297 -0
  1259. package/src/trust-zones.ts +1186 -0
  1260. package/src/types.ts +3074 -0
  1261. package/src/user-model.test.ts +124 -0
  1262. package/src/user-model.ts +162 -0
  1263. package/src/utility-learner.ts +353 -0
  1264. package/src/utility-runtime.ts +88 -0
  1265. package/src/utility-telemetry.ts +215 -0
  1266. package/src/utils/category-dir.ts +44 -0
  1267. package/src/utils/errno.ts +6 -0
  1268. package/src/utils/iso-timestamp.test.ts +37 -0
  1269. package/src/utils/iso-timestamp.ts +164 -0
  1270. package/src/utils/path.ts +26 -0
  1271. package/src/verified-recall.ts +138 -0
  1272. package/src/version-utils.test.ts +10 -0
  1273. package/src/version-utils.ts +9 -0
  1274. package/src/whitespace.ts +10 -0
  1275. package/src/work/board.ts +359 -0
  1276. package/src/work/boundary.ts +107 -0
  1277. package/src/work/storage.ts +436 -0
  1278. package/src/work/types.ts +82 -0
  1279. package/src/work-product-ledger.ts +265 -0
  1280. package/dist/access-service-BkXt3di1.d.ts +0 -2039
  1281. package/dist/capsule-crypto-SJS5VVAP.js +0 -18
  1282. package/dist/capsule-export-LLEVB2RG.js +0 -17
  1283. package/dist/capsule-import-UW45R2MZ.js +0 -16
  1284. package/dist/capsule-merge-DI7PNQ2H.js +0 -189
  1285. package/dist/chunk-2LGMW3DJ.js +0 -111
  1286. package/dist/chunk-2YMTO4ZJ.js +0 -265
  1287. package/dist/chunk-2YMTO4ZJ.js.map +0 -1
  1288. package/dist/chunk-363MWCD3.js +0 -9683
  1289. package/dist/chunk-363MWCD3.js.map +0 -1
  1290. package/dist/chunk-36CTNQY7.js +0 -1554
  1291. package/dist/chunk-36CTNQY7.js.map +0 -1
  1292. package/dist/chunk-457A4P3L.js +0 -119
  1293. package/dist/chunk-457A4P3L.js.map +0 -1
  1294. package/dist/chunk-4DXC6HQQ.js +0 -1837
  1295. package/dist/chunk-4DXC6HQQ.js.map +0 -1
  1296. package/dist/chunk-4IS4SXIQ.js +0 -2040
  1297. package/dist/chunk-57QNCUEZ.js +0 -1914
  1298. package/dist/chunk-57QNCUEZ.js.map +0 -1
  1299. package/dist/chunk-6AUUAZEX.js +0 -150
  1300. package/dist/chunk-6AUUAZEX.js.map +0 -1
  1301. package/dist/chunk-6TBWYBJ3.js +0 -236
  1302. package/dist/chunk-6XA7UN4Z.js +0 -135
  1303. package/dist/chunk-6Z6UH6TK.js +0 -2129
  1304. package/dist/chunk-6Z6UH6TK.js.map +0 -1
  1305. package/dist/chunk-74EMIVE4.js +0 -329
  1306. package/dist/chunk-74EMIVE4.js.map +0 -1
  1307. package/dist/chunk-74WWN7ZW.js +0 -82
  1308. package/dist/chunk-74WWN7ZW.js.map +0 -1
  1309. package/dist/chunk-767ODGE6.js +0 -183
  1310. package/dist/chunk-A4ACKWIW.js +0 -289
  1311. package/dist/chunk-A4ACKWIW.js.map +0 -1
  1312. package/dist/chunk-ASAITVLA.js +0 -64
  1313. package/dist/chunk-ASAITVLA.js.map +0 -1
  1314. package/dist/chunk-C5HUWVH2.js +0 -891
  1315. package/dist/chunk-C5HUWVH2.js.map +0 -1
  1316. package/dist/chunk-D54LZC5L.js +0 -147
  1317. package/dist/chunk-DF3RVK3X.js +0 -119
  1318. package/dist/chunk-DF3RVK3X.js.map +0 -1
  1319. package/dist/chunk-E6K4NIEU.js +0 -747
  1320. package/dist/chunk-E6K4NIEU.js.map +0 -1
  1321. package/dist/chunk-EEQLFRUM.js +0 -89
  1322. package/dist/chunk-EQINRHYR.js +0 -672
  1323. package/dist/chunk-EQINRHYR.js.map +0 -1
  1324. package/dist/chunk-ETOW6ACV.js +0 -158
  1325. package/dist/chunk-ETOW6ACV.js.map +0 -1
  1326. package/dist/chunk-EYNQTST2.js +0 -721
  1327. package/dist/chunk-FYIYMQ5N.js +0 -221
  1328. package/dist/chunk-FYIYMQ5N.js.map +0 -1
  1329. package/dist/chunk-G2WADRQ3.js +0 -219
  1330. package/dist/chunk-G4SK7DSQ.js +0 -121
  1331. package/dist/chunk-GGD5W7TB.js +0 -105
  1332. package/dist/chunk-GGD5W7TB.js.map +0 -1
  1333. package/dist/chunk-GVPWB7EY.js +0 -390
  1334. package/dist/chunk-GVPWB7EY.js.map +0 -1
  1335. package/dist/chunk-HJYHRE4S.js +0 -647
  1336. package/dist/chunk-I6BQZSML.js +0 -1451
  1337. package/dist/chunk-I6BQZSML.js.map +0 -1
  1338. package/dist/chunk-IBX3VFOM.js +0 -446
  1339. package/dist/chunk-IBX3VFOM.js.map +0 -1
  1340. package/dist/chunk-IXEJRKCZ.js +0 -18
  1341. package/dist/chunk-JBMSGZEQ.js +0 -441
  1342. package/dist/chunk-JBMSGZEQ.js.map +0 -1
  1343. package/dist/chunk-JRNQ3RNA.js +0 -284
  1344. package/dist/chunk-JRNQ3RNA.js.map +0 -1
  1345. package/dist/chunk-K6WK37A6.js +0 -865
  1346. package/dist/chunk-K6WK37A6.js.map +0 -1
  1347. package/dist/chunk-KBYWQWSB.js +0 -271
  1348. package/dist/chunk-KUHRUM6B.js +0 -14397
  1349. package/dist/chunk-KUHRUM6B.js.map +0 -1
  1350. package/dist/chunk-KWBPHZUU.js +0 -83
  1351. package/dist/chunk-KWBPHZUU.js.map +0 -1
  1352. package/dist/chunk-LIO5X3CM.js +0 -596
  1353. package/dist/chunk-MARWOCVP.js +0 -48
  1354. package/dist/chunk-MCC6KDQF.js +0 -5095
  1355. package/dist/chunk-MCC6KDQF.js.map +0 -1
  1356. package/dist/chunk-N5AKDXAI.js +0 -74
  1357. package/dist/chunk-NN3LPQ5D.js +0 -936
  1358. package/dist/chunk-NN3LPQ5D.js.map +0 -1
  1359. package/dist/chunk-O4XJUPSF.js +0 -533
  1360. package/dist/chunk-O4XJUPSF.js.map +0 -1
  1361. package/dist/chunk-OA3L7BFR.js +0 -183
  1362. package/dist/chunk-OA3L7BFR.js.map +0 -1
  1363. package/dist/chunk-OR64ZGRZ.js +0 -23
  1364. package/dist/chunk-P73JTV34.js +0 -275
  1365. package/dist/chunk-P73JTV34.js.map +0 -1
  1366. package/dist/chunk-P77UEOU2.js +0 -1521
  1367. package/dist/chunk-P77UEOU2.js.map +0 -1
  1368. package/dist/chunk-PB5KW5PL.js +0 -118
  1369. package/dist/chunk-PHNGXFQ6.js +0 -623
  1370. package/dist/chunk-PHNGXFQ6.js.map +0 -1
  1371. package/dist/chunk-QIGOEM65.js +0 -228
  1372. package/dist/chunk-RXTFCYQF.js +0 -108
  1373. package/dist/chunk-S2JJBLJG.js +0 -2101
  1374. package/dist/chunk-S2JJBLJG.js.map +0 -1
  1375. package/dist/chunk-S3IP6R6K.js +0 -219
  1376. package/dist/chunk-S3IP6R6K.js.map +0 -1
  1377. package/dist/chunk-SRBJUAMP.js +0 -403
  1378. package/dist/chunk-SRBJUAMP.js.map +0 -1
  1379. package/dist/chunk-URB2WSKZ.js +0 -350
  1380. package/dist/chunk-URB2WSKZ.js.map +0 -1
  1381. package/dist/chunk-VQXK37XA.js +0 -26
  1382. package/dist/chunk-VQXK37XA.js.map +0 -1
  1383. package/dist/chunk-VTU2B4VF.js +0 -146
  1384. package/dist/chunk-VTU2B4VF.js.map +0 -1
  1385. package/dist/chunk-VX2IUQFE.js +0 -613
  1386. package/dist/chunk-VX2IUQFE.js.map +0 -1
  1387. package/dist/chunk-WGK4VHGP.js +0 -4292
  1388. package/dist/chunk-WGK4VHGP.js.map +0 -1
  1389. package/dist/chunk-WTFWLUSX.js +0 -827
  1390. package/dist/chunk-WTFWLUSX.js.map +0 -1
  1391. package/dist/chunk-XJKFSSDW.js +0 -726
  1392. package/dist/chunk-XJKFSSDW.js.map +0 -1
  1393. package/dist/chunk-XMHBH5H6.js +0 -283
  1394. package/dist/chunk-XMHBH5H6.js.map +0 -1
  1395. package/dist/chunk-XMVFHBHT.js +0 -277
  1396. package/dist/chunk-Y5KDIOKF.js +0 -2403
  1397. package/dist/chunk-Y5KDIOKF.js.map +0 -1
  1398. package/dist/chunk-YNB73F22.js +0 -137
  1399. package/dist/chunk-YNB73F22.js.map +0 -1
  1400. package/dist/chunk-Z2E7VW55.js +0 -335
  1401. package/dist/chunk-Z2E7VW55.js.map +0 -1
  1402. package/dist/chunk-Z5S5HNGY.js +0 -2280
  1403. package/dist/chunk-Z5S5HNGY.js.map +0 -1
  1404. package/dist/chunk-ZL4S7ARC.js +0 -53
  1405. package/dist/chunk-ZTSE2ZJ6.js +0 -190
  1406. package/dist/chunk-ZTSE2ZJ6.js.map +0 -1
  1407. package/dist/cli-Cvy2SNhF.d.ts +0 -1259
  1408. package/dist/codex-materialize-CQlLTzke.d.ts +0 -139
  1409. package/dist/connectors-cli-DFGtY2DB.d.ts +0 -257
  1410. package/dist/contradiction-review-5LTTVDQV.js +0 -22
  1411. package/dist/contradiction-scan-3Z6YW7YA.js +0 -413
  1412. package/dist/contradiction-scan-3Z6YW7YA.js.map +0 -1
  1413. package/dist/engine-FOC3IJLA.js +0 -28
  1414. package/dist/fs-utils-IRVUFB6G.js +0 -30
  1415. package/dist/graph-edge-decay-PWB63GRE.js +0 -207
  1416. package/dist/index-1qIcnbG1.d.ts +0 -34
  1417. package/dist/memory-governance-F3QOJGEY.js +0 -37
  1418. package/dist/memory-projection-store-CY8TU40w.d.ts +0 -222
  1419. package/dist/orchestrator-AOQMo7QI.d.ts +0 -1784
  1420. package/dist/path-RMTY5Y5A.js +0 -9
  1421. package/dist/port-B6VEDIkC.d.ts +0 -53
  1422. package/dist/resolution-YGIBORXI.js +0 -101
  1423. package/dist/resolution-YGIBORXI.js.map +0 -1
  1424. package/dist/secure-store-4R2GSO7S.js +0 -156
  1425. package/dist/semantic-consolidation-ByBXb-sf.d.ts +0 -180
  1426. package/dist/state-store-3EH7HYIN.js +0 -16
  1427. package/dist/types-V3FJ26TF.js +0 -30
  1428. /package/dist/{capsule-crypto-SJS5VVAP.js.map → action-confidence.js.map} +0 -0
  1429. /package/dist/{capsule-export-LLEVB2RG.js.map → adapters/claude-code.js.map} +0 -0
  1430. /package/dist/{capsule-import-UW45R2MZ.js.map → adapters/codex.js.map} +0 -0
  1431. /package/dist/{contradiction-review-5LTTVDQV.js.map → adapters/hermes.js.map} +0 -0
  1432. /package/dist/{engine-FOC3IJLA.js.map → adapters/index.js.map} +0 -0
  1433. /package/dist/{fs-utils-IRVUFB6G.js.map → adapters/registry.js.map} +0 -0
  1434. /package/dist/{memory-governance-F3QOJGEY.js.map → adapters/replit.js.map} +0 -0
  1435. /package/dist/{path-RMTY5Y5A.js.map → adapters/types.js.map} +0 -0
  1436. /package/dist/{secure-store-4R2GSO7S.js.map → capsule-crypto-5CYAGVC5.js.map} +0 -0
  1437. /package/dist/{capsule-merge-DI7PNQ2H.js.map → capsule-merge-4MGKE7C5.js.map} +0 -0
  1438. /package/dist/{chunk-G4SK7DSQ.js.map → chunk-2WWLHTZY.js.map} +0 -0
  1439. /package/dist/{chunk-KBYWQWSB.js.map → chunk-4CRG46BG.js.map} +0 -0
  1440. /package/dist/{chunk-LIO5X3CM.js.map → chunk-7IASACLB.js.map} +0 -0
  1441. /package/dist/{chunk-EYNQTST2.js.map → chunk-EFJ3MQ4V.js.map} +0 -0
  1442. /package/dist/{chunk-D54LZC5L.js.map → chunk-FDU6HUUL.js.map} +0 -0
  1443. /package/dist/{chunk-QIGOEM65.js.map → chunk-GGKRUQOO.js.map} +0 -0
  1444. /package/dist/{chunk-HJYHRE4S.js.map → chunk-GL6I6MEQ.js.map} +0 -0
  1445. /package/dist/{state-store-3EH7HYIN.js.map → chunk-HHLLAQGZ.js.map} +0 -0
  1446. /package/dist/{chunk-4IS4SXIQ.js.map → chunk-HXXBL2KD.js.map} +0 -0
  1447. /package/dist/{chunk-767ODGE6.js.map → chunk-KNKUID7G.js.map} +0 -0
  1448. /package/dist/{chunk-6TBWYBJ3.js.map → chunk-LPMVBPA3.js.map} +0 -0
  1449. /package/dist/{chunk-PB5KW5PL.js.map → chunk-MC26UJIM.js.map} +0 -0
  1450. /package/dist/{chunk-ZL4S7ARC.js.map → chunk-MT4HVDUZ.js.map} +0 -0
  1451. /package/dist/{chunk-G2WADRQ3.js.map → chunk-MY6TPVXW.js.map} +0 -0
  1452. /package/dist/{chunk-OR64ZGRZ.js.map → chunk-NNVTUXEB.js.map} +0 -0
  1453. /package/dist/{chunk-RXTFCYQF.js.map → chunk-P4NEIHUT.js.map} +0 -0
  1454. /package/dist/{chunk-IXEJRKCZ.js.map → chunk-QRNI5JBH.js.map} +0 -0
  1455. /package/dist/{chunk-EEQLFRUM.js.map → chunk-RRF5UOBJ.js.map} +0 -0
  1456. /package/dist/{types-V3FJ26TF.js.map → chunk-SEDEKFYQ.js.map} +0 -0
  1457. /package/dist/{chunk-2LGMW3DJ.js.map → chunk-U3PN77QT.js.map} +0 -0
  1458. /package/dist/{chunk-XMVFHBHT.js.map → chunk-U3WSW6PZ.js.map} +0 -0
  1459. /package/dist/{chunk-N5AKDXAI.js.map → chunk-UWVJF25J.js.map} +0 -0
  1460. /package/dist/{chunk-MARWOCVP.js.map → chunk-XIG5PDM7.js.map} +0 -0
  1461. /package/dist/{chunk-6XA7UN4Z.js.map → chunk-XVZ7B3HG.js.map} +0 -0
  1462. /package/dist/{graph-edge-decay-PWB63GRE.js.map → graph-edge-decay-5DI5GUNL.js.map} +0 -0
@@ -1,2040 +0,0 @@
1
- import {
2
- isValidConnectorId
3
- } from "./chunk-6TBWYBJ3.js";
4
-
5
- // src/connectors/live/registry.ts
6
- var LiveConnectorRegistryError = class extends Error {
7
- constructor(message) {
8
- super(message);
9
- this.name = "LiveConnectorRegistryError";
10
- }
11
- };
12
- var LiveConnectorRegistry = class {
13
- connectors = /* @__PURE__ */ new Map();
14
- /**
15
- * Register a connector. Throws `LiveConnectorRegistryError` if the id is
16
- * malformed or already registered.
17
- *
18
- * Re-registration is rejected (rather than silently overwriting) because
19
- * silent overwrites mask plugin loading bugs in development and could let
20
- * a malicious extension shadow a built-in connector.
21
- */
22
- register(connector) {
23
- if (!connector || typeof connector !== "object") {
24
- throw new LiveConnectorRegistryError(
25
- "register(): connector must be a non-null object"
26
- );
27
- }
28
- if (!isValidConnectorId(connector.id)) {
29
- throw new LiveConnectorRegistryError(
30
- `register(): invalid connector id ${JSON.stringify(connector.id)} \u2014 must match /^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/`
31
- );
32
- }
33
- if (this.connectors.has(connector.id)) {
34
- throw new LiveConnectorRegistryError(
35
- `register(): connector id ${JSON.stringify(connector.id)} is already registered`
36
- );
37
- }
38
- if (typeof connector.displayName !== "string" || connector.displayName.length === 0) {
39
- throw new LiveConnectorRegistryError(
40
- `register(): connector ${connector.id} missing displayName`
41
- );
42
- }
43
- if (typeof connector.validateConfig !== "function") {
44
- throw new LiveConnectorRegistryError(
45
- `register(): connector ${connector.id} missing validateConfig()`
46
- );
47
- }
48
- if (typeof connector.syncIncremental !== "function") {
49
- throw new LiveConnectorRegistryError(
50
- `register(): connector ${connector.id} missing syncIncremental()`
51
- );
52
- }
53
- this.connectors.set(connector.id, connector);
54
- }
55
- /**
56
- * Look up a connector by id. Returns `undefined` if not registered.
57
- */
58
- get(id) {
59
- return this.connectors.get(id);
60
- }
61
- /**
62
- * Return all registered connectors, sorted by id for stable enumeration.
63
- */
64
- list() {
65
- return Array.from(this.connectors.values()).sort((a, b) => a.id.localeCompare(b.id));
66
- }
67
- /**
68
- * Remove a connector. Returns `true` if a connector was removed, `false`
69
- * otherwise. The cursor / state file on disk is **not** touched — callers
70
- * who want to fully decommission a connector must also delete its state
71
- * file via the `state-store` module.
72
- */
73
- unregister(id) {
74
- return this.connectors.delete(id);
75
- }
76
- /**
77
- * Number of registered connectors. Cheap; safe to call frequently.
78
- */
79
- size() {
80
- return this.connectors.size;
81
- }
82
- };
83
-
84
- // src/connectors/live/transient-errors.ts
85
- var TRANSIENT_NODE_CODES = /* @__PURE__ */ new Set([
86
- "ECONNRESET",
87
- "ECONNREFUSED",
88
- "ECONNABORTED",
89
- "ETIMEDOUT",
90
- "ESOCKETTIMEDOUT",
91
- "ENOTFOUND",
92
- "EAI_AGAIN",
93
- "EPIPE",
94
- "EHOSTUNREACH",
95
- "ENETUNREACH",
96
- "ENETDOWN",
97
- "ERR_NETWORK",
98
- "ERR_NETWORK_CHANGED"
99
- ]);
100
- function resolveHttpStatus(e, statusProps) {
101
- for (const prop of statusProps) {
102
- const v = e[prop];
103
- if (typeof v === "number" && Number.isFinite(v)) return v;
104
- }
105
- const responseStatus = e.response?.status;
106
- if (typeof responseStatus === "number" && Number.isFinite(responseStatus)) {
107
- return responseStatus;
108
- }
109
- if (typeof e.status === "number" && Number.isFinite(e.status)) return e.status;
110
- if (typeof e.code === "number" && Number.isFinite(e.code)) return e.code;
111
- if (typeof e.code === "string" && /^\d+$/.test(e.code)) {
112
- const n = Number(e.code);
113
- if (Number.isFinite(n) && n >= 100 && n <= 599) return n;
114
- }
115
- return void 0;
116
- }
117
- function isTransientHttpError(err, statusProps = []) {
118
- if (err === null || typeof err !== "object") return false;
119
- const e = err;
120
- if (typeof e.name === "string" && e.name === "AbortError") return true;
121
- const status = resolveHttpStatus(e, statusProps);
122
- if (status !== void 0) {
123
- if (status === 429) return true;
124
- if (status >= 500 && status <= 599) return true;
125
- return false;
126
- }
127
- if (typeof e.code === "string") {
128
- if (TRANSIENT_NODE_CODES.has(e.code)) return true;
129
- return false;
130
- }
131
- return true;
132
- }
133
-
134
- // src/connectors/live/google-drive.ts
135
- var GOOGLE_DRIVE_CONNECTOR_ID = "google-drive";
136
- var GOOGLE_DRIVE_CURSOR_KIND = "drivePageToken";
137
- var DEFAULT_POLL_INTERVAL_MS = 5 * 60 * 1e3;
138
- var MAX_POLL_INTERVAL_MS = 24 * 60 * 60 * 1e3;
139
- var MAX_TEXT_BYTES = 5 * 1024 * 1024;
140
- var CLIENT_SECRET_FIELD = ["client", "Secret"].join("");
141
- var REFRESH_TOKEN_FIELD = ["refresh", "Token"].join("");
142
- var MAX_CHANGES_PER_PASS = 200;
143
- var FOLDER_ID_PATTERN = /^[A-Za-z0-9_-]{8,256}$/;
144
- var GOOGLE_NATIVE_EXPORT_MIME = Object.freeze({
145
- "application/vnd.google-apps.document": "text/plain",
146
- "application/vnd.google-apps.spreadsheet": "text/csv",
147
- "application/vnd.google-apps.presentation": "text/plain"
148
- });
149
- var TEXT_MIME_ALLOWLIST = /* @__PURE__ */ new Set([
150
- "text/plain",
151
- "text/markdown",
152
- "text/csv",
153
- "text/html",
154
- "application/json",
155
- "application/xml",
156
- "text/xml"
157
- ]);
158
- function validateGoogleDriveConfig(raw) {
159
- if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
160
- throw new TypeError(
161
- `googleDrive: config must be an object, got ${raw === null ? "null" : Array.isArray(raw) ? "array" : typeof raw}`
162
- );
163
- }
164
- const r = raw;
165
- const clientId = requireNonEmptyString(r.clientId, "clientId");
166
- const clientSecret = requireNonEmptyString(r[CLIENT_SECRET_FIELD], CLIENT_SECRET_FIELD);
167
- const refreshToken = requireNonEmptyString(r[REFRESH_TOKEN_FIELD], REFRESH_TOKEN_FIELD);
168
- let pollIntervalMs;
169
- if (r.pollIntervalMs === void 0) {
170
- pollIntervalMs = DEFAULT_POLL_INTERVAL_MS;
171
- } else if (typeof r.pollIntervalMs !== "number" || !Number.isFinite(r.pollIntervalMs)) {
172
- throw new TypeError(
173
- `googleDrive: pollIntervalMs must be a finite number (got ${JSON.stringify(r.pollIntervalMs)})`
174
- );
175
- } else if (!Number.isInteger(r.pollIntervalMs)) {
176
- throw new TypeError(
177
- `googleDrive: pollIntervalMs must be an integer (got ${r.pollIntervalMs})`
178
- );
179
- } else if (r.pollIntervalMs < 1e3) {
180
- throw new RangeError(
181
- `googleDrive: pollIntervalMs must be \u22651000ms; got ${r.pollIntervalMs}`
182
- );
183
- } else if (r.pollIntervalMs > MAX_POLL_INTERVAL_MS) {
184
- throw new RangeError(
185
- `googleDrive: pollIntervalMs must be \u2264${MAX_POLL_INTERVAL_MS} (24h); got ${r.pollIntervalMs}`
186
- );
187
- } else {
188
- pollIntervalMs = r.pollIntervalMs;
189
- }
190
- let folderIds = [];
191
- if (r.folderIds !== void 0) {
192
- if (!Array.isArray(r.folderIds)) {
193
- throw new TypeError(
194
- `googleDrive: folderIds must be an array of strings (got ${typeof r.folderIds})`
195
- );
196
- }
197
- const seen = /* @__PURE__ */ new Set();
198
- const out = [];
199
- for (const value of r.folderIds) {
200
- if (typeof value !== "string") {
201
- throw new TypeError(
202
- `googleDrive: folderIds entries must be strings; found ${typeof value}`
203
- );
204
- }
205
- const trimmed = value.trim();
206
- if (!FOLDER_ID_PATTERN.test(trimmed)) {
207
- throw new RangeError(
208
- `googleDrive: folderIds entry ${JSON.stringify(value)} is not a valid Drive folder id`
209
- );
210
- }
211
- if (seen.has(trimmed)) continue;
212
- seen.add(trimmed);
213
- out.push(trimmed);
214
- }
215
- folderIds = Object.freeze(out);
216
- }
217
- return Object.freeze({
218
- clientId,
219
- [CLIENT_SECRET_FIELD]: clientSecret,
220
- [REFRESH_TOKEN_FIELD]: refreshToken,
221
- pollIntervalMs,
222
- folderIds
223
- });
224
- }
225
- function requireNonEmptyString(value, key) {
226
- if (typeof value !== "string") {
227
- throw new TypeError(
228
- `googleDrive: ${key} must be a string (got ${typeof value})`
229
- );
230
- }
231
- const trimmed = value.trim();
232
- if (trimmed.length === 0) {
233
- throw new RangeError(`googleDrive: ${key} must be non-empty`);
234
- }
235
- return trimmed;
236
- }
237
- function decideChange(change, folderScope) {
238
- if (change.removed === true) return { kind: "skip-removed" };
239
- const file = change.file;
240
- if (!file || typeof file.id !== "string") return { kind: "skip-removed" };
241
- if (file.trashed === true) return { kind: "skip-trashed" };
242
- if (folderScope.size > 0) {
243
- const parents = file.parents ?? [];
244
- let intersects = false;
245
- for (const parent of parents) {
246
- if (folderScope.has(parent)) {
247
- intersects = true;
248
- break;
249
- }
250
- }
251
- if (!intersects) return { kind: "skip-folder-scope" };
252
- }
253
- if (typeof file.size === "number" && file.size > MAX_TEXT_BYTES) {
254
- return { kind: "skip-too-large" };
255
- }
256
- if (typeof file.size === "string") {
257
- const sizeNum = Number(file.size);
258
- if (Number.isFinite(sizeNum) && sizeNum > MAX_TEXT_BYTES) {
259
- return { kind: "skip-too-large" };
260
- }
261
- }
262
- const mime = file.mimeType;
263
- if (typeof mime !== "string" || mime.length === 0) {
264
- return { kind: "skip-binary" };
265
- }
266
- const exportMime = GOOGLE_NATIVE_EXPORT_MIME[mime];
267
- if (typeof exportMime === "string") {
268
- return { kind: "import", file, mode: "export", exportMime };
269
- }
270
- if (TEXT_MIME_ALLOWLIST.has(mime) || mime.startsWith("text/")) {
271
- return { kind: "import", file, mode: "media" };
272
- }
273
- return { kind: "skip-binary" };
274
- }
275
- function createGoogleDriveConnector(options = {}) {
276
- const clientFactory = options.clientFactory ?? defaultGoogleDriveClientFactory;
277
- return {
278
- id: GOOGLE_DRIVE_CONNECTOR_ID,
279
- displayName: "Google Drive",
280
- description: "Imports text content (Google Docs/Sheets/Slides + plain text) from a user's Drive into Remnic.",
281
- validateConfig(raw) {
282
- return validateGoogleDriveConfig(raw);
283
- },
284
- async syncIncremental(args) {
285
- const config = validateGoogleDriveConfig(args.config);
286
- throwIfAborted(args.abortSignal);
287
- const client = await clientFactory(config);
288
- throwIfAborted(args.abortSignal);
289
- let pageToken;
290
- const isFirstSync = args.cursor === null;
291
- if (isFirstSync) {
292
- const seed = await client.getStartPageToken();
293
- if (typeof seed?.startPageToken !== "string" || seed.startPageToken.length === 0) {
294
- throw new Error("googleDrive: drive.changes.getStartPageToken returned an empty token");
295
- }
296
- return {
297
- newDocs: [],
298
- nextCursor: makeCursor(seed.startPageToken)
299
- };
300
- } else if (args.cursor.kind !== GOOGLE_DRIVE_CURSOR_KIND) {
301
- throw new Error(
302
- `googleDrive: unexpected cursor kind ${JSON.stringify(args.cursor.kind)}; expected ${GOOGLE_DRIVE_CURSOR_KIND}`
303
- );
304
- } else {
305
- pageToken = args.cursor.value;
306
- }
307
- const folderScope = new Set(config.folderIds);
308
- const fetchedAt = (/* @__PURE__ */ new Date()).toISOString();
309
- const newDocs = [];
310
- let skippedBinary = 0;
311
- let skippedFolderScope = 0;
312
- let skippedTooLarge = 0;
313
- let consumed = 0;
314
- let resolvedNextToken;
315
- while (true) {
316
- throwIfAborted(args.abortSignal);
317
- const remaining = MAX_CHANGES_PER_PASS - consumed;
318
- if (remaining <= 0) {
319
- resolvedNextToken = pageToken;
320
- break;
321
- }
322
- const pageSize = Math.min(100, remaining);
323
- const page = await client.listChanges({ pageToken, pageSize });
324
- for (const change of page.changes) {
325
- throwIfAborted(args.abortSignal);
326
- consumed++;
327
- const decision = decideChange(change, folderScope);
328
- switch (decision.kind) {
329
- case "import": {
330
- const doc = await fetchDocument(client, decision, fetchedAt, args.abortSignal);
331
- if (doc) newDocs.push(doc);
332
- break;
333
- }
334
- case "skip-binary":
335
- skippedBinary++;
336
- break;
337
- case "skip-folder-scope":
338
- skippedFolderScope++;
339
- break;
340
- case "skip-too-large":
341
- skippedTooLarge++;
342
- break;
343
- // skip-removed / skip-trashed are intentionally not counted —
344
- // they're upstream-driven and noisy.
345
- default:
346
- break;
347
- }
348
- }
349
- if (typeof page.newStartPageToken === "string" && page.newStartPageToken.length > 0) {
350
- resolvedNextToken = page.newStartPageToken;
351
- break;
352
- }
353
- if (typeof page.nextPageToken === "string" && page.nextPageToken.length > 0) {
354
- pageToken = page.nextPageToken;
355
- continue;
356
- }
357
- resolvedNextToken = pageToken;
358
- break;
359
- }
360
- const nextCursor = makeCursor(
361
- resolvedNextToken ?? pageToken
362
- );
363
- const result = {
364
- newDocs,
365
- nextCursor,
366
- skippedBinary,
367
- skippedFolderScope,
368
- skippedTooLarge
369
- };
370
- return result;
371
- }
372
- };
373
- }
374
- function makeCursor(value) {
375
- return {
376
- kind: GOOGLE_DRIVE_CURSOR_KIND,
377
- value,
378
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
379
- };
380
- }
381
- async function fetchDocument(client, decision, fetchedAt, abortSignal) {
382
- throwIfAborted(abortSignal);
383
- const file = decision.file;
384
- let body;
385
- try {
386
- body = decision.mode === "export" ? await client.exportFile({
387
- fileId: file.id,
388
- mimeType: decision.exportMime ?? "text/plain"
389
- }) : await client.getFileMedia({ fileId: file.id });
390
- } catch (err) {
391
- if (isTransientDriveError(err)) {
392
- throw err;
393
- }
394
- return null;
395
- }
396
- if (typeof body !== "string" || body.length === 0) return null;
397
- if (body.length > MAX_TEXT_BYTES) return null;
398
- return {
399
- id: file.id,
400
- title: typeof file.name === "string" && file.name.length > 0 ? file.name : void 0,
401
- content: body,
402
- source: {
403
- connector: GOOGLE_DRIVE_CONNECTOR_ID,
404
- externalId: file.id,
405
- externalRevision: typeof file.modifiedTime === "string" ? file.modifiedTime : void 0,
406
- externalUrl: typeof file.webViewLink === "string" ? file.webViewLink : void 0,
407
- fetchedAt
408
- }
409
- };
410
- }
411
- function throwIfAborted(signal) {
412
- if (signal?.aborted) {
413
- const err = new Error("googleDrive: sync aborted");
414
- err.name = "AbortError";
415
- throw err;
416
- }
417
- }
418
- function isTransientDriveError(err) {
419
- return isTransientHttpError(err);
420
- }
421
- var defaultGoogleDriveClientFactory = async (config) => {
422
- const specifier = "googleapis";
423
- let mod;
424
- try {
425
- mod = await import(
426
- /* @vite-ignore */
427
- specifier
428
- );
429
- } catch (err) {
430
- throw new Error(
431
- `googleDrive: optional peer dependency \`googleapis\` is not installed. Run \`npm install googleapis\` (or \`pnpm add googleapis\`) in the host package to enable the Google Drive connector. (underlying: ${err.message})`
432
- );
433
- }
434
- const { google } = mod;
435
- const oauth = new google.auth.OAuth2({
436
- clientId: config.clientId,
437
- [CLIENT_SECRET_FIELD]: config[CLIENT_SECRET_FIELD]
438
- });
439
- oauth.setCredentials({ refresh_token: config[REFRESH_TOKEN_FIELD] });
440
- const drive = google.drive({ version: "v3", auth: oauth });
441
- return {
442
- async getStartPageToken() {
443
- const res = await drive.changes.getStartPageToken({});
444
- return { startPageToken: String(res.data.startPageToken ?? "") };
445
- },
446
- async listChanges({ pageToken, pageSize }) {
447
- const res = await drive.changes.list({
448
- pageToken,
449
- pageSize,
450
- fields: "newStartPageToken, nextPageToken, changes(removed, fileId, file(id, name, mimeType, modifiedTime, trashed, parents, webViewLink, size))",
451
- spaces: "drive",
452
- includeRemoved: true
453
- });
454
- const data = res.data ?? {};
455
- return {
456
- changes: data.changes ?? [],
457
- newStartPageToken: data.newStartPageToken ?? void 0,
458
- nextPageToken: data.nextPageToken ?? void 0
459
- };
460
- },
461
- async exportFile({ fileId, mimeType }) {
462
- const res = await drive.files.export(
463
- { fileId, mimeType },
464
- { responseType: "text" }
465
- );
466
- return typeof res.data === "string" ? res.data : String(res.data ?? "");
467
- },
468
- async getFileMedia({ fileId }) {
469
- const res = await drive.files.get(
470
- { fileId, alt: "media" },
471
- { responseType: "text" }
472
- );
473
- return typeof res.data === "string" ? res.data : String(res.data ?? "");
474
- }
475
- };
476
- };
477
-
478
- // src/connectors/live/notion.ts
479
- var NOTION_CONNECTOR_ID = "notion";
480
- var NOTION_CURSOR_KIND = "notionWatermark";
481
- var NOTION_DEFAULT_POLL_INTERVAL_MS = 5 * 60 * 1e3;
482
- var NOTION_MAX_POLL_INTERVAL_MS = 24 * 60 * 60 * 1e3;
483
- var MAX_TEXT_BYTES2 = 5 * 1024 * 1024;
484
- var MAX_BLOCK_DEPTH = 5;
485
- var MAX_PAGES_PER_PASS = 200;
486
- var NOTION_TOKEN_PREFIX = "secret_";
487
- function validateNotionConfig(raw) {
488
- if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
489
- throw new TypeError(
490
- `notion: config must be an object, got ${raw === null ? "null" : Array.isArray(raw) ? "array" : typeof raw}`
491
- );
492
- }
493
- const r = raw;
494
- if (typeof r.token !== "string") {
495
- throw new TypeError(`notion: token must be a string (got ${typeof r.token})`);
496
- }
497
- const token = r.token.trim();
498
- if (token.length === 0) {
499
- throw new RangeError("notion: token must be non-empty");
500
- }
501
- if (!token.startsWith(NOTION_TOKEN_PREFIX)) {
502
- throw new RangeError(
503
- `notion: token must start with "${NOTION_TOKEN_PREFIX}" (looks like a non-integration token)`
504
- );
505
- }
506
- let pollIntervalMs;
507
- if (r.pollIntervalMs === void 0) {
508
- pollIntervalMs = NOTION_DEFAULT_POLL_INTERVAL_MS;
509
- } else if (typeof r.pollIntervalMs !== "number" || !Number.isFinite(r.pollIntervalMs)) {
510
- throw new TypeError(
511
- `notion: pollIntervalMs must be a finite number (got ${JSON.stringify(r.pollIntervalMs)})`
512
- );
513
- } else if (!Number.isInteger(r.pollIntervalMs)) {
514
- throw new TypeError(`notion: pollIntervalMs must be an integer (got ${r.pollIntervalMs})`);
515
- } else if (r.pollIntervalMs < 1e3) {
516
- throw new RangeError(`notion: pollIntervalMs must be \u22651000ms; got ${r.pollIntervalMs}`);
517
- } else if (r.pollIntervalMs > NOTION_MAX_POLL_INTERVAL_MS) {
518
- throw new RangeError(
519
- `notion: pollIntervalMs must be \u2264${NOTION_MAX_POLL_INTERVAL_MS} (24h); got ${r.pollIntervalMs}`
520
- );
521
- } else {
522
- pollIntervalMs = r.pollIntervalMs;
523
- }
524
- let databaseIds = [];
525
- if (r.databaseIds !== void 0) {
526
- if (!Array.isArray(r.databaseIds)) {
527
- throw new TypeError(
528
- `notion: databaseIds must be an array of strings (got ${typeof r.databaseIds})`
529
- );
530
- }
531
- const seen = /* @__PURE__ */ new Set();
532
- const out = [];
533
- for (const value of r.databaseIds) {
534
- if (typeof value !== "string") {
535
- throw new TypeError(
536
- `notion: databaseIds entries must be strings; found ${typeof value}`
537
- );
538
- }
539
- const trimmed = value.trim();
540
- if (!isValidNotionId(trimmed)) {
541
- throw new RangeError(
542
- `notion: databaseIds entry ${JSON.stringify(value)} is not a valid Notion id`
543
- );
544
- }
545
- if (seen.has(trimmed)) continue;
546
- seen.add(trimmed);
547
- out.push(trimmed);
548
- }
549
- databaseIds = Object.freeze(out);
550
- }
551
- return Object.freeze({ token, databaseIds, pollIntervalMs });
552
- }
553
- function isValidNotionId(value) {
554
- if (/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value)) {
555
- return true;
556
- }
557
- if (/^[0-9a-f]{32}$/i.test(value)) {
558
- return true;
559
- }
560
- return false;
561
- }
562
- function makeCursor2(payload) {
563
- return {
564
- kind: NOTION_CURSOR_KIND,
565
- value: JSON.stringify(payload),
566
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
567
- };
568
- }
569
- function parseCursorPayload(cursor) {
570
- if (cursor.kind !== NOTION_CURSOR_KIND) {
571
- throw new Error(
572
- `notion: unexpected cursor kind ${JSON.stringify(cursor.kind)}; expected ${NOTION_CURSOR_KIND}`
573
- );
574
- }
575
- let parsed;
576
- try {
577
- parsed = JSON.parse(cursor.value);
578
- } catch {
579
- throw new Error(`notion: cursor value is not valid JSON`);
580
- }
581
- if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
582
- throw new Error(`notion: cursor value does not match NotionCursorPayload shape`);
583
- }
584
- const p = parsed;
585
- const pages = typeof p.pages === "object" && p.pages !== null && !Array.isArray(p.pages) ? p.pages : {};
586
- const databases = typeof p.databases === "object" && p.databases !== null && !Array.isArray(p.databases) ? p.databases : {};
587
- return { pages, databases };
588
- }
589
- function isTransientNotionError(err) {
590
- return isTransientHttpError(err, ["notionStatus"]);
591
- }
592
- var NOTION_BASE_URL = "https://api.notion.com/v1";
593
- var NOTION_API_VERSION = "2022-06-28";
594
- function throwIfAborted2(signal) {
595
- if (signal?.aborted) {
596
- const err = new Error("notion: sync aborted");
597
- err.name = "AbortError";
598
- throw err;
599
- }
600
- }
601
- function makeNotionApiError(apiErr) {
602
- const err = new Error(
603
- `notion: API error ${apiErr.status} (${apiErr.code}): ${apiErr.message}`
604
- );
605
- err.notionStatus = apiErr.status;
606
- return err;
607
- }
608
- async function notionFetch(fetchFn, token, path, body, signal) {
609
- const url = `${NOTION_BASE_URL}${path}`;
610
- const res = await fetchFn(url, {
611
- method: "POST",
612
- headers: {
613
- Authorization: `Bearer ${token}`,
614
- "Notion-Version": NOTION_API_VERSION,
615
- "Content-Type": "application/json"
616
- },
617
- body: JSON.stringify(body),
618
- signal
619
- });
620
- const data = await res.json();
621
- if (!res.ok) {
622
- if (typeof data === "object" && data !== null && data.object === "error") {
623
- throw makeNotionApiError(data);
624
- }
625
- const err = new Error(`notion: HTTP ${res.status}`);
626
- err.notionStatus = res.status;
627
- throw err;
628
- }
629
- return data;
630
- }
631
- async function notionGet(fetchFn, token, path, signal) {
632
- const url = `${NOTION_BASE_URL}${path}`;
633
- const res = await fetchFn(url, {
634
- method: "GET",
635
- headers: {
636
- Authorization: `Bearer ${token}`,
637
- "Notion-Version": NOTION_API_VERSION
638
- },
639
- signal
640
- });
641
- const data = await res.json();
642
- if (!res.ok) {
643
- if (typeof data === "object" && data !== null && data.object === "error") {
644
- throw makeNotionApiError(data);
645
- }
646
- const err = new Error(`notion: HTTP ${res.status}`);
647
- err.notionStatus = res.status;
648
- throw err;
649
- }
650
- return data;
651
- }
652
- function extractRichText(richText) {
653
- if (!Array.isArray(richText)) return "";
654
- return richText.map((span) => {
655
- if (typeof span !== "object" || span === null) return "";
656
- return typeof span.plain_text === "string" ? span.plain_text : "";
657
- }).join("");
658
- }
659
- function extractBlockText(block) {
660
- const type = block.type;
661
- const blockData = block[type];
662
- if (typeof blockData !== "object" || blockData === null) return "";
663
- const data = blockData;
664
- if (Array.isArray(data.rich_text)) {
665
- const text = extractRichText(data.rich_text);
666
- if (text.length > 0) {
667
- if (type === "heading_1") return `# ${text}`;
668
- if (type === "heading_2") return `## ${text}`;
669
- if (type === "heading_3") return `### ${text}`;
670
- if (type === "to_do") {
671
- const checked = data.checked === true;
672
- return `- [${checked ? "x" : " "}] ${text}`;
673
- }
674
- if (type === "bulleted_list_item" || type === "numbered_list_item") {
675
- return `- ${text}`;
676
- }
677
- return text;
678
- }
679
- return "";
680
- }
681
- if (type === "code" && Array.isArray(data.rich_text)) {
682
- return extractRichText(data.rich_text);
683
- }
684
- return "";
685
- }
686
- async function fetchPageText(fetchFn, token, blockId, depth, signal) {
687
- if (depth > MAX_BLOCK_DEPTH) return "";
688
- throwIfAborted2(signal);
689
- const lines = [];
690
- let cursor = void 0;
691
- while (true) {
692
- throwIfAborted2(signal);
693
- const pathQuery = cursor ? `/blocks/${blockId}/children?page_size=100&start_cursor=${encodeURIComponent(cursor)}` : `/blocks/${blockId}/children?page_size=100`;
694
- const data = await notionGet(fetchFn, token, pathQuery, signal);
695
- if (typeof data !== "object" || data === null) break;
696
- const page = data;
697
- for (const block of page.results ?? []) {
698
- throwIfAborted2(signal);
699
- const text = extractBlockText(block);
700
- if (text.length > 0) lines.push(text);
701
- if (block.has_children && depth < MAX_BLOCK_DEPTH) {
702
- const childText = await fetchPageText(
703
- fetchFn,
704
- token,
705
- block.id,
706
- depth + 1,
707
- signal
708
- );
709
- if (childText.length > 0) lines.push(childText);
710
- }
711
- const currentSize = lines.reduce((acc, l) => acc + l.length + 1, 0);
712
- if (currentSize >= MAX_TEXT_BYTES2) break;
713
- }
714
- if (!page.has_more || typeof page.next_cursor !== "string" || page.next_cursor === null) {
715
- break;
716
- }
717
- cursor = page.next_cursor;
718
- }
719
- return lines.join("\n");
720
- }
721
- function extractPageTitle(page) {
722
- if (typeof page.properties !== "object" || page.properties === null) return void 0;
723
- for (const prop of Object.values(page.properties)) {
724
- if (prop.type === "title" && Array.isArray(prop.title)) {
725
- const text = prop.title.map((t) => t.plain_text ?? "").join("");
726
- if (text.trim().length > 0) return text.trim();
727
- }
728
- }
729
- return void 0;
730
- }
731
- function createNotionConnector(options = {}) {
732
- const fetchFn = options.fetchFn ?? // Use global fetch (available in Node.js 18+). The cast is safe — we
733
- // only use the subset defined in `NotionFetchFn`.
734
- globalThis.fetch;
735
- return {
736
- id: NOTION_CONNECTOR_ID,
737
- displayName: "Notion",
738
- description: "Imports text content from Notion database pages into Remnic on a poll schedule.",
739
- validateConfig(raw) {
740
- return validateNotionConfig(raw);
741
- },
742
- async syncIncremental(args) {
743
- const config = validateNotionConfig(args.config);
744
- throwIfAborted2(args.abortSignal);
745
- if (config.databaseIds.length === 0) {
746
- const emptyPayload = { pages: {}, databases: {} };
747
- const result = {
748
- newDocs: [],
749
- nextCursor: makeCursor2(emptyPayload),
750
- skippedUnchanged: 0,
751
- skippedTooLarge: 0,
752
- skippedEmpty: 0
753
- };
754
- return result;
755
- }
756
- const isFirstSync = args.cursor === null;
757
- const payload = isFirstSync ? { pages: {}, databases: {} } : parseCursorPayload(args.cursor);
758
- if (isFirstSync) {
759
- const seedPayload = await seedWatermark(
760
- fetchFn,
761
- config,
762
- payload,
763
- args.abortSignal
764
- );
765
- return {
766
- newDocs: [],
767
- nextCursor: makeCursor2(seedPayload),
768
- skippedUnchanged: 0,
769
- skippedTooLarge: 0,
770
- skippedEmpty: 0
771
- };
772
- }
773
- return await incrementalSync(fetchFn, config, payload, args.abortSignal);
774
- }
775
- };
776
- }
777
- async function seedWatermark(fetchFn, config, payload, signal) {
778
- const pages = { ...payload.pages };
779
- const databases = { ...payload.databases };
780
- for (const dbId of config.databaseIds) {
781
- throwIfAborted2(signal);
782
- let notionCursor = void 0;
783
- let latestInDb = "";
784
- while (true) {
785
- throwIfAborted2(signal);
786
- const body = { page_size: 100, sorts: [] };
787
- if (notionCursor) body.start_cursor = notionCursor;
788
- const data = await notionFetch(
789
- fetchFn,
790
- config.token,
791
- `/databases/${dbId}/query`,
792
- body,
793
- signal
794
- );
795
- if (typeof data !== "object" || data === null) break;
796
- const page = data;
797
- for (const p of page.results ?? []) {
798
- if (typeof p.id === "string" && typeof p.last_edited_time === "string") {
799
- pages[p.id] = p.last_edited_time;
800
- if (!latestInDb || p.last_edited_time > latestInDb) {
801
- latestInDb = p.last_edited_time;
802
- }
803
- }
804
- }
805
- if (!page.has_more || typeof page.next_cursor !== "string" || page.next_cursor === null) {
806
- break;
807
- }
808
- notionCursor = page.next_cursor;
809
- }
810
- if (latestInDb) databases[dbId] = latestInDb;
811
- }
812
- return { pages, databases };
813
- }
814
- async function incrementalSync(fetchFn, config, payload, signal) {
815
- const fetchedAt = (/* @__PURE__ */ new Date()).toISOString();
816
- const newDocs = [];
817
- const updatedPages = { ...payload.pages };
818
- const updatedDatabases = { ...payload.databases };
819
- let skippedUnchanged = 0;
820
- let skippedTooLarge = 0;
821
- let skippedEmpty = 0;
822
- let totalConsumed = 0;
823
- for (const dbId of config.databaseIds) {
824
- throwIfAborted2(signal);
825
- if (totalConsumed >= MAX_PAGES_PER_PASS) break;
826
- const dbWatermark = payload.databases[dbId];
827
- let notionCursor = void 0;
828
- let latestInDb = dbWatermark ?? "";
829
- let databaseFullyDrained = false;
830
- while (true) {
831
- throwIfAborted2(signal);
832
- if (totalConsumed >= MAX_PAGES_PER_PASS) break;
833
- const body = {
834
- page_size: 100,
835
- sorts: [
836
- {
837
- timestamp: "last_edited_time",
838
- direction: "descending"
839
- }
840
- ]
841
- };
842
- if (dbWatermark) {
843
- body.filter = {
844
- timestamp: "last_edited_time",
845
- last_edited_time: { after: dbWatermark }
846
- };
847
- }
848
- if (notionCursor) body.start_cursor = notionCursor;
849
- const data = await notionFetch(
850
- fetchFn,
851
- config.token,
852
- `/databases/${dbId}/query`,
853
- body,
854
- signal
855
- );
856
- if (typeof data !== "object" || data === null) break;
857
- const pageResp = data;
858
- let cutoffMidPage = false;
859
- for (const notionPage of pageResp.results ?? []) {
860
- throwIfAborted2(signal);
861
- totalConsumed++;
862
- const pageId = notionPage.id;
863
- const lastEdited = notionPage.last_edited_time;
864
- if (typeof pageId !== "string" || typeof lastEdited !== "string") continue;
865
- const knownRevision = payload.pages[pageId];
866
- if (knownRevision && knownRevision >= lastEdited) {
867
- skippedUnchanged++;
868
- continue;
869
- }
870
- const doc = await fetchPageDocument(
871
- fetchFn,
872
- config.token,
873
- notionPage,
874
- fetchedAt,
875
- signal
876
- );
877
- if (doc === "too-large") {
878
- skippedTooLarge++;
879
- updatedPages[pageId] = lastEdited;
880
- } else if (doc === "empty") {
881
- skippedEmpty++;
882
- updatedPages[pageId] = lastEdited;
883
- } else if (doc !== null) {
884
- newDocs.push(doc);
885
- updatedPages[pageId] = lastEdited;
886
- if (!latestInDb || lastEdited > latestInDb) {
887
- latestInDb = lastEdited;
888
- }
889
- } else {
890
- updatedPages[pageId] = lastEdited;
891
- }
892
- if (totalConsumed >= MAX_PAGES_PER_PASS) {
893
- cutoffMidPage = true;
894
- break;
895
- }
896
- }
897
- if (cutoffMidPage) {
898
- break;
899
- }
900
- if (pageResp.has_more === true) {
901
- if (typeof pageResp.next_cursor === "string" && pageResp.next_cursor.length > 0) {
902
- notionCursor = pageResp.next_cursor;
903
- continue;
904
- }
905
- break;
906
- }
907
- databaseFullyDrained = true;
908
- break;
909
- }
910
- if (databaseFullyDrained && latestInDb) {
911
- updatedDatabases[dbId] = latestInDb;
912
- }
913
- }
914
- const nextCursor = makeCursor2({ pages: updatedPages, databases: updatedDatabases });
915
- return {
916
- newDocs,
917
- nextCursor,
918
- skippedUnchanged,
919
- skippedTooLarge,
920
- skippedEmpty
921
- };
922
- }
923
- async function fetchPageDocument(fetchFn, token, notionPage, fetchedAt, signal) {
924
- throwIfAborted2(signal);
925
- let text;
926
- try {
927
- text = await fetchPageText(fetchFn, token, notionPage.id, 0, signal);
928
- } catch (err) {
929
- if (isTransientNotionError(err)) {
930
- throw err;
931
- }
932
- return null;
933
- }
934
- if (typeof text !== "string" || text.trim().length === 0) return "empty";
935
- if (text.length > MAX_TEXT_BYTES2) return "too-large";
936
- const title = extractPageTitle(notionPage);
937
- return {
938
- id: notionPage.id,
939
- title,
940
- content: text,
941
- source: {
942
- connector: NOTION_CONNECTOR_ID,
943
- externalId: notionPage.id,
944
- externalRevision: notionPage.last_edited_time,
945
- externalUrl: typeof notionPage.url === "string" ? notionPage.url : void 0,
946
- fetchedAt
947
- }
948
- };
949
- }
950
-
951
- // src/connectors/live/gmail.ts
952
- var GMAIL_CONNECTOR_ID = "gmail";
953
- var GMAIL_CURSOR_KIND = "gmailWatermark";
954
- var GMAIL_DEFAULT_POLL_INTERVAL_MS = 5 * 60 * 1e3;
955
- var GMAIL_MAX_POLL_INTERVAL_MS = 24 * 60 * 60 * 1e3;
956
- var MAX_TEXT_BYTES3 = 2 * 1024 * 1024;
957
- var CLIENT_SECRET_FIELD2 = ["client", "Secret"].join("");
958
- var REFRESH_TOKEN_FIELD2 = ["refresh", "Token"].join("");
959
- var MAX_MESSAGES_PER_PASS = 200;
960
- var LIST_PAGE_SIZE = 100;
961
- var SEEN_IDS_MAX = 1e3;
962
- var SEEN_IDS_RETAIN = 500;
963
- var SKIPPED_IDS_MAX = 5e3;
964
- var SKIPPED_IDS_RETAIN = 2500;
965
- var GMAIL_API_BASE = "https://gmail.googleapis.com/gmail/v1";
966
- var OAUTH2_TOKEN_URL = "https://oauth2.googleapis.com/token";
967
- function validateGmailConfig(raw) {
968
- if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
969
- throw new TypeError(
970
- `gmail: config must be an object, got ${raw === null ? "null" : Array.isArray(raw) ? "array" : typeof raw}`
971
- );
972
- }
973
- const r = raw;
974
- const clientId = requireNonEmptyString2(r.clientId, "clientId");
975
- const clientSecret = requireNonEmptyString2(r[CLIENT_SECRET_FIELD2], CLIENT_SECRET_FIELD2);
976
- const refreshToken = requireNonEmptyString2(r[REFRESH_TOKEN_FIELD2], REFRESH_TOKEN_FIELD2);
977
- let userId = "me";
978
- if (r.userId !== void 0) {
979
- if (typeof r.userId !== "string") {
980
- throw new TypeError(`gmail: userId must be a string (got ${typeof r.userId})`);
981
- }
982
- const trimmed = r.userId.trim();
983
- if (trimmed.length === 0) {
984
- throw new RangeError("gmail: userId must be non-empty");
985
- }
986
- userId = trimmed;
987
- }
988
- let query = "in:inbox";
989
- if (r.query !== void 0) {
990
- if (typeof r.query !== "string") {
991
- throw new TypeError(`gmail: query must be a string (got ${typeof r.query})`);
992
- }
993
- query = r.query;
994
- }
995
- let pollIntervalMs;
996
- if (r.pollIntervalMs === void 0) {
997
- pollIntervalMs = GMAIL_DEFAULT_POLL_INTERVAL_MS;
998
- } else if (typeof r.pollIntervalMs !== "number" || !Number.isFinite(r.pollIntervalMs)) {
999
- throw new TypeError(
1000
- `gmail: pollIntervalMs must be a finite number (got ${JSON.stringify(r.pollIntervalMs)})`
1001
- );
1002
- } else if (!Number.isInteger(r.pollIntervalMs)) {
1003
- throw new TypeError(
1004
- `gmail: pollIntervalMs must be an integer (got ${r.pollIntervalMs})`
1005
- );
1006
- } else if (r.pollIntervalMs < 1e3) {
1007
- throw new RangeError(
1008
- `gmail: pollIntervalMs must be \u22651000ms; got ${r.pollIntervalMs}`
1009
- );
1010
- } else if (r.pollIntervalMs > GMAIL_MAX_POLL_INTERVAL_MS) {
1011
- throw new RangeError(
1012
- `gmail: pollIntervalMs must be \u2264${GMAIL_MAX_POLL_INTERVAL_MS} (24h); got ${r.pollIntervalMs}`
1013
- );
1014
- } else {
1015
- pollIntervalMs = r.pollIntervalMs;
1016
- }
1017
- return Object.freeze({
1018
- clientId,
1019
- [CLIENT_SECRET_FIELD2]: clientSecret,
1020
- [REFRESH_TOKEN_FIELD2]: refreshToken,
1021
- userId,
1022
- query,
1023
- pollIntervalMs
1024
- });
1025
- }
1026
- function requireNonEmptyString2(value, key) {
1027
- if (typeof value !== "string") {
1028
- throw new TypeError(`gmail: ${key} must be a string (got ${typeof value})`);
1029
- }
1030
- const trimmed = value.trim();
1031
- if (trimmed.length === 0) {
1032
- throw new RangeError(`gmail: ${key} must be non-empty`);
1033
- }
1034
- return trimmed;
1035
- }
1036
- function isTransientGmailError(err) {
1037
- return isTransientHttpError(err, ["gmailStatus"]);
1038
- }
1039
- function makeCursor3(payload) {
1040
- return {
1041
- kind: GMAIL_CURSOR_KIND,
1042
- value: JSON.stringify(payload),
1043
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
1044
- };
1045
- }
1046
- function parseCursorPayload2(cursor) {
1047
- if (cursor.kind !== GMAIL_CURSOR_KIND) {
1048
- throw new Error(
1049
- `gmail: unexpected cursor kind ${JSON.stringify(cursor.kind)}; expected ${GMAIL_CURSOR_KIND}`
1050
- );
1051
- }
1052
- let parsed;
1053
- try {
1054
- parsed = JSON.parse(cursor.value);
1055
- } catch {
1056
- throw new Error(`gmail: cursor value is not valid JSON`);
1057
- }
1058
- if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
1059
- throw new Error(`gmail: cursor value does not match GmailCursorPayload shape`);
1060
- }
1061
- const p = parsed;
1062
- let watermarkMs = "";
1063
- if (typeof p.watermarkMs === "string" && p.watermarkMs.length > 0) {
1064
- watermarkMs = p.watermarkMs;
1065
- } else if (typeof p.watermarkIso === "string" && p.watermarkIso.length > 0) {
1066
- const ms = new Date(p.watermarkIso).getTime();
1067
- if (Number.isFinite(ms) && ms > 0) {
1068
- watermarkMs = String(ms);
1069
- }
1070
- }
1071
- let skippedIds = {};
1072
- if (typeof p.skippedIds === "object" && p.skippedIds !== null && !Array.isArray(p.skippedIds)) {
1073
- const raw = p.skippedIds;
1074
- for (const [id, val] of Object.entries(raw)) {
1075
- skippedIds[id] = typeof val === "string" ? val : "0";
1076
- }
1077
- }
1078
- let seenIds = {};
1079
- if (typeof p.seenIds === "object" && p.seenIds !== null && !Array.isArray(p.seenIds)) {
1080
- seenIds = p.seenIds;
1081
- }
1082
- const pageToken = typeof p.pageToken === "string" && p.pageToken.length > 0 ? p.pageToken : void 0;
1083
- return { watermarkMs, skippedIds, seenIds, pageToken };
1084
- }
1085
- function pruneSeenIds(seenIds, watermarkMs) {
1086
- const floorSecBoundaryMs = Math.floor(watermarkMs / 1e3) * 1e3;
1087
- let pruned = {};
1088
- for (const [id, dateMs] of Object.entries(seenIds)) {
1089
- if (Number(dateMs) > floorSecBoundaryMs) {
1090
- pruned[id] = dateMs;
1091
- }
1092
- }
1093
- const entries = Object.entries(pruned);
1094
- if (entries.length > SEEN_IDS_MAX) {
1095
- entries.sort((a, b) => {
1096
- const diff = Number(b[1]) - Number(a[1]);
1097
- return diff !== 0 ? diff : a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0;
1098
- });
1099
- const retained = entries.slice(0, SEEN_IDS_RETAIN);
1100
- pruned = Object.fromEntries(retained);
1101
- }
1102
- return pruned;
1103
- }
1104
- function pruneSkippedIds(skippedIds, watermarkMs) {
1105
- let pruned = {};
1106
- for (const [id, dateMs] of Object.entries(skippedIds)) {
1107
- const ms = Number(dateMs);
1108
- if (ms === 0 || ms >= watermarkMs) {
1109
- pruned[id] = dateMs;
1110
- }
1111
- }
1112
- const entries = Object.entries(pruned);
1113
- if (entries.length > SKIPPED_IDS_MAX) {
1114
- entries.sort((a, b) => {
1115
- const diff = Number(b[1]) - Number(a[1]);
1116
- return diff !== 0 ? diff : a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0;
1117
- });
1118
- const retained = entries.slice(0, SKIPPED_IDS_RETAIN);
1119
- pruned = Object.fromEntries(retained);
1120
- }
1121
- return pruned;
1122
- }
1123
- function throwIfAborted3(signal) {
1124
- if (signal?.aborted) {
1125
- const err = new Error("gmail: sync aborted");
1126
- err.name = "AbortError";
1127
- throw err;
1128
- }
1129
- }
1130
- function makeGmailApiError(status, message) {
1131
- const err = new Error(`gmail: API error ${status}: ${message}`);
1132
- err.gmailStatus = status;
1133
- return err;
1134
- }
1135
- async function gmailGet(fetchFn, accessToken, path, signal) {
1136
- const url = `${GMAIL_API_BASE}${path}`;
1137
- const res = await fetchFn(url, {
1138
- method: "GET",
1139
- headers: {
1140
- Authorization: `Bearer ${accessToken}`,
1141
- Accept: "application/json"
1142
- },
1143
- signal
1144
- });
1145
- const data = await res.json();
1146
- if (!res.ok) {
1147
- const msg = extractApiErrorMessage(data);
1148
- throw makeGmailApiError(res.status, msg);
1149
- }
1150
- return data;
1151
- }
1152
- function extractApiErrorMessage(data) {
1153
- if (typeof data === "object" && data !== null && typeof data.error === "object") {
1154
- const errObj = data.error;
1155
- if (typeof errObj.message === "string") return errObj.message;
1156
- }
1157
- return "unknown error";
1158
- }
1159
- async function exchangeRefreshToken(fetchFn, config, signal) {
1160
- throwIfAborted3(signal);
1161
- const body = new URLSearchParams({
1162
- client_id: config.clientId,
1163
- client_secret: config[CLIENT_SECRET_FIELD2],
1164
- refresh_token: config[REFRESH_TOKEN_FIELD2],
1165
- grant_type: "refresh_token"
1166
- });
1167
- const res = await fetchFn(OAUTH2_TOKEN_URL, {
1168
- method: "POST",
1169
- headers: {
1170
- "Content-Type": "application/x-www-form-urlencoded"
1171
- },
1172
- body: body.toString(),
1173
- signal
1174
- });
1175
- const data = await res.json();
1176
- if (!res.ok) {
1177
- throw makeGmailApiError(
1178
- res.status,
1179
- `OAuth2 token exchange failed (HTTP ${res.status})`
1180
- );
1181
- }
1182
- if (typeof data !== "object" || data === null || typeof data.access_token !== "string") {
1183
- throw new Error("gmail: OAuth2 token exchange returned no access_token");
1184
- }
1185
- return data.access_token;
1186
- }
1187
- function extractBodyFromPart(part) {
1188
- const mime = part.mimeType ?? "";
1189
- if (mime === "text/plain") {
1190
- return decodeBase64urlBody(part.body?.data ?? "");
1191
- }
1192
- if (mime === "text/html") {
1193
- const raw = decodeBase64urlBody(part.body?.data ?? "");
1194
- return stripHtmlTags(raw);
1195
- }
1196
- if (mime.startsWith("multipart/") && Array.isArray(part.parts)) {
1197
- for (const child of part.parts) {
1198
- if ((child.mimeType ?? "") === "text/plain") {
1199
- const text = decodeBase64urlBody(child.body?.data ?? "");
1200
- if (text.length > 0) return text;
1201
- }
1202
- }
1203
- for (const child of part.parts) {
1204
- const text = extractBodyFromPart(child);
1205
- if (text.length > 0) return text;
1206
- }
1207
- }
1208
- return "";
1209
- }
1210
- function decodeBase64urlBody(encoded) {
1211
- if (!encoded) return "";
1212
- try {
1213
- const base64 = encoded.replace(/-/g, "+").replace(/_/g, "/");
1214
- const padded = base64 + "=".repeat((4 - base64.length % 4) % 4);
1215
- return Buffer.from(padded, "base64").toString("utf-8");
1216
- } catch {
1217
- return "";
1218
- }
1219
- }
1220
- function stripHtmlTags(html) {
1221
- if (!html) return "";
1222
- const noTags = html.replace(/<[^>]*>/g, " ");
1223
- const HTML_ENTITIES = {
1224
- "&nbsp;": " ",
1225
- "&amp;": "&",
1226
- "&lt;": "<",
1227
- "&gt;": ">",
1228
- "&quot;": '"',
1229
- "&#39;": "'",
1230
- "&apos;": "'"
1231
- };
1232
- const decoded = noTags.replace(/&(?:#39|nbsp|amp|lt|gt|quot|apos);/gi, (entity) => {
1233
- return HTML_ENTITIES[entity.toLowerCase()] ?? entity;
1234
- });
1235
- return decoded.replace(/\s{2,}/g, " ").trim();
1236
- }
1237
- function extractSubject(message) {
1238
- const headers = message.payload?.headers ?? [];
1239
- for (const h of headers) {
1240
- if (typeof h.name === "string" && h.name.toLowerCase() === "subject") {
1241
- const v = h.value;
1242
- if (typeof v === "string" && v.trim().length > 0) return v.trim();
1243
- }
1244
- }
1245
- return void 0;
1246
- }
1247
- function createGmailConnector(options = {}) {
1248
- const fetchFn = options.fetchFn ?? globalThis.fetch;
1249
- return {
1250
- id: GMAIL_CONNECTOR_ID,
1251
- displayName: "Gmail",
1252
- description: "Imports new inbox messages from Gmail into Remnic on a poll schedule.",
1253
- validateConfig(raw) {
1254
- return validateGmailConfig(raw);
1255
- },
1256
- async syncIncremental(args) {
1257
- const config = validateGmailConfig(args.config);
1258
- throwIfAborted3(args.abortSignal);
1259
- const accessToken = await exchangeRefreshToken(fetchFn, config, args.abortSignal);
1260
- throwIfAborted3(args.abortSignal);
1261
- if (args.cursor === null) {
1262
- const bootstrapResult = {
1263
- newDocs: [],
1264
- nextCursor: makeCursor3({
1265
- watermarkMs: String(Date.now()),
1266
- skippedIds: {},
1267
- seenIds: {}
1268
- }),
1269
- skippedInaccessible: 0,
1270
- skippedEmpty: 0,
1271
- skippedTooLarge: 0
1272
- };
1273
- return bootstrapResult;
1274
- }
1275
- const cursorPayload = parseCursorPayload2(args.cursor);
1276
- return await incrementalSync2(
1277
- fetchFn,
1278
- accessToken,
1279
- config,
1280
- cursorPayload,
1281
- args.abortSignal
1282
- );
1283
- }
1284
- };
1285
- }
1286
- async function incrementalSync2(fetchFn, accessToken, config, cursorPayload, signal) {
1287
- const fetchedAt = (/* @__PURE__ */ new Date()).toISOString();
1288
- const newDocs = [];
1289
- let skippedInaccessible = 0;
1290
- let skippedEmpty = 0;
1291
- let skippedTooLarge = 0;
1292
- let totalConsumed = 0;
1293
- let currentWatermarkMs = 0;
1294
- let afterEpochSec = 0;
1295
- if (cursorPayload.watermarkMs.length > 0) {
1296
- const ms = Number(cursorPayload.watermarkMs);
1297
- if (Number.isFinite(ms) && ms > 0) {
1298
- currentWatermarkMs = ms;
1299
- afterEpochSec = Math.floor(ms / 1e3);
1300
- }
1301
- }
1302
- const listQuery = buildListQuery(afterEpochSec, config.query);
1303
- const seenIds = { ...cursorPayload.seenIds };
1304
- const skippedIds = { ...cursorPayload.skippedIds };
1305
- let highWaterMs = currentWatermarkMs;
1306
- let pageToken = cursorPayload.pageToken;
1307
- let listFullyDrained = false;
1308
- let capHit = false;
1309
- let capHitPageToken = void 0;
1310
- while (true) {
1311
- throwIfAborted3(signal);
1312
- let listPath = `/users/${encodeURIComponent(config.userId)}/messages?maxResults=${LIST_PAGE_SIZE}&q=${encodeURIComponent(listQuery)}`;
1313
- if (pageToken) {
1314
- listPath += `&pageToken=${encodeURIComponent(pageToken)}`;
1315
- }
1316
- let listData;
1317
- try {
1318
- listData = await gmailGet(fetchFn, accessToken, listPath, signal);
1319
- } catch (listErr) {
1320
- const listErrObj = listErr;
1321
- if (pageToken !== void 0 && listErrObj !== null && typeof listErrObj === "object" && listErrObj.gmailStatus === 400) {
1322
- pageToken = void 0;
1323
- listPath = `/users/${encodeURIComponent(config.userId)}/messages?maxResults=${LIST_PAGE_SIZE}&q=${encodeURIComponent(listQuery)}`;
1324
- listData = await gmailGet(fetchFn, accessToken, listPath, signal);
1325
- } else {
1326
- throw listErr;
1327
- }
1328
- }
1329
- throwIfAborted3(signal);
1330
- const listPage = listData;
1331
- const messages = listPage.messages ?? [];
1332
- let capHitMidPage = false;
1333
- for (const ref of messages) {
1334
- throwIfAborted3(signal);
1335
- if (skippedIds[ref.id]) {
1336
- continue;
1337
- }
1338
- if (seenIds[ref.id] !== void 0) {
1339
- continue;
1340
- }
1341
- if (totalConsumed >= MAX_MESSAGES_PER_PASS) {
1342
- capHitMidPage = true;
1343
- break;
1344
- }
1345
- totalConsumed++;
1346
- const doc = await fetchMessageDocument(
1347
- fetchFn,
1348
- accessToken,
1349
- config,
1350
- ref.id,
1351
- fetchedAt,
1352
- signal
1353
- );
1354
- if (doc === "inaccessible") {
1355
- skippedInaccessible++;
1356
- skippedIds[ref.id] = "0";
1357
- } else if (doc !== null && typeof doc === "object" && "kind" in doc) {
1358
- if (doc.kind === "empty") skippedEmpty++;
1359
- else skippedTooLarge++;
1360
- skippedIds[ref.id] = doc.internalDate.length > 0 ? doc.internalDate : "0";
1361
- const skippedMs = Number(doc.internalDate);
1362
- if (Number.isFinite(skippedMs) && skippedMs > highWaterMs) {
1363
- highWaterMs = skippedMs;
1364
- }
1365
- } else if (doc !== null) {
1366
- newDocs.push(doc);
1367
- const successDoc = doc;
1368
- if (successDoc.source.externalRevision) {
1369
- const msgMs = Number(successDoc.source.externalRevision);
1370
- if (Number.isFinite(msgMs) && msgMs > highWaterMs) {
1371
- highWaterMs = msgMs;
1372
- }
1373
- seenIds[ref.id] = successDoc.source.externalRevision;
1374
- }
1375
- }
1376
- }
1377
- const hasNextPage = typeof listPage.nextPageToken === "string" && listPage.nextPageToken.length > 0;
1378
- const resolvedNextPageToken = hasNextPage ? listPage.nextPageToken : void 0;
1379
- if (capHitMidPage) {
1380
- capHit = true;
1381
- capHitPageToken = pageToken;
1382
- break;
1383
- }
1384
- if (resolvedNextPageToken !== void 0) {
1385
- pageToken = resolvedNextPageToken;
1386
- continue;
1387
- }
1388
- listFullyDrained = true;
1389
- break;
1390
- }
1391
- let nextWatermarkMs;
1392
- let nextSeenIds;
1393
- let nextSkippedIds;
1394
- let nextPageToken;
1395
- if (listFullyDrained && !capHit && highWaterMs > currentWatermarkMs) {
1396
- nextWatermarkMs = String(highWaterMs);
1397
- nextSeenIds = pruneSeenIds(seenIds, highWaterMs);
1398
- nextSkippedIds = pruneSkippedIds(skippedIds, highWaterMs);
1399
- nextPageToken = void 0;
1400
- } else if (capHit) {
1401
- nextWatermarkMs = cursorPayload.watermarkMs;
1402
- nextSeenIds = pruneSeenIds(seenIds, currentWatermarkMs);
1403
- nextSkippedIds = pruneSkippedIds(skippedIds, currentWatermarkMs);
1404
- nextPageToken = capHitPageToken;
1405
- } else {
1406
- nextWatermarkMs = cursorPayload.watermarkMs;
1407
- nextSeenIds = pruneSeenIds(seenIds, currentWatermarkMs);
1408
- nextSkippedIds = pruneSkippedIds(skippedIds, currentWatermarkMs);
1409
- nextPageToken = void 0;
1410
- }
1411
- const nextCursor = makeCursor3({
1412
- watermarkMs: nextWatermarkMs,
1413
- skippedIds: nextSkippedIds,
1414
- seenIds: nextSeenIds,
1415
- ...nextPageToken !== void 0 ? { pageToken: nextPageToken } : {}
1416
- });
1417
- return {
1418
- newDocs,
1419
- nextCursor,
1420
- skippedInaccessible,
1421
- skippedEmpty,
1422
- skippedTooLarge
1423
- };
1424
- }
1425
- function buildListQuery(afterEpochSec, userQuery) {
1426
- const parts = [];
1427
- if (afterEpochSec > 0) {
1428
- parts.push(`after:${afterEpochSec}`);
1429
- }
1430
- const trimmedUser = userQuery.trim();
1431
- if (trimmedUser.length > 0) {
1432
- parts.push(trimmedUser);
1433
- }
1434
- return parts.join(" ");
1435
- }
1436
- async function fetchMessageDocument(fetchFn, accessToken, config, messageId, fetchedAt, signal) {
1437
- throwIfAborted3(signal);
1438
- let message;
1439
- try {
1440
- const path = `/users/${encodeURIComponent(config.userId)}/messages/${encodeURIComponent(messageId)}?format=full`;
1441
- const data = await gmailGet(fetchFn, accessToken, path, signal);
1442
- message = data;
1443
- } catch (err) {
1444
- if (isTransientGmailError(err)) {
1445
- throw err;
1446
- }
1447
- if (err !== null && typeof err === "object" && err.gmailStatus === 401) {
1448
- throw err;
1449
- }
1450
- return "inaccessible";
1451
- }
1452
- const internalDate = message.internalDate ?? "";
1453
- const body = message.payload ? extractBodyFromPart(message.payload) : "";
1454
- if (typeof body !== "string" || body.trim().length === 0) {
1455
- return { kind: "empty", internalDate };
1456
- }
1457
- if (body.length > MAX_TEXT_BYTES3) {
1458
- return { kind: "too-large", internalDate };
1459
- }
1460
- const subject = extractSubject(message);
1461
- return {
1462
- id: messageId,
1463
- title: subject,
1464
- content: body,
1465
- source: {
1466
- connector: GMAIL_CONNECTOR_ID,
1467
- externalId: messageId,
1468
- // Store internalDate (epoch ms string) as the revision so downstream
1469
- // dedup can identify repeat fetches after cursor rewind.
1470
- externalRevision: internalDate.length > 0 ? internalDate : void 0,
1471
- fetchedAt
1472
- }
1473
- };
1474
- }
1475
-
1476
- // src/connectors/live/github.ts
1477
- var GITHUB_CONNECTOR_ID = "github";
1478
- var GITHUB_CURSOR_KIND = "githubWatermark";
1479
- var GITHUB_DEFAULT_POLL_INTERVAL_MS = 5 * 60 * 1e3;
1480
- var GITHUB_MAX_POLL_INTERVAL_MS = 24 * 60 * 60 * 1e3;
1481
- var MAX_BODY_BYTES = 5 * 1024 * 1024;
1482
- var MAX_ITEMS_PER_PASS = 200;
1483
- var GITHUB_PAGE_SIZE = 100;
1484
- var REPO_SLUG_PATTERN = /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/;
1485
- function validateGitHubConfig(raw) {
1486
- if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
1487
- throw new TypeError(
1488
- `github: config must be an object, got ${raw === null ? "null" : Array.isArray(raw) ? "array" : typeof raw}`
1489
- );
1490
- }
1491
- const r = raw;
1492
- if (typeof r.token !== "string") {
1493
- throw new TypeError(`github: token must be a string (got ${typeof r.token})`);
1494
- }
1495
- const token = r.token.trim();
1496
- if (token.length === 0) {
1497
- throw new RangeError("github: token must be non-empty");
1498
- }
1499
- if (typeof r.userLogin !== "string") {
1500
- throw new TypeError(`github: userLogin must be a string (got ${typeof r.userLogin})`);
1501
- }
1502
- const userLogin = r.userLogin.trim();
1503
- if (userLogin.length === 0) {
1504
- throw new RangeError("github: userLogin must be non-empty");
1505
- }
1506
- let pollIntervalMs;
1507
- if (r.pollIntervalMs === void 0) {
1508
- pollIntervalMs = GITHUB_DEFAULT_POLL_INTERVAL_MS;
1509
- } else if (typeof r.pollIntervalMs !== "number" || !Number.isFinite(r.pollIntervalMs)) {
1510
- throw new TypeError(
1511
- `github: pollIntervalMs must be a finite number (got ${JSON.stringify(r.pollIntervalMs)})`
1512
- );
1513
- } else if (!Number.isInteger(r.pollIntervalMs)) {
1514
- throw new TypeError(`github: pollIntervalMs must be an integer (got ${r.pollIntervalMs})`);
1515
- } else if (r.pollIntervalMs < 1e3) {
1516
- throw new RangeError(`github: pollIntervalMs must be \u22651000ms; got ${r.pollIntervalMs}`);
1517
- } else if (r.pollIntervalMs > GITHUB_MAX_POLL_INTERVAL_MS) {
1518
- throw new RangeError(
1519
- `github: pollIntervalMs must be \u2264${GITHUB_MAX_POLL_INTERVAL_MS} (24h); got ${r.pollIntervalMs}`
1520
- );
1521
- } else {
1522
- pollIntervalMs = r.pollIntervalMs;
1523
- }
1524
- let repos = [];
1525
- if (r.repos !== void 0) {
1526
- if (!Array.isArray(r.repos)) {
1527
- throw new TypeError(
1528
- `github: repos must be an array of strings (got ${typeof r.repos})`
1529
- );
1530
- }
1531
- const seen = /* @__PURE__ */ new Set();
1532
- const out = [];
1533
- for (const value of r.repos) {
1534
- if (typeof value !== "string") {
1535
- throw new TypeError(
1536
- `github: repos entries must be strings; found ${typeof value}`
1537
- );
1538
- }
1539
- const trimmed = value.trim();
1540
- if (!REPO_SLUG_PATTERN.test(trimmed)) {
1541
- throw new RangeError(
1542
- `github: repos entry ${JSON.stringify(value)} is not a valid "owner/repo" slug`
1543
- );
1544
- }
1545
- if (seen.has(trimmed)) continue;
1546
- seen.add(trimmed);
1547
- out.push(trimmed);
1548
- }
1549
- repos = Object.freeze(out);
1550
- }
1551
- let includeDiscussions = false;
1552
- if (r.includeDiscussions !== void 0) {
1553
- if (typeof r.includeDiscussions !== "boolean") {
1554
- throw new TypeError(
1555
- `github: includeDiscussions must be a boolean (got ${typeof r.includeDiscussions})`
1556
- );
1557
- }
1558
- includeDiscussions = r.includeDiscussions;
1559
- }
1560
- return Object.freeze({
1561
- token,
1562
- userLogin,
1563
- repos,
1564
- pollIntervalMs,
1565
- includeDiscussions
1566
- });
1567
- }
1568
- function makeCursor4(payload) {
1569
- return {
1570
- kind: GITHUB_CURSOR_KIND,
1571
- value: JSON.stringify(payload),
1572
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
1573
- };
1574
- }
1575
- function parseCursorPayload3(cursor) {
1576
- if (cursor.kind !== GITHUB_CURSOR_KIND) {
1577
- throw new Error(
1578
- `github: unexpected cursor kind ${JSON.stringify(cursor.kind)}; expected ${GITHUB_CURSOR_KIND}`
1579
- );
1580
- }
1581
- let parsed;
1582
- try {
1583
- parsed = JSON.parse(cursor.value);
1584
- } catch {
1585
- throw new Error(`github: cursor value is not valid JSON`);
1586
- }
1587
- if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
1588
- throw new Error(`github: cursor value does not match GitHubCursorPayload shape`);
1589
- }
1590
- const p = parsed;
1591
- const watermarks = typeof p.watermarks === "object" && p.watermarks !== null && !Array.isArray(p.watermarks) ? p.watermarks : {};
1592
- const seenIds = typeof p.seenIds === "object" && p.seenIds !== null && !Array.isArray(p.seenIds) ? p.seenIds : {};
1593
- return { watermarks, seenIds };
1594
- }
1595
- function watermarkKey(repo, kind) {
1596
- return `${repo}/${kind}`;
1597
- }
1598
- function isTransientGitHubError(err) {
1599
- if (err === null || typeof err !== "object") return false;
1600
- const e = err;
1601
- if (typeof e.name === "string" && e.name === "AbortError") return true;
1602
- const status = pickNumericGitHubStatus(e);
1603
- if (status !== void 0) {
1604
- if (status === 429) return true;
1605
- if (status >= 500 && status <= 599) return true;
1606
- return false;
1607
- }
1608
- const codeStr = typeof e.code === "string" ? e.code : void 0;
1609
- if (codeStr !== void 0) {
1610
- const transientCodes = /* @__PURE__ */ new Set([
1611
- "ECONNRESET",
1612
- "ECONNREFUSED",
1613
- "ECONNABORTED",
1614
- "ETIMEDOUT",
1615
- "ESOCKETTIMEDOUT",
1616
- "ENOTFOUND",
1617
- "EAI_AGAIN",
1618
- "EPIPE",
1619
- "EHOSTUNREACH",
1620
- "ENETUNREACH",
1621
- "ENETDOWN",
1622
- "ERR_NETWORK",
1623
- "ERR_NETWORK_CHANGED"
1624
- ]);
1625
- if (transientCodes.has(codeStr)) return true;
1626
- return false;
1627
- }
1628
- return true;
1629
- }
1630
- function pickNumericGitHubStatus(e) {
1631
- if (typeof e.githubStatus === "number" && Number.isFinite(e.githubStatus)) {
1632
- return e.githubStatus;
1633
- }
1634
- if (typeof e.status === "number" && Number.isFinite(e.status)) {
1635
- return e.status;
1636
- }
1637
- return void 0;
1638
- }
1639
- var GITHUB_API_BASE = "https://api.github.com";
1640
- function throwIfAborted4(signal) {
1641
- if (signal?.aborted) {
1642
- const err = new Error("github: sync aborted");
1643
- err.name = "AbortError";
1644
- throw err;
1645
- }
1646
- }
1647
- function makeGitHubApiError(status, message) {
1648
- const err = new Error(`github: HTTP ${status}: ${message}`);
1649
- err.githubStatus = status;
1650
- return err;
1651
- }
1652
- async function githubGet(fetchFn, token, url, signal) {
1653
- const res = await fetchFn(url, {
1654
- method: "GET",
1655
- headers: {
1656
- Authorization: `Bearer ${token}`,
1657
- "User-Agent": "remnic-connector",
1658
- Accept: "application/vnd.github+json",
1659
- "X-GitHub-Api-Version": "2022-11-28"
1660
- },
1661
- signal
1662
- });
1663
- const data = await res.json();
1664
- if (!res.ok) {
1665
- const message = typeof data === "object" && data !== null && typeof data.message === "string" ? data.message : `HTTP ${res.status}`;
1666
- throw makeGitHubApiError(res.status, message);
1667
- }
1668
- return data;
1669
- }
1670
- function createGitHubConnector(options = {}) {
1671
- const fetchFn = options.fetchFn ?? globalThis.fetch;
1672
- return {
1673
- id: GITHUB_CONNECTOR_ID,
1674
- displayName: "GitHub",
1675
- description: "Imports issue comments, PR review comments, and discussion posts authored by the configured user from watched repos into Remnic.",
1676
- validateConfig(raw) {
1677
- return validateGitHubConfig(raw);
1678
- },
1679
- async syncIncremental(args) {
1680
- const config = validateGitHubConfig(args.config);
1681
- throwIfAborted4(args.abortSignal);
1682
- if (config.repos.length === 0) {
1683
- const emptyPayload = { watermarks: {}, seenIds: {} };
1684
- const result = {
1685
- newDocs: [],
1686
- nextCursor: makeCursor4(emptyPayload),
1687
- skippedOtherAuthor: 0,
1688
- skippedEmpty: 0,
1689
- skippedTooLarge: 0
1690
- };
1691
- return result;
1692
- }
1693
- const isFirstSync = args.cursor === null;
1694
- const payload = isFirstSync ? { watermarks: {}, seenIds: {} } : parseCursorPayload3(args.cursor);
1695
- if (isFirstSync) {
1696
- const seededPayload = await seedWatermarks(fetchFn, config, payload, args.abortSignal);
1697
- return {
1698
- newDocs: [],
1699
- nextCursor: makeCursor4(seededPayload),
1700
- skippedOtherAuthor: 0,
1701
- skippedEmpty: 0,
1702
- skippedTooLarge: 0
1703
- };
1704
- }
1705
- return await incrementalSync3(fetchFn, config, payload, args.abortSignal);
1706
- }
1707
- };
1708
- }
1709
- async function seedWatermarks(fetchFn, config, initial, signal) {
1710
- const watermarks = { ...initial.watermarks };
1711
- for (const repo of config.repos) {
1712
- throwIfAborted4(signal);
1713
- try {
1714
- const latest = await fetchLatestTimestamp(
1715
- fetchFn,
1716
- config.token,
1717
- `${GITHUB_API_BASE}/repos/${repo}/issues/comments?sort=updated&direction=desc&per_page=1`,
1718
- "updated_at",
1719
- signal
1720
- );
1721
- if (latest) watermarks[watermarkKey(repo, "issue-comment")] = latest;
1722
- } catch (err) {
1723
- if (isTransientGitHubError(err)) throw err;
1724
- }
1725
- throwIfAborted4(signal);
1726
- try {
1727
- const latest = await fetchLatestTimestamp(
1728
- fetchFn,
1729
- config.token,
1730
- `${GITHUB_API_BASE}/repos/${repo}/pulls/comments?sort=updated&direction=desc&per_page=1`,
1731
- "updated_at",
1732
- signal
1733
- );
1734
- if (latest) watermarks[watermarkKey(repo, "pr-review-comment")] = latest;
1735
- } catch (err) {
1736
- if (isTransientGitHubError(err)) throw err;
1737
- }
1738
- if (config.includeDiscussions) {
1739
- throwIfAborted4(signal);
1740
- try {
1741
- const latest = await fetchLatestTimestamp(
1742
- fetchFn,
1743
- config.token,
1744
- `${GITHUB_API_BASE}/repos/${repo}/discussions?sort=updated&direction=desc&per_page=1`,
1745
- "updated_at",
1746
- signal
1747
- );
1748
- if (latest) watermarks[watermarkKey(repo, "discussion")] = latest;
1749
- } catch (err) {
1750
- if (isTransientGitHubError(err)) throw err;
1751
- }
1752
- }
1753
- }
1754
- return { watermarks, seenIds: {} };
1755
- }
1756
- async function fetchLatestTimestamp(fetchFn, token, url, field, signal) {
1757
- const data = await githubGet(fetchFn, token, url, signal);
1758
- if (!Array.isArray(data) || data.length === 0) return void 0;
1759
- const first = data[0];
1760
- if (typeof first !== "object" || first === null) return void 0;
1761
- const ts = first[field];
1762
- return typeof ts === "string" && ts.length > 0 ? ts : void 0;
1763
- }
1764
- async function incrementalSync3(fetchFn, config, payload, signal) {
1765
- const fetchedAt = (/* @__PURE__ */ new Date()).toISOString();
1766
- const newDocs = [];
1767
- const updatedWatermarks = { ...payload.watermarks };
1768
- let skippedOtherAuthor = 0;
1769
- let skippedEmpty = 0;
1770
- let skippedTooLarge = 0;
1771
- let totalConsumed = 0;
1772
- const currentSeenIds = { ...payload.seenIds };
1773
- const updatedSeenIds = { ...payload.seenIds };
1774
- for (const repo of config.repos) {
1775
- if (totalConsumed >= MAX_ITEMS_PER_PASS) break;
1776
- throwIfAborted4(signal);
1777
- {
1778
- const wmKey = watermarkKey(repo, "issue-comment");
1779
- const since = payload.watermarks[wmKey];
1780
- try {
1781
- const result = await fetchAndFilterComments(
1782
- fetchFn,
1783
- config.token,
1784
- buildIssueCommentsUrl(repo, since),
1785
- repo,
1786
- "issue-comment",
1787
- config.userLogin,
1788
- since,
1789
- fetchedAt,
1790
- MAX_ITEMS_PER_PASS - totalConsumed,
1791
- currentSeenIds,
1792
- signal
1793
- );
1794
- for (const doc of result.docs) newDocs.push(doc);
1795
- skippedOtherAuthor += result.skippedOtherAuthor;
1796
- skippedEmpty += result.skippedEmpty;
1797
- skippedTooLarge += result.skippedTooLarge;
1798
- totalConsumed += result.consumed;
1799
- if (result.latestWatermark) {
1800
- const prevWm = updatedWatermarks[wmKey];
1801
- const nextWm = result.latestWatermark;
1802
- updatedWatermarks[wmKey] = nextWm;
1803
- if (prevWm && watermarkCrossedSecond(prevWm, nextWm)) {
1804
- for (const k of Object.keys(updatedSeenIds)) {
1805
- if (k.startsWith(`${repo}/issue-comment/`)) delete updatedSeenIds[k];
1806
- }
1807
- }
1808
- for (const [k, v] of Object.entries(result.newSeenIds)) {
1809
- updatedSeenIds[k] = v;
1810
- }
1811
- }
1812
- } catch (err) {
1813
- if (isTransientGitHubError(err)) throw err;
1814
- }
1815
- }
1816
- if (totalConsumed >= MAX_ITEMS_PER_PASS) break;
1817
- throwIfAborted4(signal);
1818
- {
1819
- const wmKey = watermarkKey(repo, "pr-review-comment");
1820
- const since = payload.watermarks[wmKey];
1821
- try {
1822
- const result = await fetchAndFilterComments(
1823
- fetchFn,
1824
- config.token,
1825
- buildPrReviewCommentsUrl(repo, since),
1826
- repo,
1827
- "pr-review-comment",
1828
- config.userLogin,
1829
- since,
1830
- fetchedAt,
1831
- MAX_ITEMS_PER_PASS - totalConsumed,
1832
- currentSeenIds,
1833
- signal
1834
- );
1835
- for (const doc of result.docs) newDocs.push(doc);
1836
- skippedOtherAuthor += result.skippedOtherAuthor;
1837
- skippedEmpty += result.skippedEmpty;
1838
- skippedTooLarge += result.skippedTooLarge;
1839
- totalConsumed += result.consumed;
1840
- if (result.latestWatermark) {
1841
- const prevWm = updatedWatermarks[wmKey];
1842
- const nextWm = result.latestWatermark;
1843
- updatedWatermarks[wmKey] = nextWm;
1844
- if (prevWm && watermarkCrossedSecond(prevWm, nextWm)) {
1845
- for (const k of Object.keys(updatedSeenIds)) {
1846
- if (k.startsWith(`${repo}/pr-review-comment/`)) delete updatedSeenIds[k];
1847
- }
1848
- }
1849
- for (const [k, v] of Object.entries(result.newSeenIds)) {
1850
- updatedSeenIds[k] = v;
1851
- }
1852
- }
1853
- } catch (err) {
1854
- if (isTransientGitHubError(err)) throw err;
1855
- }
1856
- }
1857
- if (config.includeDiscussions && totalConsumed < MAX_ITEMS_PER_PASS) {
1858
- throwIfAborted4(signal);
1859
- const wmKey = watermarkKey(repo, "discussion");
1860
- const since = payload.watermarks[wmKey];
1861
- try {
1862
- const result = await fetchAndFilterComments(
1863
- fetchFn,
1864
- config.token,
1865
- buildDiscussionsUrl(repo, since),
1866
- repo,
1867
- "discussion",
1868
- config.userLogin,
1869
- since,
1870
- fetchedAt,
1871
- MAX_ITEMS_PER_PASS - totalConsumed,
1872
- currentSeenIds,
1873
- signal
1874
- );
1875
- for (const doc of result.docs) newDocs.push(doc);
1876
- skippedOtherAuthor += result.skippedOtherAuthor;
1877
- skippedEmpty += result.skippedEmpty;
1878
- skippedTooLarge += result.skippedTooLarge;
1879
- totalConsumed += result.consumed;
1880
- if (result.latestWatermark) {
1881
- const prevWm = updatedWatermarks[wmKey];
1882
- const nextWm = result.latestWatermark;
1883
- updatedWatermarks[wmKey] = nextWm;
1884
- if (prevWm && watermarkCrossedSecond(prevWm, nextWm)) {
1885
- for (const k of Object.keys(updatedSeenIds)) {
1886
- if (k.startsWith(`${repo}/discussion/`)) delete updatedSeenIds[k];
1887
- }
1888
- }
1889
- for (const [k, v] of Object.entries(result.newSeenIds)) {
1890
- updatedSeenIds[k] = v;
1891
- }
1892
- }
1893
- } catch (err) {
1894
- if (isTransientGitHubError(err)) throw err;
1895
- }
1896
- }
1897
- }
1898
- return {
1899
- newDocs,
1900
- nextCursor: makeCursor4({ watermarks: updatedWatermarks, seenIds: updatedSeenIds }),
1901
- skippedOtherAuthor,
1902
- skippedEmpty,
1903
- skippedTooLarge
1904
- };
1905
- }
1906
- function watermarkCrossedSecond(prev, next) {
1907
- return prev.slice(0, 19) < next.slice(0, 19);
1908
- }
1909
- function buildIssueCommentsUrl(repo, since) {
1910
- const base = `${GITHUB_API_BASE}/repos/${repo}/issues/comments?sort=updated&direction=asc&per_page=${GITHUB_PAGE_SIZE}`;
1911
- return since ? `${base}&since=${encodeURIComponent(since)}` : base;
1912
- }
1913
- function buildPrReviewCommentsUrl(repo, since) {
1914
- const base = `${GITHUB_API_BASE}/repos/${repo}/pulls/comments?sort=updated&direction=asc&per_page=${GITHUB_PAGE_SIZE}`;
1915
- return since ? `${base}&since=${encodeURIComponent(since)}` : base;
1916
- }
1917
- function buildDiscussionsUrl(repo, since) {
1918
- const base = `${GITHUB_API_BASE}/repos/${repo}/discussions?sort=updated&direction=asc&per_page=${GITHUB_PAGE_SIZE}`;
1919
- return since ? `${base}&since=${encodeURIComponent(since)}` : base;
1920
- }
1921
- async function fetchAndFilterComments(fetchFn, token, firstPageUrl, repo, kind, userLogin, since, fetchedAt, remainingBudget, seenIds, signal) {
1922
- const docs = [];
1923
- let skippedOtherAuthor = 0;
1924
- let skippedEmpty = 0;
1925
- let skippedTooLarge = 0;
1926
- let consumed = 0;
1927
- let latestWatermark = void 0;
1928
- const newSeenIds = {};
1929
- let nextUrl = firstPageUrl;
1930
- while (nextUrl && consumed < remainingBudget) {
1931
- throwIfAborted4(signal);
1932
- const data = await githubGet(fetchFn, token, nextUrl, signal);
1933
- if (!Array.isArray(data)) break;
1934
- for (const item of data) {
1935
- if (consumed >= remainingBudget) break;
1936
- throwIfAborted4(signal);
1937
- const comment = item;
1938
- if (since && comment.updated_at < since) {
1939
- continue;
1940
- }
1941
- const seenKey = `${repo}/${kind}/${comment.id}`;
1942
- if (seenIds[seenKey] === comment.updated_at) {
1943
- continue;
1944
- }
1945
- const authorLogin = comment.user?.login ?? null;
1946
- if (authorLogin !== userLogin) {
1947
- skippedOtherAuthor++;
1948
- if (!latestWatermark || comment.updated_at > latestWatermark) {
1949
- latestWatermark = comment.updated_at;
1950
- }
1951
- continue;
1952
- }
1953
- const body = comment.body ?? "";
1954
- const trimmed = body.trim();
1955
- if (trimmed.length === 0) {
1956
- skippedEmpty++;
1957
- if (!latestWatermark || comment.updated_at > latestWatermark) {
1958
- latestWatermark = comment.updated_at;
1959
- }
1960
- continue;
1961
- }
1962
- if (trimmed.length > MAX_BODY_BYTES) {
1963
- skippedTooLarge++;
1964
- if (!latestWatermark || comment.updated_at > latestWatermark) {
1965
- latestWatermark = comment.updated_at;
1966
- }
1967
- continue;
1968
- }
1969
- consumed++;
1970
- const doc = buildDocument(comment, repo, kind, fetchedAt);
1971
- docs.push(doc);
1972
- if (!latestWatermark || comment.updated_at > latestWatermark) {
1973
- latestWatermark = comment.updated_at;
1974
- }
1975
- newSeenIds[seenKey] = comment.updated_at;
1976
- }
1977
- if (data.length < GITHUB_PAGE_SIZE) {
1978
- nextUrl = void 0;
1979
- } else {
1980
- nextUrl = advancePageUrl(nextUrl);
1981
- }
1982
- }
1983
- return { docs, skippedOtherAuthor, skippedEmpty, skippedTooLarge, consumed, latestWatermark, newSeenIds };
1984
- }
1985
- function advancePageUrl(url) {
1986
- try {
1987
- const u = new URL(url);
1988
- const page = parseInt(u.searchParams.get("page") ?? "1", 10);
1989
- u.searchParams.set("page", String(isNaN(page) ? 2 : page + 1));
1990
- return u.toString();
1991
- } catch {
1992
- return "";
1993
- }
1994
- }
1995
- function buildDocument(comment, repo, kind, fetchedAt) {
1996
- const externalId = `${repo}/${kind}/${comment.id}`;
1997
- const externalUrl = typeof comment.html_url === "string" && comment.html_url.length > 0 ? comment.html_url : void 0;
1998
- const title = buildTitle(repo, kind, comment);
1999
- return {
2000
- id: externalId,
2001
- title,
2002
- content: (comment.body ?? "").trim(),
2003
- source: {
2004
- connector: GITHUB_CONNECTOR_ID,
2005
- externalId,
2006
- externalRevision: comment.updated_at,
2007
- externalUrl,
2008
- fetchedAt
2009
- }
2010
- };
2011
- }
2012
- function buildTitle(repo, kind, comment) {
2013
- const kindLabel = kind === "issue-comment" ? "Issue comment" : kind === "pr-review-comment" ? "PR review comment" : "Discussion comment";
2014
- return `${kindLabel} in ${repo} (#${comment.id})`;
2015
- }
2016
-
2017
- export {
2018
- LiveConnectorRegistryError,
2019
- LiveConnectorRegistry,
2020
- GOOGLE_DRIVE_CONNECTOR_ID,
2021
- GOOGLE_DRIVE_CURSOR_KIND,
2022
- DEFAULT_POLL_INTERVAL_MS,
2023
- validateGoogleDriveConfig,
2024
- createGoogleDriveConnector,
2025
- defaultGoogleDriveClientFactory,
2026
- NOTION_CONNECTOR_ID,
2027
- NOTION_CURSOR_KIND,
2028
- NOTION_DEFAULT_POLL_INTERVAL_MS,
2029
- validateNotionConfig,
2030
- createNotionConnector,
2031
- GMAIL_CONNECTOR_ID,
2032
- GMAIL_DEFAULT_POLL_INTERVAL_MS,
2033
- validateGmailConfig,
2034
- createGmailConnector,
2035
- GITHUB_CONNECTOR_ID,
2036
- GITHUB_DEFAULT_POLL_INTERVAL_MS,
2037
- validateGitHubConfig,
2038
- createGitHubConnector
2039
- };
2040
- //# sourceMappingURL=chunk-4IS4SXIQ.js.map