@voltro/cli 0.33.0 → 0.35.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 (343) hide show
  1. package/CHANGELOG.md +1968 -0
  2. package/bin/nodeEnvironment.d.mts +30 -0
  3. package/bin/nodeEnvironment.mjs +158 -0
  4. package/bin/voltro.mjs +69 -5
  5. package/dist/addCommand-BNeoeSxe.js +124 -0
  6. package/dist/addCommand-aXSQveak.js +2 -0
  7. package/dist/agentsMd-BTchIZku.js +2 -0
  8. package/dist/agentsMd-mhQMF1bx.js +254 -0
  9. package/dist/apiBuild-B8aoJvuw.js +2 -0
  10. package/dist/{apiBuild-h9VHtnlw.js → apiBuild-DYD_ONLD.js} +46 -46
  11. package/dist/{appGraph-gQ_6GkQQ.js → appGraph-KGDPTuTy.js} +1 -1
  12. package/dist/appGraph-zuMGKVYX.js +2 -0
  13. package/dist/appPort-B_HpJ_ck.js +48 -0
  14. package/dist/baselineCommand-C2ClWZN3.js +2 -0
  15. package/dist/baselineCommand-DIttzO8A.js +227 -0
  16. package/dist/bin.js +71 -28
  17. package/dist/build-CD8K4XOr.js +711 -0
  18. package/dist/cacheCommand-DA4OH9xt.js +42 -0
  19. package/dist/capabilitiesCommand-nq_pz5xd.js +123 -0
  20. package/dist/checkCommand-Ct9xkTrS.js +232 -0
  21. package/dist/checkCommand-DKpDLlqu.js +2 -0
  22. package/dist/{cliArgs-qdZSElM3.js → cliArgs-D4p8n7EE.js} +12 -1
  23. package/dist/cliError-BmdYnghb.js +10 -0
  24. package/dist/cliOutput-D1tSBoRM.js +15 -0
  25. package/dist/{cliRuntime-Oh517vCV.js → cliRuntime-Dh7UDinH.js} +20 -20
  26. package/dist/cloudClient-DWL-Hw_T.js +67 -0
  27. package/dist/cloudCmd-Cvv5HGaZ.js +364 -0
  28. package/dist/clusterCmd-D5wsCmA_.js +54 -0
  29. package/dist/codegen-CYM3Zqrf.js +605 -0
  30. package/dist/codegen-ChBi_hVa.js +2 -0
  31. package/dist/codegenCommand-C4YoQIc2.js +30 -0
  32. package/dist/codemodRunner-BnFq3Fgu.js +5384 -0
  33. package/dist/commandRunner-BLAEFLjp.js +47 -0
  34. package/dist/commands-BE8E7zF3.js +816 -0
  35. package/dist/connectionConfig-UFlIEiys.js +66 -0
  36. package/dist/dashboardCommand-D7SgZGaN.js +25 -0
  37. package/dist/dataCommand-BhYwDgg-.js +537 -0
  38. package/dist/dataProfile-dW-PsfLB.js +15 -0
  39. package/dist/dbCommand-DS4b97Is.js +2 -0
  40. package/dist/{dbCommand-DTLKAfbA.js → dbCommand-O8HA63s2.js} +552 -402
  41. package/dist/{dev-C_P8FLSx.js → dev-C7sFZq3m.js} +3670 -3169
  42. package/dist/dev-D2BikO7a.js +3 -0
  43. package/dist/devActivity-Dx_3nnGv.js +100 -0
  44. package/dist/devActivity.js +1 -1
  45. package/dist/dialectDriver-CgXnDfec.js +39 -0
  46. package/dist/discover-C9XKJDco.js +25 -0
  47. package/dist/doctorCommand-CM4Ch9C7.js +2 -0
  48. package/dist/{checkCommand-xGhRFFg2.js → doctorCommand-DnimF5IM.js} +523 -1278
  49. package/dist/dormancyCommand-QewYug_s.js +69 -0
  50. package/dist/e2eCmd-BRabZww-.js +147 -0
  51. package/dist/embeddingsCommand-BfiLS_QI.js +73 -0
  52. package/dist/envCommand-CCGPRQY1.js +60 -0
  53. package/dist/evalCommand-6RUfPen4.js +118 -0
  54. package/dist/evolveCommand-CHsLCtDf.js +281 -0
  55. package/dist/fileTaxonomy-CJfgOllU.js +457 -0
  56. package/dist/frameworkTableAssembly-YyVe32Cb.js +2 -0
  57. package/dist/frameworkTableAssembly-oMPBKqlE.js +511 -0
  58. package/dist/generateCommand-DbgcUpGw.js +147 -0
  59. package/dist/index.d.ts +45 -0
  60. package/dist/index.js +4 -3
  61. package/dist/infoCommand-DwOgK1t6.js +60 -0
  62. package/dist/{inspect-BUUjt773.js → inspect-CjTYzAs_.js} +113 -41
  63. package/dist/inspect-P4pxoMaV.js +2 -0
  64. package/dist/inspectCmd-EHFZ9yYu.js +224 -0
  65. package/dist/inspectFetch-EMuhTG_9.js +151 -0
  66. package/dist/inspectMetrics-CfdKLh6t.js +72 -0
  67. package/dist/loadEnv-D9nEOClM.js +44 -0
  68. package/dist/logFileSink-C_D2wRN1.js +105 -0
  69. package/dist/logsCmd-D36xK7Zu.js +260 -0
  70. package/dist/manifestBuild-COkJoyAr.js +2 -0
  71. package/dist/{manifestBuild-BLrVuSlM.js → manifestBuild-hpPLaGxV.js} +1 -1
  72. package/dist/metaCommands-7MJfZ5cf.js +196 -0
  73. package/dist/migrate-BV7I-ZHZ.js +83 -0
  74. package/dist/mssqlClusterPatch-_4cE_nun.js +44 -0
  75. package/dist/newCommand-COWOJ1_E.js +156 -0
  76. package/dist/nodeEnvironment-cGFAj1J8.js +28 -0
  77. package/dist/packageCommand-Cug_3Ogl.js +271 -0
  78. package/dist/pageConvention-cEiRxdab.js +5 -0
  79. package/dist/privacyCommand-C-Df56U_.js +146 -0
  80. package/dist/probeCommand-CZfaaUOZ.js +122 -0
  81. package/dist/projectScaffold-DmzEKHib.js +2 -0
  82. package/dist/projectScaffold-LMMtaavR.js +814 -0
  83. package/dist/renderModeScan-D7J1B7Kw.js +105 -0
  84. package/dist/renderProfile-1OWWAAtx.js +81 -0
  85. package/dist/runtimeRegistry-DMeKfTHP.js +81 -0
  86. package/dist/runtimeTrace-CH3eUiMw.js +91 -0
  87. package/dist/scheduleCmd-DQRu6BZC.js +149 -0
  88. package/dist/scheduleManifestCmd-D2x0CTTY.js +249 -0
  89. package/dist/schemaIr-UJybUUZW.js +103 -0
  90. package/dist/{sdkgen-C81QIkiL.js → sdkgen-BLkvGRfX.js} +111 -209
  91. package/dist/seedRunner-ZmLSqNe2.js +333 -0
  92. package/dist/serveCommand-CbDHU6l-.js +2 -0
  93. package/dist/serveCommand-iwlUBNS1.js +1766 -0
  94. package/dist/serveEntry.js +5 -5
  95. package/dist/serverlessCommand-CfJZy6dS.js +482 -0
  96. package/dist/start-BgN62boB.js +3 -0
  97. package/dist/start-T4VesWiM.js +1087 -0
  98. package/dist/startEntry.js +2 -2
  99. package/dist/staticCommand-Dr2M6tpU.js +304 -0
  100. package/dist/storageCommand-Co6NfLqN.js +42 -0
  101. package/dist/templates-De8IR5-c.js +102 -0
  102. package/dist/test-CI6iDsYc.js +115 -0
  103. package/dist/tracesCmd-DStmCJPi.js +232 -0
  104. package/dist/tsconfigPaths-BWXBWgcl.js +107 -0
  105. package/dist/tsxLoader-EuXmSJ1K.js +51 -0
  106. package/dist/typecheckCommand-BlsWiCNq.js +61 -0
  107. package/dist/updateCommand-BlMZhWgO.js +2 -0
  108. package/dist/updateCommand-x0pI_x-B.js +585 -0
  109. package/dist/webDev-BcykISYQ2.js +2 -0
  110. package/dist/{inspectMetrics-1xzTKAFx.js → webDev-Dybxew86.js} +988 -1560
  111. package/dist/webhookDiscovery-CrGAfhIG.js +2 -0
  112. package/dist/webhookDiscovery-D7VaeMlz.js +51 -0
  113. package/dist/webhooksCommand-DlAgS2Iw.js +267 -0
  114. package/dist/workflowsCmd-BGF-mRZ5.js +608 -0
  115. package/package.json +209 -17
  116. package/templates/AGENTS.core.md +58 -3
  117. package/templates/AGENTS.md +64 -7
  118. package/templates/agent-docs/_index.md +6 -4
  119. package/templates/agent-docs/_manifest.json +23 -6
  120. package/templates/agent-docs/ai.md +370 -0
  121. package/templates/agent-docs/authentication.md +313 -31
  122. package/templates/agent-docs/caching.md +6 -0
  123. package/templates/agent-docs/cli.md +853 -50
  124. package/templates/agent-docs/data.md +608 -12
  125. package/templates/agent-docs/database/migrations.md +223 -25
  126. package/templates/agent-docs/database/misc.md +156 -40
  127. package/templates/agent-docs/database/querying.md +19 -1
  128. package/templates/agent-docs/database/scaling.md +60 -0
  129. package/templates/agent-docs/database/schema.md +1 -0
  130. package/templates/agent-docs/database/seedsdialects.md +208 -19
  131. package/templates/agent-docs/database/transactions.md +68 -0
  132. package/templates/agent-docs/deployment.md +284 -25
  133. package/templates/agent-docs/introduction.md +88 -17
  134. package/templates/agent-docs/local-first-mobile.md +79 -4
  135. package/templates/agent-docs/multi-tenancy.md +188 -42
  136. package/templates/agent-docs/observability.md +58 -3
  137. package/templates/agent-docs/plugins/ai-flows.md +247 -2
  138. package/templates/agent-docs/plugins/analytics-postgres.md +1 -1
  139. package/templates/agent-docs/plugins/audit.md +37 -1
  140. package/templates/agent-docs/plugins/auth-social.md +143 -0
  141. package/templates/agent-docs/plugins/auth-workos.md +4 -2
  142. package/templates/agent-docs/plugins/auth.md +131 -6
  143. package/templates/agent-docs/plugins/billing.md +132 -15
  144. package/templates/agent-docs/plugins/cdc-out.md +46 -7
  145. package/templates/agent-docs/plugins/clickhouse.md +32 -1
  146. package/templates/agent-docs/plugins/duckdb.md +1 -1
  147. package/templates/agent-docs/plugins/flags.md +132 -0
  148. package/templates/agent-docs/plugins/governance.md +105 -7
  149. package/templates/agent-docs/plugins/multitenancy.md +9 -4
  150. package/templates/agent-docs/plugins/presence.md +13 -2
  151. package/templates/agent-docs/plugins/ratelimit.md +9 -0
  152. package/templates/agent-docs/plugins/search.md +162 -8
  153. package/templates/agent-docs/plugins/sso-saml.md +47 -8
  154. package/templates/agent-docs/plugins/storage.md +11 -0
  155. package/templates/agent-docs/plugins/webhooks.md +105 -0
  156. package/templates/agent-docs/plugins.md +152 -18
  157. package/templates/agent-docs/reference.md +60 -3
  158. package/templates/agent-docs/releases.md +1117 -0
  159. package/templates/agent-docs/routing.md +43 -25
  160. package/templates/agent-docs/scheduling.md +27 -0
  161. package/templates/agent-docs/schema-driven-ui.md +92 -12
  162. package/templates/agent-docs/security.md +426 -0
  163. package/templates/agent-docs/templates/apibackends.md +87 -18
  164. package/templates/agent-docs/templates/appshells.md +32 -14
  165. package/templates/agent-docs/templates/overview.md +13 -8
  166. package/templates/agent-docs/testing.md +211 -14
  167. package/templates/agent-docs/whats-new.md +98 -136
  168. package/templates/agent-docs/workflows.md +231 -14
  169. package/templates/apps/api-ai/actions/summarize.action.ts +11 -0
  170. package/templates/apps/api-ai/package.json +8 -7
  171. package/templates/apps/api-auth/actions/me.action.ts +13 -0
  172. package/templates/apps/api-auth/package.json +9 -8
  173. package/templates/apps/api-backend/mutations/notes.create.mutation.ts +9 -0
  174. package/templates/apps/api-backend/package.json +12 -8
  175. package/templates/apps/api-backend/queries/notes.query.ts +30 -8
  176. package/templates/apps/api-backend-deactivation/actions/users.get.action.ts +14 -0
  177. package/templates/apps/api-backend-deactivation/mutations/users.create.mutation.ts +8 -0
  178. package/templates/apps/api-backend-deactivation/mutations/users.deactivate.mutation.ts +10 -0
  179. package/templates/apps/api-backend-deactivation/package.json +8 -7
  180. package/templates/apps/api-backend-mail/actions/sendWelcome.action.ts +17 -0
  181. package/templates/apps/api-backend-mail/mutations/notes.create.mutation.ts +9 -0
  182. package/templates/apps/api-backend-mail/package.json +9 -8
  183. package/templates/apps/api-backend-mail/queries/notes.query.ts +30 -8
  184. package/templates/apps/api-backend-mariadb/.env.example +14 -0
  185. package/templates/apps/api-backend-mariadb/mutations/notes.create.mutation.ts +9 -0
  186. package/templates/apps/api-backend-mariadb/package.json +10 -9
  187. package/templates/apps/api-backend-mariadb/queries/notes.query.ts +30 -8
  188. package/templates/apps/api-backend-sqlite/.env.example +14 -0
  189. package/templates/apps/api-backend-sqlite/mutations/notes.create.mutation.ts +9 -0
  190. package/templates/apps/api-backend-sqlite/package.json +9 -8
  191. package/templates/apps/api-backend-sqlite/queries/notes.query.ts +30 -8
  192. package/templates/apps/api-backend-storage/actions/uploadAvatar.action.ts +13 -0
  193. package/templates/apps/api-backend-storage/actions/uploadDocument.action.ts +12 -0
  194. package/templates/apps/api-backend-storage/mutations/notes.create.mutation.ts +9 -0
  195. package/templates/apps/api-backend-storage/package.json +9 -8
  196. package/templates/apps/api-backend-storage/queries/notes.query.ts +30 -8
  197. package/templates/apps/api-cms/actions/content.get.action.ts +7 -0
  198. package/templates/apps/api-cms/actions/content.types.action.ts +6 -0
  199. package/templates/apps/api-cms/actions/me.action.ts +13 -0
  200. package/templates/apps/api-cms/app.config.ts +19 -0
  201. package/templates/apps/api-cms/authz.ts +63 -0
  202. package/templates/apps/api-cms/mutations/content.publish.mutation.ts +10 -0
  203. package/templates/apps/api-cms/mutations/content.saveDraft.mutation.ts +10 -0
  204. package/templates/apps/api-cms/mutations/content.unpublish.mutation.ts +5 -0
  205. package/templates/apps/api-cms/package.json +11 -10
  206. package/templates/apps/api-cms/queries/content.list.query.ts +23 -7
  207. package/templates/apps/api-cms/tests/accessDecisions.test.ts +121 -0
  208. package/templates/apps/api-cms/tests/content.descriptors.test.ts +8 -4
  209. package/templates/apps/api-collab/mutations/documents.create.mutation.ts +8 -0
  210. package/templates/apps/api-collab/mutations/documents.setBody.mutation.ts +13 -0
  211. package/templates/apps/api-collab/package.json +9 -8
  212. package/templates/apps/api-collab/queries/documents.query.ts +19 -7
  213. package/templates/apps/api-data-advanced/package.json +9 -8
  214. package/templates/apps/api-data-advanced/queries/authors.withBooks.query.ts +12 -0
  215. package/templates/apps/api-data-advanced/queries/books.search.query.ts +9 -0
  216. package/templates/apps/api-durable/mutations/orders.approve.mutation.ts +17 -0
  217. package/templates/apps/api-durable/mutations/orders.place.mutation.ts +9 -0
  218. package/templates/apps/api-durable/package.json +9 -8
  219. package/templates/apps/api-feature-flags/actions/notes.export.action.ts +16 -0
  220. package/templates/apps/api-feature-flags/mutations/notes.create.mutation.ts +12 -0
  221. package/templates/apps/api-feature-flags/package.json +10 -9
  222. package/templates/apps/api-governance/README.md +30 -8
  223. package/templates/apps/api-governance/actions/profiles.get.action.server.ts +17 -1
  224. package/templates/apps/api-governance/actions/profiles.get.action.ts +29 -4
  225. package/templates/apps/api-governance/database/schema.ts +16 -4
  226. package/templates/apps/api-governance/mutations/profiles.create.mutation.ts +12 -0
  227. package/templates/apps/api-governance/package.json +9 -8
  228. package/templates/apps/api-kv/actions/sync.pull.action.ts +15 -0
  229. package/templates/apps/api-kv/actions/sync.reset.action.ts +13 -0
  230. package/templates/apps/api-kv/actions/sync.status.action.ts +7 -0
  231. package/templates/apps/api-kv/package.json +9 -8
  232. package/templates/apps/api-kv/queries/events.list.query.ts +19 -8
  233. package/templates/apps/api-moderation/mutations/comments.create.mutation.ts +11 -0
  234. package/templates/apps/api-moderation/mutations/posts.create.mutation.ts +13 -0
  235. package/templates/apps/api-moderation/package.json +9 -8
  236. package/templates/apps/api-observability/mutations/notes.create.mutation.ts +8 -0
  237. package/templates/apps/api-observability/package.json +9 -8
  238. package/templates/apps/api-observability/queries/notes.list.query.ts +13 -0
  239. package/templates/apps/api-ratelimit/mutations/notes.create.mutation.ts +14 -0
  240. package/templates/apps/api-ratelimit/package.json +9 -8
  241. package/templates/apps/api-rbac/package.json +9 -8
  242. package/templates/apps/api-rest/package.json +8 -7
  243. package/templates/apps/api-saas/mutations/projects.create.mutation.ts +13 -0
  244. package/templates/apps/api-saas/package.json +12 -11
  245. package/templates/apps/api-saas/queries/projects.list.query.ts +11 -0
  246. package/templates/apps/api-saas-starter/actions/me.action.ts +13 -0
  247. package/templates/apps/api-saas-starter/app.config.ts +19 -0
  248. package/templates/apps/api-saas-starter/authz.ts +75 -0
  249. package/templates/apps/api-saas-starter/mutations/invites.create.mutation.ts +10 -0
  250. package/templates/apps/api-saas-starter/mutations/projects.create.mutation.ts +9 -0
  251. package/templates/apps/api-saas-starter/package.json +15 -11
  252. package/templates/apps/api-saas-starter/queries/invites.list.query.ts +19 -8
  253. package/templates/apps/api-saas-starter/queries/projects.list.query.ts +18 -7
  254. package/templates/apps/api-saas-starter/tests/accessDecisions.test.ts +135 -0
  255. package/templates/apps/api-search/mutations/articles.create.mutation.ts +14 -0
  256. package/templates/apps/api-search/package.json +9 -8
  257. package/templates/apps/api-search/queries/articles.list.query.ts +21 -8
  258. package/templates/apps/api-status/README.md +10 -3
  259. package/templates/apps/api-status/app.config.ts +8 -3
  260. package/templates/apps/api-status/authz.ts +5 -3
  261. package/templates/apps/api-status/package.json +9 -8
  262. package/templates/apps/api-status/queries/components.list.query.ts +14 -6
  263. package/templates/apps/api-status/queries/incidents.live.query.ts +23 -10
  264. package/templates/apps/api-status/queries/updates.list.query.ts +16 -9
  265. package/templates/apps/api-status/tests/status.test.ts +9 -1
  266. package/templates/apps/api-versioning/actions/documents.asOf.action.ts +12 -0
  267. package/templates/apps/api-versioning/actions/documents.history.action.ts +13 -0
  268. package/templates/apps/api-versioning/mutations/documents.create.mutation.ts +9 -0
  269. package/templates/apps/api-versioning/mutations/documents.update.mutation.ts +12 -0
  270. package/templates/apps/api-versioning/package.json +9 -8
  271. package/templates/apps/api-webhooks/mutations/orders.fulfill.mutation.ts +16 -0
  272. package/templates/apps/api-webhooks/package.json +10 -9
  273. package/templates/apps/api-webhooks/queries/orders.list.query.ts +10 -0
  274. package/templates/apps/changelog/package.json +8 -6
  275. package/templates/apps/edge-functions/package.json +2 -2
  276. package/templates/apps/frontend-admin/package.json +10 -8
  277. package/templates/apps/frontend-admin/src/lib/admin.ts +20 -9
  278. package/templates/apps/frontend-admin/src/locales/de.ts +11 -1
  279. package/templates/apps/frontend-admin/src/locales/en.ts +13 -1
  280. package/templates/apps/frontend-admin/src/pages/admin/[entity]/page.tsx +65 -22
  281. package/templates/apps/frontend-admin/src/pages/admin/entity.test.tsx +130 -23
  282. package/templates/apps/frontend-admin/src/pages/admin/layout.tsx +3 -2
  283. package/templates/apps/frontend-admin/src/pages/admin/page.test.tsx +19 -2
  284. package/templates/apps/frontend-admin/src/pages/admin/page.tsx +9 -4
  285. package/templates/apps/frontend-app/app.config.ts +4 -3
  286. package/templates/apps/frontend-app/package.json +11 -8
  287. package/templates/apps/frontend-app/src/lib/api.ts +25 -0
  288. package/templates/apps/frontend-app/src/pages/page.test.tsx +130 -82
  289. package/templates/apps/frontend-app/src/pages/page.tsx +14 -18
  290. package/templates/apps/frontend-auth/package.json +10 -8
  291. package/templates/apps/frontend-blank/package.json +9 -7
  292. package/templates/apps/frontend-cms/package.json +11 -9
  293. package/templates/apps/frontend-collab/package.json +12 -9
  294. package/templates/apps/frontend-collab/src/pages/page.test.tsx +122 -78
  295. package/templates/apps/frontend-contact/package.json +9 -7
  296. package/templates/apps/frontend-dashboard/package.json +9 -7
  297. package/templates/apps/frontend-docs/package.json +9 -7
  298. package/templates/apps/frontend-i18n/package.json +8 -6
  299. package/templates/apps/frontend-landing/package.json +9 -7
  300. package/templates/apps/frontend-portal/package.json +10 -8
  301. package/templates/apps/frontend-saas/app.config.ts +10 -6
  302. package/templates/apps/frontend-saas/package.json +10 -8
  303. package/templates/apps/frontend-saas/src/lib/api.ts +27 -32
  304. package/templates/apps/frontend-saas/src/pages/dashboard/billing/page.tsx +7 -8
  305. package/templates/apps/frontend-saas/src/pages/dashboard/page.test.tsx +27 -3
  306. package/templates/apps/frontend-saas/src/pages/dashboard/page.tsx +4 -4
  307. package/templates/apps/frontend-saas/src/pages/dashboard/team/page.tsx +3 -4
  308. package/templates/apps/frontend-spa/package.json +9 -7
  309. package/templates/apps/frontend-ssr/package.json +9 -7
  310. package/templates/apps/frontend-ssr-api/package.json +10 -8
  311. package/templates/apps/frontend-static-blog/package.json +8 -6
  312. package/templates/apps/frontend-status/package.json +10 -8
  313. package/templates/apps/mobile-app/README.md +1 -0
  314. package/templates/apps/mobile-app/package.json +4 -2
  315. package/templates/apps/mobile-app/src/app/index.tsx +22 -12
  316. package/templates/apps/mobile-app/src/app/orders/[id].tsx +1 -1
  317. package/templates/apps/mobile-app/src/lib/api.ts +34 -0
  318. package/templates/apps/mobile-app/voltro.mobile.ts +4 -2
  319. package/templates/baselines/bare/.env.example +14 -0
  320. package/templates/baselines/bare/baseline.json +4 -4
  321. package/templates/baselines/compose/.env.example +14 -0
  322. package/templates/baselines/compose/README.md +1 -1
  323. package/templates/baselines/compose/baseline.json +5 -5
  324. package/templates/baselines/compose-mariadb/.env.example +14 -0
  325. package/templates/baselines/compose-mariadb/README.md +1 -1
  326. package/templates/baselines/compose-mariadb/baseline.json +5 -5
  327. package/templates/baselines/helm/.env.example +14 -0
  328. package/templates/baselines/helm/baseline.json +4 -4
  329. package/dist/apiBuild-C-x9YacA.js +0 -2
  330. package/dist/appGraph-CvQCte0z.js +0 -2
  331. package/dist/checkCommand-DRovTKza.js +0 -2
  332. package/dist/commands-CJfepbm4.js +0 -11541
  333. package/dist/dbCommand-b1gum4td.js +0 -2
  334. package/dist/dev-iiMtlkfs.js +0 -3
  335. package/dist/devActivity-BhIu6ncs.js +0 -159
  336. package/dist/frameworkTableAssembly-BwIrO5nv.js +0 -638
  337. package/dist/frameworkTableAssembly-D-EebUQX.js +0 -2
  338. package/dist/inspect-mmBuRXmy.js +0 -2
  339. package/dist/manifestBuild-Dj8Jjoto.js +0 -2
  340. package/dist/seedRunner-Bqxgp7HZ.js +0 -230
  341. package/dist/serveCommand-DdaM4Hup.js +0 -1608
  342. package/dist/start-C0koT0UO.js +0 -1084
  343. /package/templates/apps/api-ai/actions/{summarize.action.server.tsx → summarize.action.server.ts} +0 -0
