@voltro/cli 0.11.3 → 0.11.4

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 (64) hide show
  1. package/CHANGELOG.md +173 -0
  2. package/THIRD-PARTY-NOTICES.md +4 -4
  3. package/dist/apiBuild-D9MtlD02.js +2 -0
  4. package/dist/{apiBuild-zFDv0u8y.js → apiBuild-DHHuiwXF.js} +4 -4
  5. package/dist/bin.js +13 -6
  6. package/dist/{commands-BDGYrBhK.js → commands-BwbMqR-1.js} +1982 -1854
  7. package/dist/dev-BsBsIv93.js +2 -0
  8. package/dist/{dev-CGt0PP1f.js → dev-Cvojvb_J.js} +1696 -1654
  9. package/dist/{devActivity-1WtIVyHc.js → devActivity-BhIu6ncs.js} +7 -1
  10. package/dist/devActivity.js +1 -1
  11. package/dist/index.d.ts +3 -0
  12. package/dist/index.js +1 -1
  13. package/dist/{inspectMetrics-SRtv8KDy.js → inspectMetrics-D4EJ8LTi.js} +331 -323
  14. package/dist/{serveCommand-p6e5Ahgx.js → serveCommand-ARqSs73o.js} +397 -350
  15. package/dist/serveEntry.js +3 -3
  16. package/dist/{start-Crl39M38.js → start-DyJE6w1R.js} +281 -273
  17. package/dist/startEntry.js +2 -2
  18. package/package.json +17 -17
  19. package/templates/agent-docs/_manifest.json +1 -1
  20. package/templates/agent-docs/cli.md +86 -2
  21. package/templates/agent-docs/data.md +104 -1
  22. package/templates/agent-docs/database/misc.md +32 -0
  23. package/templates/agent-docs/database/querying.md +14 -1
  24. package/templates/agent-docs/internationalization.md +3 -8
  25. package/templates/agent-docs/reference.md +35 -0
  26. package/templates/agent-docs/workflows.md +31 -0
  27. package/templates/apps/api-ai/package.json +7 -7
  28. package/templates/apps/api-auth/package.json +8 -8
  29. package/templates/apps/api-backend/package.json +7 -7
  30. package/templates/apps/api-backend-deactivation/package.json +7 -7
  31. package/templates/apps/api-backend-mail/package.json +8 -8
  32. package/templates/apps/api-backend-mariadb/package.json +9 -9
  33. package/templates/apps/api-backend-storage/package.json +8 -8
  34. package/templates/apps/api-data-advanced/package.json +8 -8
  35. package/templates/apps/api-durable/package.json +8 -8
  36. package/templates/apps/api-feature-flags/package.json +9 -9
  37. package/templates/apps/api-governance/package.json +8 -8
  38. package/templates/apps/api-kv/package.json +8 -8
  39. package/templates/apps/api-moderation/package.json +8 -8
  40. package/templates/apps/api-observability/package.json +8 -8
  41. package/templates/apps/api-ratelimit/package.json +8 -8
  42. package/templates/apps/api-rbac/package.json +8 -8
  43. package/templates/apps/api-rest/package.json +7 -7
  44. package/templates/apps/api-saas/package.json +11 -11
  45. package/templates/apps/api-search/package.json +8 -8
  46. package/templates/apps/api-versioning/package.json +8 -8
  47. package/templates/apps/api-webhooks/README.md +3 -1
  48. package/templates/apps/api-webhooks/package.json +8 -8
  49. package/templates/apps/changelog/package.json +6 -6
  50. package/templates/apps/edge-functions/package.json +2 -2
  51. package/templates/apps/frontend-admin/package.json +8 -8
  52. package/templates/apps/frontend-app/package.json +8 -8
  53. package/templates/apps/frontend-blank/package.json +7 -7
  54. package/templates/apps/frontend-contact/package.json +7 -7
  55. package/templates/apps/frontend-dashboard/package.json +7 -7
  56. package/templates/apps/frontend-docs/package.json +7 -7
  57. package/templates/apps/frontend-i18n/package.json +6 -6
  58. package/templates/apps/frontend-landing/package.json +7 -7
  59. package/templates/apps/frontend-spa/package.json +7 -7
  60. package/templates/apps/frontend-ssr/package.json +7 -7
  61. package/templates/apps/frontend-ssr-api/package.json +8 -8
  62. package/templates/apps/frontend-static-blog/package.json +6 -6
  63. package/dist/apiBuild-BmPdmhgi.js +0 -2
  64. package/dist/dev-D_PGP9Kx.js +0 -2
