theokit 0.48.14 → 0.50.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 (337) hide show
  1. package/README.md +1 -0
  2. package/dist/{actions-virtual-module-YZRZMHAX.js → actions-virtual-module-DSIVNGK7.js} +14 -8
  3. package/dist/{actions-virtual-module-YZRZMHAX.js.map → actions-virtual-module-DSIVNGK7.js.map} +1 -1
  4. package/dist/{actions-virtual-module-E4PISKMB.js → actions-virtual-module-RXL2RJTW.js} +23 -12
  5. package/dist/actions-virtual-module-RXL2RJTW.js.map +1 -0
  6. package/dist/adapters/agent-mount.d.ts +127 -0
  7. package/dist/adapters/agent-mount.js +25 -0
  8. package/dist/adapters/security-headers.d.ts +132 -0
  9. package/dist/adapters/security-headers.js +64 -0
  10. package/dist/adapters/security-headers.js.map +1 -0
  11. package/dist/adapters/web-shim.d.ts +100 -13
  12. package/dist/adapters/web-shim.js +158 -54
  13. package/dist/adapters/web-shim.js.map +1 -1
  14. package/dist/agent-7IPEVCAY.js +15 -0
  15. package/dist/agent-scan-BZa-pagG.d.ts +16 -0
  16. package/dist/{app-typed-client-I4X2UJWW.js → app-typed-client-UTBMJZOE.js} +15 -9
  17. package/dist/app-typed-client-UTBMJZOE.js.map +1 -0
  18. package/dist/{app-typed-client-HLP26EYM.js → app-typed-client-XGDZKH73.js} +24 -13
  19. package/dist/app-typed-client-XGDZKH73.js.map +1 -0
  20. package/dist/aws-lambda-VKMYUMP2.js +261 -0
  21. package/dist/aws-lambda-VKMYUMP2.js.map +1 -0
  22. package/dist/{body-parser-web-4Z2QTPDU.js → body-parser-web-ON5CUTEL.js} +5 -2
  23. package/dist/body-parser-web-ON5CUTEL.js.map +1 -0
  24. package/dist/{body-parser-web-TIOTXPDW.js → body-parser-web-RV2SSAI3.js} +5 -2
  25. package/dist/body-parser-web-RV2SSAI3.js.map +1 -0
  26. package/dist/{build-F2Q5QTSC.js → build-VZODSYIQ.js} +72 -26
  27. package/dist/build-VZODSYIQ.js.map +1 -0
  28. package/dist/{bun-A5B2MJMO.js → bun-L7PP6ID5.js} +105 -13
  29. package/dist/bun-L7PP6ID5.js.map +1 -0
  30. package/dist/{check-45NKUVSQ.js → check-GIPZBFTX.js} +2 -2
  31. package/dist/{chunk-WYHYOYRH.js → chunk-2COPDKIG.js} +468 -203
  32. package/dist/chunk-2COPDKIG.js.map +1 -0
  33. package/dist/chunk-3PBAN2YE.js +146 -0
  34. package/dist/chunk-3PBAN2YE.js.map +1 -0
  35. package/dist/{chunk-HBU2GIMZ.js → chunk-3QPVEJ7D.js} +15 -9
  36. package/dist/chunk-3QPVEJ7D.js.map +1 -0
  37. package/dist/{chunk-IEES3CHD.js → chunk-47MM2JUK.js} +8 -2
  38. package/dist/chunk-47MM2JUK.js.map +1 -0
  39. package/dist/chunk-4X6H2BXP.js +108 -0
  40. package/dist/chunk-4X6H2BXP.js.map +1 -0
  41. package/dist/{chunk-A7JBF5FO.js → chunk-5K4TDLRG.js} +8 -5
  42. package/dist/chunk-5K4TDLRG.js.map +1 -0
  43. package/dist/chunk-5YPXXSYY.js +181 -0
  44. package/dist/chunk-5YPXXSYY.js.map +1 -0
  45. package/dist/{chunk-YGAXV5HR.js → chunk-6J4JWHDJ.js} +191 -112
  46. package/dist/chunk-6J4JWHDJ.js.map +1 -0
  47. package/dist/{chunk-FTFN4MYN.js → chunk-7AEBH52I.js} +639 -516
  48. package/dist/chunk-7AEBH52I.js.map +1 -0
  49. package/dist/chunk-7UZZHCRN.js +21 -0
  50. package/dist/chunk-7UZZHCRN.js.map +1 -0
  51. package/dist/{chunk-MTEWLGVY.js → chunk-BPYMC7SU.js} +4 -48
  52. package/dist/chunk-BPYMC7SU.js.map +1 -0
  53. package/dist/chunk-BU6RJPPJ.js +421 -0
  54. package/dist/chunk-BU6RJPPJ.js.map +1 -0
  55. package/dist/{chunk-FB2HBNIC.js → chunk-BX6EUYHU.js} +6 -2
  56. package/dist/chunk-BX6EUYHU.js.map +1 -0
  57. package/dist/chunk-CHTAWXC2.js +18 -0
  58. package/dist/chunk-CHTAWXC2.js.map +1 -0
  59. package/dist/chunk-D4VP2QPR.js +16 -0
  60. package/dist/chunk-D4VP2QPR.js.map +1 -0
  61. package/dist/{chunk-YXG2SGQ3.js → chunk-DHAD2O3S.js} +6 -6
  62. package/dist/chunk-DHAD2O3S.js.map +1 -0
  63. package/dist/chunk-DOI4G4X3.js +428 -0
  64. package/dist/chunk-DOI4G4X3.js.map +1 -0
  65. package/dist/chunk-E43VJ3E5.js +188 -0
  66. package/dist/chunk-E43VJ3E5.js.map +1 -0
  67. package/dist/{chunk-47CINLWF.js → chunk-EDWEYQRG.js} +2 -2
  68. package/dist/chunk-EVZKNA2W.js +110 -0
  69. package/dist/chunk-EVZKNA2W.js.map +1 -0
  70. package/dist/chunk-FD4ZDTQ6.js +181 -0
  71. package/dist/chunk-FD4ZDTQ6.js.map +1 -0
  72. package/dist/chunk-FDOOBTXJ.js +17 -0
  73. package/dist/chunk-FDOOBTXJ.js.map +1 -0
  74. package/dist/chunk-FH3SQR6P.js +275 -0
  75. package/dist/chunk-FH3SQR6P.js.map +1 -0
  76. package/dist/{chunk-T5C46IIU.js → chunk-FMTRNQQ7.js} +28 -269
  77. package/dist/chunk-FMTRNQQ7.js.map +1 -0
  78. package/dist/chunk-H53KNS6Q.js +513 -0
  79. package/dist/chunk-H53KNS6Q.js.map +1 -0
  80. package/dist/chunk-HJHGTFEJ.js +23 -0
  81. package/dist/chunk-HJHGTFEJ.js.map +1 -0
  82. package/dist/{chunk-LXAESF4Y.js → chunk-HK4AZBKX.js} +7 -4
  83. package/dist/chunk-HK4AZBKX.js.map +1 -0
  84. package/dist/chunk-IRQGAC4L.js +52 -0
  85. package/dist/chunk-IRQGAC4L.js.map +1 -0
  86. package/dist/{chunk-FNTLKHZ7.js → chunk-JDN5SAAD.js} +7 -4
  87. package/dist/chunk-JDN5SAAD.js.map +1 -0
  88. package/dist/{chunk-XALU5LCU.js → chunk-JKF25N73.js} +555 -147
  89. package/dist/chunk-JKF25N73.js.map +1 -0
  90. package/dist/{chunk-BHOTGS7N.js → chunk-KI4DOTN4.js} +25 -2
  91. package/dist/chunk-KI4DOTN4.js.map +1 -0
  92. package/dist/chunk-KOS567NB.js +790 -0
  93. package/dist/chunk-KOS567NB.js.map +1 -0
  94. package/dist/{chunk-OOBYPCZC.js → chunk-KTS6G26H.js} +304 -195
  95. package/dist/chunk-KTS6G26H.js.map +1 -0
  96. package/dist/{chunk-ZB7D62OA.js → chunk-KUZVRJ7M.js} +3 -3
  97. package/dist/chunk-L4VFNFDL.js +248 -0
  98. package/dist/chunk-L4VFNFDL.js.map +1 -0
  99. package/dist/chunk-M2WC5MF7.js +127 -0
  100. package/dist/chunk-M2WC5MF7.js.map +1 -0
  101. package/dist/chunk-N42ZWWOW.js +273 -0
  102. package/dist/chunk-N42ZWWOW.js.map +1 -0
  103. package/dist/chunk-OGLS76RN.js +43 -0
  104. package/dist/chunk-OGLS76RN.js.map +1 -0
  105. package/dist/{chunk-7LVM22VG.js → chunk-OQCRCXCP.js} +6 -6
  106. package/dist/chunk-OQCRCXCP.js.map +1 -0
  107. package/dist/{chunk-OLGPYOLO.js → chunk-P6OS7652.js} +5 -2
  108. package/dist/chunk-P6OS7652.js.map +1 -0
  109. package/dist/{chunk-O3JIAU3V.js → chunk-PF3YM6NY.js} +157 -103
  110. package/dist/chunk-PF3YM6NY.js.map +1 -0
  111. package/dist/{chunk-NTWNO24W.js → chunk-PLUHPNGA.js} +266 -110
  112. package/dist/chunk-PLUHPNGA.js.map +1 -0
  113. package/dist/chunk-Q5L5EGWZ.js +26 -0
  114. package/dist/chunk-Q5L5EGWZ.js.map +1 -0
  115. package/dist/{chunk-AATSV4UV.js → chunk-QTHVHNJJ.js} +6 -36
  116. package/dist/chunk-QTHVHNJJ.js.map +1 -0
  117. package/dist/{chunk-KD5G3YXI.js → chunk-RARK7JBR.js} +39 -10
  118. package/dist/chunk-RARK7JBR.js.map +1 -0
  119. package/dist/chunk-RJJF457I.js +111 -0
  120. package/dist/chunk-RJJF457I.js.map +1 -0
  121. package/dist/chunk-RPET332G.js +84 -0
  122. package/dist/chunk-RPET332G.js.map +1 -0
  123. package/dist/{chunk-646CA6RV.js → chunk-RQW5YMH7.js} +12 -4
  124. package/dist/chunk-RQW5YMH7.js.map +1 -0
  125. package/dist/chunk-U5PWXS3J.js +39 -0
  126. package/dist/chunk-U5PWXS3J.js.map +1 -0
  127. package/dist/{chunk-RWNSW4FM.js → chunk-UMNXCU3K.js} +12 -6
  128. package/dist/{chunk-RWNSW4FM.js.map → chunk-UMNXCU3K.js.map} +1 -1
  129. package/dist/{chunk-DS5MCU2X.js → chunk-URCXSUI3.js} +9 -9
  130. package/dist/chunk-VI7ZANB3.js +193 -0
  131. package/dist/chunk-VI7ZANB3.js.map +1 -0
  132. package/dist/chunk-VQPHPQ5L.js +14 -0
  133. package/dist/chunk-VQPHPQ5L.js.map +1 -0
  134. package/dist/chunk-WNJTJRM6.js +147 -0
  135. package/dist/chunk-WNJTJRM6.js.map +1 -0
  136. package/dist/{chunk-BMHS4WAN.js → chunk-XS7EX55U.js} +156 -42
  137. package/dist/chunk-XS7EX55U.js.map +1 -0
  138. package/dist/chunk-YN4W7LCX.js +31 -0
  139. package/dist/chunk-YN4W7LCX.js.map +1 -0
  140. package/dist/chunk-YSJOZEI6.js +1 -0
  141. package/dist/{chunk-JA2ZAT5Q.js → chunk-Z4PJMZLM.js} +2 -2
  142. package/dist/chunk-Z4PJMZLM.js.map +1 -0
  143. package/dist/{chunk-WSXNGF7X.js → chunk-ZNZISJDZ.js} +6 -2
  144. package/dist/chunk-ZNZISJDZ.js.map +1 -0
  145. package/dist/chunk-ZWN3AODA.js +11 -0
  146. package/dist/chunk-ZWN3AODA.js.map +1 -0
  147. package/dist/cli/index.js +25 -10
  148. package/dist/cli/index.js.map +1 -1
  149. package/dist/client/core.d.ts +1 -1
  150. package/dist/client/core.js +2 -0
  151. package/dist/client/core.js.map +1 -1
  152. package/dist/client/index.d.ts +44 -10
  153. package/dist/client/index.js +35 -0
  154. package/dist/client/index.js.map +1 -1
  155. package/dist/cloudflare-SIG42OIW.js +335 -0
  156. package/dist/cloudflare-SIG42OIW.js.map +1 -0
  157. package/dist/config-support-WQHQIJTA.js +104 -0
  158. package/dist/config-support-WQHQIJTA.js.map +1 -0
  159. package/dist/{csrf-BBrEZSBW.d.ts → csrf-Dgot9qSM.d.ts} +1 -1
  160. package/dist/deno-deploy-LQAYOOPW.js +196 -0
  161. package/dist/deno-deploy-LQAYOOPW.js.map +1 -0
  162. package/dist/{dev-CDFPXISP.js → dev-3UQVD2W6.js} +29 -18
  163. package/dist/dev-3UQVD2W6.js.map +1 -0
  164. package/dist/{dev-emit-GWD6IXV7.js → dev-emit-BFNMDCPB.js} +5 -5
  165. package/dist/{dev-emit-NBT6JD7R.js → dev-emit-MVAJAFGX.js} +5 -3
  166. package/dist/dev-emit-MVAJAFGX.js.map +1 -0
  167. package/dist/engine-singleton-X4R7AZBJ.js +315 -0
  168. package/dist/engine-singleton-X4R7AZBJ.js.map +1 -0
  169. package/dist/{generate-Y3GWM57K.js → generate-EN6EDITF.js} +43 -4
  170. package/dist/generate-EN6EDITF.js.map +1 -0
  171. package/dist/index-DctfHtv-.d.ts +1058 -0
  172. package/dist/index.d.ts +8 -4
  173. package/dist/index.js +25 -13
  174. package/dist/index.js.map +1 -1
  175. package/dist/{info-QXZW722N.js → info-Y55RWS42.js} +8 -6
  176. package/dist/{info-QXZW722N.js.map → info-Y55RWS42.js.map} +1 -1
  177. package/dist/{internal-api-FBK2YXSI.js → internal-api-4X6NDS2F.js} +23 -12
  178. package/dist/{internal-api-ZCJWJ5EC.js → internal-api-XQHU5JKY.js} +31 -16
  179. package/dist/internal-api-XQHU5JKY.js.map +1 -0
  180. package/dist/load-config-4ATXQUN3.js +16 -0
  181. package/dist/match-DmGgxjIU.d.ts +44 -0
  182. package/dist/{mcp-KTYP4ZON.js → mcp-IQRHFP3Y.js} +7 -7
  183. package/dist/netlify-C2IRCZKI.js +245 -0
  184. package/dist/netlify-C2IRCZKI.js.map +1 -0
  185. package/dist/node-OSVPYQ3D.js +10 -0
  186. package/dist/nonce-BXt7Qu_C.d.ts +31 -0
  187. package/dist/observability-bootstrap-LERYDHKY.js +16 -0
  188. package/dist/{openapi-OUXNB2F2.js → openapi-VFPEZSRI.js} +13 -11
  189. package/dist/{openapi-OUXNB2F2.js.map → openapi-VFPEZSRI.js.map} +1 -1
  190. package/dist/{plugin-runner-DHVr1cC5.d.ts → plugin-runner-BVMOSxvb.d.ts} +1 -1
  191. package/dist/{plugin-types-4VN1GMqV.d.ts → plugin-types-BUVfUQ0V.d.ts} +1 -1
  192. package/dist/preview-BT47VMIB.js +23 -0
  193. package/dist/preview-BT47VMIB.js.map +1 -0
  194. package/dist/provider-resolver-Dx6QuWrw.d.ts +128 -0
  195. package/dist/registry-KBZDCFVQ.js +23 -0
  196. package/dist/route-config-Cm_ZMA1C.d.ts +72 -0
  197. package/dist/route-policy-BxOycCDq.d.ts +65 -0
  198. package/dist/router/element-scroll-restoration.d.ts +28 -0
  199. package/dist/router/element-scroll-restoration.js +96 -0
  200. package/dist/router/element-scroll-restoration.js.map +1 -0
  201. package/dist/{routes-NJR4ISCT.js → routes-BPLU3ISV.js} +11 -9
  202. package/dist/{routes-NJR4ISCT.js.map → routes-BPLU3ISV.js.map} +1 -1
  203. package/dist/{scan-7MJC6PYU.js → scan-YJEE4KQK.js} +2 -2
  204. package/dist/{schema-DNIT7JQX.js → schema-SOAD43RQ.js} +7 -5
  205. package/dist/schemas-4AXHQMV3.js +25 -0
  206. package/dist/schemas-4AXHQMV3.js.map +1 -0
  207. package/dist/security-headers-Ccj7ncNx.d.ts +129 -0
  208. package/dist/server/agent/index.d.ts +2 -105
  209. package/dist/server/agent/index.js +1 -1
  210. package/dist/server/auth/index.d.ts +2 -21
  211. package/dist/server/auth/index.js +3 -2
  212. package/dist/server/cron/index.js +4 -3
  213. package/dist/server/define/index.d.ts +43 -57
  214. package/dist/server/define/index.js +10 -1
  215. package/dist/server/http/index.d.ts +7 -5
  216. package/dist/server/http/index.js +57 -12
  217. package/dist/server/index.d.ts +47 -439
  218. package/dist/server/index.js +120 -201
  219. package/dist/server/index.js.map +1 -1
  220. package/dist/server/jobs/index.js +4 -3
  221. package/dist/server/observability/index.d.ts +109 -35
  222. package/dist/server/observability/index.js +11 -7
  223. package/dist/server/plugins/index.d.ts +3 -3
  224. package/dist/server/scan/index.d.ts +47 -12
  225. package/dist/server/scan/index.js +13 -4
  226. package/dist/server/security/index.d.ts +61 -103
  227. package/dist/server/security/index.js +15 -6
  228. package/dist/server/webhook/index.d.ts +90 -3
  229. package/dist/server/webhook/index.js +12 -2
  230. package/dist/server-boundary-2WFT546S.js +149 -0
  231. package/dist/server-boundary-2WFT546S.js.map +1 -0
  232. package/dist/server-boundary-A67OPRKO.js +134 -0
  233. package/dist/server-boundary-A67OPRKO.js.map +1 -0
  234. package/dist/{services-typed-client-P4JERLBL.js → services-typed-client-XGT5SUUN.js} +2 -2
  235. package/dist/{start-25OV2CAK.js → start-3K3C4Z2X.js} +224 -161
  236. package/dist/start-3K3C4Z2X.js.map +1 -0
  237. package/dist/{static-RTO637XW.js → static-SVDWIOXJ.js} +24 -13
  238. package/dist/static-SVDWIOXJ.js.map +1 -0
  239. package/dist/{theo-cloud-UZ3GINRU.js → theo-cloud-3ET4G5T6.js} +9 -2
  240. package/dist/theo-cloud-3ET4G5T6.js.map +1 -0
  241. package/dist/vercel-BMCQKCWE.js +277 -0
  242. package/dist/vercel-BMCQKCWE.js.map +1 -0
  243. package/dist/vite-plugin/index.js +25 -13
  244. package/dist/vite-plugin-USXUIV3H.js +43 -0
  245. package/dist/vite-plugin-USXUIV3H.js.map +1 -0
  246. package/package.json +19 -6
  247. package/dist/actions-virtual-module-E4PISKMB.js.map +0 -1
  248. package/dist/agent-XAQCUQNB.js +0 -15
  249. package/dist/app-typed-client-HLP26EYM.js.map +0 -1
  250. package/dist/app-typed-client-I4X2UJWW.js.map +0 -1
  251. package/dist/aws-lambda-KES4MFJV.js +0 -172
  252. package/dist/aws-lambda-KES4MFJV.js.map +0 -1
  253. package/dist/body-parser-web-4Z2QTPDU.js.map +0 -1
  254. package/dist/body-parser-web-TIOTXPDW.js.map +0 -1
  255. package/dist/build-F2Q5QTSC.js.map +0 -1
  256. package/dist/bun-A5B2MJMO.js.map +0 -1
  257. package/dist/chunk-646CA6RV.js.map +0 -1
  258. package/dist/chunk-7LVM22VG.js.map +0 -1
  259. package/dist/chunk-A7JBF5FO.js.map +0 -1
  260. package/dist/chunk-AATSV4UV.js.map +0 -1
  261. package/dist/chunk-AM3QABW5.js +0 -161
  262. package/dist/chunk-AM3QABW5.js.map +0 -1
  263. package/dist/chunk-AXKUA57G.js +0 -94
  264. package/dist/chunk-AXKUA57G.js.map +0 -1
  265. package/dist/chunk-BHOTGS7N.js.map +0 -1
  266. package/dist/chunk-BMHS4WAN.js.map +0 -1
  267. package/dist/chunk-CMYSHZFT.js +0 -422
  268. package/dist/chunk-CMYSHZFT.js.map +0 -1
  269. package/dist/chunk-DQIPV7L5.js +0 -118
  270. package/dist/chunk-DQIPV7L5.js.map +0 -1
  271. package/dist/chunk-FB2HBNIC.js.map +0 -1
  272. package/dist/chunk-FNTLKHZ7.js.map +0 -1
  273. package/dist/chunk-FTFN4MYN.js.map +0 -1
  274. package/dist/chunk-HBU2GIMZ.js.map +0 -1
  275. package/dist/chunk-IEES3CHD.js.map +0 -1
  276. package/dist/chunk-JA2ZAT5Q.js.map +0 -1
  277. package/dist/chunk-KD5G3YXI.js.map +0 -1
  278. package/dist/chunk-KTKTHIUF.js +0 -405
  279. package/dist/chunk-KTKTHIUF.js.map +0 -1
  280. package/dist/chunk-LNVMHQ2Z.js +0 -54
  281. package/dist/chunk-LNVMHQ2Z.js.map +0 -1
  282. package/dist/chunk-LXAESF4Y.js.map +0 -1
  283. package/dist/chunk-MTEWLGVY.js.map +0 -1
  284. package/dist/chunk-NTWNO24W.js.map +0 -1
  285. package/dist/chunk-O3JIAU3V.js.map +0 -1
  286. package/dist/chunk-OLGPYOLO.js.map +0 -1
  287. package/dist/chunk-OOBYPCZC.js.map +0 -1
  288. package/dist/chunk-T5C46IIU.js.map +0 -1
  289. package/dist/chunk-U267AOWS.js +0 -28
  290. package/dist/chunk-U267AOWS.js.map +0 -1
  291. package/dist/chunk-UW2TEAGR.js +0 -77
  292. package/dist/chunk-UW2TEAGR.js.map +0 -1
  293. package/dist/chunk-WPJOTQA5.js +0 -1
  294. package/dist/chunk-WSXNGF7X.js.map +0 -1
  295. package/dist/chunk-WYHYOYRH.js.map +0 -1
  296. package/dist/chunk-XALU5LCU.js.map +0 -1
  297. package/dist/chunk-XR74JD4M.js +0 -457
  298. package/dist/chunk-XR74JD4M.js.map +0 -1
  299. package/dist/chunk-YGAXV5HR.js.map +0 -1
  300. package/dist/chunk-YXG2SGQ3.js.map +0 -1
  301. package/dist/cloudflare-IN2WB7FZ.js +0 -122
  302. package/dist/cloudflare-IN2WB7FZ.js.map +0 -1
  303. package/dist/deno-deploy-LYXQEJ6A.js +0 -107
  304. package/dist/deno-deploy-LYXQEJ6A.js.map +0 -1
  305. package/dist/dev-CDFPXISP.js.map +0 -1
  306. package/dist/dev-emit-NBT6JD7R.js.map +0 -1
  307. package/dist/generate-Y3GWM57K.js.map +0 -1
  308. package/dist/index-D_PxPXgQ.d.ts +0 -575
  309. package/dist/load-config-FIWNKOJO.js +0 -14
  310. package/dist/match-CfbEFRG4.d.ts +0 -26
  311. package/dist/netlify-DLEOCFAD.js +0 -150
  312. package/dist/netlify-DLEOCFAD.js.map +0 -1
  313. package/dist/node-QXYSUWQ4.js +0 -10
  314. package/dist/registry-S7OMF3OS.js +0 -23
  315. package/dist/start-25OV2CAK.js.map +0 -1
  316. package/dist/static-RTO637XW.js.map +0 -1
  317. package/dist/theo-cloud-UZ3GINRU.js.map +0 -1
  318. package/dist/vercel-6D6EZUVD.js +0 -133
  319. package/dist/vercel-6D6EZUVD.js.map +0 -1
  320. package/dist/vite-plugin-RJFKLF2U.js +0 -36
  321. /package/dist/{chunk-WPJOTQA5.js.map → adapters/agent-mount.js.map} +0 -0
  322. /package/dist/{agent-XAQCUQNB.js.map → agent-7IPEVCAY.js.map} +0 -0
  323. /package/dist/{check-45NKUVSQ.js.map → check-GIPZBFTX.js.map} +0 -0
  324. /package/dist/{chunk-47CINLWF.js.map → chunk-EDWEYQRG.js.map} +0 -0
  325. /package/dist/{chunk-ZB7D62OA.js.map → chunk-KUZVRJ7M.js.map} +0 -0
  326. /package/dist/{chunk-DS5MCU2X.js.map → chunk-URCXSUI3.js.map} +0 -0
  327. /package/dist/{internal-api-ZCJWJ5EC.js.map → chunk-YSJOZEI6.js.map} +0 -0
  328. /package/dist/{dev-emit-GWD6IXV7.js.map → dev-emit-BFNMDCPB.js.map} +0 -0
  329. /package/dist/{internal-api-FBK2YXSI.js.map → internal-api-4X6NDS2F.js.map} +0 -0
  330. /package/dist/{load-config-FIWNKOJO.js.map → load-config-4ATXQUN3.js.map} +0 -0
  331. /package/dist/{mcp-KTYP4ZON.js.map → mcp-IQRHFP3Y.js.map} +0 -0
  332. /package/dist/{node-QXYSUWQ4.js.map → node-OSVPYQ3D.js.map} +0 -0
  333. /package/dist/{scan-7MJC6PYU.js.map → observability-bootstrap-LERYDHKY.js.map} +0 -0
  334. /package/dist/{registry-S7OMF3OS.js.map → registry-KBZDCFVQ.js.map} +0 -0
  335. /package/dist/{schema-DNIT7JQX.js.map → scan-YJEE4KQK.js.map} +0 -0
  336. /package/dist/{vite-plugin-RJFKLF2U.js.map → schema-SOAD43RQ.js.map} +0 -0
  337. /package/dist/{services-typed-client-P4JERLBL.js.map → services-typed-client-XGT5SUUN.js.map} +0 -0
