@theokit/sdk 5.7.0 → 5.9.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 (355) hide show
  1. package/CHANGELOG.md +77 -0
  2. package/dist/a2a/index.cjs +6 -6
  3. package/dist/a2a/index.js +2 -2
  4. package/dist/agent-6STOEBGQ.js +59 -0
  5. package/dist/{agent-EQ5HKTWV.js.map → agent-6STOEBGQ.js.map} +1 -1
  6. package/dist/{agent-Dya5SmhY.d.cts → agent-Dh2YHSLj.d.cts} +33 -3
  7. package/dist/agent-ZM4FDDL7.cjs +68 -0
  8. package/dist/{agent-KA63WDQH.cjs.map → agent-ZM4FDDL7.cjs.map} +1 -1
  9. package/dist/{agent-Bqzdhkqr.d.ts → agent-enXXu447.d.ts} +33 -3
  10. package/dist/auth/index.cjs +32 -32
  11. package/dist/auth/index.js +5 -5
  12. package/dist/{batch-US4F6WPK.js → batch-427O54FQ.js} +7 -7
  13. package/dist/{batch-US4F6WPK.js.map → batch-427O54FQ.js.map} +1 -1
  14. package/dist/{batch-I6T6MXZO.cjs → batch-U4SO4RLX.cjs} +24 -24
  15. package/dist/{batch-I6T6MXZO.cjs.map → batch-U4SO4RLX.cjs.map} +1 -1
  16. package/dist/{chunk-44I6UYVH.js → chunk-26NEAJ6T.js} +4 -4
  17. package/dist/{chunk-44I6UYVH.js.map → chunk-26NEAJ6T.js.map} +1 -1
  18. package/dist/{chunk-A6PDYH55.js → chunk-4QCJAJAG.js} +2 -2
  19. package/dist/chunk-4QCJAJAG.js.map +1 -0
  20. package/dist/{chunk-XYFGKVZ7.js → chunk-53RDNK3H.js} +3 -3
  21. package/dist/{chunk-XYFGKVZ7.js.map → chunk-53RDNK3H.js.map} +1 -1
  22. package/dist/{chunk-CZWN4C6A.js → chunk-5522X223.js} +3 -3
  23. package/dist/{chunk-CZWN4C6A.js.map → chunk-5522X223.js.map} +1 -1
  24. package/dist/{chunk-EH6XD3FY.js → chunk-5DD4NJN3.js} +3 -3
  25. package/dist/{chunk-EH6XD3FY.js.map → chunk-5DD4NJN3.js.map} +1 -1
  26. package/dist/{chunk-V22DZIXO.js → chunk-5Q4RTLMP.js} +3 -3
  27. package/dist/{chunk-V22DZIXO.js.map → chunk-5Q4RTLMP.js.map} +1 -1
  28. package/dist/{chunk-ER5BOIYD.cjs → chunk-5WR33BHA.cjs} +22 -22
  29. package/dist/{chunk-ER5BOIYD.cjs.map → chunk-5WR33BHA.cjs.map} +1 -1
  30. package/dist/{chunk-4A3SKJ53.cjs → chunk-6PB5AQCY.cjs} +14 -14
  31. package/dist/{chunk-4A3SKJ53.cjs.map → chunk-6PB5AQCY.cjs.map} +1 -1
  32. package/dist/{chunk-PRZ3BES7.cjs → chunk-72CPLZPC.cjs} +5 -5
  33. package/dist/{chunk-PRZ3BES7.cjs.map → chunk-72CPLZPC.cjs.map} +1 -1
  34. package/dist/{chunk-HNAYCTX4.cjs → chunk-76PIKR4P.cjs} +22 -22
  35. package/dist/{chunk-HNAYCTX4.cjs.map → chunk-76PIKR4P.cjs.map} +1 -1
  36. package/dist/{chunk-EFMFILPG.js → chunk-7F7XE6CM.js} +3 -3
  37. package/dist/{chunk-EFMFILPG.js.map → chunk-7F7XE6CM.js.map} +1 -1
  38. package/dist/{chunk-7C3HWGCW.js → chunk-7GDHFV2M.js} +3 -3
  39. package/dist/{chunk-7C3HWGCW.js.map → chunk-7GDHFV2M.js.map} +1 -1
  40. package/dist/{chunk-CA5VUAP3.js → chunk-7HUCU3KK.js} +5 -5
  41. package/dist/{chunk-CA5VUAP3.js.map → chunk-7HUCU3KK.js.map} +1 -1
  42. package/dist/{chunk-4MMWFSCD.js → chunk-7JAKO3NM.js} +3 -3
  43. package/dist/{chunk-4MMWFSCD.js.map → chunk-7JAKO3NM.js.map} +1 -1
  44. package/dist/{chunk-UADQJBHR.cjs → chunk-7NQ7HJ3E.cjs} +6 -6
  45. package/dist/{chunk-UADQJBHR.cjs.map → chunk-7NQ7HJ3E.cjs.map} +1 -1
  46. package/dist/{chunk-ZLMU5EU3.cjs → chunk-ARMFXTY6.cjs} +114 -190
  47. package/dist/chunk-ARMFXTY6.cjs.map +1 -0
  48. package/dist/{chunk-5WKQDIGO.js → chunk-AY43232P.js} +4 -4
  49. package/dist/{chunk-5WKQDIGO.js.map → chunk-AY43232P.js.map} +1 -1
  50. package/dist/{chunk-7FDKWDA2.cjs → chunk-B3XXQX6L.cjs} +7 -7
  51. package/dist/{chunk-7FDKWDA2.cjs.map → chunk-B3XXQX6L.cjs.map} +1 -1
  52. package/dist/{chunk-ALUN2B4W.js → chunk-B5MHRQJZ.js} +9 -3
  53. package/dist/chunk-B5MHRQJZ.js.map +1 -0
  54. package/dist/{chunk-TA3K7SBK.js → chunk-BKMDRBJ7.js} +3 -3
  55. package/dist/{chunk-TA3K7SBK.js.map → chunk-BKMDRBJ7.js.map} +1 -1
  56. package/dist/{chunk-A575WPBL.cjs → chunk-BM6PDJW3.cjs} +260 -260
  57. package/dist/{chunk-A575WPBL.cjs.map → chunk-BM6PDJW3.cjs.map} +1 -1
  58. package/dist/{chunk-RWPLWMCZ.cjs → chunk-C7GKRGKN.cjs} +42 -21
  59. package/dist/chunk-C7GKRGKN.cjs.map +1 -0
  60. package/dist/{chunk-FUSDYC2B.cjs → chunk-CQYBJOB2.cjs} +4 -4
  61. package/dist/{chunk-FUSDYC2B.cjs.map → chunk-CQYBJOB2.cjs.map} +1 -1
  62. package/dist/{chunk-7JJ3A6AT.cjs → chunk-D5KXKBEN.cjs} +5 -5
  63. package/dist/{chunk-7JJ3A6AT.cjs.map → chunk-D5KXKBEN.cjs.map} +1 -1
  64. package/dist/{chunk-3VXQEQE4.js → chunk-DDRX4LYS.js} +4 -4
  65. package/dist/{chunk-3VXQEQE4.js.map → chunk-DDRX4LYS.js.map} +1 -1
  66. package/dist/{chunk-QDM3OHUT.cjs → chunk-ECD6ER3E.cjs} +4 -4
  67. package/dist/{chunk-QDM3OHUT.cjs.map → chunk-ECD6ER3E.cjs.map} +1 -1
  68. package/dist/{chunk-JMDDYA22.js → chunk-EJROML3Q.js} +4 -4
  69. package/dist/{chunk-JMDDYA22.js.map → chunk-EJROML3Q.js.map} +1 -1
  70. package/dist/{chunk-EIQFAOFD.js → chunk-GGRPAQ3B.js} +3 -3
  71. package/dist/{chunk-EIQFAOFD.js.map → chunk-GGRPAQ3B.js.map} +1 -1
  72. package/dist/{chunk-HCT4HPCL.cjs → chunk-GHHIJEFX.cjs} +4 -4
  73. package/dist/{chunk-HCT4HPCL.cjs.map → chunk-GHHIJEFX.cjs.map} +1 -1
  74. package/dist/{chunk-7A6535RA.cjs → chunk-GM54F4FE.cjs} +9 -9
  75. package/dist/{chunk-7A6535RA.cjs.map → chunk-GM54F4FE.cjs.map} +1 -1
  76. package/dist/{chunk-6M2OIS4Y.js → chunk-GMRFAX4I.js} +74 -4
  77. package/dist/chunk-GMRFAX4I.js.map +1 -0
  78. package/dist/{chunk-O6USDERH.js → chunk-GMSRRJ53.js} +3 -3
  79. package/dist/{chunk-O6USDERH.js.map → chunk-GMSRRJ53.js.map} +1 -1
  80. package/dist/{chunk-VE6DFSKU.js → chunk-GTX6FEDP.js} +3 -3
  81. package/dist/{chunk-VE6DFSKU.js.map → chunk-GTX6FEDP.js.map} +1 -1
  82. package/dist/{chunk-NJWYQWDL.js → chunk-H3CVJSFC.js} +3 -3
  83. package/dist/{chunk-NJWYQWDL.js.map → chunk-H3CVJSFC.js.map} +1 -1
  84. package/dist/{chunk-MYJGWS2J.cjs → chunk-HG5LKFG7.cjs} +16 -16
  85. package/dist/{chunk-MYJGWS2J.cjs.map → chunk-HG5LKFG7.cjs.map} +1 -1
  86. package/dist/{chunk-55GB6JYQ.js → chunk-HOHR75KF.js} +5 -5
  87. package/dist/{chunk-55GB6JYQ.js.map → chunk-HOHR75KF.js.map} +1 -1
  88. package/dist/{chunk-GBCVPKHE.js → chunk-HV4V63CO.js} +3 -3
  89. package/dist/{chunk-GBCVPKHE.js.map → chunk-HV4V63CO.js.map} +1 -1
  90. package/dist/{chunk-I2PWY7VM.cjs → chunk-IIYJMXYW.cjs} +4 -4
  91. package/dist/{chunk-I2PWY7VM.cjs.map → chunk-IIYJMXYW.cjs.map} +1 -1
  92. package/dist/{chunk-YYN6BB7R.cjs → chunk-J4SA2ZEJ.cjs} +4 -4
  93. package/dist/{chunk-YYN6BB7R.cjs.map → chunk-J4SA2ZEJ.cjs.map} +1 -1
  94. package/dist/{chunk-ATT276RD.cjs → chunk-J5623RIV.cjs} +78 -6
  95. package/dist/chunk-J5623RIV.cjs.map +1 -0
  96. package/dist/{chunk-KVSAY6NZ.cjs → chunk-J6GXS5A2.cjs} +13 -13
  97. package/dist/{chunk-KVSAY6NZ.cjs.map → chunk-J6GXS5A2.cjs.map} +1 -1
  98. package/dist/{chunk-NQTD6QOW.cjs → chunk-JW3GVLM6.cjs} +4 -4
  99. package/dist/{chunk-NQTD6QOW.cjs.map → chunk-JW3GVLM6.cjs.map} +1 -1
  100. package/dist/{chunk-TFG5IBZS.cjs → chunk-KGZ66JVZ.cjs} +14 -14
  101. package/dist/{chunk-TFG5IBZS.cjs.map → chunk-KGZ66JVZ.cjs.map} +1 -1
  102. package/dist/{chunk-47TF32NQ.js → chunk-KO6SHCEH.js} +3 -3
  103. package/dist/{chunk-47TF32NQ.js.map → chunk-KO6SHCEH.js.map} +1 -1
  104. package/dist/{chunk-EFETPSJZ.cjs → chunk-KTA7YTZQ.cjs} +12 -12
  105. package/dist/{chunk-EFETPSJZ.cjs.map → chunk-KTA7YTZQ.cjs.map} +1 -1
  106. package/dist/{chunk-D6POWE7E.cjs → chunk-MEUBLCM4.cjs} +11 -11
  107. package/dist/{chunk-D6POWE7E.cjs.map → chunk-MEUBLCM4.cjs.map} +1 -1
  108. package/dist/{chunk-VWUXIVEI.js → chunk-MFZODA5Y.js} +5 -5
  109. package/dist/{chunk-VWUXIVEI.js.map → chunk-MFZODA5Y.js.map} +1 -1
  110. package/dist/{chunk-4HS6FFGL.cjs → chunk-MPQJE3G4.cjs} +15 -15
  111. package/dist/{chunk-4HS6FFGL.cjs.map → chunk-MPQJE3G4.cjs.map} +1 -1
  112. package/dist/{chunk-QRVS2PRE.cjs → chunk-MPR2ISL2.cjs} +4 -4
  113. package/dist/{chunk-QRVS2PRE.cjs.map → chunk-MPR2ISL2.cjs.map} +1 -1
  114. package/dist/{chunk-UOLBAPDM.js → chunk-MQGSOKR3.js} +3 -3
  115. package/dist/{chunk-UOLBAPDM.js.map → chunk-MQGSOKR3.js.map} +1 -1
  116. package/dist/{chunk-HFEJE7AC.js → chunk-MU7IAA7G.js} +9 -9
  117. package/dist/{chunk-HFEJE7AC.js.map → chunk-MU7IAA7G.js.map} +1 -1
  118. package/dist/{chunk-EXTRW7GW.cjs → chunk-NAGPKWOD.cjs} +4 -4
  119. package/dist/{chunk-EXTRW7GW.cjs.map → chunk-NAGPKWOD.cjs.map} +1 -1
  120. package/dist/{chunk-KTTHHYEW.cjs → chunk-NJSIAJEK.cjs} +4 -4
  121. package/dist/{chunk-KTTHHYEW.cjs.map → chunk-NJSIAJEK.cjs.map} +1 -1
  122. package/dist/{chunk-Z3NTRKIC.cjs → chunk-NKIQTLFA.cjs} +4 -4
  123. package/dist/{chunk-Z3NTRKIC.cjs.map → chunk-NKIQTLFA.cjs.map} +1 -1
  124. package/dist/{chunk-N7VAE6DZ.js → chunk-NOO6GZTZ.js} +8 -84
  125. package/dist/chunk-NOO6GZTZ.js.map +1 -0
  126. package/dist/{chunk-GK3UG7YQ.cjs → chunk-OCEQ6DW2.cjs} +10 -10
  127. package/dist/{chunk-GK3UG7YQ.cjs.map → chunk-OCEQ6DW2.cjs.map} +1 -1
  128. package/dist/{chunk-BJUJT5ED.cjs → chunk-OF2CLCTH.cjs} +4 -4
  129. package/dist/{chunk-BJUJT5ED.cjs.map → chunk-OF2CLCTH.cjs.map} +1 -1
  130. package/dist/{chunk-HUFSABUZ.cjs → chunk-OLSEWLK5.cjs} +6 -6
  131. package/dist/{chunk-HUFSABUZ.cjs.map → chunk-OLSEWLK5.cjs.map} +1 -1
  132. package/dist/{chunk-DQZU7JK6.cjs → chunk-P22BZE7G.cjs} +4 -4
  133. package/dist/{chunk-DQZU7JK6.cjs.map → chunk-P22BZE7G.cjs.map} +1 -1
  134. package/dist/{chunk-QWD3CZWE.cjs → chunk-P7NNKEWO.cjs} +4 -4
  135. package/dist/{chunk-QWD3CZWE.cjs.map → chunk-P7NNKEWO.cjs.map} +1 -1
  136. package/dist/{chunk-DQNI52VV.js → chunk-PQCTDMUI.js} +3 -3
  137. package/dist/{chunk-DQNI52VV.js.map → chunk-PQCTDMUI.js.map} +1 -1
  138. package/dist/{chunk-3XSWF5AP.cjs → chunk-PSLCVSCS.cjs} +3 -3
  139. package/dist/{chunk-3XSWF5AP.cjs.map → chunk-PSLCVSCS.cjs.map} +1 -1
  140. package/dist/{chunk-FUUSIT2T.js → chunk-PYFBS6OQ.js} +34 -34
  141. package/dist/{chunk-FUUSIT2T.js.map → chunk-PYFBS6OQ.js.map} +1 -1
  142. package/dist/{chunk-YRLI5DVC.js → chunk-QDQQYRJI.js} +4 -4
  143. package/dist/{chunk-YRLI5DVC.js.map → chunk-QDQQYRJI.js.map} +1 -1
  144. package/dist/{chunk-P5S3WCSZ.js → chunk-R2C3HXR3.js} +4 -4
  145. package/dist/{chunk-P5S3WCSZ.js.map → chunk-R2C3HXR3.js.map} +1 -1
  146. package/dist/chunk-R3ZQBPA5.cjs +18 -0
  147. package/dist/{chunk-ANMJJD6D.cjs.map → chunk-R3ZQBPA5.cjs.map} +1 -1
  148. package/dist/{chunk-4NLCWGH7.cjs → chunk-RA7IE4NK.cjs} +15 -15
  149. package/dist/{chunk-4NLCWGH7.cjs.map → chunk-RA7IE4NK.cjs.map} +1 -1
  150. package/dist/{chunk-UBR5PWD7.js → chunk-SUVCHX4L.js} +3 -3
  151. package/dist/{chunk-UBR5PWD7.js.map → chunk-SUVCHX4L.js.map} +1 -1
  152. package/dist/{chunk-7KBNBPFK.cjs → chunk-SWALPLFQ.cjs} +2 -2
  153. package/dist/chunk-SWALPLFQ.cjs.map +1 -0
  154. package/dist/{chunk-E6QXZZKE.cjs → chunk-T5KOSR5Y.cjs} +11 -11
  155. package/dist/{chunk-E6QXZZKE.cjs.map → chunk-T5KOSR5Y.cjs.map} +1 -1
  156. package/dist/{chunk-R3LBRQAN.js → chunk-TC4RWP3Y.js} +6 -6
  157. package/dist/{chunk-R3LBRQAN.js.map → chunk-TC4RWP3Y.js.map} +1 -1
  158. package/dist/{chunk-XB4GI5RZ.js → chunk-TE6XVTOA.js} +3 -3
  159. package/dist/{chunk-XB4GI5RZ.js.map → chunk-TE6XVTOA.js.map} +1 -1
  160. package/dist/{chunk-33A27NFX.cjs → chunk-TTBIQTO5.cjs} +19 -19
  161. package/dist/{chunk-33A27NFX.cjs.map → chunk-TTBIQTO5.cjs.map} +1 -1
  162. package/dist/{chunk-6JG2RFGK.js → chunk-UKBBYVNS.js} +5 -5
  163. package/dist/{chunk-6JG2RFGK.js.map → chunk-UKBBYVNS.js.map} +1 -1
  164. package/dist/{chunk-J7J7J2GN.cjs → chunk-UNFBHV46.cjs} +9 -2
  165. package/dist/chunk-UNFBHV46.cjs.map +1 -0
  166. package/dist/{chunk-AAEZSPTC.js → chunk-UNZOJVVC.js} +4 -4
  167. package/dist/{chunk-AAEZSPTC.js.map → chunk-UNZOJVVC.js.map} +1 -1
  168. package/dist/{chunk-24SYBZPL.cjs → chunk-WPO3VCY4.cjs} +9 -9
  169. package/dist/{chunk-24SYBZPL.cjs.map → chunk-WPO3VCY4.cjs.map} +1 -1
  170. package/dist/{chunk-IUMAQURF.js → chunk-X6DUEDAF.js} +3 -3
  171. package/dist/{chunk-IUMAQURF.js.map → chunk-X6DUEDAF.js.map} +1 -1
  172. package/dist/{chunk-CFE6QF2Q.js → chunk-XCQ432OX.js} +3 -3
  173. package/dist/{chunk-CFE6QF2Q.js.map → chunk-XCQ432OX.js.map} +1 -1
  174. package/dist/{chunk-QWD4RDZ3.cjs → chunk-XDUGSTYJ.cjs} +15 -15
  175. package/dist/{chunk-QWD4RDZ3.cjs.map → chunk-XDUGSTYJ.cjs.map} +1 -1
  176. package/dist/{chunk-K2VMFZQ5.js → chunk-XKMVJ443.js} +5 -5
  177. package/dist/{chunk-K2VMFZQ5.js.map → chunk-XKMVJ443.js.map} +1 -1
  178. package/dist/{chunk-6PWOWXMC.js → chunk-XZHJYSPB.js} +3 -3
  179. package/dist/{chunk-6PWOWXMC.js.map → chunk-XZHJYSPB.js.map} +1 -1
  180. package/dist/{chunk-QC55H6RJ.cjs → chunk-YRJA2POB.cjs} +9 -9
  181. package/dist/{chunk-QC55H6RJ.cjs.map → chunk-YRJA2POB.cjs.map} +1 -1
  182. package/dist/{chunk-T3ZDEYTJ.js → chunk-ZDYDBXSD.js} +36 -15
  183. package/dist/chunk-ZDYDBXSD.js.map +1 -0
  184. package/dist/{chunk-DMRT67Y6.js → chunk-ZJZ7LV3A.js} +3 -3
  185. package/dist/{chunk-DMRT67Y6.js.map → chunk-ZJZ7LV3A.js.map} +1 -1
  186. package/dist/{chunk-G7BLGBRN.js → chunk-ZWFTECOE.js} +3 -3
  187. package/dist/{chunk-G7BLGBRN.js.map → chunk-ZWFTECOE.js.map} +1 -1
  188. package/dist/{compact-session-QT6RJOKO.js → compact-session-2N3ZYJTW.js} +12 -12
  189. package/dist/{compact-session-QT6RJOKO.js.map → compact-session-2N3ZYJTW.js.map} +1 -1
  190. package/dist/{compact-session-75KD2FCM.cjs → compact-session-RBPLUPCK.cjs} +21 -21
  191. package/dist/{compact-session-75KD2FCM.cjs.map → compact-session-RBPLUPCK.cjs.map} +1 -1
  192. package/dist/compaction.cjs +20 -16
  193. package/dist/compaction.d.cts +2 -0
  194. package/dist/compaction.d.ts +2 -0
  195. package/dist/compaction.js +2 -2
  196. package/dist/concurrency.cjs +5 -5
  197. package/dist/concurrency.js +3 -3
  198. package/dist/context/index.cjs +13 -9
  199. package/dist/context/index.cjs.map +1 -1
  200. package/dist/context/index.d.cts +2 -0
  201. package/dist/context/index.d.ts +2 -0
  202. package/dist/context/index.js +5 -5
  203. package/dist/context/index.js.map +1 -1
  204. package/dist/context-SXR2HLHT.js +7 -0
  205. package/dist/{context-OJIIXJCV.js.map → context-SXR2HLHT.js.map} +1 -1
  206. package/dist/context-ZOULM2RB.cjs +24 -0
  207. package/dist/{context-7RP5JXGM.cjs.map → context-ZOULM2RB.cjs.map} +1 -1
  208. package/dist/{cron-D8uB1Xh5.d.ts → cron-DTuaPMVI.d.ts} +2 -2
  209. package/dist/{cron-BwxDUscv.d.cts → cron-QTgcwcZt.d.cts} +2 -2
  210. package/dist/cron.cjs +34 -34
  211. package/dist/cron.d.cts +4 -4
  212. package/dist/cron.d.ts +4 -4
  213. package/dist/cron.js +33 -33
  214. package/dist/{errors-DrDEgyz1.d.cts → errors-BWOJeWTZ.d.cts} +25 -2
  215. package/dist/{errors-CLOAyuiv.d.ts → errors-DDvG18IB.d.ts} +25 -2
  216. package/dist/errors.cjs +25 -21
  217. package/dist/errors.d.cts +2 -2
  218. package/dist/errors.d.ts +2 -2
  219. package/dist/errors.js +1 -1
  220. package/dist/eval.cjs +44 -44
  221. package/dist/eval.js +34 -34
  222. package/dist/{executor-XQAOQOHD.cjs → executor-2SUGI3ZT.cjs} +21 -21
  223. package/dist/{executor-XQAOQOHD.cjs.map → executor-2SUGI3ZT.cjs.map} +1 -1
  224. package/dist/{executor-ZNDQDX6Q.js → executor-3NI7KNL4.js} +6 -6
  225. package/dist/{executor-ZNDQDX6Q.js.map → executor-3NI7KNL4.js.map} +1 -1
  226. package/dist/filesystem/index.cjs +11 -11
  227. package/dist/filesystem/index.js +2 -2
  228. package/dist/fs-session-store-JHBJFKVV.cjs +19 -0
  229. package/dist/{fs-session-store-E4U3P56L.cjs.map → fs-session-store-JHBJFKVV.cjs.map} +1 -1
  230. package/dist/fs-session-store-STZZFXH2.js +10 -0
  231. package/dist/{fs-session-store-77JU46UZ.js.map → fs-session-store-STZZFXH2.js.map} +1 -1
  232. package/dist/generate-object-NTKAWE7D.js +7 -0
  233. package/dist/{generate-object-BXV7BZRP.js.map → generate-object-NTKAWE7D.js.map} +1 -1
  234. package/dist/generate-object-YHTWG5DB.cjs +20 -0
  235. package/dist/{generate-object-YBI2TDJ3.cjs.map → generate-object-YHTWG5DB.cjs.map} +1 -1
  236. package/dist/index-manager-ONQJSWX5.js +17 -0
  237. package/dist/{index-manager-Z4XMRVWQ.js.map → index-manager-ONQJSWX5.js.map} +1 -1
  238. package/dist/{index-manager-W7RHSL6G.cjs → index-manager-ZGJN25FD.cjs} +9 -9
  239. package/dist/{index-manager-W7RHSL6G.cjs.map → index-manager-ZGJN25FD.cjs.map} +1 -1
  240. package/dist/index.cjs +148 -146
  241. package/dist/index.d.cts +28 -10
  242. package/dist/index.d.ts +28 -10
  243. package/dist/index.js +49 -49
  244. package/dist/{inject-session-L6MIIELT.cjs → inject-session-3FPXJDJP.cjs} +4 -4
  245. package/dist/{inject-session-L6MIIELT.cjs.map → inject-session-3FPXJDJP.cjs.map} +1 -1
  246. package/dist/{inject-session-XWWN4DAA.js → inject-session-YNNOE3O6.js} +3 -3
  247. package/dist/{inject-session-XWWN4DAA.js.map → inject-session-YNNOE3O6.js.map} +1 -1
  248. package/dist/interactive/index.cjs +3 -3
  249. package/dist/interactive/index.js +1 -1
  250. package/dist/internal/memory/adapters/index.cjs +7 -7
  251. package/dist/internal/memory/adapters/index.js +6 -6
  252. package/dist/internal/memory/storage/index.cjs +35 -35
  253. package/dist/internal/memory/storage/index.js +6 -6
  254. package/dist/internal/persistence/index.cjs +11 -11
  255. package/dist/internal/persistence/index.js +3 -3
  256. package/dist/internal/runtime/compression/compression-model-registry.d.ts +1 -0
  257. package/dist/internal/runtime/compression/compression-summarizer.d.ts +0 -14
  258. package/dist/internal/runtime/context/context-discovery.d.ts +20 -5
  259. package/dist/internal/runtime/context/context-loaders.d.ts +5 -1
  260. package/dist/internal/security/index.cjs +9 -9
  261. package/dist/internal/security/index.js +2 -2
  262. package/dist/judge-call-AQQYK6VT.cjs +22 -0
  263. package/dist/{judge-call-46M2E5FA.cjs.map → judge-call-AQQYK6VT.cjs.map} +1 -1
  264. package/dist/judge-call-LOL5FQEX.js +5 -0
  265. package/dist/{judge-call-FGUNNWEI.js.map → judge-call-LOL5FQEX.js.map} +1 -1
  266. package/dist/mcp-auth.cjs +9 -9
  267. package/dist/mcp-auth.js +2 -2
  268. package/dist/models.cjs +15 -15
  269. package/dist/models.js +6 -6
  270. package/dist/oauth-transaction-store-NP2YHZ6D.js +5 -0
  271. package/dist/{oauth-transaction-store-5RIR6D5C.js.map → oauth-transaction-store-NP2YHZ6D.js.map} +1 -1
  272. package/dist/oauth-transaction-store-ZINDV7AF.cjs +38 -0
  273. package/dist/{oauth-transaction-store-SXIE57OD.cjs.map → oauth-transaction-store-ZINDV7AF.cjs.map} +1 -1
  274. package/dist/path-safety.cjs +9 -9
  275. package/dist/path-safety.js +2 -2
  276. package/dist/persistence.cjs +16 -16
  277. package/dist/persistence.js +4 -4
  278. package/dist/project.cjs +5 -5
  279. package/dist/project.js +2 -2
  280. package/dist/providers.cjs +8 -8
  281. package/dist/providers.js +6 -6
  282. package/dist/{registry-DMWCJKRF.js → registry-5FK42CRV.js} +6 -6
  283. package/dist/{registry-DMWCJKRF.js.map → registry-5FK42CRV.js.map} +1 -1
  284. package/dist/{registry-BZQFYRTL.cjs → registry-BVTNO73E.cjs} +14 -14
  285. package/dist/{registry-BZQFYRTL.cjs.map → registry-BVTNO73E.cjs.map} +1 -1
  286. package/dist/retry.cjs +3 -3
  287. package/dist/retry.js +2 -2
  288. package/dist/{run-CTAdRU3U.d.ts → run-DsA5Ip2i.d.cts} +1 -1
  289. package/dist/{run-CTAdRU3U.d.cts → run-DsA5Ip2i.d.ts} +1 -1
  290. package/dist/sandbox/index.cjs +18 -18
  291. package/dist/sandbox/index.js +3 -3
  292. package/dist/{sdk-agent-BOiKqOgL.d.cts → sdk-agent-dNwjwCt5.d.cts} +2 -2
  293. package/dist/{sdk-agent-D4a_BR_6.d.ts → sdk-agent-wEOLXD3F.d.ts} +2 -2
  294. package/dist/server/auth/index.cjs +21 -21
  295. package/dist/server/auth/index.js +6 -6
  296. package/dist/server/errors-envelope.cjs +13 -13
  297. package/dist/server/errors-envelope.d.cts +2 -2
  298. package/dist/server/errors-envelope.d.ts +2 -2
  299. package/dist/server/errors-envelope.js +2 -2
  300. package/dist/skills.cjs +7 -7
  301. package/dist/skills.js +4 -4
  302. package/dist/stream-object-QAEHG4YO.js +7 -0
  303. package/dist/{stream-object-HBFMIZLD.js.map → stream-object-QAEHG4YO.js.map} +1 -1
  304. package/dist/stream-object-TKVGGA54.cjs +20 -0
  305. package/dist/{stream-object-QSKHISDJ.cjs.map → stream-object-TKVGGA54.cjs.map} +1 -1
  306. package/dist/subagents-loader-5TZCAIYQ.cjs +16 -0
  307. package/dist/{subagents-loader-MOO7DC4E.cjs.map → subagents-loader-5TZCAIYQ.cjs.map} +1 -1
  308. package/dist/subagents-loader-PEV3PD4Q.js +7 -0
  309. package/dist/{subagents-loader-CJFYQQU2.js.map → subagents-loader-PEV3PD4Q.js.map} +1 -1
  310. package/dist/subagents-loader.cjs +5 -5
  311. package/dist/subagents-loader.d.cts +3 -3
  312. package/dist/subagents-loader.d.ts +3 -3
  313. package/dist/subagents-loader.js +3 -3
  314. package/dist/subscription/index.cjs +3 -2
  315. package/dist/subscription/index.d.cts +1 -1
  316. package/dist/subscription/index.d.ts +1 -1
  317. package/dist/subscription/index.js +2 -2
  318. package/dist/task-store.cjs +5 -5
  319. package/dist/task-store.js +2 -2
  320. package/dist/types/agent.d.ts +12 -0
  321. package/dist/workflow.cjs +25 -25
  322. package/dist/workflow.d.cts +2 -2
  323. package/dist/workflow.d.ts +2 -2
  324. package/dist/workflow.js +4 -4
  325. package/docs/error-codes.md +8 -7
  326. package/docs/harness-capability-map.md +17 -1
  327. package/package.json +1 -1
  328. package/dist/agent-EQ5HKTWV.js +0 -59
  329. package/dist/agent-KA63WDQH.cjs +0 -68
  330. package/dist/chunk-6M2OIS4Y.js.map +0 -1
  331. package/dist/chunk-7KBNBPFK.cjs.map +0 -1
  332. package/dist/chunk-A6PDYH55.js.map +0 -1
  333. package/dist/chunk-ALUN2B4W.js.map +0 -1
  334. package/dist/chunk-ANMJJD6D.cjs +0 -18
  335. package/dist/chunk-ATT276RD.cjs.map +0 -1
  336. package/dist/chunk-J7J7J2GN.cjs.map +0 -1
  337. package/dist/chunk-N7VAE6DZ.js.map +0 -1
  338. package/dist/chunk-RWPLWMCZ.cjs.map +0 -1
  339. package/dist/chunk-T3ZDEYTJ.js.map +0 -1
  340. package/dist/chunk-ZLMU5EU3.cjs.map +0 -1
  341. package/dist/context-7RP5JXGM.cjs +0 -24
  342. package/dist/context-OJIIXJCV.js +0 -7
  343. package/dist/fs-session-store-77JU46UZ.js +0 -10
  344. package/dist/fs-session-store-E4U3P56L.cjs +0 -19
  345. package/dist/generate-object-BXV7BZRP.js +0 -7
  346. package/dist/generate-object-YBI2TDJ3.cjs +0 -20
  347. package/dist/index-manager-Z4XMRVWQ.js +0 -17
  348. package/dist/judge-call-46M2E5FA.cjs +0 -22
  349. package/dist/judge-call-FGUNNWEI.js +0 -5
  350. package/dist/oauth-transaction-store-5RIR6D5C.js +0 -5
  351. package/dist/oauth-transaction-store-SXIE57OD.cjs +0 -38
  352. package/dist/stream-object-HBFMIZLD.js +0 -7
  353. package/dist/stream-object-QSKHISDJ.cjs +0 -20
  354. package/dist/subagents-loader-CJFYQQU2.js +0 -7
  355. package/dist/subagents-loader-MOO7DC4E.cjs +0 -16
