@theokit/sdk 4.62.0 → 4.63.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (379) hide show
  1. package/CHANGELOG.md +97 -0
  2. package/dist/a2a/index.cjs +2 -2
  3. package/dist/a2a/index.js +1 -1
  4. package/dist/{agent-DIu6FooJ.d.ts → agent-BFno7Sfn.d.ts} +36 -21
  5. package/dist/agent-WK7MKIMH.cjs +66 -0
  6. package/dist/{agent-VYPUO4UB.cjs.map → agent-WK7MKIMH.cjs.map} +1 -1
  7. package/dist/{agent-D3Xr_-6Z.d.cts → agent-X0DKA943.d.cts} +36 -21
  8. package/dist/agent-YWMBM7LX.js +57 -0
  9. package/dist/{agent-NVBFTY5H.js.map → agent-YWMBM7LX.js.map} +1 -1
  10. package/dist/agent-session-store-6EL5NPA4.cjs +24 -0
  11. package/dist/{agent-session-store-WAKLOKWK.cjs.map → agent-session-store-6EL5NPA4.cjs.map} +1 -1
  12. package/dist/agent-session-store-OPGRB4XM.js +7 -0
  13. package/dist/{agent-session-store-G2BMUZQV.js.map → agent-session-store-OPGRB4XM.js.map} +1 -1
  14. package/dist/auth/index.cjs +18 -18
  15. package/dist/auth/index.js +6 -6
  16. package/dist/{batch-ND32UKZS.cjs → batch-BXYTW2DP.cjs} +27 -27
  17. package/dist/{batch-ND32UKZS.cjs.map → batch-BXYTW2DP.cjs.map} +1 -1
  18. package/dist/{batch-2TGJMNCJ.js → batch-L4ZXS46M.js} +10 -10
  19. package/dist/{batch-2TGJMNCJ.js.map → batch-L4ZXS46M.js.map} +1 -1
  20. package/dist/{chunk-VF7EWVDG.js → chunk-2GUYQR5P.js} +3 -3
  21. package/dist/{chunk-VF7EWVDG.js.map → chunk-2GUYQR5P.js.map} +1 -1
  22. package/dist/{chunk-J2UROOIG.cjs → chunk-2HVF2WJY.cjs} +8 -8
  23. package/dist/{chunk-J2UROOIG.cjs.map → chunk-2HVF2WJY.cjs.map} +1 -1
  24. package/dist/{chunk-44MBDIHG.js → chunk-2QDYBS2A.js} +3 -3
  25. package/dist/{chunk-44MBDIHG.js.map → chunk-2QDYBS2A.js.map} +1 -1
  26. package/dist/{chunk-NGESVVJN.cjs → chunk-3FFAEAUJ.cjs} +17 -17
  27. package/dist/{chunk-NGESVVJN.cjs.map → chunk-3FFAEAUJ.cjs.map} +1 -1
  28. package/dist/{chunk-GWC3HADL.cjs → chunk-3NSS2OIZ.cjs} +4 -4
  29. package/dist/{chunk-GWC3HADL.cjs.map → chunk-3NSS2OIZ.cjs.map} +1 -1
  30. package/dist/{chunk-CV7XMBHP.js → chunk-3O42QOMJ.js} +3 -3
  31. package/dist/{chunk-CV7XMBHP.js.map → chunk-3O42QOMJ.js.map} +1 -1
  32. package/dist/{chunk-IWBGCBR6.cjs → chunk-4CLOXP6H.cjs} +4 -4
  33. package/dist/{chunk-IWBGCBR6.cjs.map → chunk-4CLOXP6H.cjs.map} +1 -1
  34. package/dist/{chunk-YEXA3PGR.js → chunk-4FFBAUFS.js} +5 -5
  35. package/dist/{chunk-YEXA3PGR.js.map → chunk-4FFBAUFS.js.map} +1 -1
  36. package/dist/{chunk-HY57ULY2.cjs → chunk-4PYZ5AX3.cjs} +5 -5
  37. package/dist/{chunk-HY57ULY2.cjs.map → chunk-4PYZ5AX3.cjs.map} +1 -1
  38. package/dist/{chunk-OC4NTGMN.js → chunk-4QZSA2HJ.js} +3 -3
  39. package/dist/{chunk-OC4NTGMN.js.map → chunk-4QZSA2HJ.js.map} +1 -1
  40. package/dist/{chunk-K3FW2XZD.cjs → chunk-4ZHTIJNE.cjs} +9 -9
  41. package/dist/{chunk-K3FW2XZD.cjs.map → chunk-4ZHTIJNE.cjs.map} +1 -1
  42. package/dist/{chunk-BUIK7GUA.cjs → chunk-5HEG4CQH.cjs} +8 -8
  43. package/dist/{chunk-BUIK7GUA.cjs.map → chunk-5HEG4CQH.cjs.map} +1 -1
  44. package/dist/{chunk-SKXBJ2NU.cjs → chunk-5VB22SYX.cjs} +7 -54
  45. package/dist/chunk-5VB22SYX.cjs.map +1 -0
  46. package/dist/{chunk-5USCYPPI.cjs → chunk-6HKGLTJI.cjs} +8 -8
  47. package/dist/{chunk-5USCYPPI.cjs.map → chunk-6HKGLTJI.cjs.map} +1 -1
  48. package/dist/chunk-6RKUO7AW.cjs +864 -0
  49. package/dist/chunk-6RKUO7AW.cjs.map +1 -0
  50. package/dist/{chunk-5JLFFPCH.js → chunk-7YGCPMGB.js} +4 -4
  51. package/dist/{chunk-5JLFFPCH.js.map → chunk-7YGCPMGB.js.map} +1 -1
  52. package/dist/{chunk-SUKXXLWD.js → chunk-A46SWMIF.js} +6 -6
  53. package/dist/{chunk-SUKXXLWD.js.map → chunk-A46SWMIF.js.map} +1 -1
  54. package/dist/{chunk-F7AQV62G.js → chunk-A4JVILQU.js} +5 -5
  55. package/dist/{chunk-F7AQV62G.js.map → chunk-A4JVILQU.js.map} +1 -1
  56. package/dist/chunk-A4RAL2ER.cjs +51 -0
  57. package/dist/chunk-A4RAL2ER.cjs.map +1 -0
  58. package/dist/{chunk-44JAAH4X.js → chunk-B3IMEBOA.js} +3 -3
  59. package/dist/{chunk-44JAAH4X.js.map → chunk-B3IMEBOA.js.map} +1 -1
  60. package/dist/{chunk-QDED6YO6.cjs → chunk-B4EOJWOY.cjs} +5 -5
  61. package/dist/{chunk-QDED6YO6.cjs.map → chunk-B4EOJWOY.cjs.map} +1 -1
  62. package/dist/{chunk-YJDH3CKG.js → chunk-BP46RJ5X.js} +5 -5
  63. package/dist/{chunk-YJDH3CKG.js.map → chunk-BP46RJ5X.js.map} +1 -1
  64. package/dist/{chunk-QRSUA2CV.js → chunk-BU4KFWXF.js} +3 -3
  65. package/dist/{chunk-QRSUA2CV.js.map → chunk-BU4KFWXF.js.map} +1 -1
  66. package/dist/{chunk-IBYRA5PM.js → chunk-BVJJ3DRV.js} +6 -6
  67. package/dist/{chunk-IBYRA5PM.js.map → chunk-BVJJ3DRV.js.map} +1 -1
  68. package/dist/{chunk-AQLGBKNT.js → chunk-BZRFXJHA.js} +3 -3
  69. package/dist/{chunk-AQLGBKNT.js.map → chunk-BZRFXJHA.js.map} +1 -1
  70. package/dist/{chunk-UQGQFBRL.js → chunk-C3NT3PVE.js} +3 -3
  71. package/dist/{chunk-UQGQFBRL.js.map → chunk-C3NT3PVE.js.map} +1 -1
  72. package/dist/{chunk-UC3HT2S4.js → chunk-C72AZW7J.js} +3 -3
  73. package/dist/{chunk-UC3HT2S4.js.map → chunk-C72AZW7J.js.map} +1 -1
  74. package/dist/{chunk-WNTAPVU5.cjs → chunk-CQBXOJ6U.cjs} +13 -13
  75. package/dist/{chunk-WNTAPVU5.cjs.map → chunk-CQBXOJ6U.cjs.map} +1 -1
  76. package/dist/{chunk-T7XEKOVW.js → chunk-D4CUGAKZ.js} +3 -3
  77. package/dist/{chunk-T7XEKOVW.js.map → chunk-D4CUGAKZ.js.map} +1 -1
  78. package/dist/chunk-DKD3MH6A.js +194 -0
  79. package/dist/chunk-DKD3MH6A.js.map +1 -0
  80. package/dist/{chunk-YXGAW7BB.js → chunk-DN2PACRI.js} +10 -10
  81. package/dist/{chunk-YXGAW7BB.js.map → chunk-DN2PACRI.js.map} +1 -1
  82. package/dist/{chunk-XSX2UU6Y.cjs → chunk-DXGZ2NUG.cjs} +10 -10
  83. package/dist/{chunk-XSX2UU6Y.cjs.map → chunk-DXGZ2NUG.cjs.map} +1 -1
  84. package/dist/{chunk-NUKRL3I6.cjs → chunk-EG4QM7ZJ.cjs} +18 -2
  85. package/dist/chunk-EG4QM7ZJ.cjs.map +1 -0
  86. package/dist/chunk-GEEXBYFL.js +831 -0
  87. package/dist/chunk-GEEXBYFL.js.map +1 -0
  88. package/dist/chunk-GKEFRLU7.cjs +21 -0
  89. package/dist/chunk-GKEFRLU7.cjs.map +1 -0
  90. package/dist/{chunk-NIRE5CNO.cjs → chunk-HCZD23VS.cjs} +13 -13
  91. package/dist/{chunk-NIRE5CNO.cjs.map → chunk-HCZD23VS.cjs.map} +1 -1
  92. package/dist/chunk-HOXVQ5FR.cjs +201 -0
  93. package/dist/chunk-HOXVQ5FR.cjs.map +1 -0
  94. package/dist/{chunk-QARJGQSA.js → chunk-HS7AVXTF.js} +3 -3
  95. package/dist/{chunk-QARJGQSA.js.map → chunk-HS7AVXTF.js.map} +1 -1
  96. package/dist/{chunk-4I55V454.cjs → chunk-I6HGWHPU.cjs} +4 -4
  97. package/dist/{chunk-4I55V454.cjs.map → chunk-I6HGWHPU.cjs.map} +1 -1
  98. package/dist/{chunk-T73NA43R.js → chunk-IPYYKCRC.js} +3 -3
  99. package/dist/{chunk-T73NA43R.js.map → chunk-IPYYKCRC.js.map} +1 -1
  100. package/dist/{chunk-6OBIWHDR.cjs → chunk-ITYQ6VBP.cjs} +24 -365
  101. package/dist/chunk-ITYQ6VBP.cjs.map +1 -0
  102. package/dist/chunk-JPBKYL3B.cjs +18 -0
  103. package/dist/{chunk-6HTXPPHK.cjs.map → chunk-JPBKYL3B.cjs.map} +1 -1
  104. package/dist/{chunk-MZ2FGBLZ.js → chunk-K5OJUYSZ.js} +4 -4
  105. package/dist/{chunk-MZ2FGBLZ.js.map → chunk-K5OJUYSZ.js.map} +1 -1
  106. package/dist/{chunk-SKOCYA55.js → chunk-KIH6IZ43.js} +90 -88
  107. package/dist/chunk-KIH6IZ43.js.map +1 -0
  108. package/dist/{chunk-EI2Q7SJ5.cjs → chunk-KQ7TS7WW.cjs} +10 -10
  109. package/dist/{chunk-EI2Q7SJ5.cjs.map → chunk-KQ7TS7WW.cjs.map} +1 -1
  110. package/dist/{chunk-RUDY2GTT.js → chunk-KQRW2GPZ.js} +5 -5
  111. package/dist/{chunk-RUDY2GTT.js.map → chunk-KQRW2GPZ.js.map} +1 -1
  112. package/dist/{chunk-P5LCASTC.cjs → chunk-KYAJINUI.cjs} +125 -125
  113. package/dist/{chunk-P5LCASTC.cjs.map → chunk-KYAJINUI.cjs.map} +1 -1
  114. package/dist/{chunk-CQ2TQ32Y.js → chunk-LWGSI6M3.js} +5 -50
  115. package/dist/chunk-LWGSI6M3.js.map +1 -0
  116. package/dist/{chunk-ZHPWGIUX.js → chunk-LXI4XZEC.js} +5 -5
  117. package/dist/{chunk-ZHPWGIUX.js.map → chunk-LXI4XZEC.js.map} +1 -1
  118. package/dist/{chunk-AG5JPQIY.js → chunk-LXQ6HKPS.js} +3 -3
  119. package/dist/{chunk-AG5JPQIY.js.map → chunk-LXQ6HKPS.js.map} +1 -1
  120. package/dist/{chunk-ROYPRJH4.cjs → chunk-LYRDF5TQ.cjs} +9 -9
  121. package/dist/{chunk-ROYPRJH4.cjs.map → chunk-LYRDF5TQ.cjs.map} +1 -1
  122. package/dist/{chunk-G24KZRSA.js → chunk-N2U4AZGB.js} +3 -3
  123. package/dist/{chunk-G24KZRSA.js.map → chunk-N2U4AZGB.js.map} +1 -1
  124. package/dist/{chunk-4ERPXIVB.js → chunk-O73J46PV.js} +5 -5
  125. package/dist/{chunk-4ERPXIVB.js.map → chunk-O73J46PV.js.map} +1 -1
  126. package/dist/{chunk-F3YZMOAU.cjs → chunk-O7DK5PBJ.cjs} +4 -4
  127. package/dist/{chunk-F3YZMOAU.cjs.map → chunk-O7DK5PBJ.cjs.map} +1 -1
  128. package/dist/{chunk-Z4BCLVTI.cjs → chunk-O7LZFG6O.cjs} +5 -5
  129. package/dist/{chunk-Z4BCLVTI.cjs.map → chunk-O7LZFG6O.cjs.map} +1 -1
  130. package/dist/{chunk-3YJNUKYN.cjs → chunk-OHLDPWTA.cjs} +15 -15
  131. package/dist/{chunk-3YJNUKYN.cjs.map → chunk-OHLDPWTA.cjs.map} +1 -1
  132. package/dist/{chunk-FUL2I7G5.js → chunk-OSEG74VJ.js} +8 -8
  133. package/dist/{chunk-FUL2I7G5.js.map → chunk-OSEG74VJ.js.map} +1 -1
  134. package/dist/{chunk-UCBJBJ27.js → chunk-PUAEFLYK.js} +4 -4
  135. package/dist/{chunk-UCBJBJ27.js.map → chunk-PUAEFLYK.js.map} +1 -1
  136. package/dist/{chunk-CWHTMNNK.cjs → chunk-Q7LPTOD6.cjs} +24 -24
  137. package/dist/{chunk-CWHTMNNK.cjs.map → chunk-Q7LPTOD6.cjs.map} +1 -1
  138. package/dist/{chunk-2C72DXQF.cjs → chunk-RFMBZPOW.cjs} +9 -9
  139. package/dist/{chunk-2C72DXQF.cjs.map → chunk-RFMBZPOW.cjs.map} +1 -1
  140. package/dist/{chunk-NLTVXLGT.js → chunk-RFXWMRFC.js} +3 -3
  141. package/dist/{chunk-NLTVXLGT.js.map → chunk-RFXWMRFC.js.map} +1 -1
  142. package/dist/{chunk-2DG7KW4L.cjs → chunk-RMWTPV3M.cjs} +8 -8
  143. package/dist/{chunk-2DG7KW4L.cjs.map → chunk-RMWTPV3M.cjs.map} +1 -1
  144. package/dist/{chunk-P6A3M6VD.cjs → chunk-SZVR77EJ.cjs} +10 -10
  145. package/dist/{chunk-P6A3M6VD.cjs.map → chunk-SZVR77EJ.cjs.map} +1 -1
  146. package/dist/{chunk-3E77SX4H.js → chunk-TAZVKYWJ.js} +3 -3
  147. package/dist/{chunk-3E77SX4H.js.map → chunk-TAZVKYWJ.js.map} +1 -1
  148. package/dist/{chunk-WKRSH2VR.js → chunk-U6IFHFWK.js} +3 -3
  149. package/dist/{chunk-WKRSH2VR.js.map → chunk-U6IFHFWK.js.map} +1 -1
  150. package/dist/{chunk-I6TGFUCO.cjs → chunk-UALX2J2Q.cjs} +4 -4
  151. package/dist/{chunk-I6TGFUCO.cjs.map → chunk-UALX2J2Q.cjs.map} +1 -1
  152. package/dist/{chunk-XN7NOENA.js → chunk-UBDMVMBZ.js} +5 -5
  153. package/dist/{chunk-XN7NOENA.js.map → chunk-UBDMVMBZ.js.map} +1 -1
  154. package/dist/{chunk-QEKI3YKI.js → chunk-UEXIJTLC.js} +14 -349
  155. package/dist/chunk-UEXIJTLC.js.map +1 -0
  156. package/dist/{chunk-DQKERTND.cjs → chunk-UGT7GK7I.cjs} +11 -11
  157. package/dist/{chunk-DQKERTND.cjs.map → chunk-UGT7GK7I.cjs.map} +1 -1
  158. package/dist/{chunk-FKMUFNQE.js → chunk-UMP6OJIM.js} +4 -4
  159. package/dist/{chunk-FKMUFNQE.js.map → chunk-UMP6OJIM.js.map} +1 -1
  160. package/dist/{chunk-AEOZTXVW.js → chunk-UNYXQ4M5.js} +3 -3
  161. package/dist/{chunk-AEOZTXVW.js.map → chunk-UNYXQ4M5.js.map} +1 -1
  162. package/dist/{chunk-2BDH744Z.js → chunk-UTSRIDKZ.js} +3 -3
  163. package/dist/{chunk-2BDH744Z.js.map → chunk-UTSRIDKZ.js.map} +1 -1
  164. package/dist/{chunk-2ADR2GSO.cjs → chunk-UU36SHFY.cjs} +5 -5
  165. package/dist/{chunk-2ADR2GSO.cjs.map → chunk-UU36SHFY.cjs.map} +1 -1
  166. package/dist/{chunk-R3UPQFKK.cjs → chunk-V2BOS4WF.cjs} +9 -9
  167. package/dist/{chunk-R3UPQFKK.cjs.map → chunk-V2BOS4WF.cjs.map} +1 -1
  168. package/dist/chunk-WE22OXQA.js +48 -0
  169. package/dist/chunk-WE22OXQA.js.map +1 -0
  170. package/dist/{chunk-Q4CMI2LP.js → chunk-WLQNMXQE.js} +5 -5
  171. package/dist/{chunk-Q4CMI2LP.js.map → chunk-WLQNMXQE.js.map} +1 -1
  172. package/dist/{chunk-XWL6O3SW.cjs → chunk-WNO3C3N2.cjs} +4 -4
  173. package/dist/{chunk-XWL6O3SW.cjs.map → chunk-WNO3C3N2.cjs.map} +1 -1
  174. package/dist/{chunk-T7O6K6PX.js → chunk-XEQ3TM66.js} +18 -3
  175. package/dist/chunk-XEQ3TM66.js.map +1 -0
  176. package/dist/{chunk-BVZW2B5V.cjs → chunk-XJCXEKMD.cjs} +4 -4
  177. package/dist/{chunk-BVZW2B5V.cjs.map → chunk-XJCXEKMD.cjs.map} +1 -1
  178. package/dist/{chunk-JTB5Q42C.cjs → chunk-XL7Q7HB2.cjs} +4 -4
  179. package/dist/{chunk-JTB5Q42C.cjs.map → chunk-XL7Q7HB2.cjs.map} +1 -1
  180. package/dist/chunk-XO4SOZN6.js +19 -0
  181. package/dist/chunk-XO4SOZN6.js.map +1 -0
  182. package/dist/{chunk-CQGYNZ3K.cjs → chunk-XWTLIGO3.cjs} +4 -4
  183. package/dist/{chunk-CQGYNZ3K.cjs.map → chunk-XWTLIGO3.cjs.map} +1 -1
  184. package/dist/{chunk-6SBW4QR2.cjs → chunk-YML4ME27.cjs} +11 -11
  185. package/dist/{chunk-6SBW4QR2.cjs.map → chunk-YML4ME27.cjs.map} +1 -1
  186. package/dist/{chunk-P6H23T43.cjs → chunk-ZCIRZE37.cjs} +11 -11
  187. package/dist/{chunk-P6H23T43.cjs.map → chunk-ZCIRZE37.cjs.map} +1 -1
  188. package/dist/{chunk-QI7WE46I.cjs → chunk-ZLQSWSJ2.cjs} +11 -11
  189. package/dist/{chunk-QI7WE46I.cjs.map → chunk-ZLQSWSJ2.cjs.map} +1 -1
  190. package/dist/{chunk-AH6WD7JR.cjs → chunk-ZMRD5DZQ.cjs} +362 -360
  191. package/dist/chunk-ZMRD5DZQ.cjs.map +1 -0
  192. package/dist/{chunk-ILCGLTSA.cjs → chunk-ZSWPZ23K.cjs} +4 -4
  193. package/dist/{chunk-ILCGLTSA.cjs.map → chunk-ZSWPZ23K.cjs.map} +1 -1
  194. package/dist/{chunk-IDCKSLYH.js → chunk-ZZMZWBR6.js} +3 -3
  195. package/dist/{chunk-IDCKSLYH.js.map → chunk-ZZMZWBR6.js.map} +1 -1
  196. package/dist/compact-session-QV57KR66.cjs +59 -0
  197. package/dist/{compact-session-GJXJD73F.cjs.map → compact-session-QV57KR66.cjs.map} +1 -1
  198. package/dist/compact-session-RIGOWC4Y.js +22 -0
  199. package/dist/{compact-session-TSMQOIHO.js.map → compact-session-RIGOWC4Y.js.map} +1 -1
  200. package/dist/compaction.cjs +17 -17
  201. package/dist/compaction.js +4 -4
  202. package/dist/concurrency.cjs +7 -7
  203. package/dist/concurrency.js +5 -5
  204. package/dist/context-AGQ3DIZU.cjs +24 -0
  205. package/dist/{context-LCKNH2XI.cjs.map → context-AGQ3DIZU.cjs.map} +1 -1
  206. package/dist/context-GQRFBCLP.js +7 -0
  207. package/dist/{context-MZSKGKYR.js.map → context-GQRFBCLP.js.map} +1 -1
  208. package/dist/{cron-BcWmzWzT.d.cts → cron-BuiRPrvt.d.cts} +1 -1
  209. package/dist/{cron-De6hzWCF.d.ts → cron-C2SIi31n.d.ts} +1 -1
  210. package/dist/cron.cjs +37 -35
  211. package/dist/cron.d.cts +2 -2
  212. package/dist/cron.d.ts +2 -2
  213. package/dist/cron.js +36 -34
  214. package/dist/errors.cjs +22 -22
  215. package/dist/errors.js +3 -3
  216. package/dist/eval.cjs +42 -40
  217. package/dist/eval.cjs.map +1 -1
  218. package/dist/eval.js +36 -34
  219. package/dist/eval.js.map +1 -1
  220. package/dist/{executor-ZERJ3DGN.cjs → executor-6CYCA7MI.cjs} +25 -25
  221. package/dist/{executor-ZERJ3DGN.cjs.map → executor-6CYCA7MI.cjs.map} +1 -1
  222. package/dist/{executor-BMEHFOXZ.js → executor-QSEC3MRH.js} +8 -8
  223. package/dist/{executor-BMEHFOXZ.js.map → executor-QSEC3MRH.js.map} +1 -1
  224. package/dist/filesystem/index.cjs +8 -8
  225. package/dist/filesystem/index.js +4 -4
  226. package/dist/fs-session-store-4PIHT5UX.cjs +20 -0
  227. package/dist/{fs-session-store-XZ7ZTB3A.cjs.map → fs-session-store-4PIHT5UX.cjs.map} +1 -1
  228. package/dist/fs-session-store-NM6YSTE2.js +11 -0
  229. package/dist/{fs-session-store-4BHGIWRE.js.map → fs-session-store-NM6YSTE2.js.map} +1 -1
  230. package/dist/generate-object-GUNAUVBX.js +8 -0
  231. package/dist/{generate-object-N5MDZUJI.js.map → generate-object-GUNAUVBX.js.map} +1 -1
  232. package/dist/generate-object-R7HTMW7F.cjs +21 -0
  233. package/dist/{generate-object-PGSP5U7N.cjs.map → generate-object-R7HTMW7F.cjs.map} +1 -1
  234. package/dist/index-manager-RBDHP3PM.js +17 -0
  235. package/dist/{index-manager-AHAYJ33H.js.map → index-manager-RBDHP3PM.js.map} +1 -1
  236. package/dist/index-manager-UZBF22BJ.cjs +26 -0
  237. package/dist/{index-manager-RHPFVFSC.cjs.map → index-manager-UZBF22BJ.cjs.map} +1 -1
  238. package/dist/index.cjs +146 -319
  239. package/dist/index.cjs.map +1 -1
  240. package/dist/index.d.cts +8 -3
  241. package/dist/index.d.ts +8 -3
  242. package/dist/index.js +62 -235
  243. package/dist/index.js.map +1 -1
  244. package/dist/{inject-session-ZCQUB3IT.js → inject-session-DAR7OUCW.js} +8 -8
  245. package/dist/{inject-session-ZCQUB3IT.js.map → inject-session-DAR7OUCW.js.map} +1 -1
  246. package/dist/{inject-session-PPSO2IDD.cjs → inject-session-WQKMC3GR.cjs} +10 -10
  247. package/dist/{inject-session-PPSO2IDD.cjs.map → inject-session-WQKMC3GR.cjs.map} +1 -1
  248. package/dist/internal/memory/active-memory.d.ts +8 -1
  249. package/dist/internal/memory/adapters/index.cjs +9 -9
  250. package/dist/internal/memory/adapters/index.js +8 -8
  251. package/dist/internal/memory/dreaming/diary.d.ts +39 -2
  252. package/dist/internal/memory/index-db.d.ts +44 -1
  253. package/dist/internal/memory/index-manager-contract.d.ts +10 -0
  254. package/dist/internal/memory/index-manager-helpers.d.ts +20 -1
  255. package/dist/internal/memory/index-manager.d.ts +1 -1
  256. package/dist/internal/memory/lance-index.d.ts +15 -1
  257. package/dist/internal/memory/migrate-sqlite-to-lance.d.ts +43 -0
  258. package/dist/internal/memory/storage/index.cjs +101 -18
  259. package/dist/internal/memory/storage/index.d.cts +11 -1
  260. package/dist/internal/memory/storage/index.d.ts +11 -1
  261. package/dist/internal/memory/storage/index.js +10 -7
  262. package/dist/internal/memory/storage/markdown-store.d.cts +13 -42
  263. package/dist/internal/memory/storage/markdown-store.d.ts +13 -42
  264. package/dist/internal/memory/storage/memory-root.d.cts +93 -0
  265. package/dist/internal/memory/storage/memory-root.d.ts +93 -0
  266. package/dist/internal/memory/storage/session-loader.d.cts +35 -1
  267. package/dist/internal/memory/storage/session-loader.d.ts +35 -1
  268. package/dist/internal/memory/storage/session-summary-writer.d.cts +50 -2
  269. package/dist/internal/memory/storage/session-summary-writer.d.ts +50 -2
  270. package/dist/internal/memory/storage/transcript-store.d.cts +38 -1
  271. package/dist/internal/memory/storage/transcript-store.d.ts +38 -1
  272. package/dist/internal/memory/storage/wiki-loader.d.cts +27 -2
  273. package/dist/internal/memory/storage/wiki-loader.d.ts +27 -2
  274. package/dist/internal/memory/tools.d.ts +8 -1
  275. package/dist/internal/memory/types.d.ts +5 -0
  276. package/dist/internal/persistence/index.cjs +29 -28
  277. package/dist/internal/persistence/index.cjs.map +1 -1
  278. package/dist/internal/persistence/index.js +8 -7
  279. package/dist/internal/persistence/index.js.map +1 -1
  280. package/dist/internal/persistence/session-dir.d.cts +0 -15
  281. package/dist/internal/persistence/session-dir.d.ts +0 -15
  282. package/dist/internal/runtime/memory/memory-store.d.ts +2 -2
  283. package/dist/internal/security/index.cjs +14 -14
  284. package/dist/internal/security/index.js +4 -4
  285. package/dist/judge-call-LAHMBJ57.cjs +23 -0
  286. package/dist/{judge-call-EGYRC2RE.cjs.map → judge-call-LAHMBJ57.cjs.map} +1 -1
  287. package/dist/judge-call-LVXABPS3.js +6 -0
  288. package/dist/{judge-call-DWHAJATE.js.map → judge-call-LVXABPS3.js.map} +1 -1
  289. package/dist/mcp-auth.cjs +15 -15
  290. package/dist/mcp-auth.js +5 -5
  291. package/dist/models.cjs +22 -22
  292. package/dist/models.js +7 -7
  293. package/dist/path-safety.cjs +11 -11
  294. package/dist/path-safety.js +4 -4
  295. package/dist/persistence.cjs +33 -32
  296. package/dist/persistence.cjs.map +1 -1
  297. package/dist/persistence.js +10 -9
  298. package/dist/persistence.js.map +1 -1
  299. package/dist/project.cjs +6 -6
  300. package/dist/project.js +4 -4
  301. package/dist/providers.cjs +9 -9
  302. package/dist/providers.js +7 -7
  303. package/dist/registry-75W33OGL.js +10 -0
  304. package/dist/{registry-VFP3WWQP.js.map → registry-75W33OGL.js.map} +1 -1
  305. package/dist/registry-V7BDQ6QB.cjs +47 -0
  306. package/dist/{registry-VFKX7WOP.cjs.map → registry-V7BDQ6QB.cjs.map} +1 -1
  307. package/dist/retry.cjs +5 -5
  308. package/dist/retry.js +4 -4
  309. package/dist/sandbox/index.cjs +7 -7
  310. package/dist/sandbox/index.js +3 -3
  311. package/dist/server/errors-envelope.cjs +15 -15
  312. package/dist/server/errors-envelope.js +4 -4
  313. package/dist/session-transcript-6WNITKRE.cjs +63 -0
  314. package/dist/{session-transcript-HF5GEU5M.cjs.map → session-transcript-6WNITKRE.cjs.map} +1 -1
  315. package/dist/session-transcript-XAEKW6P7.js +6 -0
  316. package/dist/{session-transcript-P462ZRHX.js.map → session-transcript-XAEKW6P7.js.map} +1 -1
  317. package/dist/skills.cjs +8 -8
  318. package/dist/skills.js +6 -6
  319. package/dist/stream-object-UF4QRQRU.js +8 -0
  320. package/dist/{stream-object-L57K4OFS.js.map → stream-object-UF4QRQRU.js.map} +1 -1
  321. package/dist/stream-object-ZJTQNKY3.cjs +21 -0
  322. package/dist/{stream-object-BUCF5PHO.cjs.map → stream-object-ZJTQNKY3.cjs.map} +1 -1
  323. package/dist/subagents-loader-CRT5LLL3.js +8 -0
  324. package/dist/{subagents-loader-6ATCDEKN.js.map → subagents-loader-CRT5LLL3.js.map} +1 -1
  325. package/dist/subagents-loader-YEUFFPAL.cjs +17 -0
  326. package/dist/{subagents-loader-X5QKODCL.cjs.map → subagents-loader-YEUFFPAL.cjs.map} +1 -1
  327. package/dist/subagents-loader.cjs +7 -7
  328. package/dist/subagents-loader.d.cts +1 -1
  329. package/dist/subagents-loader.d.ts +1 -1
  330. package/dist/subagents-loader.js +5 -5
  331. package/dist/subscription/index.cjs +4 -4
  332. package/dist/subscription/index.js +3 -3
  333. package/dist/task-store.cjs +8 -8
  334. package/dist/task-store.js +5 -5
  335. package/dist/types/agent.d.ts +11 -0
  336. package/dist/types/memory-provider.d.ts +8 -0
  337. package/dist/workflow.cjs +28 -28
  338. package/dist/workflow.js +7 -7
  339. package/docs/error-codes.md +10 -9
  340. package/docs/harness-capability-map.md +57 -17
  341. package/docs/memory-decisions.md +44 -7
  342. package/package.json +1 -1
  343. package/dist/agent-NVBFTY5H.js +0 -55
  344. package/dist/agent-VYPUO4UB.cjs +0 -64
  345. package/dist/agent-session-store-G2BMUZQV.js +0 -7
  346. package/dist/agent-session-store-WAKLOKWK.cjs +0 -24
  347. package/dist/chunk-2UCFUSPW.cjs +0 -468
  348. package/dist/chunk-2UCFUSPW.cjs.map +0 -1
  349. package/dist/chunk-6HTXPPHK.cjs +0 -18
  350. package/dist/chunk-6OBIWHDR.cjs.map +0 -1
  351. package/dist/chunk-AH6WD7JR.cjs.map +0 -1
  352. package/dist/chunk-CQ2TQ32Y.js.map +0 -1
  353. package/dist/chunk-NUKRL3I6.cjs.map +0 -1
  354. package/dist/chunk-QEKI3YKI.js.map +0 -1
  355. package/dist/chunk-SKOCYA55.js.map +0 -1
  356. package/dist/chunk-SKXBJ2NU.cjs.map +0 -1
  357. package/dist/chunk-T7O6K6PX.js.map +0 -1
  358. package/dist/chunk-WCLDJSMY.js +0 -456
  359. package/dist/chunk-WCLDJSMY.js.map +0 -1
  360. package/dist/compact-session-GJXJD73F.cjs +0 -59
  361. package/dist/compact-session-TSMQOIHO.js +0 -22
  362. package/dist/context-LCKNH2XI.cjs +0 -24
  363. package/dist/context-MZSKGKYR.js +0 -7
  364. package/dist/fs-session-store-4BHGIWRE.js +0 -11
  365. package/dist/fs-session-store-XZ7ZTB3A.cjs +0 -20
  366. package/dist/generate-object-N5MDZUJI.js +0 -8
  367. package/dist/generate-object-PGSP5U7N.cjs +0 -21
  368. package/dist/index-manager-AHAYJ33H.js +0 -16
  369. package/dist/index-manager-RHPFVFSC.cjs +0 -25
  370. package/dist/judge-call-DWHAJATE.js +0 -6
  371. package/dist/judge-call-EGYRC2RE.cjs +0 -23
  372. package/dist/registry-VFKX7WOP.cjs +0 -47
  373. package/dist/registry-VFP3WWQP.js +0 -10
  374. package/dist/session-transcript-HF5GEU5M.cjs +0 -63
  375. package/dist/session-transcript-P462ZRHX.js +0 -6
  376. package/dist/stream-object-BUCF5PHO.cjs +0 -21
  377. package/dist/stream-object-L57K4OFS.js +0 -8
  378. package/dist/subagents-loader-6ATCDEKN.js +0 -8
  379. package/dist/subagents-loader-X5QKODCL.cjs +0 -17