@@ -1,36 +1,29 @@
1
1
  #!/usr/bin/env node
2
2
  import "tsx/esm";
3
3
  import {
4
+ createAgentSubjectResolver,
4
5
  handleAgentApproval,
5
6
  isAgentCardPath,
6
7
  isApprovalPath,
7
- isListApprovalsPath,
8
+ matchAgentAuxRoute,
9
+ parseApprovalAgentName,
10
+ resolvePluginSpecifiers,
8
11
  resolveTransformer,
9
- serveAgentAuxRoute,
10
- setupSsrDevMiddleware,
11
- writeWebResponseToServerResponse
12
- } from "./chunk-NTWNO24W.js";
12
+ serveMatchedAuxRoute,
13
+ serveThroughPluginLifecycle,
14
+ setupSsrDevMiddleware
15
+ } from "./chunk-PLUHPNGA.js";
13
16
  import {
14
- isMcpPath
15
- } from "./chunk-2CVV6CNN.js";
17
+ resolveTheoRootDir
18
+ } from "./chunk-FDOOBTXJ.js";
16
19
  import {
17
20
  isRouteFile,
18
21
  scanRoutes
19
- } from "./chunk-IEES3CHD.js";
20
- import {
21
- loadConfig
22
- } from "./chunk-AATSV4UV.js";
23
- import {
24
- buildServicesProxyConfig
25
- } from "./chunk-WSXNGF7X.js";
26
- import {
27
- broadcastToDevtools
28
- } from "./chunk-5ODOE6EF.js";
22
+ } from "./chunk-47MM2JUK.js";
29
23
  import {
30
24
  BATCH_PATH,
31
25
  CSP_REPORT_PATH,
32
26
  CsrfReadinessStore,
33
- TRACE_HEADER,
34
27
  applySecurityHeaders,
35
28
  createCorsHandler,
36
29
  createPluginRunnerFromConfig,
@@ -38,37 +31,54 @@ import {
38
31
  createViteLoader,
39
32
  executeAction,
40
33
  executeRoute,
41
- extractTraceId,
42
34
  findSuggestion,
43
35
  handleBatchRequest,
44
36
  handleCspReport,
45
37
  handleCsrfReadiness,
46
- mountAgent
47
- } from "./chunk-WYHYOYRH.js";
38
+ mountAgent,
39
+ readAgentPolicy,
40
+ writeWebResponseToServerResponse
41
+ } from "./chunk-2COPDKIG.js";
48
42
  import {
49
43
  getApprovalRegistry,
50
44
  resolveProvider
51
- } from "./chunk-DQIPV7L5.js";
45
+ } from "./chunk-5YPXXSYY.js";
52
46
  import {
47
+ createWebRequestSource,
53
48
  dispatchControllerRequest,
54
49
  incomingMessageToHandlerRequest,
55
- incomingMessageToWebRequest,
56
- logRequest,
57
50
  sendError
58
- } from "./chunk-T5C46IIU.js";
51
+ } from "./chunk-FMTRNQQ7.js";
52
+ import {
53
+ TRACE_HEADER,
54
+ createObservabilityPluginFromConfig,
55
+ extractTraceId
56
+ } from "./chunk-H53KNS6Q.js";
57
+ import {
58
+ logRequest
59
+ } from "./chunk-RARK7JBR.js";
59
60
  import {
60
61
  scanAgents
61
- } from "./chunk-LNVMHQ2Z.js";
62
+ } from "./chunk-EVZKNA2W.js";
62
63
  import {
63
64
  matchRoute,
64
65
  scanServerActions,
65
66
  scanServerRoutes,
66
67
  scanWebSocketRoutes
67
- } from "./chunk-BMHS4WAN.js";
68
+ } from "./chunk-XS7EX55U.js";
69
+ import {
70
+ loadConfig
71
+ } from "./chunk-QTHVHNJJ.js";
72
+ import {
73
+ buildServicesProxyConfig
74
+ } from "./chunk-ZNZISJDZ.js";
75
+ import {
76
+ broadcastToDevtools
77
+ } from "./chunk-5ODOE6EF.js";
68
78
 