@@ -0,0 +1,1766 @@
1
+ import { t as e } from "./nodeEnvironment-cGFAj1J8.js";
2
+ import { t } from "./frameworkInspectState-CX2250XB.js";
3
+ import { r as n, t as r } from "./appModuleLoader-C9r9mxZt.js";
4
+ import { n as i, t as a } from "./startupRunner-DPGFchOa.js";
5
+ import { $ as o, $t as s, A as c, At as l, B as u, C as d, Ct as ee, D as f, Dt as p, E as te, Et as ne, F as re, Ft as m, G as ie, Gt as ae, H as oe, Ht as se, I as h, It as ce, J as le, Jt as g, K as ue, Kt as de, L as fe, Lt as pe, M as me, Mt as he, N as ge, Nt as _e, O as _, Ot as ve, P as ye, Pt as be, Q as xe, Qt as Se, R as Ce, S as we, St as Te, T as v, Tt as Ee, U as De, Ut as Oe, V as ke, Vt as Ae, W as je, Wt as y, X as Me, Xt as Ne, Y as Pe, Yt as Fe, Z as b, Zt as Ie, _ as Le, _n as x, _t as Re, an as ze, at as Be, b as Ve, bt as He, c as Ue, cn as We, ct as Ge, dn as S, dt as Ke, en as qe, et as C, f as Je, fn as Ye, ft as Xe, g as Ze, gn as Qe, gt as $e, h as et, hn as tt, ht as nt, i as w, in as rt, it, j as at, jt as ot, k as st, kt as ct, ln as lt, lt as ut, m as dt, mn as ft, mt as pt, nn as mt, nt as ht, o as T, on as gt, ot as E, p as _t, pt as vt, q as yt, qt as D, r as O, rn as bt, rt as xt, sn as St, st as Ct, t as wt, tn as k, tt as Tt, u as Et, un as Dt, ut as Ot, v as kt, vn as At, vt as jt, w as Mt, wt as Nt, x as Pt, xt as Ft, y as A, yt as It, zt as j } from "./dev-C7sFZq3m.js";
6
+ import { n as Lt } from "./cliArgs-D4p8n7EE.js";
7
+ import { r as Rt } from "./appPort-B_HpJ_ck.js";
8
+ import { at as zt, nt as Bt, st as Vt } from "./webDev-Dybxew86.js";
9
+ import { r as M } from "./dialectDriver-CgXnDfec.js";
10
+ import { i as Ht, n as Ut } from "./connectionConfig-UFlIEiys.js";
11
+ import { c as N, n as Wt, o as Gt } from "./seedRunner-ZmLSqNe2.js";
12
+ import { C as Kt, S as qt, _ as Jt, d as Yt, g as P, l as Xt, m as Zt, r as Qt, u as $t, v as en } from "./frameworkTableAssembly-oMPBKqlE.js";
13
+ import { S as tn, c as nn, n as rn, p as an, s as on, x as sn } from "./fileConventions-Cof68_BL.js";
14
+ import { h as cn, o as ln } from "./inspect-CjTYzAs_.js";
15
+ import { n as un } from "./mssqlClusterPatch-_4cE_nun.js";
16
+ import { i as dn, n as fn, r as pn, t as mn } from "./webhookDiscovery-D7VaeMlz.js";
17
+ import { t as hn } from "./inspectMetrics-CfdKLh6t.js";
18
+ import { r as gn, u as _n } from "./apiBuild-DYD_ONLD.js";
19
+ import { t as vn } from "./bootTiming-BdyP9nYw.js";
20
+ import { t as yn } from "./dataProfile-dW-PsfLB.js";
21
+ import { basename as bn, join as xn } from "node:path";
22
+ import { existsSync as Sn } from "node:fs";
23
+ import { pathToFileURL as Cn } from "node:url";
24
+ import { createLogger as F } from "@voltro/logger";
25
+ import { AuthMiddleware as wn, ConnectionInfoMiddleware as Tn, actionToRpc as I, anonymousSubject as En, isWireReachable as Dn, mutationToRpc as L, queryToRpc as R, streamToRpc as On, workflowCancelDescriptor as kn, workflowDomainEventsQueryDescriptor as An, workflowEventDeliveriesQueryDescriptor as z, workflowResumeDescriptor as jn, workflowRunEventsQueryDescriptor as B, workflowRunQueryDescriptor as V, workflowRunStepsQueryDescriptor as H, workflowRunsQueryDescriptor as Mn, workflowSignalDescriptor as Nn, workflowUpdateDescriptor as Pn } from "@voltro/protocol";
26
+ import { Cause as Fn, Effect as U, Layer as W, ManagedRuntime as In } from "effect";
27
+ import { SqlClient as Ln } from "@effect/sql";
28
+ import { declaredSnapshot as Rn, describeOutcome as zn, pendingFileMigrationIds as Bn, runPlannedMigrations as Vn } from "@voltro/database/sql";
29
+ import { RpcGroup as Hn } from "@effect/rpc";
30
+ import { allRegisteredTables as Un, and as Wn, connectionIdentity as Gn, ensureTableRegistered as Kn, eq as G, or as K } from "@voltro/database";
31
+ import { AggregateRegistry as qn, CostRegistry as Jn, DORMANCY_WAKEUP_TENANT as Yn, Dispatcher as Xn, ExpectationRegistry as Zn, ExperimentRegistry as q, apiKeyManagementRoutes as Qn, attachAnalyticsMirror as $n, attachExpectations as er, attachExperiments as tr, attachFinops as nr, awaitServerListening as rr, bindMutation as J, bindStream as ir, bindSubscription as Y, buildTracingLayer as ar, cancelWakeup as or, compileCron as sr, dataStoreApiKeyStore as cr, formatServerOnlyLeaks as lr, formatUnresolvedSources as ur, frameworkApiKeyStrategy as dr, installPolicyGuardResolver as fr, loadResourceTuples as pr, makeActionRunner as mr, makeAdvisoryLockCoordinator as hr, makeApiKeyService as gr, makeApiKeyUsageBuffer as _r, makeApiKeyUsageFlusher as vr, makeAsyncKv as yr, makeAuthMiddlewareLayers as br, makeCoordinatedScheduler as xr, makeEffectStoreLayer as Sr, makeLazyWorkflowFacade as Cr, makeMutationOutputCodec as wr, makeMutationRunner as Tr, makeOneShotQueryRunner as Er, makeQueryDescriptorProducer as Dr, makeQueryFinalizer as Or, makeQueryReauthorizer as kr, makeQuerySubscriber as Ar, makeSchemaRegistry as jr, makeWorkflowFacade as Mr, makeWorkflowFacadeWithCallerContext as Nr, makeWorkflowLayers as X, noopKv as Pr, onProcessShutdown as Fr, recordSubscriptionDelivery as Ir, recordWorkflowRun as Lr, registerWakeup as Rr, resolveSecretsBackend as zr, runProvidedEffect as Br, setSecretsBackend as Vr, setSystemStoreHandle as Hr, setTupleSource as Ur, shutdownGraceMsFromEnv as Z, singleCoordinator as Wr, startRpcServer as Gr, startScheduler as Kr, stripForbiddenForWire as qr, undoCaptureEnabled as Jr, unresolvedSources as Yr, workflowToRpc as Xr, wrapStoreWithBootCodec as Zr } from "@voltro/runtime";
32
+ import { appStorageProvider as Qr, fromNodeReadable as $r, getObjectStream as ei, putObjectStream as ti, toNodeReadable as ni } from "@voltro/plugin-storage";
33
+ import { isEnvContract as ri } from "@voltro/env";
34
+ import { assertProductionSessionSecret as ii } from "@voltro/protocol/session";
35
+ import { createHash as ai, timingSafeEqual as oi } from "node:crypto";
36
+ import { buildDeliverWebhookExecute as si, buildWebhooksService as ci, defaultIncomingPath as li, deliverWebhookWorkflow as ui, makeDeferredEmitHandler as di, mountIncomingWebhook as fi } from "@voltro/plugin-webhooks";
37
+ import { getAuthSessionStrategy as pi } from "@voltro/plugin-auth";
38
+ import { registerEmailTemplates as mi } from "@voltro/plugin-mail";
39
+ import { channelFor as hi, getBroadcastPlugin as gi } from "@voltro/plugin-broadcast";
40
+ import { packBundle as _i, runExport as vi, runImport as yi, storageBlobSink as bi, storageRefsBlobSource as xi, unpackBundle as Si, unpackBundleToDir as Ci } from "@voltro/data-transfer";
41
+ //#region src/dbPoolReport.ts
42
+ var wi = (e, t, n = [], r = 0) => {
43
+ let i = n.length, a = 1 + Math.max(0, r), o = e === void 0 ? void 0 : e * a + i, s = o !== void 0 && t !== void 0 ? o * t : void 0, c = i === 0 ? " No connections outside the pool in this process." : ` PLUS ${i} outside the pool (${n.map((e) => e.reason).join("; ")}) — those do not come out of the pool budget, they come out of the DATABASE's.`, l = r > 0 ? ` This process opens ${a} pools of that size — 1 primary + ${r} read replica(s) (DB_REPLICA_URLS), each with its own DB_MAX_CONNECTIONS.` : "";
44
+ if (e === void 0) return "db pool: max per replica UNSET (DB_MAX_CONNECTIONS) — each replica opens the driver's default pool, so the fleet total is that default × replicas. Set DB_MAX_CONNECTIONS so the total stays under your database's connection limit; the pool scales with replicaCount and the database does not." + l + c + Ti;
45
+ let u = (r > 0 ? `max × ${a}` : "max") + (i === 0 ? "" : ` + ${i}`), d = r === 0 ? i === 0 ? "" : ` + ${i} = ${o}` : ` → ${u} = ${o} per pod`, ee = r === 0 && i === 0 ? "max" : `(${u})`;
46
+ return `db pool: max=${e} per replica (DB_MAX_CONNECTIONS)` + d + (s === void 0 ? ` — the fleet opens up to ${ee} × replicas connections. Check that against your database's limit before raising replicaCount.` : ` × ${t} replicas = up to ${s} connections. Check that against your database's limit.`) + l + c + Ti;
47
+ }, Ti = " A rolling update runs BOTH generations at once, so budget for (replicas + surge), not replicas — a surge pod that cannot get a connection crashloops, and a rollout that never completes cannot free the connections it is waiting for.", Ei = (e = process.env) => {
48
+ let t = e.REPLICA_COUNT;
49
+ if (t === void 0 || t === "") return;
50
+ let n = Number(t);
51
+ return Number.isInteger(n) && n > 0 ? n : void 0;
52
+ }, Di = () => Math.max(500, Math.floor(Z() * .6)), Oi = (e) => new Promise((t) => setTimeout(t, e)), ki = (e) => {
53
+ let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), r = 0;
54
+ e.on("connection", (e) => {
55
+ t.add(e), e.once("close", () => {
56
+ t.delete(e), n.delete(e);
57
+ });
58
+ }), e.on("upgrade", (e, t) => {
59
+ n.add(t);
60
+ }), e.on("request", (e, t) => {
61
+ r += 1, t.once("close", () => {
62
+ --r;
63
+ });
64
+ });
65
+ let i, a = async (t = {}) => {
66
+ let n = t.budgetMs ?? Di();
67
+ i ??= new Promise((t) => {
68
+ e.close(() => {
69
+ t();
70
+ });
71
+ }), e.closeIdleConnections();
72
+ let a = Date.now() + n;
73
+ for (; r > 0 && Date.now() < a;) await Oi(25), e.closeIdleConnections();
74
+ e.closeIdleConnections();
75
+ }, o = async () => {
76
+ i ??= new Promise((t) => {
77
+ e.close(() => {
78
+ t();
79
+ });
80
+ });
81
+ for (let e of t) if (n.has(e)) try {
82
+ e.write(Buffer.from([
83
+ 136,
84
+ 2,
85
+ 3,
86
+ 233
87
+ ]));
88
+ } catch {}
89
+ else e.destroy();
90
+ for (let e = 0; t.size > 0 && e < 250; e += 25) await Oi(25);
91
+ for (let e of t) e.destroy();
92
+ await i;
93
+ };
94
+ return {
95
+ activeRequests: () => r,
96
+ drainRequests: a,
97
+ finish: o,
98
+ drain: async (e = {}) => {
99
+ await a(e), await o();
100
+ }
101
+ };
102
+ }, Ai = "/_voltro/admin/import", ji = "/_voltro/admin/export", Q = (e, t) => ({
103
+ status: e,
104
+ contentType: "application/json; charset=utf-8",
105
+ body: JSON.stringify(t)
106
+ }), Mi = (e) => {
107
+ let t = e.authorization ?? e.Authorization, n = t ? /^Bearer\s+(.+)$/i.exec(t) : null;
108
+ return n ? n[1] : null;
109
+ }, Ni = (e, t) => oi(ai("sha256").update(e).digest(), ai("sha256").update(t).digest()), Pi = (e, t) => {
110
+ if (e.method.toUpperCase() !== "POST") return Q(405, { error: "method not allowed" });
111
+ if (!t || t.length < 16) return Q(503, { error: "data transfer misconfigured (no/weak secret)" });
112
+ let n = Mi(e.headers);
113
+ return !n || !Ni(n, t) ? Q(401, { error: "unauthorized" }) : null;
114
+ }, Fi = F({ scope: "voltro:admin-import" }), Ii = "VBUNDLE2", Li = async function* (e) {
115
+ yield e;
116
+ }, Ri = (e) => async (t) => {
117
+ let n = Pi(t, e.secret);
118
+ if (n) return n;
119
+ let r = t.headers["x-import-mode"], i = t.headers["x-import-on-conflict"], a = t.headers["x-import-atomic"] === "1" || t.headers["x-import-atomic"] === "true", o = t.headers["x-import-force"] === "1" || t.headers["x-import-force"] === "true", s = t.rawBody.byteLength >= 8 && Buffer.from(t.rawBody.subarray(0, 8)).toString("latin1") === Ii, c, l;
120
+ if (s) c = Li(t.rawBody), l = "upload";
121
+ else {
122
+ let n;
123
+ try {
124
+ n = JSON.parse(Buffer.from(t.rawBody).toString("utf8") || "{}");
125
+ } catch {
126
+ return Q(400, { error: "body must be a packed bundle archive or { bundleKey } JSON" });
127
+ }
128
+ if (typeof n.bundleKey != "string" || !n.bundleKey) return Q(400, { error: "body.bundleKey (string) is required for the storage transport" });
129
+ if (!e.openArchive) return Q(501, { error: "storage transport not configured on this instance" });
130
+ c = e.openArchive(n.bundleKey), l = "storage";
131
+ }
132
+ let u = await import("node:os"), d = await import("node:fs/promises"), ee = await import("node:path"), f = await d.mkdtemp(ee.join(u.tmpdir(), "voltro-admin-import-"));
133
+ try {
134
+ e.assetSink ? await Si(c, {
135
+ dir: f,
136
+ blobs: e.assetSink
137
+ }) : await Ci(c, f);
138
+ let t = await U.runPromiseExit(yi({
139
+ store: e.store,
140
+ bundleDir: f,
141
+ ...r ? { mode: r } : {},
142
+ ...i ? { onConflict: i } : {},
143
+ ...a ? { atomic: a } : {},
144
+ ...e.snapshot ? { targetSnapshot: e.snapshot } : {},
145
+ force: o,
146
+ onWarn: (e) => Fi.warn("admin.import", { message: e }),
147
+ ...e.assetSink ? { assetsAlreadyRestored: !0 } : {}
148
+ }));
149
+ if (t._tag === "Failure") {
150
+ let e = t.cause._tag === "Fail" ? t.cause.error : void 0;
151
+ if (e && e._tag === "SchemaDriftError") {
152
+ let t = e;
153
+ return Fi.warn("admin.import refused (schema drift)", {
154
+ transport: l,
155
+ bundle: t.bundleFingerprint.slice(0, 16),
156
+ target: t.targetFingerprint.slice(0, 16)
157
+ }), Q(409, {
158
+ error: "schema drift",
159
+ bundleFingerprint: t.bundleFingerprint,
160
+ targetFingerprint: t.targetFingerprint,
161
+ diff: t.diff,
162
+ hint: "re-export against the current schema, or resend with x-import-force: 1"
163
+ });
164
+ }
165
+ throw Error(String(e?.message ?? e ?? "import failed"));
166
+ }
167
+ let n = t.value, s = n.tables.reduce((e, t) => e + t.rowCount, 0);
168
+ return Fi.info("admin.import", {
169
+ transport: l,
170
+ tables: n.tables.length,
171
+ rows: s,
172
+ mode: r ?? "upsert",
173
+ atomic: a
174
+ }), Q(200, {
175
+ tables: n.tables.length,
176
+ rows: s,
177
+ transport: l
178
+ });
179
+ } catch (e) {
180
+ return Fi.warn("admin.import failed", {
181
+ transport: l,
182
+ error: e?.message ?? String(e)
183
+ }), Q(500, {
184
+ error: "import failed",
185
+ message: e?.message ?? String(e)
186
+ });
187
+ } finally {
188
+ await d.rm(f, {
189
+ recursive: !0,
190
+ force: !0
191
+ });
192
+ }
193
+ }, zi = F({ scope: "voltro:admin-export" }), Bi = async (e) => {
194
+ let t = [];
195
+ for await (let n of e) t.push(Buffer.from(n));
196
+ return new Uint8Array(Buffer.concat(t));
197
+ }, Vi = (e) => typeof e.tenant == "string" && e.tenant ? {
198
+ kind: "tenant",
199
+ tenantId: e.tenant
200
+ } : Array.isArray(e.tables) && e.tables.length ? {
201
+ kind: "tables",
202
+ tables: e.tables.filter((e) => typeof e == "string")
203
+ } : { kind: "all" }, Hi = (e) => async (t) => {
204
+ let n = Pi(t, e.secret);
205
+ if (n) return n;
206
+ let r;
207
+ try {
208
+ r = JSON.parse(Buffer.from(t.rawBody).toString("utf8") || "{}");
209
+ } catch {
210
+ return Q(400, { error: "body must be JSON: { profile?, tenant?, tables?, consistency?, compression?, bundleKey? }" });
211
+ }
212
+ let i = {};
213
+ if (typeof r.profile == "string" && r.profile) {
214
+ if (!e.loadProfile) return Q(501, { error: "server-side profiles not configured on this instance" });
215
+ try {
216
+ i = await e.loadProfile(r.profile);
217
+ } catch (e) {
218
+ return Q(400, {
219
+ error: `profile '${r.profile}' could not be loaded`,
220
+ message: e?.message ?? String(e)
221
+ });
222
+ }
223
+ }
224
+ let a = r.consistency === "snapshot" ? "snapshot" : i.consistency ?? "live", o = (typeof r.compression == "string" ? r.compression : void 0) ?? i.compression, s = i.scope ?? Vi(r), c = typeof r.bundleKey == "string" && r.bundleKey.length > 0, l = r.assets === !0 && e.assetSource ? { blobs: e.assetSource } : {}, u = await import("node:os"), d = await import("node:fs/promises"), ee = await import("node:path"), f = await d.mkdtemp(ee.join(u.tmpdir(), "voltro-admin-export-"));
225
+ try {
226
+ let t = await U.runPromise(vi({
227
+ store: e.store,
228
+ snapshot: e.snapshot,
229
+ dialect: e.dialect,
230
+ outDir: f,
231
+ ...i.subset ? { subset: i.subset } : {
232
+ scope: s,
233
+ ...e.tenantTables && e.tenantTables.length > 0 ? { tenantTables: e.tenantTables } : {}
234
+ },
235
+ consistency: a,
236
+ ...o ? { compression: o } : {},
237
+ ...i.masking ? { masking: i.masking } : {}
238
+ })), n = t.tables.reduce((e, t) => e + t.rowCount, 0), u = t.masking?.transformed.length ?? 0;
239
+ if (c) {
240
+ if (!e.putArchive) return Q(501, { error: "storage transport not configured on this instance" });
241
+ let i = r.bundleKey;
242
+ return await e.putArchive(i, () => _i({
243
+ dir: f,
244
+ ...l
245
+ })), zi.info("admin.export", {
246
+ transport: "storage",
247
+ tables: t.tables.length,
248
+ rows: n,
249
+ masked: u,
250
+ bundleKey: i
251
+ }), Q(200, {
252
+ bundleKey: i,
253
+ tables: t.tables.length,
254
+ rows: n,
255
+ masked: u,
256
+ transport: "storage"
257
+ });
258
+ }
259
+ let d = await Bi(_i({
260
+ dir: f,
261
+ ...l
262
+ }));
263
+ return zi.info("admin.export", {
264
+ transport: "download",
265
+ tables: t.tables.length,
266
+ rows: n,
267
+ masked: u,
268
+ bytes: d.byteLength
269
+ }), {
270
+ status: 200,
271
+ contentType: "application/octet-stream",
272
+ body: d,
273
+ headers: {
274
+ "x-export-tables": String(t.tables.length),
275
+ "x-export-rows": String(n),
276
+ "x-export-masked": String(u)
277
+ }
278
+ };
279
+ } catch (e) {
280
+ return zi.warn("admin.export failed", { error: e?.message ?? String(e) }), Q(500, {
281
+ error: "export failed",
282
+ message: e?.message ?? String(e)
283
+ });
284
+ } finally {
285
+ await d.rm(f, {
286
+ recursive: !0,
287
+ force: !0
288
+ });
289
+ }
290
+ }, Ui = (e, t, n = {}) => (async function* () {
291
+ let r = await ni((await U.runPromise(ei(e, t).pipe(U.timeout(n.openTimeout ?? "30 seconds")))).stream), i = n.stallMs ?? 12e4, a, o = () => {
292
+ a && clearTimeout(a), a = setTimeout(() => r.destroy(/* @__PURE__ */ Error(`storage read stalled for ${i}ms reading '${t}'`)), i);
293
+ };
294
+ try {
295
+ o();
296
+ for await (let e of r) o(), yield e instanceof Uint8Array ? e : new Uint8Array(e);
297
+ } finally {
298
+ a && clearTimeout(a), r.destroy();
299
+ }
300
+ })(), Wi = {
301
+ get: async () => void 0,
302
+ set: async () => {},
303
+ setWithTags: async () => {},
304
+ remove: async () => !1,
305
+ has: async () => !1,
306
+ clear: async () => {},
307
+ invalidateTag: async () => 0,
308
+ wrap: async (e, t, n) => n()
309
+ }, Gi = async (e) => {
310
+ pe(e.appProcedures ?? e.discovered, {
311
+ defaultDeny: e.security?.defaultDeny ?? !0,
312
+ commandHint: "`voltro serve`"
313
+ }), Hr({
314
+ dataStore: e.store,
315
+ schemaRegistry: e.schemaRegistry
316
+ });
317
+ let t = (e.discovered.budgets?.length ?? 0) > 0, n, r = new Xn({
318
+ store: e.store,
319
+ ...e.snapshotCache ? { cache: e.snapshotCache } : {},
320
+ ...e.reactive === void 0 ? {} : { reactive: e.reactive },
321
+ ...t ? { recordCost: (e) => n?.record(e) } : {},
322
+ recordDelivery: (e) => Ir({
323
+ label: e.label,
324
+ kind: e.kind,
325
+ durationMs: e.durationMs,
326
+ rowCount: e.rowCount
327
+ })
328
+ }), i = e.cache ?? Wi, a = e.kv ?? Pr, c, d = () => void 0, ee, f, p, te, se, ce, le, ue = Oe({
329
+ store: e.store,
330
+ warn: (e, t) => {
331
+ process.stderr.write(`[workflow] ${e} ${JSON.stringify(t)}\n`);
332
+ }
333
+ }), fe = ue.remember, he = ue.resolve, _e = y({
334
+ authority: e.authority,
335
+ getStore: () => e.store
336
+ }), _ = (e.discovered.workflows?.length ?? 0) > 0 ? Cr(() => c) : void 0, ve = (e.discovered.workflows?.length ?? 0) > 0 || (e.discovered.eventTriggers?.length ?? 0) > 0, ye = ve || (e.discovered.workflowWorkers?.length ?? 0) > 0 || e.scheduleCoordination === "cluster", Se = e.tenantIsolation === "namespace", Ce = (e.log ?? F({ scope: "voltro:serve" })).child("webhooks"), we, Te, v = e.discovered.webhooks;
337
+ if (v && v.outgoing.length > 0 && e.workflowEngineLayer !== void 0) {
338
+ e.workflowEngineLayer;
339
+ let t = gt({
340
+ store: e.store,
341
+ schemaRegistry: e.schemaRegistry,
342
+ cache: i,
343
+ kv: a
344
+ }), n = v.outgoing.map((e) => e.descriptor);
345
+ Te = ui.toLayer(si(t, { events: n })), we = ci(t, async (e) => {
346
+ let t = p;
347
+ if (t === void 0) {
348
+ Ce.error("webhook delivery skipped — the workflow runtime was never built. This is a framework defect, not a configuration problem: report it with your engine setting. Deliveries are NOT queued and will not be retried.", {
349
+ deliveryId: e.deliveryId,
350
+ targetId: e.targetId
351
+ });
352
+ return;
353
+ }
354
+ t.runPromise(ui.execute(e)).catch((t) => {
355
+ Ce.error("deliverWebhook workflow crashed", {
356
+ deliveryId: e.deliveryId,
357
+ targetId: e.targetId
358
+ }, t);
359
+ });
360
+ }, { events: n });
361
+ }
362
+ let Ae = /* @__PURE__ */ new Map();
363
+ if (v) for (let e of v.incoming) {
364
+ let t = e.descriptor.path ?? li(e.descriptor.id), n = `VOLTRO_WEBHOOK_SECRET_${e.descriptor.id.toUpperCase().replace(/[^A-Z0-9]/g, "_")}`, r = fi(e.descriptor, {
365
+ resolveSecret: async () => process.env[n] ?? null,
366
+ resolveWorkflows: () => _ === void 0 ? void 0 : Nr(_, {
367
+ traceId: `incoming:${e.descriptor.id}`,
368
+ source: `incoming:${e.descriptor.id}`
369
+ }),
370
+ log: (e) => {
371
+ let t = {
372
+ webhookId: e.webhookId,
373
+ status: e.status,
374
+ signatureOk: String(e.signatureOk),
375
+ idempotency: e.idempotency,
376
+ durationMs: e.durationMs
377
+ };
378
+ e.status >= 500 ? Ce.error("incoming delivery failed", t) : e.status >= 400 ? Ce.warn("incoming delivery rejected", t) : Ce.info("incoming delivery handled", t);
379
+ }
380
+ });
381
+ Ae.set(t, { handle: r });
382
+ }
383
+ fr(), Ur((t) => pr(e.store, t.subjectId, t.resourceType, t.resourceId));
384
+ let Ne = [], Pe = [...e.discovered.outboxHandlers ?? [], ...fn((v?.outgoing.length ?? 0) + (v?.incoming.length ?? 0) + (v?.providers.length ?? 0), []) ? [{
385
+ file: "<framework>/webhooks",
386
+ id: "voltro-webhook-emit",
387
+ definition: di(() => we)
388
+ }] : []], Ie = Pe.length > 0 ? g({
389
+ handlers: Pe,
390
+ store: e.store,
391
+ log: (e.log ?? F({ scope: "voltro:serve" })).child("outbox"),
392
+ onChange: (t) => e.store.onChange((e) => t({
393
+ table: e.table,
394
+ op: e.op
395
+ })),
396
+ onShutdown: (e) => {
397
+ Ne.push(e);
398
+ }
399
+ }) : void 0, x = de({
400
+ definitions: (e.discovered.connections ?? []).map((e) => e.definition),
401
+ store: e.store,
402
+ publicUrl: ae(e.port ?? 4e3),
403
+ log: (e.log ?? F({ scope: "voltro:serve" })).child("connections")
404
+ });
405
+ at({
406
+ events: e.discovered.events ?? [],
407
+ rpcTags: [
408
+ ...e.discovered.queries.map((e) => e.descriptor.name),
409
+ ...e.discovered.mutations.map((e) => e.descriptor.name),
410
+ ...e.discovered.actions.map((e) => e.descriptor.name),
411
+ ...(e.discovered.streams ?? []).map((e) => e.descriptor.name)
412
+ ]
413
+ });
414
+ let Re = (e.log ?? F({ scope: "voltro:serve" })).child("events"), Be = e.broadcastNamespace ?? Ze(e.plugins, void 0), Ve = Le(e.plugins, Be, Re), Ue = e.membership?.instanceId ?? process.env.POD_NAME ?? process.env.HOSTNAME ?? `serve-${process.pid}`, We = e.membership ?? kt(e.plugins, {
415
+ instanceId: Ue,
416
+ namespace: Be,
417
+ meta: { mode: "serve" },
418
+ logger: Re
419
+ }), S = me({
420
+ events: e.discovered.events ?? [],
421
+ origin: Ue,
422
+ ...Ve.publishRemote === void 0 ? {} : { publishRemote: Ve.publishRemote }
423
+ }), qe = (e.discovered.events ?? []).length > 0 ? await Ve.attach(S.bus) : null, C = ze({
424
+ store: e.store,
425
+ schemaRegistry: e.schemaRegistry,
426
+ cache: i,
427
+ kv: a,
428
+ ...we === void 0 ? {} : { webhooksService: we },
429
+ ..._ === void 0 ? {} : { workflowsProxy: _ },
430
+ eventTriggers: e.discovered.eventTriggers ?? [],
431
+ namespaceIsolationOn: Se,
432
+ ...e.ensureTenantProvisioned === void 0 ? {} : { ensureTenantProvisioned: e.ensureTenantProvisioned },
433
+ ...e.resolveResidentStore === void 0 ? {} : { resolveResidentStore: e.resolveResidentStore },
434
+ ...Ie === void 0 ? {} : { outbox: { nudge: Ie.nudge } },
435
+ ...x.active ? { connections: { registry: x.registry } } : {},
436
+ eventBus: S.bus
437
+ }), Je = W.succeed(qn, ne), Ye = W.succeed(Zn, He), Xe = W.succeed(Jn, It), $e = W.succeed(q, Ft), et = (t, n) => {
438
+ let r = t.pipe(U.provide(Sr(n)));
439
+ return (e.baseLayer ? r.pipe(U.provide(e.baseLayer)) : r).pipe(U.provide(Je)).pipe(U.provide(Ye)).pipe(U.provide(Xe)).pipe(U.provide($e));
440
+ }, tt = (e, t) => Br(et(e, t)), w = hn(), it = yt(e.plugins ?? [], w), st = u({
441
+ plugins: e.plugins ?? [],
442
+ metrics: w,
443
+ log: e.log ?? F({ scope: "voltro:serve" })
444
+ }), ct = ie(e.plugins ?? [], w), lt = e.security?.defaultDeny ?? !0, dt = Tr({
445
+ store: e.store,
446
+ defaultDeny: lt,
447
+ recordMetric: (e) => {
448
+ w.record(e);
449
+ },
450
+ ...it.mutation === void 0 ? {} : { interceptor: it.mutation },
451
+ buildContext: (e, t, n) => C(e, t, n),
452
+ runEffect: tt,
453
+ undoCapture: xe()
454
+ }), ft = b();
455
+ {
456
+ let t = o();
457
+ t !== void 0 && (e.log ?? F({ scope: "voltro:serve" })).info(t);
458
+ }
459
+ let pt = Me({
460
+ store: e.store,
461
+ ...e.approvals === void 0 ? {} : { defaultExpiryMs: e.approvals.defaultExpiryMs }
462
+ }), mt = mr({
463
+ defaultDeny: lt,
464
+ buildContext: (e) => C(e),
465
+ runEffect: tt,
466
+ recordMetric: (e) => {
467
+ w.record(e);
468
+ },
469
+ ...it.action === void 0 ? {} : { interceptor: it.action }
470
+ }), ht = Or({
471
+ tenantScopedTables: e.tenantScopedTables,
472
+ softDeleteScopedTables: e.softDeleteScopedTables
473
+ }), T = {
474
+ defaultDeny: lt,
475
+ buildContext: (e) => C(e),
476
+ finalize: (e, t) => ht(e, t.subject),
477
+ provideEffect: et,
478
+ ...it.query === void 0 ? {} : { interceptor: it.query }
479
+ }, E = Dr(T), _t = Er({
480
+ ...T,
481
+ queryRows: (t, n) => e.store.query(t).then((e) => qr(t.table, e, n.subject))
482
+ }), vt = Ar({
483
+ ...T,
484
+ subscribeDescriptor: (e, t, n) => r.subscribe(e, t, n),
485
+ subscribeComputed: (e, t, n) => r.subscribeComputed(e, t, n)
486
+ }), D = (e) => e.filter((e) => Dn(e.descriptor)), O = {};
487
+ for (let t of [
488
+ ...D(e.discovered.queries),
489
+ ...ft.queries,
490
+ ...pt.queries,
491
+ ...x.queries
492
+ ]) O[t.descriptor.name] = (e) => Y(E(t, e), r, `subscription.${t.descriptor.name}`, void 0, void 0, kr(t, e));
493
+ for (let t of [
494
+ ...D(e.discovered.mutations),
495
+ ...ft.mutations,
496
+ ...pt.mutations,
497
+ ...x.mutations
498
+ ]) {
499
+ let n = wr(t.descriptor.output);
500
+ O[t.descriptor.name] = (r) => J(async (e, n) => dt(t, e, n), r, `mutation.${t.descriptor.name}`, n, e.idempotency, t.descriptor.error);
501
+ }
502
+ for (let t of [...D(e.discovered.actions), ...x.actions]) {
503
+ let n = wr(t.descriptor.output);
504
+ O[t.descriptor.name] = (r) => J(async (e, n) => mt(t, e, n), r, `action.${t.descriptor.name}`, n, e.idempotency, t.descriptor.error);
505
+ }
506
+ let bt = () => `public-${Math.random().toString(36).slice(2, 10)}`, xt = [
507
+ ...e.discovered.queries.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
508
+ descriptor: e.descriptor,
509
+ invoke: (t, n) => _t(e, t, {
510
+ subject: n.subject,
511
+ traceId: bt()
512
+ }),
513
+ subscribe: (t, n, r) => vt(e, t, {
514
+ subject: n.subject,
515
+ traceId: bt()
516
+ }, r)
517
+ })),
518
+ ...e.discovered.mutations.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
519
+ descriptor: e.descriptor,
520
+ invoke: (t, n) => dt(e, t, {
521
+ subject: n.subject,
522
+ traceId: bt()
523
+ })
524
+ })),
525
+ ...e.discovered.actions.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
526
+ descriptor: e.descriptor,
527
+ invoke: (t, n) => mt(e, t, {
528
+ subject: n.subject,
529
+ traceId: bt()
530
+ })
531
+ }))
532
+ ], St = {
533
+ candidates: m({
534
+ queries: e.discovered.queries,
535
+ mutations: e.discovered.mutations,
536
+ actions: e.discovered.actions,
537
+ descriptorOf: (e) => e.descriptor,
538
+ runQuery: (e, t, n) => Promise.resolve(_t(e, t, n)),
539
+ runMutation: (e, t, n) => Promise.resolve(dt(e, t, n)),
540
+ runAction: (e, t, n) => Promise.resolve(mt(e, t, n))
541
+ }),
542
+ policy: e.agents?.tools ?? {},
543
+ mcpEnabled: e.agents?.mcp === !0,
544
+ resolveSubject: (t) => e.resolveSubject(t, -1).then((e) => e.subject)
545
+ }, wt = s({
546
+ ...e.restRoutes === void 0 ? {} : { restRoutes: e.restRoutes },
547
+ publicApiEntries: xt,
548
+ store: e.store,
549
+ resolveSubject: (t) => e.resolveSubject(t, -1).then((e) => e.subject),
550
+ ...e.idempotency === void 0 ? {} : { idempotency: e.idempotency },
551
+ log: e.log ?? F({ scope: "voltro:serve" })
552
+ }), Tt = e.dataTransferSecret ?? process.env.VOLTRO_DATA_TRANSFER_SECRET, Et = Tt && Tt.length >= 16 ? [{
553
+ method: "POST",
554
+ path: Ai,
555
+ handle: Ri({
556
+ secret: Tt,
557
+ store: e.store,
558
+ ...e.dataTransferSnapshot ? { snapshot: e.dataTransferSnapshot } : {},
559
+ assetSink: bi(Qr()),
560
+ openArchive: (e) => Ui(Qr(), e)
561
+ })
562
+ }, {
563
+ method: "POST",
564
+ path: ji,
565
+ handle: Hi({
566
+ secret: Tt,
567
+ store: e.store,
568
+ snapshot: e.dataTransferSnapshot ?? { tables: [] },
569
+ dialect: e.dataTransferDialect ?? "memory",
570
+ tenantTables: [...e.tenantScopedTables],
571
+ loadProfile: yn,
572
+ assetSource: xi(Qr(), e.store),
573
+ putArchive: async (e, t) => {
574
+ let { Readable: n } = await import("node:stream"), r = Qr(), i = $r("storage", () => n.from(t()));
575
+ await U.runPromise(ti(r, e, i, { contentType: "application/octet-stream" }));
576
+ }
577
+ })
578
+ }] : [], Dt = [
579
+ ...e.httpRoutes ?? [],
580
+ ...wt.httpRoutes,
581
+ ...Et,
582
+ ...x.httpRoutes
583
+ ];
584
+ Object.assign(O, S.handlers);
585
+ for (let t of D(e.discovered.streams ?? [])) O[t.descriptor.name] = (n) => ir((r) => {
586
+ let i = C(r), a = t.executor(n, i);
587
+ if (U.isEffect(a)) {
588
+ let t = a.pipe(U.provide(Sr(i.store)));
589
+ return (e.baseLayer ? t.pipe(U.provide(e.baseLayer)) : t).pipe(U.provide(Je)).pipe(U.provide(Ye)).pipe(U.provide(Xe)).pipe(U.provide($e));
590
+ }
591
+ return typeof a == "object" && a && typeof a.then == "function" ? U.promise(() => a) : a;
592
+ }, `stream.${t.descriptor.name}`);
593
+ for (let t of e.discovered.workflows ?? []) O[t.definition.name] = (e) => J(async (e, n) => {
594
+ let r = n;
595
+ return Nr(_, {
596
+ subject: r.subject,
597
+ traceId: r.traceId,
598
+ source: "workflow-rpc"
599
+ }).start(t.definition.name, e);
600
+ }, e, `workflow.${t.definition.name}`);
601
+ ve && (O[V.name] = (e) => Y(E({
602
+ descriptor: V,
603
+ executor: (e) => {
604
+ let t = e.id;
605
+ return {
606
+ table: "_voltro_workflow_runs",
607
+ order: [{
608
+ column: "startedAt",
609
+ direction: "desc"
610
+ }],
611
+ predicate: K(G("id", t), G("executionId", t)),
612
+ take: 1,
613
+ skip: void 0,
614
+ projection: void 0
615
+ };
616
+ }
617
+ }, e), r, `subscription.${V.name}`), O[Mn.name] = (e) => Y(E({
618
+ descriptor: Mn,
619
+ executor: (e) => {
620
+ let t = e, n = [...t.tag === void 0 ? [] : [G("tag", t.tag)], ...t.status === void 0 ? [] : [G("status", t.status)]], r = Number.isFinite(t.limit) && t.limit !== void 0 ? Math.min(Math.max(Math.floor(t.limit), 1), 500) : 100;
621
+ return {
622
+ table: "_voltro_workflow_runs",
623
+ order: [{
624
+ column: "startedAt",
625
+ direction: "desc"
626
+ }],
627
+ predicate: n.length === 0 ? void 0 : n.length === 1 ? n[0] : Wn(...n),
628
+ take: r,
629
+ skip: void 0,
630
+ projection: void 0
631
+ };
632
+ }
633
+ }, e), r, `subscription.${Mn.name}`), O[H.name] = (e) => Y(E({
634
+ descriptor: H,
635
+ executor: (e) => {
636
+ let t = e.runId;
637
+ return {
638
+ table: "_voltro_workflow_run_steps",
639
+ order: [{
640
+ column: "startedAt",
641
+ direction: "asc"
642
+ }],
643
+ predicate: G("runId", t),
644
+ take: 1e3,
645
+ skip: void 0,
646
+ projection: void 0
647
+ };
648
+ }
649
+ }, e), r, `subscription.${H.name}`), O[B.name] = (e) => Y(E({
650
+ descriptor: B,
651
+ executor: (e) => {
652
+ let t = e.runId;
653
+ return {
654
+ table: "_voltro_workflow_run_events",
655
+ order: [{
656
+ column: "occurredAt",
657
+ direction: "asc"
658
+ }],
659
+ predicate: G("runId", t),
660
+ take: 1e3,
661
+ skip: void 0,
662
+ projection: void 0
663
+ };
664
+ }
665
+ }, e), r, `subscription.${B.name}`), O[An.name] = (e) => Y(E({
666
+ descriptor: An,
667
+ executor: (e) => {
668
+ let t = e;
669
+ return {
670
+ table: "_voltro_workflow_events",
671
+ order: [{
672
+ column: "occurredAt",
673
+ direction: "desc"
674
+ }],
675
+ predicate: t.name === void 0 ? void 0 : G("name", t.name),
676
+ take: Math.max(1, Math.min(500, t.limit ?? 100)),
677
+ skip: void 0,
678
+ projection: void 0
679
+ };
680
+ }
681
+ }, e), r, `subscription.${An.name}`), O[z.name] = (e) => Y(E({
682
+ descriptor: z,
683
+ executor: (e) => {
684
+ let t = e.eventId;
685
+ return {
686
+ table: "_voltro_workflow_event_deliveries",
687
+ order: [{
688
+ column: "createdAt",
689
+ direction: "asc"
690
+ }],
691
+ predicate: G("eventId", t),
692
+ take: 500,
693
+ skip: void 0,
694
+ projection: void 0
695
+ };
696
+ }
697
+ }, e), r, `subscription.${z.name}`), O[kn.name] = (t) => J(async (t, n) => {
698
+ let r = t;
699
+ return await rt(e.store, n.subject, { executionId: r.executionId }), await _.cancel(r.workflowName, r.executionId), await Rt(r.workflowName, r.executionId, "workflow.cancel"), { ok: !0 };
700
+ }, t, `action.${kn.name}`), O[jn.name] = (t) => J(async (t, n) => {
701
+ let r = t;
702
+ return await rt(e.store, n.subject, { executionId: r.executionId }), await _.resume(r.workflowName, r.executionId), { ok: !0 };
703
+ }, t, `action.${jn.name}`), O[Nn.name] = (t) => J(async (t, n) => {
704
+ let r = t;
705
+ return await rt(e.store, n.subject, { id: r.id }), _.signal({ id: r.id }, r.signalName, r.payload);
706
+ }, t, `action.${Nn.name}`), O[Pn.name] = (t) => J(async (t, n) => {
707
+ let r = t;
708
+ return await rt(e.store, n.subject, { id: r.id }), _.update({ id: r.id }, r.updateName, r.payload, r.timeoutMs === void 0 ? void 0 : { timeoutMs: r.timeoutMs });
709
+ }, t, `action.${Pn.name}`));
710
+ let At = [
711
+ ...D(e.discovered.queries).map((e) => R(e.descriptor)),
712
+ ...D(e.discovered.mutations).map((e) => L(e.descriptor)),
713
+ ...D(e.discovered.actions).map((e) => I(e.descriptor)),
714
+ ...ft.queries.map((e) => R(e.descriptor)),
715
+ ...ft.mutations.map((e) => L(e.descriptor)),
716
+ ...pt.queries.map((e) => R(e.descriptor)),
717
+ ...pt.mutations.map((e) => L(e.descriptor)),
718
+ ...x.queries.map((e) => R(e.descriptor)),
719
+ ...x.mutations.map((e) => L(e.descriptor)),
720
+ ...x.actions.map((e) => I(e.descriptor)),
721
+ ...D(e.discovered.streams ?? []).map((e) => On(e.descriptor)),
722
+ ...S.rpcs,
723
+ ...(e.discovered.workflows ?? []).map((e) => Xr(e.definition)),
724
+ ...ve ? [
725
+ R(V),
726
+ R(Mn),
727
+ R(H),
728
+ R(B),
729
+ R(An),
730
+ R(z),
731
+ I(kn),
732
+ I(jn),
733
+ I(Nn),
734
+ I(Pn)
735
+ ] : []
736
+ ], jt = Hn.make(...At).middleware(wn).middleware(Tn), Mt = br({ resolveSubject: ({ headers: t, clientId: n }) => e.resolveSubject(t, n) }), Nt = e.dormancyTenantId ?? Yn, Pt = e.dormancy === "sleep" ? {
737
+ register: (t, n, r) => Rr(e.store, {
738
+ tenantId: r ?? Nt,
739
+ kind: "workflow",
740
+ refId: t,
741
+ wakeAt: n
742
+ }),
743
+ cancel: (t, n) => or(e.store, {
744
+ tenantId: n ?? Nt,
745
+ kind: "workflow",
746
+ refId: t
747
+ }).then(() => {})
748
+ } : void 0, A = ye ? await import("@voltro/workflow") : void 0, j = A?.makeWorkflowRunRecorder({
749
+ store: e.store,
750
+ ...e.workflowRecording === void 0 ? {} : { recording: e.workflowRecording },
751
+ ...Pt === void 0 ? {} : { wakeups: Pt }
752
+ }), Lt = async (t, n) => {
753
+ await A.closeWorkflowChildrenForParent({
754
+ store: e.store,
755
+ parentExecutionId: t,
756
+ parentStatus: n,
757
+ recorder: j,
758
+ log: { warn: (e, t) => {
759
+ process.stderr.write(`[workflow] ${e} ${t ? JSON.stringify(t) : ""}\n`);
760
+ } },
761
+ interruptChild: async (t, n) => {
762
+ let r = (e.discovered.workflows ?? []).find((e) => e.definition.name === t);
763
+ if (!r) throw Error(`Unknown child workflow: ${t}`);
764
+ if (!p) throw Error("Workflow runtime is not ready");
765
+ await p.runPromise(r.definition.interrupt(n));
766
+ }
767
+ });
768
+ }, Rt = async (t, n, r) => {
769
+ let i = (await e.store.query({
770
+ table: "_voltro_workflow_runs",
771
+ order: [],
772
+ predicate: G("executionId", n),
773
+ projection: void 0,
774
+ skip: void 0,
775
+ take: 1
776
+ }))[0];
777
+ if (i === void 0) return;
778
+ let a = await e.store.update("_voltro_workflow_runs", i.id, {
779
+ status: "cancelled",
780
+ cancelled: !0,
781
+ completedAt: /* @__PURE__ */ new Date()
782
+ }), o = i.subject?.tenantId ?? void 0;
783
+ a && await j.recordEvent({
784
+ runId: i.id,
785
+ eventType: "run-cancelled",
786
+ payload: {
787
+ reason: r,
788
+ workflowName: t,
789
+ executionId: n,
790
+ ...o == null ? {} : { tenantId: o }
791
+ }
792
+ }), a && await Lt(n, "cancelled");
793
+ }, zt = [
794
+ ...X(e.discovered.workflows ?? [], {
795
+ buildContext: (t, n) => e.buildContextForWorkflow?.(t, n) ?? C({
796
+ subject: t.subject,
797
+ traceId: t.traceId
798
+ }, e.store, void 0, `workflow:${n.workflowName}`, { parentExecutionId: n.executionId }),
799
+ resolveStartContext: he,
800
+ ..._e === void 0 ? {} : { resolveAuthority: _e }
801
+ }, (t, n, r) => {
802
+ let i = A.getWorkflowVersionMetadata(t.definition);
803
+ return A.wrapWorkflowExecuteWithRunRecording({
804
+ name: t.definition.name,
805
+ store: e.store,
806
+ subject: r.subject,
807
+ source: r.source ?? null,
808
+ traceId: r.traceId,
809
+ workflowVersion: i.version,
810
+ workflowCompatibleVersions: i.compatibleWith,
811
+ workflowPatches: i.patches,
812
+ parentExecutionId: r?.parentExecutionId ?? null,
813
+ parentClosePolicy: r?.parentClosePolicy ?? null,
814
+ onParentClose: ({ executionId: e, status: t }) => Lt(e, t),
815
+ ...Ge(t.definition),
816
+ onTerminal: async ({ executionId: e }) => {
817
+ await f?.gate.release(e);
818
+ },
819
+ recorder: j,
820
+ pluginWorkflowStepLayer: ct,
821
+ recordRun: Lr
822
+ }, n);
823
+ }),
824
+ ...e.discovered.workflowWorkers ?? [],
825
+ ...Te === void 0 ? [] : [Te]
826
+ ], Bt = [...(e.discovered.workflows ?? []).map((e) => e.definition.name).filter(Boolean), ...Te === void 0 ? [] : ["voltro.deliverWebhook"]], Vt = zt.length > 0 ? W.mergeAll(...zt) : W.empty;
827
+ if (((e.discovered.workflows?.length ?? 0) > 0 || (e.discovered.workflowWorkers?.length ?? 0) > 0 || e.scheduleCoordination === "cluster" || Te !== void 0) && e.workflowEngineLayer !== void 0) {
828
+ let t = Vt.pipe(W.provideMerge(e.workflowEngineLayer));
829
+ p = In.make(e.baseLayer === void 0 ? t : t.pipe(W.provideMerge(e.baseLayer))), await p.runPromise(U.void), (e.log ?? F({ scope: "voltro:serve" })).child("workflow").info(`workflow runtime ready — ${Bt.length} entity type(s) registered`, { entities: Bt });
830
+ let n = await import("@voltro/workflow/cluster"), r = (e) => p.runPromise(n.redriveFailedRun(e)), i = (e) => p.runPromise(n.resumeRunFromStep(e));
831
+ ce = await Qe({
832
+ provider: gi(e.plugins ?? [])?.broadcast?.provider,
833
+ crossReplica: gi(e.plugins ?? [])?.broadcast?.crossReplica ?? !1,
834
+ namespace: Be,
835
+ replicaId: crypto.randomUUID(),
836
+ pollStorage: () => p.runPromise(n.pollWorkflowStorage),
837
+ onChange: (t) => e.store.onChange((e) => t({
838
+ table: e.table,
839
+ op: e.op,
840
+ ...e.origin === void 0 ? {} : { origin: e.origin }
841
+ })),
842
+ log: (e.log ?? F({ scope: "voltro:serve" })).child("workflow")
843
+ }), te = async (t) => {
844
+ let n = await oe({
845
+ store: e.store,
846
+ workflows: e.discovered.workflows ?? [],
847
+ runRedrive: r
848
+ }, t.runId);
849
+ return n.statusReset && await j.recordEvent({
850
+ runId: t.runId,
851
+ eventType: "run-redriven",
852
+ payload: {
853
+ reason: "inspect.redrive",
854
+ activitiesReset: n.outcome.activitiesReset
855
+ }
856
+ }), {
857
+ redriven: n.outcome.redriven,
858
+ activitiesReset: n.outcome.activitiesReset,
859
+ reason: n.outcome.reason
860
+ };
861
+ }, se = async (t) => {
862
+ let n = await De({
863
+ store: e.store,
864
+ workflows: e.discovered.workflows ?? [],
865
+ runResume: i
866
+ }, t.runId, t.step);
867
+ return n.statusReset && await j.recordEvent({
868
+ runId: t.runId,
869
+ eventType: "run-redriven",
870
+ payload: {
871
+ reason: "inspect.resume-from-step",
872
+ step: n.stepName,
873
+ activitiesReset: n.outcome.activitiesReset
874
+ }
875
+ }), {
876
+ redriven: n.outcome.redriven,
877
+ stepName: n.stepName,
878
+ activitiesReset: n.outcome.activitiesReset,
879
+ reason: n.outcome.reason
880
+ };
881
+ };
882
+ let a = xr({
883
+ coordinator: (e.scheduleCoordination ?? "single") === "advisoryLock" ? hr(e.store, e.scheduleReplicaId ?? `pid-${process.pid}`) : Wr,
884
+ replicaId: e.scheduleReplicaId ?? `pid-${process.pid}`
885
+ }), o = {
886
+ info: (e, t) => {
887
+ process.stdout.write(`[flow-control] ${e} ${t ? JSON.stringify(t) : ""}\n`);
888
+ },
889
+ warn: (e, t) => {
890
+ process.stderr.write(`[flow-control] ${e} ${t ? JSON.stringify(t) : ""}\n`);
891
+ },
892
+ error: (e, t) => {
893
+ process.stderr.write(`[flow-control] ERROR ${e} ${t ? JSON.stringify(t) : ""}\n`);
894
+ }
895
+ }, s, l = () => {
896
+ if (s !== void 0) return s;
897
+ if (!(c === void 0 || j === void 0)) return s = re({
898
+ store: e.store,
899
+ log: P,
900
+ workflows: e.discovered.workflows ?? [],
901
+ workflowsProxy: c,
902
+ workflowRuntime: p,
903
+ workflowRunRecorder: j,
904
+ closeChildrenForParent: Lt
905
+ }), s;
906
+ };
907
+ d = l, f = nt({
908
+ store: e.store,
909
+ onChange: (t) => e.store.onChange((e) => t({
910
+ table: e.table,
911
+ op: e.op
912
+ })),
913
+ ...e.scheduling === void 0 ? {} : {
914
+ disarmWhenIdle: e.scheduling.disarmWhenIdle,
915
+ drainIntervalMs: e.scheduling.admissionDrainMs,
916
+ cancelSweepIntervalMs: e.scheduling.cancelSweepMs,
917
+ stalenessSweepIntervalMs: e.scheduling.stalenessSweepMs
918
+ },
919
+ workflows: e.discovered.workflows ?? [],
920
+ facade: () => c,
921
+ cancelRunWithReason: l,
922
+ recordRunEvent: () => j?.recordEvent,
923
+ ...e.workflowStaleness === void 0 ? {} : { staleness: e.workflowStaleness },
924
+ ...e.workflowSuspendSignalHintMs === void 0 ? {} : { suspendSignalHintMs: e.workflowSuspendSignalHintMs },
925
+ scheduleCoordinated: a,
926
+ onAbandoned: async (t) => {
927
+ await Ct({
928
+ workflows: e.discovered.workflows ?? [],
929
+ facade: () => c,
930
+ log: o,
931
+ ...t
932
+ });
933
+ },
934
+ log: o
935
+ });
936
+ let u = f;
937
+ u !== void 0 && Fr(() => u.stop()), ee = Ke({
938
+ store: e.store,
939
+ onChange: (t) => e.store.onChange((e) => t({
940
+ table: e.table,
941
+ op: e.op
942
+ })),
943
+ ...e.scheduling === void 0 ? {} : {
944
+ disarmWhenIdle: e.scheduling.disarmWhenIdle,
945
+ tickIntervalMs: e.scheduling.inferenceTickMs
946
+ },
947
+ enabled: (e.discovered.workflows?.length ?? 0) > 0,
948
+ resumeSignal: () => p === void 0 || A === void 0 ? void 0 : async ({ executionId: t, workflowName: n, signalName: r, payload: i }) => {
949
+ await p.runPromise(A.completeSuspendingSignal({
950
+ store: e.store,
951
+ target: Ot(t, n),
952
+ signalName: r,
953
+ payload: i
954
+ }));
955
+ },
956
+ runEffect: (e) => p.runPromise(e),
957
+ scheduleCoordinated: a,
958
+ log: o
959
+ });
960
+ let ne = ee;
961
+ ne !== void 0 && Fr(() => ne.stop()), c = (e.discovered.workflows?.length ?? 0) > 0 ? Mr({
962
+ workflows: e.discovered.workflows ?? [],
963
+ runEffect: (e) => p.runPromise(e),
964
+ onEnqueue: () => ce?.publishWake(),
965
+ ...u === void 0 ? {} : {
966
+ admitStart: u.gate.admitStart,
967
+ startPayloadSchema: u.gate.startPayloadSchema,
968
+ parkDelayedStart: u.gate.parkDelayed
969
+ },
970
+ rememberStartContext: fe,
971
+ signal: async (t, n, r) => {
972
+ let i = await A.sendWorkflowSignal({
973
+ store: e.store,
974
+ recorder: j,
975
+ target: t,
976
+ signalName: n,
977
+ payload: r
978
+ });
979
+ return await p.runPromise(A.completeSuspendingSignal({
980
+ store: e.store,
981
+ target: t,
982
+ signalName: n,
983
+ payload: r
984
+ })).catch(() => {}), i;
985
+ },
986
+ update: (t, n, r, i) => A.sendWorkflowUpdate({
987
+ store: e.store,
988
+ recorder: j,
989
+ target: t,
990
+ updateName: n,
991
+ payload: r,
992
+ ...i === void 0 ? {} : { options: i }
993
+ }),
994
+ listRuns: (t) => ke(e.store, t),
995
+ retry: (t, n) => je({
996
+ store: e.store,
997
+ workflows: e.discovered.workflows ?? [],
998
+ runPromise: (e) => p.runPromise(e)
999
+ }, t, n),
1000
+ redrive: (t) => oe({
1001
+ store: e.store,
1002
+ workflows: e.discovered.workflows ?? [],
1003
+ runRedrive: r
1004
+ }, t).then((e) => e.outcome)
1005
+ }) : void 0;
1006
+ }
1007
+ let M = W.mergeAll(jt.toLayer(O), Mt), Ht = k(O, e.discovered.queries.map((e) => e.descriptor.name), ve), Ut = W.mergeAll(jt.toLayer(Ht), Mt), N = e.observability, Wt = await ar({
1008
+ ...e.appName === void 0 ? {} : { serviceName: e.appName },
1009
+ ...N && N.spanProcessors.length > 0 ? { extraSpanProcessors: N.spanProcessors } : {},
1010
+ ...N && N.metricReaders.length > 0 ? { extraMetricReaders: N.metricReaders } : {},
1011
+ ...N && Object.keys(N.resourceAttributes).length > 0 ? { resourceAttributes: N.resourceAttributes } : {},
1012
+ ...N && N.sampler !== void 0 ? { sampler: N.sampler } : {}
1013
+ }), Gt = !1, Kt = e.store.ping ? () => e.store.ping().then(() => !0).catch(() => !1) : void 0, { server: qt, shutdown: Jt } = Gr({
1014
+ group: jt,
1015
+ handlersLayer: M,
1016
+ httpHandlersLayer: Ut,
1017
+ port: e.port ?? 4e3,
1018
+ ...e.host === void 0 ? {} : { host: e.host },
1019
+ path: e.path ?? "/ws",
1020
+ tracerLayer: Wt.layer,
1021
+ security: be(e),
1022
+ ...st,
1023
+ healthCheck: {
1024
+ isReady: () => Gt,
1025
+ ...Kt ? { ping: Kt } : {}
1026
+ },
1027
+ ...Dt.length > 0 ? { httpRoutes: Dt } : {},
1028
+ ...e.getStore === void 0 ? {} : { getStore: e.getStore },
1029
+ ...Ae.size > 0 ? { webhookRoutes: Ae } : {},
1030
+ ...e.inspectRoute === void 0 ? {} : { inspectRoute: e.inspectRoute }
1031
+ }), Yt = ki(qt);
1032
+ if (await rr(qt), (e.discovered.schedules?.length ?? 0) > 0) {
1033
+ let t = (e.scheduleCoordination ?? "single") === "advisoryLock" ? hr(e.store, e.scheduleReplicaId ?? `pid-${process.pid}`) : Wr;
1034
+ le = await Kr(e.discovered.schedules ?? [], {
1035
+ store: e.store,
1036
+ coordinator: t,
1037
+ defaultTrigger: e.scheduleDefaultTrigger ?? "self",
1038
+ replicaId: e.scheduleReplicaId ?? `pid-${process.pid}`,
1039
+ armSelf: e.scheduleArmSelf ?? !0,
1040
+ dormancy: e.dormancy ?? "always-on",
1041
+ ...e.dormancyTenantId === void 0 ? {} : { dormancyTenantId: e.dormancyTenantId },
1042
+ buildContext: ({ traceId: t, scheduleName: n, subject: r }) => C({
1043
+ subject: r,
1044
+ traceId: t
1045
+ }, e.store, void 0, `schedule:${n}`),
1046
+ log: {
1047
+ info: (e, t) => {
1048
+ process.stdout.write(`[schedule] ${e} ${t ? JSON.stringify(t) : ""}\n`);
1049
+ },
1050
+ warn: (e, t) => {
1051
+ process.stderr.write(`[schedule] ${e} ${t ? JSON.stringify(t) : ""}\n`);
1052
+ },
1053
+ error: (e, t) => {
1054
+ process.stderr.write(`[schedule] ERROR ${e} ${t ? JSON.stringify(t) : ""}\n`);
1055
+ },
1056
+ debug: () => {}
1057
+ },
1058
+ ...e.scheduleFireInterceptor === void 0 ? {} : { interceptFire: e.scheduleFireInterceptor },
1059
+ ...e.onScheduleRunEvent === void 0 ? {} : { onRunEvent: e.onScheduleRunEvent }
1060
+ }), e.onSchedulerReady?.(le);
1061
+ }
1062
+ let P = e.log ?? F({ scope: "voltro:serve" }), Xt, Zt;
1063
+ if ((e.discovered.subscribers?.length ?? 0) > 0 && (Xt = Fe(e.discovered.subscribers ?? [], e.store, P.child("subscribe"), e.schemaRegistry, S.bus)), (e.discovered.reactions?.length ?? 0) > 0) {
1064
+ let t = P.child("reaction"), n = async (n, r) => {
1065
+ if (n.kind === "workflow") {
1066
+ if (_ === void 0) {
1067
+ t.warn("reaction workflow act skipped — no workflow engine in this app", { workflow: n.workflow });
1068
+ return;
1069
+ }
1070
+ let e = n.payload === void 0 ? r.new ?? r.old ?? {} : n.payload(r);
1071
+ await Nr(_, {
1072
+ traceId: `reaction:${n.workflow}`,
1073
+ source: `reaction:${n.workflow}`
1074
+ }).start(n.workflow, e);
1075
+ return;
1076
+ }
1077
+ await ot(n.agent, r, {
1078
+ findAgentSend: (t) => e.discovered.actions.find((e) => e.descriptor.name === `${t}.send`),
1079
+ runAction: (e, t, n) => Promise.resolve(mt(e, t, n)),
1080
+ makeSubject: (e) => En(e),
1081
+ now: () => Date.now(),
1082
+ log: t
1083
+ });
1084
+ }, r = async (n, r) => {
1085
+ try {
1086
+ let { requireAiBudget: t } = await import("@voltro/ai");
1087
+ return (await U.runPromise(U.either(t(e.store, {
1088
+ tenantId: n,
1089
+ limitUsd: r
1090
+ }))))._tag === "Right";
1091
+ } catch (e) {
1092
+ return t.warn("reaction budget check failed — refusing the act", { tenantId: n }, e), !1;
1093
+ }
1094
+ }, i = ut(e.store, { onError: (e) => t.warn("reaction: rate-slot claim failed; refusing the act", { cause: String(e) }) });
1095
+ Zt = l(e.discovered.reactions ?? [], e.store, {
1096
+ runAct: n,
1097
+ checkBudget: r,
1098
+ claimRateSlot: (e) => i.claim(e)
1099
+ }, t);
1100
+ }
1101
+ let Qt;
1102
+ (e.discovered.aggregates?.length ?? 0) > 0 && (Qt = await Ee({
1103
+ discovered: e.discovered.aggregates ?? [],
1104
+ store: e.store,
1105
+ log: P.child("aggregate"),
1106
+ ...e.analytics === void 0 ? {} : { analytics: e.analytics },
1107
+ ...e.aggregateStorage === void 0 ? {} : { storage: e.aggregateStorage },
1108
+ ...e.aggregateCoordinator === void 0 ? {} : { coordinator: e.aggregateCoordinator }
1109
+ }), Je = W.succeed(qn, Qt.registry));
1110
+ let $t;
1111
+ (e.discovered.expectations?.length ?? 0) > 0 && ($t = er({
1112
+ discovered: e.discovered.expectations ?? [],
1113
+ store: e.store,
1114
+ log: P.child("expectation")
1115
+ }), Ye = W.succeed(Zn, $t.registry)), (e.discovered.budgets?.length ?? 0) > 0 && (n = nr({
1116
+ discovered: e.discovered.budgets ?? [],
1117
+ log: P.child("finops")
1118
+ }), Xe = W.succeed(Jn, n.registry));
1119
+ let en;
1120
+ return (e.discovered.experiments?.length ?? 0) > 0 && (en = tr({
1121
+ discovered: e.discovered.experiments ?? [],
1122
+ store: e.store,
1123
+ log: P.child("experiment")
1124
+ }), $e = W.succeed(q, en.registry)), Gt = !0, e.bootTiming?.mark("ready"), {
1125
+ dispatcher: r,
1126
+ server: qt,
1127
+ scheduler: le,
1128
+ eventsSnapshot: ge(S.bus, S.declared),
1129
+ membersSnapshot: () => ({
1130
+ members: We.membership.list(),
1131
+ capturedAt: Date.now()
1132
+ }),
1133
+ agentTools: () => St,
1134
+ rpcMetrics: () => w,
1135
+ webhooksService: () => we,
1136
+ runCanceller: () => d(),
1137
+ flowControlHealth: () => f?.cancelHealth(),
1138
+ inferenceHealth: () => ee?.health(),
1139
+ workflowWriteActions: () => _ === void 0 || j === void 0 ? void 0 : h({
1140
+ store: e.store,
1141
+ log: P,
1142
+ workflows: e.discovered.workflows ?? [],
1143
+ workflowsProxy: c,
1144
+ workflowRuntime: p,
1145
+ workflowRunRecorder: j,
1146
+ closeChildrenForParent: Lt
1147
+ }),
1148
+ redriveWorkflowRun: (e) => te ? te(e) : Promise.reject(/* @__PURE__ */ Error("redrive: this app registers no workflows")),
1149
+ resumeWorkflowRunFromStep: (e) => se ? se(e) : Promise.reject(/* @__PURE__ */ Error("resume-from-step: this app registers no workflows")),
1150
+ close: async () => {
1151
+ Gt = !1, await Yt.drainRequests();
1152
+ for (let e of Ne) try {
1153
+ await e();
1154
+ } catch (e) {
1155
+ P.warn("serve: teardown step failed", {}, e);
1156
+ }
1157
+ await qe?.detach(), await We.detach(), Qt?.detach(), $t?.detach(), n?.detach(), en?.detach(), Zt?.(), Xt?.(), await le?.shutdown(), r.close(), await ce?.detach(), await p?.dispose(), await Jt(), await Yt.finish();
1158
+ }
1159
+ };
1160
+ }, $ = F({ scope: "voltro:serve" }), Ki = (e, t, n) => (e === "production" || e === "staging") && t !== "memory" && n !== "0", qi = Lt, Ji = async (e) => {
1161
+ let t = _n(process.cwd());
1162
+ if (Sn(t)) {
1163
+ let n;
1164
+ try {
1165
+ let e = await import(Cn(t).href);
1166
+ typeof e.runServe == "function" ? n = e.runServe : $.warn("serve bundle has no runServe export — using the standard serve path");
1167
+ } catch (e) {
1168
+ $.warn("serve bundle failed to load — using the standard serve path", {}, e);
1169
+ }
1170
+ if (n) return $.info("serve: booting from the precompiled serve bundle"), n(e);
1171
+ }
1172
+ return Yi(e);
1173
+ }, Yi = async (o) => {
1174
+ let s = vn();
1175
+ e("serve");
1176
+ try {
1177
+ ii();
1178
+ } catch (e) {
1179
+ throw Bt(e instanceof Error ? e.message : String(e));
1180
+ }
1181
+ let l = process.cwd(), u = await Ue(l), ne = Rt({
1182
+ kind: "api",
1183
+ configPort: u?.port,
1184
+ env: process.env,
1185
+ flagPort: qi(o, "--port")
1186
+ });
1187
+ for (let e of ne.warnings) $.warn(e);
1188
+ let re = ne.port;
1189
+ Vr(zr(u?.secrets)), await Vt({
1190
+ rawEnv: u?.env,
1191
+ appType: "api",
1192
+ root: l,
1193
+ log: $,
1194
+ generateTypes: !1
1195
+ }), s.mark("config");
1196
+ let m = (process.env.DB_DIALECT ?? u?.store ?? "memory").toLowerCase(), ie = (m === "mariadb" || m === "postgres" || m === "mssql") && (process.env.CDC ?? "1") !== "0", ae = m === "mariadb" ? "mariadb" : m === "mssql" ? "mssql" : void 0, oe = gn(l);
1197
+ if (!r() && Sn(oe)) try {
1198
+ let e = await import(Cn(oe).href);
1199
+ if (e.modules) {
1200
+ let t = {};
1201
+ for (let [n, r] of Object.entries(e.modules)) t[xn(l, n)] = r;
1202
+ n(t), $.info("precompiled api bundle loaded", { modules: Object.keys(t).length });
1203
+ }
1204
+ } catch (e) {
1205
+ $.warn("precompiled api bundle failed to load — falling back to source", {}, e);
1206
+ }
1207
+ let h = await Je(l), g = await Et(h, { cdc: ie && ae !== void 0 }), de = ce(g);
1208
+ {
1209
+ let e = /* @__PURE__ */ new Set([
1210
+ ...g.queries.filter((e) => e.descriptor.overridesPlugin === !0).map((e) => e.descriptor.name),
1211
+ ...g.mutations.filter((e) => e.descriptor.overridesPlugin === !0).map((e) => e.descriptor.name),
1212
+ ...g.actions.filter((e) => e.descriptor.overridesPlugin === !0).map((e) => e.descriptor.name)
1213
+ ]);
1214
+ qt(Kt(u?.plugins ?? []), [
1215
+ ...g.queries.map((e) => e.descriptor.name),
1216
+ ...g.mutations.map((e) => e.descriptor.name),
1217
+ ...g.actions.map((e) => e.descriptor.name),
1218
+ ...g.streams.map((e) => e.descriptor.name)
1219
+ ], e);
1220
+ let t = se(g.serverOnlyLeaks, Ae(process.env, "strict"), lr, "`voltro serve`");
1221
+ if (t.action === "fail") throw Bt(t.message ?? "");
1222
+ t.action === "warn" && $.warn(t.message ?? "");
1223
+ }
1224
+ let pe = h.filter((e) => mn.test(e)), me = pe.length > 0 ? await pn(pe, $.child("webhooks")) : {
1225
+ outgoing: [],
1226
+ incoming: [],
1227
+ providers: []
1228
+ }, ge = dn(g.events), xe = me.outgoing.length + me.incoming.length + me.providers.length + ge.length === 0 ? void 0 : {
1229
+ ...me,
1230
+ outgoing: [...me.outgoing, ...ge]
1231
+ }, Ee = $t({
1232
+ nodeEnv: process.env.NODE_ENV,
1233
+ cdcDialect: ae,
1234
+ declared: u?.schema
1235
+ }), De = Yt({
1236
+ gates: Ee,
1237
+ runtime: {
1238
+ traces: ye(),
1239
+ undo: Jr()
1240
+ }
1241
+ });
1242
+ if (De !== void 0) throw Bt(`serve: ${De}`);
1243
+ let Oe = Qt({
1244
+ mix: g.featureMix,
1245
+ plugins: u?.plugins ?? [],
1246
+ gates: Ee,
1247
+ ...ae ? { cdcDialect: ae } : {}
1248
+ }), ke = u?.analytics !== void 0 && u.analytics.kind !== "noop" && m !== "memory" ? (await M(m)).makeSqlLayer(T()) : void 0, je = await Ie({
1249
+ spec: u?.analytics,
1250
+ sqlLayer: ke,
1251
+ log: $
1252
+ }), y = (() => {
1253
+ let e = new Set(g.tables.map((e) => e.tableName)), t = [...g.tables];
1254
+ for (let n of [...Oe, ...je.tables]) e.has(n.tableName) || (e.add(n.tableName), t.push(n));
1255
+ return t;
1256
+ })();
1257
+ for (let e of y) Kn(e);
1258
+ {
1259
+ let e = ur(Yr(g.queries.map((e) => ({
1260
+ name: e.descriptor.name,
1261
+ source: e.descriptor.source
1262
+ })), new Set(y.flatMap((e) => {
1263
+ let t = e.tableName;
1264
+ return t === void 0 ? [] : [t];
1265
+ }))));
1266
+ e !== void 0 && $.warn(e);
1267
+ }
1268
+ let Me = (process.env.NODE_ENV ?? "").toLowerCase();
1269
+ if (Ki(Me, m, process.env.VOLTRO_AUTO_MIGRATE)) {
1270
+ let e = (await M(m)).makeSqlLayer(T()), t = await U.runPromise(Ln.SqlClient.pipe(U.flatMap((e) => Bn(e, l)), U.provide(e), U.catchAll(() => U.succeed([]))));
1271
+ t.length > 0 && ($.error(`serve: refusing to boot — ${t.length} pending file-based migration(s) have never run against this database. They perform the changes a schema diff cannot infer (data moves, backfills, table splits), so the declarative fingerprint check below cannot see them and would have let this process serve un-migrated data.`, { pending: t }), $.error("Run them from your pre-deploy job — `voltro db migrate .` (schema + files) or `voltro db files .` (files alone) — or set VOLTRO_AUTO_MIGRATE=0 to bypass every boot schema check. `voltro serve` never applies them itself: a rolling deploy would start N replicas and each would try."), process.exit(1));
1272
+ let n = await U.runPromise(Ln.SqlClient.pipe(U.flatMap((e) => Vn(e, y, {
1273
+ appliedBy: `serve:${Me}`,
1274
+ environment: "prod",
1275
+ dialectId: m
1276
+ })), U.provide(e)));
1277
+ n.kind === "prod-mismatch" && ($.error(zn(n, m)), $.error(Xt({
1278
+ gates: Ee,
1279
+ nodeEnv: process.env.NODE_ENV,
1280
+ cdcDialect: ae,
1281
+ declared: u?.schema
1282
+ })), $.error("serve: refusing to boot — apply the schema first (voltro db apply in a pre-deploy step), or set VOLTRO_AUTO_MIGRATE=0 to bypass this check."), process.exit(1)), $.info(zn(n, m));
1283
+ }
1284
+ await Gt({
1285
+ dialectId: m,
1286
+ tables: y,
1287
+ mode: N(u?.reactiveTriggers),
1288
+ lockSchema: T().schema,
1289
+ makeLayer: async () => (await M(m)).makeSqlLayer(T()),
1290
+ log: {
1291
+ info: (e, t) => $.info(e, t ?? {}),
1292
+ warn: (e, t) => $.warn(e, t ?? {})
1293
+ }
1294
+ });
1295
+ let Fe = jr(y);
1296
+ s.mark("discover");
1297
+ let b = await w(u, void 0), Le = Zr(b, m);
1298
+ for (let e of Ye({
1299
+ dialect: String(u?.store ?? process.env.DB_DIALECT ?? "postgres"),
1300
+ changeStrategy: (process.env.CDC ?? "1") === "0" ? "inline" : "cdc",
1301
+ dbUrl: process.env.DB_URL,
1302
+ crossReplicaBus: gi(u?.plugins ?? [])?.broadcast.crossReplica === !0,
1303
+ tables: g.tables.map((e) => ({
1304
+ tableName: e.tableName,
1305
+ isReactive: e.isReactive === !0
1306
+ })),
1307
+ querySources: g.queries.flatMap((e) => {
1308
+ let t = e.descriptor.source;
1309
+ return t === void 0 ? [] : typeof t == "string" ? [t] : [...t];
1310
+ })
1311
+ })) e.level === "warn" ? $.warn(e.message) : $.info(e.message);
1312
+ {
1313
+ let e = S(Dt({
1314
+ tables: Un().map((e) => ({ tableName: e.tableName })),
1315
+ queries: g.queries.map((e) => ({
1316
+ name: e.descriptor.name,
1317
+ source: e.descriptor.source
1318
+ }))
1319
+ }));
1320
+ e !== void 0 && $.warn(e);
1321
+ }
1322
+ u?.cache && !process.env.CACHE_BACKEND && (process.env.CACHE_BACKEND = u.cache), u?.cacheRedisUrl && !process.env.CACHE_REDIS_URL && (process.env.CACHE_REDIS_URL = u.cacheRedisUrl), u?.cacheRedisDriver && !process.env.CACHE_REDIS_DRIVER && (process.env.CACHE_REDIS_DRIVER = u.cacheRedisDriver), u?.cacheKeyPrefix && !process.env.CACHE_KEY_PREFIX && (process.env.CACHE_KEY_PREFIX = u.cacheKeyPrefix);
1323
+ let { service: ze, invalidationBus: He, snapshotCache: Ge, cache: Ke, semantic: Qe, evictSource: nt, backend: rt, stats: at, dispose: ot } = await lt({
1324
+ env: process.env,
1325
+ semantic: u?.cacheSemantic ?? !1
1326
+ });
1327
+ Qe !== void 0 && $.info("semantic cache enabled — reactive eviction on live writes"), $.info(`cache backend resolved: ${rt}` + (rt === "redis" ? ` (driver ${process.env.CACHE_REDIS_DRIVER ?? "resp"})` : " — in-process, not cross-instance")), b.onChange((e) => {
1328
+ if (U.runFork(He.publish(e.table)), nt !== void 0) {
1329
+ let t = (e.new ?? e.old)?.id;
1330
+ nt({
1331
+ table: e.table,
1332
+ op: e.op,
1333
+ ...t === void 0 ? {} : { id: t }
1334
+ });
1335
+ }
1336
+ }), u?.kv && !process.env.KV_BACKEND && (process.env.KV_BACKEND = u.kv), u?.kvRedisUrl && !process.env.KV_REDIS_URL && (process.env.KV_REDIS_URL = u.kvRedisUrl), u?.kvKeyPrefix && !process.env.KV_KEY_PREFIX && (process.env.KV_KEY_PREFIX = u.kvKeyPrefix);
1337
+ let { kv: ut, service: gt } = await yr({ store: b });
1338
+ $.info(wi(Ut(), Ei(), m === "postgres" && (process.env.CDC ?? "1") !== "0" ? [{ reason: "CDC LISTEN consumer" }] : [], t.replicationSnapshot()?.replicaCount ?? 0)), s.mark("store");
1339
+ let yt = $n({
1340
+ store: b,
1341
+ sink: je.sink,
1342
+ log: $
1343
+ }), Ct = We({
1344
+ store: b,
1345
+ dialect: m,
1346
+ log: { info: (e) => $.info(e) }
1347
+ }), k = u?.plugins ?? [], Ot = process.env.POD_NAME ?? process.env.HOSTNAME ?? `serve-${process.pid}`, Ft, It;
1348
+ m !== "memory" && (Ft = In.make((await M(m)).makeSqlLayer(T())), It = await Ft.runPromise(Ln.SqlClient));
1349
+ let Lt = [
1350
+ "postgres",
1351
+ "mariadb",
1352
+ "mysql",
1353
+ "mssql"
1354
+ ].includes(m) ? hr(b, Ot, $) : Wr, fn = Re(u?.scheduling), _n = xr({
1355
+ maxIdleIntervalMs: fn.pollCeilingMs,
1356
+ coordinator: Lt,
1357
+ replicaId: Ot,
1358
+ log: $
1359
+ }), yn = [], F = process.env.POD_NAME ?? process.env.HOSTNAME ?? `serve-${process.pid}`, wn = gi(u?.plugins ?? [])?.broadcast?.provider, Tn = Ze(u?.plugins, u?.name ?? bn(l));
1360
+ {
1361
+ let e = et(u?.plugins, u?.name ?? bn(l));
1362
+ e !== void 0 && $.warn(e);
1363
+ }
1364
+ let I = kt(u?.plugins, {
1365
+ instanceId: F,
1366
+ namespace: Tn,
1367
+ meta: { mode: "serve" },
1368
+ logger: $
1369
+ }), En = {
1370
+ ...It ? { sql: It } : {},
1371
+ instanceId: F,
1372
+ membership: I.membership,
1373
+ ...wn === void 0 ? {} : { broadcast: wn },
1374
+ broadcastChannels: { presence: hi(Tn, "presence") },
1375
+ scheduleCoordinated: (e, t, n) => {
1376
+ let r = _n(e, t, n);
1377
+ return yn.push(r), r;
1378
+ }
1379
+ };
1380
+ for (let e of k) e.bindDataStore?.(b, En);
1381
+ c({
1382
+ store: b,
1383
+ ...st(),
1384
+ log: $
1385
+ });
1386
+ let Dn = k.filter((e) => typeof e.onChangeEvent == "function");
1387
+ if (Dn.length > 0) {
1388
+ let e = b.changeScope ?? "local";
1389
+ b.onChange((t) => {
1390
+ let n = _e(t, e);
1391
+ for (let e of Dn) U.runFork(e.onChangeEvent(n).pipe(U.catchAllCause((t) => U.sync(() => $.warn(`plugin ${e.name} onChangeEvent failed`, { error: Fn.pretty(t) })))));
1392
+ });
1393
+ }
1394
+ let L = le({
1395
+ plugins: k,
1396
+ appName: u?.name ?? "voltro-api",
1397
+ appType: "api",
1398
+ voltroVersion: process.env.npm_package_version ?? "0.0.0",
1399
+ log: $
1400
+ });
1401
+ k.length && await L.activate(), s.mark("plugins");
1402
+ let R = await L.gatherObservability(), On = {
1403
+ info: (e, t) => process.stdout.write(`[broadcast] ${e} ${t ? JSON.stringify(t) : ""}\n`),
1404
+ warn: (e, t) => process.stderr.write(`[broadcast] ${e} ${t ? JSON.stringify(t) : ""}\n`),
1405
+ debug: () => {}
1406
+ }, kn, An = await _t(b, u, m, Tn, On, (e, t) => {
1407
+ kn?.refreshAll(`broadcast gap: missed ${t} change(s) from ${e}`);
1408
+ }), z = u?.apiKeys, jn = (typeof z == "object" ? z.prefix : void 0) ?? "voltro_", B = z ? cr(b) : void 0, V = B ? _r({ flush: vr(B) }) : void 0;
1409
+ V && Fr(() => V.shutdown());
1410
+ let H = B ? gr(B, {
1411
+ prefix: jn,
1412
+ ...V ? { usage: V } : {}
1413
+ }) : void 0, Mn = H ? [dr(H, { prefix: jn })] : [], Nn = O([...u?.auth?.strategies ?? [], ...Mn], pi(u?.plugins ?? []), u?.auth?.anonymousTenantRequired ?? !1, u?.auth, () => Le), Pn = [...u?.restRoutes ?? [], ...H ? Qn(H, (typeof z == "object" ? z.managementPath : void 0) ?? "/v1/api-keys") : []], Hn = qe(u?.idempotency, b), Wn = k.map((e) => e.services).filter((e) => e !== void 0), G = W.mergeAll(bt({
1414
+ analyticsLayer: je.layer,
1415
+ cacheService: ze,
1416
+ kvService: gt,
1417
+ ...Qe === void 0 ? {} : { semanticCache: Qe },
1418
+ pluginServices: Wn,
1419
+ userLayers: u?.layers ?? []
1420
+ }), mt(u?.http ?? {})), K = await it({
1421
+ files: h,
1422
+ store: b,
1423
+ log: $,
1424
+ seedPolicy: "report",
1425
+ seedPattern: sn,
1426
+ loadSeedFiles: Wt,
1427
+ startupPattern: tn,
1428
+ loadStartupFiles: a,
1429
+ runStartups: i,
1430
+ emailPattern: Be,
1431
+ loadEmailFiles: E,
1432
+ registerEmailTemplates: mi
1433
+ });
1434
+ (K.startupCount > 0 || K.emailCount > 0) && $.info("boot lifecycle", {
1435
+ startups: K.startupCount,
1436
+ emailTemplates: K.emailCount
1437
+ }), K.startups !== void 0 && Fr(async () => {
1438
+ await K.startups.stop();
1439
+ });
1440
+ let qn = ht({
1441
+ schedules: xt({
1442
+ schedules: g.schedules,
1443
+ seeds: K.seeds,
1444
+ store: b,
1445
+ log: $.child("seeds")
1446
+ }),
1447
+ workflows: g.workflows ?? [],
1448
+ log: $.child("workflow-schedules")
1449
+ }), Jn = u?.scheduling ?? {}, Yn = Jn.trigger ?? "self", Xn = /* @__PURE__ */ new Set([
1450
+ "postgres",
1451
+ "mysql",
1452
+ "mariadb",
1453
+ "mssql"
1454
+ ]), Zn = Jn.coordination ?? (Xn.has(m) ? "advisoryLock" : "single"), q = Zn === "cluster" && Xn.has(m), er = q ? "cluster" : Zn === "advisoryLock" && Xn.has(m) ? "advisoryLock" : "single";
1455
+ Zn === "cluster" && !q && $.warn("scheduling.coordination=cluster needs a sql-backed store except sqlite — falling back to single"), Zn === "advisoryLock" && !Xn.has(m) && $.warn("scheduling.coordination=advisoryLock needs a SQL store (the claim-row gate) — falling back to single");
1456
+ let tr, nr = g.workflows.length > 0 || g.workflowWorkers.length > 0 || g.eventTriggers.length > 0 || (xe?.outgoing.length ?? 0) > 0 || q, rr;
1457
+ if (nr) {
1458
+ if (m === "mssql") {
1459
+ let e = await un(process.cwd());
1460
+ e && $.warn(e);
1461
+ }
1462
+ let [{ WorkflowEngine: e }, { makeClusterCronLayer: t, workflowEngineLayer: n, resolveRunnerStorage: r, resolveFailoverTuning: i }] = await Promise.all([import("@effect/workflow"), import("@voltro/workflow/cluster")]), a = q ? qn.filter((e) => (e.trigger ?? Yn) === "self").map((e) => t({
1463
+ name: e.name,
1464
+ cron: sr(e),
1465
+ execute: async () => {
1466
+ await tr?.fireFromCluster(e.name);
1467
+ }
1468
+ })) : [];
1469
+ rr = m === "memory" ? e.layerMemory : await (async () => {
1470
+ let e = await M(m), t = r({ sqliteFamily: e.id === "sqlite" || e.id === "turso" });
1471
+ return $.info(`workflow engine: cluster-${t}, dialect=${e.id}` + (t === "memory" ? " — single-process durable replay, no cross-pod shard handoff" + (e.id !== "sqlite" && e.id !== "turso" ? " (VOLTRO_WORKFLOW_RUNNER_STORAGE=memory: SqlRunnerStorage/cluster_runners + GET_LOCK skipped)" : "") : "")), n({
1472
+ sqlClientLayer: e.makeSqlLayer(T()),
1473
+ runnerStorage: t,
1474
+ dialectId: e.id,
1475
+ ...process.env.VOLTRO_WORKFLOW_RUNNER_PORT ? { runnerListenPort: Number(process.env.VOLTRO_WORKFLOW_RUNNER_PORT) } : {},
1476
+ ...i(),
1477
+ ...a.length > 0 ? { extraShardingLayers: a } : {}
1478
+ });
1479
+ })();
1480
+ }
1481
+ let J = ue(k, hn()), ir = h.filter((e) => /\.subscribe\.tsx?$/.test(e)), Y = ir.length > 0 ? await Ne(ir, $) : [], ar = h.filter((e) => /\.reaction\.tsx?$/.test(e)), or = ar.length > 0 ? await he(ar, $) : [], fr = h.filter((e) => an.test(e)), pr = fr.length > 0 ? await D(fr, $) : [], mr = h.filter((e) => /\.aggregate\.tsx?$/.test(e)), br = mr.length > 0 ? await p(mr, $) : [], Sr = ve();
1482
+ if (br.length > 0 && m !== "memory") try {
1483
+ Sr = ct((await M(m)).makeSqlLayer(T()));
1484
+ } catch (e) {
1485
+ $.warn("aggregate: SQL storage init failed — falling back to in-process", { err: String(e) });
1486
+ }
1487
+ let Cr = m === "memory" ? Wr : hr(b, `aggregate@${process.pid}`, $), wr = h.filter((e) => on.test(e)), Tr = wr.length > 0 ? await ee(wr, $) : [], Er = h.filter((e) => rn.test(e)), Dr = Er.length > 0 ? await Te(Er, $) : [], Or = h.filter((e) => nn.test(e)), kr = Or.length > 0 ? await Nt(Or, $) : [], Ar = [], Mr = [], Nr = h.filter((e) => Zt.test(e));
1488
+ if (Nr.length > 0) {
1489
+ let e = $.child("agent"), t = h.filter((e) => P.test(e));
1490
+ t.length > 0 && await en(t, e);
1491
+ let n = await Jt(Nr, e);
1492
+ for (let e of n.agents) for (let t of C(e)) (t.kind === "action" ? Ar : Mr).push({
1493
+ file: t.file,
1494
+ descriptor: t.descriptor,
1495
+ executor: t.executor
1496
+ });
1497
+ n.agents.length > 0 && e.info("synthesized agent routes", { agents: n.agents.map((e) => e.descriptor.name) });
1498
+ }
1499
+ s.mark("workflow");
1500
+ let X = () => {
1501
+ let e = Z.workflowWriteActions();
1502
+ if (e === void 0) throw Error("workflow actions: this app registers no workflows");
1503
+ return e;
1504
+ }, Pr = Gn({
1505
+ dialect: m,
1506
+ ...T()
1507
+ }), Ir = m === "memory" ? void 0 : (await M(m)).makeSqlLayer(T()), Lr = async () => Tt({
1508
+ sqlLayer: Ir,
1509
+ declared: y,
1510
+ log: $
1511
+ }), Rr = {
1512
+ kind: "api",
1513
+ meta: {
1514
+ name: u?.name ?? "voltro-api",
1515
+ voltroVersion: wt,
1516
+ port: re,
1517
+ mode: "start",
1518
+ store: m,
1519
+ cdc: ie ? "on" : "off",
1520
+ ...Pr === void 0 ? {} : { databaseId: Pr }
1521
+ },
1522
+ rpc: ft(g, l),
1523
+ workflows: tt(g, l),
1524
+ migrations: Lr,
1525
+ events: () => Z.eventsSnapshot(),
1526
+ agentTools: () => Z.agentTools(),
1527
+ invariantChecks: () => ({
1528
+ mode: "serve",
1529
+ accessGate: de,
1530
+ config: u,
1531
+ serverOnlyLeaks: g.serverOnlyLeaks,
1532
+ migrations: Lr
1533
+ }),
1534
+ members: () => Z.membersSnapshot(),
1535
+ inspectFireSchedule: async ({ name: e, trigger: t }) => {
1536
+ if (!tr) throw Error("scheduler not started — this app registers no self-triggered schedules (all schedules are trigger:'external', or there are none).");
1537
+ return { runId: await tr.fireNow(e, t) ?? null };
1538
+ },
1539
+ inspectBackfillSchedule: te({
1540
+ getHandle: () => tr,
1541
+ getSchedules: () => qn
1542
+ }),
1543
+ ...xe === void 0 ? {} : { webhooks: () => _({
1544
+ store: b,
1545
+ discoveredWebhooks: xe
1546
+ }) },
1547
+ plugins: () => ({
1548
+ plugins: L.snapshot(),
1549
+ capturedAt: Date.now()
1550
+ }),
1551
+ env: () => zt(u?.name ?? bn(l), {
1552
+ ...u?.env !== void 0 && ri(u.env) ? { contract: u.env } : {},
1553
+ plugins: u?.plugins ?? []
1554
+ }),
1555
+ dataCache: () => Ve({
1556
+ stats: at,
1557
+ backendKind: rt
1558
+ }),
1559
+ subscriptions: () => Pt(() => kn),
1560
+ inspectTables: () => fe(g.tables),
1561
+ inspectRows: Ce({
1562
+ store: b,
1563
+ tables: g.tables,
1564
+ mask: !0
1565
+ }),
1566
+ metrics: (e) => Z.rpcMetrics().snapshot(e),
1567
+ cluster: () => A({
1568
+ store: b,
1569
+ dialect: m,
1570
+ useClusterCron: q,
1571
+ scheduleCoordChoice: Zn
1572
+ }),
1573
+ inspectSchedules: () => v({
1574
+ schedules: qn,
1575
+ defaultTrigger: Yn,
1576
+ coordination: er
1577
+ }),
1578
+ inspectScheduleRuns: (e) => Mt(b, e),
1579
+ ...d(b, {
1580
+ controls: pt(g.workflows ?? []),
1581
+ active: (g.workflows?.length ?? 0) > 0,
1582
+ cancellation: () => Z.flowControlHealth()
1583
+ }),
1584
+ webhookActions: we(() => Z.webhooksService()),
1585
+ inspectStartWorkflow: (e) => X().inspectStartWorkflow(e),
1586
+ inspectCancelWorkflowRun: (e) => X().inspectCancelWorkflowRun(e),
1587
+ inspectSuspendWorkflowRun: (e) => X().inspectSuspendWorkflowRun(e),
1588
+ inspectResumeWorkflowRun: (e) => X().inspectResumeWorkflowRun(e),
1589
+ inspectDiscardWorkflowRun: (e) => X().inspectDiscardWorkflowRun(e),
1590
+ inspectRetryWorkflowRun: (e) => X().inspectRetryWorkflowRun(e),
1591
+ inspectSignalWorkflowRun: (e) => X().inspectSignalWorkflowRun(e),
1592
+ inspectUpdateWorkflowRun: (e) => X().inspectUpdateWorkflowRun(e),
1593
+ inspectInferences: (e) => Xe({
1594
+ store: b,
1595
+ active: (g.workflows?.length ?? 0) > 0,
1596
+ dispatcher: () => Z.inferenceHealth()
1597
+ }, e.limit === void 0 ? {} : { limit: e.limit }),
1598
+ ...vt({
1599
+ store: b,
1600
+ cancelRun: async (e) => await Z.runCanceller()?.(e) ?? !1,
1601
+ retryRun: async (e) => X().inspectRetryWorkflowRun({ runId: e }),
1602
+ redriveRun: async (e) => Z.redriveWorkflowRun({ runId: e }),
1603
+ log: $
1604
+ }),
1605
+ inspectRedriveWorkflowRun: (e) => Z.redriveWorkflowRun(e),
1606
+ inspectResumeWorkflowRunFromStep: (e) => Z.resumeWorkflowRunFromStep(e)
1607
+ }, Br = (process.env.VOLTRO_TENANT_ISOLATION ?? u?.tenancy?.isolation) === "namespace", Hr = Br && m !== "memory" ? await (async () => {
1608
+ let e = await M(m);
1609
+ return St({
1610
+ tables: y,
1611
+ sqlLayer: e.makeSqlLayer(T()),
1612
+ dialect: m,
1613
+ options: { retryFilter: e.retryFilter },
1614
+ log: {
1615
+ info: (e, t) => $.info(e, t),
1616
+ error: (e, t, n) => $.error(e, t ?? {}, n)
1617
+ }
1618
+ });
1619
+ })() : void 0, Ur = await dt({
1620
+ input: u?.tenancy?.residency,
1621
+ namespaceIsolationOn: Br,
1622
+ makeStoreForUrl: (e, t) => w(u, void 0, Ht(T(), t)),
1623
+ log: {
1624
+ info: (e, t) => $.info(e, t),
1625
+ warn: (e, t) => $.warn(e, t)
1626
+ }
1627
+ });
1628
+ Ur !== void 0 && Fr(async () => {
1629
+ await Ur.close();
1630
+ });
1631
+ let Z = await Gi({
1632
+ bootTiming: s,
1633
+ broadcastNamespace: Tn,
1634
+ scheduling: (() => {
1635
+ let e = fn;
1636
+ return {
1637
+ admissionDrainMs: e.admissionDrainMs,
1638
+ inferenceTickMs: e.inferenceTickMs,
1639
+ cancelSweepMs: e.cancelSweepMs,
1640
+ stalenessSweepMs: e.stalenessSweepMs,
1641
+ disarmWhenIdle: $e({
1642
+ changeScope: b.changeScope,
1643
+ broadcastAttached: An !== void 0
1644
+ })
1645
+ };
1646
+ })(),
1647
+ ...u?.workflows?.staleness === void 0 ? {} : { workflowStaleness: u.workflows.staleness },
1648
+ ...u?.workflows?.suspendSignalHintMs === void 0 ? {} : { workflowSuspendSignalHintMs: u.workflows.suspendSignalHintMs },
1649
+ workflowRecording: jt(u?.workflows?.recording),
1650
+ membership: {
1651
+ ...I,
1652
+ instanceId: F
1653
+ },
1654
+ security: {
1655
+ defaultDeny: j(u),
1656
+ ...be(u)
1657
+ },
1658
+ approvals: { defaultExpiryMs: Pe(u) },
1659
+ ...u?.plugins === void 0 ? {} : { plugins: u.plugins },
1660
+ ...Hn ? { idempotency: Hn } : {},
1661
+ restRoutes: Pn,
1662
+ appProcedures: de,
1663
+ discovered: {
1664
+ queries: [...g.queries, ...Mr],
1665
+ mutations: g.mutations,
1666
+ actions: [...g.actions, ...Ar],
1667
+ streams: g.streams,
1668
+ events: g.events,
1669
+ workflows: g.workflows,
1670
+ workflowWorkers: g.workflowWorkers,
1671
+ eventTriggers: g.eventTriggers,
1672
+ schedules: qn,
1673
+ subscribers: Y,
1674
+ outboxHandlers: pr,
1675
+ connections: g.connections,
1676
+ reactions: or,
1677
+ aggregates: br,
1678
+ expectations: Tr,
1679
+ budgets: Dr,
1680
+ experiments: kr,
1681
+ ...xe === void 0 ? {} : { webhooks: xe }
1682
+ },
1683
+ log: $,
1684
+ analytics: je.sink,
1685
+ aggregateStorage: Sr,
1686
+ aggregateCoordinator: Cr,
1687
+ store: b,
1688
+ kv: ut,
1689
+ cache: Ke,
1690
+ snapshotCache: Ge,
1691
+ ...u?.reactive === void 0 ? {} : { reactive: u.reactive },
1692
+ schemaRegistry: Fe,
1693
+ tenantScopedTables: g.tenantScopedTables,
1694
+ softDeleteScopedTables: g.softDeleteScopedTables,
1695
+ dataTransferSnapshot: Rn(y),
1696
+ dataTransferDialect: m,
1697
+ ...Hr === void 0 ? {} : { ensureTenantProvisioned: Hr.ensure },
1698
+ ...Ur === void 0 ? {} : { resolveResidentStore: Ur.resolveStore },
1699
+ tenantIsolation: (process.env.VOLTRO_TENANT_ISOLATION ?? u?.tenancy?.isolation) === "namespace" ? "namespace" : "shared-schema",
1700
+ resolveSubject: (e, t) => Nn({
1701
+ headers: e,
1702
+ clientId: t
1703
+ }),
1704
+ ...u?.auth === void 0 ? {} : { authority: u.auth },
1705
+ ...u?.agents === void 0 ? {} : { agents: u.agents },
1706
+ httpRoutes: k.flatMap((e) => e.httpRoutes ?? []),
1707
+ getStore: () => Le,
1708
+ ...G ? { baseLayer: G } : {},
1709
+ ...rr === void 0 ? {} : { workflowEngineLayer: rr },
1710
+ scheduleDefaultTrigger: Yn,
1711
+ scheduleCoordination: er,
1712
+ scheduleArmSelf: !q,
1713
+ dormancy: process.env.VOLTRO_DORMANCY === "sleep" || process.env.VOLTRO_DORMANCY === "always-on" ? process.env.VOLTRO_DORMANCY : u?.dormancy ?? "always-on",
1714
+ scheduleReplicaId: process.env.HOSTNAME ?? `pid-${process.pid}`,
1715
+ ...J === void 0 ? {} : { scheduleFireInterceptor: J },
1716
+ onSchedulerReady: (e) => {
1717
+ tr = e;
1718
+ },
1719
+ inspectRoute: { handle: async (e, t, n, r) => await f(e, Rr, t, {
1720
+ method: n,
1721
+ ...r === void 0 ? {} : { body: r }
1722
+ }) || ((n === "GET" ? await ln(e, Rr, t, { method: n }) : null) ?? cn(e, Rr, t, {
1723
+ method: n,
1724
+ ...r === void 0 ? {} : { body: r }
1725
+ }) ?? {
1726
+ status: 404,
1727
+ contentType: "application/json",
1728
+ body: JSON.stringify({ error: "not an inspect route" })
1729
+ }) },
1730
+ ...u?.name === void 0 ? {} : { appName: u.name },
1731
+ observability: R,
1732
+ port: re,
1733
+ ...u?.transport?.wsPath ? { path: u.transport.wsPath } : {}
1734
+ });
1735
+ return kn = Z.dispatcher, At(x([
1736
+ g.queries,
1737
+ g.mutations,
1738
+ g.actions,
1739
+ g.streams
1740
+ ]), (e) => {
1741
+ $.warn(e);
1742
+ }), $.info(`API listening on :${re}`, {
1743
+ dialect: m,
1744
+ queries: g.queries.length,
1745
+ mutations: g.mutations.length,
1746
+ actions: g.actions.length,
1747
+ streams: g.streams.length,
1748
+ workflows: g.workflows.length,
1749
+ workflowWorkers: g.workflowWorkers.length,
1750
+ schedules: qn.length,
1751
+ scheduleCoordination: er
1752
+ }), s.finish($), Fr(async () => {
1753
+ for (let e of yn) e.stop();
1754
+ Ct.stop();
1755
+ try {
1756
+ await Z.close(), ot(), Ft?.dispose(), await L.deactivate(), await An?.close(), await Se({
1757
+ mirror: yt,
1758
+ log: $
1759
+ }), await je.dispose(), await b.close?.();
1760
+ } catch (e) {
1761
+ console.error("serve: shutdown step failed, exiting anyway:", e);
1762
+ }
1763
+ }), await new Promise(() => {}), 0;
1764
+ };
1765
+ //#endregion
1766
+ export { Ji as n, Ki as r, Yi as t };