@voltro/cli 0.46.0 → 0.48.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 (96) hide show
  1. package/CHANGELOG.md +110 -0
  2. package/dist/apiBuild-DOnvi2zm.js +2 -0
  3. package/dist/{apiBuild-BKdd0I1Z.js → apiBuild-Dz8TJSxp.js} +1 -1
  4. package/dist/bin.js +1 -1
  5. package/dist/{build-co6yadYz.js → build-DLme2ppa.js} +7 -7
  6. package/dist/{checkCommand-CXAXTjZL.js → checkCommand-BUBqPBlI.js} +1 -1
  7. package/dist/{checkCommand-B-eiW-G_.js → checkCommand-Dals7g-I.js} +4 -4
  8. package/dist/{codegen-sbN1Y8PB.js → codegen-CrMXs4hb.js} +176 -162
  9. package/dist/codegen-DiMn2KkZ.js +2 -0
  10. package/dist/{codegenCommand-CB6_3sX0.js → codegenCommand-L6vacVRW.js} +4 -3
  11. package/dist/{commands-C-hxgAGr.js → commands-CAxFLqG4.js} +18 -18
  12. package/dist/{dashboardCommand-CEVO0GWF.js → dashboardCommand-CJC8Kg-s.js} +1 -1
  13. package/dist/{dataCommand-k0ezbQWa.js → dataCommand-hIaq2iKY.js} +266 -189
  14. package/dist/dbCommand-D1Q33ktl.js +2 -0
  15. package/dist/{dbCommand-BwkyNxn-.js → dbCommand-ZGNItjoJ.js} +4 -4
  16. package/dist/declaredSchemaGates-BlcwObhb.js +25 -0
  17. package/dist/{dev-DyoYst4j.js → dev-cGGsLNn6.js} +1 -1
  18. package/dist/{dev-8hTEnN6s.js → dev-lvnVq5RD.js} +32 -31
  19. package/dist/{doctorCommand-B6D7HH1-.js → doctorCommand-BK0qu7eD.js} +34 -16
  20. package/dist/doctorCommand-CWgUPye-.js +2 -0
  21. package/dist/doctorDecidedSchema-BlbWgCD_.js +23 -0
  22. package/dist/{doctorSourceRelations-CPjSwYuZ.js → doctorSourceRelations-Dd48LPvO.js} +15 -10
  23. package/dist/{dormancyCommand-CrPAwOgo.js → dormancyCommand-CyIk-zq4.js} +1 -1
  24. package/dist/{embeddingsCommand-DsSxsn_b.js → embeddingsCommand-D7TLklps.js} +1 -1
  25. package/dist/{envCommand-B_NPVGUf.js → envCommand-BHxKkGXq.js} +1 -1
  26. package/dist/{evolveCommand-DUuaCIyn.js → evolveCommand-CQh6dw21.js} +1 -1
  27. package/dist/{frameworkTableAssembly-BPlPfU07.js → frameworkTableAssembly-BNod_DKN.js} +124 -143
  28. package/dist/frameworkTableAssembly-Rft-DPUg.js +2 -0
  29. package/dist/index.js +1 -1
  30. package/dist/{migrate-CM1qwalu.js → migrate-CL5Ed01M.js} +4 -4
  31. package/dist/{runtimeTrace-BRNM06vK.js → runtimeTrace-C0SlIoQY.js} +1 -1
  32. package/dist/{sdkgen-CRCw_XcR.js → sdkgen-BXm7zx7F.js} +1 -1
  33. package/dist/{serveCommand-CHOr74WM.js → serveCommand-CV3YO9L3.js} +676 -569
  34. package/dist/serveCommand-ZP_Cb-yz.js +2 -0
  35. package/dist/serveEntry.js +1 -1
  36. package/dist/{test-CHb7UwvE.js → test-rXFq4S76.js} +1 -1
  37. package/dist/{webhooksCommand-BRrG_sGf.js → webhooksCommand-QlAk_tED.js} +1 -1
  38. package/package.json +17 -17
  39. package/templates/AGENTS.md +1 -1
  40. package/templates/agent-docs/_index.md +1 -1
  41. package/templates/agent-docs/cli.md +86 -3
  42. package/templates/agent-docs/database/migrations.md +19 -5
  43. package/templates/agent-docs/whats-new.md +39 -135
  44. package/templates/apps/api-ai/package.json +7 -7
  45. package/templates/apps/api-auth/package.json +8 -8
  46. package/templates/apps/api-backend/package.json +7 -7
  47. package/templates/apps/api-backend-deactivation/package.json +7 -7
  48. package/templates/apps/api-backend-mail/package.json +8 -8
  49. package/templates/apps/api-backend-mariadb/package.json +9 -9
  50. package/templates/apps/api-backend-sqlite/package.json +8 -8
  51. package/templates/apps/api-backend-storage/package.json +8 -8
  52. package/templates/apps/api-cms/package.json +10 -10
  53. package/templates/apps/api-collab/package.json +8 -8
  54. package/templates/apps/api-data-advanced/package.json +8 -8
  55. package/templates/apps/api-durable/package.json +8 -8
  56. package/templates/apps/api-feature-flags/package.json +9 -9
  57. package/templates/apps/api-governance/package.json +8 -8
  58. package/templates/apps/api-kv/package.json +8 -8
  59. package/templates/apps/api-moderation/package.json +8 -8
  60. package/templates/apps/api-observability/package.json +8 -8
  61. package/templates/apps/api-ratelimit/package.json +8 -8
  62. package/templates/apps/api-rbac/package.json +8 -8
  63. package/templates/apps/api-rest/package.json +7 -7
  64. package/templates/apps/api-saas/package.json +11 -11
  65. package/templates/apps/api-saas-starter/package.json +10 -10
  66. package/templates/apps/api-search/package.json +8 -8
  67. package/templates/apps/api-status/package.json +8 -8
  68. package/templates/apps/api-versioning/package.json +8 -8
  69. package/templates/apps/api-webhooks/package.json +9 -9
  70. package/templates/apps/changelog/package.json +6 -6
  71. package/templates/apps/edge-functions/package.json +2 -2
  72. package/templates/apps/frontend-admin/package.json +8 -8
  73. package/templates/apps/frontend-app/package.json +9 -9
  74. package/templates/apps/frontend-auth/package.json +8 -8
  75. package/templates/apps/frontend-blank/package.json +7 -7
  76. package/templates/apps/frontend-cms/package.json +9 -9
  77. package/templates/apps/frontend-collab/package.json +10 -10
  78. package/templates/apps/frontend-contact/package.json +7 -7
  79. package/templates/apps/frontend-dashboard/package.json +7 -7
  80. package/templates/apps/frontend-docs/package.json +7 -7
  81. package/templates/apps/frontend-i18n/package.json +6 -6
  82. package/templates/apps/frontend-landing/package.json +7 -7
  83. package/templates/apps/frontend-portal/package.json +8 -8
  84. package/templates/apps/frontend-saas/package.json +8 -8
  85. package/templates/apps/frontend-spa/package.json +7 -7
  86. package/templates/apps/frontend-ssr/package.json +7 -7
  87. package/templates/apps/frontend-ssr-api/package.json +8 -8
  88. package/templates/apps/frontend-static-blog/package.json +6 -6
  89. package/templates/apps/frontend-status/package.json +8 -8
  90. package/templates/apps/mobile-app/package.json +4 -4
  91. package/dist/apiBuild-P2gewrfQ.js +0 -2
  92. package/dist/codegen-DcE2li1i.js +0 -2
  93. package/dist/dbCommand-C2XK63Dd.js +0 -2
  94. package/dist/doctorCommand-Btl2Jz1a.js +0 -2
  95. package/dist/frameworkTableAssembly-Bob3vj9R.js +0 -2
  96. package/dist/serveCommand-BNHMVXyp.js +0 -2
@@ -4,46 +4,47 @@ import { r as n, t as r } from "./appModuleLoader-C9r9mxZt.js";
4
4
  import { t as i } from "./bootRefusal-pgvDxlrU.js";
5
5
  import { n as a, r as o } from "./startupRunner-CEqQq7ax.js";
6
6
  import { t as ee } from "./interruptedReplace-C1ZI84xi.js";
7
- import { $ as s, $t as c, A as l, At as u, Bt as d, C as f, Cn as p, Ct as m, D as h, Dt as g, E as _, En as te, Et as v, F as ne, Ft as re, G as ie, Gt as ae, H as y, Ht as oe, I as se, It as ce, J as le, Jt as b, K as x, Kt as ue, L as S, Lt as de, M as fe, Mt as pe, N as me, Nt as he, O as ge, Ot as _e, P as ve, Pt as ye, Q as be, Qt as xe, R as C, Rt as Se, S as Ce, St as we, T as Te, Tn as Ee, Tt as w, U as De, V as Oe, W as ke, Wt as Ae, X as je, Xt as Me, Y as Ne, Yt as T, Z as Pe, Zt as Fe, _ as E, _n as Ie, _t as D, an as Le, at as Re, b as ze, bn as Be, bt as Ve, c as He, cn as Ue, ct as We, dn as Ge, dt as Ke, en as qe, et as Je, f as Ye, fn as Xe, ft as Ze, g as Qe, gt as $e, h as et, hn as tt, ht as nt, i as rt, 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 O, o as k, on as gt, ot as A, p as j, pn as _t, pt as vt, q as yt, qt as bt, r as xt, rn as St, rt as Ct, sn as M, st as wt, t as Tt, tn as Et, tt as Dt, u as Ot, un as kt, ut as At, v as jt, vn as Mt, vt as N, w as P, wn as Nt, wt as Pt, x as Ft, xn as It, xt as Lt, y as Rt, yn as zt, yt as Bt, zt as Vt } from "./dev-8hTEnN6s.js";
8
- import { n as Ht } from "./cliArgs-D4p8n7EE.js";
9
- import { r as F } from "./appPort-B_HpJ_ck.js";
10
- import { ht as Ut, pt as Wt } from "./webDev-B4IEMB0n.js";
11
- import { r as I } from "./dialectDriver-czCHYpeH.js";
12
- import { i as Gt, n as Kt } from "./connectionConfig-Bk9IC7D0.js";
13
- import { c as qt, n as L, o as Jt } from "./seedRunner-Dgsiwk_e.js";
14
- import { C as Yt, S as Xt, _ as Zt, d as Qt, g as $t, l as en, m as tn, r as nn, u as rn, v as an } from "./frameworkTableAssembly-BPlPfU07.js";
15
- import { S as on, c as sn, n as cn, p as ln, s as un, x as dn } from "./fileConventions-Cof68_BL.js";
16
- import { h as fn, o as pn } from "./inspect-B7U7Cl_Z.js";
17
- import { n as mn } from "./mssqlClusterPatch-_4cE_nun.js";
18
- import { i as hn, n as gn, r as _n, t as vn } from "./webhookDiscovery-CphsQe59.js";
19
- import { t as yn } from "./inspectMetrics-CfdKLh6t.js";
20
- import { r as bn, u as xn } from "./apiBuild-BKdd0I1Z.js";
21
- import { t as Sn } from "./bootTiming-BdyP9nYw.js";
22
- import { t as Cn } from "./dataProfile-Cm0YVKSy.js";
23
- import wn, { basename as Tn, join as En } from "node:path";
24
- import { createWriteStream as Dn, existsSync as On } from "node:fs";
25
- import { pathToFileURL as kn } from "node:url";
26
- import { createLogger as R } from "@voltro/logger";
27
- import { AuthMiddleware as An, ConnectionInfoMiddleware as jn, actionToRpc as z, anonymousSubject as Mn, isWireReachable as Nn, mutationToRpc as Pn, queryToRpc as B, streamToRpc as Fn, wireErrorUnion as In, workflowCancelDescriptor as Ln, workflowDomainEventsQueryDescriptor as Rn, workflowEventDeliveriesQueryDescriptor as V, workflowResumeDescriptor as zn, workflowRunEventsQueryDescriptor as Bn, workflowRunQueryDescriptor as Vn, workflowRunStepsQueryDescriptor as Hn, workflowRunsQueryDescriptor as Un, workflowSignalDescriptor as Wn, workflowUpdateDescriptor as Gn } from "@voltro/protocol";
28
- import { allRegisteredTables as Kn, and as H, connectionIdentity as qn, ensureTableRegistered as Jn, eq as U, or as Yn } from "@voltro/database";
29
- import { Cause as Xn, Effect as W, Layer as G, ManagedRuntime as Zn } from "effect";
30
- import { SqlClient as Qn } from "@effect/sql";
31
- import { declaredSnapshot as $n, describeOutcome as er, pendingFileMigrationIds as tr, runPlannedMigrations as nr } from "@voltro/database/sql";
32
- import { AggregateRegistry as rr, CostRegistry as ir, DORMANCY_WAKEUP_TENANT as ar, Dispatcher as or, ExpectationRegistry as sr, ExperimentRegistry as cr, apiKeyManagementRoutes as lr, attachAnalyticsMirror as ur, attachExpectations as dr, attachExperiments as fr, attachFinops as pr, awaitServerListening as mr, bindMutation as K, bindStream as hr, bindSubscription as q, buildTracingLayer as gr, cancelWakeup as _r, compileCron as vr, dataStoreApiKeyStore as yr, formatServerOnlyLeaks as br, formatUnresolvedSources as xr, frameworkApiKeyStrategy as Sr, getResourcePolicy as Cr, installPolicyGuardResolver as wr, loadResourceTuples as Tr, makeActionRunner as Er, makeAdvisoryLockCoordinator as Dr, makeApiKeyService as Or, makeApiKeyUsageBuffer as kr, makeApiKeyUsageFlusher as Ar, makeAsyncKv as jr, makeAuthMiddlewareLayers as Mr, makeCoordinatedScheduler as Nr, makeEffectStoreLayer as Pr, makeLazyWorkflowFacade as Fr, makeMutationOutputCodec as Ir, makeMutationRunner as Lr, makeOneShotQueryRunner as Rr, makeQueryDescriptorProducer as zr, makeQueryFinalizer as Br, makeQueryReauthorizer as Vr, makeQuerySubscriber as Hr, makeSchemaRegistry as Ur, makeWorkflowFacade as J, makeWorkflowFacadeWithCallerContext as Wr, makeWorkflowLayers as Gr, noopKv as Kr, onProcessShutdown as qr, recordSubscriptionDelivery as Jr, recordWorkflowRun as Yr, registerDefaultTupleSource as Xr, registerWakeup as Zr, resolveSecretsBackend as Qr, runProvidedEffect as Y, setSecretsBackend as $r, setSystemStoreHandle as ei, shutdownGraceMsFromEnv as ti, singleCoordinator as ni, startRpcServer as ri, startScheduler as ii, stripForbiddenForWire as ai, undoCaptureEnabled as oi, unresolvedSources as si, withScopedRequest as ci, workflowToRpc as li, wrapStoreWithBootCodec as ui } from "@voltro/runtime";
33
- import di, { tmpdir as fi } from "node:os";
34
- import { RpcGroup as pi } from "@effect/rpc";
35
- import { appStorageProvider as mi, fromNodeReadable as hi, getObjectStream as gi, putObjectStream as _i, toNodeReadable as vi } from "@voltro/plugin-storage";
36
- import { isEnvContract as yi } from "@voltro/env";
37
- import { assertProductionSessionSecret as bi } from "@voltro/protocol/session";
7
+ import { $ as s, $t as c, A as l, At as u, Bt as d, C as f, Cn as p, Ct as m, D as h, Dt as g, E as _, En as te, Et as v, F as ne, Ft as re, G as ie, Gt as ae, H as y, Ht as oe, I as se, It as ce, J as le, Jt as b, K as x, Kt as ue, L as S, Lt as de, M as fe, Mt as pe, N as me, Nt as he, O as ge, Ot as _e, P as ve, Pt as ye, Q as be, Qt as xe, R as C, Rt as Se, S as Ce, St as we, T as Te, Tn as Ee, Tt as w, U as De, V as Oe, W as ke, Wt as Ae, X as je, Xt as Me, Y as Ne, Yt as T, Z as Pe, Zt as Fe, _ as E, _n as Ie, _t as Le, an as Re, at as ze, b as Be, bn as Ve, bt as He, c as Ue, cn as We, ct as Ge, dn as Ke, dt as qe, en as Je, et as Ye, f as Xe, fn as Ze, ft as Qe, g as $e, gt as et, h as tt, hn as nt, ht as rt, i as it, in as at, it as ot, j as st, jt as ct, k as lt, kt as ut, ln as dt, lt as ft, m as pt, mn as mt, mt as ht, nn as gt, nt as D, o as O, on as _t, ot as k, p as A, pn as vt, pt as yt, q as bt, qt as xt, r as St, rn as Ct, rt as wt, sn as j, st as Tt, t as Et, tn as Dt, tt as Ot, u as kt, un as At, ut as jt, v as Mt, vn as Nt, vt as M, w as N, wn as Pt, wt as Ft, x as It, xn as Lt, xt as Rt, y as zt, yn as Bt, yt as Vt, zt as Ht } from "./dev-lvnVq5RD.js";
8
+ import { n as Ut } from "./cliArgs-D4p8n7EE.js";
9
+ import { r as P } from "./appPort-B_HpJ_ck.js";
10
+ import { ht as Wt, pt as Gt } from "./webDev-B4IEMB0n.js";
11
+ import { r as F } from "./dialectDriver-czCHYpeH.js";
12
+ import { i as Kt, n as qt } from "./connectionConfig-Bk9IC7D0.js";
13
+ import { c as Jt, n as I, o as Yt } from "./seedRunner-Dgsiwk_e.js";
14
+ import { b as Xt, d as Zt, h as Qt, m as $t, p as en, r as tn, y as nn } from "./frameworkTableAssembly-BNod_DKN.js";
15
+ import { n as rn, r as an, t as on } from "./declaredSchemaGates-BlcwObhb.js";
16
+ import { S as sn, c as cn, n as ln, p as un, s as dn, x as fn } from "./fileConventions-Cof68_BL.js";
17
+ import { h as pn, o as mn } from "./inspect-B7U7Cl_Z.js";
18
+ import { n as hn } from "./mssqlClusterPatch-_4cE_nun.js";
19
+ import { i as gn, n as _n, r as vn, t as yn } from "./webhookDiscovery-CphsQe59.js";
20
+ import { t as bn } from "./inspectMetrics-CfdKLh6t.js";
21
+ import { r as xn, u as Sn } from "./apiBuild-Dz8TJSxp.js";
22
+ import { t as Cn } from "./bootTiming-BdyP9nYw.js";
23
+ import { t as wn } from "./dataProfile-Cm0YVKSy.js";
24
+ import Tn, { basename as En, join as Dn } from "node:path";
25
+ import { createWriteStream as On, existsSync as kn } from "node:fs";
26
+ import { pathToFileURL as An } from "node:url";
27
+ import { createLogger as L } from "@voltro/logger";
28
+ import { AuthMiddleware as jn, ConnectionInfoMiddleware as Mn, actionToRpc as R, anonymousSubject as Nn, isWireReachable as Pn, mutationToRpc as Fn, queryToRpc as z, streamToRpc as In, wireErrorUnion as Ln, workflowCancelDescriptor as Rn, workflowDomainEventsQueryDescriptor as B, workflowEventDeliveriesQueryDescriptor as V, workflowResumeDescriptor as zn, workflowRunEventsQueryDescriptor as Bn, workflowRunQueryDescriptor as Vn, workflowRunStepsQueryDescriptor as Hn, workflowRunsQueryDescriptor as Un, workflowSignalDescriptor as Wn, workflowUpdateDescriptor as Gn } from "@voltro/protocol";
29
+ import { IMPORT_RUNS_TABLE as H, allRegisteredTables as Kn, and as qn, connectionIdentity as Jn, describeImportRun as Yn, ensureTableRegistered as Xn, eq as U, or as Zn } from "@voltro/database";
30
+ import { Cause as Qn, Effect as W, Layer as G, ManagedRuntime as $n } from "effect";
31
+ import { SqlClient as er } from "@effect/sql";
32
+ import { declaredSnapshot as tr, describeOutcome as nr, pendingFileMigrationIds as rr, runPlannedMigrations as ir } from "@voltro/database/sql";
33
+ import { AggregateRegistry as ar, CostRegistry as K, DORMANCY_WAKEUP_TENANT as or, Dispatcher as sr, ExpectationRegistry as cr, ExperimentRegistry as lr, apiKeyManagementRoutes as ur, attachAnalyticsMirror as dr, attachExpectations as fr, attachExperiments as pr, attachFinops as mr, awaitServerListening as hr, bindMutation as q, bindStream as gr, bindSubscription as _r, buildTracingLayer as vr, cancelWakeup as yr, compileCron as br, dataStoreApiKeyStore as xr, formatServerOnlyLeaks as Sr, formatUnresolvedSources as Cr, frameworkApiKeyStrategy as wr, getResourcePolicy as Tr, installPolicyGuardResolver as Er, loadResourceTuples as Dr, makeActionRunner as Or, makeAdvisoryLockCoordinator as kr, makeApiKeyService as Ar, makeApiKeyUsageBuffer as jr, makeApiKeyUsageFlusher as Mr, makeAsyncKv as Nr, makeAuthMiddlewareLayers as Pr, makeCoordinatedScheduler as Fr, makeEffectStoreLayer as Ir, makeLazyWorkflowFacade as Lr, makeMutationOutputCodec as Rr, makeMutationRunner as zr, makeOneShotQueryRunner as Br, makeQueryDescriptorProducer as Vr, makeQueryFinalizer as Hr, makeQueryReauthorizer as J, makeQuerySubscriber as Ur, makeSchemaRegistry as Wr, makeWorkflowFacade as Gr, makeWorkflowFacadeWithCallerContext as Kr, makeWorkflowLayers as qr, noopKv as Jr, onProcessShutdown as Yr, recordSubscriptionDelivery as Xr, recordWorkflowRun as Zr, registerDefaultTupleSource as Y, registerWakeup as Qr, resolveSecretsBackend as $r, runProvidedEffect as ei, setSecretsBackend as ti, setSystemStoreHandle as ni, shutdownGraceMsFromEnv as ri, singleCoordinator as ii, startRpcServer as ai, startScheduler as oi, stripForbiddenForWire as si, undoCaptureEnabled as ci, unresolvedSources as li, withScopedRequest as ui, workflowToRpc as di, wrapStoreWithBootCodec as fi } from "@voltro/runtime";
34
+ import pi, { tmpdir as mi } from "node:os";
35
+ import { RpcGroup as hi } from "@effect/rpc";
36
+ import { appStorageProvider as gi, durabilityNotice as _i, fromNodeReadable as vi, getObjectStream as yi, putObjectStream as bi, toNodeReadable as xi } from "@voltro/plugin-storage";
37
+ import { isEnvContract as Si } from "@voltro/env";
38
+ import { assertProductionSessionSecret as Ci } from "@voltro/protocol/session";
38
39
  import X from "node:fs/promises";
