@theokit/sdk 5.15.0 → 5.15.2

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 (368) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/a2a/index.cjs +3 -3
  3. package/dist/a2a/index.js +1 -1
  4. package/dist/{agent-B6FQad6P.d.cts → agent-BL4kxgwq.d.cts} +7 -1
  5. package/dist/{agent-B6C9i_qu.d.ts → agent-ByDx7K30.d.ts} +7 -1
  6. package/dist/agent-D6WBBNGR.cjs +72 -0
  7. package/dist/{agent-VI2HITPT.cjs.map → agent-D6WBBNGR.cjs.map} +1 -1
  8. package/dist/agent-QRIFX2SY.js +63 -0
  9. package/dist/{agent-DRDGUU6T.js.map → agent-QRIFX2SY.js.map} +1 -1
  10. package/dist/agent-session-store-2LQEPS4H.js +6 -0
  11. package/dist/{agent-session-store-22GKA7O4.js.map → agent-session-store-2LQEPS4H.js.map} +1 -1
  12. package/dist/agent-session-store-IOH6BREF.cjs +23 -0
  13. package/dist/{agent-session-store-WP6NGDVX.cjs.map → agent-session-store-IOH6BREF.cjs.map} +1 -1
  14. package/dist/auth/index.cjs +15 -15
  15. package/dist/auth/index.js +3 -3
  16. package/dist/{batch-N2XDYZED.js → batch-7IGV2OKA.js} +8 -8
  17. package/dist/{batch-N2XDYZED.js.map → batch-7IGV2OKA.js.map} +1 -1
  18. package/dist/{batch-VFR2MAUE.cjs → batch-FIWQZ3JD.cjs} +14 -14
  19. package/dist/{batch-VFR2MAUE.cjs.map → batch-FIWQZ3JD.cjs.map} +1 -1
  20. package/dist/{chunk-AT2PESXB.cjs → chunk-2UYAL4N7.cjs} +5 -5
  21. package/dist/chunk-2UYAL4N7.cjs.map +1 -0
  22. package/dist/{chunk-K2BQQ445.js → chunk-3GQYMKVJ.js} +3 -3
  23. package/dist/{chunk-K2BQQ445.js.map → chunk-3GQYMKVJ.js.map} +1 -1
  24. package/dist/{chunk-YSTXFWQE.cjs → chunk-3HL43XBD.cjs} +4 -4
  25. package/dist/{chunk-YSTXFWQE.cjs.map → chunk-3HL43XBD.cjs.map} +1 -1
  26. package/dist/{chunk-XESYJ4JC.js → chunk-3VX7JHJI.js} +7 -7
  27. package/dist/{chunk-XESYJ4JC.js.map → chunk-3VX7JHJI.js.map} +1 -1
  28. package/dist/{chunk-6XQLTQB6.cjs → chunk-3YCNBOX7.cjs} +3 -3
  29. package/dist/{chunk-6XQLTQB6.cjs.map → chunk-3YCNBOX7.cjs.map} +1 -1
  30. package/dist/{chunk-CHKV2L2Y.cjs → chunk-46YYJIHL.cjs} +30 -30
  31. package/dist/chunk-46YYJIHL.cjs.map +1 -0
  32. package/dist/{chunk-73IITAF7.js → chunk-4C37ELQL.js} +9 -9
  33. package/dist/{chunk-73IITAF7.js.map → chunk-4C37ELQL.js.map} +1 -1
  34. package/dist/{chunk-AGO5S5WD.js → chunk-4E4D6H77.js} +3 -3
  35. package/dist/{chunk-AGO5S5WD.js.map → chunk-4E4D6H77.js.map} +1 -1
  36. package/dist/{chunk-R35ZJAYT.cjs → chunk-4JF52NED.cjs} +12 -12
  37. package/dist/{chunk-R35ZJAYT.cjs.map → chunk-4JF52NED.cjs.map} +1 -1
  38. package/dist/{chunk-INVEGVGO.js → chunk-4TA47IK4.js} +8 -8
  39. package/dist/{chunk-INVEGVGO.js.map → chunk-4TA47IK4.js.map} +1 -1
  40. package/dist/{chunk-MLGETTYX.js → chunk-4YUIYSZO.js} +6 -6
  41. package/dist/{chunk-MLGETTYX.js.map → chunk-4YUIYSZO.js.map} +1 -1
  42. package/dist/{chunk-RZL2W4C3.js → chunk-5L7S2VOL.js} +5 -5
  43. package/dist/{chunk-RZL2W4C3.js.map → chunk-5L7S2VOL.js.map} +1 -1
  44. package/dist/{chunk-3WKWBYPO.cjs → chunk-6EHOJLJ3.cjs} +20 -20
  45. package/dist/chunk-6EHOJLJ3.cjs.map +1 -0
  46. package/dist/{chunk-XOU3CL7S.cjs → chunk-6HQFPX7N.cjs} +28 -28
  47. package/dist/chunk-6HQFPX7N.cjs.map +1 -0
  48. package/dist/{chunk-DJKGDLYZ.cjs → chunk-6XT5LAZG.cjs} +126 -59
  49. package/dist/chunk-6XT5LAZG.cjs.map +1 -0
  50. package/dist/{chunk-R427EOZE.cjs → chunk-7EFT6N5C.cjs} +13 -13
  51. package/dist/{chunk-R427EOZE.cjs.map → chunk-7EFT6N5C.cjs.map} +1 -1
  52. package/dist/{chunk-L7V4DDIE.cjs → chunk-7VNFOGRD.cjs} +12 -12
  53. package/dist/chunk-7VNFOGRD.cjs.map +1 -0
  54. package/dist/{chunk-YKNBTHMD.js → chunk-AQ23NII7.js} +3 -3
  55. package/dist/{chunk-YKNBTHMD.js.map → chunk-AQ23NII7.js.map} +1 -1
  56. package/dist/{chunk-ARC2V7NY.js → chunk-ATGSV4GS.js} +4 -4
  57. package/dist/{chunk-ARC2V7NY.js.map → chunk-ATGSV4GS.js.map} +1 -1
  58. package/dist/{chunk-H7HD6RXO.cjs → chunk-AW72G4TC.cjs} +5 -5
  59. package/dist/{chunk-H7HD6RXO.cjs.map → chunk-AW72G4TC.cjs.map} +1 -1
  60. package/dist/{chunk-M4U24U6G.js → chunk-AZK3QM36.js} +5 -5
  61. package/dist/{chunk-M4U24U6G.js.map → chunk-AZK3QM36.js.map} +1 -1
  62. package/dist/{chunk-QK2ERTO3.js → chunk-BH6M2DGV.js} +4 -4
  63. package/dist/{chunk-QK2ERTO3.js.map → chunk-BH6M2DGV.js.map} +1 -1
  64. package/dist/{chunk-64ECM3XM.cjs → chunk-BTGYRM4J.cjs} +264 -264
  65. package/dist/chunk-BTGYRM4J.cjs.map +1 -0
  66. package/dist/{chunk-5M5GQYBM.js → chunk-CG64VPPU.js} +50 -50
  67. package/dist/{chunk-5M5GQYBM.js.map → chunk-CG64VPPU.js.map} +1 -1
  68. package/dist/{chunk-CBBT42VX.js → chunk-CMDM4VF6.js} +3 -3
  69. package/dist/{chunk-CBBT42VX.js.map → chunk-CMDM4VF6.js.map} +1 -1
  70. package/dist/{chunk-OLJOI4LK.js → chunk-CN732Z5C.js} +4 -4
  71. package/dist/{chunk-OLJOI4LK.js.map → chunk-CN732Z5C.js.map} +1 -1
  72. package/dist/{chunk-SETHRLQS.cjs → chunk-D3BL3EEB.cjs} +9 -9
  73. package/dist/chunk-D3BL3EEB.cjs.map +1 -0
  74. package/dist/{chunk-LCCT5ZXJ.js → chunk-DB5RYCXX.js} +13 -13
  75. package/dist/{chunk-LCCT5ZXJ.js.map → chunk-DB5RYCXX.js.map} +1 -1
  76. package/dist/{chunk-SV63WTA2.js → chunk-DBH2WA2U.js} +4 -4
  77. package/dist/{chunk-SV63WTA2.js.map → chunk-DBH2WA2U.js.map} +1 -1
  78. package/dist/{chunk-XE3CAY6Z.cjs → chunk-DEHPRORL.cjs} +4 -4
  79. package/dist/{chunk-XE3CAY6Z.cjs.map → chunk-DEHPRORL.cjs.map} +1 -1
  80. package/dist/{chunk-UKMBRMGT.js → chunk-DGO4LPLP.js} +4 -4
  81. package/dist/{chunk-UKMBRMGT.js.map → chunk-DGO4LPLP.js.map} +1 -1
  82. package/dist/{chunk-RS7YQR4X.cjs → chunk-EBX6XUN7.cjs} +7 -7
  83. package/dist/{chunk-RS7YQR4X.cjs.map → chunk-EBX6XUN7.cjs.map} +1 -1
  84. package/dist/chunk-EDIYR4VR.cjs +18 -0
  85. package/dist/{chunk-SPEN7RJU.cjs.map → chunk-EDIYR4VR.cjs.map} +1 -1
  86. package/dist/{chunk-QGDPMM3C.js → chunk-EF5IONLL.js} +5 -5
  87. package/dist/{chunk-QGDPMM3C.js.map → chunk-EF5IONLL.js.map} +1 -1
  88. package/dist/{chunk-MSW7LB2V.cjs → chunk-EOWIUDKG.cjs} +5 -5
  89. package/dist/{chunk-MSW7LB2V.cjs.map → chunk-EOWIUDKG.cjs.map} +1 -1
  90. package/dist/{chunk-L7JPXZ2C.cjs → chunk-ER3BF23R.cjs} +19 -19
  91. package/dist/{chunk-L7JPXZ2C.cjs.map → chunk-ER3BF23R.cjs.map} +1 -1
  92. package/dist/{chunk-BNEUB52I.cjs → chunk-ERBKPA2N.cjs} +4 -4
  93. package/dist/{chunk-BNEUB52I.cjs.map → chunk-ERBKPA2N.cjs.map} +1 -1
  94. package/dist/{chunk-4QCJAJAG.js → chunk-F54PXZIA.js} +5 -5
  95. package/dist/{chunk-4QCJAJAG.js.map → chunk-F54PXZIA.js.map} +1 -1
  96. package/dist/{chunk-2XWAYCFM.cjs → chunk-FBT2SF2S.cjs} +12 -12
  97. package/dist/{chunk-2XWAYCFM.cjs.map → chunk-FBT2SF2S.cjs.map} +1 -1
  98. package/dist/{chunk-AUH2EVWY.cjs → chunk-FZSPVIFK.cjs} +16 -16
  99. package/dist/chunk-FZSPVIFK.cjs.map +1 -0
  100. package/dist/{chunk-CYWOJA6B.js → chunk-GA27FFT5.js} +3 -3
  101. package/dist/{chunk-CYWOJA6B.js.map → chunk-GA27FFT5.js.map} +1 -1
  102. package/dist/{chunk-HWMGR3HA.js → chunk-GEQLHBJM.js} +6 -6
  103. package/dist/{chunk-HWMGR3HA.js.map → chunk-GEQLHBJM.js.map} +1 -1
  104. package/dist/{chunk-IJ7M6GOG.cjs → chunk-GKERJ52A.cjs} +4 -4
  105. package/dist/{chunk-IJ7M6GOG.cjs.map → chunk-GKERJ52A.cjs.map} +1 -1
  106. package/dist/{chunk-NEH3BPFD.cjs → chunk-HI5TJWQE.cjs} +19 -19
  107. package/dist/{chunk-NEH3BPFD.cjs.map → chunk-HI5TJWQE.cjs.map} +1 -1
  108. package/dist/{chunk-ZOFRNNZD.cjs → chunk-IZV72OEI.cjs} +11 -11
  109. package/dist/chunk-IZV72OEI.cjs.map +1 -0
  110. package/dist/{chunk-KU5O7WPK.js → chunk-JD3EKKKB.js} +4 -4
  111. package/dist/{chunk-KU5O7WPK.js.map → chunk-JD3EKKKB.js.map} +1 -1
  112. package/dist/{chunk-DFBWYETS.js → chunk-JRP2W2DR.js} +3 -3
  113. package/dist/{chunk-DFBWYETS.js.map → chunk-JRP2W2DR.js.map} +1 -1
  114. package/dist/{chunk-IOBHFP2E.js → chunk-JRQJMZKY.js} +82 -15
  115. package/dist/chunk-JRQJMZKY.js.map +1 -0
  116. package/dist/{chunk-YQ3XC6C2.cjs → chunk-JVH3NNJ3.cjs} +13 -13
  117. package/dist/chunk-JVH3NNJ3.cjs.map +1 -0
  118. package/dist/{chunk-VWYFGE27.cjs → chunk-KC2HKUPT.cjs} +56 -56
  119. package/dist/chunk-KC2HKUPT.cjs.map +1 -0
  120. package/dist/{chunk-PDOXYXWX.cjs → chunk-KDJTECE6.cjs} +4 -4
  121. package/dist/{chunk-PDOXYXWX.cjs.map → chunk-KDJTECE6.cjs.map} +1 -1
  122. package/dist/{chunk-QD6B6W6I.js → chunk-L2KC2G7H.js} +5 -5
  123. package/dist/{chunk-QD6B6W6I.js.map → chunk-L2KC2G7H.js.map} +1 -1
  124. package/dist/{chunk-3BBTHFGJ.js → chunk-L5B7EWWH.js} +5 -5
  125. package/dist/{chunk-3BBTHFGJ.js.map → chunk-L5B7EWWH.js.map} +1 -1
  126. package/dist/{chunk-X7CE7Y5W.js → chunk-LG4JCJEI.js} +11 -11
  127. package/dist/{chunk-X7CE7Y5W.js.map → chunk-LG4JCJEI.js.map} +1 -1
  128. package/dist/{chunk-2HXTNVLM.js → chunk-LSURFRJA.js} +6 -6
  129. package/dist/{chunk-2HXTNVLM.js.map → chunk-LSURFRJA.js.map} +1 -1
  130. package/dist/{chunk-55LLQFHW.cjs → chunk-MJGY3E3C.cjs} +4 -4
  131. package/dist/{chunk-55LLQFHW.cjs.map → chunk-MJGY3E3C.cjs.map} +1 -1
  132. package/dist/{chunk-EQ5IDL6W.cjs → chunk-MKS5FFH5.cjs} +15 -15
  133. package/dist/chunk-MKS5FFH5.cjs.map +1 -0
  134. package/dist/{chunk-WM646HEN.js → chunk-MTNCJ7MQ.js} +6 -6
  135. package/dist/{chunk-WM646HEN.js.map → chunk-MTNCJ7MQ.js.map} +1 -1
  136. package/dist/{chunk-SA6K24NB.cjs → chunk-MXJJMP4U.cjs} +7 -7
  137. package/dist/chunk-MXJJMP4U.cjs.map +1 -0
  138. package/dist/{chunk-FTXY4D44.cjs → chunk-N2ORTDSO.cjs} +20 -20
  139. package/dist/chunk-N2ORTDSO.cjs.map +1 -0
  140. package/dist/{chunk-7YUPSBDV.cjs → chunk-NDXZXGVP.cjs} +6 -6
  141. package/dist/{chunk-7YUPSBDV.cjs.map → chunk-NDXZXGVP.cjs.map} +1 -1
  142. package/dist/{chunk-3UMPP553.cjs → chunk-NMRNE6QX.cjs} +11 -11
  143. package/dist/{chunk-3UMPP553.cjs.map → chunk-NMRNE6QX.cjs.map} +1 -1
  144. package/dist/{chunk-PKRPV3R7.js → chunk-NO6AG22P.js} +6 -6
  145. package/dist/{chunk-PKRPV3R7.js.map → chunk-NO6AG22P.js.map} +1 -1
  146. package/dist/{chunk-NK5EOTDY.js → chunk-OIOSY5G6.js} +3 -3
  147. package/dist/{chunk-NK5EOTDY.js.map → chunk-OIOSY5G6.js.map} +1 -1
  148. package/dist/{chunk-RGVMJU57.js → chunk-P7B64NFK.js} +8 -8
  149. package/dist/{chunk-RGVMJU57.js.map → chunk-P7B64NFK.js.map} +1 -1
  150. package/dist/{chunk-TDED5XES.js → chunk-PCPYTBVV.js} +6 -6
  151. package/dist/chunk-PCPYTBVV.js.map +1 -0
  152. package/dist/{chunk-U7PRI3XM.cjs → chunk-PDFSLD5P.cjs} +6 -6
  153. package/dist/{chunk-U7PRI3XM.cjs.map → chunk-PDFSLD5P.cjs.map} +1 -1
  154. package/dist/{chunk-YMVTUV5K.js → chunk-PISZRLES.js} +5 -5
  155. package/dist/{chunk-YMVTUV5K.js.map → chunk-PISZRLES.js.map} +1 -1
  156. package/dist/{chunk-BUUUWQMB.cjs → chunk-PNL63WDP.cjs} +4 -4
  157. package/dist/{chunk-BUUUWQMB.cjs.map → chunk-PNL63WDP.cjs.map} +1 -1
  158. package/dist/{chunk-23SS4ID4.js → chunk-PSMWZYW6.js} +4 -4
  159. package/dist/{chunk-23SS4ID4.js.map → chunk-PSMWZYW6.js.map} +1 -1
  160. package/dist/{chunk-5645PMVU.cjs → chunk-PXYINWBC.cjs} +20 -20
  161. package/dist/chunk-PXYINWBC.cjs.map +1 -0
  162. package/dist/{chunk-RTDVSHJR.cjs → chunk-Q4UOCMAO.cjs} +5 -5
  163. package/dist/{chunk-RTDVSHJR.cjs.map → chunk-Q4UOCMAO.cjs.map} +1 -1
  164. package/dist/{chunk-5IRDK5BC.js → chunk-QH6MWGOA.js} +4 -4
  165. package/dist/{chunk-5IRDK5BC.js.map → chunk-QH6MWGOA.js.map} +1 -1
  166. package/dist/{chunk-3LMVJTNJ.js → chunk-QPUKIZOT.js} +3 -3
  167. package/dist/{chunk-3LMVJTNJ.js.map → chunk-QPUKIZOT.js.map} +1 -1
  168. package/dist/{chunk-SWALPLFQ.cjs → chunk-RTCO3USA.cjs} +16 -16
  169. package/dist/chunk-RTCO3USA.cjs.map +1 -0
  170. package/dist/{chunk-SAGRF4IB.js → chunk-S2CMEJ5F.js} +3 -3
  171. package/dist/{chunk-SAGRF4IB.js.map → chunk-S2CMEJ5F.js.map} +1 -1
  172. package/dist/{chunk-VZGE7NAI.js → chunk-S5ERB3CH.js} +3 -3
  173. package/dist/{chunk-VZGE7NAI.js.map → chunk-S5ERB3CH.js.map} +1 -1
  174. package/dist/{chunk-XJ3WU5CZ.js → chunk-S7IZEVXX.js} +6 -6
  175. package/dist/{chunk-XJ3WU5CZ.js.map → chunk-S7IZEVXX.js.map} +1 -1
  176. package/dist/{chunk-Q7UG242V.js → chunk-TIYQDJFK.js} +3 -3
  177. package/dist/{chunk-Q7UG242V.js.map → chunk-TIYQDJFK.js.map} +1 -1
  178. package/dist/{chunk-POBZXULR.cjs → chunk-TTNJOM5W.cjs} +16 -16
  179. package/dist/{chunk-POBZXULR.cjs.map → chunk-TTNJOM5W.cjs.map} +1 -1
  180. package/dist/{chunk-VCQ37TC5.js → chunk-TTXRNCXY.js} +3 -3
  181. package/dist/{chunk-VCQ37TC5.js.map → chunk-TTXRNCXY.js.map} +1 -1
  182. package/dist/{chunk-3HA7N2BB.cjs → chunk-TYKBAKAS.cjs} +5 -5
  183. package/dist/{chunk-3HA7N2BB.cjs.map → chunk-TYKBAKAS.cjs.map} +1 -1
  184. package/dist/{chunk-A77UMVMD.cjs → chunk-UMCCYXFZ.cjs} +8 -8
  185. package/dist/{chunk-A77UMVMD.cjs.map → chunk-UMCCYXFZ.cjs.map} +1 -1
  186. package/dist/{chunk-3GTN4HOO.js → chunk-UNP4NCMZ.js} +3 -3
  187. package/dist/{chunk-3GTN4HOO.js.map → chunk-UNP4NCMZ.js.map} +1 -1
  188. package/dist/{chunk-BPL5CVZ5.js → chunk-VFT63FJF.js} +3 -3
  189. package/dist/{chunk-BPL5CVZ5.js.map → chunk-VFT63FJF.js.map} +1 -1
  190. package/dist/{chunk-3KIUY67P.cjs → chunk-VHY6NVCJ.cjs} +30 -30
  191. package/dist/chunk-VHY6NVCJ.cjs.map +1 -0
  192. package/dist/{chunk-KMFBNKCT.cjs → chunk-VT3NWHFH.cjs} +6 -6
  193. package/dist/{chunk-KMFBNKCT.cjs.map → chunk-VT3NWHFH.cjs.map} +1 -1
  194. package/dist/{chunk-FJWQP6EE.js → chunk-WJ6OGKAO.js} +3 -3
  195. package/dist/{chunk-FJWQP6EE.js.map → chunk-WJ6OGKAO.js.map} +1 -1
  196. package/dist/{chunk-FLDHYF5C.cjs → chunk-X2XLSE2N.cjs} +9 -9
  197. package/dist/chunk-X2XLSE2N.cjs.map +1 -0
  198. package/dist/{chunk-UDAKAE4Z.cjs → chunk-X4ZYEZPD.cjs} +12 -12
  199. package/dist/chunk-X4ZYEZPD.cjs.map +1 -0
  200. package/dist/{chunk-QG4SXZ2A.cjs → chunk-XR6O6G3B.cjs} +27 -27
  201. package/dist/chunk-XR6O6G3B.cjs.map +1 -0
  202. package/dist/{chunk-BWYC7RZG.cjs → chunk-XTQWTVVI.cjs} +11 -11
  203. package/dist/chunk-XTQWTVVI.cjs.map +1 -0
  204. package/dist/{chunk-MLJDW2YK.js → chunk-YSGS57DA.js} +4 -4
  205. package/dist/{chunk-MLJDW2YK.js.map → chunk-YSGS57DA.js.map} +1 -1
  206. package/dist/{chunk-KCM3RMKR.js → chunk-YUQNHLKN.js} +8 -8
  207. package/dist/{chunk-KCM3RMKR.js.map → chunk-YUQNHLKN.js.map} +1 -1
  208. package/dist/{chunk-P7QYG4RZ.cjs → chunk-Z5MB2HAN.cjs} +8 -8
  209. package/dist/{chunk-P7QYG4RZ.cjs.map → chunk-Z5MB2HAN.cjs.map} +1 -1
  210. package/dist/{chunk-HJ2LV464.js → chunk-ZUWVO442.js} +4 -4
  211. package/dist/{chunk-HJ2LV464.js.map → chunk-ZUWVO442.js.map} +1 -1
  212. package/dist/{compact-session-NX7HUNTB.cjs → compact-session-5DWFHMW4.cjs} +21 -21
  213. package/dist/{compact-session-NX7HUNTB.cjs.map → compact-session-5DWFHMW4.cjs.map} +1 -1
  214. package/dist/{compact-session-Q5IGNFPW.js → compact-session-AL65PEMX.js} +12 -12
  215. package/dist/{compact-session-Q5IGNFPW.js.map → compact-session-AL65PEMX.js.map} +1 -1
  216. package/dist/context/index.cjs +11 -11
  217. package/dist/context/index.js +6 -6
  218. package/dist/context-4XSD2V3G.js +7 -0
  219. package/dist/{context-7EBZST3L.js.map → context-4XSD2V3G.js.map} +1 -1
  220. package/dist/context-ZX2VBGSX.cjs +24 -0
  221. package/dist/{context-4RSI3AXT.cjs.map → context-ZX2VBGSX.cjs.map} +1 -1
  222. package/dist/{cron-Bh3aWgQ2.d.cts → cron-B7KH9sHW.d.cts} +1 -1
  223. package/dist/{cron-CCDxeeFZ.d.ts → cron-FEO7UAQF.d.ts} +1 -1
  224. package/dist/cron.cjs +40 -40
  225. package/dist/cron.d.cts +2 -2
  226. package/dist/cron.d.ts +2 -2
  227. package/dist/cron.js +39 -39
  228. package/dist/eval.cjs +51 -51
  229. package/dist/eval.cjs.map +1 -1
  230. package/dist/eval.js +41 -41
  231. package/dist/{executor-THUXNAFR.js → executor-ZHIUSHRV.js} +7 -7
  232. package/dist/{executor-THUXNAFR.js.map → executor-ZHIUSHRV.js.map} +1 -1
  233. package/dist/{executor-5QL5AXIZ.cjs → executor-ZTLJZ5LK.cjs} +24 -24
  234. package/dist/{executor-5QL5AXIZ.cjs.map → executor-ZTLJZ5LK.cjs.map} +1 -1
  235. package/dist/filesystem/index.cjs +14 -14
  236. package/dist/filesystem/index.cjs.map +1 -1
  237. package/dist/filesystem/index.js +4 -4
  238. package/dist/{fork-agent-S2EPIML7.js → fork-agent-BHVTALT5.js} +3 -3
  239. package/dist/{fork-agent-S2EPIML7.js.map → fork-agent-BHVTALT5.js.map} +1 -1
  240. package/dist/{fork-agent-WAEQI2DL.cjs → fork-agent-DCOPPXM2.cjs} +4 -4
  241. package/dist/{fork-agent-WAEQI2DL.cjs.map → fork-agent-DCOPPXM2.cjs.map} +1 -1
  242. package/dist/fs-session-store-EZ32TFGB.js +11 -0
  243. package/dist/{fs-session-store-MYQEVUFL.js.map → fs-session-store-EZ32TFGB.js.map} +1 -1
  244. package/dist/fs-session-store-G664LDDN.cjs +20 -0
  245. package/dist/{fs-session-store-CYNTEPJZ.cjs.map → fs-session-store-G664LDDN.cjs.map} +1 -1
  246. package/dist/generate-object-JFZTK567.cjs +20 -0
  247. package/dist/{generate-object-A5F576IT.cjs.map → generate-object-JFZTK567.cjs.map} +1 -1
  248. package/dist/{generate-object-TBDOBBYW.js → generate-object-RPBXY2U3.js} +4 -4
  249. package/dist/{generate-object-TBDOBBYW.js.map → generate-object-RPBXY2U3.js.map} +1 -1
  250. package/dist/index-manager-2MJEEN2O.js +18 -0
  251. package/dist/{index-manager-NF2WRLOU.js.map → index-manager-2MJEEN2O.js.map} +1 -1
  252. package/dist/index-manager-CT6MMG7S.cjs +27 -0
  253. package/dist/{index-manager-2KH75BRW.cjs.map → index-manager-CT6MMG7S.cjs.map} +1 -1
  254. package/dist/index.cjs +130 -130
  255. package/dist/index.cjs.map +1 -1
  256. package/dist/index.d.cts +3 -3
  257. package/dist/index.d.ts +3 -3
  258. package/dist/index.js +56 -56
  259. package/dist/{inject-session-4ROYLZHY.js → inject-session-E2SZ4A35.js} +6 -6
  260. package/dist/{inject-session-4ROYLZHY.js.map → inject-session-E2SZ4A35.js.map} +1 -1
  261. package/dist/{inject-session-AWKDCGHV.cjs → inject-session-QZULG65O.cjs} +8 -8
  262. package/dist/{inject-session-AWKDCGHV.cjs.map → inject-session-QZULG65O.cjs.map} +1 -1
  263. package/dist/internal/llm/hermes-tool-extract.d.ts +2 -0
  264. package/dist/internal/memory/adapters/index.cjs +4 -4
  265. package/dist/internal/memory/adapters/index.js +3 -3
  266. package/dist/internal/memory/storage/index.cjs +45 -45
  267. package/dist/internal/memory/storage/index.js +9 -9
  268. package/dist/internal/persistence/index.cjs +22 -22
  269. package/dist/internal/persistence/index.js +6 -6
  270. package/dist/internal/security/index.cjs +9 -9
  271. package/dist/internal/security/index.js +2 -2
  272. package/dist/mcp-auth.cjs +8 -8
  273. package/dist/mcp-auth.js +3 -3
  274. package/dist/models.cjs +30 -30
  275. package/dist/models.cjs.map +1 -1
  276. package/dist/models.js +8 -8
  277. package/dist/{oauth-transaction-store-U34YLEGP.js → oauth-transaction-store-QQBWGNE2.js} +3 -3
  278. package/dist/{oauth-transaction-store-U34YLEGP.js.map → oauth-transaction-store-QQBWGNE2.js.map} +1 -1
  279. package/dist/{oauth-transaction-store-OMX436YB.cjs → oauth-transaction-store-YF7WOA6B.cjs} +10 -10
  280. package/dist/{oauth-transaction-store-OMX436YB.cjs.map → oauth-transaction-store-YF7WOA6B.cjs.map} +1 -1
  281. package/dist/path-safety.cjs +9 -9
  282. package/dist/path-safety.js +2 -2
  283. package/dist/persistence.cjs +41 -41
  284. package/dist/persistence.cjs.map +1 -1
  285. package/dist/persistence.js +11 -11
  286. package/dist/project.cjs +7 -7
  287. package/dist/project.cjs.map +1 -1
  288. package/dist/project.js +4 -4
  289. package/dist/providers.cjs +6 -6
  290. package/dist/providers.js +4 -4
  291. package/dist/{registry-5TDAF7RK.js → registry-DOYBR237.js} +6 -6
  292. package/dist/{registry-5TDAF7RK.js.map → registry-DOYBR237.js.map} +1 -1
  293. package/dist/{registry-W7TSCLQO.cjs → registry-PB7JFVUJ.cjs} +14 -14
  294. package/dist/{registry-W7TSCLQO.cjs.map → registry-PB7JFVUJ.cjs.map} +1 -1
  295. package/dist/sandbox/index.cjs +41 -41
  296. package/dist/sandbox/index.cjs.map +1 -1
  297. package/dist/sandbox/index.js +7 -7
  298. package/dist/sanitize/index.cjs +2 -2
  299. package/dist/sanitize/index.js +1 -1
  300. package/dist/server/auth/index.cjs +9 -9
  301. package/dist/server/auth/index.cjs.map +1 -1
  302. package/dist/server/auth/index.js +4 -4
  303. package/dist/{session-transcript-7TZ6HXSX.cjs → session-transcript-EBVGLZ6B.cjs} +17 -17
  304. package/dist/{session-transcript-7TZ6HXSX.cjs.map → session-transcript-EBVGLZ6B.cjs.map} +1 -1
  305. package/dist/{session-transcript-BSHZYYY6.js → session-transcript-GU2VE7JX.js} +4 -4
  306. package/dist/{session-transcript-BSHZYYY6.js.map → session-transcript-GU2VE7JX.js.map} +1 -1
  307. package/dist/skills.cjs +7 -7
  308. package/dist/skills.js +4 -4
  309. package/dist/stream-object-3AU7QDHT.js +7 -0
  310. package/dist/{stream-object-EKM4WGTI.js.map → stream-object-3AU7QDHT.js.map} +1 -1
  311. package/dist/stream-object-SLGR2KIA.cjs +20 -0
  312. package/dist/{stream-object-AS4YYM4B.cjs.map → stream-object-SLGR2KIA.cjs.map} +1 -1
  313. package/dist/subagents-loader-4PQS7ULK.cjs +16 -0
  314. package/dist/{subagents-loader-KLWF4QPD.cjs.map → subagents-loader-4PQS7ULK.cjs.map} +1 -1
  315. package/dist/subagents-loader-CPFVLWLH.js +7 -0
  316. package/dist/{subagents-loader-SXETS2F2.js.map → subagents-loader-CPFVLWLH.js.map} +1 -1
  317. package/dist/subagents-loader.cjs +4 -4
  318. package/dist/subagents-loader.d.cts +1 -1
  319. package/dist/subagents-loader.d.ts +1 -1
  320. package/dist/subagents-loader.js +3 -3
  321. package/dist/subagents.cjs +2 -2
  322. package/dist/subagents.js +1 -1
  323. package/dist/task-store.cjs +5 -5
  324. package/dist/task-store.js +2 -2
  325. package/dist/types/hooks.d.ts +7 -1
  326. package/dist/workflow.cjs +28 -28
  327. package/dist/workflow.js +5 -5
  328. package/package.json +1 -1
  329. package/dist/agent-DRDGUU6T.js +0 -63
  330. package/dist/agent-VI2HITPT.cjs +0 -72
  331. package/dist/agent-session-store-22GKA7O4.js +0 -6
  332. package/dist/agent-session-store-WP6NGDVX.cjs +0 -23
  333. package/dist/chunk-3KIUY67P.cjs.map +0 -1
  334. package/dist/chunk-3WKWBYPO.cjs.map +0 -1
  335. package/dist/chunk-5645PMVU.cjs.map +0 -1
  336. package/dist/chunk-64ECM3XM.cjs.map +0 -1
  337. package/dist/chunk-AT2PESXB.cjs.map +0 -1
  338. package/dist/chunk-AUH2EVWY.cjs.map +0 -1
  339. package/dist/chunk-BWYC7RZG.cjs.map +0 -1
  340. package/dist/chunk-CHKV2L2Y.cjs.map +0 -1
  341. package/dist/chunk-DJKGDLYZ.cjs.map +0 -1
  342. package/dist/chunk-EQ5IDL6W.cjs.map +0 -1
  343. package/dist/chunk-FLDHYF5C.cjs.map +0 -1
  344. package/dist/chunk-FTXY4D44.cjs.map +0 -1
  345. package/dist/chunk-IOBHFP2E.js.map +0 -1
  346. package/dist/chunk-L7V4DDIE.cjs.map +0 -1
  347. package/dist/chunk-QG4SXZ2A.cjs.map +0 -1
  348. package/dist/chunk-SA6K24NB.cjs.map +0 -1
  349. package/dist/chunk-SETHRLQS.cjs.map +0 -1
  350. package/dist/chunk-SPEN7RJU.cjs +0 -18
  351. package/dist/chunk-SWALPLFQ.cjs.map +0 -1
  352. package/dist/chunk-TDED5XES.js.map +0 -1
  353. package/dist/chunk-UDAKAE4Z.cjs.map +0 -1
  354. package/dist/chunk-VWYFGE27.cjs.map +0 -1
  355. package/dist/chunk-XOU3CL7S.cjs.map +0 -1
  356. package/dist/chunk-YQ3XC6C2.cjs.map +0 -1
  357. package/dist/chunk-ZOFRNNZD.cjs.map +0 -1
  358. package/dist/context-4RSI3AXT.cjs +0 -24
  359. package/dist/context-7EBZST3L.js +0 -7
  360. package/dist/fs-session-store-CYNTEPJZ.cjs +0 -20
  361. package/dist/fs-session-store-MYQEVUFL.js +0 -11
  362. package/dist/generate-object-A5F576IT.cjs +0 -20
  363. package/dist/index-manager-2KH75BRW.cjs +0 -27
  364. package/dist/index-manager-NF2WRLOU.js +0 -18
  365. package/dist/stream-object-AS4YYM4B.cjs +0 -20
  366. package/dist/stream-object-EKM4WGTI.js +0 -7
  367. package/dist/subagents-loader-KLWF4QPD.cjs +0 -16
  368. package/dist/subagents-loader-SXETS2F2.js +0 -7
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkL7V4DDIE_cjs = require('./chunk-L7V4DDIE.cjs');
3
+ var chunk7VNFOGRD_cjs = require('./chunk-7VNFOGRD.cjs');
4
4
  require('./chunk-CEGU5AVD.cjs');