69
79
  // src/vite-plugin/index.ts
70
- import { existsSync as existsSync7 } from "fs";
71
- import { resolve as resolve6, dirname as dirname4 } from "path";
80
+ import { existsSync as existsSync6 } from "fs";
81
+ import { resolve as resolve5, dirname as dirname4 } from "path";
72
82
  import { fileURLToPath } from "url";
73
83
 
74
84
  // src/vite-plugin/config-hook.ts
@@ -113,42 +123,56 @@ function runConfigHook(ctx) {
113
123
  },
114
124
  resolve: {
115
125
  alias: [
116
- // Order matters: most-specific first so `theokit/X` doesn't
117
- // get matched by the bare `theokit` alias.
118
- { find: "theokit/server", replacement: resolve(ctx.theoSrcDir, `server/index${ext}`) },
119
- { find: "theokit/client", replacement: resolve(ctx.theoSrcDir, `client/index${ext}`) },
126
+ // Order still matters — first match wins — but the entries below are
127
+ // EXACT (#377). A Vite alias whose `find` is a string matches by prefix,
128
+ // and every replacement here points at a FILE, so the old string form
129
+ // rewrote `theokit/client/core` into `…/client/index.ts/core` and the
130
+ // build died with ENOTDIR. It did that for every subpath nobody had
131
+ // listed, which made the failure open-ended rather than a typo.
132
+ { find: /^theokit\/server$/u, replacement: resolve(ctx.theoSrcDir, `server/index${ext}`) },
133
+ { find: /^theokit\/client$/u, replacement: resolve(ctx.theoSrcDir, `client/index${ext}`) },
120
134
  {
121
135
  // T2.1 (M5 lonely folders) moved the source from
122
136
  // `react-query/index.ts` into `client/react-query.ts` (sibling of
123
137
  // `client/index.ts`). The package.json export `./react-query`
124
138
  // still points at the build artifact `./dist/react-query/index.{js,d.ts}`,
125
139
  // but the dev-time source alias must follow the new location.
126
- find: "theokit/react-query",
140
+ find: /^theokit\/react-query$/u,
127
141
  replacement: resolve(ctx.theoSrcDir, `client/react-query${ext}`)
128
142
  },
129
143
  {
130
- find: "theokit/vite-plugin",
144
+ find: /^theokit\/vite-plugin$/u,
131
145
  replacement: resolve(ctx.theoSrcDir, `vite-plugin/index${ext}`)
132
146
  },
133
147
  {
134
- find: "theokit/adapters/web-shim",
148
+ find: /^theokit\/adapters\/web-shim$/u,
135
149
  replacement: resolve(ctx.theoSrcDir, `adapters/web-shim${ext}`)
136
150
  },
137
151
  {
138
- find: "theokit/adapters/ws-shim",
152
+ find: /^theokit\/adapters\/ws-shim$/u,
139
153
  replacement: resolve(ctx.theoSrcDir, `adapters/ws-shim${ext}`)
140
154
  },
141
155
  // T1.2 — devtools entry (DEV only; tree-shaken in build).
142
156
  // Source layout: src/devtools/dom/entry.tsx (has /dom/ segment)
143
157
  // Dist layout: dist/devtools/entry.js (tsup flattens /dom/)
144
158
  {
145
- find: "theokit/devtools/entry",
159
+ find: /^theokit\/devtools\/entry$/u,
146
160
  replacement: resolve(
147
161
  ctx.theoSrcDir,
148
162
  ext === ".ts" ? "devtools/dom/entry.tsx" : "devtools/entry.js"
149
163
  )
150
164
  },
151
- { find: "theokit", replacement: resolve(ctx.theoSrcDir, `index${ext}`) }
165
+ // Everything else under the package, by one rule rather than a list that
166
+ // has to grow with the exports map. The source layout mirrors the
167
+ // subpath, so `theokit/cache` is `<src>/cache` and Vite's own extension
168
+ // resolution finds the file. The two entries above that do NOT mirror it
169
+ // — react-query moved to a sibling, devtools' source carries a `/dom/`
170
+ // segment the dist flattens — are matched before this and keep their
171
+ // mapping.
172
+ { find: /^theokit\/(.+)$/u, replacement: resolve(ctx.theoSrcDir, "$1") },
173
+ // Exact, so a package merely NAMED like ours — `theokit-anything` — is
174
+ // left alone. The prefix form ate those too.
175
+ { find: /^theokit$/u, replacement: resolve(ctx.theoSrcDir, `index${ext}`) }
152
176
  ]
153
177
  }