@@ -1,2 +1,27 @@
1
- export declare function wikiDir(cwd: string): string;
2
- export declare function discoverWikiFiles(cwd: string): Promise<WikiFile[]>;
1
+ import type { MemoryRoot } from "./memory-root.js";
2
+ /**
3
+ * Wiki supplement discovery (ADR Phase 10 of memory-system-peer-project-parity).
4
+ *
5
+ * Wiki files live under `.theokit/memory/wiki/*.md`. They are READ-ONLY —
6
+ * the SDK never writes here. Each indexed chunk carries `source="wiki"` so
7
+ * `memory_search { corpus: "wiki" }` and `corpus: "all"` can scope hits.
8
+ *
9
+ * Shared with `@theokit/sdk-memory` through the semver-exempt `internal/memory-store`
10
+ * sub-path, so it carries no internal-visibility tag. `stripInternal` matches that tag as TEXT
11
+ * anywhere in the block, so naming it here — even in backticks, even to say it is absent — deletes
12
+ * this symbol from the published declarations and forces the satellite back onto a copy. Measured:
13
+ * the first draft of this very note did exactly that. See #430 and #463.
14
+ */
15
+ export interface WikiFile {
16
+ absolutePath: string;
17
+ relPath: string;
18
+ }
19
+ /** `<memory root>/wiki`. Takes the RESOLVED ROOT — see `storage/memory-root.ts` (#463). */
20
+ export declare function wikiDir(root: MemoryRoot): string;
21
+ /**
22
+ * Every wiki supplement under `<memory root>/wiki`, as `{ absolutePath, relPath }` records.
23
+ *
24
+ * Returns `[]` when the directory does not exist. These are read-only supplements the indexer tags
25
+ * with `source="wiki"`, so `memory_search({ corpus: "wiki" })` can scope to them.
26
+ */
27
+ export declare function discoverWikiFiles(root: MemoryRoot): Promise<WikiFile[]>;
@@ -1,4 +1,5 @@
1
1
  import type { MemoryIndex } from "./memory-index.js";
