@voltro/cli 0.10.0 → 0.11.1

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