5
5
  require('./chunk-RNXXYF22.cjs');
6
6
 
@@ -8,31 +8,31 @@ require('./chunk-RNXXYF22.cjs');
8
8
 
9
9
  Object.defineProperty(exports, "AuthSecretTooShortError", {
10
10
  enumerable: true,
11
- get: function () { return chunkL7V4DDIE_cjs.AuthSecretTooShortError; }
11
+ get: function () { return chunk7VNFOGRD_cjs.AuthSecretTooShortError; }
12
12
  });
13
13
  Object.defineProperty(exports, "COOKIE_NAME", {
14
14
  enumerable: true,
15
- get: function () { return chunkL7V4DDIE_cjs.COOKIE_NAME; }
15
+ get: function () { return chunk7VNFOGRD_cjs.COOKIE_NAME; }
16
16
  });
17
17
  Object.defineProperty(exports, "__TESTING__deriveKey", {
18
18
  enumerable: true,
19
- get: function () { return chunkL7V4DDIE_cjs.__TESTING__deriveKey; }
19
+ get: function () { return chunk7VNFOGRD_cjs.__TESTING__deriveKey; }
20
20
  });
21
21
  Object.defineProperty(exports, "clearTransaction", {
22
22
  enumerable: true,
23
- get: function () { return chunkL7V4DDIE_cjs.clearTransaction; }
23
+ get: function () { return chunk7VNFOGRD_cjs.clearTransaction; }
24
24
  });
