@theokit/sdk 4.40.0 → 4.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (387) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/README.md +2 -2
  3. package/dist/agent-35MGOZVH.js +46 -0
  4. package/dist/{agent-MSR3DHO4.js.map → agent-35MGOZVH.js.map} +1 -1
  5. package/dist/agent-6C2ODKFU.cjs +55 -0
  6. package/dist/{agent-OOXJJD6A.cjs.map → agent-6C2ODKFU.cjs.map} +1 -1
  7. package/dist/{agent-BzZwYFiw.d.ts → agent-BiCINq25.d.ts} +2 -2
  8. package/dist/{agent-DxEL4fHh.d.cts → agent-Zta1kvGH.d.cts} +2 -2
  9. package/dist/agent-session-store-EPUERCUU.cjs +23 -0
  10. package/dist/{agent-session-store-RHTLZ5OX.cjs.map → agent-session-store-EPUERCUU.cjs.map} +1 -1
  11. package/dist/agent-session-store-TXP5ZVOD.js +6 -0
  12. package/dist/{agent-session-store-EGTTYSKS.js.map → agent-session-store-TXP5ZVOD.js.map} +1 -1
  13. package/dist/auth/index.cjs +19 -15
  14. package/dist/auth/index.d.cts +1 -1
  15. package/dist/auth/index.d.ts +1 -1
  16. package/dist/auth/index.js +4 -4
  17. package/dist/{batch-WX2HLXX2.js → batch-OUF4N2TM.js} +9 -9
  18. package/dist/{batch-WX2HLXX2.js.map → batch-OUF4N2TM.js.map} +1 -1
  19. package/dist/{batch-FO2KZN7W.cjs → batch-URTEXK77.cjs} +26 -26
  20. package/dist/{batch-FO2KZN7W.cjs.map → batch-URTEXK77.cjs.map} +1 -1
  21. package/dist/{chunk-PDOLUFGY.cjs → chunk-27DYRARU.cjs} +4 -4
  22. package/dist/{chunk-PDOLUFGY.cjs.map → chunk-27DYRARU.cjs.map} +1 -1
  23. package/dist/{chunk-LYD3ALDT.js → chunk-2S6B5B2A.js} +5 -5
  24. package/dist/{chunk-LYD3ALDT.js.map → chunk-2S6B5B2A.js.map} +1 -1
  25. package/dist/{chunk-VTDQRUAJ.js → chunk-2WB6EIYW.js} +4 -4
  26. package/dist/{chunk-VTDQRUAJ.js.map → chunk-2WB6EIYW.js.map} +1 -1
  27. package/dist/{chunk-3CAQCFVZ.js → chunk-35NFZ7QB.js} +3 -3
  28. package/dist/{chunk-3CAQCFVZ.js.map → chunk-35NFZ7QB.js.map} +1 -1
  29. package/dist/{chunk-HCRCNI7A.js → chunk-3KY7MHR4.js} +3 -3
  30. package/dist/{chunk-HCRCNI7A.js.map → chunk-3KY7MHR4.js.map} +1 -1
  31. package/dist/{chunk-BURYFNOM.cjs → chunk-4JBHSLQO.cjs} +2 -2
  32. package/dist/chunk-4JBHSLQO.cjs.map +1 -0
  33. package/dist/{chunk-V7CA3CX5.cjs → chunk-4JRRFRV4.cjs} +5 -4
  34. package/dist/chunk-4JRRFRV4.cjs.map +1 -0
  35. package/dist/{chunk-5KOW3GLE.js → chunk-4QEC4CCS.js} +2 -2
  36. package/dist/chunk-4QEC4CCS.js.map +1 -0
  37. package/dist/{chunk-ALDFVGQQ.cjs → chunk-57KX5WTP.cjs} +9 -9
  38. package/dist/{chunk-ALDFVGQQ.cjs.map → chunk-57KX5WTP.cjs.map} +1 -1
  39. package/dist/{chunk-CJHBSSAF.cjs → chunk-64TJCXY5.cjs} +15 -15
  40. package/dist/{chunk-CJHBSSAF.cjs.map → chunk-64TJCXY5.cjs.map} +1 -1
  41. package/dist/{chunk-IEKSEAIV.js → chunk-6FSQ3CHQ.js} +3 -3
  42. package/dist/{chunk-IEKSEAIV.js.map → chunk-6FSQ3CHQ.js.map} +1 -1
  43. package/dist/{chunk-ZVQJHY4Y.cjs → chunk-6W4U2G3J.cjs} +5 -5
  44. package/dist/{chunk-ZVQJHY4Y.cjs.map → chunk-6W4U2G3J.cjs.map} +1 -1
  45. package/dist/{chunk-FMDZZRYE.cjs → chunk-6X2HUT4A.cjs} +8 -8
  46. package/dist/{chunk-FMDZZRYE.cjs.map → chunk-6X2HUT4A.cjs.map} +1 -1
  47. package/dist/{chunk-X2LDDKFM.cjs → chunk-7PESI6YD.cjs} +10 -10
  48. package/dist/{chunk-X2LDDKFM.cjs.map → chunk-7PESI6YD.cjs.map} +1 -1
  49. package/dist/{chunk-EYUZZXHZ.js → chunk-AF4BBKIF.js} +4 -4
  50. package/dist/chunk-AF4BBKIF.js.map +1 -0
  51. package/dist/{chunk-7GFX45DD.js → chunk-AM2CNBKE.js} +2 -2
  52. package/dist/chunk-AM2CNBKE.js.map +1 -0
  53. package/dist/{chunk-XKGOIGTJ.js → chunk-AZ6FKDQR.js} +3 -3
  54. package/dist/{chunk-XKGOIGTJ.js.map → chunk-AZ6FKDQR.js.map} +1 -1
  55. package/dist/{chunk-WPZTYOUX.cjs → chunk-BBZYXVLZ.cjs} +2 -2
  56. package/dist/chunk-BBZYXVLZ.cjs.map +1 -0
  57. package/dist/{chunk-2UBBO2MD.js → chunk-BHWHE453.js} +5 -5
  58. package/dist/{chunk-2UBBO2MD.js.map → chunk-BHWHE453.js.map} +1 -1
  59. package/dist/{chunk-LY4KEOOY.cjs → chunk-BRHRQOJA.cjs} +4 -4
  60. package/dist/{chunk-LY4KEOOY.cjs.map → chunk-BRHRQOJA.cjs.map} +1 -1
  61. package/dist/{chunk-4H2QARXM.cjs → chunk-BV42CCRP.cjs} +7 -7
  62. package/dist/{chunk-4H2QARXM.cjs.map → chunk-BV42CCRP.cjs.map} +1 -1
  63. package/dist/{chunk-ZRQZOJ3N.js → chunk-DCKIS53K.js} +52 -51
  64. package/dist/chunk-DCKIS53K.js.map +1 -0
  65. package/dist/{chunk-SKWVAQAY.js → chunk-DEZ75ET5.js} +3 -3
  66. package/dist/{chunk-SKWVAQAY.js.map → chunk-DEZ75ET5.js.map} +1 -1
  67. package/dist/{chunk-WJOLIPEM.js → chunk-EON4YTR6.js} +8 -8
  68. package/dist/{chunk-WJOLIPEM.js.map → chunk-EON4YTR6.js.map} +1 -1
  69. package/dist/{chunk-MI3OKONE.js → chunk-F4RUADRC.js} +3 -3
  70. package/dist/{chunk-MI3OKONE.js.map → chunk-F4RUADRC.js.map} +1 -1
  71. package/dist/{chunk-BVGJXMSB.cjs → chunk-F5DSDDBY.cjs} +312 -311
  72. package/dist/chunk-F5DSDDBY.cjs.map +1 -0
  73. package/dist/{chunk-SEWAPWAF.cjs → chunk-FMIKUGF2.cjs} +124 -124
  74. package/dist/chunk-FMIKUGF2.cjs.map +1 -0
  75. package/dist/{chunk-XZ7PO2FM.js → chunk-FRQ6F44U.js} +4 -4
  76. package/dist/{chunk-XZ7PO2FM.js.map → chunk-FRQ6F44U.js.map} +1 -1
  77. package/dist/{chunk-3LK3ZDL5.cjs → chunk-FZ4YMZA3.cjs} +5 -5
  78. package/dist/{chunk-3LK3ZDL5.cjs.map → chunk-FZ4YMZA3.cjs.map} +1 -1
  79. package/dist/{chunk-MM2JKFQV.cjs → chunk-GC44RATP.cjs} +10 -10
  80. package/dist/{chunk-MM2JKFQV.cjs.map → chunk-GC44RATP.cjs.map} +1 -1
  81. package/dist/{chunk-LNTQRD23.cjs → chunk-GH52NOCL.cjs} +26 -26
  82. package/dist/chunk-GH52NOCL.cjs.map +1 -0
  83. package/dist/{chunk-T6KFGMNY.cjs → chunk-GLEKLAUW.cjs} +12 -12
  84. package/dist/chunk-GLEKLAUW.cjs.map +1 -0
  85. package/dist/{chunk-UIPTINIF.js → chunk-GNMPCZNN.js} +6 -6
  86. package/dist/chunk-GNMPCZNN.js.map +1 -0
  87. package/dist/{chunk-K6TWHNT4.cjs → chunk-HECR7KF5.cjs} +11 -11
  88. package/dist/{chunk-K6TWHNT4.cjs.map → chunk-HECR7KF5.cjs.map} +1 -1
  89. package/dist/{chunk-NHXPQN44.js → chunk-HK4HRLWE.js} +3 -3
  90. package/dist/{chunk-NHXPQN44.js.map → chunk-HK4HRLWE.js.map} +1 -1
  91. package/dist/{chunk-LWVKI75U.js → chunk-HKSSM5RK.js} +3 -3
  92. package/dist/{chunk-LWVKI75U.js.map → chunk-HKSSM5RK.js.map} +1 -1
  93. package/dist/{chunk-ELYGL52R.cjs → chunk-HLNLYLNN.cjs} +4 -4
  94. package/dist/{chunk-ELYGL52R.cjs.map → chunk-HLNLYLNN.cjs.map} +1 -1
  95. package/dist/{chunk-ONVIALVV.js → chunk-IMX5YODO.js} +15 -15
  96. package/dist/chunk-IMX5YODO.js.map +1 -0
  97. package/dist/{chunk-C64E2EJS.js → chunk-J5RW43IR.js} +4 -4
  98. package/dist/{chunk-C64E2EJS.js.map → chunk-J5RW43IR.js.map} +1 -1
  99. package/dist/{chunk-4E3HLSYE.cjs → chunk-JA4FEA5Z.cjs} +4 -4
  100. package/dist/{chunk-4E3HLSYE.cjs.map → chunk-JA4FEA5Z.cjs.map} +1 -1
  101. package/dist/{chunk-EJNFZET4.cjs → chunk-JO76RWCA.cjs} +11 -11
  102. package/dist/{chunk-EJNFZET4.cjs.map → chunk-JO76RWCA.cjs.map} +1 -1
  103. package/dist/{chunk-QMIG7TKG.cjs → chunk-KCQUYQ3V.cjs} +17 -17
  104. package/dist/chunk-KCQUYQ3V.cjs.map +1 -0
  105. package/dist/{chunk-AKMPQJPX.js → chunk-L4JFQCG4.js} +5 -5
  106. package/dist/chunk-L4JFQCG4.js.map +1 -0
  107. package/dist/{chunk-HJMFPIRM.js → chunk-LLE7HPRI.js} +5 -5
  108. package/dist/{chunk-HJMFPIRM.js.map → chunk-LLE7HPRI.js.map} +1 -1
  109. package/dist/{chunk-4H2DCO6P.js → chunk-LXKNENHK.js} +3 -3
  110. package/dist/{chunk-4H2DCO6P.js.map → chunk-LXKNENHK.js.map} +1 -1
  111. package/dist/{chunk-PY7G7YWK.cjs → chunk-MMZX557L.cjs} +5 -5
  112. package/dist/{chunk-PY7G7YWK.cjs.map → chunk-MMZX557L.cjs.map} +1 -1
  113. package/dist/{chunk-VQ33XLC6.js → chunk-MRKSSN36.js} +3 -3
  114. package/dist/{chunk-VQ33XLC6.js.map → chunk-MRKSSN36.js.map} +1 -1
  115. package/dist/{chunk-33B2BSME.cjs → chunk-NETYW4V3.cjs} +13 -5
  116. package/dist/chunk-NETYW4V3.cjs.map +1 -0
  117. package/dist/{chunk-OVGNXGCK.cjs → chunk-NNNUQELM.cjs} +9 -9
  118. package/dist/{chunk-OVGNXGCK.cjs.map → chunk-NNNUQELM.cjs.map} +1 -1
  119. package/dist/{chunk-BM7VYZED.js → chunk-NOM2YWFP.js} +5 -5
  120. package/dist/{chunk-BM7VYZED.js.map → chunk-NOM2YWFP.js.map} +1 -1
  121. package/dist/{chunk-WMWZAJMJ.cjs → chunk-NRA36JKG.cjs} +11 -11
  122. package/dist/{chunk-WMWZAJMJ.cjs.map → chunk-NRA36JKG.cjs.map} +1 -1
  123. package/dist/{chunk-4HKAZRTC.js → chunk-O3IZ7JEL.js} +3 -3
  124. package/dist/{chunk-4HKAZRTC.js.map → chunk-O3IZ7JEL.js.map} +1 -1
  125. package/dist/{chunk-RHQJX3EI.cjs → chunk-OEFFPR2S.cjs} +4 -4
  126. package/dist/{chunk-RHQJX3EI.cjs.map → chunk-OEFFPR2S.cjs.map} +1 -1
  127. package/dist/{chunk-4GGXF7YM.js → chunk-OLLOUAUJ.js} +3 -3
  128. package/dist/{chunk-4GGXF7YM.js.map → chunk-OLLOUAUJ.js.map} +1 -1
  129. package/dist/{chunk-RA2UZBYP.js → chunk-PAV4ZPSW.js} +3 -3
  130. package/dist/{chunk-RA2UZBYP.js.map → chunk-PAV4ZPSW.js.map} +1 -1
  131. package/dist/{chunk-RNCN2TTP.js → chunk-PBML2FHN.js} +2 -2
  132. package/dist/{chunk-A76OFN2B.cjs.map → chunk-PBML2FHN.js.map} +1 -1
  133. package/dist/{chunk-XRKFWV7K.js → chunk-PYM5OUL4.js} +5 -5
  134. package/dist/{chunk-XRKFWV7K.js.map → chunk-PYM5OUL4.js.map} +1 -1
  135. package/dist/{chunk-F4SQTWVR.js → chunk-Q4DTGCSD.js} +3 -3
  136. package/dist/{chunk-F4SQTWVR.js.map → chunk-Q4DTGCSD.js.map} +1 -1
  137. package/dist/{chunk-S7OEXQMI.cjs → chunk-R3CKCRK3.cjs} +4 -4
  138. package/dist/{chunk-S7OEXQMI.cjs.map → chunk-R3CKCRK3.cjs.map} +1 -1
  139. package/dist/{chunk-5COPO3H4.cjs → chunk-RBQYHEZD.cjs} +4 -4
  140. package/dist/{chunk-5COPO3H4.cjs.map → chunk-RBQYHEZD.cjs.map} +1 -1
  141. package/dist/{chunk-KRPEPZQY.js → chunk-RJBHWM6D.js} +7 -7
  142. package/dist/chunk-RJBHWM6D.js.map +1 -0
  143. package/dist/{chunk-U53AYSHS.cjs → chunk-S4Q5OMIK.cjs} +11 -11
  144. package/dist/{chunk-U53AYSHS.cjs.map → chunk-S4Q5OMIK.cjs.map} +1 -1
  145. package/dist/{chunk-FUP3ZA5T.js → chunk-SNKY3C2L.js} +4 -4
  146. package/dist/{chunk-FUP3ZA5T.js.map → chunk-SNKY3C2L.js.map} +1 -1
  147. package/dist/{chunk-BBMN4O6E.js → chunk-TJRPNBY5.js} +4 -4
  148. package/dist/{chunk-BBMN4O6E.js.map → chunk-TJRPNBY5.js.map} +1 -1
  149. package/dist/{chunk-27E4EMR6.cjs → chunk-UJMEWGO6.cjs} +4 -4
  150. package/dist/{chunk-27E4EMR6.cjs.map → chunk-UJMEWGO6.cjs.map} +1 -1
  151. package/dist/{chunk-X627TO3A.js → chunk-UTYCG4RB.js} +12 -12
  152. package/dist/chunk-UTYCG4RB.js.map +1 -0
  153. package/dist/{chunk-5XPKYDK7.js → chunk-VQFSEKU5.js} +12 -5
  154. package/dist/chunk-VQFSEKU5.js.map +1 -0
  155. package/dist/{chunk-NJVV5OAV.cjs → chunk-WCXOKGOQ.cjs} +8 -8
  156. package/dist/chunk-WCXOKGOQ.cjs.map +1 -0
  157. package/dist/{chunk-PIBXDEZM.cjs → chunk-WIGJGFH4.cjs} +5 -5
  158. package/dist/{chunk-PIBXDEZM.cjs.map → chunk-WIGJGFH4.cjs.map} +1 -1
  159. package/dist/{chunk-LOTWA65Z.cjs → chunk-X2YQP452.cjs} +11 -11
  160. package/dist/{chunk-LOTWA65Z.cjs.map → chunk-X2YQP452.cjs.map} +1 -1
  161. package/dist/{chunk-ZAKTZ5B4.cjs → chunk-XA3TSBAH.cjs} +8 -8
  162. package/dist/{chunk-ZAKTZ5B4.cjs.map → chunk-XA3TSBAH.cjs.map} +1 -1
  163. package/dist/{chunk-H2V6CXM7.cjs → chunk-XR4LPBXH.cjs} +9 -9
  164. package/dist/{chunk-H2V6CXM7.cjs.map → chunk-XR4LPBXH.cjs.map} +1 -1
  165. package/dist/{chunk-6AE4QTSF.cjs → chunk-Y33IGXCJ.cjs} +24 -24
  166. package/dist/{chunk-6AE4QTSF.cjs.map → chunk-Y33IGXCJ.cjs.map} +1 -1
  167. package/dist/{chunk-E7WWIX34.cjs → chunk-YULF6FPB.cjs} +8 -8
  168. package/dist/{chunk-E7WWIX34.cjs.map → chunk-YULF6FPB.cjs.map} +1 -1
  169. package/dist/{chunk-23HI77BZ.js → chunk-Z6N6SDNR.js} +4 -4
  170. package/dist/chunk-Z6N6SDNR.js.map +1 -0
  171. package/dist/{chunk-A76OFN2B.cjs → chunk-ZHPET3LZ.cjs} +2 -2
  172. package/dist/chunk-ZHPET3LZ.cjs.map +1 -0
  173. package/dist/{chunk-5VKUZ26Q.js → chunk-ZNW2TXLO.js} +3 -3
  174. package/dist/{chunk-5VKUZ26Q.js.map → chunk-ZNW2TXLO.js.map} +1 -1
  175. package/dist/{chunk-N4JNY5DT.cjs → chunk-ZO2L5U6F.cjs} +32 -32
  176. package/dist/chunk-ZO2L5U6F.cjs.map +1 -0
  177. package/dist/{chunk-RMCHJZNZ.js → chunk-ZS6SLELQ.js} +4 -4
  178. package/dist/{chunk-RMCHJZNZ.js.map → chunk-ZS6SLELQ.js.map} +1 -1
  179. package/dist/{chunk-7PBAJ2WA.js → chunk-ZTEAJAE6.js} +3 -3
  180. package/dist/{chunk-7PBAJ2WA.js.map → chunk-ZTEAJAE6.js.map} +1 -1
  181. package/dist/compact-session-65XCKO6H.js +18 -0
  182. package/dist/{compact-session-AZU2LEAE.js.map → compact-session-65XCKO6H.js.map} +1 -1
  183. package/dist/compact-session-OU6SRPVJ.cjs +55 -0
  184. package/dist/{compact-session-TRCEYCPG.cjs.map → compact-session-OU6SRPVJ.cjs.map} +1 -1
  185. package/dist/compaction.cjs +16 -16
  186. package/dist/compaction.js +3 -3
  187. package/dist/concurrency.cjs +6 -6
  188. package/dist/concurrency.js +4 -4
  189. package/dist/context-2G4375BZ.cjs +22 -0
  190. package/dist/{context-DNFT4B5D.cjs.map → context-2G4375BZ.cjs.map} +1 -1
  191. package/dist/context-GSQYVVMJ.js +5 -0
  192. package/dist/{context-LYE6TJL5.js.map → context-GSQYVVMJ.js.map} +1 -1
  193. package/dist/{cron-BGR0HOz9.d.cts → cron-DgHJnMAK.d.cts} +2 -2
  194. package/dist/{cron-CDAIWCrL.d.ts → cron-DyWQsEG6.d.ts} +2 -2
  195. package/dist/cron.cjs +33 -33
  196. package/dist/cron.d.cts +3 -3
  197. package/dist/cron.d.ts +3 -3
  198. package/dist/cron.js +32 -32
  199. package/dist/{errors-DxQe4_Qy.d.ts → errors-BSoXcl3F.d.cts} +3 -3
  200. package/dist/{errors-L1bxHHO0.d.cts → errors-CHllybaU.d.ts} +3 -3
  201. package/dist/errors.cjs +21 -21
  202. package/dist/errors.d.cts +2 -2
  203. package/dist/errors.d.ts +2 -2
  204. package/dist/errors.js +2 -2
  205. package/dist/eval.cjs +43 -43
  206. package/dist/eval.cjs.map +1 -1
  207. package/dist/eval.js +33 -33
  208. package/dist/eval.js.map +1 -1
  209. package/dist/{executor-TQ3FSZ7F.cjs → executor-CB75B5BH.cjs} +24 -24
  210. package/dist/{executor-TQ3FSZ7F.cjs.map → executor-CB75B5BH.cjs.map} +1 -1
  211. package/dist/{executor-PCRX3533.js → executor-VQLTQY53.js} +7 -7
  212. package/dist/{executor-PCRX3533.js.map → executor-VQLTQY53.js.map} +1 -1
  213. package/dist/filesystem/index.cjs +7 -7
  214. package/dist/filesystem/index.js +3 -3
  215. package/dist/fs-session-store-MAZV5FXJ.cjs +19 -0
  216. package/dist/{fs-session-store-KRZZIG3O.cjs.map → fs-session-store-MAZV5FXJ.cjs.map} +1 -1
  217. package/dist/fs-session-store-ZNUYZHYI.js +10 -0
  218. package/dist/{fs-session-store-I6GUIFRO.js.map → fs-session-store-ZNUYZHYI.js.map} +1 -1
  219. package/dist/generate-object-6PWGH5DZ.cjs +20 -0
  220. package/dist/{generate-object-QILSGTEJ.cjs.map → generate-object-6PWGH5DZ.cjs.map} +1 -1
  221. package/dist/generate-object-IXMJ7FUX.js +7 -0
  222. package/dist/{generate-object-DLHT5RXH.js.map → generate-object-IXMJ7FUX.js.map} +1 -1
  223. package/dist/index-manager-X5IPG2JL.js +11 -0
  224. package/dist/{index-manager-SXF3FAQV.js.map → index-manager-X5IPG2JL.js.map} +1 -1
  225. package/dist/index-manager-YFFEPISE.cjs +20 -0
  226. package/dist/{index-manager-LEMQ73A7.cjs.map → index-manager-YFFEPISE.cjs.map} +1 -1
  227. package/dist/index.cjs +139 -139
  228. package/dist/index.cjs.map +1 -1
  229. package/dist/index.d.cts +13 -13
  230. package/dist/index.d.ts +13 -13
  231. package/dist/index.js +53 -53
  232. package/dist/index.js.map +1 -1
  233. package/dist/{inject-session-BVSERZCI.cjs → inject-session-DDC36KKP.cjs} +11 -11
  234. package/dist/{inject-session-BVSERZCI.cjs.map → inject-session-DDC36KKP.cjs.map} +1 -1
  235. package/dist/{inject-session-E75EP3LL.js → inject-session-UBM4KVSV.js} +8 -8
  236. package/dist/{inject-session-E75EP3LL.js.map → inject-session-UBM4KVSV.js.map} +1 -1
  237. package/dist/internal/auth/credential-store.d.ts +13 -0
  238. package/dist/internal/diagnostics.d.ts +2 -2
  239. package/dist/internal/error-mappers/anthropic.d.ts +1 -1
  240. package/dist/internal/eval/code-runner.d.ts +1 -1
  241. package/dist/internal/global-singleton.d.ts +1 -1
  242. package/dist/internal/judge/judge-call.d.ts +1 -1
  243. package/dist/internal/memory/adapters/index.cjs +8 -8
  244. package/dist/internal/memory/adapters/index.js +7 -7
  245. package/dist/internal/memory/embedding-adapter.d.ts +1 -1
  246. package/dist/internal/memory/memory-index.d.ts +1 -1
  247. package/dist/internal/persistence/atomic-write.d.cts +14 -1
  248. package/dist/internal/persistence/atomic-write.d.ts +14 -1
  249. package/dist/internal/persistence/index.cjs +25 -25
  250. package/dist/internal/persistence/index.js +6 -6
  251. package/dist/internal/persistence/jsonl.d.cts +2 -2
  252. package/dist/internal/persistence/jsonl.d.ts +2 -2
  253. package/dist/internal/persistence/session-artifacts.d.cts +27 -0
  254. package/dist/internal/persistence/session-artifacts.d.ts +27 -0
  255. package/dist/internal/persistence/session-transcript.d.cts +1 -1
  256. package/dist/internal/persistence/session-transcript.d.ts +1 -1
  257. package/dist/internal/runtime/lifecycle/env-policy.d.ts +1 -1
  258. package/dist/internal/security/index.cjs +13 -13
  259. package/dist/internal/security/index.js +3 -3
  260. package/dist/internal/session/agent-session.d.ts +1 -1
  261. package/dist/internal/session/compact-session.d.ts +1 -1
  262. package/dist/internal/session/session-cache.d.ts +1 -1
  263. package/dist/judge-call-3QZO5H5N.js +5 -0
  264. package/dist/{judge-call-NPRU7JIQ.js.map → judge-call-3QZO5H5N.js.map} +1 -1
  265. package/dist/judge-call-J5EETJL3.cjs +22 -0
  266. package/dist/{judge-call-AIT3EULV.cjs.map → judge-call-J5EETJL3.cjs.map} +1 -1
  267. package/dist/models.cjs +20 -20
  268. package/dist/models.cjs.map +1 -1
  269. package/dist/models.js +5 -5
  270. package/dist/models.js.map +1 -1
  271. package/dist/path-safety.cjs +10 -10
  272. package/dist/path-safety.js +3 -3
  273. package/dist/persistence.cjs +44 -30
  274. package/dist/persistence.cjs.map +1 -1
  275. package/dist/persistence.d.cts +4 -3
  276. package/dist/persistence.d.ts +4 -3
  277. package/dist/persistence.js +22 -12
  278. package/dist/persistence.js.map +1 -1
  279. package/dist/project.cjs +5 -5
  280. package/dist/project.js +3 -3
  281. package/dist/registry-KB3TS6BM.cjs +46 -0
  282. package/dist/{registry-VKDFTK6L.cjs.map → registry-KB3TS6BM.cjs.map} +1 -1
  283. package/dist/registry-PPFMCM4A.js +9 -0
  284. package/dist/{registry-AXQXPLFH.js.map → registry-PPFMCM4A.js.map} +1 -1
  285. package/dist/retry.cjs +4 -4
  286. package/dist/retry.js +3 -3
  287. package/dist/{run-XXnwwGOT.d.ts → run-C8FBAC8o.d.cts} +21 -2
  288. package/dist/{run-XXnwwGOT.d.cts → run-C8FBAC8o.d.ts} +21 -2
  289. package/dist/{run-until-BK56WG4P.js → run-until-HEQOUVU6.js} +2 -2
  290. package/dist/run-until-HEQOUVU6.js.map +1 -0
  291. package/dist/{run-until-L5KQD3PV.cjs → run-until-U2B5FJJI.cjs} +2 -2
  292. package/dist/run-until-U2B5FJJI.cjs.map +1 -0
  293. package/dist/sandbox/bwrap.d.cts +15 -1
  294. package/dist/sandbox/bwrap.d.ts +15 -1
  295. package/dist/sandbox/index.cjs +39 -24
  296. package/dist/sandbox/index.cjs.map +1 -1
  297. package/dist/sandbox/index.d.cts +1 -1
  298. package/dist/sandbox/index.d.ts +1 -1
  299. package/dist/sandbox/index.js +24 -10
  300. package/dist/sandbox/index.js.map +1 -1
  301. package/dist/sandbox/provision.d.cts +1 -1
  302. package/dist/sandbox/provision.d.ts +1 -1
  303. package/dist/server/errors-envelope.cjs +14 -14
  304. package/dist/server/errors-envelope.d.cts +3 -3
  305. package/dist/server/errors-envelope.d.ts +3 -3
  306. package/dist/server/errors-envelope.js +3 -3
  307. package/dist/session-transcript-7FWTO4BK.js +5 -0
  308. package/dist/{session-transcript-X3UMSVL2.js.map → session-transcript-7FWTO4BK.js.map} +1 -1
  309. package/dist/session-transcript-FYRKWRWV.cjs +50 -0
  310. package/dist/{session-transcript-SLQRKQ72.cjs.map → session-transcript-FYRKWRWV.cjs.map} +1 -1
  311. package/dist/skills.cjs +7 -7
  312. package/dist/skills.js +5 -5
  313. package/dist/stream-object-3R3HZPQN.cjs +20 -0
  314. package/dist/{stream-object-3HEUGMQY.cjs.map → stream-object-3R3HZPQN.cjs.map} +1 -1
  315. package/dist/stream-object-NPJXDZXO.js +7 -0
  316. package/dist/{stream-object-VWYW7FJ2.js.map → stream-object-NPJXDZXO.js.map} +1 -1
  317. package/dist/subagents-loader-5KQVYUNS.js +6 -0
  318. package/dist/{subagents-loader-QUIK6GMV.js.map → subagents-loader-5KQVYUNS.js.map} +1 -1
  319. package/dist/subagents-loader-FDXPBBRA.cjs +15 -0
  320. package/dist/{subagents-loader-F52ARQ62.cjs.map → subagents-loader-FDXPBBRA.cjs.map} +1 -1
  321. package/dist/subagents-loader.cjs +15 -15
  322. package/dist/subagents-loader.cjs.map +1 -1
  323. package/dist/subagents-loader.d.cts +2 -2
  324. package/dist/subagents-loader.d.ts +2 -2
  325. package/dist/subagents-loader.js +14 -14
  326. package/dist/subagents-loader.js.map +1 -1
  327. package/dist/subscription/index.cjs +3 -3
  328. package/dist/subscription/index.js +2 -2
  329. package/dist/task-store.cjs +7 -7
  330. package/dist/task-store.js +4 -4
  331. package/dist/types/run-events.d.ts +20 -1
  332. package/dist/types/session-record.d.ts +1 -1
  333. package/dist/types/usage.d.ts +1 -1
  334. package/dist/workflow.cjs +27 -27
  335. package/dist/workflow.js +6 -6
  336. package/docs/error-codes.md +22 -0
  337. package/docs/harness-capability-map.md +22 -0
  338. package/package.json +1 -1
  339. package/dist/agent-MSR3DHO4.js +0 -46
  340. package/dist/agent-OOXJJD6A.cjs +0 -55
  341. package/dist/agent-session-store-EGTTYSKS.js +0 -6
  342. package/dist/agent-session-store-RHTLZ5OX.cjs +0 -23
  343. package/dist/chunk-23HI77BZ.js.map +0 -1
  344. package/dist/chunk-33B2BSME.cjs.map +0 -1
  345. package/dist/chunk-5KOW3GLE.js.map +0 -1
  346. package/dist/chunk-5XPKYDK7.js.map +0 -1
  347. package/dist/chunk-7GFX45DD.js.map +0 -1
  348. package/dist/chunk-AKMPQJPX.js.map +0 -1
  349. package/dist/chunk-BURYFNOM.cjs.map +0 -1
  350. package/dist/chunk-BVGJXMSB.cjs.map +0 -1
  351. package/dist/chunk-EYUZZXHZ.js.map +0 -1
  352. package/dist/chunk-KRPEPZQY.js.map +0 -1
  353. package/dist/chunk-LNTQRD23.cjs.map +0 -1
  354. package/dist/chunk-N4JNY5DT.cjs.map +0 -1
  355. package/dist/chunk-NJVV5OAV.cjs.map +0 -1
  356. package/dist/chunk-ONVIALVV.js.map +0 -1
  357. package/dist/chunk-QMIG7TKG.cjs.map +0 -1
  358. package/dist/chunk-RNCN2TTP.js.map +0 -1
  359. package/dist/chunk-SEWAPWAF.cjs.map +0 -1
  360. package/dist/chunk-T6KFGMNY.cjs.map +0 -1
  361. package/dist/chunk-UIPTINIF.js.map +0 -1
  362. package/dist/chunk-V7CA3CX5.cjs.map +0 -1
  363. package/dist/chunk-WPZTYOUX.cjs.map +0 -1
  364. package/dist/chunk-X627TO3A.js.map +0 -1
  365. package/dist/chunk-ZRQZOJ3N.js.map +0 -1
  366. package/dist/compact-session-AZU2LEAE.js +0 -18
  367. package/dist/compact-session-TRCEYCPG.cjs +0 -55
  368. package/dist/context-DNFT4B5D.cjs +0 -22
  369. package/dist/context-LYE6TJL5.js +0 -5
  370. package/dist/fs-session-store-I6GUIFRO.js +0 -10
  371. package/dist/fs-session-store-KRZZIG3O.cjs +0 -19
  372. package/dist/generate-object-DLHT5RXH.js +0 -7
  373. package/dist/generate-object-QILSGTEJ.cjs +0 -20
  374. package/dist/index-manager-LEMQ73A7.cjs +0 -20
  375. package/dist/index-manager-SXF3FAQV.js +0 -11
  376. package/dist/judge-call-AIT3EULV.cjs +0 -22
  377. package/dist/judge-call-NPRU7JIQ.js +0 -5
  378. package/dist/registry-AXQXPLFH.js +0 -9
  379. package/dist/registry-VKDFTK6L.cjs +0 -46
  380. package/dist/run-until-BK56WG4P.js.map +0 -1
  381. package/dist/run-until-L5KQD3PV.cjs.map +0 -1
  382. package/dist/session-transcript-SLQRKQ72.cjs +0 -50
  383. package/dist/session-transcript-X3UMSVL2.js +0 -5
  384. package/dist/stream-object-3HEUGMQY.cjs +0 -20
  385. package/dist/stream-object-VWYW7FJ2.js +0 -7
  386. package/dist/subagents-loader-F52ARQ62.cjs +0 -15
  387. package/dist/subagents-loader-QUIK6GMV.js +0 -6
