@selvajs/selva 4.20.1-beta.4 → 4.21.0-beta.10

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 (302) hide show
  1. package/build/adapter-node.js +1 -1
  2. package/build/client/_app/immutable/assets/0.CqqJCiiV.css +2 -0
  3. package/build/client/_app/immutable/assets/0.CqqJCiiV.css.br +0 -0
  4. package/build/client/_app/immutable/assets/0.CqqJCiiV.css.gz +0 -0
  5. package/build/client/_app/immutable/chunks/{CzfnuBzq.js → BAhtiTKe.js} +1 -1
  6. package/build/client/_app/immutable/chunks/BAhtiTKe.js.br +0 -0
  7. package/build/client/_app/immutable/chunks/BAhtiTKe.js.gz +0 -0
  8. package/build/client/_app/immutable/chunks/{qi43d-TM.js → CKbHmAlc.js} +1 -1
  9. package/build/client/_app/immutable/chunks/CKbHmAlc.js.br +0 -0
  10. package/build/client/_app/immutable/chunks/CKbHmAlc.js.gz +0 -0
  11. package/build/client/_app/immutable/chunks/{C6Y_BUwr.js → CmlXAF26.js} +1 -1
  12. package/build/client/_app/immutable/chunks/CmlXAF26.js.br +0 -0
  13. package/build/client/_app/immutable/chunks/CmlXAF26.js.gz +0 -0
  14. package/build/client/_app/immutable/chunks/Cv7GBWJh.js +2 -0
  15. package/build/client/_app/immutable/chunks/Cv7GBWJh.js.br +0 -0
  16. package/build/client/_app/immutable/chunks/Cv7GBWJh.js.gz +0 -0
  17. package/build/client/_app/immutable/chunks/{BDYCH-_Q.js → D5j4-ZO1.js} +1 -1
  18. package/build/client/_app/immutable/chunks/D5j4-ZO1.js.br +0 -0
  19. package/build/client/_app/immutable/chunks/D5j4-ZO1.js.gz +0 -0
  20. package/build/client/_app/immutable/chunks/DW5EJMC7.js +1 -0
  21. package/build/client/_app/immutable/chunks/DW5EJMC7.js.br +0 -0
  22. package/build/client/_app/immutable/chunks/DW5EJMC7.js.gz +0 -0
  23. package/build/client/_app/immutable/chunks/{D-uUm_OB.js → DptnDNFA.js} +61 -56
  24. package/build/client/_app/immutable/chunks/DptnDNFA.js.br +0 -0
  25. package/build/client/_app/immutable/chunks/{D-uUm_OB.js.gz → DptnDNFA.js.gz} +0 -0
  26. package/build/client/_app/immutable/chunks/DvJo0Zn0.js +1 -0
  27. package/build/client/_app/immutable/chunks/DvJo0Zn0.js.br +1 -0
  28. package/build/client/_app/immutable/chunks/DvJo0Zn0.js.gz +0 -0
  29. package/build/client/_app/immutable/chunks/{DzxE3j6C.js → qXnHMKD9.js} +1 -1
  30. package/build/client/_app/immutable/chunks/qXnHMKD9.js.br +0 -0
  31. package/build/client/_app/immutable/chunks/qXnHMKD9.js.gz +0 -0
  32. package/build/client/_app/immutable/entry/{app.BpT6WkO1.js → app.DPbjEDd3.js} +2 -2
  33. package/build/client/_app/immutable/entry/app.DPbjEDd3.js.br +0 -0
  34. package/build/client/_app/immutable/entry/app.DPbjEDd3.js.gz +0 -0
  35. package/build/client/_app/immutable/nodes/{1.D3kiiIk_.js → 1.DWd6YbcT.js} +1 -1
  36. package/build/client/_app/immutable/nodes/1.DWd6YbcT.js.br +0 -0
  37. package/build/client/_app/immutable/nodes/1.DWd6YbcT.js.gz +0 -0
  38. package/build/client/_app/immutable/nodes/15._hpTnSzc.js +36 -0
  39. package/build/client/_app/immutable/nodes/15._hpTnSzc.js.br +0 -0
  40. package/build/client/_app/immutable/nodes/15._hpTnSzc.js.gz +0 -0
  41. package/build/client/_app/immutable/nodes/{2.CUNbzjI_.js → 2.CS32Eh9m.js} +1 -1
  42. package/build/client/_app/immutable/nodes/2.CS32Eh9m.js.br +0 -0
  43. package/build/client/_app/immutable/nodes/2.CS32Eh9m.js.gz +0 -0
  44. package/build/client/_app/immutable/nodes/{20.9OIre0ah.js → 20.CVaxGEhZ.js} +1 -1
  45. package/build/client/_app/immutable/nodes/20.CVaxGEhZ.js.br +0 -0
  46. package/build/client/_app/immutable/nodes/20.CVaxGEhZ.js.gz +0 -0
  47. package/build/client/_app/immutable/nodes/21.DpKe0-GH.js +1 -0
  48. package/build/client/_app/immutable/nodes/21.DpKe0-GH.js.br +0 -0
  49. package/build/client/_app/immutable/nodes/21.DpKe0-GH.js.gz +0 -0
  50. package/build/client/_app/immutable/nodes/24.DkL5kHzA.js +3 -0
  51. package/build/client/_app/immutable/nodes/24.DkL5kHzA.js.br +0 -0
  52. package/build/client/_app/immutable/nodes/24.DkL5kHzA.js.gz +0 -0
  53. package/build/client/_app/immutable/nodes/{25.DW1_vMxq.js → 25.DiYmTwXC.js} +2 -2
  54. package/build/client/_app/immutable/nodes/25.DiYmTwXC.js.br +0 -0
  55. package/build/client/_app/immutable/nodes/25.DiYmTwXC.js.gz +0 -0
  56. package/build/client/_app/immutable/nodes/26.7nAJpm5P.js +5 -0
  57. package/build/client/_app/immutable/nodes/26.7nAJpm5P.js.br +0 -0
  58. package/build/client/_app/immutable/nodes/26.7nAJpm5P.js.gz +0 -0
  59. package/build/client/_app/immutable/nodes/{3.3Z4QUsQQ.js → 3.Ctd9OGCk.js} +1 -1
  60. package/build/client/_app/immutable/nodes/3.Ctd9OGCk.js.br +0 -0
  61. package/build/client/_app/immutable/nodes/3.Ctd9OGCk.js.gz +0 -0
  62. package/build/client/_app/immutable/nodes/{5.DmA9lTA-.js → 5.Wh_w3RkZ.js} +1 -1
  63. package/build/client/_app/immutable/nodes/5.Wh_w3RkZ.js.br +2 -0
  64. package/build/client/_app/immutable/nodes/5.Wh_w3RkZ.js.gz +0 -0
  65. package/build/client/_app/immutable/nodes/{6.D6WLqCgl.js → 6.C-DiUI5R.js} +1 -1
  66. package/build/client/_app/immutable/nodes/6.C-DiUI5R.js.br +0 -0
  67. package/build/client/_app/immutable/nodes/6.C-DiUI5R.js.gz +0 -0
  68. package/build/client/_app/immutable/nodes/{7.CNuRjkv2.js → 7.B8yubYrv.js} +1 -1
  69. package/build/client/_app/immutable/nodes/7.B8yubYrv.js.br +0 -0
  70. package/build/client/_app/immutable/nodes/7.B8yubYrv.js.gz +0 -0
  71. package/build/client/_app/version.json +1 -1
  72. package/build/client/_app/version.json.br +0 -0
  73. package/build/client/_app/version.json.gz +0 -0
  74. package/build/runtime-meta.json +1 -1
  75. package/build/server/.vite/manifest.json +35 -45
  76. package/build/server/_app/immutable/assets/_layout.CqqJCiiV.css +2 -0
  77. package/build/server/chunks/DefinitionCard.js +3 -0
  78. package/build/server/chunks/DefinitionCard.js.map +1 -1
  79. package/build/server/chunks/access.js +15 -3
  80. package/build/server/chunks/access.js.map +1 -1
  81. package/build/server/chunks/api-errors.js +18 -3
  82. package/build/server/chunks/api-errors.js.map +1 -1
  83. package/build/server/chunks/api.js +9 -2
  84. package/build/server/chunks/api.js.map +1 -1
  85. package/build/server/chunks/auth-bootstrap.server.js +63 -39
  86. package/build/server/chunks/auth-bootstrap.server.js.map +1 -1
  87. package/build/server/chunks/boot.server.js +1 -1
  88. package/build/server/chunks/bootHealth.server.js +23 -23
  89. package/build/server/chunks/bootHealth.server.js.map +1 -1
  90. package/build/server/chunks/computeRateLimit.server.js +2 -2
  91. package/build/server/chunks/delete-with-blobs.js +1 -1
  92. package/build/server/chunks/engine.server.js +52 -5
  93. package/build/server/chunks/engine.server.js.map +1 -1
  94. package/build/server/chunks/grasshopper.js +217 -162
  95. package/build/server/chunks/grasshopper.js.map +1 -1
  96. package/build/server/chunks/handlers.js +70 -60
  97. package/build/server/chunks/handlers.js.map +1 -1
  98. package/build/server/chunks/http.js +24 -24
  99. package/build/server/chunks/http.js.map +1 -1
  100. package/build/server/chunks/http2.js +1 -1
  101. package/build/server/chunks/instance.js +3 -3
  102. package/build/server/chunks/instanceAdmins.server.js +31 -16
  103. package/build/server/chunks/instanceAdmins.server.js.map +1 -1
  104. package/build/server/chunks/internal.js +1 -1
  105. package/build/server/chunks/{abort-Bfrdupaj.js → keepalive-vtcjhAV3.js} +6 -3
  106. package/build/server/chunks/keepalive-vtcjhAV3.js.map +1 -0
  107. package/build/server/chunks/liveSolve.server.js +1 -1
  108. package/build/server/chunks/localeContext.svelte.js +14 -0
  109. package/build/server/chunks/localeContext.svelte.js.map +1 -1
  110. package/build/server/chunks/oauth.js +70 -24
  111. package/build/server/chunks/oauth.js.map +1 -1
  112. package/build/server/chunks/{outcome-DNrffAXp.js → outcome-D28FgvFK.js} +9 -6
  113. package/build/server/chunks/outcome-D28FgvFK.js.map +1 -0
  114. package/build/server/chunks/package.js +2 -1
  115. package/build/server/chunks/package.js.map +1 -1
  116. package/build/server/chunks/permissions.server.js +1 -1
  117. package/build/server/chunks/presets.server.js +1 -1
  118. package/build/server/chunks/providers.server.js +324 -121
  119. package/build/server/chunks/providers.server.js.map +1 -1
  120. package/build/server/chunks/registry.js +1 -1
  121. package/build/server/chunks/resolve-server.js +1 -1
  122. package/build/server/chunks/schema-extraction.js +75 -8
  123. package/build/server/chunks/schema-extraction.js.map +1 -1
  124. package/build/server/chunks/schema.js +1 -1
  125. package/build/server/chunks/schema.js.map +1 -1
  126. package/build/server/chunks/server-config-write.js +6 -6
  127. package/build/server/chunks/server-config-write.js.map +1 -1
  128. package/build/server/chunks/server2.js +2 -2
  129. package/build/server/chunks/server2.js.map +1 -1
  130. package/build/server/chunks/serverStats.server.js +1 -1
  131. package/build/server/chunks/signInMaxAge.server.js +1 -1
  132. package/build/server/chunks/solve.server.js +34 -8
  133. package/build/server/chunks/solve.server.js.map +1 -1
  134. package/build/server/chunks/sveltekit.js +4 -5
  135. package/build/server/chunks/sveltekit.js.map +1 -1
  136. package/build/server/chunks/update-outcome.js +11 -0
  137. package/build/server/chunks/update-outcome.js.map +1 -1
  138. package/build/server/chunks/updateCheck.server.js +24 -12
  139. package/build/server/chunks/updateCheck.server.js.map +1 -1
  140. package/build/server/entries/endpoints/.well-known/oauth-authorization-server/_server.ts.js +6 -3
  141. package/build/server/entries/endpoints/.well-known/oauth-authorization-server/_server.ts.js.map +1 -1
  142. package/build/server/entries/endpoints/.well-known/oauth-protected-resource/_server.ts.js +6 -3
  143. package/build/server/entries/endpoints/.well-known/oauth-protected-resource/_server.ts.js.map +1 -1
  144. package/build/server/entries/endpoints/.well-known/oauth-protected-resource/mcp/_server.ts.js +6 -3
  145. package/build/server/entries/endpoints/.well-known/oauth-protected-resource/mcp/_server.ts.js.map +1 -1
  146. package/build/server/entries/endpoints/api/admin/compute/_server.ts.js +1 -1
  147. package/build/server/entries/endpoints/api/admin/compute/actions/_server.ts.js +1 -1
  148. package/build/server/entries/endpoints/api/admin/compute/status/_server.ts.js +1 -1
  149. package/build/server/entries/endpoints/api/admin/orgs/_id_/_server.ts.js +1 -1
  150. package/build/server/entries/endpoints/api/admin/orgs/_server.ts.js +1 -1
  151. package/build/server/entries/endpoints/api/admin/projects/_id_/_server.ts.js +1 -1
  152. package/build/server/entries/endpoints/api/admin/projects/_id_/grants/_grantId_/_server.ts.js +1 -1
  153. package/build/server/entries/endpoints/api/admin/projects/_id_/grants/_server.ts.js +1 -1
  154. package/build/server/entries/endpoints/api/admin/projects/_server.ts.js +1 -1
  155. package/build/server/entries/endpoints/api/admin/system/health/_server.ts.js +9 -2
  156. package/build/server/entries/endpoints/api/admin/system/health/_server.ts.js.map +1 -1
  157. package/build/server/entries/endpoints/api/admin/system/update/_server.ts.js +59 -15
  158. package/build/server/entries/endpoints/api/admin/system/update/_server.ts.js.map +1 -1
  159. package/build/server/entries/endpoints/api/admin/users/_id_/_server.ts.js +42 -16
  160. package/build/server/entries/endpoints/api/admin/users/_id_/_server.ts.js.map +1 -1
  161. package/build/server/entries/endpoints/api/admin/users/_id_/disable/_server.ts.js +24 -13
  162. package/build/server/entries/endpoints/api/admin/users/_id_/disable/_server.ts.js.map +1 -1
  163. package/build/server/entries/endpoints/api/admin/users/_server.ts.js +2 -2
  164. package/build/server/entries/endpoints/api/files/_...path_/_server.ts.js +1 -1
  165. package/build/server/entries/endpoints/api/v1/compute/_server.ts.js +15 -6
  166. package/build/server/entries/endpoints/api/v1/compute/_server.ts.js.map +1 -1
  167. package/build/server/entries/endpoints/api/v1/compute/schema/_server.ts.js +3 -3
  168. package/build/server/entries/endpoints/api/v1/definitions/_guid_/_server.ts.js +1 -1
  169. package/build/server/entries/endpoints/api/v1/definitions/_guid_/image/_server.ts.js +1 -1
  170. package/build/server/entries/endpoints/api/v1/definitions/_guid_/publish/_server.ts.js +1 -1
  171. package/build/server/entries/endpoints/api/v1/definitions/_guid_/schema/_server.ts.js +1 -1
  172. package/build/server/entries/endpoints/api/v1/definitions/_guid_/share-links/_linkId_/_server.ts.js +1 -1
  173. package/build/server/entries/endpoints/api/v1/definitions/_guid_/share-links/_server.ts.js +1 -1
  174. package/build/server/entries/endpoints/api/v1/definitions/_guid_/solve/_server.ts.js +5 -4
  175. package/build/server/entries/endpoints/api/v1/definitions/_guid_/solve/_server.ts.js.map +1 -1
  176. package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/_server.ts.js +1 -1
  177. package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/_versionId_/_server.ts.js +1 -1
  178. package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/_versionId_/schema/_server.ts.js +1 -1
  179. package/build/server/entries/endpoints/api/v1/me/_server.ts.js +1 -1
  180. package/build/server/entries/endpoints/api/v1/me/starred/_guid_/_server.ts.js +1 -1
  181. package/build/server/entries/endpoints/api/v1/me/token/_server.ts.js +1 -1
  182. package/build/server/entries/endpoints/api/v1/orgs/_orgId_/_server.ts.js +1 -1
  183. package/build/server/entries/endpoints/api/v1/orgs/_orgId_/members/_server.ts.js +1 -1
  184. package/build/server/entries/endpoints/api/v1/orgs/_orgId_/tokens/_server.ts.js +1 -1
  185. package/build/server/entries/endpoints/api/v1/orgs/_orgId_/tokens/_tokenId_/_server.ts.js +1 -1
  186. package/build/server/entries/endpoints/api/v1/projects/_id_/_server.ts.js +1 -1
  187. package/build/server/entries/endpoints/api/v1/projects/_id_/members/_server.ts.js +1 -1
  188. package/build/server/entries/endpoints/api/v1/projects/_id_/members/_userId_/_server.ts.js +1 -1
  189. package/build/server/entries/endpoints/api/v1/projects/_id_/reclaim/_server.ts.js +1 -1
  190. package/build/server/entries/endpoints/api/v1/solve/_solveId_/cancel/_server.ts.js +1 -1
  191. package/build/server/entries/endpoints/api/v1/solve-events/_server.ts.js +1 -1
  192. package/build/server/entries/endpoints/auth/email/callback/_server.ts.js +2 -2
  193. package/build/server/entries/endpoints/auth/email/callback/_server.ts.js.map +1 -1
  194. package/build/server/entries/endpoints/auth/supabase/callback/_server.ts.js +2 -2
  195. package/build/server/entries/endpoints/auth/supabase/callback/_server.ts.js.map +1 -1
  196. package/build/server/entries/endpoints/docs/api/openapi.yaml/_server.ts.js +1 -1
  197. package/build/server/entries/endpoints/mcp/_server.ts.js +43 -13
  198. package/build/server/entries/endpoints/mcp/_server.ts.js.map +1 -1
  199. package/build/server/entries/endpoints/oauth/register/_server.ts.js +1 -1
  200. package/build/server/entries/endpoints/oauth/token/_server.ts.js +1 -1
  201. package/build/server/entries/hooks.server.js +25 -6
  202. package/build/server/entries/hooks.server.js.map +1 -1
  203. package/build/server/entries/pages/admin/compute/_page.server.ts.js +1 -2
  204. package/build/server/entries/pages/admin/compute/_page.server.ts.js.map +1 -1
  205. package/build/server/entries/pages/admin/system/_page.server.ts.js +8 -3
  206. package/build/server/entries/pages/admin/system/_page.server.ts.js.map +1 -1
  207. package/build/server/entries/pages/admin/system/_page.svelte.js +18 -2
  208. package/build/server/entries/pages/admin/system/_page.svelte.js.map +1 -1
  209. package/build/server/entries/pages/library/_guid_/_page.server.ts.js +198 -99
  210. package/build/server/entries/pages/library/_guid_/_page.server.ts.js.map +1 -1
  211. package/build/server/entries/pages/library/_guid_/_page.svelte.js +693 -40
  212. package/build/server/entries/pages/library/_guid_/_page.svelte.js.map +1 -1
  213. package/build/server/entries/pages/oauth/authorize/_page.server.ts.js +3 -2
  214. package/build/server/entries/pages/oauth/authorize/_page.server.ts.js.map +1 -1
  215. package/build/server/entries/pages/oauth/authorize/_page.svelte.js +8 -1
  216. package/build/server/entries/pages/oauth/authorize/_page.svelte.js.map +1 -1
  217. package/build/server/entries/pages/projects/_page.svelte.js +2 -0
  218. package/build/server/entries/pages/projects/_page.svelte.js.map +1 -1
  219. package/build/server/entries/pages/setup/_page.server.ts.js +62 -8
  220. package/build/server/entries/pages/setup/_page.server.ts.js.map +1 -1
  221. package/build/server/entries/pages/setup/_page.svelte.js +52 -33
  222. package/build/server/entries/pages/setup/_page.svelte.js.map +1 -1
  223. package/build/server/entries/pages/team/tokens/_page.server.ts.js +1 -1
  224. package/build/server/manifest-full.js +1 -1
  225. package/build/server/manifest.js +1 -1
  226. package/build/server/nodes/0.js +2 -2
  227. package/build/server/nodes/1.js +1 -1
  228. package/build/server/nodes/15.js +1 -1
  229. package/build/server/nodes/2.js +1 -1
  230. package/build/server/nodes/20.js +1 -1
  231. package/build/server/nodes/21.js +1 -1
  232. package/build/server/nodes/24.js +1 -1
  233. package/build/server/nodes/25.js +1 -1
  234. package/build/server/nodes/26.js +1 -1
  235. package/build/server/nodes/3.js +1 -1
  236. package/build/server/nodes/5.js +1 -1
  237. package/build/server/nodes/6.js +1 -1
  238. package/build/server/nodes/7.js +1 -1
  239. package/build/server/server.js +1 -1
  240. package/package.json +16 -13
  241. package/templates/.env.example +15 -7
  242. package/build/client/_app/immutable/assets/0.2jDm0bqh.css +0 -2
  243. package/build/client/_app/immutable/assets/0.2jDm0bqh.css.br +0 -0
  244. package/build/client/_app/immutable/assets/0.2jDm0bqh.css.gz +0 -0
  245. package/build/client/_app/immutable/chunks/BDYCH-_Q.js.br +0 -0
  246. package/build/client/_app/immutable/chunks/BDYCH-_Q.js.gz +0 -0
  247. package/build/client/_app/immutable/chunks/C6Y_BUwr.js.br +0 -0
  248. package/build/client/_app/immutable/chunks/C6Y_BUwr.js.gz +0 -0
  249. package/build/client/_app/immutable/chunks/CzfnuBzq.js.br +0 -0
  250. package/build/client/_app/immutable/chunks/CzfnuBzq.js.gz +0 -0
  251. package/build/client/_app/immutable/chunks/D-uUm_OB.js.br +0 -0
  252. package/build/client/_app/immutable/chunks/D84F7w9g.js +0 -1
  253. package/build/client/_app/immutable/chunks/D84F7w9g.js.br +0 -1
  254. package/build/client/_app/immutable/chunks/D84F7w9g.js.gz +0 -0
  255. package/build/client/_app/immutable/chunks/DQsP4nZb.js +0 -1
  256. package/build/client/_app/immutable/chunks/DQsP4nZb.js.br +0 -0
  257. package/build/client/_app/immutable/chunks/DQsP4nZb.js.gz +0 -0
  258. package/build/client/_app/immutable/chunks/DzeQucGI.js +0 -2
  259. package/build/client/_app/immutable/chunks/DzeQucGI.js.br +0 -0
  260. package/build/client/_app/immutable/chunks/DzeQucGI.js.gz +0 -0
  261. package/build/client/_app/immutable/chunks/DzxE3j6C.js.br +0 -0
  262. package/build/client/_app/immutable/chunks/DzxE3j6C.js.gz +0 -0
  263. package/build/client/_app/immutable/chunks/qi43d-TM.js.br +0 -0
  264. package/build/client/_app/immutable/chunks/qi43d-TM.js.gz +0 -0
  265. package/build/client/_app/immutable/entry/app.BpT6WkO1.js.br +0 -0
  266. package/build/client/_app/immutable/entry/app.BpT6WkO1.js.gz +0 -0
  267. package/build/client/_app/immutable/nodes/1.D3kiiIk_.js.br +0 -0
  268. package/build/client/_app/immutable/nodes/1.D3kiiIk_.js.gz +0 -0
  269. package/build/client/_app/immutable/nodes/15.BXIV1QfS.js +0 -32
  270. package/build/client/_app/immutable/nodes/15.BXIV1QfS.js.br +0 -0
  271. package/build/client/_app/immutable/nodes/15.BXIV1QfS.js.gz +0 -0
  272. package/build/client/_app/immutable/nodes/2.CUNbzjI_.js.br +0 -0
  273. package/build/client/_app/immutable/nodes/2.CUNbzjI_.js.gz +0 -0
  274. package/build/client/_app/immutable/nodes/20.9OIre0ah.js.br +0 -0
  275. package/build/client/_app/immutable/nodes/20.9OIre0ah.js.gz +0 -0
  276. package/build/client/_app/immutable/nodes/21.BkNlRItr.js +0 -1
  277. package/build/client/_app/immutable/nodes/21.BkNlRItr.js.br +0 -0
  278. package/build/client/_app/immutable/nodes/21.BkNlRItr.js.gz +0 -0
  279. package/build/client/_app/immutable/nodes/24.CPSunfJJ.js +0 -3
  280. package/build/client/_app/immutable/nodes/24.CPSunfJJ.js.br +0 -0
  281. package/build/client/_app/immutable/nodes/24.CPSunfJJ.js.gz +0 -0
  282. package/build/client/_app/immutable/nodes/25.DW1_vMxq.js.br +0 -0
  283. package/build/client/_app/immutable/nodes/25.DW1_vMxq.js.gz +0 -0
  284. package/build/client/_app/immutable/nodes/26.CqaMEm_t.js +0 -6
  285. package/build/client/_app/immutable/nodes/26.CqaMEm_t.js.br +0 -0
  286. package/build/client/_app/immutable/nodes/26.CqaMEm_t.js.gz +0 -0
  287. package/build/client/_app/immutable/nodes/3.3Z4QUsQQ.js.br +0 -0
  288. package/build/client/_app/immutable/nodes/3.3Z4QUsQQ.js.gz +0 -0
  289. package/build/client/_app/immutable/nodes/5.DmA9lTA-.js.br +0 -1
  290. package/build/client/_app/immutable/nodes/5.DmA9lTA-.js.gz +0 -0
  291. package/build/client/_app/immutable/nodes/6.D6WLqCgl.js.br +0 -0
  292. package/build/client/_app/immutable/nodes/6.D6WLqCgl.js.gz +0 -0
  293. package/build/client/_app/immutable/nodes/7.CNuRjkv2.js.br +0 -0
  294. package/build/client/_app/immutable/nodes/7.CNuRjkv2.js.gz +0 -0
  295. package/build/server/_app/immutable/assets/_layout.2jDm0bqh.css +0 -2
  296. package/build/server/chunks/abort-Bfrdupaj.js.map +0 -1
  297. package/build/server/chunks/computeLimits.js +0 -33
  298. package/build/server/chunks/computeLimits.js.map +0 -1
  299. package/build/server/chunks/outcome-DNrffAXp.js.map +0 -1
  300. /package/build/client/_app/immutable/nodes/{0.CYdyv5To.js → 0.Ds0zeDAg.js} +0 -0
  301. /package/build/client/_app/immutable/nodes/{0.CYdyv5To.js.br → 0.Ds0zeDAg.js.br} +0 -0
  302. /package/build/client/_app/immutable/nodes/{0.CYdyv5To.js.gz → 0.Ds0zeDAg.js.gz} +0 -0