39
- import { createHash as xi, timingSafeEqual as Si } from "node:crypto";
40
- import { buildDeliverWebhookExecute as Ci, buildWebhooksService as wi, defaultIncomingPath as Ti, deliverWebhookWorkflow as Ei, makeDeferredEmitHandler as Di, mountIncomingWebhook as Oi } from "@voltro/plugin-webhooks";
41
- import { getAuthSessionStrategy as ki } from "@voltro/plugin-auth";
42
- import { registerEmailTemplates as Ai } from "@voltro/plugin-mail";
43
- import { channelFor as ji, getBroadcastPlugin as Mi } from "@voltro/plugin-broadcast";
44
- import { packBundle as Ni, runExport as Pi, runImport as Fi, storageBlobSink as Ii, storageRefsBlobSource as Li, unpackBundle as Ri, unpackBundleToDir as zi } from "@voltro/data-transfer";
40
+ import { createHash as wi, timingSafeEqual as Ti } from "node:crypto";
41
+ import { buildDeliverWebhookExecute as Ei, buildWebhooksService as Di, defaultIncomingPath as Oi, deliverWebhookWorkflow as ki, makeDeferredEmitHandler as Ai, mountIncomingWebhook as ji } from "@voltro/plugin-webhooks";
42
+ import { getAuthSessionStrategy as Mi } from "@voltro/plugin-auth";
43
+ import { registerEmailTemplates as Ni } from "@voltro/plugin-mail";
44
+ import { channelFor as Pi, getBroadcastPlugin as Fi } from "@voltro/plugin-broadcast";
45
+ import { decideStaging as Ii, isEnvironmentLocal as Li, packBundle as Ri, peekBundle as zi, runExport as Bi, runImport as Vi, storageBlobSink as Hi, storageRefsBlobSource as Ui, unpackBundle as Wi, unpackBundleToDir as Gi } from "@voltro/data-transfer";
45
46
  //#region src/serveDrain.ts
46
- var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t) => setTimeout(t, e)), Hi = (e) => {
47
+ var Ki = () => Math.max(500, Math.floor(ri() * .6)), qi = (e) => new Promise((t) => setTimeout(t, e)), Ji = (e) => {
47
48
  let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), r = 0;
48
49
  e.on("connection", (e) => {
49
50
  t.add(e), e.once("close", () => {
@@ -57,14 +58,14 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
57
58
  });
58
59
  });
59
60
  let i, a = async (t = {}) => {
60
- let n = t.budgetMs ?? Bi();
61
+ let n = t.budgetMs ?? Ki();
61
62
  i ??= new Promise((t) => {
62
63
  e.close(() => {
63
64
  t();
64
65
  });
65
66
  }), e.closeIdleConnections();
66
67
  let a = Date.now() + n;
67
- for (; r > 0 && Date.now() < a;) await Vi(25), e.closeIdleConnections();
68
+ for (; r > 0 && Date.now() < a;) await qi(25), e.closeIdleConnections();
68
69
  e.closeIdleConnections();
69
70
  }, o = async () => {
70
71
  i ??= new Promise((t) => {
@@ -81,7 +82,7 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
81
82
  ]));
82
83
  } catch {}
83
84
  else e.destroy();
84
- for (let e = 0; t.size > 0 && e < 250; e += 25) await Vi(25);
85
+ for (let e = 0; t.size > 0 && e < 250; e += 25) await qi(25);
85
86
  for (let e of t) e.destroy();
86
87
  await i;
87
88
  };
@@ -93,77 +94,77 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
93
94
  await a(e), await o();
94
95
  }
95
96
  };
