@theokit/sdk 4.53.0 → 4.53.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (373) hide show
  1. package/CHANGELOG.md +8 -8
  2. package/LICENSE +2 -2
  3. package/README.md +5 -5
  4. package/bin/theokit-migrate-config.mjs +11 -2
  5. package/dist/{agent-BiCINq25.d.ts → agent-B9HXlwID.d.ts} +21 -8
  6. package/dist/agent-FFVV4U5N.js +50 -0
  7. package/dist/{agent-ZAGG6ZBS.js.map → agent-FFVV4U5N.js.map} +1 -1
  8. package/dist/agent-YLAHVHEH.cjs +59 -0
  9. package/dist/{agent-JX5SBYDE.cjs.map → agent-YLAHVHEH.cjs.map} +1 -1
  10. package/dist/{agent-Zta1kvGH.d.cts → agent-nLqeXKIX.d.cts} +21 -8
  11. package/dist/agent-session-store-DUGBAX5V.cjs +23 -0
  12. package/dist/{agent-session-store-EPX2WQI4.cjs.map → agent-session-store-DUGBAX5V.cjs.map} +1 -1
  13. package/dist/agent-session-store-TNCGL5RN.js +6 -0
  14. package/dist/{agent-session-store-JMU7ASDB.js.map → agent-session-store-TNCGL5RN.js.map} +1 -1
  15. package/dist/agent.d.ts +16 -1
  16. package/dist/auth/index.cjs +18 -18
  17. package/dist/auth/index.cjs.map +1 -1
  18. package/dist/auth/index.d.cts +1 -1
  19. package/dist/auth/index.d.ts +1 -1
  20. package/dist/auth/index.js +6 -6
  21. package/dist/auth/index.js.map +1 -1
  22. package/dist/{batch-NLIS4QTW.js → batch-UPKN4SG6.js} +9 -9
  23. package/dist/{batch-NLIS4QTW.js.map → batch-UPKN4SG6.js.map} +1 -1
  24. package/dist/{batch-WQ3AJCDV.cjs → batch-ZEFN5SO7.cjs} +26 -26
  25. package/dist/{batch-WQ3AJCDV.cjs.map → batch-ZEFN5SO7.cjs.map} +1 -1
  26. package/dist/{chunk-2QMK627M.cjs → chunk-2D43RD5D.cjs} +8 -8
  27. package/dist/{chunk-2QMK627M.cjs.map → chunk-2D43RD5D.cjs.map} +1 -1
  28. package/dist/{chunk-DM6Y5B2G.cjs → chunk-2FYEVT2B.cjs} +121 -121
  29. package/dist/{chunk-DM6Y5B2G.cjs.map → chunk-2FYEVT2B.cjs.map} +1 -1
  30. package/dist/{chunk-BBZYXVLZ.cjs → chunk-2ZPEDVLM.cjs} +2 -2
  31. package/dist/chunk-2ZPEDVLM.cjs.map +1 -0
  32. package/dist/{chunk-T6QUCG7L.cjs → chunk-3BK6YR5P.cjs} +4 -4
  33. package/dist/{chunk-T6QUCG7L.cjs.map → chunk-3BK6YR5P.cjs.map} +1 -1
  34. package/dist/{chunk-23VZBRDQ.js → chunk-3V7UJLQT.js} +3 -3
  35. package/dist/chunk-3V7UJLQT.js.map +1 -0
  36. package/dist/{chunk-ITQ4NO4P.js → chunk-3WVMJY7F.js} +3 -3
  37. package/dist/{chunk-ITQ4NO4P.js.map → chunk-3WVMJY7F.js.map} +1 -1
  38. package/dist/{chunk-RAACTJ7C.cjs → chunk-3X6PM7DU.cjs} +4 -4
  39. package/dist/{chunk-RAACTJ7C.cjs.map → chunk-3X6PM7DU.cjs.map} +1 -1
  40. package/dist/{chunk-DEZ75ET5.js → chunk-4Q4K4WB5.js} +3 -3
  41. package/dist/{chunk-DEZ75ET5.js.map → chunk-4Q4K4WB5.js.map} +1 -1
  42. package/dist/{chunk-4X3SBHPK.js → chunk-5F5NWKPN.js} +20 -4
  43. package/dist/chunk-5F5NWKPN.js.map +1 -0
  44. package/dist/{chunk-NUEL6RCZ.cjs → chunk-5YKNEMXR.cjs} +4 -4
  45. package/dist/chunk-5YKNEMXR.cjs.map +1 -0
  46. package/dist/{chunk-3YYDHUNH.cjs → chunk-665SFFFR.cjs} +11 -11
  47. package/dist/{chunk-3YYDHUNH.cjs.map → chunk-665SFFFR.cjs.map} +1 -1
  48. package/dist/{chunk-CHVSMEKM.js → chunk-6AZDM6LK.js} +3 -3
  49. package/dist/chunk-6AZDM6LK.js.map +1 -0
  50. package/dist/{chunk-AMYY3JHQ.cjs → chunk-ADLLFY3H.cjs} +9 -9
  51. package/dist/{chunk-AMYY3JHQ.cjs.map → chunk-ADLLFY3H.cjs.map} +1 -1
  52. package/dist/{chunk-634YVZLU.js → chunk-B6HOIWQ6.js} +5 -5
  53. package/dist/{chunk-634YVZLU.js.map → chunk-B6HOIWQ6.js.map} +1 -1
  54. package/dist/{chunk-EQMLJ52C.cjs → chunk-BDTVFIPB.cjs} +26 -26
  55. package/dist/{chunk-EQMLJ52C.cjs.map → chunk-BDTVFIPB.cjs.map} +1 -1
  56. package/dist/{chunk-UJ3SXRZZ.js → chunk-BERBYXFH.js} +3 -3
  57. package/dist/{chunk-UJ3SXRZZ.js.map → chunk-BERBYXFH.js.map} +1 -1
  58. package/dist/{chunk-KZBB4YKU.js → chunk-BFYGJGC5.js} +3 -3
  59. package/dist/{chunk-KZBB4YKU.js.map → chunk-BFYGJGC5.js.map} +1 -1
  60. package/dist/{chunk-SXSPMRSV.cjs → chunk-BM6N4KHO.cjs} +21 -3
  61. package/dist/chunk-BM6N4KHO.cjs.map +1 -0
  62. package/dist/{chunk-2CFEET3Y.cjs → chunk-C4H6PB5J.cjs} +4 -4
  63. package/dist/chunk-C4H6PB5J.cjs.map +1 -0
  64. package/dist/{chunk-NFATC6ZF.cjs → chunk-C5DEO6OI.cjs} +4 -4
  65. package/dist/{chunk-NFATC6ZF.cjs.map → chunk-C5DEO6OI.cjs.map} +1 -1
  66. package/dist/{chunk-EUBGGYPH.cjs → chunk-CZ2GKKYL.cjs} +5 -5
  67. package/dist/{chunk-EUBGGYPH.cjs.map → chunk-CZ2GKKYL.cjs.map} +1 -1
  68. package/dist/{chunk-I732VEDW.js → chunk-D24WJWN2.js} +3 -3
  69. package/dist/{chunk-I732VEDW.js.map → chunk-D24WJWN2.js.map} +1 -1
  70. package/dist/{chunk-3R4ZCQAZ.cjs → chunk-D75S2X6I.cjs} +5 -5
  71. package/dist/{chunk-3R4ZCQAZ.cjs.map → chunk-D75S2X6I.cjs.map} +1 -1
  72. package/dist/{chunk-5XXUYU3M.js → chunk-DGOG5NXR.js} +3 -3
  73. package/dist/{chunk-5XXUYU3M.js.map → chunk-DGOG5NXR.js.map} +1 -1
  74. package/dist/{chunk-RTLUZKDL.cjs → chunk-E7FJOO4G.cjs} +11 -11
  75. package/dist/{chunk-RTLUZKDL.cjs.map → chunk-E7FJOO4G.cjs.map} +1 -1
  76. package/dist/{chunk-BWGXYOBZ.cjs → chunk-ELKO4ZLR.cjs} +4 -4
  77. package/dist/{chunk-BWGXYOBZ.cjs.map → chunk-ELKO4ZLR.cjs.map} +1 -1
  78. package/dist/{chunk-FBZMSLDC.cjs → chunk-EZ2YEF4F.cjs} +4 -4
  79. package/dist/{chunk-FBZMSLDC.cjs.map → chunk-EZ2YEF4F.cjs.map} +1 -1
  80. package/dist/{chunk-2VFZQEDW.cjs → chunk-F77UENR6.cjs} +343 -324
  81. package/dist/chunk-F77UENR6.cjs.map +1 -0
  82. package/dist/{chunk-OZXPA3ME.js → chunk-FFM3SJTQ.js} +4 -4
  83. package/dist/{chunk-OZXPA3ME.js.map → chunk-FFM3SJTQ.js.map} +1 -1
  84. package/dist/{chunk-PLUCC4N5.js → chunk-FIOCJYLA.js} +3 -3
  85. package/dist/{chunk-PLUCC4N5.js.map → chunk-FIOCJYLA.js.map} +1 -1
  86. package/dist/{chunk-Z5U2JGEK.cjs → chunk-FOXKFTVZ.cjs} +11 -11
  87. package/dist/{chunk-Z5U2JGEK.cjs.map → chunk-FOXKFTVZ.cjs.map} +1 -1
  88. package/dist/{chunk-K42QGAKM.cjs → chunk-FPYT5WZP.cjs} +10 -10
  89. package/dist/{chunk-K42QGAKM.cjs.map → chunk-FPYT5WZP.cjs.map} +1 -1
  90. package/dist/{chunk-NZOR3N4E.js → chunk-G3JWXOGY.js} +78 -58
  91. package/dist/chunk-G3JWXOGY.js.map +1 -0
  92. package/dist/{chunk-DHVNJYTO.js → chunk-GBBDINFK.js} +3 -3
  93. package/dist/{chunk-DHVNJYTO.js.map → chunk-GBBDINFK.js.map} +1 -1
  94. package/dist/{chunk-V45L2OYP.cjs → chunk-GD63JPGC.cjs} +9 -9
  95. package/dist/{chunk-V45L2OYP.cjs.map → chunk-GD63JPGC.cjs.map} +1 -1
  96. package/dist/{chunk-I5OTK2RP.js → chunk-GOVJO4YE.js} +5 -5
  97. package/dist/{chunk-I5OTK2RP.js.map → chunk-GOVJO4YE.js.map} +1 -1
  98. package/dist/{chunk-CZHPR2G7.cjs → chunk-HAWE74GQ.cjs} +8 -8
  99. package/dist/{chunk-CZHPR2G7.cjs.map → chunk-HAWE74GQ.cjs.map} +1 -1
  100. package/dist/{chunk-KIX45IKP.js → chunk-HE4BIAOS.js} +4 -4
  101. package/dist/{chunk-KIX45IKP.js.map → chunk-HE4BIAOS.js.map} +1 -1
  102. package/dist/{chunk-AM2CNBKE.js → chunk-HKCKOAIO.js} +2 -2
  103. package/dist/chunk-HKCKOAIO.js.map +1 -0
  104. package/dist/{chunk-2YWWPCGX.js → chunk-HSQ5Q3I5.js} +10 -12
  105. package/dist/chunk-HSQ5Q3I5.js.map +1 -0
  106. package/dist/{chunk-QLAWEGTZ.cjs → chunk-JIQRXKTA.cjs} +7 -7
  107. package/dist/chunk-JIQRXKTA.cjs.map +1 -0
  108. package/dist/{chunk-EFXJ5C7X.js → chunk-KSWHTR54.js} +5 -5
  109. package/dist/{chunk-EFXJ5C7X.js.map → chunk-KSWHTR54.js.map} +1 -1
  110. package/dist/{chunk-6PTCKXD3.js → chunk-LD4MOBFX.js} +8 -8
  111. package/dist/{chunk-6PTCKXD3.js.map → chunk-LD4MOBFX.js.map} +1 -1
  112. package/dist/{chunk-2YGIBOUH.cjs → chunk-LPVIRJVF.cjs} +9 -9
  113. package/dist/chunk-LPVIRJVF.cjs.map +1 -0
  114. package/dist/{chunk-2Y5NO2SY.js → chunk-LS3LMQ23.js} +9 -9
  115. package/dist/{chunk-2Y5NO2SY.js.map → chunk-LS3LMQ23.js.map} +1 -1
  116. package/dist/{chunk-N43XLTHZ.js → chunk-LTSTGCL6.js} +3 -3
  117. package/dist/{chunk-N43XLTHZ.js.map → chunk-LTSTGCL6.js.map} +1 -1
  118. package/dist/{chunk-W4FV7JBH.js → chunk-MSFLYJDY.js} +4 -4
  119. package/dist/chunk-MSFLYJDY.js.map +1 -0
  120. package/dist/{chunk-C4EU627W.js → chunk-N5CR3TJZ.js} +4 -4
  121. package/dist/{chunk-C4EU627W.js.map → chunk-N5CR3TJZ.js.map} +1 -1
  122. package/dist/{chunk-HTK54K2J.js → chunk-NZL4BNFQ.js} +3 -3
  123. package/dist/{chunk-HTK54K2J.js.map → chunk-NZL4BNFQ.js.map} +1 -1
  124. package/dist/{chunk-T5ZWI3MC.cjs → chunk-OUOXM36O.cjs} +11 -11
  125. package/dist/{chunk-T5ZWI3MC.cjs.map → chunk-OUOXM36O.cjs.map} +1 -1
  126. package/dist/{chunk-BXVSBYGW.js → chunk-OY7O3Q6R.js} +5 -5
  127. package/dist/{chunk-BXVSBYGW.js.map → chunk-OY7O3Q6R.js.map} +1 -1
  128. package/dist/{chunk-L7EGRCKJ.js → chunk-PBZ7HMBP.js} +4 -4
  129. package/dist/{chunk-L7EGRCKJ.js.map → chunk-PBZ7HMBP.js.map} +1 -1
  130. package/dist/{chunk-OIBHY6JQ.js → chunk-PGP7IOJ2.js} +4 -4
  131. package/dist/{chunk-OIBHY6JQ.js.map → chunk-PGP7IOJ2.js.map} +1 -1
  132. package/dist/{chunk-R7TKOQMJ.js → chunk-POWRZSK4.js} +3 -3
  133. package/dist/{chunk-R7TKOQMJ.js.map → chunk-POWRZSK4.js.map} +1 -1
  134. package/dist/{chunk-R3CKCRK3.cjs → chunk-Q4RESANI.cjs} +4 -4
  135. package/dist/{chunk-R3CKCRK3.cjs.map → chunk-Q4RESANI.cjs.map} +1 -1
  136. package/dist/{chunk-QN5N3ZVT.cjs → chunk-QBTVATSF.cjs} +25 -24
  137. package/dist/chunk-QBTVATSF.cjs.map +1 -0
  138. package/dist/{chunk-ZSJPRPN7.js → chunk-R5YZACGK.js} +3 -3
  139. package/dist/{chunk-ZSJPRPN7.js.map → chunk-R5YZACGK.js.map} +1 -1
  140. package/dist/{chunk-ADVZIC43.cjs → chunk-RAHSWE5C.cjs} +10 -10
  141. package/dist/{chunk-ADVZIC43.cjs.map → chunk-RAHSWE5C.cjs.map} +1 -1
  142. package/dist/{chunk-NOS7PTKP.js → chunk-SEL2ZQMT.js} +7 -7
  143. package/dist/{chunk-NOS7PTKP.js.map → chunk-SEL2ZQMT.js.map} +1 -1
  144. package/dist/{chunk-XWCTBGYK.js → chunk-SK4QLUBK.js} +3 -3
  145. package/dist/chunk-SK4QLUBK.js.map +1 -0
  146. package/dist/{chunk-XRI6DXPZ.js → chunk-SSDD676S.js} +3 -3
  147. package/dist/chunk-SSDD676S.js.map +1 -0
  148. package/dist/{chunk-E3OCRJU6.cjs → chunk-SVO5WPZX.cjs} +11 -11
  149. package/dist/{chunk-E3OCRJU6.cjs.map → chunk-SVO5WPZX.cjs.map} +1 -1
  150. package/dist/{chunk-44IISBRZ.cjs → chunk-SZHU7A5B.cjs} +4 -4
  151. package/dist/{chunk-44IISBRZ.cjs.map → chunk-SZHU7A5B.cjs.map} +1 -1
  152. package/dist/{chunk-TR4V2LHV.cjs → chunk-TTJ54H3E.cjs} +5 -5
  153. package/dist/{chunk-TR4V2LHV.cjs.map → chunk-TTJ54H3E.cjs.map} +1 -1
  154. package/dist/{chunk-HI4ZW62S.js → chunk-U4UJHOSH.js} +4 -4
  155. package/dist/chunk-U4UJHOSH.js.map +1 -0
  156. package/dist/{chunk-XGYI2KQH.js → chunk-UFIXH26P.js} +4 -4
  157. package/dist/{chunk-XGYI2KQH.js.map → chunk-UFIXH26P.js.map} +1 -1
  158. package/dist/{chunk-JJZ4NIAG.js → chunk-V26QVGUG.js} +7 -6
  159. package/dist/chunk-V26QVGUG.js.map +1 -0
  160. package/dist/{chunk-3SHW7XKK.js → chunk-V6HWJQQV.js} +6 -5
  161. package/dist/chunk-V6HWJQQV.js.map +1 -0
  162. package/dist/{chunk-MV4TOCUK.js → chunk-VC5ABJXC.js} +3 -3
  163. package/dist/{chunk-MV4TOCUK.js.map → chunk-VC5ABJXC.js.map} +1 -1
  164. package/dist/{chunk-33L2NVTJ.cjs → chunk-VF7X6HDR.cjs} +8 -8
  165. package/dist/chunk-VF7X6HDR.cjs.map +1 -0
  166. package/dist/{chunk-7HQVDLFI.cjs → chunk-VGPXHHF3.cjs} +11 -9
  167. package/dist/chunk-VGPXHHF3.cjs.map +1 -0
  168. package/dist/{chunk-BC5EUG7R.cjs → chunk-VUKQL3L2.cjs} +18 -20
  169. package/dist/chunk-VUKQL3L2.cjs.map +1 -0
  170. package/dist/{chunk-PVBANCWU.cjs → chunk-VW6M4B3Z.cjs} +5 -5
  171. package/dist/{chunk-PVBANCWU.cjs.map → chunk-VW6M4B3Z.cjs.map} +1 -1
  172. package/dist/{chunk-KNZU4YO5.cjs → chunk-WQ53UQL4.cjs} +4 -4
  173. package/dist/{chunk-KNZU4YO5.cjs.map → chunk-WQ53UQL4.cjs.map} +1 -1
  174. package/dist/{chunk-6DCTL32L.cjs → chunk-XPR366DL.cjs} +17 -17
  175. package/dist/{chunk-6DCTL32L.cjs.map → chunk-XPR366DL.cjs.map} +1 -1
  176. package/dist/{chunk-7TB5U7RK.js → chunk-XROIW6BH.js} +6 -6
  177. package/dist/{chunk-7TB5U7RK.js.map → chunk-XROIW6BH.js.map} +1 -1
  178. package/dist/{chunk-ECPL5RV6.cjs → chunk-Y4AXQOT4.cjs} +8 -8
  179. package/dist/{chunk-ECPL5RV6.cjs.map → chunk-Y4AXQOT4.cjs.map} +1 -1
  180. package/dist/{chunk-E6T264NS.js → chunk-Y4I4EQFK.js} +3 -3
  181. package/dist/{chunk-E6T264NS.js.map → chunk-Y4I4EQFK.js.map} +1 -1
  182. package/dist/{chunk-FUASIT3E.cjs → chunk-ZN2DGEY3.cjs} +15 -15
  183. package/dist/{chunk-FUASIT3E.cjs.map → chunk-ZN2DGEY3.cjs.map} +1 -1
  184. package/dist/{chunk-YTO5BRBD.cjs → chunk-ZT57WTUJ.cjs} +8 -8
  185. package/dist/chunk-ZT57WTUJ.cjs.map +1 -0
  186. package/dist/compact-session-4MNKNMO2.js +21 -0
  187. package/dist/{compact-session-EJ36VH5I.js.map → compact-session-4MNKNMO2.js.map} +1 -1
  188. package/dist/compact-session-EPFBQ46Z.cjs +58 -0
  189. package/dist/{compact-session-6GKIS4SD.cjs.map → compact-session-EPFBQ46Z.cjs.map} +1 -1
  190. package/dist/compaction.cjs +16 -16
  191. package/dist/compaction.js +3 -3
  192. package/dist/concurrency.cjs +6 -6
  193. package/dist/concurrency.js +4 -4
  194. package/dist/context-7USNN6LP.cjs +22 -0
  195. package/dist/{context-4HGPCOH6.cjs.map → context-7USNN6LP.cjs.map} +1 -1
  196. package/dist/context-ENXZNF6J.js +5 -0
  197. package/dist/{context-DCECDKWN.js.map → context-ENXZNF6J.js.map} +1 -1
  198. package/dist/{cron-DyWQsEG6.d.ts → cron-BMjgFH-_.d.ts} +1 -1
  199. package/dist/{cron-DgHJnMAK.d.cts → cron-DFDdCdMM.d.cts} +1 -1
  200. package/dist/cron.cjs +33 -33
  201. package/dist/cron.d.cts +2 -2
  202. package/dist/cron.d.ts +2 -2
  203. package/dist/cron.js +32 -32
  204. package/dist/errors.cjs +21 -21
  205. package/dist/errors.js +2 -2
  206. package/dist/eval.cjs +43 -43
  207. package/dist/eval.js +33 -33
  208. package/dist/{executor-4SW7QGZ4.cjs → executor-2Z3LGG3I.cjs} +24 -24
  209. package/dist/{executor-4SW7QGZ4.cjs.map → executor-2Z3LGG3I.cjs.map} +1 -1
  210. package/dist/{executor-3CGPLVJL.js → executor-2Z6XJJJG.js} +7 -7
  211. package/dist/{executor-3CGPLVJL.js.map → executor-2Z6XJJJG.js.map} +1 -1
  212. package/dist/filesystem/index.cjs +7 -7
  213. package/dist/filesystem/index.js +3 -3
  214. package/dist/fs-session-store-R5FD3EN6.js +10 -0
  215. package/dist/{fs-session-store-LIKYT24K.js.map → fs-session-store-R5FD3EN6.js.map} +1 -1
  216. package/dist/fs-session-store-VVY2AHWG.cjs +19 -0
  217. package/dist/{fs-session-store-VXXDIBGM.cjs.map → fs-session-store-VVY2AHWG.cjs.map} +1 -1
  218. package/dist/generate-object-AVXOJK2I.cjs +20 -0
  219. package/dist/{generate-object-E465DX5I.cjs.map → generate-object-AVXOJK2I.cjs.map} +1 -1
  220. package/dist/generate-object-WQRCXFD2.js +7 -0
  221. package/dist/{generate-object-TVQCW2IZ.js.map → generate-object-WQRCXFD2.js.map} +1 -1
  222. package/dist/index-manager-VRU3A2YL.cjs +21 -0
  223. package/dist/{index-manager-HGGL4DD5.cjs.map → index-manager-VRU3A2YL.cjs.map} +1 -1
  224. package/dist/index-manager-WS7TVKUW.js +12 -0
  225. package/dist/{index-manager-EA6FGIQG.js.map → index-manager-WS7TVKUW.js.map} +1 -1
  226. package/dist/index.cjs +143 -135
  227. package/dist/index.d.cts +64 -8
  228. package/dist/index.d.ts +64 -8
  229. package/dist/index.js +45 -45
  230. package/dist/{inject-session-67SF65FC.cjs → inject-session-AUQLBDRS.cjs} +9 -9
  231. package/dist/{inject-session-67SF65FC.cjs.map → inject-session-AUQLBDRS.cjs.map} +1 -1
  232. package/dist/{inject-session-HO7FYVCX.js → inject-session-GMBMJVNZ.js} +7 -7
  233. package/dist/{inject-session-HO7FYVCX.js.map → inject-session-GMBMJVNZ.js.map} +1 -1
  234. package/dist/internal/auth/auth-types.d.ts +1 -1
  235. package/dist/internal/auth/oauth-device.d.ts +2 -2
  236. package/dist/internal/local-agent/mcp-pool.d.ts +2 -4
  237. package/dist/internal/mcp/oauth.d.ts +14 -1
  238. package/dist/internal/mcp/token-storage.d.ts +18 -1
  239. package/dist/internal/memory/adapters/index.cjs +8 -8
  240. package/dist/internal/memory/adapters/index.js +7 -7
  241. package/dist/internal/persistence/atomic-write.d.cts +93 -0
  242. package/dist/internal/persistence/atomic-write.d.ts +93 -0
  243. package/dist/internal/persistence/file-lock.d.cts +13 -1
  244. package/dist/internal/persistence/file-lock.d.ts +13 -1
  245. package/dist/internal/persistence/fts5-sanitize.d.cts +9 -1
  246. package/dist/internal/persistence/fts5-sanitize.d.ts +9 -1
  247. package/dist/internal/persistence/index.cjs +25 -25
  248. package/dist/internal/persistence/index.js +6 -6
  249. package/dist/internal/persistence/session-dir.d.cts +1 -0
  250. package/dist/internal/persistence/session-dir.d.ts +1 -0
  251. package/dist/internal/persistence/session-writer.d.cts +13 -0
  252. package/dist/internal/persistence/session-writer.d.ts +13 -0
  253. package/dist/internal/persistence/sqlite-wal.d.cts +9 -1
  254. package/dist/internal/persistence/sqlite-wal.d.ts +9 -1
  255. package/dist/internal/providers/builtin/cerebras.d.ts +2 -2
  256. package/dist/internal/providers/builtin/deepinfra.d.ts +1 -1
  257. package/dist/internal/providers/catalog-source-models-dev.d.ts +1 -1
  258. package/dist/internal/runtime/lifecycle/env-policy.d.ts +1 -3
  259. package/dist/internal/security/index.cjs +13 -13
  260. package/dist/internal/security/index.js +3 -3
  261. package/dist/internal/security/path-guard.d.cts +61 -0
  262. package/dist/internal/security/path-guard.d.ts +61 -0
  263. package/dist/internal/session/compact-session.d.ts +2 -2
  264. package/dist/internal/telemetry/tracer.d.ts +24 -0
  265. package/dist/judge-call-G5SGV2M2.cjs +22 -0
  266. package/dist/{judge-call-GVIJWQVE.cjs.map → judge-call-G5SGV2M2.cjs.map} +1 -1
  267. package/dist/judge-call-MDIPTBJI.js +5 -0
  268. package/dist/{judge-call-QMKGC2ZK.js.map → judge-call-MDIPTBJI.js.map} +1 -1
  269. package/dist/mcp-auth.cjs +14 -14
  270. package/dist/mcp-auth.cjs.map +1 -1
  271. package/dist/mcp-auth.js +4 -4
  272. package/dist/mcp-auth.js.map +1 -1
  273. package/dist/models.cjs +22 -22
  274. package/dist/models.cjs.map +1 -1
  275. package/dist/models.js +7 -7
  276. package/dist/models.js.map +1 -1
  277. package/dist/path-safety.cjs +10 -10
  278. package/dist/path-safety.js +3 -3
  279. package/dist/persistence.cjs +28 -28
  280. package/dist/persistence.js +8 -8
  281. package/dist/project.cjs +5 -5
  282. package/dist/project.js +3 -3
  283. package/dist/registry-63ASMXT4.cjs +46 -0
  284. package/dist/{registry-UBY26R4I.cjs.map → registry-63ASMXT4.cjs.map} +1 -1
  285. package/dist/registry-O7FJ2MPM.js +9 -0
  286. package/dist/{registry-GC7BQMSV.js.map → registry-O7FJ2MPM.js.map} +1 -1
  287. package/dist/retry.cjs +4 -4
  288. package/dist/retry.js +3 -3
  289. package/dist/sandbox/bwrap.d.cts +1 -2
  290. package/dist/sandbox/bwrap.d.ts +1 -2
  291. package/dist/sandbox/index.cjs +20 -20
  292. package/dist/sandbox/index.cjs.map +1 -1
  293. package/dist/sandbox/index.js +5 -5
  294. package/dist/sandbox/index.js.map +1 -1
  295. package/dist/server/errors-envelope.cjs +14 -14
  296. package/dist/server/errors-envelope.js +3 -3
  297. package/dist/session-transcript-DOM3UTXR.cjs +50 -0
  298. package/dist/{session-transcript-TNAJ4O3M.cjs.map → session-transcript-DOM3UTXR.cjs.map} +1 -1
  299. package/dist/session-transcript-RAKEK76V.js +5 -0
  300. package/dist/{session-transcript-SKIRBEJE.js.map → session-transcript-RAKEK76V.js.map} +1 -1
  301. package/dist/skills.cjs +7 -7
  302. package/dist/skills.js +5 -5
  303. package/dist/stream-object-L3Q7PBMF.cjs +20 -0
  304. package/dist/{stream-object-T4DAMNVB.cjs.map → stream-object-L3Q7PBMF.cjs.map} +1 -1
  305. package/dist/stream-object-ZYXWS4B2.js +7 -0
  306. package/dist/{stream-object-QMNR3YFF.js.map → stream-object-ZYXWS4B2.js.map} +1 -1
  307. package/dist/subagents-loader-I56GSKAQ.js +6 -0
  308. package/dist/{subagents-loader-WN2SB6PV.js.map → subagents-loader-I56GSKAQ.js.map} +1 -1
  309. package/dist/subagents-loader-VRW73QQT.cjs +15 -0
  310. package/dist/{subagents-loader-3CXBQWWY.cjs.map → subagents-loader-VRW73QQT.cjs.map} +1 -1
  311. package/dist/subagents-loader.cjs +6 -6
  312. package/dist/subagents-loader.d.cts +1 -1
  313. package/dist/subagents-loader.d.ts +1 -1
  314. package/dist/subagents-loader.js +4 -4
  315. package/dist/subscription/index.cjs +3 -3
  316. package/dist/subscription/index.js +2 -2
  317. package/dist/task-store.cjs +7 -7
  318. package/dist/task-store.js +4 -4
  319. package/dist/types/agent.d.ts +19 -6
  320. package/dist/types/provider-profile.d.ts +2 -2
  321. package/dist/workflow.cjs +27 -27
  322. package/dist/workflow.js +6 -6
  323. package/package.json +18 -18
  324. package/dist/agent-JX5SBYDE.cjs +0 -59
  325. package/dist/agent-ZAGG6ZBS.js +0 -50
  326. package/dist/agent-session-store-EPX2WQI4.cjs +0 -23
  327. package/dist/agent-session-store-JMU7ASDB.js +0 -6
  328. package/dist/chunk-23VZBRDQ.js.map +0 -1
  329. package/dist/chunk-2CFEET3Y.cjs.map +0 -1
  330. package/dist/chunk-2VFZQEDW.cjs.map +0 -1
  331. package/dist/chunk-2YGIBOUH.cjs.map +0 -1
  332. package/dist/chunk-2YWWPCGX.js.map +0 -1
  333. package/dist/chunk-33L2NVTJ.cjs.map +0 -1
  334. package/dist/chunk-3SHW7XKK.js.map +0 -1
  335. package/dist/chunk-4X3SBHPK.js.map +0 -1
  336. package/dist/chunk-7HQVDLFI.cjs.map +0 -1
  337. package/dist/chunk-AM2CNBKE.js.map +0 -1
  338. package/dist/chunk-BBZYXVLZ.cjs.map +0 -1
  339. package/dist/chunk-BC5EUG7R.cjs.map +0 -1
  340. package/dist/chunk-CHVSMEKM.js.map +0 -1
  341. package/dist/chunk-HI4ZW62S.js.map +0 -1
  342. package/dist/chunk-JJZ4NIAG.js.map +0 -1
  343. package/dist/chunk-NUEL6RCZ.cjs.map +0 -1
  344. package/dist/chunk-NZOR3N4E.js.map +0 -1
  345. package/dist/chunk-QLAWEGTZ.cjs.map +0 -1
  346. package/dist/chunk-QN5N3ZVT.cjs.map +0 -1
  347. package/dist/chunk-SXSPMRSV.cjs.map +0 -1
  348. package/dist/chunk-W4FV7JBH.js.map +0 -1
  349. package/dist/chunk-XRI6DXPZ.js.map +0 -1
  350. package/dist/chunk-XWCTBGYK.js.map +0 -1
  351. package/dist/chunk-YTO5BRBD.cjs.map +0 -1
  352. package/dist/compact-session-6GKIS4SD.cjs +0 -58
  353. package/dist/compact-session-EJ36VH5I.js +0 -21
  354. package/dist/context-4HGPCOH6.cjs +0 -22
  355. package/dist/context-DCECDKWN.js +0 -5
  356. package/dist/fs-session-store-LIKYT24K.js +0 -10
  357. package/dist/fs-session-store-VXXDIBGM.cjs +0 -19
  358. package/dist/generate-object-E465DX5I.cjs +0 -20
  359. package/dist/generate-object-TVQCW2IZ.js +0 -7
  360. package/dist/index-manager-EA6FGIQG.js +0 -12
  361. package/dist/index-manager-HGGL4DD5.cjs +0 -21
  362. package/dist/judge-call-GVIJWQVE.cjs +0 -22
  363. package/dist/judge-call-QMKGC2ZK.js +0 -5
  364. package/dist/registry-GC7BQMSV.js +0 -9
  365. package/dist/registry-UBY26R4I.cjs +0 -46
  366. package/dist/session-transcript-SKIRBEJE.js +0 -5
  367. package/dist/session-transcript-TNAJ4O3M.cjs +0 -50
  368. package/dist/stream-object-QMNR3YFF.js +0 -7
  369. package/dist/stream-object-T4DAMNVB.cjs +0 -20
  370. package/dist/subagents-loader-3CXBQWWY.cjs +0 -15
  371. package/dist/subagents-loader-WN2SB6PV.js +0 -6
  372. package/docs/error-codes.md +0 -179
  373. package/docs/harness-capability-map.md +0 -304
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/sandbox/bwrap.ts","../../src/sandbox/seccomp.ts","../../src/sandbox/linux-sandbox.ts","../../src/sandbox/provision.ts"],"names":["path"],"mappings":";;;;;;;;;;AAkCA,SAAS,kBAAA,CAAmB,IAAA,EAAgB,GAAA,EAAa,MAAA,EAAiB,MAAA,EAAsB;AAC9F,EAAA,KAAA,MAAW,IAAA,IAAQ,o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AA,CAAO,IAAA,EAAM,CAAA,CAAE,CAAA;AAAA,EACzF;AACA,EAAA,MAAM,OAAA,GAAU,GAAA,CAAI,MAAA,CAAO,IAAA,EAAK;AAGhC,EAAA,MAAM,QAAA,GAAW,MAAM,OAAA,CAAQ,OAAA;AAAA,IAC7B,UAAU,gBAAA,CAAiB,OAAO,CAAC,CAAA,kBAAA,EAAqB,gBAAA,CAAiB,GAAG,CAAC,CAAA;AAAA,GAC/E;AACA,EAAA,IAAI,QAAA,CAAS,aAAa,CAAA,EAAG;AAC3B,IAAA,MAAM,IAAI,kBAAA,CAAmB,UAAA,EAAY,CAAA,SAAA,EAAY,GAAG,YAAY,QAAA,CAAS,MAAA,CAAO,IAAA,EAAM,CAAA,CAAE,CAAA;AAAA,EAC9F;AAEA,EAAA,OAAO,EAAE,OAAA,EAAQ;AACnB","file":"index.js","sourcesContent":["// Promoted out of the agent-builder in M75 (plan m75-sandbox-kernel-no-framework, D1): kernel\n// confinement is framework infrastructure, not the consumer's. Measured cost of the promotion: ZERO\n// dependencies — only node:child_process, node:fs and node:path. The cBPF filter is a pure-JS Buffer.\n\nimport { execFileSync } from \"node:child_process\";\nimport { existsSync } from \"node:fs\";\nimport path from \"node:path\";\n\n/**\n * M53 — bubblewrap argv + honest detection, faithful to Codex's Linux sandbox\n * (`codex-rs/linux-sandbox/src/bwrap.rs` + `codex-rs/sandboxing/src/bwrap.rs`).\n *\n * HONEST SCOPE: filesystem confinement + network isolation via bwrap, PLUS the second stage —\n * a cBPF seccomp syscall filter (`agents/sandbox/seccomp.ts`), wired in `agents/sandbox/backend.ts`\n * via `restrictedSeccompPath()`. Ported in M63; this block claimed the opposite until M67 and\n * UNDER-DECLARED the real security posture. The honest limit that remains: the filter is **x86_64**\n * (an architecture guard refuses to install it on any other arch, with a WARN, and bwrap's FS/network\n * confinement still applies) **and** it is only installed when the network is restricted\n * (`backend.ts:87`, faithful to `landlock.rs:96-117`): with the network on there is no syscall\n * filter, only bwrap's FS confinement. `danger-full-access` skips bwrap entirely, mirroring\n * `bwrap.rs:245-252`. Deltas versus Codex remain documented in docs/CODEX-PARITY.md.\n */\n\n/**\n * Codex's three canonical modes. Defined HERE because they are sandbox vocabulary, not consumer\n * configuration: `danger-full-access` means \"do not wrap\", and that is a decision belonging to the\n * confinement subsystem.\n */\nexport type SandboxMode = \"read-only\" | \"workspace-write\" | \"danger-full-access\";\n\n/**\n * The RW binds `workspace-write` installs (protocol.rs:1189-1214), plus the metadata protection that\n * must sit ON TOP of them — order matters (permissions.rs:22-31; bwrap.rs:571-597).\n */\nfunction pushWorkspaceBinds(argv: string[], cwd: string, hasGit: boolean, gitDir: string): void {\n for (const root of workspaceWriteRoots(cwd)) argv.push(\"--bind\", root, root);\n if (hasGit) argv.push(\"--ro-bind\", gitDir, gitDir);\n}\n\n/** The RW binds `workspace-write` installs (protocol.rs:1189-1214): the workspace itself, and /tmp. */\nfunction workspaceWriteRoots(cwd: string): readonly string[] {\n return [cwd, \"/tmp\"];\n}\n\n/**\n * U-6 — the roots a mode may write to, answerable WITHOUT spawning anything.\n *\n * `[]` means nothing is writable; `null` means unrestricted — which is not the same as `[\"/\"]`,\n * because unrestricted is the absence of a root rather than a root that happens to be `/`.\n *\n * The SDK already knew this: `buildBwrapArgv` binds these exact paths. It only knew it while\n * BUILDING an argv, and a consumer needs the answer earlier — tools are scoped at agent\n * construction, before any process exists, and a file-write tool has to be told its root then. With\n * nothing to ask, consumers keep a second encoding of this three-mode vocabulary and it drifts from\n * the argv builder with nothing to catch it. This reads from the same helper the builder uses, so\n * the two cannot disagree.\n */\nexport function writableRootsFor(mode: SandboxMode, cwd: string): readonly string[] | null {\n switch (mode) {\n case \"read-only\":\n return [];\n case \"workspace-write\":\n return workspaceWriteRoots(cwd);\n case \"danger-full-access\":\n return null;\n }\n}\n\nexport interface BwrapArgvOptions {\n /** Workspace root — the single RW bind under `workspace-write` (protocol.rs:1189-1200). */\n cwd: string;\n /** `true` removes `--unshare-net` (policy `network_access`, default false). */\n network?: boolean;\n /** Injectable for tests; defaults to a real `existsSync` check on `<cwd>/.git`. */\n gitDirExists?: boolean;\n /**\n * When present, emit `--clearenv` and re-inject ONLY these vars (Codex env_clear model,\n * `exec_env.rs:25-31`). Closes the denylist gap: a secret in an oddly-named var never reaches the\n * sandboxed child. Omitted ⇒ inherit the parent env (backward-compatible; SDK scrub still applies).\n */\n env?: Record<string, string>;\n}\n\n/**\n * Pure argv builder. Returns the bwrap flags ending in `--` (caller appends `/bin/sh -c <cmd>`),\n * or `null` when the policy skips the sandbox entirely (`danger-full-access`).\n */\nexport function buildBwrapArgv(mode: SandboxMode, opts: BwrapArgvOptions): string[] | null {\n if (mode === \"danger-full-access\") return null; // bwrap skipped entirely (bwrap.rs:245-252)\n\n const cwd = path.resolve(opts.cwd);\n const gitDir = path.join(cwd, \".git\");\n const hasGit = opts.gitDirExists ?? existsSync(gitDir);\n\n const argv: string[] = [\n // core, always (bwrap.rs:318-332; user+pid namespaces explicit so it works as root in containers)\n \"--new-session\",\n \"--die-with-parent\",\n \"--unshare-user\",\n \"--unshare-pid\",\n // full-read filesystem base (bwrap.rs:446-452)\n \"--ro-bind\",\n \"/\",\n \"/\",\n \"--dev\",\n \"/dev\",\n \"--proc\",\n \"/proc\",\n ];\n\n if (!opts.network) argv.push(\"--unshare-net\"); // network off by default (bwrap.rs:325-327)\n\n // env confinement — `--clearenv` MUST precede every `--setenv` or the clear wipes them\n // (exec_env.rs:25-31 clears then rebuilds). Only when an explicit allowlist is provided.\n if (opts.env) argv.push(\"--clearenv\");\n const setenv: Record<string, string> = {\n ...(opts.env ?? {}),\n // the flag signals the child that network is unshared (spawn.rs:20,79)\n ...(opts.network ? {} : { CODEX_SANDBOX_NETWORK_DISABLED: \"1\" }),\n };\n for (const [k, v] of Object.entries(setenv)) argv.push(\"--setenv\", k, v);\n\n if (mode === \"workspace-write\") pushWorkspaceBinds(argv, cwd, hasGit, gitDir);\n // read-only: zero writable roots (protocol.rs:1176) — nothing to add\n\n argv.push(\"--chdir\", cwd, \"--\");\n return argv;\n}\n\n/** Injectable probes — each mirrors one Codex availability check. */\nexport interface BwrapProbes {\n /** `which bwrap` outside the cwd (anti-hijack, sandboxing/src/bwrap.rs:168-191). */\n which: () => string | null;\n /** `bwrap --help` text — must advertise `--perms` (launcher.rs:108-124). */\n helpText: (bin: string) => string | null;\n /** Active user-namespace probe with timeout (sandboxing/src/bwrap.rs:74-136). */\n userns: (bin: string) => boolean;\n}\n\nexport type BwrapDetection = { ok: true; bin: string } | { ok: false; reason: string };\n\n/** Honest detection — fail-closed on every probe; NEVER throws (callers WARN + fall back). */\nexport function detectBwrap(probes: BwrapProbes = realProbes): BwrapDetection {\n try {\n const bin = probes.which();\n if (!bin) return { ok: false, reason: \"bwrap not found in PATH\" };\n const help = probes.helpText(bin);\n if (!help?.includes(\"--perms\")) {\n return { ok: false, reason: `bwrap at ${bin} lacks --perms support (too old)` };\n }\n if (!probes.userns(bin)) {\n return { ok: false, reason: \"user namespaces unavailable (container/kernel restriction)\" };\n }\n return { ok: true, bin };\n } catch (err) {\n return {\n ok: false,\n reason: `bwrap probe failed: ${err instanceof Error ? err.message : String(err)}`,\n };\n }\n}\n\n/**\n * How many times the REAL probe ran in this process.\n *\n * Instrumented here rather than in a wrapper, because this is where the cost is: every `which`\n * spawns a subprocess (`which bwrap`), and the full probe cost 22.2 ms. A gate counting INJECTED\n * probes does not see the real one — that was the M71 gate's first mistake, and a mutant exposed it.\n */\nlet realProbeRuns = 0;\n\n/** How many real probes ran. TEST seam — the performance gate counts this. */\nexport function realProbeCount(): number {\n return realProbeRuns;\n}\n\n/** Real probes used in production. */\nexport const realProbes: BwrapProbes = {\n which: () => {\n realProbeRuns++;\n try {\n const out = execFileSync(\"which\", [\"bwrap\"], { encoding: \"utf8\", timeout: 2_000 }).trim();\n // anti-hijack: never accept a bwrap that lives inside the workspace (bwrap.rs:168-191)\n if (!out || out.startsWith(process.cwd() + path.sep)) return null;\n return out;\n } catch {\n return null;\n }\n },\n helpText: (bin) => {\n try {\n // bwrap --help exits 0/1 depending on version; capture output either way\n return execFileSync(bin, [\"--help\"], { encoding: \"utf8\", timeout: 2_000 });\n } catch (err) {\n const e = err as { stdout?: string; stderr?: string };\n return [e.stdout, e.stderr].filter(Boolean).join(\"\\n\") || null;\n }\n },\n userns: (bin) => {\n try {\n // active probe, 500ms budget like Codex (sandboxing/src/bwrap.rs:74-136)\n execFileSync(bin, [\"--unshare-user\", \"--unshare-net\", \"--ro-bind\", \"/\", \"/\", \"/bin/true\"], {\n timeout: 500,\n stdio: \"ignore\",\n });\n return true;\n } catch {\n return false;\n }\n },\n};\n\n/**\n * The probe result, memoized for the lifetime of the PROCESS.\n *\n * Measured before M71: `detectBwrap()` costs **22.2 ms** and was not memoized — the second call\n * cost 19.4 ms. `buildChatAgent` on the headless path fired **two** (one from\n * `createSandboxBackend`, another from `resolveSandboxPosture`, which M70 added), totalling 46.4 ms\n * per construction — and construction happens per turn. Under `strace`, ~90% of the 182 syscalls of\n * an already-warm construction came from here: `which` sweeping the PATH, `/proc/filesystems`,\n * `/newroot`, and the `.so` files the two probe subprocesses load.\n *\n * ## Why there is no invalidation\n *\n * The milestone called for invalidating on `SessionStart`. That does not work:\n * `agents/lib/hooks/hooks.ts:28-30` documents — as a **measured** correction of an earlier\n * assumption — that the event fires **once per TURN**, not per session. Invalidating there would\n * re-probe every turn, exactly the behavior memoization exists to eliminate.\n *\n * The reference does not invalidate either: Codex's only real cache is a write-once `OnceLock`\n * (`codex-rs/linux-sandbox/src/launcher.rs:52`), and its expensive probe runs once per process,\n * only to print a UI warning (`sandboxing/src/bwrap.rs:40-72`).\n *\n * **The price, stated plainly — in BOTH directions.** The original m71-cost-per-turn#ADR-1 declared\n * only one of them; the M71 review (F-perf-9) showed the omitted one was precisely the one with a\n * security consequence:\n *\n * - **Stale negative** (`bwrap` installed AFTERWARDS): not detected until restart. The system fails\n * CLOSED — the posture reports `enforced: false` and M70's veto **refuses**. Cost: annoyance (the\n * message tells you to install the bwrap you just installed). Accepted.\n * - **Stale positive** (`bwrap` removed/renamed AFTERWARDS): the posture would keep asserting\n * `enforced: true / \"kernel (bwrap)\"` and the veto would **approve**, citing a confinement that no\n * longer exists. That is the literal reintroduction of the defect M70 fixed — *\"telling the\n * operator they are protected when they are not is worse than saying nothing\"*. Before M71 the\n * per-turn re-probe closed that window on the next turn; memoization would leave it open for the\n * whole process. **That is why the positive is revalidated** below, at 1 syscall — 3 orders of\n * magnitude below the 22.2 ms of the full probe, which is the cost memoization exists to remove.\n */\nlet memo: BwrapDetection | undefined;\n\n/**\n * `detectBwrap` with memoization — what production should call.\n *\n * Note that `detectBwrap` itself does **not** memoize, on purpose: it accepts injected probes, and\n * memoizing there would let a test with fake probes poison the process cache for everyone else.\n *\n * Revalidating the positive is NOT a re-probe: `detectBwrap` spends three probes (a `which`\n * subprocess + `--help` + a user namespace). Here we only confirm the validated binary is still in\n * place. If it vanished, the memo is downgraded to a negative with the reason stated — never\n * promoted to a positive, which would require the expensive probe back.\n */\nexport function detectBwrapMemoized(probes: BwrapProbes = realProbes): BwrapDetection {\n memo ??= detectBwrap(probes);\n if (memo.ok && !existsSync(memo.bin)) {\n memo = { ok: false, reason: `bwrap disappeared from ${memo.bin} after detection` };\n }\n return memo;\n}\n\n/** TEST seam — clears the memo. Production never calls it (see m71-cost-per-turn#ADR-1). */\nexport function resetBwrapMemo(): void {\n memo = undefined;\n}\n","// Promoted from agent-builder in M75 (plan m75-sandbox-kernel-no-framework, D1): confinement with\n// kernel confinement is framework infrastructure, not the consumer's. Measured cost of the promotion: ZERO\n// no dependencies — only node:child_process, node:fs and node:path. The cBPF filter is a Buffer in pure JS.\n\n/**\n * M63 — cBPF seccomp filter generator, byte-faithful to Codex's Linux sandbox\n * (`codex-rs/linux-sandbox/src/landlock.rs:179-216`). Produces a raw `sock_filter[]` program (the exact\n * shape `bwrap --seccomp <fd>` consumes) so agent-builder ports Codex's syscall confinement WITHOUT a\n * native helper — bwrap applies `PR_SET_NO_NEW_PRIVS` + the filter before `execve`.\n *\n * Semantics (landlock.rs:252-253): default action = ALLOW; per-syscall match = ERRNO(EPERM). KILL is\n * used ONLY by the architecture/x32 guard. x86_64 only in v1 (aarch64 is a documented delta).\n */\n\n// BPF opcodes (linux/bpf_common.h)\nconst BPF_LD = 0x00;\nconst BPF_W = 0x00;\nconst BPF_ABS = 0x20;\nconst BPF_JMP = 0x05;\nconst BPF_JEQ = 0x10;\nconst BPF_JGE = 0x30;\nconst BPF_K = 0x00;\nconst BPF_RET = 0x06;\n\nconst LD_ABS_W = BPF_LD | BPF_W | BPF_ABS; // 0x20\nconst JEQ_K = BPF_JMP | BPF_JEQ | BPF_K; // 0x15\nconst JGE_K = BPF_JMP | BPF_JGE | BPF_K; // 0x35\nconst RET_K = BPF_RET | BPF_K; // 0x06\n\n// seccomp_data offsets (little-endian): nr@0, arch@4, args[0] low dword @16\nconst OFF_NR = 0;\nconst OFF_ARCH = 4;\nconst OFF_ARG0 = 16;\n\nconst AUDIT_ARCH_X86_64 = 0xc000003e;\nconst X32_BIT = 0x40000000; // nr >= this ⇒ x32 ABI ⇒ reject\n\n// seccomp return actions (linux/seccomp.h)\nconst SECCOMP_RET_ALLOW = 0x7fff0000;\nconst SECCOMP_RET_ERRNO = 0x00050000;\nconst EPERM = 1;\nconst RET_EPERM = SECCOMP_RET_ERRNO | (EPERM & 0xffff); // 0x00050001\nconst SECCOMP_RET_KILL_PROCESS = 0x80000000;\n\nconst AF_UNIX = 1;\n\n/** Always-denied, network-independent (landlock.rs:179-184). */\nconst ALWAYS_DENIED = [101, 310, 311, 425, 426, 427]; // ptrace, process_vm_readv/writev, io_uring_setup/enter/register\n/** Denied only when the network is restricted (landlock.rs:188-204). recvfrom(45)/sendmsg(46) are NOT here. */\nconst NETWORK_DENIED = [42, 43, 288, 49, 50, 52, 51, 48, 44, 307, 299, 55, 54];\n/** socket(2) / socketpair(2) — conditional on domain != AF_UNIX (landlock.rs:206-216). */\nconst SOCKET_SYSCALLS = [41, 53];\n\n/** One `sock_filter` instruction: `{u16 code, u8 jt, u8 jf, u32 k}`. */\ninterface Insn {\n code: number;\n jt: number;\n jf: number;\n k: number;\n}\nconst stmt = (code: number, k: number): Insn => ({ code, jt: 0, jf: 0, k });\nconst jmp = (code: number, k: number, jt: number, jf: number): Insn => ({ code, jt, jf, k });\n\nexport interface SeccompOptions {\n /** When true (network off), also deny the socket set + non-AF_UNIX socket(). */\n networkRestricted: boolean;\n}\n\n/**\n * Build the cBPF seccomp program as a `Buffer` (each `sock_filter` = 8 bytes). Jump targets are\n * expressed against labels and back-patched to relative offsets, so the layout is deterministic and\n * unit-testable against the authoritative syscall list.\n */\nexport function buildSeccompFilter(opts: SeccompOptions): Buffer {\n // We assemble with symbolic targets, then resolve to relative jumps. To keep the classic\n // \"deny → jump to a single DENY return; else fall through\" shape, DENY and ALLOW live at the END and\n // every JEQ jumps FORWARD to them. jt/jf carry the DISTANCE (in instructions) to the target.\n const insns: Insn[] = [];\n\n // Placeholder labels resolved after we know total length.\n // Layout: [arch guard][x32 guard][LD nr][deny checks...][socket checks...][ALLOW][DENY][KILL]\n // We build the body first with jumps to ALLOW/DENY/KILL as sentinel indices, then patch.\n const ALLOW = Symbol(\"ALLOW\");\n const DENY = Symbol(\"DENY\");\n const KILL = Symbol(\"KILL\");\n type Target = typeof ALLOW | typeof DENY | typeof KILL | number;\n interface SInsn {\n code: number;\n k: number;\n jt: Target;\n jf: Target;\n }\n const body: SInsn[] = [];\n const push = (code: number, k: number, jt: Target = 0, jf: Target = 0): void => {\n body.push({ code, k, jt, jf });\n };\n\n // --- arch guard: arch == x86_64 ? continue : KILL ---\n push(LD_ABS_W, OFF_ARCH);\n push(JEQ_K, AUDIT_ARCH_X86_64, 0, KILL); // if != → KILL\n // --- x32 guard: nr >= 0x40000000 ? KILL : continue ---\n push(LD_ABS_W, OFF_NR);\n push(JGE_K, X32_BIT, KILL, 0); // if >= → KILL\n // nr already loaded; keep it loaded for the deny checks.\n\n // --- unconditional denials → DENY ---\n const denied = opts.networkRestricted\n ? [...ALWAYS_DENIED, ...NETWORK_DENIED]\n : [...ALWAYS_DENIED];\n for (const nr of denied) push(JEQ_K, nr, DENY, 0); // if nr == syscall → DENY\n\n // --- socket-family: socket(41)/socketpair(53) → allow only AF_UNIX (only when restricted) ---\n if (opts.networkRestricted) {\n for (const sysno of SOCKET_SYSCALLS) {\n // if nr == socket → check domain; else skip the 2 domain-check instructions\n push(JEQ_K, sysno, 0, 2); // match: fall through to the LD/JEQ; no-match: jump +2 (past them)\n push(LD_ABS_W, OFF_ARG0); // load domain (args[0] low dword)\n push(JEQ_K, AF_UNIX, ALLOW, DENY); // AF_UNIX → ALLOW, else DENY\n // NOTE: after these, nr is NO LONGER in the accumulator — but every remaining syscall check\n // reloads via a fresh LD? No: the remaining path is only ALLOW. socket checks are LAST before\n // the tail, so a fall-through (non-socket syscall that reached here) goes straight to ALLOW.\n }\n }\n\n // --- tail ---\n push(RET_K, SECCOMP_RET_ALLOW); // ALLOW label target\n const allowIdx = body.length - 1;\n push(RET_K, RET_EPERM); // DENY\n const denyIdx = body.length - 1;\n push(RET_K, SECCOMP_RET_KILL_PROCESS); // KILL\n const killIdx = body.length - 1;\n\n // --- resolve symbolic targets to relative offsets ---\n // The branching IS the cBPF program: ALLOW/DENY/KILL are symbolic targets resolved to an\n // offset RELATIVE to the next instruction. Breaking it into helpers does not reduce real complexity —\n // it moves the jump arithmetic to another file and makes auditing against landlock.rs harder, the\n // the authoritative source.\n //\n // Not refactoring NOW is an M75 process decision: this function is being MIGRATED without behavior\n // change (plan m75, D4) and there is still no byte-for-byte equivalence oracle against the\n // original version. Refactoring security without that oracle is changing the lock in the dark.\n // Revisit when the parity gate (T4.2) is green — the oracle exists then.\n // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: see the reason just above\n const resolve = (i: number, t: Target): number => {\n const abs = t === ALLOW ? allowIdx : t === DENY ? denyIdx : t === KILL ? killIdx : i + 1 + t;\n // BPF jump offset is relative to the NEXT instruction: target - (i + 1)\n const off = abs - (i + 1);\n if (off < 0 || off > 255) throw new RangeError(`seccomp jump out of range at ${i}: ${off}`);\n return off;\n };\n // `for...of` over entries instead of a raw index: the SDK compiles with `noUncheckedIndexedAccess`, which\n // (correctly) types `body[i]` as possibly undefined. Iterating gives the guarantee in the type instead\n // requiring a `!` — the code already could not leave the range, and now the compiler knows it.\n for (const [i, b] of body.entries()) {\n if (b.code === JEQ_K || b.code === JGE_K) {\n insns.push(jmp(b.code, b.k, resolve(i, b.jt), resolve(i, b.jf)));\n } else {\n insns.push(stmt(b.code, b.k));\n }\n }\n\n const buf = Buffer.alloc(insns.length * 8);\n insns.forEach((ins, i) => {\n buf.writeUInt16LE(ins.code, i * 8);\n buf.writeUInt8(ins.jt, i * 8 + 2);\n buf.writeUInt8(ins.jf, i * 8 + 3);\n buf.writeUInt32LE(ins.k >>> 0, i * 8 + 4);\n });\n return buf;\n}\n","// Promoted from agent-builder in M75 (plan m75-sandbox-kernel-no-framework, D1). Renamed from\n// `BwrapSandbox` to `LinuxSandbox`: bwrap is the IMPLEMENTATION, Linux is the contract — swapping the\n// mechanism (landlock, for example) should not change the name the consumer imports.\n\nimport { mkdtempSync, rmSync, writeFileSync } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { dirname, join } from \"node:path\";\n\nimport { redactSecrets } from \"../internal/security/redact.js\";\nimport type { BwrapDetection, SandboxMode } from \"./bwrap.js\";\nimport { buildBwrapArgv, detectBwrapMemoized } from \"./bwrap.js\";\nimport { LocalSandbox } from \"./local-sandbox.js\";\nimport { buildSeccompFilter } from \"./seccomp.js\";\nimport type { SandboxBackend, SandboxConfig } from \"./types.js\";\n\n/**\n * M53 — kernel-enforced sandbox backend, injected into `createShellTool({ sandbox })`.\n *\n * `LinuxSandbox extends LocalSandbox` and only REWRITES the command: `<bwrap-bin> <policy flags> --\n * /bin/sh -c '<original>'`. Everything else (spawn, output caps, timeout, ExecuteResult shape, file\n * ops) is inherited — the SDK backend stays the single execution engine. Mirrors Codex's\n * `SandboxManager::transform` (argv prefixing before spawn, never in-process).\n */\n\n/** POSIX single-quote escaping — the inner command crosses ONE extra `/bin/sh -c` boundary. */\nfunction shellQuote(s: string): string {\n return `'${s.replaceAll(\"'\", `'\\\\''`)}'`;\n}\n\n/**\n * M57 — the single source of truth for the sandbox command wrap. Turns `command` into\n * `<bin> <bwrap flags> [--seccomp 3] -- /bin/sh -c '<command>' [3< <bpf>]`, or `null` when the policy\n * skips the sandbox (`danger-full-access`). Extracted from `LinuxSandbox.wrapCommand` so the interactive\n * PTY backend (M57) can reuse the EXACT wrap the one-shot `run_shell` already uses (DRY) — faithful to\n * Codex, where the sandbox transforms the argv before the PTY spawns it (`sandboxing/src/manager.rs:321`).\n */\nexport function wrapCommandForSandbox(\n mode: SandboxMode,\n opts: {\n cwd: string;\n network?: boolean;\n env?: Record<string, string>;\n bin?: string;\n seccompPath?: string;\n },\n command: string,\n): string | null {\n const argv = buildBwrapArgv(mode, { cwd: opts.cwd, network: opts.network, env: opts.env });\n if (argv === null) return null; // danger-full-access: bwrap skipped\n const bin = opts.bin ?? \"bwrap\";\n const seccompArgv = opts.seccompPath !== undefined ? [\"--seccomp\", \"3\"] : [];\n const base = `${shellQuote(bin)} ${[...argv.slice(0, -1), ...seccompArgv, \"--\"].map(shellQuote).join(\" \")} /bin/sh -c ${shellQuote(command)}`;\n return opts.seccompPath !== undefined ? `${base} 3< ${shellQuote(opts.seccompPath)}` : base;\n}\n\n/**\n * Env allowlist re-injected inside the sandbox after `--clearenv`. Codex env_clear model: the child\n * gets exactly what it needs to run a shell, never the parent's full env (which may hold oddly-named\n * secrets the SDK name-pattern scrub misses). `CODEX_SANDBOX_NETWORK_DISABLED` is added by the argv\n * builder when network is unshared.\n */\nconst ENV_ALLOWLIST = [\n \"PATH\",\n \"HOME\",\n \"LANG\",\n \"LC_ALL\",\n \"LC_CTYPE\",\n \"TERM\",\n \"USER\",\n \"TMPDIR\",\n \"SHELL\",\n];\n\nexport function allowlistedEnv(source: NodeJS.ProcessEnv = process.env): Record<string, string> {\n const out: Record<string, string> = {};\n for (const k of ENV_ALLOWLIST) {\n const v = source[k];\n if (v !== undefined) out[k] = v;\n }\n return out;\n}\n\nexport class LinuxSandbox extends LocalSandbox {\n private readonly mode: SandboxMode;\n private readonly network: boolean;\n private readonly cwd: string;\n private readonly bin: string;\n private readonly env: Record<string, string>;\n /** M63 — path to the cBPF seccomp program written host-side; passed to `bwrap --seccomp 3` via a\n * shell redirect. `undefined` when the network is unrestricted OR generation failed (honest fallback). */\n private readonly seccompPath: string | undefined;\n\n constructor(\n config: SandboxConfig,\n opts: { mode: SandboxMode; network?: boolean; bin?: string; env?: Record<string, string> },\n ) {\n super(config);\n this.mode = opts.mode;\n this.network = opts.network ?? false;\n this.cwd = config.workDir ?? process.cwd();\n // MEDIUM-1: run the VALIDATED absolute binary from detection (anti-hijack), never bare `bwrap`\n // which the outer shell would re-resolve via $PATH at spawn time (TOCTOU / hijack window).\n this.bin = opts.bin ?? \"bwrap\";\n this.env = opts.env ?? allowlistedEnv();\n this.seccompPath = seccompPathForNetwork(this.network);\n }\n\n /** Extracted for test visibility — delegates to the pure `wrapCommandForSandbox` (M57, single wrap SoT). */\n wrapCommand(command: string): string | null {\n return wrapCommandForSandbox(\n this.mode,\n {\n cwd: this.cwd,\n network: this.network,\n env: this.env,\n bin: this.bin,\n seccompPath: this.seccompPath,\n },\n command,\n );\n }\n\n /**\n * M75 review (architecture, HIGH) — without this override the class LIED.\n *\n * `LinuxSandbox` documents itself as a \"kernel-enforced sandbox backend\", but it overrode only\n * `execute`. `uploadFile` stayed the one inherited from `LocalSandbox`, which writes straight to\n * the host via `fs/promises` and accepts an ABSOLUTE path — no bwrap, no seccomp, no path\n * restriction. And `SandboxBackend.writeFile` delegates to it. The result was an incoherent class:\n * reading, searching and listing went through the confinement; writing did not.\n *\n * Routing through the wrapped `execute` fixes it at the root: writes come to live under the SAME\n * policy as everything else — if bwrap denies the path, the write fails, as it should. The content\n * goes over stdin (not argv) because argv has a size limit and file content does not.\n */\n override async uploadFile(path: string, content: string | Buffer): Promise<void> {\n if (this.mode === \"danger-full-access\") return super.uploadFile(path, content);\n\n const target = path.startsWith(\"/\") ? path : `${this.cwd}/${path}`;\n const b64 = Buffer.from(content).toString(\"base64\");\n // base64 on a single line: avoids any shell quoting over arbitrary content, which is exactly\n // where a \"confined\" write would turn into command injection.\n const r = await this.execute(\n `mkdir -p ${shellQuote(dirname(target))} && printf %s ${shellQuote(b64)} | base64 -d > ${shellQuote(target)}`,\n );\n if (r.exitCode !== 0) {\n throw new Error(\n `uploadFile blocked or failed under confinement (${target}): ${r.stderr.trim() || `exit ${r.exitCode}`}`,\n );\n }\n }\n\n override execute(command: string, opts?: { timeoutMs?: number }) {\n const wrapped = this.wrapCommand(command);\n if (wrapped === null) return super.execute(command, opts); // danger-full-access: plain local\n return super.execute(wrapped, opts);\n }\n}\n\nlet warnedNonX64 = false;\n\n/**\n * M63 — the restricted-network seccomp program is DETERMINISTIC, so write it ONCE per process and\n * reuse the path across every LinuxSandbox (no per-instance temp accumulation).\n *\n * ARCH GUARD (review HIGH): `buildSeccompFilter` emits an x86_64 program whose arch guard KILLs every\n * syscall whose `seccomp_data.arch != AUDIT_ARCH_X86_64`. On a non-x86_64 host that would brick EVERY\n * sandboxed command (the first execve is killed) — and silently, because generation succeeds and bwrap\n * accepts it. So we REFUSE to install on non-x64 and WARN through the honest-downgrade channel (bwrap\n * FS/network confinement still applies), exactly like the bwrap-missing fallback. `arch` is injectable\n * for tests. Cleaned on exit AND on SIGINT/SIGTERM (TUI Ctrl+C would otherwise leak the temp dir).\n */\nexport function seccompPathForArch(arch: string, warn: (m: string) => void): string | undefined {\n if (arch !== \"x64\") {\n if (!warnedNonX64) {\n warnedNonX64 = true;\n warn(\n `[sandbox] seccomp syscall filter unsupported on ${arch} (x86_64 only in v1) — running without ` +\n \"the filter; bwrap FS/network confinement still applies.\",\n );\n }\n return undefined;\n }\n try {\n const dir = mkdtempSync(join(tmpdir(), \"ab-seccomp-\"));\n const path = join(dir, \"filter.bpf\");\n writeFileSync(path, buildSeccompFilter({ networkRestricted: true }));\n const cleanup = (): void => rmSync(dir, { recursive: true, force: true });\n process.once(\"exit\", cleanup);\n process.once(\"SIGINT\", cleanup);\n process.once(\"SIGTERM\", cleanup);\n return path;\n } catch (err) {\n warn(\n `[sandbox] seccomp filter unavailable (${err instanceof Error ? err.message : String(err)}) — ` +\n \"running without syscall filter (bwrap FS/network confinement still applies).\",\n );\n return undefined;\n }\n}\n\nlet seccompFilterPath: string | undefined | null; // undefined = not tried; null = resolved absent\n/** M57 — exported so the interactive PTY backend reuses the SAME memoized x64-gated seccomp program. */\nexport function restrictedSeccompPath(): string | undefined {\n if (seccompFilterPath !== undefined) return seccompFilterPath ?? undefined;\n const path = seccompPathForArch(process.arch, (m) => console.warn(redactSecrets(m)));\n seccompFilterPath = path ?? null;\n return path;\n}\n\nlet warnedUnavailable = false;\n\n/** Test seam: reset the WARN-once latch. */\nexport function resetSandboxWarnLatch(): void {\n warnedUnavailable = false;\n}\n\n/** Durable sandbox posture for the UI — the honest answer to \"am I kernel-enforced right now?\". */\nexport interface SandboxPosture {\n mode: SandboxMode;\n enforced: boolean;\n detail: string;\n}\n\n/**\n * MEDIUM-2: compute the posture so a surface (TUI footer) can show enforcement DURABLY instead of a\n * one-shot warn. `danger-full-access` is honestly reported as unenforced; an unavailable bwrap reports\n * the downgrade reason so the user never believes they are confined when they are not.\n */\nexport function resolveSandboxPosture(opts: {\n mode: SandboxMode;\n detect?: () => BwrapDetection;\n}): SandboxPosture {\n if (opts.mode === \"danger-full-access\") {\n return { mode: opts.mode, enforced: false, detail: \"no confinement (danger-full-access)\" };\n }\n const detection = (opts.detect ?? detectBwrapMemoized)();\n if (!detection.ok) {\n return { mode: opts.mode, enforced: false, detail: `tool-gating only — ${detection.reason}` };\n }\n return { mode: opts.mode, enforced: true, detail: \"kernel (bwrap)\" };\n}\n\nexport interface CreateSandboxBackendOptions {\n mode: SandboxMode;\n workDir?: string;\n network?: boolean;\n timeoutMs?: number;\n /** Injectable for tests; defaults to the real 3-probe detection. */\n detect?: () => BwrapDetection;\n /** Injectable for tests; defaults to console.warn. */\n warn?: (message: string) => void;\n}\n\n/**\n * Honest factory: bwrap available + mode wants confinement → `LinuxSandbox` (kernel enforcement,\n * running the VALIDATED absolute bin); `danger-full-access` → plain `LocalSandbox` silently (explicit\n * opt-out, `bwrap.rs:245-252`); bwrap unavailable → WARN once + `LocalSandbox` (the declarative M23\n * gating remains the guard). NEVER pretends to sandbox — the fallback is loud, mirroring Codex's\n * MISSING_BWRAP_WARNING. The durable posture lives in `resolveSandboxPosture` for the UI.\n */\nexport function createSandboxBackend(opts: CreateSandboxBackendOptions): SandboxBackend {\n const config: SandboxConfig = { workDir: opts.workDir, timeoutMs: opts.timeoutMs };\n if (opts.mode === \"danger-full-access\") return new LocalSandbox(config);\n\n const detection = (opts.detect ?? detectBwrapMemoized)();\n if (!detection.ok) {\n if (!warnedUnavailable) {\n warnedUnavailable = true;\n const warn = opts.warn ?? ((m: string) => console.warn(redactSecrets(m)));\n warn(\n `[sandbox] OS-level enforcement unavailable (${detection.reason}) — ` +\n `falling back to tool-level gating only (sandbox_mode=${opts.mode}).`,\n );\n }\n return new LocalSandbox(config);\n }\n return new LinuxSandbox(config, { mode: opts.mode, network: opts.network, bin: detection.bin });\n}\n\n/**\n * M75 T3.2 — warning latch for the INTERACTIVE path.\n *\n * Kept separate from `createSandboxBackend`'s latch on purpose: they are two distinct decisions\n * taken at distinct moments, and a user who only ever runs an interactive shell needs to see the\n * warning even if the non-interactive path already emitted it — otherwise the session where they\n * actually type commands would be the one without the alert.\n */\nlet interactiveWarned = false;\n\n/** Reset for tests — the latch is module state and tests need isolation. */\nexport function resetInteractiveWarnLatch(): void {\n interactiveWarned = false;\n}\n\n/**\n * The rule \"seccomp ONLY with restricted network\" — in ONE place.\n *\n * Codex installs the filter only when the network is closed (`landlock.rs:96-117`), and that is not\n * a detail: the cBPF program **denies the network syscalls** (`NETWORK_DENIED`). Applying it with\n * the network open produces the worst possible combination — bwrap **allows** the network (no\n * `--unshare-net`) and seccomp **denies** it with EPERM. The user asked for network, got the bind,\n * and the calls die.\n *\n * It existed duplicated: the constructor decided conditionally, `interactiveWrapCommand` installed\n * unconditionally. They had already diverged in the first version (M75 architecture review, proven\n * at runtime: `network:true` gave `--seccomp` interactively and not one-shot). Two copies of a\n * security rule is not duplicated form — it is duplicated KNOWLEDGE, and it had already diverged.\n */\nfunction seccompPathForNetwork(networkOpen: boolean): string | undefined {\n return networkOpen ? undefined : restrictedSeccompPath();\n}\n\nexport interface InteractiveWrapOptions {\n mode: SandboxMode;\n /** `true` keeps the network. Default `false`, same as non-interactive `run_shell`. */\n network?: boolean;\n /** Injectable for tests; defaults to the real memoized detection. */\n detect?: () => BwrapDetection;\n /** Injectable for tests; defaults to `console.warn` with redaction. */\n warn?: (message: string) => void;\n}\n\n/**\n * The decision to confine or degrade, separated from the wrap itself.\n *\n * Extracted because they are two responsibilities and the SDK's complexity gate separated them for\n * us: DECIDING (is confinement available? did the user opt out?) and APPLYING (assembling the argv).\n * Keeping them together pushed the closure past 10 cognitive complexity — and the linter was right:\n * the deciding part is the one with security consequences and deserves to be read on its own.\n *\n * Returns the validated binary when confinement exists, or `null` when it does not — warning ONCE,\n * and only when the absence is a failure (not when it is an opt-out).\n */\nfunction decideConfinement(opts: InteractiveWrapOptions): string | null {\n if (opts.mode === \"danger-full-access\") return null;\n\n const detection = (opts.detect ?? detectBwrapMemoized)();\n if (detection.ok) return detection.bin;\n\n if (!interactiveWarned) {\n interactiveWarned = true;\n const warn = opts.warn ?? ((m: string) => console.warn(redactSecrets(m)));\n warn(\n `[sandbox] OS-level enforcement unavailable (${detection.reason}) — interactive session ` +\n `runs WITHOUT kernel confinement (sandbox_mode=${opts.mode}).`,\n );\n }\n return null;\n}\n\n/**\n * The composition the interactive path needs — the counterpart of `createSandboxBackend`.\n *\n * `createSandboxBackend` solves this for the non-interactive path by returning a ready BACKEND. The\n * PTY accepts no backend: it owns the spawn and only allows transforming the command. This function\n * delivers the SAME decision in the shape the PTY accepts — `(command, cwd) => string | null` —\n * ready for `new PtyInteractiveBackend({ wrapCommand: interactiveWrapCommand({ mode }) })`.\n *\n * Detection is consulted on **every wrap**, not frozen at construction: an interactive session lives\n * for hours, and a stale positive detection would keep asserting confinement after the binary\n * disappeared (the `existsSync` revalidation lives inside `detectBwrapMemoized`).\n *\n * The two routes returning `null` are semantically different and the code does not merge them:\n * `danger-full-access` is an explicit opt-out and does NOT warn; bwrap being unavailable is a\n * failure and warns once.\n */\nexport function interactiveWrapCommand(\n opts: InteractiveWrapOptions,\n): (command: string, cwd: string) => string | null {\n return (command: string, cwd: string): string | null => {\n const bin = decideConfinement(opts);\n if (bin === null) return null;\n\n return wrapCommandForSandbox(\n opts.mode,\n {\n cwd,\n network: opts.network ?? false,\n env: allowlistedEnv(),\n bin,\n seccompPath: seccompPathForNetwork(opts.network ?? false),\n },\n command,\n );\n };\n}\n","/**\n * M6-3 — portable repo provisioner for the eval harness.\n *\n * Clones a repository and checks out a ref into an isolated working dir, issuing\n * every git command through {@link SandboxBackend.execute} (ADR D2 — same code\n * runs on Local/Docker/E2B; never a direct `child_process` import). Promotes\n * theocode's `prepareRepo` (`swebench-provision.ts:37`) onto the SDK's sandbox\n * abstraction.\n *\n * reference: knowledge-base/references/theocode-eval/lib/swebench-provision.ts:37\n * (clone+checkout), :13 (ProvisionError with instanceId).\n *\n * @public\n */\n\nimport { TheokitAgentError } from \"../errors.js\";\nimport { LocalSandbox } from \"./local-sandbox.js\";\nimport { shellEscapePosix } from \"./shell-escape.js\";\nimport type { SandboxBackend } from \"./types.js\";\n\n/**\n * Raised when cloning or checking out a repo fails. Carries the `instanceId`\n * so a batch run can attribute the failure to the offending dataset row.\n */\nexport class RepoProvisionError extends TheokitAgentError {\n override readonly name = \"RepoProvisionError\";\n\n constructor(\n readonly instanceId: string,\n message: string,\n options: { cause?: unknown } = {},\n ) {\n super(`[${instanceId}] ${message}`, {\n code: \"repo_provision_failed\",\n isRetryable: false,\n ...(options.cause !== undefined ? { cause: options.cause } : {}),\n });\n }\n}\n\n/** Options for {@link provisionRepo}. */\nexport interface ProvisionRepoOptions {\n /**\n * Clonable repo URL or local path. SECURITY: when this comes from an\n * untrusted dataset, the value is passed to `git clone` after a `--`\n * end-of-options terminator (no flag injection) and with the `ext::`\n * transport disabled (no arbitrary-command transport).\n */\n readonly repoUrl: string;\n /** Branch, tag, or commit SHA to check out. Rejected if it begins with `-`. */\n readonly ref: string;\n /**\n * Unique id for this row — names the target dir and any error. Validated to\n * `[A-Za-z0-9._-]` (no path traversal) since it becomes a directory name.\n */\n readonly instanceId: string;\n}\n\n/**\n * Reject ids that would escape the workdir or be parsed as a git flag. Must\n * start with an alphanumeric (blocks `.`, `..`, `-foo`, leading-dot names) and\n * thereafter allow only `[A-Za-z0-9._-]`.\n */\nconst SAFE_INSTANCE_ID = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;\n\n/**\n * Clone `repoUrl` into `<sandbox workdir>/<instanceId>` and check out `ref`.\n * Returns the absolute `repoDir` (resolved via `git rev-parse --show-toplevel`,\n * which is portable across backends). Throws {@link RepoProvisionError} naming\n * the `instanceId` when clone or checkout exits non-zero.\n *\n * The `sandbox` is optional (V3-5): when omitted, a default {@link LocalSandbox}\n * is used (clones into the process cwd's `<instanceId>`) — pass an explicit\n * sandbox (e.g. `LocalSandbox({ workDir })` / Docker / E2B) to control the workdir.\n */\nexport function provisionRepo(opts: ProvisionRepoOptions): Promise<{ repoDir: string }>;\nexport function provisionRepo(\n sandbox: SandboxBackend,\n opts: ProvisionRepoOptions,\n): Promise<{ repoDir: string }>;\nexport async function provisionRepo(\n sandboxOrOpts: SandboxBackend | ProvisionRepoOptions,\n maybeOpts?: ProvisionRepoOptions,\n): Promise<{ repoDir: string }> {\n const sandbox = maybeOpts !== undefined ? (sandboxOrOpts as SandboxBackend) : new LocalSandbox();\n const opts = maybeOpts ?? (sandboxOrOpts as ProvisionRepoOptions);\n const { repoUrl, ref, instanceId } = opts;\n\n // Validate untrusted-derivable inputs before they reach git/the shell.\n if (!SAFE_INSTANCE_ID.test(instanceId)) {\n throw new RepoProvisionError(\n instanceId,\n \"invalid instanceId: must match [A-Za-z0-9._-] (no path traversal)\",\n );\n }\n if (ref.startsWith(\"-\")) {\n throw new RepoProvisionError(instanceId, `invalid ref: must not begin with '-' (got ${ref})`);\n }\n\n // `--` terminates options (no `--upload-pack=` flag injection); `protocol.ext.allow=never`\n // blocks the `ext::` arbitrary-command transport. `file`/`https` stay allowed.\n const clone = await sandbox.execute(\n `git -c protocol.ext.allow=never clone --quiet -- ${shellEscapePosix(repoUrl)} ${shellEscapePosix(instanceId)}`,\n );\n if (clone.exitCode !== 0) {\n throw new RepoProvisionError(instanceId, `clone failed: ${clone.stderr.trim()}`);\n }\n\n const top = await sandbox.execute(\n `git -C ${shellEscapePosix(instanceId)} rev-parse --show-toplevel`,\n );\n if (top.exitCode !== 0) {\n throw new RepoProvisionError(instanceId, `resolve repoDir failed: ${top.stderr.trim()}`);\n }\n const repoDir = top.stdout.trim();\n\n // `ref` is validated above not to begin with `-`, so it cannot be parsed as a flag.\n const checkout = await sandbox.execute(\n `git -C ${shellEscapePosix(repoDir)} checkout --quiet ${shellEscapePosix(ref)}`,\n );\n if (checkout.exitCode !== 0) {\n throw new RepoProvisionError(instanceId, `checkout ${ref} failed: ${checkout.stderr.trim()}`);\n }\n\n return { repoDir };\n}\n"]}
1
+ {"version":3,"sources":["../../src/sandbox/bwrap.ts","../../src/sandbox/seccomp.ts","../../src/sandbox/linux-sandbox.ts","../../src/sandbox/provision.ts"],"names":["path"],"mappings":";;;;;;;;;;AAiCA,SAAS,kBAAA,CAAmB,IAAA,EAAgB,GAAA,EAAa,MAAA,EAAiB,MAAA,EAAsB;AAC9F,EAAA,KAAA,MAAW,IAAA,IAAQ,oBAAoB,GAAG,CAAA,OAAQ,IAAA,CA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AAA;AAAA,EACzF;AACA,EAAA,MAAM,OAAA,GAAU,GAAA,CAAI,MAAA,CAAO,IAAA,EAAK;AAGhC,EAAA,MAAM,QAAA,GAAW,MAAM,OAAA,CAAQ,OAAA;AAAA,IAC7B,UAAU,gBAAA,CAAiB,OAAO,CAAC,CAAA,kBAAA,EAAqB,gBAAA,CAAiB,GAAG,CAAC,CAAA;AAAA,GAC/E;AACA,EAAA,IAAI,QAAA,CAAS,aAAa,CAAA,EAAG;AAC3B,IAAA,MAAM,IAAI,kBAAA,CAAmB,UAAA,EAAY,CAAA,SAAA,EAAY,GAAG,YAAY,QAAA,CAAS,MAAA,CAAO,IAAA,EAAM,CAAA,CAAE,CAAA;AAAA,EAC9F;AAEA,EAAA,OAAO,EAAE,OAAA,EAAQ;AACnB","file":"index.js","sourcesContent":["// Promoted out of the agent-builder in M75 (plan m75-sandbox-kernel-no-framework, D1): kernel\n// confinement is framework infrastructure, not the consumer's. Measured cost of the promotion: ZERO\n// dependencies — only node:child_process, node:fs and node:path. The cBPF filter is a pure-JS Buffer.\n\nimport { execFileSync } from \"node:child_process\";\nimport { existsSync } from \"node:fs\";\nimport path from \"node:path\";\n\n/**\n * M53 — bubblewrap argv + honest detection.\n *\n * HONEST SCOPE: filesystem confinement + network isolation via bwrap, PLUS the second stage —\n * a cBPF seccomp syscall filter (`agents/sandbox/seccomp.ts`), wired in `agents/sandbox/backend.ts`\n * via `restrictedSeccompPath()`. Ported in M63; this block claimed the opposite until M67 and\n * UNDER-DECLARED the real security posture. The honest limit that remains: the filter is **x86_64**\n * (an architecture guard refuses to install it on any other arch, with a WARN, and bwrap's FS/network\n * confinement still applies) **and** it is only installed when the network is restricted\n * (`backend.ts:87`, faithful to `landlock.rs:96-117`): with the network on there is no syscall\n * filter, only bwrap's FS confinement. `danger-full-access` skips bwrap entirely, mirroring\n * `bwrap.rs:245-252`. Deltas versus Codex remain documented in docs/CODEX-PARITY.md.\n */\n\n/**\n * Codex's three canonical modes. Defined HERE because they are sandbox vocabulary, not consumer\n * configuration: `danger-full-access` means \"do not wrap\", and that is a decision belonging to the\n * confinement subsystem.\n */\nexport type SandboxMode = \"read-only\" | \"workspace-write\" | \"danger-full-access\";\n\n/**\n * The RW binds `workspace-write` installs (protocol.rs:1189-1214), plus the metadata protection that\n * must sit ON TOP of them — order matters (permissions.rs:22-31; bwrap.rs:571-597).\n */\nfunction pushWorkspaceBinds(argv: string[], cwd: string, hasGit: boolean, gitDir: string): void {\n for (const root of workspaceWriteRoots(cwd)) argv.push(\"--bind\", root, root);\n if (hasGit) argv.push(\"--ro-bind\", gitDir, gitDir);\n}\n\n/** The RW binds `workspace-write` installs (protocol.rs:1189-1214): the workspace itself, and /tmp. */\nfunction workspaceWriteRoots(cwd: string): readonly string[] {\n return [cwd, \"/tmp\"];\n}\n\n/**\n * U-6 — the roots a mode may write to, answerable WITHOUT spawning anything.\n *\n * `[]` means nothing is writable; `null` means unrestricted — which is not the same as `[\"/\"]`,\n * because unrestricted is the absence of a root rather than a root that happens to be `/`.\n *\n * The SDK already knew this: `buildBwrapArgv` binds these exact paths. It only knew it while\n * BUILDING an argv, and a consumer needs the answer earlier — tools are scoped at agent\n * construction, before any process exists, and a file-write tool has to be told its root then. With\n * nothing to ask, consumers keep a second encoding of this three-mode vocabulary and it drifts from\n * the argv builder with nothing to catch it. This reads from the same helper the builder uses, so\n * the two cannot disagree.\n */\nexport function writableRootsFor(mode: SandboxMode, cwd: string): readonly string[] | null {\n switch (mode) {\n case \"read-only\":\n return [];\n case \"workspace-write\":\n return workspaceWriteRoots(cwd);\n case \"danger-full-access\":\n return null;\n }\n}\n\nexport interface BwrapArgvOptions {\n /** Workspace root — the single RW bind under `workspace-write` (protocol.rs:1189-1200). */\n cwd: string;\n /** `true` removes `--unshare-net` (policy `network_access`, default false). */\n network?: boolean;\n /** Injectable for tests; defaults to a real `existsSync` check on `<cwd>/.git`. */\n gitDirExists?: boolean;\n /**\n * When present, emit `--clearenv` and re-inject ONLY these vars (Codex env_clear model,\n * `exec_env.rs:25-31`). Closes the denylist gap: a secret in an oddly-named var never reaches the\n * sandboxed child. Omitted ⇒ inherit the parent env (backward-compatible; SDK scrub still applies).\n */\n env?: Record<string, string>;\n}\n\n/**\n * Pure argv builder. Returns the bwrap flags ending in `--` (caller appends `/bin/sh -c <cmd>`),\n * or `null` when the policy skips the sandbox entirely (`danger-full-access`).\n */\nexport function buildBwrapArgv(mode: SandboxMode, opts: BwrapArgvOptions): string[] | null {\n if (mode === \"danger-full-access\") return null; // bwrap skipped entirely (bwrap.rs:245-252)\n\n const cwd = path.resolve(opts.cwd);\n const gitDir = path.join(cwd, \".git\");\n const hasGit = opts.gitDirExists ?? existsSync(gitDir);\n\n const argv: string[] = [\n // core, always (bwrap.rs:318-332; user+pid namespaces explicit so it works as root in containers)\n \"--new-session\",\n \"--die-with-parent\",\n \"--unshare-user\",\n \"--unshare-pid\",\n // full-read filesystem base (bwrap.rs:446-452)\n \"--ro-bind\",\n \"/\",\n \"/\",\n \"--dev\",\n \"/dev\",\n \"--proc\",\n \"/proc\",\n ];\n\n if (!opts.network) argv.push(\"--unshare-net\"); // network off by default (bwrap.rs:325-327)\n\n // env confinement — `--clearenv` MUST precede every `--setenv` or the clear wipes them\n // (exec_env.rs:25-31 clears then rebuilds). Only when an explicit allowlist is provided.\n if (opts.env) argv.push(\"--clearenv\");\n const setenv: Record<string, string> = {\n ...(opts.env ?? {}),\n // the flag signals the child that network is unshared (spawn.rs:20,79)\n ...(opts.network ? {} : { CODEX_SANDBOX_NETWORK_DISABLED: \"1\" }),\n };\n for (const [k, v] of Object.entries(setenv)) argv.push(\"--setenv\", k, v);\n\n if (mode === \"workspace-write\") pushWorkspaceBinds(argv, cwd, hasGit, gitDir);\n // read-only: zero writable roots (protocol.rs:1176) — nothing to add\n\n argv.push(\"--chdir\", cwd, \"--\");\n return argv;\n}\n\n/** Injectable probes — each mirrors one Codex availability check. */\nexport interface BwrapProbes {\n /** `which bwrap` outside the cwd (anti-hijack, sandboxing/src/bwrap.rs:168-191). */\n which: () => string | null;\n /** `bwrap --help` text — must advertise `--perms` (launcher.rs:108-124). */\n helpText: (bin: string) => string | null;\n /** Active user-namespace probe with timeout (sandboxing/src/bwrap.rs:74-136). */\n userns: (bin: string) => boolean;\n}\n\nexport type BwrapDetection = { ok: true; bin: string } | { ok: false; reason: string };\n\n/** Honest detection — fail-closed on every probe; NEVER throws (callers WARN + fall back). */\nexport function detectBwrap(probes: BwrapProbes = realProbes): BwrapDetection {\n try {\n const bin = probes.which();\n if (!bin) return { ok: false, reason: \"bwrap not found in PATH\" };\n const help = probes.helpText(bin);\n if (!help?.includes(\"--perms\")) {\n return { ok: false, reason: `bwrap at ${bin} lacks --perms support (too old)` };\n }\n if (!probes.userns(bin)) {\n return { ok: false, reason: \"user namespaces unavailable (container/kernel restriction)\" };\n }\n return { ok: true, bin };\n } catch (err) {\n return {\n ok: false,\n reason: `bwrap probe failed: ${err instanceof Error ? err.message : String(err)}`,\n };\n }\n}\n\n/**\n * How many times the REAL probe ran in this process.\n *\n * Instrumented here rather than in a wrapper, because this is where the cost is: every `which`\n * spawns a subprocess (`which bwrap`), and the full probe cost 22.2 ms. A gate counting INJECTED\n * probes does not see the real one — that was the M71 gate's first mistake, and a mutant exposed it.\n */\nlet realProbeRuns = 0;\n\n/** How many real probes ran. TEST seam — the performance gate counts this. */\nexport function realProbeCount(): number {\n return realProbeRuns;\n}\n\n/** Real probes used in production. */\nexport const realProbes: BwrapProbes = {\n which: () => {\n realProbeRuns++;\n try {\n const out = execFileSync(\"which\", [\"bwrap\"], { encoding: \"utf8\", timeout: 2_000 }).trim();\n // anti-hijack: never accept a bwrap that lives inside the workspace (bwrap.rs:168-191)\n if (!out || out.startsWith(process.cwd() + path.sep)) return null;\n return out;\n } catch {\n return null;\n }\n },\n helpText: (bin) => {\n try {\n // bwrap --help exits 0/1 depending on version; capture output either way\n return execFileSync(bin, [\"--help\"], { encoding: \"utf8\", timeout: 2_000 });\n } catch (err) {\n const e = err as { stdout?: string; stderr?: string };\n return [e.stdout, e.stderr].filter(Boolean).join(\"\\n\") || null;\n }\n },\n userns: (bin) => {\n try {\n // active probe, 500ms budget like Codex (sandboxing/src/bwrap.rs:74-136)\n execFileSync(bin, [\"--unshare-user\", \"--unshare-net\", \"--ro-bind\", \"/\", \"/\", \"/bin/true\"], {\n timeout: 500,\n stdio: \"ignore\",\n });\n return true;\n } catch {\n return false;\n }\n },\n};\n\n/**\n * The probe result, memoized for the lifetime of the PROCESS.\n *\n * Measured before M71: `detectBwrap()` costs **22.2 ms** and was not memoized — the second call\n * cost 19.4 ms. `buildChatAgent` on the headless path fired **two** (one from\n * `createSandboxBackend`, another from `resolveSandboxPosture`, which M70 added), totalling 46.4 ms\n * per construction — and construction happens per turn. Under `strace`, ~90% of the 182 syscalls of\n * an already-warm construction came from here: `which` sweeping the PATH, `/proc/filesystems`,\n * `/newroot`, and the `.so` files the two probe subprocesses load.\n *\n * ## Why there is no invalidation\n *\n * The milestone called for invalidating on `SessionStart`. That does not work:\n * `agents/lib/hooks/hooks.ts:28-30` documents — as a **measured** correction of an earlier\n * assumption — that the event fires **once per TURN**, not per session. Invalidating there would\n * re-probe every turn, exactly the behavior memoization exists to eliminate.\n *\n * A write-once cache is sufficient here: the expensive probe runs once per process,\n * only to print a UI warning.\n *\n * **The price, stated plainly — in BOTH directions.** The original m71-cost-per-turn#ADR-1 declared\n * only one of them; the M71 review (F-perf-9) showed the omitted one was precisely the one with a\n * security consequence:\n *\n * - **Stale negative** (`bwrap` installed AFTERWARDS): not detected until restart. The system fails\n * CLOSED — the posture reports `enforced: false` and M70's veto **refuses**. Cost: annoyance (the\n * message tells you to install the bwrap you just installed). Accepted.\n * - **Stale positive** (`bwrap` removed/renamed AFTERWARDS): the posture would keep asserting\n * `enforced: true / \"kernel (bwrap)\"` and the veto would **approve**, citing a confinement that no\n * longer exists. That is the literal reintroduction of the defect M70 fixed — *\"telling the\n * operator they are protected when they are not is worse than saying nothing\"*. Before M71 the\n * per-turn re-probe closed that window on the next turn; memoization would leave it open for the\n * whole process. **That is why the positive is revalidated** below, at 1 syscall — 3 orders of\n * magnitude below the 22.2 ms of the full probe, which is the cost memoization exists to remove.\n */\nlet memo: BwrapDetection | undefined;\n\n/**\n * `detectBwrap` with memoization — what production should call.\n *\n * Note that `detectBwrap` itself does **not** memoize, on purpose: it accepts injected probes, and\n * memoizing there would let a test with fake probes poison the process cache for everyone else.\n *\n * Revalidating the positive is NOT a re-probe: `detectBwrap` spends three probes (a `which`\n * subprocess + `--help` + a user namespace). Here we only confirm the validated binary is still in\n * place. If it vanished, the memo is downgraded to a negative with the reason stated — never\n * promoted to a positive, which would require the expensive probe back.\n */\nexport function detectBwrapMemoized(probes: BwrapProbes = realProbes): BwrapDetection {\n memo ??= detectBwrap(probes);\n if (memo.ok && !existsSync(memo.bin)) {\n memo = { ok: false, reason: `bwrap disappeared from ${memo.bin} after detection` };\n }\n return memo;\n}\n\n/** TEST seam — clears the memo. Production never calls it (see m71-cost-per-turn#ADR-1). */\nexport function resetBwrapMemo(): void {\n memo = undefined;\n}\n","// Promoted from agent-builder in M75 (plan m75-sandbox-kernel-no-framework, D1): confinement with\n// kernel confinement is framework infrastructure, not the consumer's. Measured cost of the promotion: ZERO\n// no dependencies — only node:child_process, node:fs and node:path. The cBPF filter is a Buffer in pure JS.\n\n/**\n * M63 — cBPF seccomp filter generator. Produces a raw `sock_filter[]` program (the exact\n * shape `bwrap --seccomp <fd>` consumes) so syscall confinement needs no\n * native helper — bwrap applies `PR_SET_NO_NEW_PRIVS` + the filter before `execve`.\n *\n * Semantics (landlock.rs:252-253): default action = ALLOW; per-syscall match = ERRNO(EPERM). KILL is\n * used ONLY by the architecture/x32 guard. x86_64 only in v1 (aarch64 is a documented delta).\n */\n\n// BPF opcodes (linux/bpf_common.h)\nconst BPF_LD = 0x00;\nconst BPF_W = 0x00;\nconst BPF_ABS = 0x20;\nconst BPF_JMP = 0x05;\nconst BPF_JEQ = 0x10;\nconst BPF_JGE = 0x30;\nconst BPF_K = 0x00;\nconst BPF_RET = 0x06;\n\nconst LD_ABS_W = BPF_LD | BPF_W | BPF_ABS; // 0x20\nconst JEQ_K = BPF_JMP | BPF_JEQ | BPF_K; // 0x15\nconst JGE_K = BPF_JMP | BPF_JGE | BPF_K; // 0x35\nconst RET_K = BPF_RET | BPF_K; // 0x06\n\n// seccomp_data offsets (little-endian): nr@0, arch@4, args[0] low dword @16\nconst OFF_NR = 0;\nconst OFF_ARCH = 4;\nconst OFF_ARG0 = 16;\n\nconst AUDIT_ARCH_X86_64 = 0xc000003e;\nconst X32_BIT = 0x40000000; // nr >= this ⇒ x32 ABI ⇒ reject\n\n// seccomp return actions (linux/seccomp.h)\nconst SECCOMP_RET_ALLOW = 0x7fff0000;\nconst SECCOMP_RET_ERRNO = 0x00050000;\nconst EPERM = 1;\nconst RET_EPERM = SECCOMP_RET_ERRNO | (EPERM & 0xffff); // 0x00050001\nconst SECCOMP_RET_KILL_PROCESS = 0x80000000;\n\nconst AF_UNIX = 1;\n\n/** Always-denied, network-independent (landlock.rs:179-184). */\nconst ALWAYS_DENIED = [101, 310, 311, 425, 426, 427]; // ptrace, process_vm_readv/writev, io_uring_setup/enter/register\n/** Denied only when the network is restricted (landlock.rs:188-204). recvfrom(45)/sendmsg(46) are NOT here. */\nconst NETWORK_DENIED = [42, 43, 288, 49, 50, 52, 51, 48, 44, 307, 299, 55, 54];\n/** socket(2) / socketpair(2) — conditional on domain != AF_UNIX (landlock.rs:206-216). */\nconst SOCKET_SYSCALLS = [41, 53];\n\n/** One `sock_filter` instruction: `{u16 code, u8 jt, u8 jf, u32 k}`. */\ninterface Insn {\n code: number;\n jt: number;\n jf: number;\n k: number;\n}\nconst stmt = (code: number, k: number): Insn => ({ code, jt: 0, jf: 0, k });\nconst jmp = (code: number, k: number, jt: number, jf: number): Insn => ({ code, jt, jf, k });\n\nexport interface SeccompOptions {\n /** When true (network off), also deny the socket set + non-AF_UNIX socket(). */\n networkRestricted: boolean;\n}\n\n/**\n * Build the cBPF seccomp program as a `Buffer` (each `sock_filter` = 8 bytes). Jump targets are\n * expressed against labels and back-patched to relative offsets, so the layout is deterministic and\n * unit-testable against the authoritative syscall list.\n */\nexport function buildSeccompFilter(opts: SeccompOptions): Buffer {\n // We assemble with symbolic targets, then resolve to relative jumps. To keep the classic\n // \"deny → jump to a single DENY return; else fall through\" shape, DENY and ALLOW live at the END and\n // every JEQ jumps FORWARD to them. jt/jf carry the DISTANCE (in instructions) to the target.\n const insns: Insn[] = [];\n\n // Placeholder labels resolved after we know total length.\n // Layout: [arch guard][x32 guard][LD nr][deny checks...][socket checks...][ALLOW][DENY][KILL]\n // We build the body first with jumps to ALLOW/DENY/KILL as sentinel indices, then patch.\n const ALLOW = Symbol(\"ALLOW\");\n const DENY = Symbol(\"DENY\");\n const KILL = Symbol(\"KILL\");\n type Target = typeof ALLOW | typeof DENY | typeof KILL | number;\n interface SInsn {\n code: number;\n k: number;\n jt: Target;\n jf: Target;\n }\n const body: SInsn[] = [];\n const push = (code: number, k: number, jt: Target = 0, jf: Target = 0): void => {\n body.push({ code, k, jt, jf });\n };\n\n // --- arch guard: arch == x86_64 ? continue : KILL ---\n push(LD_ABS_W, OFF_ARCH);\n push(JEQ_K, AUDIT_ARCH_X86_64, 0, KILL); // if != → KILL\n // --- x32 guard: nr >= 0x40000000 ? KILL : continue ---\n push(LD_ABS_W, OFF_NR);\n push(JGE_K, X32_BIT, KILL, 0); // if >= → KILL\n // nr already loaded; keep it loaded for the deny checks.\n\n // --- unconditional denials → DENY ---\n const denied = opts.networkRestricted\n ? [...ALWAYS_DENIED, ...NETWORK_DENIED]\n : [...ALWAYS_DENIED];\n for (const nr of denied) push(JEQ_K, nr, DENY, 0); // if nr == syscall → DENY\n\n // --- socket-family: socket(41)/socketpair(53) → allow only AF_UNIX (only when restricted) ---\n if (opts.networkRestricted) {\n for (const sysno of SOCKET_SYSCALLS) {\n // if nr == socket → check domain; else skip the 2 domain-check instructions\n push(JEQ_K, sysno, 0, 2); // match: fall through to the LD/JEQ; no-match: jump +2 (past them)\n push(LD_ABS_W, OFF_ARG0); // load domain (args[0] low dword)\n push(JEQ_K, AF_UNIX, ALLOW, DENY); // AF_UNIX → ALLOW, else DENY\n // NOTE: after these, nr is NO LONGER in the accumulator — but every remaining syscall check\n // reloads via a fresh LD? No: the remaining path is only ALLOW. socket checks are LAST before\n // the tail, so a fall-through (non-socket syscall that reached here) goes straight to ALLOW.\n }\n }\n\n // --- tail ---\n push(RET_K, SECCOMP_RET_ALLOW); // ALLOW label target\n const allowIdx = body.length - 1;\n push(RET_K, RET_EPERM); // DENY\n const denyIdx = body.length - 1;\n push(RET_K, SECCOMP_RET_KILL_PROCESS); // KILL\n const killIdx = body.length - 1;\n\n // --- resolve symbolic targets to relative offsets ---\n // The branching IS the cBPF program: ALLOW/DENY/KILL are symbolic targets resolved to an\n // offset RELATIVE to the next instruction. Breaking it into helpers does not reduce real complexity —\n // it moves the jump arithmetic to another file and makes auditing against landlock.rs harder, the\n // the authoritative source.\n //\n // Not refactoring NOW is an M75 process decision: this function is being MIGRATED without behavior\n // change (plan m75, D4) and there is still no byte-for-byte equivalence oracle against the\n // original version. Refactoring security without that oracle is changing the lock in the dark.\n // Revisit when the parity gate (T4.2) is green — the oracle exists then.\n // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: see the reason just above\n const resolve = (i: number, t: Target): number => {\n const abs = t === ALLOW ? allowIdx : t === DENY ? denyIdx : t === KILL ? killIdx : i + 1 + t;\n // BPF jump offset is relative to the NEXT instruction: target - (i + 1)\n const off = abs - (i + 1);\n if (off < 0 || off > 255) throw new RangeError(`seccomp jump out of range at ${i}: ${off}`);\n return off;\n };\n // `for...of` over entries instead of a raw index: the SDK compiles with `noUncheckedIndexedAccess`, which\n // (correctly) types `body[i]` as possibly undefined. Iterating gives the guarantee in the type instead\n // requiring a `!` — the code already could not leave the range, and now the compiler knows it.\n for (const [i, b] of body.entries()) {\n if (b.code === JEQ_K || b.code === JGE_K) {\n insns.push(jmp(b.code, b.k, resolve(i, b.jt), resolve(i, b.jf)));\n } else {\n insns.push(stmt(b.code, b.k));\n }\n }\n\n const buf = Buffer.alloc(insns.length * 8);\n insns.forEach((ins, i) => {\n buf.writeUInt16LE(ins.code, i * 8);\n buf.writeUInt8(ins.jt, i * 8 + 2);\n buf.writeUInt8(ins.jf, i * 8 + 3);\n buf.writeUInt32LE(ins.k >>> 0, i * 8 + 4);\n });\n return buf;\n}\n","// Promoted from agent-builder in M75 (plan m75-sandbox-kernel-no-framework, D1). Renamed from\n// `BwrapSandbox` to `LinuxSandbox`: bwrap is the IMPLEMENTATION, Linux is the contract — swapping the\n// mechanism (landlock, for example) should not change the name the consumer imports.\n\nimport { mkdtempSync, rmSync, writeFileSync } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { dirname, join } from \"node:path\";\n\nimport { redactSecrets } from \"../internal/security/redact.js\";\nimport type { BwrapDetection, SandboxMode } from \"./bwrap.js\";\nimport { buildBwrapArgv, detectBwrapMemoized } from \"./bwrap.js\";\nimport { LocalSandbox } from \"./local-sandbox.js\";\nimport { buildSeccompFilter } from \"./seccomp.js\";\nimport type { SandboxBackend, SandboxConfig } from \"./types.js\";\n\n/**\n * M53 — kernel-enforced sandbox backend, injected into `createShellTool({ sandbox })`.\n *\n * `LinuxSandbox extends LocalSandbox` and only REWRITES the command: `<bwrap-bin> <policy flags> --\n * /bin/sh -c '<original>'`. Everything else (spawn, output caps, timeout, ExecuteResult shape, file\n * ops) is inherited — the SDK backend stays the single execution engine. Mirrors Codex's\n * `SandboxManager::transform` (argv prefixing before spawn, never in-process).\n */\n\n/** POSIX single-quote escaping — the inner command crosses ONE extra `/bin/sh -c` boundary. */\nfunction shellQuote(s: string): string {\n return `'${s.replaceAll(\"'\", `'\\\\''`)}'`;\n}\n\n/**\n * M57 — the single source of truth for the sandbox command wrap. Turns `command` into\n * `<bin> <bwrap flags> [--seccomp 3] -- /bin/sh -c '<command>' [3< <bpf>]`, or `null` when the policy\n * skips the sandbox (`danger-full-access`). Extracted from `LinuxSandbox.wrapCommand` so the interactive\n * PTY backend (M57) can reuse the EXACT wrap the one-shot `run_shell` already uses (DRY) — faithful to\n * Codex, where the sandbox transforms the argv before the PTY spawns it (`sandboxing/src/manager.rs:321`).\n */\nexport function wrapCommandForSandbox(\n mode: SandboxMode,\n opts: {\n cwd: string;\n network?: boolean;\n env?: Record<string, string>;\n bin?: string;\n seccompPath?: string;\n },\n command: string,\n): string | null {\n const argv = buildBwrapArgv(mode, { cwd: opts.cwd, network: opts.network, env: opts.env });\n if (argv === null) return null; // danger-full-access: bwrap skipped\n const bin = opts.bin ?? \"bwrap\";\n const seccompArgv = opts.seccompPath !== undefined ? [\"--seccomp\", \"3\"] : [];\n const base = `${shellQuote(bin)} ${[...argv.slice(0, -1), ...seccompArgv, \"--\"].map(shellQuote).join(\" \")} /bin/sh -c ${shellQuote(command)}`;\n return opts.seccompPath !== undefined ? `${base} 3< ${shellQuote(opts.seccompPath)}` : base;\n}\n\n/**\n * Env allowlist re-injected inside the sandbox after `--clearenv`. Codex env_clear model: the child\n * gets exactly what it needs to run a shell, never the parent's full env (which may hold oddly-named\n * secrets the SDK name-pattern scrub misses). `CODEX_SANDBOX_NETWORK_DISABLED` is added by the argv\n * builder when network is unshared.\n */\nconst ENV_ALLOWLIST = [\n \"PATH\",\n \"HOME\",\n \"LANG\",\n \"LC_ALL\",\n \"LC_CTYPE\",\n \"TERM\",\n \"USER\",\n \"TMPDIR\",\n \"SHELL\",\n];\n\nexport function allowlistedEnv(source: NodeJS.ProcessEnv = process.env): Record<string, string> {\n const out: Record<string, string> = {};\n for (const k of ENV_ALLOWLIST) {\n const v = source[k];\n if (v !== undefined) out[k] = v;\n }\n return out;\n}\n\nexport class LinuxSandbox extends LocalSandbox {\n private readonly mode: SandboxMode;\n private readonly network: boolean;\n private readonly cwd: string;\n private readonly bin: string;\n private readonly env: Record<string, string>;\n /** M63 — path to the cBPF seccomp program written host-side; passed to `bwrap --seccomp 3` via a\n * shell redirect. `undefined` when the network is unrestricted OR generation failed (honest fallback). */\n private readonly seccompPath: string | undefined;\n\n constructor(\n config: SandboxConfig,\n opts: { mode: SandboxMode; network?: boolean; bin?: string; env?: Record<string, string> },\n ) {\n super(config);\n this.mode = opts.mode;\n this.network = opts.network ?? false;\n this.cwd = config.workDir ?? process.cwd();\n // MEDIUM-1: run the VALIDATED absolute binary from detection (anti-hijack), never bare `bwrap`\n // which the outer shell would re-resolve via $PATH at spawn time (TOCTOU / hijack window).\n this.bin = opts.bin ?? \"bwrap\";\n this.env = opts.env ?? allowlistedEnv();\n this.seccompPath = seccompPathForNetwork(this.network);\n }\n\n /** Extracted for test visibility — delegates to the pure `wrapCommandForSandbox` (M57, single wrap SoT). */\n wrapCommand(command: string): string | null {\n return wrapCommandForSandbox(\n this.mode,\n {\n cwd: this.cwd,\n network: this.network,\n env: this.env,\n bin: this.bin,\n seccompPath: this.seccompPath,\n },\n command,\n );\n }\n\n /**\n * M75 review (architecture, HIGH) — without this override the class LIED.\n *\n * `LinuxSandbox` documents itself as a \"kernel-enforced sandbox backend\", but it overrode only\n * `execute`. `uploadFile` stayed the one inherited from `LocalSandbox`, which writes straight to\n * the host via `fs/promises` and accepts an ABSOLUTE path — no bwrap, no seccomp, no path\n * restriction. And `SandboxBackend.writeFile` delegates to it. The result was an incoherent class:\n * reading, searching and listing went through the confinement; writing did not.\n *\n * Routing through the wrapped `execute` fixes it at the root: writes come to live under the SAME\n * policy as everything else — if bwrap denies the path, the write fails, as it should. The content\n * goes over stdin (not argv) because argv has a size limit and file content does not.\n */\n override async uploadFile(path: string, content: string | Buffer): Promise<void> {\n if (this.mode === \"danger-full-access\") return super.uploadFile(path, content);\n\n const target = path.startsWith(\"/\") ? path : `${this.cwd}/${path}`;\n const b64 = Buffer.from(content).toString(\"base64\");\n // base64 on a single line: avoids any shell quoting over arbitrary content, which is exactly\n // where a \"confined\" write would turn into command injection.\n const r = await this.execute(\n `mkdir -p ${shellQuote(dirname(target))} && printf %s ${shellQuote(b64)} | base64 -d > ${shellQuote(target)}`,\n );\n if (r.exitCode !== 0) {\n throw new Error(\n `uploadFile blocked or failed under confinement (${target}): ${r.stderr.trim() || `exit ${r.exitCode}`}`,\n );\n }\n }\n\n override execute(command: string, opts?: { timeoutMs?: number }) {\n const wrapped = this.wrapCommand(command);\n if (wrapped === null) return super.execute(command, opts); // danger-full-access: plain local\n return super.execute(wrapped, opts);\n }\n}\n\nlet warnedNonX64 = false;\n\n/**\n * M63 — the restricted-network seccomp program is DETERMINISTIC, so write it ONCE per process and\n * reuse the path across every LinuxSandbox (no per-instance temp accumulation).\n *\n * ARCH GUARD (review HIGH): `buildSeccompFilter` emits an x86_64 program whose arch guard KILLs every\n * syscall whose `seccomp_data.arch != AUDIT_ARCH_X86_64`. On a non-x86_64 host that would brick EVERY\n * sandboxed command (the first execve is killed) — and silently, because generation succeeds and bwrap\n * accepts it. So we REFUSE to install on non-x64 and WARN through the honest-downgrade channel (bwrap\n * FS/network confinement still applies), exactly like the bwrap-missing fallback. `arch` is injectable\n * for tests. Cleaned on exit AND on SIGINT/SIGTERM (TUI Ctrl+C would otherwise leak the temp dir).\n */\nexport function seccompPathForArch(arch: string, warn: (m: string) => void): string | undefined {\n if (arch !== \"x64\") {\n if (!warnedNonX64) {\n warnedNonX64 = true;\n warn(\n `[sandbox] seccomp syscall filter unsupported on ${arch} (x86_64 only in v1) — running without ` +\n \"the filter; bwrap FS/network confinement still applies.\",\n );\n }\n return undefined;\n }\n try {\n const dir = mkdtempSync(join(tmpdir(), \"ab-seccomp-\"));\n const path = join(dir, \"filter.bpf\");\n writeFileSync(path, buildSeccompFilter({ networkRestricted: true }));\n const cleanup = (): void => rmSync(dir, { recursive: true, force: true });\n process.once(\"exit\", cleanup);\n process.once(\"SIGINT\", cleanup);\n process.once(\"SIGTERM\", cleanup);\n return path;\n } catch (err) {\n warn(\n `[sandbox] seccomp filter unavailable (${err instanceof Error ? err.message : String(err)}) — ` +\n \"running without syscall filter (bwrap FS/network confinement still applies).\",\n );\n return undefined;\n }\n}\n\nlet seccompFilterPath: string | undefined | null; // undefined = not tried; null = resolved absent\n/** M57 — exported so the interactive PTY backend reuses the SAME memoized x64-gated seccomp program. */\nexport function restrictedSeccompPath(): string | undefined {\n if (seccompFilterPath !== undefined) return seccompFilterPath ?? undefined;\n const path = seccompPathForArch(process.arch, (m) => console.warn(redactSecrets(m)));\n seccompFilterPath = path ?? null;\n return path;\n}\n\nlet warnedUnavailable = false;\n\n/** Test seam: reset the WARN-once latch. */\nexport function resetSandboxWarnLatch(): void {\n warnedUnavailable = false;\n}\n\n/** Durable sandbox posture for the UI — the honest answer to \"am I kernel-enforced right now?\". */\nexport interface SandboxPosture {\n mode: SandboxMode;\n enforced: boolean;\n detail: string;\n}\n\n/**\n * MEDIUM-2: compute the posture so a surface (TUI footer) can show enforcement DURABLY instead of a\n * one-shot warn. `danger-full-access` is honestly reported as unenforced; an unavailable bwrap reports\n * the downgrade reason so the user never believes they are confined when they are not.\n */\nexport function resolveSandboxPosture(opts: {\n mode: SandboxMode;\n detect?: () => BwrapDetection;\n}): SandboxPosture {\n if (opts.mode === \"danger-full-access\") {\n return { mode: opts.mode, enforced: false, detail: \"no confinement (danger-full-access)\" };\n }\n const detection = (opts.detect ?? detectBwrapMemoized)();\n if (!detection.ok) {\n return { mode: opts.mode, enforced: false, detail: `tool-gating only — ${detection.reason}` };\n }\n return { mode: opts.mode, enforced: true, detail: \"kernel (bwrap)\" };\n}\n\nexport interface CreateSandboxBackendOptions {\n mode: SandboxMode;\n workDir?: string;\n network?: boolean;\n timeoutMs?: number;\n /** Injectable for tests; defaults to the real 3-probe detection. */\n detect?: () => BwrapDetection;\n /** Injectable for tests; defaults to console.warn. */\n warn?: (message: string) => void;\n}\n\n/**\n * Honest factory: bwrap available + mode wants confinement → `LinuxSandbox` (kernel enforcement,\n * running the VALIDATED absolute bin); `danger-full-access` → plain `LocalSandbox` silently (explicit\n * opt-out, `bwrap.rs:245-252`); bwrap unavailable → WARN once + `LocalSandbox` (the declarative M23\n * gating remains the guard). NEVER pretends to sandbox — the fallback is loud, mirroring Codex's\n * MISSING_BWRAP_WARNING. The durable posture lives in `resolveSandboxPosture` for the UI.\n */\nexport function createSandboxBackend(opts: CreateSandboxBackendOptions): SandboxBackend {\n const config: SandboxConfig = { workDir: opts.workDir, timeoutMs: opts.timeoutMs };\n if (opts.mode === \"danger-full-access\") return new LocalSandbox(config);\n\n const detection = (opts.detect ?? detectBwrapMemoized)();\n if (!detection.ok) {\n if (!warnedUnavailable) {\n warnedUnavailable = true;\n const warn = opts.warn ?? ((m: string) => console.warn(redactSecrets(m)));\n warn(\n `[sandbox] OS-level enforcement unavailable (${detection.reason}) — ` +\n `falling back to tool-level gating only (sandbox_mode=${opts.mode}).`,\n );\n }\n return new LocalSandbox(config);\n }\n return new LinuxSandbox(config, { mode: opts.mode, network: opts.network, bin: detection.bin });\n}\n\n/**\n * M75 T3.2 — warning latch for the INTERACTIVE path.\n *\n * Kept separate from `createSandboxBackend`'s latch on purpose: they are two distinct decisions\n * taken at distinct moments, and a user who only ever runs an interactive shell needs to see the\n * warning even if the non-interactive path already emitted it — otherwise the session where they\n * actually type commands would be the one without the alert.\n */\nlet interactiveWarned = false;\n\n/** Reset for tests — the latch is module state and tests need isolation. */\nexport function resetInteractiveWarnLatch(): void {\n interactiveWarned = false;\n}\n\n/**\n * The rule \"seccomp ONLY with restricted network\" — in ONE place.\n *\n * Codex installs the filter only when the network is closed (`landlock.rs:96-117`), and that is not\n * a detail: the cBPF program **denies the network syscalls** (`NETWORK_DENIED`). Applying it with\n * the network open produces the worst possible combination — bwrap **allows** the network (no\n * `--unshare-net`) and seccomp **denies** it with EPERM. The user asked for network, got the bind,\n * and the calls die.\n *\n * It existed duplicated: the constructor decided conditionally, `interactiveWrapCommand` installed\n * unconditionally. They had already diverged in the first version (M75 architecture review, proven\n * at runtime: `network:true` gave `--seccomp` interactively and not one-shot). Two copies of a\n * security rule is not duplicated form — it is duplicated KNOWLEDGE, and it had already diverged.\n */\nfunction seccompPathForNetwork(networkOpen: boolean): string | undefined {\n return networkOpen ? undefined : restrictedSeccompPath();\n}\n\nexport interface InteractiveWrapOptions {\n mode: SandboxMode;\n /** `true` keeps the network. Default `false`, same as non-interactive `run_shell`. */\n network?: boolean;\n /** Injectable for tests; defaults to the real memoized detection. */\n detect?: () => BwrapDetection;\n /** Injectable for tests; defaults to `console.warn` with redaction. */\n warn?: (message: string) => void;\n}\n\n/**\n * The decision to confine or degrade, separated from the wrap itself.\n *\n * Extracted because they are two responsibilities and the SDK's complexity gate separated them for\n * us: DECIDING (is confinement available? did the user opt out?) and APPLYING (assembling the argv).\n * Keeping them together pushed the closure past 10 cognitive complexity — and the linter was right:\n * the deciding part is the one with security consequences and deserves to be read on its own.\n *\n * Returns the validated binary when confinement exists, or `null` when it does not — warning ONCE,\n * and only when the absence is a failure (not when it is an opt-out).\n */\nfunction decideConfinement(opts: InteractiveWrapOptions): string | null {\n if (opts.mode === \"danger-full-access\") return null;\n\n const detection = (opts.detect ?? detectBwrapMemoized)();\n if (detection.ok) return detection.bin;\n\n if (!interactiveWarned) {\n interactiveWarned = true;\n const warn = opts.warn ?? ((m: string) => console.warn(redactSecrets(m)));\n warn(\n `[sandbox] OS-level enforcement unavailable (${detection.reason}) — interactive session ` +\n `runs WITHOUT kernel confinement (sandbox_mode=${opts.mode}).`,\n );\n }\n return null;\n}\n\n/**\n * The composition the interactive path needs — the counterpart of `createSandboxBackend`.\n *\n * `createSandboxBackend` solves this for the non-interactive path by returning a ready BACKEND. The\n * PTY accepts no backend: it owns the spawn and only allows transforming the command. This function\n * delivers the SAME decision in the shape the PTY accepts — `(command, cwd) => string | null` —\n * ready for `new PtyInteractiveBackend({ wrapCommand: interactiveWrapCommand({ mode }) })`.\n *\n * Detection is consulted on **every wrap**, not frozen at construction: an interactive session lives\n * for hours, and a stale positive detection would keep asserting confinement after the binary\n * disappeared (the `existsSync` revalidation lives inside `detectBwrapMemoized`).\n *\n * The two routes returning `null` are semantically different and the code does not merge them:\n * `danger-full-access` is an explicit opt-out and does NOT warn; bwrap being unavailable is a\n * failure and warns once.\n */\nexport function interactiveWrapCommand(\n opts: InteractiveWrapOptions,\n): (command: string, cwd: string) => string | null {\n return (command: string, cwd: string): string | null => {\n const bin = decideConfinement(opts);\n if (bin === null) return null;\n\n return wrapCommandForSandbox(\n opts.mode,\n {\n cwd,\n network: opts.network ?? false,\n env: allowlistedEnv(),\n bin,\n seccompPath: seccompPathForNetwork(opts.network ?? false),\n },\n command,\n );\n };\n}\n","/**\n * M6-3 — portable repo provisioner for the eval harness.\n *\n * Clones a repository and checks out a ref into an isolated working dir, issuing\n * every git command through {@link SandboxBackend.execute} (ADR D2 — same code\n * runs on Local/Docker/E2B; never a direct `child_process` import). Promotes\n * theocode's `prepareRepo` (`swebench-provision.ts:37`) onto the SDK's sandbox\n * abstraction.\n *\n * reference: knowledge-base/references/theocode-eval/lib/swebench-provision.ts:37\n * (clone+checkout), :13 (ProvisionError with instanceId).\n *\n * @public\n */\n\nimport { TheokitAgentError } from \"../errors.js\";\nimport { LocalSandbox } from \"./local-sandbox.js\";\nimport { shellEscapePosix } from \"./shell-escape.js\";\nimport type { SandboxBackend } from \"./types.js\";\n\n/**\n * Raised when cloning or checking out a repo fails. Carries the `instanceId`\n * so a batch run can attribute the failure to the offending dataset row.\n */\nexport class RepoProvisionError extends TheokitAgentError {\n override readonly name = \"RepoProvisionError\";\n\n constructor(\n readonly instanceId: string,\n message: string,\n options: { cause?: unknown } = {},\n ) {\n super(`[${instanceId}] ${message}`, {\n code: \"repo_provision_failed\",\n isRetryable: false,\n ...(options.cause !== undefined ? { cause: options.cause } : {}),\n });\n }\n}\n\n/** Options for {@link provisionRepo}. */\nexport interface ProvisionRepoOptions {\n /**\n * Clonable repo URL or local path. SECURITY: when this comes from an\n * untrusted dataset, the value is passed to `git clone` after a `--`\n * end-of-options terminator (no flag injection) and with the `ext::`\n * transport disabled (no arbitrary-command transport).\n */\n readonly repoUrl: string;\n /** Branch, tag, or commit SHA to check out. Rejected if it begins with `-`. */\n readonly ref: string;\n /**\n * Unique id for this row — names the target dir and any error. Validated to\n * `[A-Za-z0-9._-]` (no path traversal) since it becomes a directory name.\n */\n readonly instanceId: string;\n}\n\n/**\n * Reject ids that would escape the workdir or be parsed as a git flag. Must\n * start with an alphanumeric (blocks `.`, `..`, `-foo`, leading-dot names) and\n * thereafter allow only `[A-Za-z0-9._-]`.\n */\nconst SAFE_INSTANCE_ID = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;\n\n/**\n * Clone `repoUrl` into `<sandbox workdir>/<instanceId>` and check out `ref`.\n * Returns the absolute `repoDir` (resolved via `git rev-parse --show-toplevel`,\n * which is portable across backends). Throws {@link RepoProvisionError} naming\n * the `instanceId` when clone or checkout exits non-zero.\n *\n * The `sandbox` is optional (V3-5): when omitted, a default {@link LocalSandbox}\n * is used (clones into the process cwd's `<instanceId>`) — pass an explicit\n * sandbox (e.g. `LocalSandbox({ workDir })` / Docker / E2B) to control the workdir.\n */\nexport function provisionRepo(opts: ProvisionRepoOptions): Promise<{ repoDir: string }>;\nexport function provisionRepo(\n sandbox: SandboxBackend,\n opts: ProvisionRepoOptions,\n): Promise<{ repoDir: string }>;\nexport async function provisionRepo(\n sandboxOrOpts: SandboxBackend | ProvisionRepoOptions,\n maybeOpts?: ProvisionRepoOptions,\n): Promise<{ repoDir: string }> {\n const sandbox = maybeOpts !== undefined ? (sandboxOrOpts as SandboxBackend) : new LocalSandbox();\n const opts = maybeOpts ?? (sandboxOrOpts as ProvisionRepoOptions);\n const { repoUrl, ref, instanceId } = opts;\n\n // Validate untrusted-derivable inputs before they reach git/the shell.\n if (!SAFE_INSTANCE_ID.test(instanceId)) {\n throw new RepoProvisionError(\n instanceId,\n \"invalid instanceId: must match [A-Za-z0-9._-] (no path traversal)\",\n );\n }\n if (ref.startsWith(\"-\")) {\n throw new RepoProvisionError(instanceId, `invalid ref: must not begin with '-' (got ${ref})`);\n }\n\n // `--` terminates options (no `--upload-pack=` flag injection); `protocol.ext.allow=never`\n // blocks the `ext::` arbitrary-command transport. `file`/`https` stay allowed.\n const clone = await sandbox.execute(\n `git -c protocol.ext.allow=never clone --quiet -- ${shellEscapePosix(repoUrl)} ${shellEscapePosix(instanceId)}`,\n );\n if (clone.exitCode !== 0) {\n throw new RepoProvisionError(instanceId, `clone failed: ${clone.stderr.trim()}`);\n }\n\n const top = await sandbox.execute(\n `git -C ${shellEscapePosix(instanceId)} rev-parse --show-toplevel`,\n );\n if (top.exitCode !== 0) {\n throw new RepoProvisionError(instanceId, `resolve repoDir failed: ${top.stderr.trim()}`);\n }\n const repoDir = top.stdout.trim();\n\n // `ref` is validated above not to begin with `-`, so it cannot be parsed as a flag.\n const checkout = await sandbox.execute(\n `git -C ${shellEscapePosix(repoDir)} checkout --quiet ${shellEscapePosix(ref)}`,\n );\n if (checkout.exitCode !== 0) {\n throw new RepoProvisionError(instanceId, `checkout ${ref} failed: ${checkout.stderr.trim()}`);\n }\n\n return { repoDir };\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunk2YGIBOUH_cjs = require('../chunk-2YGIBOUH.cjs');
4
- require('../chunk-SXSPMRSV.cjs');
3
+ var chunkLPVIRJVF_cjs = require('../chunk-LPVIRJVF.cjs');
4
+ require('../chunk-BM6N4KHO.cjs');
5
5
 
6
6
  // src/server/errors-envelope.ts
7
7
  var NAME_TO_CODE = /* @__PURE__ */ new Map([
@@ -37,7 +37,7 @@ function toEnvelope(value) {
37
37
  }
38
38
  function buildMeta(name, err) {
39
39
  const meta = { sdkErrorName: name };
40
- if (err instanceof chunk2YGIBOUH_cjs.TheokitAgentError && err.metadata !== void 0) {
40
+ if (err instanceof chunkLPVIRJVF_cjs.TheokitAgentError && err.metadata !== void 0) {
41
41
  meta.provider = err.metadata.provider;
42
42
  meta.endpoint = err.metadata.endpoint;
43
43
  if (err.metadata.statusCode !== void 0) {
@@ -47,13 +47,13 @@ function buildMeta(name, err) {
47
47
  return meta;
48
48
  }
49
49
  function buildExt(err) {
50
- if (err instanceof chunk2YGIBOUH_cjs.RateLimitError && err.metadata?.retryAfter !== void 0) {
50
+ if (err instanceof chunkLPVIRJVF_cjs.RateLimitError && err.metadata?.retryAfter !== void 0) {
51
51
  return {
52
52
  retryable: true,
53
53
  retryAfterMs: err.metadata.retryAfter * 1e3
54
54
  };
55
55
  }
56
- if (err instanceof chunk2YGIBOUH_cjs.CredentialPoolExhaustedError && err.nextRetryAt !== void 0) {
56
+ if (err instanceof chunkLPVIRJVF_cjs.CredentialPoolExhaustedError && err.nextRetryAt !== void 0) {
57
57
  const delayMs = Math.max(0, err.nextRetryAt - Date.now());
58
58
  return {
59
59
  retryable: true,
@@ -63,22 +63,22 @@ function buildExt(err) {
63
63
  return void 0;
64
64
  }
65
65
  var CODE_TO_RECONSTRUCTOR = /* @__PURE__ */ new Map([
66
- ["UNAUTHORIZED", (env) => new chunk2YGIBOUH_cjs.AuthenticationError(env.message)],
66
+ ["UNAUTHORIZED", (env) => new chunkLPVIRJVF_cjs.AuthenticationError(env.message)],
67
67
  [
68
68
  "RATE_LIMITED",
69
- (env) => new chunk2YGIBOUH_cjs.RateLimitError(env.message, env.cause !== void 0 ? { cause: env.cause } : {})
69
+ (env) => new chunkLPVIRJVF_cjs.RateLimitError(env.message, env.cause !== void 0 ? { cause: env.cause } : {})
70
70
  ],
71
- ["PROVIDER_KEY_MISSING", (env) => new chunk2YGIBOUH_cjs.ConfigurationError(env.message)],
72
- ["SERVICE_UNAVAILABLE", (env) => new chunk2YGIBOUH_cjs.NetworkError(env.message)],
73
- ["GATEWAY_TIMEOUT", (env) => new chunk2YGIBOUH_cjs.NetworkError(env.message)],
71
+ ["PROVIDER_KEY_MISSING", (env) => new chunkLPVIRJVF_cjs.ConfigurationError(env.message)],
72
+ ["SERVICE_UNAVAILABLE", (env) => new chunkLPVIRJVF_cjs.NetworkError(env.message)],
73
+ ["GATEWAY_TIMEOUT", (env) => new chunkLPVIRJVF_cjs.NetworkError(env.message)],
74
74
  [
75
75
  "AGENT_RUN_ERROR",
76
- (env) => new chunk2YGIBOUH_cjs.AgentRunError(env.message, {
76
+ (env) => new chunkLPVIRJVF_cjs.AgentRunError(env.message, {
77
77
  code: "unknown",
78
78
  ...env.cause !== void 0 ? { cause: env.cause } : {}
79
79
  })
80
80
  ],
81
- ["INTERNAL_SERVER_ERROR", (env) => new chunk2YGIBOUH_cjs.UnknownAgentError(env.message)]
81
+ ["INTERNAL_SERVER_ERROR", (env) => new chunkLPVIRJVF_cjs.UnknownAgentError(env.message)]
82
82
  // BUDGET_EXCEEDED + CREDENTIAL_POOL_EXHAUSTED reconstructors require
83
83
  // domain-specific args (budgetName, provider) that the envelope doesn't
84
84
  // always carry. Fall back to UnknownAgentError when those fields are
@@ -88,12 +88,12 @@ var CODE_TO_RECONSTRUCTOR = /* @__PURE__ */ new Map([
88
88
  function fromEnvelope(env) {
89
89
  const reconstructor = CODE_TO_RECONSTRUCTOR.get(env.code);
90
90
  if (reconstructor) return reconstructor(env);
91
- return new chunk2YGIBOUH_cjs.UnknownAgentError(env.message);
91
+ return new chunkLPVIRJVF_cjs.UnknownAgentError(env.message);
92
92
  }
93
93
 
94
94
  Object.defineProperty(exports, "MemoryAdapterError", {
95
95
  enumerable: true,
96
- get: function () { return chunk2YGIBOUH_cjs.MemoryAdapterError; }
96
+ get: function () { return chunkLPVIRJVF_cjs.MemoryAdapterError; }
97
97
  });
98
98
  exports.fromEnvelope = fromEnvelope;
99
99
  exports.toEnvelope = toEnvelope;
@@ -1,6 +1,6 @@
1
- import { TheokitAgentError, RateLimitError, CredentialPoolExhaustedError, UnknownAgentError, AuthenticationError, ConfigurationError, NetworkError, AgentRunError } from '../chunk-HI4ZW62S.js';
2
- export { MemoryAdapterError } from '../chunk-HI4ZW62S.js';
3
- import '../chunk-4X3SBHPK.js';
1
+ import { TheokitAgentError, RateLimitError, CredentialPoolExhaustedError, UnknownAgentError, AuthenticationError, ConfigurationError, NetworkError, AgentRunError } from '../chunk-U4UJHOSH.js';
2
+ export { MemoryAdapterError } from '../chunk-U4UJHOSH.js';
3
+ import '../chunk-5F5NWKPN.js';
4
4
 
5
5
  // src/server/errors-envelope.ts
6
6
  var NAME_TO_CODE = /* @__PURE__ */ new Map([
@@ -0,0 +1,50 @@
1
+ 'use strict';
2
+
3
+ var chunkY4AXQOT4_cjs = require('./chunk-Y4AXQOT4.cjs');
4
+ require('./chunk-C4H6PB5J.cjs');
5
+ require('./chunk-BM6N4KHO.cjs');
6
+
7
+
8
+
9
+ Object.defineProperty(exports, "SessionTranscript", {
10
+ enumerable: true,
11
+ get: function () { return chunkY4AXQOT4_cjs.SessionTranscript; }
12
+ });
13
+ Object.defineProperty(exports, "defaultBaseDir", {
14
+ enumerable: true,
15
+ get: function () { return chunkY4AXQOT4_cjs.defaultBaseDir; }
16
+ });
17
+ Object.defineProperty(exports, "encodeProjectDir", {
18
+ enumerable: true,
19
+ get: function () { return chunkY4AXQOT4_cjs.encodeProjectDir; }
20
+ });
21
+ Object.defineProperty(exports, "expandTilde", {
22
+ enumerable: true,
23
+ get: function () { return chunkY4AXQOT4_cjs.expandTilde; }
24
+ });
25
+ Object.defineProperty(exports, "readTranscript", {
26
+ enumerable: true,
27
+ get: function () { return chunkY4AXQOT4_cjs.readTranscript; }
28
+ });
29
+ Object.defineProperty(exports, "reconstructMessages", {
30
+ enumerable: true,
31
+ get: function () { return chunkY4AXQOT4_cjs.reconstructMessages; }
32
+ });
33
+ Object.defineProperty(exports, "safeSessionId", {
34
+ enumerable: true,
35
+ get: function () { return chunkY4AXQOT4_cjs.safeSessionId; }
36
+ });
37
+ Object.defineProperty(exports, "transcriptPath", {
38
+ enumerable: true,
39
+ get: function () { return chunkY4AXQOT4_cjs.transcriptPath; }
40
+ });
41
+ Object.defineProperty(exports, "transcriptRoot", {
42
+ enumerable: true,
43
+ get: function () { return chunkY4AXQOT4_cjs.transcriptRoot; }
44
+ });
45
+ Object.defineProperty(exports, "writeTranscript", {
46
+ enumerable: true,
47
+ get: function () { return chunkY4AXQOT4_cjs.writeTranscript; }
48
+ });
49
+ //# sourceMappingURL=session-transcript-DOM3UTXR.cjs.map
50
+ //# sourceMappingURL=session-transcript-DOM3UTXR.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"session-transcript-TNAJ4O3M.cjs"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"session-transcript-DOM3UTXR.cjs"}
@@ -0,0 +1,5 @@
1
+ export { SessionTranscript, defaultBaseDir, encodeProjectDir, expandTilde, readTranscript, reconstructMessages, safeSessionId, transcriptPath, transcriptRoot, writeTranscript } from './chunk-N5CR3TJZ.js';
2
+ import './chunk-6AZDM6LK.js';
3
+ import './chunk-5F5NWKPN.js';
4
+ //# sourceMappingURL=session-transcript-RAKEK76V.js.map
5
+ //# sourceMappingURL=session-transcript-RAKEK76V.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"session-transcript-SKIRBEJE.js"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"session-transcript-RAKEK76V.js"}
package/dist/skills.cjs CHANGED
@@ -1,21 +1,21 @@
1
1
  'use strict';
2
2
 
3
- var chunkFUASIT3E_cjs = require('./chunk-FUASIT3E.cjs');
4
- require('./chunk-YTO5BRBD.cjs');
3
+ var chunkZN2DGEY3_cjs = require('./chunk-ZN2DGEY3.cjs');
4
+ require('./chunk-ZT57WTUJ.cjs');
5
5
  require('./chunk-VKJ7V7EB.cjs');
6
- require('./chunk-44IISBRZ.cjs');
7
- require('./chunk-2YGIBOUH.cjs');
8
- require('./chunk-SXSPMRSV.cjs');
6
+ require('./chunk-SZHU7A5B.cjs');
7
+ require('./chunk-LPVIRJVF.cjs');
8
+ require('./chunk-BM6N4KHO.cjs');
9
9
 
10
10
 
11
11
 
12
12
  Object.defineProperty(exports, "buildSkillsBlock", {
13
13
  enumerable: true,
14
- get: function () { return chunkFUASIT3E_cjs.buildSkillsBlock; }
14
+ get: function () { return chunkZN2DGEY3_cjs.buildSkillsBlock; }
15
15
  });
16
16
  Object.defineProperty(exports, "discoverSkills", {
17
17
  enumerable: true,
18
- get: function () { return chunkFUASIT3E_cjs.discoverSkills; }
18
+ get: function () { return chunkZN2DGEY3_cjs.discoverSkills; }
19
19
  });
20
20
  //# sourceMappingURL=skills.cjs.map
21
21
  //# sourceMappingURL=skills.cjs.map
package/dist/skills.js CHANGED
@@ -1,8 +1,8 @@
1
- export { buildSkillsBlock, discoverSkills } from './chunk-BXVSBYGW.js';
2
- import './chunk-XWCTBGYK.js';
1
+ export { buildSkillsBlock, discoverSkills } from './chunk-OY7O3Q6R.js';
2
+ import './chunk-SK4QLUBK.js';
3
3
  import './chunk-RIAM53CP.js';
4
- import './chunk-5XXUYU3M.js';
5
- import './chunk-HI4ZW62S.js';
6
- import './chunk-4X3SBHPK.js';
4
+ import './chunk-DGOG5NXR.js';
5
+ import './chunk-U4UJHOSH.js';
6
+ import './chunk-5F5NWKPN.js';
7
7
  //# sourceMappingURL=skills.js.map
8
8
  //# sourceMappingURL=skills.js.map
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+
3
+ var chunkGD63JPGC_cjs = require('./chunk-GD63JPGC.cjs');
4
+ require('./chunk-CZ2GKKYL.cjs');
5
+ require('./chunk-WJVHMTKB.cjs');
6
+ require('./chunk-LPVIRJVF.cjs');
7
+ require('./chunk-BM6N4KHO.cjs');
8
+
9
+
10
+
11
+ Object.defineProperty(exports, "StreamObjectError", {
12
+ enumerable: true,
13
+ get: function () { return chunkGD63JPGC_cjs.StreamObjectError; }
14
+ });
15
+ Object.defineProperty(exports, "streamObjectImpl", {
16
+ enumerable: true,
17
+ get: function () { return chunkGD63JPGC_cjs.streamObjectImpl; }
18
+ });
19
+ //# sourceMappingURL=stream-object-L3Q7PBMF.cjs.map
20
+ //# sourceMappingURL=stream-object-L3Q7PBMF.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"stream-object-T4DAMNVB.cjs"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"stream-object-L3Q7PBMF.cjs"}
@@ -0,0 +1,7 @@
1
+ export { StreamObjectError, streamObjectImpl } from './chunk-Y4I4EQFK.js';
2
+ import './chunk-D24WJWN2.js';
3
+ import './chunk-4VPXM6UU.js';
4
+ import './chunk-U4UJHOSH.js';
5
+ import './chunk-5F5NWKPN.js';
6
+ //# sourceMappingURL=stream-object-ZYXWS4B2.js.map
7
+ //# sourceMappingURL=stream-object-ZYXWS4B2.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"stream-object-QMNR3YFF.js"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"stream-object-ZYXWS4B2.js"}
@@ -0,0 +1,6 @@
1
+ export { loadSubagents } from './chunk-UFIXH26P.js';
2
+ import './chunk-DGOG5NXR.js';
3
+ import './chunk-U4UJHOSH.js';
4
+ import './chunk-5F5NWKPN.js';
5
+ //# sourceMappingURL=subagents-loader-I56GSKAQ.js.map
6
+ //# sourceMappingURL=subagents-loader-I56GSKAQ.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"subagents-loader-WN2SB6PV.js"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"subagents-loader-I56GSKAQ.js"}
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ var chunkE7FJOO4G_cjs = require('./chunk-E7FJOO4G.cjs');
4
+ require('./chunk-SZHU7A5B.cjs');
5
+ require('./chunk-LPVIRJVF.cjs');
6
+ require('./chunk-BM6N4KHO.cjs');
7
+
8
+
9
+
10
+ Object.defineProperty(exports, "loadSubagents", {
11
+ enumerable: true,
12
+ get: function () { return chunkE7FJOO4G_cjs.loadSubagents; }
13
+ });
14
+ //# sourceMappingURL=subagents-loader-VRW73QQT.cjs.map
15
+ //# sourceMappingURL=subagents-loader-VRW73QQT.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"subagents-loader-3CXBQWWY.cjs"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"subagents-loader-VRW73QQT.cjs"}
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var chunkRTLUZKDL_cjs = require('./chunk-RTLUZKDL.cjs');
4
- require('./chunk-44IISBRZ.cjs');
5
- var chunk2YGIBOUH_cjs = require('./chunk-2YGIBOUH.cjs');
6
- require('./chunk-SXSPMRSV.cjs');
3
+ var chunkE7FJOO4G_cjs = require('./chunk-E7FJOO4G.cjs');
4
+ require('./chunk-SZHU7A5B.cjs');
5
+ var chunkLPVIRJVF_cjs = require('./chunk-LPVIRJVF.cjs');
6
+ require('./chunk-BM6N4KHO.cjs');
7
7
 
8
8
  // src/subagents-loader.ts
9
9
  var ACCEPTED_SOURCES = ["project"];
@@ -12,7 +12,7 @@ function resolveSources(options) {
12
12
  if (declared === void 0) return ACCEPTED_SOURCES;
13
13
  for (const source of declared) {
14
14
  if (!ACCEPTED_SOURCES.includes(source)) {
15
- throw new chunk2YGIBOUH_cjs.ConfigurationError(
15
+ throw new chunkLPVIRJVF_cjs.ConfigurationError(
16
16
  `Unknown subagent setting source "${String(source)}" (accepted: ${ACCEPTED_SOURCES.join(", ")})`,
17
17
  { code: "subagent_unknown_setting_source" }
18
18
  );
@@ -22,7 +22,7 @@ function resolveSources(options) {
22
22
  }
23
23
  async function discoverSubagents(cwd, options) {
24
24
  const sources = resolveSources(options);
25
- return chunkRTLUZKDL_cjs.loadSubagents(cwd, sources.includes("project"), void 0);
25
+ return chunkE7FJOO4G_cjs.loadSubagents(cwd, sources.includes("project"), void 0);
26
26
  }
27
27
  async function loadSubagentDefinition(name, cwd, options) {
28
28
  return (await discoverSubagents(cwd, options))[name];
@@ -1,4 +1,4 @@
1
- import { a as AgentDefinition } from './agent-Zta1kvGH.cjs';
1
+ import { a as AgentDefinition } from './agent-nLqeXKIX.cjs';
2
2
  import './run-C8FBAC8o.cjs';
3
3
  import 'zod';
4
4
 
@@ -1,4 +1,4 @@
1
- import { a as AgentDefinition } from './agent-BiCINq25.js';
1
+ import { a as AgentDefinition } from './agent-B9HXlwID.js';
2
2
  import './run-C8FBAC8o.js';
3
3
  import 'zod';
4
4