@theokit/sdk 4.51.0 → 4.52.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 (295) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/agent-C66BEJGO.cjs +58 -0
  3. package/dist/{agent-B2WU3JP6.cjs.map → agent-C66BEJGO.cjs.map} +1 -1
  4. package/dist/agent-HYQGJTIN.js +49 -0
  5. package/dist/{agent-DI2QQHSJ.js.map → agent-HYQGJTIN.js.map} +1 -1
  6. package/dist/agent-session-store-EPX2WQI4.cjs +23 -0
  7. package/dist/{agent-session-store-EPUERCUU.cjs.map → agent-session-store-EPX2WQI4.cjs.map} +1 -1
  8. package/dist/agent-session-store-JMU7ASDB.js +6 -0
  9. package/dist/{agent-session-store-TXP5ZVOD.js.map → agent-session-store-JMU7ASDB.js.map} +1 -1
  10. package/dist/auth/index.cjs +21 -16
  11. package/dist/auth/index.cjs.map +1 -1
  12. package/dist/auth/index.js +5 -4
  13. package/dist/auth/index.js.map +1 -1
  14. package/dist/{batch-OUF4N2TM.js → batch-NLIS4QTW.js} +9 -9
  15. package/dist/{batch-OUF4N2TM.js.map → batch-NLIS4QTW.js.map} +1 -1
  16. package/dist/{batch-URTEXK77.cjs → batch-WQ3AJCDV.cjs} +26 -26
  17. package/dist/{batch-URTEXK77.cjs.map → batch-WQ3AJCDV.cjs.map} +1 -1
  18. package/dist/{chunk-WUUSAMFC.cjs → chunk-2CD5XUAG.cjs} +24 -24
  19. package/dist/{chunk-WUUSAMFC.cjs.map → chunk-2CD5XUAG.cjs.map} +1 -1
  20. package/dist/{chunk-NETYW4V3.cjs → chunk-2CFEET3Y.cjs} +4 -4
  21. package/dist/{chunk-NETYW4V3.cjs.map → chunk-2CFEET3Y.cjs.map} +1 -1
  22. package/dist/{chunk-YULF6FPB.cjs → chunk-2YGIBOUH.cjs} +8 -8
  23. package/dist/{chunk-YULF6FPB.cjs.map → chunk-2YGIBOUH.cjs.map} +1 -1
  24. package/dist/{chunk-FZ4YMZA3.cjs → chunk-3R4ZCQAZ.cjs} +5 -5
  25. package/dist/{chunk-FZ4YMZA3.cjs.map → chunk-3R4ZCQAZ.cjs.map} +1 -1
  26. package/dist/{chunk-HECR7KF5.cjs → chunk-3YYDHUNH.cjs} +11 -11
  27. package/dist/{chunk-HECR7KF5.cjs.map → chunk-3YYDHUNH.cjs.map} +1 -1
  28. package/dist/{chunk-BRHRQOJA.cjs → chunk-44IISBRZ.cjs} +4 -4
  29. package/dist/{chunk-BRHRQOJA.cjs.map → chunk-44IISBRZ.cjs.map} +1 -1
  30. package/dist/{chunk-PBML2FHN.js → chunk-4X3SBHPK.js} +2 -2
  31. package/dist/chunk-4X3SBHPK.js.map +1 -0
  32. package/dist/{chunk-OLLOUAUJ.js → chunk-5XXUYU3M.js} +3 -3
  33. package/dist/{chunk-OLLOUAUJ.js.map → chunk-5XXUYU3M.js.map} +1 -1
  34. package/dist/{chunk-KCQUYQ3V.cjs → chunk-6DCTL32L.cjs} +17 -17
  35. package/dist/{chunk-KCQUYQ3V.cjs.map → chunk-6DCTL32L.cjs.map} +1 -1
  36. package/dist/{chunk-R2A3WIJY.js → chunk-6PTCKXD3.js} +8 -8
  37. package/dist/{chunk-R2A3WIJY.js.map → chunk-6PTCKXD3.js.map} +1 -1
  38. package/dist/{chunk-XR4LPBXH.cjs → chunk-7HQVDLFI.cjs} +9 -9
  39. package/dist/{chunk-XR4LPBXH.cjs.map → chunk-7HQVDLFI.cjs.map} +1 -1
  40. package/dist/{chunk-GNMPCZNN.js → chunk-7TB5U7RK.js} +6 -6
  41. package/dist/{chunk-GNMPCZNN.js.map → chunk-7TB5U7RK.js.map} +1 -1
  42. package/dist/{chunk-7PESI6YD.cjs → chunk-ADVZIC43.cjs} +10 -10
  43. package/dist/{chunk-7PESI6YD.cjs.map → chunk-ADVZIC43.cjs.map} +1 -1
  44. package/dist/{chunk-NNNUQELM.cjs → chunk-AMYY3JHQ.cjs} +9 -9
  45. package/dist/{chunk-NNNUQELM.cjs.map → chunk-AMYY3JHQ.cjs.map} +1 -1
  46. package/dist/{chunk-L4JFQCG4.js → chunk-BKRTYDVN.js} +3 -3
  47. package/dist/{chunk-L4JFQCG4.js.map → chunk-BKRTYDVN.js.map} +1 -1
  48. package/dist/{chunk-UJMEWGO6.cjs → chunk-BWGXYOBZ.cjs} +4 -4
  49. package/dist/{chunk-UJMEWGO6.cjs.map → chunk-BWGXYOBZ.cjs.map} +1 -1
  50. package/dist/{chunk-E7WDXT4X.js → chunk-BXVSBYGW.js} +5 -5
  51. package/dist/{chunk-E7WDXT4X.js.map → chunk-BXVSBYGW.js.map} +1 -1
  52. package/dist/{chunk-AF4BBKIF.js → chunk-C4EU627W.js} +4 -4
  53. package/dist/{chunk-AF4BBKIF.js.map → chunk-C4EU627W.js.map} +1 -1
  54. package/dist/{chunk-VQFSEKU5.js → chunk-CHVSMEKM.js} +3 -3
  55. package/dist/{chunk-VQFSEKU5.js.map → chunk-CHVSMEKM.js.map} +1 -1
  56. package/dist/{chunk-6X2HUT4A.cjs → chunk-CZHPR2G7.cjs} +8 -8
  57. package/dist/{chunk-6X2HUT4A.cjs.map → chunk-CZHPR2G7.cjs.map} +1 -1
  58. package/dist/{chunk-F4RUADRC.js → chunk-DHVNJYTO.js} +3 -3
  59. package/dist/{chunk-F4RUADRC.js.map → chunk-DHVNJYTO.js.map} +1 -1
  60. package/dist/{chunk-SEZJGV7C.js → chunk-DU7PBCAM.js} +5 -5
  61. package/dist/{chunk-SEZJGV7C.js.map → chunk-DU7PBCAM.js.map} +1 -1
  62. package/dist/{chunk-S4Q5OMIK.cjs → chunk-E3OCRJU6.cjs} +11 -11
  63. package/dist/{chunk-S4Q5OMIK.cjs.map → chunk-E3OCRJU6.cjs.map} +1 -1
  64. package/dist/{chunk-3KY7MHR4.js → chunk-E6T264NS.js} +3 -3
  65. package/dist/{chunk-3KY7MHR4.js.map → chunk-E6T264NS.js.map} +1 -1
  66. package/dist/{chunk-WCXOKGOQ.cjs → chunk-ECPL5RV6.cjs} +8 -8
  67. package/dist/{chunk-WCXOKGOQ.cjs.map → chunk-ECPL5RV6.cjs.map} +1 -1
  68. package/dist/{chunk-LLE7HPRI.js → chunk-EFXJ5C7X.js} +5 -5
  69. package/dist/{chunk-LLE7HPRI.js.map → chunk-EFXJ5C7X.js.map} +1 -1
  70. package/dist/{chunk-RWMNTFHZ.cjs → chunk-EQMLJ52C.cjs} +26 -26
  71. package/dist/{chunk-RWMNTFHZ.cjs.map → chunk-EQMLJ52C.cjs.map} +1 -1
  72. package/dist/{chunk-WIGJGFH4.cjs → chunk-EUBGGYPH.cjs} +5 -5
  73. package/dist/{chunk-WIGJGFH4.cjs.map → chunk-EUBGGYPH.cjs.map} +1 -1
  74. package/dist/{chunk-RBQYHEZD.cjs → chunk-FBZMSLDC.cjs} +4 -4
  75. package/dist/{chunk-RBQYHEZD.cjs.map → chunk-FBZMSLDC.cjs.map} +1 -1
  76. package/dist/{chunk-3G6ZDZ6L.cjs → chunk-FUASIT3E.cjs} +15 -15
  77. package/dist/{chunk-3G6ZDZ6L.cjs.map → chunk-FUASIT3E.cjs.map} +1 -1
  78. package/dist/{chunk-MRKSSN36.js → chunk-HI4ZW62S.js} +3 -3
  79. package/dist/{chunk-MRKSSN36.js.map → chunk-HI4ZW62S.js.map} +1 -1
  80. package/dist/{chunk-O3IZ7JEL.js → chunk-I732VEDW.js} +3 -3
  81. package/dist/{chunk-O3IZ7JEL.js.map → chunk-I732VEDW.js.map} +1 -1
  82. package/dist/{chunk-AZ6FKDQR.js → chunk-ITQ4NO4P.js} +3 -3
  83. package/dist/{chunk-AZ6FKDQR.js.map → chunk-ITQ4NO4P.js.map} +1 -1
  84. package/dist/{chunk-PYM5OUL4.js → chunk-J4RY5DTI.js} +5 -5
  85. package/dist/{chunk-PYM5OUL4.js.map → chunk-J4RY5DTI.js.map} +1 -1
  86. package/dist/{chunk-NOM2YWFP.js → chunk-JJZ4NIAG.js} +5 -5
  87. package/dist/{chunk-NOM2YWFP.js.map → chunk-JJZ4NIAG.js.map} +1 -1
  88. package/dist/{chunk-GC44RATP.cjs → chunk-K42QGAKM.cjs} +10 -10
  89. package/dist/{chunk-GC44RATP.cjs.map → chunk-K42QGAKM.cjs.map} +1 -1
  90. package/dist/{chunk-FRQ6F44U.js → chunk-KIX45IKP.js} +4 -4
  91. package/dist/{chunk-FRQ6F44U.js.map → chunk-KIX45IKP.js.map} +1 -1
  92. package/dist/{chunk-OEFFPR2S.cjs → chunk-KNZU4YO5.cjs} +4 -4
  93. package/dist/{chunk-OEFFPR2S.cjs.map → chunk-KNZU4YO5.cjs.map} +1 -1
  94. package/dist/{chunk-HK4HRLWE.js → chunk-KZBB4YKU.js} +3 -3
  95. package/dist/{chunk-HK4HRLWE.js.map → chunk-KZBB4YKU.js.map} +1 -1
  96. package/dist/{chunk-ZS6SLELQ.js → chunk-L7EGRCKJ.js} +4 -4
  97. package/dist/{chunk-ZS6SLELQ.js.map → chunk-L7EGRCKJ.js.map} +1 -1
  98. package/dist/{chunk-F7OBYH2X.cjs → chunk-LLK2RS6I.cjs} +294 -294
  99. package/dist/{chunk-F7OBYH2X.cjs.map → chunk-LLK2RS6I.cjs.map} +1 -1
  100. package/dist/{chunk-LXKNENHK.js → chunk-MV4TOCUK.js} +3 -3
  101. package/dist/{chunk-LXKNENHK.js.map → chunk-MV4TOCUK.js.map} +1 -1
  102. package/dist/{chunk-PAV4ZPSW.js → chunk-N43XLTHZ.js} +3 -3
  103. package/dist/{chunk-PAV4ZPSW.js.map → chunk-N43XLTHZ.js.map} +1 -1
  104. package/dist/{chunk-ZNW2TXLO.js → chunk-NACDF3PK.js} +3 -3
  105. package/dist/{chunk-ZNW2TXLO.js.map → chunk-NACDF3PK.js.map} +1 -1
  106. package/dist/{chunk-27DYRARU.cjs → chunk-NFATC6ZF.cjs} +4 -4
  107. package/dist/{chunk-27DYRARU.cjs.map → chunk-NFATC6ZF.cjs.map} +1 -1
  108. package/dist/{chunk-E54KDYOE.js → chunk-NOS7PTKP.js} +7 -7
  109. package/dist/{chunk-E54KDYOE.js.map → chunk-NOS7PTKP.js.map} +1 -1
  110. package/dist/{chunk-NRA36JKG.cjs → chunk-OI6RHLGC.cjs} +11 -11
  111. package/dist/{chunk-NRA36JKG.cjs.map → chunk-OI6RHLGC.cjs.map} +1 -1
  112. package/dist/{chunk-J5RW43IR.js → chunk-OIBHY6JQ.js} +4 -4
  113. package/dist/{chunk-J5RW43IR.js.map → chunk-OIBHY6JQ.js.map} +1 -1
  114. package/dist/{chunk-SNKY3C2L.js → chunk-OZXPA3ME.js} +4 -4
  115. package/dist/{chunk-SNKY3C2L.js.map → chunk-OZXPA3ME.js.map} +1 -1
  116. package/dist/{chunk-35NFZ7QB.js → chunk-PLUCC4N5.js} +3 -3
  117. package/dist/{chunk-35NFZ7QB.js.map → chunk-PLUCC4N5.js.map} +1 -1
  118. package/dist/{chunk-MMZX557L.cjs → chunk-PVBANCWU.cjs} +5 -5
  119. package/dist/{chunk-MMZX557L.cjs.map → chunk-PVBANCWU.cjs.map} +1 -1
  120. package/dist/{chunk-BV42CCRP.cjs → chunk-QLAWEGTZ.cjs} +7 -7
  121. package/dist/{chunk-BV42CCRP.cjs.map → chunk-QLAWEGTZ.cjs.map} +1 -1
  122. package/dist/{chunk-HKSSM5RK.js → chunk-R7TKOQMJ.js} +3 -3
  123. package/dist/{chunk-HKSSM5RK.js.map → chunk-R7TKOQMJ.js.map} +1 -1
  124. package/dist/{chunk-HLNLYLNN.cjs → chunk-RAACTJ7C.cjs} +4 -4
  125. package/dist/{chunk-HLNLYLNN.cjs.map → chunk-RAACTJ7C.cjs.map} +1 -1
  126. package/dist/{chunk-X2YQP452.cjs → chunk-RTLUZKDL.cjs} +11 -11
  127. package/dist/{chunk-X2YQP452.cjs.map → chunk-RTLUZKDL.cjs.map} +1 -1
  128. package/dist/{chunk-6W4U2G3J.cjs → chunk-SDJYLCJK.cjs} +5 -5
  129. package/dist/{chunk-6W4U2G3J.cjs.map → chunk-SDJYLCJK.cjs.map} +1 -1
  130. package/dist/{chunk-VK7SIDYI.js → chunk-SPZZSAHV.js} +5 -5
  131. package/dist/{chunk-VK7SIDYI.js.map → chunk-SPZZSAHV.js.map} +1 -1
  132. package/dist/{chunk-ZHPET3LZ.cjs → chunk-SXSPMRSV.cjs} +2 -2
  133. package/dist/chunk-SXSPMRSV.cjs.map +1 -0
  134. package/dist/{chunk-JA4FEA5Z.cjs → chunk-T6QUCG7L.cjs} +4 -4
  135. package/dist/{chunk-JA4FEA5Z.cjs.map → chunk-T6QUCG7L.cjs.map} +1 -1
  136. package/dist/{chunk-GLEKLAUW.cjs → chunk-T6ZCG5AP.cjs} +12 -12
  137. package/dist/{chunk-GLEKLAUW.cjs.map → chunk-T6ZCG5AP.cjs.map} +1 -1
  138. package/dist/chunk-U3PAW4PL.js +22 -0
  139. package/dist/chunk-U3PAW4PL.js.map +1 -0
  140. package/dist/{chunk-ZTEAJAE6.js → chunk-UJ3SXRZZ.js} +3 -3
  141. package/dist/{chunk-ZTEAJAE6.js.map → chunk-UJ3SXRZZ.js.map} +1 -1
  142. package/dist/{chunk-Z6N6SDNR.js → chunk-V2EJLKGA.js} +4 -4
  143. package/dist/{chunk-Z6N6SDNR.js.map → chunk-V2EJLKGA.js.map} +1 -1
  144. package/dist/{chunk-57KX5WTP.cjs → chunk-V45L2OYP.cjs} +9 -9
  145. package/dist/{chunk-57KX5WTP.cjs.map → chunk-V45L2OYP.cjs.map} +1 -1
  146. package/dist/{chunk-2WB6EIYW.js → chunk-W4FV7JBH.js} +4 -4
  147. package/dist/{chunk-2WB6EIYW.js.map → chunk-W4FV7JBH.js.map} +1 -1
  148. package/dist/chunk-WVDH34LK.cjs +24 -0
  149. package/dist/chunk-WVDH34LK.cjs.map +1 -0
  150. package/dist/{chunk-TJRPNBY5.js → chunk-XGYI2KQH.js} +4 -4
  151. package/dist/{chunk-TJRPNBY5.js.map → chunk-XGYI2KQH.js.map} +1 -1
  152. package/dist/{chunk-4JRRFRV4.cjs → chunk-XK54DTRF.cjs} +4 -4
  153. package/dist/{chunk-4JRRFRV4.cjs.map → chunk-XK54DTRF.cjs.map} +1 -1
  154. package/dist/{chunk-JGYYNDAZ.js → chunk-XWCTBGYK.js} +3 -3
  155. package/dist/{chunk-JGYYNDAZ.js.map → chunk-XWCTBGYK.js.map} +1 -1
  156. package/dist/{chunk-UQHIEUDY.cjs → chunk-YARJG3GV.cjs} +8 -8
  157. package/dist/{chunk-UQHIEUDY.cjs.map → chunk-YARJG3GV.cjs.map} +1 -1
  158. package/dist/{chunk-TDDRPFO3.js → chunk-YBB66SZZ.js} +13 -21
  159. package/dist/chunk-YBB66SZZ.js.map +1 -0
  160. package/dist/{chunk-XABN5HY6.cjs → chunk-YTO5BRBD.cjs} +8 -8
  161. package/dist/{chunk-XABN5HY6.cjs.map → chunk-YTO5BRBD.cjs.map} +1 -1
  162. package/dist/{chunk-72HEBGWN.cjs → chunk-Z5U2JGEK.cjs} +11 -11
  163. package/dist/{chunk-72HEBGWN.cjs.map → chunk-Z5U2JGEK.cjs.map} +1 -1
  164. package/dist/{chunk-ACHVCIDQ.js → chunk-ZFARZBOX.js} +35 -35
  165. package/dist/{chunk-ACHVCIDQ.js.map → chunk-ZFARZBOX.js.map} +1 -1
  166. package/dist/{chunk-QFFNMJAS.cjs → chunk-ZNEYQ56O.cjs} +124 -132
  167. package/dist/chunk-ZNEYQ56O.cjs.map +1 -0
  168. package/dist/{chunk-Q4DTGCSD.js → chunk-ZSJPRPN7.js} +3 -3
  169. package/dist/{chunk-Q4DTGCSD.js.map → chunk-ZSJPRPN7.js.map} +1 -1
  170. package/dist/compact-session-AXKDB6FC.cjs +57 -0
  171. package/dist/{compact-session-FKYCJRAK.cjs.map → compact-session-AXKDB6FC.cjs.map} +1 -1
  172. package/dist/compact-session-DUAUEFRR.js +20 -0
  173. package/dist/{compact-session-LF4YOT5S.js.map → compact-session-DUAUEFRR.js.map} +1 -1
  174. package/dist/compaction.cjs +16 -16
  175. package/dist/compaction.js +3 -3
  176. package/dist/concurrency.cjs +6 -6
  177. package/dist/concurrency.js +4 -4
  178. package/dist/context-4HGPCOH6.cjs +22 -0
  179. package/dist/{context-2G4375BZ.cjs.map → context-4HGPCOH6.cjs.map} +1 -1
  180. package/dist/context-DCECDKWN.js +5 -0
  181. package/dist/{context-GSQYVVMJ.js.map → context-DCECDKWN.js.map} +1 -1
  182. package/dist/cron.cjs +32 -31
  183. package/dist/cron.js +31 -30
  184. package/dist/errors.cjs +21 -21
  185. package/dist/errors.js +2 -2
  186. package/dist/eval.cjs +37 -36
  187. package/dist/eval.cjs.map +1 -1
  188. package/dist/eval.js +31 -30
  189. package/dist/eval.js.map +1 -1
  190. package/dist/{executor-VQLTQY53.js → executor-3CGPLVJL.js} +7 -7
  191. package/dist/{executor-VQLTQY53.js.map → executor-3CGPLVJL.js.map} +1 -1
  192. package/dist/{executor-CB75B5BH.cjs → executor-4SW7QGZ4.cjs} +24 -24
  193. package/dist/{executor-CB75B5BH.cjs.map → executor-4SW7QGZ4.cjs.map} +1 -1
  194. package/dist/filesystem/index.cjs +7 -7
  195. package/dist/filesystem/index.js +3 -3
  196. package/dist/fs-session-store-2TF3ZWMT.js +10 -0
  197. package/dist/{fs-session-store-ZNUYZHYI.js.map → fs-session-store-2TF3ZWMT.js.map} +1 -1
  198. package/dist/fs-session-store-TL4RJTXZ.cjs +19 -0
  199. package/dist/{fs-session-store-MAZV5FXJ.cjs.map → fs-session-store-TL4RJTXZ.cjs.map} +1 -1
  200. package/dist/generate-object-E465DX5I.cjs +20 -0
  201. package/dist/{generate-object-6PWGH5DZ.cjs.map → generate-object-E465DX5I.cjs.map} +1 -1
  202. package/dist/generate-object-TVQCW2IZ.js +7 -0
  203. package/dist/{generate-object-IXMJ7FUX.js.map → generate-object-TVQCW2IZ.js.map} +1 -1
  204. package/dist/index-manager-EA6FGIQG.js +12 -0
  205. package/dist/{index-manager-OMJVYS2U.js.map → index-manager-EA6FGIQG.js.map} +1 -1
  206. package/dist/index-manager-HGGL4DD5.cjs +21 -0
  207. package/dist/{index-manager-34ELCOAP.cjs.map → index-manager-HGGL4DD5.cjs.map} +1 -1
  208. package/dist/index.cjs +134 -133
  209. package/dist/index.cjs.map +1 -1
  210. package/dist/index.js +44 -43
  211. package/dist/index.js.map +1 -1
  212. package/dist/{inject-session-MWRJENH4.js → inject-session-RBGOGACE.js} +7 -7
  213. package/dist/{inject-session-MWRJENH4.js.map → inject-session-RBGOGACE.js.map} +1 -1
  214. package/dist/{inject-session-J7Y6XACY.cjs → inject-session-TASLP5FA.cjs} +9 -9
  215. package/dist/{inject-session-J7Y6XACY.cjs.map → inject-session-TASLP5FA.cjs.map} +1 -1
  216. package/dist/internal/auth/api-key-prefix.d.ts +17 -0
  217. package/dist/internal/memory/adapters/index.cjs +8 -8
  218. package/dist/internal/memory/adapters/index.js +7 -7
  219. package/dist/internal/persistence/index.cjs +25 -25
  220. package/dist/internal/persistence/index.js +6 -6
  221. package/dist/internal/security/index.cjs +13 -13
  222. package/dist/internal/security/index.js +3 -3
  223. package/dist/judge-call-GVIJWQVE.cjs +22 -0
  224. package/dist/{judge-call-J5EETJL3.cjs.map → judge-call-GVIJWQVE.cjs.map} +1 -1
  225. package/dist/judge-call-QMKGC2ZK.js +5 -0
  226. package/dist/{judge-call-3QZO5H5N.js.map → judge-call-QMKGC2ZK.js.map} +1 -1
  227. package/dist/models.cjs +20 -20
  228. package/dist/models.js +5 -5
  229. package/dist/path-safety.cjs +10 -10
  230. package/dist/path-safety.js +3 -3
  231. package/dist/persistence.cjs +28 -28
  232. package/dist/persistence.js +8 -8
  233. package/dist/project.cjs +5 -5
  234. package/dist/project.js +3 -3
  235. package/dist/registry-GC7BQMSV.js +9 -0
  236. package/dist/{registry-PPFMCM4A.js.map → registry-GC7BQMSV.js.map} +1 -1
  237. package/dist/registry-UBY26R4I.cjs +46 -0
  238. package/dist/{registry-KB3TS6BM.cjs.map → registry-UBY26R4I.cjs.map} +1 -1
  239. package/dist/retry.cjs +4 -4
  240. package/dist/retry.js +3 -3
  241. package/dist/sandbox/index.cjs +6 -6
  242. package/dist/sandbox/index.js +2 -2
  243. package/dist/server/errors-envelope.cjs +14 -14
  244. package/dist/server/errors-envelope.js +3 -3
  245. package/dist/session-transcript-SKIRBEJE.js +5 -0
  246. package/dist/{session-transcript-7FWTO4BK.js.map → session-transcript-SKIRBEJE.js.map} +1 -1
  247. package/dist/session-transcript-TNAJ4O3M.cjs +50 -0
  248. package/dist/{session-transcript-FYRKWRWV.cjs.map → session-transcript-TNAJ4O3M.cjs.map} +1 -1
  249. package/dist/skills.cjs +7 -7
  250. package/dist/skills.js +5 -5
  251. package/dist/stream-object-QMNR3YFF.js +7 -0
  252. package/dist/{stream-object-NPJXDZXO.js.map → stream-object-QMNR3YFF.js.map} +1 -1
  253. package/dist/stream-object-T4DAMNVB.cjs +20 -0
  254. package/dist/{stream-object-3R3HZPQN.cjs.map → stream-object-T4DAMNVB.cjs.map} +1 -1
  255. package/dist/subagents-loader-3CXBQWWY.cjs +15 -0
  256. package/dist/{subagents-loader-FDXPBBRA.cjs.map → subagents-loader-3CXBQWWY.cjs.map} +1 -1
  257. package/dist/subagents-loader-WN2SB6PV.js +6 -0
  258. package/dist/{subagents-loader-5KQVYUNS.js.map → subagents-loader-WN2SB6PV.js.map} +1 -1
  259. package/dist/subagents-loader.cjs +6 -6
  260. package/dist/subagents-loader.js +4 -4
  261. package/dist/subscription/index.cjs +3 -3
  262. package/dist/subscription/index.js +2 -2
  263. package/dist/task-store.cjs +7 -7
  264. package/dist/task-store.js +4 -4
  265. package/dist/workflow.cjs +27 -27
  266. package/dist/workflow.js +6 -6
  267. package/package.json +1 -1
  268. package/dist/agent-B2WU3JP6.cjs +0 -57
  269. package/dist/agent-DI2QQHSJ.js +0 -48
  270. package/dist/agent-session-store-EPUERCUU.cjs +0 -23
  271. package/dist/agent-session-store-TXP5ZVOD.js +0 -6
  272. package/dist/chunk-PBML2FHN.js.map +0 -1
  273. package/dist/chunk-QFFNMJAS.cjs.map +0 -1
  274. package/dist/chunk-TDDRPFO3.js.map +0 -1
  275. package/dist/chunk-ZHPET3LZ.cjs.map +0 -1
  276. package/dist/compact-session-FKYCJRAK.cjs +0 -56
  277. package/dist/compact-session-LF4YOT5S.js +0 -19
  278. package/dist/context-2G4375BZ.cjs +0 -22
  279. package/dist/context-GSQYVVMJ.js +0 -5
  280. package/dist/fs-session-store-MAZV5FXJ.cjs +0 -19
  281. package/dist/fs-session-store-ZNUYZHYI.js +0 -10
  282. package/dist/generate-object-6PWGH5DZ.cjs +0 -20
  283. package/dist/generate-object-IXMJ7FUX.js +0 -7
  284. package/dist/index-manager-34ELCOAP.cjs +0 -21
  285. package/dist/index-manager-OMJVYS2U.js +0 -12
  286. package/dist/judge-call-3QZO5H5N.js +0 -5
  287. package/dist/judge-call-J5EETJL3.cjs +0 -22
  288. package/dist/registry-KB3TS6BM.cjs +0 -46
  289. package/dist/registry-PPFMCM4A.js +0 -9
  290. package/dist/session-transcript-7FWTO4BK.js +0 -5
  291. package/dist/session-transcript-FYRKWRWV.cjs +0 -50
  292. package/dist/stream-object-3R3HZPQN.cjs +0 -20
  293. package/dist/stream-object-NPJXDZXO.js +0 -7
  294. package/dist/subagents-loader-5KQVYUNS.js +0 -6
  295. package/dist/subagents-loader-FDXPBBRA.cjs +0 -15
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkYULF6FPB_cjs = require('./chunk-YULF6FPB.cjs');
4
- var chunkZHPET3LZ_cjs = require('./chunk-ZHPET3LZ.cjs');
3
+ var chunk2YGIBOUH_cjs = require('./chunk-2YGIBOUH.cjs');
4
+ var chunkSXSPMRSV_cjs = require('./chunk-SXSPMRSV.cjs');
5
5
  var async_hooks = require('async_hooks');
