theokit 0.48.13 → 0.50.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (327) hide show
  1. package/README.md +1 -0
  2. package/dist/{actions-virtual-module-YQXRSSMW.js → actions-virtual-module-5WBVSDOM.js} +22 -12
  3. package/dist/actions-virtual-module-5WBVSDOM.js.map +1 -0
  4. package/dist/{actions-virtual-module-LB4NGONI.js → actions-virtual-module-ZYLMNW6K.js} +13 -8
  5. package/dist/{actions-virtual-module-LB4NGONI.js.map → actions-virtual-module-ZYLMNW6K.js.map} +1 -1
  6. package/dist/adapters/agent-mount.d.ts +127 -0
  7. package/dist/adapters/agent-mount.js +24 -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-GKUEL6OH.js +15 -0
  15. package/dist/agent-scan-BZa-pagG.d.ts +16 -0
  16. package/dist/{app-typed-client-GHO3EWZK.js → app-typed-client-4LAIEGFX.js} +23 -13
  17. package/dist/app-typed-client-4LAIEGFX.js.map +1 -0
  18. package/dist/{app-typed-client-G3J5G7E5.js → app-typed-client-DQM3Y6YY.js} +14 -9
  19. package/dist/app-typed-client-DQM3Y6YY.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/{build-WU6AKKIB.js → build-FLX6VF7Q.js} +71 -26
  23. package/dist/build-FLX6VF7Q.js.map +1 -0
  24. package/dist/{bun-33RD6K7O.js → bun-L7PP6ID5.js} +105 -13
  25. package/dist/bun-L7PP6ID5.js.map +1 -0
  26. package/dist/{check-45NKUVSQ.js → check-GIPZBFTX.js} +2 -2
  27. package/dist/{chunk-KD5G3YXI.js → chunk-2AMLGJJA.js} +35 -9
  28. package/dist/chunk-2AMLGJJA.js.map +1 -0
  29. package/dist/chunk-3PBAN2YE.js +146 -0
  30. package/dist/chunk-3PBAN2YE.js.map +1 -0
  31. package/dist/{chunk-HBU2GIMZ.js → chunk-3QPVEJ7D.js} +15 -9
  32. package/dist/chunk-3QPVEJ7D.js.map +1 -0
  33. package/dist/{chunk-47CINLWF.js → chunk-44J2ANQC.js} +2 -2
  34. package/dist/{chunk-IEES3CHD.js → chunk-47MM2JUK.js} +8 -2
  35. package/dist/chunk-47MM2JUK.js.map +1 -0
  36. package/dist/chunk-4X6H2BXP.js +108 -0
  37. package/dist/chunk-4X6H2BXP.js.map +1 -0
  38. package/dist/{chunk-A7JBF5FO.js → chunk-5K4TDLRG.js} +8 -5
  39. package/dist/chunk-5K4TDLRG.js.map +1 -0
  40. package/dist/chunk-5YPXXSYY.js +181 -0
  41. package/dist/chunk-5YPXXSYY.js.map +1 -0
  42. package/dist/{chunk-YGAXV5HR.js → chunk-6J4JWHDJ.js} +191 -112
  43. package/dist/chunk-6J4JWHDJ.js.map +1 -0
  44. package/dist/chunk-72DMJBXI.js +424 -0
  45. package/dist/chunk-72DMJBXI.js.map +1 -0
  46. package/dist/chunk-7PM6K5EV.js +513 -0
  47. package/dist/chunk-7PM6K5EV.js.map +1 -0
  48. package/dist/{chunk-MTEWLGVY.js → chunk-BPYMC7SU.js} +4 -48
  49. package/dist/chunk-BPYMC7SU.js.map +1 -0
  50. package/dist/chunk-BU6RJPPJ.js +421 -0
  51. package/dist/chunk-BU6RJPPJ.js.map +1 -0
  52. package/dist/{chunk-FB2HBNIC.js → chunk-BX6EUYHU.js} +6 -2
  53. package/dist/chunk-BX6EUYHU.js.map +1 -0
  54. package/dist/{chunk-BIVCP6X5.js → chunk-C62IZEJI.js} +465 -202
  55. package/dist/chunk-C62IZEJI.js.map +1 -0
  56. package/dist/chunk-D4VP2QPR.js +16 -0
  57. package/dist/chunk-D4VP2QPR.js.map +1 -0
  58. package/dist/{chunk-J5MXCGKA.js → chunk-DHAD2O3S.js} +6 -6
  59. package/dist/chunk-DHAD2O3S.js.map +1 -0
  60. package/dist/chunk-E43VJ3E5.js +188 -0
  61. package/dist/chunk-E43VJ3E5.js.map +1 -0
  62. package/dist/chunk-EVZKNA2W.js +110 -0
  63. package/dist/chunk-EVZKNA2W.js.map +1 -0
  64. package/dist/chunk-FD4ZDTQ6.js +181 -0
  65. package/dist/chunk-FD4ZDTQ6.js.map +1 -0
  66. package/dist/chunk-FDOOBTXJ.js +17 -0
  67. package/dist/chunk-FDOOBTXJ.js.map +1 -0
  68. package/dist/chunk-FH3SQR6P.js +275 -0
  69. package/dist/chunk-FH3SQR6P.js.map +1 -0
  70. package/dist/chunk-HJHGTFEJ.js +23 -0
  71. package/dist/chunk-HJHGTFEJ.js.map +1 -0
  72. package/dist/{chunk-LXAESF4Y.js → chunk-HK4AZBKX.js} +7 -4
  73. package/dist/chunk-HK4AZBKX.js.map +1 -0
  74. package/dist/{chunk-T5C46IIU.js → chunk-HWBRS4DZ.js} +28 -269
  75. package/dist/chunk-HWBRS4DZ.js.map +1 -0
  76. package/dist/chunk-IRQGAC4L.js +52 -0
  77. package/dist/chunk-IRQGAC4L.js.map +1 -0
  78. package/dist/{chunk-FNTLKHZ7.js → chunk-JDN5SAAD.js} +7 -4
  79. package/dist/chunk-JDN5SAAD.js.map +1 -0
  80. package/dist/{chunk-GXEX4CBH.js → chunk-JIKNR5LX.js} +673 -484
  81. package/dist/chunk-JIKNR5LX.js.map +1 -0
  82. package/dist/{chunk-GRI4XHBJ.js → chunk-JWRCZIA4.js} +266 -108
  83. package/dist/chunk-JWRCZIA4.js.map +1 -0
  84. package/dist/{chunk-E576KYYT.js → chunk-KI4DOTN4.js} +25 -2
  85. package/dist/chunk-KI4DOTN4.js.map +1 -0
  86. package/dist/{chunk-ZB7D62OA.js → chunk-KUZVRJ7M.js} +3 -3
  87. package/dist/chunk-L4VFNFDL.js +248 -0
  88. package/dist/chunk-L4VFNFDL.js.map +1 -0
  89. package/dist/chunk-M2WC5MF7.js +127 -0
  90. package/dist/chunk-M2WC5MF7.js.map +1 -0
  91. package/dist/{chunk-O3JIAU3V.js → chunk-MCTC6HSE.js} +157 -103
  92. package/dist/chunk-MCTC6HSE.js.map +1 -0
  93. package/dist/{chunk-PXFXSFJL.js → chunk-NZ5JU6D3.js} +9 -9
  94. package/dist/{chunk-YRBR424R.js → chunk-OAUI273L.js} +338 -165
  95. package/dist/chunk-OAUI273L.js.map +1 -0
  96. package/dist/chunk-OGLS76RN.js +43 -0
  97. package/dist/chunk-OGLS76RN.js.map +1 -0
  98. package/dist/{chunk-7LVM22VG.js → chunk-OQCRCXCP.js} +6 -6
  99. package/dist/chunk-OQCRCXCP.js.map +1 -0
  100. package/dist/{chunk-OLGPYOLO.js → chunk-P6OS7652.js} +5 -2
  101. package/dist/chunk-P6OS7652.js.map +1 -0
  102. package/dist/chunk-Q5L5EGWZ.js +26 -0
  103. package/dist/chunk-Q5L5EGWZ.js.map +1 -0
  104. package/dist/{chunk-S433N3CT.js → chunk-QTHVHNJJ.js} +6 -36
  105. package/dist/chunk-QTHVHNJJ.js.map +1 -0
  106. package/dist/chunk-RPET332G.js +84 -0
  107. package/dist/chunk-RPET332G.js.map +1 -0
  108. package/dist/{chunk-646CA6RV.js → chunk-RQW5YMH7.js} +12 -4
  109. package/dist/chunk-RQW5YMH7.js.map +1 -0
  110. package/dist/{chunk-XALU5LCU.js → chunk-RWNYIU6A.js} +550 -146
  111. package/dist/chunk-RWNYIU6A.js.map +1 -0
  112. package/dist/chunk-SL7YUHPV.js +111 -0
  113. package/dist/chunk-SL7YUHPV.js.map +1 -0
  114. package/dist/chunk-U5PWXS3J.js +39 -0
  115. package/dist/chunk-U5PWXS3J.js.map +1 -0
  116. package/dist/chunk-ULDCFL2O.js +273 -0
  117. package/dist/chunk-ULDCFL2O.js.map +1 -0
  118. package/dist/{chunk-RWNSW4FM.js → chunk-UMNXCU3K.js} +12 -6
  119. package/dist/{chunk-RWNSW4FM.js.map → chunk-UMNXCU3K.js.map} +1 -1
  120. package/dist/chunk-VI7ZANB3.js +193 -0
  121. package/dist/chunk-VI7ZANB3.js.map +1 -0
  122. package/dist/chunk-VQPHPQ5L.js +14 -0
  123. package/dist/chunk-VQPHPQ5L.js.map +1 -0
  124. package/dist/chunk-WNJTJRM6.js +147 -0
  125. package/dist/chunk-WNJTJRM6.js.map +1 -0
  126. package/dist/chunk-WOBSEO75.js +790 -0
  127. package/dist/chunk-WOBSEO75.js.map +1 -0
  128. package/dist/{chunk-BMHS4WAN.js → chunk-XS7EX55U.js} +156 -42
  129. package/dist/chunk-XS7EX55U.js.map +1 -0
  130. package/dist/chunk-YN4W7LCX.js +31 -0
  131. package/dist/chunk-YN4W7LCX.js.map +1 -0
  132. package/dist/chunk-YSJOZEI6.js +1 -0
  133. package/dist/{chunk-JA2ZAT5Q.js → chunk-Z4PJMZLM.js} +2 -2
  134. package/dist/chunk-Z4PJMZLM.js.map +1 -0
  135. package/dist/{chunk-7VPQHEAJ.js → chunk-ZNZISJDZ.js} +6 -2
  136. package/dist/chunk-ZNZISJDZ.js.map +1 -0
  137. package/dist/chunk-ZWN3AODA.js +11 -0
  138. package/dist/chunk-ZWN3AODA.js.map +1 -0
  139. package/dist/cli/index.js +25 -10
  140. package/dist/cli/index.js.map +1 -1
  141. package/dist/client/core.d.ts +1 -1
  142. package/dist/client/core.js +2 -0
  143. package/dist/client/core.js.map +1 -1
  144. package/dist/client/index.d.ts +44 -10
  145. package/dist/client/index.js +35 -0
  146. package/dist/client/index.js.map +1 -1
  147. package/dist/cloudflare-SIG42OIW.js +335 -0
  148. package/dist/cloudflare-SIG42OIW.js.map +1 -0
  149. package/dist/config-support-WQHQIJTA.js +104 -0
  150. package/dist/config-support-WQHQIJTA.js.map +1 -0
  151. package/dist/{csrf-BBrEZSBW.d.ts → csrf-Dgot9qSM.d.ts} +1 -1
  152. package/dist/deno-deploy-LQAYOOPW.js +196 -0
  153. package/dist/deno-deploy-LQAYOOPW.js.map +1 -0
  154. package/dist/{dev-MUWJAZRD.js → dev-ANDSEVLB.js} +28 -18
  155. package/dist/dev-ANDSEVLB.js.map +1 -0
  156. package/dist/{dev-emit-GWD6IXV7.js → dev-emit-BFNMDCPB.js} +5 -5
  157. package/dist/{dev-emit-NBT6JD7R.js → dev-emit-MVAJAFGX.js} +5 -3
  158. package/dist/dev-emit-MVAJAFGX.js.map +1 -0
  159. package/dist/engine-singleton-X4R7AZBJ.js +315 -0
  160. package/dist/engine-singleton-X4R7AZBJ.js.map +1 -0
  161. package/dist/{generate-Y3GWM57K.js → generate-EN6EDITF.js} +43 -4
  162. package/dist/generate-EN6EDITF.js.map +1 -0
  163. package/dist/index-CzxtQcnp.d.ts +1058 -0
  164. package/dist/index.d.ts +4 -0
  165. package/dist/index.js +24 -13
  166. package/dist/index.js.map +1 -1
  167. package/dist/{info-XW7HGUPH.js → info-Y55RWS42.js} +8 -6
  168. package/dist/{info-XW7HGUPH.js.map → info-Y55RWS42.js.map} +1 -1
  169. package/dist/{internal-api-V5L65YSJ.js → internal-api-IP35YU3G.js} +22 -12
  170. package/dist/{internal-api-WEOSTMSN.js → internal-api-OPU456AT.js} +30 -16
  171. package/dist/internal-api-OPU456AT.js.map +1 -0
  172. package/dist/load-config-4ATXQUN3.js +16 -0
  173. package/dist/match-DmGgxjIU.d.ts +44 -0
  174. package/dist/{mcp-ULUFJNSZ.js → mcp-5LLNAGKA.js} +7 -7
  175. package/dist/netlify-C2IRCZKI.js +245 -0
  176. package/dist/netlify-C2IRCZKI.js.map +1 -0
  177. package/dist/node-OSVPYQ3D.js +10 -0
  178. package/dist/nonce-BXt7Qu_C.d.ts +31 -0
  179. package/dist/observability-bootstrap-MZMSOE66.js +15 -0
  180. package/dist/{openapi-HZXR335W.js → openapi-VFPEZSRI.js} +13 -11
  181. package/dist/{openapi-HZXR335W.js.map → openapi-VFPEZSRI.js.map} +1 -1
  182. package/dist/{plugin-runner-BFEcgtmJ.d.ts → plugin-runner-BVMOSxvb.d.ts} +1 -1
  183. package/dist/{plugin-types-D69-lJZ9.d.ts → plugin-types-BUVfUQ0V.d.ts} +13 -1
  184. package/dist/preview-GHPT2EQ5.js +23 -0
  185. package/dist/preview-GHPT2EQ5.js.map +1 -0
  186. package/dist/provider-resolver-Dx6QuWrw.d.ts +128 -0
  187. package/dist/registry-KBZDCFVQ.js +23 -0
  188. package/dist/route-config-Cm_ZMA1C.d.ts +72 -0
  189. package/dist/route-policy-BxOycCDq.d.ts +65 -0
  190. package/dist/router/element-scroll-restoration.d.ts +28 -0
  191. package/dist/router/element-scroll-restoration.js +96 -0
  192. package/dist/router/element-scroll-restoration.js.map +1 -0
  193. package/dist/{routes-OLNQX7CT.js → routes-BPLU3ISV.js} +11 -9
  194. package/dist/{routes-OLNQX7CT.js.map → routes-BPLU3ISV.js.map} +1 -1
  195. package/dist/{scan-7MJC6PYU.js → scan-YJEE4KQK.js} +2 -2
  196. package/dist/{schema-ZO3OSWVG.js → schema-SOAD43RQ.js} +7 -5
  197. package/dist/schemas-4AXHQMV3.js +25 -0
  198. package/dist/schemas-4AXHQMV3.js.map +1 -0
  199. package/dist/security-headers-Ccj7ncNx.d.ts +129 -0
  200. package/dist/server/agent/index.d.ts +2 -90
  201. package/dist/server/agent/index.js +1 -1
  202. package/dist/server/auth/index.d.ts +2 -21
  203. package/dist/server/auth/index.js +3 -2
  204. package/dist/server/cron/index.js +4 -3
  205. package/dist/server/define/index.d.ts +51 -57
  206. package/dist/server/define/index.js +10 -1
  207. package/dist/server/http/index.d.ts +7 -5
  208. package/dist/server/http/index.js +56 -12
  209. package/dist/server/index.d.ts +47 -439
  210. package/dist/server/index.js +119 -201
  211. package/dist/server/index.js.map +1 -1
  212. package/dist/server/jobs/index.js +4 -3
  213. package/dist/server/observability/index.d.ts +109 -35
  214. package/dist/server/observability/index.js +10 -7
  215. package/dist/server/plugins/index.d.ts +3 -3
  216. package/dist/server/scan/index.d.ts +47 -12
  217. package/dist/server/scan/index.js +13 -4
  218. package/dist/server/security/index.d.ts +61 -103
  219. package/dist/server/security/index.js +15 -6
  220. package/dist/server/webhook/index.d.ts +90 -3
  221. package/dist/server/webhook/index.js +12 -2
  222. package/dist/server-boundary-6B4ZQUY7.js +148 -0
  223. package/dist/server-boundary-6B4ZQUY7.js.map +1 -0
  224. package/dist/server-boundary-7VZQRPPX.js +133 -0
  225. package/dist/server-boundary-7VZQRPPX.js.map +1 -0
  226. package/dist/{services-typed-client-PSAGRPFF.js → services-typed-client-XGT5SUUN.js} +2 -2
  227. package/dist/{start-KR2JJR7K.js → start-UZDMOT7I.js} +342 -111
  228. package/dist/start-UZDMOT7I.js.map +1 -0
  229. package/dist/{static-M2W4HUWS.js → static-SVDWIOXJ.js} +24 -13
  230. package/dist/static-SVDWIOXJ.js.map +1 -0
  231. package/dist/{theo-cloud-XAHWOUFK.js → theo-cloud-3ET4G5T6.js} +9 -2
  232. package/dist/theo-cloud-3ET4G5T6.js.map +1 -0
  233. package/dist/vercel-BMCQKCWE.js +277 -0
  234. package/dist/vercel-BMCQKCWE.js.map +1 -0
  235. package/dist/vite-plugin/index.js +24 -13
  236. package/dist/vite-plugin-VKCT2LF2.js +42 -0
  237. package/dist/vite-plugin-VKCT2LF2.js.map +1 -0
  238. package/package.json +19 -6
  239. package/dist/actions-virtual-module-YQXRSSMW.js.map +0 -1
  240. package/dist/agent-7JJW3TPB.js +0 -15
  241. package/dist/app-typed-client-G3J5G7E5.js.map +0 -1
  242. package/dist/app-typed-client-GHO3EWZK.js.map +0 -1
  243. package/dist/aws-lambda-CYNDGU5O.js +0 -172
  244. package/dist/aws-lambda-CYNDGU5O.js.map +0 -1
  245. package/dist/build-WU6AKKIB.js.map +0 -1
  246. package/dist/bun-33RD6K7O.js.map +0 -1
  247. package/dist/chunk-646CA6RV.js.map +0 -1
  248. package/dist/chunk-6E5WKMDS.js +0 -67
  249. package/dist/chunk-6E5WKMDS.js.map +0 -1
  250. package/dist/chunk-6GGWS7J3.js +0 -91
  251. package/dist/chunk-6GGWS7J3.js.map +0 -1
  252. package/dist/chunk-7LVM22VG.js.map +0 -1
  253. package/dist/chunk-7VPQHEAJ.js.map +0 -1
  254. package/dist/chunk-A7JBF5FO.js.map +0 -1
  255. package/dist/chunk-AM3QABW5.js +0 -161
  256. package/dist/chunk-AM3QABW5.js.map +0 -1
  257. package/dist/chunk-BIVCP6X5.js.map +0 -1
  258. package/dist/chunk-BMHS4WAN.js.map +0 -1
  259. package/dist/chunk-E576KYYT.js.map +0 -1
  260. package/dist/chunk-FB2HBNIC.js.map +0 -1
  261. package/dist/chunk-FNTLKHZ7.js.map +0 -1
  262. package/dist/chunk-GRI4XHBJ.js.map +0 -1
  263. package/dist/chunk-GVW5EKEU.js +0 -422
  264. package/dist/chunk-GVW5EKEU.js.map +0 -1
  265. package/dist/chunk-GXEX4CBH.js.map +0 -1
  266. package/dist/chunk-HBU2GIMZ.js.map +0 -1
  267. package/dist/chunk-IEES3CHD.js.map +0 -1
  268. package/dist/chunk-J5MXCGKA.js.map +0 -1
  269. package/dist/chunk-JA2ZAT5Q.js.map +0 -1
  270. package/dist/chunk-KD5G3YXI.js.map +0 -1
  271. package/dist/chunk-LNVMHQ2Z.js +0 -54
  272. package/dist/chunk-LNVMHQ2Z.js.map +0 -1
  273. package/dist/chunk-LXAESF4Y.js.map +0 -1
  274. package/dist/chunk-MTEWLGVY.js.map +0 -1
  275. package/dist/chunk-O3JIAU3V.js.map +0 -1
  276. package/dist/chunk-OJLL4YD6.js +0 -403
  277. package/dist/chunk-OJLL4YD6.js.map +0 -1
  278. package/dist/chunk-OLGPYOLO.js.map +0 -1
  279. package/dist/chunk-S433N3CT.js.map +0 -1
  280. package/dist/chunk-T5C46IIU.js.map +0 -1
  281. package/dist/chunk-U267AOWS.js +0 -28
  282. package/dist/chunk-U267AOWS.js.map +0 -1
  283. package/dist/chunk-UW2TEAGR.js +0 -77
  284. package/dist/chunk-UW2TEAGR.js.map +0 -1
  285. package/dist/chunk-WPJOTQA5.js +0 -1
  286. package/dist/chunk-XALU5LCU.js.map +0 -1
  287. package/dist/chunk-XR74JD4M.js +0 -457
  288. package/dist/chunk-XR74JD4M.js.map +0 -1
  289. package/dist/chunk-YGAXV5HR.js.map +0 -1
  290. package/dist/chunk-YRBR424R.js.map +0 -1
  291. package/dist/cloudflare-KYUWCEPL.js +0 -122
  292. package/dist/cloudflare-KYUWCEPL.js.map +0 -1
  293. package/dist/deno-deploy-CCTB7HGS.js +0 -107
  294. package/dist/deno-deploy-CCTB7HGS.js.map +0 -1
  295. package/dist/dev-MUWJAZRD.js.map +0 -1
  296. package/dist/dev-emit-NBT6JD7R.js.map +0 -1
  297. package/dist/generate-Y3GWM57K.js.map +0 -1
  298. package/dist/index-BEtEv6ZH.d.ts +0 -575
  299. package/dist/load-config-VKD6LKWU.js +0 -14
  300. package/dist/match-CfbEFRG4.d.ts +0 -26
  301. package/dist/netlify-AFMDNKT4.js +0 -150
  302. package/dist/netlify-AFMDNKT4.js.map +0 -1
  303. package/dist/node-ZJQEJSP3.js +0 -10
  304. package/dist/registry-GKR3EWRW.js +0 -23
  305. package/dist/start-KR2JJR7K.js.map +0 -1
  306. package/dist/static-M2W4HUWS.js.map +0 -1
  307. package/dist/theo-cloud-XAHWOUFK.js.map +0 -1
  308. package/dist/vercel-SRS2DH6O.js +0 -133
  309. package/dist/vercel-SRS2DH6O.js.map +0 -1
  310. package/dist/vite-plugin-VPJFD4HK.js +0 -36
  311. /package/dist/{chunk-WPJOTQA5.js.map → adapters/agent-mount.js.map} +0 -0
  312. /package/dist/{agent-7JJW3TPB.js.map → agent-GKUEL6OH.js.map} +0 -0
  313. /package/dist/{check-45NKUVSQ.js.map → check-GIPZBFTX.js.map} +0 -0
  314. /package/dist/{chunk-47CINLWF.js.map → chunk-44J2ANQC.js.map} +0 -0
  315. /package/dist/{chunk-ZB7D62OA.js.map → chunk-KUZVRJ7M.js.map} +0 -0
  316. /package/dist/{chunk-PXFXSFJL.js.map → chunk-NZ5JU6D3.js.map} +0 -0
  317. /package/dist/{internal-api-WEOSTMSN.js.map → chunk-YSJOZEI6.js.map} +0 -0
  318. /package/dist/{dev-emit-GWD6IXV7.js.map → dev-emit-BFNMDCPB.js.map} +0 -0
  319. /package/dist/{internal-api-V5L65YSJ.js.map → internal-api-IP35YU3G.js.map} +0 -0
  320. /package/dist/{load-config-VKD6LKWU.js.map → load-config-4ATXQUN3.js.map} +0 -0
  321. /package/dist/{mcp-ULUFJNSZ.js.map → mcp-5LLNAGKA.js.map} +0 -0
  322. /package/dist/{node-ZJQEJSP3.js.map → node-OSVPYQ3D.js.map} +0 -0
  323. /package/dist/{scan-7MJC6PYU.js.map → observability-bootstrap-MZMSOE66.js.map} +0 -0
  324. /package/dist/{registry-GKR3EWRW.js.map → registry-KBZDCFVQ.js.map} +0 -0
  325. /package/dist/{schema-ZO3OSWVG.js.map → scan-YJEE4KQK.js.map} +0 -0
  326. /package/dist/{vite-plugin-VPJFD4HK.js.map → schema-SOAD43RQ.js.map} +0 -0
  327. /package/dist/{services-typed-client-PSAGRPFF.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-GRI4XHBJ.js";
12
+ serveMatchedAuxRoute,
13
+ serveThroughPluginLifecycle,
14
+ setupSsrDevMiddleware
15
+ } from "./chunk-JWRCZIA4.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-S433N3CT.js";
23
- import {
24
- buildServicesProxyConfig
25
- } from "./chunk-7VPQHEAJ.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-BIVCP6X5.js";
38
+ mountAgent,
39
+ readAgentPolicy,
40
+ writeWebResponseToServerResponse
41
+ } from "./chunk-C62IZEJI.js";
48
42
  import {
49
43
  getApprovalRegistry,
50
44
  resolveProvider
51
- } from "./chunk-6GGWS7J3.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-HWBRS4DZ.js";
52
+ import {
53
+ TRACE_HEADER,
54
+ createObservabilityPluginFromConfig,
55
+ extractTraceId
56
+ } from "./chunk-7PM6K5EV.js";
57
+ import {
58
+ logRequest
59
+ } from "./chunk-2AMLGJJA.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,53 +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
- resolveApiKey: () => resolveProvider().apiKey
470
- });
471
- if (response === null) {
472
- next();
473
- return;
474
- }
475
- res.setHeader("x-request-id", requestId);
476
- await writeWebResponseToServerResponse(response, res);
477
- } catch (err) {
478
- res.setHeader("x-request-id", requestId);
479
- 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,
480
515
  res,
481
- "INTERNAL",
482
- err instanceof Error ? err.message : "Agent aux handler failed",
483
- 500,
484
- void 0,
485
- requestId
486
- );
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;
487
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
+ );
488
543
  logRequest({
489
- method: (req.method ?? "GET").toUpperCase(),
544
+ method,
490
545
  url: req.url ?? "",
491
546
  status: res.statusCode,
492
547
  duration: Date.now() - start,
493
548
  requestId
494
549
  });