2
+ import type { MemoryRoot } from "./storage/memory-root.js";
2
3
  export interface MemoryTool extends MemoryToolJson {
3
4
  execute(input: Record<string, unknown>): Promise<string>;
4
5
  }
@@ -9,6 +10,12 @@ export interface MemorySearchToolOptions {
9
10
  }
10
11
  export declare function createMemorySearchTool(opts: MemorySearchToolOptions): MemoryTool;
11
12
  export interface MemoryGetToolOptions {
12
- cwd: string;
13
+ /**
14
+ * The RESOLVED memory root the tool may read inside — not a cwd (#463).
15
+ *
16
+ * This guard used to derive its own root from `cwd` while `appendFact` wrote somewhere else, so
17
+ * a relocated memory was unreadable by the tool whose whole job is reading memory.
18
+ */
19
+ root: MemoryRoot;
13
20
  }
14
21
  export declare function createMemoryGetTool(opts: MemoryGetToolOptions): MemoryTool;
@@ -4,6 +4,11 @@ export interface MemoryConfig {
4
4
  userId?: string;
5
5
  scope?: "agent" | "user" | "team";
6
6
  storePath?: string;
7
+ /**
8
+ * Absolute path (or `~/`-prefixed) of the memory root. Defaults to `<cwd>/.theokit/memory`.
9
+ * See `storage/memory-root.ts` for why a relative value is refused rather than resolved.
10
+ */
11
+ directory?: string;
7
12
  }