@@ -8,8 +8,8 @@ import { t as ALL_PLATFORM_PERMISSIONS } from "./types3.js";
8
8
  import { d as encodeOffsetCursor, l as clampPageLimit, u as decodeOffsetCursor } from "./visibility.js";
9
9
  import { n as readBool } from "./limits.js";
10
10
  import { a as createLogger, i as ConsoleLogger, n as renderThrown } from "./definitions.js";
11
- import { c as ComputeError, i as TreeBuilder, l as ErrorCodes, m as isDefinitionRef, n as GrasshopperClient, p as enableDebugLogging, s as stableStringify } from "./grasshopper.js";
12
- import { i as getInputItems, n as serverSourcedInputIds, t as raceAbort } from "./abort-Bfrdupaj.js";
11
+ import { c as stableStringify, d as ErrorCodes, g as isDefinitionRef, h as enableDebugLogging, i as TreeBuilder, l as withSolveMode, n as GrasshopperClient, u as ComputeError } from "./grasshopper.js";
12
+ import { i as serverSourcedInputIds, n as KEEPALIVE_PREFERENCE, o as getInputItems, r as raceAbort, t as KEEPALIVE_INTERVAL_MS } from "./keepalive-vtcjhAV3.js";
13
13
  import { createRequire } from "node:module";