495
550
  }
496
- function createAgentMiddleware(vite, projectRoot, csrfMode = "strict", agentsDir = "agents") {
551
+ function createAgentMiddleware(vite, projectRoot, csrfMode = "strict", agentsDir = "agents", deps = {}) {
552
+ const { pluginRunner, serverDir } = deps;
497
553
  const loadModule = createViteLoader(vite);
554
+ const cardDeps = () => ({
555
+ projectRoot,
556
+ loadModule,
557
+ agentsDir,
558
+ csrfMode,
559
+ serverDir,
560
+ pluginRunner
561
+ });
498
562
  return (req, res, next) => {
499
563
  void (async () => {
500
564
  const url = req.url ?? "";
501
565
  if (isAgentCardPath(url.split("?")[0]) !== null) {
502
- await serveAux(req, res, next, url.split("?")[0], {
503
- projectRoot,
504
- loadModule,
505
- agentsDir,
506
- csrfMode
507
- });
566
+ await serveAux(req, res, next, url.split("?")[0], cardDeps());
508
567
  return;
509
568
  }
510
569
  if (!url.startsWith(PREFIX2)) {
@@ -516,16 +575,12 @@ function createAgentMiddleware(vite, projectRoot, csrfMode = "strict", agentsDir
516
575
  res.setHeader("x-request-id", requestId);
517
576
  const urlPath = url.split("?")[0];
518
577
  if (isApprovalPath(urlPath)) {
519
- await serveApprove(req, res, urlPath, csrfMode, { requestId, start });
520
- return;
521
- }
522
- if (isListApprovalsPath(urlPath) !== null || isMcpPath(urlPath) !== null) {
523
- await serveAux(req, res, next, urlPath, { projectRoot, loadModule, agentsDir, csrfMode });
578
+ await serveApprove(req, res, urlPath, cardDeps(), { requestId, start });
524
579
  return;
525
580
  }
526
581
  const agent = scanAgents(projectRoot, agentsDir).find((a) => a.agentPath === urlPath);
527
582
  if (!agent) {
528
- next();
583
+ await serveAux(req, res, next, urlPath, cardDeps());
529
584
  return;
530
585
  }
531
586
  const method = (req.method ?? "POST").toUpperCase();
@@ -541,30 +596,70 @@ function createAgentMiddleware(vite, projectRoot, csrfMode = "strict", agentsDir
541
596
  logRequest({ method, url, status: 405, duration: Date.now() - start, requestId });
542
597
  return;
543
598
  }
544
- try {
545
- const mod = await loadModule(agent.filePath);
546
- const apiKey = resolveProvider().apiKey;
547
- const request = incomingMessageToWebRequest(req);
548
- const response = await mountAgent(mod, request, apiKey, {
549
- source: agent.filePath,
550
- csrfMode,
551
- projectRoot
552
- });
553
- await writeWebResponseToServerResponse(response, res);
554
- } catch (err) {
555
- sendError(
556
- res,
557
- "INTERNAL",
558
- err instanceof Error ? err.message : "Agent handler failed",
559
- 500,
560
- void 0,
561
- requestId
562
- );
563
- }
564
- logRequest({ method, url, status: res.statusCode, duration: Date.now() - start, requestId });
599
+ await serveAgentTurn({
600
+ req,
601
+ res,
602
+ agent,
603
+ method,
604
+ url,
605
+ requestId,
606
+ start,
607
+ loadModule,
608
+ csrfMode,
609
+ projectRoot,
610
+ pluginRunner,
611
+ serverDir
612
+ });
565
613
  })();
566
614
  };
567
615
  }
616
+ async function serveAgentTurn(t) {
617
+ const {
618
+ req,
619
+ res,
620
+ agent,
621
+ method,
622
+ url,
623
+ requestId,
624
+ start,
625
+ loadModule,
626
+ csrfMode,
627
+ projectRoot,
628
+ pluginRunner,
629
+ serverDir
630
+ } = t;
631
+ const resolveSubject = createAgentSubjectResolver({
632
+ req,
633
+ res,
634
+ loadModule,
635
+ serverDir,
636
+ pluginRunner
637
+ });
638
+ await serveThroughPluginLifecycle(
639
+ {
640
+ source: createWebRequestSource(req),
641
+ res,
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
657
+ });
658
+ await writeWebResponseToServerResponse(response, res);
659
+ }
660
+ );
661
+ logRequest({ method, url, status: res.statusCode, duration: Date.now() - start, requestId });
662
+ }
568
663
 
569
664
  // src/vite-plugin/api-middleware.ts
570
665
  import { resolve as resolve2 } from "path";
@@ -615,10 +710,10 @@ async function handleBatchIfMatch(req, res, ctx) {
615
710
  async function handleBatchInline(req, res, batching, requestId) {
616
711
  try {
617
712
  const chunks = [];
618
- await new Promise((resolve7, reject) => {
713
+ await new Promise((resolve6, reject) => {
619
714
  req.on("data", (c) => chunks.push(c));
620
715
  req.on("end", () => {
621
- resolve7();
716
+ resolve6();
622
717
  });
623
718
  req.on("error", reject);
624
719
  });
@@ -683,7 +778,18 @@ async function tryControllerFallthrough(ctx) {
683
778
  requestId: ctx.requestId,
684
779
  // M47 — serve @Expose-bound agent routes via the ONE runtime (mountAgent). CSRF is already enforced
685
780
  // once at the controller-dispatch boundary (G5), so mountAgent runs with csrfMode 'off' (no double gate).
686
- serveAgent: (agent, request) => mountAgent(agent, request, resolveProvider().apiKey, { source: "expose", csrfMode: "off" })
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.
789
+ serveAgent: (agent, request) => mountAgent(agent, request, (model) => resolveProvider(model).apiKey, {
790
+ source: "expose",
791
+ csrfMode: "off"
792
+ })
687
793
  });
688
794
  if (!handled) return false;
689
795
  logRequest(
@@ -870,7 +976,12 @@ async function runConfigureServer(server, ctx) {
870
976
  })
871
977
  );
872
978
  server.middlewares.use(
873
- createAgentMiddleware(server, ctx.projectRoot, ctx.csrfMode, ctx.agentsDir)
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
+ })
874
985
  );
875
986
  const servicesProxyPrefixes = ctx.services && Object.keys(ctx.services).length > 0 ? Object.values(ctx.services).map((s) => s.proxy) : [];
876
987
  const csrfReadinessStore = ctx.csrfReadinessStoreOverride ?? new CsrfReadinessStore();
@@ -917,7 +1028,7 @@ async function runConfigureServer(server, ctx) {
917
1028
  server.watcher.on("unlink", handleRouteChange);
918
1029
  if (ctx.resolvedOpenApi !== void 0) {
919
1030
  const openApiCfg = ctx.resolvedOpenApi;
920
- const { reEmitOpenApi } = await import("./dev-emit-GWD6IXV7.js");
1031
+ const { reEmitOpenApi } = await import("./dev-emit-BFNMDCPB.js");
921
1032
  const openApiServerDir = ctx.serverDir;
922
1033
  const openApiDistDir = resolve3(ctx.projectRoot, ctx.resolvedDistDir);
923
1034
  const isRouteFileForOpenApi = (file) => file.startsWith(openApiServerDir) && /\.(ts|tsx|js|mjs)$/.test(file);
@@ -1224,19 +1335,9 @@ async function integrateUseTheoUI(cwd, opts) {
1224
1335
  return [...tailwindPlugins, ...uiPlugins];
1225
1336
  }
1226
1337
 
1227
- // src/vite-plugin/resolve-theo-root.ts
1338
+ // src/vite-plugin/transform-html-hook.ts
1228
1339
  import { existsSync as existsSync5 } from "fs";
1229
1340
  import { resolve as resolve4 } from "path";
1230
- function resolveTheoRootDir(currentDir) {
1231
- if (existsSync5(resolve4(currentDir, "client"))) {
1232
- return currentDir;
1233
- }
1234
- return resolve4(currentDir, "..");
1235
- }
1236
-
1237
- // src/vite-plugin/transform-html-hook.ts
1238
- import { existsSync as existsSync6 } from "fs";
1239
- import { resolve as resolve5 } from "path";
1240
1341
 
1241
1342
  // src/vite-plugin/inject-devtools.ts
1242
1343
  var DEVTOOLS_VIRTUAL_ID = "/@theo/devtools/entry.js";
@@ -1336,7 +1437,7 @@ function runTransformIndexHtml(html, ctx) {
1336
1437
  next = devtools.html;
1337
1438
  const styles = injectStylesheets(next, {
1338
1439
  isDev: ctx.isDevMode.value,
1339
- hasPackage: (name) => existsSync6(resolve5(ctx.projectRoot, "node_modules", ...name.split("/")))
1440
+ hasPackage: (name) => existsSync5(resolve4(ctx.projectRoot, "node_modules", ...name.split("/")))
1340
1441
  });
1341
1442
  next = styles.html;
1342
1443
  return next;
@@ -1439,6 +1540,46 @@ function generateSingleShotEntry(options) {
1439
1540
  `}`
1440
1541
  ].join("\n");
1441
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
+ }
1442
1583
  function streamingWebRenderer(appTree) {
1443
1584
  return [
1444
1585
  `// T2.3 \u2014 Web Standards streaming entry for edge runtimes (Cloudflare,`,
@@ -1458,13 +1599,16 @@ function streamingWebRenderer(appTree) {
1458
1599
  // Streaming still applies to genuine data-fetching Suspense, which is where it earns its keep.
1459
1600
  // A failed import is swallowed on purpose: React.lazy will retry and suspend as before, which
1460
1601
  // is strictly no worse than not having preloaded at all.
1461
- ` 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) ?? []`,
1462
1607
  ` await Promise.all(`,
1463
1608
  ` __theoPreloadPathsFor(__theoMatches).map((p) => __theoPreloadMap[p]().catch(() => null)),`,
1464
1609
  ` )`,
1465
1610
  ``,
1466
1611
  ` const handler = createStaticHandler(routes)`,
1467
- ` const url = new URL(request.url)`,
1468
1612
  ` const context = await handler.query(request)`,
1469
1613
  ``,
1470
1614
  ` if (context instanceof Response) {`,
@@ -1474,12 +1618,14 @@ function streamingWebRenderer(appTree) {
1474
1618
  ` const router = createStaticRouter(handler.dataRoutes, context)`,
1475
1619
  ` const app = ${appTree}`,
1476
1620
  ``,
1621
+ hydrationDataExtractSnippet(),
1622
+ ``,
1477
1623
  ` const stream = await renderToReadableStream(app, {`,
1478
1624
  ` signal: request.signal,`,
1479
1625
  ` nonce: options.nonce,`,
1480
1626
  ` onError(err) { console.error('[SSR Web Stream Error]', err) },`,
1481
1627
  ` })`,
1482
- ` return new Response(stream, {`,
1628
+ ` return new Response(__theoDocumentStream(stream, hydrationData, options), {`,
1483
1629
  ` status: 200,`,
1484
1630
  ` headers: {`,
1485
1631
  ` 'Content-Type': 'text/html; charset=utf-8',`,
@@ -1523,15 +1669,29 @@ function streamingNodeRenderer(appTree) {
1523
1669
  ` const router = createStaticRouter(handler.dataRoutes, context)`,
1524
1670
  ` const app = ${appTree}`,
1525
1671
  ``,
1672
+ hydrationDataExtractSnippet(),
1673
+ ``,
1674
+ ` const { PassThrough } = await import('node:stream')`,
1526
1675
  ` return new Promise((resolve, reject) => {`,
1527
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)`,
1528
1686
  ` const stream = renderToPipeableStream(app, {`,
1529
1687
  ` nonce: options.nonce,`,
1530
1688
  ` onShellReady() {`,
1531
1689
  ` response.statusCode = didError ? 500 : 200`,
1532
1690
  ` response.setHeader('Content-Type', 'text/html; charset=utf-8')`,
1533
1691
  ` response.setHeader('Transfer-Encoding', 'chunked')`,
1534
- ` 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)`,
1535
1695
  ` resolve({ streaming: true })`,
1536
1696
  ` },`,
1537
1697
  ` onShellError(err) { reject(err) },`,
@@ -1615,6 +1775,8 @@ function generateStreamingEntry(options) {
1615
1775
  `import { routes, __theoPreloadMap, __theoPreloadPathsFor } from '/@theo/route-manifest'`,
1616
1776
  theoUiImport,
1617
1777
  ``,
1778
+ ...streamingDocumentHelpers(),
1779
+ ``,
1618
1780
  ...streamingWebRenderer(appTree),
1619
1781
  ``,
1620
1782
  ...streamingNodeRenderer(appTree),
@@ -1724,7 +1886,6 @@ function walkRouteTree(node, parents, acc) {
1724
1886
  routePath
1725
1887
  });
1726
1888
  }
1727
- if (node.layout !== void 0) acc.layoutState.found = true;
1728
1889
  pushIf(acc.staticImports, node.layout, safeVarName(seg, "Layout"));
1729
1890
  pushIf(acc.staticImports, node.error, safeVarName(seg, "Error"));
1730
1891
  pushIf(acc.staticImports, node.loading, safeVarName(seg, "Loading"));
@@ -1739,18 +1900,20 @@ function generateRouteManifest(tree, options = {}) {
1739
1900
  const lazyPages_ = options.lazyPages !== false;
1740
1901
  const acc = {
1741
1902
  staticImports: [],
1742
- lazyPages: [],
1743
- layoutState: { found: false }
1903
+ lazyPages: []
1744
1904
  };
1745
1905
  walkRouteTree(tree, [], acc);
1746
1906
  const staticImports = acc.staticImports;
1747
1907
  const lazyPages = acc.lazyPages;
1748
- const layoutState = acc.layoutState;
1749
1908
  const lines = [`import React, { Suspense } from 'react'`];
1750
- if (layoutState.found) {
1751
- lines.push(`import { Outlet } from 'react-router'`);
1752
- }
1753
- 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
+ );
1754
1917
  for (const imp of staticImports) {
1755
1918
  lines.push(`import ${imp.varName} from '${imp.importPath}'`);
1756
1919
  }
@@ -1804,16 +1967,20 @@ function generateRouteManifest(tree, options = {}) {
1804
1967
  function genRouteConfig(node, isRoot) {
1805
1968
  const seg = node.segment || "root";
1806
1969
  const childrenArray = buildChildrenArray(node, seg);
1970
+ const withScrollRestoration = (element) => `React.createElement(React.Fragment, null, React.createElement(ScrollRestoration), React.createElement(ElementScrollRestoration), ${element})`;
1807
1971
  if (node.layout) {
1808
1972
  const layoutVar = safeVarName(seg, "Layout");
1809
1973
  const pathPart = isRoot ? `path: '/'` : `path: '${segmentPath(node)}'`;
1810
- 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} }`;
1811
1977
  }
1812
1978
  if (isRoot) {
1979
+ const rootElement = withScrollRestoration(`React.createElement(Outlet)`);
1813
1980
  if (node.children.length === 0 && !node.page && !node.notFound && !node.error) {
1814
- return `{ path: '/', children: [] }`;
1981
+ return `{ path: '/', element: ${rootElement}, children: [] }`;
1815
1982
  }
1816
- return `{ path: '/', children: ${childrenArray} }`;
1983
+ return `{ path: '/', element: ${rootElement}, children: ${childrenArray} }`;
1817
1984
  }
1818
1985
  if (node.page && node.children.length === 0 && !node.error && !node.notFound) {
1819
1986
  const pageVar = safeVarName(seg, "Page");
@@ -1981,8 +2148,8 @@ function findConsumerConfig(projectRoot, basename2) {
1981
2148
  let dir = projectRoot;
1982
2149
  for (let level = 0; level < 3; level++) {
1983
2150
  for (const ext of extensions) {
1984
- const candidate = resolve6(dir, `${basename2}${ext}`);
1985
- if (existsSync7(candidate)) return candidate;
2151
+ const candidate = resolve5(dir, `${basename2}${ext}`);
2152
+ if (existsSync6(candidate)) return candidate;
1986
2153
  }
1987
2154
  const parent = dirname4(dir);
1988
2155
  if (parent === dir) break;
@@ -1993,7 +2160,7 @@ function findConsumerConfig(projectRoot, basename2) {
1993
2160
  async function theoPluginAsync(rootOrOptions) {
1994
2161
  const options = typeof rootOrOptions === "string" ? { root: rootOrOptions } : rootOrOptions ?? {};
1995
2162
  const projectRoot = options.root ?? process.cwd();
1996
- const serverDirAbs = resolve6(projectRoot, options.serverDir ?? "server");
2163
+ const serverDirAbs = resolve5(projectRoot, options.serverDir ?? "server");
1997
2164
  const agentsDirName = options.agentsDir ?? "agents";
1998
2165
  const consumerTailwindConfig = findConsumerConfig(projectRoot, "tailwind.config");
1999
2166
  const consumerPostcssConfig = findConsumerConfig(projectRoot, "postcss.config");
@@ -2004,7 +2171,7 @@ async function theoPluginAsync(rootOrOptions) {
2004
2171
  const studioPlugins = await integrateStudio();
2005
2172
  const servicesPlugins = [];
2006
2173
  if (options.services && Object.keys(options.services).length > 0) {
2007
- const { servicesTypedClientPlugin } = await import("./services-typed-client-PSAGRPFF.js");
2174
+ const { servicesTypedClientPlugin } = await import("./services-typed-client-XGT5SUUN.js");
2008
2175
  servicesPlugins.push(
2009
2176
  servicesTypedClientPlugin({
2010
2177
  cwd: projectRoot,
@@ -2012,23 +2179,23 @@ async function theoPluginAsync(rootOrOptions) {
2012
2179
  })
2013
2180
  );
2014
2181
  }
2015
- const { appTypedClientPlugin } = await import("./app-typed-client-G3J5G7E5.js");
2182
+ const { appTypedClientPlugin } = await import("./app-typed-client-DQM3Y6YY.js");
2016
2183
  const appClientPlugin = appTypedClientPlugin({
2017
2184
  cwd: projectRoot,
2018
2185
  serverDir: serverDirAbs,
2019
- distDir: resolve6(projectRoot, ".theokit")
2186
+ distDir: resolve5(projectRoot, ".theokit")
2020
2187
  });
2021
- const { actionsVirtualModule } = await import("./actions-virtual-module-LB4NGONI.js");
2188
+ const { actionsVirtualModule } = await import("./actions-virtual-module-ZYLMNW6K.js");
2022
2189
  const actionsPlugin = actionsVirtualModule({
2023
2190
  serverDir: serverDirAbs,
2024
- distDir: resolve6(projectRoot, ".theokit")
2191
+ distDir: resolve5(projectRoot, ".theokit")
2025
2192
  });
2026
2193
  const { agentsTypedClientPlugin } = await import("./agents-typed-client-D4OA2TXB.js");
2027
- const { generateManifest } = await import("./internal-api-V5L65YSJ.js");
2194
+ const { generateManifest } = await import("./internal-api-IP35YU3G.js");
2028
2195
  const agentsClientPlugin = agentsTypedClientPlugin({
2029
2196
  projectRoot,
2030
2197
  agentsDir: agentsDirName,
2031
- distDir: resolve6(projectRoot, ".theokit"),
2198
+ distDir: resolve5(projectRoot, ".theokit"),
2032
2199
  // Agents live at <projectRoot>/<agentsDir>; generateManifest scans them via the server dir's
2033
2200
  // parent (projectRoot for the canonical layout) + the agents dir name (#95 follow-up).
2034
2201
  scanManifest: () => generateManifest(serverDirAbs, projectRoot, agentsDirName)
@@ -2041,11 +2208,17 @@ async function theoPluginAsync(rootOrOptions) {
2041
2208
  const controllerTransformPlugin = controllerSwcTransformPlugin({
2042
2209
  serverDir: serverDirAbs
2043
2210
  });
2211
+ const { serverOnlyImportBoundary } = await import("./server-boundary-7VZQRPPX.js");
2212
+ const serverBoundaryPlugin = serverOnlyImportBoundary({
2213
+ projectRoot,
2214
+ serverDir: serverDirAbs
2215
+ });
2044
2216
  return [
2045
2217
  theoPlugin(rootOrOptions),
2046
2218
  ...uiPlugins,
2047
2219
  ...studioPlugins,
2048
2220
  ...servicesPlugins,
2221
+ serverBoundaryPlugin,
2049
2222
  // #122 — swc-compile controllers/** (enforce:'pre'; order-independent).
2050
2223
  controllerTransformPlugin,
2051
2224
  appClientPlugin,
@@ -2056,10 +2229,10 @@ async function theoPluginAsync(rootOrOptions) {
2056
2229
  }
2057
2230
  function buildOptimizeDepsInclude(projectRoot, viteOptimizeDeps) {
2058
2231
  const include = [];
2059
- if (existsSync7(resolve6(projectRoot, "node_modules", "@theokit", "ui"))) {
2232
+ if (existsSync6(resolve5(projectRoot, "node_modules", "@theokit", "ui"))) {
2060
2233
  include.push("@theokit/ui");
2061
2234
  }
2062
- if (existsSync7(resolve6(projectRoot, "node_modules", "lucide-react"))) {
2235
+ if (existsSync6(resolve5(projectRoot, "node_modules", "lucide-react"))) {
2063
2236
  include.push("lucide-react");
2064
2237
  }
2065
2238
  include.push("devalue");
@@ -2085,8 +2258,8 @@ var VIRTUAL_MODULE_IDS = {
2085
2258
  function theoPlugin(rootOrOptions) {
2086
2259
  const options = typeof rootOrOptions === "string" ? { root: rootOrOptions } : rootOrOptions ?? {};
2087
2260
  const projectRoot = options.root ?? process.cwd();
2088
- const appDir = resolve6(projectRoot, options.appDir ?? "app");
2089
- const serverDir = resolve6(projectRoot, options.serverDir ?? "server");
2261
+ const appDir = resolve5(projectRoot, options.appDir ?? "app");
2262
+ const serverDir = resolve5(projectRoot, options.serverDir ?? "server");
2090
2263
  const agentsDir = options.agentsDir ?? "agents";
2091
2264
  const ssrEnabled = options.ssr ?? false;
2092
2265
  const currentDir = dirname4(fileURLToPath(import.meta.url));
@@ -2210,4 +2383,4 @@ export {
2210
2383
  theoPluginAsync,
2211
2384
  theoPlugin
2212
2385
  };
2213
- //# sourceMappingURL=chunk-YRBR424R.js.map
2386
+ //# sourceMappingURL=chunk-OAUI273L.js.map