@@ -1,17 +1,26 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkPNVDQL5Y_cjs = require('./chunk-PNVDQL5Y.cjs');
4
- var chunk4E3HLSYE_cjs = require('./chunk-4E3HLSYE.cjs');
5
- var chunkNJVV5OAV_cjs = require('./chunk-NJVV5OAV.cjs');
6
- var chunkZVQJHY4Y_cjs = require('./chunk-ZVQJHY4Y.cjs');
7
- var chunk4H2QARXM_cjs = require('./chunk-4H2QARXM.cjs');
4
+ var chunkJA4FEA5Z_cjs = require('./chunk-JA4FEA5Z.cjs');
5
+ var chunkWCXOKGOQ_cjs = require('./chunk-WCXOKGOQ.cjs');
6
+ var chunk6W4U2G3J_cjs = require('./chunk-6W4U2G3J.cjs');
7
+ var chunkBV42CCRP_cjs = require('./chunk-BV42CCRP.cjs');
8
8
  var chunkYLQQX5W2_cjs = require('./chunk-YLQQX5W2.cjs');
9
- var chunk33B2BSME_cjs = require('./chunk-33B2BSME.cjs');
10
- var chunkE7WWIX34_cjs = require('./chunk-E7WWIX34.cjs');
11
- require('./chunk-A76OFN2B.cjs');
9
+ var chunkNETYW4V3_cjs = require('./chunk-NETYW4V3.cjs');
10
+ var chunkYULF6FPB_cjs = require('./chunk-YULF6FPB.cjs');
11
+ require('./chunk-ZHPET3LZ.cjs');
12
12
  var fs = require('fs');