package/dist/workflow.cjs CHANGED
@@ -1,100 +1,100 @@
1
1
  'use strict';
2
2
 
3
- var chunk4HS6FFGL_cjs = require('./chunk-4HS6FFGL.cjs');
4
- var chunk4A3SKJ53_cjs = require('./chunk-4A3SKJ53.cjs');
3
+ var chunkMPQJE3G4_cjs = require('./chunk-MPQJE3G4.cjs');
4
+ var chunk6PB5AQCY_cjs = require('./chunk-6PB5AQCY.cjs');
5
5
  require('./chunk-VTYY7XL5.cjs');
6
6
  require('./chunk-AA27GEYS.cjs');
7
- require('./chunk-7A6535RA.cjs');
7
+ require('./chunk-GM54F4FE.cjs');
8
8
  require('./chunk-SA6K24NB.cjs');
9
9
  require('./chunk-JLRLCBJ4.cjs');
10
- require('./chunk-J7J7J2GN.cjs');
10
+ require('./chunk-UNFBHV46.cjs');
11
11
  require('./chunk-6LHQPOMI.cjs');
12
12
 
13
13
 
14
14
 
15
15
  Object.defineProperty(exports, "Workflow", {
16
16
  enumerable: true,
17
- get: function () { return chunk4HS6FFGL_cjs.Workflow; }
17
+ get: function () { return chunkMPQJE3G4_cjs.Workflow; }
18
18
  });