154
178
  };
@@ -253,7 +277,14 @@ var DEFAULT_RESOLVED = {
253
277
  async function resolvePluginConfig(projectRoot) {
254
278
  try {
255
279
  const userConfig = await loadConfig(projectRoot);
256
- const pluginRunner = await createPluginRunnerFromConfig(userConfig.plugins);
280
+ const observabilityPlugin = createObservabilityPluginFromConfig(
281
+ userConfig.observability,
282
+ process.env
283
+ );
284
+ const declaredPlugins = await resolvePluginSpecifiers(userConfig.plugins ?? [], projectRoot);
285
+ const pluginRunner = await createPluginRunnerFromConfig(
286
+ observabilityPlugin === void 0 ? declaredPlugins : [observabilityPlugin, ...declaredPlugins]
287
+ );
257
288
  const transformer = resolveTransformer(userConfig.serialization);
258
289
  let resolvedBatching;
259
290
  if (userConfig.batching === true) {
@@ -409,7 +440,7 @@ function createActionMiddleware(vite, serverDir, options) {
409
440
  // src/vite-plugin/agent-middleware.ts
410
441
  import { randomUUID as randomUUID2 } from "crypto";
411
442
  var PREFIX2 = "/api/agents/";
412
- async function serveApprove(req, res, urlPath, csrfMode, log) {
443
+ async function serveApprove(req, res, urlPath, deps, log) {
413
444
  const method = (req.method ?? "POST").toUpperCase();
414
445
  if (method !== "POST") {
415
446
  sendError(
@@ -429,24 +460,36 @@ async function serveApprove(req, res, urlPath, csrfMode, log) {
429
460
  });
430
461
  return;
431
462
  }
432
- try {
433
- const response = await handleAgentApproval(
434
- incomingMessageToWebRequest(req),
435
- urlPath,
436
- getApprovalRegistry(),
437
- csrfMode
438
- );
439
- await writeWebResponseToServerResponse(response, res);
440
- } catch (err) {
441
- sendError(
463
+ await serveThroughPluginLifecycle(
464
+ {
465
+ source: createWebRequestSource(req),
442
466
  res,
443
- "INTERNAL",
444
- err instanceof Error ? err.message : "Approve handler failed",
445
- 500,
446
- void 0,
447
- log.requestId
448
- );
449
- }
467
+ requestId: log.requestId,
468
+ pluginRunner: deps.pluginRunner,
469
+ failureMessage: "Approve handler failed"
470
+ },
471
+ async (request) => {
472
+ const agent = scanAgents(deps.projectRoot, deps.agentsDir).find(
473
+ (a) => a.name === parseApprovalAgentName(urlPath)
474
+ );
475
+ const resolveSubject = createAgentSubjectResolver({
476
+ req,
477
+ res,
478
+ loadModule: deps.loadModule,
479
+ serverDir: deps.serverDir,
480
+ pluginRunner: deps.pluginRunner
481
+ });
482
+ const policy = agent === void 0 ? void 0 : readAgentPolicy(await deps.loadModule(agent.filePath), agent.filePath);
483
+ const response = await handleAgentApproval(
484
+ request,
485
+ urlPath,
486
+ getApprovalRegistry(),
487
+ deps.csrfMode,
488
+ { policy, resolveSubject }
489
+ );
490
+ await writeWebResponseToServerResponse(response, res);
491
+ }
492
+ );
450
493
  logRequest({
451
494
  method,
452
495
  url: req.url ?? "",
@@ -458,54 +501,69 @@ async function serveApprove(req, res, urlPath, csrfMode, log) {
458
501
  async function serveAux(req, res, next, urlPath, deps) {
459
502
  const requestId = randomUUID2();
460
503
  const start = Date.now();
461
- try {
462
- const request = incomingMessageToWebRequest(req);
463
- const response = await serveAgentAuxRoute(request, urlPath, {
464
- agents: scanAgents(deps.projectRoot, deps.agentsDir),
465
- loadModule: deps.loadModule,
466
- baseUrl: `http://${req.headers.host ?? "localhost"}`,
467
- csrfMode: deps.csrfMode,
468
- // M39 — the thread follow-up route drives the agent; resolve the key on demand.
469
- // theokit#328 — the thread route drives an agent, so its key follows the model too.
470
- resolveApiKey: (model) => resolveProvider(model).apiKey
471
- });
472
- if (response === null) {
473
- next();
474
- return;
475
- }
476
- res.setHeader("x-request-id", requestId);
477
- await writeWebResponseToServerResponse(response, res);
478
- } catch (err) {
479
- res.setHeader("x-request-id", requestId);
480
- sendError(
504
+ const auxDeps = {
505
+ agents: scanAgents(deps.projectRoot, deps.agentsDir),
506
+ loadModule: deps.loadModule,
507
+ baseUrl: `http://${req.headers.host ?? "localhost"}`,
508
+ csrfMode: deps.csrfMode,
509
+ // M39 — the thread follow-up route drives the agent; resolve the key on demand.
510
+ // theokit#328 — the thread route drives an agent, so its key follows the model too.
511
+ resolveApiKey: (model) => resolveProvider(model).apiKey,
512
+ // usetheokit/theokit#365 — parity with `theokit start`; lazy for the same reason.
513
+ resolveSubject: createAgentSubjectResolver({
514
+ req,
481
515
  res,
482
- "INTERNAL",
483
- err instanceof Error ? err.message : "Agent aux handler failed",
484
- 500,
485
- void 0,
486
- requestId
487
- );
516
+ loadModule: deps.loadModule,
517
+ serverDir: deps.serverDir,
518
+ pluginRunner: deps.pluginRunner
519
+ })
520
+ };
521
+ const method = (req.method ?? "GET").toUpperCase();
522
+ const route = await matchAgentAuxRoute(method, urlPath, auxDeps);
523
+ if (route === null) {
524
+ next();
525
+ return;
488
526
  }
527
+ res.setHeader("x-request-id", requestId);
528
+ await serveThroughPluginLifecycle(
529
+ {
530
+ source: createWebRequestSource(req),
531
+ res,
532
+ requestId,
533
+ pluginRunner: deps.pluginRunner,
534
+ failureMessage: "Agent aux handler failed"
535
+ },
536
+ async (request) => {
537
+ await writeWebResponseToServerResponse(
538
+ await serveMatchedAuxRoute(route, request, auxDeps),
539
+ res
540
+ );
541
+ }
542
+ );
489
543
  logRequest({
490
- method: (req.method ?? "GET").toUpperCase(),
544
+ method,
491
545
  url: req.url ?? "",
492
546
  status: res.statusCode,
493
547
  duration: Date.now() - start,
494
548
  requestId
495
549
  });
496
550
  }
497
- function createAgentMiddleware(vite, projectRoot, csrfMode = "strict", agentsDir = "agents", pluginRunner) {
551
+ function createAgentMiddleware(vite, projectRoot, csrfMode = "strict", agentsDir = "agents", deps = {}) {
552
+ const { pluginRunner, serverDir } = deps;
498
553
  const loadModule = createViteLoader(vite);
554
+ const cardDeps = () => ({
555
+ projectRoot,
556
+ loadModule,
557
+ agentsDir,
558
+ csrfMode,
559
+ serverDir,
560
+ pluginRunner
561
+ });
499
562
  return (req, res, next) => {
500
563
  void (async () => {
501
564
  const url = req.url ?? "";
502
565
  if (isAgentCardPath(url.split("?")[0]) !== null) {
503
- await serveAux(req, res, next, url.split("?")[0], {
504
- projectRoot,
505
- loadModule,
506
- agentsDir,
507
- csrfMode
508
- });
566
+ await serveAux(req, res, next, url.split("?")[0], cardDeps());
509
567
  return;
510
568
  }
511
569
  if (!url.startsWith(PREFIX2)) {
@@ -517,16 +575,12 @@ function createAgentMiddleware(vite, projectRoot, csrfMode = "strict", agentsDir
517
575
  res.setHeader("x-request-id", requestId);
518
576
  const urlPath = url.split("?")[0];
519
577
  if (isApprovalPath(urlPath)) {
520
- await serveApprove(req, res, urlPath, csrfMode, { requestId, start });
521
- return;
522
- }
523
- if (isListApprovalsPath(urlPath) !== null || isMcpPath(urlPath) !== null) {
524
- await serveAux(req, res, next, urlPath, { projectRoot, loadModule, agentsDir, csrfMode });
578
+ await serveApprove(req, res, urlPath, cardDeps(), { requestId, start });
525
579
  return;
526
580
  }
527
581
  const agent = scanAgents(projectRoot, agentsDir).find((a) => a.agentPath === urlPath);
528
582
  if (!agent) {
529
- next();
583
+ await serveAux(req, res, next, urlPath, cardDeps());
530
584
  return;
531
585
  }
532
586
  const method = (req.method ?? "POST").toUpperCase();
@@ -553,7 +607,8 @@ function createAgentMiddleware(vite, projectRoot, csrfMode = "strict", agentsDir
553
607
  loadModule,
554
608
  csrfMode,
555
609
  projectRoot,
556
- pluginRunner
610
+ pluginRunner,
611
+ serverDir
557
612
  });
558
613
  })();
559
614
  };
@@ -570,60 +625,39 @@ async function serveAgentTurn(t) {
570
625
  loadModule,
571
626
  csrfMode,
572
627
  projectRoot,
573
- pluginRunner
628
+ pluginRunner,
629
+ serverDir
574
630
  } = t;
575
- let pluginCtx;
576
- let request;
577
- try {
578
- request = incomingMessageToWebRequest(req);
579
- pluginCtx = { request, response: res, ctx: {}, requestId };
580
- } catch (err) {
581
- sendError(
631
+ const resolveSubject = createAgentSubjectResolver({
632
+ req,
633
+ res,
634
+ loadModule,
635
+ serverDir,
636
+ pluginRunner
637
+ });
638
+ await serveThroughPluginLifecycle(
639
+ {
640
+ source: createWebRequestSource(req),
582
641
  res,
583
- "INTERNAL",
584
- err instanceof Error ? err.message : "Agent handler failed",
585
- 500,
586
- void 0,
587
- requestId
588
- );
589
- logRequest({ method, url, status: res.statusCode, duration: Date.now() - start, requestId });
590
- return;
591
- }
592
- if (pluginRunner) {
593
- pluginRunner.applyDecorations(pluginCtx.ctx);
594
- const onRequest = await pluginRunner.runOnRequest(pluginCtx);
595
- if (onRequest.shortCircuited) {
596
- logRequest({
597
- method,
598
- url,
599
- status: res.statusCode,
600
- duration: Date.now() - start,
601
- requestId
642
+ requestId,
643
+ pluginRunner,
644
+ failureMessage: "Agent handler failed"
645
+ },
646
+ async (request) => {
647
+ const mod = await loadModule(agent.filePath);
648
+ const apiKey = (model) => resolveProvider(model).apiKey;
649
+ const response = await mountAgent(mod, request, apiKey, {
650
+ source: agent.filePath,
651
+ csrfMode,
652
+ projectRoot,
653
+ // usetheokit/theokit#365 — the policy comes off `mod`; the caller owes the identity.
654
+ // usetheokit/theokit#406 — and the same name labels the run's spans.
655
+ agentName: agent.name,
656
+ resolveSubject
602
657
  });
603
- return;
658
+ await writeWebResponseToServerResponse(response, res);
604
659
  }
605
- }
606
- try {
607
- const mod = await loadModule(agent.filePath);
608
- const apiKey = (model) => resolveProvider(model).apiKey;
609
- const response = await mountAgent(mod, request, apiKey, {
610
- source: agent.filePath,
611
- csrfMode,
612
- projectRoot
613
- });
614
- await writeWebResponseToServerResponse(response, res);
615
- } catch (err) {
616
- if (pluginRunner) await pluginRunner.runOnError(pluginCtx, err);
617
- sendError(
618
- res,
619
- "INTERNAL",
620
- err instanceof Error ? err.message : "Agent handler failed",
621
- 500,
622
- void 0,
623
- requestId
624
- );
625
- }
626
- if (pluginRunner) await pluginRunner.runOnResponse(pluginCtx);
660
+ );
627
661
  logRequest({ method, url, status: res.statusCode, duration: Date.now() - start, requestId });
628
662
  }
629
663
 
@@ -676,10 +710,10 @@ async function handleBatchIfMatch(req, res, ctx) {
676
710
  async function handleBatchInline(req, res, batching, requestId) {
677
711
  try {
678
712
  const chunks = [];
679
- await new Promise((resolve7, reject) => {
713
+ await new Promise((resolve6, reject) => {
680
714
  req.on("data", (c) => chunks.push(c));
681
715
  req.on("end", () => {
682
- resolve7();
716
+ resolve6();
683
717
  });
684
718
  req.on("error", reject);
685
719
  });
@@ -744,6 +778,14 @@ async function tryControllerFallthrough(ctx) {
744
778
  requestId: ctx.requestId,
745
779
  // M47 — serve @Expose-bound agent routes via the ONE runtime (mountAgent). CSRF is already enforced
746
780
  // once at the controller-dispatch boundary (G5), so mountAgent runs with csrfMode 'off' (no double gate).
781
+ //
782
+ // usetheokit/theokit#365 gated the CONVENTION endpoints (`agents/<name>.ts`) and deliberately
783
+ // left this one to the decorator stack: an `@Expose` route is a controller method, so its
784
+ // access decision is the controller's `@Guard` chain, which the dispatcher already runs before
785
+ // it gets here. Passing a policy as well would give this one surface two authorization
786
+ // mechanisms and no rule for which wins. What is NOT solved by that: an `@Expose`d agent shares
787
+ // the conversation store with the convention endpoints, so a guard that admits a caller admits
788
+ // them to whatever `sessionId` the body names — see the advisory.
747
789
  serveAgent: (agent, request) => mountAgent(agent, request, (model) => resolveProvider(model).apiKey, {
748
790
  source: "expose",
749
791
  csrfMode: "off"
@@ -934,7 +976,12 @@ async function runConfigureServer(server, ctx) {
934
976
  })
935
977
  );
936
978
  server.middlewares.use(
937
- createAgentMiddleware(server, ctx.projectRoot, ctx.csrfMode, ctx.agentsDir, ctx.pluginRunner)
979
+ createAgentMiddleware(server, ctx.projectRoot, ctx.csrfMode, ctx.agentsDir, {
980
+ pluginRunner: ctx.pluginRunner,
981
+ // usetheokit/theokit#365 — the same backend root the route middleware scans, so an agent's
982
+ // declared policy is judged against the identity `server/context.ts` establishes.
983
+ serverDir
984
+ })
938
985
  );
939
986
  const servicesProxyPrefixes = ctx.services && Object.keys(ctx.services).length > 0 ? Object.values(ctx.services).map((s) => s.proxy) : [];
940
987
  const csrfReadinessStore = ctx.csrfReadinessStoreOverride ?? new CsrfReadinessStore();
@@ -981,7 +1028,7 @@ async function runConfigureServer(server, ctx) {
981
1028
  server.watcher.on("unlink", handleRouteChange);
982
1029
  if (ctx.resolvedOpenApi !== void 0) {
983
1030
  const openApiCfg = ctx.resolvedOpenApi;
984
- const { reEmitOpenApi } = await import("./dev-emit-GWD6IXV7.js");
1031
+ const { reEmitOpenApi } = await import("./dev-emit-BFNMDCPB.js");
985
1032
  const openApiServerDir = ctx.serverDir;
986
1033
  const openApiDistDir = resolve3(ctx.projectRoot, ctx.resolvedDistDir);
987
1034
  const isRouteFileForOpenApi = (file) => file.startsWith(openApiServerDir) && /\.(ts|tsx|js|mjs)$/.test(file);
@@ -1288,19 +1335,9 @@ async function integrateUseTheoUI(cwd, opts) {
1288
1335
  return [...tailwindPlugins, ...uiPlugins];
1289
1336
  }
1290
1337
 
1291
- // src/vite-plugin/resolve-theo-root.ts
1338
+ // src/vite-plugin/transform-html-hook.ts
1292
1339
  import { existsSync as existsSync5 } from "fs";
1293
1340
  import { resolve as resolve4 } from "path";
1294
- function resolveTheoRootDir(currentDir) {
1295
- if (existsSync5(resolve4(currentDir, "client"))) {
1296
- return currentDir;
1297
- }
1298
- return resolve4(currentDir, "..");
1299
- }
1300
-
1301
- // src/vite-plugin/transform-html-hook.ts
1302
- import { existsSync as existsSync6 } from "fs";
1303
- import { resolve as resolve5 } from "path";
1304
1341
 
1305
1342
  // src/vite-plugin/inject-devtools.ts
1306
1343
  var DEVTOOLS_VIRTUAL_ID = "/@theo/devtools/entry.js";
@@ -1400,7 +1437,7 @@ function runTransformIndexHtml(html, ctx) {
1400
1437
  next = devtools.html;
1401
1438
  const styles = injectStylesheets(next, {
1402
1439
  isDev: ctx.isDevMode.value,
1403
- hasPackage: (name) => existsSync6(resolve5(ctx.projectRoot, "node_modules", ...name.split("/")))
1440
+ hasPackage: (name) => existsSync5(resolve4(ctx.projectRoot, "node_modules", ...name.split("/")))
1404
1441
  });
1405
1442
  next = styles.html;
1406
1443
  return next;
@@ -1503,6 +1540,46 @@ function generateSingleShotEntry(options) {
1503
1540
  `}`
1504
1541
  ].join("\n");
1505
1542
  }
1543
+ function streamingDocumentHelpers() {
1544
+ return [
1545
+ `function __theoHydrationScript(hydrationData, nonce) {`,
1546
+ // `<` is escaped rather than the whole payload: loader data is developer
1547
+ // data, and the only sequence that can break out of a script element is
1548
+ // `</script`. Mirrors what the non-streaming path does in request-handler.ts.
1549
+ ` const json = JSON.stringify(hydrationData).replace(/</g, '\\u003c')`,
1550
+ ` const attr = nonce ? ' nonce="' + nonce + '"' : ''`,
1551
+ ` return '<script' + attr + '>window.__staticRouterHydrationData=' + json + '<' + '/script>'`,
1552
+ `}`,
1553
+ ``,
1554
+ `function __theoDocumentStream(appStream, hydrationData, options) {`,
1555
+ ` const encoder = new TextEncoder()`,
1556
+ ` const head = options.htmlHead ?? ''`,
1557
+ ` const tail = options.htmlTail ?? ''`,
1558
+ ` return new ReadableStream({`,
1559
+ ` async start(controller) {`,
1560
+ // Its own chunk: the reader gets <head> before React has rendered anything.
1561
+ ` if (head) controller.enqueue(encoder.encode(head))`,
1562
+ ` const reader = appStream.getReader()`,
1563
+ ` try {`,
1564
+ ` for (;;) {`,
1565
+ ` const { done, value } = await reader.read()`,
1566
+ ` if (done) break`,
1567
+ ` controller.enqueue(value)`,
1568
+ ` }`,
1569
+ ` } finally {`,
1570
+ ` reader.releaseLock()`,
1571
+ ` }`,
1572
+ // The hydration script trails the app markup and precedes the tail, so it
1573
+ // still runs before the client entry the tail loads.
1574
+ ` controller.enqueue(`,
1575
+ ` encoder.encode(__theoHydrationScript(hydrationData, options.nonce) + tail),`,
1576
+ ` )`,
1577
+ ` controller.close()`,
1578
+ ` },`,
1579
+ ` })`,
1580
+ `}`
1581
+ ];
1582
+ }
1506
1583
  function streamingWebRenderer(appTree) {
1507
1584
  return [
1508
1585
  `// T2.3 \u2014 Web Standards streaming entry for edge runtimes (Cloudflare,`,
@@ -1522,13 +1599,16 @@ function streamingWebRenderer(appTree) {
1522
1599
  // Streaming still applies to genuine data-fetching Suspense, which is where it earns its keep.
1523
1600
  // A failed import is swallowed on purpose: React.lazy will retry and suspend as before, which
1524
1601
  // is strictly no worse than not having preloaded at all.
1525
- ` const __theoMatches = matchRoutes(routes, url.split('?')[0]) ?? []`,
1602
+ // `url` is a URL here, not the string the other renderers receive as a parameter —
1603
+ // so the match key is `.pathname`, never `.split('?')`. Hoisting the declaration
1604
+ // without changing the accessor trades the TDZ for a TypeError (#344).
1605
+ ` const url = new URL(request.url)`,
1606
+ ` const __theoMatches = matchRoutes(routes, url.pathname) ?? []`,
1526
1607
  ` await Promise.all(`,
1527
1608
  ` __theoPreloadPathsFor(__theoMatches).map((p) => __theoPreloadMap[p]().catch(() => null)),`,
1528
1609
  ` )`,
1529
1610
  ``,
1530
1611
  ` const handler = createStaticHandler(routes)`,
1531
- ` const url = new URL(request.url)`,
1532
1612
  ` const context = await handler.query(request)`,
1533
1613
  ``,
1534
1614
  ` if (context instanceof Response) {`,
@@ -1538,12 +1618,14 @@ function streamingWebRenderer(appTree) {
1538
1618
  ` const router = createStaticRouter(handler.dataRoutes, context)`,
1539
1619
  ` const app = ${appTree}`,
1540
1620
  ``,
1621
+ hydrationDataExtractSnippet(),
1622
+ ``,
1541
1623
  ` const stream = await renderToReadableStream(app, {`,
1542
1624
  ` signal: request.signal,`,
1543
1625
  ` nonce: options.nonce,`,
1544
1626
  ` onError(err) { console.error('[SSR Web Stream Error]', err) },`,
1545
1627
  ` })`,
1546
- ` return new Response(stream, {`,
1628
+ ` return new Response(__theoDocumentStream(stream, hydrationData, options), {`,
1547
1629
  ` status: 200,`,
1548
1630
  ` headers: {`,
1549
1631
  ` 'Content-Type': 'text/html; charset=utf-8',`,
@@ -1587,15 +1669,29 @@ function streamingNodeRenderer(appTree) {
1587
1669
  ` const router = createStaticRouter(handler.dataRoutes, context)`,
1588
1670
  ` const app = ${appTree}`,
1589
1671
  ``,
1672
+ hydrationDataExtractSnippet(),
1673
+ ``,
1674
+ ` const { PassThrough } = await import('node:stream')`,
1590
1675
  ` return new Promise((resolve, reject) => {`,
1591
1676
  ` let didError = false`,
1677
+ // React's `pipe(dest)` ends `dest` when the source ends, which would close the
1678
+ // response before the hydration script could be written. Piping into a
1679
+ // PassThrough keeps the response open for the tail.
1680
+ ` const passthrough = new PassThrough()`,
1681
+ ` passthrough.on('data', (chunk) => { response.write(chunk) })`,
1682
+ ` passthrough.on('end', () => {`,
1683
+ ` response.end(__theoHydrationScript(hydrationData, options.nonce) + (options.htmlTail ?? ''))`,
1684
+ ` })`,
1685
+ ` passthrough.on('error', reject)`,
1592
1686
  ` const stream = renderToPipeableStream(app, {`,
1593
1687
  ` nonce: options.nonce,`,
1594
1688
  ` onShellReady() {`,
1595
1689
  ` response.statusCode = didError ? 500 : 200`,
1596
1690
  ` response.setHeader('Content-Type', 'text/html; charset=utf-8')`,
1597
1691
  ` response.setHeader('Transfer-Encoding', 'chunked')`,
1598
- ` stream.pipe(response)`,
1692
+ // The head goes out on its own write, before any React byte.
1693
+ ` if (options.htmlHead) response.write(options.htmlHead)`,
1694
+ ` stream.pipe(passthrough)`,
1599
1695
  ` resolve({ streaming: true })`,
1600
1696
  ` },`,
1601
1697
  ` onShellError(err) { reject(err) },`,
@@ -1679,6 +1775,8 @@ function generateStreamingEntry(options) {
1679
1775
  `import { routes, __theoPreloadMap, __theoPreloadPathsFor } from '/@theo/route-manifest'`,
1680
1776
  theoUiImport,
1681
1777
  ``,
1778
+ ...streamingDocumentHelpers(),
1779
+ ``,
1682
1780
  ...streamingWebRenderer(appTree),
1683
1781
  ``,
1684
1782
  ...streamingNodeRenderer(appTree),
@@ -1788,7 +1886,6 @@ function walkRouteTree(node, parents, acc) {
1788
1886
  routePath
1789
1887
  });
1790
1888
  }
1791
- if (node.layout !== void 0) acc.layoutState.found = true;
1792
1889
  pushIf(acc.staticImports, node.layout, safeVarName(seg, "Layout"));
1793
1890
  pushIf(acc.staticImports, node.error, safeVarName(seg, "Error"));
1794
1891
  pushIf(acc.staticImports, node.loading, safeVarName(seg, "Loading"));
@@ -1803,18 +1900,20 @@ function generateRouteManifest(tree, options = {}) {
1803
1900
  const lazyPages_ = options.lazyPages !== false;
1804
1901
  const acc = {
1805
1902
  staticImports: [],
1806
- lazyPages: [],
1807
- layoutState: { found: false }
1903
+ lazyPages: []
1808
1904
  };
1809
1905
  walkRouteTree(tree, [], acc);
1810
1906
  const staticImports = acc.staticImports;
1811
1907
  const lazyPages = acc.lazyPages;
1812
- const layoutState = acc.layoutState;
1813
1908
  const lines = [`import React, { Suspense } from 'react'`];
1814
- if (layoutState.found) {
1815
- lines.push(`import { Outlet } from 'react-router'`);
1816
- }
1817
- lines.push("");
1909
+ lines.push(
1910
+ `import { Outlet, ScrollRestoration } from 'react-router'`,
1911
+ // #421 — react-router restores the DOCUMENT. The layout this framework scaffolds scrolls an
1912
+ // inner element, so the restoration that was mounted and running restored nothing. Both are
1913
+ // emitted: one owns the document, the other owns the elements the app marked.
1914
+ `import { ElementScrollRestoration } from 'theokit/router/element-scroll-restoration'`,
1915
+ ""
1916
+ );
1818
1917
  for (const imp of staticImports) {
1819
1918
  lines.push(`import ${imp.varName} from '${imp.importPath}'`);
1820
1919
  }
@@ -1868,16 +1967,20 @@ function generateRouteManifest(tree, options = {}) {
1868
1967
  function genRouteConfig(node, isRoot) {
1869
1968
  const seg = node.segment || "root";
1870
1969
  const childrenArray = buildChildrenArray(node, seg);
1970
+ const withScrollRestoration = (element) => `React.createElement(React.Fragment, null, React.createElement(ScrollRestoration), React.createElement(ElementScrollRestoration), ${element})`;
1871
1971
  if (node.layout) {
1872
1972
  const layoutVar = safeVarName(seg, "Layout");
1873
1973
  const pathPart = isRoot ? `path: '/'` : `path: '${segmentPath(node)}'`;
1874
- return `{ ${pathPart}, element: React.createElement(${layoutVar}, { children: React.createElement(Outlet) }), children: ${childrenArray} }`;
1974
+ const layoutElement = `React.createElement(${layoutVar}, { children: React.createElement(Outlet) })`;
1975
+ const element = isRoot ? withScrollRestoration(layoutElement) : layoutElement;
1976
+ return `{ ${pathPart}, element: ${element}, children: ${childrenArray} }`;
1875
1977
  }
1876
1978
  if (isRoot) {
1979
+ const rootElement = withScrollRestoration(`React.createElement(Outlet)`);
1877
1980
  if (node.children.length === 0 && !node.page && !node.notFound && !node.error) {
1878
- return `{ path: '/', children: [] }`;
1981
+ return `{ path: '/', element: ${rootElement}, children: [] }`;
1879
1982
  }
1880
- return `{ path: '/', children: ${childrenArray} }`;
1983
+ return `{ path: '/', element: ${rootElement}, children: ${childrenArray} }`;
1881
1984
  }
1882
1985
  if (node.page && node.children.length === 0 && !node.error && !node.notFound) {
1883
1986
  const pageVar = safeVarName(seg, "Page");
@@ -2045,8 +2148,8 @@ function findConsumerConfig(projectRoot, basename2) {
2045
2148
  let dir = projectRoot;
2046
2149
  for (let level = 0; level < 3; level++) {
2047
2150
  for (const ext of extensions) {
2048
- const candidate = resolve6(dir, `${basename2}${ext}`);
2049
- if (existsSync7(candidate)) return candidate;
2151
+ const candidate = resolve5(dir, `${basename2}${ext}`);
2152
+ if (existsSync6(candidate)) return candidate;
2050
2153
  }
2051
2154
  const parent = dirname4(dir);
2052
2155
  if (parent === dir) break;
@@ -2057,7 +2160,7 @@ function findConsumerConfig(projectRoot, basename2) {
2057
2160
  async function theoPluginAsync(rootOrOptions) {
2058
2161
  const options = typeof rootOrOptions === "string" ? { root: rootOrOptions } : rootOrOptions ?? {};
2059
2162
  const projectRoot = options.root ?? process.cwd();
2060
- const serverDirAbs = resolve6(projectRoot, options.serverDir ?? "server");
2163
+ const serverDirAbs = resolve5(projectRoot, options.serverDir ?? "server");
2061
2164
  const agentsDirName = options.agentsDir ?? "agents";
2062
2165
  const consumerTailwindConfig = findConsumerConfig(projectRoot, "tailwind.config");
2063
2166
  const consumerPostcssConfig = findConsumerConfig(projectRoot, "postcss.config");
@@ -2068,7 +2171,7 @@ async function theoPluginAsync(rootOrOptions) {
2068
2171
  const studioPlugins = await integrateStudio();
2069
2172
  const servicesPlugins = [];
2070
2173
  if (options.services && Object.keys(options.services).length > 0) {
2071
- const { servicesTypedClientPlugin } = await import("./services-typed-client-P4JERLBL.js");
2174
+ const { servicesTypedClientPlugin } = await import("./services-typed-client-XGT5SUUN.js");
2072
2175
  servicesPlugins.push(
2073
2176
  servicesTypedClientPlugin({
2074
2177
  cwd: projectRoot,
@@ -2076,23 +2179,23 @@ async function theoPluginAsync(rootOrOptions) {
2076
2179
  })
2077
2180
  );
2078
2181
  }
2079
- const { appTypedClientPlugin } = await import("./app-typed-client-I4X2UJWW.js");
2182
+ const { appTypedClientPlugin } = await import("./app-typed-client-UTBMJZOE.js");
2080
2183
  const appClientPlugin = appTypedClientPlugin({
2081
2184
  cwd: projectRoot,
2082
2185
  serverDir: serverDirAbs,
2083
- distDir: resolve6(projectRoot, ".theokit")
2186
+ distDir: resolve5(projectRoot, ".theokit")
2084
2187
  });
2085
- const { actionsVirtualModule } = await import("./actions-virtual-module-YZRZMHAX.js");
2188
+ const { actionsVirtualModule } = await import("./actions-virtual-module-DSIVNGK7.js");
2086
2189
  const actionsPlugin = actionsVirtualModule({
2087
2190
  serverDir: serverDirAbs,
2088
- distDir: resolve6(projectRoot, ".theokit")
2191
+ distDir: resolve5(projectRoot, ".theokit")
2089
2192
  });
2090
2193
  const { agentsTypedClientPlugin } = await import("./agents-typed-client-D4OA2TXB.js");
2091
- const { generateManifest } = await import("./internal-api-FBK2YXSI.js");
2194
+ const { generateManifest } = await import("./internal-api-4X6NDS2F.js");
2092
2195
  const agentsClientPlugin = agentsTypedClientPlugin({
2093
2196
  projectRoot,
2094
2197
  agentsDir: agentsDirName,
2095
- distDir: resolve6(projectRoot, ".theokit"),
2198
+ distDir: resolve5(projectRoot, ".theokit"),
2096
2199
  // Agents live at <projectRoot>/<agentsDir>; generateManifest scans them via the server dir's
2097
2200
  // parent (projectRoot for the canonical layout) + the agents dir name (#95 follow-up).
2098
2201
  scanManifest: () => generateManifest(serverDirAbs, projectRoot, agentsDirName)
@@ -2105,11 +2208,17 @@ async function theoPluginAsync(rootOrOptions) {
2105
2208
  const controllerTransformPlugin = controllerSwcTransformPlugin({
2106
2209
  serverDir: serverDirAbs
2107
2210
  });
2211
+ const { serverOnlyImportBoundary } = await import("./server-boundary-A67OPRKO.js");
2212
+ const serverBoundaryPlugin = serverOnlyImportBoundary({
2213
+ projectRoot,
2214
+ serverDir: serverDirAbs
2215
+ });
2108
2216
  return [
2109
2217
  theoPlugin(rootOrOptions),
2110
2218
  ...uiPlugins,
2111
2219
  ...studioPlugins,
2112
2220
  ...servicesPlugins,
2221
+ serverBoundaryPlugin,
2113
2222
  // #122 — swc-compile controllers/** (enforce:'pre'; order-independent).
2114
2223
  controllerTransformPlugin,
2115
2224
  appClientPlugin,
@@ -2120,10 +2229,10 @@ async function theoPluginAsync(rootOrOptions) {
2120
2229
  }
2121
2230
  function buildOptimizeDepsInclude(projectRoot, viteOptimizeDeps) {
2122
2231
  const include = [];
2123
- if (existsSync7(resolve6(projectRoot, "node_modules", "@theokit", "ui"))) {
2232
+ if (existsSync6(resolve5(projectRoot, "node_modules", "@theokit", "ui"))) {
2124
2233
  include.push("@theokit/ui");
2125
2234
  }
2126
- if (existsSync7(resolve6(projectRoot, "node_modules", "lucide-react"))) {
2235
+ if (existsSync6(resolve5(projectRoot, "node_modules", "lucide-react"))) {
2127
2236
  include.push("lucide-react");
2128
2237
  }
2129
2238
  include.push("devalue");
@@ -2149,8 +2258,8 @@ var VIRTUAL_MODULE_IDS = {
2149
2258
  function theoPlugin(rootOrOptions) {
2150
2259
  const options = typeof rootOrOptions === "string" ? { root: rootOrOptions } : rootOrOptions ?? {};
2151
2260
  const projectRoot = options.root ?? process.cwd();
2152
- const appDir = resolve6(projectRoot, options.appDir ?? "app");
2153
- const serverDir = resolve6(projectRoot, options.serverDir ?? "server");
2261
+ const appDir = resolve5(projectRoot, options.appDir ?? "app");
2262
+ const serverDir = resolve5(projectRoot, options.serverDir ?? "server");
2154
2263
  const agentsDir = options.agentsDir ?? "agents";
2155
2264
  const ssrEnabled = options.ssr ?? false;
2156
2265
  const currentDir = dirname4(fileURLToPath(import.meta.url));
@@ -2274,4 +2383,4 @@ export {
2274
2383
  theoPluginAsync,
2275
2384
  theoPlugin
2276
2385
  };
2277
- //# sourceMappingURL=chunk-OOBYPCZC.js.map
2386
+ //# sourceMappingURL=chunk-KTS6G26H.js.map