@voltro/cli 0.20.0 → 0.20.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 +137 -0
  2. package/dist/apiBuild-C9aHz4Yh.js +2 -0
  3. package/dist/{apiBuild-CSCVI1wC.js → apiBuild-qZBEu59d.js} +2 -2
  4. package/dist/bin.js +41 -9
  5. package/dist/{commands-DQ0mUwDe.js → commands-CA7jwejs.js} +1657 -1593
  6. package/dist/dbCommand-DA_RFj5K.js +2 -0
  7. package/dist/{dbCommand-DJSxnjPt.js → dbCommand-DFw2UoC-.js} +24 -24
  8. package/dist/{dev-Z1E_twG9.js → dev-2AvdzDg2.js} +1 -1
  9. package/dist/{dev-DnHlqqoF.js → dev-OHLsAq4K.js} +1638 -1621
  10. package/dist/index.js +1 -1
  11. package/dist/{inspectMetrics-BL8kZOv3.js → inspectMetrics-DvPNXmGA.js} +12 -3
  12. package/dist/{serveCommand-Dh4qd49N.js → serveCommand-BKqTKWTX.js} +341 -341
  13. package/dist/serveEntry.js +2 -2
  14. package/dist/{start-IVgQe2YD.js → start-CXQ7WL1W.js} +10 -2
  15. package/dist/startEntry.js +2 -2
  16. package/package.json +17 -17
  17. package/templates/AGENTS.md +1 -1
  18. package/templates/agent-docs/_index.md +1 -1
  19. package/templates/agent-docs/cli.md +33 -0
  20. package/templates/agent-docs/database/seedsdialects.md +25 -0
  21. package/templates/agent-docs/database/transactions.md +15 -0
  22. package/templates/agent-docs/whats-new.md +95 -45
  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 +9 -9
  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-B1FDtx1y.js +0 -2
  59. package/dist/dbCommand-C3R5LrBZ.js +0 -2
@@ -1,23 +1,23 @@
1
- import { lt as e, t } from "./inspectMetrics-BL8kZOv3.js";
1
+ import { lt as e, t } from "./inspectMetrics-DvPNXmGA.js";
2
2
  import { s as n } from "./seedRunner-D6eu-u5U.js";
3
3
  import { r, t as i } from "./appModuleLoader-C9r9mxZt.js";
4
4
  import { f as a, m as o, n as s, p as c, u as l } from "./frameworkTableAssembly-sg41s14F.js";
5
5
  import { l as u } from "./fileConventions-CBNPZVOV.js";
6
- import { $ as d, A as ee, B as f, C as te, D as ne, E as p, F as m, G as re, H as h, I as g, L as ie, M as ae, N as _, O as v, P as oe, Q as se, R as ce, S as le, T as y, U as ue, W as de, Z as b, _ as fe, a as x, at as pe, b as me, c as he, et as S, f as C, g as ge, h as w, it as _e, j as ve, k as T, n as ye, nt as be, p as xe, r as Se, rt as Ce, s as we, tt as Te, v as Ee, w as De, x as Oe, y as ke, z as E } from "./dev-DnHlqqoF.js";
7
- import { c as D, r as Ae } from "./apiBuild-CSCVI1wC.js";
8
- import { t as je } from "./bootTiming-BdyP9nYw.js";
9
- import { n as O } from "./cliArgs-qdZSElM3.js";
10
- import { join as k } from "node:path";
11
- import { pathToFileURL as Me } from "node:url";
12
- import { Cause as Ne, Effect as A, Layer as j, ManagedRuntime as Pe } from "effect";
13
- import { createLogger as M } from "@voltro/logger";
14
- import { existsSync as Fe } from "node:fs";
15
- import { AggregateRegistry as N, Dispatcher as Ie, apiKeyManagementRoutes as Le, applySoftDeleteScope as Re, applyTenantScope as ze, attachAnalyticsMirror as Be, awaitServerListening as Ve, bindMutation as P, bindStream as He, bindSubscription as F, buildTracingLayer as Ue, cancelWakeup as We, compileCron as Ge, dataStoreApiKeyStore as Ke, dataStoreIdempotencyStore as I, formatServerOnlyLeaks as qe, frameworkApiKeyStrategy as Je, installPolicyGuardResolver as Ye, loadResourceTuples as Xe, makeActionRunner as L, makeAdvisoryLockCoordinator as Ze, makeApiKeyService as Qe, makeApiKeyUsageBuffer as $e, makeApiKeyUsageFlusher as et, makeAsyncKv as tt, makeCoordinatedScheduler as nt, makeEffectStoreLayer as R, makeLazyWorkflowFacade as rt, makeMutationRunner as it, makeOneShotQueryRunner as at, makeQueryDescriptorProducer as ot, makeQueryReauthorizer as st, makeQuerySubscriber as ct, makeSchemaRegistry as lt, makeWorkflowFacade as ut, makeWorkflowFacadeWithCallerContext as dt, makeWorkflowLayers as ft, noopKv as z, recordSubscriptionDelivery as pt, registerWakeup as B, resolveSecretsBackend as mt, runProvidedEffect as V, setSecretsBackend as ht, setSystemStoreHandle as gt, setTupleSource as _t, singleCoordinator as vt, startRpcServer as yt, startScheduler as bt, workflowToRpc as H, wrapStoreWithBootCodec as xt } from "@voltro/runtime";
16
- import { RpcGroup as St } from "@effect/rpc";
17
- import { SqlClient as Ct } from "@effect/sql";
18
- import { and as wt, ensureTableRegistered as Tt, eq as U, or as Et } from "@voltro/database";
19
- import { appStorageProvider as W, fromNodeReadable as Dt, getObjectStream as Ot, putObjectStream as kt, toNodeReadable as G } from "@voltro/plugin-storage";
20
- import { AuthMiddleware as At, ConnectionInfoMiddleware as jt, actionToRpc as K, anonymousSubject as Mt, mutationToRpc as Nt, queryToRpc as q, streamToRpc as Pt, workflowCancelDescriptor as Ft, workflowDomainEventsQueryDescriptor as It, workflowEventDeliveriesQueryDescriptor as J, workflowResumeDescriptor as Lt, workflowRunEventsQueryDescriptor as Y, workflowRunQueryDescriptor as X, workflowRunStepsQueryDescriptor as Z, workflowRunsQueryDescriptor as Rt, workflowSignalDescriptor as zt, workflowUpdateDescriptor as Bt } from "@voltro/protocol";
6
+ import { $ as d, A as ee, B as f, C as te, D as ne, E as p, F as re, G as m, I as ie, K as ae, L as h, M as g, N as oe, O as se, P as _, Q as v, R as y, S as ce, T as le, U as ue, V as de, W as b, _ as x, a as S, at as fe, b as pe, et as C, g as w, it as me, j as T, k as he, l as E, m as ge, n as _e, nt as ve, ot as ye, p as be, r as xe, rt as Se, s as Ce, tt as we, v as Te, w as Ee, x as De, y as Oe, z as D } from "./dev-OHLsAq4K.js";
7
+ import { c as O, r as ke } from "./apiBuild-qZBEu59d.js";
8
+ import { t as Ae } from "./bootTiming-BdyP9nYw.js";
9
+ import { n as k } from "./cliArgs-qdZSElM3.js";
10
+ import { join as A } from "node:path";
11
+ import { pathToFileURL as je } from "node:url";
12
+ import { Cause as Me, Effect as j, Layer as M, ManagedRuntime as Ne } from "effect";
13
+ import { createLogger as N } from "@voltro/logger";
14
+ import { existsSync as Pe } from "node:fs";
15
+ import { AggregateRegistry as P, Dispatcher as Fe, apiKeyManagementRoutes as Ie, applySoftDeleteScope as Le, applyTenantScope as Re, attachAnalyticsMirror as ze, awaitServerListening as Be, bindMutation as F, bindStream as Ve, bindSubscription as I, buildTracingLayer as He, cancelWakeup as Ue, compileCron as We, dataStoreApiKeyStore as Ge, dataStoreIdempotencyStore as L, formatServerOnlyLeaks as Ke, frameworkApiKeyStrategy as qe, installPolicyGuardResolver as Je, loadResourceTuples as Ye, makeActionRunner as R, makeAdvisoryLockCoordinator as Xe, makeApiKeyService as Ze, makeApiKeyUsageBuffer as Qe, makeApiKeyUsageFlusher as $e, makeAsyncKv as et, makeCoordinatedScheduler as tt, makeEffectStoreLayer as nt, makeLazyWorkflowFacade as rt, makeMutationRunner as it, makeOneShotQueryRunner as at, makeQueryDescriptorProducer as ot, makeQueryReauthorizer as st, makeQuerySubscriber as ct, makeSchemaRegistry as lt, makeWorkflowFacade as ut, makeWorkflowFacadeWithCallerContext as dt, makeWorkflowLayers as ft, noopKv as z, recordSubscriptionDelivery as pt, registerWakeup as B, resolveSecretsBackend as mt, runProvidedEffect as ht, setSecretsBackend as gt, setSystemStoreHandle as _t, setTupleSource as vt, singleCoordinator as yt, startRpcServer as bt, startScheduler as xt, workflowToRpc as V, wrapStoreWithBootCodec as St } from "@voltro/runtime";
16
+ import { RpcGroup as Ct } from "@effect/rpc";
17
+ import { SqlClient as wt } from "@effect/sql";
18
+ import { and as Tt, ensureTableRegistered as Et, eq as H, or as Dt } from "@voltro/database";
19
+ import { appStorageProvider as U, fromNodeReadable as Ot, getObjectStream as kt, putObjectStream as At, toNodeReadable as W } from "@voltro/plugin-storage";
20
+ import { AuthMiddleware as jt, ConnectionInfoMiddleware as Mt, actionToRpc as G, anonymousSubject as Nt, mutationToRpc as Pt, queryToRpc as K, streamToRpc as Ft, workflowCancelDescriptor as It, workflowDomainEventsQueryDescriptor as Lt, workflowEventDeliveriesQueryDescriptor as q, workflowResumeDescriptor as Rt, workflowRunEventsQueryDescriptor as J, workflowRunQueryDescriptor as Y, workflowRunStepsQueryDescriptor as X, workflowRunsQueryDescriptor as zt, workflowSignalDescriptor as Bt, workflowUpdateDescriptor as Z } from "@voltro/protocol";
21
21
  import { assertProductionSessionSecret as Vt } from "@voltro/protocol/session";
22
22
  import { createHash as Ht, timingSafeEqual as Ut } from "node:crypto";
23
23
  import { declaredSnapshot as Wt, describeOutcome as Gt, runPlannedMigrations as Kt } from "@voltro/database/sql";
