@theokit/sdk 4.63.4 → 5.0.0-next.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 (786) hide show
  1. package/CHANGELOG.md +847 -23
  2. package/dist/a2a/index.cjs +29 -13
  3. package/dist/a2a/index.cjs.map +1 -1
  4. package/dist/a2a/index.d.cts +1 -1
  5. package/dist/a2a/index.d.ts +1 -1
  6. package/dist/a2a/index.js +26 -11
  7. package/dist/a2a/index.js.map +1 -1
  8. package/dist/a2a/message-bus.d.cts +26 -3
  9. package/dist/a2a/message-bus.d.ts +26 -3
  10. package/dist/a2a/subagent.d.cts +8 -3
  11. package/dist/a2a/subagent.d.ts +8 -3
  12. package/dist/{agent-X0DKA943.d.cts → agent-C3KO5LKm.d.cts} +251 -36
  13. package/dist/{agent-BFno7Sfn.d.ts → agent-CvmTR9uf.d.ts} +251 -36
  14. package/dist/agent-GPV2JWZG.cjs +67 -0
  15. package/dist/{agent-UX7WFI6B.cjs.map → agent-GPV2JWZG.cjs.map} +1 -1
  16. package/dist/agent-Y24I5JBM.js +58 -0
  17. package/dist/{agent-A5XMIVNP.js.map → agent-Y24I5JBM.js.map} +1 -1
  18. package/dist/agent-session-store-AFML3AXC.js +6 -0
  19. package/dist/{agent-session-store-OPGRB4XM.js.map → agent-session-store-AFML3AXC.js.map} +1 -1
  20. package/dist/agent-session-store-MTSIY3MH.cjs +23 -0
  21. package/dist/{agent-session-store-6EL5NPA4.cjs.map → agent-session-store-MTSIY3MH.cjs.map} +1 -1
  22. package/dist/agent.d.ts +1 -1
  23. package/dist/auth/index.cjs +33 -34
  24. package/dist/auth/index.cjs.map +1 -1
  25. package/dist/auth/index.d.cts +1 -1
  26. package/dist/auth/index.d.ts +1 -1
  27. package/dist/auth/index.js +6 -7
  28. package/dist/auth/index.js.map +1 -1
  29. package/dist/{batch-BXYTW2DP.cjs → batch-I6T6MXZO.cjs} +58 -40
  30. package/dist/batch-I6T6MXZO.cjs.map +1 -0
  31. package/dist/{batch-L4ZXS46M.js → batch-US4F6WPK.js} +42 -24
  32. package/dist/batch-US4F6WPK.js.map +1 -0
  33. package/dist/chunk-24MGQDK3.js +31 -0
  34. package/dist/chunk-24MGQDK3.js.map +1 -0
  35. package/dist/{chunk-UGT7GK7I.cjs → chunk-24SYBZPL.cjs} +36 -18
  36. package/dist/chunk-24SYBZPL.cjs.map +1 -0
  37. package/dist/{chunk-KYAJINUI.cjs → chunk-2HPNT6HH.cjs} +581 -401
  38. package/dist/chunk-2HPNT6HH.cjs.map +1 -0
  39. package/dist/{chunk-VLVVJLDH.cjs → chunk-2NE7DTOK.cjs} +234 -193
  40. package/dist/chunk-2NE7DTOK.cjs.map +1 -0
  41. package/dist/{chunk-N2U4AZGB.js → chunk-2WXHA33T.js} +3 -3
  42. package/dist/chunk-2WXHA33T.js.map +1 -0
  43. package/dist/chunk-2XC6KDJM.js +22 -0
  44. package/dist/chunk-2XC6KDJM.js.map +1 -0
  45. package/dist/{chunk-L3MTL4NA.js → chunk-2ZLVT7H3.js} +223 -182
  46. package/dist/chunk-2ZLVT7H3.js.map +1 -0
  47. package/dist/{chunk-2GUYQR5P.js → chunk-3JHIFQ4I.js} +39 -13
  48. package/dist/chunk-3JHIFQ4I.js.map +1 -0
  49. package/dist/{chunk-BU4KFWXF.js → chunk-44I6UYVH.js} +8 -17
  50. package/dist/chunk-44I6UYVH.js.map +1 -0
  51. package/dist/{chunk-UNYXQ4M5.js → chunk-47TF32NQ.js} +10 -5
  52. package/dist/chunk-47TF32NQ.js.map +1 -0
  53. package/dist/{chunk-WNO3C3N2.cjs → chunk-4A3SKJ53.cjs} +56 -27
  54. package/dist/chunk-4A3SKJ53.cjs.map +1 -0
  55. package/dist/{chunk-YML4ME27.cjs → chunk-4HS6FFGL.cjs} +55 -46
  56. package/dist/chunk-4HS6FFGL.cjs.map +1 -0
  57. package/dist/{chunk-C72AZW7J.js → chunk-4MMWFSCD.js} +4 -4
  58. package/dist/chunk-4MMWFSCD.js.map +1 -0
  59. package/dist/{chunk-6HKGLTJI.cjs → chunk-4NLCWGH7.cjs} +15 -15
  60. package/dist/chunk-4NLCWGH7.cjs.map +1 -0
  61. package/dist/{chunk-LKBEROHN.js → chunk-4S5TWFIZ.js} +14 -14
  62. package/dist/chunk-4S5TWFIZ.js.map +1 -0
  63. package/dist/{chunk-UBDMVMBZ.js → chunk-55GB6JYQ.js} +33 -22
  64. package/dist/chunk-55GB6JYQ.js.map +1 -0
  65. package/dist/{chunk-U6IFHFWK.js → chunk-5WKQDIGO.js} +8 -17
  66. package/dist/chunk-5WKQDIGO.js.map +1 -0
  67. package/dist/chunk-67ADYSTW.js +120 -0
  68. package/dist/chunk-67ADYSTW.js.map +1 -0
  69. package/dist/{chunk-XL7Q7HB2.cjs → chunk-6LHQPOMI.cjs} +39 -6
  70. package/dist/chunk-6LHQPOMI.cjs.map +1 -0
  71. package/dist/{chunk-A4JVILQU.js → chunk-6M2OIS4Y.js} +7 -7
  72. package/dist/chunk-6M2OIS4Y.js.map +1 -0
  73. package/dist/{chunk-LWGSI6M3.js → chunk-6PWOWXMC.js} +4 -4
  74. package/dist/{chunk-LWGSI6M3.js.map → chunk-6PWOWXMC.js.map} +1 -1
  75. package/dist/{chunk-RNB4APBZ.js → chunk-6WAKKTBO.js} +9 -5
  76. package/dist/chunk-6WAKKTBO.js.map +1 -0
  77. package/dist/{chunk-V2BOS4WF.cjs → chunk-7A6535RA.cjs} +11 -11
  78. package/dist/chunk-7A6535RA.cjs.map +1 -0
  79. package/dist/{chunk-ZLQSWSJ2.cjs → chunk-7FDKWDA2.cjs} +11 -11
  80. package/dist/{chunk-ZLQSWSJ2.cjs.map → chunk-7FDKWDA2.cjs.map} +1 -1
  81. package/dist/{chunk-4VPXM6UU.js → chunk-7I5Z3UBJ.js} +3 -3
  82. package/dist/{chunk-4VPXM6UU.js.map → chunk-7I5Z3UBJ.js.map} +1 -1
  83. package/dist/{chunk-B4EOJWOY.cjs → chunk-7JJ3A6AT.cjs} +13 -7
  84. package/dist/chunk-7JJ3A6AT.cjs.map +1 -0
  85. package/dist/{chunk-WJVHMTKB.cjs → chunk-AA27GEYS.cjs} +3 -3
  86. package/dist/{chunk-WJVHMTKB.cjs.map → chunk-AA27GEYS.cjs.map} +1 -1
  87. package/dist/{chunk-BP46RJ5X.js → chunk-AAEZSPTC.js} +5 -5
  88. package/dist/{chunk-BP46RJ5X.js.map → chunk-AAEZSPTC.js.map} +1 -1
  89. package/dist/chunk-AGACYRJ2.js +11 -0
  90. package/dist/chunk-AGACYRJ2.js.map +1 -0
  91. package/dist/{chunk-ZZMZWBR6.js → chunk-ALUN2B4W.js} +81 -58
  92. package/dist/chunk-ALUN2B4W.js.map +1 -0
  93. package/dist/chunk-ANMJJD6D.cjs +18 -0
  94. package/dist/chunk-ANMJJD6D.cjs.map +1 -0
  95. package/dist/{chunk-DXGZ2NUG.cjs → chunk-ATT276RD.cjs} +12 -11
  96. package/dist/chunk-ATT276RD.cjs.map +1 -0
  97. package/dist/{chunk-4FFBAUFS.js → chunk-AWINL3ZC.js} +6 -6
  98. package/dist/chunk-AWINL3ZC.js.map +1 -0
  99. package/dist/{chunk-UU36SHFY.cjs → chunk-BJUJT5ED.cjs} +9 -8
  100. package/dist/chunk-BJUJT5ED.cjs.map +1 -0
  101. package/dist/{chunk-D4CUGAKZ.js → chunk-CZJ6Q7CW.js} +36 -6
  102. package/dist/chunk-CZJ6Q7CW.js.map +1 -0
  103. package/dist/{chunk-KQ7TS7WW.cjs → chunk-D6POWE7E.cjs} +37 -26
  104. package/dist/chunk-D6POWE7E.cjs.map +1 -0
  105. package/dist/{chunk-AWO27VRZ.js → chunk-DMRT67Y6.js} +6 -5
  106. package/dist/chunk-DMRT67Y6.js.map +1 -0
  107. package/dist/{chunk-5VB22SYX.cjs → chunk-DQZU7JK6.cjs} +7 -7
  108. package/dist/{chunk-5VB22SYX.cjs.map → chunk-DQZU7JK6.cjs.map} +1 -1
  109. package/dist/{chunk-3NSS2OIZ.cjs → chunk-DRL7URI4.cjs} +6 -6
  110. package/dist/{chunk-3NSS2OIZ.cjs.map → chunk-DRL7URI4.cjs.map} +1 -1
  111. package/dist/{chunk-RFXWMRFC.js → chunk-EFMFILPG.js} +14 -6
  112. package/dist/chunk-EFMFILPG.js.map +1 -0
  113. package/dist/{chunk-HS7AVXTF.js → chunk-EH6XD3FY.js} +4 -4
  114. package/dist/chunk-EH6XD3FY.js.map +1 -0
  115. package/dist/{chunk-KQRW2GPZ.js → chunk-EIQFAOFD.js} +6 -6
  116. package/dist/chunk-EIQFAOFD.js.map +1 -0
  117. package/dist/{chunk-XJCXEKMD.cjs → chunk-EXTRW7GW.cjs} +4 -4
  118. package/dist/chunk-EXTRW7GW.cjs.map +1 -0
  119. package/dist/{chunk-U54XCYG3.js → chunk-FJWQP6EE.js} +12 -6
  120. package/dist/chunk-FJWQP6EE.js.map +1 -0
  121. package/dist/{chunk-O7DK5PBJ.cjs → chunk-FUSDYC2B.cjs} +26 -42
  122. package/dist/chunk-FUSDYC2B.cjs.map +1 -0
  123. package/dist/{chunk-4QZSA2HJ.js → chunk-G7BLGBRN.js} +4 -4
  124. package/dist/chunk-G7BLGBRN.js.map +1 -0
  125. package/dist/{chunk-BZRFXJHA.js → chunk-GBCVPKHE.js} +55 -26
  126. package/dist/chunk-GBCVPKHE.js.map +1 -0
  127. package/dist/chunk-GGZ5GPE3.cjs +130 -0
  128. package/dist/chunk-GGZ5GPE3.cjs.map +1 -0
  129. package/dist/{chunk-5HEG4CQH.cjs → chunk-GZV6AVRL.cjs} +8 -8
  130. package/dist/{chunk-5HEG4CQH.cjs.map → chunk-GZV6AVRL.cjs.map} +1 -1
  131. package/dist/{chunk-VCLBZAZU.cjs → chunk-H6YM3PV6.cjs} +17 -17
  132. package/dist/chunk-H6YM3PV6.cjs.map +1 -0
  133. package/dist/{chunk-RFMBZPOW.cjs → chunk-HCT4HPCL.cjs} +10 -10
  134. package/dist/chunk-HCT4HPCL.cjs.map +1 -0
  135. package/dist/{chunk-OSEG74VJ.js → chunk-HFEJE7AC.js} +52 -43
  136. package/dist/chunk-HFEJE7AC.js.map +1 -0
  137. package/dist/{chunk-52NKC5HT.cjs → chunk-HUFSABUZ.cjs} +12 -8
  138. package/dist/chunk-HUFSABUZ.cjs.map +1 -0
  139. package/dist/{chunk-4CLOXP6H.cjs → chunk-HW7SEELD.cjs} +4 -4
  140. package/dist/{chunk-4CLOXP6H.cjs.map → chunk-HW7SEELD.cjs.map} +1 -1
  141. package/dist/{chunk-ZSWPZ23K.cjs → chunk-I2PWY7VM.cjs} +5 -5
  142. package/dist/chunk-I2PWY7VM.cjs.map +1 -0
  143. package/dist/{chunk-VJ26EKGJ.cjs → chunk-IJ7M6GOG.cjs} +3 -3
  144. package/dist/chunk-IJ7M6GOG.cjs.map +1 -0
  145. package/dist/{chunk-SAVIWMZB.js → chunk-ILGZ2ZZV.js} +3 -3
  146. package/dist/chunk-ILGZ2ZZV.js.map +1 -0
  147. package/dist/{chunk-4ZHTIJNE.cjs → chunk-J7J7J2GN.cjs} +87 -63
  148. package/dist/chunk-J7J7J2GN.cjs.map +1 -0
  149. package/dist/{chunk-UALX2J2Q.cjs → chunk-JLRLCBJ4.cjs} +38 -11
  150. package/dist/chunk-JLRLCBJ4.cjs.map +1 -0
  151. package/dist/{chunk-2QDYBS2A.js → chunk-JMDDYA22.js} +4 -4
  152. package/dist/chunk-JMDDYA22.js.map +1 -0
  153. package/dist/{chunk-LXQ6HKPS.js → chunk-JNAA4G4H.js} +3 -3
  154. package/dist/{chunk-LXQ6HKPS.js.map → chunk-JNAA4G4H.js.map} +1 -1
  155. package/dist/{chunk-UMP6OJIM.js → chunk-JOFVLOFY.js} +4 -4
  156. package/dist/{chunk-UMP6OJIM.js.map → chunk-JOFVLOFY.js.map} +1 -1
  157. package/dist/{chunk-A46SWMIF.js → chunk-K2VMFZQ5.js} +7 -7
  158. package/dist/chunk-K2VMFZQ5.js.map +1 -0
  159. package/dist/{chunk-DN2PACRI.js → chunk-K3NH62DG.js} +461 -282
  160. package/dist/chunk-K3NH62DG.js.map +1 -0
  161. package/dist/{chunk-LYTOXSRH.js → chunk-KDR53EO7.js} +1939 -1864
  162. package/dist/chunk-KDR53EO7.js.map +1 -0
  163. package/dist/{chunk-XWTLIGO3.cjs → chunk-KTTHHYEW.cjs} +5 -5
  164. package/dist/chunk-KTTHHYEW.cjs.map +1 -0
  165. package/dist/{chunk-3FFAEAUJ.cjs → chunk-KVSAY6NZ.cjs} +18 -18
  166. package/dist/chunk-KVSAY6NZ.cjs.map +1 -0
  167. package/dist/{chunk-IAHZCGBE.cjs → chunk-LHSWHYF3.cjs} +120 -146
  168. package/dist/chunk-LHSWHYF3.cjs.map +1 -0
  169. package/dist/{chunk-3OR54XG4.js → chunk-NJWYQWDL.js} +12 -8
  170. package/dist/chunk-NJWYQWDL.js.map +1 -0
  171. package/dist/chunk-NVXXWAU7.cjs +13 -0
  172. package/dist/chunk-NVXXWAU7.cjs.map +1 -0
  173. package/dist/{chunk-2D34UTDC.js → chunk-O6USDERH.js} +31 -11
  174. package/dist/chunk-O6USDERH.js.map +1 -0
  175. package/dist/{chunk-XO4SOZN6.js → chunk-OR6XIWLB.js} +4 -4
  176. package/dist/{chunk-XO4SOZN6.js.map → chunk-OR6XIWLB.js.map} +1 -1
  177. package/dist/{chunk-4PYZ5AX3.cjs → chunk-PRZ3BES7.cjs} +16 -8
  178. package/dist/chunk-PRZ3BES7.cjs.map +1 -0
  179. package/dist/{chunk-HCZD23VS.cjs → chunk-QC55H6RJ.cjs} +65 -39
  180. package/dist/chunk-QC55H6RJ.cjs.map +1 -0
  181. package/dist/{chunk-4O5TGQBW.cjs → chunk-QME6FDFG.cjs} +9 -5
  182. package/dist/chunk-QME6FDFG.cjs.map +1 -0
  183. package/dist/chunk-QOGNZMHD.cjs +34 -0
  184. package/dist/chunk-QOGNZMHD.cjs.map +1 -0
  185. package/dist/{chunk-7VT4P3Z4.cjs → chunk-QUAEOKDW.cjs} +1642 -1567
  186. package/dist/chunk-QUAEOKDW.cjs.map +1 -0
  187. package/dist/{chunk-B2J4ZMZL.cjs → chunk-QWD3CZWE.cjs} +6 -5
  188. package/dist/chunk-QWD3CZWE.cjs.map +1 -0
  189. package/dist/{chunk-SZVR77EJ.cjs → chunk-QWD4RDZ3.cjs} +15 -24
  190. package/dist/chunk-QWD4RDZ3.cjs.map +1 -0
  191. package/dist/{chunk-7BG5UH3T.cjs → chunk-RHZ6HP23.cjs} +4 -4
  192. package/dist/chunk-RHZ6HP23.cjs.map +1 -0
  193. package/dist/{chunk-2HVF2WJY.cjs → chunk-RQMCOFAI.cjs} +8 -8
  194. package/dist/{chunk-2HVF2WJY.cjs.map → chunk-RQMCOFAI.cjs.map} +1 -1
  195. package/dist/{chunk-VKJ7V7EB.cjs → chunk-SA6K24NB.cjs} +3 -3
  196. package/dist/chunk-SA6K24NB.cjs.map +1 -0
  197. package/dist/{chunk-7AD3ZTZL.js → chunk-SAGRF4IB.js} +3 -3
  198. package/dist/chunk-SAGRF4IB.js.map +1 -0
  199. package/dist/{chunk-PUAEFLYK.js → chunk-SVQIW5RJ.js} +4 -4
  200. package/dist/{chunk-PUAEFLYK.js.map → chunk-SVQIW5RJ.js.map} +1 -1
  201. package/dist/{chunk-43ZQRWAP.cjs → chunk-SYVWE64W.cjs} +22 -22
  202. package/dist/chunk-SYVWE64W.cjs.map +1 -0
  203. package/dist/{chunk-3O42QOMJ.js → chunk-TA3K7SBK.js} +7 -6
  204. package/dist/chunk-TA3K7SBK.js.map +1 -0
  205. package/dist/{chunk-LYRDF5TQ.cjs → chunk-TFG5IBZS.cjs} +14 -23
  206. package/dist/chunk-TFG5IBZS.cjs.map +1 -0
  207. package/dist/{chunk-GKEFRLU7.cjs → chunk-TMKTSYDS.cjs} +6 -6
  208. package/dist/{chunk-GKEFRLU7.cjs.map → chunk-TMKTSYDS.cjs.map} +1 -1
  209. package/dist/{chunk-J24VJOH3.cjs → chunk-UADQJBHR.cjs} +31 -11
  210. package/dist/chunk-UADQJBHR.cjs.map +1 -0
  211. package/dist/{chunk-TAZVKYWJ.js → chunk-UBR5PWD7.js} +26 -40
  212. package/dist/chunk-UBR5PWD7.js.map +1 -0
  213. package/dist/{chunk-IPYYKCRC.js → chunk-UFPUHJWS.js} +5 -5
  214. package/dist/{chunk-IPYYKCRC.js.map → chunk-UFPUHJWS.js.map} +1 -1
  215. package/dist/{chunk-OHLDPWTA.cjs → chunk-UGRS7ZA7.cjs} +15 -15
  216. package/dist/{chunk-OHLDPWTA.cjs.map → chunk-UGRS7ZA7.cjs.map} +1 -1
  217. package/dist/{chunk-RIAM53CP.js → chunk-UKMBRMGT.js} +3 -3
  218. package/dist/chunk-UKMBRMGT.js.map +1 -0
  219. package/dist/{chunk-L4BDVXIM.js → chunk-UNK4HNJH.js} +97 -123
  220. package/dist/chunk-UNK4HNJH.js.map +1 -0
  221. package/dist/{chunk-C3NT3PVE.js → chunk-V22DZIXO.js} +3 -3
  222. package/dist/chunk-V22DZIXO.js.map +1 -0
  223. package/dist/{chunk-OFRFZRQ4.cjs → chunk-V6ZY4AX6.cjs} +24 -14
  224. package/dist/chunk-V6ZY4AX6.cjs.map +1 -0
  225. package/dist/{chunk-B3IMEBOA.js → chunk-VE6DFSKU.js} +3 -3
  226. package/dist/{chunk-B3IMEBOA.js.map → chunk-VE6DFSKU.js.map} +1 -1
  227. package/dist/{chunk-WLQNMXQE.js → chunk-VWUXIVEI.js} +53 -26
  228. package/dist/chunk-VWUXIVEI.js.map +1 -0
  229. package/dist/{chunk-GMLBYDW4.cjs → chunk-VXDEKILY.cjs} +108 -109
  230. package/dist/chunk-VXDEKILY.cjs.map +1 -0
  231. package/dist/{chunk-ACDLHN3W.js → chunk-WJXOICRC.js} +16 -6
  232. package/dist/chunk-WJXOICRC.js.map +1 -0
  233. package/dist/{chunk-7YGCPMGB.js → chunk-XB4GI5RZ.js} +27 -12
  234. package/dist/chunk-XB4GI5RZ.js.map +1 -0
  235. package/dist/{chunk-O73J46PV.js → chunk-XDANGA2C.js} +5 -5
  236. package/dist/{chunk-O73J46PV.js.map → chunk-XDANGA2C.js.map} +1 -1
  237. package/dist/{chunk-NDGGJQTZ.js → chunk-XJZEBGXD.js} +10 -10
  238. package/dist/chunk-XJZEBGXD.js.map +1 -0
  239. package/dist/{chunk-UTSRIDKZ.js → chunk-XYFGKVZ7.js} +3 -3
  240. package/dist/chunk-XYFGKVZ7.js.map +1 -0
  241. package/dist/{chunk-RMWTPV3M.cjs → chunk-Y2KYR2ED.cjs} +27 -27
  242. package/dist/chunk-Y2KYR2ED.cjs.map +1 -0
  243. package/dist/{chunk-O7LZFG6O.cjs → chunk-YIFFF23U.cjs} +5 -5
  244. package/dist/chunk-YIFFF23U.cjs.map +1 -0
  245. package/dist/{chunk-4OTIXDMU.cjs → chunk-YJNYDJ2T.cjs} +12 -4
  246. package/dist/chunk-YJNYDJ2T.cjs.map +1 -0
  247. package/dist/{chunk-6JSIEDKL.cjs → chunk-YSTXFWQE.cjs} +13 -7
  248. package/dist/chunk-YSTXFWQE.cjs.map +1 -0
  249. package/dist/{chunk-I6HGWHPU.cjs → chunk-Z3NTRKIC.cjs} +4 -4
  250. package/dist/{chunk-I6HGWHPU.cjs.map → chunk-Z3NTRKIC.cjs.map} +1 -1
  251. package/dist/{chunk-32WTYBUH.js → chunk-ZH26RNQA.js} +91 -92
  252. package/dist/chunk-ZH26RNQA.js.map +1 -0
  253. package/dist/compact-session-BHTPCIHA.cjs +61 -0
  254. package/dist/{compact-session-QV57KR66.cjs.map → compact-session-BHTPCIHA.cjs.map} +1 -1
  255. package/dist/compact-session-W4WLJTHA.js +24 -0
  256. package/dist/{compact-session-RIGOWC4Y.js.map → compact-session-W4WLJTHA.js.map} +1 -1
  257. package/dist/compaction.cjs +20 -17
  258. package/dist/compaction.d.cts +15 -1
  259. package/dist/compaction.d.ts +15 -1
  260. package/dist/compaction.js +3 -4
  261. package/dist/concurrency.cjs +6 -7
  262. package/dist/concurrency.cjs.map +1 -1
  263. package/dist/concurrency.d.cts +6 -3
  264. package/dist/concurrency.d.ts +6 -3
  265. package/dist/concurrency.js +4 -5
  266. package/dist/concurrency.js.map +1 -1
  267. package/dist/context/index.cjs +6 -6
  268. package/dist/context/index.js +3 -3
  269. package/dist/context-NI33FS2R.cjs +23 -0
  270. package/dist/{context-WFLTTMK3.cjs.map → context-NI33FS2R.cjs.map} +1 -1
  271. package/dist/context-Y7B7SI5X.js +6 -0
  272. package/dist/{context-WI2DFG7V.js.map → context-Y7B7SI5X.js.map} +1 -1
  273. package/dist/create-skill.d.ts +4 -1
  274. package/dist/{cron-BuiRPrvt.d.cts → cron-C3PhZED0.d.cts} +8 -2
  275. package/dist/{cron-C2SIi31n.d.ts → cron-crfMMdAw.d.ts} +8 -2
  276. package/dist/cron.cjs +46 -45
  277. package/dist/cron.d.cts +5 -4
  278. package/dist/cron.d.ts +5 -4
  279. package/dist/cron.js +45 -44
  280. package/dist/{errors-BgJH9PHi.d.cts → errors-CLOAyuiv.d.ts} +133 -95
  281. package/dist/{errors-C5fJUqLk.d.ts → errors-DrDEgyz1.d.cts} +133 -95
  282. package/dist/errors-base-B5g01neU.d.cts +75 -0
  283. package/dist/errors-base-B5g01neU.d.ts +75 -0
  284. package/dist/errors-base.d.ts +73 -0
  285. package/dist/errors.cjs +25 -22
  286. package/dist/errors.d.cts +3 -2
  287. package/dist/errors.d.ts +3 -2
  288. package/dist/errors.js +2 -3
  289. package/dist/eval.cjs +74 -78
  290. package/dist/eval.cjs.map +1 -1
  291. package/dist/eval.js +64 -68
  292. package/dist/eval.js.map +1 -1
  293. package/dist/{executor-6CYCA7MI.cjs → executor-XQAOQOHD.cjs} +60 -54
  294. package/dist/executor-XQAOQOHD.cjs.map +1 -0
  295. package/dist/{executor-QSEC3MRH.js → executor-ZNDQDX6Q.js} +43 -37
  296. package/dist/executor-ZNDQDX6Q.js.map +1 -0
  297. package/dist/filesystem/index.cjs +24 -26
  298. package/dist/filesystem/index.cjs.map +1 -1
  299. package/dist/filesystem/index.js +20 -22
  300. package/dist/filesystem/index.js.map +1 -1
  301. package/dist/filesystem/types.d.cts +11 -5
  302. package/dist/filesystem/types.d.ts +11 -5
  303. package/dist/{fork-agent-RSV4E3EA.js → fork-agent-S2EPIML7.js} +3 -3
  304. package/dist/fork-agent-S2EPIML7.js.map +1 -0
  305. package/dist/{fork-agent-Y2IK2RYU.cjs → fork-agent-WAEQI2DL.cjs} +4 -4
  306. package/dist/fork-agent-WAEQI2DL.cjs.map +1 -0
  307. package/dist/fs-session-store-77JU46UZ.js +10 -0
  308. package/dist/{fs-session-store-NM6YSTE2.js.map → fs-session-store-77JU46UZ.js.map} +1 -1
  309. package/dist/fs-session-store-E4U3P56L.cjs +19 -0
  310. package/dist/{fs-session-store-4PIHT5UX.cjs.map → fs-session-store-E4U3P56L.cjs.map} +1 -1
  311. package/dist/generate-object-BXV7BZRP.js +7 -0
  312. package/dist/{generate-object-GUNAUVBX.js.map → generate-object-BXV7BZRP.js.map} +1 -1
  313. package/dist/generate-object-YBI2TDJ3.cjs +20 -0
  314. package/dist/{generate-object-R7HTMW7F.cjs.map → generate-object-YBI2TDJ3.cjs.map} +1 -1
  315. package/dist/generate-object.d.ts +2 -4
  316. package/dist/index-manager-DXR2RSFI.cjs +26 -0
  317. package/dist/{index-manager-2SRX45WJ.cjs.map → index-manager-DXR2RSFI.cjs.map} +1 -1
  318. package/dist/index-manager-QH6OXEV5.js +17 -0
  319. package/dist/{index-manager-SP4ISSDX.js.map → index-manager-QH6OXEV5.js.map} +1 -1
  320. package/dist/index.cjs +234 -194
  321. package/dist/index.cjs.map +1 -1
  322. package/dist/index.d.cts +243 -41
  323. package/dist/index.d.ts +243 -41
  324. package/dist/index.js +140 -102
  325. package/dist/index.js.map +1 -1
  326. package/dist/{inject-session-DAR7OUCW.js → inject-session-SUM6TDJF.js} +9 -9
  327. package/dist/{inject-session-DAR7OUCW.js.map → inject-session-SUM6TDJF.js.map} +1 -1
  328. package/dist/inject-session-W6A46J3E.cjs +29 -0
  329. package/dist/{inject-session-WQKMC3GR.cjs.map → inject-session-W6A46J3E.cjs.map} +1 -1
  330. package/dist/interactive/index.cjs +12 -6
  331. package/dist/interactive/index.cjs.map +1 -1
  332. package/dist/interactive/index.js +12 -6
  333. package/dist/interactive/index.js.map +1 -1
  334. package/dist/interactive/types.d.cts +14 -4
  335. package/dist/interactive/types.d.ts +14 -4
  336. package/dist/internal/agent-loop/loop-context-init.d.ts +1 -1
  337. package/dist/internal/agent-loop/loop-finalize.d.ts +25 -0
  338. package/dist/internal/agent-loop/loop.d.ts +1 -1
  339. package/dist/internal/agent-loop/message-builders.d.ts +1 -1
  340. package/dist/internal/agent-loop/tool-dispatch.d.ts +2 -2
  341. package/dist/internal/agent-loop/usage-and-cost.d.ts +1 -1
  342. package/dist/internal/auth/credential-availability.d.ts +61 -0
  343. package/dist/internal/auth/credential-store.d.ts +1 -1
  344. package/dist/internal/auth/oauth-device.d.ts +1 -1
  345. package/dist/internal/auth/oauth-engine.d.ts +1 -1
  346. package/dist/internal/auth/resolve-credential.d.ts +1 -1
  347. package/dist/internal/base-url.d.ts +14 -0
  348. package/dist/internal/cloud-agent/cloud-config-serializer.d.ts +1 -1
  349. package/dist/internal/{runtime/concurrency → concurrency}/subagent-credentials.d.ts +2 -2
  350. package/dist/internal/emit-run-event.d.ts +16 -0
  351. package/dist/internal/error-mappers/shared.d.ts +14 -1
  352. package/dist/internal/eval/assert.d.ts +2 -1
  353. package/dist/internal/eval/single-flight.d.ts +2 -1
  354. package/dist/internal/global-singleton.d.ts +6 -3
  355. package/dist/internal/llm/responses.d.ts +10 -0
  356. package/dist/internal/local-agent/local-agent-bootstrap.d.ts +5 -3
  357. package/dist/internal/local-agent/local-agent-capabilities.d.ts +38 -0
  358. package/dist/internal/local-agent/local-agent-dispatch.d.ts +2 -2
  359. package/dist/internal/local-agent/local-agent-memory-provider.d.ts +1 -1
  360. package/dist/internal/local-agent/local-agent-personality-extensions.d.ts +25 -1
  361. package/dist/internal/local-agent/local-agent-send.d.ts +42 -1
  362. package/dist/internal/local-agent/real-local-run-mcp.d.ts +26 -0
  363. package/dist/internal/local-agent/real-local-run-options.d.ts +26 -0
  364. package/dist/internal/local-agent/real-local-run-tools.d.ts +21 -4
  365. package/dist/internal/local-agent/real-local-run.d.ts +2 -2
  366. package/dist/internal/mcp/handshake-timeout.d.ts +53 -0
  367. package/dist/internal/memory/active-memory.d.ts +1 -1
  368. package/dist/internal/memory/adapters/index.cjs +10 -10
  369. package/dist/internal/memory/adapters/index.js +9 -9
  370. package/dist/internal/memory/adapters/openai-embedding.d.cts +10 -0
  371. package/dist/internal/memory/adapters/openai-embedding.d.ts +10 -0
  372. package/dist/internal/memory/corpus-sync.d.ts +23 -0
  373. package/dist/internal/memory/index-db.d.ts +15 -1
  374. package/dist/internal/memory/index-manager-contract.d.ts +12 -0
  375. package/dist/internal/memory/index-manager.d.ts +4 -10
  376. package/dist/internal/memory/index-repository.d.ts +58 -0
  377. package/dist/internal/memory/lance-memory-adapter.d.ts +16 -14
  378. package/dist/internal/memory/memory-index.d.ts +15 -0
  379. package/dist/internal/memory/sdk-memory-peer-loader.d.ts +54 -1
  380. package/dist/internal/memory/storage/index.cjs +39 -40
  381. package/dist/internal/memory/storage/index.js +10 -11
  382. package/dist/internal/memory/storage/memory-root.d.cts +2 -3
  383. package/dist/internal/memory/storage/memory-root.d.ts +2 -3
  384. package/dist/internal/persistence/atomic-write.d.cts +4 -4
  385. package/dist/internal/persistence/atomic-write.d.ts +4 -4
  386. package/dist/internal/persistence/index.cjs +24 -25
  387. package/dist/internal/persistence/index.cjs.map +1 -1
  388. package/dist/internal/persistence/index.js +7 -8
  389. package/dist/internal/persistence/index.js.map +1 -1
  390. package/dist/internal/persistence/jsonl.d.cts +3 -1
  391. package/dist/internal/persistence/jsonl.d.ts +3 -1
  392. package/dist/internal/persistence/paths.d.cts +25 -12
  393. package/dist/internal/persistence/paths.d.ts +25 -12
  394. package/dist/internal/persistence/transcript-ops.d.cts +11 -2
  395. package/dist/internal/persistence/transcript-ops.d.ts +11 -2
  396. package/dist/internal/plugins/context.d.cts +0 -10
  397. package/dist/internal/plugins/context.d.ts +0 -10
  398. package/dist/internal/plugins/types.d.cts +1 -1
  399. package/dist/internal/plugins/types.d.ts +1 -1
  400. package/dist/internal/providers/catalog-schema.d.ts +94 -0
  401. package/dist/internal/providers/catalog-source-models-dev.d.ts +11 -0
  402. package/dist/internal/runtime/compat/compat-config-file.d.ts +31 -0
  403. package/dist/internal/runtime/compat/foreign-config-sources.d.ts +58 -34
  404. package/dist/internal/runtime/compression/compression-model-registry.d.ts +1 -1
  405. package/dist/internal/runtime/compression/compression-summarizer.d.ts +5 -1
  406. package/dist/internal/runtime/fixtures/fixture-events.d.ts +1 -1
  407. package/dist/internal/runtime/fixtures/fixture-mode.d.ts +8 -14
  408. package/dist/internal/runtime/fixtures/fixture-run-base.d.ts +1 -1
  409. package/dist/internal/runtime/fixtures/fixture-scripts.d.ts +2 -2
  410. package/dist/internal/runtime/hooks/hooks-executor.d.ts +6 -1
  411. package/dist/internal/runtime/lifecycle/wrap-completion-check-run.d.ts +1 -1
  412. package/dist/internal/runtime/{memory → memory-glue}/memory-provider.d.ts +1 -1
  413. package/dist/internal/runtime/{plugins → plugin-loader}/plugin-bundles.d.ts +4 -1
  414. package/dist/internal/runtime/processors/wrap-output-run.d.ts +1 -1
  415. package/dist/internal/runtime/registry/live-agent-registry.d.ts +9 -1
  416. package/dist/internal/runtime/system-prompt/local-assembly.d.ts +2 -1
  417. package/dist/internal/scorers/llm-judge.d.ts +12 -0
  418. package/dist/internal/security/index.cjs +14 -15
  419. package/dist/internal/security/index.d.cts +6 -1
  420. package/dist/internal/security/index.d.ts +6 -1
  421. package/dist/internal/security/index.js +4 -5
  422. package/dist/internal/security/path-containment.d.ts +24 -0
  423. package/dist/internal/session/agent-session-store.d.ts +1 -1
  424. package/dist/internal/session/agent-session.d.ts +1 -1
  425. package/dist/internal/session/index.d.ts +1 -1
  426. package/dist/internal/session/session-cache.d.ts +9 -3
  427. package/dist/internal/task/registry.d.ts +1 -1
  428. package/dist/internal/task/store.d.ts +1 -1
  429. package/dist/internal/task/subscribe.d.ts +1 -1
  430. package/dist/internal/task/task-id.d.ts +22 -0
  431. package/dist/internal/telemetry/adapter-registry.d.ts +12 -2
  432. package/dist/internal/telemetry/adapters/braintrust.d.ts +6 -1
  433. package/dist/internal/telemetry/adapters/langsmith.d.ts +6 -1
  434. package/dist/internal/workflow/executor.d.ts +2 -1
  435. package/dist/internal/workflow/snapshot-store.d.ts +1 -1
  436. package/dist/internal/workflow/step-branch.d.ts +2 -2
  437. package/dist/internal/workflow/step-dowhile.d.ts +2 -2
  438. package/dist/internal/workflow/step-execution.d.ts +25 -0
  439. package/dist/internal/workflow/step-foreach.d.ts +2 -2
  440. package/dist/internal/workflow/step-parallel.d.ts +2 -2
  441. package/dist/judge-call-6MVARKU2.js +5 -0
  442. package/dist/{judge-call-LVXABPS3.js.map → judge-call-6MVARKU2.js.map} +1 -1
  443. package/dist/judge-call-I3P4D5QR.cjs +22 -0
  444. package/dist/{judge-call-LAHMBJ57.cjs.map → judge-call-I3P4D5QR.cjs.map} +1 -1
  445. package/dist/mcp-auth.cjs +14 -15
  446. package/dist/mcp-auth.cjs.map +1 -1
  447. package/dist/mcp-auth.d.cts +2 -0
  448. package/dist/mcp-auth.d.ts +2 -0
  449. package/dist/mcp-auth.js +4 -5
  450. package/dist/mcp-auth.js.map +1 -1
  451. package/dist/models.cjs +52 -42
  452. package/dist/models.cjs.map +1 -1
  453. package/dist/models.js +39 -29
  454. package/dist/models.js.map +1 -1
  455. package/dist/oauth-transaction-store-5RIR6D5C.js +5 -0
  456. package/dist/{oauth-transaction-store-W52KVHQ4.js.map → oauth-transaction-store-5RIR6D5C.js.map} +1 -1
  457. package/dist/oauth-transaction-store-SXIE57OD.cjs +38 -0
  458. package/dist/{oauth-transaction-store-BT4GLTLK.cjs.map → oauth-transaction-store-SXIE57OD.cjs.map} +1 -1
  459. package/dist/path-safety.cjs +11 -12
  460. package/dist/path-safety.d.cts +2 -0
  461. package/dist/path-safety.d.ts +2 -0
  462. package/dist/path-safety.js +4 -5
  463. package/dist/permission-engine.d.ts +10 -17
  464. package/dist/persistence.cjs +31 -31
  465. package/dist/persistence.cjs.map +1 -1
  466. package/dist/persistence.d.cts +9 -1
  467. package/dist/persistence.d.ts +9 -1
  468. package/dist/persistence.js +12 -13
  469. package/dist/persistence.js.map +1 -1
  470. package/dist/project.cjs +5 -6
  471. package/dist/project.cjs.map +1 -1
  472. package/dist/project.js +3 -4
  473. package/dist/project.js.map +1 -1
  474. package/dist/providers.cjs +10 -10
  475. package/dist/providers.d.cts +2 -0
  476. package/dist/providers.d.ts +2 -0
  477. package/dist/providers.js +8 -8
  478. package/dist/registry-BZQFYRTL.cjs +46 -0
  479. package/dist/{registry-V7BDQ6QB.cjs.map → registry-BZQFYRTL.cjs.map} +1 -1
  480. package/dist/registry-DMWCJKRF.js +9 -0
  481. package/dist/{registry-75W33OGL.js.map → registry-DMWCJKRF.js.map} +1 -1
  482. package/dist/retry.cjs +4 -5
  483. package/dist/retry.d.cts +20 -5
  484. package/dist/retry.d.ts +20 -5
  485. package/dist/retry.js +3 -4
  486. package/dist/{run-BYSHf58D.d.ts → run-CTAdRU3U.d.cts} +120 -152
  487. package/dist/{run-BYSHf58D.d.cts → run-CTAdRU3U.d.ts} +120 -152
  488. package/dist/{run-until-HEQOUVU6.js → run-until-6D6TQ4JN.js} +27 -59
  489. package/dist/run-until-6D6TQ4JN.js.map +1 -0
  490. package/dist/{run-until-U2B5FJJI.cjs → run-until-DG2KXWB2.cjs} +27 -59
  491. package/dist/run-until-DG2KXWB2.cjs.map +1 -0
  492. package/dist/sandbox/bwrap.d.cts +11 -1
  493. package/dist/sandbox/bwrap.d.ts +11 -1
  494. package/dist/sandbox/index.cjs +26 -30
  495. package/dist/sandbox/index.cjs.map +1 -1
  496. package/dist/sandbox/index.d.cts +8 -1
  497. package/dist/sandbox/index.d.ts +8 -1
  498. package/dist/sandbox/index.js +10 -14
  499. package/dist/sandbox/index.js.map +1 -1
  500. package/dist/sandbox/linux-sandbox.d.cts +20 -4
  501. package/dist/sandbox/linux-sandbox.d.ts +20 -4
  502. package/dist/sandbox/types.d.cts +18 -2
  503. package/dist/sandbox/types.d.ts +18 -2
  504. package/dist/sanitize/index.cjs +2 -2
  505. package/dist/sanitize/index.js +1 -1
  506. package/dist/sanitize/types.d.cts +15 -2
  507. package/dist/sanitize/types.d.ts +15 -2
  508. package/dist/{sdk-agent-D8qJVkuV.d.ts → sdk-agent-BOiKqOgL.d.cts} +197 -117
  509. package/dist/{sdk-agent-DEoKhA8a.d.cts → sdk-agent-D4a_BR_6.d.ts} +197 -117
  510. package/dist/server/auth/errors.d.cts +4 -3
  511. package/dist/server/auth/errors.d.ts +4 -3
  512. package/dist/server/auth/index.cjs +28 -28
  513. package/dist/server/auth/index.cjs.map +1 -1
  514. package/dist/server/auth/index.d.cts +28 -5
  515. package/dist/server/auth/index.d.ts +28 -5
  516. package/dist/server/auth/index.js +13 -13
  517. package/dist/server/auth/index.js.map +1 -1
  518. package/dist/server/auth/oauth-transaction-store.d.cts +2 -1
  519. package/dist/server/auth/oauth-transaction-store.d.ts +2 -1
  520. package/dist/server/auth/orchestrator.d.cts +4 -1
  521. package/dist/server/auth/orchestrator.d.ts +4 -1
  522. package/dist/server/auth/types.d.cts +18 -0
  523. package/dist/server/auth/types.d.ts +18 -0
  524. package/dist/server/errors-envelope.cjs +14 -15
  525. package/dist/server/errors-envelope.cjs.map +1 -1
  526. package/dist/server/errors-envelope.d.cts +3 -3
  527. package/dist/server/errors-envelope.d.ts +3 -3
  528. package/dist/server/errors-envelope.js +3 -4
  529. package/dist/server/errors-envelope.js.map +1 -1
  530. package/dist/session-transcript-LGHSNVY5.cjs +62 -0
  531. package/dist/{session-transcript-6WNITKRE.cjs.map → session-transcript-LGHSNVY5.cjs.map} +1 -1
  532. package/dist/session-transcript-VTBTCGQX.js +5 -0
  533. package/dist/{session-transcript-XAEKW6P7.js.map → session-transcript-VTBTCGQX.js.map} +1 -1
  534. package/dist/skills.cjs +8 -9
  535. package/dist/skills.js +6 -7
  536. package/dist/stream-object-HBFMIZLD.js +7 -0
  537. package/dist/{stream-object-UF4QRQRU.js.map → stream-object-HBFMIZLD.js.map} +1 -1
  538. package/dist/stream-object-QSKHISDJ.cjs +20 -0
  539. package/dist/{stream-object-ZJTQNKY3.cjs.map → stream-object-QSKHISDJ.cjs.map} +1 -1
  540. package/dist/stream-object.d.ts +2 -4
  541. package/dist/subagents-loader-TPZLTXYZ.cjs +16 -0
  542. package/dist/{subagents-loader-UCNO7FUH.cjs.map → subagents-loader-TPZLTXYZ.cjs.map} +1 -1
  543. package/dist/subagents-loader-Y6JFYXAY.js +7 -0
  544. package/dist/{subagents-loader-XP5ERVDZ.js.map → subagents-loader-Y6JFYXAY.js.map} +1 -1
  545. package/dist/subagents-loader.cjs +7 -8
  546. package/dist/subagents-loader.cjs.map +1 -1
  547. package/dist/subagents-loader.d.cts +5 -3
  548. package/dist/subagents-loader.d.ts +5 -3
  549. package/dist/subagents-loader.js +5 -6
  550. package/dist/subagents-loader.js.map +1 -1
  551. package/dist/subagents.cjs +2 -2
  552. package/dist/subagents.cjs.map +1 -1
  553. package/dist/subagents.js +1 -1
  554. package/dist/subagents.js.map +1 -1
  555. package/dist/subscription/define-subscription.d.cts +4 -1
  556. package/dist/subscription/define-subscription.d.ts +4 -1
  557. package/dist/subscription/index.cjs +4 -5
  558. package/dist/subscription/index.cjs.map +1 -1
  559. package/dist/subscription/index.d.cts +2 -0
  560. package/dist/subscription/index.d.ts +2 -0
  561. package/dist/subscription/index.js +3 -4
  562. package/dist/subscription/index.js.map +1 -1
  563. package/dist/subscription/internal/server-integration.d.cts +5 -0
  564. package/dist/subscription/internal/server-integration.d.ts +5 -0
  565. package/dist/subscription/internal/subscription-runtime.d.cts +13 -1
  566. package/dist/subscription/internal/subscription-runtime.d.ts +13 -1
  567. package/dist/task-errors.d.ts +58 -0
  568. package/dist/task-store.cjs +7 -8
  569. package/dist/task-store.d.cts +2 -0
  570. package/dist/task-store.d.ts +2 -0
  571. package/dist/task-store.js +4 -5
  572. package/dist/types/agent-prims.d.ts +21 -0
  573. package/dist/types/agent.d.ts +109 -15
  574. package/dist/types/batch.d.ts +3 -0
  575. package/dist/types/budget-tracker.d.ts +3 -0
  576. package/dist/types/budget.d.ts +12 -3
  577. package/dist/types/content-blocks.d.ts +3 -0
  578. package/dist/types/context.d.ts +3 -0
  579. package/dist/types/conversation.d.ts +5 -0
  580. package/dist/types/cron.d.ts +5 -0
  581. package/dist/types/env-policy.d.ts +3 -0
  582. package/dist/types/eval.d.ts +3 -0
  583. package/dist/types/fork.d.ts +3 -0
  584. package/dist/types/goal-events.d.ts +3 -0
  585. package/dist/types/mcp.d.ts +5 -0
  586. package/dist/types/memory-adapter.d.ts +3 -0
  587. package/dist/types/memory-provider.d.ts +44 -5
  588. package/dist/types/messages-base.d.ts +4 -0
  589. package/dist/types/messages.d.ts +5 -0
  590. package/dist/types/plugin.d.ts +32 -4
  591. package/dist/types/processors.d.ts +3 -0
  592. package/dist/types/provider-profile.d.ts +3 -0
  593. package/dist/types/providers.d.ts +3 -0
  594. package/dist/types/run-events.d.ts +36 -9
  595. package/dist/types/run.d.ts +29 -2
  596. package/dist/types/sdk-agent.d.ts +71 -1
  597. package/dist/types/session-message.d.ts +3 -0
  598. package/dist/types/session-record.d.ts +3 -0
  599. package/dist/types/session-store.d.ts +45 -0
  600. package/dist/types/task.d.ts +3 -11
  601. package/dist/types/theokit.d.ts +3 -0
  602. package/dist/types/trajectory.d.ts +3 -0
  603. package/dist/types/updates.d.ts +5 -0
  604. package/dist/types/usage.d.ts +4 -1
  605. package/dist/types/workflow.d.ts +13 -135
  606. package/dist/workflow-as-tool.d.ts +66 -0
  607. package/dist/workflow-errors.d.ts +164 -0
  608. package/dist/workflow.cjs +29 -30
  609. package/dist/workflow.d.cts +135 -74
  610. package/dist/workflow.d.ts +135 -74
  611. package/dist/workflow.js +8 -9
  612. package/docs/adr/README.md +2604 -0
  613. package/docs/error-codes.md +139 -105
  614. package/docs/harness-capability-map.md +32 -20
  615. package/docs/memory-decisions.md +1 -1
  616. package/package.json +3 -7
  617. package/bin/theokit-migrate-config.mjs +0 -278
  618. package/bin/theokit-migrate-memory.mjs +0 -116
  619. package/dist/agent-A5XMIVNP.js +0 -57
  620. package/dist/agent-UX7WFI6B.cjs +0 -66
  621. package/dist/agent-session-store-6EL5NPA4.cjs +0 -24
  622. package/dist/agent-session-store-OPGRB4XM.js +0 -7
  623. package/dist/batch-BXYTW2DP.cjs.map +0 -1
  624. package/dist/batch-L4ZXS46M.js.map +0 -1
  625. package/dist/chunk-247ZTLNU.js +0 -73
  626. package/dist/chunk-247ZTLNU.js.map +0 -1
  627. package/dist/chunk-2D34UTDC.js.map +0 -1
  628. package/dist/chunk-2GUYQR5P.js.map +0 -1
  629. package/dist/chunk-2QDYBS2A.js.map +0 -1
  630. package/dist/chunk-32WTYBUH.js.map +0 -1
  631. package/dist/chunk-3FFAEAUJ.cjs.map +0 -1
  632. package/dist/chunk-3O42QOMJ.js.map +0 -1
  633. package/dist/chunk-3OR54XG4.js.map +0 -1
  634. package/dist/chunk-43ZQRWAP.cjs.map +0 -1
  635. package/dist/chunk-4FFBAUFS.js.map +0 -1
  636. package/dist/chunk-4O5TGQBW.cjs.map +0 -1
  637. package/dist/chunk-4OTIXDMU.cjs.map +0 -1
  638. package/dist/chunk-4PYZ5AX3.cjs.map +0 -1
  639. package/dist/chunk-4QZSA2HJ.js.map +0 -1
  640. package/dist/chunk-4ZHTIJNE.cjs.map +0 -1
  641. package/dist/chunk-52NKC5HT.cjs.map +0 -1
  642. package/dist/chunk-6HKGLTJI.cjs.map +0 -1
  643. package/dist/chunk-6JSIEDKL.cjs.map +0 -1
  644. package/dist/chunk-7AD3ZTZL.js.map +0 -1
  645. package/dist/chunk-7BG5UH3T.cjs.map +0 -1
  646. package/dist/chunk-7VT4P3Z4.cjs.map +0 -1
  647. package/dist/chunk-7YGCPMGB.js.map +0 -1
  648. package/dist/chunk-A46SWMIF.js.map +0 -1
  649. package/dist/chunk-A4JVILQU.js.map +0 -1
  650. package/dist/chunk-ACDLHN3W.js.map +0 -1
  651. package/dist/chunk-AKJP2STZ.cjs +0 -81
  652. package/dist/chunk-AKJP2STZ.cjs.map +0 -1
  653. package/dist/chunk-AWO27VRZ.js.map +0 -1
  654. package/dist/chunk-B2J4ZMZL.cjs.map +0 -1
  655. package/dist/chunk-B4EOJWOY.cjs.map +0 -1
  656. package/dist/chunk-BU4KFWXF.js.map +0 -1
  657. package/dist/chunk-BZRFXJHA.js.map +0 -1
  658. package/dist/chunk-C3NT3PVE.js.map +0 -1
  659. package/dist/chunk-C72AZW7J.js.map +0 -1
  660. package/dist/chunk-D4CUGAKZ.js.map +0 -1
  661. package/dist/chunk-DN2PACRI.js.map +0 -1
  662. package/dist/chunk-DXGZ2NUG.cjs.map +0 -1
  663. package/dist/chunk-EG4QM7ZJ.cjs +0 -39
  664. package/dist/chunk-EG4QM7ZJ.cjs.map +0 -1
  665. package/dist/chunk-GMLBYDW4.cjs.map +0 -1
  666. package/dist/chunk-HCZD23VS.cjs.map +0 -1
  667. package/dist/chunk-HS7AVXTF.js.map +0 -1
  668. package/dist/chunk-IAHZCGBE.cjs.map +0 -1
  669. package/dist/chunk-J24VJOH3.cjs.map +0 -1
  670. package/dist/chunk-JPBKYL3B.cjs +0 -18
  671. package/dist/chunk-JPBKYL3B.cjs.map +0 -1
  672. package/dist/chunk-KQ7TS7WW.cjs.map +0 -1
  673. package/dist/chunk-KQRW2GPZ.js.map +0 -1
  674. package/dist/chunk-KYAJINUI.cjs.map +0 -1
  675. package/dist/chunk-L3MTL4NA.js.map +0 -1
  676. package/dist/chunk-L4BDVXIM.js.map +0 -1
  677. package/dist/chunk-LKBEROHN.js.map +0 -1
  678. package/dist/chunk-LYRDF5TQ.cjs.map +0 -1
  679. package/dist/chunk-LYTOXSRH.js.map +0 -1
  680. package/dist/chunk-N2U4AZGB.js.map +0 -1
  681. package/dist/chunk-NDGGJQTZ.js.map +0 -1
  682. package/dist/chunk-O7DK5PBJ.cjs.map +0 -1
  683. package/dist/chunk-O7LZFG6O.cjs.map +0 -1
  684. package/dist/chunk-OFRFZRQ4.cjs.map +0 -1
  685. package/dist/chunk-OSEG74VJ.js.map +0 -1
  686. package/dist/chunk-RFMBZPOW.cjs.map +0 -1
  687. package/dist/chunk-RFXWMRFC.js.map +0 -1
  688. package/dist/chunk-RIAM53CP.js.map +0 -1
  689. package/dist/chunk-RMWTPV3M.cjs.map +0 -1
  690. package/dist/chunk-RNB4APBZ.js.map +0 -1
  691. package/dist/chunk-SAVIWMZB.js.map +0 -1
  692. package/dist/chunk-SZVR77EJ.cjs.map +0 -1
  693. package/dist/chunk-TAZVKYWJ.js.map +0 -1
  694. package/dist/chunk-U54XCYG3.js.map +0 -1
  695. package/dist/chunk-U6IFHFWK.js.map +0 -1
  696. package/dist/chunk-UALX2J2Q.cjs.map +0 -1
  697. package/dist/chunk-UBDMVMBZ.js.map +0 -1
  698. package/dist/chunk-UGT7GK7I.cjs.map +0 -1
  699. package/dist/chunk-UNYXQ4M5.js.map +0 -1
  700. package/dist/chunk-UTSRIDKZ.js.map +0 -1
  701. package/dist/chunk-UU36SHFY.cjs.map +0 -1
  702. package/dist/chunk-V2BOS4WF.cjs.map +0 -1
  703. package/dist/chunk-VCLBZAZU.cjs.map +0 -1
  704. package/dist/chunk-VJ26EKGJ.cjs.map +0 -1
  705. package/dist/chunk-VKJ7V7EB.cjs.map +0 -1
  706. package/dist/chunk-VLVVJLDH.cjs.map +0 -1
  707. package/dist/chunk-WLQNMXQE.js.map +0 -1
  708. package/dist/chunk-WNO3C3N2.cjs.map +0 -1
  709. package/dist/chunk-WTMU7J4U.js +0 -14
  710. package/dist/chunk-WTMU7J4U.js.map +0 -1
  711. package/dist/chunk-XEQ3TM66.js +0 -35
  712. package/dist/chunk-XEQ3TM66.js.map +0 -1
  713. package/dist/chunk-XJCXEKMD.cjs.map +0 -1
  714. package/dist/chunk-XL7Q7HB2.cjs.map +0 -1
  715. package/dist/chunk-XWTLIGO3.cjs.map +0 -1
  716. package/dist/chunk-YML4ME27.cjs.map +0 -1
  717. package/dist/chunk-ZSWPZ23K.cjs.map +0 -1
  718. package/dist/chunk-ZZMZWBR6.js.map +0 -1
  719. package/dist/compact-session-QV57KR66.cjs +0 -59
  720. package/dist/compact-session-RIGOWC4Y.js +0 -22
  721. package/dist/context-WFLTTMK3.cjs +0 -24
  722. package/dist/context-WI2DFG7V.js +0 -7
  723. package/dist/executor-6CYCA7MI.cjs.map +0 -1
  724. package/dist/executor-QSEC3MRH.js.map +0 -1
  725. package/dist/fork-agent-RSV4E3EA.js.map +0 -1
  726. package/dist/fork-agent-Y2IK2RYU.cjs.map +0 -1
  727. package/dist/fs-session-store-4PIHT5UX.cjs +0 -20
  728. package/dist/fs-session-store-NM6YSTE2.js +0 -11
  729. package/dist/generate-object-GUNAUVBX.js +0 -8
  730. package/dist/generate-object-R7HTMW7F.cjs +0 -21
  731. package/dist/index-manager-2SRX45WJ.cjs +0 -27
  732. package/dist/index-manager-SP4ISSDX.js +0 -18
  733. package/dist/inject-session-WQKMC3GR.cjs +0 -29
  734. package/dist/internal/persistence/credential-pool-store.d.cts +0 -32
  735. package/dist/internal/persistence/credential-pool-store.d.ts +0 -32
  736. package/dist/internal/runtime/memory/memory-path-selector.d.ts +0 -73
  737. package/dist/judge-call-LAHMBJ57.cjs +0 -23
  738. package/dist/judge-call-LVXABPS3.js +0 -6
  739. package/dist/oauth-transaction-store-BT4GLTLK.cjs +0 -36
  740. package/dist/oauth-transaction-store-W52KVHQ4.js +0 -3
  741. package/dist/registry-75W33OGL.js +0 -10
  742. package/dist/registry-V7BDQ6QB.cjs +0 -47
  743. package/dist/run-until-HEQOUVU6.js.map +0 -1
  744. package/dist/run-until-U2B5FJJI.cjs.map +0 -1
  745. package/dist/server/adapter/express.d.cts +0 -9
  746. package/dist/server/adapter/express.d.ts +0 -9
  747. package/dist/server/adapter/fastify.d.cts +0 -9
  748. package/dist/server/adapter/fastify.d.ts +0 -9
  749. package/dist/server/adapter/hono.d.cts +0 -9
  750. package/dist/server/adapter/hono.d.ts +0 -9
  751. package/dist/server/adapter/shared-handler.d.cts +0 -9
  752. package/dist/server/adapter/shared-handler.d.ts +0 -9
  753. package/dist/server/adapter/types.d.cts +0 -33
  754. package/dist/server/adapter/types.d.ts +0 -33
  755. package/dist/session-transcript-6WNITKRE.cjs +0 -63
  756. package/dist/session-transcript-XAEKW6P7.js +0 -6
  757. package/dist/stream-object-UF4QRQRU.js +0 -8
  758. package/dist/stream-object-ZJTQNKY3.cjs +0 -21
  759. package/dist/subagents-loader-UCNO7FUH.cjs +0 -17
  760. package/dist/subagents-loader-XP5ERVDZ.js +0 -8
  761. /package/dist/{batch.d.ts → internal/agent/batch.d.ts} +0 -0
  762. /package/dist/{agent-helpers.d.ts → internal/agent/helpers.d.ts} +0 -0
  763. /package/dist/internal/agent-loop/{loop-types.d.ts → types.d.ts} +0 -0
  764. /package/dist/internal/auth/{auth-types.d.ts → types.d.ts} +0 -0
  765. /package/dist/internal/cloud-agent/{cloud-payload-types.d.ts → types.d.ts} +0 -0
  766. /package/dist/internal/{runtime/concurrency → concurrency}/abort-utils.d.ts +0 -0
  767. /package/dist/internal/{runtime/concurrency → concurrency}/async-local-storage.d.ts +0 -0
  768. /package/dist/internal/{runtime/concurrency → concurrency}/async-semaphore.d.ts +0 -0
  769. /package/dist/internal/{runtime/concurrency → concurrency}/delegation-depth.d.ts +0 -0
  770. /package/dist/internal/{runtime/concurrency → concurrency}/map-with-concurrency.d.ts +0 -0
  771. /package/dist/internal/{runtime/retry → error-mappers}/default-retriable.d.ts +0 -0
  772. /package/dist/internal/{runtime/fixtures/fixture-types.d.ts → memory/storage/list-markdown.d.cts} +0 -0
  773. /package/dist/internal/{runtime/plugins/plugins-manager.d.ts → memory/storage/list-markdown.d.ts} +0 -0
  774. /package/dist/internal/{resilience → retry}/circuit-breaker.d.ts +0 -0
  775. /package/dist/internal/{runtime/retry → retry}/with-retry.d.ts +0 -0
  776. /package/dist/internal/{security/secret-redactor.d.cts → runtime/fixtures/types.d.ts} +0 -0
  777. /package/dist/internal/runtime/{memory → memory-glue}/memory-store.d.ts +0 -0
  778. /package/dist/internal/runtime/{memory → memory-glue}/select-facts.d.ts +0 -0
  779. /package/dist/internal/runtime/{plugins → plugin-loader}/plugin-frontmatter.d.ts +0 -0
  780. /package/dist/internal/{security/secret-redactor.d.ts → runtime/plugin-loader/plugins-manager.d.ts} +0 -0
  781. /package/dist/internal/runtime/{reasoning → system-prompt}/native-reasoning.d.ts +0 -0
  782. /package/dist/internal/{runtime/context/path-containment.d.ts → security/path-containment.d.cts} +0 -0
  783. /package/dist/internal/session/{session-types.d.ts → types.d.ts} +0 -0
  784. /package/dist/internal/{zod/to-json-schema.d.ts → zod-to-json-schema.d.ts} +0 -0
  785. /package/dist/subscription/internal/{adapter-types.d.cts → types.d.cts} +0 -0
  786. /package/dist/subscription/internal/{adapter-types.d.ts → types.d.ts} +0 -0