8
13
  /**
9
14
  * What a fact IS, which is what decides whether it ages (#389).
@@ -1,15 +1,16 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkVTYY7XL5_cjs = require('../../chunk-VTYY7XL5.cjs');
4
- var chunkJ2UROOIG_cjs = require('../../chunk-J2UROOIG.cjs');
5
- var chunkSKXBJ2NU_cjs = require('../../chunk-SKXBJ2NU.cjs');
6
- var chunk2ADR2GSO_cjs = require('../../chunk-2ADR2GSO.cjs');
4
+ var chunk2HVF2WJY_cjs = require('../../chunk-2HVF2WJY.cjs');
5
+ var chunkA4RAL2ER_cjs = require('../../chunk-A4RAL2ER.cjs');
6
+ var chunk5VB22SYX_cjs = require('../../chunk-5VB22SYX.cjs');
7
+ var chunkUU36SHFY_cjs = require('../../chunk-UU36SHFY.cjs');
7
8
  var chunkZF2LDKQQ_cjs = require('../../chunk-ZF2LDKQQ.cjs');
8
- var chunkI6TGFUCO_cjs = require('../../chunk-I6TGFUCO.cjs');
9
+ var chunkUALX2J2Q_cjs = require('../../chunk-UALX2J2Q.cjs');
9
10
  var chunkAQO3NSRG_cjs = require('../../chunk-AQO3NSRG.cjs');
10
- require('../../chunk-K3FW2XZD.cjs');
11
- require('../../chunk-JTB5Q42C.cjs');
12
- require('../../chunk-NUKRL3I6.cjs');
11
+ require('../../chunk-4ZHTIJNE.cjs');
12
+ require('../../chunk-XL7Q7HB2.cjs');
13
+ require('../../chunk-EG4QM7ZJ.cjs');
13
14
  var promises = require('fs/promises');
14
15
 
15
16
  async function createExclusive(path, data, options) {
@@ -43,55 +44,55 @@ Object.defineProperty(exports, "PersistenceSchema", {
43
44
  });
44
45
  Object.defineProperty(exports, "migrateSchema", {
45
46
  enumerable: true,
46
- get: function () { return chunkJ2UROOIG_cjs.migrateSchema; }
47
+ get: function () { return chunk2HVF2WJY_cjs.migrateSchema; }
47
48
  });
48
49
  Object.defineProperty(exports, "readVersionedJson", {
49
50
  enumerable: true,
50
- get: function () { return chunkJ2UROOIG_cjs.readVersionedJson; }
51
+ get: function () { return chunk2HVF2WJY_cjs.readVersionedJson; }
51
52
  });
52
53
  Object.defineProperty(exports, "writeVersionedJson", {
53
54
  enumerable: true,
54
- get: function () { return chunkJ2UROOIG_cjs.writeVersionedJson; }
55
+ get: function () { return chunk2HVF2WJY_cjs.writeVersionedJson; }
55
56
  });
56
- Object.defineProperty(exports, "applyWalWithFallback", {
57
+ Object.defineProperty(exports, "containsCjk", {
57
58
  enumerable: true,
58
- get: function () { return chunkSKXBJ2NU_cjs.applyWalWithFallback; }
59
+ get: function () { return chunkA4RAL2ER_cjs.containsCjk; }
59
60
  });
60
- Object.defineProperty(exports, "containsCjk", {
61
+ Object.defineProperty(exports, "sanitizeFts5Query", {
61
62
  enumerable: true,
62
- get: function () { return chunkSKXBJ2NU_cjs.containsCjk; }
63
+ get: function () { return chunkA4RAL2ER_cjs.sanitizeFts5Query; }
63
64
  });
64
- Object.defineProperty(exports, "isCorruptionError", {
65
+ Object.defineProperty(exports, "applyWalWithFallback", {
65
66
  enumerable: true,
66
- get: function () { return chunkSKXBJ2NU_cjs.isCorruptionError; }
67
+ get: function () { return chunk5VB22SYX_cjs.applyWalWithFallback; }
67
68
  });
68
- Object.defineProperty(exports, "openSqliteResilient", {
69
+ Object.defineProperty(exports, "isCorruptionError", {
69
70
  enumerable: true,
70
- get: function () { return chunkSKXBJ2NU_cjs.openSqliteResilient; }
71
+ get: function () { return chunk5VB22SYX_cjs.isCorruptionError; }
71
72
  });
72
- Object.defineProperty(exports, "sanitizeFts5Query", {
73
+ Object.defineProperty(exports, "openSqliteResilient", {
73
74
  enumerable: true,
74
- get: function () { return chunkSKXBJ2NU_cjs.sanitizeFts5Query; }
75
+ get: function () { return chunk5VB22SYX_cjs.openSqliteResilient; }
75
76
  });
76
77
  Object.defineProperty(exports, "JsonlParseError", {
77
78
  enumerable: true,
78
- get: function () { return chunk2ADR2GSO_cjs.JsonlParseError; }
79
+ get: function () { return chunkUU36SHFY_cjs.JsonlParseError; }
79
80
  });
80
81
  Object.defineProperty(exports, "appendJsonl", {
81
82
  enumerable: true,
82
- get: function () { return chunk2ADR2GSO_cjs.appendJsonl; }
83
+ get: function () { return chunkUU36SHFY_cjs.appendJsonl; }
83
84
  });
84
85
  Object.defineProperty(exports, "loadJsonl", {
85
86
  enumerable: true,
86
- get: function () { return chunk2ADR2GSO_cjs.loadJsonl; }
87
+ get: function () { return chunkUU36SHFY_cjs.loadJsonl; }
87
88
  });
88
89
  Object.defineProperty(exports, "readJsonlIds", {
89
90
  enumerable: true,
90
- get: function () { return chunk2ADR2GSO_cjs.readJsonlIds; }
91
+ get: function () { return chunkUU36SHFY_cjs.readJsonlIds; }
91
92
  });
92
93
  Object.defineProperty(exports, "withFileLock", {
93
94
  enumerable: true,
94
- get: function () { return chunk2ADR2GSO_cjs.withFileLock; }
95
+ get: function () { return chunkUU36SHFY_cjs.withFileLock; }
95
96
  });
96
97
  Object.defineProperty(exports, "withCwdMutex", {
97
98
  enumerable: true,
@@ -99,15 +100,15 @@ Object.defineProperty(exports, "withCwdMutex", {
99
100
  });
100
101
  Object.defineProperty(exports, "atomicWriteJson", {
101
102
  enumerable: true,
102
- get: function () { return chunkI6TGFUCO_cjs.atomicWriteJson; }
103
+ get: function () { return chunkUALX2J2Q_cjs.atomicWriteJson; }
103
104
  });
104
105
  Object.defineProperty(exports, "atomicWriteText", {
105
106
  enumerable: true,
106
- get: function () { return chunkI6TGFUCO_cjs.atomicWriteText; }
107
+ get: function () { return chunkUALX2J2Q_cjs.atomicWriteText; }
107
108
  });
108
109
  Object.defineProperty(exports, "replaceFileAtomic", {
109
110
  enumerable: true,
110
- get: function () { return chunkI6TGFUCO_cjs.replaceFileAtomic; }
111
+ get: function () { return chunkUALX2J2Q_cjs.replaceFileAtomic; }
111
112
  });
112
113
  Object.defineProperty(exports, "displayTheokitHome", {
113
114
  enumerable: true,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/internal/persistence/exclusive-create.ts","../../../src/internal/persistence/sqlite-cas.ts"],"names":["open"],"mappings":";;;;;;;;;;;;;;AAwDA,eAAsB,eAAA,CACpB,IAAA,EACA,IAAA,EACA,OAAA,EACkB;AAClB,EAAA,MAAM,IAAA,GAAO,SAAS,IAAA,IAAQ,GAAA;AAC9B,EAAA,IAAI;AACF,IAAA,MAAM,MAAA,GAAS,MAAMA,aAAA,CAAK,IAAA,EAAM,MAAM,IAAI,CAAA;AAC1C,IAAA,IAAI;AACF,MAAA,MAAM,MAAA,CAAO,UAAU,IAAI,CAAA;AAC3B,MAAA,OAAO,IAAA;AAAA,IACT,CAAA,SAAE;AACA,MAAA,MAAM,OAAO,KAAA,EAAM;AAAA,IACrB;AAAA,EACF,SAAS,GAAA,EAAK;AACZ,IAAA,IAAK,GAAA,CAA8B,SAAS,QAAA,EAAU;AACpD,MAAA,OAAO,KAAA;AAAA,IACT;AACA,IAAA,MAAM,GAAA;AAAA,EACR;AACF;;;ACdO,SAAS,SAAA,CACd,EAAA,EACA,GAAA,EACA,MAAA,EACA,kBAA0B,CAAA,EACjB;AACT,EAAA,MAAM,IAAA,GAAO,EAAA,CAAG,OAAA,CAAQ,GAAG,CAAA;AAC3B,EAAA,MAAM,MAAA,GAAS,IAAA,CAAK,GAAA,CAAI,GAAI,MAAoB,CAAA;AAChD,EAAA,OAAO,OAAO,OAAA,KAAY,eAAA;AAC5B","file":"index.cjs","sourcesContent":["/**\n * O_EXCL exclusive file creation (ADR D82).\n *\n * `createExclusive(path, data, { mode })` creates a file in a single\n * syscall (`open(path, \"wx\", mode)`). Returns `true` if created, `false`\n * if it already existed (EEXIST swallowed — caller decides). All other\n * errors propagate.\n *\n * Default mode is 0o600 (owner-only) — EC-2 fix from edge-case review:\n * token files, lockfiles, and PID files MUST NOT default to world-\n * readable 0o644 under typical umask 022. Callers writing non-sensitive\n * files can pass `mode: 0o644` explicitly.\n *\n * NFS not honoring O_EXCL is documented (D61 — same stance as\n * `withFileLock`); the SDK target is ext4/APFS/NTFS.\n *\n * @internal\n */\n\nimport { open } from \"node:fs/promises\";\n\nexport interface CreateExclusiveOptions {\n /** Unix mode for the new file (default 0o600 — owner-only). */\n mode?: number;\n}\n\n/**\n * Create `path` holding `data`, but only if it does not exist yet. Returns `true` when this call\n * created it, `false` when it was already there.\n *\n * The check and the create are one `open(path, \"wx\")` syscall, so of N processes racing to create\n * the same path exactly one gets `true` — no window between testing and writing. The content is\n * written after the create, so the `false` branch tells you the file exists, not that another\n * writer has finished filling it.\n *\n * Only `EEXIST` becomes `false`. Every other error propagates: a missing parent directory is\n * `ENOENT`, an unwritable one `EACCES`. This never creates directories.\n *\n * The file is created with mode 0600 unless `options.mode` says otherwise, and the mode is\n * subject to the process umask. That default is deliberate — the callers are token files,\n * lockfiles and PID files, and 0644 under a typical umask would make them world-readable.\n *\n * **Choosing between this and the locks.** `createExclusive` claims a NAME once and is the right\n * tool for first-writer-wins: seeding a config, electing a single owner, writing a credential\n * exactly once. It cannot guard repeated updates, because a file that already exists always loses.\n * For read-modify-write on a path several writers touch, take a lock instead —\n * {@link withFileLock} across processes, `withCwdMutex` when the writers are all in this one. For\n * an in-place update guarded by a version column in SQLite, `casUpdate` is the equivalent\n * primitive.\n *\n * Atomicity is the filesystem's `O_EXCL`, which NFS does not reliably honor; the SDK targets\n * ext4, APFS and NTFS.\n *\n * Semver-exempt: reachable via the `@theokit/sdk/internal/persistence` sub-path, which the package\n * declares in `exports` but does NOT cover with its semver contract.\n */\nexport async function createExclusive(\n path: string,\n data: string | Uint8Array,\n options?: CreateExclusiveOptions,\n): Promise<boolean> {\n const mode = options?.mode ?? 0o600;\n try {\n const handle = await open(path, \"wx\", mode);\n try {\n await handle.writeFile(data);\n return true;\n } finally {\n await handle.close();\n }\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === \"EEXIST\") {\n return false;\n }\n throw err;\n }\n}\n","/**\n * SQLite optimistic compare-and-swap (ADR D83).\n *\n * `casUpdate(db, sql, params, expectedChanges)` executes a prepared\n * UPDATE and returns true if `result.changes === expectedChanges`.\n * Caller provides the full SQL (including `WHERE version = ?` predicate);\n * helper does NOT generate SQL — DRY at the level of \"wrap the\n * convention\", not \"build queries\".\n *\n * Use case canonical (Hermes `kanban_db.py:1922-1934`):\n *\n * const won = casUpdate(\n * db,\n * \"UPDATE registry SET status = ?, version = version + 1 WHERE id = ? AND version = ?\",\n * [\"running\", \"agent-foo\", 3],\n * );\n * if (!won) { ... re-read and retry ... }\n *\n * Helper does NOT retry — caller responsible for backoff (avoids hidden\n * loops). Helper does NOT cache prepared statements — `better-sqlite3`\n * caches internally; SDK use is one-shot per mutation, not hot loops.\n *\n * NOTE — no internal-visibility tag in this block. `tsconfig.base.json` sets `stripInternal: true`,\n * and TypeScript scans EVERY leading comment range of the declaration that follows, including the\n * import right below this one. The tag that used to sit here deleted that import from the emitted\n * `.d.ts`, leaving the types it binds unresolvable for any consumer running type-aware lint\n * (usetheodev/theokit-sdk#283 records the same trap on a declaration).\n */\n\nimport type Database from \"better-sqlite3\";\n\ntype DatabaseInstance = InstanceType<typeof Database>;\n\n/**\n * Run an UPDATE and report whether it changed exactly the number of rows you expected — the\n * optimistic-concurrency equivalent of taking a lock.\n *\n * `sql` is yours, in full, including the guard that makes it a compare-and-swap: the\n * `WHERE ... AND version = ?` predicate and the `SET version = version + 1` that closes it. This\n * function generates nothing. It prepares the statement, runs it with `params`, and compares\n * `changes` against `expectedChanges` (default 1).\n *\n * `false` means the guard did not match — someone else moved the row first, or the id does not\n * exist. Those two are indistinguishable here; if you need to tell them apart, re-read the row.\n * A `false` return means NOTHING was written, so the caller owns the re-read-and-retry, with\n * whatever backoff it wants. There is no retry loop hidden in here, by design.\n *\n * SQL errors propagate — bad syntax, a closed database, a constraint violation, a busy writer.\n * Only the row-count mismatch is reported as `false`.\n *\n * Runs as a single implicit transaction, so no explicit BEGIN is needed for one statement. Wrap\n * the call yourself when the swap has to commit together with other writes.\n *\n * **Choosing between this and the locks.** `casUpdate` never blocks and never waits: the loser\n * finds out immediately and decides what to do. Prefer it when the contended state is already a\n * row with a version column. When the contended state is a FILE, there is no version column to\n * swap on — use `withFileLock` across processes, or `withCwdMutex` within one. When the goal is\n * to create something exactly once rather than update it, `createExclusive` is the primitive.\n *\n * Semver-exempt: reachable via the `@theokit/sdk/internal/persistence` sub-path, which the package\n * declares in `exports` but does NOT cover with its semver contract.\n */\nexport function casUpdate(\n db: DatabaseInstance,\n sql: string,\n params: ReadonlyArray<unknown>,\n expectedChanges: number = 1,\n): boolean {\n const stmt = db.prepare(sql);\n const result = stmt.run(...(params as unknown[]));\n return result.changes === expectedChanges;\n}\n"]}
