@voltro/cli 0.50.1 → 0.52.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 (170) hide show
  1. package/CHANGELOG.md +231 -0
  2. package/dist/{agentsMd-D6yD7IQv.js → agentsMd-0l980yhL.js} +4 -1
  3. package/dist/agentsMd-SDDSkyl4.js +2 -0
  4. package/dist/apiBuild-BYBpL7Pz.js +2 -0
  5. package/dist/{apiBuild-D3s7lx57.js → apiBuild-CSFI8QGq.js} +3 -3
  6. package/dist/appGraph-CFmFKHb2.js +2 -0
  7. package/dist/appGraph-yRuKjOba.js +111 -0
  8. package/dist/bin.js +1 -1
  9. package/dist/build-CPgcMQug.js +793 -0
  10. package/dist/checkCommand-2SbqzukH.js +2 -0
  11. package/dist/{checkCommand-DsKIjL6k.js → checkCommand-COmqc2cB.js} +107 -60
  12. package/dist/{cloudCmd-F4YJeqM3.js → cloudCmd-QUXh-b5w.js} +1 -1
  13. package/dist/codegen-CctkDO-1.js +2 -0
  14. package/dist/{codegen-CrMXs4hb.js → codegen-VF479Cnb.js} +1 -1
  15. package/dist/{codegenCommand-C0S27nbB.js → codegenCommand-DCdG2JN-.js} +12 -12
  16. package/dist/{codemodRunner-DwY8Rjbl.js → codemodRunner-r7J9lIa7.js} +771 -636
  17. package/dist/{commands-Brp4DI8u.js → commands-Cc_nV8WI.js} +37 -36
  18. package/dist/{dashboardCommand-bbLfc9FW.js → dashboardCommand-C-gKvwqh.js} +3 -3
  19. package/dist/{dataCommand-k9mXTXin.js → dataCommand-BgpBHnlB.js} +299 -253
  20. package/dist/dbCommand-DNb6yeOG.js +2 -0
  21. package/dist/{dbCommand-Bf7Cy0mn.js → dbCommand-sHedr-NJ.js} +3 -3
  22. package/dist/dev--A3nsxA3.js +3 -0
  23. package/dist/{dev-C0cbqysu.js → dev-CRHoCEiy.js} +2258 -2219
  24. package/dist/doctorCommand-CqoWA2p5.js +2 -0
  25. package/dist/{doctorCommand-DyViaaCP.js → doctorCommand-DtfJ3FA6.js} +314 -234
  26. package/dist/{dormancyCommand-DMZPA_HW.js → dormancyCommand-Drn7o0No.js} +1 -1
  27. package/dist/{embeddingsCommand-CMxRPkg6.js → embeddingsCommand-Z-jO1fWN.js} +1 -1
  28. package/dist/{envCommand-CDLr-yD4.js → envCommand-D4gCrrTZ.js} +15 -15
  29. package/dist/{evolveCommand-Ct4NesL3.js → evolveCommand-CMROeKeA.js} +2 -2
  30. package/dist/fileConventions-DOqD3lPS.js +34 -0
  31. package/dist/{fileTaxonomy-CJfgOllU.js → fileTaxonomy-DvDUV9wq.js} +1 -1
  32. package/dist/frameworkTableAssembly-C6ETawPR.js +2 -0
  33. package/dist/{frameworkTableAssembly-BwJVEKLr.js → frameworkTableAssembly-w-XnLa3q.js} +1 -1
  34. package/dist/{generateCommand-BDdOxhnv.js → generateCommand-DTNPGjxo.js} +1 -1
  35. package/dist/index.js +1 -1
  36. package/dist/{infoCommand-orsKJKUy.js → infoCommand-DXM868o_.js} +1 -1
  37. package/dist/inspectMetrics-CGF94puw.js +143 -0
  38. package/dist/{metaCommands-CfRLra0s.js → metaCommands-C6RFmF1r.js} +2 -2
  39. package/dist/{migrate-D3MK9BpK.js → migrate-D0F-eTlK.js} +2 -2
  40. package/dist/{pageConvention-cEiRxdab.js → pageConvention-CzUiSbtU.js} +1 -1
  41. package/dist/{privacyCommand-XejDMvmu.js → privacyCommand-DGdopOI6.js} +1 -1
  42. package/dist/{projectScaffold-mIX_DpSe.js → projectScaffold-B4dmTlwT.js} +1 -1
  43. package/dist/{projectScaffold-BIl97_E6.js → projectScaffold-EzlErR4E.js} +1 -1
  44. package/dist/{renderModeScan-D7J1B7Kw.js → renderModeScan-CcH2X1_D.js} +25 -10
  45. package/dist/{renderProfile-1OWWAAtx.js → renderProfile-Ck32Fzxr.js} +2 -2
  46. package/dist/{runtimeTrace-Bo8jWsNe.js → runtimeTrace-BPQyCmC5.js} +1 -1
  47. package/dist/{sdkgen-OZhiT2vz.js → sdkgen-Se88ifTd.js} +1 -1
  48. package/dist/serveCommand-DLc-BznW.js +2 -0
  49. package/dist/{serveCommand-YbD5VgfV.js → serveCommand-DkP3OT0W.js} +885 -868
  50. package/dist/serveEntry.js +1 -1
  51. package/dist/start-DfL3fOiN.js +3 -0
  52. package/dist/start-jw89Xbqy.js +1339 -0
  53. package/dist/startEntry.js +1 -1
  54. package/dist/{staticCommand-Dr2M6tpU.js → staticCommand-BwNEDlSU.js} +1 -1
  55. package/dist/{test-rXFq4S76.js → test-f3amja6a.js} +1 -1
  56. package/dist/updateCommand-5gFVfK5q.js +2 -0
  57. package/dist/{updateCommand-BgH6vTtq.js → updateCommand-BMk2e4ky.js} +1 -1
  58. package/dist/{webDev-BbdkzMbd.js → webDev-BgWL9gKV.js} +1233 -853
  59. package/dist/webDev-CZbTsDcH.js +2 -0
  60. package/dist/{webhooksCommand-DjE6u0r4.js → webhooksCommand-CoIO3jbj.js} +1 -1
  61. package/package.json +48 -17
  62. package/templates/AGENTS.core.md +26 -5
  63. package/templates/AGENTS.md +30 -9
  64. package/templates/agent-docs/_index.md +4 -4
  65. package/templates/agent-docs/_manifest.json +11 -11
  66. package/templates/agent-docs/cli.md +125 -14
  67. package/templates/agent-docs/data.md +210 -7
  68. package/templates/agent-docs/database/schema.md +1 -1
  69. package/templates/agent-docs/database/seedsdialects.md +1 -1
  70. package/templates/agent-docs/deployment.md +22 -3
  71. package/templates/agent-docs/internationalization.md +131 -13
  72. package/templates/agent-docs/introduction.md +46 -0
  73. package/templates/agent-docs/local-first-mobile.md +34 -7
  74. package/templates/agent-docs/plugins/ai-flows.md +1 -1
  75. package/templates/agent-docs/plugins/audit.md +5 -5
  76. package/templates/agent-docs/plugins/cdc-out.md +2 -2
  77. package/templates/agent-docs/plugins/{versioning.md → row-history.md} +22 -22
  78. package/templates/agent-docs/plugins/storage.md +2 -2
  79. package/templates/agent-docs/plugins.md +29 -7
  80. package/templates/agent-docs/reference.md +39 -2
  81. package/templates/agent-docs/routing.md +341 -47
  82. package/templates/agent-docs/schema-driven-ui.md +78 -2
  83. package/templates/agent-docs/security.md +125 -8
  84. package/templates/agent-docs/templates/apibackends.md +14 -14
  85. package/templates/agent-docs/templates/overview.md +1 -1
  86. package/templates/agent-docs/whats-new.md +100 -29
  87. package/templates/apps/api-ai/package.json +6 -7
  88. package/templates/apps/api-ai/tests/summarize.test.ts +1 -1
  89. package/templates/apps/api-auth/package.json +8 -8
  90. package/templates/apps/api-backend/package.json +7 -7
  91. package/templates/apps/api-backend-deactivation/package.json +7 -7
  92. package/templates/apps/api-backend-mail/package.json +8 -8
  93. package/templates/apps/api-backend-mariadb/package.json +9 -9
  94. package/templates/apps/api-backend-sqlite/package.json +8 -8
  95. package/templates/apps/api-backend-storage/package.json +8 -8
  96. package/templates/apps/api-cms/package.json +9 -10
  97. package/templates/apps/api-collab/package.json +8 -8
  98. package/templates/apps/api-data-advanced/package.json +8 -8
  99. package/templates/apps/api-durable/package.json +8 -8
  100. package/templates/apps/api-feature-flags/package.json +9 -9
  101. package/templates/apps/api-governance/package.json +8 -8
  102. package/templates/apps/api-kv/package.json +8 -8
  103. package/templates/apps/api-moderation/package.json +8 -8
  104. package/templates/apps/api-observability/package.json +8 -8
  105. package/templates/apps/api-ratelimit/package.json +8 -8
  106. package/templates/apps/api-rbac/package.json +8 -8
  107. package/templates/apps/api-rest/package.json +7 -7
  108. package/templates/apps/{api-versioning → api-row-history}/README.md +3 -3
  109. package/templates/apps/{api-versioning → api-row-history}/actions/documents.asOf.action.server.ts +1 -1
  110. package/templates/apps/{api-versioning → api-row-history}/actions/documents.history.action.server.ts +1 -1
  111. package/templates/apps/{api-versioning → api-row-history}/app.config.ts +3 -3
  112. package/templates/apps/{api-versioning → api-row-history}/database/schema.ts +1 -1
  113. package/templates/apps/{api-versioning → api-row-history}/mutations/documents.create.mutation.server.ts +1 -1
  114. package/templates/apps/{api-versioning → api-row-history}/mutations/documents.create.mutation.ts +1 -1
  115. package/templates/apps/{api-versioning → api-row-history}/mutations/documents.update.mutation.ts +1 -1
  116. package/templates/apps/{api-versioning → api-row-history}/package.json +8 -8
  117. package/templates/apps/api-row-history/template.json +6 -0
  118. package/templates/apps/{api-versioning → api-row-history}/tests/documents.create.test.ts +1 -1
  119. package/templates/apps/api-saas/app.config.ts +1 -0
  120. package/templates/apps/api-saas/package.json +10 -11
  121. package/templates/apps/api-saas-starter/package.json +10 -10
  122. package/templates/apps/api-search/package.json +8 -8
  123. package/templates/apps/api-status/package.json +8 -8
  124. package/templates/apps/api-webhooks/package.json +9 -9
  125. package/templates/apps/changelog/package.json +6 -6
  126. package/templates/apps/edge-functions/package.json +2 -2
  127. package/templates/apps/frontend-admin/package.json +8 -8
  128. package/templates/apps/frontend-app/package.json +9 -9
  129. package/templates/apps/frontend-auth/package.json +8 -8
  130. package/templates/apps/frontend-blank/package.json +7 -7
  131. package/templates/apps/frontend-cms/package.json +9 -9
  132. package/templates/apps/frontend-collab/package.json +10 -10
  133. package/templates/apps/frontend-collab/src/pages/page.test.tsx +10 -9
  134. package/templates/apps/frontend-collab/src/pages/page.tsx +42 -65
  135. package/templates/apps/frontend-contact/package.json +7 -7
  136. package/templates/apps/frontend-dashboard/package.json +7 -7
  137. package/templates/apps/frontend-docs/package.json +6 -7
  138. package/templates/apps/frontend-i18n/package.json +6 -6
  139. package/templates/apps/frontend-landing/package.json +6 -7
  140. package/templates/apps/frontend-portal/package.json +8 -8
  141. package/templates/apps/frontend-saas/package.json +8 -8
  142. package/templates/apps/frontend-spa/package.json +7 -7
  143. package/templates/apps/frontend-ssr/package.json +7 -7
  144. package/templates/apps/frontend-ssr-api/package.json +8 -8
  145. package/templates/apps/frontend-static-blog/package.json +6 -6
  146. package/templates/apps/frontend-status/package.json +8 -8
  147. package/templates/apps/mobile-app/package.json +4 -4
  148. package/dist/agentsMd-Bu_XQgVf.js +0 -2
  149. package/dist/apiBuild-BZ-plaQN.js +0 -2
  150. package/dist/appGraph-CM9wvUmD.js +0 -2
  151. package/dist/appGraph-Cv2W_wO5.js +0 -111
  152. package/dist/build-CFmqF39c.js +0 -721
  153. package/dist/checkCommand-DomvYDi1.js +0 -2
  154. package/dist/codegen-DiMn2KkZ.js +0 -2
  155. package/dist/dbCommand-Bnl7MSGC.js +0 -2
  156. package/dist/dev-Dz9GqA6P.js +0 -3
  157. package/dist/doctorCommand-BlciWUJb.js +0 -2
  158. package/dist/fileConventions-Cof68_BL.js +0 -33
  159. package/dist/frameworkTableAssembly-CVDB2hCq.js +0 -2
  160. package/dist/inspectMetrics-CfdKLh6t.js +0 -72
  161. package/dist/serveCommand-Bbgg7Paq.js +0 -2
  162. package/dist/start-7b_bL8Uc.js +0 -3
  163. package/dist/start-B1nH9ahf.js +0 -1150
  164. package/dist/updateCommand-BweY17z-.js +0 -2
  165. package/dist/webDev-BcRFTsMA.js +0 -2
  166. package/templates/apps/api-versioning/template.json +0 -6
  167. /package/templates/apps/{api-versioning → api-row-history}/actions/documents.asOf.action.ts +0 -0
  168. /package/templates/apps/{api-versioning → api-row-history}/actions/documents.history.action.ts +0 -0
  169. /package/templates/apps/{api-versioning → api-row-history}/mutations/documents.update.mutation.server.ts +0 -0
  170. /package/templates/apps/{api-versioning → api-row-history}/tsconfig.json +0 -0
@@ -4,50 +4,50 @@ import { r as n, t as r } from "./appModuleLoader-C9r9mxZt.js";
4
4
  import { t as i } from "./bootRefusal-pgvDxlrU.js";
5
5
  import { n as a, r as o } from "./startupRunner-CEqQq7ax.js";
6
6
  import { t as s } from "./interruptedReplace-C3O3M1MM.js";
7
- import { $ as c, $t as l, A as u, At as d, Bt as f, C as ee, Cn as te, Ct as ne, D as p, Dt as m, E as h, En as re, Et as g, F as ie, Ft as ae, G as oe, Gt as se, H as _, Ht as ce, I as le, It as ue, J as de, Jt as v, K as y, Kt as fe, L as b, Lt as pe, M as me, Mt as he, N as ge, Nt as _e, O as ve, Ot as ye, P as be, Pt as xe, Q as Se, Qt as Ce, R as x, Rt as we, S as Te, St as Ee, T as De, Tn as Oe, Tt as S, U as ke, V as Ae, W as je, Wt as Me, X as Ne, Xt as Pe, Y as Fe, Yt as C, Z as Ie, Zt as Le, _ as w, _n as Re, _t as T, an as ze, at as Be, b as Ve, bn as He, bt as Ue, c as We, cn as Ge, ct as Ke, dn as qe, dt as Je, en as Ye, et as Xe, f as Ze, fn as Qe, ft as $e, g as et, gt as tt, h as nt, hn as rt, ht as it, i as at, in as ot, it as st, j as ct, jt as lt, k as ut, kt as dt, ln as ft, lt as pt, m as mt, mn as ht, mt as gt, nn as _t, nt as E, o as D, on as vt, ot as O, p as k, pn as yt, pt as bt, q as xt, qt as St, r as Ct, rn as A, rt as wt, sn as j, st as Tt, t as Et, tn as Dt, tt as Ot, u as kt, un as At, ut as jt, v as Mt, vn as Nt, vt as M, w as N, wn as Pt, wt as Ft, x as It, xn as Lt, xt as Rt, y as zt, yn as Bt, yt as Vt, zt as Ht } from "./dev-C0cbqysu.js";
8
- import { n as Ut } from "./cliArgs-D4p8n7EE.js";
9
- import { r as P } from "./appPort-B_HpJ_ck.js";
10
- import { ht as Wt, pt as Gt } from "./webDev-BbdkzMbd.js";
11
- import { r as F } from "./dialectDriver-czCHYpeH.js";
12
- import { i as Kt, n as qt } from "./connectionConfig-Bk9IC7D0.js";
13
- import { c as Jt, n as I, o as Yt } from "./seedRunner-Dgsiwk_e.js";
14
- import { b as Xt, d as Zt, h as Qt, m as $t, p as en, r as tn, y as nn } from "./frameworkTableAssembly-BwJVEKLr.js";
7
+ import { $ as c, $t as l, A as u, At as d, Bt as f, C as ee, Ct as p, D as te, Dn as ne, Dt as m, E as h, En as re, Et as ie, F as ae, Ft as oe, G as se, Gt as g, H as ce, I as _, It as le, J as ue, Jt as de, K as fe, Kt as pe, L as me, Lt as v, M as y, Mt as he, N as ge, Nt as _e, O as ve, Ot as ye, P as be, Pt as xe, Q as Se, Qt as Ce, R as we, Rt as Te, S as b, Sn as Ee, St as De, T as Oe, Tn as ke, Tt as Ae, U as je, Ut as x, Vt as Me, W as S, X as Ne, Xt as Pe, Y as Fe, Yt as C, Z as Ie, Zt as Le, _ as Re, _t as ze, an as Be, at as Ve, b as He, bn as Ue, bt as w, c as We, cn as Ge, ct as Ke, d as qe, dn as Je, dt as Ye, en as Xe, et as Ze, fn as Qe, ft as $e, g as et, gn as tt, gt as nt, h as rt, hn as it, ht as at, i as ot, in as st, it as ct, j as lt, jt as ut, k as dt, kt as ft, ln as pt, lt as mt, m as T, mn as ht, mt as gt, nn as E, nt as D, o as O, on as _t, ot as vt, p as yt, pn as k, pt as bt, q as xt, qt as St, r as Ct, rn as wt, rt as Tt, sn as Et, st as Dt, t as Ot, tn as kt, tt as At, u as jt, un as A, ut as Mt, v as Nt, vn as Pt, vt as j, w as M, wn as Ft, wt as It, x as Lt, xn as Rt, xt as zt, y as Bt, yn as Vt, yt as Ht, z as Ut, zt as Wt } from "./dev-CRHoCEiy.js";
8
+ import { n as N } from "./cliArgs-D4p8n7EE.js";
9
+ import { r as Gt } from "./appPort-B_HpJ_ck.js";
10
+ import { Dt as Kt, Tt as qt } from "./webDev-BgWL9gKV.js";
11
+ import { r as P } from "./dialectDriver-czCHYpeH.js";
12
+ import { i as Jt, n as Yt } from "./connectionConfig-Bk9IC7D0.js";
13
+ import { c as F, n as Xt, o as Zt } from "./seedRunner-Dgsiwk_e.js";
14
+ import { d as Qt, h as $t, m as en, p as tn, r as nn } from "./frameworkTableAssembly-w-XnLa3q.js";
15
15
  import { n as rn, r as an, t as on } from "./declaredSchemaGates-BlcwObhb.js";
16
- import { S as sn, c as cn, n as ln, p as un, s as dn, x as fn } from "./fileConventions-Cof68_BL.js";
16
+ import { S as sn, c as cn, n as ln, p as un, s as dn, x as fn } from "./fileConventions-DOqD3lPS.js";
17
17
  import { h as pn, o as mn } from "./inspect-CtL_xTbu.js";
18
- import { n as hn } from "./mssqlClusterPatch-_4cE_nun.js";
19
- import { i as gn, n as _n, r as vn, t as yn } from "./webhookDiscovery-CphsQe59.js";
20
- import { t as bn } from "./inspectMetrics-CfdKLh6t.js";
21
- import { r as xn, u as Sn } from "./apiBuild-D3s7lx57.js";
22
- import { t as Cn } from "./bootTiming-BdyP9nYw.js";
23
- import { a as wn, o as Tn, t as En } from "./dataProfile-Du3ztYxv.js";
24
- import L, { basename as Dn, join as On } from "node:path";
25
- import { createWriteStream as kn, existsSync as An } from "node:fs";
26
- import { pathToFileURL as jn } from "node:url";
27
- import { createLogger as R } from "@voltro/logger";
28
- import { AuthMiddleware as Mn, ConnectionInfoMiddleware as Nn, actionToRpc as Pn, anonymousSubject as Fn, isWireReachable as In, mutationToRpc as Ln, queryToRpc as z, streamToRpc as Rn, wireErrorUnion as zn, workflowCancelDescriptor as Bn, workflowDomainEventsQueryDescriptor as B, workflowEventDeliveriesQueryDescriptor as Vn, workflowResumeDescriptor as Hn, workflowRunEventsQueryDescriptor as Un, workflowRunQueryDescriptor as Wn, workflowRunStepsQueryDescriptor as Gn, workflowRunsQueryDescriptor as Kn, workflowSignalDescriptor as V, workflowUpdateDescriptor as H } from "@voltro/protocol";
29
- import { DATA_TRANSFERS_TABLE as U, _voltroDataTransfersTable as qn, allRegisteredTables as Jn, and as Yn, connectionIdentity as Xn, derivedRowId as Zn, describeTransferRun as Qn, ensureTableRegistered as $n, eq as W, or as er } from "@voltro/database";
30
- import { Cause as tr, Effect as G, Layer as K, ManagedRuntime as nr } from "effect";
31
- import { SqlClient as rr } from "@effect/sql";
32
- import { declaredSnapshot as ir, describeOutcome as ar, pendingFileMigrationIds as or, runPlannedMigrations as sr } from "@voltro/database/sql";
33
- import { AggregateRegistry as cr, CostRegistry as lr, DORMANCY_WAKEUP_TENANT as ur, Dispatcher as dr, ExpectationRegistry as fr, ExperimentRegistry as pr, apiKeyManagementRoutes as mr, attachAnalyticsMirror as hr, attachExpectations as gr, attachExperiments as _r, attachFinops as vr, awaitServerListening as yr, bindMutation as q, bindStream as br, bindSubscription as xr, buildTracingLayer as Sr, cancelWakeup as Cr, compileCron as wr, dataStoreApiKeyStore as Tr, formatServerOnlyLeaks as Er, formatUnresolvedSources as Dr, frameworkApiKeyStrategy as Or, getResourcePolicy as kr, installPolicyGuardResolver as Ar, loadResourceTuples as jr, makeActionRunner as Mr, makeAdvisoryLockCoordinator as Nr, makeApiKeyService as Pr, makeApiKeyUsageBuffer as Fr, makeApiKeyUsageFlusher as Ir, makeAsyncKv as Lr, makeAuthMiddlewareLayers as Rr, makeCoordinatedScheduler as zr, makeEffectStoreLayer as Br, makeLazyWorkflowFacade as Vr, makeMutationOutputCodec as Hr, makeMutationRunner as J, makeOneShotQueryRunner as Ur, makeQueryDescriptorProducer as Wr, makeQueryFinalizer as Gr, makeQueryReauthorizer as Kr, makeQuerySubscriber as qr, makeSchemaRegistry as Jr, makeWorkflowFacade as Yr, makeWorkflowFacadeWithCallerContext as Xr, makeWorkflowLayers as Y, noopKv as Zr, onProcessShutdown as Qr, recordSubscriptionDelivery as $r, recordWorkflowRun as ei, registerDefaultTupleSource as ti, registerWakeup as ni, resolveSecretsBackend as ri, runProvidedEffect as ii, setSecretsBackend as ai, setSystemStoreHandle as oi, shutdownGraceMsFromEnv as si, singleCoordinator as ci, startRpcServer as li, startScheduler as ui, stripForbiddenForWire as di, undoCaptureEnabled as fi, unresolvedSources as pi, withScopedRequest as mi, workflowToRpc as hi, wrapStoreWithBootCodec as gi } from "@voltro/runtime";
34
- import _i, { tmpdir as vi } from "node:os";
35
- import { RpcGroup as yi } from "@effect/rpc";
36
- import { appStorageProvider as bi, durabilityNotice as xi, fromNodeReadable as Si, getObjectStream as Ci, putObjectStream as wi, toNodeReadable as Ti } from "@voltro/plugin-storage";
37
- import { isEnvContract as Ei } from "@voltro/env";
38
- import { assertProductionSessionSecret as Di } from "@voltro/protocol/session";
18
+ import { i as hn, n as gn, t as _n } from "./inspectMetrics-CGF94puw.js";
19
+ import { n as vn } from "./mssqlClusterPatch-_4cE_nun.js";
20
+ import { i as yn, n as bn, r as xn, t as Sn } from "./webhookDiscovery-CphsQe59.js";
21
+ import { r as Cn, u as wn } from "./apiBuild-CSFI8QGq.js";
22
+ import { t as Tn } from "./bootTiming-BdyP9nYw.js";
23
+ import { a as En, o as Dn, t as On } from "./dataProfile-Du3ztYxv.js";
24
+ import I, { basename as kn, join as An } from "node:path";
25
+ import { createWriteStream as jn, existsSync as Mn } from "node:fs";
26
+ import { pathToFileURL as Nn } from "node:url";
27
+ import { createLogger as L } from "@voltro/logger";
28
+ import { AuthMiddleware as Pn, ConnectionInfoMiddleware as Fn, actionToRpc as In, anonymousSubject as Ln, isWireReachable as Rn, mutationToRpc as zn, queryToRpc as R, streamToRpc as Bn, wireErrorUnion as Vn, workflowCancelDescriptor as Hn, workflowDomainEventsQueryDescriptor as z, workflowEventDeliveriesQueryDescriptor as Un, workflowResumeDescriptor as Wn, workflowRunEventsQueryDescriptor as Gn, workflowRunQueryDescriptor as Kn, workflowRunStepsQueryDescriptor as qn, workflowRunsQueryDescriptor as Jn, workflowSignalDescriptor as B, workflowUpdateDescriptor as V } from "@voltro/protocol";
29
+ import { DATA_TRANSFERS_TABLE as H, _voltroDataTransfersTable as Yn, allRegisteredTables as Xn, and as Zn, connectionIdentity as Qn, derivedRowId as $n, describeTransferRun as er, ensureTableRegistered as tr, eq as U, or as nr } from "@voltro/database";
30
+ import { Cause as rr, Effect as W, Layer as G, ManagedRuntime as ir } from "effect";
31
+ import { SqlClient as ar } from "@effect/sql";
32
+ import { declaredSnapshot as or, describeOutcome as sr, pendingFileMigrationIds as cr, runPlannedMigrations as lr } from "@voltro/database/sql";
33
+ import { AggregateRegistry as ur, CostRegistry as dr, DORMANCY_WAKEUP_TENANT as fr, Dispatcher as pr, ExpectationRegistry as mr, ExperimentRegistry as hr, apiKeyManagementRoutes as gr, attachAnalyticsMirror as _r, attachExpectations as vr, attachExperiments as yr, attachFinops as br, awaitServerListening as xr, bindMutation as K, bindStream as Sr, bindSubscription as q, buildTracingLayer as Cr, cancelWakeup as wr, compileCron as Tr, dataStoreApiKeyStore as Er, formatServerOnlyLeaks as Dr, formatUnresolvedSources as Or, frameworkApiKeyStrategy as kr, getResourcePolicy as Ar, installPolicyGuardResolver as jr, loadResourceTuples as Mr, makeActionRunner as Nr, makeAdvisoryLockCoordinator as Pr, makeApiKeyService as Fr, makeApiKeyUsageBuffer as Ir, makeApiKeyUsageFlusher as Lr, makeAsyncKv as Rr, makeAuthMiddlewareLayers as zr, makeCoordinatedScheduler as Br, makeEffectStoreLayer as Vr, makeLazyWorkflowFacade as Hr, makeMutationOutputCodec as Ur, makeMutationRunner as J, makeOneShotQueryRunner as Wr, makeQueryDescriptorProducer as Gr, makeQueryFinalizer as Kr, makeQueryReauthorizer as qr, makeQuerySubscriber as Jr, makeSchemaRegistry as Yr, makeWorkflowFacade as Xr, makeWorkflowFacadeWithCallerContext as Zr, makeWorkflowLayers as Y, noopKv as Qr, onProcessShutdown as $r, recordSubscriptionDelivery as ei, recordWorkflowRun as ti, registerDefaultTupleSource as ni, registerWakeup as ri, resolveSecretsBackend as ii, runProvidedEffect as ai, setSecretsBackend as oi, setSystemStoreHandle as si, shutdownGraceMsFromEnv as ci, singleCoordinator as li, startRpcServer as ui, startScheduler as di, stripForbiddenForWire as fi, undoCaptureEnabled as pi, unresolvedSources as mi, withScopedRequest as hi, workflowToRpc as gi, wrapStoreWithBootCodec as _i } from "@voltro/runtime";
34
+ import vi, { tmpdir as yi } from "node:os";
35
+ import { RpcGroup as bi } from "@effect/rpc";
36
+ import { appStorageProvider as xi, durabilityNotice as Si, fromNodeReadable as Ci, getObjectStream as wi, putObjectStream as Ti, toNodeReadable as Ei } from "@voltro/plugin-storage";
37
+ import { isEnvContract as Di } from "@voltro/env";
38
+ import { assertProductionSessionSecret as Oi } from "@voltro/protocol/session";
39
39
  import X from "node:fs/promises";