19
19
  Object.defineProperty(exports, "WorkflowBuilder", {
20
20
  enumerable: true,
21
- get: function () { return chunk4HS6FFGL_cjs.WorkflowBuilder; }
21
+ get: function () { return chunkMPQJE3G4_cjs.WorkflowBuilder; }
22
22
  });
23
23
  Object.defineProperty(exports, "WorkflowToolError", {
24
24
  enumerable: true,
25
- get: function () { return chunk4HS6FFGL_cjs.WorkflowToolError; }
25
+ get: function () { return chunkMPQJE3G4_cjs.WorkflowToolError; }
26
26
  });
27
27
  Object.defineProperty(exports, "agentStep", {
28
28
  enumerable: true,
29
- get: function () { return chunk4HS6FFGL_cjs.agentStep; }
29
+ get: function () { return chunkMPQJE3G4_cjs.agentStep; }
30
30
  });
31
31
  Object.defineProperty(exports, "cloneWorkflow", {
32
32
  enumerable: true,
33
- get: function () { return chunk4HS6FFGL_cjs.cloneWorkflow; }
33
+ get: function () { return chunkMPQJE3G4_cjs.cloneWorkflow; }
34
34
  });
35
35
  Object.defineProperty(exports, "fn", {
36
36
  enumerable: true,
37
- get: function () { return chunk4HS6FFGL_cjs.fn; }
37
+ get: function () { return chunkMPQJE3G4_cjs.fn; }
38
38
  });
39
39
  Object.defineProperty(exports, "workflowAsTool", {
40
40
  enumerable: true,
41
- get: function () { return chunk4HS6FFGL_cjs.workflowAsTool; }
41
+ get: function () { return chunkMPQJE3G4_cjs.workflowAsTool; }
42
42
  });
43
43
  Object.defineProperty(exports, "workflowStep", {
44
44
  enumerable: true,
45
- get: function () { return chunk4HS6FFGL_cjs.workflowStep; }
45
+ get: function () { return chunkMPQJE3G4_cjs.workflowStep; }
46
46
  });
47
47
  Object.defineProperty(exports, "WorkflowAlreadyRunningError", {
48
48
  enumerable: true,
49
- get: function () { return chunk4A3SKJ53_cjs.WorkflowAlreadyRunningError; }
49
+ get: function () { return chunk6PB5AQCY_cjs.WorkflowAlreadyRunningError; }
50
50
  });
51
51
  Object.defineProperty(exports, "WorkflowCompensateNotImplementedError", {
52
52
  enumerable: true,
53
- get: function () { return chunk4A3SKJ53_cjs.WorkflowCompensateNotImplementedError; }
53
+ get: function () { return chunk6PB5AQCY_cjs.WorkflowCompensateNotImplementedError; }
54
54
  });
55
55
  Object.defineProperty(exports, "WorkflowDuplicateStepIdError", {
56
56
  enumerable: true,
57
- get: function () { return chunk4A3SKJ53_cjs.WorkflowDuplicateStepIdError; }
57
+ get: function () { return chunk6PB5AQCY_cjs.WorkflowDuplicateStepIdError; }
58
58
  });
59
59
  Object.defineProperty(exports, "WorkflowInputError", {
60
60
  enumerable: true,
61
- get: function () { return chunk4A3SKJ53_cjs.WorkflowInputError; }
61
+ get: function () { return chunk6PB5AQCY_cjs.WorkflowInputError; }
62
62
  });
63
63
  Object.defineProperty(exports, "WorkflowMaxIterationsExceededError", {
64
64
  enumerable: true,
65
- get: function () { return chunk4A3SKJ53_cjs.WorkflowMaxIterationsExceededError; }
65
+ get: function () { return chunk6PB5AQCY_cjs.WorkflowMaxIterationsExceededError; }
66
66
  });
67
67
  Object.defineProperty(exports, "WorkflowNestedError", {
68
68
  enumerable: true,
69
- get: function () { return chunk4A3SKJ53_cjs.WorkflowNestedError; }
69
+ get: function () { return chunk6PB5AQCY_cjs.WorkflowNestedError; }
70
70
  });
71
71
  Object.defineProperty(exports, "WorkflowNotSerializableError", {
72
72
  enumerable: true,
73
- get: function () { return chunk4A3SKJ53_cjs.WorkflowNotSerializableError; }
73
+ get: function () { return chunk6PB5AQCY_cjs.WorkflowNotSerializableError; }
74
74
  });
75
75
  Object.defineProperty(exports, "WorkflowOutputError", {
76
76
  enumerable: true,
77
- get: function () { return chunk4A3SKJ53_cjs.WorkflowOutputError; }
77
+ get: function () { return chunk6PB5AQCY_cjs.WorkflowOutputError; }
78
78
  });
79
79
  Object.defineProperty(exports, "WorkflowParallelError", {
80
80
  enumerable: true,
81
- get: function () { return chunk4A3SKJ53_cjs.WorkflowParallelError; }
81
+ get: function () { return chunk6PB5AQCY_cjs.WorkflowParallelError; }
82
82
  });
83
83
  Object.defineProperty(exports, "WorkflowResumeStepNotFoundError", {
84
84
  enumerable: true,
85
- get: function () { return chunk4A3SKJ53_cjs.WorkflowResumeStepNotFoundError; }
85
+ get: function () { return chunk6PB5AQCY_cjs.WorkflowResumeStepNotFoundError; }
86
86
  });
87
87
  Object.defineProperty(exports, "WorkflowSnapshotNotFoundError", {
88
88
  enumerable: true,
89
- get: function () { return chunk4A3SKJ53_cjs.WorkflowSnapshotNotFoundError; }
89
+ get: function () { return chunk6PB5AQCY_cjs.WorkflowSnapshotNotFoundError; }
90
90
  });
91
91
  Object.defineProperty(exports, "WorkflowStateError", {
92
92
  enumerable: true,
93
- get: function () { return chunk4A3SKJ53_cjs.WorkflowStateError; }
93
+ get: function () { return chunk6PB5AQCY_cjs.WorkflowStateError; }
94
94
  });
95
95
  Object.defineProperty(exports, "__resetSnapshotStoresForTests", {
96
96
  enumerable: true,
97
- get: function () { return chunk4A3SKJ53_cjs.__resetSnapshotStoresForTests; }
97
+ get: function () { return chunk6PB5AQCY_cjs.__resetSnapshotStoresForTests; }
98
98
  });
99
99
  //# sourceMappingURL=workflow.cjs.map
100
100
  //# sourceMappingURL=workflow.cjs.map
@@ -1,6 +1,6 @@
1
1
  import { ZodType, z } from 'zod';
2
- import { S as SDKAgent } from './sdk-agent-BOiKqOgL.cjs';
3
- import { t as MessageOrigin, C as CustomTool } from './run-CTAdRU3U.cjs';
2
+ import { S as SDKAgent } from './sdk-agent-dNwjwCt5.cjs';
3
+ import { t as MessageOrigin, C as CustomTool } from './run-DsA5Ip2i.cjs';
4
4
  import { T as TheokitAgentError } from './errors-base-B5g01neU.cjs';
5
5
 
