@theokit/sdk 5.7.0 → 5.8.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 (352) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/dist/a2a/index.cjs +6 -6
  3. package/dist/a2a/index.js +2 -2
  4. package/dist/{agent-Dya5SmhY.d.cts → agent-3RcPVGMo.d.cts} +21 -3
  5. package/dist/agent-7ERQNV66.js +59 -0
  6. package/dist/{agent-EQ5HKTWV.js.map → agent-7ERQNV66.js.map} +1 -1
  7. package/dist/agent-LNTR4QH5.cjs +68 -0
  8. package/dist/{agent-KA63WDQH.cjs.map → agent-LNTR4QH5.cjs.map} +1 -1
  9. package/dist/{agent-Bqzdhkqr.d.ts → agent-lS68mYIL.d.ts} +21 -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-A575WPBL.cjs → chunk-2STSX2SY.cjs} +260 -260
  19. package/dist/{chunk-A575WPBL.cjs.map → chunk-2STSX2SY.cjs.map} +1 -1
  20. package/dist/{chunk-FUUSIT2T.js → chunk-3CU5J7V3.js} +34 -34
  21. package/dist/{chunk-FUUSIT2T.js.map → chunk-3CU5J7V3.js.map} +1 -1
  22. package/dist/{chunk-A6PDYH55.js → chunk-4QCJAJAG.js} +2 -2
  23. package/dist/chunk-4QCJAJAG.js.map +1 -0
  24. package/dist/{chunk-XYFGKVZ7.js → chunk-53RDNK3H.js} +3 -3
  25. package/dist/{chunk-XYFGKVZ7.js.map → chunk-53RDNK3H.js.map} +1 -1
  26. package/dist/{chunk-CZWN4C6A.js → chunk-5522X223.js} +3 -3
  27. package/dist/{chunk-CZWN4C6A.js.map → chunk-5522X223.js.map} +1 -1
  28. package/dist/{chunk-EH6XD3FY.js → chunk-5DD4NJN3.js} +3 -3
  29. package/dist/{chunk-EH6XD3FY.js.map → chunk-5DD4NJN3.js.map} +1 -1
  30. package/dist/{chunk-V22DZIXO.js → chunk-5Q4RTLMP.js} +3 -3
  31. package/dist/{chunk-V22DZIXO.js.map → chunk-5Q4RTLMP.js.map} +1 -1
  32. package/dist/{chunk-4A3SKJ53.cjs → chunk-6PB5AQCY.cjs} +14 -14
  33. package/dist/{chunk-4A3SKJ53.cjs.map → chunk-6PB5AQCY.cjs.map} +1 -1
  34. package/dist/{chunk-PRZ3BES7.cjs → chunk-72CPLZPC.cjs} +5 -5
  35. package/dist/{chunk-PRZ3BES7.cjs.map → chunk-72CPLZPC.cjs.map} +1 -1
  36. package/dist/{chunk-HNAYCTX4.cjs → chunk-76PIKR4P.cjs} +22 -22
  37. package/dist/{chunk-HNAYCTX4.cjs.map → chunk-76PIKR4P.cjs.map} +1 -1
  38. package/dist/{chunk-EFMFILPG.js → chunk-7F7XE6CM.js} +3 -3
  39. package/dist/{chunk-EFMFILPG.js.map → chunk-7F7XE6CM.js.map} +1 -1
  40. package/dist/{chunk-7C3HWGCW.js → chunk-7GDHFV2M.js} +3 -3
  41. package/dist/{chunk-7C3HWGCW.js.map → chunk-7GDHFV2M.js.map} +1 -1
  42. package/dist/{chunk-CA5VUAP3.js → chunk-7HUCU3KK.js} +5 -5
  43. package/dist/{chunk-CA5VUAP3.js.map → chunk-7HUCU3KK.js.map} +1 -1
  44. package/dist/{chunk-4MMWFSCD.js → chunk-7JAKO3NM.js} +3 -3
  45. package/dist/{chunk-4MMWFSCD.js.map → chunk-7JAKO3NM.js.map} +1 -1
  46. package/dist/{chunk-UADQJBHR.cjs → chunk-7NQ7HJ3E.cjs} +6 -6
  47. package/dist/{chunk-UADQJBHR.cjs.map → chunk-7NQ7HJ3E.cjs.map} +1 -1
  48. package/dist/{chunk-ER5BOIYD.cjs → chunk-AOHRKGAA.cjs} +22 -22
  49. package/dist/{chunk-ER5BOIYD.cjs.map → chunk-AOHRKGAA.cjs.map} +1 -1
  50. package/dist/{chunk-ZLMU5EU3.cjs → chunk-ARMFXTY6.cjs} +114 -190
  51. package/dist/chunk-ARMFXTY6.cjs.map +1 -0
  52. package/dist/{chunk-5WKQDIGO.js → chunk-AY43232P.js} +4 -4
  53. package/dist/{chunk-5WKQDIGO.js.map → chunk-AY43232P.js.map} +1 -1
  54. package/dist/{chunk-7FDKWDA2.cjs → chunk-B3XXQX6L.cjs} +7 -7
  55. package/dist/{chunk-7FDKWDA2.cjs.map → chunk-B3XXQX6L.cjs.map} +1 -1
  56. package/dist/{chunk-ALUN2B4W.js → chunk-B5MHRQJZ.js} +9 -3
  57. package/dist/chunk-B5MHRQJZ.js.map +1 -0
  58. package/dist/{chunk-TA3K7SBK.js → chunk-BKMDRBJ7.js} +3 -3
  59. package/dist/{chunk-TA3K7SBK.js.map → chunk-BKMDRBJ7.js.map} +1 -1
  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-6JG2RFGK.js → chunk-FRL35MFN.js} +5 -5
  71. package/dist/{chunk-6JG2RFGK.js.map → chunk-FRL35MFN.js.map} +1 -1
  72. package/dist/{chunk-EIQFAOFD.js → chunk-GGRPAQ3B.js} +3 -3
  73. package/dist/{chunk-EIQFAOFD.js.map → chunk-GGRPAQ3B.js.map} +1 -1
  74. package/dist/{chunk-HCT4HPCL.cjs → chunk-GHHIJEFX.cjs} +4 -4
  75. package/dist/{chunk-HCT4HPCL.cjs.map → chunk-GHHIJEFX.cjs.map} +1 -1
  76. package/dist/{chunk-7A6535RA.cjs → chunk-GM54F4FE.cjs} +9 -9
  77. package/dist/{chunk-7A6535RA.cjs.map → chunk-GM54F4FE.cjs.map} +1 -1
  78. package/dist/{chunk-6M2OIS4Y.js → chunk-GMRFAX4I.js} +74 -4
  79. package/dist/chunk-GMRFAX4I.js.map +1 -0
  80. package/dist/{chunk-O6USDERH.js → chunk-GMSRRJ53.js} +3 -3
  81. package/dist/{chunk-O6USDERH.js.map → chunk-GMSRRJ53.js.map} +1 -1
  82. package/dist/{chunk-VE6DFSKU.js → chunk-GTX6FEDP.js} +3 -3
  83. package/dist/{chunk-VE6DFSKU.js.map → chunk-GTX6FEDP.js.map} +1 -1
  84. package/dist/{chunk-NJWYQWDL.js → chunk-H3CVJSFC.js} +3 -3
  85. package/dist/{chunk-NJWYQWDL.js.map → chunk-H3CVJSFC.js.map} +1 -1
  86. package/dist/{chunk-MYJGWS2J.cjs → chunk-HG5LKFG7.cjs} +16 -16
  87. package/dist/{chunk-MYJGWS2J.cjs.map → chunk-HG5LKFG7.cjs.map} +1 -1
  88. package/dist/{chunk-55GB6JYQ.js → chunk-HOHR75KF.js} +5 -5
  89. package/dist/{chunk-55GB6JYQ.js.map → chunk-HOHR75KF.js.map} +1 -1
  90. package/dist/{chunk-GBCVPKHE.js → chunk-HV4V63CO.js} +3 -3
  91. package/dist/{chunk-GBCVPKHE.js.map → chunk-HV4V63CO.js.map} +1 -1
  92. package/dist/{chunk-I2PWY7VM.cjs → chunk-IIYJMXYW.cjs} +4 -4
  93. package/dist/{chunk-I2PWY7VM.cjs.map → chunk-IIYJMXYW.cjs.map} +1 -1
  94. package/dist/{chunk-YYN6BB7R.cjs → chunk-J4SA2ZEJ.cjs} +4 -4
  95. package/dist/{chunk-YYN6BB7R.cjs.map → chunk-J4SA2ZEJ.cjs.map} +1 -1
  96. package/dist/{chunk-ATT276RD.cjs → chunk-J5623RIV.cjs} +78 -6
  97. package/dist/chunk-J5623RIV.cjs.map +1 -0
  98. package/dist/{chunk-KVSAY6NZ.cjs → chunk-J6GXS5A2.cjs} +13 -13
  99. package/dist/{chunk-KVSAY6NZ.cjs.map → chunk-J6GXS5A2.cjs.map} +1 -1
  100. package/dist/{chunk-NQTD6QOW.cjs → chunk-JW3GVLM6.cjs} +4 -4
  101. package/dist/{chunk-NQTD6QOW.cjs.map → chunk-JW3GVLM6.cjs.map} +1 -1
  102. package/dist/{chunk-TFG5IBZS.cjs → chunk-KGZ66JVZ.cjs} +14 -14
  103. package/dist/{chunk-TFG5IBZS.cjs.map → chunk-KGZ66JVZ.cjs.map} +1 -1
  104. package/dist/{chunk-47TF32NQ.js → chunk-KO6SHCEH.js} +3 -3
  105. package/dist/{chunk-47TF32NQ.js.map → chunk-KO6SHCEH.js.map} +1 -1
  106. package/dist/{chunk-EFETPSJZ.cjs → chunk-KTA7YTZQ.cjs} +12 -12
  107. package/dist/{chunk-EFETPSJZ.cjs.map → chunk-KTA7YTZQ.cjs.map} +1 -1
  108. package/dist/{chunk-D6POWE7E.cjs → chunk-MEUBLCM4.cjs} +11 -11
  109. package/dist/{chunk-D6POWE7E.cjs.map → chunk-MEUBLCM4.cjs.map} +1 -1
  110. package/dist/{chunk-VWUXIVEI.js → chunk-MFZODA5Y.js} +5 -5
  111. package/dist/{chunk-VWUXIVEI.js.map → chunk-MFZODA5Y.js.map} +1 -1
  112. package/dist/{chunk-4HS6FFGL.cjs → chunk-MPQJE3G4.cjs} +15 -15
  113. package/dist/{chunk-4HS6FFGL.cjs.map → chunk-MPQJE3G4.cjs.map} +1 -1
  114. package/dist/{chunk-QRVS2PRE.cjs → chunk-MPR2ISL2.cjs} +4 -4
  115. package/dist/{chunk-QRVS2PRE.cjs.map → chunk-MPR2ISL2.cjs.map} +1 -1
  116. package/dist/{chunk-UOLBAPDM.js → chunk-MQGSOKR3.js} +3 -3
  117. package/dist/{chunk-UOLBAPDM.js.map → chunk-MQGSOKR3.js.map} +1 -1
  118. package/dist/{chunk-HFEJE7AC.js → chunk-MU7IAA7G.js} +9 -9
  119. package/dist/{chunk-HFEJE7AC.js.map → chunk-MU7IAA7G.js.map} +1 -1
  120. package/dist/{chunk-EXTRW7GW.cjs → chunk-NAGPKWOD.cjs} +4 -4
  121. package/dist/{chunk-EXTRW7GW.cjs.map → chunk-NAGPKWOD.cjs.map} +1 -1
  122. package/dist/{chunk-KTTHHYEW.cjs → chunk-NJSIAJEK.cjs} +4 -4
  123. package/dist/{chunk-KTTHHYEW.cjs.map → chunk-NJSIAJEK.cjs.map} +1 -1
  124. package/dist/{chunk-Z3NTRKIC.cjs → chunk-NKIQTLFA.cjs} +4 -4
  125. package/dist/{chunk-Z3NTRKIC.cjs.map → chunk-NKIQTLFA.cjs.map} +1 -1
  126. package/dist/{chunk-N7VAE6DZ.js → chunk-NOO6GZTZ.js} +8 -84
  127. package/dist/chunk-NOO6GZTZ.js.map +1 -0
  128. package/dist/{chunk-GK3UG7YQ.cjs → chunk-OCEQ6DW2.cjs} +10 -10
  129. package/dist/{chunk-GK3UG7YQ.cjs.map → chunk-OCEQ6DW2.cjs.map} +1 -1
  130. package/dist/{chunk-BJUJT5ED.cjs → chunk-OF2CLCTH.cjs} +4 -4
  131. package/dist/{chunk-BJUJT5ED.cjs.map → chunk-OF2CLCTH.cjs.map} +1 -1
  132. package/dist/{chunk-HUFSABUZ.cjs → chunk-OLSEWLK5.cjs} +6 -6
  133. package/dist/{chunk-HUFSABUZ.cjs.map → chunk-OLSEWLK5.cjs.map} +1 -1
  134. package/dist/{chunk-DQZU7JK6.cjs → chunk-P22BZE7G.cjs} +4 -4
  135. package/dist/{chunk-DQZU7JK6.cjs.map → chunk-P22BZE7G.cjs.map} +1 -1
  136. package/dist/{chunk-QWD3CZWE.cjs → chunk-P7NNKEWO.cjs} +4 -4
  137. package/dist/{chunk-QWD3CZWE.cjs.map → chunk-P7NNKEWO.cjs.map} +1 -1
  138. package/dist/{chunk-DQNI52VV.js → chunk-PQCTDMUI.js} +3 -3
  139. package/dist/{chunk-DQNI52VV.js.map → chunk-PQCTDMUI.js.map} +1 -1
  140. package/dist/{chunk-3XSWF5AP.cjs → chunk-PSLCVSCS.cjs} +3 -3
  141. package/dist/{chunk-3XSWF5AP.cjs.map → chunk-PSLCVSCS.cjs.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-J7J7J2GN.cjs → chunk-UNFBHV46.cjs} +9 -2
  163. package/dist/chunk-UNFBHV46.cjs.map +1 -0
  164. package/dist/{chunk-AAEZSPTC.js → chunk-UNZOJVVC.js} +4 -4
  165. package/dist/{chunk-AAEZSPTC.js.map → chunk-UNZOJVVC.js.map} +1 -1
  166. package/dist/{chunk-T3ZDEYTJ.js → chunk-W4VQMXBZ.js} +4 -4
  167. package/dist/{chunk-T3ZDEYTJ.js.map → chunk-W4VQMXBZ.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-RWPLWMCZ.cjs → chunk-XW4POZ6V.cjs} +11 -11
  179. package/dist/{chunk-RWPLWMCZ.cjs.map → chunk-XW4POZ6V.cjs.map} +1 -1
  180. package/dist/{chunk-6PWOWXMC.js → chunk-XZHJYSPB.js} +3 -3
  181. package/dist/{chunk-6PWOWXMC.js.map → chunk-XZHJYSPB.js.map} +1 -1
  182. package/dist/{chunk-QC55H6RJ.cjs → chunk-YRJA2POB.cjs} +9 -9
  183. package/dist/{chunk-QC55H6RJ.cjs.map → chunk-YRJA2POB.cjs.map} +1 -1
  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-BwxDUscv.d.cts → cron-CGxoEKlx.d.cts} +2 -2
  209. package/dist/{cron-D8uB1Xh5.d.ts → cron-DJv8zMa3.d.ts} +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-7GE7YUDI.cjs +16 -0
  307. package/dist/{subagents-loader-MOO7DC4E.cjs.map → subagents-loader-7GE7YUDI.cjs.map} +1 -1
  308. package/dist/subagents-loader-S2PMZY7J.js +7 -0
  309. package/dist/{subagents-loader-CJFYQQU2.js.map → subagents-loader-S2PMZY7J.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/workflow.cjs +25 -25
  321. package/dist/workflow.d.cts +2 -2
  322. package/dist/workflow.d.ts +2 -2
  323. package/dist/workflow.js +4 -4
  324. package/docs/error-codes.md +1 -1
  325. package/docs/harness-capability-map.md +17 -1
  326. package/package.json +1 -1
  327. package/dist/agent-EQ5HKTWV.js +0 -59
  328. package/dist/agent-KA63WDQH.cjs +0 -68
  329. package/dist/chunk-6M2OIS4Y.js.map +0 -1
  330. package/dist/chunk-7KBNBPFK.cjs.map +0 -1
  331. package/dist/chunk-A6PDYH55.js.map +0 -1
  332. package/dist/chunk-ALUN2B4W.js.map +0 -1
  333. package/dist/chunk-ANMJJD6D.cjs +0 -18
  334. package/dist/chunk-ATT276RD.cjs.map +0 -1
  335. package/dist/chunk-J7J7J2GN.cjs.map +0 -1
  336. package/dist/chunk-N7VAE6DZ.js.map +0 -1
  337. package/dist/chunk-ZLMU5EU3.cjs.map +0 -1
  338. package/dist/context-7RP5JXGM.cjs +0 -24
  339. package/dist/context-OJIIXJCV.js +0 -7
  340. package/dist/fs-session-store-77JU46UZ.js +0 -10
  341. package/dist/fs-session-store-E4U3P56L.cjs +0 -19
  342. package/dist/generate-object-BXV7BZRP.js +0 -7
  343. package/dist/generate-object-YBI2TDJ3.cjs +0 -20
  344. package/dist/index-manager-Z4XMRVWQ.js +0 -17
  345. package/dist/judge-call-46M2E5FA.cjs +0 -22
  346. package/dist/judge-call-FGUNNWEI.js +0 -5
  347. package/dist/oauth-transaction-store-5RIR6D5C.js +0 -5
  348. package/dist/oauth-transaction-store-SXIE57OD.cjs +0 -38
  349. package/dist/stream-object-HBFMIZLD.js +0 -7
  350. package/dist/stream-object-QSKHISDJ.cjs +0 -20
  351. package/dist/subagents-loader-CJFYQQU2.js +0 -7
  352. package/dist/subagents-loader-MOO7DC4E.cjs +0 -16
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/internal/workflow/event-stream.ts","../src/workflow-as-tool.ts","../src/workflow.ts"],"names":["TheokitAgentError","toJsonSchema","z","PersistenceSchema","ConfigurationError","WorkflowNestedError","sanitizeIdentifier","WorkflowDuplicateStepIdError"],"mappings":";;;;;;;;;;AAgBO,SAAS,iBAAA,GAAyC;AACvD,EAAA,MAAM,SAA0B,EAAC;AACjC,EAAA,MAAM,UAA6D,EAAC;AACpE,EAAA,IAAI,KAAA,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,GAAG,MAAM,CAAA,KAAM,MAAM,CAAA;AACtD,IAAA,OAAO,CAAA,CAAE,aAAa,MAAA,GAAY,CAAC,GAAG,MAAA,EAAQ,CAAA,CAAE,QAAQ,CAAA,GAAI,MAAA;AAAA,EAC9D;AACA,EAAA,IAAI,CAAA,CAAE,IAAA,KAAS,SAAA,IAAa,CAAA,CAAE,IAAA,KAAS,SAAA,EAAW,OAAO,CAAC,CAAC,CAAA,CAAE,IAAI,CAAC,CAAA;AAClE,EAAA,OAAO,EAAC;AACV;AAEA,SAAS,mBAAA,CAAoB,OAA4B,IAAA,EAAyB;AAChF,EAAA,KAAA,MAAW,KAAK,KAAA,EAAO;AACrB,IAAA,IAAI,IAAA,CAAK,IAAI,CAAA,CAAE,EAAE,GAAG,MAAM,IAAIC,8CAAA,CAA6B,CAAA,CAAE,EAAE,CAAA;AAC/D,IAAA,IAAA,CAAK,GAAA,CAAI,EAAE,EAAE,CAAA;AACb,IAAA,KAAA,MAAW,MAAA,IAAU,aAAA,CAAc,CAAC,CAAA,EAAG;AACrC,MAAA,mBAAA,CAAoB,QAAQ,IAAI,CAAA;AAAA,IAClC;AAAA,EACF;AACF","file":"chunk-4HS6FFGL.cjs","sourcesContent":["/**\n * SE28 — a minimal pushable async iterator for `Workflow.stream()`. The executor\n * pushes {@link WorkflowEvent}s as steps run; the consumer drains them via\n * `for await`. Buffers events emitted before the consumer is ready; `end()`\n * closes the iterator so a pending/next `next()` resolves `done: true`.\n *\n * @internal\n */\n\nimport type { WorkflowEvent } from \"../../types/workflow.js\";\n\nexport interface PushableEventStream extends AsyncIterableIterator<WorkflowEvent> {\n push(event: WorkflowEvent): void;\n end(): void;\n}\n\nexport function createEventStream(): PushableEventStream {\n const buffer: WorkflowEvent[] = [];\n const waiters: Array<(r: IteratorResult<WorkflowEvent>) => void> = [];\n let ended = false;\n\n const stream: PushableEventStream = {\n push(event: WorkflowEvent): void {\n if (ended) return;\n const waiter = waiters.shift();\n if (waiter !== undefined) waiter({ value: event, done: false });\n else buffer.push(event);\n },\n end(): void {\n if (ended) return;\n ended = true;\n for (const waiter of waiters.splice(0)) waiter({ value: undefined, done: true });\n },\n next(): Promise<IteratorResult<WorkflowEvent>> {\n const buffered = buffer.shift();\n if (buffered !== undefined) return Promise.resolve({ value: buffered, done: false });\n if (ended) return Promise.resolve({ value: undefined, done: true });\n return new Promise((resolve) => waiters.push(resolve));\n },\n // `for await` calls return() on break/throw — close early so events stop\n // buffering in memory for a consumer that stopped iterating.\n return(): Promise<IteratorResult<WorkflowEvent>> {\n stream.end();\n buffer.length = 0;\n return Promise.resolve({ value: undefined, done: true });\n },\n [Symbol.asyncIterator](): PushableEventStream {\n return stream;\n },\n };\n return stream;\n}\n","/**\n * SE19 — expose a {@link Workflow} as an agent tool.\n *\n * Split out of `workflow.ts` because it answers a different question: that file is about BUILDING a\n * workflow; this one is about handing a built workflow to an agent as a callable. The file-size gate\n * is what surfaced the seam, and the seam is real — nothing here runs while steps are composed.\n *\n * Re-exported from `workflow.ts`, so `@theokit/sdk/workflow` is unchanged.\n *\n * NOTE ON THE MODULE TAG: this header deliberately carries no internal-visibility tag, and does not\n * even name one — TypeScript attaches a file-leading docblock to the FIRST declaration below it, and\n * `stripInternal: true` (tsconfig.base) then deletes that declaration from the emitted `.d.ts`.\n * `tsc --noEmit` stays clean and the declaration rollup fails with `\"X\" is not exported by \"...\"`.\n * Measured twice on this file on 2026-09-01: once with the tag, and again when the comment\n * EXPLAINING the trap quoted the tag verbatim and re-armed it.\n */\n\nimport type { ZodType, z } from \"zod\";\n\nimport { TheokitAgentError } from \"./errors.js\";\nimport { toJsonSchema } from \"./internal/zod-to-json-schema.js\";\nimport type { CustomTool } from \"./types/agent.js\";\n// `WorkflowRun` comes from the TYPE module, never from `workflow.ts`. Importing it from there\n// created a file cycle — workflow.ts re-exports this module — which madge caught with\n// tsPreCompilationDeps on, since a type-only import is still an edge. `workflowAsTool` never needed\n// the `Workflow` class anyway: its parameter is structural, `{ run: (input) => Promise<...> }`.\nimport type { WorkflowRun } from \"./types/workflow.js\";\n\n/* ─── SE19 — workflowAsTool (expose a Workflow as an agent tool) ─── */\n\n/**\n * Raised by a {@link workflowAsTool} tool when the wrapped workflow run does not\n * reach `status: \"completed\"` (a step failed, the run was cancelled/suspended).\n * The dispatch converts it to a `tool_result(isError)`.\n *\n * @public\n */\nexport class WorkflowToolError extends TheokitAgentError {\n override readonly name = \"WorkflowToolError\";\n override readonly code = \"workflow_tool_failed\" as const;\n constructor(\n readonly toolName: string,\n readonly workflowStatus: string,\n readonly workflowError?: { name: string; message: string },\n ) {\n // Not retryable at this level: the workflow already ran and reported its own status; whether the\n // underlying failure is transient is a question for the workflow's retry policy, not the tool wrapper.\n super(\n `workflowAsTool(\"${toolName}\"): workflow ${workflowStatus}${\n workflowError ? `: ${workflowError.message}` : \"\"\n }`,\n { code: \"workflow_tool_failed\", isRetryable: false },\n );\n }\n}\n\n/** Spec for {@link workflowAsTool}. `inputSchema` is the workflow's input shape (Zod). */\nexport interface WorkflowAsToolSpec<T extends ZodType> {\n /** Tool name surfaced to the LLM. Same constraints as a `CustomTool.name`. */\n name: string;\n /** Description surfaced to the LLM — when the agent should trigger the workflow. */\n description: string;\n /** Zod schema for the workflow's input (a `Workflow` carries no top-level schema). */\n inputSchema: T;\n}\n\n/**\n * SE19 — expose a {@link Workflow} as an agent {@link CustomTool}, completing the\n * \"X as tools\" trio (tools; agents-as-tools via `defineSubAgent`; workflows-as-tools).\n * The handler validates the model's args against `spec.inputSchema`, runs the\n * workflow, and returns its output (a string as-is, else JSON). A run that does not\n * reach `status: \"completed\"` raises a typed {@link WorkflowToolError} (workflow\n * step errors do NOT throw — they surface via `run.status === \"failed\"`).\n *\n * Accepts any `{ run }`-shaped workflow (structural), so it never imports the\n * `Workflow` class directly.\n *\n * @public\n */\nexport function workflowAsTool<T extends ZodType, TOutput = unknown>(\n workflow: { run: (input: z.infer<T>) => Promise<WorkflowRun<TOutput>> },\n spec: WorkflowAsToolSpec<T>,\n): CustomTool {\n const inputSchema = toJsonSchema(spec.inputSchema, { unrepresentable: \"any\" });\n return {\n name: spec.name,\n description: spec.description,\n inputSchema,\n handler: async (rawInput: Record<string, unknown>): Promise<string> => {\n const parsed = spec.inputSchema.parse(rawInput) as z.infer<T>;\n const run = await workflow.run(parsed);\n if (run.status !== \"completed\") {\n throw new WorkflowToolError(spec.name, run.status, run.error);\n }\n const output = run.output;\n return typeof output === \"string\" ? output : JSON.stringify(output ?? null);\n },\n };\n}\n","/**\n * Public `Workflow` class — declarative multi-step orchestration over\n * `Agent.send`, `Handoff`, `Agent.batch` and friends (Adoption Roadmap #5;\n * ADRs D230-D248).\n *\n * Usage:\n *\n * import { Agent } from \"@theokit/sdk\";\n * import { Workflow, fn, agentStep } from \"@theokit/sdk/workflow\";\n *\n * const classifier = await Agent.create({ ... });\n * const wf = Workflow.create({ name: \"demo\" })\n * .then(fn(\"validate\", (input: { id: string }) => {\n * if (!input.id) throw new Error(\"missing id\");\n * return input;\n * }))\n * .then(agentStep(\"classify\", classifier, (i) => `Classify: ${JSON.stringify(i)}`))\n * .commit();\n *\n * const run = await wf.run({ id: \"x\" });\n * console.log(run.status, run.output);\n *\n * @public\n */\n\nimport type { ZodType } from \"zod\";\nimport { z } from \"zod\";\nimport { ConfigurationError } from \"./errors.js\";\nimport { PersistenceSchema } from \"./internal/persistence/persistence-schema.js\";\nimport { sanitizeIdentifier } from \"./internal/security/path-guard.js\";\nimport { createEventStream } from \"./internal/workflow/event-stream.js\";\nimport type { SDKAgent } from \"./types/agent.js\";\nimport type { MessageOrigin } from \"./types/run.js\";\nimport type {\n AgentStep,\n BranchStep,\n DowhileStep,\n FnStep,\n ForeachStep,\n ParallelStep,\n RetryPolicy,\n SleepStep,\n Step,\n StepContext,\n SuspendStep,\n WorkflowDescription,\n WorkflowEvent,\n WorkflowOptions,\n WorkflowResumeOptions,\n WorkflowRun,\n WorkflowRunOptions,\n WorkflowStepDescription,\n WorkflowStream,\n} from \"./types/workflow.js\";\nimport { WorkflowDuplicateStepIdError, WorkflowNestedError } from \"./workflow-errors.js\";\n\n/* ─── Zod validation schemas ─── */\n\nconst RetryPolicySchema = z.object({\n // EC-3 absorbed: maxAttempts MUST be a finite int in [1, 20].\n maxAttempts: z\n .number()\n .int(\"retry.maxAttempts must be integer\")\n .min(1, \"retry.maxAttempts must be >= 1\")\n .max(20, \"retry.maxAttempts must be <= 20\"),\n initialBackoffMs: z.number().int().min(0).optional(),\n backoffCoefficient: z.number().min(1).optional(),\n maximumBackoffMs: z.number().int().min(0).optional(),\n nonRetryableErrors: z.array(z.string()).optional(),\n});\n\nconst WorkflowOptionsSchema = z.object({\n name: z.string().min(1).max(128),\n persistence: PersistenceSchema,\n // SE27 — declared so a future `new WorkflowBuilder(parsed)` refactor cannot\n // silently drop them (create() passes the ORIGINAL options today, but the\n // schema is also the documentation of the shape).\n inputSchema: z.custom<ZodType>().optional(),\n outputSchema: z.custom<ZodType>().optional(),\n});\n\n/* ─── Builder ─── */\n\n/**\n * Fluent step accumulator returned by {@link Workflow.create}. Each method\n * appends a step and returns the SAME builder (mutated in place, never a copy);\n * `.commit()` freezes the list into a {@link Workflow} and mints the id its\n * single-flight lock uses.\n *\n * const wf = Workflow.create({ name: \"demo\" })\n * .then(fn(\"validate\", (i: { id: string }) => i))\n * .commit();\n *\n * You never construct one directly — `Workflow.create(options)` validates the\n * options with Zod and hands it back. Import it from `@theokit/sdk/workflow`; the\n * root `@theokit/sdk` barrel does not export it.\n *\n * How it fails:\n * - Every appending method throws a plain `Error` after `.commit()` —\n * \"Workflow already committed; create a fresh Workflow.create(...) call.\" A\n * builder is single-use.\n * - A step id is validated on the spot by `sanitizeIdentifier`\n * (`^[a-z0-9][a-z0-9-_]*$`, max 64 chars). Every rejection — length, a space,\n * `/`, `..`, a leading `-`, a NUL or control char — throws `ConfigurationError`\n * with code `invalid_identifier`, not a plain `Error` (#368 collapsed a second\n * class that the control-char branch used to raise).\n * - `sleep(durationMs)` throws a plain `Error` on a negative or non-finite value.\n * - A duplicate id anywhere in the tree, including inside `parallel`, `branch`,\n * `foreach` and `dowhile`, throws `WorkflowDuplicateStepIdError` at\n * `.commit()` — not at the `.then()` that introduced it.\n *\n * Traps:\n * - `.then(step)` is a STEP APPENDER, not a promise continuation. That makes the\n * builder a JavaScript thenable, so `await Workflow.create({ ... })` — the\n * shape `await Agent.create({ ... })` trains you into — is a mistake:\n * TypeScript rejects it (TS1320) and plain JavaScript throws an unrelated\n * `TypeError: Cannot read properties of undefined (reading 'length')` out of\n * the id validator. `Workflow.create` is synchronous.\n * - `parallel`, `branch`, `foreach`, `dowhile` and `suspend` widen the output\n * type to `unknown` (or `unknown[]`); only `.then<T>()` and `sleep` carry a\n * type through. The generics are a convenience, not a checked pipeline —\n * nothing verifies that one step's output matches the next step's input.\n * - Auto-generated ids are POSITIONAL (`parallel_2`, `foreach_5`), so inserting a\n * step earlier renames the later ones. Pass `opts.id` for any step whose id you\n * rely on in event streams or resume snapshots.\n */\nexport class WorkflowBuilder<TInput = unknown, TOutput = unknown> {\n private readonly _steps: Step[] = [];\n private _committed = false;\n\n /** @internal */\n constructor(private readonly options: WorkflowOptions) {}\n\n /** @internal — only the executor reads this. */\n get __steps(): ReadonlyArray<Step> {\n return this._steps;\n }\n\n // biome-ignore lint/suspicious/noThenProperty: D233 locks the a peer framework-style `.then(step)` builder DSL. The method is fluent, never awaited.\n then<TO = unknown>(step: Step): WorkflowBuilder<TInput, TO> {\n this.assertNotCommitted();\n validateStepId(step.id);\n this._steps.push(step);\n return this as unknown as WorkflowBuilder<TInput, TO>;\n }\n\n parallel(\n branches: ReadonlyArray<ReadonlyArray<Step>>,\n opts?: { id?: string; concurrency?: number; errorPolicy?: \"fail-fast\" | \"collect\" },\n ): WorkflowBuilder<TInput, unknown[]> {\n this.assertNotCommitted();\n const id = opts?.id ?? `parallel_${this._steps.length}`;\n validateStepId(id);\n for (const branch of branches) {\n for (const inner of branch) validateStepId(inner.id);\n }\n const step: ParallelStep = {\n kind: \"parallel\",\n id,\n branches,\n ...(opts?.concurrency !== undefined ? { concurrency: opts.concurrency } : {}),\n ...(opts?.errorPolicy !== undefined ? { errorPolicy: opts.errorPolicy } : {}),\n };\n this._steps.push(step);\n return this as unknown as WorkflowBuilder<TInput, unknown[]>;\n }\n\n branch(\n predicates: BranchStep[\"predicates\"],\n opts?: { id?: string; fallback?: ReadonlyArray<Step> },\n ): WorkflowBuilder<TInput, unknown> {\n this.assertNotCommitted();\n const id = opts?.id ?? `branch_${this._steps.length}`;\n validateStepId(id);\n const step: BranchStep = {\n kind: \"branch\",\n id,\n predicates,\n ...(opts?.fallback !== undefined ? { fallback: opts.fallback } : {}),\n };\n this._steps.push(step);\n return this as unknown as WorkflowBuilder<TInput, unknown>;\n }\n\n foreach(\n iterableFrom: string,\n step: Step,\n opts?: { id?: string; concurrency?: number },\n ): WorkflowBuilder<TInput, unknown[]> {\n this.assertNotCommitted();\n const id = opts?.id ?? `foreach_${this._steps.length}`;\n validateStepId(id);\n validateStepId(iterableFrom);\n validateStepId(step.id);\n const node: ForeachStep = {\n kind: \"foreach\",\n id,\n iterableFrom,\n step,\n ...(opts?.concurrency !== undefined ? { concurrency: opts.concurrency } : {}),\n };\n this._steps.push(node);\n return this as unknown as WorkflowBuilder<TInput, unknown[]>;\n }\n\n dowhile(\n step: Step,\n condFn: DowhileStep[\"condFn\"],\n opts?: { id?: string; maxIterations?: number },\n ): WorkflowBuilder<TInput, unknown> {\n this.assertNotCommitted();\n const id = opts?.id ?? `dowhile_${this._steps.length}`;\n validateStepId(id);\n validateStepId(step.id);\n const node: DowhileStep = {\n kind: \"dowhile\",\n id,\n step,\n condFn,\n ...(opts?.maxIterations !== undefined ? { maxIterations: opts.maxIterations } : {}),\n };\n this._steps.push(node);\n return this as unknown as WorkflowBuilder<TInput, unknown>;\n }\n\n sleep(durationMs: number, id?: string): WorkflowBuilder<TInput, TOutput> {\n this.assertNotCommitted();\n const stepId = id ?? `sleep_${this._steps.length}`;\n validateStepId(stepId);\n if (!Number.isFinite(durationMs) || durationMs < 0) {\n throw new ConfigurationError(`sleep durationMs must be finite non-negative: ${durationMs}`, {\n code: \"invalid_workflow_step\",\n });\n }\n const step: SleepStep = { kind: \"sleep\", id: stepId, durationMs };\n this._steps.push(step);\n return this;\n }\n\n suspend(opts?: { id?: string; payloadSchema?: ZodType }): WorkflowBuilder<TInput, unknown> {\n this.assertNotCommitted();\n const id = opts?.id ?? `suspend_${this._steps.length}`;\n validateStepId(id);\n const step: SuspendStep = {\n kind: \"suspend\",\n id,\n ...(opts?.payloadSchema !== undefined ? { payloadSchema: opts.payloadSchema } : {}),\n };\n this._steps.push(step);\n return this as unknown as WorkflowBuilder<TInput, unknown>;\n }\n\n commit(): Workflow<TInput, TOutput> {\n this.assertNotCommitted();\n this.validateUniqueIds();\n this._committed = true;\n // EC-5 absorbed: mint unique workflowId so single-flight lock is per-instance\n const workflowId = `wf-${mintShortId()}`;\n return new Workflow<TInput, TOutput>({ ...this.options, workflowId }, [...this._steps]);\n }\n\n private validateUniqueIds(): void {\n const seen = new Set<string>();\n walkStepsValidating(this._steps, seen);\n }\n\n private assertNotCommitted(): void {\n if (this._committed) {\n throw new ConfigurationError(\n \"Workflow already committed; create a fresh Workflow.create(...) call.\",\n { code: \"workflow_already_committed\" },\n );\n }\n }\n}\n\n/* ─── Workflow class ─── */\n\n/**\n * theokit#161 — project one step to its reflectable shape, recursing into the variants that nest.\n *\n * `parallel` branches are FLATTENED: the grouping is a scheduling detail (which steps may run\n * concurrently), not shape a reader of the workflow needs, and preserving it would put a second,\n * branch-shaped level into a type whose whole purpose is to be renderable.\n */\nfunction describeStep(step: Step): WorkflowStepDescription {\n const base = { id: step.id, kind: step.kind } as const;\n if (step.kind === \"parallel\") {\n return { ...base, steps: step.branches.flat().map(describeStep) };\n }\n if (step.kind === \"branch\") {\n const fromPredicates = step.predicates.flatMap(([, steps]) => steps.map(describeStep));\n const fromFallback = (step.fallback ?? []).map(describeStep);\n return { ...base, steps: [...fromPredicates, ...fromFallback] };\n }\n if (step.kind === \"foreach\" || step.kind === \"dowhile\") {\n return { ...base, steps: [describeStep(step.step)] };\n }\n return base;\n}\n\n/**\n * A committed, immutable workflow: a fixed list of steps you can `run`, `stream`\n * or `resume`. Built with `Workflow.create(options)` plus `.commit()`; the\n * constructor is not part of the published surface.\n *\n * import { Workflow, fn } from \"@theokit/sdk/workflow\";\n * const wf = Workflow.create({ name: \"demo\" })\n * .then(fn(\"validate\", (i: { id: string }) => i))\n * .commit();\n * const run = await wf.run({ id: \"x\" }); // run.status, run.output\n *\n * THE IMPORT SPECIFIER MATTERS. `Workflow` is emitted TWICE — once as the\n * `@theokit/sdk/workflow` sub-path entry, and once inside the shared chunk behind\n * the root `@theokit/sdk` barrel. Both declarations carry private fields, so the\n * two are DISTINCT nominal types and TypeScript refuses to pass one where the\n * other is expected:\n *\n * Types have separate declarations of a private property '_options'.\n *\n * Import `Workflow` — and everything that consumes one, such as `workflowStep`\n * and `cloneWorkflow` — from `@theokit/sdk/workflow`, and do not mix the two\n * specifiers in one program. The root barrel re-exports only `Workflow`,\n * `agentStep` and `fn`; the builder, the step helpers, the error classes and every\n * workflow type live on the sub-path. (`workflowAsTool` is exempt: it accepts any\n * `{ run }`-shaped value structurally, so either `Workflow` satisfies it.)\n *\n * How it fails: a step that throws does NOT reject `run()`. The promise resolves\n * with `status: \"failed\"` and the cause on `run.error`; `\"suspended\"` and\n * `\"cancelled\"` are the other non-`\"completed\"` terminals, and an `outputSchema`\n * mismatch also lands as `\"failed\"` (`WorkflowOutputError`) rather than a throw.\n * What DOES throw out of `run()` is pre-flight: `WorkflowAlreadyRunningError` when\n * you pin `WorkflowRunOptions.runId` to one still in flight. `Workflow.resume`\n * throws `WorkflowSnapshotNotFoundError` for an unknown `runId`.\n *\n * Traps:\n * - Without an explicit `runId` each call mints its own, so concurrent runs of\n * the same committed workflow do NOT collide — the single-flight lock only\n * bites when you pin the id yourself.\n * - `stream()` reports progress; its `result` promise is the AUTHORITATIVE\n * outcome. Not every terminal emits a closing event, so a consumer that only\n * drains events can miss a failure. Always `await result`.\n * - `run()` and `stream()` load the executor by dynamic `import()`, so the first\n * call pays a module load and cannot be made synchronous.\n *\n * @public\n */\nexport class Workflow<TInput = unknown, TOutput = unknown> {\n /** @internal */\n constructor(\n private readonly _options: WorkflowOptions,\n private readonly _steps: ReadonlyArray<Step>,\n ) {}\n\n /** @internal — only the executor reads these. */\n get __options(): WorkflowOptions {\n return this._options;\n }\n /** @internal */\n get __steps(): ReadonlyArray<Step> {\n return this._steps;\n }\n\n /**\n * Construct a workflow builder. Validate options via Zod and return a\n * `WorkflowBuilder` for fluent chaining. Call `.commit()` to obtain the\n * immutable `Workflow`.\n */\n static create<TI = unknown, TO = unknown>(options: WorkflowOptions): WorkflowBuilder<TI, TO> {\n WorkflowOptionsSchema.parse(options);\n return new WorkflowBuilder<TI, TO>(options);\n }\n\n /**\n * theokit#161 — describe this workflow's shape, for a reflection surface.\n *\n * Returns `{ name, steps }`, each step carrying its `id` and `kind`, recursing into `parallel`,\n * `branch`, `foreach` and `dowhile`. Every executable a step holds — predicates, conditions,\n * agents, prompt templates — is omitted: it cannot cross a process boundary and says nothing about\n * shape.\n *\n * There is deliberately no `Workflow.list()`. A workflow is a value the caller constructs and\n * holds, so the caller already knows which ones exist; a registry would add process-global state\n * nothing releases in order to re-answer a question the host can answer itself. A reflection\n * endpoint maps over its own workflows and calls this.\n *\n * @public\n */\n describe(): WorkflowDescription {\n return {\n name: this._options.name,\n steps: this._steps.map(describeStep),\n };\n }\n\n /**\n * Run this workflow with the given input. Returns a populated\n * `WorkflowRun`. Errors inside a step DO NOT throw — they propagate via\n * `run.status === \"failed\"`.\n */\n async run(input: TInput, opts?: WorkflowRunOptions): Promise<WorkflowRun<TOutput>> {\n // Lazy import to keep the public façade lean.\n const { executeWorkflow } = await import(\"./internal/workflow/executor.js\");\n const result = await executeWorkflow<TInput, TOutput>(this._options, this._steps, input, opts);\n // T3.4: opt-in Task wrapping (ADRs D363, D374). Workflows are\n // observable via Task.list/get/subscribe; the underlying run is\n // already terminal here (executor returned), so the Task just\n // records the outcome for inspection.\n if (opts?.task !== undefined) {\n const { submit: taskSubmit } = await import(\"./internal/task/registry.js\");\n const taskOpts = opts.task === true ? {} : opts.task;\n const id = taskOpts.id ?? `wf-${result.id}`;\n await taskSubmit({\n kind: \"workflow\",\n work: async (ctx) => {\n ctx.emit({ status: result.status, runId: result.id });\n return { status: result.status, runId: result.id, output: result.output };\n },\n id,\n meta: {\n workflowName: this._options.name,\n runId: result.id,\n status: result.status,\n ...(taskOpts.meta ?? {}),\n },\n allowReservedPrefix: true,\n });\n }\n return result;\n }\n\n /**\n * SE28 — run the workflow and STREAM step-level events as they happen. Returns\n * an async iterator of {@link WorkflowEvent}s (`step_started` / `step_completed`\n * / `step_failed` / `workflow_suspended` / `workflow_completed`, top-level\n * steps) plus a `result` promise resolving to the same terminal\n * {@link WorkflowRun} `run()` returns. Iterate for progress; await `result` for\n * the outcome. The stream ends when the run terminates.\n *\n * `result` is the AUTHORITATIVE terminal status. Not every terminal state has a\n * closing event: a step failure emits `step_failed`, but an `outputSchema`\n * rejection (SE27) or an abort ends the stream WITHOUT `workflow_completed` —\n * always `await result` to read the final `status`. Consuming order is free:\n * awaiting `result` without draining, or draining without awaiting `result`,\n * both work (breaking out of `for await` stops the buffering early).\n */\n stream(input: TInput, opts?: WorkflowRunOptions): WorkflowStream<TOutput> {\n const queue = createEventStream();\n const result = (async (): Promise<WorkflowRun<TOutput>> => {\n const { executeWorkflow } = await import(\"./internal/workflow/executor.js\");\n try {\n return await executeWorkflow<TInput, TOutput>(this._options, this._steps, input, {\n ...opts,\n onStepEvent: (event: WorkflowEvent) => queue.push(event),\n } as WorkflowRunOptions);\n } finally {\n queue.end(); // authoritative terminal is `result`; close the stream\n }\n })();\n return Object.assign(queue, { result });\n }\n\n /**\n * Resume a suspended workflow from its snapshot. Throws\n * `WorkflowSnapshotNotFoundError` if `runId` is unknown.\n */\n static async resume<TO = unknown>(opts: WorkflowResumeOptions): Promise<WorkflowRun<TO>> {\n const { resumeWorkflow } = await import(\"./internal/workflow/executor.js\");\n return resumeWorkflow<TO>(opts);\n }\n}\n\n/* ─── Helper factory functions ─── */\n\n/**\n * Build a `FnStep`. `id` must match `^[a-z0-9][a-z0-9_-]*$`.\n */\nexport function fn<I = unknown, O = unknown>(\n id: string,\n step: (input: I, ctx: StepContext) => Promise<O> | O,\n opts?: { inputSchema?: ZodType; outputSchema?: ZodType; retry?: RetryPolicy },\n): FnStep {\n validateStepId(id);\n if (opts?.retry !== undefined) RetryPolicySchema.parse(opts.retry);\n return {\n kind: \"fn\",\n id,\n fn: step as FnStep[\"fn\"],\n ...(opts?.inputSchema !== undefined ? { inputSchema: opts.inputSchema } : {}),\n ...(opts?.outputSchema !== undefined ? { outputSchema: opts.outputSchema } : {}),\n ...(opts?.retry !== undefined ? { retry: opts.retry } : {}),\n };\n}\n\n/**\n * Build an `AgentStep`. The `promptTemplate` can be a static string or a\n * function that receives the input and returns the prompt.\n */\nexport function agentStep(\n id: string,\n agent: SDKAgent,\n promptTemplate: string | ((input: unknown) => string),\n opts?: { retry?: RetryPolicy; origin?: MessageOrigin },\n): AgentStep {\n validateStepId(id);\n if (opts?.retry !== undefined) RetryPolicySchema.parse(opts.retry);\n return {\n kind: \"agent\",\n id,\n agent,\n promptTemplate,\n ...(opts?.retry !== undefined ? { retry: opts.retry } : {}),\n // SE3 — carry the turn's provenance down to `agent.send()` (metadata-only).\n ...(opts?.origin !== undefined ? { origin: opts.origin } : {}),\n };\n}\n\n/**\n * SE30 — use a committed {@link Workflow} as a step inside another workflow.\n * Wraps the child as an `FnStep` (opaque — the child runs in its OWN executor\n * with its own id-space, so nested step-ids never collide with the parent's).\n * The child's output becomes the step output. A non-`completed` child fails the\n * parent step with a typed {@link WorkflowNestedError}: nested `suspended` is NOT\n * resumable in v1 (resume continues AFTER the step — the child would be skipped;\n * use a top-level suspend). See ADR 0010.\n *\n * @public\n */\nexport function workflowStep<TI = unknown, TO = unknown>(\n child: Workflow<TI, TO>,\n opts?: { id?: string },\n): FnStep {\n const id = opts?.id ?? `workflow_${child.__options.name}`;\n validateStepId(id);\n return {\n kind: \"fn\",\n id,\n fn: async (input: unknown, ctx: StepContext): Promise<unknown> => {\n const run = await child.run(input as TI, { signal: ctx.signal });\n if (run.status === \"completed\") return run.output;\n throw new WorkflowNestedError(id, child.__options.name, run.status, run.error);\n },\n };\n}\n\n/**\n * SE30 — clone a committed workflow under a new id/name. The clone runs\n * independently (its own single-flight lock + observability identity) with the\n * same committed steps. Mirrors a peer framework's `cloneWorkflow`.\n *\n * @public\n */\nexport function cloneWorkflow<TI = unknown, TO = unknown>(\n wf: Workflow<TI, TO>,\n opts: { id: string },\n): Workflow<TI, TO> {\n return new Workflow<TI, TO>(\n { ...wf.__options, name: opts.id, workflowId: `wf-${mintShortId()}` },\n [...wf.__steps],\n );\n}\n\n/* ─── Test seam re-export ─── */\n\nexport { __resetSnapshotStoresForTests } from \"./internal/workflow/snapshot-store.js\";\n\n/* ─── Re-exports for ergonomics (errors + all public types). After the\n sub-path extraction `@theokit/sdk/workflow` is the single import site,\n so type aliases must surface here (previously they reached consumers\n via `types/index.ts:25 export type * from \"./workflow.js\"`, which the\n extraction removes). ─── */\n\nexport type * from \"./types/workflow.js\";\n// SE19 — exposing a Workflow AS an agent tool answers a different question from building one,\n// and lives in its own module. Re-exported so `@theokit/sdk/workflow` is unchanged.\nexport { type WorkflowAsToolSpec, WorkflowToolError, workflowAsTool } from \"./workflow-as-tool.js\";\nexport {\n WorkflowAlreadyRunningError,\n WorkflowCompensateNotImplementedError,\n WorkflowDuplicateStepIdError,\n WorkflowInputError,\n WorkflowMaxIterationsExceededError,\n WorkflowNestedError,\n WorkflowNotSerializableError,\n WorkflowOutputError,\n WorkflowParallelError,\n WorkflowResumeStepNotFoundError,\n WorkflowSnapshotNotFoundError,\n WorkflowStateError,\n} from \"./workflow-errors.js\";\n\n/* ─── Internal helpers ─── */\n\nfunction validateStepId(id: string): void {\n // Reuses D81 grammar: ^[a-z0-9][a-z0-9_-]*$\n sanitizeIdentifier(id, { maxLen: 64 });\n}\n\nfunction mintShortId(): string {\n return globalThis.crypto.randomUUID().replace(/-/g, \"\").slice(0, 8);\n}\n\nfunction nestedStepsOf(s: Step): ReadonlyArray<ReadonlyArray<Step>> {\n if (s.kind === \"parallel\") return s.branches;\n if (s.kind === \"branch\") {\n const groups = s.predicates.map(([, branch]) => branch);\n return s.fallback !== undefined ? [...groups, s.fallback] : groups;\n }\n if (s.kind === \"foreach\" || s.kind === \"dowhile\") return [[s.step]];\n return [];\n}\n\nfunction walkStepsValidating(steps: ReadonlyArray<Step>, seen: Set<string>): void {\n for (const s of steps) {\n if (seen.has(s.id)) throw new WorkflowDuplicateStepIdError(s.id);\n seen.add(s.id);\n for (const nested of nestedStepsOf(s)) {\n walkStepsValidating(nested, seen);\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/internal/workflow/event-stream.ts","../src/workflow-as-tool.ts","../src/workflow.ts"],"names":["TheokitAgentError","toJsonSchema","z","PersistenceSchema","ConfigurationError","WorkflowNestedError","sanitizeIdentifier","WorkflowDuplicateStepIdError"],"mappings":";;;;;;;;;;AAgBO,SAAS,iBAAA,GAAyC;AACvD,EAAA,MAAM,SAA0B,EAAC;AACjC,EAAA,MAAM,UAA6D,EAAC;AACpE,EAAA,IAAI,KAAA,GAAQ,KAAA;AAEZ,EAAA,MAAM,MAAA,GAA8B;AAAA,IAClC,KAAK,KAAA,EAA4B;AAC/B,MAAA,IAAI,KAAA,EAAO;AACX,MAAA,MAAM,MAAA,GAAS,QAAQ,KAAA,EAAM;AAC7B,MAAA,IAAI,MAAA,KAAW,QAAW,MAAA,CAAO,EAAE,OAAO,KAAA,EAAO,IAAA,EAAM,OAAO,CAAA;AAAA,WACzD,MAAA,CAAO,KAAK,KAAK,CAAA;AAAA,IACxB,CAAA;AAAA,IACA,GAAA,GAAY;AACV,MAAA,IAAI,KAA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4B,IAAA,EAAyB;AAChF,EAAA,KAAA,MAAW,KAAK,KAAA,EAAO;AACrB,IAAA,IAAI,IAAA,CAAK,IAAI,CAAA,CAAE,EAAE,GAAG,MAAM,IAAIC,8CAAA,CAA6B,CAAA,CAAE,EAAE,CAAA;AAC/D,IAAA,IAAA,CAAK,GAAA,CAAI,EAAE,EAAE,CAAA;AACb,IAAA,KAAA,MAAW,MAAA,IAAU,aAAA,CAAc,CAAC,CAAA,EAAG;AACrC,MAAA,mBAAA,CAAoB,QAAQ,IAAI,CAAA;AAAA,IAClC;AAAA,EACF;AACF","file":"chunk-MPQJE3G4.cjs","sourcesContent":["/**\n * SE28 — a minimal pushable async iterator for `Workflow.stream()`. The executor\n * pushes {@link WorkflowEvent}s as steps run; the consumer drains them via\n * `for await`. Buffers events emitted before the consumer is ready; `end()`\n * closes the iterator so a pending/next `next()` resolves `done: true`.\n *\n * @internal\n */\n\nimport type { WorkflowEvent } from \"../../types/workflow.js\";\n\nexport interface PushableEventStream extends AsyncIterableIterator<WorkflowEvent> {\n push(event: WorkflowEvent): void;\n end(): void;\n}\n\nexport function createEventStream(): PushableEventStream {\n const buffer: WorkflowEvent[] = [];\n const waiters: Array<(r: IteratorResult<WorkflowEvent>) => void> = [];\n let ended = false;\n\n const stream: PushableEventStream = {\n push(event: WorkflowEvent): void {\n if (ended) return;\n const waiter = waiters.shift();\n if (waiter !== undefined) waiter({ value: event, done: false });\n else buffer.push(event);\n },\n end(): void {\n if (ended) return;\n ended = true;\n for (const waiter of waiters.splice(0)) waiter({ value: undefined, done: true });\n },\n next(): Promise<IteratorResult<WorkflowEvent>> {\n const buffered = buffer.shift();\n if (buffered !== undefined) return Promise.resolve({ value: buffered, done: false });\n if (ended) return Promise.resolve({ value: undefined, done: true });\n return new Promise((resolve) => waiters.push(resolve));\n },\n // `for await` calls return() on break/throw — close early so events stop\n // buffering in memory for a consumer that stopped iterating.\n return(): Promise<IteratorResult<WorkflowEvent>> {\n stream.end();\n buffer.length = 0;\n return Promise.resolve({ value: undefined, done: true });\n },\n [Symbol.asyncIterator](): PushableEventStream {\n return stream;\n },\n };\n return stream;\n}\n","/**\n * SE19 — expose a {@link Workflow} as an agent tool.\n *\n * Split out of `workflow.ts` because it answers a different question: that file is about BUILDING a\n * workflow; this one is about handing a built workflow to an agent as a callable. The file-size gate\n * is what surfaced the seam, and the seam is real — nothing here runs while steps are composed.\n *\n * Re-exported from `workflow.ts`, so `@theokit/sdk/workflow` is unchanged.\n *\n * NOTE ON THE MODULE TAG: this header deliberately carries no internal-visibility tag, and does not\n * even name one — TypeScript attaches a file-leading docblock to the FIRST declaration below it, and\n * `stripInternal: true` (tsconfig.base) then deletes that declaration from the emitted `.d.ts`.\n * `tsc --noEmit` stays clean and the declaration rollup fails with `\"X\" is not exported by \"...\"`.\n * Measured twice on this file on 2026-09-01: once with the tag, and again when the comment\n * EXPLAINING the trap quoted the tag verbatim and re-armed it.\n */\n\nimport type { ZodType, z } from \"zod\";\n\nimport { TheokitAgentError } from \"./errors.js\";\nimport { toJsonSchema } from \"./internal/zod-to-json-schema.js\";\nimport type { CustomTool } from \"./types/agent.js\";\n// `WorkflowRun` comes from the TYPE module, never from `workflow.ts`. Importing it from there\n// created a file cycle — workflow.ts re-exports this module — which madge caught with\n// tsPreCompilationDeps on, since a type-only import is still an edge. `workflowAsTool` never needed\n// the `Workflow` class anyway: its parameter is structural, `{ run: (input) => Promise<...> }`.\nimport type { WorkflowRun } from \"./types/workflow.js\";\n\n/* ─── SE19 — workflowAsTool (expose a Workflow as an agent tool) ─── */\n\n/**\n * Raised by a {@link workflowAsTool} tool when the wrapped workflow run does not\n * reach `status: \"completed\"` (a step failed, the run was cancelled/suspended).\n * The dispatch converts it to a `tool_result(isError)`.\n *\n * @public\n */\nexport class WorkflowToolError extends TheokitAgentError {\n override readonly name = \"WorkflowToolError\";\n override readonly code = \"workflow_tool_failed\" as const;\n constructor(\n readonly toolName: string,\n readonly workflowStatus: string,\n readonly workflowError?: { name: string; message: string },\n ) {\n // Not retryable at this level: the workflow already ran and reported its own status; whether the\n // underlying failure is transient is a question for the workflow's retry policy, not the tool wrapper.\n super(\n `workflowAsTool(\"${toolName}\"): workflow ${workflowStatus}${\n workflowError ? `: ${workflowError.message}` : \"\"\n }`,\n { code: \"workflow_tool_failed\", isRetryable: false },\n );\n }\n}\n\n/** Spec for {@link workflowAsTool}. `inputSchema` is the workflow's input shape (Zod). */\nexport interface WorkflowAsToolSpec<T extends ZodType> {\n /** Tool name surfaced to the LLM. Same constraints as a `CustomTool.name`. */\n name: string;\n /** Description surfaced to the LLM — when the agent should trigger the workflow. */\n description: string;\n /** Zod schema for the workflow's input (a `Workflow` carries no top-level schema). */\n inputSchema: T;\n}\n\n/**\n * SE19 — expose a {@link Workflow} as an agent {@link CustomTool}, completing the\n * \"X as tools\" trio (tools; agents-as-tools via `defineSubAgent`; workflows-as-tools).\n * The handler validates the model's args against `spec.inputSchema`, runs the\n * workflow, and returns its output (a string as-is, else JSON). A run that does not\n * reach `status: \"completed\"` raises a typed {@link WorkflowToolError} (workflow\n * step errors do NOT throw — they surface via `run.status === \"failed\"`).\n *\n * Accepts any `{ run }`-shaped workflow (structural), so it never imports the\n * `Workflow` class directly.\n *\n * @public\n */\nexport function workflowAsTool<T extends ZodType, TOutput = unknown>(\n workflow: { run: (input: z.infer<T>) => Promise<WorkflowRun<TOutput>> },\n spec: WorkflowAsToolSpec<T>,\n): CustomTool {\n const inputSchema = toJsonSchema(spec.inputSchema, { unrepresentable: \"any\" });\n return {\n name: spec.name,\n description: spec.description,\n inputSchema,\n handler: async (rawInput: Record<string, unknown>): Promise<string> => {\n const parsed = spec.inputSchema.parse(rawInput) as z.infer<T>;\n const run = await workflow.run(parsed);\n if (run.status !== \"completed\") {\n throw new WorkflowToolError(spec.name, run.status, run.error);\n }\n const output = run.output;\n return typeof output === \"string\" ? output : JSON.stringify(output ?? null);\n },\n };\n}\n","/**\n * Public `Workflow` class — declarative multi-step orchestration over\n * `Agent.send`, `Handoff`, `Agent.batch` and friends (Adoption Roadmap #5;\n * ADRs D230-D248).\n *\n * Usage:\n *\n * import { Agent } from \"@theokit/sdk\";\n * import { Workflow, fn, agentStep } from \"@theokit/sdk/workflow\";\n *\n * const classifier = await Agent.create({ ... });\n * const wf = Workflow.create({ name: \"demo\" })\n * .then(fn(\"validate\", (input: { id: string }) => {\n * if (!input.id) throw new Error(\"missing id\");\n * return input;\n * }))\n * .then(agentStep(\"classify\", classifier, (i) => `Classify: ${JSON.stringify(i)}`))\n * .commit();\n *\n * const run = await wf.run({ id: \"x\" });\n * console.log(run.status, run.output);\n *\n * @public\n */\n\nimport type { ZodType } from \"zod\";\nimport { z } from \"zod\";\nimport { ConfigurationError } from \"./errors.js\";\nimport { PersistenceSchema } from \"./internal/persistence/persistence-schema.js\";\nimport { sanitizeIdentifier } from \"./internal/security/path-guard.js\";\nimport { createEventStream } from \"./internal/workflow/event-stream.js\";\nimport type { SDKAgent } from \"./types/agent.js\";\nimport type { MessageOrigin } from \"./types/run.js\";\nimport type {\n AgentStep,\n BranchStep,\n DowhileStep,\n FnStep,\n ForeachStep,\n ParallelStep,\n RetryPolicy,\n SleepStep,\n Step,\n StepContext,\n SuspendStep,\n WorkflowDescription,\n WorkflowEvent,\n WorkflowOptions,\n WorkflowResumeOptions,\n WorkflowRun,\n WorkflowRunOptions,\n WorkflowStepDescription,\n WorkflowStream,\n} from \"./types/workflow.js\";\nimport { WorkflowDuplicateStepIdError, WorkflowNestedError } from \"./workflow-errors.js\";\n\n/* ─── Zod validation schemas ─── */\n\nconst RetryPolicySchema = z.object({\n // EC-3 absorbed: maxAttempts MUST be a finite int in [1, 20].\n maxAttempts: z\n .number()\n .int(\"retry.maxAttempts must be integer\")\n .min(1, \"retry.maxAttempts must be >= 1\")\n .max(20, \"retry.maxAttempts must be <= 20\"),\n initialBackoffMs: z.number().int().min(0).optional(),\n backoffCoefficient: z.number().min(1).optional(),\n maximumBackoffMs: z.number().int().min(0).optional(),\n nonRetryableErrors: z.array(z.string()).optional(),\n});\n\nconst WorkflowOptionsSchema = z.object({\n name: z.string().min(1).max(128),\n persistence: PersistenceSchema,\n // SE27 — declared so a future `new WorkflowBuilder(parsed)` refactor cannot\n // silently drop them (create() passes the ORIGINAL options today, but the\n // schema is also the documentation of the shape).\n inputSchema: z.custom<ZodType>().optional(),\n outputSchema: z.custom<ZodType>().optional(),\n});\n\n/* ─── Builder ─── */\n\n/**\n * Fluent step accumulator returned by {@link Workflow.create}. Each method\n * appends a step and returns the SAME builder (mutated in place, never a copy);\n * `.commit()` freezes the list into a {@link Workflow} and mints the id its\n * single-flight lock uses.\n *\n * const wf = Workflow.create({ name: \"demo\" })\n * .then(fn(\"validate\", (i: { id: string }) => i))\n * .commit();\n *\n * You never construct one directly — `Workflow.create(options)` validates the\n * options with Zod and hands it back. Import it from `@theokit/sdk/workflow`; the\n * root `@theokit/sdk` barrel does not export it.\n *\n * How it fails:\n * - Every appending method throws a plain `Error` after `.commit()` —\n * \"Workflow already committed; create a fresh Workflow.create(...) call.\" A\n * builder is single-use.\n * - A step id is validated on the spot by `sanitizeIdentifier`\n * (`^[a-z0-9][a-z0-9-_]*$`, max 64 chars). Every rejection — length, a space,\n * `/`, `..`, a leading `-`, a NUL or control char — throws `ConfigurationError`\n * with code `invalid_identifier`, not a plain `Error` (#368 collapsed a second\n * class that the control-char branch used to raise).\n * - `sleep(durationMs)` throws a plain `Error` on a negative or non-finite value.\n * - A duplicate id anywhere in the tree, including inside `parallel`, `branch`,\n * `foreach` and `dowhile`, throws `WorkflowDuplicateStepIdError` at\n * `.commit()` — not at the `.then()` that introduced it.\n *\n * Traps:\n * - `.then(step)` is a STEP APPENDER, not a promise continuation. That makes the\n * builder a JavaScript thenable, so `await Workflow.create({ ... })` — the\n * shape `await Agent.create({ ... })` trains you into — is a mistake:\n * TypeScript rejects it (TS1320) and plain JavaScript throws an unrelated\n * `TypeError: Cannot read properties of undefined (reading 'length')` out of\n * the id validator. `Workflow.create` is synchronous.\n * - `parallel`, `branch`, `foreach`, `dowhile` and `suspend` widen the output\n * type to `unknown` (or `unknown[]`); only `.then<T>()` and `sleep` carry a\n * type through. The generics are a convenience, not a checked pipeline —\n * nothing verifies that one step's output matches the next step's input.\n * - Auto-generated ids are POSITIONAL (`parallel_2`, `foreach_5`), so inserting a\n * step earlier renames the later ones. Pass `opts.id` for any step whose id you\n * rely on in event streams or resume snapshots.\n */\nexport class WorkflowBuilder<TInput = unknown, TOutput = unknown> {\n private readonly _steps: Step[] = [];\n private _committed = false;\n\n /** @internal */\n constructor(private readonly options: WorkflowOptions) {}\n\n /** @internal — only the executor reads this. */\n get __steps(): ReadonlyArray<Step> {\n return this._steps;\n }\n\n // biome-ignore lint/suspicious/noThenProperty: D233 locks the a peer framework-style `.then(step)` builder DSL. The method is fluent, never awaited.\n then<TO = unknown>(step: Step): WorkflowBuilder<TInput, TO> {\n this.assertNotCommitted();\n validateStepId(step.id);\n this._steps.push(step);\n return this as unknown as WorkflowBuilder<TInput, TO>;\n }\n\n parallel(\n branches: ReadonlyArray<ReadonlyArray<Step>>,\n opts?: { id?: string; concurrency?: number; errorPolicy?: \"fail-fast\" | \"collect\" },\n ): WorkflowBuilder<TInput, unknown[]> {\n this.assertNotCommitted();\n const id = opts?.id ?? `parallel_${this._steps.length}`;\n validateStepId(id);\n for (const branch of branches) {\n for (const inner of branch) validateStepId(inner.id);\n }\n const step: ParallelStep = {\n kind: \"parallel\",\n id,\n branches,\n ...(opts?.concurrency !== undefined ? { concurrency: opts.concurrency } : {}),\n ...(opts?.errorPolicy !== undefined ? { errorPolicy: opts.errorPolicy } : {}),\n };\n this._steps.push(step);\n return this as unknown as WorkflowBuilder<TInput, unknown[]>;\n }\n\n branch(\n predicates: BranchStep[\"predicates\"],\n opts?: { id?: string; fallback?: ReadonlyArray<Step> },\n ): WorkflowBuilder<TInput, unknown> {\n this.assertNotCommitted();\n const id = opts?.id ?? `branch_${this._steps.length}`;\n validateStepId(id);\n const step: BranchStep = {\n kind: \"branch\",\n id,\n predicates,\n ...(opts?.fallback !== undefined ? { fallback: opts.fallback } : {}),\n };\n this._steps.push(step);\n return this as unknown as WorkflowBuilder<TInput, unknown>;\n }\n\n foreach(\n iterableFrom: string,\n step: Step,\n opts?: { id?: string; concurrency?: number },\n ): WorkflowBuilder<TInput, unknown[]> {\n this.assertNotCommitted();\n const id = opts?.id ?? `foreach_${this._steps.length}`;\n validateStepId(id);\n validateStepId(iterableFrom);\n validateStepId(step.id);\n const node: ForeachStep = {\n kind: \"foreach\",\n id,\n iterableFrom,\n step,\n ...(opts?.concurrency !== undefined ? { concurrency: opts.concurrency } : {}),\n };\n this._steps.push(node);\n return this as unknown as WorkflowBuilder<TInput, unknown[]>;\n }\n\n dowhile(\n step: Step,\n condFn: DowhileStep[\"condFn\"],\n opts?: { id?: string; maxIterations?: number },\n ): WorkflowBuilder<TInput, unknown> {\n this.assertNotCommitted();\n const id = opts?.id ?? `dowhile_${this._steps.length}`;\n validateStepId(id);\n validateStepId(step.id);\n const node: DowhileStep = {\n kind: \"dowhile\",\n id,\n step,\n condFn,\n ...(opts?.maxIterations !== undefined ? { maxIterations: opts.maxIterations } : {}),\n };\n this._steps.push(node);\n return this as unknown as WorkflowBuilder<TInput, unknown>;\n }\n\n sleep(durationMs: number, id?: string): WorkflowBuilder<TInput, TOutput> {\n this.assertNotCommitted();\n const stepId = id ?? `sleep_${this._steps.length}`;\n validateStepId(stepId);\n if (!Number.isFinite(durationMs) || durationMs < 0) {\n throw new ConfigurationError(`sleep durationMs must be finite non-negative: ${durationMs}`, {\n code: \"invalid_workflow_step\",\n });\n }\n const step: SleepStep = { kind: \"sleep\", id: stepId, durationMs };\n this._steps.push(step);\n return this;\n }\n\n suspend(opts?: { id?: string; payloadSchema?: ZodType }): WorkflowBuilder<TInput, unknown> {\n this.assertNotCommitted();\n const id = opts?.id ?? `suspend_${this._steps.length}`;\n validateStepId(id);\n const step: SuspendStep = {\n kind: \"suspend\",\n id,\n ...(opts?.payloadSchema !== undefined ? { payloadSchema: opts.payloadSchema } : {}),\n };\n this._steps.push(step);\n return this as unknown as WorkflowBuilder<TInput, unknown>;\n }\n\n commit(): Workflow<TInput, TOutput> {\n this.assertNotCommitted();\n this.validateUniqueIds();\n this._committed = true;\n // EC-5 absorbed: mint unique workflowId so single-flight lock is per-instance\n const workflowId = `wf-${mintShortId()}`;\n return new Workflow<TInput, TOutput>({ ...this.options, workflowId }, [...this._steps]);\n }\n\n private validateUniqueIds(): void {\n const seen = new Set<string>();\n walkStepsValidating(this._steps, seen);\n }\n\n private assertNotCommitted(): void {\n if (this._committed) {\n throw new ConfigurationError(\n \"Workflow already committed; create a fresh Workflow.create(...) call.\",\n { code: \"workflow_already_committed\" },\n );\n }\n }\n}\n\n/* ─── Workflow class ─── */\n\n/**\n * theokit#161 — project one step to its reflectable shape, recursing into the variants that nest.\n *\n * `parallel` branches are FLATTENED: the grouping is a scheduling detail (which steps may run\n * concurrently), not shape a reader of the workflow needs, and preserving it would put a second,\n * branch-shaped level into a type whose whole purpose is to be renderable.\n */\nfunction describeStep(step: Step): WorkflowStepDescription {\n const base = { id: step.id, kind: step.kind } as const;\n if (step.kind === \"parallel\") {\n return { ...base, steps: step.branches.flat().map(describeStep) };\n }\n if (step.kind === \"branch\") {\n const fromPredicates = step.predicates.flatMap(([, steps]) => steps.map(describeStep));\n const fromFallback = (step.fallback ?? []).map(describeStep);\n return { ...base, steps: [...fromPredicates, ...fromFallback] };\n }\n if (step.kind === \"foreach\" || step.kind === \"dowhile\") {\n return { ...base, steps: [describeStep(step.step)] };\n }\n return base;\n}\n\n/**\n * A committed, immutable workflow: a fixed list of steps you can `run`, `stream`\n * or `resume`. Built with `Workflow.create(options)` plus `.commit()`; the\n * constructor is not part of the published surface.\n *\n * import { Workflow, fn } from \"@theokit/sdk/workflow\";\n * const wf = Workflow.create({ name: \"demo\" })\n * .then(fn(\"validate\", (i: { id: string }) => i))\n * .commit();\n * const run = await wf.run({ id: \"x\" }); // run.status, run.output\n *\n * THE IMPORT SPECIFIER MATTERS. `Workflow` is emitted TWICE — once as the\n * `@theokit/sdk/workflow` sub-path entry, and once inside the shared chunk behind\n * the root `@theokit/sdk` barrel. Both declarations carry private fields, so the\n * two are DISTINCT nominal types and TypeScript refuses to pass one where the\n * other is expected:\n *\n * Types have separate declarations of a private property '_options'.\n *\n * Import `Workflow` — and everything that consumes one, such as `workflowStep`\n * and `cloneWorkflow` — from `@theokit/sdk/workflow`, and do not mix the two\n * specifiers in one program. The root barrel re-exports only `Workflow`,\n * `agentStep` and `fn`; the builder, the step helpers, the error classes and every\n * workflow type live on the sub-path. (`workflowAsTool` is exempt: it accepts any\n * `{ run }`-shaped value structurally, so either `Workflow` satisfies it.)\n *\n * How it fails: a step that throws does NOT reject `run()`. The promise resolves\n * with `status: \"failed\"` and the cause on `run.error`; `\"suspended\"` and\n * `\"cancelled\"` are the other non-`\"completed\"` terminals, and an `outputSchema`\n * mismatch also lands as `\"failed\"` (`WorkflowOutputError`) rather than a throw.\n * What DOES throw out of `run()` is pre-flight: `WorkflowAlreadyRunningError` when\n * you pin `WorkflowRunOptions.runId` to one still in flight. `Workflow.resume`\n * throws `WorkflowSnapshotNotFoundError` for an unknown `runId`.\n *\n * Traps:\n * - Without an explicit `runId` each call mints its own, so concurrent runs of\n * the same committed workflow do NOT collide — the single-flight lock only\n * bites when you pin the id yourself.\n * - `stream()` reports progress; its `result` promise is the AUTHORITATIVE\n * outcome. Not every terminal emits a closing event, so a consumer that only\n * drains events can miss a failure. Always `await result`.\n * - `run()` and `stream()` load the executor by dynamic `import()`, so the first\n * call pays a module load and cannot be made synchronous.\n *\n * @public\n */\nexport class Workflow<TInput = unknown, TOutput = unknown> {\n /** @internal */\n constructor(\n private readonly _options: WorkflowOptions,\n private readonly _steps: ReadonlyArray<Step>,\n ) {}\n\n /** @internal — only the executor reads these. */\n get __options(): WorkflowOptions {\n return this._options;\n }\n /** @internal */\n get __steps(): ReadonlyArray<Step> {\n return this._steps;\n }\n\n /**\n * Construct a workflow builder. Validate options via Zod and return a\n * `WorkflowBuilder` for fluent chaining. Call `.commit()` to obtain the\n * immutable `Workflow`.\n */\n static create<TI = unknown, TO = unknown>(options: WorkflowOptions): WorkflowBuilder<TI, TO> {\n WorkflowOptionsSchema.parse(options);\n return new WorkflowBuilder<TI, TO>(options);\n }\n\n /**\n * theokit#161 — describe this workflow's shape, for a reflection surface.\n *\n * Returns `{ name, steps }`, each step carrying its `id` and `kind`, recursing into `parallel`,\n * `branch`, `foreach` and `dowhile`. Every executable a step holds — predicates, conditions,\n * agents, prompt templates — is omitted: it cannot cross a process boundary and says nothing about\n * shape.\n *\n * There is deliberately no `Workflow.list()`. A workflow is a value the caller constructs and\n * holds, so the caller already knows which ones exist; a registry would add process-global state\n * nothing releases in order to re-answer a question the host can answer itself. A reflection\n * endpoint maps over its own workflows and calls this.\n *\n * @public\n */\n describe(): WorkflowDescription {\n return {\n name: this._options.name,\n steps: this._steps.map(describeStep),\n };\n }\n\n /**\n * Run this workflow with the given input. Returns a populated\n * `WorkflowRun`. Errors inside a step DO NOT throw — they propagate via\n * `run.status === \"failed\"`.\n */\n async run(input: TInput, opts?: WorkflowRunOptions): Promise<WorkflowRun<TOutput>> {\n // Lazy import to keep the public façade lean.\n const { executeWorkflow } = await import(\"./internal/workflow/executor.js\");\n const result = await executeWorkflow<TInput, TOutput>(this._options, this._steps, input, opts);\n // T3.4: opt-in Task wrapping (ADRs D363, D374). Workflows are\n // observable via Task.list/get/subscribe; the underlying run is\n // already terminal here (executor returned), so the Task just\n // records the outcome for inspection.\n if (opts?.task !== undefined) {\n const { submit: taskSubmit } = await import(\"./internal/task/registry.js\");\n const taskOpts = opts.task === true ? {} : opts.task;\n const id = taskOpts.id ?? `wf-${result.id}`;\n await taskSubmit({\n kind: \"workflow\",\n work: async (ctx) => {\n ctx.emit({ status: result.status, runId: result.id });\n return { status: result.status, runId: result.id, output: result.output };\n },\n id,\n meta: {\n workflowName: this._options.name,\n runId: result.id,\n status: result.status,\n ...(taskOpts.meta ?? {}),\n },\n allowReservedPrefix: true,\n });\n }\n return result;\n }\n\n /**\n * SE28 — run the workflow and STREAM step-level events as they happen. Returns\n * an async iterator of {@link WorkflowEvent}s (`step_started` / `step_completed`\n * / `step_failed` / `workflow_suspended` / `workflow_completed`, top-level\n * steps) plus a `result` promise resolving to the same terminal\n * {@link WorkflowRun} `run()` returns. Iterate for progress; await `result` for\n * the outcome. The stream ends when the run terminates.\n *\n * `result` is the AUTHORITATIVE terminal status. Not every terminal state has a\n * closing event: a step failure emits `step_failed`, but an `outputSchema`\n * rejection (SE27) or an abort ends the stream WITHOUT `workflow_completed` —\n * always `await result` to read the final `status`. Consuming order is free:\n * awaiting `result` without draining, or draining without awaiting `result`,\n * both work (breaking out of `for await` stops the buffering early).\n */\n stream(input: TInput, opts?: WorkflowRunOptions): WorkflowStream<TOutput> {\n const queue = createEventStream();\n const result = (async (): Promise<WorkflowRun<TOutput>> => {\n const { executeWorkflow } = await import(\"./internal/workflow/executor.js\");\n try {\n return await executeWorkflow<TInput, TOutput>(this._options, this._steps, input, {\n ...opts,\n onStepEvent: (event: WorkflowEvent) => queue.push(event),\n } as WorkflowRunOptions);\n } finally {\n queue.end(); // authoritative terminal is `result`; close the stream\n }\n })();\n return Object.assign(queue, { result });\n }\n\n /**\n * Resume a suspended workflow from its snapshot. Throws\n * `WorkflowSnapshotNotFoundError` if `runId` is unknown.\n */\n static async resume<TO = unknown>(opts: WorkflowResumeOptions): Promise<WorkflowRun<TO>> {\n const { resumeWorkflow } = await import(\"./internal/workflow/executor.js\");\n return resumeWorkflow<TO>(opts);\n }\n}\n\n/* ─── Helper factory functions ─── */\n\n/**\n * Build a `FnStep`. `id` must match `^[a-z0-9][a-z0-9_-]*$`.\n */\nexport function fn<I = unknown, O = unknown>(\n id: string,\n step: (input: I, ctx: StepContext) => Promise<O> | O,\n opts?: { inputSchema?: ZodType; outputSchema?: ZodType; retry?: RetryPolicy },\n): FnStep {\n validateStepId(id);\n if (opts?.retry !== undefined) RetryPolicySchema.parse(opts.retry);\n return {\n kind: \"fn\",\n id,\n fn: step as FnStep[\"fn\"],\n ...(opts?.inputSchema !== undefined ? { inputSchema: opts.inputSchema } : {}),\n ...(opts?.outputSchema !== undefined ? { outputSchema: opts.outputSchema } : {}),\n ...(opts?.retry !== undefined ? { retry: opts.retry } : {}),\n };\n}\n\n/**\n * Build an `AgentStep`. The `promptTemplate` can be a static string or a\n * function that receives the input and returns the prompt.\n */\nexport function agentStep(\n id: string,\n agent: SDKAgent,\n promptTemplate: string | ((input: unknown) => string),\n opts?: { retry?: RetryPolicy; origin?: MessageOrigin },\n): AgentStep {\n validateStepId(id);\n if (opts?.retry !== undefined) RetryPolicySchema.parse(opts.retry);\n return {\n kind: \"agent\",\n id,\n agent,\n promptTemplate,\n ...(opts?.retry !== undefined ? { retry: opts.retry } : {}),\n // SE3 — carry the turn's provenance down to `agent.send()` (metadata-only).\n ...(opts?.origin !== undefined ? { origin: opts.origin } : {}),\n };\n}\n\n/**\n * SE30 — use a committed {@link Workflow} as a step inside another workflow.\n * Wraps the child as an `FnStep` (opaque — the child runs in its OWN executor\n * with its own id-space, so nested step-ids never collide with the parent's).\n * The child's output becomes the step output. A non-`completed` child fails the\n * parent step with a typed {@link WorkflowNestedError}: nested `suspended` is NOT\n * resumable in v1 (resume continues AFTER the step — the child would be skipped;\n * use a top-level suspend). See ADR 0010.\n *\n * @public\n */\nexport function workflowStep<TI = unknown, TO = unknown>(\n child: Workflow<TI, TO>,\n opts?: { id?: string },\n): FnStep {\n const id = opts?.id ?? `workflow_${child.__options.name}`;\n validateStepId(id);\n return {\n kind: \"fn\",\n id,\n fn: async (input: unknown, ctx: StepContext): Promise<unknown> => {\n const run = await child.run(input as TI, { signal: ctx.signal });\n if (run.status === \"completed\") return run.output;\n throw new WorkflowNestedError(id, child.__options.name, run.status, run.error);\n },\n };\n}\n\n/**\n * SE30 — clone a committed workflow under a new id/name. The clone runs\n * independently (its own single-flight lock + observability identity) with the\n * same committed steps. Mirrors a peer framework's `cloneWorkflow`.\n *\n * @public\n */\nexport function cloneWorkflow<TI = unknown, TO = unknown>(\n wf: Workflow<TI, TO>,\n opts: { id: string },\n): Workflow<TI, TO> {\n return new Workflow<TI, TO>(\n { ...wf.__options, name: opts.id, workflowId: `wf-${mintShortId()}` },\n [...wf.__steps],\n );\n}\n\n/* ─── Test seam re-export ─── */\n\nexport { __resetSnapshotStoresForTests } from \"./internal/workflow/snapshot-store.js\";\n\n/* ─── Re-exports for ergonomics (errors + all public types). After the\n sub-path extraction `@theokit/sdk/workflow` is the single import site,\n so type aliases must surface here (previously they reached consumers\n via `types/index.ts:25 export type * from \"./workflow.js\"`, which the\n extraction removes). ─── */\n\nexport type * from \"./types/workflow.js\";\n// SE19 — exposing a Workflow AS an agent tool answers a different question from building one,\n// and lives in its own module. Re-exported so `@theokit/sdk/workflow` is unchanged.\nexport { type WorkflowAsToolSpec, WorkflowToolError, workflowAsTool } from \"./workflow-as-tool.js\";\nexport {\n WorkflowAlreadyRunningError,\n WorkflowCompensateNotImplementedError,\n WorkflowDuplicateStepIdError,\n WorkflowInputError,\n WorkflowMaxIterationsExceededError,\n WorkflowNestedError,\n WorkflowNotSerializableError,\n WorkflowOutputError,\n WorkflowParallelError,\n WorkflowResumeStepNotFoundError,\n WorkflowSnapshotNotFoundError,\n WorkflowStateError,\n} from \"./workflow-errors.js\";\n\n/* ─── Internal helpers ─── */\n\nfunction validateStepId(id: string): void {\n // Reuses D81 grammar: ^[a-z0-9][a-z0-9_-]*$\n sanitizeIdentifier(id, { maxLen: 64 });\n}\n\nfunction mintShortId(): string {\n return globalThis.crypto.randomUUID().replace(/-/g, \"\").slice(0, 8);\n}\n\nfunction nestedStepsOf(s: Step): ReadonlyArray<ReadonlyArray<Step>> {\n if (s.kind === \"parallel\") return s.branches;\n if (s.kind === \"branch\") {\n const groups = s.predicates.map(([, branch]) => branch);\n return s.fallback !== undefined ? [...groups, s.fallback] : groups;\n }\n if (s.kind === \"foreach\" || s.kind === \"dowhile\") return [[s.step]];\n return [];\n}\n\nfunction walkStepsValidating(steps: ReadonlyArray<Step>, seen: Set<string>): void {\n for (const s of steps) {\n if (seen.has(s.id)) throw new WorkflowDuplicateStepIdError(s.id);\n seen.add(s.id);\n for (const nested of nestedStepsOf(s)) {\n walkStepsValidating(nested, seen);\n }\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkJ7J7J2GN_cjs = require('./chunk-J7J7J2GN.cjs');
3
+ var chunkUNFBHV46_cjs = require('./chunk-UNFBHV46.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 chunkJ7J7J2GN_cjs.ConfigurationError(`Failed to read ${describe}: ${root}`, {
12
+ throw new chunkUNFBHV46_cjs.ConfigurationError(`Failed to read ${describe}: ${root}`, {
13
13
  code: errorCode,
14
14
  cause
15
15
  });
@@ -65,5 +65,5 @@ function coerce(raw) {
65
65
 
66
66
  exports.parseSimpleYaml = parseSimpleYaml;
67
67
  exports.readWorkspaceDir = readWorkspaceDir;
68
- //# sourceMappingURL=chunk-QRVS2PRE.cjs.map
69
- //# sourceMappingURL=chunk-QRVS2PRE.cjs.map
68
+ //# sourceMappingURL=chunk-MPR2ISL2.cjs.map
69
+ //# sourceMappingURL=chunk-MPR2ISL2.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,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AC,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-QRVS2PRE.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 * - a → [\"a\",\"b\"] (block list, when `- ` items follow a bare key)\n * - b\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 * - Inline list values cannot contain a literal comma inside an element; the\n * `tags: [a,b, c]` splitter is greedy on `,`. Use the block form above or\n * reword if you need this — and note that the block form was, for a while,\n * what this line recommended and the parser could not read.\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 const lines = text.split(/\\r?\\n/);\n for (let i = 0; i < lines.length; i += 1) {\n const entry = splitEntry(lines[i] ?? \"\");\n if (entry === undefined) continue;\n const { key, raw } = entry;\n\n // `key:` with nothing after it may open a block list. Collect first, then decide: items found →\n // a list; none → `undefined`, which is the long-standing meaning of a bare key and what a\n // caller's Zod default relies on.\n const block = raw.length === 0 ? collectBlockList(lines, i + 1) : undefined;\n if (block !== undefined && block.items.length > 0) {\n fields[key] = block.items;\n // `end` is the first line that is NOT part of this list, and the loop's own `i += 1` steps\n // past it — so stop one short, or the key after a block list is swallowed.\n i = block.end - 1;\n continue;\n }\n\n fields[key] = coerce(raw);\n }\n return fields;\n}\n\n/**\n * Split one line into its key and its raw value, or report that it carries neither.\n *\n * A line with no `:` is not an entry (a `- item` continuation is the case that matters here), and\n * neither is one whose key is blank. Both were `continue`s inside the loop; they are the same\n * question — \"is this line an entry?\" — and asking it in one place is what keeps the loop under the\n * repository's cognitive-complexity limit.\n */\nfunction splitEntry(line: string): { key: string; raw: string } | undefined {\n const colonIndex = line.indexOf(\":\");\n if (colonIndex === -1) return undefined;\n const key = line.slice(0, colonIndex).trim();\n if (key.length === 0) return undefined;\n return { key, raw: line.slice(colonIndex + 1).trim() };\n}\n\n/**\n * Read the `- item` lines that follow a bare `key:`, and report where they stop.\n *\n * Line-oriented parsing skipped these outright — a `- item` has no colon — so the key coerced to\n * `undefined` and the values went nowhere. A reader saw the key on disk and found no behaviour,\n * with nothing to grep for. The docblock above made it sharper by advising \"use multi-line lists\"\n * for a limitation of the inline form; multi-line was the one shape this parser could not read.\n *\n * Extracted rather than inlined because inlining it put `parseSimpleYaml` at a cognitive complexity\n * of 24 against a limit of 10 — measured, not assumed: the pre-change function raised no such\n * diagnostic on the same file path.\n *\n * Blank and `#` lines do not end a list; anything else does. `end` is the index of that first\n * non-item line, so the caller resumes there rather than re-reading what it consumed.\n */\nfunction collectBlockList(lines: string[], start: number): { items: string[]; end: number } {\n const items: string[] = [];\n let j = start;\n for (; j < lines.length; j += 1) {\n const next = (lines[j] ?? \"\").trim();\n if (next === \"\" || next.startsWith(\"#\")) continue;\n if (!next.startsWith(\"- \")) break;\n items.push(next.slice(2).trim());\n }\n return { items, end: j };\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":["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,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AC/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-MPR2ISL2.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 * - a → [\"a\",\"b\"] (block list, when `- ` items follow a bare key)\n * - b\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 * - Inline list values cannot contain a literal comma inside an element; the\n * `tags: [a,b, c]` splitter is greedy on `,`. Use the block form above or\n * reword if you need this — and note that the block form was, for a while,\n * what this line recommended and the parser could not read.\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 const lines = text.split(/\\r?\\n/);\n for (let i = 0; i < lines.length; i += 1) {\n const entry = splitEntry(lines[i] ?? \"\");\n if (entry === undefined) continue;\n const { key, raw } = entry;\n\n // `key:` with nothing after it may open a block list. Collect first, then decide: items found →\n // a list; none → `undefined`, which is the long-standing meaning of a bare key and what a\n // caller's Zod default relies on.\n const block = raw.length === 0 ? collectBlockList(lines, i + 1) : undefined;\n if (block !== undefined && block.items.length > 0) {\n fields[key] = block.items;\n // `end` is the first line that is NOT part of this list, and the loop's own `i += 1` steps\n // past it — so stop one short, or the key after a block list is swallowed.\n i = block.end - 1;\n continue;\n }\n\n fields[key] = coerce(raw);\n }\n return fields;\n}\n\n/**\n * Split one line into its key and its raw value, or report that it carries neither.\n *\n * A line with no `:` is not an entry (a `- item` continuation is the case that matters here), and\n * neither is one whose key is blank. Both were `continue`s inside the loop; they are the same\n * question — \"is this line an entry?\" — and asking it in one place is what keeps the loop under the\n * repository's cognitive-complexity limit.\n */\nfunction splitEntry(line: string): { key: string; raw: string } | undefined {\n const colonIndex = line.indexOf(\":\");\n if (colonIndex === -1) return undefined;\n const key = line.slice(0, colonIndex).trim();\n if (key.length === 0) return undefined;\n return { key, raw: line.slice(colonIndex + 1).trim() };\n}\n\n/**\n * Read the `- item` lines that follow a bare `key:`, and report where they stop.\n *\n * Line-oriented parsing skipped these outright — a `- item` has no colon — so the key coerced to\n * `undefined` and the values went nowhere. A reader saw the key on disk and found no behaviour,\n * with nothing to grep for. The docblock above made it sharper by advising \"use multi-line lists\"\n * for a limitation of the inline form; multi-line was the one shape this parser could not read.\n *\n * Extracted rather than inlined because inlining it put `parseSimpleYaml` at a cognitive complexity\n * of 24 against a limit of 10 — measured, not assumed: the pre-change function raised no such\n * diagnostic on the same file path.\n *\n * Blank and `#` lines do not end a list; anything else does. `end` is the index of that first\n * non-item line, so the caller resumes there rather than re-reading what it consumed.\n */\nfunction collectBlockList(lines: string[], start: number): { items: string[]; end: number } {\n const items: string[] = [];\n let j = start;\n for (; j < lines.length; j += 1) {\n const next = (lines[j] ?? \"\").trim();\n if (next === \"\" || next.startsWith(\"#\")) continue;\n if (!next.startsWith(\"- \")) break;\n items.push(next.slice(2).trim());\n }\n return { items, end: j };\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,4 +1,4 @@
1
- import { ConfigurationError } from './chunk-ALUN2B4W.js';
1
+ import { ConfigurationError } from './chunk-B5MHRQJZ.js';
2
2
  import { readdir } from 'fs/promises';
3
3
 
4
4
  async function readWorkspaceDir(root, errorCode, describe) {
@@ -62,5 +62,5 @@ function coerce(raw) {
62
62
  }
63
63
 
64
64
  export { parseSimpleYaml, readWorkspaceDir };
65
- //# sourceMappingURL=chunk-UOLBAPDM.js.map
66
- //# sourceMappingURL=chunk-UOLBAPDM.js.map
65
+ //# sourceMappingURL=chunk-MQGSOKR3.js.map
66
+ //# sourceMappingURL=chunk-MQGSOKR3.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/internal/runtime/config/workspace-dir.ts","../src/internal/runtime/context/yaml-frontmatter.ts"],"names":[],"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AAA,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-UOLBAPDM.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 * - a → [\"a\",\"b\"] (block list, when `- ` items follow a bare key)\n * - b\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 * - Inline list values cannot contain a literal comma inside an element; the\n * `tags: [a,b, c]` splitter is greedy on `,`. Use the block form above or\n * reword if you need this — and note that the block form was, for a while,\n * what this line recommended and the parser could not read.\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 const lines = text.split(/\\r?\\n/);\n for (let i = 0; i < lines.length; i += 1) {\n const entry = splitEntry(lines[i] ?? \"\");\n if (entry === undefined) continue;\n const { key, raw } = entry;\n\n // `key:` with nothing after it may open a block list. Collect first, then decide: items found →\n // a list; none → `undefined`, which is the long-standing meaning of a bare key and what a\n // caller's Zod default relies on.\n const block = raw.length === 0 ? collectBlockList(lines, i + 1) : undefined;\n if (block !== undefined && block.items.length > 0) {\n fields[key] = block.items;\n // `end` is the first line that is NOT part of this list, and the loop's own `i += 1` steps\n // past it — so stop one short, or the key after a block list is swallowed.\n i = block.end - 1;\n continue;\n }\n\n fields[key] = coerce(raw);\n }\n return fields;\n}\n\n/**\n * Split one line into its key and its raw value, or report that it carries neither.\n *\n * A line with no `:` is not an entry (a `- item` continuation is the case that matters here), and\n * neither is one whose key is blank. Both were `continue`s inside the loop; they are the same\n * question — \"is this line an entry?\" — and asking it in one place is what keeps the loop under the\n * repository's cognitive-complexity limit.\n */\nfunction splitEntry(line: string): { key: string; raw: string } | undefined {\n const colonIndex = line.indexOf(\":\");\n if (colonIndex === -1) return undefined;\n const key = line.slice(0, colonIndex).trim();\n if (key.length === 0) return undefined;\n return { key, raw: line.slice(colonIndex + 1).trim() };\n}\n\n/**\n * Read the `- item` lines that follow a bare `key:`, and report where they stop.\n *\n * Line-oriented parsing skipped these outright — a `- item` has no colon — so the key coerced to\n * `undefined` and the values went nowhere. A reader saw the key on disk and found no behaviour,\n * with nothing to grep for. The docblock above made it sharper by advising \"use multi-line lists\"\n * for a limitation of the inline form; multi-line was the one shape this parser could not read.\n *\n * Extracted rather than inlined because inlining it put `parseSimpleYaml` at a cognitive complexity\n * of 24 against a limit of 10 — measured, not assumed: the pre-change function raised no such\n * diagnostic on the same file path.\n *\n * Blank and `#` lines do not end a list; anything else does. `end` is the index of that first\n * non-item line, so the caller resumes there rather than re-reading what it consumed.\n */\nfunction collectBlockList(lines: string[], start: number): { items: string[]; end: number } {\n const items: string[] = [];\n let j = start;\n for (; j < lines.length; j += 1) {\n const next = (lines[j] ?? \"\").trim();\n if (next === \"\" || next.startsWith(\"#\")) continue;\n if (!next.startsWith(\"- \")) break;\n items.push(next.slice(2).trim());\n }\n return { items, end: j };\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,CACpB,IAAA,EACA,SAAA,EACA,QAAA,EAC8B;AAC9B,EAAA,IAAI;AACF,IAAA,OAAQ,MAAM,OAAA,CAAQ,IAAA,EA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,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-MQGSOKR3.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 * - a → [\"a\",\"b\"] (block list, when `- ` items follow a bare key)\n * - b\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 * - Inline list values cannot contain a literal comma inside an element; the\n * `tags: [a,b, c]` splitter is greedy on `,`. Use the block form above or\n * reword if you need this — and note that the block form was, for a while,\n * what this line recommended and the parser could not read.\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 const lines = text.split(/\\r?\\n/);\n for (let i = 0; i < lines.length; i += 1) {\n const entry = splitEntry(lines[i] ?? \"\");\n if (entry === undefined) continue;\n const { key, raw } = entry;\n\n // `key:` with nothing after it may open a block list. Collect first, then decide: items found →\n // a list; none → `undefined`, which is the long-standing meaning of a bare key and what a\n // caller's Zod default relies on.\n const block = raw.length === 0 ? collectBlockList(lines, i + 1) : undefined;\n if (block !== undefined && block.items.length > 0) {\n fields[key] = block.items;\n // `end` is the first line that is NOT part of this list, and the loop's own `i += 1` steps\n // past it — so stop one short, or the key after a block list is swallowed.\n i = block.end - 1;\n continue;\n }\n\n fields[key] = coerce(raw);\n }\n return fields;\n}\n\n/**\n * Split one line into its key and its raw value, or report that it carries neither.\n *\n * A line with no `:` is not an entry (a `- item` continuation is the case that matters here), and\n * neither is one whose key is blank. Both were `continue`s inside the loop; they are the same\n * question — \"is this line an entry?\" — and asking it in one place is what keeps the loop under the\n * repository's cognitive-complexity limit.\n */\nfunction splitEntry(line: string): { key: string; raw: string } | undefined {\n const colonIndex = line.indexOf(\":\");\n if (colonIndex === -1) return undefined;\n const key = line.slice(0, colonIndex).trim();\n if (key.length === 0) return undefined;\n return { key, raw: line.slice(colonIndex + 1).trim() };\n}\n\n/**\n * Read the `- item` lines that follow a bare `key:`, and report where they stop.\n *\n * Line-oriented parsing skipped these outright — a `- item` has no colon — so the key coerced to\n * `undefined` and the values went nowhere. A reader saw the key on disk and found no behaviour,\n * with nothing to grep for. The docblock above made it sharper by advising \"use multi-line lists\"\n * for a limitation of the inline form; multi-line was the one shape this parser could not read.\n *\n * Extracted rather than inlined because inlining it put `parseSimpleYaml` at a cognitive complexity\n * of 24 against a limit of 10 — measured, not assumed: the pre-change function raised no such\n * diagnostic on the same file path.\n *\n * Blank and `#` lines do not end a list; anything else does. `end` is the index of that first\n * non-item line, so the caller resumes there rather than re-reading what it consumed.\n */\nfunction collectBlockList(lines: string[], start: number): { items: string[]; end: number } {\n const items: string[] = [];\n let j = start;\n for (; j < lines.length; j += 1) {\n const next = (lines[j] ?? \"\").trim();\n if (next === \"\" || next.startsWith(\"#\")) continue;\n if (!next.startsWith(\"- \")) break;\n items.push(next.slice(2).trim());\n }\n return { items, end: j };\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,8 +1,8 @@
1
- import { WorkflowNestedError, WorkflowDuplicateStepIdError } from './chunk-GBCVPKHE.js';
1
+ import { WorkflowNestedError, WorkflowDuplicateStepIdError } from './chunk-HV4V63CO.js';
2
2
  import { PersistenceSchema } from './chunk-HY66GLM6.js';
3
3
  import { toJsonSchema } from './chunk-7I5Z3UBJ.js';
4
- import { sanitizeIdentifier } from './chunk-EH6XD3FY.js';
5
- import { TheokitAgentError, ConfigurationError } from './chunk-ALUN2B4W.js';
4
+ import { sanitizeIdentifier } from './chunk-5DD4NJN3.js';
5
+ import { TheokitAgentError, ConfigurationError } from './chunk-B5MHRQJZ.js';
6
6
  import { z } from 'zod';
7
7
 
8
8
  // src/internal/workflow/event-stream.ts
@@ -287,10 +287,10 @@ var Workflow = class {
287
287
  * `run.status === "failed"`.
288
288
  */
289
289
  async run(input, opts) {
290
- const { executeWorkflow } = await import('./executor-ZNDQDX6Q.js');
290
+ const { executeWorkflow } = await import('./executor-3NI7KNL4.js');
291
291
  const result = await executeWorkflow(this._options, this._steps, input, opts);
292
292
  if (opts?.task !== void 0) {
293
- const { submit: taskSubmit } = await import('./registry-DMWCJKRF.js');
293
+ const { submit: taskSubmit } = await import('./registry-5FK42CRV.js');
294
294
  const taskOpts = opts.task === true ? {} : opts.task;
295
295
  const id = taskOpts.id ?? `wf-${result.id}`;
296
296
  await taskSubmit({
@@ -329,7 +329,7 @@ var Workflow = class {
329
329
  stream(input, opts) {
330
330
  const queue = createEventStream();
331
331
  const result = (async () => {
332
- const { executeWorkflow } = await import('./executor-ZNDQDX6Q.js');
332
+ const { executeWorkflow } = await import('./executor-3NI7KNL4.js');
333
333
  try {
334
334
  return await executeWorkflow(this._options, this._steps, input, {
335
335
  ...opts,
@@ -346,7 +346,7 @@ var Workflow = class {
346
346
  * `WorkflowSnapshotNotFoundError` if `runId` is unknown.
347
347
  */
348
348
  static async resume(opts) {
349
- const { resumeWorkflow } = await import('./executor-ZNDQDX6Q.js');
349
+ const { resumeWorkflow } = await import('./executor-3NI7KNL4.js');
350
350
  return resumeWorkflow(opts);
351
351
  }
352
352
  };
@@ -420,5 +420,5 @@ function walkStepsValidating(steps, seen) {
420
420
  }
421
421
 
422
422
  export { Workflow, WorkflowBuilder, WorkflowToolError, agentStep, cloneWorkflow, fn, workflowAsTool, workflowStep };
423
- //# sourceMappingURL=chunk-HFEJE7AC.js.map
424
- //# sourceMappingURL=chunk-HFEJE7AC.js.map
423
+ //# sourceMappingURL=chunk-MU7IAA7G.js.map
424
+ //# sourceMappingURL=chunk-MU7IAA7G.js.map