@@ -1,46 +1,70 @@
1
- import { kt as e, t } from "./inspectMetrics-SRtv8KDy.js";
2
- import { $ as n, A as r, C as i, D as a, E as o, F as s, G as c, H as l, I as u, J as d, M as f, N as p, O as ee, P as m, Q as h, S as g, T as te, U as ne, W as re, X as _, Y as ie, Z as ae, _ as oe, at as v, b as se, d as ce, et as y, f as b, g as le, h as ue, i as x, it as de, j as S, k as C, m as fe, n as pe, nt as me, o as w, ot as T, q as he, s as ge, st as _e, t as ve, ut as E, v as ye, w as be, x as xe, y as D } from "./dev-CGt0PP1f.js";
3
- import { a as Se, r as Ce } from "./startupRunner-DhlX9nqd.js";
4
- import { n as we, s as O } from "./apiBuild-zFDv0u8y.js";
5
- import { t as Te } from "./bootTiming-BdyP9nYw.js";
6
- import { join as Ee } from "node:path";
7
- import { pathToFileURL as De } from "node:url";
8
- import { Cause as k, Effect as A, Layer as j, ManagedRuntime as Oe } from "effect";
9
- import { createLogger as M } from "@voltro/logger";
10
- import { existsSync as N } from "node:fs";
11
- import { AggregateRegistry as ke, Dispatcher as P, apiKeyManagementRoutes as Ae, applySoftDeleteScope as je, applyTenantScope as Me, attachAnalyticsMirror as Ne, awaitServerListening as Pe, bindMutation as F, bindStream as Fe, bindSubscription as I, buildTracingLayer as Ie, cancelWakeup as Le, compileCron as Re, dataStoreApiKeyStore as ze, dataStoreIdempotencyStore as Be, frameworkApiKeyStrategy as Ve, installPolicyGuardResolver as He, loadResourceTuples as Ue, makeActionRunner as L, makeAdvisoryLockCoordinator as We, makeApiKeyService as Ge, makeAsyncKv as R, makeCoordinatedScheduler as Ke, makeEffectStoreLayer as qe, makeLazyWorkflowFacade as Je, makeMutationRunner as Ye, makeQueryDescriptorProducer as Xe, makeQueryReauthorizer as Ze, makeSchemaRegistry as Qe, makeWorkflowFacade as $e, makeWorkflowFacadeWithCallerContext as et, makeWorkflowLayers as tt, noopKv as nt, recordSubscriptionDelivery as rt, registerWakeup as z, resolveSecretsBackend as it, runProvidedEffect as at, setSecretsBackend as ot, setSystemStoreHandle as st, setTupleSource as ct, singleCoordinator as lt, startRpcServer as ut, startScheduler as dt, workflowToRpc as B } from "@voltro/runtime";
12
- import { RpcGroup as ft } from "@effect/rpc";
13
- import { SqlClient as pt } from "@effect/sql";
14
- import { and as mt, ensureTableRegistered as ht, eq as V, or as gt } from "@voltro/database";
15
- import { fromNodeReadable as _t, getObjectStream as vt, putObjectStream as yt, resolveStorageProvider as H, toNodeReadable as U } from "@voltro/plugin-storage";
16
- import { AuthMiddleware as bt, ConnectionInfoMiddleware as xt, actionToRpc as W, anonymousSubject as St, mutationToRpc as Ct, queryToRpc as G, streamToRpc as wt, workflowCancelDescriptor as Tt, workflowDomainEventsQueryDescriptor as Et, workflowEventDeliveriesQueryDescriptor as K, workflowResumeDescriptor as Dt, workflowRunEventsQueryDescriptor as q, workflowRunQueryDescriptor as J, workflowRunStepsQueryDescriptor as Y, workflowRunsQueryDescriptor as Ot, workflowSignalDescriptor as X, workflowUpdateDescriptor as kt } from "@voltro/protocol";
17
- import { createHash as Z, timingSafeEqual as At } from "node:crypto";
18
- import { declaredSnapshot as jt, describeOutcome as Mt, runPlannedMigrations as Nt } from "@voltro/database/sql";
19
- import { assertProductionSessionSecret as Pt } from "@voltro/protocol/session";
20
- import { getAuthSessionStrategy as Ft } from "@voltro/plugin-auth";
21
- import { collectPublicApiRoutes as It, restRoutesToHttpRoutes as Lt } from "@voltro/protocol/rest";
22
- import { buildDeliverWebhookExecute as Rt, buildWebhooksService as zt, defaultIncomingPath as Bt, deliverWebhookWorkflow as Vt, mountIncomingWebhook as Ht } from "@voltro/plugin-webhooks";
23
- import { packBundle as Ut, runExport as Wt, runImport as Gt, storageBlobSink as Kt, storageRefsBlobSource as qt, unpackBundle as Jt, unpackBundleToDir as Yt } from "@voltro/data-transfer";
24
- //#region src/adminAuth.ts
25
- var Xt = "/_voltro/admin/import", Zt = "/_voltro/admin/export", Q = (e, t) => ({
1
+ import { At as e, t } from "./inspectMetrics-D4EJ8LTi.js";
2
+ import { $ as n, A as r, C as i, D as a, E as o, F as s, G as c, H as l, I as u, J as d, M as f, N as p, O as ee, P as m, Q as h, S as g, T as te, U as ne, W as re, X as _, Y as ie, Z as ae, _ as oe, b as v, d as se, dt as ce, et as y, f as b, ft as le, g as ue, gt as x, h as de, i as S, it as fe, j as C, k as w, m as pe, n as me, nt as T, o as he, pt as ge, q as _e, s as E, t as ve, ut as ye, v as be, w as xe, x as Se, y as D } from "./dev-Cvojvb_J.js";
3
+ import { a as Ce, r as we } from "./startupRunner-DhlX9nqd.js";
4
+ import { c as O, r as Te } from "./apiBuild-DHHuiwXF.js";
5
+ import { t as Ee } from "./bootTiming-BdyP9nYw.js";
6
+ import { join as De } from "node:path";
7
+ import { pathToFileURL as Oe } from "node:url";
8
+ import { Cause as ke, Effect as k, Layer as A, ManagedRuntime as Ae } from "effect";
9
+ import { createLogger as j } from "@voltro/logger";
10
+ import { existsSync as je } from "node:fs";
11
+ import { AggregateRegistry as Me, Dispatcher as M, apiKeyManagementRoutes as N, applySoftDeleteScope as Ne, applyTenantScope as Pe, attachAnalyticsMirror as P, awaitServerListening as Fe, bindMutation as F, bindStream as Ie, bindSubscription as I, buildTracingLayer as Le, cancelWakeup as Re, compileCron as ze, dataStoreApiKeyStore as Be, dataStoreIdempotencyStore as Ve, frameworkApiKeyStrategy as He, installPolicyGuardResolver as Ue, loadResourceTuples as We, makeActionRunner as L, makeAdvisoryLockCoordinator as Ge, makeApiKeyService as Ke, makeAsyncKv as qe, makeCoordinatedScheduler as Je, makeEffectStoreLayer as Ye, makeLazyWorkflowFacade as Xe, makeMutationRunner as Ze, makeOneShotQueryRunner as Qe, makeQueryDescriptorProducer as $e, makeQueryReauthorizer as et, makeQuerySubscriber as tt, makeSchemaRegistry as R, makeWorkflowFacade as nt, makeWorkflowFacadeWithCallerContext as rt, makeWorkflowLayers as it, noopKv as z, recordSubscriptionDelivery as at, registerWakeup as ot, resolveSecretsBackend as st, runProvidedEffect as ct, setSecretsBackend as lt, setSystemStoreHandle as ut, setTupleSource as dt, singleCoordinator as ft, startRpcServer as B, startScheduler as pt, workflowToRpc as mt } from "@voltro/runtime";
12
+ import { RpcGroup as ht } from "@effect/rpc";
13
+ import { SqlClient as gt } from "@effect/sql";
14
+ import { and as _t, ensureTableRegistered as vt, eq as V, or as yt } from "@voltro/database";
15
+ import { fromNodeReadable as bt, getObjectStream as xt, putObjectStream as H, resolveStorageProvider as U, toNodeReadable as St } from "@voltro/plugin-storage";
16
+ import { AuthMiddleware as Ct, ConnectionInfoMiddleware as W, actionToRpc as G, anonymousSubject as wt, mutationToRpc as Tt, queryToRpc as K, streamToRpc as Et, workflowCancelDescriptor as Dt, workflowDomainEventsQueryDescriptor as Ot, workflowEventDeliveriesQueryDescriptor as q, workflowResumeDescriptor as kt, workflowRunEventsQueryDescriptor as J, workflowRunQueryDescriptor as At, workflowRunStepsQueryDescriptor as Y, workflowRunsQueryDescriptor as X, workflowSignalDescriptor as jt, workflowUpdateDescriptor as Mt } from "@voltro/protocol";
17
+ import { createHash as Z, timingSafeEqual as Nt } from "node:crypto";
18
+ import { declaredSnapshot as Pt, describeOutcome as Ft, runPlannedMigrations as It } from "@voltro/database/sql";
19
+ import { assertProductionSessionSecret as Lt } from "@voltro/protocol/session";
20
+ import { getAuthSessionStrategy as Rt } from "@voltro/plugin-auth";
21
+ import { collectPublicApiRoutes as zt, restRoutesToHttpRoutes as Bt } from "@voltro/protocol/rest";
22
+ import { buildDeliverWebhookExecute as Vt, buildWebhooksService as Ht, defaultIncomingPath as Ut, deliverWebhookWorkflow as Wt, mountIncomingWebhook as Gt } from "@voltro/plugin-webhooks";
23
+ import { packBundle as Kt, runExport as qt, runImport as Jt, storageBlobSink as Yt, storageRefsBlobSource as Xt, unpackBundle as Zt, unpackBundleToDir as Qt } from "@voltro/data-transfer";
24
+ //#region src/cliArgs.ts
25
+ var $t = (e, t) => {
26
+ for (let n = 0; n < e.length; n++) {
27
+ let r = e[n];
28
+ if (r === t) return e[n + 1];
29
+ if (r.startsWith(t + "=")) return r.slice(t.length + 1);
30
+ }
31
+ }, en = (e, t) => {
32
+ let n = [], r, i = !1;
33
+ for (let a = 0; a < e.length; a++) {
34
+ let o = e[a];
35
+ if (!i && o === t) {
36
+ r = e[++a], i = !0;
37
+ continue;
38
+ }
39
+ if (!i && o.startsWith(t + "=")) {
40
+ r = o.slice(t.length + 1), i = !0;
41
+ continue;
42
+ }
43
+ n.push(o);
44
+ }
45
+ return {
46
+ value: r,
47
+ rest: n
48
+ };
49
+ }, tn = (e, ...t) => e.some((e) => t.includes(e)), nn = (e) => e.find((e) => !e.startsWith("-")), rn = "/_voltro/admin/import", an = "/_voltro/admin/export", Q = (e, t) => ({
26
50
  status: e,
27
51
  contentType: "application/json; charset=utf-8",
28
52
  body: JSON.stringify(t)
29
- }), Qt = (e) => {
53
+ }), on = (e) => {
30
54
  let t = e.authorization ?? e.Authorization, n = t ? /^Bearer\s+(.+)$/i.exec(t) : null;
31
55
  return n ? n[1] : null;
32
- }, $t = (e, t) => At(Z("sha256").update(e).digest(), Z("sha256").update(t).digest()), en = (e, t) => {
56
+ }, sn = (e, t) => Nt(Z("sha256").update(e).digest(), Z("sha256").update(t).digest()), cn = (e, t) => {
33
57
  if (e.method.toUpperCase() !== "POST") return Q(405, { error: "method not allowed" });
34
58
  if (!t || t.length < 16) return Q(503, { error: "data transfer misconfigured (no/weak secret)" });
35
- let n = Qt(e.headers);
36
- return !n || !$t(n, t) ? Q(401, { error: "unauthorized" }) : null;
37
- }, tn = M({ scope: "voltro:admin-import" }), nn = "VBUNDLE2", rn = async function* (e) {
59
+ let n = on(e.headers);
60
+ return !n || !sn(n, t) ? Q(401, { error: "unauthorized" }) : null;
61
+ }, ln = j({ scope: "voltro:admin-import" }), un = "VBUNDLE2", dn = async function* (e) {
38
62
  yield e;
39
- }, an = (e) => async (t) => {
40
- let n = en(t, e.secret);
63
+ }, fn = (e) => async (t) => {
64
+ let n = cn(t, e.secret);
41
65
  if (n) return n;
42
- let r = t.headers["x-import-mode"], i = t.headers["x-import-on-conflict"], a = t.headers["x-import-atomic"] === "1" || t.headers["x-import-atomic"] === "true", o = t.headers["x-import-force"] === "1" || t.headers["x-import-force"] === "true", s = t.rawBody.byteLength >= 8 && Buffer.from(t.rawBody.subarray(0, 8)).toString("latin1") === nn, c, l;
43
- if (s) c = rn(t.rawBody), l = "upload";
66
+ let r = t.headers["x-import-mode"], i = t.headers["x-import-on-conflict"], a = t.headers["x-import-atomic"] === "1" || t.headers["x-import-atomic"] === "true", o = t.headers["x-import-force"] === "1" || t.headers["x-import-force"] === "true", s = t.rawBody.byteLength >= 8 && Buffer.from(t.rawBody.subarray(0, 8)).toString("latin1") === un, c, l;
67
+ if (s) c = dn(t.rawBody), l = "upload";
44
68
  else {
45
69
  let n;
46
70
  try {
@@ -54,11 +78,11 @@ var Xt = "/_voltro/admin/import", Zt = "/_voltro/admin/export", Q = (e, t) => ({
54
78
  }
55
79
  let u = await import("node:os"), d = await import("node:fs/promises"), f = await import("node:path"), p = await d.mkdtemp(f.join(u.tmpdir(), "voltro-admin-import-"));
56
80
  try {
57
- e.assetSink ? await Jt(c, {
81
+ e.assetSink ? await Zt(c, {
58
82
  dir: p,
59
83
  blobs: e.assetSink
60
- }) : await Yt(c, p);
61
- let t = await A.runPromiseExit(Gt({
84
+ }) : await Qt(c, p);
85
+ let t = await k.runPromiseExit(Jt({
62
86
  store: e.store,
63
87
  bundleDir: p,
64
88
  ...r ? { mode: r } : {},
@@ -66,14 +90,14 @@ var Xt = "/_voltro/admin/import", Zt = "/_voltro/admin/export", Q = (e, t) => ({
66
90
  ...a ? { atomic: a } : {},
67
91
  ...e.snapshot ? { targetSnapshot: e.snapshot } : {},
68
92
  force: o,
69
- onWarn: (e) => tn.warn("admin.import", { message: e }),
93
+ onWarn: (e) => ln.warn("admin.import", { message: e }),
70
94
  ...e.assetSink ? { assetsAlreadyRestored: !0 } : {}
71
95
  }));
72
96
  if (t._tag === "Failure") {
73
97
  let e = t.cause._tag === "Fail" ? t.cause.error : void 0;
74
98
  if (e && e._tag === "SchemaDriftError") {
75
99
  let t = e;
76
- return tn.warn("admin.import refused (schema drift)", {
100
+ return ln.warn("admin.import refused (schema drift)", {
77
101
  transport: l,
78
102
  bundle: t.bundleFingerprint.slice(0, 16),
79
103
  target: t.targetFingerprint.slice(0, 16)
@@ -88,7 +112,7 @@ var Xt = "/_voltro/admin/import", Zt = "/_voltro/admin/export", Q = (e, t) => ({
88
112
  throw Error(String(e?.message ?? e ?? "import failed"));
89
113
  }
90
114
  let n = t.value, s = n.tables.reduce((e, t) => e + t.rowCount, 0);
91
- return tn.info("admin.import", {
115
+ return ln.info("admin.import", {
92
116
  transport: l,
93
117
  tables: n.tables.length,
94
118
  rows: s,
@@ -100,7 +124,7 @@ var Xt = "/_voltro/admin/import", Zt = "/_voltro/admin/export", Q = (e, t) => ({
100
124
  transport: l
101
125
  });
102
126
  } catch (e) {
103
- return tn.warn("admin.import failed", {
127
+ return ln.warn("admin.import failed", {
104
128
  transport: l,
105
129
  error: e?.message ?? String(e)
106
130
  }), Q(500, {
@@ -113,18 +137,18 @@ var Xt = "/_voltro/admin/import", Zt = "/_voltro/admin/export", Q = (e, t) => ({
113
137
  force: !0
114
138
  });
115
139
  }
116
- }, on = M({ scope: "voltro:admin-export" }), sn = async (e) => {
140
+ }, pn = j({ scope: "voltro:admin-export" }), mn = async (e) => {
117
141
  let t = [];
118
142
  for await (let n of e) t.push(Buffer.from(n));
119
143
  return new Uint8Array(Buffer.concat(t));
120
- }, cn = (e) => typeof e.tenant == "string" && e.tenant ? {
144
+ }, hn = (e) => typeof e.tenant == "string" && e.tenant ? {
121
145
  kind: "tenant",
122
146
  tenantId: e.tenant
123
147
  } : Array.isArray(e.tables) && e.tables.length ? {
124
148
  kind: "tables",
125
149
  tables: e.tables.filter((e) => typeof e == "string")
126
- } : { kind: "all" }, ln = (e) => async (t) => {
127
- let n = en(t, e.secret);
150
+ } : { kind: "all" }, gn = (e) => async (t) => {
151
+ let n = cn(t, e.secret);
128
152
  if (n) return n;
129
153
  let r;
130
154
  try {
@@ -144,9 +168,9 @@ var Xt = "/_voltro/admin/import", Zt = "/_voltro/admin/export", Q = (e, t) => ({
144
168
  });
145
169
  }
146
170
  }
147
- let a = r.consistency === "snapshot" ? "snapshot" : i.consistency ?? "live", o = (typeof r.compression == "string" ? r.compression : void 0) ?? i.compression, s = i.scope ?? cn(r), c = typeof r.bundleKey == "string" && r.bundleKey.length > 0, l = r.assets === !0 && e.assetSource ? { blobs: e.assetSource } : {}, u = await import("node:os"), d = await import("node:fs/promises"), f = await import("node:path"), p = await d.mkdtemp(f.join(u.tmpdir(), "voltro-admin-export-"));
171
+ let a = r.consistency === "snapshot" ? "snapshot" : i.consistency ?? "live", o = (typeof r.compression == "string" ? r.compression : void 0) ?? i.compression, s = i.scope ?? hn(r), c = typeof r.bundleKey == "string" && r.bundleKey.length > 0, l = r.assets === !0 && e.assetSource ? { blobs: e.assetSource } : {}, u = await import("node:os"), d = await import("node:fs/promises"), f = await import("node:path"), p = await d.mkdtemp(f.join(u.tmpdir(), "voltro-admin-export-"));
148
172
  try {
149
- let t = await A.runPromise(Wt({
173
+ let t = await k.runPromise(qt({
150
174
  store: e.store,
151
175
  snapshot: e.snapshot,
152
176
  dialect: e.dialect,
@@ -162,10 +186,10 @@ var Xt = "/_voltro/admin/import", Zt = "/_voltro/admin/export", Q = (e, t) => ({
162
186
  if (c) {
163
187
  if (!e.putArchive) return Q(501, { error: "storage transport not configured on this instance" });
164
188
  let i = r.bundleKey;
165
- return await e.putArchive(i, () => Ut({
189
+ return await e.putArchive(i, () => Kt({
166
190
  dir: p,
167
191
  ...l
168
- })), on.info("admin.export", {
192
+ })), pn.info("admin.export", {
169
193
  transport: "storage",
170
194
  tables: t.tables.length,
171
195
  rows: n,
@@ -179,11 +203,11 @@ var Xt = "/_voltro/admin/import", Zt = "/_voltro/admin/export", Q = (e, t) => ({
179
203
  transport: "storage"
180
204
  });
181
205
  }
182
- let d = await sn(Ut({
206
+ let d = await mn(Kt({
183
207
  dir: p,
184
208
  ...l
185
209
  }));
186
- return on.info("admin.export", {
210
+ return pn.info("admin.export", {
187
211
  transport: "download",
188
212
  tables: t.tables.length,
189
213
  rows: n,
@@ -200,7 +224,7 @@ var Xt = "/_voltro/admin/import", Zt = "/_voltro/admin/export", Q = (e, t) => ({
200
224
  }
201
225
  };
202
226
  } catch (e) {
203
- return on.warn("admin.export failed", { error: e?.message ?? String(e) }), Q(500, {
227
+ return pn.warn("admin.export failed", { error: e?.message ?? String(e) }), Q(500, {
204
228
  error: "export failed",
205
229
  message: e?.message ?? String(e)
206
230
  });
@@ -210,7 +234,7 @@ var Xt = "/_voltro/admin/import", Zt = "/_voltro/admin/export", Q = (e, t) => ({
210
234
  force: !0
211
235
  });
212
236
  }
213
- }, un = async (e) => {
237
+ }, _n = async (e) => {
214
238
  let { resolve: t } = await import("node:path"), { existsSync: n } = await import("node:fs"), r = [
215
239
  e,
216
240
  `${e}.profile.ts`,
@@ -221,7 +245,7 @@ var Xt = "/_voltro/admin/import", Zt = "/_voltro/admin/export", Q = (e, t) => ({
221
245
  let a = await import(i), o = a.default ?? a.profile;
222
246
  if (!o) throw Error(`data profile '${i}' has no default export`);
223
247
  return o;
224
- }, dn = {
248
+ }, vn = {
225
249
  get: async () => void 0,
226
250
  set: async () => {},
227
251
  setWithTags: async () => {},
@@ -230,21 +254,21 @@ var Xt = "/_voltro/admin/import", Zt = "/_voltro/admin/export", Q = (e, t) => ({
230
254
  clear: async () => {},
231
255
  invalidateTag: async () => 0,
232
256
  wrap: async (e, t, n) => n()
233
- }, fn = async (e) => {
234
- st({
257
+ }, yn = async (e) => {
258
+ ut({
235
259
  dataStore: e.store,
236
260
  schemaRegistry: e.schemaRegistry
237
261
  });
238
- let t = new P({
262
+ let t = new M({
239
263
  store: e.store,
240
264
  ...e.snapshotCache ? { cache: e.snapshotCache } : {},
241
- recordDelivery: (e) => rt({
265
+ recordDelivery: (e) => at({
242
266
  label: e.label,
243
267
  kind: e.kind,
244
268
  durationMs: e.durationMs,
245
269
  rowCount: e.rowCount
246
270
  })
247
- }), n = e.cache ?? dn, r = e.kv ?? nt, a, o, c, l = /* @__PURE__ */ new Map(), u = () => `wfctx_${globalThis.crypto?.randomUUID?.() ?? `${Date.now().toString(36)}${Math.random().toString(36).slice(2)}`}`, d = async (t, n, r) => {
271
+ }), n = e.cache ?? vn, r = e.kv ?? z, a, o, c, l = /* @__PURE__ */ new Map(), u = () => `wfctx_${globalThis.crypto?.randomUUID?.() ?? `${Date.now().toString(36)}${Math.random().toString(36).slice(2)}`}`, d = async (t, n, r) => {
248
272
  let i = {
249
273
  ...r,
250
274
  source: r.source ?? `workflow:${t}`
@@ -300,7 +324,7 @@ var Xt = "/_voltro/admin/import", Zt = "/_voltro/admin/export", Q = (e, t) => ({
300
324
  process.stderr.write(`[workflow] failed to load start context for ${n}: ${e?.message ?? String(e)}\n`);
301
325
  return;
302
326
  }
303
- }, g = (e.discovered.workflows?.length ?? 0) > 0 ? Je(() => a) : void 0, te = (e.discovered.workflows?.length ?? 0) > 0 || (e.discovered.eventTriggers?.length ?? 0) > 0, ne = te || (e.discovered.workflowWorkers?.length ?? 0) > 0 || e.scheduleCoordination === "cluster", re = e.tenantIsolation === "namespace", ie = (e.log ?? M({ scope: "voltro:serve" })).child("webhooks"), oe, v = e.discovered.webhooks;
327
+ }, g = (e.discovered.workflows?.length ?? 0) > 0 ? Xe(() => a) : void 0, te = (e.discovered.workflows?.length ?? 0) > 0 || (e.discovered.eventTriggers?.length ?? 0) > 0, ne = te || (e.discovered.workflowWorkers?.length ?? 0) > 0 || e.scheduleCoordination === "cluster", re = e.tenantIsolation === "namespace", ie = (e.log ?? j({ scope: "voltro:serve" })).child("webhooks"), oe, v = e.discovered.webhooks;
304
328
  if (v && v.outgoing.length > 0 && e.workflowEngineLayer !== void 0) {
305
329
  let t = e.workflowEngineLayer, i = h({
306
330
  store: e.store,
@@ -308,9 +332,9 @@ var Xt = "/_voltro/admin/import", Zt = "/_voltro/admin/export", Q = (e, t) => ({
308
332
  cache: n,
309
333
  kv: r
310
334
  }), a = v.outgoing.map((e) => e.descriptor);
311
- oe = zt(i, async (e) => {
312
- let n = Vt.execute(e).pipe(A.provide(Vt.toLayer(Rt(i, { events: a })).pipe(j.provideMerge(t))));
313
- A.runPromise(n).catch((t) => {
335
+ oe = Ht(i, async (e) => {
336
+ let n = Wt.execute(e).pipe(k.provide(Wt.toLayer(Vt(i, { events: a })).pipe(A.provideMerge(t))));
337
+ k.runPromise(n).catch((t) => {
314
338
  ie.error("deliverWebhook workflow crashed", {
315
339
  deliveryId: e.deliveryId,
316
340
  targetId: e.targetId
@@ -320,9 +344,9 @@ var Xt = "/_voltro/admin/import", Zt = "/_voltro/admin/export", Q = (e, t) => ({
320
344
  }
321
345
  let se = /* @__PURE__ */ new Map();
322
346
  if (v) for (let e of v.incoming) {
323
- let t = e.descriptor.path ?? Bt(e.descriptor.id), n = `VOLTRO_WEBHOOK_SECRET_${e.descriptor.id.toUpperCase().replace(/[^A-Z0-9]/g, "_")}`, r = Ht(e.descriptor, {
347
+ let t = e.descriptor.path ?? Ut(e.descriptor.id), n = `VOLTRO_WEBHOOK_SECRET_${e.descriptor.id.toUpperCase().replace(/[^A-Z0-9]/g, "_")}`, r = Gt(e.descriptor, {
324
348
  resolveSecret: async () => process.env[n] ?? null,
325
- resolveWorkflows: () => g === void 0 ? void 0 : et(g, {
349
+ resolveWorkflows: () => g === void 0 ? void 0 : rt(g, {
326
350
  traceId: `incoming:${e.descriptor.id}`,
327
351
  source: `incoming:${e.descriptor.id}`
328
352
  }),
@@ -339,16 +363,16 @@ var Xt = "/_voltro/admin/import", Zt = "/_voltro/admin/export", Q = (e, t) => ({
339
363
  });
340
364
  se.set(t, { handle: r });
341
365
  }
342
- He(), ct((t) => Ue(e.store, t.subjectId, t.resourceType, t.resourceId));
366
+ Ue(), dt((t) => We(e.store, t.subjectId, t.resourceType, t.resourceId));
343
367
  let ce = (e.discovered.outboxHandlers?.length ?? 0) > 0 ? m({
344
368
  handlers: e.discovered.outboxHandlers ?? [],
345
369
  store: e.store,
346
- log: (e.log ?? M({ scope: "voltro:serve" })).child("outbox")
370
+ log: (e.log ?? j({ scope: "voltro:serve" })).child("outbox")
347
371
  }) : void 0, y = f({
348
372
  definitions: (e.discovered.connections ?? []).map((e) => e.definition),
349
373
  store: e.store,
350
- publicUrl: S(e.port ?? 4e3),
351
- log: (e.log ?? M({ scope: "voltro:serve" })).child("connections")
374
+ publicUrl: C(e.port ?? 4e3),
375
+ log: (e.log ?? j({ scope: "voltro:serve" })).child("connections")
352
376
  }), b = ae({
353
377
  store: e.store,
354
378
  schemaRegistry: e.schemaRegistry,
@@ -360,101 +384,122 @@ var Xt = "/_voltro/admin/import", Zt = "/_voltro/admin/export", Q = (e, t) => ({
360
384
  namespaceIsolationOn: re,
361
385
  ...ce === void 0 ? {} : { outbox: { nudge: ce.nudge } },
362
386
  ...y.active ? { connections: { registry: y.registry } } : {}
363
- }), le = j.succeed(ke, be), x = (t, n) => {
364
- let r = t.pipe(A.provide(qe(n)));
365
- return at((e.baseLayer ? r.pipe(A.provide(e.baseLayer)) : r).pipe(A.provide(le)));
366
- }, de = Ye({
387
+ }), le = A.succeed(Me, xe), ue = (t, n) => {
388
+ let r = t.pipe(k.provide(Ye(n)));
389
+ return ct((e.baseLayer ? r.pipe(k.provide(e.baseLayer)) : r).pipe(k.provide(le)));
390
+ }, x = Ze({
367
391
  store: e.store,
368
392
  buildContext: (e, t, n) => b(e, t, n),
369
- runEffect: x,
393
+ runEffect: ue,
370
394
  undoCapture: D()
371
- }), pe = ye(), me = L({
395
+ }), S = be(), fe = L({
372
396
  buildContext: (e) => b(e),
373
- runEffect: x
374
- }), w = Xe({
397
+ runEffect: ue
398
+ }), me = {
375
399
  buildContext: (e) => b(e),
376
- finalize: (t, n) => je(Me(t, e.tenantScopedTables, n.subject.tenantId), e.softDeleteScopedTables),
377
- provideEffect: (e, t) => e.pipe(A.provide(qe(t)))
378
- }), T = {};
400
+ finalize: (t, n) => Ne(Pe(t, e.tenantScopedTables, n.subject.tenantId), e.softDeleteScopedTables),
401
+ provideEffect: (e, t) => e.pipe(k.provide(Ye(t)))
402
+ }, T = $e(me), he = Qe({
403
+ ...me,
404
+ queryRows: (t) => e.store.query(t)
405
+ }), ge = tt({
406
+ ...me,
407
+ subscribeDescriptor: (e, n, r) => t.subscribe(e, n, r),
408
+ subscribeComputed: (e, n, r) => t.subscribeComputed(e, n, r)
409
+ }), E = {};
379
410
  for (let n of [
380
411
  ...e.discovered.queries,
381
- ...pe.queries,
412
+ ...S.queries,
382
413
  ...y.queries
383
- ]) T[n.descriptor.name] = (e) => I(w(n, e), t, `subscription.${n.descriptor.name}`, void 0, void 0, Ze(n, e));
414
+ ]) E[n.descriptor.name] = (e) => I(T(n, e), t, `subscription.${n.descriptor.name}`, void 0, void 0, et(n, e));
384
415
  for (let t of [
385
416
  ...e.discovered.mutations,
386
- ...pe.mutations,
417
+ ...S.mutations,
387
418
  ...y.mutations
388
- ]) T[t.descriptor.name] = (e) => F(async (e, n) => de(t, e, n), e, `mutation.${t.descriptor.name}`);
389
- for (let t of [...e.discovered.actions, ...y.actions]) T[t.descriptor.name] = (e) => F(async (e, n) => me(t, e, n), e, `action.${t.descriptor.name}`);
390
- let ge = () => `public-${Math.random().toString(36).slice(2, 10)}`, _e = [...e.discovered.mutations.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
391
- descriptor: e.descriptor,
392
- invoke: (t, n) => de(e, t, {
393
- subject: n.subject,
394
- traceId: ge()
395
- })
396
- })), ...e.discovered.actions.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
397
- descriptor: e.descriptor,
398
- invoke: (t, n) => me(e, t, {
399
- subject: n.subject,
400
- traceId: ge()
401
- })
402
- }))], ve = _e.length > 0 ? Lt(It(_e), {
419
+ ]) E[t.descriptor.name] = (e) => F(async (e, n) => x(t, e, n), e, `mutation.${t.descriptor.name}`);
420
+ for (let t of [...e.discovered.actions, ...y.actions]) E[t.descriptor.name] = (e) => F(async (e, n) => fe(t, e, n), e, `action.${t.descriptor.name}`);
421
+ let ve = () => `public-${Math.random().toString(36).slice(2, 10)}`, ye = [
422
+ ...e.discovered.queries.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
423
+ descriptor: e.descriptor,
424
+ invoke: (t, n) => he(e, t, {
425
+ subject: n.subject,
426
+ traceId: ve()
427
+ }),
428
+ subscribe: (t, n, r) => ge(e, t, {
429
+ subject: n.subject,
430
+ traceId: ve()
431
+ }, r)
432
+ })),
433
+ ...e.discovered.mutations.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
434
+ descriptor: e.descriptor,
435
+ invoke: (t, n) => x(e, t, {
436
+ subject: n.subject,
437
+ traceId: ve()
438
+ })
439
+ })),
440
+ ...e.discovered.actions.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
441
+ descriptor: e.descriptor,
442
+ invoke: (t, n) => fe(e, t, {
443
+ subject: n.subject,
444
+ traceId: ve()
445
+ })
446
+ }))
447
+ ], Se = ye.length > 0 ? Bt(zt(ye), {
403
448
  store: e.store,
404
449
  resolveSubject: (t) => e.resolveSubject(t, -1)
405
- }) : [], E = e.dataTransferSecret ?? process.env.VOLTRO_DATA_TRANSFER_SECRET, xe = E && E.length >= 16 ? [{
450
+ }) : [], Ce = e.dataTransferSecret ?? process.env.VOLTRO_DATA_TRANSFER_SECRET, we = Ce && Ce.length >= 16 ? [{
406
451
  method: "POST",
407
- path: Xt,
408
- handle: an({
409
- secret: E,
452
+ path: rn,
453
+ handle: fn({
454
+ secret: Ce,
410
455
  store: e.store,
411
456
  ...e.dataTransferSnapshot ? { snapshot: e.dataTransferSnapshot } : {},
412
- assetSink: Kt(H({})),
457
+ assetSink: Yt(U({})),
413
458
  openArchive: (e) => (async function* () {
414
- let t = H({}), n = await U((await A.runPromise(vt(t, e))).stream);
459
+ let t = U({}), n = await St((await k.runPromise(xt(t, e))).stream);
415
460
  for await (let e of n) yield e instanceof Uint8Array ? e : new Uint8Array(e);
416
461
  })()
417
462
  })
418
463
  }, {
419
464
  method: "POST",
420
- path: Zt,
421
- handle: ln({
422
- secret: E,
465
+ path: an,
466
+ handle: gn({
467
+ secret: Ce,
423
468
  store: e.store,
424
469
  snapshot: e.dataTransferSnapshot ?? { tables: [] },
425
470
  dialect: e.dataTransferDialect ?? "memory",
426
471
  tenantTables: [...e.tenantScopedTables],
427
- loadProfile: un,
428
- assetSource: qt(H({}), e.store),
472
+ loadProfile: _n,
473
+ assetSource: Xt(U({}), e.store),
429
474
  putArchive: async (e, t) => {
430
- let { Readable: n } = await import("node:stream"), r = H({}), i = _t("storage", () => n.from(t()));
431
- await A.runPromise(yt(r, e, i, { contentType: "application/octet-stream" }));
475
+ let { Readable: n } = await import("node:stream"), r = U({}), i = bt("storage", () => n.from(t()));
476
+ await k.runPromise(H(r, e, i, { contentType: "application/octet-stream" }));
432
477
  }
433
478
  })
434
- }] : [], Se = [
479
+ }] : [], O = [
435
480
  ...e.httpRoutes ?? [],
436
- ...ve,
437
- ...xe,
481
+ ...Se,
482
+ ...we,
438
483
  ...y.httpRoutes
439
484
  ];
440
- for (let t of e.discovered.streams ?? []) T[t.descriptor.name] = (n) => Fe((r) => {
485
+ for (let t of e.discovered.streams ?? []) E[t.descriptor.name] = (n) => Ie((r) => {
441
486
  let i = b(r), a = t.executor(n, i);
442
- if (A.isEffect(a)) {
443
- let t = a.pipe(A.provide(qe(i.store)));
444
- return (e.baseLayer ? t.pipe(A.provide(e.baseLayer)) : t).pipe(A.provide(le));
487
+ if (k.isEffect(a)) {
488
+ let t = a.pipe(k.provide(Ye(i.store)));
489
+ return (e.baseLayer ? t.pipe(k.provide(e.baseLayer)) : t).pipe(k.provide(le));
445
490
  }
446
- return typeof a == "object" && a && typeof a.then == "function" ? A.promise(() => a) : a;
491
+ return typeof a == "object" && a && typeof a.then == "function" ? k.promise(() => a) : a;
447
492
  }, `stream.${t.descriptor.name}`);
448
- for (let t of e.discovered.workflows ?? []) T[t.definition.name] = (e) => F(async (e, n) => {
493
+ for (let t of e.discovered.workflows ?? []) E[t.definition.name] = (e) => F(async (e, n) => {
449
494
  let r = n;
450
- return et(g, {
495
+ return rt(g, {
451
496
  subject: r.subject,
452
497
  traceId: r.traceId,
453
498
  source: "workflow-rpc"
454
499
  }).start(t.definition.name, e);
455
500
  }, e, `workflow.${t.definition.name}`);
456
- te && (T[J.name] = (e) => I(w({
457
- descriptor: J,
501
+ te && (E[At.name] = (e) => I(T({
502
+ descriptor: At,
458
503
  executor: (e) => {
459
504
  let t = e.id;
460
505
  return {
@@ -463,14 +508,14 @@ var Xt = "/_voltro/admin/import", Zt = "/_voltro/admin/export", Q = (e, t) => ({
463
508
  column: "startedAt",
464
509
  direction: "desc"
465
510
  }],
466
- predicate: gt(V("id", t), V("executionId", t)),
511
+ predicate: yt(V("id", t), V("executionId", t)),
467
512
  take: 1,
468
513
  skip: void 0,
469
514
  projection: void 0
470
515
  };
471
516
  }
472
- }, e), t, `subscription.${J.name}`), T[Ot.name] = (e) => I(w({
473
- descriptor: Ot,
517
+ }, e), t, `subscription.${At.name}`), E[X.name] = (e) => I(T({
518
+ descriptor: X,
474
519
  executor: (e) => {
475
520
  let t = e, n = [...t.tag === void 0 ? [] : [V("tag", t.tag)], ...t.status === void 0 ? [] : [V("status", t.status)]], r = Number.isFinite(t.limit) && t.limit !== void 0 ? Math.min(Math.max(Math.floor(t.limit), 1), 500) : 100;
476
521
  return {
@@ -479,13 +524,13 @@ var Xt = "/_voltro/admin/import", Zt = "/_voltro/admin/export", Q = (e, t) => ({
479
524
  column: "startedAt",
480
525
  direction: "desc"
481
526
  }],
482
- predicate: n.length === 0 ? void 0 : n.length === 1 ? n[0] : mt(...n),
527
+ predicate: n.length === 0 ? void 0 : n.length === 1 ? n[0] : _t(...n),
483
528
  take: r,
484
529
  skip: void 0,
485
530
  projection: void 0
486
531
  };
487
532
  }
488
- }, e), t, `subscription.${Ot.name}`), T[Y.name] = (e) => I(w({
533
+ }, e), t, `subscription.${X.name}`), E[Y.name] = (e) => I(T({
489
534
  descriptor: Y,
490
535
  executor: (e) => {
491
536
  let t = e.runId;
@@ -501,8 +546,8 @@ var Xt = "/_voltro/admin/import", Zt = "/_voltro/admin/export", Q = (e, t) => ({
501
546
  projection: void 0
502
547
  };
503
548
  }
504
- }, e), t, `subscription.${Y.name}`), T[q.name] = (e) => I(w({
505
- descriptor: q,
549
+ }, e), t, `subscription.${Y.name}`), E[J.name] = (e) => I(T({
550
+ descriptor: J,
506
551
  executor: (e) => {
507
552
  let t = e.runId;
508
553
  return {
@@ -517,8 +562,8 @@ var Xt = "/_voltro/admin/import", Zt = "/_voltro/admin/export", Q = (e, t) => ({
517
562
  projection: void 0
518
563
  };
519
564
  }
520
- }, e), t, `subscription.${q.name}`), T[Et.name] = (e) => I(w({
521
- descriptor: Et,
565
+ }, e), t, `subscription.${J.name}`), E[Ot.name] = (e) => I(T({
566
+ descriptor: Ot,
522
567
  executor: (e) => {
523
568
  let t = e;
524
569
  return {
@@ -533,8 +578,8 @@ var Xt = "/_voltro/admin/import", Zt = "/_voltro/admin/export", Q = (e, t) => ({
533
578
  projection: void 0
534
579
  };
535
580
  }
536
- }, e), t, `subscription.${Et.name}`), T[K.name] = (e) => I(w({
537
- descriptor: K,
581
+ }, e), t, `subscription.${Ot.name}`), E[q.name] = (e) => I(T({
582
+ descriptor: q,
538
583
  executor: (e) => {
539
584
  let t = e.eventId;
540
585
  return {
@@ -549,63 +594,63 @@ var Xt = "/_voltro/admin/import", Zt = "/_voltro/admin/export", Q = (e, t) => ({
549
594
  projection: void 0
550
595
  };
551
596
  }
552
- }, e), t, `subscription.${K.name}`), T[Tt.name] = (t) => F(async (t, n) => {
597
+ }, e), t, `subscription.${q.name}`), E[Dt.name] = (t) => F(async (t, n) => {
553
598
  let r = t;
554
- return await _(e.store, n.subject, { executionId: r.executionId }), await g.cancel(r.workflowName, r.executionId), await Ne(r.workflowName, r.executionId, "workflow.cancel"), { ok: !0 };
555
- }, t, `action.${Tt.name}`), T[Dt.name] = (t) => F(async (t, n) => {
599
+ return await _(e.store, n.subject, { executionId: r.executionId }), await g.cancel(r.workflowName, r.executionId), await Be(r.workflowName, r.executionId, "workflow.cancel"), { ok: !0 };
600
+ }, t, `action.${Dt.name}`), E[kt.name] = (t) => F(async (t, n) => {
556
601
  let r = t;
557
602
  return await _(e.store, n.subject, { executionId: r.executionId }), await g.resume(r.workflowName, r.executionId), { ok: !0 };
558
- }, t, `action.${Dt.name}`), T[X.name] = (t) => F(async (t, n) => {
603
+ }, t, `action.${kt.name}`), E[jt.name] = (t) => F(async (t, n) => {
559
604
  let r = t;
560
605
  return await _(e.store, n.subject, { id: r.id }), g.signal({ id: r.id }, r.signalName, r.payload);
561
- }, t, `action.${X.name}`), T[kt.name] = (t) => F(async (t, n) => {
606
+ }, t, `action.${jt.name}`), E[Mt.name] = (t) => F(async (t, n) => {
562
607
  let r = t;
563
608
  return await _(e.store, n.subject, { id: r.id }), g.update({ id: r.id }, r.updateName, r.payload, r.timeoutMs === void 0 ? void 0 : { timeoutMs: r.timeoutMs });
564
- }, t, `action.${kt.name}`));
565
- let Ce = [
566
- ...e.discovered.queries.map((e) => G(e.descriptor)),
567
- ...e.discovered.mutations.map((e) => Ct(e.descriptor)),
568
- ...e.discovered.actions.map((e) => W(e.descriptor)),
569
- ...pe.queries.map((e) => G(e.descriptor)),
570
- ...pe.mutations.map((e) => Ct(e.descriptor)),
571
- ...y.queries.map((e) => G(e.descriptor)),
572
- ...y.mutations.map((e) => Ct(e.descriptor)),
573
- ...y.actions.map((e) => W(e.descriptor)),
574
- ...(e.discovered.streams ?? []).map((e) => wt(e.descriptor)),
575
- ...(e.discovered.workflows ?? []).map((e) => B(e.definition)),
609
+ }, t, `action.${Mt.name}`));
610
+ let Te = [
611
+ ...e.discovered.queries.map((e) => K(e.descriptor)),
612
+ ...e.discovered.mutations.map((e) => Tt(e.descriptor)),
613
+ ...e.discovered.actions.map((e) => G(e.descriptor)),
614
+ ...S.queries.map((e) => K(e.descriptor)),
615
+ ...S.mutations.map((e) => Tt(e.descriptor)),
616
+ ...y.queries.map((e) => K(e.descriptor)),
617
+ ...y.mutations.map((e) => Tt(e.descriptor)),
618
+ ...y.actions.map((e) => G(e.descriptor)),
619
+ ...(e.discovered.streams ?? []).map((e) => Et(e.descriptor)),
620
+ ...(e.discovered.workflows ?? []).map((e) => mt(e.definition)),
576
621
  ...te ? [
577
- G(J),
578
- G(Ot),
579
- G(Y),
580
- G(q),
581
- G(Et),
582
- G(K),
583
- W(Tt),
584
- W(Dt),
585
- W(X),
586
- W(kt)
622
+ K(At),
623
+ K(X),
624
+ K(Y),
625
+ K(J),
626
+ K(Ot),
627
+ K(q),
628
+ G(Dt),
629
+ G(kt),
630
+ G(jt),
631
+ G(Mt)
587
632
  ] : []
588
- ], we = ft.make(...Ce).middleware(bt).middleware(xt), O = j.succeed(bt, bt.of(({ headers: t, clientId: n }) => A.promise(() => e.resolveSubject(t, n)))), Te = j.succeed(xt, xt.of(({ clientId: e }) => A.succeed({ clientId: e }))), Ee = e.dormancyTenantId ?? "default", De = e.dormancy === "sleep" ? {
589
- register: (t, n, r) => z(e.store, {
590
- tenantId: r ?? Ee,
633
+ ], Ee = ht.make(...Te).middleware(Ct).middleware(W), De = A.succeed(Ct, Ct.of(({ headers: t, clientId: n }) => k.promise(() => e.resolveSubject(t, n)))), Oe = A.succeed(W, W.of(({ clientId: e }) => k.succeed({ clientId: e }))), ke = e.dormancyTenantId ?? "default", je = e.dormancy === "sleep" ? {
634
+ register: (t, n, r) => ot(e.store, {
635
+ tenantId: r ?? ke,
591
636
  kind: "workflow",
592
637
  refId: t,
593
638
  wakeAt: n
594
639
  }),
595
- cancel: (t, n) => Le(e.store, {
596
- tenantId: n ?? Ee,
640
+ cancel: (t, n) => Re(e.store, {
641
+ tenantId: n ?? ke,
597
642
  kind: "workflow",
598
643
  refId: t
599
644
  }).then(() => {})
600
- } : void 0, k = ne ? await import("@voltro/workflow") : void 0, N = k?.makeWorkflowRunRecorder({
645
+ } : void 0, N = ne ? await import("@voltro/workflow") : void 0, P = N?.makeWorkflowRunRecorder({
601
646
  store: e.store,
602
- ...De === void 0 ? {} : { wakeups: De }
603
- }), Ae = async (t, n) => {
604
- await k.closeWorkflowChildrenForParent({
647
+ ...je === void 0 ? {} : { wakeups: je }
648
+ }), ze = async (t, n) => {
649
+ await N.closeWorkflowChildrenForParent({
605
650
  store: e.store,
606
651
  parentExecutionId: t,
607
652
  parentStatus: n,
608
- recorder: N,
653
+ recorder: P,
609
654
  log: { warn: (e, t) => {
610
655
  process.stderr.write(`[workflow] ${e} ${t ? JSON.stringify(t) : ""}\n`);
611
656
  } },
@@ -616,7 +661,7 @@ var Xt = "/_voltro/admin/import", Zt = "/_voltro/admin/export", Q = (e, t) => ({
616
661
  await o.runPromise(r.definition.interrupt(n));
617
662
  }
618
663
  });
619
- }, Ne = async (t, n, r) => {
664
+ }, Be = async (t, n, r) => {
620
665
  let i = (await e.store.query({
621
666
  table: "_voltro_workflow_runs",
622
667
  order: [],
@@ -631,7 +676,7 @@ var Xt = "/_voltro/admin/import", Zt = "/_voltro/admin/export", Q = (e, t) => ({
631
676
  cancelled: !0,
632
677
  completedAt: /* @__PURE__ */ new Date()
633
678
  }), o = i.subject?.tenantId ?? void 0;
634
- a && await N.recordEvent({
679
+ a && await P.recordEvent({
635
680
  runId: i.id,
636
681
  eventType: "run-cancelled",
637
682
  payload: {
@@ -640,16 +685,16 @@ var Xt = "/_voltro/admin/import", Zt = "/_voltro/admin/export", Q = (e, t) => ({
640
685
  executionId: n,
641
686
  ...o == null ? {} : { tenantId: o }
642
687
  }
643
- }), a && await Ae(n, "cancelled");
644
- }, Re = [...tt(e.discovered.workflows ?? [], {
688
+ }), a && await ze(n, "cancelled");
689
+ }, Ve = [...it(e.discovered.workflows ?? [], {
645
690
  buildContext: (t, n) => e.buildContextForWorkflow?.(t, n) ?? b({
646
691
  subject: t.subject,
647
692
  traceId: t.traceId
648
693
  }, e.store, void 0, `workflow:${n.workflowName}`, { parentExecutionId: n.executionId }),
649
694
  resolveStartContext: p
650
695
  }, (t, n, r) => {
651
- let i = k.getWorkflowVersionMetadata(t.definition);
652
- return k.wrapWorkflowExecuteWithRunRecording({
696
+ let i = N.getWorkflowVersionMetadata(t.definition);
697
+ return N.wrapWorkflowExecuteWithRunRecording({
653
698
  name: t.definition.name,
654
699
  store: e.store,
655
700
  subject: r.subject,
@@ -660,66 +705,66 @@ var Xt = "/_voltro/admin/import", Zt = "/_voltro/admin/export", Q = (e, t) => ({
660
705
  workflowPatches: i.patches,
661
706
  parentExecutionId: r?.parentExecutionId ?? null,
662
707
  parentClosePolicy: r?.parentClosePolicy ?? null,
663
- onParentClose: ({ executionId: e, status: t }) => Ae(e, t),
664
- recorder: N
708
+ onParentClose: ({ executionId: e, status: t }) => ze(e, t),
709
+ recorder: P
665
710
  }, n);
666
- }), ...e.discovered.workflowWorkers ?? []], ze = Re.length > 0 ? j.mergeAll(...Re) : j.empty;
667
- ((e.discovered.workflows?.length ?? 0) > 0 || (e.discovered.workflowWorkers?.length ?? 0) > 0 || e.scheduleCoordination === "cluster") && e.workflowEngineLayer !== void 0 && (o = Oe.make(ze.pipe(j.provideMerge(e.workflowEngineLayer))), await o.runPromise(A.void), a = (e.discovered.workflows?.length ?? 0) > 0 ? $e({
711
+ }), ...e.discovered.workflowWorkers ?? []], He = Ve.length > 0 ? A.mergeAll(...Ve) : A.empty;
712
+ ((e.discovered.workflows?.length ?? 0) > 0 || (e.discovered.workflowWorkers?.length ?? 0) > 0 || e.scheduleCoordination === "cluster") && e.workflowEngineLayer !== void 0 && (o = Ae.make(He.pipe(A.provideMerge(e.workflowEngineLayer))), await o.runPromise(k.void), a = (e.discovered.workflows?.length ?? 0) > 0 ? nt({
668
713
  workflows: e.discovered.workflows ?? [],
669
714
  runEffect: (e) => o.runPromise(e),
670
715
  rememberStartContext: d,
671
716
  signal: async (t, n, r) => {
672
- let i = await k.sendWorkflowSignal({
717
+ let i = await N.sendWorkflowSignal({
673
718
  store: e.store,
674
- recorder: N,
719
+ recorder: P,
675
720
  target: t,
676
721
  signalName: n,
677
722
  payload: r
678
723
  });
679
- return await o.runPromise(k.completeSuspendingSignal({
724
+ return await o.runPromise(N.completeSuspendingSignal({
680
725
  store: e.store,
681
726
  target: t,
682
727
  signalName: n,
683
728
  payload: r
684
729
  })).catch(() => {}), i;
685
730
  },
686
- update: (t, n, r, i) => k.sendWorkflowUpdate({
731
+ update: (t, n, r, i) => N.sendWorkflowUpdate({
687
732
  store: e.store,
688
- recorder: N,
733
+ recorder: P,
689
734
  target: t,
690
735
  updateName: n,
691
736
  payload: r,
692
737
  ...i === void 0 ? {} : { options: i }
693
738
  }),
694
- listRuns: (t) => fe(e.store, t),
695
- retry: (t, n) => ue({
739
+ listRuns: (t) => pe(e.store, t),
740
+ retry: (t, n) => de({
696
741
  store: e.store,
697
742
  workflows: e.discovered.workflows ?? [],
698
743
  runPromise: (e) => o.runPromise(e)
699
744
  }, t, n)
700
745
  }) : void 0);
701
- let Be = j.mergeAll(we.toLayer(T), O, Te), Ve = he(T, e.discovered.queries.map((e) => e.descriptor.name), te), Ge = j.mergeAll(we.toLayer(Ve), O, Te), R = e.observability, Ke = await Ie({
746
+ let Ke = A.mergeAll(Ee.toLayer(E), De, Oe), qe = _e(E, e.discovered.queries.map((e) => e.descriptor.name), te), Je = A.mergeAll(Ee.toLayer(qe), De, Oe), R = e.observability, st = await Le({
702
747
  ...R && R.spanProcessors.length > 0 ? { extraSpanProcessors: R.spanProcessors } : {},
703
748
  ...R && R.metricReaders.length > 0 ? { extraMetricReaders: R.metricReaders } : {},
704
749
  ...R && Object.keys(R.resourceAttributes).length > 0 ? { resourceAttributes: R.resourceAttributes } : {},
705
750
  ...R && R.sampler !== void 0 ? { sampler: R.sampler } : {}
706
- }), Qe = !1, it = e.store.ping ? () => e.store.ping().then(() => !0).catch(() => !1) : void 0, ot = ut({
707
- group: we,
708
- handlersLayer: Be,
709
- httpHandlersLayer: Ge,
751
+ }), lt = !1, gt = e.store.ping ? () => e.store.ping().then(() => !0).catch(() => !1) : void 0, vt = B({
752
+ group: Ee,
753
+ handlersLayer: Ke,
754
+ httpHandlersLayer: Je,
710
755
  port: e.port ?? 4e3,
711
756
  path: e.path ?? "/ws",
712
- tracerLayer: Ke.layer,
757
+ tracerLayer: st.layer,
713
758
  healthCheck: {
714
- isReady: () => Qe,
715
- ...it ? { ping: it } : {}
759
+ isReady: () => lt,
760
+ ...gt ? { ping: gt } : {}
716
761
  },
717
- ...Se.length > 0 ? { httpRoutes: Se } : {},
762
+ ...O.length > 0 ? { httpRoutes: O } : {},
718
763
  ...se.size > 0 ? { webhookRoutes: se } : {}
719
764
  });
720
- if (await Pe(ot), (e.discovered.schedules?.length ?? 0) > 0) {
721
- let t = (e.scheduleCoordination ?? "single") === "advisoryLock" ? We(e.store, e.scheduleReplicaId ?? `pid-${process.pid}`) : lt;
722
- c = await dt(e.discovered.schedules ?? [], {
765
+ if (await Fe(vt), (e.discovered.schedules?.length ?? 0) > 0) {
766
+ let t = (e.scheduleCoordination ?? "single") === "advisoryLock" ? Ge(e.store, e.scheduleReplicaId ?? `pid-${process.pid}`) : ft;
767
+ c = await pt(e.discovered.schedules ?? [], {
723
768
  store: e.store,
724
769
  coordinator: t,
725
770
  defaultTrigger: e.scheduleDefaultTrigger ?? "self",
@@ -738,16 +783,19 @@ var Xt = "/_voltro/admin/import", Zt = "/_voltro/admin/export", Q = (e, t) => ({
738
783
  warn: (e, t) => {
739
784
  process.stderr.write(`[schedule] ${e} ${t ? JSON.stringify(t) : ""}\n`);
740
785
  },
786
+ error: (e, t) => {
787
+ process.stderr.write(`[schedule] ERROR ${e} ${t ? JSON.stringify(t) : ""}\n`);
788
+ },
741
789
  debug: () => {}
742
790
  },
743
791
  ...e.scheduleFireInterceptor === void 0 ? {} : { interceptFire: e.scheduleFireInterceptor },
744
792
  ...e.onScheduleRunEvent === void 0 ? {} : { onRunEvent: e.onScheduleRunEvent }
745
793
  }), e.onSchedulerReady?.(c);
746
794
  }
747
- let pt = e.log ?? M({ scope: "voltro:serve" }), ht, Z;
748
- if ((e.discovered.subscribers?.length ?? 0) > 0 && (ht = s(e.discovered.subscribers ?? [], e.store, pt.child("subscribe"), e.schemaRegistry)), (e.discovered.reactions?.length ?? 0) > 0) {
749
- let t = pt.child("reaction");
750
- Z = ee(e.discovered.reactions ?? [], e.store, {
795
+ let Z = e.log ?? j({ scope: "voltro:serve" }), Nt, Pt;
796
+ if ((e.discovered.subscribers?.length ?? 0) > 0 && (Nt = s(e.discovered.subscribers ?? [], e.store, Z.child("subscribe"), e.schemaRegistry)), (e.discovered.reactions?.length ?? 0) > 0) {
797
+ let t = Z.child("reaction");
798
+ Pt = ee(e.discovered.reactions ?? [], e.store, {
751
799
  runAct: async (n, r) => {
752
800
  if (n.kind === "workflow") {
753
801
  if (g === void 0) {
@@ -755,16 +803,16 @@ var Xt = "/_voltro/admin/import", Zt = "/_voltro/admin/export", Q = (e, t) => ({
755
803
  return;
756
804
  }
757
805
  let e = r.new ?? r.old ?? {};
758
- await et(g, {
806
+ await rt(g, {
759
807
  traceId: `reaction:${n.workflow}`,
760
808
  source: `reaction:${n.workflow}`
761
809
  }).start(n.workflow, e);
762
810
  return;
763
811
  }
764
- await C(n.agent, r, {
812
+ await w(n.agent, r, {
765
813
  findAgentSend: (t) => e.discovered.actions.find((e) => e.descriptor.name === `${t}.send`),
766
- runAction: (e, t, n) => Promise.resolve(me(e, t, n)),
767
- makeSubject: (e) => St(e),
814
+ runAction: (e, t, n) => Promise.resolve(fe(e, t, n)),
815
+ makeSubject: (e) => wt(e),
768
816
  now: () => Date.now(),
769
817
  log: t
770
818
  });
@@ -772,7 +820,7 @@ var Xt = "/_voltro/admin/import", Zt = "/_voltro/admin/export", Q = (e, t) => ({
772
820
  checkBudget: async (n, r) => {
773
821
  try {
774
822
  let { requireAiBudget: t } = await import("@voltro/ai");
775
- return (await A.runPromise(A.either(t(e.store, {
823
+ return (await k.runPromise(k.either(t(e.store, {
776
824
  tenantId: n,
777
825
  limitUsd: r
778
826
  }))))._tag === "Right";
@@ -782,124 +830,121 @@ var Xt = "/_voltro/admin/import", Zt = "/_voltro/admin/export", Q = (e, t) => ({
782
830
  }
783
831
  }, t);
784
832
  }
785
- let At;
786
- return (e.discovered.aggregates?.length ?? 0) > 0 && (At = await i({
833
+ let Ft;
834
+ return (e.discovered.aggregates?.length ?? 0) > 0 && (Ft = await i({
787
835
  discovered: e.discovered.aggregates ?? [],
788
836
  store: e.store,
789
- log: pt.child("aggregate"),
837
+ log: Z.child("aggregate"),
790
838
  ...e.analytics === void 0 ? {} : { analytics: e.analytics },
791
839
  ...e.aggregateStorage === void 0 ? {} : { storage: e.aggregateStorage },
792
840
  ...e.aggregateCoordinator === void 0 ? {} : { coordinator: e.aggregateCoordinator }
793
- }), le = j.succeed(ke, At.registry)), Qe = !0, e.bootTiming?.mark("ready"), {
841
+ }), le = A.succeed(Me, Ft.registry)), lt = !0, e.bootTiming?.mark("ready"), {
794
842
  dispatcher: t,
795
- server: ot,
843
+ server: vt,
796
844
  scheduler: c,
797
845
  close: async () => {
798
- Qe = !1, At?.detach(), Z?.(), ht?.(), await c?.shutdown(), t.close(), await o?.dispose(), await new Promise((e) => ot.close(() => e()));
846
+ lt = !1, Ft?.detach(), Pt?.(), Nt?.(), await c?.shutdown(), t.close(), await o?.dispose(), await new Promise((e) => vt.close(() => e()));
799
847
  }
800
848
  };
801
- }, $ = M({ scope: "voltro:serve" }), pn = (e, t, n) => (e === "production" || e === "staging") && t !== "memory" && n !== "0", mn = (e, t) => {
802
- let n = e.indexOf(t);
803
- return n >= 0 ? e[n + 1] : void 0;
804
- }, hn = async (e) => {
849
+ }, $ = j({ scope: "voltro:serve" }), bn = (e, t, n) => (e === "production" || e === "staging") && t !== "memory" && n !== "0", xn = $t, Sn = async (e) => {
805
850
  let t = O(process.cwd());
806
- if (N(t)) {
851
+ if (je(t)) {
807
852
  let n;
808
853
  try {
809
- let e = await import(De(t).href);
854
+ let e = await import(Oe(t).href);
810
855
  typeof e.runServe == "function" ? n = e.runServe : $.warn("serve bundle has no runServe export — using the standard serve path");
811
856
  } catch (e) {
812
857
  $.warn("serve bundle failed to load — using the standard serve path", {}, e);
813
858
  }
814
859
  if (n) return $.info("serve: booting from the precompiled serve bundle"), n(e);
815
860
  }
816
- return gn(e);
817
- }, gn = async (i) => {
818
- let s = Te();
819
- process.env.NODE_ENV || (process.env.NODE_ENV = "production"), Pt();
820
- let f = process.cwd(), ee = Number(process.env.PORT ?? mn(i, "--port") ?? 4e3), m = await w(f);
821
- ot(it(m?.secrets)), await e({
861
+ return Cn(e);
862
+ }, Cn = async (i) => {
863
+ let s = Ee();
864
+ process.env.NODE_ENV || (process.env.NODE_ENV = "production"), Lt();
865
+ let f = process.cwd(), ee = Number(process.env.PORT ?? xn(i, "--port") ?? 4e3), m = await he(f);
866
+ lt(st(m?.secrets)), await e({
822
867
  rawEnv: m?.env,
823
868
  appType: "api",
824
869
  root: f,
825
870
  log: $,
826
871
  generateTypes: !1
827
872
  }), s.mark("config");
828
- let h = (process.env.DB_DIALECT ?? m?.store ?? "memory").toLowerCase(), _ = (h === "mariadb" || h === "postgres" || h === "mssql") && (process.env.CDC ?? "1") !== "0", ae = h === "mariadb" ? "mariadb" : h === "mssql" ? "mssql" : void 0, ue = we(f);
829
- if (!Ce() && N(ue)) try {
830
- let e = await import(De(ue).href);
873
+ let h = (process.env.DB_DIALECT ?? m?.store ?? "memory").toLowerCase(), _ = (h === "mariadb" || h === "postgres" || h === "mssql") && (process.env.CDC ?? "1") !== "0", ae = h === "mariadb" ? "mariadb" : h === "mssql" ? "mssql" : void 0, de = Te(f);
874
+ if (!we() && je(de)) try {
875
+ let e = await import(Oe(de).href);
831
876
  if (e.modules) {
832
877
  let t = {};
833
- for (let [n, r] of Object.entries(e.modules)) t[Ee(f, n)] = r;
834
- Se(t), $.info("precompiled api bundle loaded", { modules: Object.keys(t).length });
878
+ for (let [n, r] of Object.entries(e.modules)) t[De(f, n)] = r;
879
+ Ce(t), $.info("precompiled api bundle loaded", { modules: Object.keys(t).length });
835
880
  }
836
881
  } catch (e) {
837
882
  $.warn("precompiled api bundle failed to load — falling back to source", {}, e);
838
883
  }
839
- let S = await ce(f), C = await ge(S, { cdc: _ && ae !== void 0 }), fe = S.filter((e) => xe.test(e)), he = fe.length > 0 ? await g(fe, $.child("webhooks")) : void 0, ye = me({
840
- mix: C.featureMix,
884
+ let C = await se(f), w = await E(C, { cdc: _ && ae !== void 0 }), pe = C.filter((e) => Se.test(e)), _e = pe.length > 0 ? await g(pe, $.child("webhooks")) : void 0, be = T({
885
+ mix: w.featureMix,
841
886
  plugins: m?.plugins ?? [],
842
887
  cdc: _ && ae !== void 0,
843
888
  ...ae ? { cdcDialect: ae } : {}
844
- }), be = m?.analytics !== void 0 && m.analytics.kind !== "noop" && h !== "memory" ? (await E(h)).makeSqlLayer(x()) : void 0, D = await ne({
889
+ }), xe = m?.analytics !== void 0 && m.analytics.kind !== "noop" && h !== "memory" ? (await x(h)).makeSqlLayer(S()) : void 0, D = await ne({
845
890
  spec: m?.analytics,
846
- sqlLayer: be,
891
+ sqlLayer: xe,
847
892
  log: $
848
893
  }), O = (() => {
849
- let e = new Set(C.tables.map((e) => e.tableName)), t = [...C.tables];
850
- for (let n of [...ye, ...D.tables]) e.has(n.tableName) || (e.add(n.tableName), t.push(n));
894
+ let e = new Set(w.tables.map((e) => e.tableName)), t = [...w.tables];
895
+ for (let n of [...be, ...D.tables]) e.has(n.tableName) || (e.add(n.tableName), t.push(n));
851
896
  return t;
852
897
  })();
853
- for (let e of O) ht(e);
854
- let M = (process.env.NODE_ENV ?? "").toLowerCase();
855
- if (pn(M, h, process.env.VOLTRO_AUTO_MIGRATE)) {
856
- let e = (await E(h)).makeSqlLayer(x()), t = await A.runPromise(pt.SqlClient.pipe(A.flatMap((e) => Nt(e, O, {
857
- appliedBy: `serve:${M}`,
898
+ for (let e of O) vt(e);
899
+ let j = (process.env.NODE_ENV ?? "").toLowerCase();
900
+ if (bn(j, h, process.env.VOLTRO_AUTO_MIGRATE)) {
901
+ let e = (await x(h)).makeSqlLayer(S()), t = await k.runPromise(gt.SqlClient.pipe(k.flatMap((e) => It(e, O, {
902
+ appliedBy: `serve:${j}`,
858
903
  environment: "prod",
859
904
  dialectId: h
860
- })), A.provide(e)));
861
- t.kind === "prod-mismatch" && ($.error(Mt(t, h)), $.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(Mt(t, h));
905
+ })), k.provide(e)));
906
+ t.kind === "prod-mismatch" && ($.error(Ft(t, h)), $.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(Ft(t, h));
862
907
  }
863
- let ke = Qe(O);
908
+ let Me = R(O);
864
909
  s.mark("discover");
865
- let P = await pe(m, void 0);
910
+ let M = await me(m, void 0);
866
911
  m?.cache && !process.env.CACHE_BACKEND && (process.env.CACHE_BACKEND = m.cache), m?.cacheRedisUrl && !process.env.CACHE_REDIS_URL && (process.env.CACHE_REDIS_URL = m.cacheRedisUrl), m?.cacheRedisDriver && !process.env.CACHE_REDIS_DRIVER && (process.env.CACHE_REDIS_DRIVER = m.cacheRedisDriver), m?.cacheKeyPrefix && !process.env.CACHE_KEY_PREFIX && (process.env.CACHE_KEY_PREFIX = m.cacheKeyPrefix);
867
- let { service: je, invalidationBus: Me, snapshotCache: Pe, cache: F, backend: Fe, dispose: I } = await y({ env: process.env });
868
- $.info(`cache backend resolved: ${Fe}` + (Fe === "redis" ? ` (driver ${process.env.CACHE_REDIS_DRIVER ?? "resp"})` : " — in-process, not cross-instance")), P.onChange((e) => {
869
- A.runFork(Me.publish(e.table));
912
+ let { service: Ne, invalidationBus: Pe, snapshotCache: Fe, cache: F, backend: Ie, dispose: I } = await y({ env: process.env });
913
+ $.info(`cache backend resolved: ${Ie}` + (Ie === "redis" ? ` (driver ${process.env.CACHE_REDIS_DRIVER ?? "resp"})` : " — in-process, not cross-instance")), M.onChange((e) => {
914
+ k.runFork(Pe.publish(e.table));
870
915
  }), m?.kv && !process.env.KV_BACKEND && (process.env.KV_BACKEND = m.kv), m?.kvRedisUrl && !process.env.KV_REDIS_URL && (process.env.KV_REDIS_URL = m.kvRedisUrl), m?.kvKeyPrefix && !process.env.KV_KEY_PREFIX && (process.env.KV_KEY_PREFIX = m.kvKeyPrefix);
871
- let { kv: Ie, service: Le } = await R({ store: P });
916
+ let { kv: Le, service: Re } = await qe({ store: M });
872
917
  s.mark("store");
873
- let He = Ne({
874
- store: P,
918
+ let Ue = P({
919
+ store: M,
875
920
  sink: D.sink,
876
921
  log: $
877
- }), Ue = n({
878
- store: P,
922
+ }), We = n({
923
+ store: M,
879
924
  dialect: h
880
- }), L = m?.plugins ?? [], qe = process.env.POD_NAME ?? process.env.HOSTNAME ?? `serve-${process.pid}`, Je, Ye;
881
- h !== "memory" && (Je = Oe.make((await E(h)).makeSqlLayer(x())), Ye = await Je.runPromise(pt.SqlClient));
882
- let Xe = Ke({
925
+ }), L = m?.plugins ?? [], Ye = process.env.POD_NAME ?? process.env.HOSTNAME ?? `serve-${process.pid}`, Xe, Ze;
926
+ h !== "memory" && (Xe = Ae.make((await x(h)).makeSqlLayer(S())), Ze = await Xe.runPromise(gt.SqlClient));
927
+ let Qe = Je({
883
928
  coordinator: [
884
929
  "postgres",
885
930
  "mariadb",
886
931
  "mysql",
887
932
  "mssql"
888
- ].includes(h) ? We(P, qe, $) : lt,
889
- replicaId: qe,
933
+ ].includes(h) ? Ge(M, Ye, $) : ft,
934
+ replicaId: Ye,
890
935
  log: $
891
- }), Ze = [], $e = {
892
- ...Ye ? { sql: Ye } : {},
936
+ }), $e = [], et = {
937
+ ...Ze ? { sql: Ze } : {},
893
938
  scheduleCoordinated: (e, t, n) => {
894
- let r = Xe(e, t, n);
895
- return Ze.push(r), r;
939
+ let r = Qe(e, t, n);
940
+ return $e.push(r), r;
896
941
  }
897
942
  };
898
- for (let e of L) e.bindDataStore?.(P, $e);
899
- let et = L.filter((e) => typeof e.onChangeEvent == "function");
900
- if (et.length > 0) {
901
- let e = P.changeScope ?? "local";
902
- P.onChange((t) => {
943
+ for (let e of L) e.bindDataStore?.(M, et);
944
+ let tt = L.filter((e) => typeof e.onChangeEvent == "function");
945
+ if (tt.length > 0) {
946
+ let e = M.changeScope ?? "local";
947
+ M.onChange((t) => {
903
948
  let n = {
904
949
  table: t.table,
905
950
  op: t.op,
@@ -908,62 +953,62 @@ var Xt = "/_voltro/admin/import", Zt = "/_voltro/admin/export", Q = (e, t) => ({
908
953
  ...t.origin === void 0 ? {} : { origin: t.origin },
909
954
  changeScope: e
910
955
  };
911
- for (let e of et) A.runFork(e.onChangeEvent(n).pipe(A.catchAllCause((t) => A.sync(() => $.warn(`plugin ${e.name} onChangeEvent failed`, { error: k.pretty(t) })))));
956
+ for (let e of tt) k.runFork(e.onChangeEvent(n).pipe(k.catchAllCause((t) => k.sync(() => $.warn(`plugin ${e.name} onChangeEvent failed`, { error: ke.pretty(t) })))));
912
957
  });
913
958
  }
914
- let tt = oe({
959
+ let nt = oe({
915
960
  plugins: L,
916
961
  appName: m?.name ?? "voltro-api",
917
962
  appType: "api",
918
963
  voltroVersion: process.env.npm_package_version ?? "0.0.0",
919
964
  log: $
920
965
  });
921
- L.length && await tt.activate(), s.mark("plugins");
922
- let nt = await tt.gatherObservability(), rt = await b(P, m, h, {
966
+ L.length && await nt.activate(), s.mark("plugins");
967
+ let rt = await nt.gatherObservability(), it = await b(M, m, h, {
923
968
  info: (e, t) => process.stdout.write(`[broadcast] ${e} ${t ? JSON.stringify(t) : ""}\n`),
924
969
  warn: (e, t) => process.stderr.write(`[broadcast] ${e} ${t ? JSON.stringify(t) : ""}\n`),
925
970
  debug: () => {}
926
- }), z = m?.apiKeys, at = (typeof z == "object" ? z.prefix : void 0) ?? "voltro_", st = z ? Ge(ze(P), { prefix: at }) : void 0, ct = st ? [Ve(st, { prefix: at })] : [], ut = ve([...m?.auth?.strategies ?? [], ...ct], Ft(m?.plugins ?? []), m?.auth?.anonymousTenantRequired ?? !1), dt = [...m?.restRoutes ?? [], ...st ? Ae(st, (typeof z == "object" ? z.managementPath : void 0) ?? "/v1/api-keys") : []], B = m?.idempotency, ft = B ? {
927
- store: Be(P),
971
+ }), z = m?.apiKeys, at = (typeof z == "object" ? z.prefix : void 0) ?? "voltro_", ot = z ? Ke(Be(M), { prefix: at }) : void 0, ct = ot ? [He(ot, { prefix: at })] : [], ut = ve([...m?.auth?.strategies ?? [], ...ct], Rt(m?.plugins ?? []), m?.auth?.anonymousTenantRequired ?? !1), dt = [...m?.restRoutes ?? [], ...ot ? N(ot, (typeof z == "object" ? z.managementPath : void 0) ?? "/v1/api-keys") : []], B = m?.idempotency, pt = B ? {
972
+ store: Ve(M),
928
973
  header: (typeof B == "object" ? B.header : void 0) ?? "Idempotency-Key",
929
974
  ttlMs: (typeof B == "object" ? B.ttlMs : void 0) ?? 864e5
930
- } : void 0, mt = dt.length > 0 ? Lt(dt, {
931
- store: P,
975
+ } : void 0, mt = dt.length > 0 ? Bt(dt, {
976
+ store: M,
932
977
  resolveSubject: (e) => ut({
933
978
  headers: e,
934
979
  clientId: -1
935
980
  }),
936
- ...ft ? { idempotency: ft } : {}
937
- }) : [], V = L.map((e) => e.services).filter((e) => e !== void 0), gt = j.mergeAll(ie({
981
+ ...pt ? { idempotency: pt } : {}
982
+ }) : [], ht = L.map((e) => e.services).filter((e) => e !== void 0), _t = A.mergeAll(ie({
938
983
  analyticsLayer: D.layer,
939
- cacheService: je,
940
- kvService: Le,
941
- pluginServices: V,
984
+ cacheService: Ne,
985
+ kvService: Re,
986
+ pluginServices: ht,
942
987
  userLayers: m?.layers ?? []
943
- }), d), _t = m?.scheduling ?? {}, vt = _t.trigger ?? "self", yt = /* @__PURE__ */ new Set([
988
+ }), d), V = m?.scheduling ?? {}, yt = V.trigger ?? "self", bt = /* @__PURE__ */ new Set([
944
989
  "postgres",
945
990
  "mysql",
946
991
  "mariadb",
947
992
  "mssql"
948
- ]), H = _t.coordination ?? (yt.has(h) ? "advisoryLock" : "single"), U = H === "cluster" && yt.has(h), bt = U ? "cluster" : H === "advisoryLock" && yt.has(h) ? "advisoryLock" : "single";
949
- H === "cluster" && !U && $.warn("scheduling.coordination=cluster needs a sql-backed store except sqlite — falling back to single"), H === "advisoryLock" && !yt.has(h) && $.warn("scheduling.coordination=advisoryLock needs a SQL store (the claim-row gate) — falling back to single");
950
- let xt, W = C.workflows.length > 0 || C.workflowWorkers.length > 0 || C.eventTriggers.length > 0 || (he?.outgoing.length ?? 0) > 0 || U, St;
951
- if (W) {
993
+ ]), xt = V.coordination ?? (bt.has(h) ? "advisoryLock" : "single"), H = xt === "cluster" && bt.has(h), U = H ? "cluster" : xt === "advisoryLock" && bt.has(h) ? "advisoryLock" : "single";
994
+ xt === "cluster" && !H && $.warn("scheduling.coordination=cluster needs a sql-backed store except sqlite — falling back to single"), xt === "advisoryLock" && !bt.has(h) && $.warn("scheduling.coordination=advisoryLock needs a SQL store (the claim-row gate) — falling back to single");
995
+ let St, Ct = w.workflows.length > 0 || w.workflowWorkers.length > 0 || w.eventTriggers.length > 0 || (_e?.outgoing.length ?? 0) > 0 || H, W;
996
+ if (Ct) {
952
997
  if (h === "mssql") {
953
998
  let e = await l(process.cwd());
954
999
  e && $.warn(e);
955
1000
  }
956
- let [{ WorkflowEngine: e }, { makeClusterCronLayer: t, workflowEngineLayer: n, resolveRunnerStorage: r }] = await Promise.all([import("@effect/workflow"), import("@voltro/workflow/cluster")]), i = U ? C.schedules.filter((e) => (e.trigger ?? vt) === "self").map((e) => t({
1001
+ let [{ WorkflowEngine: e }, { makeClusterCronLayer: t, workflowEngineLayer: n, resolveRunnerStorage: r }] = await Promise.all([import("@effect/workflow"), import("@voltro/workflow/cluster")]), i = H ? w.schedules.filter((e) => (e.trigger ?? yt) === "self").map((e) => t({
957
1002
  name: e.name,
958
- cron: Re(e),
1003
+ cron: ze(e),
959
1004
  execute: async () => {
960
- await xt?.fireFromCluster(e.name);
1005
+ await St?.fireFromCluster(e.name);
961
1006
  }
962
1007
  })) : [];
963
- St = h === "memory" ? e.layerMemory : await (async () => {
964
- let e = await E(h), t = r({ sqliteFamily: e.id === "sqlite" || e.id === "turso" });
1008
+ W = h === "memory" ? e.layerMemory : await (async () => {
1009
+ let e = await x(h), t = r({ sqliteFamily: e.id === "sqlite" || e.id === "turso" });
965
1010
  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({
966
- sqlClientLayer: e.makeSqlLayer(x()),
1011
+ sqlClientLayer: e.makeSqlLayer(S()),
967
1012
  runnerStorage: t,
968
1013
  dialectId: e.id,
969
1014
  ...process.env.VOLTRO_WORKFLOW_RUNNER_PORT ? { runnerListenPort: Number(process.env.VOLTRO_WORKFLOW_RUNNER_PORT) } : {},
@@ -971,18 +1016,18 @@ var Xt = "/_voltro/admin/import", Zt = "/_voltro/admin/export", Q = (e, t) => ({
971
1016
  });
972
1017
  })();
973
1018
  }
974
- let Ct = le(L, t()), G = S.filter((e) => /\.subscribe\.tsx?$/.test(e)), wt = G.length > 0 ? await u(G, $) : [], Tt = S.filter((e) => /\.reaction\.tsx?$/.test(e)), Et = Tt.length > 0 ? await r(Tt, $) : [], K = S.filter((e) => /\.outbox\.tsx?$/.test(e)), Dt = K.length > 0 ? await p(K, $) : [], q = S.filter((e) => /\.aggregate\.tsx?$/.test(e)), J = q.length > 0 ? await te(q, $) : [], Y = o();
975
- if (J.length > 0 && h !== "memory") try {
976
- Y = a((await E(h)).makeSqlLayer(x()));
1019
+ let G = ue(L, t()), wt = C.filter((e) => /\.subscribe\.tsx?$/.test(e)), Tt = wt.length > 0 ? await u(wt, $) : [], K = C.filter((e) => /\.reaction\.tsx?$/.test(e)), Et = K.length > 0 ? await r(K, $) : [], Dt = C.filter((e) => fe.test(e)), Ot = Dt.length > 0 ? await p(Dt, $) : [], q = C.filter((e) => /\.aggregate\.tsx?$/.test(e)), kt = q.length > 0 ? await te(q, $) : [], J = o();
1020
+ if (kt.length > 0 && h !== "memory") try {
1021
+ J = a((await x(h)).makeSqlLayer(S()));
977
1022
  } catch (e) {
978
1023
  $.warn("aggregate: SQL storage init failed — falling back to in-process", { err: String(e) });
979
1024
  }
980
- let Ot = h === "memory" ? lt : We(P, `aggregate@${process.pid}`, $), X = [], kt = [], Z = S.filter((e) => de.test(e));
981
- if (Z.length > 0) {
982
- let e = $.child("agent"), t = S.filter((e) => v.test(e));
983
- t.length > 0 && await _e(t, e);
984
- let n = await T(Z, e);
985
- for (let e of n.agents) for (let t of se(e)) (t.kind === "action" ? X : kt).push({
1025
+ let At = h === "memory" ? ft : Ge(M, `aggregate@${process.pid}`, $), Y = [], X = [], jt = C.filter((e) => ye.test(e));
1026
+ if (jt.length > 0) {
1027
+ let e = $.child("agent"), t = C.filter((e) => ce.test(e));
1028
+ t.length > 0 && await ge(t, e);
1029
+ let n = await le(jt, e);
1030
+ for (let e of n.agents) for (let t of v(e)) (t.kind === "action" ? Y : X).push({
986
1031
  file: t.file,
987
1032
  descriptor: t.descriptor,
988
1033
  executor: t.executor
@@ -990,36 +1035,36 @@ var Xt = "/_voltro/admin/import", Zt = "/_voltro/admin/export", Q = (e, t) => ({
990
1035
  n.agents.length > 0 && e.info("synthesized agent routes", { agents: n.agents.map((e) => e.descriptor.name) });
991
1036
  }
992
1037
  s.mark("workflow");
993
- let At = await fn({
1038
+ let Mt = await yn({
994
1039
  bootTiming: s,
995
1040
  discovered: {
996
- queries: [...C.queries, ...kt],
997
- mutations: C.mutations,
998
- actions: [...C.actions, ...X],
999
- streams: C.streams,
1000
- workflows: C.workflows,
1001
- workflowWorkers: C.workflowWorkers,
1002
- eventTriggers: C.eventTriggers,
1003
- schedules: C.schedules,
1004
- subscribers: wt,
1005
- outboxHandlers: Dt,
1006
- connections: C.connections,
1041
+ queries: [...w.queries, ...X],
1042
+ mutations: w.mutations,
1043
+ actions: [...w.actions, ...Y],
1044
+ streams: w.streams,
1045
+ workflows: w.workflows,
1046
+ workflowWorkers: w.workflowWorkers,
1047
+ eventTriggers: w.eventTriggers,
1048
+ schedules: w.schedules,
1049
+ subscribers: Tt,
1050
+ outboxHandlers: Ot,
1051
+ connections: w.connections,
1007
1052
  reactions: Et,
1008
- aggregates: J,
1009
- ...he === void 0 ? {} : { webhooks: he }
1053
+ aggregates: kt,
1054
+ ..._e === void 0 ? {} : { webhooks: _e }
1010
1055
  },
1011
1056
  log: $,
1012
1057
  analytics: D.sink,
1013
- aggregateStorage: Y,
1014
- aggregateCoordinator: Ot,
1015
- store: P,
1016
- kv: Ie,
1058
+ aggregateStorage: J,
1059
+ aggregateCoordinator: At,
1060
+ store: M,
1061
+ kv: Le,
1017
1062
  cache: F,
1018
- snapshotCache: Pe,
1019
- schemaRegistry: ke,
1020
- tenantScopedTables: C.tenantScopedTables,
1021
- softDeleteScopedTables: C.softDeleteScopedTables,
1022
- dataTransferSnapshot: jt(O),
1063
+ snapshotCache: Fe,
1064
+ schemaRegistry: Me,
1065
+ tenantScopedTables: w.tenantScopedTables,
1066
+ softDeleteScopedTables: w.softDeleteScopedTables,
1067
+ dataTransferSnapshot: Pt(O),
1023
1068
  dataTransferDialect: h,
1024
1069
  tenantIsolation: (process.env.VOLTRO_TENANT_ISOLATION ?? m?.tenancy?.isolation) === "namespace" ? "namespace" : "shared-schema",
1025
1070
  resolveSubject: (e, t) => ut({
@@ -1027,44 +1072,46 @@ var Xt = "/_voltro/admin/import", Zt = "/_voltro/admin/export", Q = (e, t) => ({
1027
1072
  clientId: t
1028
1073
  }),
1029
1074
  httpRoutes: [...L.flatMap((e) => e.httpRoutes ?? []), ...mt],
1030
- ...gt ? { baseLayer: gt } : {},
1031
- ...St === void 0 ? {} : { workflowEngineLayer: St },
1032
- scheduleDefaultTrigger: vt,
1033
- scheduleCoordination: bt,
1034
- scheduleArmSelf: !U,
1075
+ ..._t ? { baseLayer: _t } : {},
1076
+ ...W === void 0 ? {} : { workflowEngineLayer: W },
1077
+ scheduleDefaultTrigger: yt,
1078
+ scheduleCoordination: U,
1079
+ scheduleArmSelf: !H,
1035
1080
  dormancy: process.env.VOLTRO_DORMANCY === "sleep" || process.env.VOLTRO_DORMANCY === "always-on" ? process.env.VOLTRO_DORMANCY : m?.dormancy ?? "always-on",
1036
1081
  scheduleReplicaId: process.env.HOSTNAME ?? `pid-${process.pid}`,
1037
- ...Ct === void 0 ? {} : { scheduleFireInterceptor: Ct },
1082
+ ...G === void 0 ? {} : { scheduleFireInterceptor: G },
1038
1083
  onSchedulerReady: (e) => {
1039
- xt = e;
1084
+ St = e;
1040
1085
  },
1041
- observability: nt,
1086
+ observability: rt,
1042
1087
  port: ee,
1043
1088
  ...m?.transport?.wsPath ? { path: m.transport.wsPath } : {}
1044
1089
  });
1045
1090
  c(re([
1046
- C.queries,
1047
- C.mutations,
1048
- C.actions,
1049
- C.streams
1091
+ w.queries,
1092
+ w.mutations,
1093
+ w.actions,
1094
+ w.streams
1050
1095
  ]), (e) => {
1051
1096
  $.warn(e);
1052
1097
  }), $.info(`API listening on :${ee}`, {
1053
1098
  dialect: h,
1054
- queries: C.queries.length,
1055
- mutations: C.mutations.length,
1056
- actions: C.actions.length,
1057
- streams: C.streams.length,
1058
- workflows: C.workflows.length,
1059
- workflowWorkers: C.workflowWorkers.length,
1060
- schedules: C.schedules.length,
1061
- scheduleCoordination: bt
1099
+ queries: w.queries.length,
1100
+ mutations: w.mutations.length,
1101
+ actions: w.actions.length,
1102
+ streams: w.streams.length,
1103
+ workflows: w.workflows.length,
1104
+ workflowWorkers: w.workflowWorkers.length,
1105
+ schedules: w.schedules.length,
1106
+ scheduleCoordination: U
1062
1107
  }), s.finish($);
1063
- let It = () => {
1064
- for (let e of Ze) e.stop();
1065
- He.detach(), Ue.stop(), I(), Je?.dispose(), Promise.resolve(tt.deactivate()).then(() => rt?.close()).then(() => D.dispose()).then(() => At.close()).then(() => P.close?.()).then(() => process.exit(0));
1108
+ let Z = () => {
1109
+ for (let e of $e) e.stop();
1110
+ Ue.detach(), We.stop(), I(), Xe?.dispose(), setTimeout(() => process.exit(0), 1e4).unref?.(), Promise.resolve(nt.deactivate()).then(() => it?.close()).then(() => D.dispose()).then(() => Mt.close()).then(() => M.close?.()).then(() => process.exit(0)).catch((e) => {
1111
+ console.error("serve: shutdown step failed, exiting anyway:", e), process.exit(0);
1112
+ });
1066
1113
  };
1067
- return process.on("SIGINT", It), process.on("SIGTERM", It), await new Promise(() => {}), 0;
1114
+ return process.on("SIGINT", Z), process.on("SIGTERM", Z), await new Promise(() => {}), 0;
1068
1115
  };
1069
1116
  //#endregion
1070
- export { hn as n, un as r, gn as t };
1117
+ export { $t as a, nn as i, Sn as n, tn as o, _n as r, en as s, Cn as t };