@voltro/cli 0.37.0 → 0.38.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 (104) hide show
  1. package/CHANGELOG.md +92 -0
  2. package/dist/{apiBuild-DGsShRuF.js → apiBuild-CvacV4zA.js} +2 -2
  3. package/dist/apiBuild-ttSDDOGp.js +2 -0
  4. package/dist/bin.js +1 -1
  5. package/dist/bootRefusal-pgvDxlrU.js +7 -0
  6. package/dist/{build-CiFA-E19.js → build-_LoTC1s0.js} +30 -30
  7. package/dist/{checkCommand-CLPTzYqM.js → checkCommand-Pjk5sBl2.js} +2 -2
  8. package/dist/{checkCommand-CIPYyNyc.js → checkCommand-wibtQx-N.js} +1 -1
  9. package/dist/{codegenCommand-BxS3sCeJ.js → codegenCommand-C60m_LCp.js} +1 -1
  10. package/dist/{codemodRunner-cyqu5oxr.js → codemodRunner-CXgQ-ecJ.js} +314 -201
  11. package/dist/{commands-BwG9A9Vv.js → commands-DaZVi9wi.js} +20 -20
  12. package/dist/{dashboardCommand-C7U146xQ.js → dashboardCommand-Dxy_kmoW.js} +3 -3
  13. package/dist/{dataCommand-BOwd8_aJ.js → dataCommand-D6-Ha2lf.js} +1 -1
  14. package/dist/{dev-BV6XNYKf.js → dev-CAOoXOkc.js} +1 -1
  15. package/dist/{dev-bwDgSObH.js → dev-E7Eo5GHc.js} +261 -260
  16. package/dist/doctorCommand-Cjl8Yii8.js +2 -0
  17. package/dist/{doctorCommand-BXyrtN2l.js → doctorCommand-gmDyALFL.js} +10 -10
  18. package/dist/{dormancyCommand-BDdRRLsa.js → dormancyCommand-CE6wG8lj.js} +1 -1
  19. package/dist/{embeddingsCommand-CjWGcAE6.js → embeddingsCommand-C3uAuf6N.js} +1 -1
  20. package/dist/{envCommand-B_TeG297.js → envCommand-DzuWh8ya.js} +19 -19
  21. package/dist/{evolveCommand-D6N-WfA4.js → evolveCommand-DPLqcYb2.js} +2 -2
  22. package/dist/index.js +1 -1
  23. package/dist/{infoCommand-BHKTprrx.js → infoCommand-CmczGj_l.js} +1 -1
  24. package/dist/{runtimeTrace-WYV7qYvz.js → runtimeTrace-6jfznSzr.js} +1 -1
  25. package/dist/{sdkgen-TM5sSdf7.js → sdkgen-CEJZZQUA.js} +1 -1
  26. package/dist/serveCommand-DNRF2nDI.js +2 -0
  27. package/dist/{serveCommand-CyZsXL1l.js → serveCommand-DnY4VS3D.js} +541 -540
  28. package/dist/serveEntry.js +1 -1
  29. package/dist/{start-BgN62boB.js → start-CidwCcjl.js} +1 -1
  30. package/dist/{start-T4VesWiM.js → start-RCh6qKFe.js} +24 -24
  31. package/dist/startEntry.js +1 -1
  32. package/dist/startup.d.ts +40 -1
  33. package/dist/startup.js +2 -2
  34. package/dist/startupRunner-CEqQq7ax.js +108 -0
  35. package/dist/updateCommand-B0J_T9Vs.js +2 -0
  36. package/dist/{updateCommand-9GHHsmDf.js → updateCommand-CmksX7m_.js} +1 -1
  37. package/dist/{webDev-Dybxew86.js → webDev-BKdD7c_a.js} +689 -691
  38. package/dist/webDev-CcJfdSjl2.js +2 -0
  39. package/dist/{webhooksCommand-CHWSPk5z.js → webhooksCommand-BHeaF1ZJ.js} +1 -1
  40. package/package.json +29 -17
  41. package/templates/AGENTS.md +1 -1
  42. package/templates/agent-docs/_index.md +1 -1
  43. package/templates/agent-docs/plugins/audit.md +4 -0
  44. package/templates/agent-docs/plugins/auth.md +4 -6
  45. package/templates/agent-docs/reference.md +3 -2
  46. package/templates/agent-docs/whats-new.md +49 -47
  47. package/templates/apps/api-ai/package.json +7 -7
  48. package/templates/apps/api-auth/package.json +8 -8
  49. package/templates/apps/api-backend/package.json +7 -7
  50. package/templates/apps/api-backend-deactivation/package.json +7 -7
  51. package/templates/apps/api-backend-mail/package.json +8 -8
  52. package/templates/apps/api-backend-mariadb/package.json +9 -9
  53. package/templates/apps/api-backend-sqlite/package.json +8 -8
  54. package/templates/apps/api-backend-storage/package.json +8 -8
  55. package/templates/apps/api-cms/package.json +10 -10
  56. package/templates/apps/api-cms/tests/content.write.test.ts +16 -2
  57. package/templates/apps/api-collab/mutations/documents.setBody.mutation.server.ts +11 -5
  58. package/templates/apps/api-collab/package.json +8 -8
  59. package/templates/apps/api-collab/tests/documents.setBody.test.ts +8 -2
  60. package/templates/apps/api-data-advanced/package.json +8 -8
  61. package/templates/apps/api-durable/package.json +8 -8
  62. package/templates/apps/api-feature-flags/package.json +9 -9
  63. package/templates/apps/api-governance/package.json +8 -8
  64. package/templates/apps/api-kv/package.json +8 -8
  65. package/templates/apps/api-moderation/package.json +8 -8
  66. package/templates/apps/api-observability/package.json +8 -8
  67. package/templates/apps/api-ratelimit/package.json +8 -8
  68. package/templates/apps/api-rbac/package.json +8 -8
  69. package/templates/apps/api-rest/package.json +7 -7
  70. package/templates/apps/api-saas/package.json +11 -11
  71. package/templates/apps/api-saas-starter/package.json +10 -10
  72. package/templates/apps/api-search/package.json +8 -8
  73. package/templates/apps/api-status/package.json +8 -8
  74. package/templates/apps/api-versioning/mutations/documents.update.mutation.server.ts +7 -5
  75. package/templates/apps/api-versioning/package.json +8 -8
  76. package/templates/apps/api-webhooks/package.json +9 -9
  77. package/templates/apps/changelog/package.json +6 -6
  78. package/templates/apps/edge-functions/package.json +2 -2
  79. package/templates/apps/frontend-admin/package.json +8 -8
  80. package/templates/apps/frontend-app/package.json +9 -9
  81. package/templates/apps/frontend-auth/package.json +8 -8
  82. package/templates/apps/frontend-blank/package.json +7 -7
  83. package/templates/apps/frontend-cms/package.json +9 -9
  84. package/templates/apps/frontend-collab/package.json +10 -10
  85. package/templates/apps/frontend-contact/package.json +7 -7
  86. package/templates/apps/frontend-dashboard/package.json +7 -7
  87. package/templates/apps/frontend-docs/package.json +7 -7
  88. package/templates/apps/frontend-i18n/package.json +6 -6
  89. package/templates/apps/frontend-landing/package.json +7 -7
  90. package/templates/apps/frontend-portal/package.json +8 -8
  91. package/templates/apps/frontend-saas/package.json +8 -8
  92. package/templates/apps/frontend-spa/package.json +7 -7
  93. package/templates/apps/frontend-ssr/package.json +7 -7
  94. package/templates/apps/frontend-ssr-api/package.json +8 -8
  95. package/templates/apps/frontend-static-blog/package.json +6 -6
  96. package/templates/apps/frontend-status/package.json +8 -8
  97. package/templates/apps/mobile-app/package.json +3 -3
  98. package/templates/patches/@effect__cluster@0.60.0.patch +51 -3
  99. package/dist/apiBuild-D0f6hYbH.js +0 -2
  100. package/dist/doctorCommand-C4L61G_L.js +0 -2
  101. package/dist/serveCommand-qumm7jdF.js +0 -2
  102. package/dist/startupRunner-DPGFchOa.js +0 -71
  103. package/dist/updateCommand-BN0tkl9-.js +0 -2
  104. package/dist/webDev-BcykISYQ2.js +0 -2
@@ -1,34 +1,35 @@
1
1
  import { t as e } from "./nodeEnvironment-cGFAj1J8.js";
2
2
  import { t } from "./frameworkInspectState-CX2250XB.js";
3
3
  import { r as n, t as r } from "./appModuleLoader-C9r9mxZt.js";
4
- import { n as i, t as a } from "./startupRunner-DPGFchOa.js";
5
- import { $ as o, $t as s, A as c, At as l, B as u, C as d, Ct as ee, D as f, Dt as p, E as te, Et as ne, F as re, Ft as m, G as ie, Gt as ae, H as oe, Ht as se, I as h, It as ce, J as le, Jt as g, K as ue, Kt as de, L as fe, Lt as pe, M as me, Mt as he, N as ge, Nt as _e, O as _, Ot as ve, P as ye, Pt as be, Q as xe, Qt as Se, R as Ce, S as we, St as Te, T as v, Tt as Ee, U as De, Ut as Oe, V as ke, Vt as Ae, W as je, Wt as y, X as Me, Xt as Ne, Y as Pe, Yt as Fe, Z as b, Zt as Ie, _ as Le, _n as x, _t as Re, an as ze, at as Be, b as Ve, bt as He, c as Ue, cn as We, ct as Ge, dn as S, dt as Ke, en as qe, et as Je, f as Ye, fn as Xe, ft as Ze, g as Qe, gn as $e, gt as et, h as tt, hn as nt, ht as rt, i as C, in as it, it as at, j as ot, jt as st, k as ct, kt as lt, ln as ut, lt as dt, m as ft, mn as pt, mt, nn as ht, nt as gt, o as w, on as _t, ot as T, p as vt, pt as yt, q as bt, qt as E, r as D, rn as xt, rt as St, sn as Ct, st as wt, t as Tt, tn as O, tt as Et, u as Dt, un as Ot, ut as kt, v as At, vn as jt, vt as Mt, w as Nt, wt as Pt, x as Ft, xt as It, y as k, yt as Lt, zt as A } from "./dev-bwDgSObH.js";
4
+ import { t as i } from "./bootRefusal-pgvDxlrU.js";
5
+ import { n as a, r as o } from "./startupRunner-CEqQq7ax.js";
6
+ import { $ as s, $t as c, A as l, At as u, B as d, C as ee, Ct as f, D as p, Dt as te, E as ne, Et as re, F as ie, Ft as m, G as ae, Gt as oe, H as se, Ht as ce, I as h, It as le, J as ue, Jt as g, K as de, Kt as fe, L as pe, Lt as me, M as he, Mt as ge, N as _e, Nt as _, O as ve, Ot as ye, P as be, Pt as xe, Q as Se, Qt as Ce, R as we, S as Te, St as v, T as Ee, Tt as De, U as Oe, Ut as ke, V as Ae, Vt as je, W as Me, Wt as y, X as Ne, Xt as Pe, Y as Fe, Yt as Ie, Z as b, Zt as x, _ as Le, _n as Re, _t as ze, an as Be, at as Ve, b as He, bt as Ue, c as We, cn as S, ct as Ge, dn as Ke, dt as qe, en as C, et as Je, f as Ye, fn as Xe, ft as Ze, g as Qe, gn as $e, gt as et, h as tt, hn as w, ht as nt, i as T, in as rt, it, j as at, jt as ot, k as st, kt as ct, ln as lt, lt as ut, m as dt, mn as ft, mt as pt, nn as mt, nt as ht, o as E, on as gt, ot as _t, p as vt, pt as D, q as yt, qt as O, r as bt, rn as xt, rt as St, sn as Ct, st as wt, t as Tt, tn as k, tt as Et, u as Dt, un as Ot, ut as kt, v as At, vn as jt, vt as Mt, w as Nt, wt as Pt, x as A, xt as Ft, y as j, yt as It, zt as Lt } from "./dev-E7Eo5GHc.js";
6
7
  import { n as Rt } from "./cliArgs-D4p8n7EE.js";
7
8
  import { r as zt } from "./appPort-B_HpJ_ck.js";
8
- import { at as Bt, nt as Vt, st as Ht } from "./webDev-Dybxew86.js";
9
- import { r as j } from "./dialectDriver-CgXnDfec.js";
10
- import { i as Ut, n as Wt } from "./connectionConfig-UFlIEiys.js";
11
- import { c as M, n as Gt, o as Kt } from "./seedRunner-ZmLSqNe2.js";
12
- import { C as qt, S as Jt, _ as Yt, d as Xt, g as N, l as Zt, m as Qt, r as $t, u as en, v as tn } from "./frameworkTableAssembly-oMPBKqlE.js";
13
- import { S as nn, c as rn, n as an, p as on, s as sn, x as cn } from "./fileConventions-Cof68_BL.js";
14
- import { h as ln, o as un } from "./inspect-CjTYzAs_.js";
15
- import { n as dn } from "./mssqlClusterPatch-_4cE_nun.js";
16
- import { i as fn, n as pn, r as mn, t as hn } from "./webhookDiscovery-D7VaeMlz.js";
17
- import { t as gn } from "./inspectMetrics-CfdKLh6t.js";
18
- import { r as _n, u as vn } from "./apiBuild-DGsShRuF.js";
19
- import { t as yn } from "./bootTiming-BdyP9nYw.js";
20
- import { t as bn } from "./dataProfile-dW-PsfLB.js";
21
- import { basename as xn, join as Sn } from "node:path";
22
- import { existsSync as Cn } from "node:fs";
23
- import { pathToFileURL as wn } from "node:url";
24
- import { createLogger as P } from "@voltro/logger";
25
- import { AuthMiddleware as Tn, ConnectionInfoMiddleware as En, actionToRpc as F, anonymousSubject as Dn, isWireReachable as On, mutationToRpc as I, queryToRpc as L, streamToRpc as kn, workflowCancelDescriptor as An, workflowDomainEventsQueryDescriptor as jn, workflowEventDeliveriesQueryDescriptor as R, workflowResumeDescriptor as Mn, workflowRunEventsQueryDescriptor as z, workflowRunQueryDescriptor as B, workflowRunStepsQueryDescriptor as V, workflowRunsQueryDescriptor as Nn, workflowSignalDescriptor as Pn, workflowUpdateDescriptor as Fn } from "@voltro/protocol";
26
- import { Cause as In, Effect as H, Layer as U, ManagedRuntime as Ln } from "effect";
27
- import { SqlClient as Rn } from "@effect/sql";
28
- import { declaredSnapshot as zn, describeOutcome as Bn, pendingFileMigrationIds as Vn, runPlannedMigrations as Hn } from "@voltro/database/sql";
29
- import { RpcGroup as Un } from "@effect/rpc";
30
- import { allRegisteredTables as Wn, and as Gn, connectionIdentity as Kn, ensureTableRegistered as qn, eq as W, or as G } from "@voltro/database";
31
- import { AggregateRegistry as Jn, CostRegistry as Yn, DORMANCY_WAKEUP_TENANT as Xn, Dispatcher as Zn, ExpectationRegistry as K, ExperimentRegistry as q, apiKeyManagementRoutes as Qn, attachAnalyticsMirror as $n, attachExpectations as er, attachExperiments as tr, attachFinops as nr, awaitServerListening as rr, bindMutation as J, bindStream as ir, bindSubscription as Y, buildTracingLayer as ar, cancelWakeup as or, compileCron as sr, dataStoreApiKeyStore as cr, formatServerOnlyLeaks as lr, formatUnresolvedSources as ur, frameworkApiKeyStrategy as dr, installPolicyGuardResolver as fr, loadResourceTuples as pr, makeActionRunner as mr, makeAdvisoryLockCoordinator as hr, makeApiKeyService as gr, makeApiKeyUsageBuffer as _r, makeApiKeyUsageFlusher as vr, makeAsyncKv as yr, makeAuthMiddlewareLayers as br, makeCoordinatedScheduler as xr, makeEffectStoreLayer as Sr, makeLazyWorkflowFacade as Cr, makeMutationOutputCodec as wr, makeMutationRunner as Tr, makeOneShotQueryRunner as Er, makeQueryDescriptorProducer as Dr, makeQueryFinalizer as Or, makeQueryReauthorizer as kr, makeQuerySubscriber as Ar, makeSchemaRegistry as jr, makeWorkflowFacade as Mr, makeWorkflowFacadeWithCallerContext as Nr, makeWorkflowLayers as X, noopKv as Pr, onProcessShutdown as Fr, recordSubscriptionDelivery as Ir, recordWorkflowRun as Lr, registerWakeup as Rr, resolveSecretsBackend as zr, runProvidedEffect as Br, setSecretsBackend as Vr, setSystemStoreHandle as Hr, setTupleSource as Ur, shutdownGraceMsFromEnv as Z, singleCoordinator as Wr, startRpcServer as Gr, startScheduler as Kr, stripForbiddenForWire as qr, undoCaptureEnabled as Jr, unresolvedSources as Yr, withScopedRequest as Xr, workflowToRpc as Zr, wrapStoreWithBootCodec as Qr } from "@voltro/runtime";
9
+ import { it as Bt, ot as Vt } from "./webDev-BKdD7c_a.js";
10
+ import { r as M } from "./dialectDriver-CgXnDfec.js";
11
+ import { i as Ht, n as Ut } from "./connectionConfig-UFlIEiys.js";
12
+ import { c as N, n as Wt, o as Gt } from "./seedRunner-ZmLSqNe2.js";
13
+ import { C as Kt, S as qt, _ as Jt, d as Yt, g as P, l as Xt, m as Zt, r as Qt, u as $t, v as en } from "./frameworkTableAssembly-oMPBKqlE.js";
14
+ import { S as tn, c as nn, n as rn, p as an, s as on, x as sn } from "./fileConventions-Cof68_BL.js";
15
+ import { h as cn, o as ln } from "./inspect-CjTYzAs_.js";
16
+ import { n as un } from "./mssqlClusterPatch-_4cE_nun.js";
17
+ import { i as dn, n as fn, r as pn, t as mn } from "./webhookDiscovery-D7VaeMlz.js";
18
+ import { t as hn } from "./inspectMetrics-CfdKLh6t.js";
19
+ import { r as gn, u as _n } from "./apiBuild-CvacV4zA.js";
20
+ import { t as vn } from "./bootTiming-BdyP9nYw.js";
21
+ import { t as yn } from "./dataProfile-dW-PsfLB.js";
22
+ import { basename as bn, join as xn } from "node:path";
23
+ import { existsSync as Sn } from "node:fs";
24
+ import { pathToFileURL as Cn } from "node:url";
25
+ import { createLogger as F } from "@voltro/logger";
26
+ import { AuthMiddleware as wn, ConnectionInfoMiddleware as Tn, actionToRpc as I, anonymousSubject as En, isWireReachable as Dn, mutationToRpc as L, queryToRpc as R, streamToRpc as On, workflowCancelDescriptor as kn, workflowDomainEventsQueryDescriptor as An, workflowEventDeliveriesQueryDescriptor as z, workflowResumeDescriptor as jn, workflowRunEventsQueryDescriptor as B, workflowRunQueryDescriptor as V, workflowRunStepsQueryDescriptor as H, workflowRunsQueryDescriptor as Mn, workflowSignalDescriptor as Nn, workflowUpdateDescriptor as Pn } from "@voltro/protocol";
27
+ import { Cause as Fn, Effect as U, Layer as W, ManagedRuntime as In } from "effect";
28
+ import { SqlClient as Ln } from "@effect/sql";
29
+ import { declaredSnapshot as Rn, describeOutcome as zn, pendingFileMigrationIds as Bn, runPlannedMigrations as Vn } from "@voltro/database/sql";
30
+ import { RpcGroup as Hn } from "@effect/rpc";
31
+ import { allRegisteredTables as Un, and as Wn, connectionIdentity as Gn, ensureTableRegistered as Kn, eq as G, or as K } from "@voltro/database";
32
+ import { AggregateRegistry as qn, CostRegistry as Jn, DORMANCY_WAKEUP_TENANT as Yn, Dispatcher as Xn, ExpectationRegistry as Zn, ExperimentRegistry as q, apiKeyManagementRoutes as Qn, attachAnalyticsMirror as $n, attachExpectations as er, attachExperiments as tr, attachFinops as nr, awaitServerListening as rr, bindMutation as J, bindStream as ir, bindSubscription as Y, buildTracingLayer as ar, cancelWakeup as or, compileCron as sr, dataStoreApiKeyStore as cr, formatServerOnlyLeaks as lr, formatUnresolvedSources as ur, frameworkApiKeyStrategy as dr, installPolicyGuardResolver as fr, loadResourceTuples as pr, makeActionRunner as mr, makeAdvisoryLockCoordinator as hr, makeApiKeyService as gr, makeApiKeyUsageBuffer as _r, makeApiKeyUsageFlusher as vr, makeAsyncKv as yr, makeAuthMiddlewareLayers as br, makeCoordinatedScheduler as xr, makeEffectStoreLayer as Sr, makeLazyWorkflowFacade as Cr, makeMutationOutputCodec as wr, makeMutationRunner as Tr, makeOneShotQueryRunner as Er, makeQueryDescriptorProducer as Dr, makeQueryFinalizer as Or, makeQueryReauthorizer as kr, makeQuerySubscriber as Ar, makeSchemaRegistry as jr, makeWorkflowFacade as Mr, makeWorkflowFacadeWithCallerContext as Nr, makeWorkflowLayers as X, noopKv as Pr, onProcessShutdown as Fr, recordSubscriptionDelivery as Ir, recordWorkflowRun as Lr, registerWakeup as Rr, resolveSecretsBackend as zr, runProvidedEffect as Br, setSecretsBackend as Vr, setSystemStoreHandle as Hr, setTupleSource as Ur, shutdownGraceMsFromEnv as Z, singleCoordinator as Wr, startRpcServer as Gr, startScheduler as Kr, stripForbiddenForWire as qr, undoCaptureEnabled as Jr, unresolvedSources as Yr, withScopedRequest as Xr, workflowToRpc as Zr, wrapStoreWithBootCodec as Qr } from "@voltro/runtime";
32
33
  import { appStorageProvider as $r, fromNodeReadable as ei, getObjectStream as ti, putObjectStream as ni, toNodeReadable as ri } from "@voltro/plugin-storage";