40
- import { createHash as Oi, timingSafeEqual as ki } from "node:crypto";
41
- import { buildDeliverWebhookExecute as Ai, buildWebhooksService as ji, defaultIncomingPath as Mi, deliverWebhookWorkflow as Ni, makeDeferredEmitHandler as Pi, mountIncomingWebhook as Fi } from "@voltro/plugin-webhooks";
42
- import { getAuthSessionStrategy as Ii } from "@voltro/plugin-auth";
43
- import { registerEmailTemplates as Li } from "@voltro/plugin-mail";
44
- import { channelFor as Ri, getBroadcastPlugin as zi } from "@voltro/plugin-broadcast";
45
- import { checkSchemaDrift as Bi, decideStaging as Vi, isEnvironmentLocal as Hi, packBundle as Ui, peekBundle as Wi, runExport as Gi, runImport as Ki, storageBlobSink as qi, storageRefsBlobSource as Ji, unpackBundle as Yi, unpackBundleToDir as Xi } from "@voltro/data-transfer";
40
+ import { createHash as ki, timingSafeEqual as Ai } from "node:crypto";
41
+ import { channelFor as ji, getBroadcastPlugin as Mi } from "@voltro/plugin-broadcast";
42
+ import { buildDeliverWebhookExecute as Ni, buildWebhooksService as Pi, defaultIncomingPath as Fi, deliverWebhookWorkflow as Ii, makeDeferredEmitHandler as Li, mountIncomingWebhook as Ri } from "@voltro/plugin-webhooks";
43
+ import { getAuthSessionStrategy as zi } from "@voltro/plugin-auth";
44
+ import { registerEmailTemplates as Bi } from "@voltro/plugin-mail";
45
+ import { checkSchemaDrift as Vi, decideStaging as Hi, isEnvironmentLocal as Ui, packBundle as Wi, peekBundle as Gi, runExport as Ki, runImport as qi, storageBlobSink as Ji, storageRefsBlobSource as Yi, unpackBundle as Xi, unpackBundleToDir as Zi } from "@voltro/data-transfer";
46
46
  //#region \0rolldown/runtime.js
47
- var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, { get: (e, t) => (typeof require < "u" ? require : e)[t] }) : e)(function(e) {
47
+ var Qi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, { get: (e, t) => (typeof require < "u" ? require : e)[t] }) : e)(function(e) {
48
48
  if (typeof require < "u") return require.apply(this, arguments);
49
49
  throw Error("Calling `require` for \"" + e + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
50
- }), Qi = () => Math.max(500, Math.floor(si() * .6)), $i = (e) => new Promise((t) => setTimeout(t, e)), ea = (e) => {
50
+ }), $i = () => Math.max(500, Math.floor(ci() * .6)), ea = (e) => new Promise((t) => setTimeout(t, e)), ta = (e) => {
51
51
  let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), r = 0;
52
52
  e.on("connection", (e) => {
53
53
  t.add(e), e.once("close", () => {
@@ -61,14 +61,14 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
61
61
  });
62
62
  });
63
63
  let i, a = async (t = {}) => {
64
- let n = t.budgetMs ?? Qi();
64
+ let n = t.budgetMs ?? $i();
65
65
  i ??= new Promise((t) => {
66
66
  e.close(() => {
67
67
  t();
68
68
  });
69
69
  }), e.closeIdleConnections();
70
70
  let a = Date.now() + n;
71
- for (; r > 0 && Date.now() < a;) await $i(25), e.closeIdleConnections();
71
+ for (; r > 0 && Date.now() < a;) await ea(25), e.closeIdleConnections();
72
72
  e.closeIdleConnections();
73
73
  }, o = async () => {
74
74
  i ??= new Promise((t) => {
@@ -85,7 +85,7 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
85
85
  ]));
86
86
  } catch {}
87
87
  else e.destroy();
88
- for (let e = 0; t.size > 0 && e < 250; e += 25) await $i(25);
88
+ for (let e = 0; t.size > 0 && e < 250; e += 25) await ea(25);
89
89
  for (let e of t) e.destroy();
90
90
  await i;
91
91
  };
@@ -97,83 +97,83 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
97
97
  await a(e), await o();
98
98
  }
99
99
  };