25
25
  Object.defineProperty(exports, "encodeTransaction", {
26
26
  enumerable: true,
27
- get: function () { return chunkL7V4DDIE_cjs.encodeTransaction; }
27
+ get: function () { return chunk7VNFOGRD_cjs.encodeTransaction; }
28
28
  });
29
29
  Object.defineProperty(exports, "getTransaction", {
30
30
  enumerable: true,
31
- get: function () { return chunkL7V4DDIE_cjs.getTransaction; }
31
+ get: function () { return chunk7VNFOGRD_cjs.getTransaction; }
32
32
  });
33
33
  Object.defineProperty(exports, "newTransaction", {
34
34
  enumerable: true,
35
- get: function () { return chunkL7V4DDIE_cjs.newTransaction; }
35
+ get: function () { return chunk7VNFOGRD_cjs.newTransaction; }
36
36
  });
37
- //# sourceMappingURL=oauth-transaction-store-OMX436YB.cjs.map
38
- //# sourceMappingURL=oauth-transaction-store-OMX436YB.cjs.map
37
+ //# sourceMappingURL=oauth-transaction-store-YF7WOA6B.cjs.map
38
+ //# sourceMappingURL=oauth-transaction-store-YF7WOA6B.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"oauth-transaction-store-OMX436YB.cjs"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"oauth-transaction-store-YF7WOA6B.cjs"}
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunk3KIUY67P_cjs = require('./chunk-3KIUY67P.cjs');
4
- require('./chunk-SA6K24NB.cjs');
3
+ var chunkVHY6NVCJ_cjs = require('./chunk-VHY6NVCJ.cjs');
4
+ require('./chunk-MXJJMP4U.cjs');
5
5
  require('./chunk-CEGU5AVD.cjs');
6
6
  require('./chunk-RNXXYF22.cjs');
7
7
 
@@ -9,31 +9,31 @@ require('./chunk-RNXXYF22.cjs');
9
9
 
10
10
  Object.defineProperty(exports, "ForbiddenPathError", {
11
11
  enumerable: true,
12
- get: function () { return chunk3KIUY67P_cjs.ForbiddenPathError; }
12
+ get: function () { return chunkVHY6NVCJ_cjs.ForbiddenPathError; }
13
13
  });
14
14
  Object.defineProperty(exports, "PathTraversalError", {
15
15
  enumerable: true,
16
- get: function () { return chunk3KIUY67P_cjs.PathTraversalError; }
16
+ get: function () { return chunkVHY6NVCJ_cjs.PathTraversalError; }
17
17
  });
18
18
  Object.defineProperty(exports, "assertNoSymlinkEscape", {
19
19
  enumerable: true,
20
- get: function () { return chunk3KIUY67P_cjs.assertNoSymlinkEscape; }
20
+ get: function () { return chunkVHY6NVCJ_cjs.assertNoSymlinkEscape; }
21
21
  });
22
22
  Object.defineProperty(exports, "isForbiddenPath", {
23
23
  enumerable: true,
24
- get: function () { return chunk3KIUY67P_cjs.isForbiddenPath; }
24
+ get: function () { return chunkVHY6NVCJ_cjs.isForbiddenPath; }
25
25
  });
26
26
  Object.defineProperty(exports, "safeFilenameForId", {
27
27
  enumerable: true,
28
- get: function () { return chunk3KIUY67P_cjs.safeFilenameForId; }
28
+ get: function () { return chunkVHY6NVCJ_cjs.safeFilenameForId; }
29
29
  });
30
30
  Object.defineProperty(exports, "safePathJoin", {
31
31
  enumerable: true,
32
- get: function () { return chunk3KIUY67P_cjs.safePathJoin; }
32
+ get: function () { return chunkVHY6NVCJ_cjs.safePathJoin; }
33
33
  });
34
34
  Object.defineProperty(exports, "sanitizeIdentifier", {
35
35
  enumerable: true,
36
- get: function () { return chunk3KIUY67P_cjs.sanitizeIdentifier; }
36
+ get: function () { return chunkVHY6NVCJ_cjs.sanitizeIdentifier; }
37
37
  });
38
38
  //# sourceMappingURL=path-safety.cjs.map
39
39
  //# sourceMappingURL=path-safety.cjs.map
@@ -1,5 +1,5 @@
1
- export { ForbiddenPathError, PathTraversalError, assertNoSymlinkEscape, isForbiddenPath, safeFilenameForId, safePathJoin, sanitizeIdentifier } from './chunk-PKRPV3R7.js';
2
- import './chunk-UKMBRMGT.js';
1
+ export { ForbiddenPathError, PathTraversalError, assertNoSymlinkEscape, isForbiddenPath, safeFilenameForId, safePathJoin, sanitizeIdentifier } from './chunk-NO6AG22P.js';
2
+ import './chunk-DGO4LPLP.js';
3
3
  import './chunk-TNFOU6SB.js';
4
4
  import './chunk-3OY6H3I7.js';
5
5
  //# sourceMappingURL=path-safety.js.map
@@ -1,24 +1,24 @@
1
1
  'use strict';
2
2
 
3
- var chunkBNEUB52I_cjs = require('./chunk-BNEUB52I.cjs');
3
+ var chunkERBKPA2N_cjs = require('./chunk-ERBKPA2N.cjs');
4
4
  var chunkVTYY7XL5_cjs = require('./chunk-VTYY7XL5.cjs');
5
- var chunkEQ5IDL6W_cjs = require('./chunk-EQ5IDL6W.cjs');
6
- var chunk3WKWBYPO_cjs = require('./chunk-3WKWBYPO.cjs');
5
+ var chunkMKS5FFH5_cjs = require('./chunk-MKS5FFH5.cjs');
6
+ var chunk6EHOJLJ3_cjs = require('./chunk-6EHOJLJ3.cjs');
7
7
  var chunkA4RAL2ER_cjs = require('./chunk-A4RAL2ER.cjs');
8
- var chunkAT2PESXB_cjs = require('./chunk-AT2PESXB.cjs');
9
- var chunkPOBZXULR_cjs = require('./chunk-POBZXULR.cjs');
8
+ var chunk2UYAL4N7_cjs = require('./chunk-2UYAL4N7.cjs');
9
+ var chunkTTNJOM5W_cjs = require('./chunk-TTNJOM5W.cjs');
10
10
  var chunkMHUOVS5I_cjs = require('./chunk-MHUOVS5I.cjs');
11
11
  var chunkU3DW3WDE_cjs = require('./chunk-U3DW3WDE.cjs');
12
- var chunkZOFRNNZD_cjs = require('./chunk-ZOFRNNZD.cjs');
12
+ var chunkIZV72OEI_cjs = require('./chunk-IZV72OEI.cjs');
13
13
  var chunkCEGU5AVD_cjs = require('./chunk-CEGU5AVD.cjs');
14
14
  require('./chunk-RNXXYF22.cjs');
15
- var fs = require('fs');
16
- var promises = require('fs/promises');
17
- var path = require('path');
15
+ var node_fs = require('node:fs');
16
+ var promises = require('node:fs/promises');
17
+ var node_path = require('node:path');
18
18
 
19
19
  var DEFAULT_ID_SCAN_BYTES = 64 * 1024;