33
34
  import { isEnvContract as ii } from "@voltro/env";
34
35
  import { assertProductionSessionSecret as ai } from "@voltro/protocol/session";
@@ -111,7 +112,7 @@ var Ti = (e, t, n = [], r = 0) => {
111
112
  if (!t || t.length < 16) return Q(503, { error: "data transfer misconfigured (no/weak secret)" });
112
113
  let n = Ni(e.headers);
113
114
  return !n || !Pi(n, t) ? Q(401, { error: "unauthorized" }) : null;
114
- }, Ii = P({ scope: "voltro:admin-import" }), Li = "VBUNDLE2", Ri = async function* (e) {
115
+ }, Ii = F({ scope: "voltro:admin-import" }), Li = "VBUNDLE2", Ri = async function* (e) {
115
116
  yield e;
116
117
  }, zi = (e) => async (t) => {
117
118
  let n = Fi(t, e.secret);
@@ -135,7 +136,7 @@ var Ti = (e, t, n = [], r = 0) => {
135
136
  dir: f,
136
137
  blobs: e.assetSink
137
138
  }) : await wi(c, f);
138
- let t = await H.runPromiseExit(bi({
139
+ let t = await U.runPromiseExit(bi({
139
140
  store: e.store,
140
141
  bundleDir: f,
141
142
  ...r ? { mode: r } : {},
@@ -190,7 +191,7 @@ var Ti = (e, t, n = [], r = 0) => {
190
191
  force: !0
191
192
  });
192
193
  }
193
- }, Bi = P({ scope: "voltro:admin-export" }), Vi = async (e) => {
194
+ }, Bi = F({ scope: "voltro:admin-export" }), Vi = async (e) => {
194
195
  let t = [];
195
196
  for await (let n of e) t.push(Buffer.from(n));
196
197
  return new Uint8Array(Buffer.concat(t));
@@ -223,7 +224,7 @@ var Ti = (e, t, n = [], r = 0) => {
223
224
  }
224
225
  let a = r.consistency === "snapshot" ? "snapshot" : i.consistency ?? "live", o = (typeof r.compression == "string" ? r.compression : void 0) ?? i.compression, s = i.scope ?? Hi(r), c = typeof r.bundleKey == "string" && r.bundleKey.length > 0, l = r.assets === !0 && e.assetSource ? { blobs: e.assetSource } : {}, u = await import("node:os"), d = await import("node:fs/promises"), ee = await import("node:path"), f = await d.mkdtemp(ee.join(u.tmpdir(), "voltro-admin-export-"));
225
226
  try {
226
- let t = await H.runPromise(yi({
227
+ let t = await U.runPromise(yi({
227
228
  store: e.store,
228
229
  snapshot: e.snapshot,
229
230
  dialect: e.dialect,
@@ -288,7 +289,7 @@ var Ti = (e, t, n = [], r = 0) => {
288
289
  });
289
290
  }
290
291
  }, Wi = (e, t, n = {}) => (async function* () {
291
- let r = await ri((await H.runPromise(ti(e, t).pipe(H.timeout(n.openTimeout ?? "30 seconds")))).stream), i = n.stallMs ?? 12e4, a, o = () => {
292
+ let r = await ri((await U.runPromise(ti(e, t).pipe(U.timeout(n.openTimeout ?? "30 seconds")))).stream), i = n.stallMs ?? 12e4, a, o = () => {
292
293
  a && clearTimeout(a), a = setTimeout(() => r.destroy(/* @__PURE__ */ Error(`storage read stalled for ${i}ms reading '${t}'`)), i);
293
294
  };
294
295
  try {
@@ -307,14 +308,14 @@ var Ti = (e, t, n = [], r = 0) => {
307
308
  invalidateTag: async () => 0,
308
309
  wrap: async (e, t, n) => n()
309
310
  }, Ki = async (e) => {
310
- pe(e.appProcedures ?? e.discovered, {
311
+ me(e.appProcedures ?? e.discovered, {
311
312
  defaultDeny: e.security?.defaultDeny ?? !0,
312
313
  commandHint: "`voltro serve`"
313
314
  }), Hr({
314
315
  dataStore: e.store,
315
316
  schemaRegistry: e.schemaRegistry
316
317
  });
317
- let t = (e.discovered.budgets?.length ?? 0) > 0, n, r = new Zn({
318
+ let t = (e.discovered.budgets?.length ?? 0) > 0, n, r = new Xn({
318
319
  store: e.store,
319
320
  ...e.snapshotCache ? { cache: e.snapshotCache } : {},
320
321
  ...e.reactive === void 0 ? {} : { reactive: e.reactive },
@@ -325,18 +326,18 @@ var Ti = (e, t, n = [], r = 0) => {
325
326
  durationMs: e.durationMs,
326
327
  rowCount: e.rowCount
327
328
  })
328
- }), i = e.cache ?? Gi, a = e.kv ?? Pr, c, d = () => void 0, ee, f, p, te, se, ce, le, ue = Oe({
329
+ }), i = e.cache ?? Gi, a = e.kv ?? Pr, o, l = () => void 0, ee, f, p, te, ne, ce, le, ue = ke({
329
330
  store: e.store,
330
331
  warn: (e, t) => {
331
332
  process.stderr.write(`[workflow] ${e} ${JSON.stringify(t)}\n`);
332
333
  }
333
- }), fe = ue.remember, he = ue.resolve, _e = y({
334
+ }), de = ue.remember, pe = ue.resolve, ge = y({
334
335
  authority: e.authority,
335
336
  getStore: () => e.store
336
- }), _ = (e.discovered.workflows?.length ?? 0) > 0 ? Cr(() => c) : void 0, ve = (e.discovered.workflows?.length ?? 0) > 0 || (e.discovered.eventTriggers?.length ?? 0) > 0, ye = ve || (e.discovered.workflowWorkers?.length ?? 0) > 0 || e.scheduleCoordination === "cluster", Se = e.tenantIsolation === "namespace", Ce = (e.log ?? P({ scope: "voltro:serve" })).child("webhooks"), we, Te, v = e.discovered.webhooks;
337
+ }), _ = (e.discovered.workflows?.length ?? 0) > 0 ? Cr(() => o) : void 0, ve = (e.discovered.workflows?.length ?? 0) > 0 || (e.discovered.eventTriggers?.length ?? 0) > 0, ye = ve || (e.discovered.workflowWorkers?.length ?? 0) > 0 || e.scheduleCoordination === "cluster", be = e.tenantIsolation === "namespace", Ce = (e.log ?? F({ scope: "voltro:serve" })).child("webhooks"), we, Te, v = e.discovered.webhooks;
337
338
  if (v && v.outgoing.length > 0 && e.workflowEngineLayer !== void 0) {
338
339
  e.workflowEngineLayer;
339
- let t = _t({
340
+ let t = gt({
340
341
  store: e.store,
341
342
  schemaRegistry: e.schemaRegistry,
342
343
  cache: i,
@@ -359,7 +360,7 @@ var Ti = (e, t, n = [], r = 0) => {
359
360
  });
360
361
  }, { events: n });
361
362
  }
362
- let Ae = /* @__PURE__ */ new Map();
363
+ let Ee = /* @__PURE__ */ new Map();
363
364
  if (v) for (let e of v.incoming) {
364
365
  let t = e.descriptor.path ?? ui(e.descriptor.id), n = `VOLTRO_WEBHOOK_SECRET_${e.descriptor.id.toUpperCase().replace(/[^A-Z0-9]/g, "_")}`, r = pi(e.descriptor, {
365
366
  resolveSecret: async () => process.env[n] ?? null,
@@ -378,31 +379,31 @@ var Ti = (e, t, n = [], r = 0) => {
378
379
  e.status >= 500 ? Ce.error("incoming delivery failed", t) : e.status >= 400 ? Ce.warn("incoming delivery rejected", t) : Ce.info("incoming delivery handled", t);
379
380
  }
380
381
  });
381
- Ae.set(t, { handle: r });
382
+ Ee.set(t, { handle: r });
382
383
  }
383
384
  fr(), Ur((t) => pr(e.store, t.subjectId, t.resourceType, t.resourceId));
384
- let Ne = [], Pe = [...e.discovered.outboxHandlers ?? [], ...pn((v?.outgoing.length ?? 0) + (v?.incoming.length ?? 0) + (v?.providers.length ?? 0), []) ? [{
385
+ let je = [], Pe = [...e.discovered.outboxHandlers ?? [], ...fn((v?.outgoing.length ?? 0) + (v?.incoming.length ?? 0) + (v?.providers.length ?? 0), []) ? [{
385
386
  file: "<framework>/webhooks",
386
387
  id: "voltro-webhook-emit",
387
388
  definition: fi(() => we)
388
- }] : []], Ie = Pe.length > 0 ? g({
389
+ }] : []], Fe = Pe.length > 0 ? g({
389
390
  handlers: Pe,
390
391
  store: e.store,
391
- log: (e.log ?? P({ scope: "voltro:serve" })).child("outbox"),
392
+ log: (e.log ?? F({ scope: "voltro:serve" })).child("outbox"),
392
393
  onChange: (t) => e.store.onChange((e) => t({
393
394
  table: e.table,
394
395
  op: e.op
395
396
  })),
396
397
  onShutdown: (e) => {
397
- Ne.push(e);
398
+ je.push(e);
398
399
  }
399
- }) : void 0, x = de({
400
+ }) : void 0, x = fe({
400
401
  definitions: (e.discovered.connections ?? []).map((e) => e.definition),
401
402
  store: e.store,
402
- publicUrl: ae(e.port ?? 4e3),
403
- log: (e.log ?? P({ scope: "voltro:serve" })).child("connections")
403
+ publicUrl: oe(e.port ?? 4e3),
404
+ log: (e.log ?? F({ scope: "voltro:serve" })).child("connections")
404
405
  });
405
- ot({
406
+ at({
406
407
  events: e.discovered.events ?? [],
407
408
  rpcTags: [
408
409
  ...e.discovered.queries.map((e) => e.descriptor.name),
@@ -411,16 +412,16 @@ var Ti = (e, t, n = [], r = 0) => {
411
412
  ...(e.discovered.streams ?? []).map((e) => e.descriptor.name)
412
413
  ]
413
414
  });
414
- let Re = (e.log ?? P({ scope: "voltro:serve" })).child("events"), Be = e.broadcastNamespace ?? Qe(e.plugins, void 0), Ve = Le(e.plugins, Be, Re), Ue = e.membership?.instanceId ?? process.env.POD_NAME ?? process.env.HOSTNAME ?? `serve-${process.pid}`, We = e.membership ?? At(e.plugins, {
415
- instanceId: Ue,
416
- namespace: Be,
415
+ let Re = (e.log ?? F({ scope: "voltro:serve" })).child("events"), ze = e.broadcastNamespace ?? Qe(e.plugins, void 0), Ve = Le(e.plugins, ze, Re), He = e.membership?.instanceId ?? process.env.POD_NAME ?? process.env.HOSTNAME ?? `serve-${process.pid}`, We = e.membership ?? At(e.plugins, {
416
+ instanceId: He,
417
+ namespace: ze,
417
418
  meta: { mode: "serve" },
418
419
  logger: Re
419
- }), S = me({
420
+ }), S = he({
420
421
  events: e.discovered.events ?? [],
421
- origin: Ue,
422
+ origin: He,
422
423
  ...Ve.publishRemote === void 0 ? {} : { publishRemote: Ve.publishRemote }
423
- }), qe = (e.discovered.events ?? []).length > 0 ? await Ve.attach(S.bus) : null, Je = ze({
424
+ }), Ke = (e.discovered.events ?? []).length > 0 ? await Ve.attach(S.bus) : null, C = Be({
424
425
  store: e.store,
425
426
  schemaRegistry: e.schemaRegistry,
426
427
  cache: i,
@@ -428,132 +429,132 @@ var Ti = (e, t, n = [], r = 0) => {
428
429
  ...we === void 0 ? {} : { webhooksService: we },
429
430
  ..._ === void 0 ? {} : { workflowsProxy: _ },
430
431
  eventTriggers: e.discovered.eventTriggers ?? [],
431
- namespaceIsolationOn: Se,
432
+ namespaceIsolationOn: be,
432
433
  ...e.ensureTenantProvisioned === void 0 ? {} : { ensureTenantProvisioned: e.ensureTenantProvisioned },
433
434
  ...e.resolveResidentStore === void 0 ? {} : { resolveResidentStore: e.resolveResidentStore },
434
- ...Ie === void 0 ? {} : { outbox: { nudge: Ie.nudge } },
435
+ ...Fe === void 0 ? {} : { outbox: { nudge: Fe.nudge } },
435
436
  ...x.active ? { connections: { registry: x.registry } } : {},
436
437
  eventBus: S.bus
437
- }), Ye = U.succeed(Jn, ne), Xe = U.succeed(K, He), Ze = U.succeed(Yn, Lt), et = U.succeed(q, It), tt = (t, n) => {
438
- let r = t.pipe(H.provide(Sr(n)));
439
- return (e.baseLayer ? r.pipe(H.provide(e.baseLayer)) : r).pipe(H.provide(Ye)).pipe(H.provide(Xe)).pipe(H.provide(Ze)).pipe(H.provide(et));
440
- }, nt = (e, t) => Br(tt(e, t)), C = gn(), at = bt(e.plugins ?? [], C), ct = u({
438
+ }), Je = W.succeed(qn, re), Ye = W.succeed(Zn, Ue), Xe = W.succeed(Jn, It), Ze = W.succeed(q, Ft), et = (t, n) => {
439
+ let r = t.pipe(U.provide(Sr(n)));
440
+ return (e.baseLayer ? r.pipe(U.provide(e.baseLayer)) : r).pipe(U.provide(Je)).pipe(U.provide(Ye)).pipe(U.provide(Xe)).pipe(U.provide(Ze));
441
+ }, tt = (e, t) => Br(et(e, t)), w = hn(), T = yt(e.plugins ?? [], w), it = d({
441
442
  plugins: e.plugins ?? [],
442
- metrics: C,
443
- log: e.log ?? P({ scope: "voltro:serve" })
444
- }), lt = ie(e.plugins ?? [], C), ut = e.security?.defaultDeny ?? !0, ft = Tr({
443
+ metrics: w,
444
+ log: e.log ?? F({ scope: "voltro:serve" })
445
+ }), st = ae(e.plugins ?? [], w), ct = e.security?.defaultDeny ?? !0, lt = Tr({
445
446
  store: e.store,
446
- defaultDeny: ut,
447
+ defaultDeny: ct,
447
448
  recordMetric: (e) => {
448
- C.record(e);
449
+ w.record(e);
449
450
  },
450
- ...at.mutation === void 0 ? {} : { interceptor: at.mutation },
451
- buildContext: (e, t, n) => Je(e, t, n),
452
- runEffect: nt,
453
- undoCapture: xe()
454
- }), pt = b();
451
+ ...T.mutation === void 0 ? {} : { interceptor: T.mutation },
452
+ buildContext: (e, t, n) => C(e, t, n),
453
+ runEffect: tt,
454
+ undoCapture: Se()
455
+ }), dt = b();
455
456
  {
456
- let t = o();
457
- t !== void 0 && (e.log ?? P({ scope: "voltro:serve" })).info(t);
457
+ let t = s();
458
+ t !== void 0 && (e.log ?? F({ scope: "voltro:serve" })).info(t);
458
459
  }
459
- let mt = Me({
460
+ let ft = Ne({
460
461
  store: e.store,
461
462
  ...e.approvals === void 0 ? {} : { defaultExpiryMs: e.approvals.defaultExpiryMs }
462
- }), ht = mr({
463
- defaultDeny: ut,
464
- buildContext: (e) => Je(e),
465
- runEffect: nt,
463
+ }), pt = mr({
464
+ defaultDeny: ct,
465
+ buildContext: (e) => C(e),
466
+ runEffect: tt,
466
467
  recordMetric: (e) => {
467
- C.record(e);
468
+ w.record(e);
468
469
  },
469
- ...at.action === void 0 ? {} : { interceptor: at.action }
470
- }), gt = Or({
470
+ ...T.action === void 0 ? {} : { interceptor: T.action }
471
+ }), mt = Or({
471
472
  tenantScopedTables: e.tenantScopedTables,
472
473
  softDeleteScopedTables: e.softDeleteScopedTables
473
- }), w = {
474
- defaultDeny: ut,
475
- buildContext: (e) => Je(e),
476
- finalize: (e, t) => gt(e, t.subject),
477
- provideEffect: tt,
478
- ...at.query === void 0 ? {} : { interceptor: at.query }
479
- }, T = Dr(w), vt = Er({
480
- ...w,
474
+ }), ht = {
475
+ defaultDeny: ct,
476
+ buildContext: (e) => C(e),
477
+ finalize: (e, t) => mt(e, t.subject),
478
+ provideEffect: et,
479
+ ...T.query === void 0 ? {} : { interceptor: T.query }
480
+ }, E = Dr(ht), _t = Er({
481
+ ...ht,
481
482
  queryRows: (t, n) => e.store.query(t).then((e) => qr(t.table, e, n.subject))
482
- }), yt = Ar({
483
- ...w,
483
+ }), vt = Ar({
484
+ ...ht,
484
485
  subscribeDescriptor: (e, t, n) => r.subscribe(e, t, n),
485
486
  subscribeComputed: (e, t, n) => r.subscribeComputed(e, t, n)
486
- }), E = (e) => e.filter((e) => On(e.descriptor)), D = {};
487
+ }), D = (e) => e.filter((e) => Dn(e.descriptor)), O = {};
487
488
  for (let t of [
488
- ...E(e.discovered.queries),
489
- ...pt.queries,
490
- ...mt.queries,
489
+ ...D(e.discovered.queries),
490
+ ...dt.queries,
491
+ ...ft.queries,
491
492
  ...x.queries
492
- ]) D[t.descriptor.name] = (e) => Y(T(t, e), r, `subscription.${t.descriptor.name}`, void 0, void 0, kr(t, e));
493
+ ]) O[t.descriptor.name] = (e) => Y(E(t, e), r, `subscription.${t.descriptor.name}`, void 0, void 0, kr(t, e));
493
494
  for (let t of [
494
- ...E(e.discovered.mutations),
495
- ...pt.mutations,
496
- ...mt.mutations,
495
+ ...D(e.discovered.mutations),
496
+ ...dt.mutations,
497
+ ...ft.mutations,
497
498
  ...x.mutations
498
499
  ]) {
499
500
  let n = wr(t.descriptor.output);
500
- D[t.descriptor.name] = (r) => J(async (e, n) => ft(t, e, n), r, `mutation.${t.descriptor.name}`, n, e.idempotency, t.descriptor.error);
501
+ O[t.descriptor.name] = (r) => J(async (e, n) => lt(t, e, n), r, `mutation.${t.descriptor.name}`, n, e.idempotency, t.descriptor.error);
501
502
  }
502
- for (let t of [...E(e.discovered.actions), ...x.actions]) {
503
+ for (let t of [...D(e.discovered.actions), ...x.actions]) {
503
504
  let n = wr(t.descriptor.output);
504
- D[t.descriptor.name] = (r) => J(async (e, n) => ht(t, e, n), r, `action.${t.descriptor.name}`, n, e.idempotency, t.descriptor.error);
505
+ O[t.descriptor.name] = (r) => J(async (e, n) => pt(t, e, n), r, `action.${t.descriptor.name}`, n, e.idempotency, t.descriptor.error);
505
506
  }
506
- let xt = () => `public-${Math.random().toString(36).slice(2, 10)}`, St = [
507
+ let bt = () => `public-${Math.random().toString(36).slice(2, 10)}`, xt = [
507
508
  ...e.discovered.queries.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
508
509
  descriptor: e.descriptor,
509
- invoke: (t, n) => vt(e, t, {
510
+ invoke: (t, n) => _t(e, t, {
510
511
  subject: n.subject,
511
- traceId: xt()
512
+ traceId: bt()
512
513
  }),
513
- subscribe: (t, n, r) => yt(e, t, {
514
+ subscribe: (t, n, r) => vt(e, t, {
514
515
  subject: n.subject,
515
- traceId: xt()
516
+ traceId: bt()
516
517
  }, r)
517
518
  })),
518
519
  ...e.discovered.mutations.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
519
520
  descriptor: e.descriptor,
520
- invoke: (t, n) => ft(e, t, {
521
+ invoke: (t, n) => lt(e, t, {
521
522
  subject: n.subject,
522
- traceId: xt()
523
+ traceId: bt()
523
524
  })
524
525
  })),
525
526
  ...e.discovered.actions.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
526
527
  descriptor: e.descriptor,
527
- invoke: (t, n) => ht(e, t, {
528
+ invoke: (t, n) => pt(e, t, {
528
529
  subject: n.subject,
529
- traceId: xt()
530
+ traceId: bt()
530
531
  })
531
532
  }))
532
- ], Ct = {
533
+ ], St = {
533
534
  candidates: m({
534
535
  queries: e.discovered.queries,
535
536
  mutations: e.discovered.mutations,
536
537
  actions: e.discovered.actions,
537
538
  descriptorOf: (e) => e.descriptor,
538
- runQuery: (e, t, n) => Promise.resolve(vt(e, t, n)),
539
- runMutation: (e, t, n) => Promise.resolve(ft(e, t, n)),
540
- runAction: (e, t, n) => Promise.resolve(ht(e, t, n))
539
+ runQuery: (e, t, n) => Promise.resolve(_t(e, t, n)),
540
+ runMutation: (e, t, n) => Promise.resolve(lt(e, t, n)),
541
+ runAction: (e, t, n) => Promise.resolve(pt(e, t, n))
541
542
  }),
542
543
  policy: e.agents?.tools ?? {},
543
544
  mcpEnabled: e.agents?.mcp === !0,
544
545
  resolveSubject: (t) => e.resolveSubject(t, -1).then((e) => e.subject)
545
- }, Tt = s({
546
+ }, Ct = c({
546
547
  ...e.restRoutes === void 0 ? {} : { restRoutes: e.restRoutes },
547
- publicApiEntries: St,
548
+ publicApiEntries: xt,
548
549
  store: e.store,
549
550
  resolveSubject: (t) => e.resolveSubject(t, -1).then((e) => e.subject),
550
551
  ...e.idempotency === void 0 ? {} : { idempotency: e.idempotency },
551
- log: e.log ?? P({ scope: "voltro:serve" })
552
- }), Et = e.dataTransferSecret ?? process.env.VOLTRO_DATA_TRANSFER_SECRET, Dt = Et && Et.length >= 16 ? [{
552
+ log: e.log ?? F({ scope: "voltro:serve" })
553
+ }), Tt = e.dataTransferSecret ?? process.env.VOLTRO_DATA_TRANSFER_SECRET, Et = Tt && Tt.length >= 16 ? [{
553
554
  method: "POST",
554
555
  path: ji,
555
556
  handle: zi({
556
- secret: Et,
557
+ secret: Tt,
557
558
  store: e.store,
558
559
  ...e.dataTransferSnapshot ? { snapshot: e.dataTransferSnapshot } : {},
559
560
  assetSink: xi($r()),
@@ -563,34 +564,34 @@ var Ti = (e, t, n = [], r = 0) => {
563
564
  method: "POST",
564
565
  path: Mi,
565
566
  handle: Ui({
566
- secret: Et,
567
+ secret: Tt,
567
568
  store: e.store,
568
569
  snapshot: e.dataTransferSnapshot ?? { tables: [] },
569
570
  dialect: e.dataTransferDialect ?? "memory",
570
571
  tenantTables: [...e.tenantScopedTables],
571
- loadProfile: bn,
572
+ loadProfile: yn,
572
573
  assetSource: Si($r(), e.store),
573
574
  putArchive: async (e, t) => {
574
575
  let { Readable: n } = await import("node:stream"), r = $r(), i = ei("storage", () => n.from(t()));
575
- await H.runPromise(ni(r, e, i, { contentType: "application/octet-stream" }));
576
+ await U.runPromise(ni(r, e, i, { contentType: "application/octet-stream" }));
576
577
  }
577
578
  })
578
- }] : [], Ot = [
579
+ }] : [], Dt = [
579
580
  ...e.httpRoutes ?? [],
580
- ...Tt.httpRoutes,
581
- ...Dt,
581
+ ...Ct.httpRoutes,
582
+ ...Et,
582
583
  ...x.httpRoutes
583
584
  ];
584
- Object.assign(D, S.handlers);
585
- for (let t of E(e.discovered.streams ?? [])) D[t.descriptor.name] = (n) => ir((r) => Xr(r, (r) => {
586
- let i = Je(r), a = t.executor(n, i);
587
- if (H.isEffect(a)) {
588
- let t = a.pipe(H.provide(Sr(i.store)));
589
- return (e.baseLayer ? t.pipe(H.provide(e.baseLayer)) : t).pipe(H.provide(Ye)).pipe(H.provide(Xe)).pipe(H.provide(Ze)).pipe(H.provide(et));
585
+ Object.assign(O, S.handlers);
586
+ for (let t of D(e.discovered.streams ?? [])) O[t.descriptor.name] = (n) => ir((r) => Xr(r, (r) => {
587
+ let i = C(r), a = t.executor(n, i);
588
+ if (U.isEffect(a)) {
589
+ let t = a.pipe(U.provide(Sr(i.store)));
590
+ return (e.baseLayer ? t.pipe(U.provide(e.baseLayer)) : t).pipe(U.provide(Je)).pipe(U.provide(Ye)).pipe(U.provide(Xe)).pipe(U.provide(Ze));
590
591
  }
591
- return typeof a == "object" && a && typeof a.then == "function" ? H.promise(() => a) : a;
592
+ return typeof a == "object" && a && typeof a.then == "function" ? U.promise(() => a) : a;
592
593
  }), `stream.${t.descriptor.name}`);
593
- for (let t of e.discovered.workflows ?? []) D[t.definition.name] = (e) => J(async (e, n) => {
594
+ for (let t of e.discovered.workflows ?? []) O[t.definition.name] = (e) => J(async (e, n) => {
594
595
  let r = n;
595
596
  return Nr(_, {
596
597
  subject: r.subject,
@@ -598,8 +599,8 @@ var Ti = (e, t, n = [], r = 0) => {
598
599
  source: "workflow-rpc"
599
600
  }).start(t.definition.name, e);
600
601
  }, e, `workflow.${t.definition.name}`);
601
- ve && (D[B.name] = (e) => Y(T({
602
- descriptor: B,
602
+ ve && (O[V.name] = (e) => Y(E({
603
+ descriptor: V,
603
604
  executor: (e) => {
604
605
  let t = e.id;
605
606
  return {
@@ -608,30 +609,30 @@ var Ti = (e, t, n = [], r = 0) => {
608
609
  column: "startedAt",
609
610
  direction: "desc"
610
611
  }],
611
- predicate: G(W("id", t), W("executionId", t)),
612
+ predicate: K(G("id", t), G("executionId", t)),
612
613
  take: 1,
613
614
  skip: void 0,
614
615
  projection: void 0
615
616
  };
616
617
  }
617
- }, e), r, `subscription.${B.name}`), D[Nn.name] = (e) => Y(T({
618
- descriptor: Nn,
618
+ }, e), r, `subscription.${V.name}`), O[Mn.name] = (e) => Y(E({
619
+ descriptor: Mn,
619
620
  executor: (e) => {
620
- 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;
621
+ let t = e, n = [...t.tag === void 0 ? [] : [G("tag", t.tag)], ...t.status === void 0 ? [] : [G("status", t.status)]], r = Number.isFinite(t.limit) && t.limit !== void 0 ? Math.min(Math.max(Math.floor(t.limit), 1), 500) : 100;
621
622
  return {
622
623
  table: "_voltro_workflow_runs",
623
624
  order: [{
624
625
  column: "startedAt",
625
626
  direction: "desc"
626
627
  }],
627
- predicate: n.length === 0 ? void 0 : n.length === 1 ? n[0] : Gn(...n),
628
+ predicate: n.length === 0 ? void 0 : n.length === 1 ? n[0] : Wn(...n),
628
629
  take: r,
629
630
  skip: void 0,
630
631
  projection: void 0
631
632
  };
632
633
  }
633
- }, e), r, `subscription.${Nn.name}`), D[V.name] = (e) => Y(T({
634
- descriptor: V,
634
+ }, e), r, `subscription.${Mn.name}`), O[H.name] = (e) => Y(E({
635
+ descriptor: H,
635
636
  executor: (e) => {
636
637
  let t = e.runId;
637
638
  return {
@@ -640,14 +641,14 @@ var Ti = (e, t, n = [], r = 0) => {
640
641
  column: "startedAt",
641
642
  direction: "asc"
642
643
  }],
643
- predicate: W("runId", t),
644
+ predicate: G("runId", t),
644
645
  take: 1e3,
645
646
  skip: void 0,
646
647
  projection: void 0
647
648
  };
648
649
  }
649
- }, e), r, `subscription.${V.name}`), D[z.name] = (e) => Y(T({
650
- descriptor: z,
650
+ }, e), r, `subscription.${H.name}`), O[B.name] = (e) => Y(E({
651
+ descriptor: B,
651
652
  executor: (e) => {
652
653
  let t = e.runId;
653
654
  return {
@@ -656,14 +657,14 @@ var Ti = (e, t, n = [], r = 0) => {
656
657
  column: "occurredAt",
657
658
  direction: "asc"
658
659
  }],
659
- predicate: W("runId", t),
660
+ predicate: G("runId", t),
660
661
  take: 1e3,
661
662
  skip: void 0,
662
663
  projection: void 0
663
664
  };
664
665
  }
665
- }, e), r, `subscription.${z.name}`), D[jn.name] = (e) => Y(T({
666
- descriptor: jn,
666
+ }, e), r, `subscription.${B.name}`), O[An.name] = (e) => Y(E({
667
+ descriptor: An,
667
668
  executor: (e) => {
668
669
  let t = e;
669
670
  return {
@@ -672,14 +673,14 @@ var Ti = (e, t, n = [], r = 0) => {
672
673
  column: "occurredAt",
673
674
  direction: "desc"
674
675
  }],
675
- predicate: t.name === void 0 ? void 0 : W("name", t.name),
676
+ predicate: t.name === void 0 ? void 0 : G("name", t.name),
676
677
  take: Math.max(1, Math.min(500, t.limit ?? 100)),
677
678
  skip: void 0,
678
679
  projection: void 0
679
680
  };
680
681
  }
681
- }, e), r, `subscription.${jn.name}`), D[R.name] = (e) => Y(T({
682
- descriptor: R,
682
+ }, e), r, `subscription.${An.name}`), O[z.name] = (e) => Y(E({
683
+ descriptor: z,
683
684
  executor: (e) => {
684
685
  let t = e.eventId;
685
686
  return {
@@ -688,73 +689,73 @@ var Ti = (e, t, n = [], r = 0) => {
688
689
  column: "createdAt",
689
690
  direction: "asc"
690
691
  }],
691
- predicate: W("eventId", t),
692
+ predicate: G("eventId", t),
692
693
  take: 500,
693
694
  skip: void 0,
694
695
  projection: void 0
695
696
  };
696
697
  }
697
- }, e), r, `subscription.${R.name}`), D[An.name] = (t) => J(async (t, n) => {
698
+ }, e), r, `subscription.${z.name}`), O[kn.name] = (t) => J(async (t, n) => {
698
699
  let r = t;
699
- return await it(e.store, n.subject, { executionId: r.executionId }), await _.cancel(r.workflowName, r.executionId), await zt(r.workflowName, r.executionId, "workflow.cancel"), { ok: !0 };
700
- }, t, `action.${An.name}`), D[Mn.name] = (t) => J(async (t, n) => {
700
+ return await rt(e.store, n.subject, { executionId: r.executionId }), await _.cancel(r.workflowName, r.executionId), await Rt(r.workflowName, r.executionId, "workflow.cancel"), { ok: !0 };
701
+ }, t, `action.${kn.name}`), O[jn.name] = (t) => J(async (t, n) => {
701
702
  let r = t;
702
- return await it(e.store, n.subject, { executionId: r.executionId }), await _.resume(r.workflowName, r.executionId), { ok: !0 };
703
- }, t, `action.${Mn.name}`), D[Pn.name] = (t) => J(async (t, n) => {
703
+ return await rt(e.store, n.subject, { executionId: r.executionId }), await _.resume(r.workflowName, r.executionId), { ok: !0 };
704
+ }, t, `action.${jn.name}`), O[Nn.name] = (t) => J(async (t, n) => {
704
705
  let r = t;
705
- return await it(e.store, n.subject, { id: r.id }), _.signal({ id: r.id }, r.signalName, r.payload);
706
- }, t, `action.${Pn.name}`), D[Fn.name] = (t) => J(async (t, n) => {
706
+ return await rt(e.store, n.subject, { id: r.id }), _.signal({ id: r.id }, r.signalName, r.payload);
707
+ }, t, `action.${Nn.name}`), O[Pn.name] = (t) => J(async (t, n) => {
707
708
  let r = t;
708
- return await it(e.store, n.subject, { id: r.id }), _.update({ id: r.id }, r.updateName, r.payload, r.timeoutMs === void 0 ? void 0 : { timeoutMs: r.timeoutMs });
709
- }, t, `action.${Fn.name}`));
710
- let jt = [
711
- ...E(e.discovered.queries).map((e) => L(e.descriptor)),
712
- ...E(e.discovered.mutations).map((e) => I(e.descriptor)),
713
- ...E(e.discovered.actions).map((e) => F(e.descriptor)),
714
- ...pt.queries.map((e) => L(e.descriptor)),
715
- ...pt.mutations.map((e) => I(e.descriptor)),
716
- ...mt.queries.map((e) => L(e.descriptor)),
717
- ...mt.mutations.map((e) => I(e.descriptor)),
718
- ...x.queries.map((e) => L(e.descriptor)),
719
- ...x.mutations.map((e) => I(e.descriptor)),
720
- ...x.actions.map((e) => F(e.descriptor)),
721
- ...E(e.discovered.streams ?? []).map((e) => kn(e.descriptor)),
709
+ return await rt(e.store, n.subject, { id: r.id }), _.update({ id: r.id }, r.updateName, r.payload, r.timeoutMs === void 0 ? void 0 : { timeoutMs: r.timeoutMs });
710
+ }, t, `action.${Pn.name}`));
711
+ let Ot = [
712
+ ...D(e.discovered.queries).map((e) => R(e.descriptor)),
713
+ ...D(e.discovered.mutations).map((e) => L(e.descriptor)),
714
+ ...D(e.discovered.actions).map((e) => I(e.descriptor)),
715
+ ...dt.queries.map((e) => R(e.descriptor)),
716
+ ...dt.mutations.map((e) => L(e.descriptor)),
717
+ ...ft.queries.map((e) => R(e.descriptor)),
718
+ ...ft.mutations.map((e) => L(e.descriptor)),
719
+ ...x.queries.map((e) => R(e.descriptor)),
720
+ ...x.mutations.map((e) => L(e.descriptor)),
721
+ ...x.actions.map((e) => I(e.descriptor)),
722
+ ...D(e.discovered.streams ?? []).map((e) => On(e.descriptor)),
722
723
  ...S.rpcs,
723
724
  ...(e.discovered.workflows ?? []).map((e) => Zr(e.definition)),
724
725
  ...ve ? [
725
- L(B),
726
- L(Nn),
727
- L(V),
728
- L(z),
729
- L(jn),
730
- L(R),
731
- F(An),
732
- F(Mn),
733
- F(Pn),
734
- F(Fn)
726
+ R(V),
727
+ R(Mn),
728
+ R(H),
729
+ R(B),
730
+ R(An),
731
+ R(z),
732
+ I(kn),
733
+ I(jn),
734
+ I(Nn),
735
+ I(Pn)
735
736
  ] : []
736
- ], Mt = Un.make(...jt).middleware(Tn).middleware(En), Nt = br({ resolveSubject: ({ headers: t, clientId: n }) => e.resolveSubject(t, n) }), Pt = e.dormancyTenantId ?? Xn, Ft = e.dormancy === "sleep" ? {
737
+ ], jt = Hn.make(...Ot).middleware(wn).middleware(Tn), Mt = br({ resolveSubject: ({ headers: t, clientId: n }) => e.resolveSubject(t, n) }), Nt = e.dormancyTenantId ?? Yn, Pt = e.dormancy === "sleep" ? {
737
738
  register: (t, n, r) => Rr(e.store, {
738
- tenantId: r ?? Pt,
739
+ tenantId: r ?? Nt,
739
740
  kind: "workflow",
740
741
  refId: t,
741
742
  wakeAt: n
742
743
  }),
743
744
  cancel: (t, n) => or(e.store, {
744
- tenantId: n ?? Pt,
745
+ tenantId: n ?? Nt,
745
746
  kind: "workflow",
746
747
  refId: t
747
748
  }).then(() => {})
748
- } : void 0, k = ye ? await import("@voltro/workflow") : void 0, A = k?.makeWorkflowRunRecorder({
749
+ } : void 0, A = ye ? await import("@voltro/workflow") : void 0, j = A?.makeWorkflowRunRecorder({
749
750
  store: e.store,
750
751
  ...e.workflowRecording === void 0 ? {} : { recording: e.workflowRecording },
751
- ...Ft === void 0 ? {} : { wakeups: Ft }
752
- }), Rt = async (t, n) => {
753
- await k.closeWorkflowChildrenForParent({
752
+ ...Pt === void 0 ? {} : { wakeups: Pt }
753
+ }), Lt = async (t, n) => {
754
+ await A.closeWorkflowChildrenForParent({
754
755
  store: e.store,
755
756
  parentExecutionId: t,
756
757
  parentStatus: n,
757
- recorder: A,
758
+ recorder: j,
758
759
  log: { warn: (e, t) => {
759
760
  process.stderr.write(`[workflow] ${e} ${t ? JSON.stringify(t) : ""}\n`);
760
761
  } },
@@ -765,11 +766,11 @@ var Ti = (e, t, n = [], r = 0) => {
765
766
  await p.runPromise(r.definition.interrupt(n));
766
767
  }
767
768
  });
768
- }, zt = async (t, n, r) => {
769
+ }, Rt = async (t, n, r) => {
769
770
  let i = (await e.store.query({
770
771
  table: "_voltro_workflow_runs",
771
772
  order: [],
772
- predicate: W("executionId", n),
773
+ predicate: G("executionId", n),
773
774
  projection: void 0,
774
775
  skip: void 0,
775
776
  take: 1
@@ -780,7 +781,7 @@ var Ti = (e, t, n = [], r = 0) => {
780
781
  cancelled: !0,
781
782
  completedAt: /* @__PURE__ */ new Date()
782
783
  }), o = i.subject?.tenantId ?? void 0;
783
- a && await A.recordEvent({
784
+ a && await j.recordEvent({
784
785
  runId: i.id,
785
786
  eventType: "run-cancelled",
786
787
  payload: {
@@ -789,18 +790,18 @@ var Ti = (e, t, n = [], r = 0) => {
789
790
  executionId: n,
790
791
  ...o == null ? {} : { tenantId: o }
791
792
  }
792
- }), a && await Rt(n, "cancelled");
793
- }, Bt = [
793
+ }), a && await Lt(n, "cancelled");
794
+ }, zt = [
794
795
  ...X(e.discovered.workflows ?? [], {
795
- buildContext: (t, n) => e.buildContextForWorkflow?.(t, n) ?? Je({
796
+ buildContext: (t, n) => e.buildContextForWorkflow?.(t, n) ?? C({
796
797
  subject: t.subject,
797
798
  traceId: t.traceId
798
799
  }, e.store, void 0, `workflow:${n.workflowName}`, { parentExecutionId: n.executionId }),
799
- resolveStartContext: he,
800
- ..._e === void 0 ? {} : { resolveAuthority: _e }
800
+ resolveStartContext: pe,
801
+ ...ge === void 0 ? {} : { resolveAuthority: ge }
801
802
  }, (t, n, r) => {
802
- let i = k.getWorkflowVersionMetadata(t.definition);
803
- return k.wrapWorkflowExecuteWithRunRecording({
803
+ let i = A.getWorkflowVersionMetadata(t.definition);
804
+ return A.wrapWorkflowExecuteWithRunRecording({
804
805
  name: t.definition.name,
805
806
  store: e.store,
806
807
  subject: r.subject,
@@ -811,27 +812,27 @@ var Ti = (e, t, n = [], r = 0) => {
811
812
  workflowPatches: i.patches,
812
813
  parentExecutionId: r?.parentExecutionId ?? null,
813
814
  parentClosePolicy: r?.parentClosePolicy ?? null,
814
- onParentClose: ({ executionId: e, status: t }) => Rt(e, t),
815
+ onParentClose: ({ executionId: e, status: t }) => Lt(e, t),
815
816
  ...Ge(t.definition),
816
817
  onTerminal: async ({ executionId: e }) => {
817
818
  await f?.gate.release(e);
818
819
  },
819
- recorder: A,
820
- pluginWorkflowStepLayer: lt,
820
+ recorder: j,
821
+ pluginWorkflowStepLayer: st,
821
822
  recordRun: Lr
822
823
  }, n);
823
824
  }),
824
825
  ...e.discovered.workflowWorkers ?? [],
825
826
  ...Te === void 0 ? [] : [Te]
826
- ], Vt = [...(e.discovered.workflows ?? []).map((e) => e.definition.name).filter(Boolean), ...Te === void 0 ? [] : ["voltro.deliverWebhook"]], Ht = Bt.length > 0 ? U.mergeAll(...Bt) : U.empty;
827
+ ], Bt = [...(e.discovered.workflows ?? []).map((e) => e.definition.name).filter(Boolean), ...Te === void 0 ? [] : ["voltro.deliverWebhook"]], Vt = zt.length > 0 ? W.mergeAll(...zt) : W.empty;
827
828
  if (((e.discovered.workflows?.length ?? 0) > 0 || (e.discovered.workflowWorkers?.length ?? 0) > 0 || e.scheduleCoordination === "cluster" || Te !== void 0) && e.workflowEngineLayer !== void 0) {
828
- let t = Ht.pipe(U.provideMerge(e.workflowEngineLayer));
829
- p = Ln.make(e.baseLayer === void 0 ? t : t.pipe(U.provideMerge(e.baseLayer))), await p.runPromise(H.void), (e.log ?? P({ scope: "voltro:serve" })).child("workflow").info(`workflow runtime ready — ${Vt.length} entity type(s) registered`, { entities: Vt });
829
+ let t = Vt.pipe(W.provideMerge(e.workflowEngineLayer));
830
+ p = In.make(e.baseLayer === void 0 ? t : t.pipe(W.provideMerge(e.baseLayer))), await p.runPromise(U.void), (e.log ?? F({ scope: "voltro:serve" })).child("workflow").info(`workflow runtime ready — ${Bt.length} entity type(s) registered`, { entities: Bt });
830
831
  let n = await import("@voltro/workflow/cluster"), r = (e) => p.runPromise(n.redriveFailedRun(e)), i = (e) => p.runPromise(n.resumeRunFromStep(e));
831
832
  ce = await $e({
832
833
  provider: _i(e.plugins ?? [])?.broadcast?.provider,
833
834
  crossReplica: _i(e.plugins ?? [])?.broadcast?.crossReplica ?? !1,
834
- namespace: Be,
835
+ namespace: ze,
835
836
  replicaId: crypto.randomUUID(),
836
837
  pollStorage: () => p.runPromise(n.pollWorkflowStorage),
837
838
  onChange: (t) => e.store.onChange((e) => t({
@@ -839,14 +840,14 @@ var Ti = (e, t, n = [], r = 0) => {
839
840
  op: e.op,
840
841
  ...e.origin === void 0 ? {} : { origin: e.origin }
841
842
  })),
842
- log: (e.log ?? P({ scope: "voltro:serve" })).child("workflow")
843
+ log: (e.log ?? F({ scope: "voltro:serve" })).child("workflow")
843
844
  }), te = async (t) => {
844
- let n = await oe({
845
+ let n = await se({
845
846
  store: e.store,
846
847
  workflows: e.discovered.workflows ?? [],
847
848
  runRedrive: r
848
849
  }, t.runId);
849
- return n.statusReset && await A.recordEvent({
850
+ return n.statusReset && await j.recordEvent({
850
851
  runId: t.runId,
851
852
  eventType: "run-redriven",
852
853
  payload: {
@@ -858,13 +859,13 @@ var Ti = (e, t, n = [], r = 0) => {
858
859
  activitiesReset: n.outcome.activitiesReset,
859
860
  reason: n.outcome.reason
860
861
  };
861
- }, se = async (t) => {
862
- let n = await De({
862
+ }, ne = async (t) => {
863
+ let n = await Oe({
863
864
  store: e.store,
864
865
  workflows: e.discovered.workflows ?? [],
865
866
  runResume: i
866
867
  }, t.runId, t.step);
867
- return n.statusReset && await A.recordEvent({
868
+ return n.statusReset && await j.recordEvent({
868
869
  runId: t.runId,
869
870
  eventType: "run-redriven",
870
871
  payload: {
@@ -882,7 +883,7 @@ var Ti = (e, t, n = [], r = 0) => {
882
883
  let a = xr({
883
884
  coordinator: (e.scheduleCoordination ?? "single") === "advisoryLock" ? hr(e.store, e.scheduleReplicaId ?? `pid-${process.pid}`) : Wr,
884
885
  replicaId: e.scheduleReplicaId ?? `pid-${process.pid}`
885
- }), o = {
886
+ }), s = {
886
887
  info: (e, t) => {
887
888
  process.stdout.write(`[flow-control] ${e} ${t ? JSON.stringify(t) : ""}\n`);
888
889
  },
@@ -892,19 +893,19 @@ var Ti = (e, t, n = [], r = 0) => {
892
893
  error: (e, t) => {
893
894
  process.stderr.write(`[flow-control] ERROR ${e} ${t ? JSON.stringify(t) : ""}\n`);
894
895
  }
895
- }, s, l = () => {
896
- if (s !== void 0) return s;
897
- if (!(c === void 0 || A === void 0)) return s = re({
896
+ }, c, u = () => {
897
+ if (c !== void 0) return c;
898
+ if (!(o === void 0 || j === void 0)) return c = ie({
898
899
  store: e.store,
899
- log: N,
900
+ log: P,
900
901
  workflows: e.discovered.workflows ?? [],
901
- workflowsProxy: c,
902
+ workflowsProxy: o,
902
903
  workflowRuntime: p,
903
- workflowRunRecorder: A,
904
- closeChildrenForParent: Rt
905
- }), s;
904
+ workflowRunRecorder: j,
905
+ closeChildrenForParent: Lt
906
+ }), c;
906
907
  };
907
- d = l, f = rt({
908
+ l = u, f = nt({
908
909
  store: e.store,
909
910
  onChange: (t) => e.store.onChange((e) => t({
910
911
  table: e.table,
@@ -917,24 +918,24 @@ var Ti = (e, t, n = [], r = 0) => {
917
918
  stalenessSweepIntervalMs: e.scheduling.stalenessSweepMs
918
919
  },
919
920
  workflows: e.discovered.workflows ?? [],
920
- facade: () => c,
921
- cancelRunWithReason: l,
922
- recordRunEvent: () => A?.recordEvent,
921
+ facade: () => o,
922
+ cancelRunWithReason: u,
923
+ recordRunEvent: () => j?.recordEvent,
923
924
  ...e.workflowStaleness === void 0 ? {} : { staleness: e.workflowStaleness },
924
925
  ...e.workflowSuspendSignalHintMs === void 0 ? {} : { suspendSignalHintMs: e.workflowSuspendSignalHintMs },
925
926
  scheduleCoordinated: a,
926
927
  onAbandoned: async (t) => {
927
928
  await wt({
928
929
  workflows: e.discovered.workflows ?? [],
929
- facade: () => c,
930
- log: o,
930
+ facade: () => o,
931
+ log: s,
931
932
  ...t
932
933
  });
933
934
  },
934
- log: o
935
+ log: s
935
936
  });
936
- let u = f;
937
- u !== void 0 && Fr(() => u.stop()), ee = Ke({
937
+ let d = f;
938
+ d !== void 0 && Fr(() => d.stop()), ee = qe({
938
939
  store: e.store,
939
940
  onChange: (t) => e.store.onChange((e) => t({
940
941
  table: e.table,
@@ -945,8 +946,8 @@ var Ti = (e, t, n = [], r = 0) => {
945
946
  tickIntervalMs: e.scheduling.inferenceTickMs
946
947
  },
947
948
  enabled: (e.discovered.workflows?.length ?? 0) > 0,
948
- resumeSignal: () => p === void 0 || k === void 0 ? void 0 : async ({ executionId: t, workflowName: n, signalName: r, payload: i }) => {
949
- await p.runPromise(k.completeSuspendingSignal({
949
+ resumeSignal: () => p === void 0 || A === void 0 ? void 0 : async ({ executionId: t, workflowName: n, signalName: r, payload: i }) => {
950
+ await p.runPromise(A.completeSuspendingSignal({
950
951
  store: e.store,
951
952
  target: kt(t, n),
952
953
  signalName: r,
@@ -955,81 +956,81 @@ var Ti = (e, t, n = [], r = 0) => {
955
956
  },
956
957
  runEffect: (e) => p.runPromise(e),
957
958
  scheduleCoordinated: a,
958
- log: o
959
+ log: s
959
960
  });
960
- let ne = ee;
961
- ne !== void 0 && Fr(() => ne.stop()), c = (e.discovered.workflows?.length ?? 0) > 0 ? Mr({
961
+ let re = ee;
962
+ re !== void 0 && Fr(() => re.stop()), o = (e.discovered.workflows?.length ?? 0) > 0 ? Mr({
962
963
  workflows: e.discovered.workflows ?? [],
963
964
  runEffect: (e) => p.runPromise(e),
964
965
  onEnqueue: () => ce?.publishWake(),
965
- ...u === void 0 ? {} : {
966
- admitStart: u.gate.admitStart,
967
- startPayloadSchema: u.gate.startPayloadSchema,
968
- parkDelayedStart: u.gate.parkDelayed
966
+ ...d === void 0 ? {} : {
967
+ admitStart: d.gate.admitStart,
968
+ startPayloadSchema: d.gate.startPayloadSchema,
969
+ parkDelayedStart: d.gate.parkDelayed
969
970
  },
970
- rememberStartContext: fe,
971
+ rememberStartContext: de,
971
972
  signal: async (t, n, r) => {
972
- let i = await k.sendWorkflowSignal({
973
+ let i = await A.sendWorkflowSignal({
973
974
  store: e.store,
974
- recorder: A,
975
+ recorder: j,
975
976
  target: t,
976
977
  signalName: n,
977
978
  payload: r
978
979
  });
979
- return await p.runPromise(k.completeSuspendingSignal({
980
+ return await p.runPromise(A.completeSuspendingSignal({
980
981
  store: e.store,
981
982
  target: t,
982
983
  signalName: n,
983
984
  payload: r
984
985
  })).catch(() => {}), i;
985
986
  },
986
- update: (t, n, r, i) => k.sendWorkflowUpdate({
987
+ update: (t, n, r, i) => A.sendWorkflowUpdate({
987
988
  store: e.store,
988
- recorder: A,
989
+ recorder: j,
989
990
  target: t,
990
991
  updateName: n,
991
992
  payload: r,
992
993
  ...i === void 0 ? {} : { options: i }
993
994
  }),
994
- listRuns: (t) => ke(e.store, t),
995
- retry: (t, n) => je({
995
+ listRuns: (t) => Ae(e.store, t),
996
+ retry: (t, n) => Me({
996
997
  store: e.store,
997
998
  workflows: e.discovered.workflows ?? [],
998
999
  runPromise: (e) => p.runPromise(e)
999
1000
  }, t, n),
1000
- redrive: (t) => oe({
1001
+ redrive: (t) => se({
1001
1002
  store: e.store,
1002
1003
  workflows: e.discovered.workflows ?? [],
1003
1004
  runRedrive: r
1004
1005
  }, t).then((e) => e.outcome)
1005
1006
  }) : void 0;
1006
1007
  }
1007
- let j = U.mergeAll(Mt.toLayer(D), Nt), Ut = O(D, e.discovered.queries.map((e) => e.descriptor.name), ve), Wt = U.mergeAll(Mt.toLayer(Ut), Nt), M = e.observability, Gt = await ar({
1008
+ let M = W.mergeAll(jt.toLayer(O), Mt), Ht = k(O, e.discovered.queries.map((e) => e.descriptor.name), ve), Ut = W.mergeAll(jt.toLayer(Ht), Mt), N = e.observability, Wt = await ar({
1008
1009
  ...e.appName === void 0 ? {} : { serviceName: e.appName },
1009
- ...M && M.spanProcessors.length > 0 ? { extraSpanProcessors: M.spanProcessors } : {},
1010
- ...M && M.metricReaders.length > 0 ? { extraMetricReaders: M.metricReaders } : {},
1011
- ...M && Object.keys(M.resourceAttributes).length > 0 ? { resourceAttributes: M.resourceAttributes } : {},
1012
- ...M && M.sampler !== void 0 ? { sampler: M.sampler } : {}
1013
- }), Kt = !1, qt = e.store.ping ? () => e.store.ping().then(() => !0).catch(() => !1) : void 0, { server: Jt, shutdown: Yt } = Gr({
1014
- group: Mt,
1015
- handlersLayer: j,
1016
- httpHandlersLayer: Wt,
1010
+ ...N && N.spanProcessors.length > 0 ? { extraSpanProcessors: N.spanProcessors } : {},
1011
+ ...N && N.metricReaders.length > 0 ? { extraMetricReaders: N.metricReaders } : {},
1012
+ ...N && Object.keys(N.resourceAttributes).length > 0 ? { resourceAttributes: N.resourceAttributes } : {},
1013
+ ...N && N.sampler !== void 0 ? { sampler: N.sampler } : {}
1014
+ }), Gt = !1, Kt = e.store.ping ? () => e.store.ping().then(() => !0).catch(() => !1) : void 0, { server: qt, shutdown: Jt } = Gr({
1015
+ group: jt,
1016
+ handlersLayer: M,
1017
+ httpHandlersLayer: Ut,
1017
1018
  port: e.port ?? 4e3,
1018
1019
  ...e.host === void 0 ? {} : { host: e.host },
1019
1020
  path: e.path ?? "/ws",
1020
- tracerLayer: Gt.layer,
1021
- security: be(e),
1022
- ...ct,
1021
+ tracerLayer: Wt.layer,
1022
+ security: xe(e),
1023
+ ...it,
1023
1024
  healthCheck: {
1024
- isReady: () => Kt,
1025
- ...qt ? { ping: qt } : {}
1025
+ isReady: () => Gt,
1026
+ ...Kt ? { ping: Kt } : {}
1026
1027
  },
1027
- ...Ot.length > 0 ? { httpRoutes: Ot } : {},
1028
+ ...Dt.length > 0 ? { httpRoutes: Dt } : {},
1028
1029
  ...e.getStore === void 0 ? {} : { getStore: e.getStore },
1029
- ...Ae.size > 0 ? { webhookRoutes: Ae } : {},
1030
+ ...Ee.size > 0 ? { webhookRoutes: Ee } : {},
1030
1031
  ...e.inspectRoute === void 0 ? {} : { inspectRoute: e.inspectRoute }
1031
- }), Xt = Ai(Jt);
1032
- if (await rr(Jt), (e.discovered.schedules?.length ?? 0) > 0) {
1032
+ }), Yt = Ai(qt);
1033
+ if (await rr(qt), (e.discovered.schedules?.length ?? 0) > 0) {
1033
1034
  let t = (e.scheduleCoordination ?? "single") === "advisoryLock" ? hr(e.store, e.scheduleReplicaId ?? `pid-${process.pid}`) : Wr;
1034
1035
  le = await Kr(e.discovered.schedules ?? [], {
1035
1036
  store: e.store,
@@ -1039,7 +1040,7 @@ var Ti = (e, t, n = [], r = 0) => {
1039
1040
  armSelf: e.scheduleArmSelf ?? !0,
1040
1041
  dormancy: e.dormancy ?? "always-on",
1041
1042
  ...e.dormancyTenantId === void 0 ? {} : { dormancyTenantId: e.dormancyTenantId },
1042
- buildContext: ({ traceId: t, scheduleName: n, subject: r }) => Je({
1043
+ buildContext: ({ traceId: t, scheduleName: n, subject: r }) => C({
1043
1044
  subject: r,
1044
1045
  traceId: t
1045
1046
  }, e.store, void 0, `schedule:${n}`),
@@ -1059,9 +1060,9 @@ var Ti = (e, t, n = [], r = 0) => {
1059
1060
  ...e.onScheduleRunEvent === void 0 ? {} : { onRunEvent: e.onScheduleRunEvent }
1060
1061
  }), e.onSchedulerReady?.(le);
1061
1062
  }
1062
- let N = e.log ?? P({ scope: "voltro:serve" }), Zt, Qt;
1063
- if ((e.discovered.subscribers?.length ?? 0) > 0 && (Zt = Fe(e.discovered.subscribers ?? [], e.store, N.child("subscribe"), e.schemaRegistry, S.bus)), (e.discovered.reactions?.length ?? 0) > 0) {
1064
- let t = N.child("reaction"), n = async (n, r) => {
1063
+ let P = e.log ?? F({ scope: "voltro:serve" }), Xt, Zt;
1064
+ if ((e.discovered.subscribers?.length ?? 0) > 0 && (Xt = Ie(e.discovered.subscribers ?? [], e.store, P.child("subscribe"), e.schemaRegistry, S.bus)), (e.discovered.reactions?.length ?? 0) > 0) {
1065
+ let t = P.child("reaction"), n = async (n, r) => {
1065
1066
  if (n.kind === "workflow") {
1066
1067
  if (_ === void 0) {
1067
1068
  t.warn("reaction workflow act skipped — no workflow engine in this app", { workflow: n.workflow });
@@ -1074,95 +1075,95 @@ var Ti = (e, t, n = [], r = 0) => {
1074
1075
  }).start(n.workflow, e);
1075
1076
  return;
1076
1077
  }
1077
- await st(n.agent, r, {
1078
+ await ot(n.agent, r, {
1078
1079
  findAgentSend: (t) => e.discovered.actions.find((e) => e.descriptor.name === `${t}.send`),
1079
- runAction: (e, t, n) => Promise.resolve(ht(e, t, n)),
1080
- makeSubject: (e) => Dn(e),
1080
+ runAction: (e, t, n) => Promise.resolve(pt(e, t, n)),
1081
+ makeSubject: (e) => En(e),
1081
1082
  now: () => Date.now(),
1082
1083
  log: t
1083
1084
  });
1084
1085
  }, r = async (n, r) => {
1085
1086
  try {
1086
1087
  let { requireAiBudget: t } = await import("@voltro/ai");
1087
- return (await H.runPromise(H.either(t(e.store, {
1088
+ return (await U.runPromise(U.either(t(e.store, {
1088
1089
  tenantId: n,
1089
1090
  limitUsd: r
1090
1091
  }))))._tag === "Right";
1091
1092
  } catch (e) {
1092
1093
  return t.warn("reaction budget check failed — refusing the act", { tenantId: n }, e), !1;
1093
1094
  }
1094
- }, i = dt(e.store, { onError: (e) => t.warn("reaction: rate-slot claim failed; refusing the act", { cause: String(e) }) });
1095
- Qt = l(e.discovered.reactions ?? [], e.store, {
1095
+ }, i = ut(e.store, { onError: (e) => t.warn("reaction: rate-slot claim failed; refusing the act", { cause: String(e) }) });
1096
+ Zt = u(e.discovered.reactions ?? [], e.store, {
1096
1097
  runAct: n,
1097
1098
  checkBudget: r,
1098
1099
  claimRateSlot: (e) => i.claim(e)
1099
1100
  }, t);
1100
1101
  }
1101
- let $t;
1102
- (e.discovered.aggregates?.length ?? 0) > 0 && ($t = await Ee({
1102
+ let Qt;
1103
+ (e.discovered.aggregates?.length ?? 0) > 0 && (Qt = await De({
1103
1104
  discovered: e.discovered.aggregates ?? [],
1104
1105
  store: e.store,
1105
- log: N.child("aggregate"),
1106
+ log: P.child("aggregate"),
1106
1107
  ...e.analytics === void 0 ? {} : { analytics: e.analytics },
1107
1108
  ...e.aggregateStorage === void 0 ? {} : { storage: e.aggregateStorage },
1108
1109
  ...e.aggregateCoordinator === void 0 ? {} : { coordinator: e.aggregateCoordinator }
1109
- }), Ye = U.succeed(Jn, $t.registry));
1110
- let en;
1111
- (e.discovered.expectations?.length ?? 0) > 0 && (en = er({
1110
+ }), Je = W.succeed(qn, Qt.registry));
1111
+ let $t;
1112
+ (e.discovered.expectations?.length ?? 0) > 0 && ($t = er({
1112
1113
  discovered: e.discovered.expectations ?? [],
1113
1114
  store: e.store,
1114
- log: N.child("expectation")
1115
- }), Xe = U.succeed(K, en.registry)), (e.discovered.budgets?.length ?? 0) > 0 && (n = nr({
1115
+ log: P.child("expectation")
1116
+ }), Ye = W.succeed(Zn, $t.registry)), (e.discovered.budgets?.length ?? 0) > 0 && (n = nr({
1116
1117
  discovered: e.discovered.budgets ?? [],
1117
- log: N.child("finops")
1118
- }), Ze = U.succeed(Yn, n.registry));
1119
- let tn;
1120
- return (e.discovered.experiments?.length ?? 0) > 0 && (tn = tr({
1118
+ log: P.child("finops")
1119
+ }), Xe = W.succeed(Jn, n.registry));
1120
+ let en;
1121
+ return (e.discovered.experiments?.length ?? 0) > 0 && (en = tr({
1121
1122
  discovered: e.discovered.experiments ?? [],
1122
1123
  store: e.store,
1123
- log: N.child("experiment")
1124
- }), et = U.succeed(q, tn.registry)), Kt = !0, e.bootTiming?.mark("ready"), {
1124
+ log: P.child("experiment")
1125
+ }), Ze = W.succeed(q, en.registry)), Gt = !0, e.bootTiming?.mark("ready"), {
1125
1126
  dispatcher: r,
1126
- server: Jt,
1127
+ server: qt,
1127
1128
  scheduler: le,
1128
- eventsSnapshot: ge(S.bus, S.declared),
1129
+ eventsSnapshot: _e(S.bus, S.declared),
1129
1130
  membersSnapshot: () => ({
1130
1131
  members: We.membership.list(),
1131
1132
  capturedAt: Date.now()
1132
1133
  }),
1133
- agentTools: () => Ct,
1134
- rpcMetrics: () => C,
1134
+ agentTools: () => St,
1135
+ rpcMetrics: () => w,
1135
1136
  webhooksService: () => we,
1136
- runCanceller: () => d(),
1137
+ runCanceller: () => l(),
1137
1138
  flowControlHealth: () => f?.cancelHealth(),
1138
1139
  inferenceHealth: () => ee?.health(),
1139
- workflowWriteActions: () => _ === void 0 || A === void 0 ? void 0 : h({
1140
+ workflowWriteActions: () => _ === void 0 || j === void 0 ? void 0 : h({
1140
1141
  store: e.store,
1141
- log: N,
1142
+ log: P,
1142
1143
  workflows: e.discovered.workflows ?? [],
1143
- workflowsProxy: c,
1144
+ workflowsProxy: o,
1144
1145
  workflowRuntime: p,
1145
- workflowRunRecorder: A,
1146
- closeChildrenForParent: Rt
1146
+ workflowRunRecorder: j,
1147
+ closeChildrenForParent: Lt
1147
1148
  }),
1148
1149
  redriveWorkflowRun: (e) => te ? te(e) : Promise.reject(/* @__PURE__ */ Error("redrive: this app registers no workflows")),
1149
- resumeWorkflowRunFromStep: (e) => se ? se(e) : Promise.reject(/* @__PURE__ */ Error("resume-from-step: this app registers no workflows")),
1150
+ resumeWorkflowRunFromStep: (e) => ne ? ne(e) : Promise.reject(/* @__PURE__ */ Error("resume-from-step: this app registers no workflows")),
1150
1151
  close: async () => {
1151
- Kt = !1, await Xt.drainRequests();
1152
- for (let e of Ne) try {
1152
+ Gt = !1, await Yt.drainRequests();
1153
+ for (let e of je) try {
1153
1154
  await e();
1154
1155
  } catch (e) {
1155
- N.warn("serve: teardown step failed", {}, e);
1156
+ P.warn("serve: teardown step failed", {}, e);
1156
1157
  }
1157
- await qe?.detach(), await We.detach(), $t?.detach(), en?.detach(), n?.detach(), tn?.detach(), Qt?.(), Zt?.(), await le?.shutdown(), r.close(), await ce?.detach(), await p?.dispose(), await Yt(), await Xt.finish();
1158
+ await Ke?.detach(), await We.detach(), Qt?.detach(), $t?.detach(), n?.detach(), en?.detach(), Zt?.(), Xt?.(), await le?.shutdown(), r.close(), await ce?.detach(), await p?.dispose(), await Jt(), await Yt.finish();
1158
1159
  }
1159
1160
  };
1160
- }, $ = P({ scope: "voltro:serve" }), qi = (e, t, n) => (e === "production" || e === "staging") && t !== "memory" && n !== "0", Ji = Rt, Yi = async (e) => {
1161
- let t = vn(process.cwd());
1162
- if (Cn(t)) {
1161
+ }, $ = F({ scope: "voltro:serve" }), qi = (e, t, n) => (e === "production" || e === "staging") && t !== "memory" && n !== "0", Ji = Rt, Yi = async (e) => {
1162
+ let t = _n(process.cwd());
1163
+ if (Sn(t)) {
1163
1164
  let n;
1164
1165
  try {
1165
- let e = await import(wn(t).href);
1166
+ let e = await import(Cn(t).href);
1166
1167
  typeof e.runServe == "function" ? n = e.runServe : $.warn("serve bundle has no runServe export — using the standard serve path");
1167
1168
  } catch (e) {
1168
1169
  $.warn("serve bundle failed to load — using the standard serve path", {}, e);
@@ -1170,91 +1171,91 @@ var Ti = (e, t, n = [], r = 0) => {
1170
1171
  if (n) return $.info("serve: booting from the precompiled serve bundle"), n(e);
1171
1172
  }
1172
1173
  return Xi(e);
1173
- }, Xi = async (o) => {
1174
- let s = yn();
1174
+ }, Xi = async (s) => {
1175
+ let c = vn();
1175
1176
  e("serve");
1176
1177
  try {
1177
1178
  ai();
1178
1179
  } catch (e) {
1179
- throw Vt(e instanceof Error ? e.message : String(e));
1180
+ throw i(e instanceof Error ? e.message : String(e));
1180
1181
  }
1181
- let l = process.cwd(), u = await Ue(l), ne = zt({
1182
+ let u = process.cwd(), d = await We(u), re = zt({
1182
1183
  kind: "api",
1183
- configPort: u?.port,
1184
+ configPort: d?.port,
1184
1185
  env: process.env,
1185
- flagPort: Ji(o, "--port")
1186
+ flagPort: Ji(s, "--port")
1186
1187
  });
1187
- for (let e of ne.warnings) $.warn(e);
1188
- let re = ne.port;
1189
- Vr(zr(u?.secrets)), await Ht({
1190
- rawEnv: u?.env,
1188
+ for (let e of re.warnings) $.warn(e);
1189
+ let ie = re.port;
1190
+ Vr(zr(d?.secrets)), await Vt({
1191
+ rawEnv: d?.env,
1191
1192
  appType: "api",
1192
- root: l,
1193
+ root: u,
1193
1194
  log: $,
1194
1195
  generateTypes: !1
1195
- }), s.mark("config");
1196
- let m = (process.env.DB_DIALECT ?? u?.store ?? "memory").toLowerCase(), ie = (m === "mariadb" || m === "postgres" || m === "mssql") && (process.env.CDC ?? "1") !== "0", ae = m === "mariadb" ? "mariadb" : m === "mssql" ? "mssql" : void 0, oe = _n(l);
1197
- if (!r() && Cn(oe)) try {
1198
- let e = await import(wn(oe).href);
1196
+ }), c.mark("config");
1197
+ let m = (process.env.DB_DIALECT ?? d?.store ?? "memory").toLowerCase(), ae = (m === "mariadb" || m === "postgres" || m === "mssql") && (process.env.CDC ?? "1") !== "0", oe = m === "mariadb" ? "mariadb" : m === "mssql" ? "mssql" : void 0, se = gn(u);
1198
+ if (!r() && Sn(se)) try {
1199
+ let e = await import(Cn(se).href);
1199
1200
  if (e.modules) {
1200
1201
  let t = {};
1201
- for (let [n, r] of Object.entries(e.modules)) t[Sn(l, n)] = r;
1202
+ for (let [n, r] of Object.entries(e.modules)) t[xn(u, n)] = r;
1202
1203
  n(t), $.info("precompiled api bundle loaded", { modules: Object.keys(t).length });
1203
1204
  }
1204
1205
  } catch (e) {
1205
1206
  $.warn("precompiled api bundle failed to load — falling back to source", {}, e);
1206
1207
  }
1207
- let h = await Ye(l), g = await Dt(h, { cdc: ie && ae !== void 0 }), de = ce(g);
1208
+ let h = await Ye(u), g = await Dt(h, { cdc: ae && oe !== void 0 }), fe = le(g);
1208
1209
  {
1209
1210
  let e = /* @__PURE__ */ new Set([
1210
1211
  ...g.queries.filter((e) => e.descriptor.overridesPlugin === !0).map((e) => e.descriptor.name),
1211
1212
  ...g.mutations.filter((e) => e.descriptor.overridesPlugin === !0).map((e) => e.descriptor.name),
1212
1213
  ...g.actions.filter((e) => e.descriptor.overridesPlugin === !0).map((e) => e.descriptor.name)
1213
1214
  ]);
1214
- Jt(qt(u?.plugins ?? []), [
1215
+ qt(Kt(d?.plugins ?? []), [
1215
1216
  ...g.queries.map((e) => e.descriptor.name),
1216
1217
  ...g.mutations.map((e) => e.descriptor.name),
1217
1218
  ...g.actions.map((e) => e.descriptor.name),
1218
1219
  ...g.streams.map((e) => e.descriptor.name)
1219
1220
  ], e);
1220
- let t = se(g.serverOnlyLeaks, Ae(process.env, "strict"), lr, "`voltro serve`");
1221
- if (t.action === "fail") throw Vt(t.message ?? "");
1221
+ let t = ce(g.serverOnlyLeaks, je(process.env, "strict"), lr, "`voltro serve`");
1222
+ if (t.action === "fail") throw i(t.message ?? "");
1222
1223
  t.action === "warn" && $.warn(t.message ?? "");
1223
1224
  }
1224
- let pe = h.filter((e) => hn.test(e)), me = pe.length > 0 ? await mn(pe, $.child("webhooks")) : {
1225
+ let me = h.filter((e) => mn.test(e)), he = me.length > 0 ? await pn(me, $.child("webhooks")) : {
1225
1226
  outgoing: [],
1226
1227
  incoming: [],
1227
1228
  providers: []
1228
- }, ge = fn(g.events), xe = me.outgoing.length + me.incoming.length + me.providers.length + ge.length === 0 ? void 0 : {
1229
- ...me,
1230
- outgoing: [...me.outgoing, ...ge]
1231
- }, Ee = en({
1229
+ }, _e = dn(g.events), Se = he.outgoing.length + he.incoming.length + he.providers.length + _e.length === 0 ? void 0 : {
1230
+ ...he,
1231
+ outgoing: [...he.outgoing, ..._e]
1232
+ }, De = $t({
1232
1233
  nodeEnv: process.env.NODE_ENV,
1233
- cdcDialect: ae,
1234
- declared: u?.schema
1235
- }), De = Xt({
1236
- gates: Ee,
1234
+ cdcDialect: oe,
1235
+ declared: d?.schema
1236
+ }), Oe = Yt({
1237
+ gates: De,
1237
1238
  runtime: {
1238
- traces: ye(),
1239
+ traces: be(),
1239
1240
  undo: Jr()
1240
1241
  }
1241
1242
  });
1242
- if (De !== void 0) throw Vt(`serve: ${De}`);
1243
- let Oe = $t({
1243
+ if (Oe !== void 0) throw i(`serve: ${Oe}`);
1244
+ let ke = Qt({
1244
1245
  mix: g.featureMix,
1245
- plugins: u?.plugins ?? [],
1246
- gates: Ee,
1247
- ...ae ? { cdcDialect: ae } : {}
1248
- }), ke = u?.analytics !== void 0 && u.analytics.kind !== "noop" && m !== "memory" ? (await j(m)).makeSqlLayer(w()) : void 0, je = await Ie({
1249
- spec: u?.analytics,
1250
- sqlLayer: ke,
1246
+ plugins: d?.plugins ?? [],
1247
+ gates: De,
1248
+ ...oe ? { cdcDialect: oe } : {}
1249
+ }), Ae = d?.analytics !== void 0 && d.analytics.kind !== "noop" && m !== "memory" ? (await M(m)).makeSqlLayer(E()) : void 0, Me = await x({
1250
+ spec: d?.analytics,
1251
+ sqlLayer: Ae,
1251
1252
  log: $
1252
1253
  }), y = (() => {
1253
1254
  let e = new Set(g.tables.map((e) => e.tableName)), t = [...g.tables];
1254
- for (let n of [...Oe, ...je.tables]) e.has(n.tableName) || (e.add(n.tableName), t.push(n));
1255
+ for (let n of [...ke, ...Me.tables]) e.has(n.tableName) || (e.add(n.tableName), t.push(n));
1255
1256
  return t;
1256
1257
  })();
1257
- for (let e of y) qn(e);
1258
+ for (let e of y) Kn(e);
1258
1259
  {
1259
1260
  let e = ur(Yr(g.queries.map((e) => ({
1260
1261
  name: e.descriptor.name,
@@ -1265,41 +1266,41 @@ var Ti = (e, t, n = [], r = 0) => {
1265
1266
  }))));
1266
1267
  e !== void 0 && $.warn(e);
1267
1268
  }
1268
- let Me = (process.env.NODE_ENV ?? "").toLowerCase();
1269
- if (qi(Me, m, process.env.VOLTRO_AUTO_MIGRATE)) {
1270
- let e = (await j(m)).makeSqlLayer(w()), t = await H.runPromise(Rn.SqlClient.pipe(H.flatMap((e) => Vn(e, l)), H.provide(e), H.catchAll(() => H.succeed([]))));
1269
+ let Ne = (process.env.NODE_ENV ?? "").toLowerCase();
1270
+ if (qi(Ne, m, process.env.VOLTRO_AUTO_MIGRATE)) {
1271
+ let e = (await M(m)).makeSqlLayer(E()), t = await U.runPromise(Ln.SqlClient.pipe(U.flatMap((e) => Bn(e, u)), U.provide(e), U.catchAll(() => U.succeed([]))));
1271
1272
  t.length > 0 && ($.error(`serve: refusing to boot — ${t.length} pending file-based migration(s) have never run against this database. They perform the changes a schema diff cannot infer (data moves, backfills, table splits), so the declarative fingerprint check below cannot see them and would have let this process serve un-migrated data.`, { pending: t }), $.error("Run them from your pre-deploy job — `voltro db migrate .` (schema + files) or `voltro db files .` (files alone) — or set VOLTRO_AUTO_MIGRATE=0 to bypass every boot schema check. `voltro serve` never applies them itself: a rolling deploy would start N replicas and each would try."), process.exit(1));
1272
- let n = await H.runPromise(Rn.SqlClient.pipe(H.flatMap((e) => Hn(e, y, {
1273
- appliedBy: `serve:${Me}`,
1273
+ let n = await U.runPromise(Ln.SqlClient.pipe(U.flatMap((e) => Vn(e, y, {
1274
+ appliedBy: `serve:${Ne}`,
1274
1275
  environment: "prod",
1275
1276
  dialectId: m
1276
- })), H.provide(e)));
1277
- n.kind === "prod-mismatch" && ($.error(Bn(n, m)), $.error(Zt({
1278
- gates: Ee,
1277
+ })), U.provide(e)));
1278
+ n.kind === "prod-mismatch" && ($.error(zn(n, m)), $.error(Xt({
1279
+ gates: De,
1279
1280
  nodeEnv: process.env.NODE_ENV,
1280
- cdcDialect: ae,
1281
- declared: u?.schema
1282
- })), $.error("serve: refusing to boot — apply the schema first (voltro db apply in a pre-deploy step), or set VOLTRO_AUTO_MIGRATE=0 to bypass this check."), process.exit(1)), $.info(Bn(n, m));
1281
+ cdcDialect: oe,
1282
+ declared: d?.schema
1283
+ })), $.error("serve: refusing to boot — apply the schema first (voltro db apply in a pre-deploy step), or set VOLTRO_AUTO_MIGRATE=0 to bypass this check."), process.exit(1)), $.info(zn(n, m));
1283
1284
  }
1284
- await Kt({
1285
+ await Gt({
1285
1286
  dialectId: m,
1286
1287
  tables: y,
1287
- mode: M(u?.reactiveTriggers),
1288
- lockSchema: w().schema,
1289
- makeLayer: async () => (await j(m)).makeSqlLayer(w()),
1288
+ mode: N(d?.reactiveTriggers),
1289
+ lockSchema: E().schema,
1290
+ makeLayer: async () => (await M(m)).makeSqlLayer(E()),
1290
1291
  log: {
1291
1292
  info: (e, t) => $.info(e, t ?? {}),
1292
1293
  warn: (e, t) => $.warn(e, t ?? {})
1293
1294
  }
1294
1295
  });
1295
- let Fe = jr(y);
1296
- s.mark("discover");
1297
- let b = await C(u, void 0), Le = Qr(b, m);
1296
+ let Ie = jr(y);
1297
+ c.mark("discover");
1298
+ let b = await T(d, void 0), Le = Qr(b, m);
1298
1299
  for (let e of Xe({
1299
- dialect: String(u?.store ?? process.env.DB_DIALECT ?? "postgres"),
1300
+ dialect: String(d?.store ?? process.env.DB_DIALECT ?? "postgres"),
1300
1301
  changeStrategy: (process.env.CDC ?? "1") === "0" ? "inline" : "cdc",
1301
1302
  dbUrl: process.env.DB_URL,
1302
- crossReplicaBus: _i(u?.plugins ?? [])?.broadcast.crossReplica === !0,
1303
+ crossReplicaBus: _i(d?.plugins ?? [])?.broadcast.crossReplica === !0,
1303
1304
  tables: g.tables.map((e) => ({
1304
1305
  tableName: e.tableName,
1305
1306
  isReactive: e.isReactive === !0
@@ -1310,8 +1311,8 @@ var Ti = (e, t, n = [], r = 0) => {
1310
1311
  })
1311
1312
  })) e.level === "warn" ? $.warn(e.message) : $.info(e.message);
1312
1313
  {
1313
- let e = S(Ot({
1314
- tables: Wn().map((e) => ({ tableName: e.tableName })),
1314
+ let e = Ke(Ot({
1315
+ tables: Un().map((e) => ({ tableName: e.tableName })),
1315
1316
  queries: g.queries.map((e) => ({
1316
1317
  name: e.descriptor.name,
1317
1318
  source: e.descriptor.source
@@ -1319,147 +1320,147 @@ var Ti = (e, t, n = [], r = 0) => {
1319
1320
  }));
1320
1321
  e !== void 0 && $.warn(e);
1321
1322
  }
1322
- u?.cache && !process.env.CACHE_BACKEND && (process.env.CACHE_BACKEND = u.cache), u?.cacheRedisUrl && !process.env.CACHE_REDIS_URL && (process.env.CACHE_REDIS_URL = u.cacheRedisUrl), u?.cacheRedisDriver && !process.env.CACHE_REDIS_DRIVER && (process.env.CACHE_REDIS_DRIVER = u.cacheRedisDriver), u?.cacheKeyPrefix && !process.env.CACHE_KEY_PREFIX && (process.env.CACHE_KEY_PREFIX = u.cacheKeyPrefix);
1323
- let { service: ze, invalidationBus: He, snapshotCache: Ge, cache: Ke, semantic: $e, evictSource: rt, backend: it, stats: ot, dispose: st } = await ut({
1323
+ d?.cache && !process.env.CACHE_BACKEND && (process.env.CACHE_BACKEND = d.cache), d?.cacheRedisUrl && !process.env.CACHE_REDIS_URL && (process.env.CACHE_REDIS_URL = d.cacheRedisUrl), d?.cacheRedisDriver && !process.env.CACHE_REDIS_DRIVER && (process.env.CACHE_REDIS_DRIVER = d.cacheRedisDriver), d?.cacheKeyPrefix && !process.env.CACHE_KEY_PREFIX && (process.env.CACHE_KEY_PREFIX = d.cacheKeyPrefix);
1324
+ let { service: Be, invalidationBus: Ue, snapshotCache: Ge, cache: qe, semantic: $e, evictSource: nt, backend: rt, stats: at, dispose: ot } = await lt({
1324
1325
  env: process.env,
1325
- semantic: u?.cacheSemantic ?? !1
1326
+ semantic: d?.cacheSemantic ?? !1
1326
1327
  });
1327
- $e !== void 0 && $.info("semantic cache enabled — reactive eviction on live writes"), $.info(`cache backend resolved: ${it}` + (it === "redis" ? ` (driver ${process.env.CACHE_REDIS_DRIVER ?? "resp"})` : " — in-process, not cross-instance")), b.onChange((e) => {
1328
- if (H.runFork(He.publish(e.table)), rt !== void 0) {
1328
+ $e !== void 0 && $.info("semantic cache enabled — reactive eviction on live writes"), $.info(`cache backend resolved: ${rt}` + (rt === "redis" ? ` (driver ${process.env.CACHE_REDIS_DRIVER ?? "resp"})` : " — in-process, not cross-instance")), b.onChange((e) => {
1329
+ if (U.runFork(Ue.publish(e.table)), nt !== void 0) {
1329
1330
  let t = (e.new ?? e.old)?.id;
1330
- rt({
1331
+ nt({
1331
1332
  table: e.table,
1332
1333
  op: e.op,
1333
1334
  ...t === void 0 ? {} : { id: t }
1334
1335
  });
1335
1336
  }
1336
- }), u?.kv && !process.env.KV_BACKEND && (process.env.KV_BACKEND = u.kv), u?.kvRedisUrl && !process.env.KV_REDIS_URL && (process.env.KV_REDIS_URL = u.kvRedisUrl), u?.kvKeyPrefix && !process.env.KV_KEY_PREFIX && (process.env.KV_KEY_PREFIX = u.kvKeyPrefix);
1337
- let { kv: dt, service: _t } = await yr({ store: b });
1338
- $.info(Ti(Wt(), Di(), m === "postgres" && (process.env.CDC ?? "1") !== "0" ? [{ reason: "CDC LISTEN consumer" }] : [], t.replicationSnapshot()?.replicaCount ?? 0)), s.mark("store");
1339
- let bt = $n({
1337
+ }), d?.kv && !process.env.KV_BACKEND && (process.env.KV_BACKEND = d.kv), d?.kvRedisUrl && !process.env.KV_REDIS_URL && (process.env.KV_REDIS_URL = d.kvRedisUrl), d?.kvKeyPrefix && !process.env.KV_KEY_PREFIX && (process.env.KV_KEY_PREFIX = d.kvKeyPrefix);
1338
+ let { kv: ut, service: gt } = await yr({ store: b });
1339
+ $.info(Ti(Ut(), Di(), m === "postgres" && (process.env.CDC ?? "1") !== "0" ? [{ reason: "CDC LISTEN consumer" }] : [], t.replicationSnapshot()?.replicaCount ?? 0)), c.mark("store");
1340
+ let yt = $n({
1340
1341
  store: b,
1341
- sink: je.sink,
1342
+ sink: Me.sink,
1342
1343
  log: $
1343
- }), wt = We({
1344
+ }), wt = S({
1344
1345
  store: b,
1345
1346
  dialect: m,
1346
1347
  log: { info: (e) => $.info(e) }
1347
- }), O = u?.plugins ?? [], kt = process.env.POD_NAME ?? process.env.HOSTNAME ?? `serve-${process.pid}`, It, Lt;
1348
- m !== "memory" && (It = Ln.make((await j(m)).makeSqlLayer(w())), Lt = await It.runPromise(Rn.SqlClient));
1348
+ }), k = d?.plugins ?? [], kt = process.env.POD_NAME ?? process.env.HOSTNAME ?? `serve-${process.pid}`, Ft, It;
1349
+ m !== "memory" && (Ft = In.make((await M(m)).makeSqlLayer(E())), It = await Ft.runPromise(Ln.SqlClient));
1349
1350
  let Rt = [
1350
1351
  "postgres",
1351
1352
  "mariadb",
1352
1353
  "mysql",
1353
1354
  "mssql"
1354
- ].includes(m) ? hr(b, kt, $) : Wr, pn = Re(u?.scheduling), vn = xr({
1355
- maxIdleIntervalMs: pn.pollCeilingMs,
1355
+ ].includes(m) ? hr(b, kt, $) : Wr, fn = ze(d?.scheduling), _n = xr({
1356
+ maxIdleIntervalMs: fn.pollCeilingMs,
1356
1357
  coordinator: Rt,
1357
1358
  replicaId: kt,
1358
1359
  log: $
1359
- }), bn = [], P = process.env.POD_NAME ?? process.env.HOSTNAME ?? `serve-${process.pid}`, Tn = _i(u?.plugins ?? [])?.broadcast?.provider, En = Qe(u?.plugins, u?.name ?? xn(l));
1360
+ }), yn = [], F = process.env.POD_NAME ?? process.env.HOSTNAME ?? `serve-${process.pid}`, wn = _i(d?.plugins ?? [])?.broadcast?.provider, Tn = Qe(d?.plugins, d?.name ?? bn(u));
1360
1361
  {
1361
- let e = tt(u?.plugins, u?.name ?? xn(l));
1362
+ let e = tt(d?.plugins, d?.name ?? bn(u));
1362
1363
  e !== void 0 && $.warn(e);
1363
1364
  }
1364
- let F = At(u?.plugins, {
1365
- instanceId: P,
1366
- namespace: En,
1365
+ let I = At(d?.plugins, {
1366
+ instanceId: F,
1367
+ namespace: Tn,
1367
1368
  meta: { mode: "serve" },
1368
1369
  logger: $
1369
- }), Dn = {
1370
- ...Lt ? { sql: Lt } : {},
1371
- instanceId: P,
1372
- membership: F.membership,
1373
- ...Tn === void 0 ? {} : { broadcast: Tn },
1374
- broadcastChannels: { presence: gi(En, "presence") },
1370
+ }), En = {
1371
+ ...It ? { sql: It } : {},
1372
+ instanceId: F,
1373
+ membership: I.membership,
1374
+ ...wn === void 0 ? {} : { broadcast: wn },
1375
+ broadcastChannels: { presence: gi(Tn, "presence") },
1375
1376
  scheduleCoordinated: (e, t, n) => {
1376
- let r = vn(e, t, n);
1377
- return bn.push(r), r;
1377
+ let r = _n(e, t, n);
1378
+ return yn.push(r), r;
1378
1379
  }
1379
1380
  };
1380
- for (let e of O) e.bindDataStore?.(Le, Dn);
1381
- c({
1381
+ for (let e of k) e.bindDataStore?.(Le, En);
1382
+ l({
1382
1383
  store: b,
1383
- ...ct(),
1384
+ ...st(),
1384
1385
  log: $
1385
1386
  });
1386
- let On = O.filter((e) => typeof e.onChangeEvent == "function");
1387
- if (On.length > 0) {
1387
+ let Dn = k.filter((e) => typeof e.onChangeEvent == "function");
1388
+ if (Dn.length > 0) {
1388
1389
  let e = b.changeScope ?? "local";
1389
1390
  b.onChange((t) => {
1390
- let n = _e(t, e);
1391
- for (let e of On) H.runFork(e.onChangeEvent(n).pipe(H.catchAllCause((t) => H.sync(() => $.warn(`plugin ${e.name} onChangeEvent failed`, { error: In.pretty(t) })))));
1391
+ let n = _(t, e);
1392
+ for (let e of Dn) U.runFork(e.onChangeEvent(n).pipe(U.catchAllCause((t) => U.sync(() => $.warn(`plugin ${e.name} onChangeEvent failed`, { error: Fn.pretty(t) })))));
1392
1393
  });
1393
1394
  }
1394
- let I = le({
1395
- plugins: O,
1396
- appName: u?.name ?? "voltro-api",
1395
+ let L = ue({
1396
+ plugins: k,
1397
+ appName: d?.name ?? "voltro-api",
1397
1398
  appType: "api",
1398
1399
  voltroVersion: process.env.npm_package_version ?? "0.0.0",
1399
1400
  log: $
1400
1401
  });
1401
- O.length && await I.activate(), s.mark("plugins");
1402
- let L = await I.gatherObservability(), kn = {
1402
+ k.length && await L.activate(), c.mark("plugins");
1403
+ let R = await L.gatherObservability(), On = {
1403
1404
  info: (e, t) => process.stdout.write(`[broadcast] ${e} ${t ? JSON.stringify(t) : ""}\n`),
1404
1405
  warn: (e, t) => process.stderr.write(`[broadcast] ${e} ${t ? JSON.stringify(t) : ""}\n`),
1405
1406
  debug: () => {}
1406
- }, An, jn = await vt(b, u, m, En, kn, (e, t) => {
1407
- An?.refreshAll(`broadcast gap: missed ${t} change(s) from ${e}`);
1408
- }), R = u?.apiKeys, Mn = (typeof R == "object" ? R.prefix : void 0) ?? "voltro_", z = R ? cr(b) : void 0, B = z ? _r({ flush: vr(z) }) : void 0;
1409
- B && Fr(() => B.shutdown());
1410
- let V = z ? gr(z, {
1411
- prefix: Mn,
1412
- ...B ? { usage: B } : {}
1413
- }) : void 0, Nn = V ? [dr(V, { prefix: Mn })] : [], Pn = D([...u?.auth?.strategies ?? [], ...Nn], mi(u?.plugins ?? []), u?.auth?.anonymousTenantRequired ?? !1, u?.auth, () => Le), Fn = [...u?.restRoutes ?? [], ...V ? Qn(V, (typeof R == "object" ? R.managementPath : void 0) ?? "/v1/api-keys") : []], Un = qe(u?.idempotency, b), Gn = O.map((e) => e.services).filter((e) => e !== void 0), W = U.mergeAll(xt({
1414
- analyticsLayer: je.layer,
1415
- cacheService: ze,
1416
- kvService: _t,
1407
+ }, kn, An = await vt(b, d, m, Tn, On, (e, t) => {
1408
+ kn?.refreshAll(`broadcast gap: missed ${t} change(s) from ${e}`);
1409
+ }), z = d?.apiKeys, jn = (typeof z == "object" ? z.prefix : void 0) ?? "voltro_", B = z ? cr(b) : void 0, V = B ? _r({ flush: vr(B) }) : void 0;
1410
+ V && Fr(() => V.shutdown());
1411
+ let H = B ? gr(B, {
1412
+ prefix: jn,
1413
+ ...V ? { usage: V } : {}
1414
+ }) : void 0, Mn = H ? [dr(H, { prefix: jn })] : [], Nn = bt([...d?.auth?.strategies ?? [], ...Mn], mi(d?.plugins ?? []), d?.auth?.anonymousTenantRequired ?? !1, d?.auth, () => Le), Pn = [...d?.restRoutes ?? [], ...H ? Qn(H, (typeof z == "object" ? z.managementPath : void 0) ?? "/v1/api-keys") : []], Hn = C(d?.idempotency, b), Wn = k.map((e) => e.services).filter((e) => e !== void 0), G = W.mergeAll(xt({
1415
+ analyticsLayer: Me.layer,
1416
+ cacheService: Be,
1417
+ kvService: gt,
1417
1418
  ...$e === void 0 ? {} : { semanticCache: $e },
1418
- pluginServices: Gn,
1419
- userLayers: u?.layers ?? []
1420
- }), ht(u?.http ?? {})), G = await at({
1419
+ pluginServices: Wn,
1420
+ userLayers: d?.layers ?? []
1421
+ }), mt(d?.http ?? {})), K = await it({
1421
1422
  files: h,
1422
1423
  store: b,
1423
1424
  log: $,
1424
1425
  seedPolicy: "report",
1425
- seedPattern: cn,
1426
- loadSeedFiles: Gt,
1427
- startupPattern: nn,
1426
+ seedPattern: sn,
1427
+ loadSeedFiles: Wt,
1428
+ startupPattern: tn,
1428
1429
  loadStartupFiles: a,
1429
- runStartups: i,
1430
- emailPattern: Be,
1431
- loadEmailFiles: T,
1430
+ runStartups: o,
1431
+ emailPattern: Ve,
1432
+ loadEmailFiles: _t,
1432
1433
  registerEmailTemplates: hi
1433
1434
  });
1434
- (G.startupCount > 0 || G.emailCount > 0) && $.info("boot lifecycle", {
1435
- startups: G.startupCount,
1436
- emailTemplates: G.emailCount
1437
- }), G.startups !== void 0 && Fr(async () => {
1438
- await G.startups.stop();
1435
+ (K.startupCount > 0 || K.emailCount > 0) && $.info("boot lifecycle", {
1436
+ startups: K.startupCount,
1437
+ emailTemplates: K.emailCount
1438
+ }), K.startups !== void 0 && Fr(async () => {
1439
+ await K.startups.stop();
1439
1440
  });
1440
- let Jn = gt({
1441
+ let qn = ht({
1441
1442
  schedules: St({
1442
1443
  schedules: g.schedules,
1443
- seeds: G.seeds,
1444
+ seeds: K.seeds,
1444
1445
  store: b,
1445
1446
  log: $.child("seeds")
1446
1447
  }),
1447
1448
  workflows: g.workflows ?? [],
1448
1449
  log: $.child("workflow-schedules")
1449
- }), Yn = u?.scheduling ?? {}, Xn = Yn.trigger ?? "self", Zn = /* @__PURE__ */ new Set([
1450
+ }), Jn = d?.scheduling ?? {}, Yn = Jn.trigger ?? "self", Xn = /* @__PURE__ */ new Set([
1450
1451
  "postgres",
1451
1452
  "mysql",
1452
1453
  "mariadb",
1453
1454
  "mssql"
1454
- ]), K = Yn.coordination ?? (Zn.has(m) ? "advisoryLock" : "single"), q = K === "cluster" && Zn.has(m), er = q ? "cluster" : K === "advisoryLock" && Zn.has(m) ? "advisoryLock" : "single";
1455
- K === "cluster" && !q && $.warn("scheduling.coordination=cluster needs a sql-backed store except sqlite — falling back to single"), K === "advisoryLock" && !Zn.has(m) && $.warn("scheduling.coordination=advisoryLock needs a SQL store (the claim-row gate) — falling back to single");
1456
- let tr, nr = g.workflows.length > 0 || g.workflowWorkers.length > 0 || g.eventTriggers.length > 0 || (xe?.outgoing.length ?? 0) > 0 || q, rr;
1455
+ ]), Zn = Jn.coordination ?? (Xn.has(m) ? "advisoryLock" : "single"), q = Zn === "cluster" && Xn.has(m), er = q ? "cluster" : Zn === "advisoryLock" && Xn.has(m) ? "advisoryLock" : "single";
1456
+ Zn === "cluster" && !q && $.warn("scheduling.coordination=cluster needs a sql-backed store except sqlite — falling back to single"), Zn === "advisoryLock" && !Xn.has(m) && $.warn("scheduling.coordination=advisoryLock needs a SQL store (the claim-row gate) — falling back to single");
1457
+ let tr, nr = g.workflows.length > 0 || g.workflowWorkers.length > 0 || g.eventTriggers.length > 0 || (Se?.outgoing.length ?? 0) > 0 || q, rr;
1457
1458
  if (nr) {
1458
1459
  if (m === "mssql") {
1459
- let e = await dn(process.cwd());
1460
+ let e = await un(process.cwd());
1460
1461
  e && $.warn(e);
1461
1462
  }
1462
- let [{ WorkflowEngine: e }, { makeClusterCronLayer: t, workflowEngineLayer: n, resolveRunnerStorage: r, resolveFailoverTuning: i }] = await Promise.all([import("@effect/workflow"), import("@voltro/workflow/cluster")]), a = q ? Jn.filter((e) => (e.trigger ?? Xn) === "self").map((e) => t({
1463
+ let [{ WorkflowEngine: e }, { makeClusterCronLayer: t, workflowEngineLayer: n, resolveRunnerStorage: r, resolveFailoverTuning: i }] = await Promise.all([import("@effect/workflow"), import("@voltro/workflow/cluster")]), a = q ? qn.filter((e) => (e.trigger ?? Yn) === "self").map((e) => t({
1463
1464
  name: e.name,
1464
1465
  cron: sr(e),
1465
1466
  execute: async () => {
@@ -1467,9 +1468,9 @@ var Ti = (e, t, n = [], r = 0) => {
1467
1468
  }
1468
1469
  })) : [];
1469
1470
  rr = m === "memory" ? e.layerMemory : await (async () => {
1470
- let e = await j(m), t = r({ sqliteFamily: e.id === "sqlite" || e.id === "turso" });
1471
+ let e = await M(m), t = r({ sqliteFamily: e.id === "sqlite" || e.id === "turso" });
1471
1472
  return $.info(`workflow engine: cluster-${t}, dialect=${e.id}` + (t === "memory" ? " — single-process durable replay, no cross-pod shard handoff" + (e.id !== "sqlite" && e.id !== "turso" ? " (VOLTRO_WORKFLOW_RUNNER_STORAGE=memory: SqlRunnerStorage/cluster_runners + GET_LOCK skipped)" : "") : "")), n({
1472
- sqlClientLayer: e.makeSqlLayer(w()),
1473
+ sqlClientLayer: e.makeSqlLayer(E()),
1473
1474
  runnerStorage: t,
1474
1475
  dialectId: e.id,
1475
1476
  ...process.env.VOLTRO_WORKFLOW_RUNNER_PORT ? { runnerListenPort: Number(process.env.VOLTRO_WORKFLOW_RUNNER_PORT) } : {},
@@ -1478,17 +1479,17 @@ var Ti = (e, t, n = [], r = 0) => {
1478
1479
  });
1479
1480
  })();
1480
1481
  }
1481
- let J = ue(O, gn()), ir = h.filter((e) => /\.subscribe\.tsx?$/.test(e)), Y = ir.length > 0 ? await Ne(ir, $) : [], ar = h.filter((e) => /\.reaction\.tsx?$/.test(e)), or = ar.length > 0 ? await he(ar, $) : [], fr = h.filter((e) => on.test(e)), pr = fr.length > 0 ? await E(fr, $) : [], mr = h.filter((e) => /\.aggregate\.tsx?$/.test(e)), br = mr.length > 0 ? await p(mr, $) : [], Sr = ve();
1482
+ let J = de(k, hn()), ir = h.filter((e) => /\.subscribe\.tsx?$/.test(e)), Y = ir.length > 0 ? await Pe(ir, $) : [], ar = h.filter((e) => /\.reaction\.tsx?$/.test(e)), or = ar.length > 0 ? await ge(ar, $) : [], fr = h.filter((e) => an.test(e)), pr = fr.length > 0 ? await O(fr, $) : [], mr = h.filter((e) => /\.aggregate\.tsx?$/.test(e)), br = mr.length > 0 ? await te(mr, $) : [], Sr = ye();
1482
1483
  if (br.length > 0 && m !== "memory") try {
1483
- Sr = lt((await j(m)).makeSqlLayer(w()));
1484
+ Sr = ct((await M(m)).makeSqlLayer(E()));
1484
1485
  } catch (e) {
1485
1486
  $.warn("aggregate: SQL storage init failed — falling back to in-process", { err: String(e) });
1486
1487
  }
1487
- let Cr = m === "memory" ? Wr : hr(b, `aggregate@${process.pid}`, $), wr = h.filter((e) => sn.test(e)), Tr = wr.length > 0 ? await ee(wr, $) : [], Er = h.filter((e) => an.test(e)), Dr = Er.length > 0 ? await Te(Er, $) : [], Or = h.filter((e) => rn.test(e)), kr = Or.length > 0 ? await Pt(Or, $) : [], Ar = [], Mr = [], Nr = h.filter((e) => Qt.test(e));
1488
+ let Cr = m === "memory" ? Wr : hr(b, `aggregate@${process.pid}`, $), wr = h.filter((e) => on.test(e)), Tr = wr.length > 0 ? await f(wr, $) : [], Er = h.filter((e) => rn.test(e)), Dr = Er.length > 0 ? await v(Er, $) : [], Or = h.filter((e) => nn.test(e)), kr = Or.length > 0 ? await Pt(Or, $) : [], Ar = [], Mr = [], Nr = h.filter((e) => Zt.test(e));
1488
1489
  if (Nr.length > 0) {
1489
- let e = $.child("agent"), t = h.filter((e) => N.test(e));
1490
- t.length > 0 && await tn(t, e);
1491
- let n = await Yt(Nr, e);
1490
+ let e = $.child("agent"), t = h.filter((e) => P.test(e));
1491
+ t.length > 0 && await en(t, e);
1492
+ let n = await Jt(Nr, e);
1492
1493
  for (let e of n.agents) for (let t of Je(e)) (t.kind === "action" ? Ar : Mr).push({
1493
1494
  file: t.file,
1494
1495
  descriptor: t.descriptor,
@@ -1496,38 +1497,38 @@ var Ti = (e, t, n = [], r = 0) => {
1496
1497
  });
1497
1498
  n.agents.length > 0 && e.info("synthesized agent routes", { agents: n.agents.map((e) => e.descriptor.name) });
1498
1499
  }
1499
- s.mark("workflow");
1500
+ c.mark("workflow");
1500
1501
  let X = () => {
1501
1502
  let e = Z.workflowWriteActions();
1502
1503
  if (e === void 0) throw Error("workflow actions: this app registers no workflows");
1503
1504
  return e;
1504
- }, Pr = Kn({
1505
+ }, Pr = Gn({
1505
1506
  dialect: m,
1506
- ...w()
1507
- }), Ir = m === "memory" ? void 0 : (await j(m)).makeSqlLayer(w()), Lr = async () => Et({
1507
+ ...E()
1508
+ }), Ir = m === "memory" ? void 0 : (await M(m)).makeSqlLayer(E()), Lr = async () => Et({
1508
1509
  sqlLayer: Ir,
1509
1510
  declared: y,
1510
1511
  log: $
1511
1512
  }), Rr = {
1512
1513
  kind: "api",
1513
1514
  meta: {
1514
- name: u?.name ?? "voltro-api",
1515
+ name: d?.name ?? "voltro-api",
1515
1516
  voltroVersion: Tt,
1516
- port: re,
1517
+ port: ie,
1517
1518
  mode: "start",
1518
1519
  store: m,
1519
- cdc: ie ? "on" : "off",
1520
+ cdc: ae ? "on" : "off",
1520
1521
  ...Pr === void 0 ? {} : { databaseId: Pr }
1521
1522
  },
1522
- rpc: pt(g, l),
1523
- workflows: nt(g, l),
1523
+ rpc: ft(g, u),
1524
+ workflows: w(g, u),
1524
1525
  migrations: Lr,
1525
1526
  events: () => Z.eventsSnapshot(),
1526
1527
  agentTools: () => Z.agentTools(),
1527
1528
  invariantChecks: () => ({
1528
1529
  mode: "serve",
1529
- accessGate: de,
1530
- config: u,
1530
+ accessGate: fe,
1531
+ config: d,
1531
1532
  serverOnlyLeaks: g.serverOnlyLeaks,
1532
1533
  migrations: Lr
1533
1534
  }),
@@ -1536,52 +1537,52 @@ var Ti = (e, t, n = [], r = 0) => {
1536
1537
  if (!tr) throw Error("scheduler not started — this app registers no self-triggered schedules (all schedules are trigger:'external', or there are none).");
1537
1538
  return { runId: await tr.fireNow(e, t) ?? null };
1538
1539
  },
1539
- inspectBackfillSchedule: te({
1540
+ inspectBackfillSchedule: ne({
1540
1541
  getHandle: () => tr,
1541
- getSchedules: () => Jn
1542
+ getSchedules: () => qn
1542
1543
  }),
1543
- ...xe === void 0 ? {} : { webhooks: () => _({
1544
+ ...Se === void 0 ? {} : { webhooks: () => ve({
1544
1545
  store: b,
1545
- discoveredWebhooks: xe
1546
+ discoveredWebhooks: Se
1546
1547
  }) },
1547
1548
  plugins: () => ({
1548
- plugins: I.snapshot(),
1549
+ plugins: L.snapshot(),
1549
1550
  capturedAt: Date.now()
1550
1551
  }),
1551
- env: () => Bt(u?.name ?? xn(l), {
1552
- ...u?.env !== void 0 && ii(u.env) ? { contract: u.env } : {},
1553
- plugins: u?.plugins ?? []
1552
+ env: () => Bt(d?.name ?? bn(u), {
1553
+ ...d?.env !== void 0 && ii(d.env) ? { contract: d.env } : {},
1554
+ plugins: d?.plugins ?? []
1554
1555
  }),
1555
- dataCache: () => Ve({
1556
- stats: ot,
1557
- backendKind: it
1556
+ dataCache: () => He({
1557
+ stats: at,
1558
+ backendKind: rt
1558
1559
  }),
1559
- subscriptions: () => Ft(() => An),
1560
- inspectTables: () => fe(g.tables),
1561
- inspectRows: Ce({
1560
+ subscriptions: () => A(() => kn),
1561
+ inspectTables: () => pe(g.tables),
1562
+ inspectRows: we({
1562
1563
  store: b,
1563
1564
  tables: g.tables,
1564
1565
  mask: !0
1565
1566
  }),
1566
1567
  metrics: (e) => Z.rpcMetrics().snapshot(e),
1567
- cluster: () => k({
1568
+ cluster: () => j({
1568
1569
  store: b,
1569
1570
  dialect: m,
1570
1571
  useClusterCron: q,
1571
- scheduleCoordChoice: K
1572
+ scheduleCoordChoice: Zn
1572
1573
  }),
1573
- inspectSchedules: () => v({
1574
- schedules: Jn,
1575
- defaultTrigger: Xn,
1574
+ inspectSchedules: () => Ee({
1575
+ schedules: qn,
1576
+ defaultTrigger: Yn,
1576
1577
  coordination: er
1577
1578
  }),
1578
1579
  inspectScheduleRuns: (e) => Nt(b, e),
1579
- ...d(b, {
1580
- controls: mt(g.workflows ?? []),
1580
+ ...ee(b, {
1581
+ controls: pt(g.workflows ?? []),
1581
1582
  active: (g.workflows?.length ?? 0) > 0,
1582
1583
  cancellation: () => Z.flowControlHealth()
1583
1584
  }),
1584
- webhookActions: we(() => Z.webhooksService()),
1585
+ webhookActions: Te(() => Z.webhooksService()),
1585
1586
  inspectStartWorkflow: (e) => X().inspectStartWorkflow(e),
1586
1587
  inspectCancelWorkflowRun: (e) => X().inspectCancelWorkflowRun(e),
1587
1588
  inspectSuspendWorkflowRun: (e) => X().inspectSuspendWorkflowRun(e),
@@ -1595,7 +1596,7 @@ var Ti = (e, t, n = [], r = 0) => {
1595
1596
  active: (g.workflows?.length ?? 0) > 0,
1596
1597
  dispatcher: () => Z.inferenceHealth()
1597
1598
  }, e.limit === void 0 ? {} : { limit: e.limit }),
1598
- ...yt({
1599
+ ...D({
1599
1600
  store: b,
1600
1601
  cancelRun: async (e) => await Z.runCanceller()?.(e) ?? !1,
1601
1602
  retryRun: async (e) => X().inspectRetryWorkflowRun({ runId: e }),
@@ -1604,11 +1605,11 @@ var Ti = (e, t, n = [], r = 0) => {
1604
1605
  }),
1605
1606
  inspectRedriveWorkflowRun: (e) => Z.redriveWorkflowRun(e),
1606
1607
  inspectResumeWorkflowRunFromStep: (e) => Z.resumeWorkflowRunFromStep(e)
1607
- }, Br = (process.env.VOLTRO_TENANT_ISOLATION ?? u?.tenancy?.isolation) === "namespace", Hr = Br && m !== "memory" ? await (async () => {
1608
- let e = await j(m);
1608
+ }, Br = (process.env.VOLTRO_TENANT_ISOLATION ?? d?.tenancy?.isolation) === "namespace", Hr = Br && m !== "memory" ? await (async () => {
1609
+ let e = await M(m);
1609
1610
  return Ct({
1610
1611
  tables: y,
1611
- sqlLayer: e.makeSqlLayer(w()),
1612
+ sqlLayer: e.makeSqlLayer(E()),
1612
1613
  dialect: m,
1613
1614
  options: { retryFilter: e.retryFilter },
1614
1615
  log: {
@@ -1616,10 +1617,10 @@ var Ti = (e, t, n = [], r = 0) => {
1616
1617
  error: (e, t, n) => $.error(e, t ?? {}, n)
1617
1618
  }
1618
1619
  });
1619
- })() : void 0, Ur = await ft({
1620
- input: u?.tenancy?.residency,
1620
+ })() : void 0, Ur = await dt({
1621
+ input: d?.tenancy?.residency,
1621
1622
  namespaceIsolationOn: Br,
1622
- makeStoreForUrl: (e, t) => C(u, void 0, Ut(w(), t)),
1623
+ makeStoreForUrl: (e, t) => T(d, void 0, Ht(E(), t)),
1623
1624
  log: {
1624
1625
  info: (e, t) => $.info(e, t),
1625
1626
  warn: (e, t) => $.warn(e, t)
@@ -1629,10 +1630,10 @@ var Ti = (e, t, n = [], r = 0) => {
1629
1630
  await Ur.close();
1630
1631
  });
1631
1632
  let Z = await Ki({
1632
- bootTiming: s,
1633
- broadcastNamespace: En,
1633
+ bootTiming: c,
1634
+ broadcastNamespace: Tn,
1634
1635
  scheduling: (() => {
1635
- let e = pn;
1636
+ let e = fn;
1636
1637
  return {
1637
1638
  admissionDrainMs: e.admissionDrainMs,
1638
1639
  inferenceTickMs: e.inferenceTickMs,
@@ -1640,26 +1641,26 @@ var Ti = (e, t, n = [], r = 0) => {
1640
1641
  stalenessSweepMs: e.stalenessSweepMs,
1641
1642
  disarmWhenIdle: et({
1642
1643
  changeScope: b.changeScope,
1643
- broadcastAttached: jn !== void 0
1644
+ broadcastAttached: An !== void 0
1644
1645
  })
1645
1646
  };
1646
1647
  })(),
1647
- ...u?.workflows?.staleness === void 0 ? {} : { workflowStaleness: u.workflows.staleness },
1648
- ...u?.workflows?.suspendSignalHintMs === void 0 ? {} : { workflowSuspendSignalHintMs: u.workflows.suspendSignalHintMs },
1649
- workflowRecording: Mt(u?.workflows?.recording),
1648
+ ...d?.workflows?.staleness === void 0 ? {} : { workflowStaleness: d.workflows.staleness },
1649
+ ...d?.workflows?.suspendSignalHintMs === void 0 ? {} : { workflowSuspendSignalHintMs: d.workflows.suspendSignalHintMs },
1650
+ workflowRecording: Mt(d?.workflows?.recording),
1650
1651
  membership: {
1651
- ...F,
1652
- instanceId: P
1652
+ ...I,
1653
+ instanceId: F
1653
1654
  },
1654
1655
  security: {
1655
- defaultDeny: A(u),
1656
- ...be(u)
1656
+ defaultDeny: Lt(d),
1657
+ ...xe(d)
1657
1658
  },
1658
- approvals: { defaultExpiryMs: Pe(u) },
1659
- ...u?.plugins === void 0 ? {} : { plugins: u.plugins },
1660
- ...Un ? { idempotency: Un } : {},
1661
- restRoutes: Fn,
1662
- appProcedures: de,
1659
+ approvals: { defaultExpiryMs: Fe(d) },
1660
+ ...d?.plugins === void 0 ? {} : { plugins: d.plugins },
1661
+ ...Hn ? { idempotency: Hn } : {},
1662
+ restRoutes: Pn,
1663
+ appProcedures: fe,
1663
1664
  discovered: {
1664
1665
  queries: [...g.queries, ...Mr],
1665
1666
  mutations: g.mutations,
@@ -1669,7 +1670,7 @@ var Ti = (e, t, n = [], r = 0) => {
1669
1670
  workflows: g.workflows,
1670
1671
  workflowWorkers: g.workflowWorkers,
1671
1672
  eventTriggers: g.eventTriggers,
1672
- schedules: Jn,
1673
+ schedules: qn,
1673
1674
  subscribers: Y,
1674
1675
  outboxHandlers: pr,
1675
1676
  connections: g.connections,
@@ -1678,48 +1679,48 @@ var Ti = (e, t, n = [], r = 0) => {
1678
1679
  expectations: Tr,
1679
1680
  budgets: Dr,
1680
1681
  experiments: kr,
1681
- ...xe === void 0 ? {} : { webhooks: xe }
1682
+ ...Se === void 0 ? {} : { webhooks: Se }
1682
1683
  },
1683
1684
  log: $,
1684
- analytics: je.sink,
1685
+ analytics: Me.sink,
1685
1686
  aggregateStorage: Sr,
1686
1687
  aggregateCoordinator: Cr,
1687
1688
  store: b,
1688
- kv: dt,
1689
- cache: Ke,
1689
+ kv: ut,
1690
+ cache: qe,
1690
1691
  snapshotCache: Ge,
1691
- ...u?.reactive === void 0 ? {} : { reactive: u.reactive },
1692
- schemaRegistry: Fe,
1692
+ ...d?.reactive === void 0 ? {} : { reactive: d.reactive },
1693
+ schemaRegistry: Ie,
1693
1694
  tenantScopedTables: g.tenantScopedTables,
1694
1695
  softDeleteScopedTables: g.softDeleteScopedTables,
1695
- dataTransferSnapshot: zn(y),
1696
+ dataTransferSnapshot: Rn(y),
1696
1697
  dataTransferDialect: m,
1697
1698
  ...Hr === void 0 ? {} : { ensureTenantProvisioned: Hr.ensure },
1698
1699
  ...Ur === void 0 ? {} : { resolveResidentStore: Ur.resolveStore },
1699
- tenantIsolation: (process.env.VOLTRO_TENANT_ISOLATION ?? u?.tenancy?.isolation) === "namespace" ? "namespace" : "shared-schema",
1700
- resolveSubject: (e, t) => Pn({
1700
+ tenantIsolation: (process.env.VOLTRO_TENANT_ISOLATION ?? d?.tenancy?.isolation) === "namespace" ? "namespace" : "shared-schema",
1701
+ resolveSubject: (e, t) => Nn({
1701
1702
  headers: e,
1702
1703
  clientId: t
1703
1704
  }),
1704
- ...u?.auth === void 0 ? {} : { authority: u.auth },
1705
- ...u?.agents === void 0 ? {} : { agents: u.agents },
1706
- httpRoutes: O.flatMap((e) => e.httpRoutes ?? []),
1705
+ ...d?.auth === void 0 ? {} : { authority: d.auth },
1706
+ ...d?.agents === void 0 ? {} : { agents: d.agents },
1707
+ httpRoutes: k.flatMap((e) => e.httpRoutes ?? []),
1707
1708
  getStore: () => Le,
1708
- ...W ? { baseLayer: W } : {},
1709
+ ...G ? { baseLayer: G } : {},
1709
1710
  ...rr === void 0 ? {} : { workflowEngineLayer: rr },
1710
- scheduleDefaultTrigger: Xn,
1711
+ scheduleDefaultTrigger: Yn,
1711
1712
  scheduleCoordination: er,
1712
1713
  scheduleArmSelf: !q,
1713
- dormancy: process.env.VOLTRO_DORMANCY === "sleep" || process.env.VOLTRO_DORMANCY === "always-on" ? process.env.VOLTRO_DORMANCY : u?.dormancy ?? "always-on",
1714
+ dormancy: process.env.VOLTRO_DORMANCY === "sleep" || process.env.VOLTRO_DORMANCY === "always-on" ? process.env.VOLTRO_DORMANCY : d?.dormancy ?? "always-on",
1714
1715
  scheduleReplicaId: process.env.HOSTNAME ?? `pid-${process.pid}`,
1715
1716
  ...J === void 0 ? {} : { scheduleFireInterceptor: J },
1716
1717
  onSchedulerReady: (e) => {
1717
1718
  tr = e;
1718
1719
  },
1719
- inspectRoute: { handle: async (e, t, n, r) => await f(e, Rr, t, {
1720
+ inspectRoute: { handle: async (e, t, n, r) => await p(e, Rr, t, {
1720
1721
  method: n,
1721
1722
  ...r === void 0 ? {} : { body: r }
1722
- }) || ((n === "GET" ? await un(e, Rr, t, { method: n }) : null) ?? ln(e, Rr, t, {
1723
+ }) || ((n === "GET" ? await ln(e, Rr, t, { method: n }) : null) ?? cn(e, Rr, t, {
1723
1724
  method: n,
1724
1725
  ...r === void 0 ? {} : { body: r }
1725
1726
  }) ?? {
@@ -1727,19 +1728,19 @@ var Ti = (e, t, n = [], r = 0) => {
1727
1728
  contentType: "application/json",
1728
1729
  body: JSON.stringify({ error: "not an inspect route" })
1729
1730
  }) },
1730
- ...u?.name === void 0 ? {} : { appName: u.name },
1731
- observability: L,
1732
- port: re,
1733
- ...u?.transport?.wsPath ? { path: u.transport.wsPath } : {}
1731
+ ...d?.name === void 0 ? {} : { appName: d.name },
1732
+ observability: R,
1733
+ port: ie,
1734
+ ...d?.transport?.wsPath ? { path: d.transport.wsPath } : {}
1734
1735
  });
1735
- return An = Z.dispatcher, jt(x([
1736
+ return kn = Z.dispatcher, jt(Re([
1736
1737
  g.queries,
1737
1738
  g.mutations,
1738
1739
  g.actions,
1739
1740
  g.streams
1740
1741
  ]), (e) => {
1741
1742
  $.warn(e);
1742
- }), $.info(`API listening on :${re}`, {
1743
+ }), $.info(`API listening on :${ie}`, {
1743
1744
  dialect: m,
1744
1745
  queries: g.queries.length,
1745
1746
  mutations: g.mutations.length,
@@ -1747,16 +1748,16 @@ var Ti = (e, t, n = [], r = 0) => {
1747
1748
  streams: g.streams.length,
1748
1749
  workflows: g.workflows.length,
1749
1750
  workflowWorkers: g.workflowWorkers.length,
1750
- schedules: Jn.length,
1751
+ schedules: qn.length,
1751
1752
  scheduleCoordination: er
1752
- }), s.finish($), Fr(async () => {
1753
- for (let e of bn) e.stop();
1753
+ }), c.finish($), Fr(async () => {
1754
+ for (let e of yn) e.stop();
1754
1755
  wt.stop();
1755
1756
  try {
1756
- await Z.close(), st(), It?.dispose(), await I.deactivate(), await jn?.close(), await Se({
1757
- mirror: bt,
1757
+ await Z.close(), ot(), Ft?.dispose(), await L.deactivate(), await An?.close(), await Ce({
1758
+ mirror: yt,
1758
1759
  log: $
1759
- }), await je.dispose(), await b.close?.();
1760
+ }), await Me.dispose(), await b.close?.();
1760
1761
  } catch (e) {
1761
1762
  console.error("serve: shutdown step failed, exiting anyway:", e);
1762
1763
  }