1
+ {"version":3,"sources":["../../../src/internal/persistence/exclusive-create.ts","../../../src/internal/persistence/sqlite-cas.ts"],"names":["open"],"mappings":";;;;;;;;;;;;;;;AAwDA,eAAsB,eAAA,CACpB,IAAA,EACA,IAAA,EACA,OAAA,EACkB;AAClB,EAAA,MAAM,IAAA,GAAO,SAAS,IAAA,IAAQ,GAAA;AAC9B,EAAA,IAAI;AACF,IAAA,MAAM,MAAA,GAAS,MAAMA,aAAA,CAAK,IAAA,EAAM,MAAM,IAAI,CAAA;AAC1C,IAAA,IAAI;AACF,MAAA,MAAM,MAAA,CAAO,UAAU,IAAI,CAAA;AAC3B,MAAA,OAAO,IAAA;AAAA,IACT,CAAA,SAAE;AACA,MAAA,MAAM,OAAO,KAAA,EAAM;AAAA,IACrB;AAAA,EACF,SAAS,GAAA,EAAK;AACZ,IAAA,IAAK,GAAA,CAA8B,SAAS,QAAA,EAAU;AACpD,MAAA,OAAO,KAAA;AAAA,IACT;AACA,IAAA,MAAM,GAAA;AAAA,EACR;AACF;;;ACdO,SAAS,SAAA,CACd,EAAA,EACA,GAAA,EACA,MAAA,EACA,kBAA0B,CAAA,EACjB;AACT,EAAA,MAAM,IAAA,GAAO,EAAA,CAAG,OAAA,CAAQ,GAAG,CAAA;AAC3B,EAAA,MAAM,MAAA,GAAS,IAAA,CAAK,GAAA,CAAI,GAAI,MAAoB,CAAA;AAChD,EAAA,OAAO,OAAO,OAAA,KAAY,eAAA;AAC5B","file":"index.cjs","sourcesContent":["/**\n * O_EXCL exclusive file creation (ADR D82).\n *\n * `createExclusive(path, data, { mode })` creates a file in a single\n * syscall (`open(path, \"wx\", mode)`). Returns `true` if created, `false`\n * if it already existed (EEXIST swallowed — caller decides). All other\n * errors propagate.\n *\n * Default mode is 0o600 (owner-only) — EC-2 fix from edge-case review:\n * token files, lockfiles, and PID files MUST NOT default to world-\n * readable 0o644 under typical umask 022. Callers writing non-sensitive\n * files can pass `mode: 0o644` explicitly.\n *\n * NFS not honoring O_EXCL is documented (D61 — same stance as\n * `withFileLock`); the SDK target is ext4/APFS/NTFS.\n *\n * @internal\n */\n\nimport { open } from \"node:fs/promises\";\n\nexport interface CreateExclusiveOptions {\n /** Unix mode for the new file (default 0o600 — owner-only). */\n mode?: number;\n}\n\n/**\n * Create `path` holding `data`, but only if it does not exist yet. Returns `true` when this call\n * created it, `false` when it was already there.\n *\n * The check and the create are one `open(path, \"wx\")` syscall, so of N processes racing to create\n * the same path exactly one gets `true` — no window between testing and writing. The content is\n * written after the create, so the `false` branch tells you the file exists, not that another\n * writer has finished filling it.\n *\n * Only `EEXIST` becomes `false`. Every other error propagates: a missing parent directory is\n * `ENOENT`, an unwritable one `EACCES`. This never creates directories.\n *\n * The file is created with mode 0600 unless `options.mode` says otherwise, and the mode is\n * subject to the process umask. That default is deliberate — the callers are token files,\n * lockfiles and PID files, and 0644 under a typical umask would make them world-readable.\n *\n * **Choosing between this and the locks.** `createExclusive` claims a NAME once and is the right\n * tool for first-writer-wins: seeding a config, electing a single owner, writing a credential\n * exactly once. It cannot guard repeated updates, because a file that already exists always loses.\n * For read-modify-write on a path several writers touch, take a lock instead —\n * {@link withFileLock} across processes, `withCwdMutex` when the writers are all in this one. For\n * an in-place update guarded by a version column in SQLite, `casUpdate` is the equivalent\n * primitive.\n *\n * Atomicity is the filesystem's `O_EXCL`, which NFS does not reliably honor; the SDK targets\n * ext4, APFS and NTFS.\n *\n * Semver-exempt: reachable via the `@theokit/sdk/internal/persistence` sub-path, which the package\n * declares in `exports` but does NOT cover with its semver contract.\n */\nexport async function createExclusive(\n path: string,\n data: string | Uint8Array,\n options?: CreateExclusiveOptions,\n): Promise<boolean> {\n const mode = options?.mode ?? 0o600;\n try {\n const handle = await open(path, \"wx\", mode);\n try {\n await handle.writeFile(data);\n return true;\n } finally {\n await handle.close();\n }\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === \"EEXIST\") {\n return false;\n }\n throw err;\n }\n}\n","/**\n * SQLite optimistic compare-and-swap (ADR D83).\n *\n * `casUpdate(db, sql, params, expectedChanges)` executes a prepared\n * UPDATE and returns true if `result.changes === expectedChanges`.\n * Caller provides the full SQL (including `WHERE version = ?` predicate);\n * helper does NOT generate SQL — DRY at the level of \"wrap the\n * convention\", not \"build queries\".\n *\n * Use case canonical (Hermes `kanban_db.py:1922-1934`):\n *\n * const won = casUpdate(\n * db,\n * \"UPDATE registry SET status = ?, version = version + 1 WHERE id = ? AND version = ?\",\n * [\"running\", \"agent-foo\", 3],\n * );\n * if (!won) { ... re-read and retry ... }\n *\n * Helper does NOT retry — caller responsible for backoff (avoids hidden\n * loops). Helper does NOT cache prepared statements — `better-sqlite3`\n * caches internally; SDK use is one-shot per mutation, not hot loops.\n *\n * NOTE — no internal-visibility tag in this block. `tsconfig.base.json` sets `stripInternal: true`,\n * and TypeScript scans EVERY leading comment range of the declaration that follows, including the\n * import right below this one. The tag that used to sit here deleted that import from the emitted\n * `.d.ts`, leaving the types it binds unresolvable for any consumer running type-aware lint\n * (usetheodev/theokit-sdk#283 records the same trap on a declaration).\n */\n\nimport type Database from \"better-sqlite3\";\n\ntype DatabaseInstance = InstanceType<typeof Database>;\n\n/**\n * Run an UPDATE and report whether it changed exactly the number of rows you expected — the\n * optimistic-concurrency equivalent of taking a lock.\n *\n * `sql` is yours, in full, including the guard that makes it a compare-and-swap: the\n * `WHERE ... AND version = ?` predicate and the `SET version = version + 1` that closes it. This\n * function generates nothing. It prepares the statement, runs it with `params`, and compares\n * `changes` against `expectedChanges` (default 1).\n *\n * `false` means the guard did not match — someone else moved the row first, or the id does not\n * exist. Those two are indistinguishable here; if you need to tell them apart, re-read the row.\n * A `false` return means NOTHING was written, so the caller owns the re-read-and-retry, with\n * whatever backoff it wants. There is no retry loop hidden in here, by design.\n *\n * SQL errors propagate — bad syntax, a closed database, a constraint violation, a busy writer.\n * Only the row-count mismatch is reported as `false`.\n *\n * Runs as a single implicit transaction, so no explicit BEGIN is needed for one statement. Wrap\n * the call yourself when the swap has to commit together with other writes.\n *\n * **Choosing between this and the locks.** `casUpdate` never blocks and never waits: the loser\n * finds out immediately and decides what to do. Prefer it when the contended state is already a\n * row with a version column. When the contended state is a FILE, there is no version column to\n * swap on — use `withFileLock` across processes, or `withCwdMutex` within one. When the goal is\n * to create something exactly once rather than update it, `createExclusive` is the primitive.\n *\n * Semver-exempt: reachable via the `@theokit/sdk/internal/persistence` sub-path, which the package\n * declares in `exports` but does NOT cover with its semver contract.\n */\nexport function casUpdate(\n db: DatabaseInstance,\n sql: string,\n params: ReadonlyArray<unknown>,\n expectedChanges: number = 1,\n): boolean {\n const stmt = db.prepare(sql);\n const result = stmt.run(...(params as unknown[]));\n return result.changes === expectedChanges;\n}\n"]}
@@ -1,13 +1,14 @@
1
1
  export { PersistenceSchema } from '../../chunk-HY66GLM6.js';