20
20
  async function listSessions(cwd, options = {}) {
21
- const dir = path.join(options.baseDir ?? chunk3WKWBYPO_cjs.transcriptRoot(), "projects", chunk3WKWBYPO_cjs.encodeProjectDir(cwd));
21
+ const dir = node_path.join(options.baseDir ?? chunk6EHOJLJ3_cjs.transcriptRoot(), "projects", chunk6EHOJLJ3_cjs.encodeProjectDir(cwd));
22
22
  let names;
23
23
  try {
24
24
  names = await promises.readdir(dir);
@@ -28,7 +28,7 @@ async function listSessions(cwd, options = {}) {
28
28
  const out = [];
29
29
  for (const name of names) {
30
30
  if (!name.endsWith(".jsonl")) continue;
31
- const transcript = path.join(dir, name);
31
+ const transcript = node_path.join(dir, name);
32
32
  let modifiedAt;
33
33
  try {
34
34
  modifiedAt = (await promises.stat(transcript)).mtime;
@@ -48,7 +48,7 @@ async function listSessions(cwd, options = {}) {
48
48
  async function readSessionId(path, maxBytes) {
49
49
  let buffered = "";
50
50
  try {
51
- const stream = fs.createReadStream(path, { encoding: "utf8", end: maxBytes - 1 });
51
+ const stream = node_fs.createReadStream(path, { encoding: "utf8", end: maxBytes - 1 });
52
52
  for await (const chunk of stream) {
53
53
  buffered += chunk;
54
54
  const lines = buffered.split("\n");
@@ -84,7 +84,7 @@ function classifySessionArtifact(name, isDirectory) {
84
84
  if (isDirectory) return void 0;
85
85
  if (name.endsWith(".jsonl")) return "transcript";
86
86
  if (name.endsWith(".writer.lock")) return "writer-lock";
87
- if (chunkZOFRNNZD_cjs.atomicWriteTempTarget(name) !== void 0) return "temp";
87
+ if (chunkIZV72OEI_cjs.atomicWriteTempTarget(name) !== void 0) return "temp";
88
88
  return void 0;
89
89
  }
90
90
  var LiveTranscriptError = class extends chunkCEGU5AVD_cjs.TheokitAgentError {
@@ -102,21 +102,21 @@ function forkTranscript(src, dst, options = {}) {
102
102
  for (const live of options.liveSessionPaths ?? []) {
103
103
  if (live === dst) throw new LiveTranscriptError(dst);
104
104
  }
105
- const lines = fs.readFileSync(src, "utf8").split("\n").filter((l) => l.trim().length > 0);
105
+ const lines = node_fs.readFileSync(src, "utf8").split("\n").filter((l) => l.trim().length > 0);
106
106
  const kept = options.beforeRecordIndex === void 0 ? lines : lines.slice(0, options.beforeRecordIndex);
107
107
  const body = kept.length > 0 ? `${kept.join("\n")}
108
108
  ` : "";
109
- const fd = fs.openSync(dst, "wx", options.mode ?? 384);
109
+ const fd = node_fs.openSync(dst, "wx", options.mode ?? 384);
110
110
  try {
111
- fs.writeSync(fd, body);
111
+ node_fs.writeSync(fd, body);
112
112
  } finally {
113
- fs.closeSync(fd);
113
+ node_fs.closeSync(fd);
114
114
  }
115
115
  }
116
116
  var TAIL_CHUNK = 64 * 1024;
117
117
  function readRawTail(path, want) {
118
- const fd = fs.openSync(path, "r");
119
- const size = fs.fstatSync(fd).size;
118
+ const fd = node_fs.openSync(path, "r");
119
+ const size = node_fs.fstatSync(fd).size;
120
120
  let bytesRead = 0;
121
121
  let tail = "";
122
122
  let pos = size;
@@ -125,13 +125,13 @@ function readRawTail(path, want) {
125
125
  const len = Math.min(TAIL_CHUNK, pos);
126
126
  pos -= len;
127
127
  const buf = Buffer.alloc(len);
128
- fs.readSync(fd, buf, 0, len, pos);
128
+ node_fs.readSync(fd, buf, 0, len, pos);
129
129
  bytesRead += len;
130
130
  tail = buf.toString("utf8") + tail;
131
131
  if (nonEmptyLines(tail).length > want) break;
132
132
  }
133
133
  } finally {
134
- fs.closeSync(fd);
134
+ node_fs.closeSync(fd);
135
135
  }
136
136
  const lines = nonEmptyLines(tail);
137
137
  return { lines: pos > 0 ? lines.slice(1) : lines, bytesRead };
@@ -164,7 +164,7 @@ function readJsonlTail(path, options = {}) {
164
164
 
165
165
  Object.defineProperty(exports, "SqliteSessionStore", {
166
166
  enumerable: true,
167
- get: function () { return chunkBNEUB52I_cjs.SqliteSessionStore; }
167
+ get: function () { return chunkERBKPA2N_cjs.SqliteSessionStore; }
168
168
  });
169
169
  Object.defineProperty(exports, "PersistenceSchema", {
170
170
  enumerable: true,
@@ -172,35 +172,35 @@ Object.defineProperty(exports, "PersistenceSchema", {
172
172
  });
173
173
  Object.defineProperty(exports, "SessionBusyError", {
174
174
  enumerable: true,
175
- get: function () { return chunkEQ5IDL6W_cjs.SessionBusyError; }
175
+ get: function () { return chunkMKS5FFH5_cjs.SessionBusyError; }
176
176
  });
177
177
  Object.defineProperty(exports, "acquireSessionWriter", {
178
178
  enumerable: true,
179
- get: function () { return chunkEQ5IDL6W_cjs.acquireSessionWriter; }
179
+ get: function () { return chunkMKS5FFH5_cjs.acquireSessionWriter; }
180
180
  });
181
181
  Object.defineProperty(exports, "sessionHasWriter", {
182
182
  enumerable: true,
183
- get: function () { return chunkEQ5IDL6W_cjs.sessionHasWriter; }
183
+ get: function () { return chunkMKS5FFH5_cjs.sessionHasWriter; }
184
184
  });
185
185
  Object.defineProperty(exports, "encodeProjectDir", {
186
186
  enumerable: true,
187
- get: function () { return chunk3WKWBYPO_cjs.encodeProjectDir; }
187
+ get: function () { return chunk6EHOJLJ3_cjs.encodeProjectDir; }
188
188
  });
189
189
  Object.defineProperty(exports, "legacyTranscriptPath", {
190
190
  enumerable: true,
191
- get: function () { return chunk3WKWBYPO_cjs.legacyTranscriptPath; }
191
+ get: function () { return chunk6EHOJLJ3_cjs.legacyTranscriptPath; }
192
192
  });
193
193
  Object.defineProperty(exports, "sessionUuidFor", {
194
194
  enumerable: true,
195
- get: function () { return chunk3WKWBYPO_cjs.sessionUuidFor; }
195
+ get: function () { return chunk6EHOJLJ3_cjs.sessionUuidFor; }
196
196
  });
197
197
  Object.defineProperty(exports, "transcriptPath", {
198
198
  enumerable: true,
199
- get: function () { return chunk3WKWBYPO_cjs.transcriptPath; }
199
+ get: function () { return chunk6EHOJLJ3_cjs.transcriptPath; }
200
200
  });
201
201
  Object.defineProperty(exports, "transcriptRoot", {
202
202
  enumerable: true,
203
- get: function () { return chunk3WKWBYPO_cjs.transcriptRoot; }
203
+ get: function () { return chunk6EHOJLJ3_cjs.transcriptRoot; }
204
204
  });
205
205
  Object.defineProperty(exports, "sanitizeFts5Query", {
206
206
  enumerable: true,
@@ -208,31 +208,31 @@ Object.defineProperty(exports, "sanitizeFts5Query", {
208
208
  });
209
209
  Object.defineProperty(exports, "applyWalWithFallback", {
210
210
  enumerable: true,
211
- get: function () { return chunkAT2PESXB_cjs.applyWalWithFallback; }
211
+ get: function () { return chunk2UYAL4N7_cjs.applyWalWithFallback; }
212
212
  });
213
213
  Object.defineProperty(exports, "isCorruptionError", {
214
214
  enumerable: true,
215
- get: function () { return chunkAT2PESXB_cjs.isCorruptionError; }
215
+ get: function () { return chunk2UYAL4N7_cjs.isCorruptionError; }
216
216
  });
217
217
  Object.defineProperty(exports, "openSqliteResilient", {
218
218
  enumerable: true,
219
- get: function () { return chunkAT2PESXB_cjs.openSqliteResilient; }
219
+ get: function () { return chunk2UYAL4N7_cjs.openSqliteResilient; }
220
220
  });
221
221
  Object.defineProperty(exports, "JsonlParseError", {
222
222
  enumerable: true,
223
- get: function () { return chunkPOBZXULR_cjs.JsonlParseError; }
223
+ get: function () { return chunkTTNJOM5W_cjs.JsonlParseError; }
224
224
  });
225
225
  Object.defineProperty(exports, "appendJsonl", {
226
226
  enumerable: true,
227
- get: function () { return chunkPOBZXULR_cjs.appendJsonl; }
227
+ get: function () { return chunkTTNJOM5W_cjs.appendJsonl; }
228
228
  });
229
229
  Object.defineProperty(exports, "loadJsonl", {
230
230
  enumerable: true,
231
- get: function () { return chunkPOBZXULR_cjs.loadJsonl; }
231
+ get: function () { return chunkTTNJOM5W_cjs.loadJsonl; }
232
232
  });
233
233
  Object.defineProperty(exports, "readJsonlIds", {
234
234
  enumerable: true,
235
- get: function () { return chunkPOBZXULR_cjs.readJsonlIds; }
235
+ get: function () { return chunkTTNJOM5W_cjs.readJsonlIds; }
236
236
  });
237
237
  Object.defineProperty(exports, "withFileLock", {
238
238
  enumerable: true,
@@ -244,19 +244,19 @@ Object.defineProperty(exports, "withCwdMutex", {
244
244
  });
245
245
  Object.defineProperty(exports, "atomicWriteJson", {
246
246
  enumerable: true,
247
- get: function () { return chunkZOFRNNZD_cjs.atomicWriteJson; }
247
+ get: function () { return chunkIZV72OEI_cjs.atomicWriteJson; }
248
248
  });
249
249
  Object.defineProperty(exports, "atomicWriteTempTarget", {
250
250
  enumerable: true,
251
- get: function () { return chunkZOFRNNZD_cjs.atomicWriteTempTarget; }
251
+ get: function () { return chunkIZV72OEI_cjs.atomicWriteTempTarget; }
252
252
  });
253
253
  Object.defineProperty(exports, "atomicWriteText", {
254
254
  enumerable: true,
255
- get: function () { return chunkZOFRNNZD_cjs.atomicWriteText; }
255
+ get: function () { return chunkIZV72OEI_cjs.atomicWriteText; }
256
256
  });
257
257
  Object.defineProperty(exports, "replaceFileAtomic", {
258
258
  enumerable: true,
259
- get: function () { return chunkZOFRNNZD_cjs.replaceFileAtomic; }
259
+ get: function () { return chunkIZV72OEI_cjs.replaceFileAtomic; }
260
260
  });
261
261
  exports.LiveSessionError = LiveTranscriptError;
262
262
  exports.LiveTranscriptError = LiveTranscriptError;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/internal/persistence/list-sessions.ts","../src/internal/persistence/session-artifacts.ts","../src/internal/persistence/transcript-ops.ts"],"names":["join","transcriptRoot","encodeProjectDir","readdir","stat","createReadStream","atomicWriteTempTarget","TheokitAgentError","readFileSync","openSync","writeSync","closeSync","fstatSync","readSync"],"mappings":";;;;;;;;;;;;;;;;;;AA8FA,IAAM,wBAAwB,EAAA,GAAK,IAAA;AAenC,eAAsB,YAAA,CACpB,GAAA,EACA,OAAA,GAA+B,EAAC,EACI;AACpC,EAAA,MAAM,GAAA,GAAMA,UAAK,OAAA,CAAQ,OAAA,IAAWC,kCAAe,EAAG,UAAA,EAAYC,kCAAA,CAAiB,GAAG,CAAC,CAAA;AACvF,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n * #598 — enumerate the sessions on disk, saying where each id came from.\n *\n * ## Why this exists\n *\n * Every transcript helper this package published mapped FORWARD — `sessionUuidFor`,\n * `transcriptPath`, `legacyTranscriptPath`, `encodeProjectDir`, `transcriptRoot`. **None enumerated.**\n * So a consumer that needed the list rebuilt it, and two independent ones did, in opposite\n * directions, and both got it wrong on the first attempt:\n *\n * | consumer | direction | what broke |\n * |---|---|---|\n * | `@theokit/agents` | file → id | derived the id from the file STEM |\n * | a downstream agent runtime | id → file | compared session ids against filenames |\n *\n * The second measured, against 5.0.1: the protected set never matched, **so neither the registered\n * sessions nor the live one were protected and everything classified as an orphan** — a garbage\n * collector that would delete the session in use.\n *\n * ## Why documentation was not the fix\n *\n * `b85dab4` documented the rename thoroughly. One of those two consumers had READ it and broke\n * anyway; the other had not and broke identically. Two samples, one informed and one not, same\n * defect. If reading were sufficient the informed sample would have survived — so the cause is the\n * shape of the surface, not the reader.\n *\n * And it cannot be closed by publishing an inverse: the filename is a UUIDv8 over SHA-256, which has\n * none. Whoever holds the file must read the id from INSIDE it, and that the id lives in the first\n * record is this package's knowledge. Both consumers had to discover it by reading bytes.\n *\n * ## Why the id is not just a string\n *\n * An `id: string` that is sometimes read from the transcript and sometimes inferred from the\n * filename is the same defect one layer up: a value that reads as authoritative and occasionally is\n * not. That is precisely what produced the garbage-collector failure above.\n *\n * So every entry carries {@link SessionListing.idSource}, and an entry whose id could not be\n * determined is `undefined` rather than guessed. A caller deciding what to DELETE needs to tell\n * \"this session is not registered\" from \"I could not read this file\" — those look identical in a\n * plain list and mean opposite things.\n *\n * @public\n */\n\nimport { createReadStream } from \"node:fs\";\nimport { readdir, stat } from \"node:fs/promises\";\nimport { join } from \"node:path\";\n\nimport { encodeProjectDir, transcriptRoot } from \"./session-transcript.js\";\n\n/** How the `id` on a {@link SessionListing} was obtained. */\nexport type SessionIdSource =\n /** Read from the `sessionId` of the transcript's first well-formed record. Authoritative. */\n | \"transcript\"\n /**\n * Not determined: the file was unreadable, empty, or its first records carried no `sessionId`.\n * `id` is `undefined` — deliberately not the filename, which is a hash and not an id.\n */\n | \"unavailable\";\n\n/** One session found on disk. */\nexport interface SessionListing {\n /**\n * The session id, or `undefined` when {@link idSource} is `\"unavailable\"`.\n *\n * Never derived from the filename. The filename is a UUIDv8 over SHA-256 of the id, so treating\n * it as the id is the exact defect this function exists to prevent.\n */\n readonly id: string | undefined;\n /** Where {@link id} came from. Check this before acting on `id`. */\n readonly idSource: SessionIdSource;\n /** Absolute path to the `.jsonl` transcript. */\n readonly transcript: string;\n /** Last modification time of the transcript. */\n readonly modifiedAt: Date;\n}\n\n/** Options for {@link listSessions}. */\nexport interface ListSessionsOptions {\n /**\n * Root under which `projects/<encoded-cwd>/` lives. Defaults to {@link transcriptRoot}, which\n * honours `THEOKIT_HOME`.\n */\n readonly baseDir?: string;\n /**\n * How many bytes of each transcript to read looking for the id. Default 65536.\n *\n * A cap rather than a full read because a transcript grows without bound and the id is in the\n * first record. A session whose id is not in the first 64KB reports `\"unavailable\"` rather than\n * being read to the end — bounded work with a declared outcome beats an unbounded read.\n */\n readonly idScanBytes?: number;\n}\n\nconst DEFAULT_ID_SCAN_BYTES = 64 * 1024;\n\n/**\n * Every session transcript under `<baseDir>/projects/<encoded-cwd>/`, with the id read from inside\n * each file.\n *\n * An absent directory yields `[]` — a cwd with no sessions is the common case, not an error.\n *\n * ```ts\n * for (const s of await listSessions(process.cwd())) {\n * if (s.idSource === \"unavailable\") continue; // do not guess, and do not delete\n * …\n * }\n * ```\n */\nexport async function listSessions(\n cwd: string,\n options: ListSessionsOptions = {},\n): Promise<readonly SessionListing[]> {\n const dir = join(options.baseDir ?? transcriptRoot(), \"projects\", encodeProjectDir(cwd));\n let names: string[];\n try {\n names = await readdir(dir);\n } catch {\n return [];\n }\n\n const out: SessionListing[] = [];\n for (const name of names) {\n if (!name.endsWith(\".jsonl\")) continue;\n const transcript = join(dir, name);\n let modifiedAt: Date;\n try {\n modifiedAt = (await stat(transcript)).mtime;\n } catch {\n // Vanished between readdir and stat — a live session being rotated. Skipping is correct:\n // reporting a file that no longer exists would be worse than omitting it.\n continue;\n }\n const id = await readSessionId(transcript, options.idScanBytes ?? DEFAULT_ID_SCAN_BYTES);\n out.push({\n id,\n idSource: id === undefined ? \"unavailable\" : \"transcript\",\n transcript,\n modifiedAt,\n });\n }\n return out;\n}\n\n/**\n * The `sessionId` of the first well-formed record, or `undefined`.\n *\n * Reads at most `maxBytes` and stops at the first record that yields one. Tolerant of malformed\n * lines for the same reason `readTranscript` is: a truncated final line in a live transcript is\n * normal, and failing the whole listing over it would make the function useless exactly when it\n * matters.\n */\nasync function readSessionId(path: string, maxBytes: number): Promise<string | undefined> {\n let buffered = \"\";\n try {\n const stream = createReadStream(path, { encoding: \"utf8\", end: maxBytes - 1 });\n for await (const chunk of stream) {\n buffered += chunk as string;\n const lines = buffered.split(\"\\n\");\n buffered = lines.pop() ?? \"\";\n for (const line of lines) {\n const id = sessionIdOfLine(line);\n if (id !== undefined) {\n stream.destroy();\n return id;\n }\n }\n }\n } catch {\n return undefined;\n }\n return sessionIdOfLine(buffered);\n}\n\nfunction sessionIdOfLine(line: string): string | undefined {\n if (line.trim() === \"\") return undefined;\n try {\n const parsed: unknown = JSON.parse(line);\n if (typeof parsed !== \"object\" || parsed === null) return undefined;\n const id = (parsed as { sessionId?: unknown }).sessionId;\n return typeof id === \"string\" && id !== \"\" ? id : undefined;\n } catch {\n return undefined;\n }\n}\n","import { atomicWriteTempTarget } from \"./atomic-write.js\";\n\n/**\n * The kinds of file this SDK leaves in a project's transcript directory.\n *\n * - `transcript` — the session itself (`transcriptPath`).\n * - `writer-lock` — the cross-process writer lease (`session-writer.ts`, `<file>.writer.lock`).\n * - `lock-directory` — `withFileLock`'s companion, taken by `mkdir`, so it is a DIRECTORY.\n * - `temp` — what `replaceFileAtomic` leaves when a process dies between the open and the rename.\n */\nexport type SessionArtifact = \"transcript\" | \"writer-lock\" | \"lock-directory\" | \"temp\";\n\n/**\n * U-1 — what is this entry, if it is one of ours?\n *\n * The SDK writes four kinds of file into a project directory and reasons about none of them\n * afterwards: there is no retention, no collector, and there was no way even to ask what an entry\n * IS. A consumer wanting to reclaim disk had to re-derive the suffixes by reading this source — and\n * one did, which means a suffix changing here would have left its classifier silently mislabelling\n * files on a path that deletes them.\n *\n * This is deliberately NOT a garbage collector. Retention is policy — how many days, how many to\n * keep, which session is live, whether to delete at all — and policy belongs to the application,\n * which is the only one that can know. What belongs here is the half only the SDK can answer.\n *\n * `undefined` means \"not written by this SDK\", and it is the answer that matters most: a caller\n * deleting what it does not recognise is how an editor's swap file gets collected. The `temp` case\n * defers to {@link atomicWriteTempTarget} rather than matching `.tmp`, for exactly that reason.\n */\nexport function classifySessionArtifact(\n name: string,\n isDirectory: boolean,\n): SessionArtifact | undefined {\n // `withFileLock` takes its lock by `mkdir`, so the same name as a plain file is not ours.\n if (name.endsWith(\".jsonl.lock\")) return isDirectory ? \"lock-directory\" : undefined;\n if (isDirectory) return undefined;\n if (name.endsWith(\".jsonl\")) return \"transcript\";\n if (name.endsWith(\".writer.lock\")) return \"writer-lock\";\n if (atomicWriteTempTarget(name) !== undefined) return \"temp\";\n return undefined;\n}\n","/**\n * M81 — transcript operations the consumer was doing by hand INSIDE the framework's own store.\n *\n * ## What this replaces\n *\n * `agents/lib/session/backtrack.ts:188` (agent-builder) wrote straight into the session store with a\n * bare `writeFileSync` — no atomicity, no lock, no API. 243 lines re-implementing parse, cut and\n * write for a format the framework owns. The consumer is not at fault: nothing here was reachable.\n *\n * ## The rule that travels WITH the operation\n *\n * `rules/audit-trail-rotation.md § Session transcripts (M60)` defines a NEVER-delete list — the live\n * pointer, the most recent transcript, and any active registry entry. That rule lived in the\n * CONSUMER. Moving the operation here without moving the rule would ship an API able to destroy\n * exactly what the rule protects — the same shape of defect as M80's `reconcileUpdateGoalStatus`:\n * critical knowledge outside the module that needs it, applied by convention.\n *\n * So `forkTranscript` takes `liveSessionPaths` and refuses, with a TYPED error, to write over any of\n * them. The caller supplies the list because only the caller knows which session is live; the\n * enforcement lives here because that is where the write happens.\n *\n * @internal\n */\n\nimport { closeSync, fstatSync, openSync, readFileSync, readSync, writeSync } from \"node:fs\";\n\nimport { TheokitAgentError } from \"../../errors.js\";\n\n/**\n * M81 — the target is a protected session (live pointer / most-recent transcript / active entry).\n *\n * Typed rather than a bare `Error` because the caller must distinguish \"this session is protected\"\n * from \"the disk is full\": the first is a correct refusal, the second is an incident.\n *\n * RENAMED from `LiveSessionError` (2026-09-01). `session-guard.ts` exports a DIFFERENT class of that\n * name from the root barrel, with an incompatible shape — `(sessionId, reason)` and a `reason`\n * field, against this one's `(path)` and `code: \"live_session_protected\"` — and `.` and\n * `./persistence` are both declared subpaths, so one consumer can hold both. `instanceof` never\n * crossed the pair, so a `catch` checking the root import silently missed this one and ran its\n * fallback for a condition it believed it handled; `err.name` matched BOTH, so a name check looked\n * right and then read `err.reason`, which only the other one has. The names now say what each\n * refusal is about: destroying a SESSION, versus overwriting a TRANSCRIPT file.\n */\nexport class LiveTranscriptError extends TheokitAgentError {\n override readonly name = \"LiveTranscriptError\";\n\n constructor(readonly path: string) {\n super(\n `refusing to write over a live session transcript: ${path}. ` +\n \"Fork to a new id instead — the live pointer, the most recent transcript and any active \" +\n \"registry entry are never overwritten (audit-trail rotation, M60).\",\n { code: \"live_session_protected\", isRetryable: false },\n );\n }\n}\n\n/** Options for {@link forkTranscript}. */\nexport interface ForkTranscriptOptions {\n /** Keep records `[0, beforeRecordIndex)`. Omit to copy the whole transcript. */\n readonly beforeRecordIndex?: number;\n /**\n * Paths that must never be written over — the live pointer, the most recent transcript, any active\n * registry entry. The caller supplies them because only the caller knows which session is live.\n */\n readonly liveSessionPaths?: readonly string[];\n /**\n * M107 — permission bits for the created destination. Default: `0o600`.\n *\n * A transcript carries the conversation. Before M107 no mode was passed at all, so the file was\n * born `0o666 & ~umask` — measured `0o664` (group-WRITABLE) on a `umask 002` machine, `0o644` on\n * `umask 022`, `0o466` on `umask 0200`. This is a DEFAULT and not a required knob on purpose: a\n * knob would reach zero consumers by omission, which is the failure mode that matters.\n *\n * As with any `open` mode, the `umask` may still CLEAR bits — under `umask 0200` the result is\n * `0o400`. That is accepted: the invariant bought here is \"neither group nor others\", and `0o400`\n * satisfies it more strictly. The SDK deliberately does not `fchmod` the default back, because\n * that would hand back a bit the operator asked to remove.\n */\n readonly mode?: number;\n}\n\n/**\n * Copy `src` into `dst`, keeping the first `beforeRecordIndex` records. The SOURCE is never touched.\n *\n * Atomicity comes from `wx` (exclusive create): two concurrent forks to the same destination cannot\n * both succeed — the loser gets `EEXIST` rather than writing over a half-written file. That is also\n * why an existing destination is a refusal, not a silent overwrite: losing a transcript without an\n * error is the worst failure mode for an operation that touches user sessions.\n */\nexport function forkTranscript(\n src: string,\n dst: string,\n options: ForkTranscriptOptions = {},\n): void {\n for (const live of options.liveSessionPaths ?? []) {\n if (live === dst) throw new LiveTranscriptError(dst);\n }\n\n const lines = readFileSync(src, \"utf8\")\n .split(\"\\n\")\n .filter((l) => l.trim().length > 0);\n const kept =\n options.beforeRecordIndex === undefined ? lines : lines.slice(0, options.beforeRecordIndex);\n const body = kept.length > 0 ? `${kept.join(\"\\n\")}\\n` : \"\";\n\n // `wx` — fails with EEXIST instead of truncating. The exclusivity IS the concurrency guarantee,\n // and M107 only added the third argument: the mode. See `ForkTranscriptOptions.mode`.\n const fd = openSync(dst, \"wx\", options.mode ?? 0o600);\n try {\n writeSync(fd, body);\n } finally {\n closeSync(fd);\n }\n}\n\n/** Options for {@link readJsonlTail}. */\nexport interface ReadJsonlTailOptions {\n /** Maximum records to return, counted from the END. */\n readonly maxRecords?: number;\n /**\n * Start the window AFTER the last record whose `subtype` (or `type`) equals this.\n *\n * Matched STRUCTURALLY since T2.5. It used to be `line.includes(marker)`, so any message\n * mentioning the marker in its text truncated the read — silently, with a successful return.\n */\n readonly sinceMarker?: string;\n /** Test-only: also report how many bytes were read, to prove the read is not whole-file. */\n readonly _stats?: boolean;\n}\n\nconst TAIL_CHUNK = 64 * 1024;\n\n/**\n * Reads chunks backwards until enough complete lines have accumulated.\n *\n * Extracted from `readJsonlTail` because the read loop and the record selection are two\n * responsibilities — and together they exceeded the complexity ceiling. The buffer's first line may\n * be cut in half when the read stopped before the start of the file; that is why it is discarded.\n */\nfunction readRawTail(path: string, want: number): { lines: string[]; bytesRead: number } {\n // Opened FIRST, then sized through the descriptor. `statSync(path)` followed by\n // `openSync(path)` resolves the name twice, and `size` is what drives every read offset below —\n // so a path that changed between the two calls would have the loop seeking by one file's length\n // inside another (CodeQL js/file-system-race #19). `fstat` on the open fd describes the file\n // being read, by construction.\n const fd = openSync(path, \"r\");\n const size = fstatSync(fd).size;\n let bytesRead = 0;\n let tail = \"\";\n let pos = size;\n try {\n while (pos > 0) {\n const len = Math.min(TAIL_CHUNK, pos);\n pos -= len;\n const buf = Buffer.alloc(len);\n readSync(fd, buf, 0, len, pos);\n bytesRead += len;\n tail = buf.toString(\"utf8\") + tail;\n if (nonEmptyLines(tail).length > want) break;\n }\n } finally {\n closeSync(fd);\n }\n const lines = nonEmptyLines(tail);\n return { lines: pos > 0 ? lines.slice(1) : lines, bytesRead };\n}\n\n/** Non-empty lines, in file order. */\nfunction nonEmptyLines(text: string): string[] {\n return text.split(\"\\n\").filter((l) => l.trim().length > 0);\n}\n\n/**\n * Whether a raw JSONL line IS the marker record, rather than a line that talks about it.\n *\n * Matches on the record's own discriminants (`subtype`, then `type`) — the fields that identify\n * what a record *is*. Free text is never consulted, which is the whole point: content is the user's\n * and must not steer the reader.\n *\n * A line that does not parse is not a marker. Deciding a window boundary from bytes that are not a\n * record would be guessing, and this function exists because guessing is what it replaced.\n */\nfunction isMarkerRecord(line: string, marker: string): boolean {\n let record: { type?: unknown; subtype?: unknown };\n try {\n record = JSON.parse(line) as { type?: unknown; subtype?: unknown };\n } catch {\n return false;\n }\n return record.subtype === marker || record.type === marker;\n}\n\n/**\n * Read the LAST records of a JSONL file without loading the whole thing.\n *\n * Reads fixed-size chunks backwards from EOF until enough newlines have been seen. A session\n * transcript grows without bound; loading megabytes to show the last three turns is the cost this\n * exists to avoid — and a `slice` over a full read would be that same cost with a better name.\n */\nexport function readJsonlTail<T = Record<string, unknown>>(\n path: string,\n options: ReadJsonlTailOptions = {},\n): T[] {\n const want = options.maxRecords ?? Number.POSITIVE_INFINITY;\n const { lines, bytesRead } = readRawTail(path, want);\n\n let sel = lines;\n if (options.sinceMarker !== undefined) {\n const marker = options.sinceMarker;\n // STRUCTURAL, not `line.includes(marker)`.\n //\n // A raw substring match is true for any line that merely MENTIONS the marker — a user asking\n // \"how does compact_boundary work?\" silently truncated the window to start at their question.\n // The read then succeeded, returned fewer records than exist, and said nothing. That is the\n // measured reason the only would-be consumer kept its own reader instead of this one.\n const idx = sel.findLastIndex((l) => isMarkerRecord(l, marker));\n if (idx >= 0) sel = sel.slice(idx + 1);\n }\n if (Number.isFinite(want)) sel = sel.slice(-want);\n\n const out = sel.map((l) => JSON.parse(l) as T);\n return options._stats === true ? (Object.assign(out, { bytesRead }) as T[]) : out;\n}\n"]}
1
+ {"version":3,"sources":["../src/internal/persistence/list-sessions.ts","../src/internal/persistence/session-artifacts.ts","../src/internal/persistence/transcript-ops.ts"],"names":["join","transcriptRoot","encodeProjectDir","readdir","stat","createReadStream","atomicWriteTempTarget","TheokitAgentError","readFileSync","openSync","writeSync","closeSync","fstatSync","readSync"],"mappings":";;;;;;;;;;;;;;;;;;AA8FA,IAAM,wBAAwB,EAAA,GAAK,IAAA;AAenC,eAAsB,YAAA,CACpB,GAAA,EACA,OAAA,GAA+B,EAAC,EACI;AACpC,EAAA,MAAM,GAAA,GAAMA,eAAK,OAAA,CAAQ,OAAA,IAAWC,kCAAe,EAAG,UAAA,EAAYC,kCAAA,CAAiB,GAAG,CAAC,CAAA;AACvF,EAAA,IAAI,KAAA;AACJ,EAAA,IAAI;AACF,IAAA,KAAA,GAAQ,MAAMC,iBAAQ,GAAG,CAAA;AAAA,EAC3B,CAAA,CAAA,MAAQ;AACN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AAI;AACF,IAAA,MAAA,GAAS,IAAA,CAAK,MAAM,IAAI,CAAA;AAAA,EAC1B,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,OAAO,MAAA,CAAO,OAAA,KAAY,MAAA,IAAU,MAAA,CAAO,IAAA,KAAS,MAAA;AACtD;AASO,SAAS,aAAA,CACd,IAAA,EACA,OAAA,GAAgC,EAAC,EAC5B;AACL,EAAA,MAAM,IAAA,GAAO,OAAA,CAAQ,UAAA,IAAc,MAAA,CAAO,iBAAA;AAC1C,EAAA,MAAM,EAAE,KAAA,EAAO,SAAA,EAAU,GAAI,WAAA,CAAY,MAAM,IAAI,CAAA;AAEnD,EAAA,IAAI,GAAA,GAAM,KAAA;AACV,EAAA,IAAI,OAAA,CAAQ,gBAAgB,MAAA,EAAW;AACrC,IAAA,MAAM,SAAS,OAAA,CAAQ,WAAA;AAOvB,IAAA,MAAM,GAAA,GAAM,IAAI,aAAA,CAAc,CAAC,MAAM,cAAA,CAAe,CAAA,EAAG,MAAM,CAAC,CAAA;AAC9D,IAAA,IAAI,OAAO,CAAA,EAAG,GAAA,GAAM,GAAA,CAAI,KAAA,CAAM,MAAM,CAAC,CAAA;AAAA,EACvC;AACA,EAAA,IAAI,MAAA,CAAO,SAAS,IAAI,CAAA,QAAS,GAAA,CAAI,KAAA,CAAM,CAAC,IAAI,CAAA;AAEhD,EAAA,MAAM,GAAA,GAAM,IAAI,GAAA,CAAI,CAAC,MAAM,IAAA,CAAK,KAAA,CAAM,CAAC,CAAM,CAAA;AAC7C,EAAA,OAAO,OAAA,CAAQ,WAAW,IAAA,GAAQ,MAAA,CAAO,OAAO,GAAA,EAAK,EAAE,SAAA,EAAW,CAAA,GAAY,GAAA;AAChF","file":"persistence.cjs","sourcesContent":["/**\n * #598 — enumerate the sessions on disk, saying where each id came from.\n *\n * ## Why this exists\n *\n * Every transcript helper this package published mapped FORWARD — `sessionUuidFor`,\n * `transcriptPath`, `legacyTranscriptPath`, `encodeProjectDir`, `transcriptRoot`. **None enumerated.**\n * So a consumer that needed the list rebuilt it, and two independent ones did, in opposite\n * directions, and both got it wrong on the first attempt:\n *\n * | consumer | direction | what broke |\n * |---|---|---|\n * | `@theokit/agents` | file → id | derived the id from the file STEM |\n * | a downstream agent runtime | id → file | compared session ids against filenames |\n *\n * The second measured, against 5.0.1: the protected set never matched, **so neither the registered\n * sessions nor the live one were protected and everything classified as an orphan** — a garbage\n * collector that would delete the session in use.\n *\n * ## Why documentation was not the fix\n *\n * `b85dab4` documented the rename thoroughly. One of those two consumers had READ it and broke\n * anyway; the other had not and broke identically. Two samples, one informed and one not, same\n * defect. If reading were sufficient the informed sample would have survived — so the cause is the\n * shape of the surface, not the reader.\n *\n * And it cannot be closed by publishing an inverse: the filename is a UUIDv8 over SHA-256, which has\n * none. Whoever holds the file must read the id from INSIDE it, and that the id lives in the first\n * record is this package's knowledge. Both consumers had to discover it by reading bytes.\n *\n * ## Why the id is not just a string\n *\n * An `id: string` that is sometimes read from the transcript and sometimes inferred from the\n * filename is the same defect one layer up: a value that reads as authoritative and occasionally is\n * not. That is precisely what produced the garbage-collector failure above.\n *\n * So every entry carries {@link SessionListing.idSource}, and an entry whose id could not be\n * determined is `undefined` rather than guessed. A caller deciding what to DELETE needs to tell\n * \"this session is not registered\" from \"I could not read this file\" — those look identical in a\n * plain list and mean opposite things.\n *\n * @public\n */\n\nimport { createReadStream } from \"node:fs\";\nimport { readdir, stat } from \"node:fs/promises\";\nimport { join } from \"node:path\";\n\nimport { encodeProjectDir, transcriptRoot } from \"./session-transcript.js\";\n\n/** How the `id` on a {@link SessionListing} was obtained. */\nexport type SessionIdSource =\n /** Read from the `sessionId` of the transcript's first well-formed record. Authoritative. */\n | \"transcript\"\n /**\n * Not determined: the file was unreadable, empty, or its first records carried no `sessionId`.\n * `id` is `undefined` — deliberately not the filename, which is a hash and not an id.\n */\n | \"unavailable\";\n\n/** One session found on disk. */\nexport interface SessionListing {\n /**\n * The session id, or `undefined` when {@link idSource} is `\"unavailable\"`.\n *\n * Never derived from the filename. The filename is a UUIDv8 over SHA-256 of the id, so treating\n * it as the id is the exact defect this function exists to prevent.\n */\n readonly id: string | undefined;\n /** Where {@link id} came from. Check this before acting on `id`. */\n readonly idSource: SessionIdSource;\n /** Absolute path to the `.jsonl` transcript. */\n readonly transcript: string;\n /** Last modification time of the transcript. */\n readonly modifiedAt: Date;\n}\n\n/** Options for {@link listSessions}. */\nexport interface ListSessionsOptions {\n /**\n * Root under which `projects/<encoded-cwd>/` lives. Defaults to {@link transcriptRoot}, which\n * honours `THEOKIT_HOME`.\n */\n readonly baseDir?: string;\n /**\n * How many bytes of each transcript to read looking for the id. Default 65536.\n *\n * A cap rather than a full read because a transcript grows without bound and the id is in the\n * first record. A session whose id is not in the first 64KB reports `\"unavailable\"` rather than\n * being read to the end — bounded work with a declared outcome beats an unbounded read.\n */\n readonly idScanBytes?: number;\n}\n\nconst DEFAULT_ID_SCAN_BYTES = 64 * 1024;\n\n/**\n * Every session transcript under `<baseDir>/projects/<encoded-cwd>/`, with the id read from inside\n * each file.\n *\n * An absent directory yields `[]` — a cwd with no sessions is the common case, not an error.\n *\n * ```ts\n * for (const s of await listSessions(process.cwd())) {\n * if (s.idSource === \"unavailable\") continue; // do not guess, and do not delete\n * …\n * }\n * ```\n */\nexport async function listSessions(\n cwd: string,\n options: ListSessionsOptions = {},\n): Promise<readonly SessionListing[]> {\n const dir = join(options.baseDir ?? transcriptRoot(), \"projects\", encodeProjectDir(cwd));\n let names: string[];\n try {\n names = await readdir(dir);\n } catch {\n return [];\n }\n\n const out: SessionListing[] = [];\n for (const name of names) {\n if (!name.endsWith(\".jsonl\")) continue;\n const transcript = join(dir, name);\n let modifiedAt: Date;\n try {\n modifiedAt = (await stat(transcript)).mtime;\n } catch {\n // Vanished between readdir and stat — a live session being rotated. Skipping is correct:\n // reporting a file that no longer exists would be worse than omitting it.\n continue;\n }\n const id = await readSessionId(transcript, options.idScanBytes ?? DEFAULT_ID_SCAN_BYTES);\n out.push({\n id,\n idSource: id === undefined ? \"unavailable\" : \"transcript\",\n transcript,\n modifiedAt,\n });\n }\n return out;\n}\n\n/**\n * The `sessionId` of the first well-formed record, or `undefined`.\n *\n * Reads at most `maxBytes` and stops at the first record that yields one. Tolerant of malformed\n * lines for the same reason `readTranscript` is: a truncated final line in a live transcript is\n * normal, and failing the whole listing over it would make the function useless exactly when it\n * matters.\n */\nasync function readSessionId(path: string, maxBytes: number): Promise<string | undefined> {\n let buffered = \"\";\n try {\n const stream = createReadStream(path, { encoding: \"utf8\", end: maxBytes - 1 });\n for await (const chunk of stream) {\n buffered += chunk as string;\n const lines = buffered.split(\"\\n\");\n buffered = lines.pop() ?? \"\";\n for (const line of lines) {\n const id = sessionIdOfLine(line);\n if (id !== undefined) {\n stream.destroy();\n return id;\n }\n }\n }\n } catch {\n return undefined;\n }\n return sessionIdOfLine(buffered);\n}\n\nfunction sessionIdOfLine(line: string): string | undefined {\n if (line.trim() === \"\") return undefined;\n try {\n const parsed: unknown = JSON.parse(line);\n if (typeof parsed !== \"object\" || parsed === null) return undefined;\n const id = (parsed as { sessionId?: unknown }).sessionId;\n return typeof id === \"string\" && id !== \"\" ? id : undefined;\n } catch {\n return undefined;\n }\n}\n","import { atomicWriteTempTarget } from \"./atomic-write.js\";\n\n/**\n * The kinds of file this SDK leaves in a project's transcript directory.\n *\n * - `transcript` — the session itself (`transcriptPath`).\n * - `writer-lock` — the cross-process writer lease (`session-writer.ts`, `<file>.writer.lock`).\n * - `lock-directory` — `withFileLock`'s companion, taken by `mkdir`, so it is a DIRECTORY.\n * - `temp` — what `replaceFileAtomic` leaves when a process dies between the open and the rename.\n */\nexport type SessionArtifact = \"transcript\" | \"writer-lock\" | \"lock-directory\" | \"temp\";\n\n/**\n * U-1 — what is this entry, if it is one of ours?\n *\n * The SDK writes four kinds of file into a project directory and reasons about none of them\n * afterwards: there is no retention, no collector, and there was no way even to ask what an entry\n * IS. A consumer wanting to reclaim disk had to re-derive the suffixes by reading this source — and\n * one did, which means a suffix changing here would have left its classifier silently mislabelling\n * files on a path that deletes them.\n *\n * This is deliberately NOT a garbage collector. Retention is policy — how many days, how many to\n * keep, which session is live, whether to delete at all — and policy belongs to the application,\n * which is the only one that can know. What belongs here is the half only the SDK can answer.\n *\n * `undefined` means \"not written by this SDK\", and it is the answer that matters most: a caller\n * deleting what it does not recognise is how an editor's swap file gets collected. The `temp` case\n * defers to {@link atomicWriteTempTarget} rather than matching `.tmp`, for exactly that reason.\n */\nexport function classifySessionArtifact(\n name: string,\n isDirectory: boolean,\n): SessionArtifact | undefined {\n // `withFileLock` takes its lock by `mkdir`, so the same name as a plain file is not ours.\n if (name.endsWith(\".jsonl.lock\")) return isDirectory ? \"lock-directory\" : undefined;\n if (isDirectory) return undefined;\n if (name.endsWith(\".jsonl\")) return \"transcript\";\n if (name.endsWith(\".writer.lock\")) return \"writer-lock\";\n if (atomicWriteTempTarget(name) !== undefined) return \"temp\";\n return undefined;\n}\n","/**\n * M81 — transcript operations the consumer was doing by hand INSIDE the framework's own store.\n *\n * ## What this replaces\n *\n * `agents/lib/session/backtrack.ts:188` (agent-builder) wrote straight into the session store with a\n * bare `writeFileSync` — no atomicity, no lock, no API. 243 lines re-implementing parse, cut and\n * write for a format the framework owns. The consumer is not at fault: nothing here was reachable.\n *\n * ## The rule that travels WITH the operation\n *\n * `rules/audit-trail-rotation.md § Session transcripts (M60)` defines a NEVER-delete list — the live\n * pointer, the most recent transcript, and any active registry entry. That rule lived in the\n * CONSUMER. Moving the operation here without moving the rule would ship an API able to destroy\n * exactly what the rule protects — the same shape of defect as M80's `reconcileUpdateGoalStatus`:\n * critical knowledge outside the module that needs it, applied by convention.\n *\n * So `forkTranscript` takes `liveSessionPaths` and refuses, with a TYPED error, to write over any of\n * them. The caller supplies the list because only the caller knows which session is live; the\n * enforcement lives here because that is where the write happens.\n *\n * @internal\n */\n\nimport { closeSync, fstatSync, openSync, readFileSync, readSync, writeSync } from \"node:fs\";\n\nimport { TheokitAgentError } from \"../../errors.js\";\n\n/**\n * M81 — the target is a protected session (live pointer / most-recent transcript / active entry).\n *\n * Typed rather than a bare `Error` because the caller must distinguish \"this session is protected\"\n * from \"the disk is full\": the first is a correct refusal, the second is an incident.\n *\n * RENAMED from `LiveSessionError` (2026-09-01). `session-guard.ts` exports a DIFFERENT class of that\n * name from the root barrel, with an incompatible shape — `(sessionId, reason)` and a `reason`\n * field, against this one's `(path)` and `code: \"live_session_protected\"` — and `.` and\n * `./persistence` are both declared subpaths, so one consumer can hold both. `instanceof` never\n * crossed the pair, so a `catch` checking the root import silently missed this one and ran its\n * fallback for a condition it believed it handled; `err.name` matched BOTH, so a name check looked\n * right and then read `err.reason`, which only the other one has. The names now say what each\n * refusal is about: destroying a SESSION, versus overwriting a TRANSCRIPT file.\n */\nexport class LiveTranscriptError extends TheokitAgentError {\n override readonly name = \"LiveTranscriptError\";\n\n constructor(readonly path: string) {\n super(\n `refusing to write over a live session transcript: ${path}. ` +\n \"Fork to a new id instead — the live pointer, the most recent transcript and any active \" +\n \"registry entry are never overwritten (audit-trail rotation, M60).\",\n { code: \"live_session_protected\", isRetryable: false },\n );\n }\n}\n\n/** Options for {@link forkTranscript}. */\nexport interface ForkTranscriptOptions {\n /** Keep records `[0, beforeRecordIndex)`. Omit to copy the whole transcript. */\n readonly beforeRecordIndex?: number;\n /**\n * Paths that must never be written over — the live pointer, the most recent transcript, any active\n * registry entry. The caller supplies them because only the caller knows which session is live.\n */\n readonly liveSessionPaths?: readonly string[];\n /**\n * M107 — permission bits for the created destination. Default: `0o600`.\n *\n * A transcript carries the conversation. Before M107 no mode was passed at all, so the file was\n * born `0o666 & ~umask` — measured `0o664` (group-WRITABLE) on a `umask 002` machine, `0o644` on\n * `umask 022`, `0o466` on `umask 0200`. This is a DEFAULT and not a required knob on purpose: a\n * knob would reach zero consumers by omission, which is the failure mode that matters.\n *\n * As with any `open` mode, the `umask` may still CLEAR bits — under `umask 0200` the result is\n * `0o400`. That is accepted: the invariant bought here is \"neither group nor others\", and `0o400`\n * satisfies it more strictly. The SDK deliberately does not `fchmod` the default back, because\n * that would hand back a bit the operator asked to remove.\n */\n readonly mode?: number;\n}\n\n/**\n * Copy `src` into `dst`, keeping the first `beforeRecordIndex` records. The SOURCE is never touched.\n *\n * Atomicity comes from `wx` (exclusive create): two concurrent forks to the same destination cannot\n * both succeed — the loser gets `EEXIST` rather than writing over a half-written file. That is also\n * why an existing destination is a refusal, not a silent overwrite: losing a transcript without an\n * error is the worst failure mode for an operation that touches user sessions.\n */\nexport function forkTranscript(\n src: string,\n dst: string,\n options: ForkTranscriptOptions = {},\n): void {\n for (const live of options.liveSessionPaths ?? []) {\n if (live === dst) throw new LiveTranscriptError(dst);\n }\n\n const lines = readFileSync(src, \"utf8\")\n .split(\"\\n\")\n .filter((l) => l.trim().length > 0);\n const kept =\n options.beforeRecordIndex === undefined ? lines : lines.slice(0, options.beforeRecordIndex);\n const body = kept.length > 0 ? `${kept.join(\"\\n\")}\\n` : \"\";\n\n // `wx` — fails with EEXIST instead of truncating. The exclusivity IS the concurrency guarantee,\n // and M107 only added the third argument: the mode. See `ForkTranscriptOptions.mode`.\n const fd = openSync(dst, \"wx\", options.mode ?? 0o600);\n try {\n writeSync(fd, body);\n } finally {\n closeSync(fd);\n }\n}\n\n/** Options for {@link readJsonlTail}. */\nexport interface ReadJsonlTailOptions {\n /** Maximum records to return, counted from the END. */\n readonly maxRecords?: number;\n /**\n * Start the window AFTER the last record whose `subtype` (or `type`) equals this.\n *\n * Matched STRUCTURALLY since T2.5. It used to be `line.includes(marker)`, so any message\n * mentioning the marker in its text truncated the read — silently, with a successful return.\n */\n readonly sinceMarker?: string;\n /** Test-only: also report how many bytes were read, to prove the read is not whole-file. */\n readonly _stats?: boolean;\n}\n\nconst TAIL_CHUNK = 64 * 1024;\n\n/**\n * Reads chunks backwards until enough complete lines have accumulated.\n *\n * Extracted from `readJsonlTail` because the read loop and the record selection are two\n * responsibilities — and together they exceeded the complexity ceiling. The buffer's first line may\n * be cut in half when the read stopped before the start of the file; that is why it is discarded.\n */\nfunction readRawTail(path: string, want: number): { lines: string[]; bytesRead: number } {\n // Opened FIRST, then sized through the descriptor. `statSync(path)` followed by\n // `openSync(path)` resolves the name twice, and `size` is what drives every read offset below —\n // so a path that changed between the two calls would have the loop seeking by one file's length\n // inside another (CodeQL js/file-system-race #19). `fstat` on the open fd describes the file\n // being read, by construction.\n const fd = openSync(path, \"r\");\n const size = fstatSync(fd).size;\n let bytesRead = 0;\n let tail = \"\";\n let pos = size;\n try {\n while (pos > 0) {\n const len = Math.min(TAIL_CHUNK, pos);\n pos -= len;\n const buf = Buffer.alloc(len);\n readSync(fd, buf, 0, len, pos);\n bytesRead += len;\n tail = buf.toString(\"utf8\") + tail;\n if (nonEmptyLines(tail).length > want) break;\n }\n } finally {\n closeSync(fd);\n }\n const lines = nonEmptyLines(tail);\n return { lines: pos > 0 ? lines.slice(1) : lines, bytesRead };\n}\n\n/** Non-empty lines, in file order. */\nfunction nonEmptyLines(text: string): string[] {\n return text.split(\"\\n\").filter((l) => l.trim().length > 0);\n}\n\n/**\n * Whether a raw JSONL line IS the marker record, rather than a line that talks about it.\n *\n * Matches on the record's own discriminants (`subtype`, then `type`) — the fields that identify\n * what a record *is*. Free text is never consulted, which is the whole point: content is the user's\n * and must not steer the reader.\n *\n * A line that does not parse is not a marker. Deciding a window boundary from bytes that are not a\n * record would be guessing, and this function exists because guessing is what it replaced.\n */\nfunction isMarkerRecord(line: string, marker: string): boolean {\n let record: { type?: unknown; subtype?: unknown };\n try {\n record = JSON.parse(line) as { type?: unknown; subtype?: unknown };\n } catch {\n return false;\n }\n return record.subtype === marker || record.type === marker;\n}\n\n/**\n * Read the LAST records of a JSONL file without loading the whole thing.\n *\n * Reads fixed-size chunks backwards from EOF until enough newlines have been seen. A session\n * transcript grows without bound; loading megabytes to show the last three turns is the cost this\n * exists to avoid — and a `slice` over a full read would be that same cost with a better name.\n */\nexport function readJsonlTail<T = Record<string, unknown>>(\n path: string,\n options: ReadJsonlTailOptions = {},\n): T[] {\n const want = options.maxRecords ?? Number.POSITIVE_INFINITY;\n const { lines, bytesRead } = readRawTail(path, want);\n\n let sel = lines;\n if (options.sinceMarker !== undefined) {\n const marker = options.sinceMarker;\n // STRUCTURAL, not `line.includes(marker)`.\n //\n // A raw substring match is true for any line that merely MENTIONS the marker — a user asking\n // \"how does compact_boundary work?\" silently truncated the window to start at their question.\n // The read then succeeded, returned fewer records than exist, and said nothing. That is the\n // measured reason the only would-be consumer kept its own reader instead of this one.\n const idx = sel.findLastIndex((l) => isMarkerRecord(l, marker));\n if (idx >= 0) sel = sel.slice(idx + 1);\n }\n if (Number.isFinite(want)) sel = sel.slice(-want);\n\n const out = sel.map((l) => JSON.parse(l) as T);\n return options._stats === true ? (Object.assign(out, { bytesRead }) as T[]) : out;\n}\n"]}
@@ -1,20 +1,20 @@
1
- export { SqliteSessionStore } from './chunk-BPL5CVZ5.js';
1
+ export { SqliteSessionStore } from './chunk-VFT63FJF.js';
2
2
  export { PersistenceSchema } from './chunk-HY66GLM6.js';
3
- export { SessionBusyError, acquireSessionWriter, sessionHasWriter } from './chunk-5IRDK5BC.js';
4
- import { transcriptRoot, encodeProjectDir } from './chunk-XESYJ4JC.js';
5
- export { encodeProjectDir, legacyTranscriptPath, sessionUuidFor, transcriptPath, transcriptRoot } from './chunk-XESYJ4JC.js';
3
+ export { SessionBusyError, acquireSessionWriter, sessionHasWriter } from './chunk-QH6MWGOA.js';
4
+ import { transcriptRoot, encodeProjectDir } from './chunk-3VX7JHJI.js';
5
+ export { encodeProjectDir, legacyTranscriptPath, sessionUuidFor, transcriptPath, transcriptRoot } from './chunk-3VX7JHJI.js';
6
6
  export { sanitizeFts5Query } from './chunk-WE22OXQA.js';
7
- export { applyWalWithFallback, isCorruptionError, openSqliteResilient } from './chunk-MLJDW2YK.js';
8
- export { JsonlParseError, appendJsonl, loadJsonl, readJsonlIds } from './chunk-KU5O7WPK.js';
7
+ export { applyWalWithFallback, isCorruptionError, openSqliteResilient } from './chunk-YSGS57DA.js';
8
+ export { JsonlParseError, appendJsonl, loadJsonl, readJsonlIds } from './chunk-JD3EKKKB.js';
9
9
  export { withFileLock } from './chunk-FGGVSHDW.js';
10
10
  export { withCwdMutex } from './chunk-PPU2D4FZ.js';
11
- import { atomicWriteTempTarget } from './chunk-M4U24U6G.js';
12
- export { atomicWriteJson, atomicWriteTempTarget, atomicWriteText, replaceFileAtomic } from './chunk-M4U24U6G.js';
11
+ import { atomicWriteTempTarget } from './chunk-AZK3QM36.js';
12
+ export { atomicWriteJson, atomicWriteTempTarget, atomicWriteText, replaceFileAtomic } from './chunk-AZK3QM36.js';
13
13
  import { TheokitAgentError } from './chunk-TNFOU6SB.js';
14
14
  import './chunk-3OY6H3I7.js';
15
- import { createReadStream, readFileSync, openSync, writeSync, closeSync, fstatSync, readSync } from 'fs';
16
- import { readdir, stat } from 'fs/promises';
17
- import { join } from 'path';
15
+ import { createReadStream, readFileSync, openSync, writeSync, closeSync, fstatSync, readSync } from 'node:fs';
16
+ import { readdir, stat } from 'node:fs/promises';
17
+ import { join } from 'node:path';
18
18
 
19
19
  var DEFAULT_ID_SCAN_BYTES = 64 * 1024;
20
20
  async function listSessions(cwd, options = {}) {
package/dist/project.cjs CHANGED
@@ -1,17 +1,17 @@
1
1
  'use strict';
2
2
 
3
- var chunkSWALPLFQ_cjs = require('./chunk-SWALPLFQ.cjs');
4
- var chunkZOFRNNZD_cjs = require('./chunk-ZOFRNNZD.cjs');
3
+ var chunkRTCO3USA_cjs = require('./chunk-RTCO3USA.cjs');
4
+ var chunkIZV72OEI_cjs = require('./chunk-IZV72OEI.cjs');
5
5
  var chunkCEGU5AVD_cjs = require('./chunk-CEGU5AVD.cjs');
6
6
  require('./chunk-RNXXYF22.cjs');
7
- var promises = require('fs/promises');
8
- var path = require('path');
7
+ var promises = require('node:fs/promises');
8
+ var node_path = require('node:path');
9
9
 
10
10
  var DEFAULT_FILENAME = "THEO.md";
11
11
  async function readProjectInstructions(cwd, options) {
12
12
  const filename = options?.filename ?? DEFAULT_FILENAME;
13
13
  const scope = options?.scope ?? "nearest";
14
- const paths = chunkSWALPLFQ_cjs.walkUpForFile(cwd, filename, options?.stopDir);
14
+ const paths = chunkRTCO3USA_cjs.walkUpForFile(cwd, filename, options?.stopDir);
15
15
  const files = [];
16
16
  for (const path of paths) {
17
17
  try {
@@ -30,13 +30,13 @@ function reduceContent(files, scope) {
30
30
  }
31
31
  async function writeProjectInstructions(cwd, content, options) {
32
32
  const filename = options?.filename ?? DEFAULT_FILENAME;
33
- if (!chunkSWALPLFQ_cjs.isSafePattern(filename)) {
33
+ if (!chunkRTCO3USA_cjs.isSafePattern(filename)) {
34
34
  throw new chunkCEGU5AVD_cjs.ConfigurationError(
35
35
  `writeProjectInstructions: unsafe filename ${JSON.stringify(filename)} (no path traversal, separators, or absolute paths)`,
36
36
  { code: "unsafe_filename" }
37
37
  );
38
38
  }
39
- await chunkZOFRNNZD_cjs.replaceFileAtomic(path.join(cwd, filename), content);
39
+ await chunkIZV72OEI_cjs.replaceFileAtomic(node_path.join(cwd, filename), content);
40
40
  }
41
41
 
42
42
  exports.readProjectInstructions = readProjectInstructions;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/internal/runtime/context/project-instructions.ts"],"names":["walkUpForFile","readFile","isSafePattern","ConfigurationError","replaceFileAtomic","join"],"mappings":";;;;;;;;;AA8CA,IAAM,gBAAA,GAAmB,SAAA;AAiBzB,eAAsB,uBAAA,CACpB,KACA,OAAA,EAC8B;AAC9B,EAAA,MAAM,QAAA,GAAW,SAAS,QAAA,IAAY,gBAAA;AACtC,EAAA,MAAM,KAAA,GAAQ,SAAS,KAAA,IAAS,SAAA;AAChC,EAAA,MAAM,KAAA,GAAQA,+BAAA,CAAc,GAAA,EAAK,QAAA,EAAU,SAAS,OAAO,CAAA;AAE3D,EAAA,MAAM,QAAkC,EAAC;AACzC,EAAA,KAAA,MAAW,QAAQ,KAAA,EAAO;AACxB,IAAA,IAAI;AACF,MAAA,KAAA,CAAM,IAAA,CAAK,EAAE,IAAA,EAAM,OAAA,EAAS,MAAMC,iBAAA,CAAS,IAAA,EAAM,MAAM,CAAA,EAAG,CAAA;AAAA,IAC5D,CAAA,CAAA,MAAQ;AAAA,IAER;AAAA,EACF;AAEA,EAAA,OAAO,EAAE,KAAA,EAAO,OAAA,EAAS,aAAA,CAAc,KAAA,EAAO,KAAK,CAAA,EAAE;AACvD;AAEA,SAAS,aAAA,CACP,OACA,KAAA,EACoB;AACpB,EAAA,IAAI,KAAA,CAAM,MAAA,KAAW,CAAA,EAAG,OAAO,MAAA;AAC/B,EAAA,IAAI,UAAU,QAAA,EAAU;AACtB,IAAA,OAAO,CAAC,GAAG,KAAK,CAAA,CACb,OAAA,EAAQ,CACR,GAAA,CAAI,CAAC,CAAA,KAAM,CAAA,CAAE,OAAO,CAAA,CACpB,KAAK,MAAM,CAAA;AAAA,EAChB;AACA,EAAA,OAAO,KAAA,CAAM,CAAC,CAAA,EAAG,OAAA;AACnB;AAiBA,eAAsB,wBAAA,CACpB,GAAA,EACA,OAAA,EACA,OAAA,EACe;AACf,EAAA,MAAM,QAAA,GAAW,SAAS,QAAA,IAAY,gBAAA;AACtC,EAAA,IAAI,CAACC,+BAAA,CAAc,QAAQ,CAAA,EAAG;AAC5B,IAAA,MAAM,IAAIC,oCAAA;AAAA,MACR,CAAA,0CAAA,EAA6C,IAAA,CAAK,SAAA,CAAU,QAAQ,CAAC,CAAA,mDAAA,CAAA;AAAA,MACrE,EAAE,MAAM,iBAAA;AAAkB,KAC5B;AAAA,EACF;AACA,EAAA,MAAMC,mCAAA,CAAkBC,SAAA,CAAK,GAAA,EAAK,QAAQ,GAAG,OAAO,CAAA;AACtD","file":"project.cjs","sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\n\nimport { ConfigurationError } from \"../../../errors.js\";\nimport { replaceFileAtomic } from \"../../persistence/atomic-write.js\";\nimport { isSafePattern, walkUpForFile } from \"./context-discovery.js\";\n\n/** How discovered instruction files are reduced to a single `content` string. */\nexport type ProjectInstructionScope = \"nearest\" | \"merged\";\n\n/** One discovered project-instruction file. */\nexport interface ProjectInstructionFile {\n /** Absolute path to the file. */\n path: string;\n /** Full file content (never truncated — the caller bounds it). */\n content: string;\n}\n\n/** Result of {@link readProjectInstructions}. */\nexport interface ProjectInstructions {\n /** Found files, nearest-first (innermost directory first). Empty if none. */\n files: ProjectInstructionFile[];\n /**\n * The `scope`-selected reduction: `nearest` → the innermost file's content;\n * `merged` → all files joined root-first (nearest content last). `undefined`\n * when no file was found.\n */\n content: string | undefined;\n}\n\n/** Options for {@link readProjectInstructions}. */\nexport interface ReadProjectInstructionsOptions {\n /** Instruction filename to discover. Default `\"THEO.md\"`. */\n filename?: string;\n /** How to reduce the found files to `content`. Default `\"nearest\"`. */\n scope?: ProjectInstructionScope;\n /** Stop the upward walk at this directory (inclusive). Default: filesystem root. */\n stopDir?: string;\n}\n\n/** Options for {@link writeProjectInstructions}. */\nexport interface WriteProjectInstructionsOptions {\n /** Instruction filename to write. Default `\"THEO.md\"`. */\n filename?: string;\n}\n\nconst DEFAULT_FILENAME = \"THEO.md\";\n\n/**\n * Read hierarchical project instructions by walking up from `cwd`.\n *\n * Discovers every `<dir>/<filename>` from `cwd` up to the filesystem root (or\n * `stopDir`), reads each, and returns them nearest-first in `files` plus a\n * `content` reduction chosen by `scope`. Composes the hardened internal\n * `walkUpForFile` (64-level cap, realpath dedup, FS-race tolerant).\n *\n * NEVER throws: a missing/unreadable directory or a path that exists but is not\n * a readable file is skipped; no instruction file → `{ files: [], content: undefined }`.\n *\n * Public via `@theokit/sdk/project`.\n *\n * @public\n */\nexport async function readProjectInstructions(\n cwd: string,\n options?: ReadProjectInstructionsOptions,\n): Promise<ProjectInstructions> {\n const filename = options?.filename ?? DEFAULT_FILENAME;\n const scope = options?.scope ?? \"nearest\";\n const paths = walkUpForFile(cwd, filename, options?.stopDir);\n\n const files: ProjectInstructionFile[] = [];\n for (const path of paths) {\n try {\n files.push({ path, content: await readFile(path, \"utf8\") });\n } catch {\n // FS-race / unreadable / directory-named-like-file → skip (never-throw)\n }\n }\n\n return { files, content: reduceContent(files, scope) };\n}\n\nfunction reduceContent(\n files: ProjectInstructionFile[],\n scope: ProjectInstructionScope,\n): string | undefined {\n if (files.length === 0) return undefined;\n if (scope === \"merged\") {\n return [...files]\n .reverse()\n .map((f) => f.content)\n .join(\"\\n\\n\");\n }\n return files[0]?.content;\n}\n\n/**\n * Write project instructions to `<cwd>/<filename>` atomically (temp + fsync +\n * rename, via the shipped `replaceFileAtomic`).\n *\n * Unlike the reader, this FAILS LOUD: an unsafe `filename` (path traversal,\n * separators, absolute) is rejected with `ConfigurationError`\n * (`code: \"unsafe_filename\"`) — symmetric with the reader, whose `filename`\n * flows through the same `isSafePattern` guard — and a write error (e.g. the\n * parent directory does not exist) propagates to the caller. A failed mutation\n * is a real error, never silently swallowed.\n *\n * Public via `@theokit/sdk/project`.\n *\n * @public\n */\nexport async function writeProjectInstructions(\n cwd: string,\n content: string,\n options?: WriteProjectInstructionsOptions,\n): Promise<void> {\n const filename = options?.filename ?? DEFAULT_FILENAME;\n if (!isSafePattern(filename)) {\n throw new ConfigurationError(\n `writeProjectInstructions: unsafe filename ${JSON.stringify(filename)} (no path traversal, separators, or absolute paths)`,\n { code: \"unsafe_filename\" },\n );\n }\n await replaceFileAtomic(join(cwd, filename), content);\n}\n"]}
1
+ {"version":3,"sources":["../src/internal/runtime/context/project-instructions.ts"],"names":["walkUpForFile","readFile","isSafePattern","ConfigurationError","replaceFileAtomic","join"],"mappings":";;;;;;;;;AA8CA,IAAM,gBAAA,GAAmB,SAAA;AAiBzB,eAAsB,uBAAA,CACpB,KACA,OAAA,EAC8B;AAC9B,EAAA,MAAM,QAAA,GAAW,SAAS,QAAA,IAAY,gBAAA;AACtC,EAAA,MAAM,KAAA,GAAQ,SAAS,KAAA,IAAS,SAAA;AAChC,EAAA,MAA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file":"project.cjs","sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\n\nimport { ConfigurationError } from \"../../../errors.js\";\nimport { replaceFileAtomic } from \"../../persistence/atomic-write.js\";\nimport { isSafePattern, walkUpForFile } from \"./context-discovery.js\";\n\n/** How discovered instruction files are reduced to a single `content` string. */\nexport type ProjectInstructionScope = \"nearest\" | \"merged\";\n\n/** One discovered project-instruction file. */\nexport interface ProjectInstructionFile {\n /** Absolute path to the file. */\n path: string;\n /** Full file content (never truncated — the caller bounds it). */\n content: string;\n}\n\n/** Result of {@link readProjectInstructions}. */\nexport interface ProjectInstructions {\n /** Found files, nearest-first (innermost directory first). Empty if none. */\n files: ProjectInstructionFile[];\n /**\n * The `scope`-selected reduction: `nearest` → the innermost file's content;\n * `merged` → all files joined root-first (nearest content last). `undefined`\n * when no file was found.\n */\n content: string | undefined;\n}\n\n/** Options for {@link readProjectInstructions}. */\nexport interface ReadProjectInstructionsOptions {\n /** Instruction filename to discover. Default `\"THEO.md\"`. */\n filename?: string;\n /** How to reduce the found files to `content`. Default `\"nearest\"`. */\n scope?: ProjectInstructionScope;\n /** Stop the upward walk at this directory (inclusive). Default: filesystem root. */\n stopDir?: string;\n}\n\n/** Options for {@link writeProjectInstructions}. */\nexport interface WriteProjectInstructionsOptions {\n /** Instruction filename to write. Default `\"THEO.md\"`. */\n filename?: string;\n}\n\nconst DEFAULT_FILENAME = \"THEO.md\";\n\n/**\n * Read hierarchical project instructions by walking up from `cwd`.\n *\n * Discovers every `<dir>/<filename>` from `cwd` up to the filesystem root (or\n * `stopDir`), reads each, and returns them nearest-first in `files` plus a\n * `content` reduction chosen by `scope`. Composes the hardened internal\n * `walkUpForFile` (64-level cap, realpath dedup, FS-race tolerant).\n *\n * NEVER throws: a missing/unreadable directory or a path that exists but is not\n * a readable file is skipped; no instruction file → `{ files: [], content: undefined }`.\n *\n * Public via `@theokit/sdk/project`.\n *\n * @public\n */\nexport async function readProjectInstructions(\n cwd: string,\n options?: ReadProjectInstructionsOptions,\n): Promise<ProjectInstructions> {\n const filename = options?.filename ?? DEFAULT_FILENAME;\n const scope = options?.scope ?? \"nearest\";\n const paths = walkUpForFile(cwd, filename, options?.stopDir);\n\n const files: ProjectInstructionFile[] = [];\n for (const path of paths) {\n try {\n files.push({ path, content: await readFile(path, \"utf8\") });\n } catch {\n // FS-race / unreadable / directory-named-like-file → skip (never-throw)\n }\n }\n\n return { files, content: reduceContent(files, scope) };\n}\n\nfunction reduceContent(\n files: ProjectInstructionFile[],\n scope: ProjectInstructionScope,\n): string | undefined {\n if (files.length === 0) return undefined;\n if (scope === \"merged\") {\n return [...files]\n .reverse()\n .map((f) => f.content)\n .join(\"\\n\\n\");\n }\n return files[0]?.content;\n}\n\n/**\n * Write project instructions to `<cwd>/<filename>` atomically (temp + fsync +\n * rename, via the shipped `replaceFileAtomic`).\n *\n * Unlike the reader, this FAILS LOUD: an unsafe `filename` (path traversal,\n * separators, absolute) is rejected with `ConfigurationError`\n * (`code: \"unsafe_filename\"`) — symmetric with the reader, whose `filename`\n * flows through the same `isSafePattern` guard — and a write error (e.g. the\n * parent directory does not exist) propagates to the caller. A failed mutation\n * is a real error, never silently swallowed.\n *\n * Public via `@theokit/sdk/project`.\n *\n * @public\n */\nexport async function writeProjectInstructions(\n cwd: string,\n content: string,\n options?: WriteProjectInstructionsOptions,\n): Promise<void> {\n const filename = options?.filename ?? DEFAULT_FILENAME;\n if (!isSafePattern(filename)) {\n throw new ConfigurationError(\n `writeProjectInstructions: unsafe filename ${JSON.stringify(filename)} (no path traversal, separators, or absolute paths)`,\n { code: \"unsafe_filename\" },\n );\n }\n await replaceFileAtomic(join(cwd, filename), content);\n}\n"]}
package/dist/project.js CHANGED
@@ -1,9 +1,9 @@
1
- import { walkUpForFile, isSafePattern } from './chunk-4QCJAJAG.js';
2
- import { replaceFileAtomic } from './chunk-M4U24U6G.js';
1
+ import { walkUpForFile, isSafePattern } from './chunk-F54PXZIA.js';
2
+ import { replaceFileAtomic } from './chunk-AZK3QM36.js';
3
3
  import { ConfigurationError } from './chunk-TNFOU6SB.js';
4
4
  import './chunk-3OY6H3I7.js';
5
- import { readFile } from 'fs/promises';
6
- import { join } from 'path';
5
+ import { readFile } from 'node:fs/promises';
6
+ import { join } from 'node:path';
7
7
 
8
8
  var DEFAULT_FILENAME = "THEO.md";
9
9
  async function readProjectInstructions(cwd, options) {
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var chunkSPEN7RJU_cjs = require('./chunk-SPEN7RJU.cjs');
4
- require('./chunk-P7QYG4RZ.cjs');
3
+ var chunkEDIYR4VR_cjs = require('./chunk-EDIYR4VR.cjs');
4
+ require('./chunk-Z5MB2HAN.cjs');
5
5
  require('./chunk-NVXXWAU7.cjs');
6
- require('./chunk-A77UMVMD.cjs');
7
- require('./chunk-5645PMVU.cjs');
6
+ require('./chunk-UMCCYXFZ.cjs');
7
+ require('./chunk-PXYINWBC.cjs');
8
8
  require('./chunk-IOFMRS6T.cjs');
9
9
  require('./chunk-EHD25JBZ.cjs');
10
10
  require('./chunk-CEGU5AVD.cjs');
@@ -14,11 +14,11 @@ require('./chunk-RNXXYF22.cjs');
14
14
 
15
15
  Object.defineProperty(exports, "getProviderProfile", {
16
16
  enumerable: true,
17
- get: function () { return chunkSPEN7RJU_cjs.getProviderProfile; }
17
+ get: function () { return chunkEDIYR4VR_cjs.getProviderProfile; }
18
18
  });
19
19
  Object.defineProperty(exports, "listProviders", {
20
20
  enumerable: true,
21
- get: function () { return chunkSPEN7RJU_cjs.listProviders; }
21
+ get: function () { return chunkEDIYR4VR_cjs.listProviders; }
22
22
  });
23
23
  //# sourceMappingURL=providers.cjs.map
24
24
  //# sourceMappingURL=providers.cjs.map
package/dist/providers.js CHANGED
@@ -1,8 +1,8 @@
1
- export { getProviderProfile, listProviders } from './chunk-YKNBTHMD.js';
2
- import './chunk-RZL2W4C3.js';
1
+ export { getProviderProfile, listProviders } from './chunk-AQ23NII7.js';
2
+ import './chunk-5L7S2VOL.js';
3
3
  import './chunk-AGACYRJ2.js';
4
- import './chunk-3GTN4HOO.js';
5
- import './chunk-QD6B6W6I.js';
4
+ import './chunk-UNP4NCMZ.js';
5
+ import './chunk-L2KC2G7H.js';
6
6
  import './chunk-5IUDICRK.js';
7
7
  import './chunk-Q7GYMXVC.js';
8
8
  import './chunk-TNFOU6SB.js';