@@ -41,7 +41,7 @@ var ln = "VoltroBootRefusal", un = (e) => {
41
41
  if (!t || t.length < 16) return Q(503, { error: "data transfer misconfigured (no/weak secret)" });
42
42
  let n = pn(e.headers);
43
43
  return !n || !mn(n, t) ? Q(401, { error: "unauthorized" }) : null;
44
- }, gn = M({ scope: "voltro:admin-import" }), _n = "VBUNDLE2", vn = async function* (e) {
44
+ }, gn = N({ scope: "voltro:admin-import" }), _n = "VBUNDLE2", vn = async function* (e) {
45
45
  yield e;
46
46
  }, yn = (e) => async (t) => {
47
47
  let n = hn(t, e.secret);
@@ -65,7 +65,7 @@ var ln = "VoltroBootRefusal", un = (e) => {
65
65
  dir: f,
66
66
  blobs: e.assetSink
67
67
  }) : await cn(c, f);
68
- let t = await A.runPromiseExit(rn({
68
+ let t = await j.runPromiseExit(rn({
69
69
  store: e.store,
70
70
  bundleDir: f,
71
71
  ...r ? { mode: r } : {},
@@ -120,7 +120,7 @@ var ln = "VoltroBootRefusal", un = (e) => {
120
120
  force: !0
121
121
  });
122
122
  }
123
- }, bn = M({ scope: "voltro:admin-export" }), xn = async (e) => {
123
+ }, bn = N({ scope: "voltro:admin-export" }), xn = async (e) => {
124
124
  let t = [];
125
125
  for await (let n of e) t.push(Buffer.from(n));
126
126
  return new Uint8Array(Buffer.concat(t));
@@ -153,7 +153,7 @@ var ln = "VoltroBootRefusal", un = (e) => {
153
153
  }
154
154
  let a = r.consistency === "snapshot" ? "snapshot" : i.consistency ?? "live", o = (typeof r.compression == "string" ? r.compression : void 0) ?? i.compression, s = i.scope ?? Sn(r), c = typeof r.bundleKey == "string" && r.bundleKey.length > 0, l = r.assets === !0 && e.assetSource ? { blobs: e.assetSource } : {}, u = await import("node:os"), d = await import("node:fs/promises"), ee = await import("node:path"), f = await d.mkdtemp(ee.join(u.tmpdir(), "voltro-admin-export-"));
155
155
  try {
156
- let t = await A.runPromise(nn({
156
+ let t = await j.runPromise(nn({
157
157
  store: e.store,
158
158
  snapshot: e.snapshot,
159
159
  dialect: e.dialect,
@@ -229,7 +229,7 @@ var ln = "VoltroBootRefusal", un = (e) => {
229
229
  if (!o) throw Error(`data profile '${i}' has no default export`);
230
230
  return o;
231
231
  }, Tn = (e, t, n = {}) => (async function* () {
232
- let r = await G((await A.runPromise(Ot(e, t).pipe(A.timeout(n.openTimeout ?? "30 seconds")))).stream), i = n.stallMs ?? 12e4, a, o = () => {
232
+ let r = await W((await j.runPromise(kt(e, t).pipe(j.timeout(n.openTimeout ?? "30 seconds")))).stream), i = n.stallMs ?? 12e4, a, o = () => {
233
233
  a && clearTimeout(a), a = setTimeout(() => r.destroy(/* @__PURE__ */ Error(`storage read stalled for ${i}ms reading '${t}'`)), i);
234
234
  };
235
235
  try {
@@ -248,11 +248,11 @@ var ln = "VoltroBootRefusal", un = (e) => {
248
248
  invalidateTag: async () => 0,
249
249
  wrap: async (e, t, n) => n()
250
250
  }, Dn = async (e) => {
251
- gt({
251
+ _t({
252
252
  dataStore: e.store,
253
253
  schemaRegistry: e.schemaRegistry
254
254
  });
255
- let t = new Ie({
255
+ let t = new Fe({
256
256
  store: e.store,
257
257
  ...e.snapshotCache ? { cache: e.snapshotCache } : {},
258
258
  recordDelivery: (e) => pt({
@@ -271,7 +271,7 @@ var ln = "VoltroBootRefusal", un = (e) => {
271
271
  let r = await e.store.query({
272
272
  table: "_voltro_workflow_start_contexts",
273
273
  order: [],
274
- predicate: U("executionId", n),
274
+ predicate: H("executionId", n),
275
275
  projection: ["id"],
276
276
  skip: void 0,
277
277
  take: 1
@@ -299,7 +299,7 @@ var ln = "VoltroBootRefusal", un = (e) => {
299
299
  let t = (await e.store.query({
300
300
  table: "_voltro_workflow_start_contexts",
301
301
  order: [],
302
- predicate: U("executionId", n),
302
+ predicate: H("executionId", n),
303
303
  projection: void 0,
304
304
  skip: void 0,
305
305
  take: 1
@@ -317,26 +317,26 @@ var ln = "VoltroBootRefusal", un = (e) => {
317
317
  process.stderr.write(`[workflow] failed to load start context for ${n}: ${e?.message ?? String(e)}\n`);
318
318
  return;
319
319
  }
320
- }, d = (e.discovered.workflows?.length ?? 0) > 0 ? rt(() => i) : void 0, f = (e.discovered.workflows?.length ?? 0) > 0 || (e.discovered.eventTriggers?.length ?? 0) > 0, te = f || (e.discovered.workflowWorkers?.length ?? 0) > 0 || e.scheduleCoordination === "cluster", ne = e.tenantIsolation === "namespace", p = (e.log ?? M({ scope: "voltro:serve" })).child("webhooks"), re, h = e.discovered.webhooks;
321
- if (h && h.outgoing.length > 0 && e.workflowEngineLayer !== void 0) {
322
- let t = e.workflowEngineLayer, i = be({
320
+ }, d = (e.discovered.workflows?.length ?? 0) > 0 ? rt(() => i) : 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", m = (e.log ?? N({ scope: "voltro:serve" })).child("webhooks"), ae, g = e.discovered.webhooks;
321
+ if (g && g.outgoing.length > 0 && e.workflowEngineLayer !== void 0) {
322
+ let t = e.workflowEngineLayer, i = Se({
323
323
  store: e.store,
324
324
  schemaRegistry: e.schemaRegistry,
325
325
  cache: n,
326
326
  kv: r
327
- }), a = h.outgoing.map((e) => e.descriptor);
328
- re = Zt(i, async (e) => {
329
- let n = $t.execute(e).pipe(A.provide($t.toLayer(Xt(i, { events: a })).pipe(j.provideMerge(t))));
330
- A.runPromise(n).catch((t) => {
331
- p.error("deliverWebhook workflow crashed", {
327
+ }), a = g.outgoing.map((e) => e.descriptor);
328
+ ae = Zt(i, async (e) => {
329
+ let n = $t.execute(e).pipe(j.provide($t.toLayer(Xt(i, { events: a })).pipe(M.provideMerge(t))));
330
+ j.runPromise(n).catch((t) => {
331
+ m.error("deliverWebhook workflow crashed", {
332
332
  deliveryId: e.deliveryId,
333
333
  targetId: e.targetId
334
334
  }, t);
335
335
  });
336
336
  }, { events: a });
337
337
  }
338
- let ie = /* @__PURE__ */ new Map();
339
- if (h) for (let e of h.incoming) {
338
+ let oe = /* @__PURE__ */ new Map();
339
+ if (g) for (let e of g.incoming) {
340
340
  let t = e.descriptor.path ?? Qt(e.descriptor.id), n = `VOLTRO_WEBHOOK_SECRET_${e.descriptor.id.toUpperCase().replace(/[^A-Z0-9]/g, "_")}`, r = en(e.descriptor, {
341
341
  resolveSecret: async () => process.env[n] ?? null,
342
342
  resolveWorkflows: () => d === void 0 ? void 0 : dt(d, {
@@ -351,136 +351,136 @@ var ln = "VoltroBootRefusal", un = (e) => {
351
351
  idempotency: e.idempotency,
352
352
  durationMs: e.durationMs
353
353
  };
354
- e.status >= 500 ? p.error("incoming delivery failed", t) : e.status >= 400 ? p.warn("incoming delivery rejected", t) : p.info("incoming delivery handled", t);
354
+ e.status >= 500 ? m.error("incoming delivery failed", t) : e.status >= 400 ? m.warn("incoming delivery rejected", t) : m.info("incoming delivery handled", t);
355
355
  }
356
356
  });
357
- ie.set(t, { handle: r });
357
+ oe.set(t, { handle: r });
358
358
  }
359
- Ye(), _t((t) => Xe(e.store, t.subjectId, t.resourceType, t.resourceId));
360
- let ae = (e.discovered.outboxHandlers?.length ?? 0) > 0 ? ce({
359
+ Je(), vt((t) => Ye(e.store, t.subjectId, t.resourceType, t.resourceId));
360
+ let se = (e.discovered.outboxHandlers?.length ?? 0) > 0 ? D({
361
361
  handlers: e.discovered.outboxHandlers ?? [],
362
362
  store: e.store,
363
- log: (e.log ?? M({ scope: "voltro:serve" })).child("outbox")
364
- }) : void 0, _ = g({
363
+ log: (e.log ?? N({ scope: "voltro:serve" })).child("outbox")
364
+ }) : void 0, _ = h({
365
365
  definitions: (e.discovered.connections ?? []).map((e) => e.definition),
366
366
  store: e.store,
367
- publicUrl: m(e.port ?? 4e3),
368
- log: (e.log ?? M({ scope: "voltro:serve" })).child("connections")
369
- }), v = Te({
367
+ publicUrl: ie(e.port ?? 4e3),
368
+ log: (e.log ?? N({ scope: "voltro:serve" })).child("connections")
369
+ }), y = ve({
370
370
  store: e.store,
371
371
  schemaRegistry: e.schemaRegistry,
372
372
  cache: n,
373
373
  kv: r,
374
- ...re === void 0 ? {} : { webhooksService: re },
374
+ ...ae === void 0 ? {} : { webhooksService: ae },
375
375
  ...d === void 0 ? {} : { workflowsProxy: d },
376
376
  eventTriggers: e.discovered.eventTriggers ?? [],
377
- namespaceIsolationOn: ne,
378
- ...ae === void 0 ? {} : { outbox: { nudge: ae.nudge } },
377
+ namespaceIsolationOn: re,
378
+ ...se === void 0 ? {} : { outbox: { nudge: se.nudge } },
379
379
  ..._.active ? { connections: { registry: _.registry } } : {}
380
- }), oe = j.succeed(N, y), se = (t, n) => {
381
- let r = t.pipe(A.provide(R(n)));
382
- return V((e.baseLayer ? r.pipe(A.provide(e.baseLayer)) : r).pipe(A.provide(oe)));
383
- }, le = it({
380
+ }), ce = M.succeed(P, p), ue = (t, n) => {
381
+ let r = t.pipe(j.provide(nt(n)));
382
+ return ht((e.baseLayer ? r.pipe(j.provide(e.baseLayer)) : r).pipe(j.provide(ce)));
383
+ }, de = it({
384
384
  store: e.store,
385
- buildContext: (e, t, n) => v(e, t, n),
386
- runEffect: se,
387
- undoCapture: me()
388
- }), ue = ke(), de = L({
389
- buildContext: (e) => v(e),
390
- runEffect: se
385
+ buildContext: (e, t, n) => y(e, t, n),
386
+ runEffect: ue,
387
+ undoCapture: De()
388
+ }), b = pe(), S = R({
389
+ buildContext: (e) => y(e),
390
+ runEffect: ue
391
391
  }), fe = {
392
- buildContext: (e) => v(e),
393
- finalize: (t, n) => Re(ze(t, e.tenantScopedTables, n.subject.tenantId), e.softDeleteScopedTables),
394
- provideEffect: (e, t) => e.pipe(A.provide(R(t)))
395
- }, x = ot(fe), pe = at({
392
+ buildContext: (e) => y(e),
393
+ finalize: (t, n) => Le(Re(t, e.tenantScopedTables, n.subject.tenantId), e.softDeleteScopedTables),
394
+ provideEffect: (e, t) => e.pipe(j.provide(nt(t)))
395
+ }, C = ot(fe), me = at({
396
396
  ...fe,
397
397
  queryRows: (t) => e.store.query(t)
398
398
  }), he = ct({
399
399
  ...fe,
400
400
  subscribeDescriptor: (e, n, r) => t.subscribe(e, n, r),
401
401
  subscribeComputed: (e, n, r) => t.subscribeComputed(e, n, r)
402
- }), C = {};
402
+ }), E = {};
403
403
  for (let n of [
404
404
  ...e.discovered.queries,
405
- ...ue.queries,
405
+ ...b.queries,
406
406
  ..._.queries
407
- ]) C[n.descriptor.name] = (e) => F(x(n, e), t, `subscription.${n.descriptor.name}`, void 0, void 0, st(n, e));
407
+ ]) E[n.descriptor.name] = (e) => I(C(n, e), t, `subscription.${n.descriptor.name}`, void 0, void 0, st(n, e));
408
408
  for (let t of [
409
409
  ...e.discovered.mutations,
410
- ...ue.mutations,
410
+ ...b.mutations,
411
411
  ..._.mutations
412
- ]) C[t.descriptor.name] = (e) => P(async (e, n) => le(t, e, n), e, `mutation.${t.descriptor.name}`);
413
- for (let t of [...e.discovered.actions, ..._.actions]) C[t.descriptor.name] = (e) => P(async (e, n) => de(t, e, n), e, `action.${t.descriptor.name}`);
414
- let _e = () => `public-${Math.random().toString(36).slice(2, 10)}`, ve = [
412
+ ]) E[t.descriptor.name] = (e) => F(async (e, n) => de(t, e, n), e, `mutation.${t.descriptor.name}`);
413
+ for (let t of [...e.discovered.actions, ..._.actions]) E[t.descriptor.name] = (e) => F(async (e, n) => S(t, e, n), e, `action.${t.descriptor.name}`);
414
+ let ge = () => `public-${Math.random().toString(36).slice(2, 10)}`, _e = [
415
415
  ...e.discovered.queries.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
416
416
  descriptor: e.descriptor,
417
- invoke: (t, n) => pe(e, t, {
417
+ invoke: (t, n) => me(e, t, {
418
418
  subject: n.subject,
419
- traceId: _e()
419
+ traceId: ge()
420
420
  }),
421
421
  subscribe: (t, n, r) => he(e, t, {
422
422
  subject: n.subject,
423
- traceId: _e()
423
+ traceId: ge()
424
424
  }, r)
425
425
  })),
426
426
  ...e.discovered.mutations.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
427
427
  descriptor: e.descriptor,
428
- invoke: (t, n) => le(e, t, {
428
+ invoke: (t, n) => de(e, t, {
429
429
  subject: n.subject,
430
- traceId: _e()
430
+ traceId: ge()
431
431
  })
432
432
  })),
433
433
  ...e.discovered.actions.filter((e) => e.descriptor.publicApi !== void 0).map((e) => ({
434
434
  descriptor: e.descriptor,
435
- invoke: (t, n) => de(e, t, {
435
+ invoke: (t, n) => S(e, t, {
436
436
  subject: n.subject,
437
- traceId: _e()
437
+ traceId: ge()
438
438
  })
439
439
  }))
440
- ], ye = ve.length > 0 ? Yt(Jt(ve), {
440
+ ], ye = _e.length > 0 ? Yt(Jt(_e), {
441
441
  store: e.store,
442
442
  resolveSubject: (t) => e.resolveSubject(t, -1)
443
- }) : [], xe = e.dataTransferSecret ?? process.env.VOLTRO_DATA_TRANSFER_SECRET, Se = xe && xe.length >= 16 ? [{
443
+ }) : [], be = e.dataTransferSecret ?? process.env.VOLTRO_DATA_TRANSFER_SECRET, xe = be && be.length >= 16 ? [{
444
444
  method: "POST",
445
445
  path: dn,
446
446
  handle: yn({
447
- secret: xe,
447
+ secret: be,
448
448
  store: e.store,
449
449
  ...e.dataTransferSnapshot ? { snapshot: e.dataTransferSnapshot } : {},
450
- assetSink: an(W()),
451
- openArchive: (e) => Tn(W(), e)
450
+ assetSink: an(U()),
451
+ openArchive: (e) => Tn(U(), e)
452
452
  })
453
453
  }, {
454
454
  method: "POST",
455
455
  path: fn,
456
456
  handle: Cn({
457
- secret: xe,
457
+ secret: be,
458
458
  store: e.store,
459
459
  snapshot: e.dataTransferSnapshot ?? { tables: [] },
460
460
  dialect: e.dataTransferDialect ?? "memory",
461
461
  tenantTables: [...e.tenantScopedTables],
462
462
  loadProfile: wn,
463
- assetSource: on(W(), e.store),
463
+ assetSource: on(U(), e.store),
464
464
  putArchive: async (e, t) => {
465
- let { Readable: n } = await import("node:stream"), r = W(), i = Dt("storage", () => n.from(t()));
466
- await A.runPromise(kt(r, e, i, { contentType: "application/octet-stream" }));
465
+ let { Readable: n } = await import("node:stream"), r = U(), i = Ot("storage", () => n.from(t()));
466
+ await j.runPromise(At(r, e, i, { contentType: "application/octet-stream" }));
467
467
  }
468
468
  })
469
469
  }] : [], Ce = [
470
470
  ...e.httpRoutes ?? [],
471
471
  ...ye,
472
- ...Se,
472
+ ...xe,
473
473
  ..._.httpRoutes
474
474
  ];
475
- for (let t of e.discovered.streams ?? []) C[t.descriptor.name] = (n) => He((r) => {
476
- let i = v(r), a = t.executor(n, i);
477
- if (A.isEffect(a)) {
478
- let t = a.pipe(A.provide(R(i.store)));
479
- return (e.baseLayer ? t.pipe(A.provide(e.baseLayer)) : t).pipe(A.provide(oe));
475
+ for (let t of e.discovered.streams ?? []) E[t.descriptor.name] = (n) => Ve((r) => {
476
+ let i = y(r), a = t.executor(n, i);
477
+ if (j.isEffect(a)) {
478
+ let t = a.pipe(j.provide(nt(i.store)));
479
+ return (e.baseLayer ? t.pipe(j.provide(e.baseLayer)) : t).pipe(j.provide(ce));
480
480
  }
481
- return typeof a == "object" && a && typeof a.then == "function" ? A.promise(() => a) : a;
481
+ return typeof a == "object" && a && typeof a.then == "function" ? j.promise(() => a) : a;
482
482
  }, `stream.${t.descriptor.name}`);
483
- for (let t of e.discovered.workflows ?? []) C[t.definition.name] = (e) => P(async (e, n) => {
483
+ for (let t of e.discovered.workflows ?? []) E[t.definition.name] = (e) => F(async (e, n) => {
484
484
  let r = n;
485
485
  return dt(d, {
486
486
  subject: r.subject,
@@ -488,8 +488,8 @@ var ln = "VoltroBootRefusal", un = (e) => {
488
488
  source: "workflow-rpc"
489
489
  }).start(t.definition.name, e);
490
490
  }, e, `workflow.${t.definition.name}`);
491
- f && (C[X.name] = (e) => F(x({
492
- descriptor: X,
491
+ te && (E[Y.name] = (e) => I(C({
492
+ descriptor: Y,
493
493
  executor: (e) => {
494
494
  let t = e.id;
495
495
  return {
@@ -498,30 +498,30 @@ var ln = "VoltroBootRefusal", un = (e) => {
498
498
  column: "startedAt",
499
499
  direction: "desc"
500
500
  }],
501
- predicate: Et(U("id", t), U("executionId", t)),
501
+ predicate: Dt(H("id", t), H("executionId", t)),
502
502
  take: 1,
503
503
  skip: void 0,
504
504
  projection: void 0
505
505
  };
506
506
  }
507
- }, e), t, `subscription.${X.name}`), C[Rt.name] = (e) => F(x({
508
- descriptor: Rt,
507
+ }, e), t, `subscription.${Y.name}`), E[zt.name] = (e) => I(C({
508
+ descriptor: zt,
509
509
  executor: (e) => {
510
- let t = e, n = [...t.tag === void 0 ? [] : [U("tag", t.tag)], ...t.status === void 0 ? [] : [U("status", t.status)]], r = Number.isFinite(t.limit) && t.limit !== void 0 ? Math.min(Math.max(Math.floor(t.limit), 1), 500) : 100;
510
+ 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;
511
511
  return {
512
512
  table: "_voltro_workflow_runs",
513
513
  order: [{
514
514
  column: "startedAt",
515
515
  direction: "desc"
516
516
  }],
517
- predicate: n.length === 0 ? void 0 : n.length === 1 ? n[0] : wt(...n),
517
+ predicate: n.length === 0 ? void 0 : n.length === 1 ? n[0] : Tt(...n),
518
518
  take: r,
519
519
  skip: void 0,
520
520
  projection: void 0
521
521
  };
522
522
  }
523
- }, e), t, `subscription.${Rt.name}`), C[Z.name] = (e) => F(x({
524
- descriptor: Z,
523
+ }, e), t, `subscription.${zt.name}`), E[X.name] = (e) => I(C({
524
+ descriptor: X,
525
525
  executor: (e) => {
526
526
  let t = e.runId;
527
527
  return {
@@ -530,14 +530,14 @@ var ln = "VoltroBootRefusal", un = (e) => {
530
530
  column: "startedAt",
531
531
  direction: "asc"
532
532
  }],
533
- predicate: U("runId", t),
533
+ predicate: H("runId", t),
534
534
  take: 1e3,
535
535
  skip: void 0,
536
536
  projection: void 0
537
537
  };
538
538
  }
539
- }, e), t, `subscription.${Z.name}`), C[Y.name] = (e) => F(x({
540
- descriptor: Y,
539
+ }, e), t, `subscription.${X.name}`), E[J.name] = (e) => I(C({
540
+ descriptor: J,
541
541
  executor: (e) => {
542
542
  let t = e.runId;
543
543
  return {
@@ -546,14 +546,14 @@ var ln = "VoltroBootRefusal", un = (e) => {
546
546
  column: "occurredAt",
547
547
  direction: "asc"
548
548
  }],
549
- predicate: U("runId", t),
549
+ predicate: H("runId", t),
550
550
  take: 1e3,
551
551
  skip: void 0,
552
552
  projection: void 0
553
553
  };
554
554
  }
555
- }, e), t, `subscription.${Y.name}`), C[It.name] = (e) => F(x({
556
- descriptor: It,
555
+ }, e), t, `subscription.${J.name}`), E[Lt.name] = (e) => I(C({
556
+ descriptor: Lt,
557
557
  executor: (e) => {
558
558
  let t = e;
559
559
  return {
@@ -562,14 +562,14 @@ var ln = "VoltroBootRefusal", un = (e) => {
562
562
  column: "occurredAt",
563
563
  direction: "desc"
564
564
  }],
565
- predicate: t.name === void 0 ? void 0 : U("name", t.name),
565
+ predicate: t.name === void 0 ? void 0 : H("name", t.name),
566
566
  take: Math.max(1, Math.min(500, t.limit ?? 100)),
567
567
  skip: void 0,
568
568
  projection: void 0
569
569
  };
570
570
  }
571
- }, e), t, `subscription.${It.name}`), C[J.name] = (e) => F(x({
572
- descriptor: J,
571
+ }, e), t, `subscription.${Lt.name}`), E[q.name] = (e) => I(C({
572
+ descriptor: q,
573
573
  executor: (e) => {
574
574
  let t = e.eventId;
575
575
  return {
@@ -578,69 +578,69 @@ var ln = "VoltroBootRefusal", un = (e) => {
578
578
  column: "createdAt",
579
579
  direction: "asc"
580
580
  }],
581
- predicate: U("eventId", t),
581
+ predicate: H("eventId", t),
582
582
  take: 500,
583
583
  skip: void 0,
584
584
  projection: void 0
585
585
  };
586
586
  }
587
- }, e), t, `subscription.${J.name}`), C[Ft.name] = (t) => P(async (t, n) => {
587
+ }, e), t, `subscription.${q.name}`), E[It.name] = (t) => F(async (t, n) => {
588
588
  let r = t;
589
- return await S(e.store, n.subject, { executionId: r.executionId }), await d.cancel(r.workflowName, r.executionId), await Ne(r.workflowName, r.executionId, "workflow.cancel"), { ok: !0 };
590
- }, t, `action.${Ft.name}`), C[Lt.name] = (t) => P(async (t, n) => {
589
+ return await we(e.store, n.subject, { executionId: r.executionId }), await d.cancel(r.workflowName, r.executionId), await Me(r.workflowName, r.executionId, "workflow.cancel"), { ok: !0 };
590
+ }, t, `action.${It.name}`), E[Rt.name] = (t) => F(async (t, n) => {
591
591
  let r = t;
592
- return await S(e.store, n.subject, { executionId: r.executionId }), await d.resume(r.workflowName, r.executionId), { ok: !0 };
593
- }, t, `action.${Lt.name}`), C[zt.name] = (t) => P(async (t, n) => {
592
+ return await we(e.store, n.subject, { executionId: r.executionId }), await d.resume(r.workflowName, r.executionId), { ok: !0 };
593
+ }, t, `action.${Rt.name}`), E[Bt.name] = (t) => F(async (t, n) => {
594
594
  let r = t;
595
- return await S(e.store, n.subject, { id: r.id }), d.signal({ id: r.id }, r.signalName, r.payload);
596
- }, t, `action.${zt.name}`), C[Bt.name] = (t) => P(async (t, n) => {
595
+ return await we(e.store, n.subject, { id: r.id }), d.signal({ id: r.id }, r.signalName, r.payload);
596
+ }, t, `action.${Bt.name}`), E[Z.name] = (t) => F(async (t, n) => {
597
597
  let r = t;
598
- return await S(e.store, n.subject, { id: r.id }), d.update({ id: r.id }, r.updateName, r.payload, r.timeoutMs === void 0 ? void 0 : { timeoutMs: r.timeoutMs });
599
- }, t, `action.${Bt.name}`));
600
- let we = [
601
- ...e.discovered.queries.map((e) => q(e.descriptor)),
602
- ...e.discovered.mutations.map((e) => Nt(e.descriptor)),
603
- ...e.discovered.actions.map((e) => K(e.descriptor)),
604
- ...ue.queries.map((e) => q(e.descriptor)),
605
- ...ue.mutations.map((e) => Nt(e.descriptor)),
606
- ..._.queries.map((e) => q(e.descriptor)),
607
- ..._.mutations.map((e) => Nt(e.descriptor)),
608
- ..._.actions.map((e) => K(e.descriptor)),
609
- ...(e.discovered.streams ?? []).map((e) => Pt(e.descriptor)),
610
- ...(e.discovered.workflows ?? []).map((e) => H(e.definition)),
611
- ...f ? [
612
- q(X),
613
- q(Rt),
614
- q(Z),
615
- q(Y),
616
- q(It),
617
- q(J),
618
- K(Ft),
619
- K(Lt),
598
+ return await we(e.store, n.subject, { id: r.id }), d.update({ id: r.id }, r.updateName, r.payload, r.timeoutMs === void 0 ? void 0 : { timeoutMs: r.timeoutMs });
599
+ }, t, `action.${Z.name}`));
600
+ let Te = [
601
+ ...e.discovered.queries.map((e) => K(e.descriptor)),
602
+ ...e.discovered.mutations.map((e) => Pt(e.descriptor)),
603
+ ...e.discovered.actions.map((e) => G(e.descriptor)),
604
+ ...b.queries.map((e) => K(e.descriptor)),
605
+ ...b.mutations.map((e) => Pt(e.descriptor)),
606
+ ..._.queries.map((e) => K(e.descriptor)),
607
+ ..._.mutations.map((e) => Pt(e.descriptor)),
608
+ ..._.actions.map((e) => G(e.descriptor)),
609
+ ...(e.discovered.streams ?? []).map((e) => Ft(e.descriptor)),
610
+ ...(e.discovered.workflows ?? []).map((e) => V(e.definition)),
611
+ ...te ? [
612
+ K(Y),
620
613
  K(zt),
621
- K(Bt)
614
+ K(X),
615
+ K(J),
616
+ K(Lt),
617
+ K(q),
618
+ G(It),
619
+ G(Rt),
620
+ G(Bt),
621
+ G(Z)
622
622
  ] : []
623
- ], Ee = St.make(...we).middleware(At).middleware(jt), Oe = j.succeed(At, At.of(({ headers: t, clientId: n }) => A.promise(() => e.resolveSubject(t, n)))), D = j.succeed(jt, jt.of(({ clientId: e }) => A.succeed({ clientId: e }))), Ae = e.dormancyTenantId ?? "default", je = e.dormancy === "sleep" ? {
623
+ ], Ee = Ct.make(...Te).middleware(jt).middleware(Mt), Oe = M.succeed(jt, jt.of(({ headers: t, clientId: n }) => j.promise(() => e.resolveSubject(t, n)))), O = M.succeed(Mt, Mt.of(({ clientId: e }) => j.succeed({ clientId: e }))), ke = e.dormancyTenantId ?? "default", Ae = e.dormancy === "sleep" ? {
624
624
  register: (t, n, r) => B(e.store, {
625
- tenantId: r ?? Ae,
625
+ tenantId: r ?? ke,
626
626
  kind: "workflow",
627
627
  refId: t,
628
628
  wakeAt: n
629
629
  }),
630
- cancel: (t, n) => We(e.store, {
631
- tenantId: n ?? Ae,
630
+ cancel: (t, n) => Ue(e.store, {
631
+ tenantId: n ?? ke,
632
632
  kind: "workflow",
633
633
  refId: t
634
634
  }).then(() => {})
635
- } : void 0, O = te ? await import("@voltro/workflow") : void 0, k = O?.makeWorkflowRunRecorder({
635
+ } : void 0, k = ne ? await import("@voltro/workflow") : void 0, A = k?.makeWorkflowRunRecorder({
636
636
  store: e.store,
637
- ...je === void 0 ? {} : { wakeups: je }
638
- }), Me = async (t, n) => {
639
- await O.closeWorkflowChildrenForParent({
637
+ ...Ae === void 0 ? {} : { wakeups: Ae }
638
+ }), je = async (t, n) => {
639
+ await k.closeWorkflowChildrenForParent({
640
640
  store: e.store,
641
641
  parentExecutionId: t,
642
642
  parentStatus: n,
643
- recorder: k,
643
+ recorder: A,
644
644
  log: { warn: (e, t) => {
645
645
  process.stderr.write(`[workflow] ${e} ${t ? JSON.stringify(t) : ""}\n`);
646
646
  } },
@@ -651,11 +651,11 @@ var ln = "VoltroBootRefusal", un = (e) => {
651
651
  await a.runPromise(r.definition.interrupt(n));
652
652
  }
653
653
  });
654
- }, Ne = async (t, n, r) => {
654
+ }, Me = async (t, n, r) => {
655
655
  let i = (await e.store.query({
656
656
  table: "_voltro_workflow_runs",
657
657
  order: [],
658
- predicate: U("executionId", n),
658
+ predicate: H("executionId", n),
659
659
  projection: void 0,
660
660
  skip: void 0,
661
661
  take: 1
@@ -666,7 +666,7 @@ var ln = "VoltroBootRefusal", un = (e) => {
666
666
  cancelled: !0,
667
667
  completedAt: /* @__PURE__ */ new Date()
668
668
  }), o = i.subject?.tenantId ?? void 0;
669
- a && await k.recordEvent({
669
+ a && await A.recordEvent({
670
670
  runId: i.id,
671
671
  eventType: "run-cancelled",
672
672
  payload: {
@@ -675,16 +675,16 @@ var ln = "VoltroBootRefusal", un = (e) => {
675
675
  executionId: n,
676
676
  ...o == null ? {} : { tenantId: o }
677
677
  }
678
- }), a && await Me(n, "cancelled");
679
- }, Fe = [...ft(e.discovered.workflows ?? [], {
680
- buildContext: (t, n) => e.buildContextForWorkflow?.(t, n) ?? v({
678
+ }), a && await je(n, "cancelled");
679
+ }, Pe = [...ft(e.discovered.workflows ?? [], {
680
+ buildContext: (t, n) => e.buildContextForWorkflow?.(t, n) ?? y({
681
681
  subject: t.subject,
682
682
  traceId: t.traceId
683
683
  }, e.store, void 0, `workflow:${n.workflowName}`, { parentExecutionId: n.executionId }),
684
684
  resolveStartContext: u
685
685
  }, (t, n, r) => {
686
- let i = O.getWorkflowVersionMetadata(t.definition);
687
- return O.wrapWorkflowExecuteWithRunRecording({
686
+ let i = k.getWorkflowVersionMetadata(t.definition);
687
+ return k.wrapWorkflowExecuteWithRunRecording({
688
688
  name: t.definition.name,
689
689
  store: e.store,
690
690
  subject: r.subject,
@@ -695,70 +695,70 @@ var ln = "VoltroBootRefusal", un = (e) => {
695
695
  workflowPatches: i.patches,
696
696
  parentExecutionId: r?.parentExecutionId ?? null,
697
697
  parentClosePolicy: r?.parentClosePolicy ?? null,
698
- onParentClose: ({ executionId: e, status: t }) => Me(e, t),
699
- recorder: k
698
+ onParentClose: ({ executionId: e, status: t }) => je(e, t),
699
+ recorder: A
700
700
  }, n);
701
- }), ...e.discovered.workflowWorkers ?? []], Le = Fe.length > 0 ? j.mergeAll(...Fe) : j.empty;
701
+ }), ...e.discovered.workflowWorkers ?? []], Ie = Pe.length > 0 ? M.mergeAll(...Pe) : M.empty;
702
702
  if (((e.discovered.workflows?.length ?? 0) > 0 || (e.discovered.workflowWorkers?.length ?? 0) > 0 || e.scheduleCoordination === "cluster") && e.workflowEngineLayer !== void 0) {
703
- let t = Le.pipe(j.provideMerge(e.workflowEngineLayer));
704
- a = Pe.make(e.baseLayer === void 0 ? t : t.pipe(j.provideMerge(e.baseLayer))), await a.runPromise(A.void), i = (e.discovered.workflows?.length ?? 0) > 0 ? ut({
703
+ let t = Ie.pipe(M.provideMerge(e.workflowEngineLayer));
704
+ a = Ne.make(e.baseLayer === void 0 ? t : t.pipe(M.provideMerge(e.baseLayer))), await a.runPromise(j.void), i = (e.discovered.workflows?.length ?? 0) > 0 ? ut({
705
705
  workflows: e.discovered.workflows ?? [],
706
706
  runEffect: (e) => a.runPromise(e),
707
707
  rememberStartContext: l,
708
708
  signal: async (t, n, r) => {
709
- let i = await O.sendWorkflowSignal({
709
+ let i = await k.sendWorkflowSignal({
710
710
  store: e.store,
711
- recorder: k,
711
+ recorder: A,
712
712
  target: t,
713
713
  signalName: n,
714
714
  payload: r
715
715
  });
716
- return await a.runPromise(O.completeSuspendingSignal({
716
+ return await a.runPromise(k.completeSuspendingSignal({
717
717
  store: e.store,
718
718
  target: t,
719
719
  signalName: n,
720
720
  payload: r
721
721
  })).catch(() => {}), i;
722
722
  },
723
- update: (t, n, r, i) => O.sendWorkflowUpdate({
723
+ update: (t, n, r, i) => k.sendWorkflowUpdate({
724
724
  store: e.store,
725
- recorder: k,
725
+ recorder: A,
726
726
  target: t,
727
727
  updateName: n,
728
728
  payload: r,
729
729
  ...i === void 0 ? {} : { options: i }
730
730
  }),
731
731
  listRuns: (t) => w(e.store, t),
732
- retry: (t, n) => ge({
732
+ retry: (t, n) => x({
733
733
  store: e.store,
734
734
  workflows: e.discovered.workflows ?? [],
735
735
  runPromise: (e) => a.runPromise(e)
736
736
  }, t, n)
737
737
  }) : void 0;
738
738
  }
739
- let Be = j.mergeAll(Ee.toLayer(C), Oe, D), Ge = b(C, e.discovered.queries.map((e) => e.descriptor.name), f), Ke = j.mergeAll(Ee.toLayer(Ge), Oe, D), I = e.observability, qe = await Ue({
740
- ...I && I.spanProcessors.length > 0 ? { extraSpanProcessors: I.spanProcessors } : {},
741
- ...I && I.metricReaders.length > 0 ? { extraMetricReaders: I.metricReaders } : {},
742
- ...I && Object.keys(I.resourceAttributes).length > 0 ? { resourceAttributes: I.resourceAttributes } : {},
743
- ...I && I.sampler !== void 0 ? { sampler: I.sampler } : {}
744
- }), Je = !1, Qe = e.store.ping ? () => e.store.ping().then(() => !0).catch(() => !1) : void 0, { server: $e, shutdown: et } = yt({
739
+ let ze = M.mergeAll(Ee.toLayer(E), Oe, O), We = v(E, e.discovered.queries.map((e) => e.descriptor.name), te), Ge = M.mergeAll(Ee.toLayer(We), Oe, O), L = e.observability, Ke = await He({
740
+ ...L && L.spanProcessors.length > 0 ? { extraSpanProcessors: L.spanProcessors } : {},
741
+ ...L && L.metricReaders.length > 0 ? { extraMetricReaders: L.metricReaders } : {},
742
+ ...L && Object.keys(L.resourceAttributes).length > 0 ? { resourceAttributes: L.resourceAttributes } : {},
743
+ ...L && L.sampler !== void 0 ? { sampler: L.sampler } : {}
744
+ }), qe = !1, Ze = e.store.ping ? () => e.store.ping().then(() => !0).catch(() => !1) : void 0, { server: Qe, shutdown: $e } = bt({
745
745
  group: Ee,
746
- handlersLayer: Be,
747
- httpHandlersLayer: Ke,
746
+ handlersLayer: ze,
747
+ httpHandlersLayer: Ge,
748
748
  port: e.port ?? 4e3,
749
749
  path: e.path ?? "/ws",
750
- tracerLayer: qe.layer,
750
+ tracerLayer: Ke.layer,
751
751
  healthCheck: {
752
- isReady: () => Je,
753
- ...Qe ? { ping: Qe } : {}
752
+ isReady: () => qe,
753
+ ...Ze ? { ping: Ze } : {}
754
754
  },
755
755
  ...Ce.length > 0 ? { httpRoutes: Ce } : {},
756
756
  ...e.getStore === void 0 ? {} : { getStore: e.getStore },
757
- ...ie.size > 0 ? { webhookRoutes: ie } : {}
757
+ ...oe.size > 0 ? { webhookRoutes: oe } : {}
758
758
  });
759
- if (await Ve($e), (e.discovered.schedules?.length ?? 0) > 0) {
760
- let t = (e.scheduleCoordination ?? "single") === "advisoryLock" ? Ze(e.store, e.scheduleReplicaId ?? `pid-${process.pid}`) : vt;
761
- o = await bt(e.discovered.schedules ?? [], {
759
+ if (await Be(Qe), (e.discovered.schedules?.length ?? 0) > 0) {
760
+ let t = (e.scheduleCoordination ?? "single") === "advisoryLock" ? Xe(e.store, e.scheduleReplicaId ?? `pid-${process.pid}`) : yt;
761
+ o = await xt(e.discovered.schedules ?? [], {
762
762
  store: e.store,
763
763
  coordinator: t,
764
764
  defaultTrigger: e.scheduleDefaultTrigger ?? "self",
@@ -766,7 +766,7 @@ var ln = "VoltroBootRefusal", un = (e) => {
766
766
  armSelf: e.scheduleArmSelf ?? !0,
767
767
  dormancy: e.dormancy ?? "always-on",
768
768
  ...e.dormancyTenantId === void 0 ? {} : { dormancyTenantId: e.dormancyTenantId },
769
- buildContext: ({ traceId: t, scheduleName: n, subject: r }) => v({
769
+ buildContext: ({ traceId: t, scheduleName: n, subject: r }) => y({
770
770
  subject: r,
771
771
  traceId: t
772
772
  }, e.store, void 0, `schedule:${n}`),
@@ -786,10 +786,10 @@ var ln = "VoltroBootRefusal", un = (e) => {
786
786
  ...e.onScheduleRunEvent === void 0 ? {} : { onRunEvent: e.onScheduleRunEvent }
787
787
  }), e.onSchedulerReady?.(o);
788
788
  }
789
- let tt = e.log ?? M({ scope: "voltro:serve" }), nt, lt;
790
- if ((e.discovered.subscribers?.length ?? 0) > 0 && (nt = E(e.discovered.subscribers ?? [], e.store, tt.child("subscribe"), e.schemaRegistry)), (e.discovered.reactions?.length ?? 0) > 0) {
791
- let t = tt.child("reaction");
792
- lt = T(e.discovered.reactions ?? [], e.store, {
789
+ let et = e.log ?? N({ scope: "voltro:serve" }), tt, lt;
790
+ if ((e.discovered.subscribers?.length ?? 0) > 0 && (tt = f(e.discovered.subscribers ?? [], e.store, et.child("subscribe"), e.schemaRegistry)), (e.discovered.reactions?.length ?? 0) > 0) {
791
+ let t = et.child("reaction");
792
+ lt = ee(e.discovered.reactions ?? [], e.store, {
793
793
  runAct: async (n, r) => {
794
794
  if (n.kind === "workflow") {
795
795
  if (d === void 0) {
@@ -803,10 +803,10 @@ var ln = "VoltroBootRefusal", un = (e) => {
803
803
  }).start(n.workflow, e);
804
804
  return;
805
805
  }
806
- await ee(n.agent, r, {
806
+ await T(n.agent, r, {
807
807
  findAgentSend: (t) => e.discovered.actions.find((e) => e.descriptor.name === `${t}.send`),
808
- runAction: (e, t, n) => Promise.resolve(de(e, t, n)),
809
- makeSubject: (e) => Mt(e),
808
+ runAction: (e, t, n) => Promise.resolve(S(e, t, n)),
809
+ makeSubject: (e) => Nt(e),
810
810
  now: () => Date.now(),
811
811
  log: t
812
812
  });
@@ -814,7 +814,7 @@ var ln = "VoltroBootRefusal", un = (e) => {
814
814
  checkBudget: async (n, r) => {
815
815
  try {
816
816
  let { requireAiBudget: t } = await import("@voltro/ai");
817
- return (await A.runPromise(A.either(t(e.store, {
817
+ return (await j.runPromise(j.either(t(e.store, {
818
818
  tenantId: n,
819
819
  limitUsd: r
820
820
  }))))._tag === "Right";
@@ -825,27 +825,27 @@ var ln = "VoltroBootRefusal", un = (e) => {
825
825
  }, t);
826
826
  }
827
827
  let mt;
828
- return (e.discovered.aggregates?.length ?? 0) > 0 && (mt = await De({
828
+ return (e.discovered.aggregates?.length ?? 0) > 0 && (mt = await le({
829
829
  discovered: e.discovered.aggregates ?? [],
830
830
  store: e.store,
831
- log: tt.child("aggregate"),
831
+ log: et.child("aggregate"),
832
832
  ...e.analytics === void 0 ? {} : { analytics: e.analytics },
833
833
  ...e.aggregateStorage === void 0 ? {} : { storage: e.aggregateStorage },
834
834
  ...e.aggregateCoordinator === void 0 ? {} : { coordinator: e.aggregateCoordinator }
835
- }), oe = j.succeed(N, mt.registry)), Je = !0, e.bootTiming?.mark("ready"), {
835
+ }), ce = M.succeed(P, mt.registry)), qe = !0, e.bootTiming?.mark("ready"), {
836
836
  dispatcher: t,
837
- server: $e,
837
+ server: Qe,
838
838
  scheduler: o,
839
839
  close: async () => {
840
- Je = !1, mt?.detach(), lt?.(), nt?.(), await o?.shutdown(), t.close(), await a?.dispose(), await new Promise((e) => $e.close(() => e())), await et();
840
+ qe = !1, mt?.detach(), lt?.(), tt?.(), await o?.shutdown(), t.close(), await a?.dispose(), await new Promise((e) => Qe.close(() => e())), await $e();
841
841
  }
842
842
  };
843
- }, $ = M({ scope: "voltro:serve" }), On = (e, t, n) => (e === "production" || e === "staging") && t !== "memory" && n !== "0", kn = O, An = async (e) => {
844
- let t = D(process.cwd());
845
- if (Fe(t)) {
843
+ }, $ = N({ scope: "voltro:serve" }), On = (e, t, n) => (e === "production" || e === "staging") && t !== "memory" && n !== "0", kn = k, An = async (e) => {
844
+ let t = O(process.cwd());
845
+ if (Pe(t)) {
846
846
  let n;
847
847
  try {
848
- let e = await import(Me(t).href);
848
+ let e = await import(je(t).href);
849
849
  typeof e.runServe == "function" ? n = e.runServe : $.warn("serve bundle has no runServe export — using the standard serve path");
850
850
  } catch (e) {
851
851
  $.warn("serve bundle failed to load — using the standard serve path", {}, e);
@@ -854,67 +854,67 @@ var ln = "VoltroBootRefusal", un = (e) => {
854
854
  }
855
855
  return jn(e);
856
856
  }, jn = async (ee) => {
857
- let m = je();
857
+ let f = Ae();
858
858
  process.env.NODE_ENV || (process.env.NODE_ENV = "production");
859
859
  try {
860
860
  Vt();
861
861
  } catch (e) {
862
862
  throw un(e instanceof Error ? e.message : String(e));
863
863
  }
864
- let g = process.cwd(), ce = Number(process.env.PORT ?? kn(ee, "--port") ?? 4e3), y = await we(g);
865
- ht(mt(y?.secrets)), await e({
866
- rawEnv: y?.env,
864
+ let p = process.cwd(), ie = Number(process.env.PORT ?? kn(ee, "--port") ?? 4e3), h = await Ce(p);
865
+ gt(mt(h?.secrets)), await e({
866
+ rawEnv: h?.env,
867
867
  appType: "api",
868
- root: g,
868
+ root: p,
869
869
  log: $,
870
870
  generateTypes: !1
871
- }), m.mark("config");
872
- let b = (process.env.DB_DIALECT ?? y?.store ?? "memory").toLowerCase(), me = (b === "mariadb" || b === "postgres" || b === "mssql") && (process.env.CDC ?? "1") !== "0", S = b === "mariadb" ? "mariadb" : b === "mssql" ? "mssql" : void 0, ge = Ae(g);
873
- if (!i() && Fe(ge)) try {
874
- let e = await import(Me(ge).href);
871
+ }), f.mark("config");
872
+ let v = (process.env.DB_DIALECT ?? h?.store ?? "memory").toLowerCase(), le = (v === "mariadb" || v === "postgres" || v === "mssql") && (process.env.CDC ?? "1") !== "0", x = v === "mariadb" ? "mariadb" : v === "mssql" ? "mssql" : void 0, pe = ke(p);
873
+ if (!i() && Pe(pe)) try {
874
+ let e = await import(je(pe).href);
875
875
  if (e.modules) {
876
876
  let t = {};
877
- for (let [n, r] of Object.entries(e.modules)) t[k(g, n)] = r;
877
+ for (let [n, r] of Object.entries(e.modules)) t[A(p, n)] = r;
878
878
  r(t), $.info("precompiled api bundle loaded", { modules: Object.keys(t).length });
879
879
  }
880
880
  } catch (e) {
881
881
  $.warn("precompiled api bundle failed to load — falling back to source", {}, e);
882
882
  }
883
- let w = await C(g), T = await he(w, { cdc: me && S !== void 0 });
883
+ let w = await be(p), T = await E(w, { cdc: le && x !== void 0 });
884
884
  {
885
- let e = oe(T.serverOnlyLeaks, _(process.env, "strict"), qe, "`voltro serve`");
885
+ let e = re(T.serverOnlyLeaks, _(process.env, "strict"), Ke, "`voltro serve`");
886
886
  if (e.action === "fail") throw un(e.message ?? "");
887
887
  e.action === "warn" && $.warn(e.message ?? "");
888
888
  }
889
- let be = w.filter((e) => le.test(e)), Te = be.length > 0 ? await te(be, $.child("webhooks")) : void 0, De = s({
889
+ let ve = w.filter((e) => te.test(e)), Se = ve.length > 0 ? await Ee(ve, $.child("webhooks")) : void 0, we = s({
890
890
  mix: T.featureMix,
891
- plugins: y?.plugins ?? [],
892
- cdc: me && S !== void 0,
893
- ...S ? { cdcDialect: S } : {}
894
- }), ke = y?.analytics !== void 0 && y.analytics.kind !== "noop" && b !== "memory" ? (await n(b)).makeSqlLayer(x()) : void 0, E = await ue({
895
- spec: y?.analytics,
896
- sqlLayer: ke,
891
+ plugins: h?.plugins ?? [],
892
+ cdc: le && x !== void 0,
893
+ ...x ? { cdcDialect: x } : {}
894
+ }), De = h?.analytics !== void 0 && h.analytics.kind !== "noop" && v !== "memory" ? (await n(v)).makeSqlLayer(S()) : void 0, D = await b({
895
+ spec: h?.analytics,
896
+ sqlLayer: De,
897
897
  log: $
898
- }), D = (() => {
898
+ }), O = (() => {
899
899
  let e = new Set(T.tables.map((e) => e.tableName)), t = [...T.tables];
900
- for (let n of [...De, ...E.tables]) e.has(n.tableName) || (e.add(n.tableName), t.push(n));
900
+ for (let n of [...we, ...D.tables]) e.has(n.tableName) || (e.add(n.tableName), t.push(n));
901
901
  return t;
902
902
  })();
903
- for (let e of D) Tt(e);
904
- let O = (process.env.NODE_ENV ?? "").toLowerCase();
905
- if (On(O, b, process.env.VOLTRO_AUTO_MIGRATE)) {
906
- let e = (await n(b)).makeSqlLayer(x()), t = await A.runPromise(Ct.SqlClient.pipe(A.flatMap((e) => Kt(e, D, {
907
- appliedBy: `serve:${O}`,
903
+ for (let e of O) Et(e);
904
+ let k = (process.env.NODE_ENV ?? "").toLowerCase();
905
+ if (On(k, v, process.env.VOLTRO_AUTO_MIGRATE)) {
906
+ let e = (await n(v)).makeSqlLayer(S()), t = await j.runPromise(wt.SqlClient.pipe(j.flatMap((e) => Kt(e, O, {
907
+ appliedBy: `serve:${k}`,
908
908
  environment: "prod",
909
- dialectId: b
910
- })), A.provide(e)));
911
- t.kind === "prod-mismatch" && ($.error(Gt(t, b)), $.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(Gt(t, b));
909
+ dialectId: v
910
+ })), j.provide(e)));
911
+ t.kind === "prod-mismatch" && ($.error(Gt(t, v)), $.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(Gt(t, v));
912
912
  }
913
- let M = lt(D);
914
- m.mark("discover");
915
- let N = await Se(y, void 0), Ie = xt(N, b);
916
- for (let e of pe({
917
- dialect: String(y?.store ?? process.env.DB_DIALECT ?? "postgres"),
913
+ let N = lt(O);
914
+ f.mark("discover");
915
+ let P = await xe(h, void 0), Fe = St(P, v);
916
+ for (let e of ye({
917
+ dialect: String(h?.store ?? process.env.DB_DIALECT ?? "postgres"),
918
918
  changeStrategy: (process.env.CDC ?? "1") === "0" ? "inline" : "cdc",
919
919
  dbUrl: process.env.DB_URL,
920
920
  tables: T.tables.map((e) => ({
@@ -926,30 +926,30 @@ var ln = "VoltroBootRefusal", un = (e) => {
926
926
  return t === void 0 ? [] : typeof t == "string" ? [t] : [...t];
927
927
  })
928
928
  })) e.level === "warn" ? $.warn(e.message) : $.info(e.message);
929
- y?.cache && !process.env.CACHE_BACKEND && (process.env.CACHE_BACKEND = y.cache), y?.cacheRedisUrl && !process.env.CACHE_REDIS_URL && (process.env.CACHE_REDIS_URL = y.cacheRedisUrl), y?.cacheRedisDriver && !process.env.CACHE_REDIS_DRIVER && (process.env.CACHE_REDIS_DRIVER = y.cacheRedisDriver), y?.cacheKeyPrefix && !process.env.CACHE_KEY_PREFIX && (process.env.CACHE_KEY_PREFIX = y.cacheKeyPrefix);
930
- let { service: Re, invalidationBus: ze, snapshotCache: Ve, cache: P, backend: He, dispose: F } = await _e({ env: process.env });
931
- $.info(`cache backend resolved: ${He}` + (He === "redis" ? ` (driver ${process.env.CACHE_REDIS_DRIVER ?? "resp"})` : " — in-process, not cross-instance")), N.onChange((e) => {
932
- A.runFork(ze.publish(e.table));
933
- }), y?.kv && !process.env.KV_BACKEND && (process.env.KV_BACKEND = y.kv), y?.kvRedisUrl && !process.env.KV_REDIS_URL && (process.env.KV_REDIS_URL = y.kvRedisUrl), y?.kvKeyPrefix && !process.env.KV_KEY_PREFIX && (process.env.KV_KEY_PREFIX = y.kvKeyPrefix);
934
- let { kv: Ue, service: We } = await tt({ store: N });
935
- m.mark("store");
936
- let Ye = Be({
937
- store: N,
938
- sink: E.sink,
929
+ h?.cache && !process.env.CACHE_BACKEND && (process.env.CACHE_BACKEND = h.cache), h?.cacheRedisUrl && !process.env.CACHE_REDIS_URL && (process.env.CACHE_REDIS_URL = h.cacheRedisUrl), h?.cacheRedisDriver && !process.env.CACHE_REDIS_DRIVER && (process.env.CACHE_REDIS_DRIVER = h.cacheRedisDriver), h?.cacheKeyPrefix && !process.env.CACHE_KEY_PREFIX && (process.env.CACHE_KEY_PREFIX = h.cacheKeyPrefix);
930
+ let { service: Le, invalidationBus: Re, snapshotCache: Be, cache: F, backend: Ve, dispose: I } = await fe({ env: process.env });
931
+ $.info(`cache backend resolved: ${Ve}` + (Ve === "redis" ? ` (driver ${process.env.CACHE_REDIS_DRIVER ?? "resp"})` : " — in-process, not cross-instance")), P.onChange((e) => {
932
+ j.runFork(Re.publish(e.table));
933
+ }), h?.kv && !process.env.KV_BACKEND && (process.env.KV_BACKEND = h.kv), h?.kvRedisUrl && !process.env.KV_REDIS_URL && (process.env.KV_REDIS_URL = h.kvRedisUrl), h?.kvKeyPrefix && !process.env.KV_KEY_PREFIX && (process.env.KV_KEY_PREFIX = h.kvKeyPrefix);
934
+ let { kv: He, service: Ue } = await et({ store: P });
935
+ f.mark("store");
936
+ let Je = ze({
937
+ store: P,
938
+ sink: D.sink,
939
939
  log: $
940
- }), Xe = Ce({
941
- store: N,
942
- dialect: b
943
- }), L = y?.plugins ?? [], R = process.env.POD_NAME ?? process.env.HOSTNAME ?? `serve-${process.pid}`, rt, it;
944
- b !== "memory" && (rt = Pe.make((await n(b)).makeSqlLayer(x())), it = await rt.runPromise(Ct.SqlClient));
945
- let at = nt({
940
+ }), Ye = me({
941
+ store: P,
942
+ dialect: v
943
+ }), R = h?.plugins ?? [], nt = process.env.POD_NAME ?? process.env.HOSTNAME ?? `serve-${process.pid}`, rt, it;
944
+ v !== "memory" && (rt = Ne.make((await n(v)).makeSqlLayer(S())), it = await rt.runPromise(wt.SqlClient));
945
+ let at = tt({
946
946
  coordinator: [
947
947
  "postgres",
948
948
  "mariadb",
949
949
  "mysql",
950
950
  "mssql"
951
- ].includes(b) ? Ze(N, R, $) : vt,
952
- replicaId: R,
951
+ ].includes(v) ? Xe(P, nt, $) : yt,
952
+ replicaId: nt,
953
953
  log: $
954
954
  }), ot = [], st = {
955
955
  ...it ? { sql: it } : {},
@@ -958,75 +958,75 @@ var ln = "VoltroBootRefusal", un = (e) => {
958
958
  return ot.push(r), r;
959
959
  }
960
960
  };
961
- for (let e of L) e.bindDataStore?.(N, st);
962
- let ct = L.filter((e) => typeof e.onChangeEvent == "function");
961
+ for (let e of R) e.bindDataStore?.(P, st);
962
+ let ct = R.filter((e) => typeof e.onChangeEvent == "function");
963
963
  if (ct.length > 0) {
964
- let e = N.changeScope ?? "local";
965
- N.onChange((t) => {
966
- let n = ae(t, e);
967
- for (let e of ct) A.runFork(e.onChangeEvent(n).pipe(A.catchAllCause((t) => A.sync(() => $.warn(`plugin ${e.name} onChangeEvent failed`, { error: Ne.pretty(t) })))));
964
+ let e = P.changeScope ?? "local";
965
+ P.onChange((t) => {
966
+ let n = oe(t, e);
967
+ for (let e of ct) j.runFork(e.onChangeEvent(n).pipe(j.catchAllCause((t) => j.sync(() => $.warn(`plugin ${e.name} onChangeEvent failed`, { error: Me.pretty(t) })))));
968
968
  });
969
969
  }
970
- let ut = Ee({
971
- plugins: L,
972
- appName: y?.name ?? "voltro-api",
970
+ let ut = Oe({
971
+ plugins: R,
972
+ appName: h?.name ?? "voltro-api",
973
973
  appType: "api",
974
974
  voltroVersion: process.env.npm_package_version ?? "0.0.0",
975
975
  log: $
976
976
  });
977
- L.length && await ut.activate(), m.mark("plugins");
978
- let dt = await ut.gatherObservability(), ft = await xe(N, y, b, {
977
+ R.length && await ut.activate(), f.mark("plugins");
978
+ let dt = await ut.gatherObservability(), ft = await ge(P, h, v, {
979
979
  info: (e, t) => process.stdout.write(`[broadcast] ${e} ${t ? JSON.stringify(t) : ""}\n`),
980
980
  warn: (e, t) => process.stderr.write(`[broadcast] ${e} ${t ? JSON.stringify(t) : ""}\n`),
981
981
  debug: () => {}
982
- }), z = y?.apiKeys, pt = (typeof z == "object" ? z.prefix : void 0) ?? "voltro_", B = z ? Ke(N) : void 0, V = B ? $e({ flush: et(B) }) : void 0;
983
- V && process.once("exit", () => {
984
- V.shutdown();
982
+ }), z = h?.apiKeys, pt = (typeof z == "object" ? z.prefix : void 0) ?? "voltro_", B = z ? Ge(P) : void 0, ht = B ? Qe({ flush: $e(B) }) : void 0;
983
+ ht && process.once("exit", () => {
984
+ ht.shutdown();
985
985
  });
986
- let gt = B ? Qe(B, {
986
+ let _t = B ? Ze(B, {
987
987
  prefix: pt,
988
- ...V ? { usage: V } : {}
989
- }) : void 0, _t = gt ? [Je(gt, { prefix: pt })] : [], yt = ye([...y?.auth?.strategies ?? [], ..._t], qt(y?.plugins ?? []), y?.auth?.anonymousTenantRequired ?? !1, y?.auth?.resolveScopes, () => Ie), bt = [...y?.restRoutes ?? [], ...gt ? Le(gt, (typeof z == "object" ? z.managementPath : void 0) ?? "/v1/api-keys") : []], H = y?.idempotency, St = H ? {
990
- store: I(N),
991
- header: (typeof H == "object" ? H.header : void 0) ?? "Idempotency-Key",
992
- ttlMs: (typeof H == "object" ? H.ttlMs : void 0) ?? 864e5
993
- } : void 0, wt = bt.length > 0 ? Yt(bt, {
994
- store: N,
995
- resolveSubject: (e) => yt({
988
+ ...ht ? { usage: ht } : {}
989
+ }) : void 0, vt = _t ? [qe(_t, { prefix: pt })] : [], bt = _e([...h?.auth?.strategies ?? [], ...vt], qt(h?.plugins ?? []), h?.auth?.anonymousTenantRequired ?? !1, h?.auth?.resolveScopes, () => Fe), xt = [...h?.restRoutes ?? [], ..._t ? Ie(_t, (typeof z == "object" ? z.managementPath : void 0) ?? "/v1/api-keys") : []], V = h?.idempotency, Ct = V ? {
990
+ store: L(P),
991
+ header: (typeof V == "object" ? V.header : void 0) ?? "Idempotency-Key",
992
+ ttlMs: (typeof V == "object" ? V.ttlMs : void 0) ?? 864e5
993
+ } : void 0, Tt = xt.length > 0 ? Yt(xt, {
994
+ store: P,
995
+ resolveSubject: (e) => bt({
996
996
  headers: e,
997
997
  clientId: -1
998
998
  }),
999
- ...St ? { idempotency: St } : {}
1000
- }) : [], U = L.map((e) => e.services).filter((e) => e !== void 0), Et = j.mergeAll(d({
1001
- analyticsLayer: E.layer,
1002
- cacheService: Re,
1003
- kvService: We,
1004
- pluginServices: U,
1005
- userLayers: y?.layers ?? []
1006
- }), se(y?.http ?? {})), W = y?.scheduling ?? {}, Dt = W.trigger ?? "self", Ot = /* @__PURE__ */ new Set([
999
+ ...Ct ? { idempotency: Ct } : {}
1000
+ }) : [], H = R.map((e) => e.services).filter((e) => e !== void 0), Dt = M.mergeAll(C({
1001
+ analyticsLayer: D.layer,
1002
+ cacheService: Le,
1003
+ kvService: Ue,
1004
+ pluginServices: H,
1005
+ userLayers: h?.layers ?? []
1006
+ }), d(h?.http ?? {})), U = h?.scheduling ?? {}, Ot = U.trigger ?? "self", kt = /* @__PURE__ */ new Set([
1007
1007
  "postgres",
1008
1008
  "mysql",
1009
1009
  "mariadb",
1010
1010
  "mssql"
1011
- ]), kt = W.coordination ?? (Ot.has(b) ? "advisoryLock" : "single"), G = kt === "cluster" && Ot.has(b), At = G ? "cluster" : kt === "advisoryLock" && Ot.has(b) ? "advisoryLock" : "single";
1012
- kt === "cluster" && !G && $.warn("scheduling.coordination=cluster needs a sql-backed store except sqlite — falling back to single"), kt === "advisoryLock" && !Ot.has(b) && $.warn("scheduling.coordination=advisoryLock needs a SQL store (the claim-row gate) — falling back to single");
1013
- let jt, K = T.workflows.length > 0 || T.workflowWorkers.length > 0 || T.eventTriggers.length > 0 || (Te?.outgoing.length ?? 0) > 0 || G, Mt;
1014
- if (K) {
1015
- if (b === "mssql") {
1016
- let e = await h(process.cwd());
1011
+ ]), At = U.coordination ?? (kt.has(v) ? "advisoryLock" : "single"), W = At === "cluster" && kt.has(v), jt = W ? "cluster" : At === "advisoryLock" && kt.has(v) ? "advisoryLock" : "single";
1012
+ At === "cluster" && !W && $.warn("scheduling.coordination=cluster needs a sql-backed store except sqlite — falling back to single"), At === "advisoryLock" && !kt.has(v) && $.warn("scheduling.coordination=advisoryLock needs a SQL store (the claim-row gate) — falling back to single");
1013
+ let Mt, G = T.workflows.length > 0 || T.workflowWorkers.length > 0 || T.eventTriggers.length > 0 || (Se?.outgoing.length ?? 0) > 0 || W, Nt;
1014
+ if (G) {
1015
+ if (v === "mssql") {
1016
+ let e = await ue(process.cwd());
1017
1017
  e && $.warn(e);
1018
1018
  }
1019
- let [{ WorkflowEngine: e }, { makeClusterCronLayer: t, workflowEngineLayer: r, resolveRunnerStorage: i }] = await Promise.all([import("@effect/workflow"), import("@voltro/workflow/cluster")]), a = G ? T.schedules.filter((e) => (e.trigger ?? Dt) === "self").map((e) => t({
1019
+ let [{ WorkflowEngine: e }, { makeClusterCronLayer: t, workflowEngineLayer: r, resolveRunnerStorage: i }] = await Promise.all([import("@effect/workflow"), import("@voltro/workflow/cluster")]), a = W ? T.schedules.filter((e) => (e.trigger ?? Ot) === "self").map((e) => t({
1020
1020
  name: e.name,
1021
- cron: Ge(e),
1021
+ cron: We(e),
1022
1022
  execute: async () => {
1023
- await jt?.fireFromCluster(e.name);
1023
+ await Mt?.fireFromCluster(e.name);
1024
1024
  }
1025
1025
  })) : [];
1026
- Mt = b === "memory" ? e.layerMemory : await (async () => {
1027
- let e = await n(b), t = i({ sqliteFamily: e.id === "sqlite" || e.id === "turso" });
1026
+ Nt = v === "memory" ? e.layerMemory : await (async () => {
1027
+ let e = await n(v), t = i({ sqliteFamily: e.id === "sqlite" || e.id === "turso" });
1028
1028
  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)" : "") : "")), r({
1029
- sqlClientLayer: e.makeSqlLayer(x()),
1029
+ sqlClientLayer: e.makeSqlLayer(S()),
1030
1030
  runnerStorage: t,
1031
1031
  dialectId: e.id,
1032
1032
  ...process.env.VOLTRO_WORKFLOW_RUNNER_PORT ? { runnerListenPort: Number(process.env.VOLTRO_WORKFLOW_RUNNER_PORT) } : {},
@@ -1034,87 +1034,87 @@ var ln = "VoltroBootRefusal", un = (e) => {
1034
1034
  });
1035
1035
  })();
1036
1036
  }
1037
- let Nt = fe(L, t()), q = w.filter((e) => /\.subscribe\.tsx?$/.test(e)), Pt = q.length > 0 ? await f(q, $) : [], Ft = w.filter((e) => /\.reaction\.tsx?$/.test(e)), It = Ft.length > 0 ? await ve(Ft, $) : [], J = w.filter((e) => u.test(e)), Lt = J.length > 0 ? await ie(J, $) : [], Y = w.filter((e) => /\.aggregate\.tsx?$/.test(e)), X = Y.length > 0 ? await p(Y, $) : [], Z = ne();
1038
- if (X.length > 0 && b !== "memory") try {
1039
- Z = v((await n(b)).makeSqlLayer(x()));
1037
+ let Pt = Te(R, t()), K = w.filter((e) => /\.subscribe\.tsx?$/.test(e)), Ft = K.length > 0 ? await de(K, $) : [], It = w.filter((e) => /\.reaction\.tsx?$/.test(e)), Lt = It.length > 0 ? await g(It, $) : [], q = w.filter((e) => u.test(e)), Rt = q.length > 0 ? await y(q, $) : [], J = w.filter((e) => /\.aggregate\.tsx?$/.test(e)), Y = J.length > 0 ? await ne(J, $) : [], X = se();
1038
+ if (Y.length > 0 && v !== "memory") try {
1039
+ X = he((await n(v)).makeSqlLayer(S()));
1040
1040
  } catch (e) {
1041
1041
  $.warn("aggregate: SQL storage init failed — falling back to in-process", { err: String(e) });
1042
1042
  }
1043
- let Rt = b === "memory" ? vt : Ze(N, `aggregate@${process.pid}`, $), zt = [], Bt = [], Ht = w.filter((e) => l.test(e));
1043
+ let zt = v === "memory" ? yt : Xe(P, `aggregate@${process.pid}`, $), Bt = [], Z = [], Ht = w.filter((e) => l.test(e));
1044
1044
  if (Ht.length > 0) {
1045
1045
  let e = $.child("agent"), t = w.filter((e) => a.test(e));
1046
1046
  t.length > 0 && await o(t, e);
1047
1047
  let n = await c(Ht, e);
1048
- for (let e of n.agents) for (let t of Oe(e)) (t.kind === "action" ? zt : Bt).push({
1048
+ for (let e of n.agents) for (let t of ce(e)) (t.kind === "action" ? Bt : Z).push({
1049
1049
  file: t.file,
1050
1050
  descriptor: t.descriptor,
1051
1051
  executor: t.executor
1052
1052
  });
1053
1053
  n.agents.length > 0 && e.info("synthesized agent routes", { agents: n.agents.map((e) => e.descriptor.name) });
1054
1054
  }
1055
- m.mark("workflow");
1055
+ f.mark("workflow");
1056
1056
  let Ut = await Dn({
1057
- bootTiming: m,
1057
+ bootTiming: f,
1058
1058
  discovered: {
1059
- queries: [...T.queries, ...Bt],
1059
+ queries: [...T.queries, ...Z],
1060
1060
  mutations: T.mutations,
1061
- actions: [...T.actions, ...zt],
1061
+ actions: [...T.actions, ...Bt],
1062
1062
  streams: T.streams,
1063
1063
  workflows: T.workflows,
1064
1064
  workflowWorkers: T.workflowWorkers,
1065
1065
  eventTriggers: T.eventTriggers,
1066
1066
  schedules: T.schedules,
1067
- subscribers: Pt,
1068
- outboxHandlers: Lt,
1067
+ subscribers: Ft,
1068
+ outboxHandlers: Rt,
1069
1069
  connections: T.connections,
1070
- reactions: It,
1071
- aggregates: X,
1072
- ...Te === void 0 ? {} : { webhooks: Te }
1070
+ reactions: Lt,
1071
+ aggregates: Y,
1072
+ ...Se === void 0 ? {} : { webhooks: Se }
1073
1073
  },
1074
1074
  log: $,
1075
- analytics: E.sink,
1076
- aggregateStorage: Z,
1077
- aggregateCoordinator: Rt,
1078
- store: N,
1079
- kv: Ue,
1080
- cache: P,
1081
- snapshotCache: Ve,
1082
- schemaRegistry: M,
1075
+ analytics: D.sink,
1076
+ aggregateStorage: X,
1077
+ aggregateCoordinator: zt,
1078
+ store: P,
1079
+ kv: He,
1080
+ cache: F,
1081
+ snapshotCache: Be,
1082
+ schemaRegistry: N,
1083
1083
  tenantScopedTables: T.tenantScopedTables,
1084
1084
  softDeleteScopedTables: T.softDeleteScopedTables,
1085
- dataTransferSnapshot: Wt(D),
1086
- dataTransferDialect: b,
1087
- tenantIsolation: (process.env.VOLTRO_TENANT_ISOLATION ?? y?.tenancy?.isolation) === "namespace" ? "namespace" : "shared-schema",
1088
- resolveSubject: (e, t) => yt({
1085
+ dataTransferSnapshot: Wt(O),
1086
+ dataTransferDialect: v,
1087
+ tenantIsolation: (process.env.VOLTRO_TENANT_ISOLATION ?? h?.tenancy?.isolation) === "namespace" ? "namespace" : "shared-schema",
1088
+ resolveSubject: (e, t) => bt({
1089
1089
  headers: e,
1090
1090
  clientId: t
1091
1091
  }),
1092
- httpRoutes: [...L.flatMap((e) => e.httpRoutes ?? []), ...wt],
1093
- getStore: () => Ie,
1094
- ...Et ? { baseLayer: Et } : {},
1095
- ...Mt === void 0 ? {} : { workflowEngineLayer: Mt },
1096
- scheduleDefaultTrigger: Dt,
1097
- scheduleCoordination: At,
1098
- scheduleArmSelf: !G,
1099
- dormancy: process.env.VOLTRO_DORMANCY === "sleep" || process.env.VOLTRO_DORMANCY === "always-on" ? process.env.VOLTRO_DORMANCY : y?.dormancy ?? "always-on",
1092
+ httpRoutes: [...R.flatMap((e) => e.httpRoutes ?? []), ...Tt],
1093
+ getStore: () => Fe,
1094
+ ...Dt ? { baseLayer: Dt } : {},
1095
+ ...Nt === void 0 ? {} : { workflowEngineLayer: Nt },
1096
+ scheduleDefaultTrigger: Ot,
1097
+ scheduleCoordination: jt,
1098
+ scheduleArmSelf: !W,
1099
+ dormancy: process.env.VOLTRO_DORMANCY === "sleep" || process.env.VOLTRO_DORMANCY === "always-on" ? process.env.VOLTRO_DORMANCY : h?.dormancy ?? "always-on",
1100
1100
  scheduleReplicaId: process.env.HOSTNAME ?? `pid-${process.pid}`,
1101
- ...Nt === void 0 ? {} : { scheduleFireInterceptor: Nt },
1101
+ ...Pt === void 0 ? {} : { scheduleFireInterceptor: Pt },
1102
1102
  onSchedulerReady: (e) => {
1103
- jt = e;
1103
+ Mt = e;
1104
1104
  },
1105
1105
  observability: dt,
1106
- port: ce,
1107
- ...y?.transport?.wsPath ? { path: y.transport.wsPath } : {}
1106
+ port: ie,
1107
+ ...h?.transport?.wsPath ? { path: h.transport.wsPath } : {}
1108
1108
  });
1109
- re(de([
1109
+ ae(m([
1110
1110
  T.queries,
1111
1111
  T.mutations,
1112
1112
  T.actions,
1113
1113
  T.streams
1114
1114
  ]), (e) => {
1115
1115
  $.warn(e);
1116
- }), $.info(`API listening on :${ce}`, {
1117
- dialect: b,
1116
+ }), $.info(`API listening on :${ie}`, {
1117
+ dialect: v,
1118
1118
  queries: T.queries.length,
1119
1119
  mutations: T.mutations.length,
1120
1120
  actions: T.actions.length,
@@ -1122,11 +1122,11 @@ var ln = "VoltroBootRefusal", un = (e) => {
1122
1122
  workflows: T.workflows.length,
1123
1123
  workflowWorkers: T.workflowWorkers.length,
1124
1124
  schedules: T.schedules.length,
1125
- scheduleCoordination: At
1126
- }), m.finish($);
1125
+ scheduleCoordination: jt
1126
+ }), f.finish($);
1127
1127
  let Jt = () => {
1128
1128
  for (let e of ot) e.stop();
1129
- Ye.detach(), Xe.stop(), F(), rt?.dispose(), setTimeout(() => process.exit(0), 1e4).unref?.(), Promise.resolve(ut.deactivate()).then(() => ft?.close()).then(() => E.dispose()).then(() => Ut.close()).then(() => N.close?.()).then(() => process.exit(0)).catch((e) => {
1129
+ Je.detach(), Ye.stop(), I(), rt?.dispose(), setTimeout(() => process.exit(0), 1e4).unref?.(), Promise.resolve(ut.deactivate()).then(() => ft?.close()).then(() => D.dispose()).then(() => Ut.close()).then(() => P.close?.()).then(() => process.exit(0)).catch((e) => {
1130
1130
  console.error("serve: shutdown step failed, exiting anyway:", e), process.exit(0);
1131
1131
  });
1132
1132
  };