@theokit/sdk 4.62.0 → 4.63.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (379) hide show
  1. package/CHANGELOG.md +97 -0
  2. package/dist/a2a/index.cjs +2 -2
  3. package/dist/a2a/index.js +1 -1
  4. package/dist/{agent-DIu6FooJ.d.ts → agent-BFno7Sfn.d.ts} +36 -21
  5. package/dist/agent-WK7MKIMH.cjs +66 -0
  6. package/dist/{agent-VYPUO4UB.cjs.map → agent-WK7MKIMH.cjs.map} +1 -1
  7. package/dist/{agent-D3Xr_-6Z.d.cts → agent-X0DKA943.d.cts} +36 -21
  8. package/dist/agent-YWMBM7LX.js +57 -0
  9. package/dist/{agent-NVBFTY5H.js.map → agent-YWMBM7LX.js.map} +1 -1
  10. package/dist/agent-session-store-6EL5NPA4.cjs +24 -0
  11. package/dist/{agent-session-store-WAKLOKWK.cjs.map → agent-session-store-6EL5NPA4.cjs.map} +1 -1
  12. package/dist/agent-session-store-OPGRB4XM.js +7 -0
  13. package/dist/{agent-session-store-G2BMUZQV.js.map → agent-session-store-OPGRB4XM.js.map} +1 -1
  14. package/dist/auth/index.cjs +18 -18
  15. package/dist/auth/index.js +6 -6
  16. package/dist/{batch-ND32UKZS.cjs → batch-BXYTW2DP.cjs} +27 -27
  17. package/dist/{batch-ND32UKZS.cjs.map → batch-BXYTW2DP.cjs.map} +1 -1
  18. package/dist/{batch-2TGJMNCJ.js → batch-L4ZXS46M.js} +10 -10
  19. package/dist/{batch-2TGJMNCJ.js.map → batch-L4ZXS46M.js.map} +1 -1
  20. package/dist/{chunk-VF7EWVDG.js → chunk-2GUYQR5P.js} +3 -3
  21. package/dist/{chunk-VF7EWVDG.js.map → chunk-2GUYQR5P.js.map} +1 -1
  22. package/dist/{chunk-J2UROOIG.cjs → chunk-2HVF2WJY.cjs} +8 -8
  23. package/dist/{chunk-J2UROOIG.cjs.map → chunk-2HVF2WJY.cjs.map} +1 -1
  24. package/dist/{chunk-44MBDIHG.js → chunk-2QDYBS2A.js} +3 -3
  25. package/dist/{chunk-44MBDIHG.js.map → chunk-2QDYBS2A.js.map} +1 -1
  26. package/dist/{chunk-NGESVVJN.cjs → chunk-3FFAEAUJ.cjs} +17 -17
  27. package/dist/{chunk-NGESVVJN.cjs.map → chunk-3FFAEAUJ.cjs.map} +1 -1
  28. package/dist/{chunk-GWC3HADL.cjs → chunk-3NSS2OIZ.cjs} +4 -4
  29. package/dist/{chunk-GWC3HADL.cjs.map → chunk-3NSS2OIZ.cjs.map} +1 -1
  30. package/dist/{chunk-CV7XMBHP.js → chunk-3O42QOMJ.js} +3 -3
  31. package/dist/{chunk-CV7XMBHP.js.map → chunk-3O42QOMJ.js.map} +1 -1
  32. package/dist/{chunk-IWBGCBR6.cjs → chunk-4CLOXP6H.cjs} +4 -4
  33. package/dist/{chunk-IWBGCBR6.cjs.map → chunk-4CLOXP6H.cjs.map} +1 -1
  34. package/dist/{chunk-YEXA3PGR.js → chunk-4FFBAUFS.js} +5 -5
  35. package/dist/{chunk-YEXA3PGR.js.map → chunk-4FFBAUFS.js.map} +1 -1
  36. package/dist/{chunk-HY57ULY2.cjs → chunk-4PYZ5AX3.cjs} +5 -5
  37. package/dist/{chunk-HY57ULY2.cjs.map → chunk-4PYZ5AX3.cjs.map} +1 -1
  38. package/dist/{chunk-OC4NTGMN.js → chunk-4QZSA2HJ.js} +3 -3
  39. package/dist/{chunk-OC4NTGMN.js.map → chunk-4QZSA2HJ.js.map} +1 -1
  40. package/dist/{chunk-K3FW2XZD.cjs → chunk-4ZHTIJNE.cjs} +9 -9
  41. package/dist/{chunk-K3FW2XZD.cjs.map → chunk-4ZHTIJNE.cjs.map} +1 -1
  42. package/dist/{chunk-BUIK7GUA.cjs → chunk-5HEG4CQH.cjs} +8 -8
  43. package/dist/{chunk-BUIK7GUA.cjs.map → chunk-5HEG4CQH.cjs.map} +1 -1
  44. package/dist/{chunk-SKXBJ2NU.cjs → chunk-5VB22SYX.cjs} +7 -54
  45. package/dist/chunk-5VB22SYX.cjs.map +1 -0
  46. package/dist/{chunk-5USCYPPI.cjs → chunk-6HKGLTJI.cjs} +8 -8
  47. package/dist/{chunk-5USCYPPI.cjs.map → chunk-6HKGLTJI.cjs.map} +1 -1
  48. package/dist/chunk-6RKUO7AW.cjs +864 -0
  49. package/dist/chunk-6RKUO7AW.cjs.map +1 -0
  50. package/dist/{chunk-5JLFFPCH.js → chunk-7YGCPMGB.js} +4 -4
  51. package/dist/{chunk-5JLFFPCH.js.map → chunk-7YGCPMGB.js.map} +1 -1
  52. package/dist/{chunk-SUKXXLWD.js → chunk-A46SWMIF.js} +6 -6
  53. package/dist/{chunk-SUKXXLWD.js.map → chunk-A46SWMIF.js.map} +1 -1
  54. package/dist/{chunk-F7AQV62G.js → chunk-A4JVILQU.js} +5 -5
  55. package/dist/{chunk-F7AQV62G.js.map → chunk-A4JVILQU.js.map} +1 -1
  56. package/dist/chunk-A4RAL2ER.cjs +51 -0
  57. package/dist/chunk-A4RAL2ER.cjs.map +1 -0
  58. package/dist/{chunk-44JAAH4X.js → chunk-B3IMEBOA.js} +3 -3
  59. package/dist/{chunk-44JAAH4X.js.map → chunk-B3IMEBOA.js.map} +1 -1
  60. package/dist/{chunk-QDED6YO6.cjs → chunk-B4EOJWOY.cjs} +5 -5
  61. package/dist/{chunk-QDED6YO6.cjs.map → chunk-B4EOJWOY.cjs.map} +1 -1
  62. package/dist/{chunk-YJDH3CKG.js → chunk-BP46RJ5X.js} +5 -5
  63. package/dist/{chunk-YJDH3CKG.js.map → chunk-BP46RJ5X.js.map} +1 -1
  64. package/dist/{chunk-QRSUA2CV.js → chunk-BU4KFWXF.js} +3 -3
  65. package/dist/{chunk-QRSUA2CV.js.map → chunk-BU4KFWXF.js.map} +1 -1
  66. package/dist/{chunk-IBYRA5PM.js → chunk-BVJJ3DRV.js} +6 -6
  67. package/dist/{chunk-IBYRA5PM.js.map → chunk-BVJJ3DRV.js.map} +1 -1
  68. package/dist/{chunk-AQLGBKNT.js → chunk-BZRFXJHA.js} +3 -3
  69. package/dist/{chunk-AQLGBKNT.js.map → chunk-BZRFXJHA.js.map} +1 -1
  70. package/dist/{chunk-UQGQFBRL.js → chunk-C3NT3PVE.js} +3 -3
  71. package/dist/{chunk-UQGQFBRL.js.map → chunk-C3NT3PVE.js.map} +1 -1
  72. package/dist/{chunk-UC3HT2S4.js → chunk-C72AZW7J.js} +3 -3
  73. package/dist/{chunk-UC3HT2S4.js.map → chunk-C72AZW7J.js.map} +1 -1
  74. package/dist/{chunk-WNTAPVU5.cjs → chunk-CQBXOJ6U.cjs} +13 -13
  75. package/dist/{chunk-WNTAPVU5.cjs.map → chunk-CQBXOJ6U.cjs.map} +1 -1
  76. package/dist/{chunk-T7XEKOVW.js → chunk-D4CUGAKZ.js} +3 -3
  77. package/dist/{chunk-T7XEKOVW.js.map → chunk-D4CUGAKZ.js.map} +1 -1
  78. package/dist/chunk-DKD3MH6A.js +194 -0
  79. package/dist/chunk-DKD3MH6A.js.map +1 -0
  80. package/dist/{chunk-YXGAW7BB.js → chunk-DN2PACRI.js} +10 -10
  81. package/dist/{chunk-YXGAW7BB.js.map → chunk-DN2PACRI.js.map} +1 -1
  82. package/dist/{chunk-XSX2UU6Y.cjs → chunk-DXGZ2NUG.cjs} +10 -10
  83. package/dist/{chunk-XSX2UU6Y.cjs.map → chunk-DXGZ2NUG.cjs.map} +1 -1
  84. package/dist/{chunk-NUKRL3I6.cjs → chunk-EG4QM7ZJ.cjs} +18 -2
  85. package/dist/chunk-EG4QM7ZJ.cjs.map +1 -0
  86. package/dist/chunk-GEEXBYFL.js +831 -0
  87. package/dist/chunk-GEEXBYFL.js.map +1 -0
  88. package/dist/chunk-GKEFRLU7.cjs +21 -0
  89. package/dist/chunk-GKEFRLU7.cjs.map +1 -0
  90. package/dist/{chunk-NIRE5CNO.cjs → chunk-HCZD23VS.cjs} +13 -13
  91. package/dist/{chunk-NIRE5CNO.cjs.map → chunk-HCZD23VS.cjs.map} +1 -1
  92. package/dist/chunk-HOXVQ5FR.cjs +201 -0
  93. package/dist/chunk-HOXVQ5FR.cjs.map +1 -0
  94. package/dist/{chunk-QARJGQSA.js → chunk-HS7AVXTF.js} +3 -3
  95. package/dist/{chunk-QARJGQSA.js.map → chunk-HS7AVXTF.js.map} +1 -1
  96. package/dist/{chunk-4I55V454.cjs → chunk-I6HGWHPU.cjs} +4 -4
  97. package/dist/{chunk-4I55V454.cjs.map → chunk-I6HGWHPU.cjs.map} +1 -1
  98. package/dist/{chunk-T73NA43R.js → chunk-IPYYKCRC.js} +3 -3
  99. package/dist/{chunk-T73NA43R.js.map → chunk-IPYYKCRC.js.map} +1 -1
  100. package/dist/{chunk-6OBIWHDR.cjs → chunk-ITYQ6VBP.cjs} +24 -365
  101. package/dist/chunk-ITYQ6VBP.cjs.map +1 -0
  102. package/dist/chunk-JPBKYL3B.cjs +18 -0
  103. package/dist/{chunk-6HTXPPHK.cjs.map → chunk-JPBKYL3B.cjs.map} +1 -1
  104. package/dist/{chunk-MZ2FGBLZ.js → chunk-K5OJUYSZ.js} +4 -4
  105. package/dist/{chunk-MZ2FGBLZ.js.map → chunk-K5OJUYSZ.js.map} +1 -1
  106. package/dist/{chunk-SKOCYA55.js → chunk-KIH6IZ43.js} +90 -88
  107. package/dist/chunk-KIH6IZ43.js.map +1 -0
  108. package/dist/{chunk-EI2Q7SJ5.cjs → chunk-KQ7TS7WW.cjs} +10 -10
  109. package/dist/{chunk-EI2Q7SJ5.cjs.map → chunk-KQ7TS7WW.cjs.map} +1 -1
  110. package/dist/{chunk-RUDY2GTT.js → chunk-KQRW2GPZ.js} +5 -5
  111. package/dist/{chunk-RUDY2GTT.js.map → chunk-KQRW2GPZ.js.map} +1 -1
  112. package/dist/{chunk-P5LCASTC.cjs → chunk-KYAJINUI.cjs} +125 -125
  113. package/dist/{chunk-P5LCASTC.cjs.map → chunk-KYAJINUI.cjs.map} +1 -1
  114. package/dist/{chunk-CQ2TQ32Y.js → chunk-LWGSI6M3.js} +5 -50
  115. package/dist/chunk-LWGSI6M3.js.map +1 -0
  116. package/dist/{chunk-ZHPWGIUX.js → chunk-LXI4XZEC.js} +5 -5
  117. package/dist/{chunk-ZHPWGIUX.js.map → chunk-LXI4XZEC.js.map} +1 -1
  118. package/dist/{chunk-AG5JPQIY.js → chunk-LXQ6HKPS.js} +3 -3
  119. package/dist/{chunk-AG5JPQIY.js.map → chunk-LXQ6HKPS.js.map} +1 -1
  120. package/dist/{chunk-ROYPRJH4.cjs → chunk-LYRDF5TQ.cjs} +9 -9
  121. package/dist/{chunk-ROYPRJH4.cjs.map → chunk-LYRDF5TQ.cjs.map} +1 -1
  122. package/dist/{chunk-G24KZRSA.js → chunk-N2U4AZGB.js} +3 -3
  123. package/dist/{chunk-G24KZRSA.js.map → chunk-N2U4AZGB.js.map} +1 -1
  124. package/dist/{chunk-4ERPXIVB.js → chunk-O73J46PV.js} +5 -5
  125. package/dist/{chunk-4ERPXIVB.js.map → chunk-O73J46PV.js.map} +1 -1
  126. package/dist/{chunk-F3YZMOAU.cjs → chunk-O7DK5PBJ.cjs} +4 -4
  127. package/dist/{chunk-F3YZMOAU.cjs.map → chunk-O7DK5PBJ.cjs.map} +1 -1
  128. package/dist/{chunk-Z4BCLVTI.cjs → chunk-O7LZFG6O.cjs} +5 -5
  129. package/dist/{chunk-Z4BCLVTI.cjs.map → chunk-O7LZFG6O.cjs.map} +1 -1
  130. package/dist/{chunk-3YJNUKYN.cjs → chunk-OHLDPWTA.cjs} +15 -15
  131. package/dist/{chunk-3YJNUKYN.cjs.map → chunk-OHLDPWTA.cjs.map} +1 -1
  132. package/dist/{chunk-FUL2I7G5.js → chunk-OSEG74VJ.js} +8 -8
  133. package/dist/{chunk-FUL2I7G5.js.map → chunk-OSEG74VJ.js.map} +1 -1
  134. package/dist/{chunk-UCBJBJ27.js → chunk-PUAEFLYK.js} +4 -4
  135. package/dist/{chunk-UCBJBJ27.js.map → chunk-PUAEFLYK.js.map} +1 -1
  136. package/dist/{chunk-CWHTMNNK.cjs → chunk-Q7LPTOD6.cjs} +24 -24
  137. package/dist/{chunk-CWHTMNNK.cjs.map → chunk-Q7LPTOD6.cjs.map} +1 -1
  138. package/dist/{chunk-2C72DXQF.cjs → chunk-RFMBZPOW.cjs} +9 -9
  139. package/dist/{chunk-2C72DXQF.cjs.map → chunk-RFMBZPOW.cjs.map} +1 -1
  140. package/dist/{chunk-NLTVXLGT.js → chunk-RFXWMRFC.js} +3 -3
  141. package/dist/{chunk-NLTVXLGT.js.map → chunk-RFXWMRFC.js.map} +1 -1
  142. package/dist/{chunk-2DG7KW4L.cjs → chunk-RMWTPV3M.cjs} +8 -8
  143. package/dist/{chunk-2DG7KW4L.cjs.map → chunk-RMWTPV3M.cjs.map} +1 -1
  144. package/dist/{chunk-P6A3M6VD.cjs → chunk-SZVR77EJ.cjs} +10 -10
  145. package/dist/{chunk-P6A3M6VD.cjs.map → chunk-SZVR77EJ.cjs.map} +1 -1
  146. package/dist/{chunk-3E77SX4H.js → chunk-TAZVKYWJ.js} +3 -3
  147. package/dist/{chunk-3E77SX4H.js.map → chunk-TAZVKYWJ.js.map} +1 -1
  148. package/dist/{chunk-WKRSH2VR.js → chunk-U6IFHFWK.js} +3 -3
  149. package/dist/{chunk-WKRSH2VR.js.map → chunk-U6IFHFWK.js.map} +1 -1
  150. package/dist/{chunk-I6TGFUCO.cjs → chunk-UALX2J2Q.cjs} +4 -4
  151. package/dist/{chunk-I6TGFUCO.cjs.map → chunk-UALX2J2Q.cjs.map} +1 -1
  152. package/dist/{chunk-XN7NOENA.js → chunk-UBDMVMBZ.js} +5 -5
  153. package/dist/{chunk-XN7NOENA.js.map → chunk-UBDMVMBZ.js.map} +1 -1
  154. package/dist/{chunk-QEKI3YKI.js → chunk-UEXIJTLC.js} +14 -349
  155. package/dist/chunk-UEXIJTLC.js.map +1 -0
  156. package/dist/{chunk-DQKERTND.cjs → chunk-UGT7GK7I.cjs} +11 -11
  157. package/dist/{chunk-DQKERTND.cjs.map → chunk-UGT7GK7I.cjs.map} +1 -1
  158. package/dist/{chunk-FKMUFNQE.js → chunk-UMP6OJIM.js} +4 -4
  159. package/dist/{chunk-FKMUFNQE.js.map → chunk-UMP6OJIM.js.map} +1 -1
  160. package/dist/{chunk-AEOZTXVW.js → chunk-UNYXQ4M5.js} +3 -3
  161. package/dist/{chunk-AEOZTXVW.js.map → chunk-UNYXQ4M5.js.map} +1 -1
  162. package/dist/{chunk-2BDH744Z.js → chunk-UTSRIDKZ.js} +3 -3
  163. package/dist/{chunk-2BDH744Z.js.map → chunk-UTSRIDKZ.js.map} +1 -1
  164. package/dist/{chunk-2ADR2GSO.cjs → chunk-UU36SHFY.cjs} +5 -5
  165. package/dist/{chunk-2ADR2GSO.cjs.map → chunk-UU36SHFY.cjs.map} +1 -1
  166. package/dist/{chunk-R3UPQFKK.cjs → chunk-V2BOS4WF.cjs} +9 -9
  167. package/dist/{chunk-R3UPQFKK.cjs.map → chunk-V2BOS4WF.cjs.map} +1 -1
  168. package/dist/chunk-WE22OXQA.js +48 -0
  169. package/dist/chunk-WE22OXQA.js.map +1 -0
  170. package/dist/{chunk-Q4CMI2LP.js → chunk-WLQNMXQE.js} +5 -5
  171. package/dist/{chunk-Q4CMI2LP.js.map → chunk-WLQNMXQE.js.map} +1 -1
  172. package/dist/{chunk-XWL6O3SW.cjs → chunk-WNO3C3N2.cjs} +4 -4
  173. package/dist/{chunk-XWL6O3SW.cjs.map → chunk-WNO3C3N2.cjs.map} +1 -1
  174. package/dist/{chunk-T7O6K6PX.js → chunk-XEQ3TM66.js} +18 -3
  175. package/dist/chunk-XEQ3TM66.js.map +1 -0
  176. package/dist/{chunk-BVZW2B5V.cjs → chunk-XJCXEKMD.cjs} +4 -4
  177. package/dist/{chunk-BVZW2B5V.cjs.map → chunk-XJCXEKMD.cjs.map} +1 -1
  178. package/dist/{chunk-JTB5Q42C.cjs → chunk-XL7Q7HB2.cjs} +4 -4
  179. package/dist/{chunk-JTB5Q42C.cjs.map → chunk-XL7Q7HB2.cjs.map} +1 -1
  180. package/dist/chunk-XO4SOZN6.js +19 -0
  181. package/dist/chunk-XO4SOZN6.js.map +1 -0
  182. package/dist/{chunk-CQGYNZ3K.cjs → chunk-XWTLIGO3.cjs} +4 -4
  183. package/dist/{chunk-CQGYNZ3K.cjs.map → chunk-XWTLIGO3.cjs.map} +1 -1
  184. package/dist/{chunk-6SBW4QR2.cjs → chunk-YML4ME27.cjs} +11 -11
  185. package/dist/{chunk-6SBW4QR2.cjs.map → chunk-YML4ME27.cjs.map} +1 -1
  186. package/dist/{chunk-P6H23T43.cjs → chunk-ZCIRZE37.cjs} +11 -11
  187. package/dist/{chunk-P6H23T43.cjs.map → chunk-ZCIRZE37.cjs.map} +1 -1
  188. package/dist/{chunk-QI7WE46I.cjs → chunk-ZLQSWSJ2.cjs} +11 -11
  189. package/dist/{chunk-QI7WE46I.cjs.map → chunk-ZLQSWSJ2.cjs.map} +1 -1
  190. package/dist/{chunk-AH6WD7JR.cjs → chunk-ZMRD5DZQ.cjs} +362 -360
  191. package/dist/chunk-ZMRD5DZQ.cjs.map +1 -0
  192. package/dist/{chunk-ILCGLTSA.cjs → chunk-ZSWPZ23K.cjs} +4 -4
  193. package/dist/{chunk-ILCGLTSA.cjs.map → chunk-ZSWPZ23K.cjs.map} +1 -1
  194. package/dist/{chunk-IDCKSLYH.js → chunk-ZZMZWBR6.js} +3 -3
  195. package/dist/{chunk-IDCKSLYH.js.map → chunk-ZZMZWBR6.js.map} +1 -1
  196. package/dist/compact-session-QV57KR66.cjs +59 -0
  197. package/dist/{compact-session-GJXJD73F.cjs.map → compact-session-QV57KR66.cjs.map} +1 -1
  198. package/dist/compact-session-RIGOWC4Y.js +22 -0
  199. package/dist/{compact-session-TSMQOIHO.js.map → compact-session-RIGOWC4Y.js.map} +1 -1
  200. package/dist/compaction.cjs +17 -17
  201. package/dist/compaction.js +4 -4
  202. package/dist/concurrency.cjs +7 -7
  203. package/dist/concurrency.js +5 -5
  204. package/dist/context-AGQ3DIZU.cjs +24 -0
  205. package/dist/{context-LCKNH2XI.cjs.map → context-AGQ3DIZU.cjs.map} +1 -1
  206. package/dist/context-GQRFBCLP.js +7 -0
  207. package/dist/{context-MZSKGKYR.js.map → context-GQRFBCLP.js.map} +1 -1
  208. package/dist/{cron-BcWmzWzT.d.cts → cron-BuiRPrvt.d.cts} +1 -1
  209. package/dist/{cron-De6hzWCF.d.ts → cron-C2SIi31n.d.ts} +1 -1
  210. package/dist/cron.cjs +37 -35
  211. package/dist/cron.d.cts +2 -2
  212. package/dist/cron.d.ts +2 -2
  213. package/dist/cron.js +36 -34
  214. package/dist/errors.cjs +22 -22
  215. package/dist/errors.js +3 -3
  216. package/dist/eval.cjs +42 -40
  217. package/dist/eval.cjs.map +1 -1
  218. package/dist/eval.js +36 -34
  219. package/dist/eval.js.map +1 -1
  220. package/dist/{executor-ZERJ3DGN.cjs → executor-6CYCA7MI.cjs} +25 -25
  221. package/dist/{executor-ZERJ3DGN.cjs.map → executor-6CYCA7MI.cjs.map} +1 -1
  222. package/dist/{executor-BMEHFOXZ.js → executor-QSEC3MRH.js} +8 -8
  223. package/dist/{executor-BMEHFOXZ.js.map → executor-QSEC3MRH.js.map} +1 -1
  224. package/dist/filesystem/index.cjs +8 -8
  225. package/dist/filesystem/index.js +4 -4
  226. package/dist/fs-session-store-4PIHT5UX.cjs +20 -0
  227. package/dist/{fs-session-store-XZ7ZTB3A.cjs.map → fs-session-store-4PIHT5UX.cjs.map} +1 -1
  228. package/dist/fs-session-store-NM6YSTE2.js +11 -0
  229. package/dist/{fs-session-store-4BHGIWRE.js.map → fs-session-store-NM6YSTE2.js.map} +1 -1
  230. package/dist/generate-object-GUNAUVBX.js +8 -0
  231. package/dist/{generate-object-N5MDZUJI.js.map → generate-object-GUNAUVBX.js.map} +1 -1
  232. package/dist/generate-object-R7HTMW7F.cjs +21 -0
  233. package/dist/{generate-object-PGSP5U7N.cjs.map → generate-object-R7HTMW7F.cjs.map} +1 -1
  234. package/dist/index-manager-RBDHP3PM.js +17 -0
  235. package/dist/{index-manager-AHAYJ33H.js.map → index-manager-RBDHP3PM.js.map} +1 -1
  236. package/dist/index-manager-UZBF22BJ.cjs +26 -0
  237. package/dist/{index-manager-RHPFVFSC.cjs.map → index-manager-UZBF22BJ.cjs.map} +1 -1
  238. package/dist/index.cjs +146 -319
  239. package/dist/index.cjs.map +1 -1
  240. package/dist/index.d.cts +8 -3
  241. package/dist/index.d.ts +8 -3
  242. package/dist/index.js +62 -235
  243. package/dist/index.js.map +1 -1
  244. package/dist/{inject-session-ZCQUB3IT.js → inject-session-DAR7OUCW.js} +8 -8
  245. package/dist/{inject-session-ZCQUB3IT.js.map → inject-session-DAR7OUCW.js.map} +1 -1
  246. package/dist/{inject-session-PPSO2IDD.cjs → inject-session-WQKMC3GR.cjs} +10 -10
  247. package/dist/{inject-session-PPSO2IDD.cjs.map → inject-session-WQKMC3GR.cjs.map} +1 -1
  248. package/dist/internal/memory/active-memory.d.ts +8 -1
  249. package/dist/internal/memory/adapters/index.cjs +9 -9
  250. package/dist/internal/memory/adapters/index.js +8 -8
  251. package/dist/internal/memory/dreaming/diary.d.ts +39 -2
  252. package/dist/internal/memory/index-db.d.ts +44 -1
  253. package/dist/internal/memory/index-manager-contract.d.ts +10 -0
  254. package/dist/internal/memory/index-manager-helpers.d.ts +20 -1
  255. package/dist/internal/memory/index-manager.d.ts +1 -1
  256. package/dist/internal/memory/lance-index.d.ts +15 -1
  257. package/dist/internal/memory/migrate-sqlite-to-lance.d.ts +43 -0
  258. package/dist/internal/memory/storage/index.cjs +101 -18
  259. package/dist/internal/memory/storage/index.d.cts +11 -1
  260. package/dist/internal/memory/storage/index.d.ts +11 -1
  261. package/dist/internal/memory/storage/index.js +10 -7
  262. package/dist/internal/memory/storage/markdown-store.d.cts +13 -42
  263. package/dist/internal/memory/storage/markdown-store.d.ts +13 -42
  264. package/dist/internal/memory/storage/memory-root.d.cts +93 -0
  265. package/dist/internal/memory/storage/memory-root.d.ts +93 -0
  266. package/dist/internal/memory/storage/session-loader.d.cts +35 -1
  267. package/dist/internal/memory/storage/session-loader.d.ts +35 -1
  268. package/dist/internal/memory/storage/session-summary-writer.d.cts +50 -2
  269. package/dist/internal/memory/storage/session-summary-writer.d.ts +50 -2
  270. package/dist/internal/memory/storage/transcript-store.d.cts +38 -1
  271. package/dist/internal/memory/storage/transcript-store.d.ts +38 -1
  272. package/dist/internal/memory/storage/wiki-loader.d.cts +27 -2
  273. package/dist/internal/memory/storage/wiki-loader.d.ts +27 -2
  274. package/dist/internal/memory/tools.d.ts +8 -1
  275. package/dist/internal/memory/types.d.ts +5 -0
  276. package/dist/internal/persistence/index.cjs +29 -28
  277. package/dist/internal/persistence/index.cjs.map +1 -1
  278. package/dist/internal/persistence/index.js +8 -7
  279. package/dist/internal/persistence/index.js.map +1 -1
  280. package/dist/internal/persistence/session-dir.d.cts +0 -15
  281. package/dist/internal/persistence/session-dir.d.ts +0 -15
  282. package/dist/internal/runtime/memory/memory-store.d.ts +2 -2
  283. package/dist/internal/security/index.cjs +14 -14
  284. package/dist/internal/security/index.js +4 -4
  285. package/dist/judge-call-LAHMBJ57.cjs +23 -0
  286. package/dist/{judge-call-EGYRC2RE.cjs.map → judge-call-LAHMBJ57.cjs.map} +1 -1
  287. package/dist/judge-call-LVXABPS3.js +6 -0
  288. package/dist/{judge-call-DWHAJATE.js.map → judge-call-LVXABPS3.js.map} +1 -1
  289. package/dist/mcp-auth.cjs +15 -15
  290. package/dist/mcp-auth.js +5 -5
  291. package/dist/models.cjs +22 -22
  292. package/dist/models.js +7 -7
  293. package/dist/path-safety.cjs +11 -11
  294. package/dist/path-safety.js +4 -4
  295. package/dist/persistence.cjs +33 -32
  296. package/dist/persistence.cjs.map +1 -1
  297. package/dist/persistence.js +10 -9
  298. package/dist/persistence.js.map +1 -1
  299. package/dist/project.cjs +6 -6
  300. package/dist/project.js +4 -4
  301. package/dist/providers.cjs +9 -9
  302. package/dist/providers.js +7 -7
  303. package/dist/registry-75W33OGL.js +10 -0
  304. package/dist/{registry-VFP3WWQP.js.map → registry-75W33OGL.js.map} +1 -1
  305. package/dist/registry-V7BDQ6QB.cjs +47 -0
  306. package/dist/{registry-VFKX7WOP.cjs.map → registry-V7BDQ6QB.cjs.map} +1 -1
  307. package/dist/retry.cjs +5 -5
  308. package/dist/retry.js +4 -4
  309. package/dist/sandbox/index.cjs +7 -7
  310. package/dist/sandbox/index.js +3 -3
  311. package/dist/server/errors-envelope.cjs +15 -15
  312. package/dist/server/errors-envelope.js +4 -4
  313. package/dist/session-transcript-6WNITKRE.cjs +63 -0
  314. package/dist/{session-transcript-HF5GEU5M.cjs.map → session-transcript-6WNITKRE.cjs.map} +1 -1
  315. package/dist/session-transcript-XAEKW6P7.js +6 -0
  316. package/dist/{session-transcript-P462ZRHX.js.map → session-transcript-XAEKW6P7.js.map} +1 -1
  317. package/dist/skills.cjs +8 -8
  318. package/dist/skills.js +6 -6
  319. package/dist/stream-object-UF4QRQRU.js +8 -0
  320. package/dist/{stream-object-L57K4OFS.js.map → stream-object-UF4QRQRU.js.map} +1 -1
  321. package/dist/stream-object-ZJTQNKY3.cjs +21 -0
  322. package/dist/{stream-object-BUCF5PHO.cjs.map → stream-object-ZJTQNKY3.cjs.map} +1 -1
  323. package/dist/subagents-loader-CRT5LLL3.js +8 -0
  324. package/dist/{subagents-loader-6ATCDEKN.js.map → subagents-loader-CRT5LLL3.js.map} +1 -1
  325. package/dist/subagents-loader-YEUFFPAL.cjs +17 -0
  326. package/dist/{subagents-loader-X5QKODCL.cjs.map → subagents-loader-YEUFFPAL.cjs.map} +1 -1
  327. package/dist/subagents-loader.cjs +7 -7
  328. package/dist/subagents-loader.d.cts +1 -1
  329. package/dist/subagents-loader.d.ts +1 -1
  330. package/dist/subagents-loader.js +5 -5
  331. package/dist/subscription/index.cjs +4 -4
  332. package/dist/subscription/index.js +3 -3
  333. package/dist/task-store.cjs +8 -8
  334. package/dist/task-store.js +5 -5
  335. package/dist/types/agent.d.ts +11 -0
  336. package/dist/types/memory-provider.d.ts +8 -0
  337. package/dist/workflow.cjs +28 -28
  338. package/dist/workflow.js +7 -7
  339. package/docs/error-codes.md +10 -9
  340. package/docs/harness-capability-map.md +57 -17
  341. package/docs/memory-decisions.md +44 -7
  342. package/package.json +1 -1
  343. package/dist/agent-NVBFTY5H.js +0 -55
  344. package/dist/agent-VYPUO4UB.cjs +0 -64
  345. package/dist/agent-session-store-G2BMUZQV.js +0 -7
  346. package/dist/agent-session-store-WAKLOKWK.cjs +0 -24
  347. package/dist/chunk-2UCFUSPW.cjs +0 -468
  348. package/dist/chunk-2UCFUSPW.cjs.map +0 -1
  349. package/dist/chunk-6HTXPPHK.cjs +0 -18
  350. package/dist/chunk-6OBIWHDR.cjs.map +0 -1
  351. package/dist/chunk-AH6WD7JR.cjs.map +0 -1
  352. package/dist/chunk-CQ2TQ32Y.js.map +0 -1
  353. package/dist/chunk-NUKRL3I6.cjs.map +0 -1
  354. package/dist/chunk-QEKI3YKI.js.map +0 -1
  355. package/dist/chunk-SKOCYA55.js.map +0 -1
  356. package/dist/chunk-SKXBJ2NU.cjs.map +0 -1
  357. package/dist/chunk-T7O6K6PX.js.map +0 -1
  358. package/dist/chunk-WCLDJSMY.js +0 -456
  359. package/dist/chunk-WCLDJSMY.js.map +0 -1
  360. package/dist/compact-session-GJXJD73F.cjs +0 -59
  361. package/dist/compact-session-TSMQOIHO.js +0 -22
  362. package/dist/context-LCKNH2XI.cjs +0 -24
  363. package/dist/context-MZSKGKYR.js +0 -7
  364. package/dist/fs-session-store-4BHGIWRE.js +0 -11
  365. package/dist/fs-session-store-XZ7ZTB3A.cjs +0 -20
  366. package/dist/generate-object-N5MDZUJI.js +0 -8
  367. package/dist/generate-object-PGSP5U7N.cjs +0 -21
  368. package/dist/index-manager-AHAYJ33H.js +0 -16
  369. package/dist/index-manager-RHPFVFSC.cjs +0 -25
  370. package/dist/judge-call-DWHAJATE.js +0 -6
  371. package/dist/judge-call-EGYRC2RE.cjs +0 -23
  372. package/dist/registry-VFKX7WOP.cjs +0 -47
  373. package/dist/registry-VFP3WWQP.js +0 -10
  374. package/dist/session-transcript-HF5GEU5M.cjs +0 -63
  375. package/dist/session-transcript-P462ZRHX.js +0 -6
  376. package/dist/stream-object-BUCF5PHO.cjs +0 -21
  377. package/dist/stream-object-L57K4OFS.js +0 -8
  378. package/dist/subagents-loader-6ATCDEKN.js +0 -8
  379. package/dist/subagents-loader-X5QKODCL.cjs +0 -17
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/internal/persistence/fts5-sanitize.ts","../src/internal/persistence/sqlite-wal.ts","../src/internal/persistence/sqlite-open.ts"],"names":["diag","mkdir","dirname","ConfigurationError","rename"],"mappings":";;;;;;;;AAsBA,IAAM,WAAA,GAAc,GAAA;AACpB,IAAM,YAAA,GAAe,GAAA;AAUd,SAAS,kBAAkB,KAAA,EAAuB;AACvD,EAAA,IAAI,KAAA,CAAM,MAAA,KAAW,CAAA,EAAG,OAAO,KAAA;AAG/B,EAAA,MAAM,UAAoB,EAAC;AAC3B,EAAA,IAAI,IAAA,GAAO,KAAA,CAAM,OAAA,CAAQ,UAAA,EAAY,CAAC,KAAA,KAAU;AAC9C,IAAA,OAAA,CAAQ,KAAK,KAAK,CAAA;AAClB,IAAA,OAAO,GAAG,WAAW,CAAA,EAAG,QAAQ,MAAA,GAAS,CAAC,GAAG,YAAY,CAAA,CAAA;AAAA,EAC3D,CAAC,CAAA;AAGD,EAAA,IAAA,GAAO,IAAA,CAAK,OAAA,CAAQ,cAAA,EAAgB,GAAG,CAAA;AAGvC,EAAA,IAAA,GAAO,IAAA,CAAK,OAAA,CAAQ,MAAA,EAAQ,GAAG,CAAA;AAG/B,EAAA,IAAA,GAAO,IAAA,CAAK,OAAA,CAAQ,sBAAA,EAAwB,EAAE,CAAA;AAC9C,EAAA,IAAA,GAAO,IAAA,CAAK,OAAA,CAAQ,sBAAA,EAAwB,EAAE,CAAA;AAI9C,EAAA,IAAA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ACF","file":"chunk-SKXBJ2NU.cjs","sourcesContent":["/**\n * FTS5 query sanitization + CJK detection (ADR D64).\n *\n * Port of Hermes' 6-step sanitizer (`hermes_state.py:1797-1847`). Prevents\n * crashes on user inputs with hyphens, dots, underscores, and unmatched\n * specials. Auto-quotes identifier-shaped tokens so `error-code` finds\n * literal `error-code` instead of `error AND code`.\n *\n * CJK detection returns true for inputs containing characters in the main\n * CJK Unicode ranges (Chinese, Japanese, Korean). CJK trigram routing is\n * deferred to v1.4 — callers receiving `containsCjk === true` should\n * short-circuit to an empty result or LIKE fallback for v1.3.\n *\n * @internal\n */\n\n// Control-char sentinels for the phrase-preservation placeholder. U+0001\n// and U+0002 are essentially never present in real user queries, and\n// crucially do NOT form word boundaries / `\\w` characters, so Step 5's\n// auto-quote regex (`\\b\\w+[-._]\\w[\\w\\-._]*\\b`) cannot match them.\n// Choosing `__PHRASE_N__` instead would re-trigger Step 5 on the second\n// sanitize pass and break idempotence.\nconst PHRASE_OPEN = \"\u0001\";\nconst PHRASE_CLOSE = \"\u0002\";\n\n/**\n * Six-step FTS5 query sanitizer. Returns a query string safe for passing\n * to `WHERE <fts5_table> MATCH ?` as a parameter.\n *\n * Returns empty string when the input contains only specials (caller MUST\n * short-circuit to avoid runtime SQL error — EC-3).\n *\n */\nexport function sanitizeFts5Query(query: string): string {\n if (query.length === 0) return query;\n\n // Step 1: preserve \"quoted phrases\" via control-char placeholders.\n const phrases: string[] = [];\n let text = query.replace(/\"[^\"]+\"/g, (match) => {\n phrases.push(match);\n return `${PHRASE_OPEN}${phrases.length - 1}${PHRASE_CLOSE}`;\n });\n\n // Step 2: strip unmatched specials (brackets, braces, parens, double quotes, caret).\n text = text.replace(/[[\\]{}()\"^]/g, \" \");\n\n // Step 3: collapse repeated asterisks (FTS5 prefix operator is single `*`).\n text = text.replace(/\\*+/g, \"*\");\n\n // Step 4: strip dangling boolean operators (AND/OR/NOT) at start/end.\n text = text.replace(/^\\s*(AND|OR|NOT)\\s+/i, \"\");\n text = text.replace(/\\s+(AND|OR|NOT)\\s*$/i, \"\");\n\n // Step 5: auto-quote identifier-shaped tokens that contain `-`, `.`, or `_`.\n // FTS5 tokenizer would otherwise split them as boolean conjunctions.\n text = text.replace(/\\b\\w+[-._]\\w[\\w\\-._]*\\b/g, (match) => `\"${match}\"`);\n\n // Step 6: restore preserved phrases.\n for (let i = 0; i < phrases.length; i += 1) {\n text = text.replace(`${PHRASE_OPEN}${i}${PHRASE_CLOSE}`, phrases[i] ?? \"\");\n }\n\n return text.trim();\n}\n\n// CJK code-point ranges. Coverage matches Hermes' coarse detection for v1.3;\n// fine-grained trigram routing comes in v1.4.\nconst CJK_RANGES: ReadonlyArray<readonly [number, number]> = [\n [0x3000, 0x303f], // CJK Symbols and Punctuation\n [0x3040, 0x309f], // Hiragana\n [0x30a0, 0x30ff], // Katakana\n [0x3400, 0x4dbf], // CJK Unified Ideographs Extension A\n [0x4e00, 0x9fff], // CJK Unified Ideographs\n [0xac00, 0xd7af], // Hangul Syllables\n];\n\n/**\n * Report whether `text` holds at least one Chinese, Japanese or Korean character.\n *\n * Iterates by code point, so surrogate pairs are handled correctly, and returns on the first hit.\n * An empty string is `false`.\n *\n * Coverage is deliberately coarse: CJK Symbols and Punctuation, Hiragana, Katakana, Hangul\n * Syllables, and CJK Unified Ideographs including Extension A. Everything beyond that — the\n * higher ideograph extensions, Halfwidth and Fullwidth Forms, Hangul Jamo — reads as `false`, so\n * a `false` is not proof that the text is CJK-free.\n *\n * The reason to ask is FTS5: the default tokenizer splits on whitespace, which CJK text does not\n * use, so a matching query against it returns nothing rather than failing. A caller seeing `true`\n * should short-circuit to an empty result or a LIKE fallback instead of running the search and\n * reporting no matches.\n *\n * Semver-exempt: reachable via the `@theokit/sdk/internal/persistence` sub-path, which the package\n * declares in `exports` but does NOT cover with its semver contract.\n */\nexport function containsCjk(text: string): boolean {\n for (const char of text) {\n const cp = char.codePointAt(0);\n if (cp === undefined) continue;\n for (const [lo, hi] of CJK_RANGES) {\n if (cp >= lo && cp <= hi) return true;\n }\n }\n return false;\n}\n","/**\n * SQLite WAL mode helper with NFS/SMB/FUSE fallback to DELETE (ADR D63).\n *\n * WAL is faster (concurrent readers + one writer) but unsupported on some\n * network/FUSE filesystems. Try WAL; if the pragma returns something else\n * or throws, fall back to DELETE journal mode. Warn one time per label.\n *\n * This block is the MODULE header and must stay at offset 0. Sitting below the import it became a\n * leading comment of the first declaration instead, which is how its tag deleted `PragmaCapable`\n * from the emitted `.d.ts` while `applyWalWithFallback` — which names it — survived.\n */\n\nimport { diag } from \"../diagnostics.js\";\n\n/**\n * The narrow slice of a SQLite handle this module needs: anything with a `pragma()` method, which\n * `better-sqlite3` satisfies without being named here.\n *\n * Not exported, but it appears in the signature of `applyWalWithFallback`, so it is emitted into\n * the published declarations and a consumer can structurally satisfy it.\n */\ninterface PragmaCapable {\n pragma: (statement: string, options?: { simple?: boolean }) => unknown;\n}\n\n/**\n * What journal mode a connection ended up in after `applyWalWithFallback`.\n *\n * `mode` is the mode actually in effect, never the one that was requested. `fellBack` is `true`\n * only when WAL was attempted and refused — either the pragma threw or it reported a mode other\n * than `wal` — and the connection was put into DELETE instead.\n *\n * `fellBack: true` is normal on NFS, SMB and FUSE, where WAL needs shared memory the filesystem\n * does not provide. It is not an error and nothing further is required of the caller; the\n * consequence is slower concurrent access, since DELETE mode does not allow readers alongside a\n * writer. Treat it as a signal about the storage, not about the database.\n *\n * @public — re-exported from the semver-protected `@theokit/sdk/persistence` barrel, and (for\n * back-compat) from the semver-exempt `@theokit/sdk/internal/persistence` alias.\n */\nexport interface WalApplyResult {\n /** Final journal_mode actually in effect. */\n mode: \"wal\" | \"delete\";\n /** True if we wanted WAL but the filesystem refused. */\n fellBack: boolean;\n}\n\nconst warnedLabels = new Set<string>();\n\n/**\n * Apply WAL mode with DELETE fallback. Idempotent — safe to call multiple\n * times on the same connection.\n *\n * @param db any `pragma()`-capable SQLite handle (e.g., `better-sqlite3`)\n * @param label short identifier used in the warning (e.g., \"memory-index\")\n *\n */\nexport function applyWalWithFallback(db: PragmaCapable, label: string): WalApplyResult {\n try {\n const result = db.pragma(\"journal_mode = WAL\", { simple: true });\n if (typeof result === \"string\" && result.toLowerCase() === \"wal\") {\n return { mode: \"wal\", fellBack: false };\n }\n logFallback(label, `got \"${String(result)}\" instead of \"wal\"`);\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n logFallback(label, msg);\n }\n\n db.pragma(\"journal_mode = DELETE\");\n return { mode: \"delete\", fellBack: true };\n}\n\nfunction logFallback(label: string, reason: string): void {\n if (warnedLabels.has(label)) return;\n warnedLabels.add(label);\n diag(\n `[theokit-sdk] ${label}: WAL unavailable (${reason}); using DELETE journal mode. ` +\n \"This is normal on NFS/SMB/FUSE; expect slightly slower concurrent access.\\n\",\n );\n}\n\n/**\n * Test helper — clears the warn-once registry.\n *\n * @internal\n */\nexport function _resetWalWarnings(): void {\n warnedLabels.clear();\n}\n","/**\n * Resilient SQLite open (plan m0-foundation-expose-primitives, M0-5).\n *\n * Generalizes the driver-load + WAL-apply + corruption-recovery logic that was\n * duplicated (byte-identical) across `sdk/internal/memory/index-db.ts` and\n * `sdk-memory/internal/index/index-db.ts`. Schema-agnostic: the caller applies\n * its own PRAGMA/SCHEMA via the `onOpen` callback.\n *\n * Corruption recovery (EC-7): when opening fails with a \"malformed\" / \"not a\n * database\" / \"encrypted\" error and `recoverCorrupt` is not false, the file is\n * renamed aside to `<path>.corrupt-<ts>` (plus its WAL/SHM siblings) and a fresh\n * DB is opened. The corrupt file is renamed, NOT backed up — the timestamped\n * `.corrupt-*` file is kept for manual recovery.\n *\n * @internal — public via `@theokit/sdk/internal/persistence` (semver-exempt)\n */\n\nimport { mkdir, rename } from \"node:fs/promises\";\nimport { dirname } from \"node:path\";\n\nimport { ConfigurationError } from \"../../errors.js\";\nimport { diag } from \"../diagnostics.js\";\nimport { applyWalWithFallback } from \"./sqlite-wal.js\";\n\n/** Minimal SQLite handle surface every driver (`better-sqlite3`) exposes. */\nexport interface ResilientSqliteDb {\n /** SQLite `pragma()` access (used by `applyWalWithFallback`). */\n pragma(statement: string, options?: { simple?: boolean }): unknown;\n exec(sql: string): void;\n close(): void;\n}\n\n/**\n * Input to {@link openSqliteResilient}.\n *\n * The trap is `recoverCorrupt`, whose default is ON. When the driver reports a corrupt or encrypted\n * database, the file is renamed aside and a FRESH one is opened — so the call SUCCEEDS and hands\n * back an EMPTY database. The old bytes survive on disk under the renamed path, but a caller that\n * treats a resolved promise as \"my data is here\" is wrong exactly when it matters. Pass\n * `recoverCorrupt: false` to get the corruption error thrown instead.\n *\n * Semver-exempt: reachable via the '@theokit/sdk/internal/persistence' sub-path, which the package\n * declares in 'exports' but does NOT cover with its semver contract.\n *\n * @typeParam T - the concrete DB handle the driver returns; defaults to {@link ResilientSqliteDb}\n */\nexport interface OpenSqliteResilientOptions<T extends ResilientSqliteDb> {\n /** Absolute path to the SQLite file. Parent directories are created. */\n filePath: string;\n /**\n * Called after the driver is open and WAL is applied, before the handle is\n * returned. Apply PRAGMA/SCHEMA statements here. Errors propagate.\n */\n onOpen?: (db: T) => void | Promise<void>;\n /** Label used in the WAL-fallback warning and corruption-recovery log. Default \"sqlite\". */\n label?: string;\n /** When true (default) a corruption error renames the file aside and rebuilds. */\n recoverCorrupt?: boolean;\n}\n\n/**\n * Open a SQLite file with WAL (+ DELETE fallback) and corruption recovery.\n *\n * @typeParam T - the concrete DB handle type the driver returns (defaults to the\n * minimal {@link ResilientSqliteDb} surface)\n */\nexport async function openSqliteResilient<T extends ResilientSqliteDb = ResilientSqliteDb>(\n options: OpenSqliteResilientOptions<T>,\n): Promise<T> {\n await mkdir(dirname(options.filePath), { recursive: true });\n try {\n return await openConcrete(options);\n } catch (cause) {\n if (options.recoverCorrupt !== false && isCorruptionError(cause)) {\n await renameAside(options.filePath, options.label ?? \"sqlite\");\n return await openConcrete(options);\n }\n throw cause;\n }\n}\n\nasync function openConcrete<T extends ResilientSqliteDb>(\n options: OpenSqliteResilientOptions<T>,\n): Promise<T> {\n const db = await loadDriver<T>(options.filePath);\n // Apply WAL with NFS/SMB/FUSE fallback BEFORE schema so the journal mode is\n // set for the whole session.\n applyWalWithFallback(db, options.label ?? \"sqlite\");\n await options.onOpen?.(db);\n return db;\n}\n\n/** Injectable driver loaders (tests simulate a consumer env without better-sqlite3). */\ninterface DriverLoaders {\n betterSqlite3?: () => Promise<unknown>;\n nodeSqlite?: () => Promise<unknown>;\n}\nlet driverLoaderOverrides: DriverLoaders | undefined;\n\n/** Test-only. @internal */\nexport function _setDriverLoadersForTests(overrides: DriverLoaders | undefined): void {\n driverLoaderOverrides = overrides;\n}\n\n/**\n * Adapt `node:sqlite`'s `DatabaseSync` to the better-sqlite3 surface this module's callers use\n * (`prepare/get/all/run`, `exec`, `close`, `pragma`, `loadExtension`). The error message below has\n * ALWAYS promised this fallback (\"or run on Node 22.5+ for built-in node:sqlite\") — before the\n * flicker-bug fix the promise was fabricated: only better-sqlite3 was ever tried, so every consumer\n * without the optional native dep lost memory tools AND got a per-turn stderr WARN.\n */\nfunction adaptNodeSqlite(db: {\n prepare(sql: string): unknown;\n exec(sql: string): void;\n close(): void;\n loadExtension?: (path: string) => void;\n}): ResilientSqliteDb {\n const pragma = (statement: string, options?: { simple?: boolean }): unknown => {\n const stmt = db.prepare(`PRAGMA ${statement}`) as {\n get(): Record<string, unknown> | undefined;\n };\n const row = stmt.get();\n if (options?.simple === true) {\n return row === undefined ? undefined : Object.values(row)[0];\n }\n return row === undefined ? [] : [row];\n };\n return new Proxy(db as unknown as ResilientSqliteDb, {\n get(target, prop, receiver) {\n if (prop === \"pragma\") return pragma;\n if (prop === \"loadExtension\" && typeof db.loadExtension !== \"function\") {\n return () => {\n throw new Error(\n \"SQLite extension loading is unavailable on the node:sqlite fallback — install better-sqlite3 for sqlite-vec\",\n );\n };\n }\n const value = Reflect.get(target, prop, receiver) as unknown;\n return typeof value === \"function\"\n ? (value as (...a: unknown[]) => unknown).bind(target)\n : value;\n },\n });\n}\n\n// PRE-EXISTING debt, exposed when M75 fixed the Biome config that used to abort before\n// sweeping these files (a nested root under refactor/). It is not new code and was not touched\n// by M75; refactoring SDK internals without review would trade a visible problem for a diff\n// risky. Tracked in usetheodev/theokit-sdk#151.\n// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: see the reason just above\nasync function loadDriver<T extends ResilientSqliteDb>(filePath: string): Promise<T> {\n let betterSqliteCause: unknown;\n try {\n const mod = (await (driverLoaderOverrides?.betterSqlite3?.() ?? import(\"better-sqlite3\"))) as {\n default?: unknown;\n };\n const Ctor = mod.default ?? mod;\n if (typeof Ctor !== \"function\") {\n throw new Error(`better-sqlite3 export is not a constructor (got ${typeof Ctor})`);\n }\n return new (Ctor as new (path: string) => unknown)(filePath) as T;\n } catch (cause) {\n betterSqliteCause = cause;\n }\n // Fallback: the Node 22.5+ built-in driver (the path the error message documents).\n // `process.getBuiltinModule` (Node 22.3+) instead of `import(\"node:sqlite\")` — bundlers that\n // predate the sqlite builtin rewrite the import specifier to a bare \"sqlite\" package (proven in\n // the published dist: \"Cannot find package 'sqlite'\"), while getBuiltinModule is opaque to them.\n try {\n const mod = (await (driverLoaderOverrides?.nodeSqlite?.() ??\n Promise.resolve(\n (process as { getBuiltinModule?: (id: string) => unknown }).getBuiltinModule?.(\n \"node:sqlite\",\n ) ??\n (() => {\n throw new Error(\"node:sqlite built-in unavailable (Node < 22.3)\");\n })(),\n ))) as {\n DatabaseSync: new (\n path: string,\n ) => {\n prepare(sql: string): unknown;\n exec(sql: string): void;\n close(): void;\n };\n };\n return adaptNodeSqlite(new mod.DatabaseSync(filePath)) as T;\n } catch (nodeSqliteCause) {\n const b =\n betterSqliteCause instanceof Error ? betterSqliteCause.message : String(betterSqliteCause);\n const n = nodeSqliteCause instanceof Error ? nodeSqliteCause.message : String(nodeSqliteCause);\n throw new ConfigurationError(\n `Failed to load SQLite driver. Install \\`better-sqlite3\\` or run on Node 22.5+ for built-in \\`node:sqlite\\`. better-sqlite3: ${b}; node:sqlite: ${n}`,\n { code: \"sqlite_driver_unavailable\", cause: nodeSqliteCause },\n );\n }\n}\n\n/** True when an open error indicates an unreadable / corrupt database file. */\nexport function isCorruptionError(cause: unknown): boolean {\n if (!(cause instanceof Error)) return false;\n const msg = cause.message.toLowerCase();\n return (\n msg.includes(\"malformed\") ||\n msg.includes(\"not a database\") ||\n msg.includes(\"encrypted\") ||\n msg.includes(\"disk image is malformed\")\n );\n}\n\nasync function renameAside(filePath: string, label: string): Promise<void> {\n const asidePath = `${filePath}.corrupt-${Date.now()}`;\n await rename(filePath, asidePath).catch(() => undefined);\n await rename(`${filePath}-wal`, `${asidePath}-wal`).catch(() => undefined);\n await rename(`${filePath}-shm`, `${asidePath}-shm`).catch(() => undefined);\n diag(\n `[theokit-sdk] ${label} database corrupt; renamed aside to ${asidePath} and rebuilt schema\\n`,\n );\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/internal/diagnostics.ts"],"names":[],"mappings":";AAoEA,IAAM,SAAA,mBAAY,MAAA,CAAO,GAAA,CAAI,iCAAiC,CAAA;AAI9D,SAAS,WAAA,GAA2C;AAClD,EAAA,OAAQ,WAAqC,SAAS,CAAA;AACxD;AASO,SAAS,mBAAmB,IAAA,EAAyC;AAC1E,EAAC,UAAA,CAAqC,SAAS,CAAA,GAAI,IAAA;AACrD;AAQO,SAAS,KAAK,OAAA,EAAuB;AAG1C,EAAA,MAAM,OAAO,WAAA,EAAY;AACzB,EAAA,IAAI,SAAS,MAAA,EAAW;AACxB,EAAA,IAAI;AACF,IAAA,IAAA,CAAK,OAAO,CAAA;AAAA,EACd,CAAA,CAAA,MAAQ;AAAA,EAER;AACF","file":"chunk-T7O6K6PX.js","sourcesContent":["/**\n * The library's single diagnostics channel — silent by default (#147).\n *\n * ## The problem\n *\n * The SDK wrote diagnostics straight to `process.stderr` from hot paths — 92 sites across 51\n * files under `internal/`. In a TUI host (Ink, alternate screen), those writes interleave with the\n * render and **corrupt the frame**. And the host had no way to intercept them: there was no\n * injectable logger. One consumer went as far as installing `proper-lockfile` just to silence ONE\n * of them.\n *\n * A library cannot assume `stdout`/`stderr` are free sinks. The application owns the terminal, not\n * the dependency.\n *\n * ## The contract\n *\n * - **`setDiagnosticsSink(fn)`** hands the messages to the application, which decides where to put\n * them (a status line, a file, a panel). It is what was missing for a TUI to coexist with the SDK.\n * - **With no sink, nothing is emitted.** A library does not own the host's terminal.\n *\n * ## Silent by default, and how 36 suites survived the flip\n *\n * The default WAS `stderr`, and 36 test files spy on `process.stderr.write` to assert a given\n * warning is emitted. That contract is real and had to survive; migrating all 36 by hand, across\n * four different spy styles, is how you weaken 36 suites in one commit.\n *\n * So the flip happened at the default, and `vitest.setup.ts` installs a sink that FORWARDS to\n * `stderr` for the duration of every test. Those assertions still test what they always tested —\n * \"this condition emits a diagnostic\" — through the channel a host would use, while production\n * emits nothing unless asked.\n *\n * The cost is stated rather than hidden: no test observes the production default by accident, so\n * `tests/diagnostics-public-entry.test.ts` pins it explicitly by clearing the sink first.\n *\n * ## Coverage is the whole guarantee\n *\n * The first sweep migrated the 92 sites under `internal/` and left `src/`'s own modules —\n * `event-bus.ts`, `batch.ts`, `compaction.ts`, `internal/workflow/step-branch.ts`. A host could\n * therefore install a sink and still have its frame corrupted by a batch run, which is the reported\n * defect with a smaller blast radius. Those are routed here too, and\n * `tests/lint/no-direct-terminal-write.test.ts` is what keeps the next hot path from\n * reintroducing one. \"Mostly interceptable\" is not interceptable.\n *\n * The remaining direct writers are allowlisted there with a reason, and every one of them is a seam\n * whose destination the CALLER already chooses (`opts.warn`, `opts.logger`, the Workflow logger).\n *\n * ## What this is NOT\n *\n * It is not a logger with levels, formatting or multiple destinations. It is the minimum that\n * resolves the reported blocker; a full logger here would be inventing a requirement nobody asked\n * for.\n */\n\n/** Receives each diagnostic message already formatted, with the trailing `\\n`. */\nexport type DiagnosticsSink = (message: string) => void;\n\n/**\n * The registry lives on `globalThis`, not in a module-level `let` (theokit#173).\n *\n * A module-level binding is a per-INSTANCE singleton, and a package manager will install two\n * physical copies of the same version whenever two dependents resolve different peer sets. Measured:\n * `@theokit/sdk@4.39.1` existed under two pnpm store hashes in the theokit workspace, so a sink\n * installed through `@theokit/agents` landed in a different registry than the emitter writes to.\n *\n * The failure mode is the quiet one — the re-export resolves, the function is callable, nothing\n * throws, and no diagnostic ever arrives. `Symbol.for` gives every copy in the process the same\n * slot; the `v1` suffix leaves room to change the shape without colliding with an older copy.\n */\nconst SINK_SLOT = Symbol.for(\"theokit.sdk.diagnostics.sink.v1\");\n\ntype SinkHolder = Record<symbol, DiagnosticsSink | undefined>;\n\nfunction currentSink(): DiagnosticsSink | undefined {\n return (globalThis as unknown as SinkHolder)[SINK_SLOT];\n}\n\n/**\n * Installs (or removes, by passing `undefined`) the diagnostics destination.\n *\n * When a sink is present it is the ONLY destination — `stderr` gets no copy. Duplicating\n * destinations would hand the problem back to the TUI that installed the sink precisely to get the\n * messages out of the terminal.\n */\nexport function setDiagnosticsSink(next: DiagnosticsSink | undefined): void {\n (globalThis as unknown as SinkHolder)[SINK_SLOT] = next;\n}\n\n/**\n * Emits a library diagnostic message.\n *\n * Replaces `process.stderr.write` on internal paths. Never throws: a faulty sink must not\n * must not take down the run it merely observes.\n */\nexport function diag(message: string): void {\n // Silent by default (#147): with no sink installed the message is dropped. A library must not\n // assume the host's stdout/stderr are free-form log sinks — in a TUI they are the render surface.\n const sink = currentSink();\n if (sink === undefined) return;\n try {\n sink(message);\n } catch {\n // Observability never breaks the run — same principle as `emitRunEvent`.\n }\n}\n\n/**\n * Emits a diagnostic that reports a USER-VISIBLE FAILURE, and is never silently dropped.\n *\n * `diag` is silent with no sink installed, and that is right for chatter: a library must not assume\n * the host's stderr is a free-form log, because in a TUI it is the render surface. A failure is a\n * different message. `theokit-sdk#189` is the record of the difference — an MCP server failed to\n * start, the only report went to `diag()`, the embedding UI never read it, and the user saw an\n * agent with missing tools and no reason given.\n *\n * The two failure modes are not symmetric, which is the whole decision: a corrupted frame is\n * visible and recoverable, while a silently dropped failure is neither. So this falls back to\n * stderr rather than to silence.\n *\n * A sink still takes precedence — the host installed it precisely to keep these off the terminal —\n * EXCEPT when the sink throws. A broken sink swallowing the one report of a failure is the same\n * defect one layer further in.\n *\n * @internal\n */\nexport function diagFailure(message: string): void {\n const sink = currentSink();\n if (sink !== undefined) {\n try {\n sink(message);\n return;\n } catch {\n // Fall through: the sink is broken, and this message is too important to drop with it.\n }\n }\n try {\n // `globalThis.process?.stderr` rather than a bare `process`: in a browser the bare form is a\n // ReferenceError that the catch below would swallow — working by accident, on an exception used\n // as ordinary control flow. Optional chaining states the intent: write to stderr where one\n // exists, stay silent where none does.\n globalThis.process?.stderr?.write(`${message}\\n`);\n } catch {\n // Nothing left to try. Observability never breaks the run.\n }\n}\n"]}
@@ -1,456 +0,0 @@
1
- import { splitFrontmatter, parseSimpleYaml } from './chunk-KVNWIAO4.js';
2
- import { sanitizeIdentifier, safePathJoin, safeFilenameForId } from './chunk-QARJGQSA.js';
3
- import { encodeProjectDir } from './chunk-FKMUFNQE.js';
4
- import { withCwdMutex } from './chunk-Q5EWJPRY.js';
5
- import { replaceFileAtomic } from './chunk-VF7EWVDG.js';
6
- import { ConfigurationError } from './chunk-IDCKSLYH.js';
7
- import { redactSecrets } from './chunk-T7XEKOVW.js';
8
- import { readdir, readFile, mkdir } from 'fs/promises';
9
- import { homedir } from 'os';
10
- import { resolve, join } from 'path';
11
-
12
- var MEMORY_KINDS = ["user", "feedback", "project", "reference"];
13
- function legacyMemoryJsonPath(cwd, config) {
14
- if (config.storePath !== void 0) {
15
- return resolve(cwd, config.storePath);
16
- }
17
- const namespace = sanitizeIdentifier(config.namespace ?? "default");
18
- const scope = sanitizeIdentifier(config.scope ?? "agent", { maxLen: 16 });
19
- const userId = sanitizeIdentifier(config.userId ?? "default");
20
- return safePathJoin(cwd, ".theokit", "memory", namespace, `${scope}-${userId}.json`);
21
- }
22
-
23
- // src/internal/memory/storage/memory-file.ts
24
- var SAFE_SLUG = /^[a-z0-9][a-z0-9_-]*$/;
25
- var MAX_SLUG_LENGTH = 64;
26
- var TARGET_SLUG_LENGTH = 32;
27
- var TITLE_MAX_LENGTH = 40;
28
- var TITLE_MAX_WORDS = 4;
29
- var SLUG_STOPWORDS = /* @__PURE__ */ new Set([
30
- "the",
31
- "a",
32
- "an",
33
- "and",
34
- "or",
35
- "but",
36
- "is",
37
- "are",
38
- "was",
39
- "were",
40
- "be",
41
- "been",
42
- "being",
43
- "for",
44
- "of",
45
- "to",
46
- "in",
47
- "on",
48
- "at",
49
- "by",
50
- "with",
51
- "from",
52
- "as",
53
- "that",
54
- "this",
55
- "these",
56
- "those",
57
- "it",
58
- "its",
59
- "he",
60
- "she",
61
- "they",
62
- "we",
63
- "you",
64
- "i",
65
- "do",
66
- "does",
67
- "did",
68
- "has",
69
- "have",
70
- "had",
71
- "will",
72
- "would",
73
- "can",
74
- "could",
75
- "should",
76
- "must",
77
- "not",
78
- "no",
79
- "over",
80
- "under",
81
- "into",
82
- "onto",
83
- "than",
84
- "then",
85
- "when",
86
- "where",
87
- "which",
88
- "who",
89
- "why",
90
- "how",
91
- "all",
92
- "any",
93
- "each",
94
- "more",
95
- "most",
96
- "other",
97
- "some",
98
- "such",
99
- "only",
100
- "own",
101
- "same",
102
- "so",
103
- "too",
104
- "very",
105
- "just",
106
- "also",
107
- "about",
108
- "after",
109
- "before",
110
- "between",
111
- "during",
112
- "up",
113
- "down",
114
- "out",
115
- "off",
116
- "again",
117
- "once",
118
- "here",
119
- "there",
120
- "if",
121
- "because",
122
- "while"
123
- ]);
124
- function topicWords(text) {
125
- return text.toLowerCase().normalize("NFD").replace(/[̀-ͯ]/g, "").split(/[^a-z0-9]+/).filter((w) => w.length >= 2 && !SLUG_STOPWORDS.has(w));
126
- }
127
- function slugForFact(text) {
128
- const words = topicWords(text);
129
- let slug = "";
130
- for (const w of words) {
131
- const next = slug.length === 0 ? w : `${slug}-${w}`;
132
- if (next.length > TARGET_SLUG_LENGTH && slug.length > 0) break;
133
- if (next.length > MAX_SLUG_LENGTH) break;
134
- slug = next;
135
- }
136
- if (slug.length === 0) {
137
- slug = text.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, MAX_SLUG_LENGTH).replace(/-+$/, "");
138
- }
139
- return SAFE_SLUG.test(slug) ? slug : safeFilenameForId(text);
140
- }
141
- function titleForFact(text) {
142
- const words = topicWords(text);
143
- if (words.length === 0) return text.trim().slice(0, TITLE_MAX_LENGTH);
144
- let title = "";
145
- let used = 0;
146
- for (const w of words) {
147
- if (used >= TITLE_MAX_WORDS) break;
148
- const next = title.length === 0 ? w : `${title} ${w}`;
149
- if (next.length > TITLE_MAX_LENGTH && title.length > 0) break;
150
- title = next;
151
- used += 1;
152
- }
153
- if (title.length === 0) title = words[0];
154
- return title.charAt(0).toUpperCase() + title.slice(1);
155
- }
156
- function readMetadata(raw) {
157
- const metadata = raw ?? {};
158
- const rawKind = metadata.type;
159
- const kind = typeof rawKind === "string" && MEMORY_KINDS.includes(rawKind) ? rawKind : void 0;
160
- const modified = typeof metadata.modified === "string" ? metadata.modified : void 0;
161
- const observations = readObservationCount(metadata.observations);
162
- return {
163
- ...kind !== void 0 ? { kind } : {},
164
- ...modified !== void 0 ? { modified } : {},
165
- ...observations !== void 0 ? { observations } : {}
166
- };
167
- }
168
- function readObservationCount(raw) {
169
- if (typeof raw !== "number") return void 0;
170
- if (!Number.isInteger(raw) || raw <= 0) return void 0;
171
- return raw;
172
- }
173
- function renderMemoryFile(fields) {
174
- const metadata = [" node_type: memory"];
175
- if (fields.kind !== void 0) metadata.push(` type: ${fields.kind}`);
176
- if (fields.modified !== void 0) metadata.push(` modified: ${fields.modified}`);
177
- if (fields.observations !== void 0) {
178
- metadata.push(` observations: ${fields.observations}`);
179
- }
180
- return [
181
- "---",
182
- `name: ${fields.name}`,
183
- `description: ${JSON.stringify(fields.description)}`,
184
- "metadata:",
185
- ...metadata,
186
- "---",
187
- "",
188
- fields.body,
189
- ""
190
- ].join("\n");
191
- }
192
- function parseMemoryFile(raw) {
193
- const { yaml, body } = splitFrontmatter(raw);
194
- if (yaml === void 0) return void 0;
195
- let fields;
196
- try {
197
- fields = parseSimpleYaml(yaml);
198
- } catch {
199
- return void 0;
200
- }
201
- const name = fields.name;
202
- const description = fields.description;
203
- if (typeof name !== "string" || typeof description !== "string") return void 0;
204
- return {
205
- name,
206
- description,
207
- ...readMetadata(fields.metadata),
208
- body: body.trim()
209
- };
210
- }
211
-
212
- // src/internal/memory/storage/threat-scan.ts
213
- var INVISIBLE_CLASS = "\\u200B-\\u200F\\u202A-\\u202E\\u2066-\\u2069\\uFEFF";
214
- var THREAT_PATTERNS = [
215
- {
216
- id: "invisible_unicode",
217
- // Text that renders as one thing to a reviewer and another to a parser is the whole
218
- // technique.
219
- test: new RegExp(`[${INVISIBLE_CLASS}]`, "u"),
220
- why: "contains invisible or bidirectional control characters"
221
- },
222
- {
223
- id: "instruction_override",
224
- // The framing that tries to make recalled text outrank the system prompt. A memory entry
225
- // states what was learned; it never addresses the model's instructions.
226
- test: /\b(?:ignore|disregard|forget|override)\s+(?:all\s+|any\s+|the\s+|your\s+|previous\s+|prior\s+|earlier\s+|above\s+)*(?:instruction|prompt|rule|directive|guideline|system\s+prompt)/i,
227
- why: "addresses the model's instructions instead of stating what was learned"
228
- },
229
- {
230
- id: "role_reassignment",
231
- test: /\b(?:you\s+are\s+now|from\s+now\s+on\s+you\s+(?:are|will|must)|new\s+system\s+prompt|act\s+as\s+(?:if\s+you\s+are\s+)?(?:an?\s+)?(?:unrestricted|jailbroken|developer\s+mode))/i,
232
- why: "attempts to reassign the agent's role"
233
- },
234
- // A `pipe_to_shell` pattern (`curl … | sh`) was written here and REMOVED after measurement.
235
- // It fired on 1 of 797 real memory files, and the hit was legitimate: a note documenting the
236
- // product's own install command in a table. Fetch-and-execute in a hostile entry and in an
237
- // install instruction are textually identical, so the pattern cannot be narrowed — only
238
- // traded. Rejecting the write would mean the first person to save install docs to memory
239
- // gets a hard failure, which buys nothing: an entry the agent READS is not an entry the
240
- // agent RUNS, and execution is gated at the tool boundary, where it belongs. Left out on
241
- // purpose, so nobody re-adds it without repeating the measurement.
242
- {
243
- id: "encoded_payload",
244
- // A base64 run this long is not prose. Short tokens are left alone precisely so that hashes,
245
- // commit SHAs and identifiers keep working.
246
- test: /[A-Za-z0-9+/]{256,}={0,2}/,
247
- why: "carries a long encoded payload rather than readable text"
248
- }
249
- ];
250
- var EXCERPT_RADIUS = 40;
251
- var EXCERPT_SCRUB = new RegExp(`[\\u0000-\\u001F${INVISIBLE_CLASS}]`, "gu");
252
- function scanForThreats(text) {
253
- for (const pattern of THREAT_PATTERNS) {
254
- const m = pattern.test.exec(text);
255
- if (m === null) continue;
256
- const at = m.index;
257
- const start = Math.max(0, at - EXCERPT_RADIUS);
258
- const end = Math.min(text.length, at + m[0].length + EXCERPT_RADIUS);
259
- const window = text.slice(start, end).replace(EXCERPT_SCRUB, "\u2423");
260
- return {
261
- id: pattern.id,
262
- why: pattern.why,
263
- excerpt: `${start > 0 ? "\u2026" : ""}${window}${end < text.length ? "\u2026" : ""}`
264
- };
265
- }
266
- return void 0;
267
- }
268
- THREAT_PATTERNS.map((p) => p.id);
269
-
270
- // src/internal/memory/storage/markdown-store.ts
271
- var MEMORY_MD_HEADER = "# Memory Index\n";
272
- var FACTS_HEADING = "## Facts";
273
- var MAX_NAME_VARIANTS = 50;
274
- function memoryDir(cwd) {
275
- return join(cwd, ".theokit", "memory");
276
- }
277
- function memoryWriteDir(cwd, sessionDir) {
278
- if (sessionDir === void 0 || sessionDir.trim().length === 0) return memoryDir(cwd);
279
- return join(sessionDir, "projects", encodeProjectDir(cwd), "memory");
280
- }
281
- function claudeProjectMemoryDir(cwd) {
282
- const home = process.env.CLAUDE_CONFIG_DIR?.trim();
283
- const root = home !== void 0 && home.length > 0 ? home : join(homedir(), ".claude");
284
- return join(root, "projects", encodeProjectDir(cwd), "memory");
285
- }
286
- function memoryMdPath(cwd) {
287
- return join(memoryDir(cwd), "MEMORY.md");
288
- }
289
- function notesDir(cwd) {
290
- return join(memoryDir(cwd), "notes");
291
- }
292
- function byNaturalName(a, b) {
293
- const split = (f) => {
294
- const stem = f.replace(/\.md$/, "");
295
- const m = /^(.*?)-(\d+)$/.exec(stem);
296
- return m === null ? [stem, 0] : [m[1], Number(m[2])];
297
- };
298
- const [baseA, nA] = split(a);
299
- const [baseB, nB] = split(b);
300
- return baseA === baseB ? nA - nB : baseA.localeCompare(baseB);
301
- }
302
- async function readFactsFromMarkdown(cwd, sessionDir) {
303
- const facts = [];
304
- const roots = [
305
- .../* @__PURE__ */ new Set([memoryDir(cwd), memoryWriteDir(cwd, sessionDir), claudeProjectMemoryDir(cwd)])
306
- ];
307
- for (const dir of roots) {
308
- let entries;
309
- try {
310
- entries = await readdir(dir);
311
- } catch {
312
- continue;
313
- }
314
- const inDir = [];
315
- for (const entry of entries.sort(byNaturalName)) {
316
- const fact = await readMemoryFileIn(dir, entry);
317
- if (fact !== void 0) inDir.push(fact);
318
- }
319
- inDir.sort((a, b) => (a.modified ?? "").localeCompare(b.modified ?? ""));
320
- facts.push(...inDir);
321
- }
322
- try {
323
- facts.push(...parseFactsSection(await readFile(memoryMdPath(cwd), "utf8")));
324
- } catch {
325
- }
326
- return facts;
327
- }
328
- async function readMemoryFileIn(dir, entry) {
329
- if (!entry.endsWith(".md") || entry === "MEMORY.md") return void 0;
330
- let raw;
331
- try {
332
- raw = await readFile(join(dir, entry), "utf8");
333
- } catch {
334
- return void 0;
335
- }
336
- const parsed = parseMemoryFile(raw);
337
- if (parsed === void 0) return void 0;
338
- const body = parsed.body.trim();
339
- return {
340
- text: body.length > 0 ? body : parsed.description,
341
- ...parsed.kind !== void 0 ? { kind: parsed.kind } : {},
342
- ...parsed.modified !== void 0 ? { modified: parsed.modified } : {},
343
- ...parsed.observations !== void 0 ? { observations: parsed.observations } : {}
344
- };
345
- }
346
- function assertWritable(fact, text) {
347
- if (fact.kind !== void 0 && !MEMORY_KINDS.includes(fact.kind)) {
348
- throw new ConfigurationError(
349
- `Unknown memory fact kind "${fact.kind}". Expected one of: ${MEMORY_KINDS.join(", ")}.`,
350
- { code: "invalid_memory_kind" }
351
- );
352
- }
353
- const threat = scanForThreats(text);
354
- if (threat !== void 0) {
355
- throw new ConfigurationError(
356
- `Refusing to write a memory entry that ${threat.why}: ${threat.excerpt}`,
357
- { code: "memory_threat_rejected" }
358
- );
359
- }
360
- }
361
- function appendFactToMarkdown(cwd, fact, targetDir = memoryDir(cwd)) {
362
- return withCwdMutex(targetDir, async () => {
363
- const text = redactSecrets(fact.text);
364
- assertWritable(fact, text);
365
- const title = fact.title?.trim() ?? titleForFact(text);
366
- const base = fact.title !== void 0 ? slugForFact(fact.title) : slugForFact(text);
367
- await mkdir(targetDir, { recursive: true });
368
- const name = await resolveName(targetDir, base, text);
369
- const description = fact.description?.trim() ?? text;
370
- const observations = await nextObservationCount(targetDir, name, text);
371
- await replaceFileAtomic(
372
- join(targetDir, `${name}.md`),
373
- renderMemoryFile({
374
- name,
375
- description,
376
- ...fact.kind !== void 0 ? { kind: fact.kind } : {},
377
- modified: (/* @__PURE__ */ new Date()).toISOString(),
378
- observations,
379
- body: text
380
- })
381
- );
382
- await replaceFileAtomic(
383
- join(targetDir, "MEMORY.md"),
384
- await nextIndex(targetDir, description, name, title)
385
- );
386
- });
387
- }
388
- async function resolveName(dir, base, text) {
389
- const wanted = normalizeFactText(text);
390
- for (let i = 1; i <= MAX_NAME_VARIANTS; i += 1) {
391
- const candidate = i === 1 ? base : `${base}-${i}`;
392
- let existing;
393
- try {
394
- existing = await readFile(join(dir, `${candidate}.md`), "utf8");
395
- } catch {
396
- return candidate;
397
- }
398
- const parsed = parseMemoryFile(existing);
399
- if (parsed === void 0) return candidate;
400
- if (normalizeFactText(parsed.body) === wanted) return candidate;
401
- }
402
- return slugForFact(text) === base ? safeFilenameForId(text) : slugForFact(text);
403
- }
404
- async function nextObservationCount(dir, name, text) {
405
- let existing;
406
- try {
407
- existing = await readFile(join(dir, `${name}.md`), "utf8");
408
- } catch {
409
- return 1;
410
- }
411
- const parsed = parseMemoryFile(existing);
412
- if (parsed === void 0) return 1;
413
- const sameFact = normalizeFactText(parsed.body) === normalizeFactText(text);
414
- if (!sameFact) return 1;
415
- return (parsed.observations ?? 1) + 1;
416
- }
417
- function normalizeFactText(text) {
418
- return text.trim().toLowerCase().replace(/\s+/g, " ").replace(/[.!?]+$/, "");
419
- }
420
- async function nextIndex(dir, text, name, title) {
421
- let existing = "";
422
- try {
423
- existing = await readFile(join(dir, "MEMORY.md"), "utf8");
424
- } catch {
425
- existing = "";
426
- }
427
- const hook = text.replace(/\s+/g, " ").trim();
428
- const entry = hook.length > 0 && hook !== title ? `- [${title}](${name}.md) \u2014 ${hook}` : `- [${title}](${name}.md)`;
429
- const kept = existing.split("\n").filter((line) => !line.startsWith(`- [`) || !line.includes(`](${name}.md)`));
430
- const body = kept.join("\n").trimEnd();
431
- const head = body.length > 0 ? body : MEMORY_MD_HEADER;
432
- return `${head}
433
- ${entry}
434
- `;
435
- }
436
- var INDEX_ENTRY = /^\[[^\]]*\]\([^)]+\.md\)(?:\s+—\s.*)?$/;
437
- function parseFactsSection(raw) {
438
- const idx = raw.indexOf(FACTS_HEADING);
439
- if (idx === -1) return [];
440
- const tail = raw.slice(idx + FACTS_HEADING.length);
441
- const nextHeading = tail.search(/\n#{1,2}\s/);
442
- const block = nextHeading === -1 ? tail : tail.slice(0, nextHeading);
443
- return block.split("\n").map((line) => line.trim()).filter((line) => line.startsWith("- ")).map((line) => line.slice(2).trim()).filter((body) => !INDEX_ENTRY.test(body)).map((body) => ({ text: body }));
444
- }
445
- async function readFacts(cwd, config, memoryHome) {
446
- if (!config.enabled) return [];
447
- return readFactsFromMarkdown(cwd, memoryHome);
448
- }
449
- async function appendFact(cwd, config, fact, memoryHome) {
450
- if (!config.enabled) return;
451
- await appendFactToMarkdown(cwd, fact, memoryWriteDir(cwd, memoryHome));
452
- }
453
-
454
- export { MEMORY_KINDS, appendFact, appendFactToMarkdown, claudeProjectMemoryDir, legacyMemoryJsonPath, memoryDir, memoryMdPath, memoryWriteDir, notesDir, readFacts, readFactsFromMarkdown };
455
- //# sourceMappingURL=chunk-WCLDJSMY.js.map
456
- //# sourceMappingURL=chunk-WCLDJSMY.js.map