2
- export { migrateSchema, readVersionedJson, writeVersionedJson } from '../../chunk-UCBJBJ27.js';
3
- export { applyWalWithFallback, containsCjk, isCorruptionError, openSqliteResilient, sanitizeFts5Query } from '../../chunk-CQ2TQ32Y.js';
4
- export { JsonlParseError, appendJsonl, loadJsonl, readJsonlIds, withFileLock } from '../../chunk-CV7XMBHP.js';
2
+ export { migrateSchema, readVersionedJson, writeVersionedJson } from '../../chunk-PUAEFLYK.js';
3
+ export { containsCjk, sanitizeFts5Query } from '../../chunk-WE22OXQA.js';
4
+ export { applyWalWithFallback, isCorruptionError, openSqliteResilient } from '../../chunk-LWGSI6M3.js';
5
+ export { JsonlParseError, appendJsonl, loadJsonl, readJsonlIds, withFileLock } from '../../chunk-3O42QOMJ.js';
5
6
  export { withCwdMutex } from '../../chunk-Q5EWJPRY.js';
6
- export { atomicWriteJson, atomicWriteText, replaceFileAtomic } from '../../chunk-VF7EWVDG.js';
7
+ export { atomicWriteJson, atomicWriteText, replaceFileAtomic } from '../../chunk-2GUYQR5P.js';
7
8
  export { displayTheokitHome, getProfilesRoot, getTheokitHome } from '../../chunk-UFLD2HEV.js';
8
- import '../../chunk-IDCKSLYH.js';
9
- import '../../chunk-T7XEKOVW.js';
10
- import '../../chunk-T7O6K6PX.js';
9
+ import '../../chunk-ZZMZWBR6.js';
10
+ import '../../chunk-D4CUGAKZ.js';
11
+ import '../../chunk-XEQ3TM66.js';
11
12
  import { open } from 'fs/promises';
12
13
 
13
14
  async function createExclusive(path, data, options) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/internal/persistence/exclusive-create.ts","../../../src/internal/persistence/sqlite-cas.ts"],"names":[],"mappings":";;;;;;;;;;;;AAwDA,eAAsB,eAAA,CACpB,IAAA,EACA,IAAA,EACA,OAAA,EACkB;AAClB,EAAA,MAAM,IAAA,GAAO,SAAS,IAAA,IAAQ,GAAA;AAC9B,EAAA,IAAI;AACF,IAAA,MAAM,MAAA,GAAS,MAAM,IAAA,CAAK,IAAA,EAAM,MAAM,IAAI,CAAA;AAC1C,IAAA,IAAI;AACF,MAAA,MAAM,MAAA,CAAO,UAAU,IAAI,CAAA;AAC3B,MAAA,OAAO,IAAA;AAAA,IACT,CAAA,SAAE;AACA,MAAA,MAAM,OAAO,KAAA,EAAM;AAAA,IACrB;AAAA,EACF,SAAS,GAAA,EAAK;AACZ,IAAA,IAAK,GAAA,CAA8B,SAAS,QAAA,EAAU;AACpD,MAAA,OAAO,KAAA;AAAA,IACT;AACA,IAAA,MAAM,GAAA;AAAA,EACR;AACF;;;ACdO,SAAS,SAAA,CACd,EAAA,EACA,GAAA,EACA,MAAA,EACA,kBAA0B,CAAA,EACjB;AACT,EAAA,MAAM,IAAA,GAAO,EAAA,CAAG,OAAA,CAAQ,GAAG,CAAA;AAC3B,EAAA,MAAM,MAAA,GAAS,IAAA,CAAK,GAAA,CAAI,GAAI,MAAoB,CAAA;AAChD,EAAA,OAAO,OAAO,OAAA,KAAY,eAAA;AAC5B","file":"index.js","sourcesContent":["/**\n * O_EXCL exclusive file creation (ADR D82).\n *\n * `createExclusive(path, data, { mode })` creates a file in a single\n * syscall (`open(path, \"wx\", mode)`). Returns `true` if created, `false`\n * if it already existed (EEXIST swallowed — caller decides). All other\n * errors propagate.\n *\n * Default mode is 0o600 (owner-only) — EC-2 fix from edge-case review:\n * token files, lockfiles, and PID files MUST NOT default to world-\n * readable 0o644 under typical umask 022. Callers writing non-sensitive\n * files can pass `mode: 0o644` explicitly.\n *\n * NFS not honoring O_EXCL is documented (D61 — same stance as\n * `withFileLock`); the SDK target is ext4/APFS/NTFS.\n *\n * @internal\n */\n\nimport { open } from \"node:fs/promises\";\n\nexport interface CreateExclusiveOptions {\n /** Unix mode for the new file (default 0o600 — owner-only). */\n mode?: number;\n}\n\n/**\n * Create `path` holding `data`, but only if it does not exist yet. Returns `true` when this call\n * created it, `false` when it was already there.\n *\n * The check and the create are one `open(path, \"wx\")` syscall, so of N processes racing to create\n * the same path exactly one gets `true` — no window between testing and writing. The content is\n * written after the create, so the `false` branch tells you the file exists, not that another\n * writer has finished filling it.\n *\n * Only `EEXIST` becomes `false`. Every other error propagates: a missing parent directory is\n * `ENOENT`, an unwritable one `EACCES`. This never creates directories.\n *\n * The file is created with mode 0600 unless `options.mode` says otherwise, and the mode is\n * subject to the process umask. That default is deliberate — the callers are token files,\n * lockfiles and PID files, and 0644 under a typical umask would make them world-readable.\n *\n * **Choosing between this and the locks.** `createExclusive` claims a NAME once and is the right\n * tool for first-writer-wins: seeding a config, electing a single owner, writing a credential\n * exactly once. It cannot guard repeated updates, because a file that already exists always loses.\n * For read-modify-write on a path several writers touch, take a lock instead —\n * {@link withFileLock} across processes, `withCwdMutex` when the writers are all in this one. For\n * an in-place update guarded by a version column in SQLite, `casUpdate` is the equivalent\n * primitive.\n *\n * Atomicity is the filesystem's `O_EXCL`, which NFS does not reliably honor; the SDK targets\n * ext4, APFS and NTFS.\n *\n * Semver-exempt: reachable via the `@theokit/sdk/internal/persistence` sub-path, which the package\n * declares in `exports` but does NOT cover with its semver contract.\n */\nexport async function createExclusive(\n path: string,\n data: string | Uint8Array,\n options?: CreateExclusiveOptions,\n): Promise<boolean> {\n const mode = options?.mode ?? 0o600;\n try {\n const handle = await open(path, \"wx\", mode);\n try {\n await handle.writeFile(data);\n return true;\n } finally {\n await handle.close();\n }\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === \"EEXIST\") {\n return false;\n }\n throw err;\n }\n}\n","/**\n * SQLite optimistic compare-and-swap (ADR D83).\n *\n * `casUpdate(db, sql, params, expectedChanges)` executes a prepared\n * UPDATE and returns true if `result.changes === expectedChanges`.\n * Caller provides the full SQL (including `WHERE version = ?` predicate);\n * helper does NOT generate SQL — DRY at the level of \"wrap the\n * convention\", not \"build queries\".\n *\n * Use case canonical (Hermes `kanban_db.py:1922-1934`):\n *\n * const won = casUpdate(\n * db,\n * \"UPDATE registry SET status = ?, version = version + 1 WHERE id = ? AND version = ?\",\n * [\"running\", \"agent-foo\", 3],\n * );\n * if (!won) { ... re-read and retry ... }\n *\n * Helper does NOT retry — caller responsible for backoff (avoids hidden\n * loops). Helper does NOT cache prepared statements — `better-sqlite3`\n * caches internally; SDK use is one-shot per mutation, not hot loops.\n *\n * NOTE — no internal-visibility tag in this block. `tsconfig.base.json` sets `stripInternal: true`,\n * and TypeScript scans EVERY leading comment range of the declaration that follows, including the\n * import right below this one. The tag that used to sit here deleted that import from the emitted\n * `.d.ts`, leaving the types it binds unresolvable for any consumer running type-aware lint\n * (usetheodev/theokit-sdk#283 records the same trap on a declaration).\n */\n\nimport type Database from \"better-sqlite3\";\n\ntype DatabaseInstance = InstanceType<typeof Database>;\n\n/**\n * Run an UPDATE and report whether it changed exactly the number of rows you expected — the\n * optimistic-concurrency equivalent of taking a lock.\n *\n * `sql` is yours, in full, including the guard that makes it a compare-and-swap: the\n * `WHERE ... AND version = ?` predicate and the `SET version = version + 1` that closes it. This\n * function generates nothing. It prepares the statement, runs it with `params`, and compares\n * `changes` against `expectedChanges` (default 1).\n *\n * `false` means the guard did not match — someone else moved the row first, or the id does not\n * exist. Those two are indistinguishable here; if you need to tell them apart, re-read the row.\n * A `false` return means NOTHING was written, so the caller owns the re-read-and-retry, with\n * whatever backoff it wants. There is no retry loop hidden in here, by design.\n *\n * SQL errors propagate — bad syntax, a closed database, a constraint violation, a busy writer.\n * Only the row-count mismatch is reported as `false`.\n *\n * Runs as a single implicit transaction, so no explicit BEGIN is needed for one statement. Wrap\n * the call yourself when the swap has to commit together with other writes.\n *\n * **Choosing between this and the locks.** `casUpdate` never blocks and never waits: the loser\n * finds out immediately and decides what to do. Prefer it when the contended state is already a\n * row with a version column. When the contended state is a FILE, there is no version column to\n * swap on — use `withFileLock` across processes, or `withCwdMutex` within one. When the goal is\n * to create something exactly once rather than update it, `createExclusive` is the primitive.\n *\n * Semver-exempt: reachable via the `@theokit/sdk/internal/persistence` sub-path, which the package\n * declares in `exports` but does NOT cover with its semver contract.\n */\nexport function casUpdate(\n db: DatabaseInstance,\n sql: string,\n params: ReadonlyArray<unknown>,\n expectedChanges: number = 1,\n): boolean {\n const stmt = db.prepare(sql);\n const result = stmt.run(...(params as unknown[]));\n return result.changes === expectedChanges;\n}\n"]}