6
6
  /**
@@ -1,6 +1,6 @@
1
1
  import { ZodType, z } from 'zod';
2
- import { S as SDKAgent } from './sdk-agent-D4a_BR_6.js';
3
- import { t as MessageOrigin, C as CustomTool } from './run-CTAdRU3U.js';
2
+ import { S as SDKAgent } from './sdk-agent-wEOLXD3F.js';
3
+ import { t as MessageOrigin, C as CustomTool } from './run-DsA5Ip2i.js';
4
4
  import { T as TheokitAgentError } from './errors-base-B5g01neU.js';
5
5
 
6
6
  /**
package/dist/workflow.js CHANGED
@@ -1,11 +1,11 @@
1
- export { Workflow, WorkflowBuilder, WorkflowToolError, agentStep, cloneWorkflow, fn, workflowAsTool, workflowStep } from './chunk-HFEJE7AC.js';
2
- export { WorkflowAlreadyRunningError, WorkflowCompensateNotImplementedError, WorkflowDuplicateStepIdError, WorkflowInputError, WorkflowMaxIterationsExceededError, WorkflowNestedError, WorkflowNotSerializableError, WorkflowOutputError, WorkflowParallelError, WorkflowResumeStepNotFoundError, WorkflowSnapshotNotFoundError, WorkflowStateError, __resetSnapshotStoresForTests } from './chunk-GBCVPKHE.js';
1
+ export { Workflow, WorkflowBuilder, WorkflowToolError, agentStep, cloneWorkflow, fn, workflowAsTool, workflowStep } from './chunk-MU7IAA7G.js';
2
+ export { WorkflowAlreadyRunningError, WorkflowCompensateNotImplementedError, WorkflowDuplicateStepIdError, WorkflowInputError, WorkflowMaxIterationsExceededError, WorkflowNestedError, WorkflowNotSerializableError, WorkflowOutputError, WorkflowParallelError, WorkflowResumeStepNotFoundError, WorkflowSnapshotNotFoundError, WorkflowStateError, __resetSnapshotStoresForTests } from './chunk-HV4V63CO.js';
3
3
  import './chunk-HY66GLM6.js';
4
4
  import './chunk-7I5Z3UBJ.js';
5
- import './chunk-EH6XD3FY.js';
5
+ import './chunk-5DD4NJN3.js';
6
6
  import './chunk-UKMBRMGT.js';
7
7
  import './chunk-3JHIFQ4I.js';
8
- import './chunk-ALUN2B4W.js';
8
+ import './chunk-B5MHRQJZ.js';
9
9
  import './chunk-CZJ6Q7CW.js';
10
10
  //# sourceMappingURL=workflow.js.map
11
11
  //# sourceMappingURL=workflow.js.map
@@ -6,7 +6,7 @@ Branch on `code`, never on the message: messages carry context (an id, a path, a
6
6
 
7
7
  **Transport codes vs the rest.** `ErrorCode` in `errors.ts` is the small canonical union a provider failure maps onto — the codes marked *transport* below. Everything else is raised by a specific subsystem at a specific place, and a `catch` that only handles the union will meet them anyway.
8
8
 
9
- 243 distinct code(s).
9
+ 244 distinct code(s).
10
10
 
11
11
  | Code | Kind | Raised by | Sites |
12
12
  |---|---|---|---|
@@ -45,7 +45,7 @@ Branch on `code`, never on the message: messages carry context (an id, a path, a
45
45
  | `cloud_run_unknown_status` | domain | NetworkError | `packages/sdk/src/internal/cloud-agent/real-cloud-run.ts:284` +1 |
46
46
  | `cloud_runtime_pre_release` | domain | ConfigurationError | `packages/sdk/src/agent.ts:417` +2 |
47
47
  | `cloud_stdio_cwd_rejected` | domain | ConfigurationError | `packages/sdk/src/internal/runtime/validation/validate-agent-options.ts:121` |
48
- | `compression_failed` | domain | — | `packages/sdk/src/internal/runtime/compression/compression-summarizer.ts:41` |
48
+ | `compression_failed` | domain | — | `packages/sdk/src/errors.ts:700` |
49
49
  | `compression_model_unresolved` | domain | — | `packages/sdk/src/internal/runtime/compression/compression-model-registry.ts:102` +1 |
50
50
  | `context_config_shape` | domain | ConfigurationError | `packages/sdk/src/internal/runtime/context/context-manager.ts:288` |
51
51
  | `context_frontmatter_invalid` | domain | ConfigurationError | `packages/sdk/src/internal/runtime/context/context-frontmatter.ts:38` |
@@ -198,13 +198,14 @@ Branch on `code`, never on the message: messages carry context (an id, a path, a
198
198
  | `ssrf_blocked` | domain | — | `packages/sdk-tools/src/internal/network-guard.ts:23` |
199
199
  | `stream_idle_timeout` | domain | NetworkError | `packages/sdk/src/internal/llm/sse.ts:95` |
200
200
  | `stream_truncated` | domain | NetworkError | `packages/sdk/src/internal/llm/anthropic.ts:184` +1 |
201
- | `subagent_mcp_unsupported_local` | domain | ConfigurationError | `packages/sdk/src/internal/runtime/skills/subagents-loader.ts:207` |
201
+ | `subagent_foreign_runtime_field` | domain | ConfigurationError | `packages/sdk/src/internal/runtime/skills/subagents-loader.ts:245` |
202
+ | `subagent_mcp_unsupported_local` | domain | ConfigurationError | `packages/sdk/src/internal/runtime/skills/subagents-loader.ts:272` |
202
203
  | `subagent_missing_description` | domain | ConfigurationError | `packages/sdk/src/internal/runtime/validation/validate-agent-options.ts:142` |
203
- | `subagent_missing_frontmatter` | domain | ConfigurationError | `packages/sdk/src/internal/runtime/skills/subagents-loader.ts:284` |
204
+ | `subagent_missing_frontmatter` | domain | ConfigurationError | `packages/sdk/src/internal/runtime/skills/subagents-loader.ts:349` |
204
205
  | `subagent_missing_prompt` | domain | ConfigurationError | `packages/sdk/src/internal/runtime/validation/validate-agent-options.ts:147` |
205
- | `subagent_reasoning_effort_without_model` | domain | ConfigurationError | `packages/sdk/src/internal/runtime/skills/subagents-loader.ts:227` |
206
- | `subagent_sandbox_not_boolean` | domain | ConfigurationError | `packages/sdk/src/internal/runtime/skills/subagents-loader.ts:247` |
207
- | `subagent_unknown_field` | domain | ConfigurationError | `packages/sdk/src/internal/runtime/skills/subagents-loader.ts:192` |
206
+ | `subagent_reasoning_effort_without_model` | domain | ConfigurationError | `packages/sdk/src/internal/runtime/skills/subagents-loader.ts:292` |
207
+ | `subagent_sandbox_not_boolean` | domain | ConfigurationError | `packages/sdk/src/internal/runtime/skills/subagents-loader.ts:312` |
208
+ | `subagent_unknown_field` | domain | ConfigurationError | `packages/sdk/src/internal/runtime/skills/subagents-loader.ts:249` |
208
209
  | `subagent_unknown_setting_source` | domain | ConfigurationError | `packages/sdk/src/subagents-loader.ts:96` |
209
210
  | `subscribe_baseUrl_missing` | domain | SubscriptionError | `packages/sdk/src/subscription/theokit-subscribe.ts:77` |
210
211
  | `subscribe_name_invalid` | domain | SubscriptionError | `packages/sdk/src/subscription/theokit-subscribe.ts:72` |
@@ -4,7 +4,7 @@ Every public symbol the TheoKit workspace publishes, and the exact specifier to
4
4
 
5
5
  A symbol listed under two specifiers is reachable from both, but that does NOT make the two interchangeable: a class emitted separately into a subpath entry is a distinct nominal type from the one in the root bundle, so passing one where the other is expected fails on a private field. When a symbol appears twice, import it and everything it is passed to from the SAME specifier.
6
6
 
7
- 1212 export(s) across 46 entry point(s).
7
+ 1228 export(s) across 46 entry point(s).
8
8
 
9
9
  ## `@theokit/acp`
10
10
 
@@ -61,6 +61,7 @@ A symbol listed under two specifiers is reachable from both, but that does NOT m
61
61
  | `ActiveMemoryPassResult` | interface | Result of `MemoryProvider.runActivePass(...)` — what the kernel injects into the LLM call. |
62
62
  | `Agent` | class | Static façade for creating and managing Theo agents. |
63
63
  | `AgentBuilder` | class | Fluent builder for {@link AgentOptions } . |
64
+ | `AgentBuilderDeps` | interface | Terminal-method callbacks injected by `Agent.builder()` so that `agent-builder.ts` does NOT need a static import of `Agent` — keeps the dependency graph acyclic (G6). |
64
65
  | `AgentConversationTurn` | interface | Agent turn: user message + assistant/tool/thinking steps. |
65
66
  | `AgentDefinition` | interface | Subagent definition. |
66
67
  | `AgentDescription` | interface | theokit#123 — the read-only introspection of a registered agent, returned by `Agent.describe()`. |
@@ -136,6 +137,8 @@ A symbol listed under two specifiers is reachable from both, but that does NOT m
136
137
  | `CounterBudgetTrackerOptions` | interface | Options for `createCounterBudgetTracker`. |
137
138
  | `createCounterBudgetTracker` | function | Build a fresh tracker. |
138
139
  | `CreateSkillSpec` | interface | Spec accepted by {@link createSkill } . |
140
+ | `createTokenLimiter` | function | SE25 — a processor that caps text to a token budget. |
141
+ | `createUnicodeNormalizer` | function | SE25 — an input processor that normalizes user text: Unicode NFC (so canonically-equivalent sequences compare equal) plus optional control-char stripping and whitespace collapsing. |
139
142
  | `CredentialInput` | interface | One provider's credential lookup, as the product resolved it. |
140
143
  | `CredentialReport` | interface | A presence-only view of one credential, safe to print, log, or attach to a support bundle. |
141
144
  | `Cron` | class | Static façade for scheduling Theo agent runs on a cron expression. |
@@ -166,6 +169,7 @@ A symbol listed under two specifiers is reachable from both, but that does NOT m
166
169
  | `effectiveToolNames` | function | The tool names an agent created with `options` will offer the model, as far as the options can say. |
167
170
  | `emitRunEvent` | function | SE2 — emit a {@link RunEvent } to an optional sink, swallowing any sink error so observability can never break the run (fail-safe, mirrors the EventBus EC-2 contract). |
168
171
  | `EnvOptOut` | interface | A key deliberately left off the environment, with the reason and what would reverse it. |
172
+ | `EnvPolicy` | type | Owner: `sandbox/` (1 of 2 importers). |
169
173
  | `EnvReachabilityAudit` | interface | The two failures, reported separately because they have opposite fixes. |
170
174
  | `EnvReachabilityInput` | interface | The three lists the audit compares: every key the product declares, the subset an environment variable can set, and the documented exemptions. |
171
175
  | `ErrorCode` | type | Finite, machine-readable error codes for provider-originated errors (ADR D66). |
@@ -177,6 +181,8 @@ A symbol listed under two specifiers is reachable from both, but that does NOT m
177
181
  | `extractRawId` | function | Extract the raw provider id from a `MemoryId`, enforcing that the prefix matches `expectedAdapterId`. |
178
182
  | `fn` | function | Build a `FnStep`. |
179
183
  | `foldLayers` | function | Combine `entries` into one record. |
184
+ | `ForkOptions` | interface | Caller-supplied fork configuration. |
185
+ | `ForkResult` | interface | Outcome of a fork run. |
180
186
  | `GenerateObjectError` | class | Typed error thrown by {@link Agent.generateObject } when the model refuses to call the synthetic `output` tool or when retries are exhausted. |
181
187
  | `GenerateObjectOptions` | interface | Options accepted by {@link Agent.generateObject } . |
182
188
  | `GenerateObjectResult` | interface | Successful return from {@link Agent.generateObject } . |
@@ -191,6 +197,8 @@ A symbol listed under two specifiers is reachable from both, but that does NOT m
191
197
  | `GoalOptions` | interface | Per-call configuration for `Agent.runUntil`. |
192
198
  | `GoalResult` | interface | Return value of the `runUntil` async generator. |
193
199
  | `guardSessionDestruction` | function | Throw unless `sessionId` is safe to destroy. |
200
+ | `HookApprovalGate` | interface | #631 — a consumer's decision point before this package spawns a hook. |
201
+ | `HookApprovalRequest` | interface | #631 — what the consumer is shown when asked to approve a hook. |
194
202
  | `HookName` | type | The fixed set of points a `"general"` plugin may attach to through `PluginContext.on`. |
195
203
  | `ImageBlock` | interface | SE7 — a base64-encoded image block a tool can hand back as (part of) its result or its `ToolError`. |
196
204
  | `inferApiMode` | function | Guess which usage shape a provider reports, from its name alone. |
@@ -217,6 +225,7 @@ A symbol listed under two specifiers is reachable from both, but that does NOT m
217
225
  | `LiveAgentRegistry` | class | An LRU-plus-idle cache of live `SDKAgent` instances, reached through `Agent.registry`. |
218
226
  | `LiveSessionError` | class | Raised by `guardSessionDestruction` instead of letting a session be destroyed. |
219
227
  | `LiveSessionReason` | type | Why the destruction was refused. |
228
+ | `LlmCallContext` | interface | #65 — context for the `pre_llm_call` / `post_llm_call` hooks. |
220
229
  | `loadProjectEnv` | function | Read the project's `.env` into `env`, then restore every {@link SOVEREIGN_ENV_KEYS } entry to the value it had BEFORE the load — including restoring it to absent. |
221
230
  | `LocalOptions` | interface | Local agent configuration. |
222
231
  | `ManagedSettings` | interface | What an operator may impose. |
@@ -436,6 +445,7 @@ A symbol listed under two specifiers is reachable from both, but that does NOT m
436
445
  | `ToolCallCompletedUpdate` | interface | Tool call completed. |
437
446
  | `ToolCallStartedUpdate` | interface | Tool call started — args committed. |
438
447
  | `ToolCallSummary` | interface | M82 — one tool call of the turn, as seen by `transform_tool_result`. |
448
+ | `ToolContext` | interface | #65 — a 2nd argument passed to a tool handler, carrying the run's cancellation signal (ties into #58) so a cooperative tool can stop when the run is cancelled. |
439
449
  | `ToolContextMessage` | interface | SE12 — a read-only, text-only projection of one turn of the run's conversation, exposed to a tool handler via `ctx.messages`. |
440
450
  | `ToolError` | class | Thrown from a tool `handler` to surface a failure to the model. |
441
451
  | `ToolResult` | interface | Result of a tool invocation. |
@@ -895,6 +905,8 @@ A symbol listed under two specifiers is reachable from both, but that does NOT m
895
905
  | `compactTranscript` | function | Compact a transcript. |
896
906
  | `CompactTranscriptOptions` | interface | Options for {@link compactTranscript } . |
897
907
  | `CompressibleMessage` | interface | Minimal message shape for compaction/compression input. |
908
+ | `CompressionConfig` | interface | Consumer-facing compression options on `Agent.create`. |
909
+ | `CompressionModelUnresolvedError` | class | T2.2 — Typed error thrown when `resolveCompressionModel` cannot find a same-family-cheaper-tier mapping for `agentModel`. |
898
910
  | `CONTEXT_WINDOW_FLOOR` | const | M77 — the floor used ONLY when neither the catalog nor the caller knows the window. |
899
911
  | `CONTEXT_WINDOW_MARGIN` | const | M77 — default safety margin on the context window. |
900
912
  | `ContextWindowMarginError` | class | M77 — the margin is outside `(0, 1]`. |
@@ -932,6 +944,8 @@ A symbol listed under two specifiers is reachable from both, but that does NOT m
932
944
  | `ResolveContextImportsOptions` | interface | Options for {@link resolveContextImports } . |
933
945
  | `runDiscovery` | function | Find, read and parse every context file the specs describe, and return them ready for the aggregator. |
934
946
  | `shouldActivateRule` | function | Decide whether a parsed rule applies to this turn, given the files in scope. |
947
+ | `WithheldSpec` | interface | A spec a declaration did not admit, with the grant that would. |
948
+ | `withheldSpecs` | function | The mirror of {@link admittedSpecs } : the specs a declaration did NOT admit. |
935
949
 
936
950
  ## `@theokit/sdk/cron`
937
951
 
@@ -949,6 +963,7 @@ A symbol listed under two specifiers is reachable from both, but that does NOT m
949
963
  | `AuthenticationError` | class | Invalid API key, not logged in, insufficient permissions. |
950
964
  | `BudgetExceededError` | class | Thrown by `Budget` enforcement (ADR D386) when a `mode: "block"` budget would be exceeded by the upcoming LLM call. |
951
965
  | `coerceToKnownAgentRunErrorCode` | function | T1.1 boundary helper — coerce an arbitrary string (typically arriving from a downstream `RunErrorDetail.code` or a deserialized cloud response) into a `KnownAgentRunErrorCode`. |
966
+ | `CompressionFailedError` | class | Compression of a conversation failed. |
952
967
  | `ConfigurationError` | class | Invalid model, bad request parameters, malformed options. |
953
968
  | `CredentialPoolExhaustedError` | class | Thrown when every credential in a per-provider pool is in cooldown and no healthy key is available (ADR D133). |
954
969
  | `ErrorCode` | type | Finite, machine-readable error codes for provider-originated errors (ADR D66). |
@@ -1376,6 +1391,7 @@ A symbol listed under two specifiers is reachable from both, but that does NOT m
1376
1391
 
1377
1392
  | Symbol | Kind | Summary |
1378
1393
  |---|---|---|
1394
+ | `defineSubscription` | function | Define a typed subscription. |
1379
1395
  | `DefineSubscriptionOptions` | interface | Options accepted by {@link defineSubscription } . |
1380
1396
  | `isTrackedEnvelope` | function | Type guard for {@link TrackedEnvelope } . |
1381
1397
  | `subscribe` | function | Subscribe to a typed subscription. |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theokit/sdk",
3
- "version": "5.7.0",
3
+ "version": "5.9.0",
4
4
  "description": "TypeScript SDK for the Theo agent harness — same surface, local or cloud.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/usetheokit/theokit-sdk#readme",
@@ -1,59 +0,0 @@
1
- export { Agent } from './chunk-FUUSIT2T.js';
2
- import './chunk-K2VMFZQ5.js';
3
- import './chunk-CZWN4C6A.js';
4
- import './chunk-K2BQQ445.js';
5
- import './chunk-P5S3WCSZ.js';
6
- import './chunk-DQNI52VV.js';
7
- import './chunk-2SFBB54R.js';
8
- import './chunk-55GB6JYQ.js';
9
- import './chunk-H73MEMQB.js';
10
- import './chunk-OR6XIWLB.js';
11
- import './chunk-R3LBRQAN.js';
12
- import './chunk-AAEZSPTC.js';
13
- import './chunk-N7VAE6DZ.js';
14
- import './chunk-UBR5PWD7.js';
15
- import './chunk-2XC6KDJM.js';
16
- import './chunk-XB4GI5RZ.js';
17
- import './chunk-24MGQDK3.js';
18
- import './chunk-2WXHA33T.js';
19
- import './chunk-HKCKOAIO.js';
20
- import './chunk-3VXQEQE4.js';
21
- import './chunk-7C3HWGCW.js';
22
- import './chunk-KVNWIAO4.js';
23
- import './chunk-SVQIW5RJ.js';
24
- import './chunk-FD2UT76F.js';
25
- import './chunk-7I5Z3UBJ.js';
26
- import './chunk-FJWQP6EE.js';
27
- import './chunk-NAF4L3T6.js';
28
- import './chunk-CFE6QF2Q.js';
29
- import './chunk-6X6ID4MO.js';
30
- import './chunk-CA5VUAP3.js';
31
- import './chunk-A6PDYH55.js';
32
- import './chunk-SAGRF4IB.js';
33
- import './chunk-EH6XD3FY.js';
34
- import './chunk-UKMBRMGT.js';
35
- import './chunk-4MMWFSCD.js';
36
- import './chunk-G7BLGBRN.js';
37
- import './chunk-VE6DFSKU.js';
38
- import './chunk-JOFVLOFY.js';
39
- import './chunk-WE22OXQA.js';
40
- import './chunk-6PWOWXMC.js';
41
- import './chunk-TA3K7SBK.js';
42
- import './chunk-Q5EWJPRY.js';
43
- import './chunk-EIQFAOFD.js';
44
- import './chunk-3JHIFQ4I.js';
45
- import './chunk-T3ZDEYTJ.js';
46
- import './chunk-X7EUUHXU.js';
47
- import './chunk-UOLBAPDM.js';
48
- import './chunk-6M2OIS4Y.js';
49
- import './chunk-R7WIIPUR.js';
50
- import './chunk-XYFGKVZ7.js';
51
- import './chunk-VWUXIVEI.js';
52
- import './chunk-AGACYRJ2.js';
53
- import './chunk-JMDDYA22.js';
54
- import './chunk-V22DZIXO.js';
55
- import './chunk-NJWYQWDL.js';
56
- import './chunk-ALUN2B4W.js';
57
- import './chunk-CZJ6Q7CW.js';
58
- //# sourceMappingURL=agent-EQ5HKTWV.js.map
59
- //# sourceMappingURL=agent-EQ5HKTWV.js.map
@@ -1,68 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkA575WPBL_cjs = require('./chunk-A575WPBL.cjs');
4
- require('./chunk-KVSAY6NZ.cjs');
5
- require('./chunk-3XSWF5AP.cjs');
6
- require('./chunk-BUUUWQMB.cjs');
7
- require('./chunk-33A27NFX.cjs');
8
- require('./chunk-YYN6BB7R.cjs');
9
- require('./chunk-BV2MWEMV.cjs');
10
- require('./chunk-D6POWE7E.cjs');
11
- require('./chunk-GHX4P3V2.cjs');
12
- require('./chunk-TMKTSYDS.cjs');
13
- require('./chunk-HNAYCTX4.cjs');
14
- require('./chunk-7FDKWDA2.cjs');
15
- require('./chunk-ZLMU5EU3.cjs');
16
- require('./chunk-FUSDYC2B.cjs');
17
- require('./chunk-YJNYDJ2T.cjs');
18
- require('./chunk-24SYBZPL.cjs');
19
- require('./chunk-QOGNZMHD.cjs');
20
- require('./chunk-YIFFF23U.cjs');
21
- require('./chunk-2ZPEDVLM.cjs');
22
- require('./chunk-EFETPSJZ.cjs');
23
- require('./chunk-GK3UG7YQ.cjs');
24
- require('./chunk-KRD3GQAA.cjs');
25
- require('./chunk-RQMCOFAI.cjs');
26
- require('./chunk-MUUQ2WFJ.cjs');
27
- require('./chunk-AA27GEYS.cjs');
28
- require('./chunk-YSTXFWQE.cjs');
29
- require('./chunk-FRITRLZQ.cjs');
30
- require('./chunk-NQTD6QOW.cjs');
31
- require('./chunk-NINIJCHU.cjs');
32
- require('./chunk-MYJGWS2J.cjs');
33
- require('./chunk-7KBNBPFK.cjs');
34
- require('./chunk-IJ7M6GOG.cjs');
35
- require('./chunk-7A6535RA.cjs');
36
- require('./chunk-SA6K24NB.cjs');
37
- require('./chunk-I2PWY7VM.cjs');
38
- require('./chunk-KTTHHYEW.cjs');
39
- require('./chunk-Z3NTRKIC.cjs');
40
- require('./chunk-GZV6AVRL.cjs');
41
- require('./chunk-A4RAL2ER.cjs');
42
- require('./chunk-DQZU7JK6.cjs');
43
- require('./chunk-BJUJT5ED.cjs');
44
- require('./chunk-ZF2LDKQQ.cjs');
45
- require('./chunk-HCT4HPCL.cjs');
46
- require('./chunk-JLRLCBJ4.cjs');
47
- require('./chunk-RWPLWMCZ.cjs');
48
- require('./chunk-TY56BKSK.cjs');
49
- require('./chunk-QRVS2PRE.cjs');
50
- require('./chunk-ATT276RD.cjs');
51
- require('./chunk-3EE6LVWT.cjs');
52
- require('./chunk-ANMJJD6D.cjs');
53
- require('./chunk-QC55H6RJ.cjs');
54
- require('./chunk-NVXXWAU7.cjs');
55
- require('./chunk-4NLCWGH7.cjs');
56
- require('./chunk-EXTRW7GW.cjs');
57
- require('./chunk-HUFSABUZ.cjs');
58
- require('./chunk-J7J7J2GN.cjs');
59
- require('./chunk-6LHQPOMI.cjs');
60
-
61
-
62
-
63
- Object.defineProperty(exports, "Agent", {
64
- enumerable: true,
65
- get: function () { return chunkA575WPBL_cjs.Agent; }
66
- });
67
- //# sourceMappingURL=agent-KA63WDQH.cjs.map
68
- //# sourceMappingURL=agent-KA63WDQH.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/internal/runtime/compression/compression-helpers.ts","../src/compaction.ts"],"names":[],"mappings":";;;;AA0BO,SAAS,uBAAA,CACd,QAAA,EACA,YAAA,GAAe,CAAA,EACO;AACtB,EAAA,IAAI,QAAA,CAAS,UAAU,YAAA,EAAc;AACnC,IAAA,OAAO,EAAE,YAAY,EAAC,EAAG,YAAY,CAAC,GAAG,QAAQ,CAAA,EAAE;AAAA,EACrD;AACA,EAAA,OAAO;AAAA,IACL,UAAA,EAAY,QAAA,CAAS,KAAA,CAAM,CAAA,EAAG,CAAC,YAAY,CAAA;AAAA,IAC3C,UAAA,EAAY,QAAA,CAAS,KAAA,CAAM,CAAC,YAAY;AAAA,GAC1C;AACF;;;ACOO,IAAM,iBAAA,GAAoB;AAQ1B,IAAM,gBAAA,GAAmB,CAAA;;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA,4CAAA;AAwBhC,SAAS,aAAa,MAAA,EAAsB;AAC1C,EAAA,IAAI,WAAW,EAAA,EAAI;AACjB,IAAA,MAAM,IAAI,kBAAkB,qCAAA,EAAuC;AAAA,MACjE,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AACF;AAGA,SAAS,cAAA,CAAe,SAA8B,MAAA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ACnD,EAAA,OAAO,IAAA,CAAK,IAAA,CAAK,IAAA,CAAK,MAAA,GAAS,eAAe,CAAA;AAChD;AAUO,SAAS,cAAc,KAAA,EAAoC;AAChE,EAAA,OAAO,MAAM,SAAA,IAAa,KAAA,CAAM,gBAAgB,KAAA,CAAM,MAAA,IAAU,MAAM,SAAA,IAAa,CAAA,CAAA;AACrF","file":"chunk-6M2OIS4Y.js","sourcesContent":["/**\n * Compression helpers (T2.3, ADR D92).\n *\n * Scaffold for future compression LLM integration:\n * - `selectCompressionWindow` — splits messages into compress/preserve halves\n * - `assertCompressionReduced` — 10% reduction floor to detect \"compression placebo\"\n *\n * The compression LLM call itself is out of scope for this plan (requires\n * an auxiliary-model ADR). These helpers are used by `Agent.send` when a\n * future iteration adds compression.\n *\n * @internal\n */\n\nexport interface CompressionWindow<M> {\n toCompress: M[];\n toPreserve: M[];\n}\n\n/**\n * Split `messages` into the half to compress (older) and the half to\n * preserve verbatim (recent). When `messages.length <= preserveLast`,\n * everything is preserved.\n *\n * @internal\n */\nexport function selectCompressionWindow<M>(\n messages: readonly M[],\n preserveLast = 6,\n): CompressionWindow<M> {\n if (messages.length <= preserveLast) {\n return { toCompress: [], toPreserve: [...messages] };\n }\n return {\n toCompress: messages.slice(0, -preserveLast),\n toPreserve: messages.slice(-preserveLast),\n };\n}\n\nexport interface CompressionCheck {\n reduced: boolean;\n reductionPct: number;\n reason?: string;\n}\n\n/**\n * Check that compression actually reduced token count by at least `minPct`\n * (default 10%). Returns `{ reduced: false }` for spirals-in-formation\n * (compression LLM outputs that grow or barely shrink).\n *\n * @internal\n */\nexport function assertCompressionReduced(\n before: number,\n after: number,\n minPct = 10,\n): CompressionCheck {\n if (before <= 0) {\n return { reduced: false, reductionPct: 0, reason: \"before count was zero\" };\n }\n const reductionPct = ((before - after) / before) * 100;\n if (reductionPct >= minPct) {\n return { reduced: true, reductionPct };\n }\n return {\n reduced: false,\n reductionPct,\n reason: `compression reduced ${reductionPct.toFixed(1)}% (< ${minPct}% min). Spiral likely.`,\n };\n}\n","/**\n * Public compaction / context-management helpers (M2-1, extended V3-3).\n *\n * Promotes the SDK's compaction capability to a public surface so consumers can\n * compact a transcript, mark/filter conversation checkpoints, and detect\n * context-overflow — without reaching into `internal/`.\n *\n * Two recent-window modes (V3-3):\n * - `keepRecent` (turn-count, default) — keeps the last N turns verbatim and\n * always preserves leading system PROMPTS; reuses the internal\n * `selectCompressionWindow` (no second algorithm).\n * - `keepTokens` (token-budget) — keeps the trailing turns whose accumulated\n * `estimateTokens` fits the budget (theocode `splitTranscript` semantics). In\n * this mode leading system prompts are NOT special-cased (D6).\n *\n * Summarization is delegated to a caller-supplied callback (which receives the\n * older window + the summary template). With `failSafe`, a thrown summarizer\n * returns the ORIGINAL transcript + a structured warn (compaction is an\n * optimization, never a cause of data loss); without it, the error propagates.\n *\n * Public from the `@theokit/sdk/compaction` sub-path.\n */\n\nimport { TheokitAgentError } from \"./errors.js\";\nimport { diag } from \"./internal/diagnostics.js\";\nimport { selectCompressionWindow } from \"./internal/runtime/compression/compression-helpers.js\";\nimport { redactSecrets } from \"./internal/security/redact.js\";\n\n/**\n * Minimal message shape for compaction/compression input. THE canonical public origin (leaf type —\n * rollup-plugin-dts cannot re-export types from internal modules into entry bundles; M42 lesson).\n *\n * @public\n */\nexport interface CompressibleMessage {\n role: \"user\" | \"assistant\" | \"system\";\n content: string;\n}\n\n/**\n * Sentinel prefix marking a conversation checkpoint turn. A visible, structured,\n * prose-unlikely token (no invisible/control bytes — safe to persist and to read\n * in source). Only {@link buildCheckpoint} should produce content beginning with it.\n */\nexport const CHECKPOINT_MARKER = \"[[theokit:checkpoint]] \";\n\n/**\n * The 7-section summary template handed to the `summarize` callback (theocode\n * parity shape). Every header is always present so the summarizer cannot silently\n * drop a category; the model is told to preserve file paths, commands, and error\n * text verbatim. Override per-call via {@link CompactTranscriptOptions.summaryTemplate}.\n */\nexport const SUMMARY_TEMPLATE = `Summarize the conversation so far into these sections (keep every header even if empty):\n\n## Goal\nWhat the user is ultimately trying to achieve.\n\n## Constraints\nHard requirements, conventions, and rules stated.\n\n## Progress\nWhat has been done so far.\n\n## Decisions\nChoices made and their rationale.\n\n## Next\nThe immediate next steps.\n\n## Critical\nAnything that MUST NOT be forgotten (preserve verbatim: error messages, exact values).\n\n## Files\nFile paths touched or referenced (verbatim).`;\n\n/** Reject an empty marker — it would match every turn via `startsWith(\"\")` (EC-3). */\nfunction assertMarker(marker: string): void {\n if (marker === \"\") {\n throw new TheokitAgentError(\"compaction marker must be non-empty\", {\n code: \"invalid_argument\",\n });\n }\n}\n\n/** True for a real system prompt — a `system` turn that is NOT a checkpoint marker. */\nfunction isSystemPrompt(message: CompressibleMessage, marker: string): boolean {\n return message.role === \"system\" && !message.content.startsWith(marker);\n}\n\n/** Carried split: leading system prompts (preserved), the older window, the verbatim tail. */\ninterface TranscriptSplit {\n systemPrompts: CompressibleMessage[];\n head: CompressibleMessage[];\n recent: CompressibleMessage[];\n}\n\n/**\n * Token-budget split (theocode `splitTranscript`): walk from the END accumulating\n * `estimateTokens` until `keepTokens` is exceeded; everything older is the head.\n * Always keeps ≥ 1 recent turn. No system-prompt special-casing (D6).\n */\nfunction selectByTokenBudget(\n messages: CompressibleMessage[],\n keepTokens: number,\n): { head: CompressibleMessage[]; recent: CompressibleMessage[] } {\n let acc = 0;\n let splitIndex = messages.length;\n for (let i = messages.length - 1; i >= 0; i -= 1) {\n acc += estimateTokens(messages[i]?.content ?? \"\");\n if (acc > keepTokens && i < messages.length - 1) {\n splitIndex = i + 1;\n break;\n }\n splitIndex = i;\n }\n return { head: messages.slice(0, splitIndex), recent: messages.slice(splitIndex) };\n}\n\n/** Turn-count split (M2): preserve leading system prompts; window the rest by `keepRecent`. */\nfunction splitByRecent(\n messages: CompressibleMessage[],\n keepRecent: number,\n marker: string,\n): TranscriptSplit {\n const systemPrompts = messages.filter((m) => isSystemPrompt(m, marker));\n const rest = messages.filter((m) => !isSystemPrompt(m, marker));\n const { toCompress, toPreserve } = selectCompressionWindow(rest, keepRecent);\n return { systemPrompts, head: toCompress, recent: toPreserve };\n}\n\n/** Options for {@link compactTranscript}. */\nexport interface CompactTranscriptOptions {\n /** Trailing turns preserved verbatim by COUNT (default 6). Ignored when `keepTokens` is set. */\n keepRecent?: number;\n /**\n * Trailing turns preserved verbatim by TOKEN BUDGET (theocode mode). When set,\n * takes precedence over `keepRecent` and disables system-prompt preservation (D6).\n */\n keepTokens?: number;\n /** Checkpoint marker (default {@link CHECKPOINT_MARKER}). Must be non-empty. */\n marker?: string;\n /** Summary template passed to `summarize` (default {@link SUMMARY_TEMPLATE}). */\n summaryTemplate?: string;\n /** Summarize the older window into one turn; if omitted, the older window is dropped. */\n summarize?: (older: CompressibleMessage[], template: string) => Promise<CompressibleMessage>;\n /**\n * When true, a thrown `summarize` returns the ORIGINAL transcript + a structured\n * warn (compaction never loses data). Default false: the error propagates.\n */\n failSafe?: boolean;\n}\n\n/** Sentinel returned by {@link runSummarize} when fail-safe swallowed a throw. */\nconst FAILSAFE_ABORT = Symbol(\"failsafe-abort\");\n\n/** Run the summarizer; on throw, either propagate or (fail-safe) warn + signal abort. */\nasync function runSummarize(\n summarize: NonNullable<CompactTranscriptOptions[\"summarize\"]>,\n head: CompressibleMessage[],\n template: string,\n failSafe: boolean,\n): Promise<CompressibleMessage | typeof FAILSAFE_ABORT> {\n try {\n return await summarize(head, template);\n } catch (err) {\n if (!failSafe) throw err;\n // Unbreakable Rule 8 — never fail silently. The breadcrumb points at the root\n // cause when a summarizer fails every turn and context grows unchecked. The\n // summarizer is caller-supplied, so its error text is routed through\n // `redactSecrets` (ADR D68 — no unredacted output sink in src/).\n // theokit#147 — through the interceptable channel. A summarizer failing every turn is exactly\n // the breadcrumb a TUI host wants in its own panel, not smeared across its alternate screen.\n diag(\n `[compaction] summarizer failed — proceeding uncompacted: ${redactSecrets(err instanceof Error ? err.message : String(err))}\\n`,\n );\n return FAILSAFE_ABORT;\n }\n}\n\n/**\n * Compact a transcript. In `keepRecent` mode (default) the last `keepRecent` turns\n * are kept verbatim and leading system PROMPTS preserved; in `keepTokens` mode the\n * trailing turns within the token budget are kept (no system special-casing, D6).\n * The older window is summarized (via `summarize`, receiving the template) or\n * dropped. Never mutates the input.\n */\nexport async function compactTranscript(\n messages: CompressibleMessage[],\n options: CompactTranscriptOptions = {},\n): Promise<CompressibleMessage[]> {\n const marker = options.marker ?? CHECKPOINT_MARKER;\n assertMarker(marker);\n const split =\n options.keepTokens != null\n ? { systemPrompts: [], ...selectByTokenBudget(messages, options.keepTokens) }\n : splitByRecent(messages, options.keepRecent ?? 6, marker);\n if (split.head.length === 0) {\n return [...messages];\n }\n if (!options.summarize) {\n return [...split.systemPrompts, ...split.recent];\n }\n const template = options.summaryTemplate ?? SUMMARY_TEMPLATE;\n const summary = await runSummarize(\n options.summarize,\n split.head,\n template,\n options.failSafe ?? false,\n );\n if (summary === FAILSAFE_ABORT) {\n return [...messages];\n }\n return [...split.systemPrompts, summary, ...split.recent];\n}\n\n/**\n * Build a checkpoint marker turn (a `system` turn whose content starts with\n * `marker`, default {@link CHECKPOINT_MARKER}). `marker` must be non-empty.\n */\nexport function buildCheckpoint(\n label?: string,\n marker: string = CHECKPOINT_MARKER,\n): CompressibleMessage {\n assertMarker(marker);\n return { role: \"system\", content: marker + (label ?? \"\") };\n}\n\n/** Options for {@link filterFromLatestCheckpoint}. */\nexport interface FilterCheckpointOptions {\n /** Marker to scan for (default {@link CHECKPOINT_MARKER}). */\n marker?: string;\n /**\n * `'after'` (default, M2) returns turns AFTER the latest marker (exclusive);\n * `'from'` (theocode) returns turns FROM the latest marker (inclusive).\n */\n include?: \"after\" | \"from\";\n}\n\n/**\n * Return the turns relative to the most recent checkpoint marker (all turns if\n * none). `include: 'after'` (default) excludes the checkpoint; `'from'` includes\n * it (the summary stands in for the pruned head). Never mutates the input.\n */\nexport function filterFromLatestCheckpoint(\n messages: CompressibleMessage[],\n options: FilterCheckpointOptions = {},\n): CompressibleMessage[] {\n const marker = options.marker ?? CHECKPOINT_MARKER;\n const offset = options.include === \"from\" ? 0 : 1;\n for (let i = messages.length - 1; i >= 0; i -= 1) {\n if (messages[i]?.content.startsWith(marker)) {\n return messages.slice(i + offset);\n }\n }\n return [...messages];\n}\n\n/**\n * True iff `err` is a {@link TheokitAgentError} (or subclass) reporting a\n * context-window-exceeded condition (the typed `context_too_long` code). Reads\n * both `code` (set by provider mappers) and `metadata.code` (the preferred field)\n * — never a brittle message regex.\n */\nexport function isContextOverflowError(err: unknown): boolean {\n return (\n err instanceof TheokitAgentError &&\n (err.code === \"context_too_long\" || err.metadata?.code === \"context_too_long\")\n );\n}\n\n/**\n * M77 — the margin is outside `(0, 1]`. Typed, because a margin > 1 would GROW the assumed window,\n * which is the unsafe direction: `shouldCompact` is monotonically decreasing in `contextWindow`, so\n * overestimating it makes the trigger fire too late and the context overflow.\n */\nexport class ContextWindowMarginError extends TheokitAgentError {\n constructor(readonly margin: number) {\n super(\n `context-window margin must be in (0, 1], got ${String(margin)}. ` +\n `A margin above 1 grows the assumed window and delays compaction past the real limit.`,\n { code: \"invalid_context_window_margin\" },\n );\n }\n}\n\n/**\n * M77 — default safety margin on the context window.\n *\n * `0.95` is not a guess: it is the single reference's value. Codex ships\n * `effective_context_window_percent: 95` (`models-manager/src/model_info.rs:158`) and never budgets\n * against 100% of a window. Being MULTIPLICATIVE, it stays conservative at any window size, which a\n * fixed subtraction would not.\n */\nexport const CONTEXT_WINDOW_MARGIN = 0.95;\n\n/**\n * M77 — the floor used ONLY when neither the catalog nor the caller knows the window.\n *\n * Honest about its own weakness. This number has **one** source (the M77 milestone text); the search\n * for a second one failed, because the reference has no fallback at all — Codex returns `Option` and\n * its callers early-return (`core/src/session/turn_context.rs:213`, `core/src/compact_remote.rs:374`).\n *\n * It is conservative only UPWARD. For a model whose real window is larger, budgeting against 128k\n * compacts early — wasteful but safe. For a model whose real window is SMALLER (an 8k or 32k model\n * absent from the catalog), it compacts too late and the context still overflows. That residual risk\n * is real and is why {@link resolveEffectiveContextWindow} never lets this floor compete with a known\n * catalog value, and why the `compaction_fallback` event exists: a surface can show that the budget is\n * a guess instead of the user finding out when the provider rejects the request.\n */\nexport const CONTEXT_WINDOW_FLOOR = 128_000;\n\n/** Where the effective window came from — carried into the M77 structured event. */\nexport type ContextWindowSource = \"override\" | \"catalog\" | \"fallback\";\n\n/** Input to {@link resolveEffectiveContextWindow}. */\nexport interface EffectiveContextWindowInput {\n /** Caller-supplied window, in tokens. Clamped by `catalog` when both are present. */\n readonly override?: number | undefined;\n /** The model's window from the catalog, in tokens. Absent when the model is unknown. */\n readonly catalog?: number | undefined;\n /** Safety margin in `(0, 1]`. Codex uses 0.95 (`model_info.rs:158`). */\n readonly margin: number;\n /** Conservative floor used ONLY when neither `override` nor `catalog` is available. */\n readonly floor?: number | undefined;\n}\n\n/** Result of {@link resolveEffectiveContextWindow}. */\nexport interface EffectiveContextWindow {\n /** The window to budget against, after clamp and margin. */\n readonly window: number;\n /** Which input won — `\"fallback\"` means neither override nor catalog was available. */\n readonly source: ContextWindowSource;\n /** `true` when an `override` above the catalog window was clamped down to it. */\n readonly clamped: boolean;\n}\n\n/**\n * Absolute cap on a declared context window, applied when no catalog entry exists to compare against.\n *\n * **10M**, not 2M. The first version used 2M on the rationale that it sat \"comfortably above the\n * largest published window\" — adversarial review measured the opposite: Llama 4 Scout publishes\n * **10M**, and it arrives precisely via OpenRouter, the provider **without** a catalog, which is the\n * case this cap exists to cover. The user would have silently lost 80% of the declared window.\n *\n * The cap still serves what motivates it — one extra zero on 400k gives 4M, which passes; two zeros\n * give 40M, which does not. A limit that rejects legitimate configuration is worse than no limit,\n * because failing OPEN is visible when it happens and silently losing 80% is not.\n */\nexport const ABSOLUTE_CONTEXT_WINDOW_CAP = 10_000_000;\n\n/**\n * Resolve the window to budget against — the fail-SAFE replacement for reading the catalog directly.\n *\n * Today `post-run-lifecycle.ts` reads `getCatalogModelInfo(model)?.limit?.context` and, when that is\n * `undefined`, auto-compaction simply never fires. That is fail-OPEN: the context grows until the\n * provider rejects the request. (The comment there calls it \"fail-safe\" — M77 corrects it.)\n *\n * Three techniques, two of them borrowed from the single reference:\n *\n * 1. **Override, CLAMPED by the catalog** — Codex `models-manager/src/model_info.rs:26-31` lets\n * config override the window but limits it with `context_window.min(max_context_window)`.\n * Without the clamp, declaring 999k on a 200k model reopens the overflow through another door.\n * 2. **Multiplicative margin** — Codex `model_info.rs:158` (`effective_context_window_percent: 95`)\n * never budgets against 100% of the window. Being multiplicative, it is conservative for ANY\n * window size.\n * 3. **Floor, only when nothing is known** — deliberately NOT a blanket default. A fixed floor is\n * conservative only upward: applied to a small model it would inflate the assumed window and\n * reproduce the very fail-open this function exists to close. Hence the floor never competes\n * with a known catalog value.\n *\n * Pure — no catalog lookup, no I/O. The caller supplies the numbers, mirroring `shouldCompact`.\n */\nexport function resolveEffectiveContextWindow(\n input: EffectiveContextWindowInput,\n): EffectiveContextWindow {\n if (!(input.margin > 0) || input.margin > 1) {\n throw new ContextWindowMarginError(input.margin);\n }\n\n const withMargin = (raw: number): number => Math.floor(raw * input.margin);\n\n if (input.override !== undefined) {\n // The catalog is the preferred cap; without it the ABSOLUTE cap applies.\n //\n // M95 (adversarial review of M94) — the previous version clamped **only** when a catalog entry\n // existed, and the whole reason the `contextWindow` key exists is the model that has NO entry\n // (OpenRouter has zero). So the clamp was missing in exactly the case that justifies the\n // feature, while the documentation — including an already-published CHANGELOG — stated without\n // qualification that \"declaring 10M does not blow past the provider\".\n //\n // The concrete scenario is one extra zero: `context_window = 4000000`. The only guard was a\n // `.positive().int()`, which sets no upper bound. The agent would never compact until the\n // provider refused the turn — the silent fail-OPEN that M77 exists to prevent.\n const cap = input.catalog ?? ABSOLUTE_CONTEXT_WINDOW_CAP;\n const clamped = input.override > cap;\n return { window: withMargin(clamped ? cap : input.override), source: \"override\", clamped };\n }\n\n if (input.catalog !== undefined) {\n return { window: withMargin(input.catalog), source: \"catalog\", clamped: false };\n }\n\n return { window: withMargin(input.floor ?? 0), source: \"fallback\", clamped: false };\n}\n\n/** Input to {@link shouldCompact}: an estimate, the model's window, and reserved headroom. */\nexport interface ShouldCompactInput {\n /** Estimated token count of the next request (e.g. from {@link estimateTokens}). */\n readonly estimated: number;\n /** The model's total context window, in tokens. */\n readonly contextWindow: number;\n /** Tokens to reserve as headroom (output + safety margin). */\n readonly buffer: number;\n /**\n * Tokens reserved for the model's response generation, SEPARATE from `buffer`.\n * Default 0 — omitting it preserves the legacy\n * `estimated >= contextWindow - buffer` result.\n */\n readonly maxOutput?: number;\n}\n\n/**\n * Characters per token in the tokenizer-free estimate below.\n *\n * Exported so the ratio has ONE owner. It used to be a named constant in `built-in-processors.ts`\n * and an inlined `4` here, with both `estimateTokens` functions `@public` from two different package\n * entry points — so tuning the ratio, or switching to code points instead of UTF-16 units (the\n * caveat both docblocks already carried), would have silently diverged them.\n *\n * @public\n */\nexport const CHARS_PER_TOKEN = 4;\n\n/**\n * Tokenizer-free token estimate via the conventional ~4-chars-per-token\n * heuristic: `ceil(text.length / CHARS_PER_TOKEN)`. `\"\"` → 0; any non-empty text → ≥ 1.\n * A cheap PRE-CALL gate for {@link shouldCompact} — NOT exact tokenization\n * (a consumer needing exactness supplies their own tokenizer). Uses UTF-16\n * `.length` (code units), so multibyte text is approximate.\n *\n * `built-in-processors.ts` re-exports this under the same name, so both entry points keep working\n * and there is one implementation behind them.\n */\nexport function estimateTokens(text: string): number {\n return Math.ceil(text.length / CHARS_PER_TOKEN);\n}\n\n/**\n * Decide BEFORE sending whether to compact: `true` when the `estimated` token\n * count leaves less than `buffer` headroom in the `contextWindow`\n * (`estimated >= contextWindow - buffer`). A `buffer >= contextWindow`\n * (non-positive threshold) always returns `true`. Pure — the caller supplies\n * the window (e.g. from `resolveModelCapabilities`), keeping this decoupled\n * from the per-model catalog.\n */\nexport function shouldCompact(input: ShouldCompactInput): boolean {\n return input.estimated >= input.contextWindow - input.buffer - (input.maxOutput ?? 0);\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/internal/runtime/context/context-discovery.ts"],"names":["isAbsolute","resolve","existsSync","join","dirname","realpathSync","glob"],"mappings":";;;;;;;AAsIO,SAAS,aAAA,CACd,OACA,aAAA,EAC8B;AAC9B,EAAA,IAAI,aAAA,KAAkB,QAAW,OAAO,KAAA;AACxC,EAAA,MAAM,OAAA,GAAU,IAAI,GAAA,CAAI,aAAa,CAAA;AACrC,EAAA,OAAO,KAAA,CAAM,MAAA,CAAO,CAAC,IAAA,KAAS,IAAA,CAAK,OAAA,KAAY,MAAA,IAAa,OAAA,CAAQ,GAAA,CAAI,IAAA,CAAK,OAAO,CAAC,CAAA;AACvF;AAwBO,SAAS,aAAA,CACd,OACA,aAAA,EAC0F;AAC1F,EAAA,IAAI,aAAA,KAAkB,MAAA,EAAW,OAAO,EAAC;AACzC,EAAA,MAAM,OAAA,GAAU,IAAI,GAAA,CAAI,aAAa,CAAA;AACrC,EAAA,OAAO,KAAA,CACJ,MAAA,CAAO,CAAC,IAAA,KAAS,IAAA,CAAK,OAAA,KAAY,MAAA,IAAa,CAAC,OAAA,CAAQ,GAAA,CAAI,IAAA,CAAK,OAAO,CAAC,CAAA,CACzE,GAAA,CAAI,CAAC,IAAA,MAAU,EAAE,EAAA,EAAI,IAAA,CAAK,EAAA,EAAI,OAAA,EAAS,IAAA,CAAK,OAAA,EAAS,KAAA,EAAO,MAAA,CAAO,IAAA,CAAK,OAAO,GAAE,CAAE,CAAA;AACxF;AAmBO,IAAM,uBAAA,GAAwD;AAAA,EACnE;AAAA,IACE,EAAA,EAAI,WAAA;AAAA,IACJ,OAAA,EAAS,QAAA;AAAA,IACT,OAAA,EAAS,WAAA;AAAA,IACT,KAAA,EAAO,eAAA;AAAA,IACP,MAAA,EAAQ,gBAAA;AAAA,IACR,aAAA,EAAe,KAAA;AAAA,IACf,QAAA,EAAU;AAAA,GACZ;AAAA,EACA;AAAA,IACE,EAAA,EAAI,WAAA;AAAA,IACJ,OAAA,EAAS,QAAA;AAAA,IAC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ChC;AAAA,EACF,CAAA,CAAA,MAAQ;AAGN,IAAA,OAAO,EAAC;AAAA,EACV;AAQA,EAAA,OAAO,KAAA,CAAM,IAAA,CAAK,CAAC,CAAA,EAAG,CAAA,KAAO,CAAA,GAAI,CAAA,GAAI,EAAA,GAAK,CAAA,GAAI,CAAA,GAAI,CAAA,GAAI,CAAE,CAAA;AAC1D","file":"chunk-7KBNBPFK.cjs","sourcesContent":["/**\n * Context file discovery (T1.1, ADRs D150 / D151).\n *\n * Discovers context files via three scopes:\n * - `cwd-only` — single dir, single path lookup\n * - `git-root-walk` — walk cwd → git-root, collect every directory's match\n * (nearest-first ordering)\n * - `globbed` — glob pattern relative to cwd (e.g. `.cursor/rules/*.mdc`)\n *\n * Pure `existsSync` checks — **no `.gitignore` parsing** (EC-A, KISS) and\n * **no invented `.theokitignore`** (EC-B). Paths normalized via\n * `realpath` to dedup symlink chains pointing to the same physical file\n * (EC-F). Git worktrees work transparently because `.git` exists as a\n * file in that case (EC-N).\n *\n * @internal\n */\n\nimport { existsSync, realpathSync } from \"node:fs\";\nimport { glob } from \"node:fs/promises\";\nimport { dirname, isAbsolute, join, resolve } from \"node:path\";\n\n/** Single filename (\"AGENTS.md\") or relative glob (\".cursor/rules/*.mdc\"). */\nexport type DiscoveryScope = \"cwd-only\" | \"git-root-walk\" | \"globbed\";\n\n/** Parser to apply once file is read. */\nexport type DiscoveryParser = \"plain-markdown\" | \"mdc\" | \"frontmatter-zod\" | \"rules-frontmatter\";\n\n/**\n * One kind of context file the runner knows how to find and read. The shipped registry is\n * `DEFAULT_DISCOVERY_SPECS`; a caller supplies its own array to change the set.\n *\n * `scope` decides how `pattern` is used and how many files a single spec can yield:\n * `cwd-only` looks for one path and stops, `git-root-walk` collects a match in every directory\n * from `cwd` up to the git root (nearest first), and `globbed` expands `pattern` as a glob\n * relative to `cwd`. So `pattern` is a filename for the first two and a glob for the third —\n * putting a glob on a walk scope silently finds nothing.\n *\n * `priority` orders the merged prompt, ascending, and is a plain number rather than an index, so\n * a new spec can be slotted between two existing ones. Lower means earlier and therefore more\n * general; later content wins on conflict.\n *\n * `parser` must match the file format — `plain-markdown` reads the whole file, `mdc` and\n * `rules-frontmatter` parse frontmatter and can DECLINE the file when its activation conditions\n * do not hold, and `frontmatter-zod` is the legacy path the runner currently skips entirely.\n *\n * `followImports` is honored only by `plain-markdown`, and turns `@path` directives in the body\n * into inlined content bounded by the import root. Setting it on a frontmatter parser does\n * nothing.\n *\n * `id` names the source in `<source name=\"\">` and in telemetry. When one spec matches files in\n * several directories, the runner suffixes it with the path relative to the git root to keep them\n * apart.\n *\n * @public — re-exported from `@theokit/sdk/context`, and therefore under semver.\n */\nexport interface DiscoverySpec {\n /** Stable identifier — used as `<source name=\"\">` and telemetry key. */\n readonly id: string;\n /** Priority for merge (lower = earlier in prompt). */\n readonly priority: number;\n /** Filename (cwd-only/git-root-walk) or glob (globbed). */\n readonly pattern: string;\n readonly scope: DiscoveryScope;\n readonly parser: DiscoveryParser;\n /** Whether to follow `@path` import directives (CLAUDE.md / GEMINI.md). */\n readonly followImports: boolean;\n /**\n * The `CompatSource` kind whose grant gates this file — the name a consumer writes in\n * `local.compatSources` to receive it.\n *\n * Absent means UNGATED, and that covers two different situations which the field deliberately does\n * not distinguish, because the gate treats them identically:\n *\n * 1. **Native.** theokit's own roots. Declaring theokit is what running theokit means, so there is\n * no separate grant to ask for.\n * 2. **A repo-root instruction file.** `AGENTS.md`, `GEMINI.md`, `CLAUDE.md` and\n * `.cursor/rules/*.mdc` are every bit as foreign as `.claude/` is, and every one of them puts\n * a cloned repository's prose into the system prompt. They are ungated anyway, for a reason\n * that is a limit rather than a judgement: `adaptersFor` registers ONE foreign adapter,\n * `claude-code`, so `compatSources` has no spelling that admits `agents`, `gemini` or\n * `cursor`. Labelling them would gate them on a grant nobody can write, making three formats\n * permanently unreachable — a silent loss of capability with no way to restore it, which is a\n * worse defect than the one being fixed and the exact shape this codebase already paid for in\n * usetheokit/theokit-sdk#524.\n *\n * `CLAUDE.md` is ungated for the adjacent reason, and this one IS a judgement: the grant gates\n * the foreign ROOT — the `.claude/` directory whose hooks, skills, subagents and plugins\n * already require it — and `CLAUDE.md` does not live there. It sits at the repository root\n * beside the other three, is widely used as a generic agent-instructions file by projects that\n * have no `.claude/` at all, and gating it would take it from them.\n *\n * So this field closes the door the grant vocabulary already has a key for, and leaves three\n * named. Whether a repo-root instruction file should require an opt-in at all is a product\n * decision affecting every consumer, not a bug fix, and it is tracked separately — writing it\n * down is the point, because an undocumented gap reads as an oversight.\n *\n * Optional because this interface is `@public` and under semver: a caller passing its own array\n * keeps working, and its specs read as ungated — the behaviour they had before this field existed.\n *\n * On the SPEC rather than as a condition at the call site, because the table MIXES dialects.\n * Adding one is adding a row, not editing a branch somebody else has to find.\n */\n readonly dialect?: string;\n}\n\n/**\n * The specs a consumer's declared compat sources admit.\n *\n * The half that turns {@link DiscoverySpec.dialect} from a label into a gate. A field nobody consults\n * is a control that is declared, exported, documented and wired to nothing — which is the failure\n * this whole change exists to close, and it would be a poor joke to reproduce it here.\n *\n * Three rules, and each is a decision rather than a convenience:\n *\n * - **A spec with no `dialect` is always admitted.** Absent means native, and a caller's own array\n * predates this field: filtering it by a question it never answered would remove content nobody\n * asked to remove.\n * - **`undefined` sources admit everything.** That is every consumer before this field existed. This\n * is the back-compatibility floor and the reason the change is a minor rather than a breaking one.\n * - **A declared list admits only the dialects it names.** This is the fix: a consumer who grants\n * `theokit` for its own roots and never declares `claude-code` stops receiving that repository's\n * `.claude/rules/*.md` in its prompt.\n *\n * `@internal`, deliberately. The docblock claimed `@public — re-exported from\n * '@theokit/sdk/context'` and the barrel exported no such name: a reach asserted and not given,\n * which is the defect this whole change is about, committed in the fix for it. A consumer building\n * its own `specs` array does not need this function — it passes `declaredCompatKinds` to\n * `runDiscovery` and gets the same filtering, through a public option on a public interface. So the\n * honest correction is to narrow the claim rather than widen the surface.\n *\n * @internal — exported from the module so the gate is testable at its boundary rather than only\n * through a whole agent, and not re-exported from any public entry point.\n */\nexport function admittedSpecs(\n specs: ReadonlyArray<DiscoverySpec>,\n declaredKinds: ReadonlyArray<string> | undefined,\n): ReadonlyArray<DiscoverySpec> {\n if (declaredKinds === undefined) return specs;\n const granted = new Set(declaredKinds);\n return specs.filter((spec) => spec.dialect === undefined || granted.has(spec.dialect));\n}\n\n/**\n * The mirror of {@link admittedSpecs}: the specs a declaration did NOT admit.\n *\n * It exists because `runDiscovery`'s own docblock admits the gap it closes — *\"a shorter result\n * than expected means 'nothing qualified', and this function will not tell you which of those it\n * was\"*. After B-081 gates the four repo-root instruction files, a consumer who declares nothing\n * goes from receiving four files to receiving none, and that has to be legible.\n *\n * Returned as a VALUE rather than only logged, because a log line cannot be asserted by a\n * consumer's test, and this repository does not ship controls that cannot be observed. The loud\n * half is the `warnOnce` the caller emits from this list.\n *\n * Each entry carries the grant that WOULD admit it — being told you lost something, without being\n * told what would bring it back, is a diagnosis with no remedy.\n *\n * `undefined` declaredKinds means \"no gate configured\", which admits everything and therefore\n * withholds nothing. That is NOT the same as `[]`, which is a real declaration of no foreign\n * dialect and withholds every gated spec — the distinction `declaredCompatKinds` already carries,\n * preserved here rather than re-decided.\n *\n * @public — re-exported from `@theokit/sdk/context`, and therefore under semver.\n */\nexport function withheldSpecs(\n specs: ReadonlyArray<DiscoverySpec>,\n declaredKinds: ReadonlyArray<string> | undefined,\n): ReadonlyArray<{ readonly id: string; readonly pattern: string; readonly grant: string }> {\n if (declaredKinds === undefined) return [];\n const granted = new Set(declaredKinds);\n return specs\n .filter((spec) => spec.dialect !== undefined && !granted.has(spec.dialect))\n .map((spec) => ({ id: spec.id, pattern: spec.pattern, grant: String(spec.dialect) }));\n}\n\n/**\n * The context files theokit looks for out of the box, in the order they are concatenated.\n *\n * Two things follow from the ordering. `AGENTS.md` comes first at priority 10 and `THEO.md` last,\n * so theokit-specific instruction wins over the vendor-neutral file on conflict. And the array is\n * consumed in the order written — the runner does not re-sort it — so a caller passing its own\n * array is responsible for keeping `priority` and array position consistent.\n *\n * `CLAUDE.md` and `GEMINI.md` are the only two entries with `followImports: true`, which means\n * they are the only files whose `@path` directives pull other files into the prompt. Those\n * imports cannot escape the import root.\n *\n * Frozen only by type: `ReadonlyArray` is a compile-time constraint, and the array and its\n * elements are not deep-frozen at runtime. Build a new array rather than mutating this one.\n *\n * @public — re-exported from `@theokit/sdk/context`, and therefore under semver.\n */\nexport const DEFAULT_DISCOVERY_SPECS: ReadonlyArray<DiscoverySpec> = [\n {\n id: \"AGENTS.md\",\n dialect: \"agents\",\n pattern: \"AGENTS.md\",\n scope: \"git-root-walk\",\n parser: \"plain-markdown\",\n followImports: false,\n priority: 10,\n },\n {\n id: \"GEMINI.md\",\n dialect: \"gemini\",\n pattern: \"GEMINI.md\",\n scope: \"git-root-walk\",\n parser: \"plain-markdown\",\n followImports: true,\n priority: 20,\n },\n {\n id: \"CLAUDE.md\",\n dialect: \"claude-code\",\n pattern: \"CLAUDE.md\",\n scope: \"git-root-walk\",\n parser: \"plain-markdown\",\n followImports: true,\n priority: 30,\n },\n {\n id: \"cursor-rules\",\n dialect: \"cursor\",\n pattern: \".cursor/rules/*.mdc\",\n scope: \"globbed\",\n parser: \"mdc\",\n followImports: false,\n priority: 40,\n },\n {\n id: \"theokit-rules\",\n pattern: \".theokit/rules/*.md\",\n scope: \"globbed\",\n parser: \"rules-frontmatter\",\n followImports: false,\n priority: 45,\n },\n {\n // Rules written for the Claude Code CLI. Measured 2026-08-26 over this repository's 32 rule\n // files: none carries frontmatter, and `rules-frontmatter` already reads a file without it as\n // `alwaysApply: true` — the format needed nothing, only a spec pointing at the directory.\n //\n // 47, not 46. Specs sort ascending and a context budget drops the tail first, so it must land\n // AFTER `.theokit/rules` (45) — the explicit namespace should survive a squeeze the borrowed one\n // does not. It must also leave a slot on BOTH sides: B-127 makes these numbers a public contract\n // precisely so a consumer can place its own source between two defaults, and 46 would have left\n // no room between 45 and itself. 47 keeps 46 free below and 48–49 free above.\n //\n // The reckoning B-127's docblock asks for: no published priority MOVES, so a consumer that chose\n // 46, 48 or 49 is unaffected. A consumer that had chosen 47 now collides — that is the cost of\n // an eighth default, paid once and recorded here rather than discovered later.\n id: \"claude-rules\",\n dialect: \"claude-code\",\n pattern: \".claude/rules/*.md\",\n scope: \"globbed\",\n parser: \"rules-frontmatter\",\n followImports: false,\n priority: 47,\n },\n {\n id: \"theokit-context\",\n pattern: \".theokit/context/*.md\",\n scope: \"globbed\",\n parser: \"frontmatter-zod\",\n followImports: false,\n priority: 50,\n },\n {\n // usetheokit/theokit-sdk#531 — THEO.md was the only context file that could not live at the\n // project root: every sibling here is `git-root-walk`, and this one was `cwd-only` pointed\n // at `.theokit/THEO.md` specifically, with no warning that a root THEO.md was inert.\n //\n // ADDED rather than moving the existing entry below: a project already using\n // `.theokit/THEO.md` keeps working unchanged. 55 sits between `theokit-context` (50) and the\n // existing `THEO.md` (60), leaving room on both sides — the numbering discipline\n // `claude-rules` (47) already established for this array.\n //\n // `followImports: true`, unlike the existing entry (`false`) and unlike `AGENTS.md`. This is\n // a DELIBERATE divergence between the two THEO.md specs, not an inconsistency: a root-level\n // file is edited by the same people, in the same place, as CLAUDE.md/GEMINI.md — the two\n // other root-level, human-facing files that both carry `followImports: true` — so it belongs\n // in their category rather than AGENTS.md's vendor-neutral, import-free one. Because this is a\n // NEW spec, choosing `true` here changes nothing for `.theokit/THEO.md`, which keeps `false`.\n id: \"THEO.md.root\",\n pattern: \"THEO.md\",\n scope: \"git-root-walk\",\n parser: \"plain-markdown\",\n followImports: true,\n priority: 55,\n },\n {\n id: \"THEO.md\",\n pattern: \".theokit/THEO.md\",\n scope: \"cwd-only\",\n parser: \"plain-markdown\",\n followImports: false,\n priority: 60,\n },\n\n // ── The private chain (B-023) ───────────────────────────────────────────────────────────────\n //\n // `*.local.md` is the gitignored companion where an operator keeps the standing corrections too\n // personal or too situational to commit. Nothing read it: measured 2026-09-12, a grep for the four\n // `.local` spellings returned 0 files across this package's source, against a control of 23 for\n // `CLAUDE.md`. The file exists, it is named the documented way, and the agent behaves exactly as\n // it would if the operator had written nothing.\n //\n // ORDER. They sit ABOVE every public spec because a correction has to be composed after the rule\n // it corrects, and they keep the public chain's relative order among themselves (AGENTS, CLAUDE,\n // THEO) so the two halves read the same way.\n //\n // THE COST OF THAT, stated rather than discovered later: `applyAggregateCap` fills the budget in\n // ascending priority, so the HIGHEST numbers are the first dropped when the total cap is reached.\n // Placing the private chain last therefore makes it the first to go under pressure. The\n // alternative — a low number, to protect it — would compose the operator's refinement BEFORE the\n // general rule, which inverts its meaning and is the defect this item is about. The existing table\n // already accepts that trade: `.theokit/THEO.md`, the project's most specific instructions, is at\n // 60 and is equally droppable. This follows the convention rather than inventing an exception.\n //\n // WHY THESE THREE AND NOT SIX. A private companion pairs with a public file THIS seam reads, and\n // the documented convention is THEO / AGENTS / CLAUDE. `GEMINI.local.md` and a private\n // `.cursor/rules` are not part of it, and inventing them would publish a convention nobody writes.\n // Note the rule lands differently in `@theokit/agents`' `DEFAULT_FILE_NAMES`, which has no\n // `CLAUDE.md` and therefore gets no `CLAUDE.local.md` — same rule, two seams, stated at both ends.\n //\n // UNGATED, like the public repo-root files beside them. `CLAUDE.local.md` is a repo-root file, not\n // a `.claude/` one, so it follows `CLAUDE.md` rather than `claude-rules` — see `dialect`'s\n // docblock for why the grant gates the foreign ROOT and not the files beside it.\n {\n id: \"AGENTS.local.md\",\n pattern: \"AGENTS.local.md\",\n scope: \"git-root-walk\",\n parser: \"plain-markdown\",\n followImports: false,\n priority: 70,\n },\n {\n id: \"CLAUDE.local.md\",\n pattern: \"CLAUDE.local.md\",\n scope: \"git-root-walk\",\n parser: \"plain-markdown\",\n // Mirrors `CLAUDE.md`, which follows imports. A private file that could not `@import` while its\n // public sibling can would be a difference nobody declared.\n followImports: true,\n priority: 75,\n },\n {\n id: \"THEO.local.md\",\n pattern: \"THEO.local.md\",\n scope: \"git-root-walk\",\n parser: \"plain-markdown\",\n // Mirrors `THEO.md.root`, which follows imports.\n followImports: true,\n priority: 80,\n },\n];\n\nconst SAFE_FILENAME = /^[a-zA-Z0-9_.\\-/*]+$/;\nconst TRAVERSAL_RE = /(^|\\/)\\.\\.(\\/|$)/;\n\n/**\n * Reject patterns that contain path traversal (`..`) or non-allowed\n * characters (D81 parity, EC-4).\n *\n * @internal\n */\nexport function isSafePattern(pattern: string): boolean {\n if (typeof pattern !== \"string\" || pattern.length === 0) return false;\n if (TRAVERSAL_RE.test(pattern)) return false;\n if (isAbsolute(pattern)) return false;\n return SAFE_FILENAME.test(pattern);\n}\n\n/**\n * Walk upward from `cwd` looking for the closest directory containing\n * a `.git` entry (file OR directory — worktrees use a `.git` FILE,\n * EC-N). Returns the absolute path of that directory, or `undefined`\n * when no git root exists at or above `cwd`.\n *\n * @internal\n */\nexport function findGitRoot(cwd: string): string | undefined {\n if (typeof cwd !== \"string\" || cwd.length === 0) return undefined;\n let current = resolve(cwd);\n // Guard against infinite loops on weird filesystems.\n for (let i = 0; i < 64; i += 1) {\n if (existsSync(join(current, \".git\"))) return current;\n const parent = dirname(current);\n if (parent === current) return undefined;\n current = parent;\n }\n return undefined;\n}\n\n/**\n * Walk `cwd` upward to `stopDir` (inclusive) collecting every existing\n * occurrence of `filename`. Returns absolute, realpath-deduped paths in\n * nearest-first order (innermost dir first).\n *\n * No `.gitignore` parsing (EC-A). Realpath collapses symlink chains\n * pointing to the same physical file (EC-F). Filesystem races (file\n * deleted mid-walk) are skipped silently (EC-5).\n *\n * @internal\n */\n// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: walk-up loop combines validation + realpath dedup + FS-race handling + stopDir guard in a single bounded loop; splitting fragments the dedup invariant.\nexport function walkUpForFile(\n cwd: string,\n filename: string,\n stopDir: string | undefined,\n): string[] {\n if (!isSafePattern(filename)) {\n return [];\n }\n const start = resolve(cwd);\n const stop = stopDir !== undefined ? resolve(stopDir) : undefined;\n const found: string[] = [];\n const seenReal = new Set<string>();\n let current = start;\n // 64-level depth cap.\n for (let i = 0; i < 64; i += 1) {\n const candidate = join(current, filename);\n if (existsSync(candidate)) {\n let real: string;\n try {\n real = realpathSync(candidate);\n } catch {\n // FS race (deleted mid-walk) — skip.\n real = candidate;\n }\n if (!seenReal.has(real)) {\n seenReal.add(real);\n found.push(real);\n }\n }\n if (stop !== undefined && current === stop) break;\n const parent = dirname(current);\n if (parent === current) break;\n current = parent;\n }\n return found;\n}\n\n/**\n * Glob-style discovery under `cwd` (e.g. `.cursor/rules/*.mdc`, `.theokit/rules/**\\/*.md`).\n * Returns absolute, lex-sorted paths.\n *\n * `*` matches within one path segment and `**` spans any depth, including zero — so\n * `.theokit/rules/**\\/*.md` finds `rules/top.md` as well as `rules/deep/nested/inner.md`, while\n * `.theokit/rules/*.md` keeps its flat meaning and finds only the first. That distinction is the\n * compatibility contract: every existing spec uses a single `*`, and widening it would silently\n * start absorbing nested files nobody chose to expose.\n *\n * ## Why this used to be flat, and what changed (B-119)\n *\n * The previous implementation split the pattern at its LAST `/`, treated the prefix as a literal\n * directory and did one `readdir` — documented as \"nested directories deferred to v2\" (EC-R). The\n * deferral was deliberate; what made it a defect was measured from a consumer. TheoCode's own rule\n * loader descends recursively, so migrating it onto the `theokit-rules` spec would have silently\n * dropped every nested rule — on the path that decides whether a repository's hooks execute. And a\n * pattern written to say so, `.theokit/rules/**\\/*.md`, resolved its directory part to a literal\n * `**` and matched NOTHING, not even the top-level file it matched before the globstar was added.\n *\n * ## Why the stdlib rather than a walker\n *\n * `fs.promises.glob` (Node ≥ 22, and this package requires ≥ 22.12) implements exactly these\n * semantics, verified against a fixture before adoption: `**\\/*.md` returns all three depths,\n * `*.md` returns one, and it emits no experimental warning. Writing a recursive walker here would\n * have been a third implementation of matching inside one package — the same duplication that let\n * the enumerator and the compiler in `context-glob.ts` disagree in the first place. `globToRegex`\n * stays where it belongs: deciding whether a rule APPLIES to a set of paths, which is a different\n * question from which files exist.\n *\n * `isSafePattern` still runs first and is unchanged, so `..` is refused before any I/O.\n *\n * @internal\n */\nexport async function walkUpForGlob(cwd: string, pattern: string): Promise<string[]> {\n if (!isSafePattern(pattern)) return [];\n const found: string[] = [];\n try {\n for await (const entry of glob(pattern, { cwd })) {\n found.push(resolve(cwd, entry));\n }\n } catch {\n // A pattern whose directory does not exist is the ordinary case — most projects have no\n // `.cursor/rules/`. Same outcome as matching nothing.\n return [];\n }\n // Sorted, because discovery order becomes prompt order and must not vary with the filesystem.\n //\n // The comparator is explicit and deliberately NOT `localeCompare`, which is the usual suggestion\n // for a bare `.sort()`. `localeCompare` orders by the machine's locale, so the same tree would\n // assemble a different prompt on a differently-configured machine — trading one source of\n // non-determinism for a subtler one. Code-unit ordering is what a bare `.sort()` already does for\n // strings; writing it out states the intent and keeps the result machine-independent.\n return found.sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));\n}\n"]}