6
6
  var fs = require('fs');
7
7
  var promises = require('fs/promises');
@@ -17,7 +17,7 @@ var warned = /* @__PURE__ */ new Set();
17
17
  function warnOnce(key, message) {
18
18
  if (warned.has(key)) return;
19
19
  warned.add(key);
20
- chunkZHPET3LZ_cjs.diag(`${message}
20
+ chunkSXSPMRSV_cjs.diag(`${message}
21
21
  `);
22
22
  }
23
23
  async function loadHookConfig(cwd) {
@@ -35,7 +35,7 @@ async function loadHookConfig(cwd) {
35
35
  try {
36
36
  raw = await promises.readFile(jsonPath, "utf8");
37
37
  } catch (cause) {
38
- throw new chunkYULF6FPB_cjs.ConfigurationError(`Failed to read hooks config: ${jsonPath}`, {
38
+ throw new chunk2YGIBOUH_cjs.ConfigurationError(`Failed to read hooks config: ${jsonPath}`, {
39
39
  code: "hooks_read_error",
40
40
  cause
41
41
  });
@@ -44,7 +44,7 @@ async function loadHookConfig(cwd) {
44
44
  try {
45
45
  parsed = JSON.parse(raw);
46
46
  } catch (cause) {
47
- throw new chunkYULF6FPB_cjs.ConfigurationError(`Invalid JSON in hooks config: ${jsonPath}`, {
47
+ throw new chunk2YGIBOUH_cjs.ConfigurationError(`Invalid JSON in hooks config: ${jsonPath}`, {
48
48
  code: "hooks_json_invalid",
49
49
  cause
50
50
  });
@@ -53,7 +53,7 @@ async function loadHookConfig(cwd) {
53
53
  }
54
54
  function asRecord(value, path, where) {
55
55
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
56
- throw new chunkYULF6FPB_cjs.ConfigurationError(`hooks: expected an object at ${where} in ${path}`, {
56
+ throw new chunk2YGIBOUH_cjs.ConfigurationError(`hooks: expected an object at ${where} in ${path}`, {
57
57
  code: "hooks_json_invalid"
58
58
  });
59
59
  }
@@ -61,7 +61,7 @@ function asRecord(value, path, where) {
61
61
  }
62
62
  function asArray(value, path, where) {
63
63
  if (!Array.isArray(value)) {
64
- throw new chunkYULF6FPB_cjs.ConfigurationError(`hooks: expected an array at ${where} in ${path}`, {
64
+ throw new chunk2YGIBOUH_cjs.ConfigurationError(`hooks: expected an array at ${where} in ${path}`, {
65
65
  code: "hooks_json_invalid"
66
66
  });
67
67
  }
@@ -99,13 +99,13 @@ function flattenEventGroups(groups, path, ccEvent) {
99
99
  function parseClaudeCodeCommand(raw, matcher, path, ccEvent) {
100
100
  const cmd = asRecord(raw, path, `hooks.${ccEvent}[].hooks[]`);
101
101
  if (cmd.type !== "command") {
102
- throw new chunkYULF6FPB_cjs.ConfigurationError(
102
+ throw new chunk2YGIBOUH_cjs.ConfigurationError(
103
103
  `hooks: only { "type": "command" } is supported (got ${JSON.stringify(cmd.type)}) in ${path}`,
104
104
  { code: "hooks_unsupported_type" }
105
105
  );
106
106
  }
107
107
  if (typeof cmd.command !== "string" || cmd.command.length === 0) {
108
- throw new chunkYULF6FPB_cjs.ConfigurationError(`hooks: "command" must be a non-empty string in ${path}`, {
108
+ throw new chunk2YGIBOUH_cjs.ConfigurationError(`hooks: "command" must be a non-empty string in ${path}`, {
109
109
  code: "hooks_invalid_command"
110
110
  });
111
111
  }
@@ -137,5 +137,5 @@ exports.loadHookConfig = loadHookConfig;
137
137
  exports.warnOnce = warnOnce;
138
138
  exports.warnPersonalitySwitchInsideFork = warnPersonalitySwitchInsideFork;
139
139
  exports.withPersonalityContext = withPersonalityContext;
140
- //# sourceMappingURL=chunk-HECR7KF5.cjs.map
141
- //# sourceMappingURL=chunk-HECR7KF5.cjs.map
140
+ //# sourceMappingURL=chunk-3YYDHUNH.cjs.map
141
+ //# sourceMappingURL=chunk-3YYDHUNH.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/internal/runtime/hooks/hooks-source.ts","../src/internal/personality/context.ts"],"names":["diag","join","existsSync","readFile","ConfigurationError","AsyncLocalStorage"],"mappings":";;;;;;;;;AAiCA,IAAM,qBAAA,GAA6D;AAAA,EACjE,UAAA,EAAY,YAAA;AAAA,EACZ,WAAA,EAAa,aAAA;AAAA,EACb,gBAAA,EAAkB,QAAA;AAAA,EAClB,IAAA,EAAM;AACR,CAAA;AAYA,IAAM,MAAA,uBAAa,GAAA,EAAY;AAYxB,SAAS,QAAA,CAAS,KAAa,OAAA,EAAuB;AAC3D,EAAA,IAAI,MAAA,CAAO,GAAA,CA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AAK,SAAA,CAAU,IAAI,IAAI,CAAC,QAAQ,IAAI,CAAA,CAAA;AAAA,MAC3F,EAAE,MAAM,wBAAA;AAAyB,KACnC;AAAA,EACF;AACA,EAAA,IAAI,OAAO,GAAA,CAAI,OAAA,KAAY,YAAY,GAAA,CAAI,OAAA,CAAQ,WAAW,CAAA,EAAG;AAC/D,IAAA,MAAM,IAAIA,oCAAA,CAAmB,CAAA,+CAAA,EAAkD,IAAI,CAAA,CAAA,EAAI;AAAA,MACrF,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AACA,EAAA,MAAM,EAAA,GAAkB,EAAE,OAAA,EAAS,GAAA,CAAI,OAAA,EAAQ;AAC/C,EAAA,IAAI,OAAA,KAAY,MAAA,EAAW,EAAA,CAAG,OAAA,GAAU,OAAA;AACxC,EAAA,IAAI,OAAO,GAAA,CAAI,OAAA,KAAY,QAAA,IAAY,GAAA,CAAI,UAAU,CAAA,EAAG;AACtD,IAAA,EAAA,CAAG,SAAA,GAAY,IAAA,CAAK,KAAA,CAAM,GAAA,CAAI,UAAU,GAAI,CAAA;AAAA,EAC9C;AACA,EAAA,OAAO,EAAA;AACT;;;ACrKA,IAAM,OAAA,GAAU,IAAIC,6BAAA,EAA0C;AAQvD,SAAS,sBAAA,CACd,KACA,EAAA,EACY;AACZ,EAAA,OAAO,OAAA,CAAQ,GAAA,CAAI,GAAA,EAAK,EAAE,CAAA;AAC5B;AAQO,SAAS,yBAAA,GAAgE;AAC9E,EAAA,OAAO,QAAQ,QAAA,EAAS;AAC1B;AASO,SAAS,gCAAgC,OAAA,EAAuB;AACrE,EAAA,QAAA;AAAA,IACE,8BAA8B,OAAO,CAAA,CAAA;AAAA,IACrC,CAAA,0IAAA;AAAA,GACF;AACF","file":"chunk-HECR7KF5.cjs","sourcesContent":["/**\n * Single source of truth for loading the hooks config (ADR 0016 — reverses\n * D74/D77 for hooks: JSON is canonical again, in the Claude Code shape).\n *\n * `.theokit/hooks.json` (Claude-Code-shaped JSON) is the only supported form.\n * A stray legacy `.theokit/hooks/*.md` dir (no hooks.json) is NOT loaded — it\n * warns to migrate and yields no hooks. Absent both → empty config.\n *\n * Consumed by `hooks-executor.ts` (runtime dispatch).\n *\n * Config shape (identical to Claude Code's `settings.json` hooks):\n * { \"hooks\": { \"PreToolUse\": [ { \"matcher\": \"shell\",\n * \"hooks\": [ { \"type\": \"command\", \"command\": \"…\", \"timeout\": 30 } ] } ] } }\n *\n * @internal\n */\n\nimport { existsSync } from \"node:fs\";\nimport { readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\n\nimport { ConfigurationError } from \"../../../errors.js\";\nimport { diag } from \"../../diagnostics.js\";\n\n/** The five lifecycle events the SDK runtime actually fires. */\nexport type HookEvent = \"preRun\" | \"postRun\" | \"preToolUse\" | \"postToolUse\" | \"stop\";\n\n/**\n * Claude Code event name → the SDK firing event. Only events the runtime\n * genuinely emits are mapped; a Claude Code event with no SDK firing point\n * (SessionStart / SubagentStop / PreCompact / Notification / SessionEnd) is\n * skipped with a warn rather than silently accepted (it would never run).\n */\nconst CLAUDE_CODE_EVENT_MAP: Readonly<Record<string, HookEvent>> = {\n PreToolUse: \"preToolUse\",\n PostToolUse: \"postToolUse\",\n UserPromptSubmit: \"preRun\",\n Stop: \"stop\",\n};\n\nexport interface HookCommand {\n command: string;\n matcher?: string;\n timeoutMs?: number;\n}\n\nexport interface HookConfig {\n hooks?: Partial<Record<HookEvent, HookCommand[]>>;\n}\n\nconst warned = new Set<string>();\n\n/**\n * Emit a stderr warn once per process per unique key. Helps surface the\n * deprecation path without spamming when the loader is called many times\n * during a session (cron + send + skills all hit this).\n *\n * Note: spawned workers (cron, subagent) start fresh processes — warn\n * re-emits there, by design (1 per process boot, not per call).\n *\n * @internal\n */\nexport function warnOnce(key: string, message: string): void {\n if (warned.has(key)) return;\n warned.add(key);\n diag(`${message}\\n`);\n}\n\n/** Reset for tests; not exported via barrel. @internal */\nexport function _resetWarnOnceForTests(): void {\n warned.clear();\n}\n\n/**\n * Load hooks from `.theokit/hooks.json` (Claude-Code-shaped — the only supported\n * form). A stray legacy `.theokit/hooks/*.md` markdown dir (no `hooks.json`) is\n * NOT loaded — it emits a one-time migration warn and yields no hooks.\n *\n * @internal\n */\nexport async function loadHookConfig(cwd: string): Promise<HookConfig> {\n const jsonPath = join(cwd, \".theokit\", \"hooks.json\");\n\n if (!existsSync(jsonPath)) {\n if (existsSync(join(cwd, \".theokit\", \"hooks\"))) {\n warnOnce(\n \"hooks-md-unsupported\",\n \"[theokit-sdk] .theokit/hooks/*.md hooks are no longer supported (ADR 0016) — migrate to a Claude-Code-shaped .theokit/hooks.json\",\n );\n }\n return {};\n }\n\n let raw: string;\n try {\n raw = await readFile(jsonPath, \"utf8\");\n } catch (cause) {\n throw new ConfigurationError(`Failed to read hooks config: ${jsonPath}`, {\n code: \"hooks_read_error\",\n cause,\n });\n }\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch (cause) {\n throw new ConfigurationError(`Invalid JSON in hooks config: ${jsonPath}`, {\n code: \"hooks_json_invalid\",\n cause,\n });\n }\n return parseClaudeCodeConfig(parsed, jsonPath);\n}\n\n/** Narrow an unknown to a record, or throw a typed config error. */\nfunction asRecord(value: unknown, path: string, where: string): Record<string, unknown> {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n throw new ConfigurationError(`hooks: expected an object at ${where} in ${path}`, {\n code: \"hooks_json_invalid\",\n });\n }\n return value as Record<string, unknown>;\n}\n\n/** Narrow an unknown to an array, or throw a typed config error. */\nfunction asArray(value: unknown, path: string, where: string): unknown[] {\n if (!Array.isArray(value)) {\n throw new ConfigurationError(`hooks: expected an array at ${where} in ${path}`, {\n code: \"hooks_json_invalid\",\n });\n }\n return value;\n}\n\n/**\n * Parse Claude Code's nested hooks config into the SDK's flat internal shape:\n * `{ hooks: { PreToolUse: [{ matcher?, hooks: [{ type:\"command\", command, timeout? }] }] } }`\n * → `{ hooks: { preToolUse: [{ command, matcher?, timeoutMs? }] } }`. Each group's\n * `matcher` applies to every command it wraps; `timeout` (seconds) → `timeoutMs`.\n */\nfunction parseClaudeCodeConfig(raw: unknown, path: string): HookConfig {\n const root = asRecord(raw, path, \"the root\");\n if (root.hooks === undefined) return {};\n const hooksRec = asRecord(root.hooks, path, `\"hooks\"`);\n const grouped: Partial<Record<HookEvent, HookCommand[]>> = {};\n\n for (const [ccEvent, groups] of Object.entries(hooksRec)) {\n const event = CLAUDE_CODE_EVENT_MAP[ccEvent];\n if (event === undefined) {\n warnOnce(\n `hooks-event-${ccEvent}`,\n `[theokit-sdk] hooks: event \"${ccEvent}\" is not fired by the SDK runtime (supported: ${Object.keys(CLAUDE_CODE_EVENT_MAP).join(\", \")}) — skipping`,\n );\n continue;\n }\n grouped[event] = [...(grouped[event] ?? []), ...flattenEventGroups(groups, path, ccEvent)];\n }\n return { hooks: grouped };\n}\n\n/** Flatten one Claude Code event's matcher-groups into internal HookCommands. */\nfunction flattenEventGroups(groups: unknown, path: string, ccEvent: string): HookCommand[] {\n const commands: HookCommand[] = [];\n for (const rawGroup of asArray(groups, path, `hooks.${ccEvent}`)) {\n const group = asRecord(rawGroup, path, `hooks.${ccEvent}[]`);\n const matcher = group.matcher === undefined ? undefined : String(group.matcher);\n for (const rawCmd of asArray(group.hooks, path, `hooks.${ccEvent}[].hooks`)) {\n commands.push(parseClaudeCodeCommand(rawCmd, matcher, path, ccEvent));\n }\n }\n return commands;\n}\n\n/** One `{ type:\"command\", command, timeout? }` entry → an internal HookCommand. */\nfunction parseClaudeCodeCommand(\n raw: unknown,\n matcher: string | undefined,\n path: string,\n ccEvent: string,\n): HookCommand {\n const cmd = asRecord(raw, path, `hooks.${ccEvent}[].hooks[]`);\n if (cmd.type !== \"command\") {\n throw new ConfigurationError(\n `hooks: only { \"type\": \"command\" } is supported (got ${JSON.stringify(cmd.type)}) in ${path}`,\n { code: \"hooks_unsupported_type\" },\n );\n }\n if (typeof cmd.command !== \"string\" || cmd.command.length === 0) {\n throw new ConfigurationError(`hooks: \"command\" must be a non-empty string in ${path}`, {\n code: \"hooks_invalid_command\",\n });\n }\n const hc: HookCommand = { command: cmd.command };\n if (matcher !== undefined) hc.matcher = matcher;\n if (typeof cmd.timeout === \"number\" && cmd.timeout > 0) {\n hc.timeoutMs = Math.round(cmd.timeout * 1000);\n }\n return hc;\n}\n","/**\n * Personality fork-context (ADR D168 + EC-A snapshot semantic).\n *\n * Uses Node's `AsyncLocalStorage` so a fork's execution chain can know\n * that it is running inside a fork AND can see the slug that was active\n * on the parent **at fork-construction time**.\n *\n * **EC-A:** The slug stored here is captured ONCE at the wrap site\n * (`localAgentFork`) — passing `parentStore.active(parentAgentId)`\n * returns a primitive `string | undefined`, which is then frozen\n * inside the ALS context object. Subsequent `usePersonality` calls on\n * the parent do NOT mutate the fork's view, because the fork reads from\n * its own ALS frame, not from the parent's store.\n *\n * @internal\n */\n\nimport { AsyncLocalStorage } from \"node:async_hooks\";\n\nimport { warnOnce } from \"../runtime/hooks/hooks-source.js\";\n\n/**\n * Snapshot data carried into a fork's async context.\n *\n * @internal\n */\nexport interface PersonalityForkContext {\n /** Parent's active personality slug at fork-construction time. */\n readonly slug: string | undefined;\n /** Always `true` inside this scope (used by guards). */\n readonly isFork: true;\n}\n\nconst storage = new AsyncLocalStorage<PersonalityForkContext>();\n\n/**\n * Run `fn` with `ctx` bound as the active fork context. Nested calls\n * shadow the outer context (EC-22).\n *\n * @internal\n */\nexport function withPersonalityContext<T>(\n ctx: PersonalityForkContext,\n fn: () => Promise<T>,\n): Promise<T> {\n return storage.run(ctx, fn);\n}\n\n/**\n * Return the active fork context, or `undefined` when called outside a\n * fork scope.\n *\n * @internal\n */\nexport function currentPersonalityContext(): PersonalityForkContext | undefined {\n return storage.getStore();\n}\n\n/**\n * Emit one warning per agentId stating that personality switches inside\n * a fork are no-ops. The fork inherits the parent snapshot — runtime\n * mutation is intentionally rejected to keep fork voice deterministic.\n *\n * @internal\n */\nexport function warnPersonalitySwitchInsideFork(agentId: string): void {\n warnOnce(\n `personality-switch-in-fork-${agentId}`,\n `[theokit-sdk] usePersonality is a no-op inside a fork (D168). Subagents inherit the parent's active personality at fork-construction time.`,\n );\n}\n"]}
1
+ {"version":3,"sources":["../src/internal/runtime/hooks/hooks-source.ts","../src/internal/personality/context.ts"],"names":["diag","join","existsSync","readFile","ConfigurationError","AsyncLocalStorage"],"mappings":";;;;;;;;;AAiCA,IAAM,qBAAA,GAA6D;AAAA,EACjE,UAAA,EAAY,YAAA;AAAA,EACZ,WAAA,EAAa,aAAA;AAAA,EACb,gBAAA,EAAkB,QAAA;AAAA,EAClB,IAAA,EAAM;AACR,CAAA;AAYA,IAAM,MAAA,uBAAa,GAAA,EAAY;AAYxB,SAAS,QAAA,CAAS,KAAa,OAAA,EAAuB;AAC3D,EAAA,IAAI,MAAA,CAAO,GAAA,CAAI,GAAG,CAAA,EAAG;AACrB,EAAA,MAAA,CAAO,IAAI,GAAG,CAAA;AACd,EAAAA,sBAAA,CAAK,GAAG,OAAO;AAAA,CAAI,CAAA;AACrB;AAcA,eAAsB,eAAe,GAAA,EAAkC;AACrE,EAAA,MAAM,QAAA,GAAWC,SAAA,CAAK,GAAA,EAAK,UAAA,EAAY,YAAY,CAAA;AAEnD,EAAA,IAAI,CAACC,aAAA,CAAW,QAAQ,CAAA,EAAG;AACzB,IAAA,IAAIA,cAAWD,SAAA,CAAK,GAAA,EAAK,UAAA,EAAY,OAAO,CAAC,CAAA,EAAG;AAC9C,MAAA,QAAA;AAAA,QACE,sBAAA;AAAA,QACA;AAAA,OACF;AAAA,IACF;AACA,IAAA,OAAO,EAAC;AAAA,EACV;AAEA,EAAA,IAAI,GAAA;AACJ,EAAA,IAAI;AACF,IAAA,GAAA,GAAM,MAAME,iBAAA,CAAS,QAAA,EAAU,MAAM,CAAA;AAAA,EACvC,SAAS,KAAA,EAAO;AACd,IAAA,MAAM,IAAIC,oCAAA,CAAmB,CAAA,6BAAA,EAAgC,QAAQ,CAAA,CAAA,EAAI;AAAA,MAC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ACT;;;ACrKA,IAAM,OAAA,GAAU,IAAIC,6BAAA,EAA0C;AAQvD,SAAS,sBAAA,CACd,KACA,EAAA,EACY;AACZ,EAAA,OAAO,OAAA,CAAQ,GAAA,CAAI,GAAA,EAAK,EAAE,CAAA;AAC5B;AAQO,SAAS,yBAAA,GAAgE;AAC9E,EAAA,OAAO,QAAQ,QAAA,EAAS;AAC1B;AASO,SAAS,gCAAgC,OAAA,EAAuB;AACrE,EAAA,QAAA;AAAA,IACE,8BAA8B,OAAO,CAAA,CAAA;AAAA,IACrC,CAAA,0IAAA;AAAA,GACF;AACF","file":"chunk-3YYDHUNH.cjs","sourcesContent":["/**\n * Single source of truth for loading the hooks config (ADR 0016 — reverses\n * D74/D77 for hooks: JSON is canonical again, in the Claude Code shape).\n *\n * `.theokit/hooks.json` (Claude-Code-shaped JSON) is the only supported form.\n * A stray legacy `.theokit/hooks/*.md` dir (no hooks.json) is NOT loaded — it\n * warns to migrate and yields no hooks. Absent both → empty config.\n *\n * Consumed by `hooks-executor.ts` (runtime dispatch).\n *\n * Config shape (identical to Claude Code's `settings.json` hooks):\n * { \"hooks\": { \"PreToolUse\": [ { \"matcher\": \"shell\",\n * \"hooks\": [ { \"type\": \"command\", \"command\": \"…\", \"timeout\": 30 } ] } ] } }\n *\n * @internal\n */\n\nimport { existsSync } from \"node:fs\";\nimport { readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\n\nimport { ConfigurationError } from \"../../../errors.js\";\nimport { diag } from \"../../diagnostics.js\";\n\n/** The five lifecycle events the SDK runtime actually fires. */\nexport type HookEvent = \"preRun\" | \"postRun\" | \"preToolUse\" | \"postToolUse\" | \"stop\";\n\n/**\n * Claude Code event name → the SDK firing event. Only events the runtime\n * genuinely emits are mapped; a Claude Code event with no SDK firing point\n * (SessionStart / SubagentStop / PreCompact / Notification / SessionEnd) is\n * skipped with a warn rather than silently accepted (it would never run).\n */\nconst CLAUDE_CODE_EVENT_MAP: Readonly<Record<string, HookEvent>> = {\n PreToolUse: \"preToolUse\",\n PostToolUse: \"postToolUse\",\n UserPromptSubmit: \"preRun\",\n Stop: \"stop\",\n};\n\nexport interface HookCommand {\n command: string;\n matcher?: string;\n timeoutMs?: number;\n}\n\nexport interface HookConfig {\n hooks?: Partial<Record<HookEvent, HookCommand[]>>;\n}\n\nconst warned = new Set<string>();\n\n/**\n * Emit a stderr warn once per process per unique key. Helps surface the\n * deprecation path without spamming when the loader is called many times\n * during a session (cron + send + skills all hit this).\n *\n * Note: spawned workers (cron, subagent) start fresh processes — warn\n * re-emits there, by design (1 per process boot, not per call).\n *\n * @internal\n */\nexport function warnOnce(key: string, message: string): void {\n if (warned.has(key)) return;\n warned.add(key);\n diag(`${message}\\n`);\n}\n\n/** Reset for tests; not exported via barrel. @internal */\nexport function _resetWarnOnceForTests(): void {\n warned.clear();\n}\n\n/**\n * Load hooks from `.theokit/hooks.json` (Claude-Code-shaped — the only supported\n * form). A stray legacy `.theokit/hooks/*.md` markdown dir (no `hooks.json`) is\n * NOT loaded — it emits a one-time migration warn and yields no hooks.\n *\n * @internal\n */\nexport async function loadHookConfig(cwd: string): Promise<HookConfig> {\n const jsonPath = join(cwd, \".theokit\", \"hooks.json\");\n\n if (!existsSync(jsonPath)) {\n if (existsSync(join(cwd, \".theokit\", \"hooks\"))) {\n warnOnce(\n \"hooks-md-unsupported\",\n \"[theokit-sdk] .theokit/hooks/*.md hooks are no longer supported (ADR 0016) — migrate to a Claude-Code-shaped .theokit/hooks.json\",\n );\n }\n return {};\n }\n\n let raw: string;\n try {\n raw = await readFile(jsonPath, \"utf8\");\n } catch (cause) {\n throw new ConfigurationError(`Failed to read hooks config: ${jsonPath}`, {\n code: \"hooks_read_error\",\n cause,\n });\n }\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch (cause) {\n throw new ConfigurationError(`Invalid JSON in hooks config: ${jsonPath}`, {\n code: \"hooks_json_invalid\",\n cause,\n });\n }\n return parseClaudeCodeConfig(parsed, jsonPath);\n}\n\n/** Narrow an unknown to a record, or throw a typed config error. */\nfunction asRecord(value: unknown, path: string, where: string): Record<string, unknown> {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n throw new ConfigurationError(`hooks: expected an object at ${where} in ${path}`, {\n code: \"hooks_json_invalid\",\n });\n }\n return value as Record<string, unknown>;\n}\n\n/** Narrow an unknown to an array, or throw a typed config error. */\nfunction asArray(value: unknown, path: string, where: string): unknown[] {\n if (!Array.isArray(value)) {\n throw new ConfigurationError(`hooks: expected an array at ${where} in ${path}`, {\n code: \"hooks_json_invalid\",\n });\n }\n return value;\n}\n\n/**\n * Parse Claude Code's nested hooks config into the SDK's flat internal shape:\n * `{ hooks: { PreToolUse: [{ matcher?, hooks: [{ type:\"command\", command, timeout? }] }] } }`\n * → `{ hooks: { preToolUse: [{ command, matcher?, timeoutMs? }] } }`. Each group's\n * `matcher` applies to every command it wraps; `timeout` (seconds) → `timeoutMs`.\n */\nfunction parseClaudeCodeConfig(raw: unknown, path: string): HookConfig {\n const root = asRecord(raw, path, \"the root\");\n if (root.hooks === undefined) return {};\n const hooksRec = asRecord(root.hooks, path, `\"hooks\"`);\n const grouped: Partial<Record<HookEvent, HookCommand[]>> = {};\n\n for (const [ccEvent, groups] of Object.entries(hooksRec)) {\n const event = CLAUDE_CODE_EVENT_MAP[ccEvent];\n if (event === undefined) {\n warnOnce(\n `hooks-event-${ccEvent}`,\n `[theokit-sdk] hooks: event \"${ccEvent}\" is not fired by the SDK runtime (supported: ${Object.keys(CLAUDE_CODE_EVENT_MAP).join(\", \")}) — skipping`,\n );\n continue;\n }\n grouped[event] = [...(grouped[event] ?? []), ...flattenEventGroups(groups, path, ccEvent)];\n }\n return { hooks: grouped };\n}\n\n/** Flatten one Claude Code event's matcher-groups into internal HookCommands. */\nfunction flattenEventGroups(groups: unknown, path: string, ccEvent: string): HookCommand[] {\n const commands: HookCommand[] = [];\n for (const rawGroup of asArray(groups, path, `hooks.${ccEvent}`)) {\n const group = asRecord(rawGroup, path, `hooks.${ccEvent}[]`);\n const matcher = group.matcher === undefined ? undefined : String(group.matcher);\n for (const rawCmd of asArray(group.hooks, path, `hooks.${ccEvent}[].hooks`)) {\n commands.push(parseClaudeCodeCommand(rawCmd, matcher, path, ccEvent));\n }\n }\n return commands;\n}\n\n/** One `{ type:\"command\", command, timeout? }` entry → an internal HookCommand. */\nfunction parseClaudeCodeCommand(\n raw: unknown,\n matcher: string | undefined,\n path: string,\n ccEvent: string,\n): HookCommand {\n const cmd = asRecord(raw, path, `hooks.${ccEvent}[].hooks[]`);\n if (cmd.type !== \"command\") {\n throw new ConfigurationError(\n `hooks: only { \"type\": \"command\" } is supported (got ${JSON.stringify(cmd.type)}) in ${path}`,\n { code: \"hooks_unsupported_type\" },\n );\n }\n if (typeof cmd.command !== \"string\" || cmd.command.length === 0) {\n throw new ConfigurationError(`hooks: \"command\" must be a non-empty string in ${path}`, {\n code: \"hooks_invalid_command\",\n });\n }\n const hc: HookCommand = { command: cmd.command };\n if (matcher !== undefined) hc.matcher = matcher;\n if (typeof cmd.timeout === \"number\" && cmd.timeout > 0) {\n hc.timeoutMs = Math.round(cmd.timeout * 1000);\n }\n return hc;\n}\n","/**\n * Personality fork-context (ADR D168 + EC-A snapshot semantic).\n *\n * Uses Node's `AsyncLocalStorage` so a fork's execution chain can know\n * that it is running inside a fork AND can see the slug that was active\n * on the parent **at fork-construction time**.\n *\n * **EC-A:** The slug stored here is captured ONCE at the wrap site\n * (`localAgentFork`) — passing `parentStore.active(parentAgentId)`\n * returns a primitive `string | undefined`, which is then frozen\n * inside the ALS context object. Subsequent `usePersonality` calls on\n * the parent do NOT mutate the fork's view, because the fork reads from\n * its own ALS frame, not from the parent's store.\n *\n * @internal\n */\n\nimport { AsyncLocalStorage } from \"node:async_hooks\";\n\nimport { warnOnce } from \"../runtime/hooks/hooks-source.js\";\n\n/**\n * Snapshot data carried into a fork's async context.\n *\n * @internal\n */\nexport interface PersonalityForkContext {\n /** Parent's active personality slug at fork-construction time. */\n readonly slug: string | undefined;\n /** Always `true` inside this scope (used by guards). */\n readonly isFork: true;\n}\n\nconst storage = new AsyncLocalStorage<PersonalityForkContext>();\n\n/**\n * Run `fn` with `ctx` bound as the active fork context. Nested calls\n * shadow the outer context (EC-22).\n *\n * @internal\n */\nexport function withPersonalityContext<T>(\n ctx: PersonalityForkContext,\n fn: () => Promise<T>,\n): Promise<T> {\n return storage.run(ctx, fn);\n}\n\n/**\n * Return the active fork context, or `undefined` when called outside a\n * fork scope.\n *\n * @internal\n */\nexport function currentPersonalityContext(): PersonalityForkContext | undefined {\n return storage.getStore();\n}\n\n/**\n * Emit one warning per agentId stating that personality switches inside\n * a fork are no-ops. The fork inherits the parent snapshot — runtime\n * mutation is intentionally rejected to keep fork voice deterministic.\n *\n * @internal\n */\nexport function warnPersonalitySwitchInsideFork(agentId: string): void {\n warnOnce(\n `personality-switch-in-fork-${agentId}`,\n `[theokit-sdk] usePersonality is a no-op inside a fork (D168). Subagents inherit the parent's active personality at fork-construction time.`,\n );\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkYULF6FPB_cjs = require('./chunk-YULF6FPB.cjs');
3
+ var chunk2YGIBOUH_cjs = require('./chunk-2YGIBOUH.cjs');
4
4
  var promises = require('fs/promises');
5
5
 
6
6
  async function readWorkspaceDir(root, errorCode, describe) {
@@ -9,7 +9,7 @@ async function readWorkspaceDir(root, errorCode, describe) {
9
9
  } catch (cause) {
10
10
  const err = cause;
11
11
  if (err.code === "ENOENT") return [];
12
- throw new chunkYULF6FPB_cjs.ConfigurationError(`Failed to read ${describe}: ${root}`, {
12
+ throw new chunk2YGIBOUH_cjs.ConfigurationError(`Failed to read ${describe}: ${root}`, {
13
13
  code: errorCode,
14
14
  cause
15
15
  });
@@ -42,5 +42,5 @@ function coerce(raw) {
42
42
 
43
43
  exports.parseSimpleYaml = parseSimpleYaml;
44
44
  exports.readWorkspaceDir = readWorkspaceDir;
45
- //# sourceMappingURL=chunk-BRHRQOJA.cjs.map
46
- //# sourceMappingURL=chunk-BRHRQOJA.cjs.map
45
+ //# sourceMappingURL=chunk-44IISBRZ.cjs.map
46
+ //# sourceMappingURL=chunk-44IISBRZ.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/internal/runtime/config/workspace-dir.ts","../src/internal/runtime/context/yaml-frontmatter.ts"],"names":["readdir","ConfigurationError"],"mappings":";;;;;AAyBA,eAAsB,gBAAA,CACpB,IAAA,EACA,SAAA,EACA,QAAA,EAC8B;AAC9B,EAAA,IAAI;AACF,IAAA,OAAQ,MAAMA,gBAAA,CAAQ,IAAA,EAAM,EAAE,aAAA,EAAe,MAAM,CAAA;AAAA,EACrD,SAAS,KAAA,EAAO;AACd,IAAA,MAAM,GAAA,GAAM,KAAA;AACZ,IAAA,IAAI,GAAA,CAAI,IAAA,KAAS,QAAA,EAAU,OAAO,EAAC;AACnC,IAAA,MAAM,IAAIC,oCAAA,CAAmB,CAAA,eAAA,EAAkB,QAAQ,CAAA,EAAA,EAAK,IAAI,CAAA,CAAA,EAAI;AAAA,MAClE,IAAA,EAAM,SAAA;AAAA,MACN;AAAA,KACD,CAAA;AAAA,EACH;AACF;;;AClBO,SAAS,gBAAgB,IAAA,EAA4D;AAC1F,EAAA,MAAM,SAAuD,EAAC;AAC9D,EAAA,KAAA,MAAW,IAAA,IAAQ,IAAA,CAAK,KAAA,CAAM,OAAO,CAAA,EAAG;AACtC,IAAA,MAAM,UAAA,GAAa,IAAA,CAAK,OAAA,CAAQ,GAAG,CAAA;AACnC,IAAA,IAAI,eAAe,EAAA,EAAI;AACvB,IAAA,MAAM,MAAM,IAAA,CAAK,KAAA,CAAM,CAAA,EAAG,UAAU,EAAE,IAAA,EAAK;AAC3C,IAAA,IAAI,GAAA,CAAI,WAAW,CAAA,EAAG;AACtB,IAAA,MAAM,MAAM,IAAA,CAAK,KAAA,CAAM,UAAA,GAAa,CAAC,EAAE,IAAA,EAAK;AAC5C,IAAA,MAAA,CAAO,GAAG,CAAA,GAAI,MAAA,CAAO,GAAG,CAAA;AAAA,EAC1B;AACA,EAAA,OAAO,MAAA;AACT;AAEA,SAAS,OAAO,GAAA,EAA2C;AAEzD,EAAA,IAAI,GAAA,CAAI,MAAA,KAAW,CAAA,EAAG,OAAO,MAAA;AAC7B,EAAA,IAAI,IAAI,UAAA,CAAW,GAAG,KAAK,GAAA,CAAI,QAAA,CAAS,GAAG,CAAA,EAAG;AAC5C,IAAA,OAAO,GAAA,CACJ,MAAM,CAAA,EAAG,EAAE,EACX,KAAA,CAAM,GAAG,EACT,GAAA,CAAI,CAAC,MAAM,CAAA,CAAE,IAAA,EAAM,CAAA,CACnB,MAAA,CAAO,CAAC,CAAA,KAAM,CAAA,CAAE,SAAS,CAAC,CAAA;AAAA,EAC/B;AACA,EAAA,IAAI,GAAA,KAAQ,MAAA,IAAU,GAAA,KAAQ,OAAA,SAAgB,GAAA,KAAQ,MAAA;AACtD,EAAA,MAAM,CAAA,GAAI,OAAO,GAAG,CAAA;AACpB,EAAA,IAAI,MAAA,CAAO,SAAS,CAAC,CAAA,IAAK,QAAQ,MAAA,CAAO,CAAC,GAAG,OAAO,CAAA;AACpD,EAAA,OAAO,GAAA;AACT","file":"chunk-BRHRQOJA.cjs","sourcesContent":["import { readdir } from \"node:fs/promises\";\n\nimport { ConfigurationError } from \"../../../errors.js\";\n\n/**\n * Entry returned by `readWorkspaceDir`. Mirrors the subset of\n * `fs.Dirent` the file-based loaders use.\n */\nexport interface WorkspaceDirEntry {\n name: string;\n isDirectory(): boolean;\n isFile(): boolean;\n}\n\n/**\n * Read a workspace subdirectory and return its entries. When the directory\n * does not exist (`ENOENT`), returns an empty array — the file-based loaders\n * (skills, plugins, agents) treat a missing directory as \"no entries\"\n * rather than an error.\n *\n * Any other I/O failure is wrapped as `ConfigurationError` so callers can\n * surface a stable error code.\n *\n * @internal\n */\nexport async function readWorkspaceDir(\n root: string,\n errorCode: string,\n describe: string,\n): Promise<WorkspaceDirEntry[]> {\n try {\n return (await readdir(root, { withFileTypes: true })) as WorkspaceDirEntry[];\n } catch (cause) {\n const err = cause as NodeJS.ErrnoException;\n if (err.code === \"ENOENT\") return [];\n throw new ConfigurationError(`Failed to read ${describe}: ${root}`, {\n code: errorCode,\n cause,\n });\n }\n}\n","/**\n * Tiny YAML-frontmatter parser shared by the file-based loaders (skills,\n * subagents, hooks, context, plugins). Supports four scalar shapes:\n *\n * key: bar → \"bar\" (string)\n * key: 42 → 42 (number)\n * key: true → true (boolean)\n * key: [a, b, c] → [\"a\",\"b\",\"c\"](string[])\n * key: → undefined (caller's Zod default kicks in)\n *\n * Limitations (intentional — keep parser tiny, no dep):\n * - No nested objects (use flat keys like `providerId` not `provider.id`).\n * - No quoted strings — `match: \"1\"` becomes the literal 3-char string `\"1\"`.\n * - List values cannot contain a literal comma inside an element; the\n * `tags: [a,b, c]` splitter is greedy on `,`. Use multi-line lists or\n * reword if you need this.\n *\n * @internal\n */\n\nexport type FrontmatterValue = string | number | boolean | string[];\n\nexport function parseSimpleYaml(text: string): Record<string, FrontmatterValue | undefined> {\n const fields: Record<string, FrontmatterValue | undefined> = {};\n for (const line of text.split(/\\r?\\n/)) {\n const colonIndex = line.indexOf(\":\");\n if (colonIndex === -1) continue;\n const key = line.slice(0, colonIndex).trim();\n if (key.length === 0) continue;\n const raw = line.slice(colonIndex + 1).trim();\n fields[key] = coerce(raw);\n }\n return fields;\n}\n\nfunction coerce(raw: string): FrontmatterValue | undefined {\n // EC-3: empty value → undefined so Zod `.optional().default(...)` applies.\n if (raw.length === 0) return undefined;\n if (raw.startsWith(\"[\") && raw.endsWith(\"]\")) {\n return raw\n .slice(1, -1)\n .split(\",\")\n .map((s) => s.trim())\n .filter((s) => s.length > 0);\n }\n if (raw === \"true\" || raw === \"false\") return raw === \"true\";\n const n = Number(raw);\n if (Number.isFinite(n) && raw === String(n)) return n;\n return raw;\n}\n"]}
1
+ {"version":3,"sources":["../src/internal/runtime/config/workspace-dir.ts","../src/internal/runtime/context/yaml-front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,GAAG,KAAK,GAAA,CAAI,QAAA,CAAS,GAAG,CAAA,EAAG;AAC5C,IAAA,OAAO,GAAA,CACJ,MAAM,CAAA,EAAG,EAAE,EACX,KAAA,CAAM,GAAG,EACT,GAAA,CAAI,CAAC,MAAM,CAAA,CAAE,IAAA,EAAM,CAAA,CACnB,MAAA,CAAO,CAAC,CAAA,KAAM,CAAA,CAAE,SAAS,CAAC,CAAA;AAAA,EAC/B;AACA,EAAA,IAAI,GAAA,KAAQ,MAAA,IAAU,GAAA,KAAQ,OAAA,SAAgB,GAAA,KAAQ,MAAA;AACtD,EAAA,MAAM,CAAA,GAAI,OAAO,GAAG,CAAA;AACpB,EAAA,IAAI,MAAA,CAAO,SAAS,CAAC,CAAA,IAAK,QAAQ,MAAA,CAAO,CAAC,GAAG,OAAO,CAAA;AACpD,EAAA,OAAO,GAAA;AACT","file":"chunk-44IISBRZ.cjs","sourcesContent":["import { readdir } from \"node:fs/promises\";\n\nimport { ConfigurationError } from \"../../../errors.js\";\n\n/**\n * Entry returned by `readWorkspaceDir`. Mirrors the subset of\n * `fs.Dirent` the file-based loaders use.\n */\nexport interface WorkspaceDirEntry {\n name: string;\n isDirectory(): boolean;\n isFile(): boolean;\n}\n\n/**\n * Read a workspace subdirectory and return its entries. When the directory\n * does not exist (`ENOENT`), returns an empty array — the file-based loaders\n * (skills, plugins, agents) treat a missing directory as \"no entries\"\n * rather than an error.\n *\n * Any other I/O failure is wrapped as `ConfigurationError` so callers can\n * surface a stable error code.\n *\n * @internal\n */\nexport async function readWorkspaceDir(\n root: string,\n errorCode: string,\n describe: string,\n): Promise<WorkspaceDirEntry[]> {\n try {\n return (await readdir(root, { withFileTypes: true })) as WorkspaceDirEntry[];\n } catch (cause) {\n const err = cause as NodeJS.ErrnoException;\n if (err.code === \"ENOENT\") return [];\n throw new ConfigurationError(`Failed to read ${describe}: ${root}`, {\n code: errorCode,\n cause,\n });\n }\n}\n","/**\n * Tiny YAML-frontmatter parser shared by the file-based loaders (skills,\n * subagents, hooks, context, plugins). Supports four scalar shapes:\n *\n * key: bar → \"bar\" (string)\n * key: 42 → 42 (number)\n * key: true → true (boolean)\n * key: [a, b, c] → [\"a\",\"b\",\"c\"](string[])\n * key: → undefined (caller's Zod default kicks in)\n *\n * Limitations (intentional — keep parser tiny, no dep):\n * - No nested objects (use flat keys like `providerId` not `provider.id`).\n * - No quoted strings — `match: \"1\"` becomes the literal 3-char string `\"1\"`.\n * - List values cannot contain a literal comma inside an element; the\n * `tags: [a,b, c]` splitter is greedy on `,`. Use multi-line lists or\n * reword if you need this.\n *\n * @internal\n */\n\nexport type FrontmatterValue = string | number | boolean | string[];\n\nexport function parseSimpleYaml(text: string): Record<string, FrontmatterValue | undefined> {\n const fields: Record<string, FrontmatterValue | undefined> = {};\n for (const line of text.split(/\\r?\\n/)) {\n const colonIndex = line.indexOf(\":\");\n if (colonIndex === -1) continue;\n const key = line.slice(0, colonIndex).trim();\n if (key.length === 0) continue;\n const raw = line.slice(colonIndex + 1).trim();\n fields[key] = coerce(raw);\n }\n return fields;\n}\n\nfunction coerce(raw: string): FrontmatterValue | undefined {\n // EC-3: empty value → undefined so Zod `.optional().default(...)` applies.\n if (raw.length === 0) return undefined;\n if (raw.startsWith(\"[\") && raw.endsWith(\"]\")) {\n return raw\n .slice(1, -1)\n .split(\",\")\n .map((s) => s.trim())\n .filter((s) => s.length > 0);\n }\n if (raw === \"true\" || raw === \"false\") return raw === \"true\";\n const n = Number(raw);\n if (Number.isFinite(n) && raw === String(n)) return n;\n return raw;\n}\n"]}
@@ -148,5 +148,5 @@ function redactSecrets(text, opts) {
148
148
  }
149
149
 
150
150
  export { addPattern, diag, maskToken, redactSecrets, setDiagnosticsSink };
151
- //# sourceMappingURL=chunk-PBML2FHN.js.map
152
- //# sourceMappingURL=chunk-PBML2FHN.js.map
151
+ //# sourceMappingURL=chunk-4X3SBHPK.js.map
152
+ //# sourceMappingURL=chunk-4X3SBHPK.js.map
@@ -0,0 +1 @@
1
+ {"version":3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IAClB,CAAC,CAAA;AAAA,EACH;AACA,EAAA,OAAO,CAAA;AACT","file":"chunk-4X3SBHPK.js","sourcesContent":["/**\n * The library's single diagnostics channel — silent by default (#147).\n *\n * ## The problem\n *\n * The SDK wrote diagnostics straight to `process.stderr` from hot paths — 92 sites across 51\n * files under `internal/`. In a TUI host (Ink, alternate screen), those writes interleave with the\n * render and **corrupt the frame**. And the host had no way to intercept them: there was no\n * injectable logger. One consumer went as far as installing `proper-lockfile` just to silence ONE\n * of them.\n *\n * A library cannot assume `stdout`/`stderr` are free sinks. The application owns the terminal, not\n * the dependency.\n *\n * ## The contract\n *\n * - **`setDiagnosticsSink(fn)`** hands the messages to the application, which decides where to put\n * them (a status line, a file, a panel). It is what was missing for a TUI to coexist with the SDK.\n * - **With no sink, nothing is emitted.** A library does not own the host's terminal.\n *\n * ## Silent by default, and how 36 suites survived the flip\n *\n * The default WAS `stderr`, and 36 test files spy on `process.stderr.write` to assert a given\n * warning is emitted. That contract is real and had to survive; migrating all 36 by hand, across\n * four different spy styles, is how you weaken 36 suites in one commit.\n *\n * So the flip happened at the default, and `vitest.setup.ts` installs a sink that FORWARDS to\n * `stderr` for the duration of every test. Those assertions still test what they always tested —\n * \"this condition emits a diagnostic\" — through the channel a host would use, while production\n * emits nothing unless asked.\n *\n * The cost is stated rather than hidden: no test observes the production default by accident, so\n * `tests/diagnostics-public-entry.test.ts` pins it explicitly by clearing the sink first.\n *\n * ## Coverage is the whole guarantee\n *\n * The first sweep migrated the 92 sites under `internal/` and left `src/`'s own modules —\n * `event-bus.ts`, `batch.ts`, `compaction.ts`, `internal/workflow/step-branch.ts`. A host could\n * therefore install a sink and still have its frame corrupted by a batch run, which is the reported\n * defect with a smaller blast radius. Those are routed here too, and\n * `tests/lint/no-direct-terminal-write.test.ts` is what keeps the next hot path from\n * reintroducing one. \"Mostly interceptable\" is not interceptable.\n *\n * The remaining direct writers are allowlisted there with a reason, and every one of them is a seam\n * whose destination the CALLER already chooses (`opts.warn`, `opts.logger`, the Workflow logger).\n *\n * ## What this is NOT\n *\n * It is not a logger with levels, formatting or multiple destinations. It is the minimum that\n * resolves the reported blocker; a full logger here would be inventing a requirement nobody asked\n * for.\n */\n\n/** Receives each diagnostic message already formatted, with the trailing `\\n`. */\nexport type DiagnosticsSink = (message: string) => void;\n\n/**\n * The registry lives on `globalThis`, not in a module-level `let` (theokit#173).\n *\n * A module-level binding is a per-INSTANCE singleton, and a package manager will install two\n * physical copies of the same version whenever two dependents resolve different peer sets. Measured:\n * `@theokit/sdk@4.39.1` existed under two pnpm store hashes in the theokit workspace, so a sink\n * installed through `@theokit/agents` landed in a different registry than the emitter writes to.\n *\n * The failure mode is the quiet one — the re-export resolves, the function is callable, nothing\n * throws, and no diagnostic ever arrives. `Symbol.for` gives every copy in the process the same\n * slot; the `v1` suffix leaves room to change the shape without colliding with an older copy.\n */\nconst SINK_SLOT = Symbol.for(\"theokit.sdk.diagnostics.sink.v1\");\n\ntype SinkHolder = Record<symbol, DiagnosticsSink | undefined>;\n\nfunction currentSink(): DiagnosticsSink | undefined {\n return (globalThis as unknown as SinkHolder)[SINK_SLOT];\n}\n\n/**\n * Installs (or removes, by passing `undefined`) the diagnostics destination.\n *\n * When a sink is present it is the ONLY destination — `stderr` gets no copy. Duplicating\n * destinations would hand the problem back to the TUI that installed the sink precisely to get the\n * messages out of the terminal.\n */\nexport function setDiagnosticsSink(next: DiagnosticsSink | undefined): void {\n (globalThis as unknown as SinkHolder)[SINK_SLOT] = next;\n}\n\n/**\n * Emits a library diagnostic message.\n *\n * Replaces `process.stderr.write` on internal paths. Never throws: a faulty sink must not\n * must not take down the run it merely observes.\n */\nexport function diag(message: string): void {\n // Silent by default (#147): with no sink installed the message is dropped. A library must not\n // assume the host's stdout/stderr are free-form log sinks — in a TUI they are the render surface.\n const sink = currentSink();\n if (sink === undefined) return;\n try {\n sink(message);\n } catch {\n // Observability never breaks the run — same principle as `emitRunEvent`.\n }\n}\n\n/**\n * Emits a diagnostic that reports a USER-VISIBLE FAILURE, and is never silently dropped.\n *\n * `diag` is silent with no sink installed, and that is right for chatter: a library must not assume\n * the host's stderr is a free-form log, because in a TUI it is the render surface. A failure is a\n * different message. `theokit-sdk#189` is the record of the difference — an MCP server failed to\n * start, the only report went to `diag()`, the embedding UI never read it, and the user saw an\n * agent with missing tools and no reason given.\n *\n * The two failure modes are not symmetric, which is the whole decision: a corrupted frame is\n * visible and recoverable, while a silently dropped failure is neither. So this falls back to\n * stderr rather than to silence.\n *\n * A sink still takes precedence — the host installed it precisely to keep these off the terminal —\n * EXCEPT when the sink throws. A broken sink swallowing the one report of a failure is the same\n * defect one layer further in.\n *\n * @internal\n */\nexport function diagFailure(message: string): void {\n const sink = currentSink();\n if (sink !== undefined) {\n try {\n sink(message);\n return;\n } catch {\n // Fall through: the sink is broken, and this message is too important to drop with it.\n }\n }\n try {\n process.stderr.write(`${message}\\n`);\n } catch {\n // Nothing left to try. Observability never breaks the run.\n }\n}\n","import { diag } from \"../diagnostics.js\";\n\n/**\n * Canonical secret redaction module (ADRs D68-D73).\n *\n * Single source of truth for credential pattern masking across the SDK.\n * Wired at output boundaries: `ErrorMetadata.raw` (mappers/shared.ts),\n * telemetry span attributes (telemetry/tracer.ts), transcript JSONL\n * appends (agent-session-store.ts), migration logger output\n * (memory/migrate-sqlite-to-lance.ts).\n *\n * - D68: central module, single source of truth (replaces 2 duplicates)\n * - D69: env snapshot at module init (prompt-injection defense)\n * - D70: ON by default, warn on opt-out\n * - D71: two-bucket masking — short fully masked, long preserves prefix+suffix\n * - D72: `codeFile` opt-out for legitimate prefix-shaped content\n * - D73: redact at OUTPUT boundaries, not at storage\n *\n * @internal\n */\n\n// D69: env snapshot captured at module load. Subsequent mutations of\n// process.env.THEOKIT_REDACT_SECRETS are ignored — defends against\n// prompt injection that tries to disable redaction mid-run.\nlet REDACT_ENABLED: boolean = readEnvOnce();\n\nfunction readEnvOnce(): boolean {\n const raw = process.env.THEOKIT_REDACT_SECRETS;\n if (raw === undefined) return true; // D70: default ON\n return [\"1\", \"true\", \"yes\", \"on\"].includes(raw.toLowerCase());\n}\n\n// D70: warn once on opt-out so the user knows they're vulnerable.\nlet warnedOptOut = false;\nif (!REDACT_ENABLED && !warnedOptOut) {\n diag(\n \"[theokit-sdk] Secret redaction is DISABLED via THEOKIT_REDACT_SECRETS. \" +\n \"Credentials may leak into errors, telemetry, logs, transcripts.\\n\",\n );\n warnedOptOut = true;\n}\n\n/**\n * Built-in credential patterns. Order matters — more specific prefixes\n * must come before generic ones (e.g., `sk-ant-` before `sk-`). Quantifiers\n * are all bounded `{n,m}` or applied to char classes — linear time, no ReDoS.\n *\n * @internal\n */\nconst BUILTIN_PATTERNS: readonly RegExp[] = [\n // T5.4: 30+ vendor prefixes (was 12 pre-T5.4). Order matters — more\n // specific prefixes precede generic ones (e.g., sk-ant-admin01 before\n // sk-ant-, sk-proj- before sk-). PEM block deliberately first so its\n // multi-line span runs before any per-line patterns can fire.\n /-----BEGIN[ ]+(?:RSA |EC |DSA |OPENSSH |ENCRYPTED |)PRIVATE KEY-----[\\s\\S]+?-----END[ ]+(?:RSA |EC |DSA |OPENSSH |ENCRYPTED |)PRIVATE KEY-----/g,\n // JWT — exact 3-segment base64url. Dotted; the body floor of 4 chars per\n // segment matches the minimum legal payload while skipping `a.b.c` noise.\n /eyJ[A-Za-z0-9_-]{4,}\\.eyJ[A-Za-z0-9_-]{4,}\\.[A-Za-z0-9_-]{4,}/g,\n // Azure Storage SAS — match the sig= component (URL-encoded base64).\n /(?<=[?&]sig=)[A-Za-z0-9%+/]{20,}/g,\n // Anthropic\n /sk-ant-admin01-[A-Za-z0-9_-]{10,}/g, // Anthropic admin keys (must precede sk-ant-)\n /sk-ant-[A-Za-z0-9_-]{10,}/g, // Anthropic regular\n // OpenAI family + clones (sk- generic must come AFTER all sk-foo- variants)\n /sk-proj-[A-Za-z0-9_-]{10,}/g, // OpenAI project key (must precede sk- generic)\n /sk-[A-Za-z0-9_-]{10,}/g, // OpenAI / OpenRouter / DeepInfra / Together / DeepSeek\n // Provider prefixes (alphabetized for maintainability)\n /AIza[A-Za-z0-9_-]{35}/g, // Google API key\n /AKIA[A-Z0-9]{16}/g, // AWS access key\n /fw_[A-Za-z0-9]{20,}/g, // Fireworks\n /glpat-[A-Za-z0-9_-]{20}/g, // GitLab PAT\n /ghp_[A-Za-z0-9]{36}/g, // GitHub PAT classic\n /github_pat_[A-Za-z0-9_]{82}/g, // GitHub PAT fine-grained\n /gsk_[A-Za-z0-9]{20,}/g, // Groq\n /hf_[A-Za-z0-9]{20,}/g, // HuggingFace\n /\\bpa-[A-Za-z0-9_-]{20,}/g, // Voyage AI (word-boundary to skip CSS / kebab IDs)\n /pcsk_[A-Za-z0-9_-]{20,}/g, // Pinecone\n /pplx-[A-Za-z0-9_-]{20,}/g, // Perplexity\n /r8_[A-Za-z0-9_-]{20,}/g, // Replicate\n /rk_live_[A-Za-z0-9]{20,}/g, // Stripe restricted\n /sk_live_[A-Za-z0-9]{20,}/g, // Stripe secret\n /sntrys_[A-Za-z0-9]{40,}/g, // Sentry user auth\n /xai-[A-Za-z0-9_-]{20,}/g, // xAI (Grok)\n /xox[bpasr]-[A-Za-z0-9-]{10,}/g, //Slack tokens\n // Additional unique-prefix tokens with low false-positive risk\n /npm_[A-Za-z0-9]{36}/g, // npm access token\n /SG\\.[A-Za-z0-9_-]{22}\\.[A-Za-z0-9_-]{43}/g, // SendGrid\n /\\bSK[A-Za-z0-9]{32}\\b/g, // Twilio API SID (word-boundary to skip CSS class noise)\n /\\bkey-[a-f0-9]{32}\\b/g, // Mailgun (hex-only narrows false positives)\n /MT[A-Za-z0-9_-]{23}\\.[A-Za-z0-9_-]{6}\\.[A-Za-z0-9_-]{27}/g, // Discord bot\n /\\b(?:sdk|mob)-[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}\\b/g, // LaunchDarkly\n];\n\n// `Bearer <token>` matched as its own first-class pattern so PARAM_PATTERN\n// doesn't have to handle the unusual `Authorization: Bearer xxx` shape\n// (no `:` or `=` between \"Bearer\" and the value — bare whitespace).\nconst BEARER_PATTERN = /\\b(Bearer\\s+)([A-Za-z0-9_\\-.+/=]{8,})/g;\n\n// Parametric: matches `key=value` and `key: value` (with optional quote\n// between the key and the separator, to handle JSON: `\"api_key\": \"...\"`)\n// in URLs, query strings, JSON-like bodies, HTTP headers. Captures the\n// prefix so we keep it visible while masking the value.\n//\n// `authorization` deliberately excluded — BEARER_PATTERN handles the\n// common `Authorization: Bearer xxx` shape. Including it here causes\n// double-masking (\"Authorization: *** ***\") after Bearer fires.\n// T5.4: keyword set expanded from 6 → 16 to cover the OAuth / JWT / generic\n// credential vocabulary surfaced by DR6 finding #4. `authorization`,\n// `auth`, `bearer` stay excluded — BEARER_PATTERN handles the\n// `Authorization: Bearer xxx` shape and including these here would\n// re-catch the post-BUILTIN-masked form (D71 prefix-preservation\n// contract) and double-mask to `***`.\n//\n// Value class includes `.` so JWT / `.env` / dotted base64url values\n// match; the callback skips already-masked values (containing the\n// `...` D71 separator) to preserve the BUILTIN prefix-mask result.\nconst PARAM_PATTERN =\n /(\\b(?:access_token|api_key|api-key|client_secret|credential|credentials|id_token|jwt|password|private_key|refresh_token|secret|service_account|session_token|token|x-api-key)\\b[\"']?\\s*[:=]\\s*[\"']?)([A-Za-z0-9_\\-.+/]+)/gi;\n\nconst _extraPatterns: RegExp[] = [];\n\n/**\n * Add a user-defined redaction pattern. Additive — never removes builtins.\n * Throws if the regex lacks the `/g` flag (without `/g`, `.replace` only\n * substitutes the first match and the rest leaks).\n *\n * @internal — exposed publicly via `Security.addPattern` in `src/security.ts`.\n */\nexport function addPattern(re: RegExp): void {\n if (!re.global) {\n throw new Error(\"Security.addPattern: regex must have /g flag for replace-all semantics\");\n }\n _extraPatterns.push(re);\n}\n\n/**\n * Two-bucket masking (D71):\n * - tokens shorter than 18 chars → fully masked as `***`\n * - tokens >= 18 chars → keep first 6 + `...` + last 4\n *\n * Rationale: long tokens are unique per-account; prefix+suffix preserves\n * debuggability without revealing the secret middle.\n *\n * @internal\n */\nexport function maskToken(token: string): string {\n if (token.length < 18) return \"***\";\n return `${token.slice(0, 6)}...${token.slice(-4)}`;\n}\n\n// issue #117 — the EXACT shape of a `maskToken` output (`slice(0,6)+\"...\"+slice(-4)`\n// = 6 chars, literal `...`, 4 chars). Used to detect a value PARAM_PATTERN would\n// otherwise re-mask, WITHOUT skipping a raw secret that merely contains `...`.\nconst MASK_SHAPE = /^.{6}\\.\\.\\..{4}$/s;\n\n/**\n * Redact known credential patterns from `text`. Default behavior masks\n * builtins + extras + parametric `key=value` sinks.\n *\n * With `{ codeFile: true }` (D72), skips PARAM_PATTERN to avoid mangling\n * `.env.example`, schema JSON, or test fixtures that legitimately contain\n * prefix-like strings.\n *\n * Returns the redacted string. Coerces non-strings via JSON.stringify;\n * EC-7 fix (edge-case review): wraps in try/catch so circular references\n * never propagate — returns sentinel `\"[unredactable: circular]\"`.\n *\n * @internal\n */\n// Coerce arbitrary input to a string for redaction. Returns `null`\n// sentinel when the value is null/undefined/non-stringifiable, so the\n// caller can short-circuit with `\"\"`. EC-7 fix: circular refs go through\n// the try/catch and produce the sentinel marker, never throwing.\nfunction coerceToString(value: unknown): string | null {\n if (typeof value === \"string\") return value;\n if (value === null || value === undefined) return null;\n if (typeof value === \"object\") {\n try {\n const s = JSON.stringify(value);\n return s === undefined ? null : s;\n } catch {\n return \"[unredactable: circular]\";\n }\n }\n return String(value);\n}\n\nexport function redactSecrets(text: unknown, opts?: { codeFile?: boolean }): string {\n const coerced = coerceToString(text);\n if (coerced === null) return \"\";\n if (!REDACT_ENABLED) return coerced;\n\n let s = coerced;\n for (const re of BUILTIN_PATTERNS) {\n s = s.replace(re, (m) => maskToken(m));\n }\n for (const re of _extraPatterns) {\n s = s.replace(re, (m) => maskToken(m));\n }\n if (!opts?.codeFile) {\n // Bearer first (preserves \"Bearer \" prefix, masks the token after).\n // Must run before PARAM_PATTERN so the bare-whitespace shape doesn't\n // get mis-handled as a value.\n s = s.replace(BEARER_PATTERN, (_, prefix: string) => `${prefix}***`);\n // T5.4: skip if value already contains the D71 bucket-mask separator\n // (`...`) — BUILTIN ran first and produced a prefix-preserved mask;\n // re-masking would lose the prefix and degrade debuggability.\n s = s.replace(PARAM_PATTERN, (whole, prefix: string, value: string) => {\n // issue #117 — skip ONLY when the value is already a mask that a BUILTIN\n // pattern produced (maskToken's exact `6chars...4chars` shape), so we don't\n // re-mask and lose the prefix. The old `value.includes(\"...\")` was too broad:\n // a REAL secret that happens to contain `...` (e.g. `L_-cxw-.2UI_..._`) was\n // skipped and LEAKED. The mask shape is exact (maskToken: slice(0,6)+\"...\"+\n // slice(-4)), so a raw secret with `...` elsewhere is now masked.\n if (MASK_SHAPE.test(value)) return whole;\n return `${prefix}***`;\n });\n }\n return s;\n}\n\n/**\n * Test-only helper exported for `_test-reset.ts`. NOT included in the\n * `index.ts` barrel — vitest setup imports the dedicated module via\n * explicit path to discourage production callers.\n *\n * @internal\n */\nexport function _resetForTests(opts: { enabled?: boolean; clearExtras?: boolean }): void {\n if (opts.enabled !== undefined) REDACT_ENABLED = opts.enabled;\n if (opts.clearExtras === true) _extraPatterns.length = 0;\n}\n\n/**\n * T5.4 — Test-only count of BUILTIN_PATTERNS. Exposed so the count-floor\n * assertion can run without re-deriving the array shape in test land.\n * NOT included in the public barrel.\n *\n * @internal\n */\nexport function __TESTING__BUILTIN_PATTERN_COUNT(): number {\n return BUILTIN_PATTERNS.length;\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { ConfigurationError } from './chunk-MRKSSN36.js';
1
+ import { ConfigurationError } from './chunk-HI4ZW62S.js';
2
2
  import { readdir } from 'fs/promises';
3
3
 
4
4
  async function readWorkspaceDir(root, errorCode, describe) {
@@ -39,5 +39,5 @@ function coerce(raw) {
39
39
  }
40
40
 
41
41
  export { parseSimpleYaml, readWorkspaceDir };
42
- //# sourceMappingURL=chunk-OLLOUAUJ.js.map
43
- //# sourceMappingURL=chunk-OLLOUAUJ.js.map
42
+ //# sourceMappingURL=chunk-5XXUYU3M.js.map
43
+ //# sourceMappingURL=chunk-5XXUYU3M.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/internal/runtime/config/workspace-dir.ts","../src/internal/runtime/context/yaml-frontmatter.ts"],"names":[],"mappings":";;;AAyBA,eAAsB,gBAAA,CACpB,IAAA,EACA,SAAA,EACA,QAAA,EAC8B;AAC9B,EAAA,IAAI;AACF,IAAA,OAAQ,MAAM,OAAA,CAAQ,IAAA,EAAM,EAAE,aAAA,EAAe,MAAM,CAAA;AAAA,EACrD,SAAS,KAAA,EAAO;AACd,IAAA,MAAM,GAAA,GAAM,KAAA;AACZ,IAAA,IAAI,GAAA,CAAI,IAAA,KAAS,QAAA,EAAU,OAAO,EAAC;AACnC,IAAA,MAAM,IAAI,kBAAA,CAAmB,CAAA,eAAA,EAAkB,QAAQ,CAAA,EAAA,EAAK,IAAI,CAAA,CAAA,EAAI;AAAA,MAClE,IAAA,EAAM,SAAA;AAAA,MACN;AAAA,KACD,CAAA;AAAA,EACH;AACF;;;AClBO,SAAS,gBAAgB,IAAA,EAA4D;AAC1F,EAAA,MAAM,SAAuD,EAAC;AAC9D,EAAA,KAAA,MAAW,IAAA,IAAQ,IAAA,CAAK,KAAA,CAAM,OAAO,CAAA,EAAG;AACtC,IAAA,MAAM,UAAA,GAAa,IAAA,CAAK,OAAA,CAAQ,GAAG,CAAA;AACnC,IAAA,IAAI,eAAe,EAAA,EAAI;AACvB,IAAA,MAAM,MAAM,IAAA,CAAK,KAAA,CAAM,CAAA,EAAG,UAAU,EAAE,IAAA,EAAK;AAC3C,IAAA,IAAI,GAAA,CAAI,WAAW,CAAA,EAAG;AACtB,IAAA,MAAM,MAAM,IAAA,CAAK,KAAA,CAAM,UAAA,GAAa,CAAC,EAAE,IAAA,EAAK;AAC5C,IAAA,MAAA,CAAO,GAAG,CAAA,GAAI,MAAA,CAAO,GAAG,CAAA;AAAA,EAC1B;AACA,EAAA,OAAO,MAAA;AACT;AAEA,SAAS,OAAO,GAAA,EAA2C;AAEzD,EAAA,IAAI,GAAA,CAAI,MAAA,KAAW,CAAA,EAAG,OAAO,MAAA;AAC7B,EAAA,IAAI,IAAI,UAAA,CAAW,GAAG,KAAK,GAAA,CAAI,QAAA,CAAS,GAAG,CAAA,EAAG;AAC5C,IAAA,OAAO,GAAA,CACJ,MAAM,CAAA,EAAG,EAAE,EACX,KAAA,CAAM,GAAG,EACT,GAAA,CAAI,CAAC,MAAM,CAAA,CAAE,IAAA,EAAM,CAAA,CACnB,MAAA,CAAO,CAAC,CAAA,KAAM,CAAA,CAAE,SAAS,CAAC,CAAA;AAAA,EAC/B;AACA,EAAA,IAAI,GAAA,KAAQ,MAAA,IAAU,GAAA,KAAQ,OAAA,SAAgB,GAAA,KAAQ,MAAA;AACtD,EAAA,MAAM,CAAA,GAAI,OAAO,GAAG,CAAA;AACpB,EAAA,IAAI,MAAA,CAAO,SAAS,CAAC,CAAA,IAAK,QAAQ,MAAA,CAAO,CAAC,GAAG,OAAO,CAAA;AACpD,EAAA,OAAO,GAAA;AACT","file":"chunk-OLLOUAUJ.js","sourcesContent":["import { readdir } from \"node:fs/promises\";\n\nimport { ConfigurationError } from \"../../../errors.js\";\n\n/**\n * Entry returned by `readWorkspaceDir`. Mirrors the subset of\n * `fs.Dirent` the file-based loaders use.\n */\nexport interface WorkspaceDirEntry {\n name: string;\n isDirectory(): boolean;\n isFile(): boolean;\n}\n\n/**\n * Read a workspace subdirectory and return its entries. When the directory\n * does not exist (`ENOENT`), returns an empty array — the file-based loaders\n * (skills, plugins, agents) treat a missing directory as \"no entries\"\n * rather than an error.\n *\n * Any other I/O failure is wrapped as `ConfigurationError` so callers can\n * surface a stable error code.\n *\n * @internal\n */\nexport async function readWorkspaceDir(\n root: string,\n errorCode: string,\n describe: string,\n): Promise<WorkspaceDirEntry[]> {\n try {\n return (await readdir(root, { withFileTypes: true })) as WorkspaceDirEntry[];\n } catch (cause) {\n const err = cause as NodeJS.ErrnoException;\n if (err.code === \"ENOENT\") return [];\n throw new ConfigurationError(`Failed to read ${describe}: ${root}`, {\n code: errorCode,\n cause,\n });\n }\n}\n","/**\n * Tiny YAML-frontmatter parser shared by the file-based loaders (skills,\n * subagents, hooks, context, plugins). Supports four scalar shapes:\n *\n * key: bar → \"bar\" (string)\n * key: 42 → 42 (number)\n * key: true → true (boolean)\n * key: [a, b, c] → [\"a\",\"b\",\"c\"](string[])\n * key: → undefined (caller's Zod default kicks in)\n *\n * Limitations (intentional — keep parser tiny, no dep):\n * - No nested objects (use flat keys like `providerId` not `provider.id`).\n * - No quoted strings — `match: \"1\"` becomes the literal 3-char string `\"1\"`.\n * - List values cannot contain a literal comma inside an element; the\n * `tags: [a,b, c]` splitter is greedy on `,`. Use multi-line lists or\n * reword if you need this.\n *\n * @internal\n */\n\nexport type FrontmatterValue = string | number | boolean | string[];\n\nexport function parseSimpleYaml(text: string): Record<string, FrontmatterValue | undefined> {\n const fields: Record<string, FrontmatterValue | undefined> = {};\n for (const line of text.split(/\\r?\\n/)) {\n const colonIndex = line.indexOf(\":\");\n if (colonIndex === -1) continue;\n const key = line.slice(0, colonIndex).trim();\n if (key.length === 0) continue;\n const raw = line.slice(colonIndex + 1).trim();\n fields[key] = coerce(raw);\n }\n return fields;\n}\n\nfunction coerce(raw: string): FrontmatterValue | undefined {\n // EC-3: empty value → undefined so Zod `.optional().default(...)` applies.\n if (raw.length === 0) return undefined;\n if (raw.startsWith(\"[\") && raw.endsWith(\"]\")) {\n return raw\n .slice(1, -1)\n .split(\",\")\n .map((s) => s.trim())\n .filter((s) => s.length > 0);\n }\n if (raw === \"true\" || raw === \"false\") return raw === \"true\";\n const n = Number(raw);\n if (Number.isFinite(n) && raw === String(n)) return n;\n return raw;\n}\n"]}
1
+ {"version":3,"sources":["../src/internal/runtime/config/workspace-dir.ts","../src/internal/runtime/context/yaml-frontmatter.ts"],"names":[],"mappings":";;;AAyBA,eAAsB,gBAAA,CACp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AO,GAAA,CACJ,MAAM,CAAA,EAAG,EAAE,EACX,KAAA,CAAM,GAAG,EACT,GAAA,CAAI,CAAC,MAAM,CAAA,CAAE,IAAA,EAAM,CAAA,CACnB,MAAA,CAAO,CAAC,CAAA,KAAM,CAAA,CAAE,SAAS,CAAC,CAAA;AAAA,EAC/B;AACA,EAAA,IAAI,GAAA,KAAQ,MAAA,IAAU,GAAA,KAAQ,OAAA,SAAgB,GAAA,KAAQ,MAAA;AACtD,EAAA,MAAM,CAAA,GAAI,OAAO,GAAG,CAAA;AACpB,EAAA,IAAI,MAAA,CAAO,SAAS,CAAC,CAAA,IAAK,QAAQ,MAAA,CAAO,CAAC,GAAG,OAAO,CAAA;AACpD,EAAA,OAAO,GAAA;AACT","file":"chunk-5XXUYU3M.js","sourcesContent":["import { readdir } from \"node:fs/promises\";\n\nimport { ConfigurationError } from \"../../../errors.js\";\n\n/**\n * Entry returned by `readWorkspaceDir`. Mirrors the subset of\n * `fs.Dirent` the file-based loaders use.\n */\nexport interface WorkspaceDirEntry {\n name: string;\n isDirectory(): boolean;\n isFile(): boolean;\n}\n\n/**\n * Read a workspace subdirectory and return its entries. When the directory\n * does not exist (`ENOENT`), returns an empty array — the file-based loaders\n * (skills, plugins, agents) treat a missing directory as \"no entries\"\n * rather than an error.\n *\n * Any other I/O failure is wrapped as `ConfigurationError` so callers can\n * surface a stable error code.\n *\n * @internal\n */\nexport async function readWorkspaceDir(\n root: string,\n errorCode: string,\n describe: string,\n): Promise<WorkspaceDirEntry[]> {\n try {\n return (await readdir(root, { withFileTypes: true })) as WorkspaceDirEntry[];\n } catch (cause) {\n const err = cause as NodeJS.ErrnoException;\n if (err.code === \"ENOENT\") return [];\n throw new ConfigurationError(`Failed to read ${describe}: ${root}`, {\n code: errorCode,\n cause,\n });\n }\n}\n","/**\n * Tiny YAML-frontmatter parser shared by the file-based loaders (skills,\n * subagents, hooks, context, plugins). Supports four scalar shapes:\n *\n * key: bar → \"bar\" (string)\n * key: 42 → 42 (number)\n * key: true → true (boolean)\n * key: [a, b, c] → [\"a\",\"b\",\"c\"](string[])\n * key: → undefined (caller's Zod default kicks in)\n *\n * Limitations (intentional — keep parser tiny, no dep):\n * - No nested objects (use flat keys like `providerId` not `provider.id`).\n * - No quoted strings — `match: \"1\"` becomes the literal 3-char string `\"1\"`.\n * - List values cannot contain a literal comma inside an element; the\n * `tags: [a,b, c]` splitter is greedy on `,`. Use multi-line lists or\n * reword if you need this.\n *\n * @internal\n */\n\nexport type FrontmatterValue = string | number | boolean | string[];\n\nexport function parseSimpleYaml(text: string): Record<string, FrontmatterValue | undefined> {\n const fields: Record<string, FrontmatterValue | undefined> = {};\n for (const line of text.split(/\\r?\\n/)) {\n const colonIndex = line.indexOf(\":\");\n if (colonIndex === -1) continue;\n const key = line.slice(0, colonIndex).trim();\n if (key.length === 0) continue;\n const raw = line.slice(colonIndex + 1).trim();\n fields[key] = coerce(raw);\n }\n return fields;\n}\n\nfunction coerce(raw: string): FrontmatterValue | undefined {\n // EC-3: empty value → undefined so Zod `.optional().default(...)` applies.\n if (raw.length === 0) return undefined;\n if (raw.startsWith(\"[\") && raw.endsWith(\"]\")) {\n return raw\n .slice(1, -1)\n .split(\",\")\n .map((s) => s.trim())\n .filter((s) => s.length > 0);\n }\n if (raw === \"true\" || raw === \"false\") return raw === \"true\";\n const n = Number(raw);\n if (Number.isFinite(n) && raw === String(n)) return n;\n return raw;\n}\n"]}
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkBUUUWQMB_cjs = require('./chunk-BUUUWQMB.cjs');
4
- var chunk27DYRARU_cjs = require('./chunk-27DYRARU.cjs');
5
- var chunkXR4LPBXH_cjs = require('./chunk-XR4LPBXH.cjs');
6
- var chunkYULF6FPB_cjs = require('./chunk-YULF6FPB.cjs');
7
- var chunkZHPET3LZ_cjs = require('./chunk-ZHPET3LZ.cjs');
4
+ var chunkNFATC6ZF_cjs = require('./chunk-NFATC6ZF.cjs');
5
+ var chunk7HQVDLFI_cjs = require('./chunk-7HQVDLFI.cjs');
6
+ var chunk2YGIBOUH_cjs = require('./chunk-2YGIBOUH.cjs');
7
+ var chunkSXSPMRSV_cjs = require('./chunk-SXSPMRSV.cjs');
8
8
  var async_hooks = require('async_hooks');
9
9
  var crypto = require('crypto');
10
10
 
@@ -116,9 +116,9 @@ var TaskIterator = class {
116
116
  };
117
117
  function buildSubscribe(deps) {
118
118
  return function subscribe2(id) {
119
- if (!chunkXR4LPBXH_cjs.isValidTaskId(id, true)) throw new chunkYULF6FPB_cjs.TaskNotFoundError(id);
119
+ if (!chunk7HQVDLFI_cjs.isValidTaskId(id, true)) throw new chunk2YGIBOUH_cjs.TaskNotFoundError(id);
120
120
  const buffer = deps.getBuffer(id);
121
- if (buffer === void 0) throw new chunkYULF6FPB_cjs.TaskNotFoundError(id);
121
+ if (buffer === void 0) throw new chunk2YGIBOUH_cjs.TaskNotFoundError(id);
122
122
  return {
123
123
  [Symbol.asyncIterator]() {
124
124
  return new TaskIterator(buffer, id, deps);
@@ -187,10 +187,10 @@ var EVICTION_INTERVAL_MS = 5 * 60 * 1e3;
187
187
  var RING_CAP = 64;
188
188
  var reentryAls = new async_hooks.AsyncLocalStorage();
189
189
  function buildState(opts) {
190
- const store = opts.store === void 0 ? new chunkXR4LPBXH_cjs.InMemoryTaskStore() : chunkXR4LPBXH_cjs.getTaskStoreFor(opts.store);
190
+ const store = opts.store === void 0 ? new chunk7HQVDLFI_cjs.InMemoryTaskStore() : chunk7HQVDLFI_cjs.getTaskStoreFor(opts.store);
191
191
  return {
192
192
  store,
193
- semaphore: chunk27DYRARU_cjs.createSemaphore(opts.maxConcurrent ?? DEFAULT_CONCURRENCY),
193
+ semaphore: chunkNFATC6ZF_cjs.createSemaphore(opts.maxConcurrent ?? DEFAULT_CONCURRENCY),
194
194
  aborters: /* @__PURE__ */ new Map(),
195
195
  buffers: /* @__PURE__ */ new Map(),
196
196
  subscribers: /* @__PURE__ */ new Map(),
@@ -208,7 +208,7 @@ function __getSubscribersCountForTests(taskId) {
208
208
  }
209
209
  function configure(opts) {
210
210
  if (state.firstSubmitSeen) {
211
- chunkZHPET3LZ_cjs.diag(
211
+ chunkSXSPMRSV_cjs.diag(
212
212
  "[task] configure() ignored \u2014 registry already in use; reset via __resetTaskRegistryForTests()\n"
213
213
  );
214
214
  return;
@@ -225,7 +225,7 @@ function emitToSubscribers(taskId, event) {
225
225
  try {
226
226
  cb(event);
227
227
  } catch (err) {
228
- chunkZHPET3LZ_cjs.diag(`[task] subscriber threw: ${err.message}
228
+ chunkSXSPMRSV_cjs.diag(`[task] subscriber threw: ${err.message}
229
229
  `);
230
230
  }
231
231
  }
@@ -234,7 +234,7 @@ async function safeUpdate(taskId, mutate) {
234
234
  try {
235
235
  return await state.store.update(taskId, mutate);
236
236
  } catch (err) {
237
- chunkZHPET3LZ_cjs.diag(`[task] store.update failed for ${taskId}: ${err.message}
237
+ chunkSXSPMRSV_cjs.diag(`[task] store.update failed for ${taskId}: ${err.message}
238
238
  `);
239
239
  return void 0;
240
240
  }
@@ -313,8 +313,8 @@ async function buildAndInsertQueued(internal, resolvedId) {
313
313
  }
314
314
  function resolveIdInternal(internal) {
315
315
  if (internal.id === void 0) return crypto.randomUUID();
316
- if (!chunkXR4LPBXH_cjs.isValidTaskId(internal.id, internal.allowReservedPrefix ?? false)) {
317
- throw new chunkYULF6FPB_cjs.InvalidTaskIdError(`invalid task id: ${internal.id}`, internal.id);
316
+ if (!chunk7HQVDLFI_cjs.isValidTaskId(internal.id, internal.allowReservedPrefix ?? false)) {
317
+ throw new chunk2YGIBOUH_cjs.InvalidTaskIdError(`invalid task id: ${internal.id}`, internal.id);
318
318
  }
319
319
  return internal.id;
320
320
  }
@@ -429,11 +429,11 @@ async function list(filter = {}) {
429
429
  return state.store.list(filter);
430
430
  }
431
431
  async function get(id) {
432
- if (!chunkXR4LPBXH_cjs.isValidTaskId(id, true)) return void 0;
432
+ if (!chunk7HQVDLFI_cjs.isValidTaskId(id, true)) return void 0;
433
433
  return state.store.get(id);
434
434
  }
435
435
  async function cancel(id, reason) {
436
- if (!chunkXR4LPBXH_cjs.isValidTaskId(id, true)) return { cancelled: false, alreadyTerminal: false };
436
+ if (!chunk7HQVDLFI_cjs.isValidTaskId(id, true)) return { cancelled: false, alreadyTerminal: false };
437
437
  const handle = await state.store.get(id);
438
438
  if (handle === void 0) return { cancelled: false, alreadyTerminal: false };
439
439
  if (handle.state === "finished" || handle.state === "error" || handle.state === "cancelled") {
@@ -493,5 +493,5 @@ exports.get = get;
493
493
  exports.list = list;
494
494
  exports.submit = submit;
495
495
  exports.subscribe = subscribe;
496
- //# sourceMappingURL=chunk-KCQUYQ3V.cjs.map
497
- //# sourceMappingURL=chunk-KCQUYQ3V.cjs.map
496
+ //# sourceMappingURL=chunk-6DCTL32L.cjs.map
497
+ //# sourceMappingURL=chunk-6DCTL32L.cjs.map