@@ -27,7 +27,8 @@ export type PermissionAction = "allow" | "deny" | "ask";
27
27
  * `allow` EXCEPT an explicit `deny` rule. Never asks. a peer project
28
28
  * `dangerously-skip-permissions` / Codex `Never` / Anthropic `bypassPermissions`.
29
29
  */
30
- export type PermissionMode = "default" | "plan" | "acceptEdits" | "bypass" | "bypassPermissions";
30
+ import type { PermissionMode } from "./types/agent-prims.js";
31
+ export type { PermissionMode };
31
32
  /**
32
33
  * SE1 — apply a {@link PermissionMode} to a rule-engine verdict. Pure.
33
34
  *
@@ -60,23 +61,15 @@ export type ArgMatcher = string | RegExp | ((value: unknown) => boolean);
60
61
  * `{ tool: "shell", args: { command: /rm\s+-rf/ }, action: "deny" }` blocks the destructive call and
61
62
  * leaves `ls` to fall through to a later rule. Every declared matcher must pass.
62
63
  *
63
- * **A missing argument is NOT handled uniformly, and the difference bites in the unsafe direction.**
64
- * For a string or RegExp matcher, an argument the call did not supply fails the matcher, so the rule
65
- * does not match and evaluation continues. For a PREDICATE matcher the function is called anyway,
66
- * with `undefined`:
64
+ * **A rule that declares an argument the call did not supply does not match**, whatever form the
65
+ * matcher takes string, RegExp or predicate. The predicate is not invoked with `undefined`; the
66
+ * guard runs first, for every matcher form. Evaluation continues to the next rule.
67
67
  *
68
- * ```ts
69
- * { tool: "shell", args: { command: (v) => v !== "prod" }, action: "allow" }
70
- * // evaluate("shell", {}) the predicate gets `undefined`, returns true, the rule MATCHES,
71
- * // and a call that supplied no arguments at all is authorized.
72
- *
73
- * { tool: "shell", args: { command: (v) => v.includes("rm") }, action: "deny" }
74
- * // evaluate("shell", {}) → TypeError thrown out of the permission gate.
75
- * ```
76
- *
77
- * Until that is fixed (issue #367), guard the parameter in every predicate you write —
78
- * `(v) => typeof v === "string" && v !== "prod"` — rather than relying on the matcher never being
79
- * reached.
68
+ * That was not always true, and the fix is the reason this paragraph is explicit (#367). A predicate
69
+ * used to be called anyway, so `(v) => v !== "prod"` returned true for a missing argument and an
70
+ * ALLOW rule authorized a call that supplied nothing, while `(v) => v.includes("rm")` threw a
71
+ * TypeError out of the permission gate. This docblock told consumers to guard every predicate by
72
+ * hand for months after `argMatches` stopped needing it — you do not have to.
80
73
  *
81
74
  * A rule that matches yields an EXPLICIT verdict, and that is what makes it survive a permissive
82
75
  * `PermissionMode`: `acceptEdits` auto-approves the unmatched default but still honours an explicit
@@ -1,16 +1,15 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkVTYY7XL5_cjs = require('./chunk-VTYY7XL5.cjs');
4
- var chunkI6HGWHPU_cjs = require('./chunk-I6HGWHPU.cjs');
5
- var chunk5HEG4CQH_cjs = require('./chunk-5HEG4CQH.cjs');
4
+ var chunkZ3NTRKIC_cjs = require('./chunk-Z3NTRKIC.cjs');
5
+ var chunkGZV6AVRL_cjs = require('./chunk-GZV6AVRL.cjs');
6
6
  var chunkA4RAL2ER_cjs = require('./chunk-A4RAL2ER.cjs');
7
- var chunk5VB22SYX_cjs = require('./chunk-5VB22SYX.cjs');
8
- var chunkUU36SHFY_cjs = require('./chunk-UU36SHFY.cjs');
7
+ var chunkDQZU7JK6_cjs = require('./chunk-DQZU7JK6.cjs');
8
+ var chunkBJUJT5ED_cjs = require('./chunk-BJUJT5ED.cjs');
9
9
  var chunkZF2LDKQQ_cjs = require('./chunk-ZF2LDKQQ.cjs');
10
- var chunkUALX2J2Q_cjs = require('./chunk-UALX2J2Q.cjs');
11
- var chunk4ZHTIJNE_cjs = require('./chunk-4ZHTIJNE.cjs');
12
- require('./chunk-XL7Q7HB2.cjs');
13
- require('./chunk-EG4QM7ZJ.cjs');
10
+ var chunkJLRLCBJ4_cjs = require('./chunk-JLRLCBJ4.cjs');
11
+ var chunkJ7J7J2GN_cjs = require('./chunk-J7J7J2GN.cjs');
12
+ require('./chunk-6LHQPOMI.cjs');
14
13
  var fs = require('fs');
15
14
 
16
15
  // src/internal/persistence/session-artifacts.ts
@@ -19,10 +18,10 @@ function classifySessionArtifact(name, isDirectory) {
19
18
  if (isDirectory) return void 0;
20
19
  if (name.endsWith(".jsonl")) return "transcript";
21
20
  if (name.endsWith(".writer.lock")) return "writer-lock";
22
- if (chunkUALX2J2Q_cjs.atomicWriteTempTarget(name) !== void 0) return "temp";
21
+ if (chunkJLRLCBJ4_cjs.atomicWriteTempTarget(name) !== void 0) return "temp";
23
22
  return void 0;
24
23
  }
25
- var LiveSessionError = class extends chunk4ZHTIJNE_cjs.TheokitAgentError {
24
+ var LiveTranscriptError = class extends chunkJ7J7J2GN_cjs.TheokitAgentError {
26
25
  constructor(path) {
27
26
  super(
28
27
  `refusing to write over a live session transcript: ${path}. Fork to a new id instead \u2014 the live pointer, the most recent transcript and any active registry entry are never overwritten (audit-trail rotation, M60).`,
@@ -31,11 +30,11 @@ var LiveSessionError = class extends chunk4ZHTIJNE_cjs.TheokitAgentError {
31
30
  this.path = path;
32
31
  }
33
32
  path;
34
- name = "LiveSessionError";
33
+ name = "LiveTranscriptError";
35
34
  };
36
35
  function forkTranscript(src, dst, options = {}) {
37
36
  for (const live of options.liveSessionPaths ?? []) {
38
- if (live === dst) throw new LiveSessionError(dst);
37
+ if (live === dst) throw new LiveTranscriptError(dst);
39
38
  }
40
39
  const lines = fs.readFileSync(src, "utf8").split("\n").filter((l) => l.trim().length > 0);
41
40
  const kept = options.beforeRecordIndex === void 0 ? lines : lines.slice(0, options.beforeRecordIndex);
@@ -103,27 +102,27 @@ Object.defineProperty(exports, "PersistenceSchema", {
103
102
  });
104
103
  Object.defineProperty(exports, "SessionBusyError", {
105
104
  enumerable: true,
106
- get: function () { return chunkI6HGWHPU_cjs.SessionBusyError; }
105
+ get: function () { return chunkZ3NTRKIC_cjs.SessionBusyError; }
107
106
  });
108
107
  Object.defineProperty(exports, "acquireSessionWriter", {
109
108
  enumerable: true,
110
- get: function () { return chunkI6HGWHPU_cjs.acquireSessionWriter; }
109
+ get: function () { return chunkZ3NTRKIC_cjs.acquireSessionWriter; }
111
110
  });
112
111
  Object.defineProperty(exports, "sessionHasWriter", {
113
112
  enumerable: true,
114
- get: function () { return chunkI6HGWHPU_cjs.sessionHasWriter; }
113
+ get: function () { return chunkZ3NTRKIC_cjs.sessionHasWriter; }
115
114
  });
116
115
  Object.defineProperty(exports, "encodeProjectDir", {
117
116
  enumerable: true,
118
- get: function () { return chunk5HEG4CQH_cjs.encodeProjectDir; }
117
+ get: function () { return chunkGZV6AVRL_cjs.encodeProjectDir; }
119
118
  });
120
119
  Object.defineProperty(exports, "transcriptPath", {
121
120
  enumerable: true,
122
- get: function () { return chunk5HEG4CQH_cjs.transcriptPath; }
121
+ get: function () { return chunkGZV6AVRL_cjs.transcriptPath; }
123
122
  });
124
123
  Object.defineProperty(exports, "transcriptRoot", {
125
124
  enumerable: true,
126
- get: function () { return chunk5HEG4CQH_cjs.transcriptRoot; }
125
+ get: function () { return chunkGZV6AVRL_cjs.transcriptRoot; }
127
126
  });
128
127
  Object.defineProperty(exports, "sanitizeFts5Query", {
129
128
  enumerable: true,
@@ -131,35 +130,35 @@ Object.defineProperty(exports, "sanitizeFts5Query", {
131
130
  });
132
131
  Object.defineProperty(exports, "applyWalWithFallback", {
133
132
  enumerable: true,
134
- get: function () { return chunk5VB22SYX_cjs.applyWalWithFallback; }
133
+ get: function () { return chunkDQZU7JK6_cjs.applyWalWithFallback; }
135
134
  });
136
135
  Object.defineProperty(exports, "isCorruptionError", {
137
136
  enumerable: true,
138
- get: function () { return chunk5VB22SYX_cjs.isCorruptionError; }
137
+ get: function () { return chunkDQZU7JK6_cjs.isCorruptionError; }
139
138
  });
140
139
  Object.defineProperty(exports, "openSqliteResilient", {
141
140
  enumerable: true,
142
- get: function () { return chunk5VB22SYX_cjs.openSqliteResilient; }
141
+ get: function () { return chunkDQZU7JK6_cjs.openSqliteResilient; }
143
142
  });
144
143
  Object.defineProperty(exports, "JsonlParseError", {
145
144
  enumerable: true,
146
- get: function () { return chunkUU36SHFY_cjs.JsonlParseError; }
145
+ get: function () { return chunkBJUJT5ED_cjs.JsonlParseError; }
147
146
  });
148
147
  Object.defineProperty(exports, "appendJsonl", {
149
148
  enumerable: true,
150
- get: function () { return chunkUU36SHFY_cjs.appendJsonl; }
149
+ get: function () { return chunkBJUJT5ED_cjs.appendJsonl; }
151
150
  });
152
151
  Object.defineProperty(exports, "loadJsonl", {
153
152
  enumerable: true,
154
- get: function () { return chunkUU36SHFY_cjs.loadJsonl; }
153
+ get: function () { return chunkBJUJT5ED_cjs.loadJsonl; }
155
154
  });
156
155
  Object.defineProperty(exports, "readJsonlIds", {
157
156
  enumerable: true,
158
- get: function () { return chunkUU36SHFY_cjs.readJsonlIds; }
157
+ get: function () { return chunkBJUJT5ED_cjs.readJsonlIds; }
159
158
  });
160
159
  Object.defineProperty(exports, "withFileLock", {
161
160
  enumerable: true,
162
- get: function () { return chunkUU36SHFY_cjs.withFileLock; }
161
+ get: function () { return chunkBJUJT5ED_cjs.withFileLock; }
163
162
  });
164
163
  Object.defineProperty(exports, "withCwdMutex", {
165
164
  enumerable: true,
@@ -167,21 +166,22 @@ Object.defineProperty(exports, "withCwdMutex", {
167
166
  });
168
167
  Object.defineProperty(exports, "atomicWriteJson", {
169
168
  enumerable: true,
170
- get: function () { return chunkUALX2J2Q_cjs.atomicWriteJson; }
169
+ get: function () { return chunkJLRLCBJ4_cjs.atomicWriteJson; }
171
170
  });
172
171
  Object.defineProperty(exports, "atomicWriteTempTarget", {
173
172
  enumerable: true,
174
- get: function () { return chunkUALX2J2Q_cjs.atomicWriteTempTarget; }
173
+ get: function () { return chunkJLRLCBJ4_cjs.atomicWriteTempTarget; }
175
174
  });
176
175
  Object.defineProperty(exports, "atomicWriteText", {
177
176
  enumerable: true,
178
- get: function () { return chunkUALX2J2Q_cjs.atomicWriteText; }
177
+ get: function () { return chunkJLRLCBJ4_cjs.atomicWriteText; }
179
178
  });
180
179
  Object.defineProperty(exports, "replaceFileAtomic", {
181
180
  enumerable: true,
182
- get: function () { return chunkUALX2J2Q_cjs.replaceFileAtomic; }
181
+ get: function () { return chunkJLRLCBJ4_cjs.replaceFileAtomic; }
183
182
  });
184
- exports.LiveSessionError = LiveSessionError;
183
+ exports.LiveSessionError = LiveTranscriptError;
184
+ exports.LiveTranscriptError = LiveTranscriptError;
185
185
  exports.classifySessionArtifact = classifySessionArtifact;
186
186
  exports.forkTranscript = forkTranscript;
187
187
  exports.readJsonlTail = readJsonlTail;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/internal/persistence/session-artifacts.ts","../src/internal/persistence/transcript-ops.ts"],"names":["atomicWriteTempTarget","TheokitAgentError","readFileSync","openSync","writeSync","closeSync","fstatSync","readSync"],"mappings":";;;;;;;;;;;;;;;;AA6BO,SAAS,uBAAA,CACd,MACA,WAAA,EAC6B;AAE7B,EAAA,IAAI,KAAK,QAAA,CAAS,aAAa,CAAA,EAAG,OAAO,cAAc,gBAAA,GAAmB,MAAA;AAC1E,EAAA,IAAI,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;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":["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 */\nexport class LiveSessionError extends TheokitAgentError {\n override readonly name = \"LiveSessionError\";\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 LiveSessionError(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/session-artifacts.ts","../src/internal/persistence/transcript-ops.ts"],"names":["atomicWriteTempTarget","TheokitAgentError","readFileSync","openSync","writeSync","closeSync","fstatSync","readSync"],"mappings":";;;;;;;;;;;;;;;AA6BO,SAAS,uBAAA,CACd,MACA,WAAA,EAC6B;AAE7B,EAAA,IAAI,KAAK,QAAA,CAAS,aAAa,CAAA,EAAG,OAAO,cAAc,gBAAA,GAAmB,MAAA;AAC1E,EAAA,IAAI,aAAa,OAAO,MAAA;AACxB,EAAA,IA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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":["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,4 +1,6 @@
1
1
  /**
2
+ * Published as `@theokit/sdk/persistence`.
3
+ *
2
4
  * Public persistence primitives (V2-3 — Theo Harness Capability Map, Theme G).
3
5
  *
4
6
  * Promotes the consumer-grade persistence helpers from `internal/persistence`
@@ -28,5 +30,11 @@ export type { OpenSqliteResilientOptions, ResilientSqliteDb, } from "./internal/
28
30
  export { isCorruptionError, openSqliteResilient } from "./internal/persistence/sqlite-open.js";
29
31
  export type { WalApplyResult } from "./internal/persistence/sqlite-wal.js";
30
32
  export { applyWalWithFallback } from "./internal/persistence/sqlite-wal.js";
31
- export { type ForkTranscriptOptions, forkTranscript, LiveSessionError, type ReadJsonlTailOptions, readJsonlTail, } from "./internal/persistence/transcript-ops.js";
33
+ /**
34
+ * @deprecated Renamed to {@link LiveTranscriptError}. The root barrel exports a DIFFERENT class
35
+ * under this name (`session-guard.ts`, about refusing to destroy a session), and a consumer holding
36
+ * both got two classes `instanceof` could not tell apart while `err.name` matched both. This alias
37
+ * keeps existing imports working; it will be removed in the next major.
38
+ */
39
+ export { type ForkTranscriptOptions, forkTranscript, LiveTranscriptError, LiveTranscriptError as LiveSessionError, type ReadJsonlTailOptions, readJsonlTail, } from "./internal/persistence/transcript-ops.js";
32
40
  export type { TranscriptBlock, TranscriptMessage } from "./types/session-record.js";
@@ -1,4 +1,6 @@
1
1
  /**
2
+ * Published as `@theokit/sdk/persistence`.
3
+ *
2
4
  * Public persistence primitives (V2-3 — Theo Harness Capability Map, Theme G).
3
5
  *
4
6
  * Promotes the consumer-grade persistence helpers from `internal/persistence`
@@ -28,5 +30,11 @@ export type { OpenSqliteResilientOptions, ResilientSqliteDb, } from "./internal/
28
30
  export { isCorruptionError, openSqliteResilient } from "./internal/persistence/sqlite-open.js";
29
31
  export type { WalApplyResult } from "./internal/persistence/sqlite-wal.js";
30
32
  export { applyWalWithFallback } from "./internal/persistence/sqlite-wal.js";
31
- export { type ForkTranscriptOptions, forkTranscript, LiveSessionError, type ReadJsonlTailOptions, readJsonlTail, } from "./internal/persistence/transcript-ops.js";
33
+ /**
34
+ * @deprecated Renamed to {@link LiveTranscriptError}. The root barrel exports a DIFFERENT class
35
+ * under this name (`session-guard.ts`, about refusing to destroy a session), and a consumer holding
36
+ * both got two classes `instanceof` could not tell apart while `err.name` matched both. This alias
37
+ * keeps existing imports working; it will be removed in the next major.
38
+ */
39
+ export { type ForkTranscriptOptions, forkTranscript, LiveTranscriptError, LiveTranscriptError as LiveSessionError, type ReadJsonlTailOptions, readJsonlTail, } from "./internal/persistence/transcript-ops.js";
32
40
  export type { TranscriptBlock, TranscriptMessage } from "./types/session-record.js";
@@ -1,15 +1,14 @@
1
1
  export { PersistenceSchema } from './chunk-HY66GLM6.js';
2
- export { SessionBusyError, acquireSessionWriter, sessionHasWriter } from './chunk-B3IMEBOA.js';
3
- export { encodeProjectDir, transcriptPath, transcriptRoot } from './chunk-UMP6OJIM.js';
2
+ export { SessionBusyError, acquireSessionWriter, sessionHasWriter } from './chunk-VE6DFSKU.js';
3
+ export { encodeProjectDir, transcriptPath, transcriptRoot } from './chunk-JOFVLOFY.js';
4
4
  export { sanitizeFts5Query } from './chunk-WE22OXQA.js';
5
- export { applyWalWithFallback, isCorruptionError, openSqliteResilient } from './chunk-LWGSI6M3.js';
6
- export { JsonlParseError, appendJsonl, loadJsonl, readJsonlIds, withFileLock } from './chunk-3O42QOMJ.js';
5
+ export { applyWalWithFallback, isCorruptionError, openSqliteResilient } from './chunk-6PWOWXMC.js';
6
+ export { JsonlParseError, appendJsonl, loadJsonl, readJsonlIds, withFileLock } from './chunk-TA3K7SBK.js';
7
7
  export { withCwdMutex } from './chunk-Q5EWJPRY.js';
8
- import { atomicWriteTempTarget } from './chunk-2GUYQR5P.js';
9
- export { atomicWriteJson, atomicWriteTempTarget, atomicWriteText, replaceFileAtomic } from './chunk-2GUYQR5P.js';
10
- import { TheokitAgentError } from './chunk-ZZMZWBR6.js';
11
- import './chunk-D4CUGAKZ.js';
12
- import './chunk-XEQ3TM66.js';
8
+ import { atomicWriteTempTarget } from './chunk-3JHIFQ4I.js';
9
+ export { atomicWriteJson, atomicWriteTempTarget, atomicWriteText, replaceFileAtomic } from './chunk-3JHIFQ4I.js';
10
+ import { TheokitAgentError } from './chunk-ALUN2B4W.js';
11
+ import './chunk-CZJ6Q7CW.js';
13
12
  import { readFileSync, openSync, writeSync, closeSync, fstatSync, readSync } from 'fs';
14
13
 
15
14
  // src/internal/persistence/session-artifacts.ts
@@ -21,7 +20,7 @@ function classifySessionArtifact(name, isDirectory) {
21
20
  if (atomicWriteTempTarget(name) !== void 0) return "temp";
22
21
  return void 0;
23
22
  }
24
- var LiveSessionError = class extends TheokitAgentError {
23
+ var LiveTranscriptError = class extends TheokitAgentError {
25
24
  constructor(path) {
26
25
  super(
27
26
  `refusing to write over a live session transcript: ${path}. Fork to a new id instead \u2014 the live pointer, the most recent transcript and any active registry entry are never overwritten (audit-trail rotation, M60).`,
@@ -30,11 +29,11 @@ var LiveSessionError = class extends TheokitAgentError {
30
29
  this.path = path;
31
30
  }
32
31
  path;
33
- name = "LiveSessionError";
32
+ name = "LiveTranscriptError";
34
33
  };
35
34
  function forkTranscript(src, dst, options = {}) {
36
35
  for (const live of options.liveSessionPaths ?? []) {
37
- if (live === dst) throw new LiveSessionError(dst);
36
+ if (live === dst) throw new LiveTranscriptError(dst);
38
37
  }
39
38
  const lines = readFileSync(src, "utf8").split("\n").filter((l) => l.trim().length > 0);
40
39
  const kept = options.beforeRecordIndex === void 0 ? lines : lines.slice(0, options.beforeRecordIndex);
@@ -96,6 +95,6 @@ function readJsonlTail(path, options = {}) {
96
95
  return options._stats === true ? Object.assign(out, { bytesRead }) : out;
97
96
  }
98
97
 
99
- export { LiveSessionError, classifySessionArtifact, forkTranscript, readJsonlTail };
98
+ export { LiveTranscriptError as LiveSessionError, LiveTranscriptError, classifySessionArtifact, forkTranscript, readJsonlTail };
100
99
  //# sourceMappingURL=persistence.js.map
101
100
  //# sourceMappingURL=persistence.js.map
@@ -1 +1 @@
1
- {"version":3,"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A,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.js","sourcesContent":["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 */\nexport class LiveSessionError extends TheokitAgentError {\n override readonly name = \"LiveSessionError\";\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 LiveSessionError(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/session-artifacts.ts","../src/internal/persistence/transcript-ops.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AA6BO,SAAS,uBAAA,CACd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AC,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.js","sourcesContent":["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"]}
package/dist/project.cjs CHANGED
@@ -1,10 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkLKFET5A3_cjs = require('./chunk-LKFET5A3.cjs');
4
- var chunkUALX2J2Q_cjs = require('./chunk-UALX2J2Q.cjs');
5
- var chunk4ZHTIJNE_cjs = require('./chunk-4ZHTIJNE.cjs');
6
- require('./chunk-XL7Q7HB2.cjs');
7
- require('./chunk-EG4QM7ZJ.cjs');
4
+ var chunkJLRLCBJ4_cjs = require('./chunk-JLRLCBJ4.cjs');
5
+ var chunkJ7J7J2GN_cjs = require('./chunk-J7J7J2GN.cjs');
6
+ require('./chunk-6LHQPOMI.cjs');
8
7
  var promises = require('fs/promises');
9
8
  var path = require('path');
10
9
 
@@ -32,12 +31,12 @@ function reduceContent(files, scope) {
32
31
  async function writeProjectInstructions(cwd, content, options) {
33
32
  const filename = options?.filename ?? DEFAULT_FILENAME;
34
33
  if (!chunkLKFET5A3_cjs.isSafePattern(filename)) {
35
- throw new chunk4ZHTIJNE_cjs.ConfigurationError(
34
+ throw new chunkJ7J7J2GN_cjs.ConfigurationError(
36
35
  `writeProjectInstructions: unsafe filename ${JSON.stringify(filename)} (no path traversal, separators, or absolute paths)`,
37
36
  { code: "unsafe_filename" }
38
37
  );
39
38
  }
40
- await chunkUALX2J2Q_cjs.replaceFileAtomic(path.join(cwd, filename), content);
39
+ await chunkJLRLCBJ4_cjs.replaceFileAtomic(path.join(cwd, filename), content);
41
40
  }
42
41
 
43
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;AAiB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AAC,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,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"]}
package/dist/project.js CHANGED
@@ -1,8 +1,7 @@
1
1
  import { walkUpForFile, isSafePattern } from './chunk-WFC26L6Y.js';
2
- import { replaceFileAtomic } from './chunk-2GUYQR5P.js';
3
- import { ConfigurationError } from './chunk-ZZMZWBR6.js';
4
- import './chunk-D4CUGAKZ.js';
5
- import './chunk-XEQ3TM66.js';
2
+ import { replaceFileAtomic } from './chunk-3JHIFQ4I.js';
3
+ import { ConfigurationError } from './chunk-ALUN2B4W.js';
4
+ import './chunk-CZJ6Q7CW.js';
6
5
  import { readFile } from 'fs/promises';
7
6
  import { join } from 'path';
8
7
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/internal/runtime/context/project-instructions.ts"],"names":[],"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,GAAQ,aAAA,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,MAAM,QAAA,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,CAAC,aAAA,CAAc,QAAQ,CAAA,EAAG;AAC5B,IAAA,MAAM,IAAI,kBAAA;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,MAAM,iBAAA,CAAkB,IAAA,CAAK,GAAA,EAAK,QAAQ,GAAG,OAAO,CAAA;AACtD","file":"project.js","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":[],"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,GAAQ,aAAA,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,MAAM,QAAA,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,CAAC,aAAA,CAAc,QAAQ,CAAA,EAAG;AAC5B,IAAA,MAAM,IAAI,kBAAA;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,MAAM,iBAAA,CAAkB,IAAA,CAAK,GAAA,EAAK,QAAQ,GAAG,OAAO,CAAA;AACtD","file":"project.js","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,23 +1,23 @@
1
1
  'use strict';
2
2
 
3
- var chunkJPBKYL3B_cjs = require('./chunk-JPBKYL3B.cjs');
4
- require('./chunk-HCZD23VS.cjs');
5
- require('./chunk-6HKGLTJI.cjs');
6
- require('./chunk-XJCXEKMD.cjs');
7
- require('./chunk-52NKC5HT.cjs');
8
- require('./chunk-4ZHTIJNE.cjs');
9
- require('./chunk-XL7Q7HB2.cjs');
10
- require('./chunk-EG4QM7ZJ.cjs');
3
+ var chunkANMJJD6D_cjs = require('./chunk-ANMJJD6D.cjs');
4
+ require('./chunk-QC55H6RJ.cjs');
5
+ require('./chunk-NVXXWAU7.cjs');
6
+ require('./chunk-4NLCWGH7.cjs');
7
+ require('./chunk-EXTRW7GW.cjs');
8
+ require('./chunk-HUFSABUZ.cjs');
9
+ require('./chunk-J7J7J2GN.cjs');
10
+ require('./chunk-6LHQPOMI.cjs');
11
11
 
12
12
 
13
13
 
14
14
  Object.defineProperty(exports, "getProviderProfile", {
15
15
  enumerable: true,
16
- get: function () { return chunkJPBKYL3B_cjs.getProviderProfile; }
16
+ get: function () { return chunkANMJJD6D_cjs.getProviderProfile; }
17
17
  });
18
18
  Object.defineProperty(exports, "listProviders", {
19
19
  enumerable: true,
20
- get: function () { return chunkJPBKYL3B_cjs.listProviders; }
20
+ get: function () { return chunkANMJJD6D_cjs.listProviders; }
21
21
  });
22
22
  //# sourceMappingURL=providers.cjs.map
23
23
  //# sourceMappingURL=providers.cjs.map
@@ -1,4 +1,6 @@
1
1
  /**
2
+ * Published as `@theokit/sdk/providers`.
3
+ *
2
4
  * The provider registry, as public API.
3
5
  *
4
6
  * It was `@internal`, which meant the SDK was the only thing that could answer "which providers
@@ -1,4 +1,6 @@
1
1
  /**
2
+ * Published as `@theokit/sdk/providers`.
3
+ *
2
4
  * The provider registry, as public API.
3
5
  *
4
6
  * It was `@internal`, which meant the SDK was the only thing that could answer "which providers