1
+ {"version":3,"sources":["../../../src/internal/persistence/exclusive-create.ts","../../../src/internal/persistence/sqlite-cas.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAwDA,eAAsB,eAAA,CACpB,IAAA,EACA,IAAA,EACA,OAAA,EACkB;AAClB,EAAA,MAAM,IAAA,GAAO,SAAS,IAAA,IAAQ,GAAA;AAC9B,EAAA,IAAI;AACF,IAAA,MAAM,MAAA,GAAS,MAAM,IAAA,CAAK,IAAA,EAAM,MAAM,IAAI,CAAA;AAC1C,IAAA,IAAI;AACF,MAAA,MAAM,MAAA,CAAO,UAAU,IAAI,CAAA;AAC3B,MAAA,OAAO,IAAA;AAAA,IACT,CAAA,SAAE;AACA,MAAA,MAAM,OAAO,KAAA,EAAM;AAAA,IACrB;AAAA,EACF,SAAS,GAAA,EAAK;AACZ,IAAA,IAAK,GAAA,CAA8B,SAAS,QAAA,EAAU;AACpD,MAAA,OAAO,KAAA;AAAA,IACT;AACA,IAAA,MAAM,GAAA;AAAA,EACR;AACF;;;ACdO,SAAS,SAAA,CACd,EAAA,EACA,GAAA,EACA,MAAA,EACA,kBAA0B,CAAA,EACjB;AACT,EAAA,MAAM,IAAA,GAAO,EAAA,CAAG,OAAA,CAAQ,GAAG,CAAA;AAC3B,EAAA,MAAM,MAAA,GAAS,IAAA,CAAK,GAAA,CAAI,GAAI,MAAoB,CAAA;AAChD,EAAA,OAAO,OAAO,OAAA,KAAY,eAAA;AAC5B","file":"index.js","sourcesContent":["/**\n * O_EXCL exclusive file creation (ADR D82).\n *\n * `createExclusive(path, data, { mode })` creates a file in a single\n * syscall (`open(path, \"wx\", mode)`). Returns `true` if created, `false`\n * if it already existed (EEXIST swallowed — caller decides). All other\n * errors propagate.\n *\n * Default mode is 0o600 (owner-only) — EC-2 fix from edge-case review:\n * token files, lockfiles, and PID files MUST NOT default to world-\n * readable 0o644 under typical umask 022. Callers writing non-sensitive\n * files can pass `mode: 0o644` explicitly.\n *\n * NFS not honoring O_EXCL is documented (D61 — same stance as\n * `withFileLock`); the SDK target is ext4/APFS/NTFS.\n *\n * @internal\n */\n\nimport { open } from \"node:fs/promises\";\n\nexport interface CreateExclusiveOptions {\n /** Unix mode for the new file (default 0o600 — owner-only). */\n mode?: number;\n}\n\n/**\n * Create `path` holding `data`, but only if it does not exist yet. Returns `true` when this call\n * created it, `false` when it was already there.\n *\n * The check and the create are one `open(path, \"wx\")` syscall, so of N processes racing to create\n * the same path exactly one gets `true` — no window between testing and writing. The content is\n * written after the create, so the `false` branch tells you the file exists, not that another\n * writer has finished filling it.\n *\n * Only `EEXIST` becomes `false`. Every other error propagates: a missing parent directory is\n * `ENOENT`, an unwritable one `EACCES`. This never creates directories.\n *\n * The file is created with mode 0600 unless `options.mode` says otherwise, and the mode is\n * subject to the process umask. That default is deliberate — the callers are token files,\n * lockfiles and PID files, and 0644 under a typical umask would make them world-readable.\n *\n * **Choosing between this and the locks.** `createExclusive` claims a NAME once and is the right\n * tool for first-writer-wins: seeding a config, electing a single owner, writing a credential\n * exactly once. It cannot guard repeated updates, because a file that already exists always loses.\n * For read-modify-write on a path several writers touch, take a lock instead —\n * {@link withFileLock} across processes, `withCwdMutex` when the writers are all in this one. For\n * an in-place update guarded by a version column in SQLite, `casUpdate` is the equivalent\n * primitive.\n *\n * Atomicity is the filesystem's `O_EXCL`, which NFS does not reliably honor; the SDK targets\n * ext4, APFS and NTFS.\n *\n * Semver-exempt: reachable via the `@theokit/sdk/internal/persistence` sub-path, which the package\n * declares in `exports` but does NOT cover with its semver contract.\n */\nexport async function createExclusive(\n path: string,\n data: string | Uint8Array,\n options?: CreateExclusiveOptions,\n): Promise<boolean> {\n const mode = options?.mode ?? 0o600;\n try {\n const handle = await open(path, \"wx\", mode);\n try {\n await handle.writeFile(data);\n return true;\n } finally {\n await handle.close();\n }\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === \"EEXIST\") {\n return false;\n }\n throw err;\n }\n}\n","/**\n * SQLite optimistic compare-and-swap (ADR D83).\n *\n * `casUpdate(db, sql, params, expectedChanges)` executes a prepared\n * UPDATE and returns true if `result.changes === expectedChanges`.\n * Caller provides the full SQL (including `WHERE version = ?` predicate);\n * helper does NOT generate SQL — DRY at the level of \"wrap the\n * convention\", not \"build queries\".\n *\n * Use case canonical (Hermes `kanban_db.py:1922-1934`):\n *\n * const won = casUpdate(\n * db,\n * \"UPDATE registry SET status = ?, version = version + 1 WHERE id = ? AND version = ?\",\n * [\"running\", \"agent-foo\", 3],\n * );\n * if (!won) { ... re-read and retry ... }\n *\n * Helper does NOT retry — caller responsible for backoff (avoids hidden\n * loops). Helper does NOT cache prepared statements — `better-sqlite3`\n * caches internally; SDK use is one-shot per mutation, not hot loops.\n *\n * NOTE — no internal-visibility tag in this block. `tsconfig.base.json` sets `stripInternal: true`,\n * and TypeScript scans EVERY leading comment range of the declaration that follows, including the\n * import right below this one. The tag that used to sit here deleted that import from the emitted\n * `.d.ts`, leaving the types it binds unresolvable for any consumer running type-aware lint\n * (usetheodev/theokit-sdk#283 records the same trap on a declaration).\n */\n\nimport type Database from \"better-sqlite3\";\n\ntype DatabaseInstance = InstanceType<typeof Database>;\n\n/**\n * Run an UPDATE and report whether it changed exactly the number of rows you expected — the\n * optimistic-concurrency equivalent of taking a lock.\n *\n * `sql` is yours, in full, including the guard that makes it a compare-and-swap: the\n * `WHERE ... AND version = ?` predicate and the `SET version = version + 1` that closes it. This\n * function generates nothing. It prepares the statement, runs it with `params`, and compares\n * `changes` against `expectedChanges` (default 1).\n *\n * `false` means the guard did not match — someone else moved the row first, or the id does not\n * exist. Those two are indistinguishable here; if you need to tell them apart, re-read the row.\n * A `false` return means NOTHING was written, so the caller owns the re-read-and-retry, with\n * whatever backoff it wants. There is no retry loop hidden in here, by design.\n *\n * SQL errors propagate — bad syntax, a closed database, a constraint violation, a busy writer.\n * Only the row-count mismatch is reported as `false`.\n *\n * Runs as a single implicit transaction, so no explicit BEGIN is needed for one statement. Wrap\n * the call yourself when the swap has to commit together with other writes.\n *\n * **Choosing between this and the locks.** `casUpdate` never blocks and never waits: the loser\n * finds out immediately and decides what to do. Prefer it when the contended state is already a\n * row with a version column. When the contended state is a FILE, there is no version column to\n * swap on — use `withFileLock` across processes, or `withCwdMutex` within one. When the goal is\n * to create something exactly once rather than update it, `createExclusive` is the primitive.\n *\n * Semver-exempt: reachable via the `@theokit/sdk/internal/persistence` sub-path, which the package\n * declares in `exports` but does NOT cover with its semver contract.\n */\nexport function casUpdate(\n db: DatabaseInstance,\n sql: string,\n params: ReadonlyArray<unknown>,\n expectedChanges: number = 1,\n): boolean {\n const stmt = db.prepare(sql);\n const result = stmt.run(...(params as unknown[]));\n return result.changes === expectedChanges;\n}\n"]}
@@ -1,16 +1 @@
1
- /** The subset of `LocalOptions` this resolver reads. */
2
- interface SessionDirOptions {
3
- sessionDir?: string;
4
- baseDir?: string;
5
- }
6
- /**
7
- * The session directory the caller ASKED for, or `undefined` when they asked for nothing.
8
- *
9
- * {@link resolveSessionDir} always answers with a path, falling back to the default home — which is
10
- * the right answer for "where do transcripts go" and the wrong one for "did this consumer opt into
11
- * sharing state with the Claude Code CLI". Memory writes need the second question, and the two
12
- * accepted names for the option live here, so asking it anywhere else would put a copy of that
13
- * knowledge somewhere it can drift.
14
- */
15
- export declare function explicitSessionDir(local: SessionDirOptions | undefined): string | undefined;
16
1
  export {};
@@ -1,16 +1 @@
1
- /** The subset of `LocalOptions` this resolver reads. */
2
- interface SessionDirOptions {
3
- sessionDir?: string;
4
- baseDir?: string;
5
- }
6
- /**
7
- * The session directory the caller ASKED for, or `undefined` when they asked for nothing.
8
- *
9
- * {@link resolveSessionDir} always answers with a path, falling back to the default home — which is
10
- * the right answer for "where do transcripts go" and the wrong one for "did this consumer opt into
11
- * sharing state with the Claude Code CLI". Memory writes need the second question, and the two
12
- * accepted names for the option live here, so asking it anywhere else would put a copy of that
13
- * knowledge somewhere it can drift.
14
- */
15
- export declare function explicitSessionDir(local: SessionDirOptions | undefined): string | undefined;
16
1
  export {};
@@ -1,4 +1,4 @@
1
1
  import { type MemoryConfig, type MemoryFact, redactSecrets } from "../../memory/types.js";
2
2
  export { redactSecrets };
3
- export declare function readMemoryFacts(cwd: string, config: MemoryConfig, memoryHome?: string): Promise<MemoryFact[]>;
4
- export declare function appendMemoryFact(cwd: string, config: MemoryConfig, fact: MemoryFact, memoryHome?: string): Promise<void>;
3
+ export declare function readMemoryFacts(cwd: string, config: MemoryConfig): Promise<MemoryFact[]>;
4
+ export declare function appendMemoryFact(cwd: string, config: MemoryConfig, fact: MemoryFact): Promise<void>;
@@ -1,53 +1,53 @@
1
1
  'use strict';
2
2
 
3
3
  require('../../chunk-MUUQ2WFJ.cjs');
4
- var chunkR3UPQFKK_cjs = require('../../chunk-R3UPQFKK.cjs');
4
+ var chunkV2BOS4WF_cjs = require('../../chunk-V2BOS4WF.cjs');
5
5
  require('../../chunk-VKJ7V7EB.cjs');
6
- require('../../chunk-K3FW2XZD.cjs');
7
- var chunkJTB5Q42C_cjs = require('../../chunk-JTB5Q42C.cjs');
8
- require('../../chunk-NUKRL3I6.cjs');
6
+ require('../../chunk-4ZHTIJNE.cjs');
7
+ var chunkXL7Q7HB2_cjs = require('../../chunk-XL7Q7HB2.cjs');
8
+ require('../../chunk-EG4QM7ZJ.cjs');
9
9
 
10
10
 
11
11
 
12
12
  Object.defineProperty(exports, "ForbiddenPathError", {
13
13
  enumerable: true,
14
- get: function () { return chunkR3UPQFKK_cjs.ForbiddenPathError; }
14
+ get: function () { return chunkV2BOS4WF_cjs.ForbiddenPathError; }
15
15
  });
16
16
  Object.defineProperty(exports, "PathTraversalError", {
17
17
  enumerable: true,
18
- get: function () { return chunkR3UPQFKK_cjs.PathTraversalError; }
18
+ get: function () { return chunkV2BOS4WF_cjs.PathTraversalError; }
19
19
  });
20
20
  Object.defineProperty(exports, "assertNoSymlinkEscape", {
21
21
  enumerable: true,
22
- get: function () { return chunkR3UPQFKK_cjs.assertNoSymlinkEscape; }
22
+ get: function () { return chunkV2BOS4WF_cjs.assertNoSymlinkEscape; }
23
23
  });
24
24
  Object.defineProperty(exports, "isForbiddenPath", {
25
25
  enumerable: true,
26
- get: function () { return chunkR3UPQFKK_cjs.isForbiddenPath; }
26
+ get: function () { return chunkV2BOS4WF_cjs.isForbiddenPath; }
27
27
  });
28
28
  Object.defineProperty(exports, "safePathJoin", {
29
29
  enumerable: true,
30
- get: function () { return chunkR3UPQFKK_cjs.safePathJoin; }
30
+ get: function () { return chunkV2BOS4WF_cjs.safePathJoin; }
31
31
  });
32
32
  Object.defineProperty(exports, "sanitizeIdentifier", {
33
33
  enumerable: true,
34
- get: function () { return chunkR3UPQFKK_cjs.sanitizeIdentifier; }
34
+ get: function () { return chunkV2BOS4WF_cjs.sanitizeIdentifier; }
35
35
  });
36
36
  Object.defineProperty(exports, "validateArtifactPath", {
37
37
  enumerable: true,
38
- get: function () { return chunkR3UPQFKK_cjs.validateArtifactPath; }
38
+ get: function () { return chunkV2BOS4WF_cjs.validateArtifactPath; }
39
39
  });
40
40
  Object.defineProperty(exports, "addPattern", {
41
41
  enumerable: true,
42
- get: function () { return chunkJTB5Q42C_cjs.addPattern; }
42
+ get: function () { return chunkXL7Q7HB2_cjs.addPattern; }
43
43
  });
44
44
  Object.defineProperty(exports, "maskToken", {
45
45
  enumerable: true,
46
- get: function () { return chunkJTB5Q42C_cjs.maskToken; }
46
+ get: function () { return chunkXL7Q7HB2_cjs.maskToken; }
47
47
  });
48
48
  Object.defineProperty(exports, "redactSecrets", {
49
49
  enumerable: true,
50
- get: function () { return chunkJTB5Q42C_cjs.redactSecrets; }
50
+ get: function () { return chunkXL7Q7HB2_cjs.redactSecrets; }
51
51
  });
52
52
  //# sourceMappingURL=index.cjs.map
53
53
  //# sourceMappingURL=index.cjs.map
@@ -1,8 +1,8 @@
1
1
  import '../../chunk-FD2UT76F.js';
2
- export { ForbiddenPathError, PathTraversalError, assertNoSymlinkEscape, isForbiddenPath, safePathJoin, sanitizeIdentifier, validateArtifactPath } from '../../chunk-QARJGQSA.js';
2
+ export { ForbiddenPathError, PathTraversalError, assertNoSymlinkEscape, isForbiddenPath, safePathJoin, sanitizeIdentifier, validateArtifactPath } from '../../chunk-HS7AVXTF.js';
3
3
  import '../../chunk-RIAM53CP.js';
4
- import '../../chunk-IDCKSLYH.js';
5
- export { addPattern, maskToken, redactSecrets } from '../../chunk-T7XEKOVW.js';
6
- import '../../chunk-T7O6K6PX.js';
4
+ import '../../chunk-ZZMZWBR6.js';
5
+ export { addPattern, maskToken, redactSecrets } from '../../chunk-D4CUGAKZ.js';
6
+ import '../../chunk-XEQ3TM66.js';
7
7
  //# sourceMappingURL=index.js.map
8
8
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ var chunk3NSS2OIZ_cjs = require('./chunk-3NSS2OIZ.cjs');
4
+ require('./chunk-4ZHTIJNE.cjs');
5
+ require('./chunk-XL7Q7HB2.cjs');
6
+ require('./chunk-EG4QM7ZJ.cjs');
7
+
8
+
9
+
10
+ Object.defineProperty(exports, "JudgeCredentialError", {
11
+ enumerable: true,
12
+ get: function () { return chunk3NSS2OIZ_cjs.JudgeCredentialError; }
13
+ });
14
+ Object.defineProperty(exports, "composeJudgePrompt", {
15
+ enumerable: true,
16
+ get: function () { return chunk3NSS2OIZ_cjs.composeJudgePrompt; }
17
+ });
18
+ Object.defineProperty(exports, "judgeCallImpl", {
19
+ enumerable: true,
20
+ get: function () { return chunk3NSS2OIZ_cjs.judgeCallImpl; }
21
+ });
22
+ //# sourceMappingURL=judge-call-LAHMBJ57.cjs.map
23
+ //# sourceMappingURL=judge-call-LAHMBJ57.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"judge-call-EGYRC2RE.cjs"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"judge-call-LAHMBJ57.cjs"}
@@ -0,0 +1,6 @@
1
+ export { JudgeCredentialError, composeJudgePrompt, judgeCallImpl } from './chunk-IPYYKCRC.js';
2
+ import './chunk-ZZMZWBR6.js';
3
+ import './chunk-D4CUGAKZ.js';
4
+ import './chunk-XEQ3TM66.js';
5
+ //# sourceMappingURL=judge-call-LVXABPS3.js.map
6
+ //# sourceMappingURL=judge-call-LVXABPS3.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"judge-call-DWHAJATE.js"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"judge-call-LVXABPS3.js"}
package/dist/mcp-auth.cjs CHANGED
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var chunkI6TGFUCO_cjs = require('./chunk-I6TGFUCO.cjs');
4
- var chunkBVZW2B5V_cjs = require('./chunk-BVZW2B5V.cjs');
5
- var chunkK3FW2XZD_cjs = require('./chunk-K3FW2XZD.cjs');
6
- require('./chunk-JTB5Q42C.cjs');
7
- var chunkNUKRL3I6_cjs = require('./chunk-NUKRL3I6.cjs');
3
+ var chunkUALX2J2Q_cjs = require('./chunk-UALX2J2Q.cjs');
4
+ var chunkXJCXEKMD_cjs = require('./chunk-XJCXEKMD.cjs');
5
+ var chunk4ZHTIJNE_cjs = require('./chunk-4ZHTIJNE.cjs');
6
+ require('./chunk-XL7Q7HB2.cjs');
7
+ var chunkEG4QM7ZJ_cjs = require('./chunk-EG4QM7ZJ.cjs');
8
8
  var crypto = require('crypto');
9
9
  var http = require('http');
10
10
  var promises = require('readline/promises');
@@ -44,7 +44,7 @@ function tryRequireKeytar() {
44
44
  cachedKeytar = r("keytar");
45
45
  } catch {
46
46
  if (!keytarWarned) {
47
- chunkNUKRL3I6_cjs.diag(
47
+ chunkEG4QM7ZJ_cjs.diag(
48
48
  `[theokit-sdk] keytar not installed; MCP OAuth tokens will be stored in ${storeFilePath()} (chmod 600 where POSIX). Install \`keytar\` for OS keychain storage.
49
49
  `
50
50
  );
@@ -74,7 +74,7 @@ async function setTokens(serverName, tokens) {
74
74
  }
75
75
  }
76
76
  allTokens[serverName] = tokens;
77
- await chunkI6TGFUCO_cjs.atomicWriteJson(filePath, allTokens);
77
+ await chunkUALX2J2Q_cjs.atomicWriteJson(filePath, allTokens);
78
78
  try {
79
79
  fs.chmodSync(filePath, 384);
80
80
  } catch {
@@ -93,7 +93,7 @@ async function getTokens(serverName) {
93
93
  }
94
94
  const filePath = storeFilePath();
95
95
  if (!fs.existsSync(filePath)) return void 0;
96
- chunkBVZW2B5V_cjs.assertSecureModes(path.dirname(filePath), filePath);
96
+ chunkXJCXEKMD_cjs.assertSecureModes(path.dirname(filePath), filePath);
97
97
  try {
98
98
  const all = JSON.parse(fs.readFileSync(filePath, "utf8"));
99
99
  return all[serverName];
@@ -134,7 +134,7 @@ async function refreshAccessToken(serverName, clientId, refreshToken, oauth) {
134
134
  body: body.toString()
135
135
  });
136
136
  if (!response.ok) {
137
- throw new chunkK3FW2XZD_cjs.ConfigurationError(`OAuth refresh failed: HTTP ${response.status}`, {
137
+ throw new chunk4ZHTIJNE_cjs.ConfigurationError(`OAuth refresh failed: HTTP ${response.status}`, {
138
138
  code: "oauth_refresh_failed"
139
139
  });
140
140
  }
@@ -180,7 +180,7 @@ async function runPkceFlow(serverName, clientId, scopes, oauth) {
180
180
  authUrl.searchParams.set("code_challenge", challenge);
181
181
  authUrl.searchParams.set("code_challenge_method", "S256");
182
182
  authUrl.searchParams.set("state", state);
183
- chunkNUKRL3I6_cjs.diag(
183
+ chunkEG4QM7ZJ_cjs.diag(
184
184
  `
185
185
  [theokit-sdk] OAuth required for MCP server "${serverName}".
186
186
  Open this URL to authenticate:
@@ -190,7 +190,7 @@ Open this URL to authenticate:
190
190
  );
191
191
  const { code, state: returnedState } = await codeWaiter;
192
192
  if (returnedState !== state) {
193
- throw new chunkK3FW2XZD_cjs.ConfigurationError(
193
+ throw new chunk4ZHTIJNE_cjs.ConfigurationError(
194
194
  "OAuth state mismatch \u2014 possible CSRF attempt; aborting token exchange.",
195
195
  { code: "oauth_state_mismatch" }
196
196
  );
@@ -209,7 +209,7 @@ Open this URL to authenticate:
209
209
  });
210
210
  if (!response.ok) {
211
211
  const errText = await response.text();
212
- throw new chunkK3FW2XZD_cjs.ConfigurationError(
212
+ throw new chunk4ZHTIJNE_cjs.ConfigurationError(
213
213
  `OAuth token exchange failed: HTTP ${response.status}: ${errText.slice(0, 200)}`,
214
214
  { code: "oauth_token_exchange_failed" }
215
215
  );
@@ -255,7 +255,7 @@ async function openLocalhostCallback(expectedState, timeoutMs) {
255
255
  });
256
256
  server.listen(0, "127.0.0.1");
257
257
  const timeoutHandle = setTimeout(() => {
258
- rejectCode?.(new chunkK3FW2XZD_cjs.ConfigurationError("OAuth flow timed out", { code: "oauth_timeout" }));
258
+ rejectCode?.(new chunk4ZHTIJNE_cjs.ConfigurationError("OAuth flow timed out", { code: "oauth_timeout" }));
259
259
  }, timeoutMs);
260
260
  await new Promise((r) => {
261
261
  if (server.listening) r();
@@ -264,7 +264,7 @@ async function openLocalhostCallback(expectedState, timeoutMs) {
264
264
  const address = server.address();
265
265
  if (typeof address !== "object" || address === null) {
266
266
  server.close();
267
- throw new chunkK3FW2XZD_cjs.ConfigurationError("OAuth localhost callback failed to bind", {
267
+ throw new chunk4ZHTIJNE_cjs.ConfigurationError("OAuth localhost callback failed to bind", {
268
268
  code: "oauth_bind_failed"
269
269
  });
270
270
  }
@@ -300,7 +300,7 @@ async function readCodeFromStdin(expectedState, timeoutMs) {
300
300
  }).catch(reject);
301
301
  setTimeout(() => {
302
302
  rl.close();
303
- reject(new chunkK3FW2XZD_cjs.ConfigurationError("OAuth manual input timed out", { code: "oauth_timeout" }));
303
+ reject(new chunk4ZHTIJNE_cjs.ConfigurationError("OAuth manual input timed out", { code: "oauth_timeout" }));
304
304
  }, timeoutMs);
305
305
  });
306
306
  return promise;
package/dist/mcp-auth.js CHANGED
@@ -1,8 +1,8 @@
1
- import { atomicWriteJson } from './chunk-VF7EWVDG.js';
2
- import { assertSecureModes } from './chunk-UQGQFBRL.js';
3
- import { ConfigurationError } from './chunk-IDCKSLYH.js';
4
- import './chunk-T7XEKOVW.js';
5
- import { diag } from './chunk-T7O6K6PX.js';
1
+ import { atomicWriteJson } from './chunk-2GUYQR5P.js';
2
+ import { assertSecureModes } from './chunk-C3NT3PVE.js';
3
+ import { ConfigurationError } from './chunk-ZZMZWBR6.js';
4
+ import './chunk-D4CUGAKZ.js';
5
+ import { diag } from './chunk-XEQ3TM66.js';
6
6
  import { randomBytes, createHash } from 'crypto';
7
7
  import { createServer } from 'http';
8
8
  import { createInterface } from 'readline/promises';