14
14
  import * as crypto from "node:crypto";
15
15
  import { createCipheriv, createDecipheriv, createHash, createHmac, createPrivateKey, randomBytes, randomUUID, sign, timingSafeEqual } from "node:crypto";
@@ -579,6 +579,14 @@ function isEncryptedSecret(value) {
579
579
  function isLegacyEnvelope(value) {
580
580
  return value.startsWith(PREFIX_V1) || value.startsWith(PREFIX_V2);
581
581
  }
582
+ /**
583
+ * An `enc:v<n>:` envelope this build cannot open: a newer Selva sealed it, and this
584
+ * one runs after a downgrade. It is ciphertext, so it must never be reported or
585
+ * used as a plaintext key.
586
+ */
587
+ function isUnknownEnvelope(value) {
588
+ return /^enc:v\d+:/.test(value) && !isEncryptedSecret(value);
589
+ }
582
590
  function bindingAad({ id, url }) {
583
591
  return Buffer.from(JSON.stringify([id, url]), "utf8");
584
592
  }
@@ -1657,21 +1665,43 @@ var LocalComputeServerStore = class LocalComputeServerStore {
1657
1665
  };
1658
1666
  }
1659
1667
  /**
1660
- * Tolerant per-row decrypt: a row that fails to authenticate under the
1661
- * current `SELVA_AT_REST_KEY` comes back with `apiKey: undefined` and a
1662
- * logged warning, rather than failing the whole read — the page keeps
1663
- * rendering, and a solve against that server fails later when
1664
- * Rhino.Compute rejects the missing key. `verifySecrets()` is the strict
1665
- * counterpart for boot time.
1668
+ * Tolerant per-row decrypt: a row whose key cannot be opened comes back with
1669
+ * `apiKey: undefined` and a logged warning, rather than failing the whole read.
1670
+ * The page keeps rendering, and a solve against that server fails later when
1671
+ * Rhino.Compute rejects the missing key. That covers ciphertext that does not
1672
+ * authenticate under the current `SELVA_AT_REST_KEY`, and an envelope from a
1673
+ * newer Selva. `verifySecrets()` is the strict counterpart for boot time.
1666
1674
  *
1667
- * Plaintext-on-disk still hard-fails: the store never writes plaintext
1668
- * (every write goes through `encryptApiKeys`), so seeing it means someone
1669
- * hand-edited the file with a real secret exposed — surface that loudly.
1675
+ * Plaintext is the exception. The store never writes it (every write goes
1676
+ * through `encryptApiKeys`), so seeing it means someone hand-edited the file
1677
+ * with a real secret exposed: a read that would use the key throws.
1678
+ * `plaintext: 'unreadable'` returns the row keyless instead, for the save
1679
+ * path: a throw there would block the save that replaces the key.
1670
1680
  */