13
13
 
14
- var LiveSessionError = class extends chunkE7WWIX34_cjs.TheokitAgentError {
14
+ // src/internal/persistence/session-artifacts.ts
15
+ function classifySessionArtifact(name, isDirectory) {
16
+ if (name.endsWith(".jsonl.lock")) return isDirectory ? "lock-directory" : void 0;
17
+ if (isDirectory) return void 0;
18
+ if (name.endsWith(".jsonl")) return "transcript";
19
+ if (name.endsWith(".writer.lock")) return "writer-lock";
20
+ if (chunkNETYW4V3_cjs.atomicWriteTempTarget(name) !== void 0) return "temp";
21
+ return void 0;
22
+ }
23
+ var LiveSessionError = class extends chunkYULF6FPB_cjs.TheokitAgentError {
15
24
  constructor(path) {
16
25
  super(
17
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).`,
@@ -38,7 +47,7 @@ function forkTranscript(src, dst, options = {}) {
38
47
  }
39
48
  }
40
49
  var TAIL_CHUNK = 64 * 1024;
41
- function lerCaudaBruta(path, want) {
50
+ function readRawTail(path, want) {
42
51
  const size = fs.statSync(path).size;
43
52
  const fd = fs.openSync(path, "r");
44
53
  let bytesRead = 0;
@@ -65,11 +74,11 @@ function nonEmptyLines(text) {
65
74
  }
66
75
  function readJsonlTail(path, options = {}) {
67
76
  const want = options.maxRecords ?? Number.POSITIVE_INFINITY;
68
- const { lines, bytesRead } = lerCaudaBruta(path, want);
77
+ const { lines, bytesRead } = readRawTail(path, want);
69
78
  let sel = lines;
70
79
  if (options.sinceMarker !== void 0) {
71
- const marcador = options.sinceMarker;
72
- const idx = sel.findLastIndex((l) => l.includes(marcador));
80
+ const marker = options.sinceMarker;
81
+ const idx = sel.findLastIndex((l) => l.includes(marker));
73
82
  if (idx >= 0) sel = sel.slice(idx + 1);
74
83
  }
75
84
  if (Number.isFinite(want)) sel = sel.slice(-want);
@@ -83,63 +92,63 @@ Object.defineProperty(exports, "PersistenceSchema", {
83
92
  });
84
93
  Object.defineProperty(exports, "SessionBusyError", {
85
94
  enumerable: true,
86
- get: function () { return chunk4E3HLSYE_cjs.SessionBusyError; }
95
+ get: function () { return chunkJA4FEA5Z_cjs.SessionBusyError; }
87
96
  });
88
97
  Object.defineProperty(exports, "acquireSessionWriter", {
89
98
  enumerable: true,
90
- get: function () { return chunk4E3HLSYE_cjs.acquireSessionWriter; }
99
+ get: function () { return chunkJA4FEA5Z_cjs.acquireSessionWriter; }
91
100
  });
92
101
  Object.defineProperty(exports, "sessionHasWriter", {
93
102
  enumerable: true,
94
- get: function () { return chunk4E3HLSYE_cjs.sessionHasWriter; }
103
+ get: function () { return chunkJA4FEA5Z_cjs.sessionHasWriter; }
95
104
  });
96
105
  Object.defineProperty(exports, "encodeProjectDir", {
97
106
  enumerable: true,
98
- get: function () { return chunkNJVV5OAV_cjs.encodeProjectDir; }
107
+ get: function () { return chunkWCXOKGOQ_cjs.encodeProjectDir; }
99
108
  });
100
109
  Object.defineProperty(exports, "transcriptPath", {
101
110
  enumerable: true,
102
- get: function () { return chunkNJVV5OAV_cjs.transcriptPath; }
111
+ get: function () { return chunkWCXOKGOQ_cjs.transcriptPath; }
103
112
  });
104
113
  Object.defineProperty(exports, "transcriptRoot", {
105
114
  enumerable: true,
106
- get: function () { return chunkNJVV5OAV_cjs.transcriptRoot; }
115
+ get: function () { return chunkWCXOKGOQ_cjs.transcriptRoot; }
107
116
  });
108
117
  Object.defineProperty(exports, "JsonlParseError", {
109
118
  enumerable: true,
110
- get: function () { return chunkZVQJHY4Y_cjs.JsonlParseError; }
119
+ get: function () { return chunk6W4U2G3J_cjs.JsonlParseError; }
111
120
  });
112
121
  Object.defineProperty(exports, "appendJsonl", {
113
122
  enumerable: true,
114
- get: function () { return chunkZVQJHY4Y_cjs.appendJsonl; }
123
+ get: function () { return chunk6W4U2G3J_cjs.appendJsonl; }
115
124
  });
116
125
  Object.defineProperty(exports, "loadJsonl", {
117
126
  enumerable: true,
118
- get: function () { return chunkZVQJHY4Y_cjs.loadJsonl; }
127
+ get: function () { return chunk6W4U2G3J_cjs.loadJsonl; }
119
128
  });
120
129
  Object.defineProperty(exports, "readJsonlIds", {
121
130
  enumerable: true,
122
- get: function () { return chunkZVQJHY4Y_cjs.readJsonlIds; }
131
+ get: function () { return chunk6W4U2G3J_cjs.readJsonlIds; }
123
132
  });
124
133
  Object.defineProperty(exports, "withFileLock", {
125
134
  enumerable: true,
126
- get: function () { return chunkZVQJHY4Y_cjs.withFileLock; }
135
+ get: function () { return chunk6W4U2G3J_cjs.withFileLock; }
127
136
  });
128
137
  Object.defineProperty(exports, "applyWalWithFallback", {
129
138
  enumerable: true,
130
- get: function () { return chunk4H2QARXM_cjs.applyWalWithFallback; }
139
+ get: function () { return chunkBV42CCRP_cjs.applyWalWithFallback; }
131
140
  });
132
141
  Object.defineProperty(exports, "isCorruptionError", {
133
142
  enumerable: true,
134
- get: function () { return chunk4H2QARXM_cjs.isCorruptionError; }
143
+ get: function () { return chunkBV42CCRP_cjs.isCorruptionError; }
135
144
  });
136
145
  Object.defineProperty(exports, "openSqliteResilient", {
137
146
  enumerable: true,
138
- get: function () { return chunk4H2QARXM_cjs.openSqliteResilient; }
147
+ get: function () { return chunkBV42CCRP_cjs.openSqliteResilient; }
139
148
  });
140
149
  Object.defineProperty(exports, "sanitizeFts5Query", {
141
150
  enumerable: true,
142
- get: function () { return chunk4H2QARXM_cjs.sanitizeFts5Query; }
151
+ get: function () { return chunkBV42CCRP_cjs.sanitizeFts5Query; }
143
152
  });
144
153
  Object.defineProperty(exports, "withCwdMutex", {
145
154
  enumerable: true,
@@ -147,17 +156,22 @@ Object.defineProperty(exports, "withCwdMutex", {
147
156
  });
148
157
  Object.defineProperty(exports, "atomicWriteJson", {
149
158
  enumerable: true,
150
- get: function () { return chunk33B2BSME_cjs.atomicWriteJson; }
159
+ get: function () { return chunkNETYW4V3_cjs.atomicWriteJson; }
160
+ });
161
+ Object.defineProperty(exports, "atomicWriteTempTarget", {
162
+ enumerable: true,
163
+ get: function () { return chunkNETYW4V3_cjs.atomicWriteTempTarget; }
151
164
  });
152
165
  Object.defineProperty(exports, "atomicWriteText", {
153
166
  enumerable: true,
154
- get: function () { return chunk33B2BSME_cjs.atomicWriteText; }
167
+ get: function () { return chunkNETYW4V3_cjs.atomicWriteText; }
155
168
  });
156
169
  Object.defineProperty(exports, "replaceFileAtomic", {
157
170
  enumerable: true,
158
- get: function () { return chunk33B2BSME_cjs.replaceFileAtomic; }
171
+ get: function () { return chunkNETYW4V3_cjs.replaceFileAtomic; }
159
172
  });
160
173
  exports.LiveSessionError = LiveSessionError;
174
+ exports.classifySessionArtifact = classifySessionArtifact;
161
175
  exports.forkTranscript = forkTranscript;
162
176
  exports.readJsonlTail = readJsonlTail;
163
177
  //# sourceMappingURL=persistence.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/internal/persistence/transcript-ops.ts"],"names":["TheokitAgentError","readFileSync","openSync","writeSync","closeSync","statSync","readSync"],"mappings":";;;;;;;;;;;;;AAkCO,IAAM,gBAAA,GAAN,cAA+BA,mCAAA,CAAkB;AAAA,EAGtD,YAAqB,IAAA,EAAc;AACjC,IAAA,KAAA;AAAA,MACE,qDAAqD,IAAI,CAAA,+JAAA,CAAA;AAAA,MAGzD,EAAE,IAAA,EAAM,wBAAA,EAA0B,WAAA,EAAa,KAAA;AAAM,KACvD;AANmB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAOrB;AAAA,EAPqB,IAAA;AAAA,EAFH,IAAA,GAAO,kBAAA;AAU3B;AAmCO,SAAS,cAAA,CACd,GAAA,EACA,GAAA,EACA,OAAA,GAAiC,EAAC,EAC5B;AACN,EAAA,KAAA,MAAW,IAAA,IAAQ,OAAA,CAAQ,gBAAA,IAAoB,EAAC,EAAG;AACjD,IAAA,IAAI,IAAA,KAAS,GAAA,EAAK,MAAM,IAAI,iBAAiB,GAAG,CAAA;AAAA,EAClD;AAEA,EAAA,MAAM,KAAA,GAAQC,eAAA,CAAa,GAAA,EAAK,MAAM,EACnC,KAAA,CAAM,IAAI,CAAA,CACV,MAAA,CAAO,CAAC,CAAA,KAAM,CAAA,CAAE,IAAA,EAAK,CAAE,SAAS,CAAC,CAAA;AACpC,EAAA,MAAM,IAAA,GACJ,QAAQ,iBAAA,KAAsB,MAAA,GAAY,QAAQ,KAAA,CAAM,KAAA,CAAM,C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GAAA,EAAK,EAAE,SAAA,EAAW,CAAA,GAAY,GAAA;AAChF","file":"persistence.cjs","sourcesContent":["/**\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, openSync, readFileSync, readSync, statSync, 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 /** Stop once a line contains this marker (exclusive). */\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 lerCaudaBruta(path: string, want: number): { lines: string[]; bytesRead: number } {\n const size = statSync(path).size;\n const fd = openSync(path, \"r\");\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 * 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 } = lerCaudaBruta(path, want);\n\n let sel = lines;\n if (options.sinceMarker !== undefined) {\n const marcador = options.sinceMarker;\n const idx = sel.findLastIndex((l) => l.includes(marcador));\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","statSync","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,IAAI,IAAA,CAAK,QAAA,CAAS,QAAQ,CAAA,EAAG,OAAO,YAAA;AACpC,EAAA,IAAI,IAAA,CAAK,QAAA,CAAS,cAAc,CAAA,EAAG,OAAO,aAAA;AAC1C,EAAA,IAAIA,uCAAA,CAAsB,IAAI,CAAA,KAAM,MAAA,EAAW,OAAO,MAAA;AACtD,EAAA,OAAO,MAAA;AACT;ACNO,IAAM,gBAAA,GAAN,cAA+BC,mCAAA,CAAkB;AAAA,EAGtD,YAAqB,IAAA,EAAc;AACjC,IAAA,KAAA;AAAA,MACE,qDAAqD,IAAI,CAAA,+JAAA,CAAA;AAAA,MAGzD,EAAE,IAAA,EAAM,wBAAA,EAA0B,WAAA,EAAa,KAAA;AAAM,KACvD;AANmB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAOrB;AAAA,EAPqB,IAAA;AAAA,EAFH,IAAA,GAAO,kBAAA;AAU3B;AAmCO,SAAS,cAAA,CACd,GAAA,EACA,GAAA,EACA,OAAA,GAAiC,EAAC,EAC5B;AACN,EAAA,KAAA,MAAW,IAAA,IAAQ,OAAA,CAAQ,gBAAA,IAAoB,EAAC,EAAG;AACjD,IAAA,IAAI,IAAA,KAAS,GAAA,EAAK,MAAM,IAAI,iBAAiB,GAAG,CAAA;AAAA,EAClD;AAEA,EAAA,MAAM,KAA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AA,CAAO,SAAS,IAAI,CAAA,QAAS,GAAA,CAAI,KAAA,CAAM,CAAC,IAAI,CAAA;AAEhD,EAAA,MAAM,GAAA,GAAM,IAAI,GAAA,CAAI,CAAC,MAAM,IAAA,CAAK,KAAA,CAAM,CAAC,CAAM,CAAA;AAC7C,EAAA,OAAO,OAAA,CAAQ,WAAW,IAAA,GAAQ,MAAA,CAAO,OAAO,GAAA,EAAK,EAAE,SAAA,EAAW,CAAA,GAAY,GAAA;AAChF","file":"persistence.cjs","sourcesContent":["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, openSync, readFileSync, readSync, statSync, 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 /** Stop once a line contains this marker (exclusive). */\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 const size = statSync(path).size;\n const fd = openSync(path, \"r\");\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 * 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 const idx = sel.findLastIndex((l) => l.includes(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,5 +1,5 @@
1
1
  /**
2
- * Public persistence primitives (V2-3 — Theo Harness Capability Map, Tema G).
2
+ * Public persistence primitives (V2-3 — Theo Harness Capability Map, Theme G).
3
3
  *
4
4
  * Promotes the consumer-grade persistence helpers from `internal/persistence`
5
5
  * to a STABLE, semver-protected public sub-path so consumers (e.g. a code
@@ -8,19 +8,20 @@
8
8
  * semver-exempt `@theokit/sdk/internal/persistence` path.
9
9
  *
10
10
  * Several of these were extracted FROM a real consumer (theocode's SWE-bench
11
- * harness — see the `referencia:` comments in `internal/persistence/jsonl.ts`);
11
+ * harness — see the `reference:` comments in `internal/persistence/jsonl.ts`);
12
12
  * this sub-path lets that consumer adopt its own contributed pattern back from a
13
13
  * stable home. DTS is generated via tsc (this barrel reaches `internal/`, like
14
14
  * `retry`/`compaction` — see `tsconfig.tools-dts.json`).
15
15
  */
16
16
  export type { AtomicWriteJsonOptions } from "./internal/persistence/atomic-write.js";
17
- export { atomicWriteJson, atomicWriteText, replaceFileAtomic, } from "./internal/persistence/atomic-write.js";
17
+ export { atomicWriteJson, atomicWriteTempTarget, atomicWriteText, replaceFileAtomic, } from "./internal/persistence/atomic-write.js";
18
18
  export { withCwdMutex } from "./internal/persistence/cwd-mutex.js";
19
19
  export type { FileLockOptions } from "./internal/persistence/file-lock.js";
20
20
  export { withFileLock } from "./internal/persistence/file-lock.js";
21
21
  export { sanitizeFts5Query } from "./internal/persistence/fts5-sanitize.js";
22
22
  export { appendJsonl, JsonlParseError, loadJsonl, readJsonlIds, } from "./internal/persistence/jsonl.js";
23
23
  export { PersistenceSchema } from "./internal/persistence/persistence-schema.js";
24
+ export { classifySessionArtifact, type SessionArtifact, } from "./internal/persistence/session-artifacts.js";
24
25
  export { encodeProjectDir, transcriptPath, transcriptRoot, } from "./internal/persistence/session-transcript.js";
25
26
  export { acquireSessionWriter, SessionBusyError, type SessionWriterLease, sessionHasWriter, } from "./internal/persistence/session-writer.js";
26
27
  export type { OpenSqliteResilientOptions, ResilientSqliteDb, } from "./internal/persistence/sqlite-open.js";
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Public persistence primitives (V2-3 — Theo Harness Capability Map, Tema G).
2
+ * Public persistence primitives (V2-3 — Theo Harness Capability Map, Theme G).
3
3
  *
4
4
  * Promotes the consumer-grade persistence helpers from `internal/persistence`
5
5
  * to a STABLE, semver-protected public sub-path so consumers (e.g. a code
@@ -8,19 +8,20 @@
8
8
  * semver-exempt `@theokit/sdk/internal/persistence` path.
9
9
  *
10
10
  * Several of these were extracted FROM a real consumer (theocode's SWE-bench
11
- * harness — see the `referencia:` comments in `internal/persistence/jsonl.ts`);
11
+ * harness — see the `reference:` comments in `internal/persistence/jsonl.ts`);
12
12
  * this sub-path lets that consumer adopt its own contributed pattern back from a
13
13
  * stable home. DTS is generated via tsc (this barrel reaches `internal/`, like
14
14
  * `retry`/`compaction` — see `tsconfig.tools-dts.json`).
15
15
  */
16
16
  export type { AtomicWriteJsonOptions } from "./internal/persistence/atomic-write.js";
17
- export { atomicWriteJson, atomicWriteText, replaceFileAtomic, } from "./internal/persistence/atomic-write.js";
17
+ export { atomicWriteJson, atomicWriteTempTarget, atomicWriteText, replaceFileAtomic, } from "./internal/persistence/atomic-write.js";
18
18
  export { withCwdMutex } from "./internal/persistence/cwd-mutex.js";
19
19
  export type { FileLockOptions } from "./internal/persistence/file-lock.js";
20
20
  export { withFileLock } from "./internal/persistence/file-lock.js";
21
21
  export { sanitizeFts5Query } from "./internal/persistence/fts5-sanitize.js";
22
22
  export { appendJsonl, JsonlParseError, loadJsonl, readJsonlIds, } from "./internal/persistence/jsonl.js";
23
23
  export { PersistenceSchema } from "./internal/persistence/persistence-schema.js";
24
+ export { classifySessionArtifact, type SessionArtifact, } from "./internal/persistence/session-artifacts.js";
24
25
  export { encodeProjectDir, transcriptPath, transcriptRoot, } from "./internal/persistence/session-transcript.js";
25
26
  export { acquireSessionWriter, SessionBusyError, type SessionWriterLease, sessionHasWriter, } from "./internal/persistence/session-writer.js";
26
27
  export type { OpenSqliteResilientOptions, ResilientSqliteDb, } from "./internal/persistence/sqlite-open.js";
@@ -1,14 +1,24 @@
1
1
  export { PersistenceSchema } from './chunk-CAH3G4IS.js';
2
- export { SessionBusyError, acquireSessionWriter, sessionHasWriter } from './chunk-LWVKI75U.js';
3
- export { encodeProjectDir, transcriptPath, transcriptRoot } from './chunk-EYUZZXHZ.js';
4
- export { JsonlParseError, appendJsonl, loadJsonl, readJsonlIds, withFileLock } from './chunk-5VKUZ26Q.js';
5
- export { applyWalWithFallback, isCorruptionError, openSqliteResilient, sanitizeFts5Query } from './chunk-VTDQRUAJ.js';
2
+ export { SessionBusyError, acquireSessionWriter, sessionHasWriter } from './chunk-HKSSM5RK.js';
3
+ export { encodeProjectDir, transcriptPath, transcriptRoot } from './chunk-AF4BBKIF.js';
4
+ export { JsonlParseError, appendJsonl, loadJsonl, readJsonlIds, withFileLock } from './chunk-ZNW2TXLO.js';
5
+ export { applyWalWithFallback, isCorruptionError, openSqliteResilient, sanitizeFts5Query } from './chunk-2WB6EIYW.js';
6
6
  export { withCwdMutex } from './chunk-2XLKLVVR.js';
7
- export { atomicWriteJson, atomicWriteText, replaceFileAtomic } from './chunk-5XPKYDK7.js';
8
- import { TheokitAgentError } from './chunk-VQ33XLC6.js';
9
- import './chunk-RNCN2TTP.js';
7
+ import { atomicWriteTempTarget } from './chunk-VQFSEKU5.js';
8
+ export { atomicWriteJson, atomicWriteTempTarget, atomicWriteText, replaceFileAtomic } from './chunk-VQFSEKU5.js';
9
+ import { TheokitAgentError } from './chunk-MRKSSN36.js';
10
+ import './chunk-PBML2FHN.js';
10
11
  import { readFileSync, openSync, writeSync, closeSync, statSync, readSync } from 'fs';
11
12
 
13
+ // src/internal/persistence/session-artifacts.ts
14
+ function classifySessionArtifact(name, isDirectory) {
15
+ if (name.endsWith(".jsonl.lock")) return isDirectory ? "lock-directory" : void 0;
16
+ if (isDirectory) return void 0;
17
+ if (name.endsWith(".jsonl")) return "transcript";
18
+ if (name.endsWith(".writer.lock")) return "writer-lock";
19
+ if (atomicWriteTempTarget(name) !== void 0) return "temp";
20
+ return void 0;
21
+ }
12
22
  var LiveSessionError = class extends TheokitAgentError {
13
23
  constructor(path) {
14
24
  super(
@@ -36,7 +46,7 @@ function forkTranscript(src, dst, options = {}) {
36
46
  }
37
47
  }
38
48
  var TAIL_CHUNK = 64 * 1024;
39
- function lerCaudaBruta(path, want) {
49
+ function readRawTail(path, want) {
40
50
  const size = statSync(path).size;
41
51
  const fd = openSync(path, "r");
42
52
  let bytesRead = 0;
@@ -63,11 +73,11 @@ function nonEmptyLines(text) {
63
73
  }
64
74
  function readJsonlTail(path, options = {}) {
65
75
  const want = options.maxRecords ?? Number.POSITIVE_INFINITY;
66
- const { lines, bytesRead } = lerCaudaBruta(path, want);
76
+ const { lines, bytesRead } = readRawTail(path, want);
67
77
  let sel = lines;
68
78
  if (options.sinceMarker !== void 0) {
69
- const marcador = options.sinceMarker;
70
- const idx = sel.findLastIndex((l) => l.includes(marcador));
79
+ const marker = options.sinceMarker;
80
+ const idx = sel.findLastIndex((l) => l.includes(marker));
71
81
  if (idx >= 0) sel = sel.slice(idx + 1);
72
82
  }
73
83
  if (Number.isFinite(want)) sel = sel.slice(-want);
@@ -75,6 +85,6 @@ function readJsonlTail(path, options = {}) {
75
85
  return options._stats === true ? Object.assign(out, { bytesRead }) : out;
76
86
  }
77
87
 
78
- export { LiveSessionError, forkTranscript, readJsonlTail };
88
+ export { LiveSessionError, classifySessionArtifact, forkTranscript, readJsonlTail };
79
89
  //# sourceMappingURL=persistence.js.map
80
90
  //# sourceMappingURL=persistence.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/internal/persistence/transcript-ops.ts"],"names":[],"mappings":";;;;;;;;;;;AAk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3D;AASO,SAAS,aAAA,CACd,IAAA,EACA,OAAA,GAAgC,EAAC,EAC5B;AACL,EAAA,MAAM,IAAA,GAAO,OAAA,CAAQ,UAAA,IAAc,MAAA,CAAO,iBAAA;AAC1C,EAAA,MAAM,EAAE,KAAA,EAAO,SAAA,EAAU,GAAI,aAAA,CAAc,MAAM,IAAI,CAAA;AAErD,EAAA,IAAI,GAAA,GAAM,KAAA;AACV,EAAA,IAAI,OAAA,CAAQ,gBAAgB,MAAA,EAAW;AACrC,IAAA,MAAM,WAAW,OAAA,CAAQ,WAAA;AACzB,IAAA,MAAM,GAAA,GAAM,IAAI,aAAA,CAAc,CAAC,MAAM,CAAA,CAAE,QAAA,CAAS,QAAQ,CAAC,CAAA;AACzD,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":["/**\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, openSync, readFileSync, readSync, statSync, 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 /** Stop once a line contains this marker (exclusive). */\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 lerCaudaBruta(path: string, want: number): { lines: string[]; bytesRead: number } {\n const size = statSync(path).size;\n const fd = openSync(path, \"r\");\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 * 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 } = lerCaudaBruta(path, want);\n\n let sel = lines;\n if (options.sinceMarker !== undefined) {\n const marcador = options.sinceMarker;\n const idx = sel.findLastIndex((l) => l.includes(marcador));\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,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,IAAI,IAAA,CAAK,QAAA,CAAS,QAAQ,CAAA,EAAG,OAAO,YAAA;AACp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,SAAS,cAAc,IAAA,EAAwB;AAC7C,EAAA,OAAO,IAAA,CAAK,KAAA,CAAM,IAAI,CAAA,CAAE,MAAA,CAAO,CAAC,CAAA,KAAM,CAAA,CAAE,IAAA,EAAK,CAAE,MAAA,GAAS,CAAC,CAAA;AAC3D;AASO,SAAS,aAAA,CACd,IAAA,EACA,OAAA,GAAgC,EAAC,EAC5B;AACL,EAAA,MAAM,IAAA,GAAO,OAAA,CAAQ,UAAA,IAAc,MAAA,CAAO,iBAAA;AAC1C,EAAA,MAAM,EAAE,KAAA,EAAO,SAAA,EAAU,GAAI,WAAA,CAAY,MAAM,IAAI,CAAA;AAEnD,EAAA,IAAI,GAAA,GAAM,KAAA;AACV,EAAA,IAAI,OAAA,CAAQ,gBAAgB,MAAA,EAAW;AACrC,IAAA,MAAM,SAAS,OAAA,CAAQ,WAAA;AACvB,IAAA,MAAM,GAAA,GAAM,IAAI,aAAA,CAAc,CAAC,MAAM,CAAA,CAAE,QAAA,CAAS,MAAM,CAAC,CAAA;AACvD,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, openSync, readFileSync, readSync, statSync, 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 /** Stop once a line contains this marker (exclusive). */\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 const size = statSync(path).size;\n const fd = openSync(path, \"r\");\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 * 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 const idx = sel.findLastIndex((l) => l.includes(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,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkYPEPCZHF_cjs = require('./chunk-YPEPCZHF.cjs');
4
- var chunk33B2BSME_cjs = require('./chunk-33B2BSME.cjs');
5
- var chunkE7WWIX34_cjs = require('./chunk-E7WWIX34.cjs');
6
- require('./chunk-A76OFN2B.cjs');
4
+ var chunkNETYW4V3_cjs = require('./chunk-NETYW4V3.cjs');
5
+ var chunkYULF6FPB_cjs = require('./chunk-YULF6FPB.cjs');
6
+ require('./chunk-ZHPET3LZ.cjs');
7
7
  var promises = require('fs/promises');
8
8
  var path = require('path');
9
9
 
@@ -31,12 +31,12 @@ function reduceContent(files, scope) {
31
31
  async function writeProjectInstructions(cwd, content, options) {
32
32
  const filename = options?.filename ?? DEFAULT_FILENAME;
33
33
  if (!chunkYPEPCZHF_cjs.isSafePattern(filename)) {
34
- throw new chunkE7WWIX34_cjs.ConfigurationError(
34
+ throw new chunkYULF6FPB_cjs.ConfigurationError(
35
35
  `writeProjectInstructions: unsafe filename ${JSON.stringify(filename)} (no path traversal, separators, or absolute paths)`,
36
36
  { code: "unsafe_filename" }
37
37
  );
38
38
  }
39
- await chunk33B2BSME_cjs.replaceFileAtomic(path.join(cwd, filename), content);
39
+ await chunkNETYW4V3_cjs.replaceFileAtomic(path.join(cwd, filename), content);
40
40
  }
41
41
 
42
42
  exports.readProjectInstructions = readProjectInstructions;
package/dist/project.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { walkUpForFile, isSafePattern } from './chunk-UJ7IQJAG.js';
2
- import { replaceFileAtomic } from './chunk-5XPKYDK7.js';
3
- import { ConfigurationError } from './chunk-VQ33XLC6.js';
4
- import './chunk-RNCN2TTP.js';
2
+ import { replaceFileAtomic } from './chunk-VQFSEKU5.js';
3
+ import { ConfigurationError } from './chunk-MRKSSN36.js';
4
+ import './chunk-PBML2FHN.js';
5
5
  import { readFile } from 'fs/promises';
6
6
  import { join } from 'path';
7
7
 
@@ -0,0 +1,46 @@
1
+ 'use strict';
2
+
3
+ var chunkKCQUYQ3V_cjs = require('./chunk-KCQUYQ3V.cjs');
4
+ require('./chunk-BUUUWQMB.cjs');
5
+ require('./chunk-27DYRARU.cjs');
6
+ require('./chunk-XR4LPBXH.cjs');
7
+ require('./chunk-NETYW4V3.cjs');
8
+ require('./chunk-YULF6FPB.cjs');
9
+ require('./chunk-ZHPET3LZ.cjs');
10
+
11
+
12
+
13
+ Object.defineProperty(exports, "__getSubscribersCountForTests", {
14
+ enumerable: true,
15
+ get: function () { return chunkKCQUYQ3V_cjs.__getSubscribersCountForTests; }
16
+ });
17
+ Object.defineProperty(exports, "__resetTaskRegistryForTests", {
18
+ enumerable: true,
19
+ get: function () { return chunkKCQUYQ3V_cjs.__resetTaskRegistryForTests; }
20
+ });
21
+ Object.defineProperty(exports, "cancel", {
22
+ enumerable: true,
23
+ get: function () { return chunkKCQUYQ3V_cjs.cancel; }
24
+ });
25
+ Object.defineProperty(exports, "configure", {
26
+ enumerable: true,
27
+ get: function () { return chunkKCQUYQ3V_cjs.configure; }
28
+ });
29
+ Object.defineProperty(exports, "get", {
30
+ enumerable: true,
31
+ get: function () { return chunkKCQUYQ3V_cjs.get; }
32
+ });
33
+ Object.defineProperty(exports, "list", {
34
+ enumerable: true,
35
+ get: function () { return chunkKCQUYQ3V_cjs.list; }
36
+ });
37
+ Object.defineProperty(exports, "submit", {
38
+ enumerable: true,
39
+ get: function () { return chunkKCQUYQ3V_cjs.submit; }
40
+ });
41
+ Object.defineProperty(exports, "subscribe", {
42
+ enumerable: true,
43
+ get: function () { return chunkKCQUYQ3V_cjs.subscribe; }
44
+ });
45
+ //# sourceMappingURL=registry-KB3TS6BM.cjs.map
46
+ //# sourceMappingURL=registry-KB3TS6BM.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"registry-VKDFTK6L.cjs"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"registry-KB3TS6BM.cjs"}
@@ -0,0 +1,9 @@
1
+ export { __getSubscribersCountForTests, __resetTaskRegistryForTests, cancel, configure, get, list, submit, subscribe } from './chunk-GNMPCZNN.js';
2
+ import './chunk-K2BQQ445.js';
3
+ import './chunk-Q4DTGCSD.js';
4
+ import './chunk-NOM2YWFP.js';
5
+ import './chunk-VQFSEKU5.js';
6
+ import './chunk-MRKSSN36.js';
7
+ import './chunk-PBML2FHN.js';
8
+ //# sourceMappingURL=registry-PPFMCM4A.js.map
9
+ //# sourceMappingURL=registry-PPFMCM4A.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"registry-AXQXPLFH.js"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"registry-PPFMCM4A.js"}
package/dist/retry.cjs CHANGED
@@ -1,14 +1,14 @@
1
1
  'use strict';
2
2
 
3
- var chunkPY7G7YWK_cjs = require('./chunk-PY7G7YWK.cjs');
4
- require('./chunk-E7WWIX34.cjs');
5
- require('./chunk-A76OFN2B.cjs');
3
+ var chunkMMZX557L_cjs = require('./chunk-MMZX557L.cjs');
4
+ require('./chunk-YULF6FPB.cjs');
5
+ require('./chunk-ZHPET3LZ.cjs');
6
6
 
7
7
 
8
8
 
9
9
  Object.defineProperty(exports, "Retry", {
10
10
  enumerable: true,
11
- get: function () { return chunkPY7G7YWK_cjs.Retry; }
11
+ get: function () { return chunkMMZX557L_cjs.Retry; }
12
12
  });
13
13
  //# sourceMappingURL=retry.cjs.map
14
14
  //# sourceMappingURL=retry.cjs.map
package/dist/retry.js CHANGED
@@ -1,5 +1,5 @@
1
- export { Retry } from './chunk-4H2DCO6P.js';
2
- import './chunk-VQ33XLC6.js';
3
- import './chunk-RNCN2TTP.js';
1
+ export { Retry } from './chunk-LXKNENHK.js';
2
+ import './chunk-MRKSSN36.js';
3
+ import './chunk-PBML2FHN.js';
4
4
  //# sourceMappingURL=retry.js.map
5
5
  //# sourceMappingURL=retry.js.map
@@ -274,7 +274,26 @@ declare class PermissionEngine {
274
274
  *
275
275
  * @public
276
276
  */
277
- type RunEvent = RunToolProgressEvent | RunRateLimitEvent | RunPermissionDeniedEvent | RunTaskStartedEvent | RunTaskUpdatedEvent | RunTaskCompletedEvent | RunCompactBoundaryEvent | RunCompactionFallbackEvent | RunTripwireEvent | RunCompletionCheckEvent;
277
+ type RunEvent = RunToolProgressEvent | RunRateLimitEvent | RunPermissionDeniedEvent | RunTaskStartedEvent | RunTaskUpdatedEvent | RunTaskCompletedEvent | RunCompactBoundaryEvent | RunCompactionFallbackEvent | RunTripwireEvent | RunCompletionCheckEvent | RunMcpServerFailedEvent;
278
+ /**
279
+ * theokit#188 — an MCP server was configured but its tools could not be listed, so NONE of its
280
+ * tools exist for this run.
281
+ *
282
+ * The failure was always caught (`safeListTools` returns `[]` so one broken server cannot take the
283
+ * turn down) and always DIAGNOSED — to `diag()`, i.e. the SDK's stderr. Nothing reached the
284
+ * consumer, so a UI listing configured servers could show one as present while every tool it
285
+ * provides had silently vanished. Degrading gracefully is right; degrading INVISIBLY is not.
286
+ *
287
+ * Emitted once per failing server per run, on the same catch path that already had both the name
288
+ * and the reason.
289
+ */
290
+ interface RunMcpServerFailedEvent {
291
+ readonly type: "mcp_server_failed";
292
+ /** The server as named in the MCP configuration, so the consumer can match it to what it lists. */
293
+ readonly serverName: string;
294
+ /** Why listing failed — a spawn error, a handshake timeout, a protocol error. */
295
+ readonly message: string;
296
+ }
278
297
  /**
279
298
  * SE24 — a guardrail processor called `abort()`; the run stops with a tripwire.
280
299
  * Delivered via {@link SendOptions.onRunEvent} (mirrors the `RunResult.tripwire`
@@ -1024,7 +1043,7 @@ type CostStatus = "actual" | "estimated" | "included" | "unknown";
1024
1043
  type CostSource = "openrouter_api" | "litellm_snapshot" | "user_override" | "subscription_included" | "unknown";
1025
1044
  /**
1026
1045
  * Cost breakdown attached to `RunResult.cost`. When `status === "unknown"`,
1027
- * `amountUsd` is `undefined` — DO NOT default to 0 (mentira). UI exibe
1046
+ * `amountUsd` is `undefined` — DO NOT default to 0 (a lie). The UI shows
1028
1047
  * `n/a` para unknown, `~$1.23` para estimated, `$1.23` para actual.
1029
1048
  */
1030
1049
  interface CostBreakdown {
@@ -274,7 +274,26 @@ declare class PermissionEngine {
274
274
  *
275
275
  * @public
276
276
  */
277
- type RunEvent = RunToolProgressEvent | RunRateLimitEvent | RunPermissionDeniedEvent | RunTaskStartedEvent | RunTaskUpdatedEvent | RunTaskCompletedEvent | RunCompactBoundaryEvent | RunCompactionFallbackEvent | RunTripwireEvent | RunCompletionCheckEvent;
277
+ type RunEvent = RunToolProgressEvent | RunRateLimitEvent | RunPermissionDeniedEvent | RunTaskStartedEvent | RunTaskUpdatedEvent | RunTaskCompletedEvent | RunCompactBoundaryEvent | RunCompactionFallbackEvent | RunTripwireEvent | RunCompletionCheckEvent | RunMcpServerFailedEvent;
278
+ /**
279
+ * theokit#188 — an MCP server was configured but its tools could not be listed, so NONE of its
280
+ * tools exist for this run.
281
+ *
282
+ * The failure was always caught (`safeListTools` returns `[]` so one broken server cannot take the
283
+ * turn down) and always DIAGNOSED — to `diag()`, i.e. the SDK's stderr. Nothing reached the
284
+ * consumer, so a UI listing configured servers could show one as present while every tool it
285
+ * provides had silently vanished. Degrading gracefully is right; degrading INVISIBLY is not.
286
+ *
287
+ * Emitted once per failing server per run, on the same catch path that already had both the name
288
+ * and the reason.
289
+ */
290
+ interface RunMcpServerFailedEvent {
291
+ readonly type: "mcp_server_failed";
292
+ /** The server as named in the MCP configuration, so the consumer can match it to what it lists. */
293
+ readonly serverName: string;
294
+ /** Why listing failed — a spawn error, a handshake timeout, a protocol error. */
295
+ readonly message: string;
296
+ }
278
297
  /**
279
298
  * SE24 — a guardrail processor called `abort()`; the run stops with a tripwire.
280
299
  * Delivered via {@link SendOptions.onRunEvent} (mirrors the `RunResult.tripwire`
@@ -1024,7 +1043,7 @@ type CostStatus = "actual" | "estimated" | "included" | "unknown";
1024
1043
  type CostSource = "openrouter_api" | "litellm_snapshot" | "user_override" | "subscription_included" | "unknown";
1025
1044
  /**
1026
1045
  * Cost breakdown attached to `RunResult.cost`. When `status === "unknown"`,
1027
- * `amountUsd` is `undefined` — DO NOT default to 0 (mentira). UI exibe
1046
+ * `amountUsd` is `undefined` — DO NOT default to 0 (a lie). The UI shows
1028
1047
  * `n/a` para unknown, `~$1.23` para estimated, `$1.23` para actual.
1029
1048
  */
1030
1049
  interface CostBreakdown {