96
- }, Ui = "/_voltro/admin/import", Wi = "/_voltro/admin/export", Z = (e, t) => ({
97
+ }, Yi = "/_voltro/admin/import", Xi = "/_voltro/admin/export", Zi = "/_voltro/admin/imports", Z = (e, t) => ({
97
98
  status: e,
98
99
  contentType: "application/json; charset=utf-8",
99
100
  body: JSON.stringify(t)
100
- }), Gi = (e) => {
101
+ }), Qi = (e) => {
101
102
  let t = e.authorization ?? e.Authorization, n = t ? /^Bearer\s+(.+)$/i.exec(t) : null;
102
103
  return n ? n[1] : null;
103
- }, Ki = (e, t) => Si(xi("sha256").update(e).digest(), xi("sha256").update(t).digest()), qi = (e, t) => {
104
- if (e.method.toUpperCase() !== "POST") return Z(405, { error: "method not allowed" });
104
+ }, $i = (e, t) => Ti(wi("sha256").update(e).digest(), wi("sha256").update(t).digest()), ea = (e, t, n = "POST") => {
105
+ if (e.method.toUpperCase() !== n) return Z(405, { error: "method not allowed" });
105
106
  if (!t || t.length < 16) return Z(503, { error: "data transfer misconfigured (no/weak secret)" });
106
- let n = Gi(e.headers);
107
- return !n || !Ki(n, t) ? Z(401, { error: "unauthorized" }) : null;
108
- }, Ji = /^[A-Za-z0-9_-]{8,64}$/, Yi = (e) => Ji.test(e), Xi = () => wn.join(di.tmpdir(), "voltro-import-uploads"), Zi = (e) => wn.join(Xi(), e), Qi = (e) => wn.join(Zi(e), "archive.bin"), $i = (e) => wn.join(Zi(e), "meta.json"), ea = async (e = Date.now()) => {
107
+ let r = Qi(e.headers);
108
+ return !r || !$i(r, t) ? Z(401, { error: "unauthorized" }) : null;
109
+ }, ta = /^[A-Za-z0-9_-]{8,64}$/, na = (e) => ta.test(e), ra = () => Tn.join(pi.tmpdir(), "voltro-import-uploads"), ia = (e) => Tn.join(ra(), e), aa = (e) => Tn.join(ia(e), "archive.bin"), oa = (e) => Tn.join(ia(e), "meta.json"), sa = async (e = Date.now()) => {
109
110
  let t = 0;
110
111
  try {
111
- for (let n of await X.readdir(Xi())) {
112
- let r = await X.stat(Zi(n)).catch(() => null);
113
- r !== null && (e - r.mtimeMs <= 864e5 || (await X.rm(Zi(n), {
112
+ for (let n of await X.readdir(ra())) {
113
+ let r = await X.stat(ia(n)).catch(() => null);
114
+ r !== null && (e - r.mtimeMs <= 864e5 || (await X.rm(ia(n), {
114
115
  recursive: !0,
115
116
  force: !0
116
117
  }).catch(() => void 0), t++));
117
118
  }
118
119
  } catch {}
119
120
  return t;
120
- }, ta = async (e) => {
121
- if (!Yi(e)) return {
121
+ }, ca = async (e) => {
122
+ if (!na(e)) return {
122
123
  bytes: 0,
123
124
  key: null
124
125
  };
125
- let t = await X.stat(Qi(e)).catch(() => null);
126
+ let t = await X.stat(aa(e)).catch(() => null);
126
127
  if (t === null) return {
127
128
  bytes: 0,
128
129
  key: null
129
130
  };
130
- let n = await X.readFile($i(e), "utf8").then((e) => JSON.parse(e), () => ({}));
131
+ let n = await X.readFile(oa(e), "utf8").then((e) => JSON.parse(e), () => ({}));
131
132
  return {
132
133
  bytes: t.size,
133
134
  key: n.key ?? null
134
135
  };
135
- }, na = async (e) => {
136
- if (!Yi(e.id)) return {
136
+ }, la = async (e) => {
137
+ if (!na(e.id)) return {
137
138
  reason: "bad-id",
138
- message: `upload id must match ${String(Ji)}`
139
+ message: `upload id must match ${String(ta)}`
139
140
  };
140
- let t = await ta(e.id);
141
+ let t = await ca(e.id);
141
142
  return t.key !== null && t.key !== e.key ? {
142
143
  reason: "key-mismatch",
143
144
  message: "this upload id already holds a different bundle. Use a new upload id, or delete the partial upload."
144
- } : e.offset === t.bytes ? (await X.mkdir(Zi(e.id), { recursive: !0 }), t.key === null && await X.writeFile($i(e.id), JSON.stringify({
145
+ } : e.offset === t.bytes ? (await X.mkdir(ia(e.id), { recursive: !0 }), t.key === null && await X.writeFile(oa(e.id), JSON.stringify({
145
146
  key: e.key,
146
147
  startedAt: (/* @__PURE__ */ new Date()).toISOString()
147
148
  })), await new Promise((t, n) => {
148
- let r = Dn(Qi(e.id), { flags: "a" });
149
+ let r = On(aa(e.id), { flags: "a" });
149
150
  r.on("error", n), r.on("finish", () => t()), r.end(Buffer.from(e.bytes));
150
151
  }), { total: t.bytes + e.bytes.byteLength }) : {
151
152
  reason: "offset-mismatch",
152
153
  message: `chunk starts at ${e.offset} but the server holds ${t.bytes} byte(s)`,
153
154
  expectedOffset: t.bytes
154
155
  };
155
- }, ra = async (e) => {
156
- let t = await X.stat(Qi(e));
156
+ }, ua = async (e) => {
157
+ let t = await X.stat(aa(e));
157
158
  return {
158
- path: Qi(e),
159
+ path: aa(e),
159
160
  bytes: t.size
160
161
  };
161
- }, ia = async (e) => {
162
- Yi(e) && await X.rm(Zi(e), {
162
+ }, da = async (e) => {
163
+ na(e) && await X.rm(ia(e), {
163
164
  recursive: !0,
164
165
  force: !0
165
166
  }).catch(() => void 0);
166
- }, Q = R({ scope: "voltro:admin-import" }), aa = "VBUNDLE2", oa = (e) => {
167
+ }, Q = L({ scope: "voltro:admin-import" }), fa = "VBUNDLE2", pa = (e) => {
167
168
  let t = e.req.headers["x-import-rollback-key"];
168
169
  if (e.mode !== "replace") return { options: {} };
169
170
  if (typeof t != "string" || t.length === 0) return Q.warn("admin.import: no rollback capture — this run empties the target first, and nothing was asked to be kept. Send `x-import-rollback-key: <storage key>` (voltro data import --rollback-key <key>) to have the instance store the target's current rows before deleting them."), { options: {} };
@@ -171,39 +172,81 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
171
172
  options: {},
172
173
  refusal: Z(409, {
173
174
  error: "rollback capture requested but this instance has no object storage configured",
174
- hint: "A capture written to the pod would not survive the failure it exists for. Configure storage (the same one the storage-push export uses), or re-send without `x-import-rollback-key` to accept that a run which does not finish can leave the target emptied."
175
+ hint: "A capture written to the pod would not survive the failure it exists for. Configure storage (the same one the storage-push export uses), or re-send without `x-import-rollback-key` to accept that a run which does not finish can leave the target emptied. Note that CONFIGURED is not the same question as SURVIVES: a `filesystem` provider pointed at a container directory with no volume behind it passes this check and dies with the pod. The run says so when it can observe it — the capture path being on the same filesystem as `/`."
175
176
  })
176
177
  };
177
- let n = En(fi(), `voltro-rollback-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`), r = e.deps.putArchive;
178
+ let n = Dn(mi(), `voltro-rollback-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`), r = e.deps.putArchive;
178
179
  return {
179
180
  key: t,
180
181
  options: {
181
182
  rollbackDir: n,
182
183
  onRollbackCaptured: async () => {
183
- await r(t, () => Ni({ dir: n })), Q.info("admin.import: rollback capture stored", { bundleKey: t });
184
+ let e = _i(n);
185
+ e !== void 0 && Q.warn(`admin.import: ${e}`), await r(t, () => Ri({ dir: n })), Q.info("admin.import: rollback capture stored", { bundleKey: t });
184
186
  }
185
187
  }
186
188
  };
187
- }, sa = async function* (e) {
189
+ }, ma = async function* (e) {
188
190
  yield e;
189
- }, ca = (e) => async (t) => {
190
- let n = qi(t, e.secret);
191
+ }, ha = (e) => async (t) => {
192
+ let n = ea(t, e.secret);
191
193
  if (n) return n;
192
- let r = t.headers["x-import-mode"], i = t.headers["x-import-on-conflict"], a = t.headers["x-import-atomic"], o = a === "0" || a === "false" ? !1 : a === "1" || a === "true" || r === "replace", ee = t.headers["x-import-force"] === "1" || t.headers["x-import-force"] === "true", s = oa({
194
+ let r = t.headers["x-import-mode"], i = t.headers["x-import-on-conflict"], a = t.headers["x-import-atomic"], o = a === "0" || a === "false" ? !1 : a === "1" || a === "true" || r === "replace", ee = t.headers["x-import-force"] === "1" || t.headers["x-import-force"] === "true", s = pa({
193
195
  req: t,
194
196
  mode: r,
195
197
  deps: e
196
198
  });
197
199
  if (s.refusal !== void 0) return s.refusal;
198
- let c = t.headers["x-import-dry-run"] === "1" || t.headers["x-import-dry-run"] === "true", l = (t.headers["x-import-tables"] ?? "").split(",").map((e) => e.trim()).filter(Boolean), u = t.headers["x-import-upload-id"], d;
200
+ let c = t.headers["x-import-dry-run"] === "1" || t.headers["x-import-dry-run"] === "true", l = (t.headers["x-import-tables"] ?? "").split(",").map((e) => e.trim()).filter(Boolean);
201
+ if (t.headers["x-import-preflight"] === "1" || t.headers["x-import-preflight"] === "true") {
202
+ let n;
203
+ try {
204
+ n = JSON.parse(Buffer.from(t.rawBody).toString("utf8") || "{}");
205
+ } catch {
206
+ return Z(400, { error: "a preflight body must be JSON: { tables: string[] } or { bundleKey: string }" });
207
+ }
208
+ let i = Array.isArray(n.tables) ? n.tables.filter((e) => typeof e == "string") : [];
209
+ if (i.length === 0 && typeof n.bundleKey == "string" && n.bundleKey !== "" && e.openArchive) {
210
+ let t = await zi(e.openArchive(n.bundleKey), ["manifest.json"]).then((e) => e.get("manifest.json"), () => void 0);
211
+ if (t !== void 0) try {
212
+ i = (JSON.parse(Buffer.from(t).toString("utf8")).tables ?? []).map((e) => e.name).filter((e) => typeof e == "string");
213
+ } catch {}
214
+ }
215
+ if (i.length === 0) return Z(400, {
216
+ error: "a preflight needs { tables: string[] } — the bundle's table names, so the staging decision can be made against them",
217
+ hint: "or { bundleKey } on an instance with storage configured, where this endpoint reads the table list out of the archive itself"
218
+ });
219
+ let a = Ii({
220
+ mode: r ?? "upsert",
221
+ ...e.dialect === void 0 ? {} : { targetDialect: e.dialect },
222
+ ...e.snapshot === void 0 ? {} : { targetSnapshot: e.snapshot },
223
+ bundleTables: i,
224
+ isSkipped: Li,
225
+ canRunSql: !0
226
+ });
227
+ return Z(200, {
228
+ preflight: !0,
229
+ mode: r ?? "upsert",
230
+ atomic: o,
231
+ staged: a.active,
232
+ ...a.blocker === void 0 ? {} : { reason: a.blocker },
233
+ stagedTables: a.tables.length,
234
+ rollback: s.key === void 0 ? { taken: !1 } : {
235
+ taken: !0,
236
+ key: s.key
237
+ },
238
+ dialect: e.dialect ?? null
239
+ });
240
+ }
241
+ let u = t.headers["x-import-upload-id"], d;
199
242
  if (u !== void 0 && u !== "") {
200
- if (ea(), t.headers["x-import-probe"] === "1") return Z(200, {
243
+ if (sa(), t.headers["x-import-probe"] === "1") return Z(200, {
201
244
  uploadId: u,
202
- bytes: (await ta(u)).bytes
245
+ bytes: (await ca(u)).bytes
203
246
  });
204
247
  let e = t.headers["x-import-upload-key"] ?? "", n = Number(t.headers["x-import-chunk-offset"] ?? "0");
205
248
  if (e === "" || !Number.isFinite(n) || n < 0) return Z(400, { error: "a chunked upload needs x-import-upload-key and a numeric x-import-chunk-offset" });
206
- let r = await na({
249
+ let r = await la({
207
250
  id: u,
208
251
  key: e,
209
252
  offset: n,
@@ -222,13 +265,13 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
222
265
  uploadId: u,
223
266
  bytes: r.total
224
267
  });
225
- d = (await ra(u)).path;
268
+ d = (await ua(u)).path;
226
269
  }
227
- let f = t.rawBody.byteLength >= 8 && Buffer.from(t.rawBody.subarray(0, 8)).toString("latin1") === aa, p, m;
270
+ let f = t.rawBody.byteLength >= 8 && Buffer.from(t.rawBody.subarray(0, 8)).toString("latin1") === fa, p, m;
228
271
  if (d !== void 0) {
229
272
  let { createReadStream: e } = await import("node:fs");
230
273
  p = e(d), m = "chunked";
231
- } else if (f) p = sa(t.rawBody), m = "upload";
274
+ } else if (f) p = ma(t.rawBody), m = "upload";
232
275
  else {
233
276
  let n;
234
277
  try {
@@ -242,11 +285,11 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
242
285
  }
243
286
  let h = await import("node:os"), g = await import("node:fs/promises"), _ = await import("node:path"), te = await g.mkdtemp(_.join(h.tmpdir(), "voltro-admin-import-"));
244
287
  try {
245
- e.assetSink ? await Ri(p, {
288
+ e.assetSink ? await Wi(p, {
246
289
  dir: te,
247
290
  blobs: e.assetSink
248
- }) : await zi(p, te);
249
- let t = await W.runPromiseExit(Fi({
291
+ }) : await Gi(p, te);
292
+ let t = await W.runPromiseExit(Vi({
250
293
  store: e.store,
251
294
  bundleDir: te,
252
295
  ...r ? { mode: r } : {},
@@ -258,6 +301,7 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
258
301
  ...c ? { dryRun: c } : {},
259
302
  ...l.length > 0 ? { tables: l } : {},
260
303
  ...e.snapshot ? { targetSnapshot: e.snapshot } : {},
304
+ ...e.dialect ? { targetDialect: e.dialect } : {},
261
305
  force: ee,
262
306
  onWarn: (e) => Q.warn("admin.import", { message: e }),
263
307
  ...e.assetSink ? { assetsAlreadyRestored: !0 } : {}
@@ -328,20 +372,28 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
328
372
  await g.rm(te, {
329
373
  recursive: !0,
330
374
  force: !0
331
- }), u !== void 0 && u !== "" && d !== void 0 && await ia(u);
375
+ }), u !== void 0 && u !== "" && d !== void 0 && await da(u);
332
376
  }
333
- }, la = R({ scope: "voltro:admin-export" }), ua = async (e) => {
377
+ }, ga = L({ scope: "voltro:admin-export" }), _a = async (e) => {
334
378
  let t = [];
335
379
  for await (let n of e) t.push(Buffer.from(n));
336
380
  return new Uint8Array(Buffer.concat(t));
337
- }, da = (e) => typeof e.tenant == "string" && e.tenant ? {
338
- kind: "tenant",
339
- tenantId: e.tenant
340
- } : Array.isArray(e.tables) && e.tables.length ? {
341
- kind: "tables",
342
- tables: e.tables.filter((e) => typeof e == "string")
343
- } : { kind: "all" }, fa = (e) => async (t) => {
344
- let n = qi(t, e.secret);
381
+ }, va = (e) => Array.isArray(e) ? e.filter((e) => typeof e == "string") : [], ya = (e) => {
382
+ if (typeof e.tenant == "string" && e.tenant) return {
383
+ kind: "tenant",
384
+ tenantId: e.tenant
385
+ };
386
+ if (Array.isArray(e.tables) && e.tables.length) return {
387
+ kind: "tables",
388
+ tables: va(e.tables)
389
+ };
390
+ let t = va(e.exclude);
391
+ return t.length > 0 ? {
392
+ kind: "all",
393
+ exclude: t
394
+ } : { kind: "all" };
395
+ }, ba = (e) => async (t) => {
396
+ let n = ea(t, e.secret);
345
397
  if (n) return n;
346
398
  let r;
347
399
  try {
@@ -361,9 +413,9 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
361
413
  });
362
414
  }
363
415
  }
364
- let a = r.consistency === "snapshot" ? "snapshot" : i.consistency ?? "live", o = (typeof r.compression == "string" ? r.compression : void 0) ?? i.compression, ee = i.scope ?? da(r), s = typeof r.bundleKey == "string" && r.bundleKey.length > 0, c = r.assets === !0 && e.assetSource ? { blobs: e.assetSource } : {}, l = await import("node:os"), u = await import("node:fs/promises"), d = await import("node:path"), f = await u.mkdtemp(d.join(l.tmpdir(), "voltro-admin-export-"));
416
+ let a = r.consistency === "snapshot" ? "snapshot" : i.consistency ?? "live", o = (typeof r.compression == "string" ? r.compression : void 0) ?? i.compression, ee = i.scope ?? ya(r), s = typeof r.bundleKey == "string" && r.bundleKey.length > 0, c = r.assets === !0 && e.assetSource ? { blobs: e.assetSource } : {}, l = await import("node:os"), u = await import("node:fs/promises"), d = await import("node:path"), f = await u.mkdtemp(d.join(l.tmpdir(), "voltro-admin-export-"));
365
417
  try {
366
- let t = await W.runPromise(Pi({
418
+ let t = await W.runPromise(Bi({
367
419
  store: e.store,
368
420
  snapshot: e.snapshot,
369
421
  dialect: e.dialect,
@@ -379,10 +431,10 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
379
431
  if (s) {
380
432
  if (!e.putArchive) return Z(501, { error: "storage transport not configured on this instance" });
381
433
  let i = r.bundleKey;
382
- return await e.putArchive(i, () => Ni({
434
+ return await e.putArchive(i, () => Ri({
383
435
  dir: f,
384
436
  ...c
385
- })), la.info("admin.export", {
437
+ })), ga.info("admin.export", {
386
438
  transport: "storage",
387
439
  tables: t.tables.length,
388
440
  rows: n,
@@ -396,11 +448,11 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
396
448
  transport: "storage"
397
449
  });
398
450
  }
399
- let u = await ua(Ni({
451
+ let u = await _a(Ri({
400
452
  dir: f,
401
453
  ...c
402
454
  }));
403
- return la.info("admin.export", {
455
+ return ga.info("admin.export", {
404
456
  transport: "download",
405
457
  tables: t.tables.length,
406
458
  rows: n,
@@ -417,7 +469,7 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
417
469
  }
418
470
  };
419
471
  } catch (e) {
420
- return la.warn("admin.export failed", { error: e?.message ?? String(e) }), Z(500, {
472
+ return ga.warn("admin.export failed", { error: e?.message ?? String(e) }), Z(500, {
421
473
  error: "export failed",
422
474
  message: e?.message ?? String(e)
423
475
  });
@@ -427,8 +479,51 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
427
479
  force: !0
428
480
  });
429
481
  }
430
- }, pa = (e, t, n = {}) => (async function* () {
431
- let r = await W.runPromise(gi(e, t).pipe(W.timeout(n.openTimeout ?? "30 seconds"))), i = await vi(r.stream), a = n.stallMs ?? 12e4, o, ee = () => {
482
+ }, xa = async (e, t) => await e.query({
483
+ table: H,
484
+ order: [{
485
+ column: "startedAt",
486
+ direction: "desc"
487
+ }],
488
+ predicate: void 0,
489
+ projection: void 0,
490
+ skip: 0,
491
+ take: t
492
+ }), Sa = (e) => ({
493
+ ...e,
494
+ startedAt: new Date(e.startedAt),
495
+ finishedAt: e.finishedAt === null ? null : new Date(e.finishedAt)
496
+ }), Ca = (e) => async (t) => {
497
+ let n = ea(t, e.secret, "GET");
498
+ if (n) return n;
499
+ let r = Number(new URLSearchParams(t.query ?? "").get("limit") ?? "20"), i = Number.isFinite(r) ? Math.max(1, Math.min(200, Math.trunc(r))) : 20, a;
500
+ try {
501
+ a = (await xa(e.store, i)).map(Sa);
502
+ } catch (e) {
503
+ return Z(409, {
504
+ error: "no import history",
505
+ message: `this instance has no \`${H}\` table, so no import has been recorded. Run \`voltro db apply\` against it; imports themselves are unaffected.`,
506
+ detail: e?.message ?? String(e)
507
+ });
508
+ }
509
+ return Z(200, {
510
+ running: a.filter((e) => e.finishedAt === null && e.failure === null).length,
511
+ runs: a.map((e) => ({
512
+ id: e.id,
513
+ startedAt: e.startedAt.toISOString(),
514
+ finishedAt: e.finishedAt === null ? null : e.finishedAt.toISOString(),
515
+ mode: e.mode,
516
+ via: e.via,
517
+ bundle: e.bundle,
518
+ sourceFingerprint: e.sourceFingerprint,
519
+ tablesWritten: e.tablesWritten,
520
+ rowsWritten: e.rowsWritten,
521
+ failure: e.failure,
522
+ line: Yn(e)
523
+ }))
524
+ });
525
+ }, wa = (e, t, n = {}) => (async function* () {
526
+ let r = await W.runPromise(yi(e, t).pipe(W.timeout(n.openTimeout ?? "30 seconds"))), i = await xi(r.stream), a = n.stallMs ?? 12e4, o, ee = () => {
432
527
  o && clearTimeout(o), o = setTimeout(() => i.destroy(/* @__PURE__ */ Error(`storage read stalled for ${a}ms reading '${t}'`)), a);
433
528
  };
434
529
  try {
@@ -437,7 +532,7 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
437
532
  } finally {
438
533
  o && clearTimeout(o), i.destroy();
439
534
  }
440
- })(), ma = {
535
+ })(), Ta = {
441
536
  get: async () => void 0,
442
537
  set: async () => {},
443
538
  setWithTags: async () => {},
@@ -446,43 +541,43 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
446
541
  clear: async () => {},
447
542
  invalidateTag: async () => 0,
448
543
  wrap: async (e, t, n) => n()
449
- }, ha = async (e) => {
544
+ }, Ea = async (e) => {
450
545
  d(e.appProcedures ?? e.discovered, {
451
546
  defaultDeny: e.security?.defaultDeny ?? !0,
452
547
  commandHint: "`voltro serve`"
453
- }), ei({
548
+ }), ni({
454
549
  dataStore: e.store,
455
550
  schemaRegistry: e.schemaRegistry
456
551
  });
457
- let t = (e.discovered.budgets?.length ?? 0) > 0, n, r = new or({
552
+ let t = (e.discovered.budgets?.length ?? 0) > 0, n, r = new sr({
458
553
  store: e.store,
459
554
  ...e.snapshotCache ? { cache: e.snapshotCache } : {},
460
555
  ...e.reactive === void 0 ? {} : { reactive: e.reactive },
461
556
  ...t ? { recordCost: (e) => n?.record(e) } : {},
462
- recordDelivery: (e) => Jr({
557
+ recordDelivery: (e) => Xr({
463
558
  label: e.label,
464
559
  kind: e.kind,
465
560
  durationMs: e.durationMs,
466
561
  rowCount: e.rowCount
467
562
  })
468
- }), i = e.cache ?? ma, a = e.kv ?? Kr, o, ee = () => void 0, c, l, u, f, p, m, h, _ = ue({
563
+ }), i = e.cache ?? Ta, a = e.kv ?? Jr, o, ee = () => void 0, c, l, u, f, p, m, h, _ = ue({
469
564
  store: e.store,
470
565
  warn: (e, t) => {
471
566
  process.stderr.write(`[workflow] ${e} ${JSON.stringify(t)}\n`);
472
567
  }
473
- }), te = _.remember, ae = _.resolve, oe = bt({
568
+ }), te = _.remember, ae = _.resolve, oe = xt({
474
569
  authority: e.authority,
475
570
  getStore: () => e.store
476
- }), S = (e.discovered.workflows?.length ?? 0) > 0 ? Fr(() => o) : void 0, de = (e.discovered.workflows?.length ?? 0) > 0 || (e.discovered.eventTriggers?.length ?? 0) > 0, he = de || (e.discovered.workflowWorkers?.length ?? 0) > 0 || e.scheduleCoordination === "cluster", ge = e.tenantIsolation === "namespace", _e = (e.log ?? R({ scope: "voltro:serve" })).child("webhooks"), ve, ye, C = e.discovered.webhooks;
571
+ }), S = (e.discovered.workflows?.length ?? 0) > 0 ? Lr(() => o) : void 0, de = (e.discovered.workflows?.length ?? 0) > 0 || (e.discovered.eventTriggers?.length ?? 0) > 0, he = de || (e.discovered.workflowWorkers?.length ?? 0) > 0 || e.scheduleCoordination === "cluster", ge = e.tenantIsolation === "namespace", _e = (e.log ?? L({ scope: "voltro:serve" })).child("webhooks"), ve, ye, C = e.discovered.webhooks;
477
572
  if (C && C.outgoing.length > 0 && e.workflowEngineLayer !== void 0) {
478
573
  e.workflowEngineLayer;
479
- let t = ut({
574
+ let t = dt({
480
575
  store: e.store,
481
576
  schemaRegistry: e.schemaRegistry,
482
577
  cache: i,
483
578
  kv: a
484
579
  }), n = C.outgoing.map((e) => e.descriptor);
485
- ye = Ei.toLayer(Ci(t, { events: n })), ve = wi(t, async (e) => {
580
+ ye = ki.toLayer(Ei(t, { events: n })), ve = Di(t, async (e) => {
486
581
  let t = u;
487
582
  if (t === void 0) {
488
583
  _e.error("webhook delivery skipped — the workflow runtime was never built. This is a framework defect, not a configuration problem: report it with your engine setting. Deliveries are NOT queued and will not be retried.", {
@@ -491,7 +586,7 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
491
586
  });
492
587
  return;
493
588
  }
494
- t.runPromise(Ei.execute(e)).catch((t) => {
589
+ t.runPromise(ki.execute(e)).catch((t) => {
495
590
  _e.error("deliverWebhook workflow crashed", {
496
591
  deliveryId: e.deliveryId,
497
592
  targetId: e.targetId
@@ -501,9 +596,9 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
501
596
  }
502
597
  let Se = /* @__PURE__ */ new Map();
503
598
  if (C) for (let e of C.incoming) {
504
- let t = e.descriptor.path ?? Ti(e.descriptor.id), n = `VOLTRO_WEBHOOK_SECRET_${e.descriptor.id.toUpperCase().replace(/[^A-Z0-9]/g, "_")}`, r = Oi(e.descriptor, {
599
+ let t = e.descriptor.path ?? Oi(e.descriptor.id), n = `VOLTRO_WEBHOOK_SECRET_${e.descriptor.id.toUpperCase().replace(/[^A-Z0-9]/g, "_")}`, r = ji(e.descriptor, {
505
600
  resolveSecret: async () => process.env[n] ?? null,
506
- resolveWorkflows: () => S === void 0 ? void 0 : Wr(S, {
601
+ resolveWorkflows: () => S === void 0 ? void 0 : Kr(S, {
507
602
  traceId: `incoming:${e.descriptor.id}`,
508
603
  source: `incoming:${e.descriptor.id}`
509
604
  }),
@@ -520,15 +615,15 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
520
615
  });
521
616
  Se.set(t, { handle: r });
522
617
  }
523
- wr(), Xr((t) => Tr(e.store, t.subjectId, t.resourceType, t.resourceId)) || R({ scope: "voltro:serve" }).info("policy guards: using the app-registered tuple source");
524
- let Ce = [], Te = [...e.discovered.outboxHandlers ?? [], ...gn((C?.outgoing.length ?? 0) + (C?.incoming.length ?? 0) + (C?.providers.length ?? 0), []) ? [{
618
+ Er(), Y((t) => Dr(e.store, t.subjectId, t.resourceType, t.resourceId)) || L({ scope: "voltro:serve" }).info("policy guards: using the app-registered tuple source");
619
+ let Ce = [], Te = [...e.discovered.outboxHandlers ?? [], ..._n((C?.outgoing.length ?? 0) + (C?.incoming.length ?? 0) + (C?.providers.length ?? 0), []) ? [{
525
620
  file: "<framework>/webhooks",
526
621
  id: "voltro-webhook-emit",
527
- definition: Di(() => ve)
622
+ definition: Ai(() => ve)
528
623
  }] : []], Ee = Te.length > 0 ? Fe({
529
624
  handlers: Te,
530
625
  store: e.store,
531
- log: (e.log ?? R({ scope: "voltro:serve" })).child("outbox"),
626
+ log: (e.log ?? L({ scope: "voltro:serve" })).child("outbox"),
532
627
  onChange: (t) => e.store.onChange((e) => t({
533
628
  table: e.table,
534
629
  op: e.op
@@ -540,9 +635,9 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
540
635
  definitions: (e.discovered.connections ?? []).map((e) => e.definition),
541
636
  store: e.store,
542
637
  publicUrl: b(e.port ?? 4e3),
543
- log: (e.log ?? R({ scope: "voltro:serve" })).child("connections")
638
+ log: (e.log ?? L({ scope: "voltro:serve" })).child("connections")
544
639
  });
545
- ot({
640
+ st({
546
641
  events: e.discovered.events ?? [],
547
642
  rpcTags: [
548
643
  ...e.discovered.queries.map((e) => e.descriptor.name),
@@ -551,16 +646,16 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
551
646
  ...(e.discovered.streams ?? []).map((e) => e.descriptor.name)
552
647
  ]
553
648
  });
554
- let Ae = (e.log ?? R({ scope: "voltro:serve" })).child("events"), je = e.broadcastNamespace ?? Qe(e.plugins, void 0), Me = E(e.plugins, je, Ae), Ne = e.membership?.instanceId ?? process.env.POD_NAME ?? process.env.HOSTNAME ?? `serve-${process.pid}`, Ie = e.membership ?? jt(e.plugins, {
649
+ let Ae = (e.log ?? L({ scope: "voltro:serve" })).child("events"), je = e.broadcastNamespace ?? $e(e.plugins, void 0), Me = E(e.plugins, je, Ae), Ne = e.membership?.instanceId ?? process.env.POD_NAME ?? process.env.HOSTNAME ?? `serve-${process.pid}`, Ie = e.membership ?? Mt(e.plugins, {
555
650
  instanceId: Ne,
556
651
  namespace: je,
557
652
  meta: { mode: "serve" },
558
653
  logger: Ae
559
- }), D = fe({
654
+ }), Le = fe({
560
655
  events: e.discovered.events ?? [],
561
656
  origin: Ne,
562
657
  ...Me.publishRemote === void 0 ? {} : { publishRemote: Me.publishRemote }
563
- }), Le = (e.discovered.events ?? []).length > 0 ? await Me.attach(D.bus) : null, Re = Ue({
658
+ }), Re = (e.discovered.events ?? []).length > 0 ? await Me.attach(Le.bus) : null, ze = We({
564
659
  store: e.store,
565
660
  schemaRegistry: e.schemaRegistry,
566
661
  cache: i,
@@ -573,180 +668,192 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
573
668
  ...e.resolveResidentStore === void 0 ? {} : { resolveResidentStore: e.resolveResidentStore },
574
669
  ...Ee === void 0 ? {} : { outbox: { nudge: Ee.nudge } },
575
670
  ...w.active ? { connections: { registry: w.registry } } : {},
576
- eventBus: D.bus
577
- }), ze = G.succeed(rr, g), Be = G.succeed(sr, Lt), He = G.succeed(ir, Ve), Ge = G.succeed(cr, we), qe = (t, n) => {
578
- let r = t.pipe(W.provide(Pr(n)));
579
- return (e.baseLayer ? r.pipe(W.provide(e.baseLayer)) : r).pipe(W.provide(ze)).pipe(W.provide(Be)).pipe(W.provide(He)).pipe(W.provide(Ge));
580
- }, Ye = (e, t) => {
581
- let n = qe(e, t);
582
- return Y(n);
583
- }, Xe = yn(), et = le(e.plugins ?? [], Xe), tt = Oe({
671
+ eventBus: Le.bus
672
+ }), Be = G.succeed(ar, g), Ve = G.succeed(cr, Rt), Ue = G.succeed(K, He), Ke = G.succeed(lr, we), Je = (t, n) => {
673
+ let r = t.pipe(W.provide(Ir(n)));
674
+ return (e.baseLayer ? r.pipe(W.provide(e.baseLayer)) : r).pipe(W.provide(Be)).pipe(W.provide(Ve)).pipe(W.provide(Ue)).pipe(W.provide(Ke));
675
+ }, Xe = (e, t) => {
676
+ let n = Je(e, t);
677
+ return ei(n);
678
+ }, Ze = bn(), tt = le(e.plugins ?? [], Ze), nt = Oe({
584
679
  plugins: e.plugins ?? [],
585
- metrics: Xe,
586
- log: e.log ?? R({ scope: "voltro:serve" })
587
- }), nt = x(e.plugins ?? [], Xe), rt = e.security?.defaultDeny ?? !0, at = Lr({
680
+ metrics: Ze,
681
+ log: e.log ?? L({ scope: "voltro:serve" })
682
+ }), rt = x(e.plugins ?? [], Ze), it = e.security?.defaultDeny ?? !0, ot = zr({
588
683
  store: e.store,
589
- defaultDeny: rt,
684
+ defaultDeny: it,
590
685
  recordMetric: (e) => {
591
- Xe.record(e);
686
+ Ze.record(e);
592
687
  },
593
- ...et.mutation === void 0 ? {} : { interceptor: et.mutation },
594
- buildContext: (e, t, n) => Re(e, t, n),
595
- runEffect: Ye,
688
+ ...tt.mutation === void 0 ? {} : { interceptor: tt.mutation },
689
+ buildContext: (e, t, n) => ze(e, t, n),
690
+ runEffect: Xe,
596
691
  undoCapture: s()
597
- }), ct = be();
692
+ }), lt = be();
598
693
  {
599
- let t = Je();
600
- t !== void 0 && (e.log ?? R({ scope: "voltro:serve" })).info(t);
694
+ let t = Ye();
695
+ t !== void 0 && (e.log ?? L({ scope: "voltro:serve" })).info(t);
601
696
  }
602
- let lt = Pe({
697
+ let ut = Pe({
603
698
  store: e.store,
604
699
  ...e.approvals === void 0 ? {} : { defaultExpiryMs: e.approvals.defaultExpiryMs }
605
- }), ft = Er({
606
- defaultDeny: rt,
607
- buildContext: (e) => Re(e),
608
- runEffect: Ye,
700
+ }), pt = Or({
701
+ defaultDeny: it,
702
+ buildContext: (e) => ze(e),
703
+ runEffect: Xe,
609
704
  recordMetric: (e) => {
610
- Xe.record(e);
705
+ Ze.record(e);
611
706
  },
612
- ...et.action === void 0 ? {} : { interceptor: et.action }
613
- }), pt = Br({
707
+ ...tt.action === void 0 ? {} : { interceptor: tt.action }
708
+ }), mt = Hr({
614
709
  tenantScopedTables: e.tenantScopedTables,
615
710
  softDeleteScopedTables: e.softDeleteScopedTables
616
- }), mt = {
617
- defaultDeny: rt,
618
- buildContext: (e) => Re(e),
619
- finalize: (e, t) => pt(e, t.subject),
620
- provideEffect: qe,
621
- ...et.query === void 0 ? {} : { interceptor: et.query }
622
- }, O = zr(mt), k = Rr({
623
- ...mt,
624
- queryRows: (t, n) => e.store.query(t).then((e) => ai(t.table, e, n.subject))
625
- }), gt = Hr({
626
- ...mt,
711
+ }), ht = {
712
+ defaultDeny: it,
713
+ buildContext: (e) => ze(e),
714
+ finalize: (e, t) => mt(e, t.subject),
715
+ provideEffect: Je,
716
+ ...tt.query === void 0 ? {} : { interceptor: tt.query }
717
+ }, D = Vr(ht), O = Br({
718
+ ...ht,
719
+ queryRows: (t, n) => e.store.query(t).then((e) => si(t.table, e, n.subject))
720
+ }), _t = Ur({
721
+ ...ht,
627
722
  subscribeDescriptor: (e, t, n) => r.subscribe(e, t, n),
628
723
  subscribeComputed: (e, t, n) => r.subscribeComputed(e, t, n)
629
- }), A = (e) => e.filter((e) => Nn(e.descriptor)), j = {};
724
+ }), k = (e) => e.filter((e) => Pn(e.descriptor)), A = {};
630
725
  for (let t of [
631
- ...A(e.discovered.queries),
632
- ...ct.queries,
726
+ ...k(e.discovered.queries),
633
727
  ...lt.queries,
728
+ ...ut.queries,
634
729
  ...w.queries
635
- ]) j[t.descriptor.name] = (e) => q(O(t, e), r, `subscription.${t.descriptor.name}`, void 0, void 0, Vr(t, e));
730
+ ]) A[t.descriptor.name] = (e) => _r(D(t, e), r, `subscription.${t.descriptor.name}`, void 0, void 0, J(t, e));
636
731
  for (let t of [
637
- ...A(e.discovered.mutations),
638
- ...ct.mutations,
732
+ ...k(e.discovered.mutations),
639
733
  ...lt.mutations,
734
+ ...ut.mutations,
640
735
  ...w.mutations
641
736
  ]) {
642
- let n = Ir(t.descriptor.output);
643
- j[t.descriptor.name] = (r) => K(async (e, n) => at(t, e, n), r, `mutation.${t.descriptor.name}`, n, e.idempotency, In(t.descriptor, "mutation"));
737
+ let n = Rr(t.descriptor.output);
738
+ A[t.descriptor.name] = (r) => q(async (e, n) => ot(t, e, n), r, `mutation.${t.descriptor.name}`, n, e.idempotency, Ln(t.descriptor, "mutation"));
644
739
  }
645
- for (let t of [...A(e.discovered.actions), ...w.actions]) {
646
- let n = Ir(t.descriptor.output);
647
- j[t.descriptor.name] = (r) => K(async (e, n) => ft(t, e, n), r, `action.${t.descriptor.name}`, n, e.idempotency, In(t.descriptor, "action"));
740
+ for (let t of [...k(e.discovered.actions), ...w.actions]) {
741
+ let n = Rr(t.descriptor.output);
742
+ A[t.descriptor.name] = (r) => q(async (e, n) => pt(t, e, n), r, `action.${t.descriptor.name}`, n, e.idempotency, Ln(t.descriptor, "action"));
648
743
  }
649
- let _t = () => `public-${Math.random().toString(36).slice(2, 10)}`, vt = [
744
+ let vt = () => `public-${Math.random().toString(36).slice(2, 10)}`, yt = [
650
745
  ...e.discovered.queries.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
651
746
  descriptor: e.descriptor,
652
- invoke: (t, n) => k(e, t, {
747
+ invoke: (t, n) => O(e, t, {
653
748
  subject: n.subject,
654
- traceId: _t()
749
+ traceId: vt()
655
750
  }),
656
- subscribe: (t, n, r) => gt(e, t, {
751
+ subscribe: (t, n, r) => _t(e, t, {
657
752
  subject: n.subject,
658
- traceId: _t()
753
+ traceId: vt()
659
754
  }, r)
660
755
  })),
661
756
  ...e.discovered.mutations.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
662
757
  descriptor: e.descriptor,
663
- invoke: (t, n) => at(e, t, {
758
+ invoke: (t, n) => ot(e, t, {
664
759
  subject: n.subject,
665
- traceId: _t()
760
+ traceId: vt()
666
761
  })
667
762
  })),
668
763
  ...e.discovered.actions.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
669
764
  descriptor: e.descriptor,
670
- invoke: (t, n) => ft(e, t, {
765
+ invoke: (t, n) => pt(e, t, {
671
766
  subject: n.subject,
672
- traceId: _t()
767
+ traceId: vt()
673
768
  })
674
769
  }))
675
- ], yt = {
770
+ ], bt = {
676
771
  candidates: ce({
677
772
  queries: e.discovered.queries,
678
773
  mutations: e.discovered.mutations,
679
774
  actions: e.discovered.actions,
680
775
  descriptorOf: (e) => e.descriptor,
681
- runQuery: (e, t, n) => Promise.resolve(k(e, t, n)),
682
- runMutation: (e, t, n) => Promise.resolve(at(e, t, n)),
683
- runAction: (e, t, n) => Promise.resolve(ft(e, t, n))
776
+ runQuery: (e, t, n) => Promise.resolve(O(e, t, n)),
777
+ runMutation: (e, t, n) => Promise.resolve(ot(e, t, n)),
778
+ runAction: (e, t, n) => Promise.resolve(pt(e, t, n))
684
779
  }),
685
780
  policy: e.agents?.tools ?? {},
686
781
  mcpEnabled: e.agents?.mcp === !0,
687
782
  resolveSubject: (t) => e.resolveSubject(t, -1).then((e) => e.subject)
688
- }, xt = ht({
783
+ }, St = gt({
689
784
  ...e.restRoutes === void 0 ? {} : { restRoutes: e.restRoutes },
690
- publicApiEntries: vt,
785
+ publicApiEntries: yt,
691
786
  store: e.store,
692
787
  resolveSubject: (t) => e.resolveSubject(t, -1).then((e) => e.subject),
693
788
  ...e.idempotency === void 0 ? {} : { idempotency: e.idempotency },
694
- log: e.log ?? R({ scope: "voltro:serve" })
695
- }), St = e.dataTransferSecret ?? process.env.VOLTRO_DATA_TRANSFER_SECRET, Ct = async (e, t) => {
696
- let { Readable: n } = await import("node:stream"), r = mi(), i = hi("storage", () => n.from(t()));
697
- await W.runPromise(_i(r, e, i, { contentType: "application/octet-stream" }));
698
- }, wt = St && St.length >= 16 ? [{
699
- method: "POST",
700
- path: Ui,
701
- handle: ca({
702
- secret: St,
703
- store: e.store,
704
- ...e.dataTransferSnapshot ? { snapshot: e.dataTransferSnapshot } : {},
705
- assetSink: Ii(mi()),
706
- openArchive: (e) => pa(mi(), e),
707
- refreshSubscriptions: (e) => {
708
- r.refreshAll(e);
709
- },
710
- putArchive: Ct,
711
- ...e.dataTransferDialect ? { dialect: e.dataTransferDialect } : {}
712
- })
713
- }, {
714
- method: "POST",
715
- path: Wi,
716
- handle: fa({
717
- secret: St,
718
- store: e.store,
719
- snapshot: e.dataTransferSnapshot ?? { tables: [] },
720
- dialect: e.dataTransferDialect ?? "memory",
721
- tenantTables: [...e.tenantScopedTables],
722
- loadProfile: Cn,
723
- assetSource: Li(mi(), e.store),
724
- putArchive: Ct
725
- })
726
- }] : [], Tt = [
789
+ log: e.log ?? L({ scope: "voltro:serve" })
790
+ }), Ct = e.dataTransferSecret ?? process.env.VOLTRO_DATA_TRANSFER_SECRET, wt = async (e, t) => {
791
+ let { Readable: n } = await import("node:stream"), r = gi(), i = vi("storage", () => n.from(t()));
792
+ await W.runPromise(bi(r, e, i, { contentType: "application/octet-stream" }));
793
+ }, Tt = Ct && Ct.length >= 16 ? [
794
+ {
795
+ method: "POST",
796
+ path: Yi,
797
+ handle: ha({
798
+ secret: Ct,
799
+ store: e.store,
800
+ ...e.dataTransferSnapshot ? { snapshot: e.dataTransferSnapshot } : {},
801
+ ...e.dataTransferDialect ? { dialect: e.dataTransferDialect } : {},
802
+ assetSink: Hi(gi()),
803
+ openArchive: (e) => wa(gi(), e),
804
+ refreshSubscriptions: (e) => {
805
+ r.refreshAll(e);
806
+ },
807
+ putArchive: wt,
808
+ ...e.dataTransferDialect ? { dialect: e.dataTransferDialect } : {}
809
+ })
810
+ },
811
+ {
812
+ method: "GET",
813
+ path: Zi,
814
+ handle: Ca({
815
+ secret: Ct,
816
+ store: e.store
817
+ })
818
+ },
819
+ {
820
+ method: "POST",
821
+ path: Xi,
822
+ handle: ba({
823
+ secret: Ct,
824
+ store: e.store,
825
+ snapshot: e.dataTransferSnapshot ?? { tables: [] },
826
+ dialect: e.dataTransferDialect ?? "memory",
827
+ tenantTables: [...e.tenantScopedTables],
828
+ loadProfile: wn,
829
+ assetSource: Ui(gi(), e.store),
830
+ putArchive: wt
831
+ })
832
+ }
833
+ ] : [], Et = [
727
834
  ...e.httpRoutes ?? [],
728
- ...xt.httpRoutes,
729
- ...wt,
835
+ ...St.httpRoutes,
836
+ ...Tt,
730
837
  ...w.httpRoutes
731
838
  ];
732
- Object.assign(j, D.handlers);
733
- for (let t of A(e.discovered.streams ?? [])) j[t.descriptor.name] = (n) => hr((r) => ci(r, (r) => {
734
- let i = Re(r), a = t.executor(n, i);
839
+ Object.assign(A, Le.handlers);
840
+ for (let t of k(e.discovered.streams ?? [])) A[t.descriptor.name] = (n) => gr((r) => ui(r, (r) => {
841
+ let i = ze(r), a = t.executor(n, i);
735
842
  if (W.isEffect(a)) {
736
- let t = a.pipe(W.provide(Pr(i.store)));
737
- return (e.baseLayer ? t.pipe(W.provide(e.baseLayer)) : t).pipe(W.provide(ze)).pipe(W.provide(Be)).pipe(W.provide(He)).pipe(W.provide(Ge));
843
+ let t = a.pipe(W.provide(Ir(i.store)));
844
+ return (e.baseLayer ? t.pipe(W.provide(e.baseLayer)) : t).pipe(W.provide(Be)).pipe(W.provide(Ve)).pipe(W.provide(Ue)).pipe(W.provide(Ke));
738
845
  }
739
846
  return typeof a == "object" && a && typeof a.then == "function" ? W.promise(() => a) : a;
740
847
  }), `stream.${t.descriptor.name}`);
741
- for (let t of e.discovered.workflows ?? []) j[t.definition.name] = (e) => K(async (e, n) => {
848
+ for (let t of e.discovered.workflows ?? []) A[t.definition.name] = (e) => q(async (e, n) => {
742
849
  let r = n;
743
- return Wr(S, {
850
+ return Kr(S, {
744
851
  subject: r.subject,
745
852
  traceId: r.traceId,
746
853
  source: "workflow-rpc"
747
854
  }).start(t.definition.name, e);
748
855
  }, e, `workflow.${t.definition.name}`);
749
- de && (j[Vn.name] = (e) => q(O({
856
+ de && (A[Vn.name] = (e) => _r(D({
750
857
  descriptor: Vn,
751
858
  executor: (e) => {
752
859
  let t = e.id;
@@ -756,13 +863,13 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
756
863
  column: "startedAt",
757
864
  direction: "desc"
758
865
  }],
759
- predicate: Yn(U("id", t), U("executionId", t)),
866
+ predicate: Zn(U("id", t), U("executionId", t)),
760
867
  take: 1,
761
868
  skip: void 0,
762
869
  projection: void 0
763
870
  };
764
871
  }
765
- }, e), r, `subscription.${Vn.name}`), j[Un.name] = (e) => q(O({
872
+ }, e), r, `subscription.${Vn.name}`), A[Un.name] = (e) => _r(D({
766
873
  descriptor: Un,
767
874
  executor: (e) => {
768
875
  let t = e, n = [...t.tag === void 0 ? [] : [U("tag", t.tag)], ...t.status === void 0 ? [] : [U("status", t.status)]], r = Number.isFinite(t.limit) && t.limit !== void 0 ? Math.min(Math.max(Math.floor(t.limit), 1), 500) : 100;
@@ -772,13 +879,13 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
772
879
  column: "startedAt",
773
880
  direction: "desc"
774
881
  }],
775
- predicate: n.length === 0 ? void 0 : n.length === 1 ? n[0] : H(...n),
882
+ predicate: n.length === 0 ? void 0 : n.length === 1 ? n[0] : qn(...n),
776
883
  take: r,
777
884
  skip: void 0,
778
885
  projection: void 0
779
886
  };
780
887
  }
781
- }, e), r, `subscription.${Un.name}`), j[Hn.name] = (e) => q(O({
888
+ }, e), r, `subscription.${Un.name}`), A[Hn.name] = (e) => _r(D({
782
889
  descriptor: Hn,
783
890
  executor: (e) => {
784
891
  let t = e.runId;
@@ -794,7 +901,7 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
794
901
  projection: void 0
795
902
  };
796
903
  }
797
- }, e), r, `subscription.${Hn.name}`), j[Bn.name] = (e) => q(O({
904
+ }, e), r, `subscription.${Hn.name}`), A[Bn.name] = (e) => _r(D({
798
905
  descriptor: Bn,
799
906
  executor: (e) => {
800
907
  let t = e.runId;
@@ -810,8 +917,8 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
810
917
  projection: void 0
811
918
  };
812
919
  }
813
- }, e), r, `subscription.${Bn.name}`), j[Rn.name] = (e) => q(O({
814
- descriptor: Rn,
920
+ }, e), r, `subscription.${Bn.name}`), A[B.name] = (e) => _r(D({
921
+ descriptor: B,
815
922
  executor: (e) => {
816
923
  let t = e;
817
924
  return {
@@ -826,7 +933,7 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
826
933
  projection: void 0
827
934
  };
828
935
  }
829
- }, e), r, `subscription.${Rn.name}`), j[V.name] = (e) => q(O({
936
+ }, e), r, `subscription.${B.name}`), A[V.name] = (e) => _r(D({
830
937
  descriptor: V,
831
938
  executor: (e) => {
832
939
  let t = e.eventId;
@@ -842,67 +949,67 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
842
949
  projection: void 0
843
950
  };
844
951
  }
845
- }, e), r, `subscription.${V.name}`), j[Ln.name] = (t) => K(async (t, n) => {
952
+ }, e), r, `subscription.${V.name}`), A[Rn.name] = (t) => q(async (t, n) => {
846
953
  let r = t;
847
- return await M(e.store, n.subject, { executionId: r.executionId }), await S.cancel(r.workflowName, r.executionId), await Pt(r.workflowName, r.executionId, "workflow.cancel"), { ok: !0 };
848
- }, t, `action.${Ln.name}`), j[zn.name] = (t) => K(async (t, n) => {
954
+ return await j(e.store, n.subject, { executionId: r.executionId }), await S.cancel(r.workflowName, r.executionId), await Ft(r.workflowName, r.executionId, "workflow.cancel"), { ok: !0 };
955
+ }, t, `action.${Rn.name}`), A[zn.name] = (t) => q(async (t, n) => {
849
956
  let r = t;
850
- return await M(e.store, n.subject, { executionId: r.executionId }), await S.resume(r.workflowName, r.executionId), { ok: !0 };
851
- }, t, `action.${zn.name}`), j[Wn.name] = (t) => K(async (t, n) => {
957
+ return await j(e.store, n.subject, { executionId: r.executionId }), await S.resume(r.workflowName, r.executionId), { ok: !0 };
958
+ }, t, `action.${zn.name}`), A[Wn.name] = (t) => q(async (t, n) => {
852
959
  let r = t;
853
- return await M(e.store, n.subject, { id: r.id }), S.signal({ id: r.id }, r.signalName, r.payload);
854
- }, t, `action.${Wn.name}`), j[Gn.name] = (t) => K(async (t, n) => {
960
+ return await j(e.store, n.subject, { id: r.id }), S.signal({ id: r.id }, r.signalName, r.payload);
961
+ }, t, `action.${Wn.name}`), A[Gn.name] = (t) => q(async (t, n) => {
855
962
  let r = t;
856
- return await M(e.store, n.subject, { id: r.id }), S.update({ id: r.id }, r.updateName, r.payload, r.timeoutMs === void 0 ? void 0 : { timeoutMs: r.timeoutMs });
963
+ return await j(e.store, n.subject, { id: r.id }), S.update({ id: r.id }, r.updateName, r.payload, r.timeoutMs === void 0 ? void 0 : { timeoutMs: r.timeoutMs });
857
964
  }, t, `action.${Gn.name}`));
858
- let Et = [
859
- ...A(e.discovered.queries).map((e) => B(e.descriptor)),
860
- ...A(e.discovered.mutations).map((e) => Pn(e.descriptor)),
861
- ...A(e.discovered.actions).map((e) => z(e.descriptor)),
862
- ...ct.queries.map((e) => B(e.descriptor)),
863
- ...ct.mutations.map((e) => Pn(e.descriptor)),
864
- ...lt.queries.map((e) => B(e.descriptor)),
865
- ...lt.mutations.map((e) => Pn(e.descriptor)),
866
- ...w.queries.map((e) => B(e.descriptor)),
867
- ...w.mutations.map((e) => Pn(e.descriptor)),
868
- ...w.actions.map((e) => z(e.descriptor)),
869
- ...A(e.discovered.streams ?? []).map((e) => Fn(e.descriptor)),
870
- ...D.rpcs,
871
- ...(e.discovered.workflows ?? []).map((e) => li(e.definition)),
965
+ let Dt = [
966
+ ...k(e.discovered.queries).map((e) => z(e.descriptor)),
967
+ ...k(e.discovered.mutations).map((e) => Fn(e.descriptor)),
968
+ ...k(e.discovered.actions).map((e) => R(e.descriptor)),
969
+ ...lt.queries.map((e) => z(e.descriptor)),
970
+ ...lt.mutations.map((e) => Fn(e.descriptor)),
971
+ ...ut.queries.map((e) => z(e.descriptor)),
972
+ ...ut.mutations.map((e) => Fn(e.descriptor)),
973
+ ...w.queries.map((e) => z(e.descriptor)),
974
+ ...w.mutations.map((e) => Fn(e.descriptor)),
975
+ ...w.actions.map((e) => R(e.descriptor)),
976
+ ...k(e.discovered.streams ?? []).map((e) => In(e.descriptor)),
977
+ ...Le.rpcs,
978
+ ...(e.discovered.workflows ?? []).map((e) => di(e.definition)),
872
979
  ...de ? [
873
- B(Vn),
874
- B(Un),
875
- B(Hn),
876
- B(Bn),
877
- B(Rn),
878
- B(V),
879
- z(Ln),
880
- z(zn),
881
- z(Wn),
882
- z(Gn)
980
+ z(Vn),
981
+ z(Un),
982
+ z(Hn),
983
+ z(Bn),
984
+ z(B),
985
+ z(V),
986
+ R(Rn),
987
+ R(zn),
988
+ R(Wn),
989
+ R(Gn)
883
990
  ] : []
884
- ], Dt = pi.make(...Et).middleware(An).middleware(jn), Ot = Mr({ resolveSubject: ({ headers: t, clientId: n }) => e.resolveSubject(t, n) }), kt = e.dormancyTenantId ?? ar, Mt = e.dormancy === "sleep" ? {
885
- register: (t, n, r) => Zr(e.store, {
886
- tenantId: r ?? kt,
991
+ ], Ot = hi.make(...Dt).middleware(jn).middleware(Mn), kt = Pr({ resolveSubject: ({ headers: t, clientId: n }) => e.resolveSubject(t, n) }), At = e.dormancyTenantId ?? or, Nt = e.dormancy === "sleep" ? {
992
+ register: (t, n, r) => Qr(e.store, {
993
+ tenantId: r ?? At,
887
994
  kind: "workflow",
888
995
  refId: t,
889
996
  wakeAt: n
890
997
  }),
891
- cancel: (t, n) => _r(e.store, {
892
- tenantId: n ?? kt,
998
+ cancel: (t, n) => yr(e.store, {
999
+ tenantId: n ?? At,
893
1000
  kind: "workflow",
894
1001
  refId: t
895
1002
  }).then(() => {})
896
- } : void 0, N = he ? await import("@voltro/workflow") : void 0, P = N?.makeWorkflowRunRecorder({
1003
+ } : void 0, M = he ? await import("@voltro/workflow") : void 0, N = M?.makeWorkflowRunRecorder({
897
1004
  store: e.store,
898
1005
  ...e.workflowRecording === void 0 ? {} : { recording: e.workflowRecording },
899
- ...Mt === void 0 ? {} : { wakeups: Mt }
900
- }), Nt = async (t, n) => {
901
- await N.closeWorkflowChildrenForParent({
1006
+ ...Nt === void 0 ? {} : { wakeups: Nt }
1007
+ }), Pt = async (t, n) => {
1008
+ await M.closeWorkflowChildrenForParent({
902
1009
  store: e.store,
903
1010
  parentExecutionId: t,
904
1011
  parentStatus: n,
905
- recorder: P,
1012
+ recorder: N,
906
1013
  log: { warn: (e, t) => {
907
1014
  process.stderr.write(`[workflow] ${e} ${t ? JSON.stringify(t) : ""}\n`);
908
1015
  } },
@@ -913,7 +1020,7 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
913
1020
  await u.runPromise(r.definition.interrupt(n));
914
1021
  }
915
1022
  });
916
- }, Pt = async (t, n, r) => {
1023
+ }, Ft = async (t, n, r) => {
917
1024
  let i = (await e.store.query({
918
1025
  table: "_voltro_workflow_runs",
919
1026
  order: [],
@@ -928,7 +1035,7 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
928
1035
  cancelled: !0,
929
1036
  completedAt: /* @__PURE__ */ new Date()
930
1037
  }), o = i.subject?.tenantId ?? void 0;
931
- a && await P.recordEvent({
1038
+ a && await N.recordEvent({
932
1039
  runId: i.id,
933
1040
  eventType: "run-cancelled",
934
1041
  payload: {
@@ -937,18 +1044,18 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
937
1044
  executionId: n,
938
1045
  ...o == null ? {} : { tenantId: o }
939
1046
  }
940
- }), a && await Nt(n, "cancelled");
941
- }, Ft = [
942
- ...Gr(e.discovered.workflows ?? [], {
943
- buildContext: (t, n) => e.buildContextForWorkflow?.(t, n) ?? Re({
1047
+ }), a && await Pt(n, "cancelled");
1048
+ }, It = [
1049
+ ...qr(e.discovered.workflows ?? [], {
1050
+ buildContext: (t, n) => e.buildContextForWorkflow?.(t, n) ?? ze({
944
1051
  subject: t.subject,
945
1052
  traceId: t.traceId
946
1053
  }, e.store, void 0, `workflow:${n.workflowName}`, { parentExecutionId: n.executionId }),
947
1054
  resolveStartContext: ae,
948
1055
  ...oe === void 0 ? {} : { resolveAuthority: oe }
949
1056
  }, (t, n, r) => {
950
- let i = N.getWorkflowVersionMetadata(t.definition);
951
- return N.wrapWorkflowExecuteWithRunRecording({
1057
+ let i = M.getWorkflowVersionMetadata(t.definition);
1058
+ return M.wrapWorkflowExecuteWithRunRecording({
952
1059
  name: t.definition.name,
953
1060
  store: e.store,
954
1061
  subject: r.subject,
@@ -959,26 +1066,26 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
959
1066
  workflowPatches: i.patches,
960
1067
  parentExecutionId: r?.parentExecutionId ?? null,
961
1068
  parentClosePolicy: r?.parentClosePolicy ?? null,
962
- onParentClose: ({ executionId: e, status: t }) => Nt(e, t),
963
- ...dt(t.definition),
1069
+ onParentClose: ({ executionId: e, status: t }) => Pt(e, t),
1070
+ ...ft(t.definition),
964
1071
  onTerminal: async ({ executionId: e }) => {
965
1072
  await l?.gate.release(e);
966
1073
  },
967
- recorder: P,
968
- pluginWorkflowStepLayer: nt,
969
- recordRun: Yr
1074
+ recorder: N,
1075
+ pluginWorkflowStepLayer: rt,
1076
+ recordRun: Zr
970
1077
  }, n);
971
1078
  }),
972
1079
  ...e.discovered.workflowWorkers ?? [],
973
1080
  ...ye === void 0 ? [] : [ye]
974
- ], It = [...(e.discovered.workflows ?? []).map((e) => e.definition.name).filter(Boolean), ...ye === void 0 ? [] : ["voltro.deliverWebhook"]], Rt = Ft.length > 0 ? G.mergeAll(...Ft) : G.empty;
1081
+ ], Lt = [...(e.discovered.workflows ?? []).map((e) => e.definition.name).filter(Boolean), ...ye === void 0 ? [] : ["voltro.deliverWebhook"]], zt = It.length > 0 ? G.mergeAll(...It) : G.empty;
975
1082
  if (((e.discovered.workflows?.length ?? 0) > 0 || (e.discovered.workflowWorkers?.length ?? 0) > 0 || e.scheduleCoordination === "cluster" || ye !== void 0) && e.workflowEngineLayer !== void 0) {
976
- let t = Rt.pipe(G.provideMerge(e.workflowEngineLayer));
977
- u = Zn.make(e.baseLayer === void 0 ? t : t.pipe(G.provideMerge(e.baseLayer))), await u.runPromise(W.void), (e.log ?? R({ scope: "voltro:serve" })).child("workflow").info(`workflow runtime ready — ${It.length} entity type(s) registered`, { entities: It });
1083
+ let t = zt.pipe(G.provideMerge(e.workflowEngineLayer));
1084
+ u = $n.make(e.baseLayer === void 0 ? t : t.pipe(G.provideMerge(e.baseLayer))), await u.runPromise(W.void), (e.log ?? L({ scope: "voltro:serve" })).child("workflow").info(`workflow runtime ready — ${Lt.length} entity type(s) registered`, { entities: Lt });
978
1085
  let n = await import("@voltro/workflow/cluster"), r = (e) => u.runPromise(n.redriveFailedRun(e)), i = (e) => u.runPromise(n.resumeRunFromStep(e));
979
- m = await zt({
980
- provider: Mi(e.plugins ?? [])?.broadcast?.provider,
981
- crossReplica: Mi(e.plugins ?? [])?.broadcast?.crossReplica ?? !1,
1086
+ m = await Bt({
1087
+ provider: Fi(e.plugins ?? [])?.broadcast?.provider,
1088
+ crossReplica: Fi(e.plugins ?? [])?.broadcast?.crossReplica ?? !1,
982
1089
  namespace: je,
983
1090
  replicaId: crypto.randomUUID(),
984
1091
  pollStorage: () => u.runPromise(n.pollWorkflowStorage),
@@ -987,14 +1094,14 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
987
1094
  op: e.op,
988
1095
  ...e.origin === void 0 ? {} : { origin: e.origin }
989
1096
  })),
990
- log: (e.log ?? R({ scope: "voltro:serve" })).child("workflow")
1097
+ log: (e.log ?? L({ scope: "voltro:serve" })).child("workflow")
991
1098
  }), f = async (t) => {
992
1099
  let n = await De({
993
1100
  store: e.store,
994
1101
  workflows: e.discovered.workflows ?? [],
995
1102
  runRedrive: r
996
1103
  }, t.runId);
997
- return n.statusReset && await P.recordEvent({
1104
+ return n.statusReset && await N.recordEvent({
998
1105
  runId: t.runId,
999
1106
  eventType: "run-redriven",
1000
1107
  payload: {
@@ -1012,7 +1119,7 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
1012
1119
  workflows: e.discovered.workflows ?? [],
1013
1120
  runResume: i
1014
1121
  }, t.runId, t.step);
1015
- return n.statusReset && await P.recordEvent({
1122
+ return n.statusReset && await N.recordEvent({
1016
1123
  runId: t.runId,
1017
1124
  eventType: "run-redriven",
1018
1125
  payload: {
@@ -1027,7 +1134,7 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
1027
1134
  reason: n.outcome.reason
1028
1135
  };
1029
1136
  };
1030
- let a = (e.scheduleCoordination ?? "single") === "advisoryLock" ? Dr(e.store, e.scheduleReplicaId ?? `pid-${process.pid}`) : ni, s = Nr({
1137
+ let a = (e.scheduleCoordination ?? "single") === "advisoryLock" ? kr(e.store, e.scheduleReplicaId ?? `pid-${process.pid}`) : ii, s = Fr({
1031
1138
  coordinator: a,
1032
1139
  replicaId: e.scheduleReplicaId ?? `pid-${process.pid}`
1033
1140
  }), d = {
@@ -1042,17 +1149,17 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
1042
1149
  }
1043
1150
  }, h, g = () => {
1044
1151
  if (h !== void 0) return h;
1045
- if (o !== void 0 && P !== void 0) return h = ne({
1152
+ if (o !== void 0 && N !== void 0) return h = ne({
1046
1153
  store: e.store,
1047
- log: L,
1154
+ log: I,
1048
1155
  workflows: e.discovered.workflows ?? [],
1049
1156
  workflowsProxy: o,
1050
1157
  workflowRuntime: u,
1051
- workflowRunRecorder: P,
1052
- closeChildrenForParent: Nt
1158
+ workflowRunRecorder: N,
1159
+ closeChildrenForParent: Pt
1053
1160
  }), h;
1054
1161
  };
1055
- ee = g, l = $e({
1162
+ ee = g, l = et({
1056
1163
  store: e.store,
1057
1164
  onChange: (t) => e.store.onChange((e) => t({
1058
1165
  table: e.table,
@@ -1067,12 +1174,12 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
1067
1174
  workflows: e.discovered.workflows ?? [],
1068
1175
  facade: () => o,
1069
1176
  cancelRunWithReason: g,
1070
- recordRunEvent: () => P?.recordEvent,
1177
+ recordRunEvent: () => N?.recordEvent,
1071
1178
  ...e.workflowStaleness === void 0 ? {} : { staleness: e.workflowStaleness },
1072
1179
  ...e.workflowSuspendSignalHintMs === void 0 ? {} : { suspendSignalHintMs: e.workflowSuspendSignalHintMs },
1073
1180
  scheduleCoordinated: s,
1074
1181
  onAbandoned: async (t) => {
1075
- await We({
1182
+ await Ge({
1076
1183
  workflows: e.discovered.workflows ?? [],
1077
1184
  facade: () => o,
1078
1185
  log: d,
@@ -1082,7 +1189,7 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
1082
1189
  log: d
1083
1190
  });
1084
1191
  let _ = l;
1085
- _ !== void 0 && qr(() => _.stop()), c = Ze({
1192
+ _ !== void 0 && Yr(() => _.stop()), c = Qe({
1086
1193
  store: e.store,
1087
1194
  onChange: (t) => e.store.onChange((e) => t({
1088
1195
  table: e.table,
@@ -1093,10 +1200,10 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
1093
1200
  tickIntervalMs: e.scheduling.inferenceTickMs
1094
1201
  },
1095
1202
  enabled: (e.discovered.workflows?.length ?? 0) > 0,
1096
- resumeSignal: () => u === void 0 || N === void 0 ? void 0 : async ({ executionId: t, workflowName: n, signalName: r, payload: i }) => {
1097
- await u.runPromise(N.completeSuspendingSignal({
1203
+ resumeSignal: () => u === void 0 || M === void 0 ? void 0 : async ({ executionId: t, workflowName: n, signalName: r, payload: i }) => {
1204
+ await u.runPromise(M.completeSuspendingSignal({
1098
1205
  store: e.store,
1099
- target: Ke(t, n),
1206
+ target: qe(t, n),
1100
1207
  signalName: r,
1101
1208
  payload: i
1102
1209
  }));
@@ -1106,7 +1213,7 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
1106
1213
  log: d
1107
1214
  });
1108
1215
  let v = c;
1109
- v !== void 0 && qr(() => v.stop()), o = (e.discovered.workflows?.length ?? 0) > 0 ? J({
1216
+ v !== void 0 && Yr(() => v.stop()), o = (e.discovered.workflows?.length ?? 0) > 0 ? Gr({
1110
1217
  workflows: e.discovered.workflows ?? [],
1111
1218
  runEffect: (e) => u.runPromise(e),
1112
1219
  onEnqueue: () => m?.publishWake(),
@@ -1117,23 +1224,23 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
1117
1224
  },
1118
1225
  rememberStartContext: te,
1119
1226
  signal: async (t, n, r) => {
1120
- let i = await N.sendWorkflowSignal({
1227
+ let i = await M.sendWorkflowSignal({
1121
1228
  store: e.store,
1122
- recorder: P,
1229
+ recorder: N,
1123
1230
  target: t,
1124
1231
  signalName: n,
1125
1232
  payload: r
1126
1233
  });
1127
- return await u.runPromise(N.completeSuspendingSignal({
1234
+ return await u.runPromise(M.completeSuspendingSignal({
1128
1235
  store: e.store,
1129
1236
  target: t,
1130
1237
  signalName: n,
1131
1238
  payload: r
1132
1239
  })).catch(() => {}), i;
1133
1240
  },
1134
- update: (t, n, r, i) => N.sendWorkflowUpdate({
1241
+ update: (t, n, r, i) => M.sendWorkflowUpdate({
1135
1242
  store: e.store,
1136
- recorder: P,
1243
+ recorder: N,
1137
1244
  target: t,
1138
1245
  updateName: n,
1139
1246
  payload: r,
@@ -1152,34 +1259,34 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
1152
1259
  }, t).then((e) => e.outcome)
1153
1260
  }) : void 0;
1154
1261
  }
1155
- let Bt = G.mergeAll(Dt.toLayer(j), Ot), Vt = it(j, e.discovered.queries.map((e) => e.descriptor.name), de), Ht = G.mergeAll(Dt.toLayer(Vt), Ot), F = e.observability, Ut = await gr({
1262
+ let Vt = G.mergeAll(Ot.toLayer(A), kt), Ht = at(A, e.discovered.queries.map((e) => e.descriptor.name), de), Ut = G.mergeAll(Ot.toLayer(Ht), kt), P = e.observability, Wt = await vr({
1156
1263
  ...e.appName === void 0 ? {} : { serviceName: e.appName },
1157
- ...F && F.spanProcessors.length > 0 ? { extraSpanProcessors: F.spanProcessors } : {},
1158
- ...F && F.metricReaders.length > 0 ? { extraMetricReaders: F.metricReaders } : {},
1159
- ...F && Object.keys(F.resourceAttributes).length > 0 ? { resourceAttributes: F.resourceAttributes } : {},
1160
- ...F && F.sampler !== void 0 ? { sampler: F.sampler } : {}
1161
- }), Wt = !1, I = e.store.ping ? () => e.store.ping().then(() => !0).catch(() => !1) : void 0, { server: Gt, shutdown: Kt } = ri({
1162
- group: Dt,
1163
- handlersLayer: Bt,
1164
- httpHandlersLayer: Ht,
1264
+ ...P && P.spanProcessors.length > 0 ? { extraSpanProcessors: P.spanProcessors } : {},
1265
+ ...P && P.metricReaders.length > 0 ? { extraMetricReaders: P.metricReaders } : {},
1266
+ ...P && Object.keys(P.resourceAttributes).length > 0 ? { resourceAttributes: P.resourceAttributes } : {},
1267
+ ...P && P.sampler !== void 0 ? { sampler: P.sampler } : {}
1268
+ }), Gt = !1, F = e.store.ping ? () => e.store.ping().then(() => !0).catch(() => !1) : void 0, { server: Kt, shutdown: qt } = ai({
1269
+ group: Ot,
1270
+ handlersLayer: Vt,
1271
+ httpHandlersLayer: Ut,
1165
1272
  port: e.port ?? 4e3,
1166
1273
  ...e.host === void 0 ? {} : { host: e.host },
1167
1274
  path: e.path ?? "/ws",
1168
- tracerLayer: Ut.layer,
1275
+ tracerLayer: Wt.layer,
1169
1276
  security: re(e),
1170
- ...tt,
1277
+ ...nt,
1171
1278
  healthCheck: {
1172
- isReady: () => Wt,
1173
- ...I ? { ping: I } : {}
1279
+ isReady: () => Gt,
1280
+ ...F ? { ping: F } : {}
1174
1281
  },
1175
- ...Tt.length > 0 ? { httpRoutes: Tt } : {},
1282
+ ...Et.length > 0 ? { httpRoutes: Et } : {},
1176
1283
  ...e.getStore === void 0 ? {} : { getStore: e.getStore },
1177
1284
  ...Se.size > 0 ? { webhookRoutes: Se } : {},
1178
1285
  ...e.inspectRoute === void 0 ? {} : { inspectRoute: e.inspectRoute }
1179
- }), qt = Hi(Gt);
1180
- if (await mr(Gt), (e.discovered.schedules?.length ?? 0) > 0) {
1181
- let t = (e.scheduleCoordination ?? "single") === "advisoryLock" ? Dr(e.store, e.scheduleReplicaId ?? `pid-${process.pid}`) : ni;
1182
- h = await ii(e.discovered.schedules ?? [], {
1286
+ }), Jt = Ji(Kt);
1287
+ if (await hr(Kt), (e.discovered.schedules?.length ?? 0) > 0) {
1288
+ let t = (e.scheduleCoordination ?? "single") === "advisoryLock" ? kr(e.store, e.scheduleReplicaId ?? `pid-${process.pid}`) : ii;
1289
+ h = await oi(e.discovered.schedules ?? [], {
1183
1290
  store: e.store,
1184
1291
  coordinator: t,
1185
1292
  defaultTrigger: e.scheduleDefaultTrigger ?? "self",
@@ -1187,7 +1294,7 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
1187
1294
  armSelf: e.scheduleArmSelf ?? !0,
1188
1295
  dormancy: e.dormancy ?? "always-on",
1189
1296
  ...e.dormancyTenantId === void 0 ? {} : { dormancyTenantId: e.dormancyTenantId },
1190
- buildContext: ({ traceId: t, scheduleName: n, subject: r }) => Re({
1297
+ buildContext: ({ traceId: t, scheduleName: n, subject: r }) => ze({
1191
1298
  subject: r,
1192
1299
  traceId: t
1193
1300
  }, e.store, void 0, `schedule:${n}`),
@@ -1207,16 +1314,16 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
1207
1314
  ...e.onScheduleRunEvent === void 0 ? {} : { onRunEvent: e.onScheduleRunEvent }
1208
1315
  }), e.onSchedulerReady?.(h);
1209
1316
  }
1210
- let L = e.log ?? R({ scope: "voltro:serve" }), Jt, Yt;
1211
- if ((e.discovered.subscribers?.length ?? 0) > 0 && (Jt = xe(e.discovered.subscribers ?? [], e.store, L.child("subscribe"), e.schemaRegistry, D.bus)), (e.discovered.reactions?.length ?? 0) > 0) {
1212
- let t = L.child("reaction"), n = async (n, r) => {
1317
+ let I = e.log ?? L({ scope: "voltro:serve" }), Yt, Xt;
1318
+ if ((e.discovered.subscribers?.length ?? 0) > 0 && (Yt = xe(e.discovered.subscribers ?? [], e.store, I.child("subscribe"), e.schemaRegistry, Le.bus)), (e.discovered.reactions?.length ?? 0) > 0) {
1319
+ let t = I.child("reaction"), n = async (n, r) => {
1213
1320
  if (n.kind === "workflow") {
1214
1321
  if (S === void 0) {
1215
1322
  t.warn("reaction workflow act skipped — no workflow engine in this app", { workflow: n.workflow });
1216
1323
  return;
1217
1324
  }
1218
1325
  let e = n.payload === void 0 ? r.new ?? r.old ?? {} : n.payload(r);
1219
- await Wr(S, {
1326
+ await Kr(S, {
1220
1327
  traceId: `reaction:${n.workflow}`,
1221
1328
  source: `reaction:${n.workflow}`
1222
1329
  }).start(n.workflow, e);
@@ -1224,8 +1331,8 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
1224
1331
  }
1225
1332
  await pe(n.agent, r, {
1226
1333
  findAgentSend: (t) => e.discovered.actions.find((e) => e.descriptor.name === `${t}.send`),
1227
- runAction: (e, t, n) => Promise.resolve(ft(e, t, n)),
1228
- makeSubject: (e) => Mn(e),
1334
+ runAction: (e, t, n) => Promise.resolve(pt(e, t, n)),
1335
+ makeSubject: (e) => Nn(e),
1229
1336
  now: () => Date.now(),
1230
1337
  log: t
1231
1338
  });
@@ -1239,161 +1346,161 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
1239
1346
  } catch (e) {
1240
1347
  return t.warn("reaction budget check failed — refusing the act", { tenantId: n }, e), !1;
1241
1348
  }
1242
- }, i = At(e.store, { onError: (e) => t.warn("reaction: rate-slot claim failed; refusing the act", { cause: String(e) }) });
1243
- Yt = st(e.discovered.reactions ?? [], e.store, {
1349
+ }, i = jt(e.store, { onError: (e) => t.warn("reaction: rate-slot claim failed; refusing the act", { cause: String(e) }) });
1350
+ Xt = ct(e.discovered.reactions ?? [], e.store, {
1244
1351
  runAct: n,
1245
1352
  checkBudget: r,
1246
1353
  claimRateSlot: (e) => i.claim(e)
1247
1354
  }, t);
1248
1355
  }
1249
- let Xt;
1250
- (e.discovered.aggregates?.length ?? 0) > 0 && (Xt = await v({
1356
+ let Zt;
1357
+ (e.discovered.aggregates?.length ?? 0) > 0 && (Zt = await v({
1251
1358
  discovered: e.discovered.aggregates ?? [],
1252
1359
  store: e.store,
1253
- log: L.child("aggregate"),
1360
+ log: I.child("aggregate"),
1254
1361
  ...e.analytics === void 0 ? {} : { analytics: e.analytics },
1255
1362
  ...e.aggregateStorage === void 0 ? {} : { storage: e.aggregateStorage },
1256
1363
  ...e.aggregateCoordinator === void 0 ? {} : { coordinator: e.aggregateCoordinator }
1257
- }), ze = G.succeed(rr, Xt.registry));
1258
- let Zt;
1259
- (e.discovered.expectations?.length ?? 0) > 0 && (Zt = dr({
1364
+ }), Be = G.succeed(ar, Zt.registry));
1365
+ let Qt;
1366
+ (e.discovered.expectations?.length ?? 0) > 0 && (Qt = fr({
1260
1367
  discovered: e.discovered.expectations ?? [],
1261
1368
  store: e.store,
1262
- log: L.child("expectation")
1263
- }), Be = G.succeed(sr, Zt.registry)), (e.discovered.budgets?.length ?? 0) > 0 && (n = pr({
1369
+ log: I.child("expectation")
1370
+ }), Ve = G.succeed(cr, Qt.registry)), (e.discovered.budgets?.length ?? 0) > 0 && (n = mr({
1264
1371
  discovered: e.discovered.budgets ?? [],
1265
- log: L.child("finops")
1266
- }), He = G.succeed(ir, n.registry));
1267
- let Qt;
1268
- return (e.discovered.experiments?.length ?? 0) > 0 && (Qt = fr({
1372
+ log: I.child("finops")
1373
+ }), Ue = G.succeed(K, n.registry));
1374
+ let $t;
1375
+ return (e.discovered.experiments?.length ?? 0) > 0 && ($t = pr({
1269
1376
  discovered: e.discovered.experiments ?? [],
1270
1377
  store: e.store,
1271
- log: L.child("experiment")
1272
- }), Ge = G.succeed(cr, Qt.registry)), Wt = !0, e.bootTiming?.mark("ready"), {
1378
+ log: I.child("experiment")
1379
+ }), Ke = G.succeed(lr, $t.registry)), Gt = !0, e.bootTiming?.mark("ready"), {
1273
1380
  dispatcher: r,
1274
- server: Gt,
1381
+ server: Kt,
1275
1382
  scheduler: h,
1276
- eventsSnapshot: me(D.bus, D.declared),
1383
+ eventsSnapshot: me(Le.bus, Le.declared),
1277
1384
  membersSnapshot: () => ({
1278
1385
  members: Ie.membership.list(),
1279
1386
  capturedAt: Date.now()
1280
1387
  }),
1281
- agentTools: () => yt,
1282
- rpcMetrics: () => Xe,
1388
+ agentTools: () => bt,
1389
+ rpcMetrics: () => Ze,
1283
1390
  webhooksService: () => ve,
1284
1391
  runCanceller: () => ee(),
1285
1392
  flowControlHealth: () => l?.cancelHealth(),
1286
1393
  inferenceHealth: () => c?.health(),
1287
- workflowWriteActions: () => S === void 0 || P === void 0 ? void 0 : se({
1394
+ workflowWriteActions: () => S === void 0 || N === void 0 ? void 0 : se({
1288
1395
  store: e.store,
1289
- log: L,
1396
+ log: I,
1290
1397
  workflows: e.discovered.workflows ?? [],
1291
1398
  workflowsProxy: o,
1292
1399
  workflowRuntime: u,
1293
- workflowRunRecorder: P,
1294
- closeChildrenForParent: Nt
1400
+ workflowRunRecorder: N,
1401
+ closeChildrenForParent: Pt
1295
1402
  }),
1296
1403
  redriveWorkflowRun: (e) => f ? f(e) : Promise.reject(/* @__PURE__ */ Error("redrive: this app registers no workflows")),
1297
1404
  resumeWorkflowRunFromStep: (e) => p ? p(e) : Promise.reject(/* @__PURE__ */ Error("resume-from-step: this app registers no workflows")),
1298
1405
  close: async () => {
1299
- Wt = !1, await qt.drainRequests();
1406
+ Gt = !1, await Jt.drainRequests();
1300
1407
  for (let e of Ce) try {
1301
1408
  await e();
1302
1409
  } catch (e) {
1303
- L.warn("serve: teardown step failed", {}, e);
1410
+ I.warn("serve: teardown step failed", {}, e);
1304
1411
  }
1305
- await Le?.detach(), await Ie.detach(), Xt?.detach(), Zt?.detach(), n?.detach(), Qt?.detach(), Yt?.(), Jt?.(), await h?.shutdown(), r.close(), await m?.detach(), await u?.dispose(), await Kt(), await qt.finish();
1412
+ await Re?.detach(), await Ie.detach(), Zt?.detach(), Qt?.detach(), n?.detach(), $t?.detach(), Xt?.(), Yt?.(), await h?.shutdown(), r.close(), await m?.detach(), await u?.dispose(), await qt(), await Jt.finish();
1306
1413
  }
1307
1414
  };
1308
- }, $ = R({ scope: "voltro:serve" }), ga = (e, t, n) => (e === "production" || e === "staging") && t !== "memory" && n !== "0", _a = Ht, va = async (e) => {
1309
- let t = xn(process.cwd());
1310
- if (On(t)) {
1415
+ }, $ = L({ scope: "voltro:serve" }), Da = (e, t, n) => (e === "production" || e === "staging") && t !== "memory" && n !== "0", Oa = Ut, ka = async (e) => {
1416
+ let t = Sn(process.cwd());
1417
+ if (kn(t)) {
1311
1418
  let n;
1312
1419
  try {
1313
- let e = await import(kn(t).href);
1420
+ let e = await import(An(t).href);
1314
1421
  typeof e.runServe == "function" ? n = e.runServe : $.warn("serve bundle has no runServe export — using the standard serve path");
1315
1422
  } catch (e) {
1316
1423
  $.warn("serve bundle failed to load — using the standard serve path", {}, e);
1317
1424
  }
1318
1425
  if (n) return $.info("serve: booting from the precompiled serve bundle"), n(e);
1319
1426
  }
1320
- return ya(e);
1321
- }, ya = async (s) => {
1322
- let d = Sn();
1427
+ return Aa(e);
1428
+ }, Aa = async (s) => {
1429
+ let d = Cn();
1323
1430
  e("serve");
1324
1431
  try {
1325
- bi();
1432
+ Ci();
1326
1433
  } catch (e) {
1327
1434
  throw i(e instanceof Error ? e.message : String(e));
1328
1435
  }
1329
- let g = process.cwd(), v = await He(g), ne = F({
1436
+ let g = process.cwd(), v = await Ue(g), ne = P({
1330
1437
  kind: "api",
1331
1438
  configPort: v?.port,
1332
1439
  env: process.env,
1333
- flagPort: _a(s, "--port")
1440
+ flagPort: Oa(s, "--port")
1334
1441
  });
1335
1442
  for (let e of ne.warnings) $.warn(e);
1336
1443
  let ie = ne.port;
1337
- $r(Qr(v?.secrets)), await Ut({
1444
+ ti($r(v?.secrets)), await Wt({
1338
1445
  rawEnv: v?.env,
1339
1446
  appType: "api",
1340
1447
  root: g,
1341
1448
  log: $,
1342
1449
  generateTypes: !1
1343
1450
  }), d.mark("config");
1344
- let y = (process.env.DB_DIALECT ?? v?.store ?? "memory").toLowerCase(), se = (y === "mariadb" || y === "postgres" || y === "mssql") && (process.env.CDC ?? "1") !== "0", ce = y === "mariadb" ? "mariadb" : y === "mssql" ? "mssql" : void 0, le = bn(g);
1345
- if (!r() && On(le)) try {
1346
- let e = await import(kn(le).href);
1451
+ let y = (process.env.DB_DIALECT ?? v?.store ?? "memory").toLowerCase(), se = (y === "mariadb" || y === "postgres" || y === "mssql") && (process.env.CDC ?? "1") !== "0", ce = y === "mariadb" ? "mariadb" : y === "mssql" ? "mssql" : void 0, le = xn(g);
1452
+ if (!r() && kn(le)) try {
1453
+ let e = await import(An(le).href);
1347
1454
  if (e.modules) {
1348
1455
  let t = {};
1349
- for (let [n, r] of Object.entries(e.modules)) t[En(g, n)] = r;
1456
+ for (let [n, r] of Object.entries(e.modules)) t[Dn(g, n)] = r;
1350
1457
  n(t), $.info("precompiled api bundle loaded", { modules: Object.keys(t).length });
1351
1458
  }
1352
1459
  } catch (e) {
1353
1460
  $.warn("precompiled api bundle failed to load — falling back to source", {}, e);
1354
1461
  }
1355
- let b = await Ye(g), x = await Ot(b, { cdc: se && ce !== void 0 }), ue = Vt(x);
1462
+ let b = await Xe(g), x = await kt(b, { cdc: se && ce !== void 0 }), ue = Ht(x);
1356
1463
  {
1357
1464
  let e = /* @__PURE__ */ new Set([
1358
1465
  ...x.queries.filter((e) => e.descriptor.overridesPlugin === !0).map((e) => e.descriptor.name),
1359
1466
  ...x.mutations.filter((e) => e.descriptor.overridesPlugin === !0).map((e) => e.descriptor.name),
1360
1467
  ...x.actions.filter((e) => e.descriptor.overridesPlugin === !0).map((e) => e.descriptor.name)
1361
1468
  ]);
1362
- Xt(Yt(v?.plugins ?? []), [
1469
+ nn(Xt(v?.plugins ?? []), [
1363
1470
  ...x.queries.map((e) => e.descriptor.name),
1364
1471
  ...x.mutations.map((e) => e.descriptor.name),
1365
1472
  ...x.actions.map((e) => e.descriptor.name),
1366
1473
  ...x.streams.map((e) => e.descriptor.name)
1367
1474
  ], e);
1368
- let t = ae(x.serverOnlyLeaks, Ae(process.env, "strict"), br, "`voltro serve`");
1475
+ let t = ae(x.serverOnlyLeaks, Ae(process.env, "strict"), Sr, "`voltro serve`");
1369
1476
  if (t.action === "fail") throw i(t.message ?? "");
1370
1477
  t.action === "warn" && $.warn(t.message ?? "");
1371
1478
  }
1372
- let fe = b.filter((e) => vn.test(e)), pe = fe.length > 0 ? await _n(fe, $.child("webhooks")) : {
1479
+ let fe = b.filter((e) => yn.test(e)), pe = fe.length > 0 ? await vn(fe, $.child("webhooks")) : {
1373
1480
  outgoing: [],
1374
1481
  incoming: [],
1375
1482
  providers: []
1376
- }, me = hn(x.events), be = pe.outgoing.length + pe.incoming.length + pe.providers.length + me.length === 0 ? void 0 : {
1483
+ }, me = gn(x.events), be = pe.outgoing.length + pe.incoming.length + pe.providers.length + me.length === 0 ? void 0 : {
1377
1484
  ...pe,
1378
1485
  outgoing: [...pe.outgoing, ...me]
1379
1486
  }, xe = rn({
1380
1487
  nodeEnv: process.env.NODE_ENV,
1381
1488
  cdcDialect: ce,
1382
1489
  declared: v?.schema
1383
- }), we = Qt({
1490
+ }), we = an({
1384
1491
  gates: xe,
1385
1492
  runtime: {
1386
1493
  traces: ve(),
1387
- undo: oi()
1494
+ undo: ci()
1388
1495
  }
1389
1496
  });
1390
1497
  if (we !== void 0) throw i(`serve: ${we}`);
1391
- let De = nn({
1498
+ let De = tn({
1392
1499
  mix: x.featureMix,
1393
1500
  plugins: v?.plugins ?? [],
1394
1501
  gates: xe,
1395
1502
  ...ce ? { cdcDialect: ce } : {}
1396
- }), Oe = v?.analytics !== void 0 && v.analytics.kind !== "noop" && y !== "memory" ? (await I(y)).makeSqlLayer(k()) : void 0, ke = await qe({
1503
+ }), Oe = v?.analytics !== void 0 && v.analytics.kind !== "noop" && y !== "memory" ? (await F(y)).makeSqlLayer(O()) : void 0, ke = await Je({
1397
1504
  spec: v?.analytics,
1398
1505
  sqlLayer: Oe,
1399
1506
  log: $
@@ -1402,51 +1509,51 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
1402
1509
  for (let n of [...De, ...ke.tables]) e.has(n.tableName) || (e.add(n.tableName), t.push(n));
1403
1510
  return t;
1404
1511
  })();
1405
- for (let e of T) Jn(e);
1512
+ for (let e of T) Xn(e);
1406
1513
  {
1407
- let e = xr(si(Be(x), It(T)));
1514
+ let e = Cr(li(Ve(x), Lt(T)));
1408
1515
  e !== void 0 && $.warn(e);
1409
1516
  }
1410
1517
  let Pe = (process.env.NODE_ENV ?? "").toLowerCase();
1411
- if (ga(Pe, y, process.env.VOLTRO_AUTO_MIGRATE)) {
1412
- let e = (await I(y)).makeSqlLayer(k()), t = await W.runPromise(Qn.SqlClient.pipe(W.flatMap((e) => tr(e, g)), W.provide(e), W.catchAll(() => W.succeed([]))));
1518
+ if (Da(Pe, y, process.env.VOLTRO_AUTO_MIGRATE)) {
1519
+ let e = (await F(y)).makeSqlLayer(O()), t = await W.runPromise(er.SqlClient.pipe(W.flatMap((e) => rr(e, g)), W.provide(e), W.catchAll(() => W.succeed([]))));
1413
1520
  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));
1414
- let n = await W.runPromise(Qn.SqlClient.pipe(W.flatMap((e) => nr(e, T, {
1521
+ let n = await W.runPromise(er.SqlClient.pipe(W.flatMap((e) => ir(e, T, {
1415
1522
  appliedBy: `serve:${Pe}`,
1416
1523
  environment: "prod",
1417
1524
  dialectId: y
1418
1525
  })), W.provide(e)));
1419
- n.kind === "prod-mismatch" && ($.error(er(n, y)), $.error(en({
1526
+ n.kind === "prod-mismatch" && ($.error(nr(n, y)), $.error(on({
1420
1527
  gates: xe,
1421
1528
  nodeEnv: process.env.NODE_ENV,
1422
1529
  cdcDialect: ce,
1423
1530
  declared: v?.schema
1424
- })), $.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(er(n, y));
1531
+ })), $.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(nr(n, y));
1425
1532
  }
1426
- await Jt({
1533
+ await Yt({
1427
1534
  dialectId: y,
1428
1535
  tables: T,
1429
- mode: qt(v?.reactiveTriggers),
1430
- lockSchema: k().schema,
1431
- makeLayer: async () => (await I(y)).makeSqlLayer(k()),
1536
+ mode: Jt(v?.reactiveTriggers),
1537
+ lockSchema: O().schema,
1538
+ makeLayer: async () => (await F(y)).makeSqlLayer(O()),
1432
1539
  log: {
1433
1540
  info: (e, t) => $.info(e, t ?? {}),
1434
1541
  warn: (e, t) => $.warn(e, t ?? {})
1435
1542
  }
1436
1543
  });
1437
- let Fe = Ur(T);
1544
+ let Fe = Wr(T);
1438
1545
  d.mark("discover");
1439
- let E = await rt(v, void 0);
1546
+ let E = await it(v, void 0);
1440
1547
  {
1441
1548
  let e = await ee(E);
1442
1549
  if (e !== void 0) throw i(`serve: ${e}`);
1443
1550
  }
1444
- let Ve = ui(E, y);
1445
- for (let e of tt({
1551
+ let He = fi(E, y);
1552
+ for (let e of nt({
1446
1553
  dialect: String(v?.store ?? process.env.DB_DIALECT ?? "postgres"),
1447
1554
  changeStrategy: (process.env.CDC ?? "1") === "0" ? "inline" : "cdc",
1448
1555
  dbUrl: process.env.DB_URL,
1449
- crossReplicaBus: Mi(v?.plugins ?? [])?.broadcast.crossReplica === !0,
1556
+ crossReplicaBus: Fi(v?.plugins ?? [])?.broadcast.crossReplica === !0,
1450
1557
  tables: x.tables.map((e) => ({
1451
1558
  tableName: e.tableName,
1452
1559
  isReactive: e.isReactive === !0
@@ -1457,144 +1564,144 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
1457
1564
  })
1458
1565
  })) e.level === "warn" ? $.warn(e.message) : $.info(e.message);
1459
1566
  {
1460
- let e = _t({
1567
+ let e = vt({
1461
1568
  tables: Kn().map((e) => ({ tableName: e.tableName })),
1462
1569
  queries: x.queries.map((e) => ({
1463
1570
  name: e.descriptor.name,
1464
1571
  source: e.descriptor.source
1465
1572
  }))
1466
- }), t = pt(e);
1573
+ }), t = mt(e);
1467
1574
  t !== void 0 && $.warn(t);
1468
1575
  }
1469
1576
  v?.cache && !process.env.CACHE_BACKEND && (process.env.CACHE_BACKEND = v.cache), v?.cacheRedisUrl && !process.env.CACHE_REDIS_URL && (process.env.CACHE_REDIS_URL = v.cacheRedisUrl), v?.cacheRedisDriver && !process.env.CACHE_REDIS_DRIVER && (process.env.CACHE_REDIS_DRIVER = v.cacheRedisDriver), v?.cacheKeyPrefix && !process.env.CACHE_KEY_PREFIX && (process.env.CACHE_KEY_PREFIX = v.cacheKeyPrefix);
1470
- let { service: Ue, invalidationBus: We, snapshotCache: Ke, cache: Je, semantic: Ze, evictSource: $e, backend: it, stats: ot, dispose: st } = await Xe({
1577
+ let { service: We, invalidationBus: Ge, snapshotCache: qe, cache: Ye, semantic: Qe, evictSource: et, backend: at, stats: st, dispose: ct } = await Ze({
1471
1578
  env: process.env,
1472
1579
  semantic: v?.cacheSemantic ?? !1
1473
1580
  });
1474
- Ze !== 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")), E.onChange((e) => {
1475
- if (W.runFork(We.publish(e.table)), $e !== void 0) {
1581
+ Qe !== void 0 && $.info("semantic cache enabled — reactive eviction on live writes"), $.info(`cache backend resolved: ${at}` + (at === "redis" ? ` (driver ${process.env.CACHE_REDIS_DRIVER ?? "resp"})` : " — in-process, not cross-instance")), E.onChange((e) => {
1582
+ if (W.runFork(Ge.publish(e.table)), et !== void 0) {
1476
1583
  let t = (e.new ?? e.old)?.id;
1477
- $e({
1584
+ et({
1478
1585
  table: e.table,
1479
1586
  op: e.op,
1480
1587
  ...t === void 0 ? {} : { id: t }
1481
1588
  });
1482
1589
  }
1483
1590
  }), v?.kv && !process.env.KV_BACKEND && (process.env.KV_BACKEND = v.kv), v?.kvRedisUrl && !process.env.KV_REDIS_URL && (process.env.KV_REDIS_URL = v.kvRedisUrl), v?.kvKeyPrefix && !process.env.KV_KEY_PREFIX && (process.env.KV_KEY_PREFIX = v.kvKeyPrefix);
1484
- let { kv: ut, service: dt } = await jr({ store: E });
1485
- Nt({
1591
+ let { kv: dt, service: ft } = await Nr({ store: E });
1592
+ Pt({
1486
1593
  log: $,
1487
- max: Kt(),
1594
+ max: qt(),
1488
1595
  outOfPool: p(y, (process.env.CDC ?? "1") !== "0"),
1489
1596
  readPools: t.replicationSnapshot()?.replicaCount ?? 0,
1490
1597
  always: !0
1491
1598
  }), d.mark("store");
1492
- let ht = ur({
1599
+ let gt = dr({
1493
1600
  store: E,
1494
1601
  sink: ke.sink,
1495
1602
  log: $
1496
- }), bt = Ge({
1603
+ }), xt = Ke({
1497
1604
  store: E,
1498
1605
  dialect: y,
1499
1606
  log: { info: (e) => $.info(e) }
1500
- }), M = v?.plugins ?? [], At = process.env.POD_NAME ?? process.env.HOSTNAME ?? `serve-${process.pid}`, Lt, zt;
1501
- y !== "memory" && (Lt = Zn.make((await I(y)).makeSqlLayer(k())), zt = await Lt.runPromise(Qn.SqlClient));
1502
- let Ht = [
1607
+ }), j = v?.plugins ?? [], jt = process.env.POD_NAME ?? process.env.HOSTNAME ?? `serve-${process.pid}`, Rt, Bt;
1608
+ y !== "memory" && (Rt = $n.make((await F(y)).makeSqlLayer(O())), Bt = await Rt.runPromise(er.SqlClient));
1609
+ let Ut = [
1503
1610
  "postgres",
1504
1611
  "mariadb",
1505
1612
  "mysql",
1506
1613
  "mssql"
1507
- ].includes(y) ? Dr(E, At, $) : ni, gn = N(v?.scheduling), xn = Nr({
1508
- maxIdleIntervalMs: gn.pollCeilingMs,
1509
- coordinator: Ht,
1510
- replicaId: At,
1614
+ ].includes(y) ? kr(E, jt, $) : ii, _n = M(v?.scheduling), Sn = Fr({
1615
+ maxIdleIntervalMs: _n.pollCeilingMs,
1616
+ coordinator: Ut,
1617
+ replicaId: jt,
1511
1618
  log: $
1512
- }), Cn = [], wn = process.env.POD_NAME ?? process.env.HOSTNAME ?? `serve-${process.pid}`, Dn = Mi(v?.plugins ?? [])?.broadcast?.provider, R = Qe(v?.plugins, v?.name ?? Tn(g));
1619
+ }), wn = [], Tn = process.env.POD_NAME ?? process.env.HOSTNAME ?? `serve-${process.pid}`, On = Fi(v?.plugins ?? [])?.broadcast?.provider, L = $e(v?.plugins, v?.name ?? En(g));
1513
1620
  {
1514
- let e = et(v?.plugins, v?.name ?? Tn(g));
1621
+ let e = tt(v?.plugins, v?.name ?? En(g));
1515
1622
  e !== void 0 && $.warn(e);
1516
1623
  }
1517
- let An = jt(v?.plugins, {
1518
- instanceId: wn,
1519
- namespace: R,
1624
+ let jn = Mt(v?.plugins, {
1625
+ instanceId: Tn,
1626
+ namespace: L,
1520
1627
  meta: { mode: "serve" },
1521
1628
  logger: $
1522
- }), jn = {
1523
- ...zt ? { sql: zt } : {},
1524
- instanceId: wn,
1525
- membership: An.membership,
1526
- ...Dn === void 0 ? {} : { broadcast: Dn },
1527
- broadcastChannels: { presence: ji(R, "presence") },
1629
+ }), Mn = {
1630
+ ...Bt ? { sql: Bt } : {},
1631
+ instanceId: Tn,
1632
+ membership: jn.membership,
1633
+ ...On === void 0 ? {} : { broadcast: On },
1634
+ broadcastChannels: { presence: Pi(L, "presence") },
1528
1635
  scheduleCoordinated: (e, t, n) => {
1529
- let r = xn(e, t, n);
1530
- return Cn.push(r), r;
1636
+ let r = Sn(e, t, n);
1637
+ return wn.push(r), r;
1531
1638
  }
1532
1639
  };
1533
- for (let e of M) e.bindDataStore?.(Ve, jn);
1640
+ for (let e of j) e.bindDataStore?.(He, Mn);
1534
1641
  l({
1535
1642
  store: E,
1536
- ...ct(),
1643
+ ...lt(),
1537
1644
  log: $
1538
1645
  });
1539
- let z = M.filter((e) => typeof e.onChangeEvent == "function");
1540
- if (z.length > 0) {
1646
+ let R = j.filter((e) => typeof e.onChangeEvent == "function");
1647
+ if (R.length > 0) {
1541
1648
  let e = E.changeScope ?? "local";
1542
1649
  E.onChange((t) => {
1543
1650
  let n = ye(t, e);
1544
- for (let e of z) W.runFork(e.onChangeEvent(n).pipe(W.catchAllCause((t) => W.sync(() => $.warn(`plugin ${e.name} onChangeEvent failed`, { error: Xn.pretty(t) })))));
1651
+ for (let e of R) W.runFork(e.onChangeEvent(n).pipe(W.catchAllCause((t) => W.sync(() => $.warn(`plugin ${e.name} onChangeEvent failed`, { error: Qn.pretty(t) })))));
1545
1652
  });
1546
1653
  }
1547
- let Mn = Ne({
1548
- plugins: M,
1654
+ let Nn = Ne({
1655
+ plugins: j,
1549
1656
  appName: v?.name ?? "voltro-api",
1550
1657
  appType: "api",
1551
1658
  voltroVersion: process.env.npm_package_version ?? "0.0.0",
1552
1659
  log: $
1553
1660
  });
1554
- M.length && await Mn.activate(), d.mark("plugins");
1555
- let Nn = await Mn.gatherObservability(), Pn = {
1661
+ j.length && await Nn.activate(), d.mark("plugins");
1662
+ let Pn = await Nn.gatherObservability(), Fn = {
1556
1663
  info: (e, t) => process.stdout.write(`[broadcast] ${e} ${t ? JSON.stringify(t) : ""}\n`),
1557
1664
  warn: (e, t) => process.stderr.write(`[broadcast] ${e} ${t ? JSON.stringify(t) : ""}\n`),
1558
1665
  debug: () => {}
1559
- }, B, Fn = await j(E, v, y, R, Pn, (e, t) => {
1560
- B?.refreshAll(`broadcast gap: missed ${t} change(s) from ${e}`);
1561
- }), In = v?.apiKeys, Ln = (typeof In == "object" ? In.prefix : void 0) ?? "voltro_", Rn = In ? yr(E) : void 0, V = Rn ? kr({ flush: Ar(Rn) }) : void 0;
1562
- V && qr(() => V.shutdown());
1563
- let zn = Rn ? Or(Rn, {
1564
- prefix: Ln,
1666
+ }, z, In = await A(E, v, y, L, Fn, (e, t) => {
1667
+ z?.refreshAll(`broadcast gap: missed ${t} change(s) from ${e}`);
1668
+ }), Ln = v?.apiKeys, Rn = (typeof Ln == "object" ? Ln.prefix : void 0) ?? "voltro_", B = Ln ? xr(E) : void 0, V = B ? jr({ flush: Mr(B) }) : void 0;
1669
+ V && Yr(() => V.shutdown());
1670
+ let zn = B ? Ar(B, {
1671
+ prefix: Rn,
1565
1672
  ...V ? { usage: V } : {}
1566
- }) : void 0, Bn = zn ? [Sr(zn, { prefix: Ln })] : [], Vn = xt([...v?.auth?.strategies ?? [], ...Bn], ki(v?.plugins ?? []), v?.auth?.anonymousTenantRequired ?? !1, v?.auth, () => Ve), Hn = [...v?.restRoutes ?? [], ...zn ? lr(zn, (typeof In == "object" ? In.managementPath : void 0) ?? "/v1/api-keys") : []], Un = St(v?.idempotency, E), Wn = M.map((e) => e.services).filter((e) => e !== void 0), Gn = G.mergeAll(gt({
1673
+ }) : void 0, Bn = zn ? [wr(zn, { prefix: Rn })] : [], Vn = St([...v?.auth?.strategies ?? [], ...Bn], Mi(v?.plugins ?? []), v?.auth?.anonymousTenantRequired ?? !1, v?.auth, () => He), Hn = [...v?.restRoutes ?? [], ...zn ? ur(zn, (typeof Ln == "object" ? Ln.managementPath : void 0) ?? "/v1/api-keys") : []], Un = Ct(v?.idempotency, E), Wn = j.map((e) => e.services).filter((e) => e !== void 0), Gn = G.mergeAll(_t({
1567
1674
  analyticsLayer: ke.layer,
1568
- cacheService: Ue,
1569
- kvService: dt,
1570
- ...Ze === void 0 ? {} : { semanticCache: Ze },
1675
+ cacheService: We,
1676
+ kvService: ft,
1677
+ ...Qe === void 0 ? {} : { semanticCache: Qe },
1571
1678
  pluginServices: Wn,
1572
1679
  userLayers: v?.layers ?? []
1573
- }), Le(v?.http ?? {})), H = await Re({
1680
+ }), Re(v?.http ?? {})), H = await ze({
1574
1681
  files: b,
1575
1682
  store: E,
1576
1683
  log: $,
1577
1684
  seedPolicy: "report",
1578
- seedPattern: dn,
1579
- loadSeedFiles: L,
1580
- startupPattern: on,
1685
+ seedPattern: fn,
1686
+ loadSeedFiles: I,
1687
+ startupPattern: sn,
1581
1688
  loadStartupFiles: a,
1582
1689
  runStartups: o,
1583
- emailPattern: A,
1584
- loadEmailFiles: wt,
1585
- registerEmailTemplates: Ai
1690
+ emailPattern: k,
1691
+ loadEmailFiles: Tt,
1692
+ registerEmailTemplates: Ni
1586
1693
  });
1587
1694
  (H.startupCount > 0 || H.emailCount > 0) && $.info("boot lifecycle", {
1588
1695
  startups: H.startupCount,
1589
1696
  emailTemplates: H.emailCount
1590
- }), H.startups !== void 0 && qr(async () => {
1697
+ }), H.startups !== void 0 && Yr(async () => {
1591
1698
  await H.startups.stop();
1592
1699
  }), de({
1593
1700
  demands: Se(ue),
1594
- isRegistered: (e) => Cr(e) !== void 0
1701
+ isRegistered: (e) => Tr(e) !== void 0
1595
1702
  });
1596
- let U = Ct({
1597
- schedules: at({
1703
+ let qn = wt({
1704
+ schedules: ot({
1598
1705
  schedules: x.schedules,
1599
1706
  seeds: H.seeds,
1600
1707
  store: E,
@@ -1602,30 +1709,30 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
1602
1709
  }),
1603
1710
  workflows: x.workflows ?? [],
1604
1711
  log: $.child("workflow-schedules")
1605
- }), Yn = v?.scheduling ?? {}, rr = Yn.trigger ?? "self", ir = /* @__PURE__ */ new Set([
1712
+ }), Yn = v?.scheduling ?? {}, U = Yn.trigger ?? "self", Zn = /* @__PURE__ */ new Set([
1606
1713
  "postgres",
1607
1714
  "mysql",
1608
1715
  "mariadb",
1609
1716
  "mssql"
1610
- ]), ar = Yn.coordination ?? (ir.has(y) ? "advisoryLock" : "single"), or = ar === "cluster" && ir.has(y), sr = or ? "cluster" : ar === "advisoryLock" && ir.has(y) ? "advisoryLock" : "single";
1611
- ar === "cluster" && !or && $.warn("scheduling.coordination=cluster needs a sql-backed store except sqlite — falling back to single"), ar === "advisoryLock" && !ir.has(y) && $.warn("scheduling.coordination=advisoryLock needs a SQL store (the claim-row gate) — falling back to single");
1612
- let cr, dr = x.workflows.length > 0 || x.workflowWorkers.length > 0 || x.eventTriggers.length > 0 || (be?.outgoing.length ?? 0) > 0 || or, fr;
1613
- if (dr) {
1717
+ ]), ar = Yn.coordination ?? (Zn.has(y) ? "advisoryLock" : "single"), K = ar === "cluster" && Zn.has(y), or = K ? "cluster" : ar === "advisoryLock" && Zn.has(y) ? "advisoryLock" : "single";
1718
+ ar === "cluster" && !K && $.warn("scheduling.coordination=cluster needs a sql-backed store except sqlite — falling back to single"), ar === "advisoryLock" && !Zn.has(y) && $.warn("scheduling.coordination=advisoryLock needs a SQL store (the claim-row gate) — falling back to single");
1719
+ let sr, cr = x.workflows.length > 0 || x.workflowWorkers.length > 0 || x.eventTriggers.length > 0 || (be?.outgoing.length ?? 0) > 0 || K, lr;
1720
+ if (cr) {
1614
1721
  if (y === "mssql") {
1615
- let e = await mn(process.cwd());
1722
+ let e = await hn(process.cwd());
1616
1723
  e && $.warn(e);
1617
1724
  }
1618
- let [{ WorkflowEngine: e }, { makeClusterCronLayer: t, workflowEngineLayer: n, resolveRunnerStorage: r, resolveFailoverTuning: i }] = await Promise.all([import("@effect/workflow"), import("@voltro/workflow/cluster")]), a = or ? U.filter((e) => (e.trigger ?? rr) === "self").map((e) => t({
1725
+ let [{ WorkflowEngine: e }, { makeClusterCronLayer: t, workflowEngineLayer: n, resolveRunnerStorage: r, resolveFailoverTuning: i }] = await Promise.all([import("@effect/workflow"), import("@voltro/workflow/cluster")]), a = K ? qn.filter((e) => (e.trigger ?? U) === "self").map((e) => t({
1619
1726
  name: e.name,
1620
- cron: vr(e),
1727
+ cron: br(e),
1621
1728
  execute: async () => {
1622
- await cr?.fireFromCluster(e.name);
1729
+ await sr?.fireFromCluster(e.name);
1623
1730
  }
1624
1731
  })) : [];
1625
- fr = y === "memory" ? e.layerMemory : await (async () => {
1626
- let e = await I(y), t = r({ sqliteFamily: e.id === "sqlite" || e.id === "turso" });
1732
+ lr = y === "memory" ? e.layerMemory : await (async () => {
1733
+ let e = await F(y), t = r({ sqliteFamily: e.id === "sqlite" || e.id === "turso" });
1627
1734
  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({
1628
- sqlClientLayer: e.makeSqlLayer(k()),
1735
+ sqlClientLayer: e.makeSqlLayer(O()),
1629
1736
  runnerStorage: t,
1630
1737
  dialectId: e.id,
1631
1738
  ...process.env.VOLTRO_WORKFLOW_RUNNER_PORT ? { runnerListenPort: Number(process.env.VOLTRO_WORKFLOW_RUNNER_PORT) } : {},
@@ -1634,24 +1741,24 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
1634
1741
  });
1635
1742
  })();
1636
1743
  }
1637
- let pr = yt(M, yn()), mr = b.filter((e) => /\.subscribe\.tsx?$/.test(e)), K = mr.length > 0 ? await c(mr, $) : [], hr = b.filter((e) => /\.reaction\.tsx?$/.test(e)), q = hr.length > 0 ? await he(hr, $) : [], gr = b.filter((e) => ln.test(e)), _r = gr.length > 0 ? await Me(gr, $) : [], wr = b.filter((e) => /\.aggregate\.tsx?$/.test(e)), Tr = wr.length > 0 ? await _e(wr, $) : [];
1744
+ let fr = bt(j, bn()), pr = b.filter((e) => /\.subscribe\.tsx?$/.test(e)), mr = pr.length > 0 ? await c(pr, $) : [], hr = b.filter((e) => /\.reaction\.tsx?$/.test(e)), q = hr.length > 0 ? await he(hr, $) : [], gr = b.filter((e) => un.test(e)), _r = gr.length > 0 ? await Me(gr, $) : [], vr = b.filter((e) => /\.aggregate\.tsx?$/.test(e)), yr = vr.length > 0 ? await _e(vr, $) : [];
1638
1745
  {
1639
- let e = xr(si(Be({ aggregates: Tr.map((e) => e.definition) }), It(T)));
1746
+ let e = Cr(li(Ve({ aggregates: yr.map((e) => e.definition) }), Lt(T)));
1640
1747
  e !== void 0 && $.warn(e);
1641
1748
  }
1642
- let Er = lt();
1643
- if (Tr.length > 0 && y !== "memory") try {
1644
- let e = (await I(y)).makeSqlLayer(k());
1749
+ let Er = ut();
1750
+ if (yr.length > 0 && y !== "memory") try {
1751
+ let e = (await F(y)).makeSqlLayer(O());
1645
1752
  Er = u(e);
1646
1753
  } catch (e) {
1647
1754
  $.warn("aggregate: SQL storage init failed — falling back to in-process", { err: String(e) });
1648
1755
  }
1649
- let Mr = y === "memory" ? ni : Dr(E, `aggregate@${process.pid}`, $), Pr = b.filter((e) => un.test(e)), Fr = Pr.length > 0 ? await Pt(Pr, $) : [], Ir = b.filter((e) => cn.test(e)), Lr = Ir.length > 0 ? await m(Ir, $) : [], Rr = b.filter((e) => sn.test(e)), zr = Rr.length > 0 ? await w(Rr, $) : [], Br = [], Vr = [], Hr = b.filter((e) => tn.test(e));
1756
+ let Dr = y === "memory" ? ii : kr(E, `aggregate@${process.pid}`, $), Or = b.filter((e) => dn.test(e)), Pr = Or.length > 0 ? await Ft(Or, $) : [], Ir = b.filter((e) => ln.test(e)), Lr = Ir.length > 0 ? await m(Ir, $) : [], Rr = b.filter((e) => cn.test(e)), zr = Rr.length > 0 ? await w(Rr, $) : [], Br = [], Vr = [], Hr = b.filter((e) => Zt.test(e));
1650
1757
  if (Hr.length > 0) {
1651
- let e = $.child("agent"), t = b.filter((e) => $t.test(e));
1652
- t.length > 0 && await an(t, e);
1653
- let n = await Zt(Hr, e);
1654
- for (let e of n.agents) for (let t of Dt(e)) (t.kind === "action" ? Br : Vr).push({
1758
+ let e = $.child("agent"), t = b.filter((e) => en.test(e));
1759
+ t.length > 0 && await Qt(t, e);
1760
+ let n = await $t(Hr, e);
1761
+ for (let e of n.agents) for (let t of Ot(e)) (t.kind === "action" ? Br : Vr).push({
1655
1762
  file: t.file,
1656
1763
  descriptor: t.descriptor,
1657
1764
  executor: t.executor
@@ -1663,26 +1770,26 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
1663
1770
  let e = Y.workflowWriteActions();
1664
1771
  if (e === void 0) throw Error("workflow actions: this app registers no workflows");
1665
1772
  return e;
1666
- }, Wr = qn({
1773
+ }, Ur = Jn({
1667
1774
  dialect: y,
1668
- ...k()
1669
- }), Gr = y === "memory" ? void 0 : (await I(y)).makeSqlLayer(k()), Kr = async () => O({
1775
+ ...O()
1776
+ }), Gr = y === "memory" ? void 0 : (await F(y)).makeSqlLayer(O()), Kr = async () => D({
1670
1777
  sqlLayer: Gr,
1671
1778
  declared: T,
1672
1779
  log: $
1673
- }), Jr = {
1780
+ }), qr = {
1674
1781
  kind: "api",
1675
1782
  meta: {
1676
1783
  name: v?.name ?? "voltro-api",
1677
- voltroVersion: Tt,
1784
+ voltroVersion: Et,
1678
1785
  port: ie,
1679
1786
  mode: "start",
1680
1787
  store: y,
1681
1788
  cdc: se ? "on" : "off",
1682
- ...Wr === void 0 ? {} : { databaseId: Wr }
1789
+ ...Ur === void 0 ? {} : { databaseId: Ur }
1683
1790
  },
1684
1791
  rpc: Ie(x, g),
1685
- workflows: Mt(x, g),
1792
+ workflows: Nt(x, g),
1686
1793
  migrations: Kr,
1687
1794
  events: () => Y.eventsSnapshot(),
1688
1795
  agentTools: () => Y.agentTools(),
@@ -1695,30 +1802,30 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
1695
1802
  }),
1696
1803
  members: () => Y.membersSnapshot(),
1697
1804
  inspectFireSchedule: async ({ name: e, trigger: t }) => {
1698
- if (!cr) throw Error("scheduler not started — this app registers no self-triggered schedules (all schedules are trigger:'external', or there are none).");
1699
- return { runId: await cr.fireNow(e, t) ?? null };
1805
+ if (!sr) throw Error("scheduler not started — this app registers no self-triggered schedules (all schedules are trigger:'external', or there are none).");
1806
+ return { runId: await sr.fireNow(e, t) ?? null };
1700
1807
  },
1701
1808
  inspectBackfillSchedule: _({
1702
- getHandle: () => cr,
1703
- getSchedules: () => U
1809
+ getHandle: () => sr,
1810
+ getSchedules: () => qn
1704
1811
  }),
1705
1812
  ...be === void 0 ? {} : { webhooks: () => ge({
1706
1813
  store: E,
1707
1814
  discoveredWebhooks: be
1708
1815
  }) },
1709
1816
  plugins: () => ({
1710
- plugins: Mn.snapshot(),
1817
+ plugins: Nn.snapshot(),
1711
1818
  capturedAt: Date.now()
1712
1819
  }),
1713
- env: () => Wt(v?.name ?? Tn(g), {
1714
- ...v?.env !== void 0 && yi(v.env) ? { contract: v.env } : {},
1820
+ env: () => Gt(v?.name ?? En(g), {
1821
+ ...v?.env !== void 0 && Si(v.env) ? { contract: v.env } : {},
1715
1822
  plugins: v?.plugins ?? []
1716
1823
  }),
1717
- dataCache: () => ze({
1718
- stats: ot,
1719
- backendKind: it
1824
+ dataCache: () => Be({
1825
+ stats: st,
1826
+ backendKind: at
1720
1827
  }),
1721
- subscriptions: () => Ft(() => B),
1828
+ subscriptions: () => It(() => z),
1722
1829
  inspectTables: () => S(x.tables),
1723
1830
  inspectRows: C({
1724
1831
  store: E,
@@ -1726,20 +1833,20 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
1726
1833
  mask: !0
1727
1834
  }),
1728
1835
  metrics: (e) => Y.rpcMetrics().snapshot(e),
1729
- cluster: () => Rt({
1836
+ cluster: () => zt({
1730
1837
  store: E,
1731
1838
  dialect: y,
1732
- useClusterCron: or,
1839
+ useClusterCron: K,
1733
1840
  scheduleCoordChoice: ar
1734
1841
  }),
1735
1842
  inspectSchedules: () => Te({
1736
- schedules: U,
1737
- defaultTrigger: rr,
1738
- coordination: sr
1843
+ schedules: qn,
1844
+ defaultTrigger: U,
1845
+ coordination: or
1739
1846
  }),
1740
- inspectScheduleRuns: (e) => P(E, e),
1847
+ inspectScheduleRuns: (e) => N(E, e),
1741
1848
  ...f(E, {
1742
- controls: nt(x.workflows ?? []),
1849
+ controls: rt(x.workflows ?? []),
1743
1850
  active: (x.workflows?.length ?? 0) > 0,
1744
1851
  cancellation: () => Y.flowControlHealth()
1745
1852
  }),
@@ -1752,12 +1859,12 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
1752
1859
  inspectRetryWorkflowRun: (e) => J().inspectRetryWorkflowRun(e),
1753
1860
  inspectSignalWorkflowRun: (e) => J().inspectSignalWorkflowRun(e),
1754
1861
  inspectUpdateWorkflowRun: (e) => J().inspectUpdateWorkflowRun(e),
1755
- inspectInferences: (e) => vt({
1862
+ inspectInferences: (e) => yt({
1756
1863
  store: E,
1757
1864
  active: (x.workflows?.length ?? 0) > 0,
1758
1865
  dispatcher: () => Y.inferenceHealth()
1759
1866
  }, e.limit === void 0 ? {} : { limit: e.limit }),
1760
- ...mt({
1867
+ ...ht({
1761
1868
  store: E,
1762
1869
  cancelRun: async (e) => await Y.runCanceller()?.(e) ?? !1,
1763
1870
  retryRun: async (e) => J().inspectRetryWorkflowRun({ runId: e }),
@@ -1766,11 +1873,11 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
1766
1873
  }),
1767
1874
  inspectRedriveWorkflowRun: (e) => Y.redriveWorkflowRun(e),
1768
1875
  inspectResumeWorkflowRunFromStep: (e) => Y.resumeWorkflowRunFromStep(e)
1769
- }, Yr = (process.env.VOLTRO_TENANT_ISOLATION ?? v?.tenancy?.isolation) === "namespace", Xr = Yr && y !== "memory" ? await (async () => {
1770
- let e = await I(y);
1771
- return kt({
1876
+ }, Jr = (process.env.VOLTRO_TENANT_ISOLATION ?? v?.tenancy?.isolation) === "namespace", Xr = Jr && y !== "memory" ? await (async () => {
1877
+ let e = await F(y);
1878
+ return At({
1772
1879
  tables: T,
1773
- sqlLayer: e.makeSqlLayer(k()),
1880
+ sqlLayer: e.makeSqlLayer(O()),
1774
1881
  dialect: y,
1775
1882
  options: { retryFilter: e.retryFilter },
1776
1883
  log: {
@@ -1778,40 +1885,40 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
1778
1885
  error: (e, t, n) => $.error(e, t ?? {}, n)
1779
1886
  }
1780
1887
  });
1781
- })() : void 0, Zr = await ft({
1888
+ })() : void 0, Zr = await pt({
1782
1889
  input: v?.tenancy?.residency,
1783
- namespaceIsolationOn: Yr,
1784
- makeStoreForUrl: (e, t) => rt(v, void 0, Gt(k(), t)),
1890
+ namespaceIsolationOn: Jr,
1891
+ makeStoreForUrl: (e, t) => it(v, void 0, Kt(O(), t)),
1785
1892
  log: {
1786
1893
  info: (e, t) => $.info(e, t),
1787
1894
  warn: (e, t) => $.warn(e, t)
1788
1895
  }
1789
1896
  });
1790
- Zr !== void 0 && qr(async () => {
1897
+ Zr !== void 0 && Yr(async () => {
1791
1898
  await Zr.close();
1792
1899
  });
1793
- let Y = await ha({
1900
+ let Y = await Ea({
1794
1901
  bootTiming: d,
1795
- broadcastNamespace: R,
1902
+ broadcastNamespace: L,
1796
1903
  scheduling: (() => {
1797
- let e = gn;
1904
+ let e = _n;
1798
1905
  return {
1799
1906
  admissionDrainMs: e.admissionDrainMs,
1800
1907
  inferenceTickMs: e.inferenceTickMs,
1801
1908
  cancelSweepMs: e.cancelSweepMs,
1802
1909
  stalenessSweepMs: e.stalenessSweepMs,
1803
- disarmWhenIdle: D({
1910
+ disarmWhenIdle: Le({
1804
1911
  changeScope: E.changeScope,
1805
- broadcastAttached: Fn !== void 0
1912
+ broadcastAttached: In !== void 0
1806
1913
  })
1807
1914
  };
1808
1915
  })(),
1809
1916
  ...v?.workflows?.staleness === void 0 ? {} : { workflowStaleness: v.workflows.staleness },
1810
1917
  ...v?.workflows?.suspendSignalHintMs === void 0 ? {} : { workflowSuspendSignalHintMs: v.workflows.suspendSignalHintMs },
1811
- workflowRecording: Bt(v?.workflows?.recording),
1918
+ workflowRecording: Vt(v?.workflows?.recording),
1812
1919
  membership: {
1813
- ...An,
1814
- instanceId: wn
1920
+ ...jn,
1921
+ instanceId: Tn
1815
1922
  },
1816
1923
  security: {
1817
1924
  defaultDeny: oe(v),
@@ -1831,13 +1938,13 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
1831
1938
  workflows: x.workflows,
1832
1939
  workflowWorkers: x.workflowWorkers,
1833
1940
  eventTriggers: x.eventTriggers,
1834
- schedules: U,
1835
- subscribers: K,
1941
+ schedules: qn,
1942
+ subscribers: mr,
1836
1943
  outboxHandlers: _r,
1837
1944
  connections: x.connections,
1838
1945
  reactions: q,
1839
- aggregates: Tr,
1840
- expectations: Fr,
1946
+ aggregates: yr,
1947
+ expectations: Pr,
1841
1948
  budgets: Lr,
1842
1949
  experiments: zr,
1843
1950
  ...be === void 0 ? {} : { webhooks: be }
@@ -1845,16 +1952,16 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
1845
1952
  log: $,
1846
1953
  analytics: ke.sink,
1847
1954
  aggregateStorage: Er,
1848
- aggregateCoordinator: Mr,
1955
+ aggregateCoordinator: Dr,
1849
1956
  store: E,
1850
- kv: ut,
1851
- cache: Je,
1852
- snapshotCache: Ke,
1957
+ kv: dt,
1958
+ cache: Ye,
1959
+ snapshotCache: qe,
1853
1960
  ...v?.reactive === void 0 ? {} : { reactive: v.reactive },
1854
1961
  schemaRegistry: Fe,
1855
1962
  tenantScopedTables: x.tenantScopedTables,
1856
1963
  softDeleteScopedTables: x.softDeleteScopedTables,
1857
- dataTransferSnapshot: $n(T, y),
1964
+ dataTransferSnapshot: tr(T, y),
1858
1965
  dataTransferDialect: y,
1859
1966
  ...Xr === void 0 ? {} : { ensureTenantProvisioned: Xr.ensure },
1860
1967
  ...Zr === void 0 ? {} : { resolveResidentStore: Zr.resolveStore },
@@ -1865,23 +1972,23 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
1865
1972
  }),
1866
1973
  ...v?.auth === void 0 ? {} : { authority: v.auth },
1867
1974
  ...v?.agents === void 0 ? {} : { agents: v.agents },
1868
- httpRoutes: M.flatMap((e) => e.httpRoutes ?? []),
1869
- getStore: () => Ve,
1975
+ httpRoutes: j.flatMap((e) => e.httpRoutes ?? []),
1976
+ getStore: () => He,
1870
1977
  ...Gn ? { baseLayer: Gn } : {},
1871
- ...fr === void 0 ? {} : { workflowEngineLayer: fr },
1872
- scheduleDefaultTrigger: rr,
1873
- scheduleCoordination: sr,
1874
- scheduleArmSelf: !or,
1978
+ ...lr === void 0 ? {} : { workflowEngineLayer: lr },
1979
+ scheduleDefaultTrigger: U,
1980
+ scheduleCoordination: or,
1981
+ scheduleArmSelf: !K,
1875
1982
  dormancy: process.env.VOLTRO_DORMANCY === "sleep" || process.env.VOLTRO_DORMANCY === "always-on" ? process.env.VOLTRO_DORMANCY : v?.dormancy ?? "always-on",
1876
1983
  scheduleReplicaId: process.env.HOSTNAME ?? `pid-${process.pid}`,
1877
- ...pr === void 0 ? {} : { scheduleFireInterceptor: pr },
1984
+ ...fr === void 0 ? {} : { scheduleFireInterceptor: fr },
1878
1985
  onSchedulerReady: (e) => {
1879
- cr = e;
1986
+ sr = e;
1880
1987
  },
1881
- inspectRoute: { handle: async (e, t, n, r) => await h(e, Jr, t, {
1988
+ inspectRoute: { handle: async (e, t, n, r) => await h(e, qr, t, {
1882
1989
  method: n,
1883
1990
  ...r === void 0 ? {} : { body: r }
1884
- }) || ((n === "GET" ? await pn(e, Jr, t, { method: n }) : null) ?? fn(e, Jr, t, {
1991
+ }) || ((n === "GET" ? await mn(e, qr, t, { method: n }) : null) ?? pn(e, qr, t, {
1885
1992
  method: n,
1886
1993
  ...r === void 0 ? {} : { body: r }
1887
1994
  }) ?? {
@@ -1890,11 +1997,11 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
1890
1997
  body: JSON.stringify({ error: "not an inspect route" })
1891
1998
  }) },
1892
1999
  ...v?.name === void 0 ? {} : { appName: v.name },
1893
- observability: Nn,
2000
+ observability: Pn,
1894
2001
  port: ie,
1895
2002
  ...v?.transport?.wsPath ? { path: v.transport.wsPath } : {}
1896
2003
  });
1897
- return B = Y.dispatcher, te(Ee([
2004
+ return z = Y.dispatcher, te(Ee([
1898
2005
  x.queries,
1899
2006
  x.mutations,
1900
2007
  x.actions,
@@ -1909,14 +2016,14 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
1909
2016
  streams: x.streams.length,
1910
2017
  workflows: x.workflows.length,
1911
2018
  workflowWorkers: x.workflowWorkers.length,
1912
- schedules: U.length,
1913
- scheduleCoordination: sr
1914
- }), d.finish($), qr(async () => {
1915
- for (let e of Cn) e.stop();
1916
- bt.stop();
2019
+ schedules: qn.length,
2020
+ scheduleCoordination: or
2021
+ }), d.finish($), Yr(async () => {
2022
+ for (let e of wn) e.stop();
2023
+ xt.stop();
1917
2024
  try {
1918
- await Y.close(), st(), Lt?.dispose(), await Mn.deactivate(), await Fn?.close(), await Et({
1919
- mirror: ht,
2025
+ await Y.close(), ct(), Rt?.dispose(), await Nn.deactivate(), await In?.close(), await Dt({
2026
+ mirror: gt,
1920
2027
  log: $
1921
2028
  }), await ke.dispose(), await E.close?.();
1922
2029
  } catch (e) {
@@ -1925,4 +2032,4 @@ var Bi = () => Math.max(500, Math.floor(ti() * .6)), Vi = (e) => new Promise((t)
1925
2032
  }), await new Promise(() => {}), 0;
1926
2033
  };
1927
2034
  //#endregion
1928
- export { va as n, ga as r, ya as t };
2035
+ export { ka as n, Da as r, Aa as t };