100
- }, ta = "/_voltro/admin/import", na = "/_voltro/admin/import/start", ra = "/_voltro/admin/export", ia = "/_voltro/admin/export/download", aa = "/_voltro/admin/transfers", Z = (e, t) => ({
100
+ }, na = "/_voltro/admin/import", ra = "/_voltro/admin/import/start", ia = "/_voltro/admin/export", aa = "/_voltro/admin/export/download", oa = "/_voltro/admin/transfers", Z = (e, t) => ({
101
101
  status: e,
102
102
  contentType: "application/json; charset=utf-8",
103
103
  body: JSON.stringify(t)
104
- }), oa = (e) => {
104
+ }), sa = (e) => {
105
105
  let t = e.authorization ?? e.Authorization, n = t ? /^Bearer\s+(.+)$/i.exec(t) : null;
106
106
  return n ? n[1] : null;
107
- }, sa = (e, t) => ki(Oi("sha256").update(e).digest(), Oi("sha256").update(t).digest()), ca = (e, t, n = "POST") => {
107
+ }, ca = (e, t) => Ai(ki("sha256").update(e).digest(), ki("sha256").update(t).digest()), la = (e, t, n = "POST") => {
108
108
  if (e.method.toUpperCase() !== n) return Z(405, { error: "method not allowed" });
109
109
  if (!t || t.length < 16) return Z(503, { error: "data transfer misconfigured (no/weak secret)" });
110
- let r = oa(e.headers);
111
- return !r || !sa(r, t) ? Z(401, { error: "unauthorized" }) : null;
112
- }, la = /^[A-Za-z0-9_-]{8,64}$/, ua = (e) => la.test(e), da = () => process.env.VOLTRO_IMPORT_UPLOAD_DIR ?? L.join(_i.tmpdir(), "voltro-import-uploads"), fa = (e) => L.join(da(), e), pa = (e) => L.join(fa(e), "archive.bin"), ma = (e) => L.join(fa(e), "meta.json"), ha = async (e = Date.now()) => {
110
+ let r = sa(e.headers);
111
+ return !r || !ca(r, t) ? Z(401, { error: "unauthorized" }) : null;
112
+ }, ua = /^[A-Za-z0-9_-]{8,64}$/, da = (e) => ua.test(e), fa = () => process.env.VOLTRO_IMPORT_UPLOAD_DIR ?? I.join(vi.tmpdir(), "voltro-import-uploads"), pa = (e) => I.join(fa(), e), ma = (e) => I.join(pa(e), "archive.bin"), ha = (e) => I.join(pa(e), "meta.json"), ga = async (e = Date.now()) => {
113
113
  let t = 0;
114
114
  try {
115
- for (let n of await X.readdir(da())) {
115
+ for (let n of await X.readdir(fa())) {
116
116
  if (n === ".runs") continue;
117
- let r = await X.stat(fa(n)).catch(() => null);
118
- r !== null && (e - r.mtimeMs <= 864e5 || (await X.rm(fa(n), {
117
+ let r = await X.stat(pa(n)).catch(() => null);
118
+ r !== null && (e - r.mtimeMs <= 864e5 || (await X.rm(pa(n), {
119
119
  recursive: !0,
120
120
  force: !0
121
121
  }).catch(() => void 0), t++));
122
122
  }
123
123
  } catch {}
124
124
  return t;
125
- }, ga = async (e) => {
126
- if (!ua(e)) return {
125
+ }, _a = async (e) => {
126
+ if (!da(e)) return {
127
127
  bytes: 0,
128
128
  key: null,
129
129
  runId: null
130
130
  };
131
- let t = await X.stat(pa(e)).catch(() => null);
131
+ let t = await X.stat(ma(e)).catch(() => null);
132
132
  if (t === null) return {
133
133
  bytes: 0,
134
134
  key: null,
135
135
  runId: null
136
136
  };
137
- let n = await _a(e);
137
+ let n = await va(e);
138
138
  return {
139
139
  bytes: t.size,
140
140
  key: n.key ?? null,
141
141
  runId: n.runId ?? null
142
142
  };
143
- }, _a = async (e) => {
143
+ }, va = async (e) => {
144
144
  try {
145
- let t = await X.readFile(ma(e), "utf8");
145
+ let t = await X.readFile(ha(e), "utf8");
146
146
  return JSON.parse(t);
147
147
  } catch {
148
148
  return {};
149
149
  }
150
- }, va = async (e, t) => {
151
- let n = ma(e), r = `${n}.${process.pid}.${Math.random().toString(36).slice(2, 8)}.tmp`;
150
+ }, ya = async (e, t) => {
151
+ let n = ha(e), r = `${n}.${process.pid}.${Math.random().toString(36).slice(2, 8)}.tmp`;
152
152
  await X.writeFile(r, JSON.stringify(t)), await X.rename(r, n);
153
- }, ya = async (e, t, n) => {
154
- if (!ua(e)) return t;
155
- await X.mkdir(fa(e), { recursive: !0 });
156
- let r = await _a(e), i = typeof r.runId == "string" && r.runId.length > 0 ? r.runId : null;
157
- return i !== null && n?.takeOver !== !0 ? i : (await va(e, {
153
+ }, ba = async (e, t, n) => {
154
+ if (!da(e)) return t;
155
+ await X.mkdir(pa(e), { recursive: !0 });
156
+ let r = await va(e), i = typeof r.runId == "string" && r.runId.length > 0 ? r.runId : null;
157
+ return i !== null && n?.takeOver !== !0 ? i : (await ya(e, {
158
158
  ...r,
159
159
  runId: t
160
160
  }), t);
161
- }, ba = async (e) => {
162
- if (!ua(e)) return;
163
- let t = await _a(e);
161
+ }, xa = async (e) => {
162
+ if (!da(e)) return;
163
+ let t = await va(e);
164
164
  if (t.runId === void 0) return;
165
165
  let { runId: n, ...r } = t;
166
- await va(e, r).catch(() => void 0);
167
- }, xa = async (e, t, n) => (await X.mkdir(fa(e), { recursive: !0 }), await X.writeFile(pa(e), Buffer.from(t)), await va(e, {
168
- ...await _a(e),
166
+ await ya(e, r).catch(() => void 0);
167
+ }, Sa = async (e, t, n) => (await X.mkdir(pa(e), { recursive: !0 }), await X.writeFile(ma(e), Buffer.from(t)), await ya(e, {
168
+ ...await va(e),
169
169
  key: n,
170
170
  startedAt: (/* @__PURE__ */ new Date()).toISOString()
171
- }), t.byteLength), Sa = (e) => `up-${Oi("sha256").update(e).digest("hex").slice(0, 32)}`, Ca = async (e) => {
172
- if (!ua(e.id)) return {
171
+ }), t.byteLength), Ca = (e) => `up-${ki("sha256").update(e).digest("hex").slice(0, 32)}`, wa = async (e) => {
172
+ if (!da(e.id)) return {
173
173
  reason: "bad-id",
174
- message: `upload id must match ${String(la)}`
174
+ message: `upload id must match ${String(ua)}`
175
175
  };
176
- let t = await ga(e.id);
176
+ let t = await _a(e.id);
177
177
  if (t.key !== null && t.key !== e.key) return {
178
178
  reason: "key-mismatch",
179
179
  message: "this upload id already holds a different bundle. Use a new upload id, or delete the partial upload."
@@ -183,34 +183,34 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
183
183
  message: `chunk starts at ${e.offset} but the server holds ${t.bytes} byte(s)`,
184
184
  expectedOffset: t.bytes
185
185
  };
186
- if (await X.mkdir(fa(e.id), { recursive: !0 }), t.key === null) {
187
- let t = await _a(e.id);
188
- await va(e.id, {
186
+ if (await X.mkdir(pa(e.id), { recursive: !0 }), t.key === null) {
187
+ let t = await va(e.id);
188
+ await ya(e.id, {
189
189
  ...t,
190
190
  key: e.key,
191
191
  startedAt: (/* @__PURE__ */ new Date()).toISOString()
192
192
  });
193
193
  }
194
194
  return await new Promise((t, n) => {
195
- let r = kn(pa(e.id), { flags: "a" });
195
+ let r = jn(ma(e.id), { flags: "a" });
196
196
  r.on("error", n), r.on("finish", () => t()), r.end(Buffer.from(e.bytes));
197
197
  }), { total: t.bytes + e.bytes.byteLength };
198
- }, wa = async (e) => {
199
- let t = await X.stat(pa(e));
198
+ }, Ta = async (e) => {
199
+ let t = await X.stat(ma(e));
200
200
  return {
201
- path: pa(e),
201
+ path: ma(e),
202
202
  bytes: t.size
203
203
  };
204
- }, Ta = () => L.join(da(), ".runs"), Ea = (e) => L.join(Ta(), `${e}.bin`), Da = async (e, t) => {
205
- if (!ua(e)) return null;
206
- let n = pa(e), r = await X.stat(n).catch(() => null);
204
+ }, Ea = () => I.join(fa(), ".runs"), Da = (e) => I.join(Ea(), `${e}.bin`), Oa = async (e, t) => {
205
+ if (!da(e)) return null;
206
+ let n = ma(e), r = await X.stat(n).catch(() => null);
207
207
  if (r === null || r.size === 0) return null;
208
- await X.mkdir(Ta(), { recursive: !0 });
209
- let i = Ea(t);
208
+ await X.mkdir(Ea(), { recursive: !0 });
209
+ let i = Da(t);
210
210
  return await X.rename(n, i), i;
211
- }, Oa = async (e) => {
212
- await X.rm(Ea(e), { force: !0 }).catch(() => void 0);
213
- }, Q = R({ scope: "voltro:admin-import" }), ka = "VBUNDLE2", Aa = (e) => {
211
+ }, ka = async (e) => {
212
+ await X.rm(Da(e), { force: !0 }).catch(() => void 0);
213
+ }, Q = L({ scope: "voltro:admin-import" }), Aa = "VBUNDLE2", ja = (e) => {
214
214
  let t = e.req.headers["x-import-rollback-key"];
215
215
  if (e.mode !== "replace") return { options: {} };
216
216
  if (typeof t != "string" || t.length === 0) return Q.warn("admin.import: no rollback capture — this run empties the target first, and nothing was asked to be kept. Send `x-import-rollback-key: <storage key>` (voltro data import --rollback-key <key>) to have the instance store the target's current rows before deleting them."), { options: {} };
@@ -221,18 +221,18 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
221
221
  hint: "A capture written to the pod would not survive the failure it exists for. Configure storage (the same one the storage-push export uses), or re-send without `x-import-rollback-key` to accept that a run which does not finish can leave the target emptied. Note that CONFIGURED is not the same question as SURVIVES: a `filesystem` provider pointed at a container directory with no volume behind it passes this check and dies with the pod. The run says so when it can observe it — the capture path being on the same filesystem as `/`."
222
222
  })
223
223
  };
224
- let n = On(vi(), `voltro-rollback-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`), r = e.deps.putArchive;
224
+ let n = An(yi(), `voltro-rollback-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`), r = e.deps.putArchive;
225
225
  return {
226
226
  key: t,
227
227
  options: {
228
228
  rollbackDir: n,
229
229
  onRollbackCaptured: async () => {
230
- let e = xi(n);
231
- e !== void 0 && Q.warn(`admin.import: ${e}`), await r(t, () => Ui({ dir: n })), Q.info("admin.import: rollback capture stored", { bundleKey: t });
230
+ let e = Si(n);
231
+ e !== void 0 && Q.warn(`admin.import: ${e}`), await r(t, () => Wi({ dir: n })), Q.info("admin.import: rollback capture stored", { bundleKey: t });
232
232
  }
233
233
  }
234
234
  };
235
- }, ja = (e) => {
235
+ }, Ma = (e) => {
236
236
  let t = e["x-import-mode"], n = e["x-import-atomic"];
237
237
  return {
238
238
  mode: t,
@@ -242,34 +242,34 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
242
242
  dryRun: e["x-import-dry-run"] === "1" || e["x-import-dry-run"] === "true",
243
243
  tables: (e["x-import-tables"] ?? "").split(",").map((e) => e.trim()).filter(Boolean)
244
244
  };
245
- }, Ma = async (e, t) => {
245
+ }, Na = async (e, t) => {
246
246
  if (typeof t.bundleKey == "string" && t.bundleKey !== "") {
247
247
  if (!e.openArchive) return { refusal: Z(501, { error: "storage transport not configured on this instance" }) };
248
248
  let n = e.openArchive, r = t.bundleKey;
249
249
  return {
250
250
  source: () => n(r),
251
251
  transport: "storage",
252
- uploadId: Sa(r)
252
+ uploadId: Ca(r)
253
253
  };
254
254
  }
255
255
  let n = t.uploadId;
256
- if (typeof n != "string" || !ua(n)) return { refusal: Z(400, { error: "start needs { uploadId } from an upload, or { bundleKey } for the storage transport" }) };
257
- let r = await wa(n).catch(() => null);
256
+ if (typeof n != "string" || !da(n)) return { refusal: Z(400, { error: "start needs { uploadId } from an upload, or { bundleKey } for the storage transport" }) };
257
+ let r = await Ta(n).catch(() => null);
258
258
  return r === null || r.bytes === 0 ? { refusal: Z(409, {
259
259
  error: "no such upload",
260
260
  message: `this instance holds no bytes for upload '${n}'. Upload the bundle first, or re-upload if it has expired.`
261
261
  }) } : {
262
- source: () => Na(r.path),
262
+ source: () => Pa(r.path),
263
263
  transport: "upload",
264
264
  uploadId: n
265
265
  };
266
- }, Na = (e) => {
267
- let { createReadStream: t } = Zi("node:fs");
266
+ }, Pa = (e) => {
267
+ let { createReadStream: t } = Qi("node:fs");
268
268
  return t(e);
269
- }, Pa = (e) => async (t) => {
270
- let n = ca(t, e.secret);
269
+ }, Fa = (e) => async (t) => {
270
+ let n = la(t, e.secret);
271
271
  if (n) return n;
272
- let r = ja(t.headers), i = Aa({
272
+ let r = Ma(t.headers), i = ja({
273
273
  req: t,
274
274
  mode: r.mode,
275
275
  deps: e
@@ -283,16 +283,16 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
283
283
  return Z(400, { error: "a preflight body must be JSON: { tables: string[] } or { bundleKey: string }" });
284
284
  }
285
285
  let a = Array.isArray(n.tables) ? n.tables.filter((e) => typeof e == "string") : [];
286
- if (a.length === 0 && typeof n.bundleKey == "string" && n.bundleKey !== "" && e.openArchive && (a = [...await Fa(e.openArchive(n.bundleKey))]), a.length === 0) return Z(400, {
286
+ if (a.length === 0 && typeof n.bundleKey == "string" && n.bundleKey !== "" && e.openArchive && (a = [...await Ia(e.openArchive(n.bundleKey))]), a.length === 0) return Z(400, {
287
287
  error: "a preflight needs { tables: string[] } — the bundle's table names, so the staging decision can be made against them",
288
288
  hint: "or { bundleKey } on an instance with storage configured, where this endpoint reads the table list out of the archive itself"
289
289
  });
290
- let o = Vi({
290
+ let o = Hi({
291
291
  mode: r.mode ?? "upsert",
292
292
  ...e.dialect === void 0 ? {} : { targetDialect: e.dialect },
293
293
  ...e.snapshot === void 0 ? {} : { targetSnapshot: e.snapshot },
294
294
  bundleTables: a,
295
- isSkipped: Hi,
295
+ isSkipped: Ui,
296
296
  canRunSql: !0
297
297
  });
298
298
  return Z(200, {
@@ -311,8 +311,8 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
311
311
  }
312
312
  let a = t.headers["x-import-upload-id"];
313
313
  if (a !== void 0 && a !== "") {
314
- if (ha(), t.headers["x-import-probe"] === "1") {
315
- let e = await ga(a);
314
+ if (ga(), t.headers["x-import-probe"] === "1") {
315
+ let e = await _a(a);
316
316
  return Z(200, {
317
317
  uploadId: a,
318
318
  bytes: e.bytes,
@@ -321,7 +321,7 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
321
321
  }
322
322
  let e = t.headers["x-import-upload-key"] ?? "", n = Number(t.headers["x-import-chunk-offset"] ?? "0");
323
323
  if (e === "" || !Number.isFinite(n) || n < 0) return Z(400, { error: "a chunked upload needs x-import-upload-key and a numeric x-import-chunk-offset" });
324
- let r = await Ca({
324
+ let r = await wa({
325
325
  id: a,
326
326
  key: e,
327
327
  offset: n,
@@ -343,12 +343,12 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
343
343
  complete: i
344
344
  });
345
345
  }
346
- if (t.rawBody.byteLength >= 8 && Buffer.from(t.rawBody.subarray(0, 8)).toString("latin1") === ka) {
347
- ha();
348
- let e = Oi("sha256").update(Buffer.from(t.rawBody)).digest("hex"), n = Sa(e);
346
+ if (t.rawBody.byteLength >= 8 && Buffer.from(t.rawBody.subarray(0, 8)).toString("latin1") === Aa) {
347
+ ga();
348
+ let e = ki("sha256").update(Buffer.from(t.rawBody)).digest("hex"), n = Ca(e);
349
349
  return Z(202, {
350
350
  uploadId: n,
351
- bytes: await xa(n, t.rawBody, e),
351
+ bytes: await Sa(n, t.rawBody, e),
352
352
  complete: !0
353
353
  });
354
354
  }
@@ -359,22 +359,22 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
359
359
  return Z(400, { error: "body must be a packed bundle archive or { bundleKey } JSON" });
360
360
  }
361
361
  return typeof o.bundleKey != "string" || !o.bundleKey ? Z(400, { error: "body.bundleKey (string) is required for the storage transport" }) : e.openArchive ? Z(202, {
362
- uploadId: Sa(o.bundleKey),
362
+ uploadId: Ca(o.bundleKey),
363
363
  bundleKey: o.bundleKey,
364
364
  complete: !0
365
365
  }) : Z(501, { error: "storage transport not configured on this instance" });
366
- }, Fa = async (e) => {
367
- let t = await Wi(e, ["manifest.json"]).then((e) => e.get("manifest.json"), () => void 0);
366
+ }, Ia = async (e) => {
367
+ let t = await Gi(e, ["manifest.json"]).then((e) => e.get("manifest.json"), () => void 0);
368
368
  if (t === void 0) return [];
369
369
  try {
370
370
  return (JSON.parse(Buffer.from(t).toString("utf8")).tables ?? []).map((e) => e.name).filter((e) => typeof e == "string");
371
371
  } catch {
372
372
  return [];
373
373
  }
374
- }, Ia = (e) => async (t) => {
375
- let n = ca(t, e.secret);
374
+ }, La = (e) => async (t) => {
375
+ let n = la(t, e.secret);
376
376
  if (n) return n;
377
- let r = ja(t.headers), i = Aa({
377
+ let r = Ma(t.headers), i = ja({
378
378
  req: t,
379
379
  mode: r.mode,
380
380
  deps: e
@@ -386,12 +386,12 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
386
386
  } catch {
387
387
  return Z(400, { error: "body must be JSON: { uploadId } or { bundleKey }" });
388
388
  }
389
- let o = typeof a.bundleKey == "string" && a.bundleKey !== "" ? Sa(a.bundleKey) : typeof a.uploadId == "string" ? a.uploadId : "";
390
- if (!ua(o)) return Z(400, { error: "start needs { uploadId } from an upload, or { bundleKey } for the storage transport" });
391
- let s = Zn("dimp", `${o}-${Date.now()}-${Math.random()}`), c = await ya(o, s);
389
+ let o = typeof a.bundleKey == "string" && a.bundleKey !== "" ? Ca(a.bundleKey) : typeof a.uploadId == "string" ? a.uploadId : "";
390
+ if (!da(o)) return Z(400, { error: "start needs { uploadId } from an upload, or { bundleKey } for the storage transport" });
391
+ let s = $n("dimp", `${o}-${Date.now()}-${Math.random()}`), c = await ba(o, s);
392
392
  if (c !== s) {
393
- let t = await wn(e.store, c);
394
- if (Tn(t) === void 0 && t !== null) return Q.info("admin.import start: already running", {
393
+ let t = await En(e.store, c);
394
+ if (Dn(t) === void 0 && t !== null) return Q.info("admin.import start: already running", {
395
395
  uploadId: o,
396
396
  runId: c
397
397
  }), Z(202, {
@@ -402,18 +402,18 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
402
402
  Q.info("admin.import start: taking over a claim whose run is not running", {
403
403
  uploadId: o,
404
404
  staleRunId: c,
405
- outcome: Tn(t) ?? "no record"
406
- }), c = await ya(o, s, { takeOver: !0 });
405
+ outcome: Dn(t) ?? "no record"
406
+ }), c = await ba(o, s, { takeOver: !0 });
407
407
  }
408
- let l = async (e) => (await ba(o).catch(() => void 0), e), u = await Ma(e, {
408
+ let l = async (e) => (await xa(o).catch(() => void 0), e), u = await Na(e, {
409
409
  ...typeof a.uploadId == "string" ? { uploadId: a.uploadId } : {},
410
410
  ...typeof a.bundleKey == "string" ? { bundleKey: a.bundleKey } : {}
411
411
  });
412
412
  if ("refusal" in u) return l(u.refusal);
413
413
  if (e.snapshot !== void 0 && !r.force) {
414
- let t = await La(u.source());
414
+ let t = await Ra(u.source());
415
415
  if (t !== null) {
416
- let n = Bi(t.source?.schemaFingerprint ?? "", e.snapshot, Ra(t));
416
+ let n = Vi(t.source?.schemaFingerprint ?? "", e.snapshot, za(t));
417
417
  if (n.drifted) return Q.warn("admin.import refused (schema drift)", {
418
418
  transport: u.transport,
419
419
  bundle: n.bundleFingerprint.slice(0, 16),
@@ -428,17 +428,17 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
428
428
  }
429
429
  }
430
430
  let d = null;
431
- if (u.transport === "upload" && (d = await Da(u.uploadId, c), d === null)) return l(Z(409, {
431
+ if (u.transport === "upload" && (d = await Oa(u.uploadId, c), d === null)) return l(Z(409, {
432
432
  error: "no such upload",
433
433
  message: `the bytes for upload '${u.uploadId}' are gone. Re-upload the bundle.`
434
434
  }));
435
- let f = await za(e.store, {
435
+ let f = await Ba(e.store, {
436
436
  runId: c,
437
437
  mode: r.mode ?? "upsert",
438
438
  via: "api",
439
439
  bundle: u.transport === "storage" ? String(a.bundleKey) : u.uploadId
440
440
  });
441
- return Ba({
441
+ return Va({
442
442
  deps: e,
443
443
  opts: r,
444
444
  rollback: i,
@@ -446,7 +446,7 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
446
446
  traced: f,
447
447
  resolved: d === null ? u : {
448
448
  ...u,
449
- source: () => Na(d)
449
+ source: () => Pa(d)
450
450
  }
451
451
  }), Q.info("admin.import started", {
452
452
  runId: c,
@@ -465,15 +465,15 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
465
465
  recorded: f,
466
466
  outcome: "poll /_voltro/admin/transfers for this runId — a 202 means started, not finished"
467
467
  });
468
- }, La = async (e) => {
469
- let t = await Wi(e, ["manifest.json"]).then((e) => e.get("manifest.json"), () => null);
468
+ }, Ra = async (e) => {
469
+ let t = await Gi(e, ["manifest.json"]).then((e) => e.get("manifest.json"), () => null);
470
470
  if (t == null) return null;
471
471
  try {
472
472
  return JSON.parse(Buffer.from(t).toString("utf8"));
473
473
  } catch {
474
474
  return null;
475
475
  }
476
- }, Ra = (e) => ({ tables: (e.tables ?? []).map((e) => ({
476
+ }, za = (e) => ({ tables: (e.tables ?? []).map((e) => ({
477
477
  name: e.name,
478
478
  indexes: [],
479
479
  columns: Object.entries(e.columnTypes ?? {}).map(([e, t]) => ({
@@ -483,9 +483,9 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
483
483
  unique: !1,
484
484
  hasDefault: !1
485
485
  }))
486
- })) }), za = async (e, t) => {
486
+ })) }), Ba = async (e, t) => {
487
487
  try {
488
- return $n(qn), await e.insert(U, {
488
+ return tr(Yn), await e.insert(H, {
489
489
  id: t.runId,
490
490
  direction: "import",
491
491
  startedAt: /* @__PURE__ */ new Date(),
@@ -505,23 +505,23 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
505
505
  error: e?.message ?? String(e)
506
506
  }), !1;
507
507
  }
508
- }, Ba = async (e) => {
508
+ }, Va = async (e) => {
509
509
  let { deps: t, opts: n, rollback: r, resolved: i, runId: a } = e, o = await import("node:os"), s = await import("node:fs/promises"), c = await import("node:path"), l = await s.mkdtemp(c.join(o.tmpdir(), "voltro-admin-import-")), u = async (n) => {
510
510
  Q.warn("admin.import failed", {
511
511
  runId: a,
512
512
  transport: i.transport,
513
513
  error: n
514
- }), e.traced && await t.store.update(U, a, {
514
+ }), e.traced && await t.store.update(H, a, {
515
515
  failure: n,
516
516
  finishedAt: null
517
517
  }).then(() => void 0, () => void 0);
518
518
  };
519
519
  try {
520
- t.assetSink ? await Yi(i.source(), {
520
+ t.assetSink ? await Xi(i.source(), {
521
521
  dir: l,
522
522
  blobs: t.assetSink
523
- }) : await Xi(i.source(), l);
524
- let o = await G.runPromiseExit(Ki({
523
+ }) : await Zi(i.source(), l);
524
+ let o = await W.runPromiseExit(qi({
525
525
  store: t.store,
526
526
  bundleDir: l,
527
527
  ...n.mode ? { mode: n.mode } : {},
@@ -566,24 +566,24 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
566
566
  await s.rm(l, {
567
567
  recursive: !0,
568
568
  force: !0
569
- }).catch(() => void 0), await Oa(a).catch(() => void 0), await ba(i.uploadId).catch(() => void 0);
569
+ }).catch(() => void 0), await ka(a).catch(() => void 0), await xa(i.uploadId).catch(() => void 0);
570
570
  }
571
- }, Va = /^[A-Za-z0-9_-]{8,64}$/, Ha = (e) => Va.test(e), Ua = () => process.env.VOLTRO_EXPORT_ARTIFACT_DIR ?? L.join(_i.tmpdir(), "voltro-export-artifacts"), Wa = (e) => L.join(Ua(), e), Ga = (e) => L.join(Wa(e), "archive.bin"), Ka = async (e = Date.now()) => {
571
+ }, Ha = /^[A-Za-z0-9_-]{8,64}$/, Ua = (e) => Ha.test(e), Wa = () => process.env.VOLTRO_EXPORT_ARTIFACT_DIR ?? I.join(vi.tmpdir(), "voltro-export-artifacts"), Ga = (e) => I.join(Wa(), e), Ka = (e) => I.join(Ga(e), "archive.bin"), qa = async (e = Date.now()) => {
572
572
  let t = 0;
573
573
  try {
574
- for (let n of await X.readdir(Ua())) {
575
- let r = await X.stat(Wa(n)).catch(() => null);
576
- r !== null && (e - r.mtimeMs <= 864e5 || (await X.rm(Wa(n), {
574
+ for (let n of await X.readdir(Wa())) {
575
+ let r = await X.stat(Ga(n)).catch(() => null);
576
+ r !== null && (e - r.mtimeMs <= 864e5 || (await X.rm(Ga(n), {
577
577
  recursive: !0,
578
578
  force: !0
579
579
  }).catch(() => void 0), t++));
580
580
  }
581
581
  } catch {}
582
582
  return t;
583
- }, qa = async (e, t) => {
584
- if (!Ha(e)) throw Error(`invalid run id: ${e}`);
585
- await X.mkdir(Wa(e), { recursive: !0 });
586
- let { createWriteStream: n } = await import("node:fs"), r = n(Ga(e)), i = 0;
583
+ }, Ja = async (e, t) => {
584
+ if (!Ua(e)) throw Error(`invalid run id: ${e}`);
585
+ await X.mkdir(Ga(e), { recursive: !0 });
586
+ let { createWriteStream: n } = await import("node:fs"), r = n(Ka(e)), i = 0;
587
587
  try {
588
588
  for await (let e of t) i += e.byteLength, r.write(Buffer.from(e)) || await new Promise((e, t) => {
589
589
  r.once("drain", e), r.once("error", t);
@@ -594,18 +594,18 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
594
594
  });
595
595
  }
596
596
  return i;
597
- }, Ja = async (e) => {
598
- if (!Ha(e)) return null;
599
- let t = await X.stat(Ga(e)).catch(() => null);
597
+ }, Ya = async (e) => {
598
+ if (!Ua(e)) return null;
599
+ let t = await X.stat(Ka(e)).catch(() => null);
600
600
  return t === null ? null : t.size;
601
- }, Ya = async (e, t, n) => {
602
- let r = await Ja(e);
601
+ }, Xa = async (e, t, n) => {
602
+ let r = await Ya(e);
603
603
  if (r === null) return null;
604
604
  if (t >= r) return {
605
605
  bytes: Buffer.alloc(0),
606
606
  total: r
607
607
  };
608
- let i = await X.open(Ga(e), "r");
608
+ let i = await X.open(Ka(e), "r");
609
609
  try {
610
610
  let e = Math.max(0, Math.min(n, r - t)), a = Buffer.alloc(e);
611
611
  return await i.read(a, 0, e, t), {
@@ -615,27 +615,27 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
615
615
  } finally {
616
616
  await i.close();
617
617
  }
618
- }, Xa = async (e) => {
619
- Ha(e) && await X.rm(Wa(e), {
618
+ }, Za = async (e) => {
619
+ Ua(e) && await X.rm(Ga(e), {
620
620
  recursive: !0,
621
621
  force: !0
622
622
  }).catch(() => void 0);
623
- }, Za = R({ scope: "voltro:admin-export" }), Qa = (e) => Array.isArray(e) ? e.filter((e) => typeof e == "string") : [], $a = (e) => {
623
+ }, Qa = L({ scope: "voltro:admin-export" }), $a = (e) => Array.isArray(e) ? e.filter((e) => typeof e == "string") : [], eo = (e) => {
624
624
  if (typeof e.tenant == "string" && e.tenant) return {
625
625
  kind: "tenant",
626
626
  tenantId: e.tenant
627
627
  };
628
628
  if (Array.isArray(e.tables) && e.tables.length) return {
629
629
  kind: "tables",
630
- tables: Qa(e.tables)
630
+ tables: $a(e.tables)
631
631
  };
632
- let t = Qa(e.exclude);
632
+ let t = $a(e.exclude);
633
633
  return t.length > 0 ? {
634
634
  kind: "all",
635
635
  exclude: t
636
636
  } : { kind: "all" };
637
- }, eo = (e) => async (t) => {
638
- let n = ca(t, e.secret);
637
+ }, to = (e) => async (t) => {
638
+ let n = la(t, e.secret);
639
639
  if (n) return n;
640
640
  let r;
641
641
  try {
@@ -655,12 +655,12 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
655
655
  });
656
656
  }
657
657
  }
658
- let a = r.consistency === "snapshot" ? "snapshot" : i.consistency ?? "live", o = (typeof r.compression == "string" ? r.compression : void 0) ?? i.compression, s = i.scope ?? $a(r), c = typeof r.bundleKey == "string" && r.bundleKey.length > 0, l = r.assets === !0 && e.assetSource ? { blobs: e.assetSource } : {}, u = Zn("dexp", `${Date.now()}-${Math.random()}`), d = await to(e.store, {
658
+ let a = r.consistency === "snapshot" ? "snapshot" : i.consistency ?? "live", o = (typeof r.compression == "string" ? r.compression : void 0) ?? i.compression, s = i.scope ?? eo(r), c = typeof r.bundleKey == "string" && r.bundleKey.length > 0, l = r.assets === !0 && e.assetSource ? { blobs: e.assetSource } : {}, u = $n("dexp", `${Date.now()}-${Math.random()}`), d = await no(e.store, {
659
659
  runId: u,
660
660
  mode: i.subset ? "subset" : s.kind,
661
661
  bundle: c ? String(r.bundleKey) : null
662
662
  });
663
- return no({
663
+ return ro({
664
664
  deps: e,
665
665
  runId: u,
666
666
  recorded: d,
@@ -670,7 +670,7 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
670
670
  blobs: l,
671
671
  ...o ? { compression: o } : {},
672
672
  ...c ? { bundleKey: String(r.bundleKey) } : {}
673
- }), Ka(), Za.info("admin.export started", {
673
+ }), qa(), Qa.info("admin.export started", {
674
674
  runId: u,
675
675
  scope: s.kind,
676
676
  storage: c
@@ -681,9 +681,9 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
681
681
  recorded: d,
682
682
  outcome: "poll /_voltro/admin/transfers for this runId; fetch the bytes from /_voltro/admin/export/download"
683
683
  });
684
- }, to = async (e, t) => {
684
+ }, no = async (e, t) => {
685
685
  try {
686
- return $n(qn), await e.insert(U, {
686
+ return tr(Yn), await e.insert(H, {
687
687
  id: t.runId,
688
688
  direction: "export",
689
689
  startedAt: /* @__PURE__ */ new Date(),
@@ -698,17 +698,17 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
698
698
  staged: null
699
699
  }), !0;
700
700
  } catch (e) {
701
- return Za.warn("admin.export: the run could not be recorded", {
701
+ return Qa.warn("admin.export: the run could not be recorded", {
702
702
  runId: t.runId,
703
703
  error: e?.message ?? String(e)
704
704
  }), !1;
705
705
  }
706
- }, no = async (e) => {
706
+ }, ro = async (e) => {
707
707
  let { deps: t, runId: n } = e, r = await import("node:os"), i = await import("node:fs/promises"), a = await import("node:path"), o = await i.mkdtemp(a.join(r.tmpdir(), "voltro-admin-export-")), s = async (r) => {
708
- e.recorded && await t.store.update(U, n, r).then(() => void 0, () => void 0);
708
+ e.recorded && await t.store.update(H, n, r).then(() => void 0, () => void 0);
709
709
  };
710
710
  try {
711
- let r = await G.runPromise(Gi({
711
+ let r = await W.runPromise(Ki({
712
712
  store: t.store,
713
713
  snapshot: t.snapshot,
714
714
  dialect: t.dialect,
@@ -723,16 +723,16 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
723
723
  })), i = r.tables.reduce((e, t) => e + t.rowCount, 0), a = r.masking?.transformed.length ?? 0;
724
724
  if (e.bundleKey !== void 0) {
725
725
  if (!t.putArchive) throw Error("storage transport not configured on this instance");
726
- await t.putArchive(e.bundleKey, () => Ui({
726
+ await t.putArchive(e.bundleKey, () => Wi({
727
727
  dir: o,
728
728
  ...e.blobs
729
729
  }));
730
730
  }
731
- let c = await qa(n, Ui({
731
+ let c = await Ja(n, Wi({
732
732
  dir: o,
733
733
  ...e.blobs
734
734
  }));
735
- Za.info("admin.export complete", {
735
+ Qa.info("admin.export complete", {
736
736
  runId: n,
737
737
  tables: r.tables.length,
738
738
  rows: i,
@@ -748,25 +748,25 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
748
748
  });
749
749
  } catch (e) {
750
750
  let t = e?.message ?? String(e);
751
- Za.warn("admin.export failed", {
751
+ Qa.warn("admin.export failed", {
752
752
  runId: n,
753
753
  error: t
754
754
  }), await s({
755
755
  failure: t,
756
756
  finishedAt: null
757
- }), await Xa(n);
757
+ }), await Za(n);
758
758
  } finally {
759
759
  await i.rm(o, {
760
760
  recursive: !0,
761
761
  force: !0
762
762
  }).catch(() => void 0);
763
763
  }
764
- }, ro = (e) => async (t) => {
765
- let n = ca(t, e.secret, "GET");
764
+ }, io = (e) => async (t) => {
765
+ let n = la(t, e.secret, "GET");
766
766
  if (n) return n;
767
767
  let r = new URLSearchParams(t.query ?? ""), i = r.get("runId") ?? "";
768
- if (!Ha(i)) return Z(400, { error: "download needs ?runId=<id> from the 202 the export answered with" });
769
- let a = Math.max(0, Number(r.get("offset") ?? "0") || 0), o = Number(r.get("length") ?? "8388608"), s = await Ya(i, a, Number.isFinite(o) && o > 0 ? Math.min(o, ao) : io);
768
+ if (!Ua(i)) return Z(400, { error: "download needs ?runId=<id> from the 202 the export answered with" });
769
+ let a = Math.max(0, Number(r.get("offset") ?? "0") || 0), o = Number(r.get("length") ?? "8388608"), s = await Xa(i, a, Number.isFinite(o) && o > 0 ? Math.min(o, oo) : ao);
770
770
  return s === null ? Z(404, {
771
771
  error: "no artefact",
772
772
  message: `this instance holds no produced bundle for run '${i}'. It may have expired, or the export may still be running — poll the run first.`
@@ -780,8 +780,8 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
780
780
  "x-export-length": String(s.bytes.byteLength)
781
781
  }
782
782
  };
783
- }, io = 8388608, ao = 33554432, oo = async (e, t) => await e.query({
784
- table: U,
783
+ }, ao = 8388608, oo = 33554432, so = async (e, t) => await e.query({
784
+ table: H,
785
785
  order: [{
786
786
  column: "startedAt",
787
787
  direction: "desc"
@@ -790,23 +790,23 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
790
790
  projection: void 0,
791
791
  skip: 0,
792
792
  take: t
793
- }), so = (e) => {
793
+ }), co = (e) => {
794
794
  let t = new Date(e);
795
795
  return Number.isFinite(t.getTime()) ? t : /* @__PURE__ */ new Date(0);
796
- }, co = (e) => ({
796
+ }, lo = (e) => ({
797
797
  ...e,
798
- startedAt: so(e.startedAt),
799
- finishedAt: e.finishedAt === null || e.finishedAt === void 0 ? null : so(e.finishedAt)
800
- }), lo = (e) => async (t) => {
801
- let n = ca(t, e.secret, "GET");
798
+ startedAt: co(e.startedAt),
799
+ finishedAt: e.finishedAt === null || e.finishedAt === void 0 ? null : co(e.finishedAt)
800
+ }), uo = (e) => async (t) => {
801
+ let n = la(t, e.secret, "GET");
802
802
  if (n) return n;
803
803
  let r = Number(new URLSearchParams(t.query ?? "").get("limit") ?? "20"), i = Number.isFinite(r) ? Math.max(1, Math.min(200, Math.trunc(r))) : 20, a;
804
804
  try {
805
- a = (await oo(e.store, i)).map(co);
805
+ a = (await so(e.store, i)).map(lo);
806
806
  } catch (e) {
807
807
  return Z(409, {
808
808
  error: "no import history",
809
- message: `this instance has no \`${U}\` table, so no import has been recorded. Run \`voltro db apply\` against it; imports themselves are unaffected.`,
809
+ message: `this instance has no \`${H}\` table, so no import has been recorded. Run \`voltro db apply\` against it; imports themselves are unaffected.`,
810
810
  detail: e?.message ?? String(e)
811
811
  });
812
812
  }
@@ -825,11 +825,11 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
825
825
  direction: e.direction,
826
826
  failure: e.failure,
827
827
  staged: e.staged,
828
- line: Qn(e)
828
+ line: er(e)
829
829
  }))
830
830
  });
831
- }, uo = (e, t, n = {}) => (async function* () {
832
- let r = await G.runPromise(Ci(e, t).pipe(G.timeout(n.openTimeout ?? "30 seconds"))), i = await Ti(r.stream), a = n.stallMs ?? 12e4, o, s = () => {
831
+ }, fo = (e, t, n = {}) => (async function* () {
832
+ let r = await W.runPromise(wi(e, t).pipe(W.timeout(n.openTimeout ?? "30 seconds"))), i = await Ei(r.stream), a = n.stallMs ?? 12e4, o, s = () => {
833
833
  o && clearTimeout(o), o = setTimeout(() => i.destroy(/* @__PURE__ */ Error(`storage read stalled for ${a}ms reading '${t}'`)), a);
834
834
  };
835
835
  try {
@@ -838,7 +838,7 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
838
838
  } finally {
839
839
  o && clearTimeout(o), i.destroy();
840
840
  }
841
- })(), fo = {
841
+ })(), po = {
842
842
  get: async () => void 0,
843
843
  set: async () => {},
844
844
  setWithTags: async () => {},
@@ -847,64 +847,64 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
847
847
  clear: async () => {},
848
848
  invalidateTag: async () => 0,
849
849
  wrap: async (e, t, n) => n()
850
- }, po = async (e) => {
851
- f(e.appProcedures ?? e.discovered, {
850
+ }, mo = async (e) => {
851
+ Me(e.appProcedures ?? e.discovered, {
852
852
  defaultDeny: e.security?.defaultDeny ?? !0,
853
853
  commandHint: "`voltro serve`"
854
- }), oi({
854
+ }), si({
855
855
  dataStore: e.store,
856
856
  schemaRegistry: e.schemaRegistry
857
857
  });
858
- let t = (e.discovered.budgets?.length ?? 0) > 0, n, r = new dr({
858
+ let t = (e.discovered.budgets?.length ?? 0) > 0, n, r = new pr({
859
859
  store: e.store,
860
860
  ...e.snapshotCache ? { cache: e.snapshotCache } : {},
861
861
  ...e.reactive === void 0 ? {} : { reactive: e.reactive },
862
862
  ...t ? { recordCost: (e) => n?.record(e) } : {},
863
- recordDelivery: (e) => $r({
863
+ recordDelivery: (e) => ei({
864
864
  label: e.label,
865
865
  kind: e.kind,
866
866
  durationMs: e.durationMs,
867
867
  rowCount: e.rowCount
868
868
  })
869
- }), i = e.cache ?? fo, a = e.kv ?? Zr, o, s = () => void 0, l, u, d, ee, te, ne, p, h = fe({
869
+ }), i = e.cache ?? po, a = e.kv ?? Qr, o, s = () => void 0, u, d, f, ee, te, ne, h, re = St({
870
870
  store: e.store,
871
871
  warn: (e, t) => {
872
872
  process.stderr.write(`[workflow] ${e} ${JSON.stringify(t)}\n`);
873
873
  }
874
- }), re = h.remember, se = h.resolve, ce = St({
874
+ }), ie = re.remember, ae = re.resolve, oe = de({
875
875
  authority: e.authority,
876
876
  getStore: () => e.store
877
- }), b = (e.discovered.workflows?.length ?? 0) > 0 ? Vr(() => o) : void 0, pe = (e.discovered.workflows?.length ?? 0) > 0 || (e.discovered.eventTriggers?.length ?? 0) > 0, _e = pe || (e.discovered.workflowWorkers?.length ?? 0) > 0 || e.scheduleCoordination === "cluster", ve = e.tenantIsolation === "namespace", ye = (e.log ?? R({ scope: "voltro:serve" })).child("webhooks"), be, xe, x = e.discovered.webhooks;
878
- if (x && x.outgoing.length > 0 && e.workflowEngineLayer !== void 0) {
877
+ }), g = (e.discovered.workflows?.length ?? 0) > 0 ? Hr(() => o) : void 0, ue = (e.discovered.workflows?.length ?? 0) > 0 || (e.discovered.eventTriggers?.length ?? 0) > 0, pe = ue || (e.discovered.workflowWorkers?.length ?? 0) > 0 || e.scheduleCoordination === "cluster", ve = e.tenantIsolation === "namespace", xe = (e.log ?? L({ scope: "voltro:serve" })).child("webhooks"), we, Te, b = e.discovered.webhooks;
878
+ if (b && b.outgoing.length > 0 && e.workflowEngineLayer !== void 0) {
879
879
  e.workflowEngineLayer;
880
- let t = ft({
880
+ let t = A({
881
881
  store: e.store,
882
882
  schemaRegistry: e.schemaRegistry,
883
883
  cache: i,
884
884
  kv: a
885
- }), n = x.outgoing.map((e) => e.descriptor);
886
- xe = Ni.toLayer(Ai(t, { events: n })), be = ji(t, async (e) => {
887
- let t = d;
885
+ }), n = b.outgoing.map((e) => e.descriptor);
886
+ Te = Ii.toLayer(Ni(t, { events: n })), we = Pi(t, async (e) => {
887
+ let t = f;
888
888
  if (t === void 0) {
889
- ye.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.", {
889
+ xe.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.", {
890
890
  deliveryId: e.deliveryId,
891
891
  targetId: e.targetId
892
892
  });
893
893
  return;
894
894
  }
895
- t.runPromise(Ni.execute(e)).catch((t) => {
896
- ye.error("deliverWebhook workflow crashed", {
895
+ t.runPromise(Ii.execute(e)).catch((t) => {
896
+ xe.error("deliverWebhook workflow crashed", {
897
897
  deliveryId: e.deliveryId,
898
898
  targetId: e.targetId
899
899
  }, t);
900
900
  });
901
901
  }, { events: n });
902
902
  }
903
- let we = /* @__PURE__ */ new Map();
904
- if (x) for (let e of x.incoming) {
905
- let t = e.descriptor.path ?? Mi(e.descriptor.id), n = `VOLTRO_WEBHOOK_SECRET_${e.descriptor.id.toUpperCase().replace(/[^A-Z0-9]/g, "_")}`, r = Fi(e.descriptor, {
903
+ let Ee = /* @__PURE__ */ new Map();
904
+ if (b) for (let e of b.incoming) {
905
+ let t = e.descriptor.path ?? Fi(e.descriptor.id), n = `VOLTRO_WEBHOOK_SECRET_${e.descriptor.id.toUpperCase().replace(/[^A-Z0-9]/g, "_")}`, r = Ri(e.descriptor, {
906
906
  resolveSecret: async () => process.env[n] ?? null,
907
- resolveWorkflows: () => b === void 0 ? void 0 : Xr(b, {
907
+ resolveWorkflows: () => g === void 0 ? void 0 : Zr(g, {
908
908
  traceId: `incoming:${e.descriptor.id}`,
909
909
  source: `incoming:${e.descriptor.id}`
910
910
  }),
@@ -916,34 +916,34 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
916
916
  idempotency: e.idempotency,
917
917
  durationMs: e.durationMs
918
918
  };
919
- e.status >= 500 ? ye.error("incoming delivery failed", t) : e.status >= 400 ? ye.warn("incoming delivery rejected", t) : ye.info("incoming delivery handled", t);
919
+ e.status >= 500 ? xe.error("incoming delivery failed", t) : e.status >= 400 ? xe.warn("incoming delivery rejected", t) : xe.info("incoming delivery handled", t);
920
920
  }
921
921
  });
922
- we.set(t, { handle: r });
922
+ Ee.set(t, { handle: r });
923
923
  }
924
- Ar(), ti((t) => jr(e.store, t.subjectId, t.resourceType, t.resourceId)) || R({ scope: "voltro:serve" }).info("policy guards: using the app-registered tuple source");
925
- let Te = [], De = [...e.discovered.outboxHandlers ?? [], ..._n((x?.outgoing.length ?? 0) + (x?.incoming.length ?? 0) + (x?.providers.length ?? 0), []) ? [{
924
+ jr(), ni((t) => Mr(e.store, t.subjectId, t.resourceType, t.resourceId)) || L({ scope: "voltro:serve" }).info("policy guards: using the app-registered tuple source");
925
+ let Oe = [], ke = [...e.discovered.outboxHandlers ?? [], ...bn((b?.outgoing.length ?? 0) + (b?.incoming.length ?? 0) + (b?.providers.length ?? 0), []) ? [{
926
926
  file: "<framework>/webhooks",
927
927
  id: "voltro-webhook-emit",
928
- definition: Pi(() => be)
929
- }] : []], Oe = De.length > 0 ? Le({
930
- handlers: De,
928
+ definition: Li(() => we)
929
+ }] : []], Ae = ke.length > 0 ? Ce({
930
+ handlers: ke,
931
931
  store: e.store,
932
- log: (e.log ?? R({ scope: "voltro:serve" })).child("outbox"),
932
+ log: (e.log ?? L({ scope: "voltro:serve" })).child("outbox"),
933
933
  onChange: (t) => e.store.onChange((e) => t({
934
934
  table: e.table,
935
935
  op: e.op
936
936
  })),
937
937
  onShutdown: (e) => {
938
- Te.push(e);
938
+ Oe.push(e);
939
939
  }
940
- }) : void 0, S = C({
940
+ }) : void 0, x = Pe({
941
941
  definitions: (e.discovered.connections ?? []).map((e) => e.definition),
942
942
  store: e.store,
943
- publicUrl: v(e.port ?? 4e3),
944
- log: (e.log ?? R({ scope: "voltro:serve" })).child("connections")
943
+ publicUrl: C(e.port ?? 4e3),
944
+ log: (e.log ?? L({ scope: "voltro:serve" })).child("connections")
945
945
  });
946
- ct({
946
+ y({
947
947
  events: e.discovered.events ?? [],
948
948
  rpcTags: [
949
949
  ...e.discovered.queries.map((e) => e.descriptor.name),
@@ -952,236 +952,236 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
952
952
  ...(e.discovered.streams ?? []).map((e) => e.descriptor.name)
953
953
  ]
954
954
  });
955
- let Me = (e.log ?? R({ scope: "voltro:serve" })).child("events"), Ne = e.broadcastNamespace ?? et(e.plugins, void 0), Pe = w(e.plugins, Ne, Me), Fe = e.membership?.instanceId ?? process.env.POD_NAME ?? process.env.HOSTNAME ?? `serve-${process.pid}`, Re = e.membership ?? Mt(e.plugins, {
956
- instanceId: Fe,
957
- namespace: Ne,
955
+ let Ne = (e.log ?? L({ scope: "voltro:serve" })).child("events"), Ie = e.broadcastNamespace ?? Re(e.plugins, void 0), Le = Nt(e.plugins, Ie, Ne), Ve = e.membership?.instanceId ?? process.env.POD_NAME ?? process.env.HOSTNAME ?? `serve-${process.pid}`, He = e.membership ?? Bt(e.plugins, {
956
+ instanceId: Ve,
957
+ namespace: Ie,
958
958
  meta: { mode: "serve" },
959
- logger: Me
960
- }), T = me({
959
+ logger: Ne
960
+ }), w = ge({
961
961
  events: e.discovered.events ?? [],
962
- origin: Fe,
963
- ...Pe.publishRemote === void 0 ? {} : { publishRemote: Pe.publishRemote }
964
- }), ze = (e.discovered.events ?? []).length > 0 ? await Pe.attach(T.bus) : null, Be = Ge({
962
+ origin: Ve,
963
+ ...Le.publishRemote === void 0 ? {} : { publishRemote: Le.publishRemote }
964
+ }), We = (e.discovered.events ?? []).length > 0 ? await Le.attach(w.bus) : null, Ke = pt({
965
965
  store: e.store,
966
966
  schemaRegistry: e.schemaRegistry,
967
967
  cache: i,
968
968
  kv: a,
969
- ...be === void 0 ? {} : { webhooksService: be },
970
- ...b === void 0 ? {} : { workflowsProxy: b },
969
+ ...we === void 0 ? {} : { webhooksService: we },
970
+ ...g === void 0 ? {} : { workflowsProxy: g },
971
971
  eventTriggers: e.discovered.eventTriggers ?? [],
972
972
  namespaceIsolationOn: ve,
973
973
  ...e.ensureTenantProvisioned === void 0 ? {} : { ensureTenantProvisioned: e.ensureTenantProvisioned },
974
974
  ...e.resolveResidentStore === void 0 ? {} : { resolveResidentStore: e.resolveResidentStore },
975
- ...Oe === void 0 ? {} : { outbox: { nudge: Oe.nudge } },
976
- ...S.active ? { connections: { registry: S.registry } } : {},
977
- eventBus: T.bus
978
- }), Ve = K.succeed(cr, m), He = K.succeed(fr, Rt), We = K.succeed(lr, Ue), qe = K.succeed(pr, Ee), Ye = (t, n) => {
979
- let r = t.pipe(G.provide(Br(n)));
980
- return (e.baseLayer ? r.pipe(G.provide(e.baseLayer)) : r).pipe(G.provide(Ve)).pipe(G.provide(He)).pipe(G.provide(We)).pipe(G.provide(qe));
981
- }, Ze = (e, t) => {
982
- let n = Ye(e, t);
983
- return ii(n);
984
- }, Qe = bn(), nt = de(e.plugins ?? [], Qe), rt = Ae({
975
+ ...Ae === void 0 ? {} : { outbox: { nudge: Ae.nudge } },
976
+ ...x.active ? { connections: { registry: x.registry } } : {},
977
+ eventBus: w.bus
978
+ }), qe = G.succeed(ur, ye), Je = G.succeed(mr, De), Xe = G.succeed(dr, zt), Qe = G.succeed(hr, p), et = (t, n) => {
979
+ let r = t.pipe(W.provide(Vr(n)));
980
+ return (e.baseLayer ? r.pipe(W.provide(e.baseLayer)) : r).pipe(W.provide(qe)).pipe(W.provide(Je)).pipe(W.provide(Xe)).pipe(W.provide(Qe));
981
+ }, tt = (e, t) => {
982
+ let n = et(e, t);
983
+ return ai(n);
984
+ }, nt = _n(), rt = Fe(e.plugins ?? [], nt), it = ce({
985
985
  plugins: e.plugins ?? [],
986
- metrics: Qe,
987
- log: e.log ?? R({ scope: "voltro:serve" })
988
- }), it = y(e.plugins ?? [], Qe), at = e.security?.defaultDeny ?? !0, st = J({
986
+ metrics: nt,
987
+ log: e.log ?? L({ scope: "voltro:serve" })
988
+ }), at = xt(e.plugins ?? [], nt), ot = e.security?.defaultDeny ?? !0, st = J({
989
989
  store: e.store,
990
- defaultDeny: at,
990
+ defaultDeny: ot,
991
991
  recordMetric: (e) => {
992
- Qe.record(e);
992
+ nt.record(e);
993
993
  },
994
- ...nt.mutation === void 0 ? {} : { interceptor: nt.mutation },
995
- buildContext: (e, t, n) => Be(e, t, n),
996
- runEffect: Ze,
997
- undoCapture: c()
998
- }), ut = Se();
994
+ ...rt.mutation === void 0 ? {} : { interceptor: rt.mutation },
995
+ buildContext: (e, t, n) => Ke(e, t, n),
996
+ runEffect: tt,
997
+ undoCapture: Ze()
998
+ }), ct = c();
999
999
  {
1000
- let t = Xe();
1001
- t !== void 0 && (e.log ?? R({ scope: "voltro:serve" })).info(t);
1000
+ let t = At();
1001
+ t !== void 0 && (e.log ?? L({ scope: "voltro:serve" })).info(t);
1002
1002
  }
1003
- let dt = Ie({
1003
+ let lt = Se({
1004
1004
  store: e.store,
1005
1005
  ...e.approvals === void 0 ? {} : { defaultExpiryMs: e.approvals.defaultExpiryMs }
1006
- }), mt = Mr({
1007
- defaultDeny: at,
1008
- buildContext: (e) => Be(e),
1009
- runEffect: Ze,
1006
+ }), ut = Nr({
1007
+ defaultDeny: ot,
1008
+ buildContext: (e) => Ke(e),
1009
+ runEffect: tt,
1010
1010
  recordMetric: (e) => {
1011
- Qe.record(e);
1011
+ nt.record(e);
1012
1012
  },
1013
- ...nt.action === void 0 ? {} : { interceptor: nt.action }
1014
- }), ht = Gr({
1013
+ ...rt.action === void 0 ? {} : { interceptor: rt.action }
1014
+ }), dt = Kr({
1015
1015
  tenantScopedTables: e.tenantScopedTables,
1016
1016
  softDeleteScopedTables: e.softDeleteScopedTables
1017
- }), gt = {
1018
- defaultDeny: at,
1019
- buildContext: (e) => Be(e),
1020
- finalize: (e, t) => ht(e, t.subject),
1021
- provideEffect: Ye,
1022
- ...nt.query === void 0 ? {} : { interceptor: nt.query }
1023
- }, E = Wr(gt), D = Ur({
1024
- ...gt,
1025
- queryRows: (t, n) => e.store.query(t).then((e) => di(t.table, e, n.subject))
1026
- }), vt = qr({
1027
- ...gt,
1017
+ }), ft = {
1018
+ defaultDeny: ot,
1019
+ buildContext: (e) => Ke(e),
1020
+ finalize: (e, t) => dt(e, t.subject),
1021
+ provideEffect: et,
1022
+ ...rt.query === void 0 ? {} : { interceptor: rt.query }
1023
+ }, T = Gr(ft), ht = Wr({
1024
+ ...ft,
1025
+ queryRows: (t, n) => e.store.query(t).then((e) => fi(t.table, e, n.subject))
1026
+ }), gt = Jr({
1027
+ ...ft,
1028
1028
  subscribeDescriptor: (e, t, n) => r.subscribe(e, t, n),
1029
1029
  subscribeComputed: (e, t, n) => r.subscribeComputed(e, t, n)
1030
- }), O = (e) => e.filter((e) => In(e.descriptor)), k = {};
1030
+ }), E = (e) => e.filter((e) => Rn(e.descriptor)), D = {};
1031
1031
  for (let t of [
1032
- ...O(e.discovered.queries),
1033
- ...ut.queries,
1034
- ...dt.queries,
1035
- ...S.queries
1036
- ]) k[t.descriptor.name] = (e) => xr(E(t, e), r, `subscription.${t.descriptor.name}`, void 0, void 0, Kr(t, e));
1032
+ ...E(e.discovered.queries),
1033
+ ...ct.queries,
1034
+ ...lt.queries,
1035
+ ...x.queries
1036
+ ]) D[t.descriptor.name] = (e) => q(T(t, e), r, `subscription.${t.descriptor.name}`, void 0, void 0, qr(t, e));
1037
1037
  for (let t of [
1038
- ...O(e.discovered.mutations),
1039
- ...ut.mutations,
1040
- ...dt.mutations,
1041
- ...S.mutations
1038
+ ...E(e.discovered.mutations),
1039
+ ...ct.mutations,
1040
+ ...lt.mutations,
1041
+ ...x.mutations
1042
1042
  ]) {
1043
- let n = Hr(t.descriptor.output);
1044
- k[t.descriptor.name] = (r) => q(async (e, n) => st(t, e, n), r, `mutation.${t.descriptor.name}`, n, e.idempotency, zn(t.descriptor, "mutation"));
1043
+ let n = Ur(t.descriptor.output);
1044
+ D[t.descriptor.name] = (r) => K(async (e, n) => st(t, e, n), r, `mutation.${t.descriptor.name}`, n, e.idempotency, Vn(t.descriptor, "mutation"));
1045
1045
  }
1046
- for (let t of [...O(e.discovered.actions), ...S.actions]) {
1047
- let n = Hr(t.descriptor.output);
1048
- k[t.descriptor.name] = (r) => q(async (e, n) => mt(t, e, n), r, `action.${t.descriptor.name}`, n, e.idempotency, zn(t.descriptor, "action"));
1046
+ for (let t of [...E(e.discovered.actions), ...x.actions]) {
1047
+ let n = Ur(t.descriptor.output);
1048
+ D[t.descriptor.name] = (r) => K(async (e, n) => ut(t, e, n), r, `action.${t.descriptor.name}`, n, e.idempotency, Vn(t.descriptor, "action"));
1049
1049
  }
1050
- let yt = () => `public-${Math.random().toString(36).slice(2, 10)}`, bt = [
1050
+ let O = () => `public-${Math.random().toString(36).slice(2, 10)}`, _t = [
1051
1051
  ...e.discovered.queries.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
1052
1052
  descriptor: e.descriptor,
1053
- invoke: (t, n) => D(e, t, {
1053
+ invoke: (t, n) => ht(e, t, {
1054
1054
  subject: n.subject,
1055
- traceId: yt()
1055
+ traceId: O()
1056
1056
  }),
1057
- subscribe: (t, n, r) => vt(e, t, {
1057
+ subscribe: (t, n, r) => gt(e, t, {
1058
1058
  subject: n.subject,
1059
- traceId: yt()
1059
+ traceId: O()
1060
1060
  }, r)
1061
1061
  })),
1062
1062
  ...e.discovered.mutations.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
1063
1063
  descriptor: e.descriptor,
1064
1064
  invoke: (t, n) => st(e, t, {
1065
1065
  subject: n.subject,
1066
- traceId: yt()
1066
+ traceId: O()
1067
1067
  })
1068
1068
  })),
1069
1069
  ...e.discovered.actions.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
1070
1070
  descriptor: e.descriptor,
1071
- invoke: (t, n) => mt(e, t, {
1071
+ invoke: (t, n) => ut(e, t, {
1072
1072
  subject: n.subject,
1073
- traceId: yt()
1073
+ traceId: O()
1074
1074
  })
1075
1075
  }))
1076
- ], xt = {
1077
- candidates: ue({
1076
+ ], vt = {
1077
+ candidates: v({
1078
1078
  queries: e.discovered.queries,
1079
1079
  mutations: e.discovered.mutations,
1080
1080
  actions: e.discovered.actions,
1081
1081
  descriptorOf: (e) => e.descriptor,
1082
- runQuery: (e, t, n) => Promise.resolve(D(e, t, n)),
1082
+ runQuery: (e, t, n) => Promise.resolve(ht(e, t, n)),
1083
1083
  runMutation: (e, t, n) => Promise.resolve(st(e, t, n)),
1084
- runAction: (e, t, n) => Promise.resolve(mt(e, t, n))
1084
+ runAction: (e, t, n) => Promise.resolve(ut(e, t, n))
1085
1085
  }),
1086
1086
  policy: e.agents?.tools ?? {},
1087
1087
  mcpEnabled: e.agents?.mcp === !0,
1088
1088
  resolveSubject: (t) => e.resolveSubject(t, -1).then((e) => e.subject)
1089
- }, Ct = _t({
1089
+ }, yt = wt({
1090
1090
  ...e.restRoutes === void 0 ? {} : { restRoutes: e.restRoutes },
1091
- publicApiEntries: bt,
1091
+ publicApiEntries: _t,
1092
1092
  store: e.store,
1093
1093
  resolveSubject: (t) => e.resolveSubject(t, -1).then((e) => e.subject),
1094
1094
  ...e.idempotency === void 0 ? {} : { idempotency: e.idempotency },
1095
- log: e.log ?? R({ scope: "voltro:serve" })
1096
- }), A = e.dataTransferSecret ?? process.env.VOLTRO_DATA_TRANSFER_SECRET, wt = async (e, t) => {
1097
- let { Readable: n } = await import("node:stream"), r = bi(), i = Si("storage", () => n.from(t()));
1098
- await G.runPromise(wi(r, e, i, { contentType: "application/octet-stream" }));
1099
- }, Tt = A && A.length >= 16 ? [
1095
+ log: e.log ?? L({ scope: "voltro:serve" })
1096
+ }), k = e.dataTransferSecret ?? process.env.VOLTRO_DATA_TRANSFER_SECRET, Ct = async (e, t) => {
1097
+ let { Readable: n } = await import("node:stream"), r = xi(), i = Ci("storage", () => n.from(t()));
1098
+ await W.runPromise(Ti(r, e, i, { contentType: "application/octet-stream" }));
1099
+ }, Tt = k && k.length >= 16 ? [
1100
1100
  {
1101
1101
  method: "POST",
1102
- path: ta,
1103
- handle: Pa({
1104
- secret: A,
1102
+ path: na,
1103
+ handle: Fa({
1104
+ secret: k,
1105
1105
  store: e.store,
1106
1106
  ...e.dataTransferSnapshot ? { snapshot: e.dataTransferSnapshot } : {},
1107
1107
  ...e.dataTransferDialect ? { dialect: e.dataTransferDialect } : {},
1108
- assetSink: qi(bi()),
1109
- openArchive: (e) => uo(bi(), e),
1108
+ assetSink: Ji(xi()),
1109
+ openArchive: (e) => fo(xi(), e),
1110
1110
  refreshSubscriptions: (e) => {
1111
1111
  r.refreshAll(e);
1112
1112
  },
1113
- putArchive: wt,
1113
+ putArchive: Ct,
1114
1114
  ...e.dataTransferDialect ? { dialect: e.dataTransferDialect } : {}
1115
1115
  })
1116
1116
  },
1117
1117
  {
1118
1118
  method: "POST",
1119
- path: na,
1120
- handle: Ia({
1121
- secret: A,
1119
+ path: ra,
1120
+ handle: La({
1121
+ secret: k,
1122
1122
  store: e.store,
1123
1123
  ...e.dataTransferSnapshot ? { snapshot: e.dataTransferSnapshot } : {},
1124
1124
  ...e.dataTransferDialect ? { dialect: e.dataTransferDialect } : {},
1125
- assetSink: qi(bi()),
1126
- openArchive: (e) => uo(bi(), e),
1125
+ assetSink: Ji(xi()),
1126
+ openArchive: (e) => fo(xi(), e),
1127
1127
  refreshSubscriptions: (e) => {
1128
1128
  r.refreshAll(e);
1129
1129
  },
1130
- putArchive: wt
1130
+ putArchive: Ct
1131
1131
  })
1132
1132
  },
1133
1133
  {
1134
1134
  method: "GET",
1135
- path: aa,
1136
- handle: lo({
1137
- secret: A,
1135
+ path: oa,
1136
+ handle: uo({
1137
+ secret: k,
1138
1138
  store: e.store
1139
1139
  })
1140
1140
  },
1141
1141
  {
1142
1142
  method: "GET",
1143
- path: ia,
1144
- handle: ro({ secret: A })
1143
+ path: aa,
1144
+ handle: io({ secret: k })
1145
1145
  },
1146
1146
  {
1147
1147
  method: "POST",
1148
- path: ra,
1149
- handle: eo({
1150
- secret: A,
1148
+ path: ia,
1149
+ handle: to({
1150
+ secret: k,
1151
1151
  store: e.store,
1152
1152
  snapshot: e.dataTransferSnapshot ?? { tables: [] },
1153
1153
  dialect: e.dataTransferDialect ?? "memory",
1154
1154
  tenantTables: [...e.tenantScopedTables],
1155
- loadProfile: En,
1156
- assetSource: Ji(bi(), e.store),
1157
- putArchive: wt
1155
+ loadProfile: On,
1156
+ assetSource: Yi(xi(), e.store),
1157
+ putArchive: Ct
1158
1158
  })
1159
1159
  }
1160
1160
  ] : [], Et = [
1161
1161
  ...e.httpRoutes ?? [],
1162
- ...Ct.httpRoutes,
1162
+ ...yt.httpRoutes,
1163
1163
  ...Tt,
1164
- ...S.httpRoutes
1164
+ ...x.httpRoutes
1165
1165
  ];
1166
- Object.assign(k, T.handlers);
1167
- for (let t of O(e.discovered.streams ?? [])) k[t.descriptor.name] = (n) => br((r) => mi(r, (r) => {
1168
- let i = Be(r), a = t.executor(n, i);
1169
- if (G.isEffect(a)) {
1170
- let t = a.pipe(G.provide(Br(i.store)));
1171
- return (e.baseLayer ? t.pipe(G.provide(e.baseLayer)) : t).pipe(G.provide(Ve)).pipe(G.provide(He)).pipe(G.provide(We)).pipe(G.provide(qe));
1166
+ Object.assign(D, w.handlers);
1167
+ for (let t of E(e.discovered.streams ?? [])) D[t.descriptor.name] = (n) => Sr((r) => hi(r, (r) => {
1168
+ let i = Ke(r), a = t.executor(n, i);
1169
+ if (W.isEffect(a)) {
1170
+ let t = a.pipe(W.provide(Vr(i.store)));
1171
+ return (e.baseLayer ? t.pipe(W.provide(e.baseLayer)) : t).pipe(W.provide(qe)).pipe(W.provide(Je)).pipe(W.provide(Xe)).pipe(W.provide(Qe));
1172
1172
  }
1173
- return typeof a == "object" && a && typeof a.then == "function" ? G.promise(() => a) : a;
1173
+ return typeof a == "object" && a && typeof a.then == "function" ? W.promise(() => a) : a;
1174
1174
  }), `stream.${t.descriptor.name}`);
1175
- for (let t of e.discovered.workflows ?? []) k[t.definition.name] = (e) => q(async (e, n) => {
1175
+ for (let t of e.discovered.workflows ?? []) D[t.definition.name] = (e) => K(async (e, n) => {
1176
1176
  let r = n;
1177
- return Xr(b, {
1177
+ return Zr(g, {
1178
1178
  subject: r.subject,
1179
1179
  traceId: r.traceId,
1180
1180
  source: "workflow-rpc"
1181
1181
  }).start(t.definition.name, e);
1182
1182
  }, e, `workflow.${t.definition.name}`);
1183
- pe && (k[Wn.name] = (e) => xr(E({
1184
- descriptor: Wn,
1183
+ ue && (D[Kn.name] = (e) => q(T({
1184
+ descriptor: Kn,
1185
1185
  executor: (e) => {
1186
1186
  let t = e.id;
1187
1187
  return {
@@ -1190,30 +1190,30 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
1190
1190
  column: "startedAt",
1191
1191
  direction: "desc"
1192
1192
  }],
1193
- predicate: er(W("id", t), W("executionId", t)),
1193
+ predicate: nr(U("id", t), U("executionId", t)),
1194
1194
  take: 1,
1195
1195
  skip: void 0,
1196
1196
  projection: void 0
1197
1197
  };
1198
1198
  }
1199
- }, e), r, `subscription.${Wn.name}`), k[Kn.name] = (e) => xr(E({
1200
- descriptor: Kn,
1199
+ }, e), r, `subscription.${Kn.name}`), D[Jn.name] = (e) => q(T({
1200
+ descriptor: Jn,
1201
1201
  executor: (e) => {
1202
- let t = e, n = [...t.tag === void 0 ? [] : [W("tag", t.tag)], ...t.status === void 0 ? [] : [W("status", t.status)]], r = Number.isFinite(t.limit) && t.limit !== void 0 ? Math.min(Math.max(Math.floor(t.limit), 1), 500) : 100;
1202
+ let t = e, n = [...t.tag === void 0 ? [] : [U("tag", t.tag)], ...t.status === void 0 ? [] : [U("status", t.status)]], r = Number.isFinite(t.limit) && t.limit !== void 0 ? Math.min(Math.max(Math.floor(t.limit), 1), 500) : 100;
1203
1203
  return {
1204
1204
  table: "_voltro_workflow_runs",
1205
1205
  order: [{
1206
1206
  column: "startedAt",
1207
1207
  direction: "desc"
1208
1208
  }],
1209
- predicate: n.length === 0 ? void 0 : n.length === 1 ? n[0] : Yn(...n),
1209
+ predicate: n.length === 0 ? void 0 : n.length === 1 ? n[0] : Zn(...n),
1210
1210
  take: r,
1211
1211
  skip: void 0,
1212
1212
  projection: void 0
1213
1213
  };
1214
1214
  }
1215
- }, e), r, `subscription.${Kn.name}`), k[Gn.name] = (e) => xr(E({
1216
- descriptor: Gn,
1215
+ }, e), r, `subscription.${Jn.name}`), D[qn.name] = (e) => q(T({
1216
+ descriptor: qn,
1217
1217
  executor: (e) => {
1218
1218
  let t = e.runId;
1219
1219
  return {
@@ -1222,14 +1222,14 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
1222
1222
  column: "startedAt",
1223
1223
  direction: "asc"
1224
1224
  }],
1225
- predicate: W("runId", t),
1225
+ predicate: U("runId", t),
1226
1226
  take: 1e3,
1227
1227
  skip: void 0,
1228
1228
  projection: void 0
1229
1229
  };
1230
1230
  }
1231
- }, e), r, `subscription.${Gn.name}`), k[Un.name] = (e) => xr(E({
1232
- descriptor: Un,
1231
+ }, e), r, `subscription.${qn.name}`), D[Gn.name] = (e) => q(T({
1232
+ descriptor: Gn,
1233
1233
  executor: (e) => {
1234
1234
  let t = e.runId;
1235
1235
  return {
@@ -1238,14 +1238,14 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
1238
1238
  column: "occurredAt",
1239
1239
  direction: "asc"
1240
1240
  }],
1241
- predicate: W("runId", t),
1241
+ predicate: U("runId", t),
1242
1242
  take: 1e3,
1243
1243
  skip: void 0,
1244
1244
  projection: void 0
1245
1245
  };
1246
1246
  }
1247
- }, e), r, `subscription.${Un.name}`), k[B.name] = (e) => xr(E({
1248
- descriptor: B,
1247
+ }, e), r, `subscription.${Gn.name}`), D[z.name] = (e) => q(T({
1248
+ descriptor: z,
1249
1249
  executor: (e) => {
1250
1250
  let t = e;
1251
1251
  return {
@@ -1254,14 +1254,14 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
1254
1254
  column: "occurredAt",
1255
1255
  direction: "desc"
1256
1256
  }],
1257
- predicate: t.name === void 0 ? void 0 : W("name", t.name),
1257
+ predicate: t.name === void 0 ? void 0 : U("name", t.name),
1258
1258
  take: Math.max(1, Math.min(500, t.limit ?? 100)),
1259
1259
  skip: void 0,
1260
1260
  projection: void 0
1261
1261
  };
1262
1262
  }
1263
- }, e), r, `subscription.${B.name}`), k[Vn.name] = (e) => xr(E({
1264
- descriptor: Vn,
1263
+ }, e), r, `subscription.${z.name}`), D[Un.name] = (e) => q(T({
1264
+ descriptor: Un,
1265
1265
  executor: (e) => {
1266
1266
  let t = e.eventId;
1267
1267
  return {
@@ -1270,88 +1270,88 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
1270
1270
  column: "createdAt",
1271
1271
  direction: "asc"
1272
1272
  }],
1273
- predicate: W("eventId", t),
1273
+ predicate: U("eventId", t),
1274
1274
  take: 500,
1275
1275
  skip: void 0,
1276
1276
  projection: void 0
1277
1277
  };
1278
1278
  }
1279
- }, e), r, `subscription.${Vn.name}`), k[Bn.name] = (t) => q(async (t, n) => {
1279
+ }, e), r, `subscription.${Un.name}`), D[Hn.name] = (t) => K(async (t, n) => {
1280
1280
  let r = t;
1281
- return await j(e.store, n.subject, { executionId: r.executionId }), await b.cancel(r.workflowName, r.executionId), await Ft(r.workflowName, r.executionId, "workflow.cancel"), { ok: !0 };
1282
- }, t, `action.${Bn.name}`), k[Hn.name] = (t) => q(async (t, n) => {
1281
+ return await Ge(e.store, n.subject, { executionId: r.executionId }), await g.cancel(r.workflowName, r.executionId), await It(r.workflowName, r.executionId, "workflow.cancel"), { ok: !0 };
1282
+ }, t, `action.${Hn.name}`), D[Wn.name] = (t) => K(async (t, n) => {
1283
1283
  let r = t;
1284
- return await j(e.store, n.subject, { executionId: r.executionId }), await b.resume(r.workflowName, r.executionId), { ok: !0 };
1285
- }, t, `action.${Hn.name}`), k[V.name] = (t) => q(async (t, n) => {
1284
+ return await Ge(e.store, n.subject, { executionId: r.executionId }), await g.resume(r.workflowName, r.executionId), { ok: !0 };
1285
+ }, t, `action.${Wn.name}`), D[B.name] = (t) => K(async (t, n) => {
1286
1286
  let r = t;
1287
- return await j(e.store, n.subject, { id: r.id }), b.signal({ id: r.id }, r.signalName, r.payload);
1288
- }, t, `action.${V.name}`), k[H.name] = (t) => q(async (t, n) => {
1287
+ return await Ge(e.store, n.subject, { id: r.id }), g.signal({ id: r.id }, r.signalName, r.payload);
1288
+ }, t, `action.${B.name}`), D[V.name] = (t) => K(async (t, n) => {
1289
1289
  let r = t;
1290
- return await j(e.store, n.subject, { id: r.id }), b.update({ id: r.id }, r.updateName, r.payload, r.timeoutMs === void 0 ? void 0 : { timeoutMs: r.timeoutMs });
1291
- }, t, `action.${H.name}`));
1290
+ return await Ge(e.store, n.subject, { id: r.id }), g.update({ id: r.id }, r.updateName, r.payload, r.timeoutMs === void 0 ? void 0 : { timeoutMs: r.timeoutMs });
1291
+ }, t, `action.${V.name}`));
1292
1292
  let Dt = [
1293
- ...O(e.discovered.queries).map((e) => z(e.descriptor)),
1294
- ...O(e.discovered.mutations).map((e) => Ln(e.descriptor)),
1295
- ...O(e.discovered.actions).map((e) => Pn(e.descriptor)),
1296
- ...ut.queries.map((e) => z(e.descriptor)),
1297
- ...ut.mutations.map((e) => Ln(e.descriptor)),
1298
- ...dt.queries.map((e) => z(e.descriptor)),
1299
- ...dt.mutations.map((e) => Ln(e.descriptor)),
1300
- ...S.queries.map((e) => z(e.descriptor)),
1301
- ...S.mutations.map((e) => Ln(e.descriptor)),
1302
- ...S.actions.map((e) => Pn(e.descriptor)),
1303
- ...O(e.discovered.streams ?? []).map((e) => Rn(e.descriptor)),
1304
- ...T.rpcs,
1305
- ...(e.discovered.workflows ?? []).map((e) => hi(e.definition)),
1306
- ...pe ? [
1307
- z(Wn),
1308
- z(Kn),
1309
- z(Gn),
1310
- z(Un),
1311
- z(B),
1312
- z(Vn),
1313
- Pn(Bn),
1314
- Pn(Hn),
1315
- Pn(V),
1316
- Pn(H)
1293
+ ...E(e.discovered.queries).map((e) => R(e.descriptor)),
1294
+ ...E(e.discovered.mutations).map((e) => zn(e.descriptor)),
1295
+ ...E(e.discovered.actions).map((e) => In(e.descriptor)),
1296
+ ...ct.queries.map((e) => R(e.descriptor)),
1297
+ ...ct.mutations.map((e) => zn(e.descriptor)),
1298
+ ...lt.queries.map((e) => R(e.descriptor)),
1299
+ ...lt.mutations.map((e) => zn(e.descriptor)),
1300
+ ...x.queries.map((e) => R(e.descriptor)),
1301
+ ...x.mutations.map((e) => zn(e.descriptor)),
1302
+ ...x.actions.map((e) => In(e.descriptor)),
1303
+ ...E(e.discovered.streams ?? []).map((e) => Bn(e.descriptor)),
1304
+ ...w.rpcs,
1305
+ ...(e.discovered.workflows ?? []).map((e) => gi(e.definition)),
1306
+ ...ue ? [
1307
+ R(Kn),
1308
+ R(Jn),
1309
+ R(qn),
1310
+ R(Gn),
1311
+ R(z),
1312
+ R(Un),
1313
+ In(Hn),
1314
+ In(Wn),
1315
+ In(B),
1316
+ In(V)
1317
1317
  ] : []
1318
- ], Ot = yi.make(...Dt).middleware(Mn).middleware(Nn), kt = Rr({ resolveSubject: ({ headers: t, clientId: n }) => e.resolveSubject(t, n) }), At = e.dormancyTenantId ?? ur, Nt = e.dormancy === "sleep" ? {
1319
- register: (t, n, r) => ni(e.store, {
1320
- tenantId: r ?? At,
1318
+ ], Ot = bi.make(...Dt).middleware(Pn).middleware(Fn), kt = zr({ resolveSubject: ({ headers: t, clientId: n }) => e.resolveSubject(t, n) }), jt = e.dormancyTenantId ?? fr, Pt = e.dormancy === "sleep" ? {
1319
+ register: (t, n, r) => ri(e.store, {
1320
+ tenantId: r ?? jt,
1321
1321
  kind: "workflow",
1322
1322
  refId: t,
1323
1323
  wakeAt: n
1324
1324
  }),
1325
- cancel: (t, n) => Cr(e.store, {
1326
- tenantId: n ?? At,
1325
+ cancel: (t, n) => wr(e.store, {
1326
+ tenantId: n ?? jt,
1327
1327
  kind: "workflow",
1328
1328
  refId: t
1329
1329
  }).then(() => {})
1330
- } : void 0, M = _e ? await import("@voltro/workflow") : void 0, N = M?.makeWorkflowRunRecorder({
1330
+ } : void 0, j = pe ? await import("@voltro/workflow") : void 0, M = j?.makeWorkflowRunRecorder({
1331
1331
  store: e.store,
1332
1332
  ...e.workflowRecording === void 0 ? {} : { recording: e.workflowRecording },
1333
- ...Nt === void 0 ? {} : { wakeups: Nt }
1334
- }), Pt = async (t, n) => {
1335
- await M.closeWorkflowChildrenForParent({
1333
+ ...Pt === void 0 ? {} : { wakeups: Pt }
1334
+ }), Ft = async (t, n) => {
1335
+ await j.closeWorkflowChildrenForParent({
1336
1336
  store: e.store,
1337
1337
  parentExecutionId: t,
1338
1338
  parentStatus: n,
1339
- recorder: N,
1339
+ recorder: M,
1340
1340
  log: { warn: (e, t) => {
1341
1341
  process.stderr.write(`[workflow] ${e} ${t ? JSON.stringify(t) : ""}\n`);
1342
1342
  } },
1343
1343
  interruptChild: async (t, n) => {
1344
1344
  let r = (e.discovered.workflows ?? []).find((e) => e.definition.name === t);
1345
1345
  if (!r) throw Error(`Unknown child workflow: ${t}`);
1346
- if (!d) throw Error("Workflow runtime is not ready");
1347
- await d.runPromise(r.definition.interrupt(n));
1346
+ if (!f) throw Error("Workflow runtime is not ready");
1347
+ await f.runPromise(r.definition.interrupt(n));
1348
1348
  }
1349
1349
  });
1350
- }, Ft = async (t, n, r) => {
1350
+ }, It = async (t, n, r) => {
1351
1351
  let i = (await e.store.query({
1352
1352
  table: "_voltro_workflow_runs",
1353
1353
  order: [],
1354
- predicate: W("executionId", n),
1354
+ predicate: U("executionId", n),
1355
1355
  projection: void 0,
1356
1356
  skip: void 0,
1357
1357
  take: 1
@@ -1362,7 +1362,7 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
1362
1362
  cancelled: !0,
1363
1363
  completedAt: /* @__PURE__ */ new Date()
1364
1364
  }), o = i.subject?.tenantId ?? void 0;
1365
- a && await N.recordEvent({
1365
+ a && await M.recordEvent({
1366
1366
  runId: i.id,
1367
1367
  eventType: "run-cancelled",
1368
1368
  payload: {
@@ -1371,18 +1371,18 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
1371
1371
  executionId: n,
1372
1372
  ...o == null ? {} : { tenantId: o }
1373
1373
  }
1374
- }), a && await Pt(n, "cancelled");
1375
- }, It = [
1374
+ }), a && await Ft(n, "cancelled");
1375
+ }, Lt = [
1376
1376
  ...Y(e.discovered.workflows ?? [], {
1377
- buildContext: (t, n) => e.buildContextForWorkflow?.(t, n) ?? Be({
1377
+ buildContext: (t, n) => e.buildContextForWorkflow?.(t, n) ?? Ke({
1378
1378
  subject: t.subject,
1379
1379
  traceId: t.traceId
1380
1380
  }, e.store, void 0, `workflow:${n.workflowName}`, { parentExecutionId: n.executionId }),
1381
- resolveStartContext: se,
1382
- ...ce === void 0 ? {} : { resolveAuthority: ce }
1381
+ resolveStartContext: ae,
1382
+ ...oe === void 0 ? {} : { resolveAuthority: oe }
1383
1383
  }, (t, n, r) => {
1384
- let i = M.getWorkflowVersionMetadata(t.definition);
1385
- return M.wrapWorkflowExecuteWithRunRecording({
1384
+ let i = j.getWorkflowVersionMetadata(t.definition);
1385
+ return j.wrapWorkflowExecuteWithRunRecording({
1386
1386
  name: t.definition.name,
1387
1387
  store: e.store,
1388
1388
  subject: r.subject,
@@ -1393,42 +1393,42 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
1393
1393
  workflowPatches: i.patches,
1394
1394
  parentExecutionId: r?.parentExecutionId ?? null,
1395
1395
  parentClosePolicy: r?.parentClosePolicy ?? null,
1396
- onParentClose: ({ executionId: e, status: t }) => Pt(e, t),
1397
- ...pt(t.definition),
1396
+ onParentClose: ({ executionId: e, status: t }) => Ft(e, t),
1397
+ ...Mt(t.definition),
1398
1398
  onTerminal: async ({ executionId: e }) => {
1399
- await u?.gate.release(e);
1399
+ await d?.gate.release(e);
1400
1400
  },
1401
- recorder: N,
1402
- pluginWorkflowStepLayer: it,
1403
- recordRun: ei
1401
+ recorder: M,
1402
+ pluginWorkflowStepLayer: at,
1403
+ recordRun: ti
1404
1404
  }, n);
1405
1405
  }),
1406
1406
  ...e.discovered.workflowWorkers ?? [],
1407
- ...xe === void 0 ? [] : [xe]
1408
- ], Lt = [...(e.discovered.workflows ?? []).map((e) => e.definition.name).filter(Boolean), ...xe === void 0 ? [] : ["voltro.deliverWebhook"]], zt = It.length > 0 ? K.mergeAll(...It) : K.empty;
1409
- if (((e.discovered.workflows?.length ?? 0) > 0 || (e.discovered.workflowWorkers?.length ?? 0) > 0 || e.scheduleCoordination === "cluster" || xe !== void 0) && e.workflowEngineLayer !== void 0) {
1410
- let t = zt.pipe(K.provideMerge(e.workflowEngineLayer));
1411
- d = nr.make(e.baseLayer === void 0 ? t : t.pipe(K.provideMerge(e.baseLayer))), await d.runPromise(G.void), (e.log ?? R({ scope: "voltro:serve" })).child("workflow").info(`workflow runtime ready — ${Lt.length} entity type(s) registered`, { entities: Lt });
1412
- let n = await import("@voltro/workflow/cluster"), r = (e) => d.runPromise(n.redriveFailedRun(e)), i = (e) => d.runPromise(n.resumeRunFromStep(e));
1413
- ne = await Bt({
1414
- provider: zi(e.plugins ?? [])?.broadcast?.provider,
1415
- crossReplica: zi(e.plugins ?? [])?.broadcast?.crossReplica ?? !1,
1416
- namespace: Ne,
1407
+ ...Te === void 0 ? [] : [Te]
1408
+ ], Rt = [...(e.discovered.workflows ?? []).map((e) => e.definition.name).filter(Boolean), ...Te === void 0 ? [] : ["voltro.deliverWebhook"]], Vt = Lt.length > 0 ? G.mergeAll(...Lt) : G.empty;
1409
+ if (((e.discovered.workflows?.length ?? 0) > 0 || (e.discovered.workflowWorkers?.length ?? 0) > 0 || e.scheduleCoordination === "cluster" || Te !== void 0) && e.workflowEngineLayer !== void 0) {
1410
+ let t = Vt.pipe(G.provideMerge(e.workflowEngineLayer));
1411
+ f = ir.make(e.baseLayer === void 0 ? t : t.pipe(G.provideMerge(e.baseLayer))), await f.runPromise(W.void), (e.log ?? L({ scope: "voltro:serve" })).child("workflow").info(`workflow runtime ready — ${Rt.length} entity type(s) registered`, { entities: Rt });
1412
+ let n = await import("@voltro/workflow/cluster"), r = (e) => f.runPromise(n.redriveFailedRun(e)), i = (e) => f.runPromise(n.resumeRunFromStep(e));
1413
+ ne = await Ue({
1414
+ provider: Mi(e.plugins ?? [])?.broadcast?.provider,
1415
+ crossReplica: Mi(e.plugins ?? [])?.broadcast?.crossReplica ?? !1,
1416
+ namespace: Ie,
1417
1417
  replicaId: crypto.randomUUID(),
1418
- pollStorage: () => d.runPromise(n.pollWorkflowStorage),
1418
+ pollStorage: () => f.runPromise(n.pollWorkflowStorage),
1419
1419
  onChange: (t) => e.store.onChange((e) => t({
1420
1420
  table: e.table,
1421
1421
  op: e.op,
1422
1422
  ...e.origin === void 0 ? {} : { origin: e.origin }
1423
1423
  })),
1424
- log: (e.log ?? R({ scope: "voltro:serve" })).child("workflow")
1424
+ log: (e.log ?? L({ scope: "voltro:serve" })).child("workflow")
1425
1425
  }), ee = async (t) => {
1426
- let n = await ke({
1426
+ let n = await S({
1427
1427
  store: e.store,
1428
1428
  workflows: e.discovered.workflows ?? [],
1429
1429
  runRedrive: r
1430
1430
  }, t.runId);
1431
- return n.statusReset && await N.recordEvent({
1431
+ return n.statusReset && await M.recordEvent({
1432
1432
  runId: t.runId,
1433
1433
  eventType: "run-redriven",
1434
1434
  payload: {
@@ -1441,12 +1441,12 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
1441
1441
  reason: n.outcome.reason
1442
1442
  };
1443
1443
  }, te = async (t) => {
1444
- let n = await je({
1444
+ let n = await se({
1445
1445
  store: e.store,
1446
1446
  workflows: e.discovered.workflows ?? [],
1447
1447
  runResume: i
1448
1448
  }, t.runId, t.step);
1449
- return n.statusReset && await N.recordEvent({
1449
+ return n.statusReset && await M.recordEvent({
1450
1450
  runId: t.runId,
1451
1451
  eventType: "run-redriven",
1452
1452
  payload: {
@@ -1461,10 +1461,10 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
1461
1461
  reason: n.outcome.reason
1462
1462
  };
1463
1463
  };
1464
- let a = (e.scheduleCoordination ?? "single") === "advisoryLock" ? Nr(e.store, e.scheduleReplicaId ?? `pid-${process.pid}`) : ci, c = zr({
1464
+ let a = (e.scheduleCoordination ?? "single") === "advisoryLock" ? Pr(e.store, e.scheduleReplicaId ?? `pid-${process.pid}`) : li, c = Br({
1465
1465
  coordinator: a,
1466
1466
  replicaId: e.scheduleReplicaId ?? `pid-${process.pid}`
1467
- }), f = {
1467
+ }), l = {
1468
1468
  info: (e, t) => {
1469
1469
  process.stdout.write(`[flow-control] ${e} ${t ? JSON.stringify(t) : ""}\n`);
1470
1470
  },
@@ -1476,17 +1476,17 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
1476
1476
  }
1477
1477
  }, p, m = () => {
1478
1478
  if (p !== void 0) return p;
1479
- if (o !== void 0 && N !== void 0) return p = ie({
1479
+ if (o !== void 0 && M !== void 0) return p = _({
1480
1480
  store: e.store,
1481
- log: I,
1481
+ log: F,
1482
1482
  workflows: e.discovered.workflows ?? [],
1483
1483
  workflowsProxy: o,
1484
- workflowRuntime: d,
1485
- workflowRunRecorder: N,
1486
- closeChildrenForParent: Pt
1484
+ workflowRuntime: f,
1485
+ workflowRunRecorder: M,
1486
+ closeChildrenForParent: Ft
1487
1487
  }), p;
1488
1488
  };
1489
- s = m, u = tt({
1489
+ s = m, d = ze({
1490
1490
  store: e.store,
1491
1491
  onChange: (t) => e.store.onChange((e) => t({
1492
1492
  table: e.table,
@@ -1501,22 +1501,22 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
1501
1501
  workflows: e.discovered.workflows ?? [],
1502
1502
  facade: () => o,
1503
1503
  cancelRunWithReason: m,
1504
- recordRunEvent: () => N?.recordEvent,
1504
+ recordRunEvent: () => M?.recordEvent,
1505
1505
  ...e.workflowStaleness === void 0 ? {} : { staleness: e.workflowStaleness },
1506
1506
  ...e.workflowSuspendSignalHintMs === void 0 ? {} : { suspendSignalHintMs: e.workflowSuspendSignalHintMs },
1507
1507
  scheduleCoordinated: c,
1508
1508
  onAbandoned: async (t) => {
1509
- await Ke({
1509
+ await mt({
1510
1510
  workflows: e.discovered.workflows ?? [],
1511
1511
  facade: () => o,
1512
- log: f,
1512
+ log: l,
1513
1513
  ...t
1514
1514
  });
1515
1515
  },
1516
- log: f
1516
+ log: l
1517
1517
  });
1518
- let h = u;
1519
- h !== void 0 && Qr(() => h.stop()), l = $e({
1518
+ let h = d;
1519
+ h !== void 0 && $r(() => h.stop()), u = bt({
1520
1520
  store: e.store,
1521
1521
  onChange: (t) => e.store.onChange((e) => t({
1522
1522
  table: e.table,
@@ -1527,93 +1527,102 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
1527
1527
  tickIntervalMs: e.scheduling.inferenceTickMs
1528
1528
  },
1529
1529
  enabled: (e.discovered.workflows?.length ?? 0) > 0,
1530
- resumeSignal: () => d === void 0 || M === void 0 ? void 0 : async ({ executionId: t, workflowName: n, signalName: r, payload: i }) => {
1531
- await d.runPromise(M.completeSuspendingSignal({
1530
+ resumeSignal: () => f === void 0 || j === void 0 ? void 0 : async ({ executionId: t, workflowName: n, signalName: r, payload: i }) => {
1531
+ await f.runPromise(j.completeSuspendingSignal({
1532
1532
  store: e.store,
1533
- target: Je(t, n),
1533
+ target: $e(t, n),
1534
1534
  signalName: r,
1535
1535
  payload: i
1536
1536
  }));
1537
1537
  },
1538
- runEffect: (e) => d.runPromise(e),
1538
+ runEffect: (e) => f.runPromise(e),
1539
1539
  scheduleCoordinated: c,
1540
- log: f
1540
+ log: l
1541
1541
  });
1542
- let g = l;
1543
- g !== void 0 && Qr(() => g.stop()), o = (e.discovered.workflows?.length ?? 0) > 0 ? Yr({
1542
+ let re = u;
1543
+ re !== void 0 && $r(() => re.stop()), o = (e.discovered.workflows?.length ?? 0) > 0 ? Xr({
1544
1544
  workflows: e.discovered.workflows ?? [],
1545
- runEffect: (e) => d.runPromise(e),
1545
+ runEffect: (e) => f.runPromise(e),
1546
1546
  onEnqueue: () => ne?.publishWake(),
1547
1547
  ...h === void 0 ? {} : {
1548
1548
  admitStart: h.gate.admitStart,
1549
1549
  startPayloadSchema: h.gate.startPayloadSchema,
1550
1550
  parkDelayedStart: h.gate.parkDelayed
1551
1551
  },
1552
- rememberStartContext: re,
1552
+ rememberStartContext: ie,
1553
1553
  signal: async (t, n, r) => {
1554
- let i = await M.sendWorkflowSignal({
1554
+ let i = await j.sendWorkflowSignal({
1555
1555
  store: e.store,
1556
- recorder: N,
1556
+ recorder: M,
1557
1557
  target: t,
1558
1558
  signalName: n,
1559
1559
  payload: r
1560
1560
  });
1561
- return await d.runPromise(M.completeSuspendingSignal({
1561
+ return await f.runPromise(j.completeSuspendingSignal({
1562
1562
  store: e.store,
1563
1563
  target: t,
1564
1564
  signalName: n,
1565
1565
  payload: r
1566
1566
  })).catch(() => {}), i;
1567
1567
  },
1568
- update: (t, n, r, i) => M.sendWorkflowUpdate({
1568
+ update: (t, n, r, i) => j.sendWorkflowUpdate({
1569
1569
  store: e.store,
1570
- recorder: N,
1570
+ recorder: M,
1571
1571
  target: t,
1572
1572
  updateName: n,
1573
1573
  payload: r,
1574
1574
  ...i === void 0 ? {} : { options: i }
1575
1575
  }),
1576
- listRuns: (t) => _(e.store, t),
1577
- retry: (t, n) => oe({
1576
+ listRuns: (t) => je(e.store, t),
1577
+ retry: (t, n) => fe({
1578
1578
  store: e.store,
1579
1579
  workflows: e.discovered.workflows ?? [],
1580
- runPromise: (e) => d.runPromise(e)
1580
+ runPromise: (e) => f.runPromise(e)
1581
1581
  }, t, n),
1582
- redrive: (t) => ke({
1582
+ redrive: (t) => S({
1583
1583
  store: e.store,
1584
1584
  workflows: e.discovered.workflows ?? [],
1585
1585
  runRedrive: r
1586
1586
  }, t).then((e) => e.outcome)
1587
1587
  }) : void 0;
1588
1588
  }
1589
- let Vt = K.mergeAll(Ot.toLayer(k), kt), Ht = ot(k, e.discovered.queries.map((e) => e.descriptor.name), pe), Ut = K.mergeAll(Ot.toLayer(Ht), kt), P = e.observability, Wt = await Sr({
1589
+ let Ht = G.mergeAll(Ot.toLayer(D), kt), Ut = Be(D, e.discovered.queries.map((e) => e.descriptor.name), ue), Wt = G.mergeAll(Ot.toLayer(Ut), kt), N = e.observability, Gt = await Cr({
1590
1590
  ...e.appName === void 0 ? {} : { serviceName: e.appName },
1591
- ...P && P.spanProcessors.length > 0 ? { extraSpanProcessors: P.spanProcessors } : {},
1592
- ...P && P.metricReaders.length > 0 ? { extraMetricReaders: P.metricReaders } : {},
1593
- ...P && Object.keys(P.resourceAttributes).length > 0 ? { resourceAttributes: P.resourceAttributes } : {},
1594
- ...P && P.sampler !== void 0 ? { sampler: P.sampler } : {}
1595
- }), Gt = !1, F = e.store.ping ? () => e.store.ping().then(() => !0).catch(() => !1) : void 0, { server: Kt, shutdown: qt } = li({
1591
+ ...N && N.spanProcessors.length > 0 ? { extraSpanProcessors: N.spanProcessors } : {},
1592
+ ...N && N.metricReaders.length > 0 ? { extraMetricReaders: N.metricReaders } : {},
1593
+ ...N && Object.keys(N.resourceAttributes).length > 0 ? { resourceAttributes: N.resourceAttributes } : {},
1594
+ ...N && N.sampler !== void 0 ? { sampler: N.sampler } : {}
1595
+ }), Kt = !1, qt = e.store.ping ? () => e.store.ping().then(() => !0).catch(() => !1) : void 0, { server: P, shutdown: Jt } = ui({
1596
1596
  group: Ot,
1597
- handlersLayer: Vt,
1598
- httpHandlersLayer: Ut,
1597
+ handlersLayer: Ht,
1598
+ httpHandlersLayer: Wt,
1599
1599
  port: e.port ?? 4e3,
1600
1600
  ...e.host === void 0 ? {} : { host: e.host },
1601
1601
  path: e.path ?? "/ws",
1602
- tracerLayer: Wt.layer,
1603
- security: ae(e),
1604
- ...rt,
1602
+ tracerLayer: Gt.layer,
1603
+ security: le(e),
1604
+ ...gn(e),
1605
+ ...e.discovered.wsGateways !== void 0 && e.discovered.wsGateways.length > 0 ? { webSocketGateways: e.discovered.wsGateways } : {},
1606
+ resolveGatewaySubject: async (t) => {
1607
+ let n = await e.resolveSubject(t, -1);
1608
+ return n.subject.type === "anonymous" ? null : {
1609
+ subject: n.subject,
1610
+ ...n.credentialExpiresAt === void 0 ? {} : { credentialExpiresAt: n.credentialExpiresAt * 1e3 }
1611
+ };
1612
+ },
1613
+ ...it,
1605
1614
  healthCheck: {
1606
- isReady: () => Gt,
1607
- ...F ? { ping: F } : {}
1615
+ isReady: () => Kt,
1616
+ ...qt ? { ping: qt } : {}
1608
1617
  },
1609
1618
  ...Et.length > 0 ? { httpRoutes: Et } : {},
1610
1619
  ...e.getStore === void 0 ? {} : { getStore: e.getStore },
1611
- ...we.size > 0 ? { webhookRoutes: we } : {},
1620
+ ...Ee.size > 0 ? { webhookRoutes: Ee } : {},
1612
1621
  ...e.inspectRoute === void 0 ? {} : { inspectRoute: e.inspectRoute }
1613
- }), Jt = ea(Kt);
1614
- if (await yr(Kt), (e.discovered.schedules?.length ?? 0) > 0) {
1615
- let t = (e.scheduleCoordination ?? "single") === "advisoryLock" ? Nr(e.store, e.scheduleReplicaId ?? `pid-${process.pid}`) : ci;
1616
- p = await ui(e.discovered.schedules ?? [], {
1622
+ }), Yt = ta(P);
1623
+ if (await xr(P), (e.discovered.schedules?.length ?? 0) > 0) {
1624
+ let t = (e.scheduleCoordination ?? "single") === "advisoryLock" ? Pr(e.store, e.scheduleReplicaId ?? `pid-${process.pid}`) : li;
1625
+ h = await di(e.discovered.schedules ?? [], {
1617
1626
  store: e.store,
1618
1627
  coordinator: t,
1619
1628
  defaultTrigger: e.scheduleDefaultTrigger ?? "self",
@@ -1621,7 +1630,7 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
1621
1630
  armSelf: e.scheduleArmSelf ?? !0,
1622
1631
  dormancy: e.dormancy ?? "always-on",
1623
1632
  ...e.dormancyTenantId === void 0 ? {} : { dormancyTenantId: e.dormancyTenantId },
1624
- buildContext: ({ traceId: t, scheduleName: n, subject: r }) => Be({
1633
+ buildContext: ({ traceId: t, scheduleName: n, subject: r }) => Ke({
1625
1634
  subject: r,
1626
1635
  traceId: t
1627
1636
  }, e.store, void 0, `schedule:${n}`),
@@ -1639,248 +1648,245 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
1639
1648
  },
1640
1649
  ...e.scheduleFireInterceptor === void 0 ? {} : { interceptFire: e.scheduleFireInterceptor },
1641
1650
  ...e.onScheduleRunEvent === void 0 ? {} : { onRunEvent: e.onScheduleRunEvent }
1642
- }), e.onSchedulerReady?.(p);
1651
+ }), e.onSchedulerReady?.(h);
1643
1652
  }
1644
- let I = e.log ?? R({ scope: "voltro:serve" }), Yt, Xt;
1645
- if ((e.discovered.subscribers?.length ?? 0) > 0 && (Yt = Ce(e.discovered.subscribers ?? [], e.store, I.child("subscribe"), e.schemaRegistry, T.bus)), (e.discovered.reactions?.length ?? 0) > 0) {
1646
- let t = I.child("reaction"), n = async (n, r) => {
1653
+ let F = e.log ?? L({ scope: "voltro:serve" }), Xt, Zt;
1654
+ if ((e.discovered.subscribers?.length ?? 0) > 0 && (Xt = l(e.discovered.subscribers ?? [], e.store, F.child("subscribe"), e.schemaRegistry, w.bus)), (e.discovered.reactions?.length ?? 0) > 0) {
1655
+ let t = F.child("reaction"), n = async (n, r) => {
1647
1656
  if (n.kind === "workflow") {
1648
- if (b === void 0) {
1657
+ if (g === void 0) {
1649
1658
  t.warn("reaction workflow act skipped — no workflow engine in this app", { workflow: n.workflow });
1650
1659
  return;
1651
1660
  }
1652
1661
  let e = n.payload === void 0 ? r.new ?? r.old ?? {} : n.payload(r);
1653
- await Xr(b, {
1662
+ await Zr(g, {
1654
1663
  traceId: `reaction:${n.workflow}`,
1655
1664
  source: `reaction:${n.workflow}`
1656
1665
  }).start(n.workflow, e);
1657
1666
  return;
1658
1667
  }
1659
- await he(n.agent, r, {
1668
+ await _e(n.agent, r, {
1660
1669
  findAgentSend: (t) => e.discovered.actions.find((e) => e.descriptor.name === `${t}.send`),
1661
- runAction: (e, t, n) => Promise.resolve(mt(e, t, n)),
1662
- makeSubject: (e) => Fn(e),
1670
+ runAction: (e, t, n) => Promise.resolve(ut(e, t, n)),
1671
+ makeSubject: (e) => Ln(e),
1663
1672
  now: () => Date.now(),
1664
1673
  log: t
1665
1674
  });
1666
1675
  }, r = async (n, r) => {
1667
1676
  try {
1668
1677
  let { requireAiBudget: t } = await import("@voltro/ai");
1669
- return (await G.runPromise(G.either(t(e.store, {
1678
+ return (await W.runPromise(W.either(t(e.store, {
1670
1679
  tenantId: n,
1671
1680
  limitUsd: r
1672
1681
  }))))._tag === "Right";
1673
1682
  } catch (e) {
1674
1683
  return t.warn("reaction budget check failed — refusing the act", { tenantId: n }, e), !1;
1675
1684
  }
1676
- }, i = jt(e.store, { onError: (e) => t.warn("reaction: rate-slot claim failed; refusing the act", { cause: String(e) }) });
1677
- Xt = lt(e.discovered.reactions ?? [], e.store, {
1685
+ }, i = Ye(e.store, { onError: (e) => t.warn("reaction: rate-slot claim failed; refusing the act", { cause: String(e) }) });
1686
+ Zt = he(e.discovered.reactions ?? [], e.store, {
1678
1687
  runAct: n,
1679
1688
  checkBudget: r,
1680
1689
  claimRateSlot: (e) => i.claim(e)
1681
1690
  }, t);
1682
1691
  }
1683
- let Zt;
1684
- (e.discovered.aggregates?.length ?? 0) > 0 && (Zt = await g({
1692
+ let Qt;
1693
+ (e.discovered.aggregates?.length ?? 0) > 0 && (Qt = await m({
1685
1694
  discovered: e.discovered.aggregates ?? [],
1686
1695
  store: e.store,
1687
- log: I.child("aggregate"),
1696
+ log: F.child("aggregate"),
1688
1697
  ...e.analytics === void 0 ? {} : { analytics: e.analytics },
1689
1698
  ...e.aggregateStorage === void 0 ? {} : { storage: e.aggregateStorage },
1690
1699
  ...e.aggregateCoordinator === void 0 ? {} : { coordinator: e.aggregateCoordinator }
1691
- }), Ve = K.succeed(cr, Zt.registry));
1692
- let Qt;
1693
- (e.discovered.expectations?.length ?? 0) > 0 && (Qt = gr({
1700
+ }), qe = G.succeed(ur, Qt.registry));
1701
+ let $t;
1702
+ (e.discovered.expectations?.length ?? 0) > 0 && ($t = vr({
1694
1703
  discovered: e.discovered.expectations ?? [],
1695
1704
  store: e.store,
1696
- log: I.child("expectation")
1697
- }), He = K.succeed(fr, Qt.registry)), (e.discovered.budgets?.length ?? 0) > 0 && (n = vr({
1705
+ log: F.child("expectation")
1706
+ }), Je = G.succeed(mr, $t.registry)), (e.discovered.budgets?.length ?? 0) > 0 && (n = br({
1698
1707
  discovered: e.discovered.budgets ?? [],
1699
- log: I.child("finops")
1700
- }), We = K.succeed(lr, n.registry));
1701
- let $t;
1702
- return (e.discovered.experiments?.length ?? 0) > 0 && ($t = _r({
1708
+ log: F.child("finops")
1709
+ }), Xe = G.succeed(dr, n.registry));
1710
+ let en;
1711
+ return (e.discovered.experiments?.length ?? 0) > 0 && (en = yr({
1703
1712
  discovered: e.discovered.experiments ?? [],
1704
1713
  store: e.store,
1705
- log: I.child("experiment")
1706
- }), qe = K.succeed(pr, $t.registry)), Gt = !0, e.bootTiming?.mark("ready"), {
1714
+ log: F.child("experiment")
1715
+ }), Qe = G.succeed(hr, en.registry)), Kt = !0, e.bootTiming?.mark("ready"), {
1707
1716
  dispatcher: r,
1708
- server: Kt,
1709
- scheduler: p,
1710
- eventsSnapshot: ge(T.bus, T.declared),
1717
+ server: P,
1718
+ scheduler: h,
1719
+ eventsSnapshot: be(w.bus, w.declared),
1711
1720
  membersSnapshot: () => ({
1712
- members: Re.membership.list(),
1721
+ members: He.membership.list(),
1713
1722
  capturedAt: Date.now()
1714
1723
  }),
1715
- agentTools: () => xt,
1716
- rpcMetrics: () => Qe,
1717
- webhooksService: () => be,
1724
+ agentTools: () => vt,
1725
+ rpcMetrics: () => nt,
1726
+ webhooksService: () => we,
1718
1727
  runCanceller: () => s(),
1719
- flowControlHealth: () => u?.cancelHealth(),
1720
- inferenceHealth: () => l?.health(),
1721
- workflowWriteActions: () => b === void 0 || N === void 0 ? void 0 : le({
1728
+ flowControlHealth: () => d?.cancelHealth(),
1729
+ inferenceHealth: () => u?.health(),
1730
+ workflowWriteActions: () => g === void 0 || M === void 0 ? void 0 : me({
1722
1731
  store: e.store,
1723
- log: I,
1732
+ log: F,
1724
1733
  workflows: e.discovered.workflows ?? [],
1725
1734
  workflowsProxy: o,
1726
- workflowRuntime: d,
1727
- workflowRunRecorder: N,
1728
- closeChildrenForParent: Pt
1735
+ workflowRuntime: f,
1736
+ workflowRunRecorder: M,
1737
+ closeChildrenForParent: Ft
1729
1738
  }),
1730
1739
  redriveWorkflowRun: (e) => ee ? ee(e) : Promise.reject(/* @__PURE__ */ Error("redrive: this app registers no workflows")),
1731
1740
  resumeWorkflowRunFromStep: (e) => te ? te(e) : Promise.reject(/* @__PURE__ */ Error("resume-from-step: this app registers no workflows")),
1732
1741
  close: async () => {
1733
- Gt = !1, await Jt.drainRequests();
1734
- for (let e of Te) try {
1742
+ Kt = !1, await Yt.drainRequests();
1743
+ for (let e of Oe) try {
1735
1744
  await e();
1736
1745
  } catch (e) {
1737
- I.warn("serve: teardown step failed", {}, e);
1746
+ F.warn("serve: teardown step failed", {}, e);
1738
1747
  }
1739
- await ze?.detach(), await Re.detach(), Zt?.detach(), Qt?.detach(), n?.detach(), $t?.detach(), Xt?.(), Yt?.(), await p?.shutdown(), r.close(), await ne?.detach(), await d?.dispose(), await qt(), await Jt.finish();
1748
+ await We?.detach(), await He.detach(), Qt?.detach(), $t?.detach(), n?.detach(), en?.detach(), Zt?.(), Xt?.(), await h?.shutdown(), r.close(), await ne?.detach(), await f?.dispose(), await Jt(), await Yt.finish();
1740
1749
  }
1741
1750
  };
1742
- }, $ = R({ scope: "voltro:serve" }), mo = (e, t, n) => (e === "production" || e === "staging") && t !== "memory" && n !== "0", ho = Ut, go = async (e) => {
1743
- let t = Sn(process.cwd());
1744
- if (An(t)) {
1751
+ }, $ = L({ scope: "voltro:serve" }), ho = (e, t, n) => (e === "production" || e === "staging") && t !== "memory" && n !== "0", go = N, _o = async (e) => {
1752
+ let t = wn(process.cwd());
1753
+ if (Mn(t)) {
1745
1754
  let n;
1746
1755
  try {
1747
- let e = await import(jn(t).href);
1756
+ let e = await import(Nn(t).href);
1748
1757
  typeof e.runServe == "function" ? n = e.runServe : $.warn("serve bundle has no runServe export — using the standard serve path");
1749
1758
  } catch (e) {
1750
1759
  $.warn("serve bundle failed to load — using the standard serve path", {}, e);
1751
1760
  }
1752
1761
  if (n) return $.info("serve: booting from the precompiled serve bundle"), n(e);
1753
1762
  }
1754
- return _o(e);
1755
- }, _o = async (c) => {
1756
- let f = Cn();
1763
+ return vo(e);
1764
+ }, vo = async (c) => {
1765
+ let l = Tn();
1757
1766
  e("serve");
1758
1767
  try {
1759
- Di();
1768
+ Oi();
1760
1769
  } catch (e) {
1761
1770
  throw i(e instanceof Error ? e.message : String(e));
1762
1771
  }
1763
- let m = process.cwd(), g = await We(m), ie = P({
1772
+ let p = process.cwd(), m = await We(p), se = Gt({
1764
1773
  kind: "api",
1765
- configPort: g?.port,
1774
+ configPort: m?.port,
1766
1775
  env: process.env,
1767
- flagPort: ho(c, "--port")
1776
+ flagPort: go(c, "--port")
1768
1777
  });
1769
- for (let e of ie.warnings) $.warn(e);
1770
- let oe = ie.port;
1771
- ai(ri(g?.secrets)), await Wt({
1772
- rawEnv: g?.env,
1778
+ for (let e of se.warnings) $.warn(e);
1779
+ let ce = se.port;
1780
+ oi(ii(m?.secrets)), await Kt({
1781
+ rawEnv: m?.env,
1773
1782
  appType: "api",
1774
- root: m,
1783
+ root: p,
1775
1784
  log: $,
1776
1785
  generateTypes: !1
1777
- }), f.mark("config");
1778
- let _ = (process.env.DB_DIALECT ?? g?.store ?? "memory").toLowerCase(), le = (_ === "mariadb" || _ === "postgres" || _ === "mssql") && (process.env.CDC ?? "1") !== "0", ue = _ === "mariadb" ? "mariadb" : _ === "mssql" ? "mssql" : void 0, de = xn(m);
1779
- if (!r() && An(de)) try {
1780
- let e = await import(jn(de).href);
1786
+ }), l.mark("config");
1787
+ let _ = (process.env.DB_DIALECT ?? m?.store ?? "memory").toLowerCase(), de = (_ === "mariadb" || _ === "postgres" || _ === "mssql") && (process.env.CDC ?? "1") !== "0", fe = _ === "mariadb" ? "mariadb" : _ === "mssql" ? "mssql" : void 0, me = Cn(p);
1788
+ if (!r() && Mn(me)) try {
1789
+ let e = await import(Nn(me).href);
1781
1790
  if (e.modules) {
1782
1791
  let t = {};
1783
- for (let [n, r] of Object.entries(e.modules)) t[On(m, n)] = r;
1792
+ for (let [n, r] of Object.entries(e.modules)) t[An(p, n)] = r;
1784
1793
  n(t), $.info("precompiled api bundle loaded", { modules: Object.keys(t).length });
1785
1794
  }
1786
1795
  } catch (e) {
1787
1796
  $.warn("precompiled api bundle failed to load — falling back to source", {}, e);
1788
1797
  }
1789
- let v = await Ze(m), y = await kt(v, { cdc: le && ue !== void 0 }), fe = Ht(y);
1798
+ let v = await yt(p), y = await jt(v, { cdc: de && fe !== void 0 }), he = f(y);
1790
1799
  {
1791
- let e = /* @__PURE__ */ new Set([
1792
- ...y.queries.filter((e) => e.descriptor.overridesPlugin === !0).map((e) => e.descriptor.name),
1793
- ...y.mutations.filter((e) => e.descriptor.overridesPlugin === !0).map((e) => e.descriptor.name),
1794
- ...y.actions.filter((e) => e.descriptor.overridesPlugin === !0).map((e) => e.descriptor.name)
1795
- ]);
1796
- nn(Xt(g?.plugins ?? []), [
1797
- ...y.queries.map((e) => e.descriptor.name),
1798
- ...y.mutations.map((e) => e.descriptor.name),
1799
- ...y.actions.map((e) => e.descriptor.name),
1800
- ...y.streams.map((e) => e.descriptor.name)
1801
- ], e);
1802
- let t = se(y.serverOnlyLeaks, Me(process.env, "strict"), Er, "`voltro serve`");
1803
- if (t.action === "fail") throw i(t.message ?? "");
1804
- t.action === "warn" && $.warn(t.message ?? "");
1800
+ qe({
1801
+ plugins: m?.plugins ?? [],
1802
+ queries: y.queries,
1803
+ mutations: y.mutations,
1804
+ actions: y.actions,
1805
+ streams: y.streams,
1806
+ log: $
1807
+ });
1808
+ let e = pe(y.serverOnlyLeaks, g(process.env, "strict"), Dr, "`voltro serve`");
1809
+ if (e.action === "fail") throw i(e.message ?? "");
1810
+ e.action === "warn" && $.warn(e.message ?? "");
1805
1811
  }
1806
- let me = v.filter((e) => yn.test(e)), he = me.length > 0 ? await vn(me, $.child("webhooks")) : {
1812
+ let ge = v.filter((e) => Sn.test(e)), _e = ge.length > 0 ? await xn(ge, $.child("webhooks")) : {
1807
1813
  outgoing: [],
1808
1814
  incoming: [],
1809
1815
  providers: []
1810
- }, ge = gn(y.events), Se = he.outgoing.length + he.incoming.length + he.providers.length + ge.length === 0 ? void 0 : {
1811
- ...he,
1812
- outgoing: [...he.outgoing, ...ge]
1813
- }, Ce = rn({
1816
+ }, ye = yn(y.events), be = _e.outgoing.length + _e.incoming.length + _e.providers.length + ye.length === 0 ? void 0 : {
1817
+ ..._e,
1818
+ outgoing: [..._e.outgoing, ...ye]
1819
+ }, Se = rn({
1814
1820
  nodeEnv: process.env.NODE_ENV,
1815
- cdcDialect: ue,
1816
- declared: g?.schema
1817
- }), Ee = an({
1818
- gates: Ce,
1821
+ cdcDialect: fe,
1822
+ declared: m?.schema
1823
+ }), Ce = an({
1824
+ gates: Se,
1819
1825
  runtime: {
1820
- traces: be(),
1821
- undo: fi()
1826
+ traces: ae(),
1827
+ undo: pi()
1822
1828
  }
1823
1829
  });
1824
- if (Ee !== void 0) throw i(`serve: ${Ee}`);
1825
- let ke = tn({
1830
+ if (Ce !== void 0) throw i(`serve: ${Ce}`);
1831
+ let De = nn({
1826
1832
  mix: y.featureMix,
1827
- plugins: g?.plugins ?? [],
1828
- gates: Ce,
1829
- ...ue ? { cdcDialect: ue } : {}
1830
- }), Ae = g?.analytics !== void 0 && g.analytics.kind !== "noop" && _ !== "memory" ? (await F(_)).makeSqlLayer(D()) : void 0, je = await Ye({
1831
- spec: g?.analytics,
1832
- sqlLayer: Ae,
1833
+ plugins: m?.plugins ?? [],
1834
+ gates: Se,
1835
+ ...fe ? { cdcDialect: fe } : {}
1836
+ }), je = m?.analytics !== void 0 && m.analytics.kind !== "noop" && _ !== "memory" ? (await P(_)).makeSqlLayer(O()) : void 0, Me = await kt({
1837
+ spec: m?.analytics,
1838
+ sqlLayer: je,
1833
1839
  log: $
1834
- }), C = (() => {
1840
+ }), S = (() => {
1835
1841
  let e = new Set(y.tables.map((e) => e.tableName)), t = [...y.tables];
1836
- for (let n of [...ke, ...je.tables]) e.has(n.tableName) || (e.add(n.tableName), t.push(n));
1842
+ for (let n of [...De, ...Me.tables]) e.has(n.tableName) || (e.add(n.tableName), t.push(n));
1837
1843
  return t;
1838
1844
  })();
1839
- for (let e of C) $n(e);
1845
+ for (let e of S) tr(e);
1840
1846
  {
1841
- let e = Dr(pi(He(y), Lt(C)));
1847
+ let e = Or(mi(Rt(y), Ee(S)));
1842
1848
  e !== void 0 && $.warn(e);
1843
1849
  }
1844
- let Ie = (process.env.NODE_ENV ?? "").toLowerCase();
1845
- if (mo(Ie, _, process.env.VOLTRO_AUTO_MIGRATE)) {
1846
- let e = (await F(_)).makeSqlLayer(D()), t = await G.runPromise(rr.SqlClient.pipe(G.flatMap((e) => or(e, m)), G.provide(e), G.catchAll(() => G.succeed([]))));
1850
+ let Pe = (process.env.NODE_ENV ?? "").toLowerCase();
1851
+ if (ho(Pe, _, process.env.VOLTRO_AUTO_MIGRATE)) {
1852
+ let e = (await P(_)).makeSqlLayer(O()), t = await W.runPromise(ar.SqlClient.pipe(W.flatMap((e) => cr(e, p)), W.provide(e), W.catchAll(() => W.succeed([]))));
1847
1853
  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));
1848
- let n = await G.runPromise(rr.SqlClient.pipe(G.flatMap((e) => sr(e, C, {
1849
- appliedBy: `serve:${Ie}`,
1854
+ let n = await W.runPromise(ar.SqlClient.pipe(W.flatMap((e) => lr(e, S, {
1855
+ appliedBy: `serve:${Pe}`,
1850
1856
  environment: "prod",
1851
1857
  dialectId: _
1852
- })), G.provide(e)));
1853
- n.kind === "prod-mismatch" && ($.error(ar(n, _)), $.error(on({
1854
- gates: Ce,
1858
+ })), W.provide(e)));
1859
+ n.kind === "prod-mismatch" && ($.error(sr(n, _)), $.error(on({
1860
+ gates: Se,
1855
1861
  nodeEnv: process.env.NODE_ENV,
1856
- cdcDialect: ue,
1857
- declared: g?.schema
1858
- })), $.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(ar(n, _));
1862
+ cdcDialect: fe,
1863
+ declared: m?.schema
1864
+ })), $.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(sr(n, _));
1859
1865
  }
1860
- await Yt({
1866
+ await Zt({
1861
1867
  dialectId: _,
1862
- tables: C,
1863
- mode: Jt(g?.reactiveTriggers),
1864
- lockSchema: D().schema,
1865
- makeLayer: async () => (await F(_)).makeSqlLayer(D()),
1868
+ tables: S,
1869
+ mode: F(m?.reactiveTriggers),
1870
+ lockSchema: O().schema,
1871
+ makeLayer: async () => (await P(_)).makeSqlLayer(O()),
1866
1872
  log: {
1867
1873
  info: (e, t) => $.info(e, t ?? {}),
1868
1874
  warn: (e, t) => $.warn(e, t ?? {})
1869
1875
  }
1870
1876
  });
1871
- let Le = Jr(C);
1872
- f.mark("discover");
1873
- let w = await at(g, void 0);
1877
+ let Fe = Yr(S);
1878
+ l.mark("discover");
1879
+ let C = await ot(m, void 0);
1874
1880
  {
1875
- let e = await s(w);
1881
+ let e = await s(C);
1876
1882
  if (e !== void 0) throw i(`serve: ${e}`);
1877
1883
  }
1878
- let Ue = gi(w, _);
1879
- for (let e of rt({
1880
- dialect: String(g?.store ?? process.env.DB_DIALECT ?? "postgres"),
1884
+ let ze = _i(C, _);
1885
+ for (let e of tt({
1886
+ dialect: String(m?.store ?? process.env.DB_DIALECT ?? "postgres"),
1881
1887
  changeStrategy: (process.env.CDC ?? "1") === "0" ? "inline" : "cdc",
1882
1888
  dbUrl: process.env.DB_URL,
1883
- crossReplicaBus: zi(g?.plugins ?? [])?.broadcast.crossReplica === !0,
1889
+ crossReplicaBus: Mi(m?.plugins ?? [])?.broadcast.crossReplica === !0,
1884
1890
  tables: y.tables.map((e) => ({
1885
1891
  tableName: e.tableName,
1886
1892
  isReactive: e.isReactive === !0
@@ -1891,175 +1897,184 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
1891
1897
  })
1892
1898
  })) e.level === "warn" ? $.warn(e.message) : $.info(e.message);
1893
1899
  {
1894
- let e = yt({
1895
- tables: Jn().map((e) => ({ tableName: e.tableName })),
1900
+ let e = ht({
1901
+ tables: Xn().map((e) => ({ tableName: e.tableName })),
1896
1902
  queries: y.queries.map((e) => ({
1897
1903
  name: e.descriptor.name,
1898
1904
  source: e.descriptor.source
1899
1905
  }))
1900
- }), t = ht(e);
1906
+ }), t = it(e);
1901
1907
  t !== void 0 && $.warn(t);
1902
1908
  }
1903
- g?.cache && !process.env.CACHE_BACKEND && (process.env.CACHE_BACKEND = g.cache), g?.cacheRedisUrl && !process.env.CACHE_REDIS_URL && (process.env.CACHE_REDIS_URL = g.cacheRedisUrl), g?.cacheRedisDriver && !process.env.CACHE_REDIS_DRIVER && (process.env.CACHE_REDIS_DRIVER = g.cacheRedisDriver), g?.cacheKeyPrefix && !process.env.CACHE_KEY_PREFIX && (process.env.CACHE_KEY_PREFIX = g.cacheKeyPrefix);
1904
- let { service: Ge, invalidationBus: Ke, snapshotCache: Je, cache: Xe, semantic: $e, evictSource: tt, backend: ot, stats: ct, dispose: lt } = await Qe({
1909
+ m?.cache && !process.env.CACHE_BACKEND && (process.env.CACHE_BACKEND = m.cache), m?.cacheRedisUrl && !process.env.CACHE_REDIS_URL && (process.env.CACHE_REDIS_URL = m.cacheRedisUrl), m?.cacheRedisDriver && !process.env.CACHE_REDIS_DRIVER && (process.env.CACHE_REDIS_DRIVER = m.cacheRedisDriver), m?.cacheKeyPrefix && !process.env.CACHE_KEY_PREFIX && (process.env.CACHE_KEY_PREFIX = m.cacheKeyPrefix);
1910
+ let { service: Be, invalidationBus: Ue, snapshotCache: Ge, cache: Ye, semantic: Ze, evictSource: $e, backend: pt, stats: mt, dispose: bt } = await k({
1905
1911
  env: process.env,
1906
- semantic: g?.cacheSemantic ?? !1
1912
+ semantic: m?.cacheSemantic ?? !1
1907
1913
  });
1908
- $e !== void 0 && $.info("semantic cache enabled — reactive eviction on live writes"), $.info(`cache backend resolved: ${ot}` + (ot === "redis" ? ` (driver ${process.env.CACHE_REDIS_DRIVER ?? "resp"})` : " — in-process, not cross-instance")), w.onChange((e) => {
1909
- if (G.runFork(Ke.publish(e.table)), tt !== void 0) {
1914
+ Ze !== void 0 && $.info("semantic cache enabled — reactive eviction on live writes"), $.info(`cache backend resolved: ${pt}` + (pt === "redis" ? ` (driver ${process.env.CACHE_REDIS_DRIVER ?? "resp"})` : " — in-process, not cross-instance")), C.onChange((e) => {
1915
+ if (W.runFork(Ue.publish(e.table)), $e !== void 0) {
1910
1916
  let t = (e.new ?? e.old)?.id;
1911
- tt({
1917
+ $e({
1912
1918
  table: e.table,
1913
1919
  op: e.op,
1914
1920
  ...t === void 0 ? {} : { id: t }
1915
1921
  });
1916
1922
  }
1917
- }), g?.kv && !process.env.KV_BACKEND && (process.env.KV_BACKEND = g.kv), g?.kvRedisUrl && !process.env.KV_REDIS_URL && (process.env.KV_REDIS_URL = g.kvRedisUrl), g?.kvKeyPrefix && !process.env.KV_KEY_PREFIX && (process.env.KV_KEY_PREFIX = g.kvKeyPrefix);
1918
- let { kv: ft, service: pt } = await Lr({ store: w });
1919
- Pt({
1923
+ }), m?.kv && !process.env.KV_BACKEND && (process.env.KV_BACKEND = m.kv), m?.kvRedisUrl && !process.env.KV_REDIS_URL && (process.env.KV_REDIS_URL = m.kvRedisUrl), m?.kvKeyPrefix && !process.env.KV_KEY_PREFIX && (process.env.KV_KEY_PREFIX = m.kvKeyPrefix);
1924
+ let { kv: xt, service: St } = await Rr({ store: C });
1925
+ ke({
1920
1926
  log: $,
1921
- max: qt(),
1922
- outOfPool: te(_, (process.env.CDC ?? "1") !== "0"),
1927
+ max: Yt(),
1928
+ outOfPool: Ft(_, (process.env.CDC ?? "1") !== "0"),
1923
1929
  readPools: t.replicationSnapshot()?.replicaCount ?? 0,
1924
1930
  always: !0
1925
- }), f.mark("store");
1926
- let _t = hr({
1927
- store: w,
1928
- sink: je.sink,
1931
+ }), l.mark("store");
1932
+ let wt = _r({
1933
+ store: C,
1934
+ sink: Me.sink,
1929
1935
  log: $
1930
- }), St = qe({
1931
- store: w,
1936
+ }), At = Qe({
1937
+ store: C,
1932
1938
  dialect: _,
1933
1939
  log: { info: (e) => $.info(e) }
1934
- }), j = g?.plugins ?? [], jt = process.env.POD_NAME ?? process.env.HOSTNAME ?? `serve-${process.pid}`, Rt, Bt;
1935
- _ !== "memory" && (Rt = nr.make((await F(_)).makeSqlLayer(D())), Bt = await Rt.runPromise(rr.SqlClient));
1936
- let Ut = [
1940
+ }), A = m?.plugins ?? [], Mt = process.env.POD_NAME ?? process.env.HOSTNAME ?? `serve-${process.pid}`, Nt, zt;
1941
+ _ !== "memory" && (Nt = ir.make((await P(_)).makeSqlLayer(O())), zt = await Nt.runPromise(ar.SqlClient));
1942
+ let N = [
1937
1943
  "postgres",
1938
1944
  "mariadb",
1939
1945
  "mysql",
1940
1946
  "mssql"
1941
- ].includes(_) ? Nr(w, jt, $) : ci, _n = M(g?.scheduling), Sn = zr({
1942
- maxIdleIntervalMs: _n.pollCeilingMs,
1943
- coordinator: Ut,
1944
- replicaId: jt,
1947
+ ].includes(_) ? Pr(C, Mt, $) : li, gn = Ht(m?.scheduling), bn = Br({
1948
+ maxIdleIntervalMs: gn.pollCeilingMs,
1949
+ coordinator: N,
1950
+ replicaId: Mt,
1945
1951
  log: $
1946
- }), wn = [], Tn = process.env.POD_NAME ?? process.env.HOSTNAME ?? `serve-${process.pid}`, En = zi(g?.plugins ?? [])?.broadcast?.provider, L = et(g?.plugins, g?.name ?? Dn(m));
1952
+ }), wn = [], En = process.env.POD_NAME ?? process.env.HOSTNAME ?? `serve-${process.pid}`, Dn = Mi(m?.plugins ?? [])?.broadcast?.provider, On = Re(m?.plugins, m?.name ?? kn(p));
1947
1953
  {
1948
- let e = nt(g?.plugins, g?.name ?? Dn(m));
1954
+ let e = et(m?.plugins, m?.name ?? kn(p));
1949
1955
  e !== void 0 && $.warn(e);
1950
1956
  }
1951
- let kn = Mt(g?.plugins, {
1952
- instanceId: Tn,
1953
- namespace: L,
1957
+ let I = Bt(m?.plugins, {
1958
+ instanceId: En,
1959
+ namespace: On,
1954
1960
  meta: { mode: "serve" },
1955
1961
  logger: $
1956
- }), R = {
1957
- ...Bt ? { sql: Bt } : {},
1958
- instanceId: Tn,
1959
- membership: kn.membership,
1960
- ...En === void 0 ? {} : { broadcast: En },
1961
- broadcastChannels: { presence: Ri(L, "presence") },
1962
+ }), jn = hn({
1963
+ mode: "serve",
1964
+ dialect: _,
1965
+ ...Dn === void 0 ? {} : { provider: Dn },
1966
+ logger: $
1967
+ });
1968
+ $r(async () => {
1969
+ await jn.stop();
1970
+ });
1971
+ let L = {
1972
+ ...zt ? { sql: zt } : {},
1973
+ instanceId: En,
1974
+ membership: I.membership,
1975
+ ...Dn === void 0 ? {} : { broadcast: Dn },
1976
+ broadcastChannels: { presence: ji(On, "presence") },
1962
1977
  scheduleCoordinated: (e, t, n) => {
1963
- let r = Sn(e, t, n);
1978
+ let r = bn(e, t, n);
1964
1979
  return wn.push(r), r;
1965
1980
  }
1966
1981
  };
1967
- for (let e of j) e.bindDataStore?.(Ue, R);
1968
- u({
1969
- store: w,
1970
- ...ut(),
1982
+ for (let e of A) e.bindDataStore?.(ze, L);
1983
+ lt({
1984
+ store: C,
1985
+ ...u(),
1971
1986
  log: $
1972
1987
  });
1973
- let Mn = j.filter((e) => typeof e.onChangeEvent == "function");
1974
- if (Mn.length > 0) {
1975
- let e = w.changeScope ?? "local";
1976
- w.onChange((t) => {
1977
- let n = xe(t, e);
1978
- for (let e of Mn) G.runFork(e.onChangeEvent(n).pipe(G.catchAllCause((t) => G.sync(() => $.warn(`plugin ${e.name} onChangeEvent failed`, { error: tr.pretty(t) })))));
1988
+ let Pn = A.filter((e) => typeof e.onChangeEvent == "function");
1989
+ if (Pn.length > 0) {
1990
+ let e = C.changeScope ?? "local";
1991
+ C.onChange((t) => {
1992
+ let n = oe(t, e);
1993
+ for (let e of Pn) W.runFork(e.onChangeEvent(n).pipe(W.catchAllCause((t) => W.sync(() => $.warn(`plugin ${e.name} onChangeEvent failed`, { error: rr.pretty(t) })))));
1979
1994
  });
1980
1995
  }
1981
- let Nn = Fe({
1982
- plugins: j,
1983
- appName: g?.name ?? "voltro-api",
1996
+ let Fn = Ne({
1997
+ plugins: A,
1998
+ appName: m?.name ?? "voltro-api",
1984
1999
  appType: "api",
1985
2000
  voltroVersion: process.env.npm_package_version ?? "0.0.0",
1986
2001
  log: $
1987
2002
  });
1988
- j.length && await Nn.activate(), f.mark("plugins");
1989
- let Pn = await Nn.gatherObservability(), Fn = {
2003
+ A.length && await Fn.activate(), l.mark("plugins");
2004
+ let In = await Fn.gatherObservability(), Ln = {
1990
2005
  info: (e, t) => process.stdout.write(`[broadcast] ${e} ${t ? JSON.stringify(t) : ""}\n`),
1991
2006
  warn: (e, t) => process.stderr.write(`[broadcast] ${e} ${t ? JSON.stringify(t) : ""}\n`),
1992
2007
  debug: () => {}
1993
- }, In, Ln = await k(w, g, _, L, Fn, (e, t) => {
1994
- In?.refreshAll(`broadcast gap: missed ${t} change(s) from ${e}`);
1995
- }), z = g?.apiKeys, Rn = (typeof z == "object" ? z.prefix : void 0) ?? "voltro_", zn = z ? Tr(w) : void 0, Bn = zn ? Fr({ flush: Ir(zn) }) : void 0;
1996
- Bn && Qr(() => Bn.shutdown());
1997
- let B = zn ? Pr(zn, {
1998
- prefix: Rn,
1999
- ...Bn ? { usage: Bn } : {}
2000
- }) : void 0, Vn = B ? [Or(B, { prefix: Rn })] : [], Hn = Ct([...g?.auth?.strategies ?? [], ...Vn], Ii(g?.plugins ?? []), g?.auth?.anonymousTenantRequired ?? !1, g?.auth, () => Ue), Un = [...g?.restRoutes ?? [], ...B ? mr(B, (typeof z == "object" ? z.managementPath : void 0) ?? "/v1/api-keys") : []], Wn = A(g?.idempotency, w), Gn = j.map((e) => e.services).filter((e) => e !== void 0), Kn = K.mergeAll(vt({
2001
- analyticsLayer: je.layer,
2002
- cacheService: Ge,
2003
- kvService: pt,
2004
- ...$e === void 0 ? {} : { semanticCache: $e },
2005
- pluginServices: Gn,
2006
- userLayers: g?.layers ?? []
2007
- }), ze(g?.http ?? {})), V = await Be({
2008
+ }, Rn, zn = await T(C, m, _, On, Ln, (e, t) => {
2009
+ Rn?.refreshAll(`broadcast gap: missed ${t} change(s) from ${e}`);
2010
+ }), R = m?.apiKeys, Bn = (typeof R == "object" ? R.prefix : void 0) ?? "voltro_", Vn = R ? Er(C) : void 0, Hn = Vn ? Ir({ flush: Lr(Vn) }) : void 0;
2011
+ Hn && $r(() => Hn.shutdown());
2012
+ let z = Vn ? Fr(Vn, {
2013
+ prefix: Bn,
2014
+ ...Hn ? { usage: Hn } : {}
2015
+ }) : void 0, Un = z ? [kr(z, { prefix: Bn })] : [], Wn = Ct([...m?.auth?.strategies ?? [], ...Un], zi(m?.plugins ?? []), m?.auth?.anonymousTenantRequired ?? !1, m?.auth, () => ze), Gn = [...m?.restRoutes ?? [], ...z ? gr(z, (typeof R == "object" ? R.managementPath : void 0) ?? "/v1/api-keys") : []], Kn = st(m?.idempotency, C), qn = A.map((e) => e.services).filter((e) => e !== void 0), Jn = G.mergeAll(Et({
2016
+ analyticsLayer: Me.layer,
2017
+ cacheService: Be,
2018
+ kvService: St,
2019
+ ...Ze === void 0 ? {} : { semanticCache: Ze },
2020
+ pluginServices: qn,
2021
+ userLayers: m?.layers ?? []
2022
+ }), _t(m?.http ?? {})), B = await vt({
2008
2023
  files: v,
2009
- store: w,
2024
+ store: C,
2010
2025
  log: $,
2011
2026
  seedPolicy: "report",
2012
2027
  seedPattern: fn,
2013
- loadSeedFiles: I,
2028
+ loadSeedFiles: Xt,
2014
2029
  startupPattern: sn,
2015
2030
  loadStartupFiles: a,
2016
2031
  runStartups: o,
2017
- emailPattern: O,
2018
- loadEmailFiles: Tt,
2019
- registerEmailTemplates: Li
2032
+ emailPattern: Dt,
2033
+ loadEmailFiles: Ke,
2034
+ registerEmailTemplates: Bi
2020
2035
  });
2021
- (V.startupCount > 0 || V.emailCount > 0) && $.info("boot lifecycle", {
2022
- startups: V.startupCount,
2023
- emailTemplates: V.emailCount
2024
- }), V.startups !== void 0 && Qr(async () => {
2025
- await V.startups.stop();
2026
- }), pe({
2027
- demands: we(fe),
2028
- isRegistered: (e) => kr(e) !== void 0
2036
+ (B.startupCount > 0 || B.emailCount > 0) && $.info("boot lifecycle", {
2037
+ startups: B.startupCount,
2038
+ emailTemplates: B.emailCount
2039
+ }), B.startups !== void 0 && $r(async () => {
2040
+ await B.startups.stop();
2041
+ }), Te({
2042
+ demands: Wt(he),
2043
+ isRegistered: (e) => Ar(e) !== void 0
2029
2044
  });
2030
- let H = wt({
2031
- schedules: st({
2045
+ let V = ct({
2046
+ schedules: Ve({
2032
2047
  schedules: y.schedules,
2033
- seeds: V.seeds,
2034
- store: w,
2048
+ seeds: B.seeds,
2049
+ store: C,
2035
2050
  log: $.child("seeds")
2036
2051
  }),
2037
2052
  workflows: y.workflows ?? [],
2038
2053
  log: $.child("workflow-schedules")
2039
- }), U = g?.scheduling ?? {}, qn = U.trigger ?? "self", Yn = /* @__PURE__ */ new Set([
2054
+ }), H = m?.scheduling ?? {}, Yn = H.trigger ?? "self", Zn = /* @__PURE__ */ new Set([
2040
2055
  "postgres",
2041
2056
  "mysql",
2042
2057
  "mariadb",
2043
2058
  "mssql"
2044
- ]), Zn = U.coordination ?? (Yn.has(_) ? "advisoryLock" : "single"), Qn = Zn === "cluster" && Yn.has(_), W = Qn ? "cluster" : Zn === "advisoryLock" && Yn.has(_) ? "advisoryLock" : "single";
2045
- Zn === "cluster" && !Qn && $.warn("scheduling.coordination=cluster needs a sql-backed store except sqlite — falling back to single"), Zn === "advisoryLock" && !Yn.has(_) && $.warn("scheduling.coordination=advisoryLock needs a SQL store (the claim-row gate) — falling back to single");
2046
- let er, cr = y.workflows.length > 0 || y.workflowWorkers.length > 0 || y.eventTriggers.length > 0 || (Se?.outgoing.length ?? 0) > 0 || Qn, lr;
2047
- if (cr) {
2059
+ ]), $n = H.coordination ?? (Zn.has(_) ? "advisoryLock" : "single"), er = $n === "cluster" && Zn.has(_), U = er ? "cluster" : $n === "advisoryLock" && Zn.has(_) ? "advisoryLock" : "single";
2060
+ $n === "cluster" && !er && $.warn("scheduling.coordination=cluster needs a sql-backed store except sqlite — falling back to single"), $n === "advisoryLock" && !Zn.has(_) && $.warn("scheduling.coordination=advisoryLock needs a SQL store (the claim-row gate) — falling back to single");
2061
+ let nr, ur = y.workflows.length > 0 || y.workflowWorkers.length > 0 || y.eventTriggers.length > 0 || (be?.outgoing.length ?? 0) > 0 || er, dr;
2062
+ if (ur) {
2048
2063
  if (_ === "mssql") {
2049
- let e = await hn(process.cwd());
2064
+ let e = await vn(process.cwd());
2050
2065
  e && $.warn(e);
2051
2066
  }
2052
- let [{ WorkflowEngine: e }, { makeClusterCronLayer: t, workflowEngineLayer: n, resolveRunnerStorage: r, resolveFailoverTuning: i }] = await Promise.all([import("@effect/workflow"), import("@voltro/workflow/cluster")]), a = Qn ? H.filter((e) => (e.trigger ?? qn) === "self").map((e) => t({
2067
+ let [{ WorkflowEngine: e }, { makeClusterCronLayer: t, workflowEngineLayer: n, resolveRunnerStorage: r, resolveFailoverTuning: i }] = await Promise.all([import("@effect/workflow"), import("@voltro/workflow/cluster")]), a = er ? V.filter((e) => (e.trigger ?? Yn) === "self").map((e) => t({
2053
2068
  name: e.name,
2054
- cron: wr(e),
2069
+ cron: Tr(e),
2055
2070
  execute: async () => {
2056
- await er?.fireFromCluster(e.name);
2071
+ await nr?.fireFromCluster(e.name);
2057
2072
  }
2058
2073
  })) : [];
2059
- lr = _ === "memory" ? e.layerMemory : await (async () => {
2060
- let e = await F(_), t = r({ sqliteFamily: e.id === "sqlite" || e.id === "turso" });
2074
+ dr = _ === "memory" ? e.layerMemory : await (async () => {
2075
+ let e = await P(_), t = r({ sqliteFamily: e.id === "sqlite" || e.id === "turso" });
2061
2076
  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({
2062
- sqlClientLayer: e.makeSqlLayer(D()),
2077
+ sqlClientLayer: e.makeSqlLayer(O()),
2063
2078
  runnerStorage: t,
2064
2079
  dialectId: e.id,
2065
2080
  ...process.env.VOLTRO_WORKFLOW_RUNNER_PORT ? { runnerListenPort: Number(process.env.VOLTRO_WORKFLOW_RUNNER_PORT) } : {},
@@ -2068,116 +2083,116 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
2068
2083
  });
2069
2084
  })();
2070
2085
  }
2071
- let ur = xt(j, bn()), dr = v.filter((e) => /\.subscribe\.tsx?$/.test(e)), fr = dr.length > 0 ? await l(dr, $) : [], pr = v.filter((e) => /\.reaction\.tsx?$/.test(e)), gr = pr.length > 0 ? await _e(pr, $) : [], _r = v.filter((e) => un.test(e)), vr = _r.length > 0 ? await Pe(_r, $) : [], yr = v.filter((e) => /\.aggregate\.tsx?$/.test(e)), q = yr.length > 0 ? await ye(yr, $) : [];
2086
+ let fr = ue(A, _n()), pr = v.filter((e) => /\.subscribe\.tsx?$/.test(e)), mr = pr.length > 0 ? await Xe(pr, $) : [], hr = v.filter((e) => /\.reaction\.tsx?$/.test(e)), vr = hr.length > 0 ? await xe(hr, $) : [], yr = v.filter((e) => un.test(e)), br = yr.length > 0 ? await Le(yr, $) : [], xr = v.filter((e) => /\.aggregate\.tsx?$/.test(e)), K = xr.length > 0 ? await ft(xr, $) : [];
2072
2087
  {
2073
- let e = Dr(pi(He({ aggregates: q.map((e) => e.definition) }), Lt(C)));
2088
+ let e = Or(mi(Rt({ aggregates: K.map((e) => e.definition) }), Ee(S)));
2074
2089
  e !== void 0 && $.warn(e);
2075
2090
  }
2076
- let br = dt();
2077
- if (q.length > 0 && _ !== "memory") try {
2078
- let e = (await F(_)).makeSqlLayer(D());
2079
- br = d(e);
2091
+ let Sr = d();
2092
+ if (K.length > 0 && _ !== "memory") try {
2093
+ let e = (await P(_)).makeSqlLayer(O());
2094
+ Sr = ut(e);
2080
2095
  } catch (e) {
2081
2096
  $.warn("aggregate: SQL storage init failed — falling back to in-process", { err: String(e) });
2082
2097
  }
2083
- let xr = _ === "memory" ? ci : Nr(w, `aggregate@${process.pid}`, $), Sr = v.filter((e) => dn.test(e)), Cr = Sr.length > 0 ? await Ft(Sr, $) : [], Ar = v.filter((e) => ln.test(e)), jr = Ar.length > 0 ? await ne(Ar, $) : [], Mr = v.filter((e) => cn.test(e)), Rr = Mr.length > 0 ? await S(Mr, $) : [], Br = [], Vr = [], Hr = v.filter((e) => Zt.test(e));
2084
- if (Hr.length > 0) {
2085
- let e = $.child("agent"), t = v.filter((e) => en.test(e));
2086
- t.length > 0 && await Qt(t, e);
2087
- let n = await $t(Hr, e);
2088
- for (let e of n.agents) for (let t of Ot(e)) (t.kind === "action" ? Br : Vr).push({
2098
+ let q = _ === "memory" ? li : Pr(C, `aggregate@${process.pid}`, $), Cr = v.filter((e) => dn.test(e)), wr = Cr.length > 0 ? await Ae(Cr, $) : [], jr = v.filter((e) => ln.test(e)), Mr = jr.length > 0 ? await It(jr, $) : [], Nr = v.filter((e) => cn.test(e)), zr = Nr.length > 0 ? await ie(Nr, $) : [], Vr = [], Hr = [], Ur = v.filter((e) => Qt.test(e));
2099
+ if (Ur.length > 0) {
2100
+ let e = $.child("agent"), t = v.filter((e) => tn.test(e));
2101
+ t.length > 0 && await $t(t, e);
2102
+ let n = await en(Ur, e);
2103
+ for (let e of n.agents) for (let t of D(e)) (t.kind === "action" ? Vr : Hr).push({
2089
2104
  file: t.file,
2090
2105
  descriptor: t.descriptor,
2091
2106
  executor: t.executor
2092
2107
  });
2093
2108
  n.agents.length > 0 && e.info("synthesized agent routes", { agents: n.agents.map((e) => e.descriptor.name) });
2094
2109
  }
2095
- f.mark("workflow");
2110
+ l.mark("workflow");
2096
2111
  let J = () => {
2097
2112
  let e = Y.workflowWriteActions();
2098
2113
  if (e === void 0) throw Error("workflow actions: this app registers no workflows");
2099
2114
  return e;
2100
- }, Ur = Xn({
2115
+ }, Wr = Qn({
2101
2116
  dialect: _,
2102
- ...D()
2103
- }), Wr = _ === "memory" ? void 0 : (await F(_)).makeSqlLayer(D()), Gr = async () => E({
2104
- sqlLayer: Wr,
2105
- declared: C,
2117
+ ...O()
2118
+ }), Gr = _ === "memory" ? void 0 : (await P(_)).makeSqlLayer(O()), Kr = async () => Tt({
2119
+ sqlLayer: Gr,
2120
+ declared: S,
2106
2121
  log: $
2107
- }), Kr = {
2122
+ }), qr = {
2108
2123
  kind: "api",
2109
2124
  meta: {
2110
- name: g?.name ?? "voltro-api",
2111
- voltroVersion: Et,
2112
- port: oe,
2125
+ name: m?.name ?? "voltro-api",
2126
+ voltroVersion: Ot,
2127
+ port: ce,
2113
2128
  mode: "start",
2114
2129
  store: _,
2115
- cdc: le ? "on" : "off",
2116
- ...Ur === void 0 ? {} : { databaseId: Ur }
2130
+ cdc: de ? "on" : "off",
2131
+ ...Wr === void 0 ? {} : { databaseId: Wr }
2117
2132
  },
2118
- rpc: Re(y, m),
2119
- workflows: Nt(y, m),
2120
- migrations: Gr,
2133
+ rpc: Pt(y, p),
2134
+ workflows: Vt(y, p),
2135
+ migrations: Kr,
2121
2136
  events: () => Y.eventsSnapshot(),
2122
2137
  agentTools: () => Y.agentTools(),
2123
2138
  invariantChecks: () => ({
2124
2139
  mode: "serve",
2125
- accessGate: fe,
2126
- config: g,
2140
+ accessGate: he,
2141
+ config: m,
2127
2142
  serverOnlyLeaks: y.serverOnlyLeaks,
2128
- migrations: Gr
2143
+ migrations: Kr
2129
2144
  }),
2130
2145
  members: () => Y.membersSnapshot(),
2131
2146
  inspectFireSchedule: async ({ name: e, trigger: t }) => {
2132
- if (!er) throw Error("scheduler not started — this app registers no self-triggered schedules (all schedules are trigger:'external', or there are none).");
2133
- return { runId: await er.fireNow(e, t) ?? null };
2147
+ if (!nr) throw Error("scheduler not started — this app registers no self-triggered schedules (all schedules are trigger:'external', or there are none).");
2148
+ return { runId: await nr.fireNow(e, t) ?? null };
2134
2149
  },
2135
- inspectBackfillSchedule: h({
2136
- getHandle: () => er,
2137
- getSchedules: () => H
2150
+ inspectBackfillSchedule: te({
2151
+ getHandle: () => nr,
2152
+ getSchedules: () => V
2138
2153
  }),
2139
- ...Se === void 0 ? {} : { webhooks: () => ve({
2140
- store: w,
2141
- discoveredWebhooks: Se
2154
+ ...be === void 0 ? {} : { webhooks: () => dt({
2155
+ store: C,
2156
+ discoveredWebhooks: be
2142
2157
  }) },
2143
2158
  plugins: () => ({
2144
- plugins: Nn.snapshot(),
2159
+ plugins: Fn.snapshot(),
2145
2160
  capturedAt: Date.now()
2146
2161
  }),
2147
- env: () => Gt(g?.name ?? Dn(m), {
2148
- ...g?.env !== void 0 && Ei(g.env) ? { contract: g.env } : {},
2149
- plugins: g?.plugins ?? []
2162
+ env: () => qt(m?.name ?? kn(p), {
2163
+ ...m?.env !== void 0 && Di(m.env) ? { contract: m.env } : {},
2164
+ plugins: m?.plugins ?? []
2150
2165
  }),
2151
- dataCache: () => Ve({
2152
- stats: ct,
2153
- backendKind: ot
2166
+ dataCache: () => Lt({
2167
+ stats: mt,
2168
+ backendKind: pt
2154
2169
  }),
2155
- subscriptions: () => It(() => In),
2156
- inspectTables: () => b(y.tables),
2157
- inspectRows: x({
2158
- store: w,
2170
+ subscriptions: () => b(() => Rn),
2171
+ inspectTables: () => we(y.tables),
2172
+ inspectRows: Ut({
2173
+ store: C,
2159
2174
  tables: y.tables,
2160
2175
  mask: !0
2161
2176
  }),
2162
2177
  metrics: (e) => Y.rpcMetrics().snapshot(e),
2163
- cluster: () => zt({
2164
- store: w,
2178
+ cluster: () => He({
2179
+ store: C,
2165
2180
  dialect: _,
2166
- useClusterCron: Qn,
2167
- scheduleCoordChoice: Zn
2181
+ useClusterCron: er,
2182
+ scheduleCoordChoice: $n
2168
2183
  }),
2169
- inspectSchedules: () => De({
2170
- schedules: H,
2171
- defaultTrigger: qn,
2172
- coordination: W
2184
+ inspectSchedules: () => h({
2185
+ schedules: V,
2186
+ defaultTrigger: Yn,
2187
+ coordination: U
2173
2188
  }),
2174
- inspectScheduleRuns: (e) => N(w, e),
2175
- ...ee(w, {
2176
- controls: it(y.workflows ?? []),
2189
+ inspectScheduleRuns: (e) => Oe(C, e),
2190
+ ...M(C, {
2191
+ controls: nt(y.workflows ?? []),
2177
2192
  active: (y.workflows?.length ?? 0) > 0,
2178
2193
  cancellation: () => Y.flowControlHealth()
2179
2194
  }),
2180
- webhookActions: Te(() => Y.webhooksService()),
2195
+ webhookActions: ee(() => Y.webhooksService()),
2181
2196
  inspectStartWorkflow: (e) => J().inspectStartWorkflow(e),
2182
2197
  inspectCancelWorkflowRun: (e) => J().inspectCancelWorkflowRun(e),
2183
2198
  inspectSuspendWorkflowRun: (e) => J().inspectSuspendWorkflowRun(e),
@@ -2186,13 +2201,13 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
2186
2201
  inspectRetryWorkflowRun: (e) => J().inspectRetryWorkflowRun(e),
2187
2202
  inspectSignalWorkflowRun: (e) => J().inspectSignalWorkflowRun(e),
2188
2203
  inspectUpdateWorkflowRun: (e) => J().inspectUpdateWorkflowRun(e),
2189
- inspectInferences: (e) => bt({
2190
- store: w,
2204
+ inspectInferences: (e) => gt({
2205
+ store: C,
2191
2206
  active: (y.workflows?.length ?? 0) > 0,
2192
2207
  dispatcher: () => Y.inferenceHealth()
2193
2208
  }, e.limit === void 0 ? {} : { limit: e.limit }),
2194
- ...gt({
2195
- store: w,
2209
+ ...at({
2210
+ store: C,
2196
2211
  cancelRun: async (e) => await Y.runCanceller()?.(e) ?? !1,
2197
2212
  retryRun: async (e) => J().inspectRetryWorkflowRun({ runId: e }),
2198
2213
  redriveRun: async (e) => Y.redriveWorkflowRun({ runId: e }),
@@ -2200,11 +2215,11 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
2200
2215
  }),
2201
2216
  inspectRedriveWorkflowRun: (e) => Y.redriveWorkflowRun(e),
2202
2217
  inspectResumeWorkflowRunFromStep: (e) => Y.resumeWorkflowRunFromStep(e)
2203
- }, qr = (process.env.VOLTRO_TENANT_ISOLATION ?? g?.tenancy?.isolation) === "namespace", Yr = qr && _ !== "memory" ? await (async () => {
2204
- let e = await F(_);
2205
- return At({
2206
- tables: C,
2207
- sqlLayer: e.makeSqlLayer(D()),
2218
+ }, Jr = (process.env.VOLTRO_TENANT_ISOLATION ?? m?.tenancy?.isolation) === "namespace", Xr = Jr && _ !== "memory" ? await (async () => {
2219
+ let e = await P(_);
2220
+ return Je({
2221
+ tables: S,
2222
+ sqlLayer: e.makeSqlLayer(O()),
2208
2223
  dialect: _,
2209
2224
  options: { retryFilter: e.retryFilter },
2210
2225
  log: {
@@ -2212,110 +2227,111 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
2212
2227
  error: (e, t, n) => $.error(e, t ?? {}, n)
2213
2228
  }
2214
2229
  });
2215
- })() : void 0, Xr = await mt({
2216
- input: g?.tenancy?.residency,
2217
- namespaceIsolationOn: qr,
2218
- makeStoreForUrl: (e, t) => at(g, void 0, Kt(D(), t)),
2230
+ })() : void 0, Zr = await rt({
2231
+ input: m?.tenancy?.residency,
2232
+ namespaceIsolationOn: Jr,
2233
+ makeStoreForUrl: (e, t) => ot(m, void 0, Jt(O(), t)),
2219
2234
  log: {
2220
2235
  info: (e, t) => $.info(e, t),
2221
2236
  warn: (e, t) => $.warn(e, t)
2222
2237
  }
2223
2238
  });
2224
- Xr !== void 0 && Qr(async () => {
2225
- await Xr.close();
2239
+ Zr !== void 0 && $r(async () => {
2240
+ await Zr.close();
2226
2241
  });
2227
- let Y = await po({
2228
- bootTiming: f,
2229
- broadcastNamespace: L,
2242
+ let Y = await mo({
2243
+ bootTiming: l,
2244
+ broadcastNamespace: On,
2230
2245
  scheduling: (() => {
2231
- let e = _n;
2246
+ let e = gn;
2232
2247
  return {
2233
2248
  admissionDrainMs: e.admissionDrainMs,
2234
2249
  inferenceTickMs: e.inferenceTickMs,
2235
2250
  cancelSweepMs: e.cancelSweepMs,
2236
2251
  stalenessSweepMs: e.stalenessSweepMs,
2237
- disarmWhenIdle: T({
2238
- changeScope: w.changeScope,
2239
- broadcastAttached: Ln !== void 0
2252
+ disarmWhenIdle: j({
2253
+ changeScope: C.changeScope,
2254
+ broadcastAttached: zn !== void 0
2240
2255
  })
2241
2256
  };
2242
2257
  })(),
2243
- ...g?.workflows?.staleness === void 0 ? {} : { workflowStaleness: g.workflows.staleness },
2244
- ...g?.workflows?.suspendSignalHintMs === void 0 ? {} : { workflowSuspendSignalHintMs: g.workflows.suspendSignalHintMs },
2245
- workflowRecording: Vt(g?.workflows?.recording),
2258
+ ...m?.workflows?.staleness === void 0 ? {} : { workflowStaleness: m.workflows.staleness },
2259
+ ...m?.workflows?.suspendSignalHintMs === void 0 ? {} : { workflowSuspendSignalHintMs: m.workflows.suspendSignalHintMs },
2260
+ workflowRecording: w(m?.workflows?.recording),
2246
2261
  membership: {
2247
- ...kn,
2248
- instanceId: Tn
2262
+ ...I,
2263
+ instanceId: En
2249
2264
  },
2250
2265
  security: {
2251
- defaultDeny: ce(g),
2252
- ...ae(g)
2266
+ defaultDeny: x(m),
2267
+ ...le(m)
2253
2268
  },
2254
- approvals: { defaultExpiryMs: Ne(g) },
2255
- ...g?.plugins === void 0 ? {} : { plugins: g.plugins },
2256
- ...Wn ? { idempotency: Wn } : {},
2257
- restRoutes: Un,
2258
- appProcedures: fe,
2269
+ approvals: { defaultExpiryMs: Ie(m) },
2270
+ ...m?.plugins === void 0 ? {} : { plugins: m.plugins },
2271
+ ...Kn ? { idempotency: Kn } : {},
2272
+ restRoutes: Gn,
2273
+ appProcedures: he,
2259
2274
  discovered: {
2260
- queries: [...y.queries, ...Vr],
2275
+ wsGateways: y.wsGateways,
2276
+ queries: [...y.queries, ...Hr],
2261
2277
  mutations: y.mutations,
2262
- actions: [...y.actions, ...Br],
2278
+ actions: [...y.actions, ...Vr],
2263
2279
  streams: y.streams,
2264
2280
  events: y.events,
2265
2281
  workflows: y.workflows,
2266
2282
  workflowWorkers: y.workflowWorkers,
2267
2283
  eventTriggers: y.eventTriggers,
2268
- schedules: H,
2269
- subscribers: fr,
2270
- outboxHandlers: vr,
2284
+ schedules: V,
2285
+ subscribers: mr,
2286
+ outboxHandlers: br,
2271
2287
  connections: y.connections,
2272
- reactions: gr,
2273
- aggregates: q,
2274
- expectations: Cr,
2275
- budgets: jr,
2276
- experiments: Rr,
2277
- ...Se === void 0 ? {} : { webhooks: Se }
2288
+ reactions: vr,
2289
+ aggregates: K,
2290
+ expectations: wr,
2291
+ budgets: Mr,
2292
+ experiments: zr,
2293
+ ...be === void 0 ? {} : { webhooks: be }
2278
2294
  },
2279
2295
  log: $,
2280
- analytics: je.sink,
2281
- aggregateStorage: br,
2282
- aggregateCoordinator: xr,
2283
- store: w,
2284
- kv: ft,
2285
- cache: Xe,
2286
- snapshotCache: Je,
2287
- ...g?.reactive === void 0 ? {} : { reactive: g.reactive },
2288
- schemaRegistry: Le,
2296
+ analytics: Me.sink,
2297
+ aggregateStorage: Sr,
2298
+ aggregateCoordinator: q,
2299
+ store: C,
2300
+ kv: xt,
2301
+ cache: Ye,
2302
+ snapshotCache: Ge,
2303
+ ...m?.reactive === void 0 ? {} : { reactive: m.reactive },
2304
+ schemaRegistry: Fe,
2289
2305
  tenantScopedTables: y.tenantScopedTables,
2290
2306
  softDeleteScopedTables: y.softDeleteScopedTables,
2291
- dataTransferSnapshot: ir(C, _),
2307
+ dataTransferSnapshot: or(S, _),
2292
2308
  dataTransferDialect: _,
2293
- ...Yr === void 0 ? {} : { ensureTenantProvisioned: Yr.ensure },
2294
- ...Xr === void 0 ? {} : { resolveResidentStore: Xr.resolveStore },
2295
- tenantIsolation: (process.env.VOLTRO_TENANT_ISOLATION ?? g?.tenancy?.isolation) === "namespace" ? "namespace" : "shared-schema",
2296
- resolveSubject: (e, t) => Hn({
2309
+ ...Xr === void 0 ? {} : { ensureTenantProvisioned: Xr.ensure },
2310
+ ...Zr === void 0 ? {} : { resolveResidentStore: Zr.resolveStore },
2311
+ tenantIsolation: (process.env.VOLTRO_TENANT_ISOLATION ?? m?.tenancy?.isolation) === "namespace" ? "namespace" : "shared-schema",
2312
+ resolveSubject: (e, t) => Wn({
2297
2313
  headers: e,
2298
2314
  clientId: t
2299
2315
  }),
2300
- ...g?.auth === void 0 ? {} : { authority: g.auth },
2301
- ...g?.agents === void 0 ? {} : { agents: g.agents },
2302
- httpRoutes: j.flatMap((e) => e.httpRoutes ?? []),
2303
- getStore: () => Ue,
2304
- ...Kn ? { baseLayer: Kn } : {},
2305
- ...lr === void 0 ? {} : { workflowEngineLayer: lr },
2306
- scheduleDefaultTrigger: qn,
2307
- scheduleCoordination: W,
2308
- scheduleArmSelf: !Qn,
2309
- dormancy: process.env.VOLTRO_DORMANCY === "sleep" || process.env.VOLTRO_DORMANCY === "always-on" ? process.env.VOLTRO_DORMANCY : g?.dormancy ?? "always-on",
2316
+ ...m?.auth === void 0 ? {} : { authority: m.auth },
2317
+ ...m?.agents === void 0 ? {} : { agents: m.agents },
2318
+ httpRoutes: A.flatMap((e) => e.httpRoutes ?? []),
2319
+ getStore: () => ze,
2320
+ ...Jn ? { baseLayer: Jn } : {},
2321
+ ...dr === void 0 ? {} : { workflowEngineLayer: dr },
2322
+ scheduleDefaultTrigger: Yn,
2323
+ scheduleCoordination: U,
2324
+ scheduleArmSelf: !er,
2325
+ dormancy: process.env.VOLTRO_DORMANCY === "sleep" || process.env.VOLTRO_DORMANCY === "always-on" ? process.env.VOLTRO_DORMANCY : m?.dormancy ?? "always-on",
2310
2326
  scheduleReplicaId: process.env.HOSTNAME ?? `pid-${process.pid}`,
2311
- ...ur === void 0 ? {} : { scheduleFireInterceptor: ur },
2327
+ ...fr === void 0 ? {} : { scheduleFireInterceptor: fr },
2312
2328
  onSchedulerReady: (e) => {
2313
- er = e;
2329
+ nr = e;
2314
2330
  },
2315
- inspectRoute: { handle: async (e, t, n, r) => await p(e, Kr, t, {
2331
+ inspectRoute: { handle: async (e, t, n, r) => await ve(e, qr, t, {
2316
2332
  method: n,
2317
2333
  ...r === void 0 ? {} : { body: r }
2318
- }) || ((n === "GET" ? await mn(e, Kr, t, { method: n }) : null) ?? pn(e, Kr, t, {
2334
+ }) || ((n === "GET" ? await mn(e, qr, t, { method: n }) : null) ?? pn(e, qr, t, {
2319
2335
  method: n,
2320
2336
  ...r === void 0 ? {} : { body: r }
2321
2337
  }) ?? {
@@ -2323,19 +2339,20 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
2323
2339
  contentType: "application/json",
2324
2340
  body: JSON.stringify({ error: "not an inspect route" })
2325
2341
  }) },
2326
- ...g?.name === void 0 ? {} : { appName: g.name },
2327
- observability: Pn,
2328
- port: oe,
2329
- ...g?.transport?.wsPath ? { path: g.transport.wsPath } : {}
2342
+ ...m?.name === void 0 ? {} : { appName: m.name },
2343
+ observability: In,
2344
+ port: ce,
2345
+ ...m?.transport?.wsPath ? { path: m.transport.wsPath } : {},
2346
+ ...m?.http === void 0 ? {} : { http: m.http }
2330
2347
  });
2331
- return In = Y.dispatcher, re(Oe([
2348
+ return Rn = Y.dispatcher, ne(re([
2332
2349
  y.queries,
2333
2350
  y.mutations,
2334
2351
  y.actions,
2335
2352
  y.streams
2336
2353
  ]), (e) => {
2337
2354
  $.warn(e);
2338
- }), $.info(`API listening on :${oe}`, {
2355
+ }), $.info(`API listening on :${ce}`, {
2339
2356
  dialect: _,
2340
2357
  queries: y.queries.length,
2341
2358
  mutations: y.mutations.length,
@@ -2343,20 +2360,20 @@ var Zi = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy <
2343
2360
  streams: y.streams.length,
2344
2361
  workflows: y.workflows.length,
2345
2362
  workflowWorkers: y.workflowWorkers.length,
2346
- schedules: H.length,
2347
- scheduleCoordination: W
2348
- }), f.finish($), Qr(async () => {
2363
+ schedules: V.length,
2364
+ scheduleCoordination: U
2365
+ }), l.finish($), $r(async () => {
2349
2366
  for (let e of wn) e.stop();
2350
- St.stop();
2367
+ At.stop();
2351
2368
  try {
2352
- await Y.close(), lt(), Rt?.dispose(), await Nn.deactivate(), await Ln?.close(), await Dt({
2353
- mirror: _t,
2369
+ await Y.close(), bt(), Nt?.dispose(), await Fn.deactivate(), await zn?.close(), await E({
2370
+ mirror: wt,
2354
2371
  log: $
2355
- }), await je.dispose(), await w.close?.();
2372
+ }), await Me.dispose(), await C.close?.();
2356
2373
  } catch (e) {
2357
2374
  console.error("serve: shutdown step failed, exiting anyway:", e);
2358
2375
  }
2359
2376
  }), await new Promise(() => {}), 0;
2360
2377
  };
2361
2378
  //#endregion
2362
- export { go as n, mo as r, _o as t };
2379
+ export { _o as n, ho as r, vo as t };