1671
- decryptApiKeys(servers) {
1681
+ decryptApiKeys(servers, { plaintext = "throw" } = {}) {
1672
1682
  return servers.map((s) => {
1673
1683
  if (!s.apiKey) return s;
1674
- if (!isEncryptedSecret(s.apiKey)) throw new Error(`compute.config.json contains an unencrypted apiKey for server "${s.label}" (${s.id}). Re-enter the key via /admin/compute so it is stored encrypted.`);
1684
+ const fields = {
1685
+ component: "selva",
1686
+ serverLabel: s.label,
1687
+ serverId: s.id
1688
+ };
1689
+ if (isUnknownEnvelope(s.apiKey)) {
1690
+ this.logger.warn(`Could not read apiKey: it is sealed as ${s.apiKey.slice(0, 6)}, a format this Selva version does not know. A newer version wrote it. This server is returned without an apiKey and solves against it will fail. Upgrade Selva again, or re-enter the key via /admin/compute.`, fields);
1691
+ return {
1692
+ ...s,
1693
+ apiKey: void 0
1694
+ };
1695
+ }
1696
+ if (!isEncryptedSecret(s.apiKey)) {
1697
+ const message = `compute.config.json contains an unencrypted apiKey for server "${s.label}" (${s.id}). Re-enter the key via /admin/compute so it is stored encrypted.`;
1698
+ if (plaintext === "throw") throw new Error(message);
1699
+ this.logger.error(message, fields);
1700
+ return {
1701
+ ...s,
1702
+ apiKey: void 0
1703
+ };
1704
+ }
1675
1705
  try {
1676
1706
  return {
1677
1707
  ...s,
@@ -1679,9 +1709,7 @@ var LocalComputeServerStore = class LocalComputeServerStore {
1679
1709
  };
1680
1710
  } catch (cause) {
1681
1711
  this.logger.warn("Could not decrypt apiKey: the stored ciphertext does not match the current SELVA_AT_REST_KEY. This server is returned without an apiKey and solves against it will fail. Re-enter the key via /admin/compute, or restore the original SELVA_AT_REST_KEY.", {
1682
- component: "selva",
1683
- serverLabel: s.label,
1684
- serverId: s.id,
1712
+ ...fields,
1685
1713
  err: cause instanceof Error ? cause.stack ?? cause.message : String(cause)
1686
1714
  });
1687
1715
  return {
@@ -1706,6 +1734,14 @@ var LocalComputeServerStore = class LocalComputeServerStore {
1706
1734
  let legacyEnvelopes = 0;
1707
1735
  for (const s of all.servers) {
1708
1736
  if (!s.apiKey) continue;
1737
+ if (isUnknownEnvelope(s.apiKey)) {
1738
+ failures.push({
1739
+ serverId: s.id,
1740
+ serverLabel: s.label,
1741
+ reason: "unknown_envelope"
1742
+ });
1743
+ continue;
1744
+ }
1709
1745
  if (!isEncryptedSecret(s.apiKey)) {
1710
1746
  plaintextFound = true;
1711
1747
  failures.push({
@@ -1777,7 +1813,7 @@ var LocalComputeServerStore = class LocalComputeServerStore {
1777
1813
  async getConfig(_ctx, opts = {}) {
1778
1814
  const all = await this.readAll();
1779
1815
  const config = {
1780
- servers: (opts.includeApiKeys ? this.decryptApiKeys(all.servers) : all.servers.map((s) => ({
1816
+ servers: (opts.includeApiKeys ? this.decryptApiKeys(all.servers, { plaintext: "unreadable" }) : all.servers.map((s) => ({
1781
1817
  ...s,
1782
1818
  apiKey: void 0
1783
1819
  }))).map((s, i) => ({
@@ -3511,9 +3547,9 @@ var ORG_COLUMNS = "id, name, slug, owner_id, assets, created_by, updated_by, cre
3511
3547
  /** Explicit column list for `org_members` — every field `rowToOrgMember` consumes. */
3512
3548
  var ORG_MEMBER_COLUMNS = "org_id, user_id, role, permissions, joined_at, updated_at, updated_by, deleted_at";
3513
3549
  /**
3514
- * Org + org-membership store backed by Postgres. The queries rely on RLS
3515
- * for per-user visibility; the service-role client bypasses those policies
3516
- * for admin paths (setup, janitor, tests).
3550
+ * Org + org-membership store backed by Postgres. Reads run as the caller, so
3551
+ * RLS decides what they see. Writes run as the service role: the app has
3552
+ * already decided, and sessions hold no write privilege.
3517
3553
  */
3518
3554
  var SupabaseOrgStore = class {
3519
3555
  clients;
@@ -3544,7 +3580,7 @@ var SupabaseOrgStore = class {
3544
3580
  return data ? rowToOrg(data) : null;
3545
3581
  }
3546
3582
  async createOrg(ctx, org) {
3547
- const client = this.clients.forRequest(ctx);
3583
+ const client = this.clients.serviceClient;
3548
3584
  const { error } = await client.from("orgs").insert(orgToRow(org));
3549
3585
  if (error) throw mapPostgrestError(error);
3550
3586
  const { error: memberError } = await client.from("org_members").upsert({
@@ -3569,12 +3605,12 @@ var SupabaseOrgStore = class {
3569
3605
  if (patch.assets !== void 0) row.assets = patch.assets;
3570
3606
  if (Object.keys(row).length === 0) return;
3571
3607
  Object.assign(row, stampUpdate(ctx));
3572
- const { error, data } = await this.clients.forRequest(ctx).from("orgs").update(row).eq("id", id).is("deleted_at", null).select("id");
3608
+ const { error, data } = await this.clients.serviceClient.from("orgs").update(row).eq("id", id).is("deleted_at", null).select("id");
3573
3609
  if (error) throw mapPostgrestError(error);
3574
3610
  if (!data || data.length === 0) throw new ProviderError(`Org '${id}' not found`, 404);
3575
3611
  }
3576
3612
  async deleteOrg(ctx, id) {
3577
- const client = this.clients.forRequest(ctx);
3613
+ const client = this.clients.serviceClient;
3578
3614
  const stampRow = stampSoftDelete(ctx);
3579
3615
  const { error: orgErr, data: orgData } = await client.from("orgs").update(stampRow).eq("id", id).is("deleted_at", null).select("id");
3580
3616
  if (orgErr) throw mapPostgrestError(orgErr);
@@ -3650,7 +3686,7 @@ var SupabaseOrgStore = class {
3650
3686
  deleted_at: null,
3651
3687
  ...stampUpdate(ctx)
3652
3688
  };
3653
- const { error } = await this.clients.forRequest(ctx).from("org_members").upsert(row, { onConflict: "org_id,user_id" });
3689
+ const { error } = await this.clients.serviceClient.from("org_members").upsert(row, { onConflict: "org_id,user_id" });
3654
3690
  if (error) throw mapPostgrestError(error);
3655
3691
  await this.events.emit({
3656
3692
  type: "org_member.added",
@@ -3665,7 +3701,7 @@ var SupabaseOrgStore = class {
3665
3701
  permissions: [...DEFAULT_ORG_PERMISSIONS[role]],
3666
3702
  ...stampUpdate(ctx)
3667
3703
  };
3668
- const { data, error } = await this.clients.forRequest(ctx).from("org_members").update(row).eq("org_id", orgId).eq("user_id", userId).is("deleted_at", null).select("user_id");
3704
+ const { data, error } = await this.clients.serviceClient.from("org_members").update(row).eq("org_id", orgId).eq("user_id", userId).is("deleted_at", null).select("user_id");
3669
3705
  if (error) throw mapPostgrestError(error);
3670
3706
  if (!data || data.length === 0) throw new ProviderError(`Org member '${userId}' not found`, 404);
3671
3707
  await this.events.emit({
@@ -3681,7 +3717,7 @@ var SupabaseOrgStore = class {
3681
3717
  permissions: [...permissions],
3682
3718
  ...stampUpdate(ctx)
3683
3719
  };
3684
- const { data, error } = await this.clients.forRequest(ctx).from("org_members").update(row).eq("org_id", orgId).eq("user_id", userId).is("deleted_at", null).select("user_id");
3720
+ const { data, error } = await this.clients.serviceClient.from("org_members").update(row).eq("org_id", orgId).eq("user_id", userId).is("deleted_at", null).select("user_id");
3685
3721
  if (error) throw mapPostgrestError(error);
3686
3722
  if (!data || data.length === 0) throw new ProviderError(`Org member '${userId}' not found`, 404);
3687
3723
  await this.events.emit({
@@ -3693,10 +3729,16 @@ var SupabaseOrgStore = class {
3693
3729
  });
3694
3730
  }
3695
3731
  async removeOrgMember(ctx, orgId, userId) {
3696
- const { error } = await this.clients.forRequest(ctx).rpc("remove_org_member", {
3732
+ const svc = this.clients.serviceClient;
3733
+ let { error } = await svc.rpc("remove_org_member", {
3697
3734
  o: orgId,
3698
- u: userId
3735
+ u: userId,
3736
+ actor: ctx.userId || null
3699
3737
  });
3738
+ if (error?.code === "PGRST202") ({error} = await svc.rpc("remove_org_member", {
3739
+ o: orgId,
3740
+ u: userId
3741
+ }));
3700
3742
  if (error) throw mapPostgrestError(error);
3701
3743
  await this.events.emit({
3702
3744
  type: "org_member.removed",
@@ -3796,7 +3838,7 @@ var SupabaseProjectStore = class {
3796
3838
  return data ? rowToProject(data) : null;
3797
3839
  }
3798
3840
  async createProject(ctx, project) {
3799
- const client = this.clients.forRequest(ctx);
3841
+ const client = this.clients.serviceClient;
3800
3842
  const { error } = await client.from("projects").insert(projectToRow(project));
3801
3843
  if (error) throw mapPostgrestError(error);
3802
3844
  const { error: memberError } = await client.from("project_members").upsert({
@@ -3823,12 +3865,12 @@ var SupabaseProjectStore = class {
3823
3865
  if (patch.autoJoinOnUpload !== void 0) row.auto_join_on_upload = patch.autoJoinOnUpload;
3824
3866
  if (Object.keys(row).length === 0) return;
3825
3867
  Object.assign(row, stampUpdate(ctx));
3826
- const { data, error } = await this.clients.forRequest(ctx).from("projects").update(row).eq("id", id).is("deleted_at", null).select("id");
3868
+ const { data, error } = await this.clients.serviceClient.from("projects").update(row).eq("id", id).is("deleted_at", null).select("id");
3827
3869
  if (error) throw mapPostgrestError(error);
3828
3870
  if (!data || data.length === 0) throw new ProviderError(`Project '${id}' not found`, 404);
3829
3871
  }
3830
3872
  async deleteProject(ctx, id) {
3831
- const client = this.clients.forRequest(ctx);
3873
+ const client = this.clients.serviceClient;
3832
3874
  const stampRow = stampSoftDelete(ctx);
3833
3875
  const { data, error } = await client.from("projects").update(stampRow).eq("id", id).is("deleted_at", null).select("id");
3834
3876
  if (error) throw mapPostgrestError(error);
@@ -3849,7 +3891,7 @@ var SupabaseProjectStore = class {
3849
3891
  });
3850
3892
  }
3851
3893
  async reactivateProject(ctx, orgId, slug) {
3852
- const client = this.clients.forRequest(ctx);
3894
+ const client = this.clients.serviceClient;
3853
3895
  const { data, error } = await client.from("projects").update({ deleted_at: null }).eq("org_id", orgId).eq("slug", slug).not("deleted_at", "is", null).select(PROJECT_COLUMNS).maybeSingle();
3854
3896
  if (error) throw mapPostgrestError(error);
3855
3897
  if (!data) return null;
@@ -3895,7 +3937,7 @@ var SupabaseProjectStore = class {
3895
3937
  deleted_at: null,
3896
3938
  ...stampUpdate(ctx)
3897
3939
  };
3898
- const { error } = await this.clients.forRequest(ctx).from("project_members").upsert(row, { onConflict: "project_id,user_id" });
3940
+ const { error } = await this.clients.serviceClient.from("project_members").upsert(row, { onConflict: "project_id,user_id" });
3899
3941
  if (error) throw mapPostgrestError(error);
3900
3942
  await this.events.emit({
3901
3943
  type: "project_member.added",
@@ -3909,7 +3951,7 @@ var SupabaseProjectStore = class {
3909
3951
  role,
3910
3952
  ...stampUpdate(ctx)
3911
3953
  };
3912
- const { data, error } = await this.clients.forRequest(ctx).from("project_members").update(row).eq("project_id", projectId).eq("user_id", userId).is("deleted_at", null).select("user_id");
3954
+ const { data, error } = await this.clients.serviceClient.from("project_members").update(row).eq("project_id", projectId).eq("user_id", userId).is("deleted_at", null).select("user_id");
3913
3955
  if (error) throw mapPostgrestError(error);
3914
3956
  if (!data || data.length === 0) throw new ProviderError(`Project member '${userId}' not found`, 404);
3915
3957
  await this.events.emit({
@@ -3921,7 +3963,7 @@ var SupabaseProjectStore = class {
3921
3963
  });
3922
3964
  }
3923
3965
  async removeProjectMember(ctx, projectId, userId) {
3924
- const { error } = await this.clients.forRequest(ctx).from("project_members").update(stampSoftDelete(ctx)).eq("project_id", projectId).eq("user_id", userId).is("deleted_at", null);
3966
+ const { error } = await this.clients.serviceClient.from("project_members").update(stampSoftDelete(ctx)).eq("project_id", projectId).eq("user_id", userId).is("deleted_at", null);
3925
3967
  if (error) throw mapPostgrestError(error);
3926
3968
  await this.events.emit({
3927
3969
  type: "project_member.removed",
@@ -4073,7 +4115,7 @@ var SupabaseDefinitionStore = class {
4073
4115
  return found;
4074
4116
  }
4075
4117
  async create(ctx, record) {
4076
- const { error } = await this.clients.forRequest(ctx).from("definitions").insert(recordToRow(record));
4118
+ const { error } = await this.clients.serviceClient.from("definitions").insert(recordToRow(record));
4077
4119
  if (error) throw mapPostgrestError(error);
4078
4120
  await this.events.emit({
4079
4121
  type: "definition.created",
@@ -4086,12 +4128,12 @@ var SupabaseDefinitionStore = class {
4086
4128
  const row = patchToRow(patch);
4087
4129
  if (Object.keys(row).length === 0) return;
4088
4130
  Object.assign(row, stampUpdate(ctx));
4089
- const { data, error } = await this.clients.forRequest(ctx).from("definitions").update(row).eq("guid", guid).is("deleted_at", null).select("guid");
4131
+ const { data, error } = await this.clients.serviceClient.from("definitions").update(row).eq("guid", guid).is("deleted_at", null).select("guid");
4090
4132
  if (error) throw mapPostgrestError(error);
4091
4133
  if (!data || data.length === 0) throw new ProviderError(`Definition '${guid}' not found`, 404);
4092
4134
  }
4093
4135
  async delete(ctx, guid) {
4094
- const { data, error } = await this.clients.forRequest(ctx).from("definitions").update(stampSoftDelete(ctx)).eq("guid", guid).is("deleted_at", null).select("guid");
4136
+ const { data, error } = await this.clients.serviceClient.from("definitions").update(stampSoftDelete(ctx)).eq("guid", guid).is("deleted_at", null).select("guid");
4095
4137
  if (error) throw mapPostgrestError(error);
4096
4138
  if (!data || data.length === 0) return;
4097
4139
  await this.events.emit({
@@ -4101,7 +4143,7 @@ var SupabaseDefinitionStore = class {
4101
4143
  });
4102
4144
  }
4103
4145
  async deleteByProject(ctx, projectId) {
4104
- const { data, error } = await this.clients.forRequest(ctx).from("definitions").update(stampSoftDelete(ctx)).eq("project_id", projectId).is("deleted_at", null).select("guid");
4146
+ const { data, error } = await this.clients.serviceClient.from("definitions").update(stampSoftDelete(ctx)).eq("project_id", projectId).is("deleted_at", null).select("guid");
4105
4147
  if (error) throw mapPostgrestError(error);
4106
4148
  for (const row of data ?? []) await this.events.emit({
4107
4149
  type: "definition.deleted",
@@ -4110,17 +4152,17 @@ var SupabaseDefinitionStore = class {
4110
4152
  });
4111
4153
  }
4112
4154
  async incrementSolveCount(ctx, guid) {
4113
- const { error } = await this.clients.forRequest(ctx).rpc("increment_run_count", { g: guid });
4155
+ const { error } = await this.clients.serviceClient.rpc("increment_run_count", { g: guid });
4114
4156
  if (error) throw mapPostgrestError(error);
4115
4157
  }
4116
4158
  async reserveNextVersionNumber(ctx, guid) {
4117
- const { data, error } = await this.clients.forRequest(ctx).rpc("reserve_next_version_number", { g: guid });
4159
+ const { data, error } = await this.clients.serviceClient.rpc("reserve_next_version_number", { g: guid });
4118
4160
  if (error) throw mapPostgrestError(error);
4119
4161
  if (typeof data !== "number") throw new ProviderError(`Definition '${guid}' not found`, 404);
4120
4162
  return data;
4121
4163
  }
4122
4164
  async createVersion(ctx, version) {
4123
- const { error } = await this.clients.forRequest(ctx).from("definition_versions").insert(versionToRow(version));
4165
+ const { error } = await this.clients.serviceClient.from("definition_versions").insert(versionToRow(version));
4124
4166
  if (error) throw mapPostgrestError(error);
4125
4167
  await this.events.emit({
4126
4168
  type: "definition_version.created",
@@ -4156,14 +4198,14 @@ var SupabaseDefinitionStore = class {
4156
4198
  return data ? rowToVersion(data) : null;
4157
4199
  }
4158
4200
  async setVersionSchema(ctx, versionId, schema) {
4159
- const { error } = await this.clients.forRequest(ctx).from("definition_versions").update({
4201
+ const { error } = await this.clients.serviceClient.from("definition_versions").update({
4160
4202
  schema,
4161
4203
  schema_extracted_at: (/* @__PURE__ */ new Date()).toISOString()
4162
4204
  }).eq("id", versionId);
4163
4205
  if (error) throw mapPostgrestError(error);
4164
4206
  }
4165
4207
  async deleteVersion(ctx, versionId) {
4166
- const { error } = await this.clients.forRequest(ctx).from("definition_versions").delete().eq("id", versionId);
4208
+ const { error } = await this.clients.serviceClient.from("definition_versions").delete().eq("id", versionId);
4167
4209
  if (error) throw mapPostgrestError(error);
4168
4210
  await this.events.emit({
4169
4211
  type: "definition_version.deleted",
@@ -4184,7 +4226,7 @@ var SupabaseDefinitionStore = class {
4184
4226
  await this.repointChannel(ctx, definitionId, versionId, "draft_version_id");
4185
4227
  }
4186
4228
  async attachInitialVersion(ctx, definitionId, versionId) {
4187
- const client = this.clients.forRequest(ctx);
4229
+ const client = this.clients.serviceClient;
4188
4230
  const { data: version, error: vError } = await client.from("definition_versions").select("id, definition_guid").eq("id", versionId).maybeSingle();
4189
4231
  if (vError) throw mapPostgrestError(vError);
4190
4232
  if (!version || version.definition_guid !== definitionId) throw new ProviderError(`Version '${versionId}' not found for this definition`, 404);
@@ -4199,7 +4241,7 @@ var SupabaseDefinitionStore = class {
4199
4241
  if (!data || data.length === 0) throw new ProviderError(`Definition '${definitionId}' not found`, 404);
4200
4242
  }
4201
4243
  async repointChannel(ctx, definitionId, versionId, column) {
4202
- const client = this.clients.forRequest(ctx);
4244
+ const client = this.clients.serviceClient;
4203
4245
  const { data: version, error: vError } = await client.from("definition_versions").select("id, definition_guid").eq("id", versionId).maybeSingle();
4204
4246
  if (vError) throw mapPostgrestError(vError);
4205
4247
  if (!version || version.definition_guid !== definitionId) throw new ProviderError(`Version '${versionId}' not found for this definition`, 404);
@@ -4326,8 +4368,8 @@ var INVITE_COLUMNS = "id, token_hash, email, org_id, org_role, org_permissions,
4326
4368
  * unauthenticated caller (still validating an invite link) can resolve it
4327
4369
  * without RLS blocking them. The raw token is hashed at the route layer
4328
4370
  * (`invites/token.server.ts` in the selva app); this store only ever sees the
4329
- * HMAC digest. Other operations go through the normal REST API, with RLS
4330
- * enforcing `manage_org_members`.
4371
+ * HMAC digest. Reads run as the caller, where RLS asks for `manage_org_members`;
4372
+ * writes run as the service role.
4331
4373
  */
4332
4374
  var SupabaseInviteStore = class {
4333
4375
  clients;
@@ -4337,7 +4379,7 @@ var SupabaseInviteStore = class {
4337
4379
  this.events = events;
4338
4380
  }
4339
4381
  async create(ctx, invite) {
4340
- const { error } = await this.clients.forRequest(ctx).from("invites").insert(inviteToRow(invite));
4382
+ const { error } = await this.clients.serviceClient.from("invites").insert(inviteToRow(invite));
4341
4383
  if (error) throw mapPostgrestError(error);
4342
4384
  await this.events.emit({
4343
4385
  type: "invite.created",
@@ -4365,7 +4407,7 @@ var SupabaseInviteStore = class {
4365
4407
  }
4366
4408
  async markAccepted(ctx, id, userId) {
4367
4409
  const now = (/* @__PURE__ */ new Date()).toISOString();
4368
- const { data, error } = await this.clients.forRequest(ctx).from("invites").update({
4410
+ const { data, error } = await this.clients.serviceClient.from("invites").update({
4369
4411
  accepted_at: now,
4370
4412
  accepted_by_user_id: userId
4371
4413
  }).eq("id", id).is("accepted_at", null).gt("expires_at", now).select("org_id");
@@ -4382,7 +4424,7 @@ var SupabaseInviteStore = class {
4382
4424
  return true;
4383
4425
  }
4384
4426
  async reopen(ctx, id, userId) {
4385
- const { data, error } = await this.clients.forRequest(ctx).from("invites").update({
4427
+ const { data, error } = await this.clients.serviceClient.from("invites").update({
4386
4428
  accepted_at: null,
4387
4429
  accepted_by_user_id: null
4388
4430
  }).eq("id", id).eq("accepted_by_user_id", userId).select("id");
@@ -4390,7 +4432,7 @@ var SupabaseInviteStore = class {
4390
4432
  return (data?.length ?? 0) > 0;
4391
4433
  }
4392
4434
  async revoke(ctx, id) {
4393
- const { data, error } = await this.clients.forRequest(ctx).from("invites").delete().eq("id", id).is("accepted_at", null).select("org_id");
4435
+ const { data, error } = await this.clients.serviceClient.from("invites").delete().eq("id", id).is("accepted_at", null).select("org_id");
4394
4436
  if (error) throw mapPostgrestError(error);
4395
4437
  const row = data?.[0];
4396
4438
  if (!row) return;
@@ -4402,7 +4444,7 @@ var SupabaseInviteStore = class {
4402
4444
  });
4403
4445
  }
4404
4446
  async revokePendingByEmail(ctx, orgId, email) {
4405
- const { data, error } = await this.clients.forRequest(ctx).from("invites").delete().eq("org_id", orgId).eq("email", email.trim().toLowerCase()).is("accepted_at", null).select("id");
4447
+ const { data, error } = await this.clients.serviceClient.from("invites").delete().eq("org_id", orgId).eq("email", email.trim().toLowerCase()).is("accepted_at", null).select("id");
4406
4448
  if (error) throw mapPostgrestError(error);
4407
4449
  const ids = (data ?? []).map((r) => r.id);
4408
4450
  for (const id of ids) await this.events.emit({
@@ -4414,7 +4456,7 @@ var SupabaseInviteStore = class {
4414
4456
  return ids;
4415
4457
  }
4416
4458
  async deleteByOrg(ctx, orgId) {
4417
- const { error } = await this.clients.forRequest(ctx).from("invites").delete().eq("org_id", orgId);
4459
+ const { error } = await this.clients.serviceClient.from("invites").delete().eq("org_id", orgId);
4418
4460
  if (error) throw mapPostgrestError(error);
4419
4461
  }
4420
4462
  };
@@ -4551,7 +4593,7 @@ var SupabaseComputeServerStore = class {
4551
4593
  server_id: s.id,
4552
4594
  org_id: orgId
4553
4595
  })));
4554
- const { error } = await this.clients.forRequest(ctx).rpc("save_platform_compute_servers", {
4596
+ const { error } = await this.clients.serviceClient.rpc("save_platform_compute_servers", {
4555
4597
  servers: platformOnly.map((s) => serverToRow(this.encryptServerApiKey(s))),
4556
4598
  shares,
4557
4599
  default_server: defaultServerId ?? null
@@ -4563,7 +4605,7 @@ var SupabaseComputeServerStore = class {
4563
4605
  ...s,
4564
4606
  ownerOrgId: orgId
4565
4607
  }));
4566
- const { error } = await this.clients.forRequest(ctx).rpc("save_org_compute_servers", {
4608
+ const { error } = await this.clients.serviceClient.rpc("save_org_compute_servers", {
4567
4609
  o: orgId,
4568
4610
  servers: orgOnly.map((s) => serverToRow(this.encryptServerApiKey(s))),
4569
4611
  set_default: defaultServerId !== void 0,
@@ -4572,7 +4614,7 @@ var SupabaseComputeServerStore = class {
4572
4614
  if (error) throw mapPostgrestError(error);
4573
4615
  }
4574
4616
  async setOrgDefault(ctx, orgId, serverId) {
4575
- const client = this.clients.forRequest(ctx);
4617
+ const client = this.clients.serviceClient;
4576
4618
  if (serverId === null) {
4577
4619
  const { error } = await client.from("compute_server_org_defaults").delete().eq("org_id", orgId);
4578
4620
  if (error) throw mapPostgrestError(error);
@@ -4585,7 +4627,7 @@ var SupabaseComputeServerStore = class {
4585
4627
  if (error) throw mapPostgrestError(error);
4586
4628
  }
4587
4629
  async deleteByOrg(ctx, orgId) {
4588
- const client = this.clients.forRequest(ctx);
4630
+ const client = this.clients.serviceClient;
4589
4631
  const { error: defErr } = await client.from("compute_server_org_defaults").delete().eq("org_id", orgId);
4590
4632
  if (defErr) throw mapPostgrestError(defErr);
4591
4633
  const { error: srvErr } = await client.from("compute_servers").delete().eq("scope", "org").eq("owner_org_id", orgId);
@@ -4619,6 +4661,17 @@ var SupabaseComputeServerStore = class {
4619
4661
  */
4620
4662
  decryptRowApiKey(row) {
4621
4663
  if (!row.api_key) return row;
4664
+ if (isUnknownEnvelope(row.api_key)) {
4665
+ this.logger.warn(`Could not read api_key: it is sealed as ${row.api_key.slice(0, 6)}, a format this Selva version does not know. A newer version wrote it. This server is returned without an apiKey and solves against it will fail. Upgrade Selva again, or re-enter the key via /admin/compute`, {
4666
+ component: "selva",
4667
+ serverLabel: row.label,
4668
+ serverId: row.id
4669
+ });
4670
+ return {
4671
+ ...row,
4672
+ api_key: null
4673
+ };
4674
+ }
4622
4675
  if (!isEncryptedSecret(row.api_key)) {
4623
4676
  this.logger.warn("Compute server row has a plaintext api_key; re-save it via /admin/compute so it is stored encrypted", {
4624
4677
  component: "selva",
@@ -4672,6 +4725,14 @@ var SupabaseComputeServerStore = class {
4672
4725
  for (const row of data ?? []) {
4673
4726
  const { api_key: apiKey, id, label } = row;
4674
4727
  if (!apiKey) continue;
4728
+ if (isUnknownEnvelope(apiKey)) {
4729
+ failures.push({
4730
+ serverId: id,
4731
+ serverLabel: label,
4732
+ reason: "unknown_envelope"
4733
+ });
4734
+ continue;
4735
+ }
4675
4736
  if (!isEncryptedSecret(apiKey)) {
4676
4737
  plaintextFound = true;
4677
4738
  failures.push({
@@ -4804,7 +4865,7 @@ var SupabaseShareLinkStore = class {
4804
4865
  this.events = events;
4805
4866
  }
4806
4867
  async create(ctx, link) {
4807
- const { error } = await this.clients.forRequest(ctx).from("share_links").insert(linkToRow(link));
4868
+ const { error } = await this.clients.serviceClient.from("share_links").insert(linkToRow(link));
4808
4869
  if (error) throw mapPostgrestError(error);
4809
4870
  await this.events.emit({
4810
4871
  type: "share_link.minted",
@@ -4849,15 +4910,14 @@ var SupabaseShareLinkStore = class {
4849
4910
  return data ? rowToLink(data) : null;
4850
4911
  }
4851
4912
  async revoke(ctx, id) {
4852
- const client = this.clients.forRequest(ctx);
4913
+ const client = this.clients.serviceClient;
4853
4914
  const { data, error } = await client.from("share_links").update({ revoked_at: (/* @__PURE__ */ new Date()).toISOString() }).eq("id", id).is("revoked_at", null).select("id");
4854
4915
  if (error) throw mapPostgrestError(error);
4855
4916
  if (!data || data.length === 0) {
4856
4917
  const { data: existing, error: readError } = await client.from("share_links").select("revoked_at").eq("id", id).maybeSingle();
4857
4918
  if (readError) throw mapPostgrestError(readError);
4858
4919
  if (!existing) throw new ProviderError(`Share link '${id}' not found`, 404);
4859
- if (existing.revoked_at) return;
4860
- throw new ProviderError(`Forbidden: cannot revoke share link '${id}'`, 403);
4920
+ return;
4861
4921
  }
4862
4922
  await this.events.emit({
4863
4923
  type: "share_link.revoked",
@@ -4929,7 +4989,7 @@ var SupabaseApiTokenStore = class {
4929
4989
  this.events = events;
4930
4990
  }
4931
4991
  async create(ctx, token) {
4932
- const { error } = await this.clients.forRequest(ctx).from("api_tokens").insert(tokenToRow(token));
4992
+ const { error } = await this.clients.serviceClient.from("api_tokens").insert(tokenToRow(token));
4933
4993
  if (error) throw mapPostgrestError(error);
4934
4994
  await this.events.emit({
4935
4995
  type: "api_token.created",
@@ -4962,12 +5022,12 @@ var SupabaseApiTokenStore = class {
4962
5022
  };
4963
5023
  }
4964
5024
  async revoke(ctx, id, reason) {
4965
- const { data, error } = await this.clients.forRequest(ctx).from("api_tokens").update({ revoked_at: (/* @__PURE__ */ new Date()).toISOString() }).eq("id", id).is("revoked_at", null).select("id, org_id");
5025
+ const { data, error } = await this.clients.serviceClient.from("api_tokens").update({ revoked_at: (/* @__PURE__ */ new Date()).toISOString() }).eq("id", id).is("revoked_at", null).select("id, org_id");
4966
5026
  if (error) throw mapPostgrestError(error);
4967
5027
  for (const row of data ?? []) await this.emitRevoked(ctx, row, reason);
4968
5028
  }
4969
5029
  async revokeAllForUser(ctx, userId, opts) {
4970
- let query = this.clients.forRequest(ctx).from("api_tokens").update({ revoked_at: (/* @__PURE__ */ new Date()).toISOString() }).eq("user_id", userId).is("revoked_at", null);
5030
+ let query = this.clients.serviceClient.from("api_tokens").update({ revoked_at: (/* @__PURE__ */ new Date()).toISOString() }).eq("user_id", userId).is("revoked_at", null);
4971
5031
  if (opts.orgId) query = query.eq("org_id", opts.orgId);
4972
5032
  const { data, error } = await query.select("id, org_id");
4973
5033
  if (error) throw mapPostgrestError(error);
@@ -4976,7 +5036,7 @@ var SupabaseApiTokenStore = class {
4976
5036
  return rows.map((r) => r.id);
4977
5037
  }
4978
5038
  async touchLastUsed(ctx, id, at) {
4979
- const { error } = await this.clients.forRequest(ctx).from("api_tokens").update({ last_used_at: at }).eq("id", id);
5039
+ const { error } = await this.clients.serviceClient.from("api_tokens").update({ last_used_at: at }).eq("id", id);
4980
5040
  if (error) throw mapPostgrestError(error);
4981
5041
  }
4982
5042
  /**
@@ -4991,7 +5051,7 @@ var SupabaseApiTokenStore = class {
4991
5051
  if (cleared.error) throw mapPostgrestError(cleared.error);
4992
5052
  }
4993
5053
  async deleteByOrg(ctx, orgId) {
4994
- const { error } = await this.clients.forRequest(ctx).from("api_tokens").delete().eq("org_id", orgId);
5054
+ const { error } = await this.clients.serviceClient.from("api_tokens").delete().eq("org_id", orgId);
4995
5055
  if (error) throw mapPostgrestError(error);
4996
5056
  }
4997
5057
  emitRevoked(ctx, row, reason) {
@@ -5045,7 +5105,15 @@ function tokenToRow(t) {
5045
5105
  * whenever a migration is added — `migration-head.test.ts` asserts it
5046
5106
  * matches the migrations directory, so CI catches drift.
5047
5107
  */
5048
- var EXPECTED_MIGRATION_HEAD = "20261108140000";
5108
+ var EXPECTED_MIGRATION_HEAD = "20261113130000";
5109
+ /**
5110
+ * The oldest head this build runs on; the handshake fails below it. Behind
5111
+ * {@link EXPECTED_MIGRATION_HEAD} only while a migration has to land after the
5112
+ * app: `20261113120000` takes every write away from sessions, which an older
5113
+ * build still writes with, so the app updates first and `db push` follows.
5114
+ * Raise it to the newest head once nothing needs that order.
5115
+ */
5116
+ var REQUIRED_MIGRATION_HEAD = "20261108140000";
5049
5117
  // ../providers/supabase/src/data/client.ts
5050
5118
  /** Default schema every engine store targets. */
5051
5119
  var DEFAULT_SCHEMA = "selva";
@@ -5625,8 +5693,10 @@ var SupabaseDataProvider = class SupabaseDataProvider {
5625
5693
  * package's migrations) and compares it to the head this build expects.
5626
5694
  * Three failure shapes: the RPC is missing (handshake migration never
5627
5695
  * applied), the head is empty (no migrations pushed), or the head is
5628
- * lexicographically behind (operator upgraded the app but skipped
5629
- * `supabase db push`). Never throws — boot health consumes the report.
5696
+ * lexicographically behind {@link REQUIRED_MIGRATION_HEAD} (operator upgraded
5697
+ * the app but skipped `supabase db push`). A head between that and the newest
5698
+ * is ok, with a message naming what is pending. Never throws — boot health
5699
+ * consumes the report.
5630
5700
  */
5631
5701
  async verifySchemaVersion() {
5632
5702
  const expected = EXPECTED_MIGRATION_HEAD;
@@ -5646,12 +5716,17 @@ var SupabaseDataProvider = class SupabaseDataProvider {
5646
5716
  actual: "",
5647
5717
  message: `The database reports no applied migrations. ${pushHint}`
5648
5718
  };
5649
- const ok = actual >= expected;
5719
+ if (actual < "20261108140000") return {
5720
+ ok: false,
5721
+ expected,
5722
+ actual,
5723
+ message: `Database migration head ${actual} is behind ${REQUIRED_MIGRATION_HEAD}, the oldest this app runs on. ${pushHint}`
5724
+ };
5650
5725
  return {
5651
- ok,
5726
+ ok: true,
5652
5727
  expected,
5653
5728
  actual,
5654
- message: ok ? void 0 : `Database migration head ${actual} is behind the app's expected ${expected}. ${pushHint}`
5729
+ message: actual < expected ? `Migrations after ${actual} are pending; the app runs without them. ${pushHint}` : void 0
5655
5730
  };
5656
5731
  } catch (err) {
5657
5732
  return {
@@ -5997,6 +6072,13 @@ var SupabaseAuthProvider = class SupabaseAuthProvider {
5997
6072
  * on its own schedule.
5998
6073
  */
5999
6074
  lastRevalidatedAt = /* @__PURE__ */ new Map();
6075
+ /**
6076
+ * When this process ended a user's sessions (sign-out, disable, delete), by
6077
+ * user id. A session last rechecked before that moment is rechecked on its
6078
+ * next request instead of riding out the window. Other instances still take
6079
+ * up to `revalidateMs`.
6080
+ */
6081
+ sessionsEndedAt = /* @__PURE__ */ new Map();
6000
6082
  constructor(config) {
6001
6083
  this.supabaseUrl = config.supabaseUrl;
6002
6084
  this.anonKey = config.anonKey;
@@ -6019,7 +6101,10 @@ var SupabaseAuthProvider = class SupabaseAuthProvider {
6019
6101
  autoRefreshToken: false
6020
6102
  } });
6021
6103
  this.passwordAuth = new SupabasePasswordAuth(this.admin, this.anon, (email, password) => this.signIn(email, password), config.enableSelfSignup ?? false, (user) => this.hydrate(user));
6022
- this.sessionRefresh = new SupabaseSessionRefresh(this.anon, this.admin, this.logger);
6104
+ this.sessionRefresh = new SupabaseSessionRefresh(this.anon, this.admin, this.logger, (token) => {
6105
+ const userId = unverifiedSubject(token);
6106
+ if (userId) this.markSessionsEnded(userId);
6107
+ });
6023
6108
  this.oauth = new SupabaseOAuthAuth(this.anon, (user) => this.hydrate(user), config.oauthProviders ?? []);
6024
6109
  this.emailLink = new SupabaseEmailLinkAuth(this.anon, (user) => this.hydrate(user), config.allowEmailLinkSignup ?? true);
6025
6110
  this.delegatedSession = new SupabaseDelegatedSession({
@@ -6074,13 +6159,14 @@ var SupabaseAuthProvider = class SupabaseAuthProvider {
6074
6159
  if (!claims) return null;
6075
6160
  if (claims.app_metadata?.disabled === true) return null;
6076
6161
  const sessionId = typeof claims.session_id === "string" ? claims.session_id : claims.sub;
6077
- if (this.shouldRevalidate(sessionId)) {
6162
+ if (this.shouldRevalidate(sessionId, claims.sub)) {
6163
+ const startedAt = Date.now();
6078
6164
  const fresh = await this.verifyViaGetUser(token);
6079
6165
  if (!fresh) {
6080
6166
  this.lastRevalidatedAt.delete(sessionId);
6081
6167
  return null;
6082
6168
  }
6083
- this.markRevalidated(sessionId);
6169
+ this.markRevalidated(sessionId, startedAt);
6084
6170
  return fresh;
6085
6171
  }
6086
6172
  return {
@@ -6107,13 +6193,20 @@ var SupabaseAuthProvider = class SupabaseAuthProvider {
6107
6193
  return null;
6108
6194
  }
6109
6195
  }
6110
- shouldRevalidate(sessionId) {
6196
+ shouldRevalidate(sessionId, userId) {
6111
6197
  const last = this.lastRevalidatedAt.get(sessionId);
6112
- return last === void 0 || Date.now() - last >= this.revalidateMs;
6198
+ if (last === void 0 || Date.now() - last >= this.revalidateMs) return true;
6199
+ const ended = this.sessionsEndedAt.get(userId);
6200
+ return ended !== void 0 && last <= ended;
6201
+ }
6202
+ markSessionsEnded(userId) {
6203
+ const now = Date.now();
6204
+ for (const [id, at] of this.sessionsEndedAt) if (now - at > this.revalidateMs) this.sessionsEndedAt.delete(id);
6205
+ this.sessionsEndedAt.set(userId, now);
6113
6206
  }
6114
- markRevalidated(sessionId) {
6207
+ markRevalidated(sessionId, at) {
6115
6208
  const now = Date.now();
6116
- this.lastRevalidatedAt.set(sessionId, now);
6209
+ this.lastRevalidatedAt.set(sessionId, at);
6117
6210
  if (this.lastRevalidatedAt.size > 1e4) {
6118
6211
  const cutoff = now - this.revalidateMs * 2;
6119
6212
  for (const [id, ts] of this.lastRevalidatedAt) if (ts < cutoff) this.lastRevalidatedAt.delete(id);
@@ -6155,6 +6248,7 @@ var SupabaseAuthProvider = class SupabaseAuthProvider {
6155
6248
  if (e.status === 404 || /not.?found/i.test(e.message ?? "")) return "not_found";
6156
6249
  throw error;
6157
6250
  }
6251
+ this.markSessionsEnded(id);
6158
6252
  return "ok";
6159
6253
  }
6160
6254
  async disableUser(id) {
@@ -6172,6 +6266,7 @@ var SupabaseAuthProvider = class SupabaseAuthProvider {
6172
6266
  if (e.status === 404 || /not.?found/i.test(e.message ?? "")) return "not_found";
6173
6267
  throw error;
6174
6268
  }
6269
+ this.markSessionsEnded(id);
6175
6270
  return "ok";
6176
6271
  }
6177
6272
  async touchLastLogin(id) {
@@ -6313,6 +6408,15 @@ function isDisabled(user) {
6313
6408
  if (user.app_metadata?.disabled === true) return true;
6314
6409
  return user.banned_until ? Date.parse(user.banned_until) > Date.now() : false;
6315
6410
  }
6411
+ /** The `sub` of a JWT, unverified: only ever used to force a recheck, never to trust. */
6412
+ function unverifiedSubject(token) {
6413
+ try {
6414
+ const payload = JSON.parse(Buffer.from(token.split(".")[1] ?? "", "base64url").toString());
6415
+ return typeof payload?.sub === "string" ? payload.sub : null;
6416
+ } catch {
6417
+ return null;
6418
+ }
6419
+ }
6316
6420
  /**
6317
6421
  * Supabase-backed `ISessionRefresh`. `refreshSession` uses the anon client —
6318
6422
  * a refresh token authenticates itself. `revokeSession` uses the service-role
@@ -6322,10 +6426,12 @@ var SupabaseSessionRefresh = class {
6322
6426
  anon;
6323
6427
  admin;
6324
6428
  logger;
6325
- constructor(anon, admin, logger) {
6429
+ onRevoked;
6430
+ constructor(anon, admin, logger, onRevoked) {
6326
6431
  this.anon = anon;
6327
6432
  this.admin = admin;
6328
6433
  this.logger = logger;
6434
+ this.onRevoked = onRevoked;
6329
6435
  }
6330
6436
  async refreshSession(refreshToken) {
6331
6437
  const { data, error } = await this.anon.auth.refreshSession({ refresh_token: refreshToken });
@@ -6338,6 +6444,7 @@ var SupabaseSessionRefresh = class {
6338
6444
  }
6339
6445
  async revokeSession(token) {
6340
6446
  const { error } = await this.admin.auth.admin.signOut(token, "global");
6447
+ this.onRevoked(token);
6341
6448
  if (!error) return true;
6342
6449
  const e = error;
6343
6450
  if (e.status === 401 || e.status === 403 || e.status === 404) return true;
@@ -33909,6 +34016,40 @@ var unlimitedFetch = ((input, init) => (0, import_undici.fetch)(input, {
33909
34016
  function fetchForDeadline(deadlineMs) {
33910
34017
  return deadlineMs >= UNDICI_DEFAULT_LIMIT_MS ? unlimitedFetch : void 0;
33911
34018
  }
34019
+ /**
34020
+ * False for a header carrying only the proxy's `affinity`, from a child that sends no timing:
34021
+ * read as zeros, it would put the whole solve on `compute_link`.
34022
+ */
34023
+ function reportsTiming(rhino) {
34024
+ return rhino.cacheHit === true || rhino.decode !== void 0 || rhino.solve !== void 0 || rhino.encode !== void 0;
34025
+ }
34026
+ /**
34027
+ * `total` is the server's headers-to-out wall time, so browser `ttfb − total`
34028
+ * ≈ network+send latency. When the compute server reports its own timing
34029
+ * (VektorNode fork), `rhino_*` is time on the compute server and `compute_link`
34030
+ * is everything between it (network + queue wait). `rhino_cache` is 1 when the
34031
+ * compute server answered from its own result cache.
34032
+ */
34033
+ function buildServerTiming(parts) {
34034
+ let header = `load;dur=${parts.defLoadMs.toFixed(1)}, tree;dur=${parts.treeBuildMs.toFixed(1)}, solve;dur=${parts.solveMs.toFixed(1)}, serialize;dur=${parts.serializeMs.toFixed(1)}, gzip;dur=${parts.gzipMs.toFixed(1)}, total;dur=${parts.serverTotalMs.toFixed(1)}`;
34035
+ const rhino = parts.rhino;
34036
+ if (rhino && reportsTiming(rhino)) {
34037
+ const decode = rhino.decode ?? 0;
34038
+ const solve = rhino.solve ?? 0;
34039
+ const encode = rhino.encode ?? 0;
34040
+ const computeLinkMs = Math.max(0, parts.solveMs - decode - solve - encode);
34041
+ header += `, rhino_decode;dur=${decode.toFixed(1)}, rhino_solve;dur=${solve.toFixed(1)}, rhino_encode;dur=${encode.toFixed(1)}, compute_link;dur=${computeLinkMs.toFixed(1)}, rhino_cache;dur=${rhino.cacheHit ? 1 : 0}`;
34042
+ if (rhino.gh !== void 0) header += `, rhino_gh;dur=${rhino.gh.toFixed(1)}`;
34043
+ if (rhino.recomputed) header += `, rhino_recomputed;desc="${rhino.recomputed.ran}/${rhino.recomputed.total}"`;
34044
+ }
34045
+ if (rhino?.affinity) header += `, rhino_affinity;desc=${rhino.affinity}`;
34046
+ for (const [label, ms] of parts.prepMarks) header += `, p_${label};dur=${ms.toFixed(1)}`;
34047
+ const settle = parts.settle;
34048
+ header += `, selva_cache;dur=${settle.fromCache ? 1 : 0}`;
34049
+ if (settle.definitionReuploaded !== void 0) header += `, def_reupload;dur=${settle.definitionReuploaded ? 1 : 0}`;
34050
+ if (parts.defBytes) header += `, def_bytes;desc=${parts.defBytes}`;
34051
+ return header;
34052
+ }
33912
34053
  /** Rhino.Compute's own default `--timeout`, for a server that can't report its own. */
33913
34054
  var DEFAULT_SOLVE_DEADLINE_MS = 1e5;
33914
34055
  /**
@@ -33996,7 +34137,7 @@ function createClientCache(config) {
33996
34137
  draining.delete(entry);
33997
34138
  entry.scheduler.dispose();
33998
34139
  }
33999
- async function build(server, definitionGuid) {
34140
+ async function build(server) {
34000
34141
  const debugVerbose = config.debug === "verbose";
34001
34142
  const longFetch = fetchForDeadline(MAX_SOLVE_DEADLINE_MS);
34002
34143
  const clientConfig = {
@@ -34008,8 +34149,13 @@ function createClientCache(config) {
34008
34149
  ...longFetch && { fetch: longFetch }
34009
34150
  };
34010
34151
  if (config.debug) clientConfig.onServerTiming = (t) => {
34152
+ const routed = t.affinity ? ` | session ${t.affinity}` : "";
34011
34153
  if (t.cacheHit) {
34012
- debugLog("[Compute/rhino-cache] solve-cache (cachesolve): HIT (cached result, solve skipped)");
34154
+ debugLog(`[Compute/rhino-cache] solve-cache (cachesolve): HIT (cached result, solve skipped)${routed}`);
34155
+ return;
34156
+ }
34157
+ if (!reportsTiming(t)) {
34158
+ debugLog(`[Compute/rhino-cache] no solve timing${routed}`);
34013
34159
  return;
34014
34160
  }
34015
34161
  const decode = t.decode ?? 0;
@@ -34018,9 +34164,8 @@ function createClientCache(config) {
34018
34164
  const defCache = decode <= 1 ? "HIT (definition reused, no re-upload/parse)" : "miss (full parse)";
34019
34165
  const solveCache = config.cachesolve ? "miss (solved fresh)" : "off";
34020
34166
  const ran = t.recomputed ? ` | ran ${t.recomputed.ran}/${t.recomputed.total} objects` : "";
34021
- debugLog(`[Compute/rhino-cache] decode=${decode}ms solve=${solve}ms encode=${encode}ms | definition-cache: ${defCache} | solve-cache (cachesolve): ${solveCache}${ran}`);
34167
+ debugLog(`[Compute/rhino-cache] decode=${decode}ms solve=${solve}ms encode=${encode}ms | definition-cache: ${defCache} | solve-cache (cachesolve): ${solveCache}${ran}${routed}`);
34022
34168
  };
34023
- if (definitionGuid) clientConfig.headers = { "X-Selva-Definition": definitionGuid };
34024
34169
  const client = await GrasshopperClient.create(clientConfig);
34025
34170
  const probe = createConcurrencyProbe(client, debugLog);
34026
34171
  const readReported = async () => await Promise.resolve(client.serverStats?.getLimits?.()).catch(() => null) ?? null;
@@ -34087,14 +34232,14 @@ function createClientCache(config) {
34087
34232
  retire(entry);
34088
34233
  }
34089
34234
  const self = {
34090
- async getClient(server, opts) {
34235
+ async getClient(server) {
34091
34236
  const key = server.id;
34092
34237
  const existing = cache.get(key);
34093
34238
  if (existing) {
34094
34239
  cache.delete(key);
34095
34240
  cache.set(key, existing);
34096
34241
  if (!cacheEnabled || await deploymentChecks.get(existing)?.() !== false) return existing;
34097
- return self.getClient(server, opts);
34242
+ return self.getClient(server);
34098
34243
  }
34099
34244
  const inFlight = pending.get(key);
34100
34245
  if (inFlight) return inFlight.promise;
@@ -34111,7 +34256,7 @@ function createClientCache(config) {
34111
34256
  const promise = (async () => {
34112
34257
  let entry;
34113
34258
  try {
34114
- entry = await build(server, opts?.definitionGuid);
34259
+ entry = await build(server);
34115
34260
  } catch (err) {
34116
34261
  if (!token.stale) failed.set(key, {
34117
34262
  error: err,
@@ -34155,6 +34300,14 @@ function createClientCache(config) {
34155
34300
  evictEntry(id);
34156
34301
  }
34157
34302
  },
34303
+ largestReportedRequestBytes() {
34304
+ let largest = null;
34305
+ for (const { limits } of cache.values()) {
34306
+ const reported = limits.maxRequestBytes;
34307
+ if (reported !== null && (largest === null || reported > largest)) largest = reported;
34308
+ }
34309
+ return largest;
34310
+ },
34158
34311
  solveCacheStats() {
34159
34312
  const total = {
34160
34313
  warmClients: cache.size,
@@ -34432,32 +34585,6 @@ function createResponseEncoder(response, maxBytes) {
34432
34585
  };
34433
34586
  } };
34434
34587
  }
34435
- /**
34436
- * `total` is the server's headers-to-out wall time, so browser `ttfb − total`
34437
- * ≈ network+send latency. When the compute server reports its own timing
34438
- * (VektorNode fork), `rhino_*` is time on the compute server and `compute_link`
34439
- * is everything between it (network + queue wait). `rhino_cache` is 1 when the
34440
- * compute server answered from its own result cache.
34441
- */
34442
- function buildServerTiming(parts) {
34443
- let header = `load;dur=${parts.defLoadMs.toFixed(1)}, tree;dur=${parts.treeBuildMs.toFixed(1)}, solve;dur=${parts.solveMs.toFixed(1)}, serialize;dur=${parts.serializeMs.toFixed(1)}, gzip;dur=${parts.gzipMs.toFixed(1)}, total;dur=${parts.serverTotalMs.toFixed(1)}`;
34444
- const rhino = parts.rhino;
34445
- if (rhino) {
34446
- const decode = rhino.decode ?? 0;
34447
- const solve = rhino.solve ?? 0;
34448
- const encode = rhino.encode ?? 0;
34449
- const computeLinkMs = Math.max(0, parts.solveMs - decode - solve - encode);
34450
- header += `, rhino_decode;dur=${decode.toFixed(1)}, rhino_solve;dur=${solve.toFixed(1)}, rhino_encode;dur=${encode.toFixed(1)}, compute_link;dur=${computeLinkMs.toFixed(1)}, rhino_cache;dur=${rhino.cacheHit ? 1 : 0}`;
34451
- if (rhino.gh !== void 0) header += `, rhino_gh;dur=${rhino.gh.toFixed(1)}`;
34452
- if (rhino.recomputed) header += `, rhino_recomputed;desc="${rhino.recomputed.ran}/${rhino.recomputed.total}"`;
34453
- }
34454
- for (const [label, ms] of parts.prepMarks) header += `, p_${label};dur=${ms.toFixed(1)}`;
34455
- const settle = parts.settle;
34456
- header += `, selva_cache;dur=${settle.fromCache ? 1 : 0}`;
34457
- if (settle.definitionReuploaded !== void 0) header += `, def_reupload;dur=${settle.definitionReuploaded ? 1 : 0}`;
34458
- if (parts.defBytes) header += `, def_bytes;desc=${parts.defBytes}`;
34459
- return header;
34460
- }
34461
34588
  function createSolveCacheSingleFlight(options = {}) {
34462
34589
  const inflight = /* @__PURE__ */ new Map();
34463
34590
  function free(key, flight) {
@@ -34543,8 +34670,9 @@ function buildSolveInputTree(inputs, values) {
34543
34670
  }
34544
34671
  /**
34545
34672
  * Runs one solve against a warm scheduler and classifies how it ended: a solved response, or an
34546
- * expected failure as a value instead of a throw. This is the part single-flight shares, so
34547
- * nothing here depends on who is asking.
34673
+ * expected failure as a value instead of a throw. Single-flight shares this part, so its args come
34674
+ * from the caller that started the flight. Anything per caller must be in the coalesce key, or,
34675
+ * like `sessionId`, be harmless for the joiners to inherit.
34548
34676
  */
34549
34677
  function shed(durationMs, reason, message) {
34550
34678
  return {
@@ -34605,6 +34733,9 @@ async function runSolvePipeline(args) {
34605
34733
  const detail = await args.client.scheduler.solveDetailed(args.definitionSource, args.inputTree, {
34606
34734
  signal: args.signal,
34607
34735
  selvaevents: args.selvaEvents,
34736
+ sessionId: args.sessionId,
34737
+ solveMode: args.solveMode,
34738
+ headers: args.headers,
34608
34739
  onServerTiming: (t) => {
34609
34740
  rhino = t;
34610
34741
  }
@@ -34674,8 +34805,8 @@ var SolveEngine = class {
34674
34805
  this.byteCache = createDefinitionByteCache(this.limits.computeDefinitionCacheBytes);
34675
34806
  this.singleFlight = createSolveCacheSingleFlight({ onJoin: options.onSolveCoalesced });
34676
34807
  }
34677
- getClient(server, opts) {
34678
- return this.clientCache.getClient(server, opts);
34808
+ getClient(server) {
34809
+ return this.clientCache.getClient(server);
34679
34810
  }
34680
34811
  definitionRef(versionId, load) {
34681
34812
  return this.byteCache.getOrLoad(versionId, load);
@@ -34691,6 +34822,13 @@ var SolveEngine = class {
34691
34822
  this.clientCache.clearSolveCaches();
34692
34823
  }
34693
34824
  /**
34825
+ * The largest request body a warm client's server reports accepting
34826
+ * (`RHINO_COMPUTE_MAX_REQUEST_SIZE`). Null until a server that reports one has been reached.
34827
+ */
34828
+ largestReportedRequestBytes() {
34829
+ return this.clientCache.largestReportedRequestBytes();
34830
+ }
34831
+ /**
34694
34832
  * Drop every retained `.gh` byte entry. Safe at any time: entries key on an
34695
34833
  * immutable version id, so clearing costs a storage re-read and nothing else.
34696
34834
  */
@@ -34714,7 +34852,7 @@ var SolveEngine = class {
34714
34852
  };
34715
34853
  let client;
34716
34854
  try {
34717
- client = await this.clientCache.getClient(args.server, { definitionGuid: args.definitionGuid });
34855
+ client = await this.clientCache.getClient(args.server);
34718
34856
  } catch (error) {
34719
34857
  if (args.signal.aborted) return {
34720
34858
  kind: "client_abort",
@@ -34744,12 +34882,15 @@ var SolveEngine = class {
34744
34882
  }
34745
34883
  const treeBuildMs = performance.now() - treeBuildStart;
34746
34884
  const live = args.selvaEvents ? `:live:${args.selvaEvents.solveId}` : "";
34747
- const flight = await this.singleFlight.run(`${identity}:${args.server.id}:${this.clientGeneration(client)}:${stableStringify(inputTree)}${live}`, (signal) => runSolvePipeline({
34885
+ const flight = await this.singleFlight.run(`${identity}:${args.server.id}:${this.clientGeneration(client)}:${withSolveMode(stableStringify(inputTree), args.solveMode)}${live}`, (signal) => runSolvePipeline({
34748
34886
  definitionSource,
34749
34887
  inputTree,
34750
34888
  client,
34751
34889
  responseMaxBytes: this.limits.computeResponseMaxBytes,
34752
34890
  selvaEvents: args.selvaEvents,
34891
+ sessionId: args.sessionId,
34892
+ solveMode: args.solveMode,
34893
+ ...args.definitionGuid && { headers: { "X-Selva-Definition": args.definitionGuid } },
34753
34894
  signal
34754
34895
  }), args.signal);
34755
34896
  if (args.signal.aborted) return {
@@ -34851,6 +34992,60 @@ var SolveEngine = class {
34851
34992
  };
34852
34993
  }
34853
34994
  };
34995
+ var SPACE = new Uint8Array([32]);
34996
+ /** True when the request asked for a keep-alive response (`Prefer: selva-keepalive`). */
34997
+ function wantsKeepalive(request) {
34998
+ const prefer = request.headers.get("Prefer");
34999
+ if (!prefer) return false;
35000
+ return prefer.split(",").some((token) => token.split(";")[0].trim().toLowerCase() === KEEPALIVE_PREFERENCE);
35001
+ }
35002
+ /**
35003
+ * Answers 200 at once and holds the connection with a space every `intervalMs` until `work`
35004
+ * settles, then sends its status, headers and body (wire format in `shared/keepalive.ts`).
35005
+ *
35006
+ * `work` must resolve to every outcome, errors included: once the 200 is out, a rejection can
35007
+ * only drop the connection.
35008
+ */
35009
+ function respondWithKeepalive(work, intervalMs = KEEPALIVE_INTERVAL_MS) {
35010
+ let timer;
35011
+ const body = new ReadableStream({
35012
+ start(controller) {
35013
+ controller.enqueue(SPACE);
35014
+ timer = setInterval(() => controller.enqueue(SPACE), intervalMs);
35015
+ work.then(async (response) => {
35016
+ clearInterval(timer);
35017
+ const meta = {
35018
+ status: response.status,
35019
+ headers: [...response.headers]
35020
+ };
35021
+ controller.enqueue(new TextEncoder().encode(`${JSON.stringify(meta)}\n`));
35022
+ if (response.body) {
35023
+ const reader = response.body.getReader();
35024
+ for (;;) {
35025
+ const { done, value } = await reader.read();
35026
+ if (done) break;
35027
+ controller.enqueue(value);
35028
+ }
35029
+ }
35030
+ controller.close();
35031
+ }).catch((err) => {
35032
+ clearInterval(timer);
35033
+ controller.error(err);
35034
+ });
35035
+ },
35036
+ cancel() {
35037
+ clearInterval(timer);
35038
+ }
35039
+ });
35040
+ return new Response(body, {
35041
+ status: 200,
35042
+ headers: {
35043
+ "Content-Type": "application/octet-stream",
35044
+ "Cache-Control": "no-store",
35045
+ "Preference-Applied": KEEPALIVE_PREFERENCE
35046
+ }
35047
+ });
35048
+ }
34854
35049
  // ../server/src/organizations/org-asset-service.ts
34855
35050
  /**
34856
35051
  * Orchestrates org-asset writes that span IStorageProvider + IOrgStore — one
@@ -35295,6 +35490,14 @@ var APP_SETTINGS = composeManifest([
35295
35490
  class: "bootstrap",
35296
35491
  description: "Deployment directory the admin updater runs in. Defaults to the working directory."
35297
35492
  }),
35493
+ defineSetting({
35494
+ key: "NPM_CONFIG_REGISTRY",
35495
+ label: "npm registry",
35496
+ type: "url",
35497
+ onInvalid: "fail",
35498
+ class: "bootstrap",
35499
+ description: "Registry updates are checked against and installed from. Defaults to registry.npmjs.org."
35500
+ }),
35298
35501
  defineSetting({
35299
35502
  key: "SELVA_EVENT_CALLBACK_ORIGIN",
35300
35503
  label: "Solve event callback address",
@@ -35622,6 +35825,6 @@ if (!globalThis[ERROR_HOOKS_FLAG]) {
35622
35825
  getErrorReporter().capture(error, { tags: { origin: "uncaughtException" } });
35623
35826
  });
35624
35827
  }
35625
- export { deploymentSnapshot as A, classifyAssetPath as B, getUserProfileStore as C, computeDebugMode as D, RETIRED_KEYS as E, postedServerSourcedIds as F, definitionPaths as G, NoopEventSink as H, solveInputsFromSchema as I, diffSnapshots as K, LocalComputeServerStore as L, MAX_SOLVE_DEADLINE_MS as M, SolveEngine as N, deploymentManifest as O, acceptsGzip as P, isEncryptedSecret as R, getTenancy as S, providers as T, actorFrom as U, orgPaths as V, actorOf as W, getPlatformProjectGrantStore as _, getComputeServerConfigStore as a, getSolveMetricSink as b, getDefinitionService as c, getInviteStore as d, getLogger as f, getPermissionStore as g, getOrganizationProvider as h, getBranding as i, keyRotationStatus as j, deploymentReport as k, getErrorReporter as l, getOrgAssetService as m, getAuditQuery as n, getDataProvider as o, getNotificationProvider as p, getAuthProvider as r, getDefinitionMeta as s, flag as t, getEventSink as u, getProjectProvider as v, lazyLogger as w, getStorageProvider as x, getShareLinkStore as y, emptyProfile as z };
35828
+ export { deploymentSnapshot as A, LocalComputeServerStore as B, getUserProfileStore as C, computeDebugMode as D, RETIRED_KEYS as E, acceptsGzip as F, NoopEventSink as G, emptyProfile as H, postedServerSourcedIds as I, definitionPaths as J, actorFrom as K, respondWithKeepalive as L, DEFAULT_SOLVE_DEADLINE_MS as M, MAX_SOLVE_DEADLINE_MS as N, deploymentManifest as O, SolveEngine as P, solveInputsFromSchema as R, getTenancy as S, providers as T, classifyAssetPath as U, isEncryptedSecret as V, orgPaths as W, diffSnapshots as Y, getPlatformProjectGrantStore as _, getComputeServerConfigStore as a, getSolveMetricSink as b, getDefinitionService as c, getInviteStore as d, getLogger as f, getPermissionStore as g, getOrganizationProvider as h, getBranding as i, keyRotationStatus as j, deploymentReport as k, getErrorReporter as l, getOrgAssetService as m, getAuditQuery as n, getDataProvider as o, getNotificationProvider as p, actorOf as q, getAuthProvider as r, getDefinitionMeta as s, flag as t, getEventSink as u, getProjectProvider as v, lazyLogger as w, getStorageProvider as x, getShareLinkStore as y, wantsKeepalive as z };
35626
35829
 
35627
35830
  //# sourceMappingURL=providers.server.js.map