@voltro/cli 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/apiBuild-CmtI6Ygh.js +2 -0
  3. package/dist/{apiBuild-deIjJKJm.js → apiBuild-OrDkXGFX.js} +2 -2
  4. package/dist/bin.js +2 -2
  5. package/dist/{commands-BHdc71DG.js → commands-DT4PipBz.js} +666 -526
  6. package/dist/dev-Ca1jdwnt.js +2 -0
  7. package/dist/{dev-Bqyq62Ak.js → dev-Ga65K4jc.js} +469 -469
  8. package/dist/index.js +1 -1
  9. package/dist/{inspectMetrics-BLUBAWLb.js → inspectMetrics-EK0CcHyu.js} +977 -759
  10. package/dist/{serveCommand-Dn6--0Bv.js → serveCommand-CR5xnYZt.js} +5 -5
  11. package/dist/serveEntry.js +3 -3
  12. package/dist/{start-CWZW_4Et.js → start-DuyBQxW3.js} +332 -296
  13. package/dist/startEntry.js +2 -2
  14. package/package.json +17 -17
  15. package/templates/AGENTS.core.md +15 -4
  16. package/templates/AGENTS.md +15 -4
  17. package/templates/agent-docs/authentication.md +7 -4
  18. package/templates/agent-docs/cli.md +35 -4
  19. package/templates/agent-docs/data.md +94 -70
  20. package/templates/agent-docs/database/schema.md +1 -1
  21. package/templates/agent-docs/reference.md +20 -0
  22. package/templates/agent-docs/routing.md +158 -24
  23. package/templates/agent-docs/testing.md +24 -0
  24. package/templates/apps/api-ai/package.json +7 -7
  25. package/templates/apps/api-auth/package.json +8 -8
  26. package/templates/apps/api-backend/package.json +7 -7
  27. package/templates/apps/api-backend-deactivation/package.json +7 -7
  28. package/templates/apps/api-backend-mail/package.json +8 -8
  29. package/templates/apps/api-backend-mariadb/package.json +9 -9
  30. package/templates/apps/api-backend-storage/package.json +8 -8
  31. package/templates/apps/api-data-advanced/package.json +8 -8
  32. package/templates/apps/api-durable/package.json +8 -8
  33. package/templates/apps/api-feature-flags/package.json +9 -9
  34. package/templates/apps/api-governance/package.json +8 -8
  35. package/templates/apps/api-kv/package.json +8 -8
  36. package/templates/apps/api-moderation/package.json +8 -8
  37. package/templates/apps/api-observability/package.json +8 -8
  38. package/templates/apps/api-ratelimit/package.json +8 -8
  39. package/templates/apps/api-rbac/package.json +8 -8
  40. package/templates/apps/api-rest/package.json +7 -7
  41. package/templates/apps/api-saas/package.json +11 -11
  42. package/templates/apps/api-search/package.json +8 -8
  43. package/templates/apps/api-versioning/package.json +8 -8
  44. package/templates/apps/api-webhooks/package.json +8 -8
  45. package/templates/apps/changelog/package.json +6 -6
  46. package/templates/apps/edge-functions/package.json +2 -2
  47. package/templates/apps/frontend-admin/package.json +8 -8
  48. package/templates/apps/frontend-app/package.json +8 -8
  49. package/templates/apps/frontend-blank/package.json +7 -7
  50. package/templates/apps/frontend-contact/package.json +7 -7
  51. package/templates/apps/frontend-dashboard/package.json +7 -7
  52. package/templates/apps/frontend-docs/package.json +7 -7
  53. package/templates/apps/frontend-i18n/package.json +6 -6
  54. package/templates/apps/frontend-landing/package.json +7 -7
  55. package/templates/apps/frontend-spa/package.json +7 -7
  56. package/templates/apps/frontend-ssr/package.json +7 -7
  57. package/templates/apps/frontend-ssr-api/package.json +8 -8
  58. package/templates/apps/frontend-static-blog/package.json +6 -6
  59. package/dist/apiBuild-CSM74oEZ.js +0 -2
  60. package/dist/dev-BYfrYwrT.js +0 -2
@@ -4,19 +4,20 @@ import { FileSystem as c } from "@effect/platform";
4
4
  import { NodeContext as l, NodeRuntime as u } from "@effect/platform-node";
5
5
  import { Cause as d, Effect as f, Layer as p } from "effect";
6
6
  import { LoggerLayer as m, addSink as h, createLogger as g, printReadyBlock as _ } from "@voltro/logger";
7
- import { closeSync as v, existsSync as y, mkdirSync as b, openSync as x, promises as S, readFileSync as C, readdirSync as w, statSync as T, unlinkSync as E, unwatchFile as ee, watchFile as D, writeSync as te } from "node:fs";
8
- import { currentTraceContext as O, lastWriteProvenance as ne, recordSample as re, resolveSecret as k } from "@voltro/runtime";
9
- import { mkdir as A, writeFile as j } from "node:fs/promises";
10
- import { FRAMEWORK_ENV_CATALOG as M, appEnvEntries as N, checkEnvNaming as ie, formatEnvErrors as ae, installEnvSnapshot as oe, isEnvContract as se, pluginEnvEntries as ce, renderDotEnvExample as P, resolveEnv as le } from "@voltro/env";
7
+ import { closeSync as v, existsSync as y, mkdirSync as b, openSync as x, promises as S, readFileSync as C, readdirSync as w, statSync as T, unlinkSync as E, unwatchFile as ee, watchFile as D, writeSync as O } from "node:fs";
8
+ import { currentTraceContext as k, lastWriteProvenance as te, recordSample as ne, resolveSecret as A } from "@voltro/runtime";
9
+ import { mkdir as re, writeFile as j } from "node:fs/promises";
10
+ import { FRAMEWORK_ENV_CATALOG as M, appEnvEntries as ie, checkEnvNaming as ae, formatEnvErrors as N, installEnvSnapshot as oe, isEnvContract as se, pluginEnvEntries as ce, renderDotEnvExample as P, resolveEnv as le } from "@voltro/env";
11
11
  import { __installPublicEnv as ue } from "@voltro/env/public";
12
12
  import { createHash as de } from "node:crypto";
13
13
  import { spawn as fe } from "node:child_process";
14
14
  import { timingSafeStringEqual as pe } from "@voltro/protocol/session";
15
- import { homedir as F } from "node:os";
16
- import { createConnection as me } from "node:net";
17
- import { createRequire as he } from "node:module";
15
+ import { homedir as me } from "node:os";
16
+ import { createConnection as he } from "node:net";
17
+ import { createRequire as ge } from "node:module";
18
+ import { PassThrough as _e } from "node:stream";
18
19
  //#region src/cliRuntime.ts
19
- var ge = [
20
+ var ve = [
20
21
  "severity",
21
22
  "code",
22
23
  "detail",
@@ -33,14 +34,14 @@ var ge = [
33
34
  "file",
34
35
  "line",
35
36
  "routine"
36
- ], I = (e, t = 0, n = /* @__PURE__ */ new WeakSet()) => {
37
+ ], ye = (e, t = 0, n = /* @__PURE__ */ new WeakSet()) => {
37
38
  if (t > 10 || typeof e != "object" || !e || n.has(e)) return null;
38
39
  n.add(e);
39
40
  let r = e, i = r.message;
40
41
  if (typeof i == "string" && i.length > 0 && i !== "Failed to execute statement") {
41
42
  let e = { message: i };
42
43
  typeof r.stack == "string" && (e.stack = r.stack);
43
- for (let t of ge) r[t] !== void 0 && (e[t] = r[t]);
44
+ for (let t of ve) r[t] !== void 0 && (e[t] = r[t]);
44
45
  return e;
45
46
  }
46
47
  for (let e of [
@@ -53,20 +54,20 @@ var ge = [
53
54
  ]) {
54
55
  let i = r[e];
55
56
  if (i !== void 0) {
56
- let e = I(i, t + 1, n);
57
+ let e = ye(i, t + 1, n);
57
58
  if (e) return e;
58
59
  }
59
60
  }
60
61
  if (Array.isArray(r.failures)) for (let e of r.failures) {
61
- let r = I(e, t + 1, n);
62
+ let r = ye(e, t + 1, n);
62
63
  if (r) return r;
63
64
  }
64
65
  return null;
65
- }, _e = (e = {}) => p.merge(l.layer, m({
66
+ }, F = (e = {}) => p.merge(l.layer, m({
66
67
  ...e.scope ? { defaultScope: e.scope } : {},
67
68
  ...e.logger
68
- })), ve = async (e, t = {}) => {
69
- let n = e.pipe(f.provide(_e(t)));
69
+ })), be = async (e, t = {}) => {
70
+ let n = e.pipe(f.provide(F(t)));
70
71
  return await f.runPromise(f.matchCauseEffect(n, {
71
72
  onSuccess: (e) => f.succeed(e),
72
73
  onFailure: (e) => {
@@ -82,7 +83,7 @@ var ge = [
82
83
  }
83
84
  let n = null;
84
85
  for (let e of t) {
85
- let t = I(e);
86
+ let t = ye(e);
86
87
  if (t) {
87
88
  n = t;
88
89
  break;
@@ -102,39 +103,39 @@ var ge = [
102
103
  return f.zipRight(f.logError("cli command failed", r), f.succeed(1));
103
104
  }
104
105
  }).pipe(f.provide(m(t.logger ?? {}))));
105
- }, ye = (e, t = {}) => {
106
- let n = e.pipe(f.provide(_e(t)));
106
+ }, I = (e, t = {}) => {
107
+ let n = e.pipe(f.provide(F(t)));
107
108
  u.runMain(n, { disableErrorReporting: !1 });
108
- }, L = t(o(import.meta.url)), be = [a(L, "..", "templates"), a(L, "..", "..", "templates")], xe = (e) => ({
109
+ }, xe = t(o(import.meta.url)), L = [a(xe, "..", "templates"), a(xe, "..", "..", "templates")], Se = (e) => ({
109
110
  _tag: "TemplateNotFoundError",
110
111
  searched: e
111
- }), Se = ["AGENTS.md", "CLAUDE.md"], Ce = "voltro:agents-md:keep", we = 2048, Te = "<!-- VOLTRO:INDEX -->", R = (e, t) => e.exists(t).pipe(f.orElseSucceed(() => !1)), z = (e, t) => e.readFileString(t).pipe(f.orElseSucceed(() => "")), Ee = (e, t) => e.readFileString(t).pipe(f.map((e) => {
112
+ }), Ce = ["AGENTS.md", "CLAUDE.md"], we = "voltro:agents-md:keep", Te = 2048, Ee = "<!-- VOLTRO:INDEX -->", R = (e, t) => e.exists(t).pipe(f.orElseSucceed(() => !1)), z = (e, t) => e.readFileString(t).pipe(f.orElseSucceed(() => "")), De = (e, t) => e.readFileString(t).pipe(f.map((e) => {
112
113
  try {
113
114
  return JSON.parse(e).workspaces !== void 0;
114
115
  } catch {
115
116
  return !1;
116
117
  }
117
- }), f.orElseSucceed(() => !1)), De = (e) => f.gen(function* () {
118
+ }), f.orElseSucceed(() => !1)), Oe = (e) => f.gen(function* () {
118
119
  let n = yield* c.FileSystem, i = a(e);
119
120
  for (;;) {
120
- if ((yield* R(n, r(i, ".git"))) || (yield* R(n, r(i, "pnpm-workspace.yaml"))) || (yield* Ee(n, r(i, "package.json")))) return i;
121
+ if ((yield* R(n, r(i, ".git"))) || (yield* R(n, r(i, "pnpm-workspace.yaml"))) || (yield* De(n, r(i, "package.json")))) return i;
121
122
  let o = t(i);
122
123
  if (o === i) return a(e);
123
124
  i = o;
124
125
  }
125
- }), Oe = (e, t, n) => f.gen(function* () {
126
+ }), ke = (e, t, n) => f.gen(function* () {
126
127
  yield* e.makeDirectory(n, { recursive: !0 }).pipe(f.orElseSucceed(() => void 0));
127
128
  let i = yield* e.readDirectory(t).pipe(f.orElseSucceed(() => []));
128
129
  for (let a of i) {
129
130
  let i = r(t, a), o = r(n, a);
130
- (yield* e.stat(i).pipe(f.orElseSucceed(() => null)))?.type === "Directory" ? yield* Oe(e, i, o) : yield* e.copyFile(i, o).pipe(f.orElseSucceed(() => void 0));
131
+ (yield* e.stat(i).pipe(f.orElseSucceed(() => null)))?.type === "Directory" ? yield* ke(e, i, o) : yield* e.copyFile(i, o).pipe(f.orElseSucceed(() => void 0));
131
132
  }
132
- }), ke = (e) => typeof e?.name == "string" && e.name.length > 0 ? e.name.split("#")[0] : null, Ae = (e, t) => f.gen(function* () {
133
+ }), Ae = (e) => typeof e?.name == "string" && e.name.length > 0 ? e.name.split("#")[0] : null, je = (e, t) => f.gen(function* () {
133
134
  let n = r(t, "app.config.ts");
134
135
  if (!(yield* R(e, n))) return null;
135
136
  let i = (yield* f.tryPromise(() => import(s(n).href)).pipe(f.orElseSucceed(() => null)))?.default;
136
- return !i || i.type && i.type !== "api" ? i?.type === "web" ? [] : null : (i.plugins ?? []).map(ke).filter((e) => e !== null);
137
- }), je = (e, t) => f.gen(function* () {
137
+ return !i || i.type && i.type !== "api" ? i?.type === "web" ? [] : null : (i.plugins ?? []).map(Ae).filter((e) => e !== null);
138
+ }), Me = (e, t) => f.gen(function* () {
138
139
  let n = [], i = [], a = r(t, "apps");
139
140
  if (!(yield* R(e, a))) return {
140
141
  apis: n,
@@ -153,7 +154,7 @@ var ge = [
153
154
  apis: n,
154
155
  webs: i
155
156
  };
156
- }), Me = (e) => e.replace(/\|/g, "\\|").replace(/\n/g, " ").trim(), Ne = (e, t, n) => {
157
+ }), Ne = (e) => e.replace(/\|/g, "\\|").replace(/\n/g, " ").trim(), Pe = (e, t, n) => {
157
158
  let r = [
158
159
  "<!-- voltro agent-docs index — regenerated at seed time -->",
159
160
  "## Deep reference (read on demand)",
@@ -165,17 +166,17 @@ var ge = [
165
166
  "",
166
167
  "| Topic | Open | Summary |",
167
168
  "|---|---|---|",
168
- ...e.modules.map((e) => `| ${e.title} | \`${n}${e.path}\` | ${Me(e.description)} |`),
169
+ ...e.modules.map((e) => `| ${e.title} | \`${n}${e.path}\` | ${Ne(e.description)} |`),
169
170
  ""
170
- ], i = new Map(e.plugins.map((e) => [e.pkg, e])), a = t === null ? e.plugins.map((e) => `| ${e.slug} | \`node_modules/${e.pkg}/README.md\` | ${Me(e.description)} |`) : t.map((e) => {
171
+ ], i = new Map(e.plugins.map((e) => [e.pkg, e])), a = t === null ? e.plugins.map((e) => `| ${e.slug} | \`node_modules/${e.pkg}/README.md\` | ${Ne(e.description)} |`) : t.map((e) => {
171
172
  let t = i.get(e);
172
- return t ? `| ${t.slug} | \`node_modules/${e}/README.md\` | ${Me(t.description)} |` : `| ${e.replace(/^@[^/]+\//, "")} | \`node_modules/${e}/README.md\` | (see plugin README) |`;
173
+ return t ? `| ${t.slug} | \`node_modules/${e}/README.md\` | ${Ne(t.description)} |` : `| ${e.replace(/^@[^/]+\//, "")} | \`node_modules/${e}/README.md\` | (see plugin README) |`;
173
174
  });
174
175
  return r.push(`### Plugins${t === null ? "" : " (installed)"}`, "", "| Plugin | Open | Summary |", "|---|---|---|"), r.push(a.length ? a.join("\n") : "| _(none installed)_ | | |", ""), r.join("\n");
175
- }, Pe = (e, t, n) => {
176
+ }, Fe = (e, t, n) => {
176
177
  let r = t.templates?.[e] ?? t.templates?.[e.replace(/^frontend-/, "")];
177
178
  return `\nScaffolded from the \`${e}\` template — see \`${r ? `${n}${r}` : `${n}agent-docs/templates/overview.md`}\`.\n`;
178
- }, Fe = {
179
+ }, Ie = {
179
180
  api: (e, t, n = "") => `# api — agent notes
180
181
 
181
182
  You are in a Voltro **api** app. Server primitives live here: \`queries/\`,
@@ -215,7 +216,7 @@ You are in a Voltro **web** app. File-based routing under \`src/pages/**\`.
215
216
  Deep reference (paths from the repo root): \`${e}agent-docs/routing.md\`,
216
217
  \`${e}agent-docs/schema-driven-ui.md\`, \`${e}agent-docs/internationalization.md\`.
217
218
  ${t}`
218
- }, Ie = [
219
+ }, Le = [
219
220
  {
220
221
  name: "voltro-schema",
221
222
  description: "Define or change a Voltro database table/schema (columns, mixins, indexes, relations).",
@@ -246,7 +247,7 @@ ${t}`
246
247
  description: "Export/import + backup/restore Voltro data & assets, and copy prod→dev/stage SAFELY with fail-closed masking/anonymization (.sensitive()/.safe()) + referential subsetting. Use for data takeout, seeding lower envs, backups, or cross-dialect moves.",
247
248
  module: "cli.md"
248
249
  }
249
- ], Le = (e, t) => `---
250
+ ], Re = (e, t) => `---
250
251
  name: ${e.name}
251
252
  description: ${e.description}
252
253
  ---
@@ -257,10 +258,10 @@ Open the full reference and follow the patterns there:
257
258
 
258
259
  Also read the repo-root \`AGENTS.md\` for the always-true rules (browser/server
259
260
  boundary, naming, anti-patterns) before editing.
260
- `, Re = (e, n, r, i) => f.gen(function* () {
261
+ `, ze = (e, n, r, i) => f.gen(function* () {
261
262
  let a = yield* R(e, n);
262
263
  if (a) {
263
- if ((yield* z(e, n)).slice(0, we).includes("voltro:agents-md:keep")) return {
264
+ if ((yield* z(e, n)).slice(0, Te).includes("voltro:agents-md:keep")) return {
264
265
  path: n,
265
266
  action: "protected"
266
267
  };
@@ -273,64 +274,64 @@ boundary, naming, anti-patterns) before editing.
273
274
  path: n,
274
275
  action: a ? "overwritten" : "created"
275
276
  };
276
- }), ze = (e, t = {}) => f.gen(function* () {
277
- let n = yield* c.FileSystem, i = yield* De(e), o = null;
278
- for (let e of be) if (yield* R(n, r(e, "AGENTS.core.md"))) {
277
+ }), Be = (e, t = {}) => f.gen(function* () {
278
+ let n = yield* c.FileSystem, i = yield* Oe(e), o = null;
279
+ for (let e of L) if (yield* R(n, r(e, "AGENTS.core.md"))) {
279
280
  o = e;
280
281
  break;
281
282
  }
282
283
  if (o === null) {
283
- for (let e of be) if (yield* R(n, r(e, "AGENTS.md"))) {
284
+ for (let e of L) if (yield* R(n, r(e, "AGENTS.md"))) {
284
285
  let a = yield* z(n, r(e, "AGENTS.md")), o = [];
285
- for (let e of Se) o.push(yield* Re(n, r(i, e), a, t.force ?? !1));
286
+ for (let e of Ce) o.push(yield* ze(n, r(i, e), a, t.force ?? !1));
286
287
  return { files: o };
287
288
  }
288
- return yield* f.fail(xe(be.map((e) => r(e, "AGENTS.core.md"))));
289
+ return yield* f.fail(Se(L.map((e) => r(e, "AGENTS.core.md"))));
289
290
  }
290
291
  let s = yield* z(n, r(o, "AGENTS.core.md")), l = yield* z(n, r(o, "agent-docs", "_manifest.json")), u = l ? JSON.parse(l) : {
291
292
  modules: [],
292
293
  plugins: []
293
- }, d = (t.preferPointer ?? !1) || (yield* R(n, r(i, "node_modules/@voltro/cli/templates/agent-docs", "_manifest.json"))), p = d ? "node_modules/@voltro/cli/templates/" : "", m = t.force ?? !1, h = Se.map((e) => r(i, e));
294
- if ((yield* f.forEach(h, (e) => z(n, e).pipe(f.map((e) => e.slice(0, we))))).every((e) => e.includes("voltro:agents-md:keep"))) return { files: h.map((e) => ({
294
+ }, d = (t.preferPointer ?? !1) || (yield* R(n, r(i, "node_modules/@voltro/cli/templates/agent-docs", "_manifest.json"))), p = d ? "node_modules/@voltro/cli/templates/" : "", m = t.force ?? !1, h = Ce.map((e) => r(i, e));
295
+ if ((yield* f.forEach(h, (e) => z(n, e).pipe(f.map((e) => e.slice(0, Te))))).every((e) => e.includes("voltro:agents-md:keep"))) return { files: h.map((e) => ({
295
296
  path: e,
296
297
  action: "protected"
297
298
  })) };
298
- let { apis: g, webs: _ } = yield* je(n, i), v = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Set(), b = !1;
299
+ let { apis: g, webs: _ } = yield* Me(n, i), v = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Set(), b = !1;
299
300
  for (let e of g) {
300
- let t = yield* Ae(n, e);
301
+ let t = yield* je(n, e);
301
302
  if (v.set(e, t), t !== null) {
302
303
  b = !0;
303
304
  for (let e of t) y.add(e);
304
305
  }
305
306
  }
306
- let x = t.plugins ? t.plugins.map(ke).filter((e) => e !== null) : b ? [...y] : null, S = s.includes(Te) ? s.replace(Te, Ne(u, x, p)) : s, C = [];
307
- for (let e of h) C.push(yield* Re(n, e, S, m));
308
- d || (yield* Oe(n, r(o, "agent-docs"), r(i, "agent-docs")));
307
+ let x = t.plugins ? t.plugins.map(Ae).filter((e) => e !== null) : b ? [...y] : null, S = s.includes(Ee) ? s.replace(Ee, Pe(u, x, p)) : s, C = [];
308
+ for (let e of h) C.push(yield* ze(n, e, S, m));
309
+ d || (yield* ke(n, r(o, "agent-docs"), r(i, "agent-docs")));
309
310
  let w = new Map((t.appTemplates ?? []).map((e) => [a(e.dir), e.template])), T = (e) => {
310
311
  let t = w.get(a(e));
311
- return t ? Pe(t, u, p) : "";
312
- }, E = (e, t) => f.forEach(Se, (i) => Re(n, r(e, i), t, m));
313
- for (let e of g) C.push(...yield* E(e, Fe.api(p, v.get(e) ?? null, T(e)))), (yield* R(n, r(e, "database"))) && C.push(...yield* E(r(e, "database"), Fe.database(p)));
314
- for (let e of _) C.push(...yield* E(e, Fe.web(p, T(e))));
315
- for (let e of Ie) C.push(yield* Re(n, r(i, ".claude", "skills", e.name, "SKILL.md"), Le(e, p), m));
312
+ return t ? Fe(t, u, p) : "";
313
+ }, E = (e, t) => f.forEach(Ce, (i) => ze(n, r(e, i), t, m));
314
+ for (let e of g) C.push(...yield* E(e, Ie.api(p, v.get(e) ?? null, T(e)))), (yield* R(n, r(e, "database"))) && C.push(...yield* E(r(e, "database"), Ie.database(p)));
315
+ for (let e of _) C.push(...yield* E(e, Ie.web(p, T(e))));
316
+ for (let e of Le) C.push(yield* ze(n, r(i, ".claude", "skills", e.name, "SKILL.md"), Re(e, p), m));
316
317
  return { files: C };
317
- }), Be = (e, t = {}) => f.runPromise(ze(e, t).pipe(f.provide(l.layer))), Ve = async (e) => {
318
+ }), Ve = (e, t = {}) => f.runPromise(Be(e, t).pipe(f.provide(l.layer))), He = async (e) => {
318
319
  let t = e.includes("--force"), n = e.find((e) => !e.startsWith("-")) ?? process.cwd();
319
- return ve(f.gen(function* () {
320
- let e = yield* ze(n, { force: t });
320
+ return be(f.gen(function* () {
321
+ let e = yield* Be(n, { force: t });
321
322
  for (let t of e.files) {
322
- let e = t.action === "created" ? "wrote" : t.action === "overwritten" ? "overwrote" : t.action === "protected" ? `protected (hand-maintained — has "${Ce}")` : "present (use --force to overwrite)";
323
+ let e = t.action === "created" ? "wrote" : t.action === "overwritten" ? "overwrote" : t.action === "protected" ? `protected (hand-maintained — has "${we}")` : "present (use --force to overwrite)";
323
324
  yield* f.logInfo(`${t.path.split("/").slice(-2).join("/")} ${e}`, { action: t.action });
324
325
  }
325
326
  return 0;
326
327
  }).pipe(f.catchTag("TemplateNotFoundError", (e) => f.gen(function* () {
327
328
  return yield* f.logError("AGENTS.md template not found", { searched: e.searched }), 1;
328
329
  }))), { scope: "voltro:agents-md" });
329
- }, He = (e) => e.replace(/\\"|"(?:[^"\\]|\\.)*"|(\/\/[^\n]*|\/\*[\s\S]*?\*\/)/g, (e, t) => t ? "" : e), Ue = (e) => {
330
+ }, Ue = (e) => e.replace(/\\"|"(?:[^"\\]|\\.)*"|(\/\/[^\n]*|\/\*[\s\S]*?\*\/)/g, (e, t) => t ? "" : e), We = (e) => {
330
331
  try {
331
332
  let t = r(e, "tsconfig.json");
332
333
  if (!y(t)) return [];
333
- let n = JSON.parse(He(C(t, "utf8"))).compilerOptions ?? {}, i = n.paths ?? {}, o = a(e, n.baseUrl ?? "."), s = [];
334
+ let n = JSON.parse(Ue(C(t, "utf8"))).compilerOptions ?? {}, i = n.paths ?? {}, o = a(e, n.baseUrl ?? "."), s = [];
334
335
  for (let [e, t] of Object.entries(i)) {
335
336
  let n = t[0];
336
337
  if (!n) continue;
@@ -350,17 +351,17 @@ boundary, naming, anti-patterns) before editing.
350
351
  } catch {
351
352
  return [];
352
353
  }
353
- }, We = (e) => {
354
+ }, Ge = (e) => {
354
355
  let t = e;
355
356
  return t?.code === "ERR_MODULE_NOT_FOUND" || /Cannot find (package|module)/.test(String(t?.message ?? ""));
356
- }, Ge = async (e, t) => {
357
+ }, Ke = async (e, t) => {
357
358
  try {
358
359
  return await t();
359
360
  } catch (t) {
360
- throw We(t) ? Error(`voltro: the build tool '${e}' is not installed.\n\nIt's an OPTIONAL dependency of @voltro/cli — needed by 'voltro dev' and 'voltro build', but excluded from a serve-only production install (that's how prod images stay lean). If you are building, reinstall WITHOUT '--no-optional' (e.g. 'pnpm install'). A production SERVE container does not need '${e}' — it boots from the precompiled bundle.`) : t;
361
+ throw Ge(t) ? Error(`voltro: the build tool '${e}' is not installed.\n\nIt's an OPTIONAL dependency of @voltro/cli — needed by 'voltro dev' and 'voltro build', but excluded from a serve-only production install (that's how prod images stay lean). If you are building, reinstall WITHOUT '--no-optional' (e.g. 'pnpm install'). A production SERVE container does not need '${e}' — it boots from the precompiled bundle.`) : t;
361
362
  }
362
- }, Ke = "// AUTO-GENERATED by Voltro — DO NOT EDIT.\n// Source: app.config.ts `env` (defineEnv). Regenerated on every `voltro dev` boot.\n", qe = (e, t) => t ? `${e} | undefined` : e, Je = (e, t) => Object.entries(e.vars).filter(([, e]) => t(e.access)).map(([e, t]) => `${t.description ? ` /** ${t.description} */\n` : ""} readonly ${e}: ${qe(t.tsType, t.optional)}`).join("\n"), Ye = async (e, t) => {
363
- let n = Je(t, () => !0), i = `${Ke}
363
+ }, qe = "// AUTO-GENERATED by Voltro — DO NOT EDIT.\n// Source: app.config.ts `env` (defineEnv). Regenerated on every `voltro dev` boot.\n", Je = (e, t) => t ? `${e} | undefined` : e, Ye = (e, t) => Object.entries(e.vars).filter(([, e]) => t(e.access)).map(([e, t]) => `${t.description ? ` /** ${t.description} */\n` : ""} readonly ${e}: ${Je(t.tsType, t.optional)}`).join("\n"), Xe = async (e, t) => {
364
+ let n = Ye(t, () => !0), i = `${qe}
364
365
  import '@voltro/env/server'
365
366
 
366
367
  declare module '@voltro/env/server' {
@@ -370,8 +371,8 @@ ${n.length > 0 ? n : " // (no variables declared)"}
370
371
  }
371
372
  `;
372
373
  await j(r(e, "env.generated.d.ts"), i, "utf8");
373
- }, Xe = async (e, t) => {
374
- let n = Je(t, (e) => e === "public"), i = `${Ke}
374
+ }, Ze = async (e, t) => {
375
+ let n = Ye(t, (e) => e === "public"), i = `${qe}
375
376
  import '@voltro/env/public'
376
377
 
377
378
  declare module '@voltro/env/public' {
@@ -380,9 +381,9 @@ ${n.length > 0 ? n : " // (no public variables declared)"}
380
381
  }
381
382
  }
382
383
  `, a = r(e, "src");
383
- await A(a, { recursive: !0 }), await j(r(a, "voltro-env.d.ts"), i, "utf8");
384
- }, Ze = async (e, t) => {
385
- let n = `${Ke}
384
+ await re(a, { recursive: !0 }), await j(r(a, "voltro-env.d.ts"), i, "utf8");
385
+ }, Qe = async (e, t) => {
386
+ let n = `${qe}
386
387
  import { __installPublicEnv } from '@voltro/env/public'
387
388
 
388
389
  export const publicEnvValues = ${JSON.stringify(t, null, 2)} as const
@@ -390,13 +391,13 @@ export const publicEnvValues = ${JSON.stringify(t, null, 2)} as const
390
391
  // Set the browser/SSR-shared global the \`publicEnv\` accessor reads.
391
392
  __installPublicEnv(publicEnvValues)
392
393
  `;
393
- await A(e, { recursive: !0 }), await j(r(e, "env.public.ts"), n, "utf8");
394
- }, Qe = async (e) => {
394
+ await re(e, { recursive: !0 }), await j(r(e, "env.public.ts"), n, "utf8");
395
+ }, $e = async (e) => {
395
396
  let t = se(e.rawEnv) ? e.rawEnv : void 0, n = await le({
396
397
  contract: t,
397
- resolveSecret: k
398
- }), r = [...n.errors, ...ie(t, e.appType)];
399
- if (r.length > 0) throw Error(ae(r));
398
+ resolveSecret: A
399
+ }), r = [...n.errors, ...ae(t, e.appType)];
400
+ if (r.length > 0) throw Error(N(r));
400
401
  oe(n.values), e.appType === "web" && ue(n.publicValues);
401
402
  let i = t ? Object.keys(t.vars).length : 0;
402
403
  if (i > 0) {
@@ -409,52 +410,52 @@ __installPublicEnv(publicEnvValues)
409
410
  n.length > 0 && e.log.warn(`env: ${n.length} secret var(s) declared on a web app — secrets are reachable only from server-side render code and are NEVER bundled. Prefer declaring secrets on the api.`, { keys: n });
410
411
  }
411
412
  }
412
- return e.generateTypes && t && (e.appType === "api" ? await Ye(e.root, t) : await Xe(e.root, t)), {
413
+ return e.generateTypes && t && (e.appType === "api" ? await Xe(e.root, t) : await Ze(e.root, t)), {
413
414
  resolved: n,
414
415
  contract: t
415
416
  };
416
- }, B = g({ scope: "vite" }), $e = /\x1b\[[0-9;]*m/g, et = /^\s*\[?vite\]?\s*(\([a-z-]+\)\s*)?/, tt = (e) => e.replace($e, "").replace(et, "").trim(), nt = /proxy error/i, rt = [
417
+ }, et = g({ scope: "vite" }), tt = /\x1b\[[0-9;]*m/g, nt = /^\s*\[?vite\]?\s*(\([a-z-]+\)\s*)?/, rt = (e) => e.replace(tt, "").replace(nt, "").trim(), it = /proxy error/i, at = [
417
418
  "ECONNREFUSED",
418
419
  "ECONNRESET",
419
420
  "ECONNABORTED",
420
421
  "EPIPE",
421
422
  "ETIMEDOUT"
422
- ], it = (e, t = 0) => {
423
+ ], ot = (e, t = 0) => {
423
424
  if (e == null || t > 5) return !1;
424
425
  let n = e;
425
- return typeof n.code == "string" && rt.includes(n.code) || typeof n.message == "string" && rt.some((e) => n.message.includes(e)) || Array.isArray(n.errors) && n.errors.some((e) => it(e, t + 1)) ? !0 : it(n.cause, t + 1);
426
- }, at = 4e3, ot = () => {
426
+ return typeof n.code == "string" && at.includes(n.code) || typeof n.message == "string" && at.some((e) => n.message.includes(e)) || Array.isArray(n.errors) && n.errors.some((e) => ot(e, t + 1)) ? !0 : ot(n.cause, t + 1);
427
+ }, st = 4e3, ct = () => {
427
428
  let e = /* @__PURE__ */ new Set(), t = 0, n = {
428
429
  hasWarned: !1,
429
430
  info: (e) => {
430
- let t = tt(e);
431
- t.length !== 0 && B.info(t);
431
+ let t = rt(e);
432
+ t.length !== 0 && et.info(t);
432
433
  },
433
434
  warn: (e) => {
434
435
  n.hasWarned = !0;
435
- let t = tt(e);
436
- t.length !== 0 && B.warn(t);
436
+ let t = rt(e);
437
+ t.length !== 0 && et.warn(t);
437
438
  },
438
439
  warnOnce: (t) => {
439
- let r = tt(t);
440
- e.has(r) || (e.add(r), n.hasWarned = !0, r.length !== 0 && B.warn(r));
440
+ let r = rt(t);
441
+ e.has(r) || (e.add(r), n.hasWarned = !0, r.length !== 0 && et.warn(r));
441
442
  },
442
443
  error: (e, n) => {
443
- let r = tt(e), i = n?.error;
444
+ let r = rt(e), i = n?.error;
444
445
  if (r.length !== 0) {
445
- if (nt.test(r) && it(i)) {
446
+ if (it.test(r) && ot(i)) {
446
447
  let e = Date.now();
447
- e - t > at && (t = e, B.info("waiting for api — proxy upstream not accepting connections yet (still starting?)"));
448
+ e - t > st && (t = e, et.info("waiting for api — proxy upstream not accepting connections yet (still starting?)"));
448
449
  return;
449
450
  }
450
- B.error(r, {}, i);
451
+ et.error(r, {}, i);
451
452
  }
452
453
  },
453
454
  clearScreen: () => {},
454
455
  hasErrorLogged: (e) => !1
455
456
  };
456
457
  return n;
457
- }, st = (e) => {
458
+ }, lt = (e) => {
458
459
  let t = [];
459
460
  for (let n of e.split("/").filter(Boolean)) n.startsWith("[[...") && n.endsWith("]]") ? t.push({
460
461
  name: n.slice(5, -2),
@@ -470,7 +471,7 @@ __installPublicEnv(publicEnvValues)
470
471
  optional: !1
471
472
  });
472
473
  return t;
473
- }, ct = (e) => e.replace(/-([a-z0-9])/g, (e, t) => t.toUpperCase()), lt = async (e) => {
474
+ }, ut = (e) => e.replace(/-([a-z0-9])/g, (e, t) => t.toUpperCase()), dt = async (e) => {
474
475
  let n = a(e);
475
476
  for (let e = 0; e < 4; e++) {
476
477
  let e = r(n, "project.json");
@@ -488,8 +489,8 @@ __installPublicEnv(publicEnvValues)
488
489
  n = i;
489
490
  }
490
491
  return null;
491
- }, ut = async (t) => {
492
- let n = await lt(t);
492
+ }, ft = async (t) => {
493
+ let n = await dt(t);
493
494
  if (!n) return [];
494
495
  let { projectDir: i, manifest: a } = n, o = e(t), s = a.apps ?? {}, c = [];
495
496
  for (let [e, t] of Object.entries(s)) {
@@ -501,20 +502,20 @@ __installPublicEnv(publicEnvValues)
501
502
  let { pages: e } = await $(n);
502
503
  a = e.map((e) => ({
503
504
  pattern: e.pattern,
504
- params: st(e.pattern)
505
+ params: lt(e.pattern)
505
506
  }));
506
507
  } catch {
507
508
  continue;
508
509
  }
509
510
  c.push({
510
- key: ct(e),
511
+ key: ut(e),
511
512
  origin: `http://localhost:${t.port}`,
512
513
  ...typeof t.origin == "string" && t.origin.length > 0 ? { prodOrigin: t.origin } : {},
513
514
  routes: a
514
515
  });
515
516
  }
516
517
  return c;
517
- }, dt = (e) => {
518
+ }, pt = (e) => {
518
519
  if (e.params.length === 0) return `'${e.pattern}'`;
519
520
  let t = e.pattern;
520
521
  for (let n of e.params) {
@@ -522,21 +523,21 @@ __installPublicEnv(publicEnvValues)
522
523
  t = t.replace(e, r);
523
524
  }
524
525
  return "`" + t + "`";
525
- }, ft = (e) => e.params.length === 0 ? "EmptyParams" : `{ ${e.params.map((e) => {
526
+ }, mt = (e) => e.params.length === 0 ? "EmptyParams" : `{ ${e.params.map((e) => {
526
527
  let t = "string";
527
528
  return e.optional ? `readonly ${e.name}?: ${t}` : `readonly ${e.name}: ${t}`;
528
- }).join("; ")} }`, pt = (e, t, n) => {
529
- let r = ft(e), i = dt(e), a = t ? "VoltroExternalUrl" : "VoltroRouteUrl", o = t && n ? `${n} + ` : "";
529
+ }).join("; ")} }`, ht = (e, t, n) => {
530
+ let r = mt(e), i = pt(e), a = t ? "VoltroExternalUrl" : "VoltroRouteUrl", o = t && n ? `${n} + ` : "";
530
531
  return e.params.length === 0 ? `() => (${o}${i}) as ${a}` : `({ ${e.params.map((e) => e.name).join(", ")} }: ${r}) => (${o}${i}) as ${a}`;
531
- }, mt = (e) => `{\n${[...e].sort((e, t) => e.pattern.localeCompare(t.pattern)).map((e) => ` ${JSON.stringify(e.pattern)}: ${pt(e, !1)},`).join("\n")}\n}`, ht = (e, t) => {
532
+ }, gt = (e) => `{\n${[...e].sort((e, t) => e.pattern.localeCompare(t.pattern)).map((e) => ` ${JSON.stringify(e.pattern)}: ${ht(e, !1)},`).join("\n")}\n}`, _t = (e, t) => {
532
533
  if (e.routes.length === 0) return ` ${e.key}: {} as Record<string, never>,`;
533
- let n = [...e.routes].sort((e, t) => e.pattern.localeCompare(t.pattern)), r = t === "prod" && e.prodOrigin ? e.prodOrigin : e.origin, i = JSON.stringify(r), a = n.map((e) => ` ${JSON.stringify(e.pattern)}: ${pt(e, !0, i)},`);
534
+ let n = [...e.routes].sort((e, t) => e.pattern.localeCompare(t.pattern)), r = t === "prod" && e.prodOrigin ? e.prodOrigin : e.origin, i = JSON.stringify(r), a = n.map((e) => ` ${JSON.stringify(e.pattern)}: ${ht(e, !0, i)},`);
534
535
  return ` ${e.key}: {\n${a.join("\n")}\n },`;
535
- }, gt = async (e) => {
536
+ }, vt = async (e) => {
536
537
  let n = e.pages.map((e) => ({
537
538
  pattern: e.pattern,
538
- params: st(e.pattern)
539
- })), i = await ut(e.appRoot), a = [
539
+ params: lt(e.pattern)
540
+ })), i = await ft(e.appRoot), a = [
540
541
  "// THIS FILE IS GENERATED — DO NOT EDIT BY HAND.",
541
542
  "// Re-emitted by `voltro dev` whenever `src/pages/**` changes.",
542
543
  "// Type-safe route builders consumed by <Link to={...}>.",
@@ -545,7 +546,7 @@ __installPublicEnv(publicEnvValues)
545
546
  "",
546
547
  "type EmptyParams = Record<string, never>",
547
548
  ""
548
- ].join("\n"), o = e.mode ?? "dev", s = `${a}\n${`export const routes = ${mt(n)} as const\n`}\n${i.length === 0 ? "export const siblingApps = {} as Record<string, never>\n" : `export const siblingApps = {\n${i.map((e) => ht(e, o)).join("\n")}\n} as const\n`}`, c = r(e.appRoot, ".framework", "routes.generated.ts");
549
+ ].join("\n"), o = e.mode ?? "dev", s = `${a}\n${`export const routes = ${gt(n)} as const\n`}\n${i.length === 0 ? "export const siblingApps = {} as Record<string, never>\n" : `export const siblingApps = {\n${i.map((e) => _t(e, o)).join("\n")}\n} as const\n`}`, c = r(e.appRoot, ".framework", "routes.generated.ts");
549
550
  await S.mkdir(t(c), { recursive: !0 });
550
551
  let l = null;
551
552
  try {
@@ -558,16 +559,16 @@ __installPublicEnv(publicEnvValues)
558
559
  path: c,
559
560
  wrote: !0
560
561
  });
561
- }, _t = (e) => {
562
- let t = N(e.contract), n = (e.plugins ?? []).flatMap((e) => ce(e.name, e.declaredEnv)), r = e.includeFramework === !1 ? [] : M, i = /* @__PURE__ */ new Set(), a = [];
562
+ }, yt = (e) => {
563
+ let t = ie(e.contract), n = (e.plugins ?? []).flatMap((e) => ce(e.name, e.declaredEnv)), r = e.includeFramework === !1 ? [] : M, i = /* @__PURE__ */ new Set(), a = [];
563
564
  for (let e of [
564
565
  ...t,
565
566
  ...n,
566
567
  ...r
567
568
  ]) i.has(e.key) || (i.add(e.key), a.push(e));
568
569
  return a;
569
- }, vt = (e, t, n = (e) => process.env[e]) => {
570
- let r = _t(t).map((e) => {
570
+ }, bt = (e, t, n = (e) => process.env[e]) => {
571
+ let r = yt(t).map((e) => {
571
572
  let t = n(e.key) !== void 0;
572
573
  return {
573
574
  ...e,
@@ -584,13 +585,13 @@ __installPublicEnv(publicEnvValues)
584
585
  missingRequired: r.filter((e) => e.required && !e.isSet && e.default === void 0).length
585
586
  }
586
587
  };
587
- }, yt = (e, t) => P(_t({
588
+ }, xt = (e, t) => P(yt({
588
589
  ...e,
589
590
  includeFramework: !1
590
591
  }), {
591
592
  includeFramework: e.includeFramework !== !1,
592
593
  ...t ? { header: t } : {}
593
- }), V = "/_voltro/inspect", H = () => process.env.VOLTRO_INSPECT === "off", U = (e) => {
594
+ }), B = "/_voltro/inspect", V = () => process.env.VOLTRO_INSPECT === "off", H = (e) => {
594
595
  let t = process.env.VOLTRO_INSPECT_TOKEN;
595
596
  if (!t || t.length === 0) return { ok: !0 };
596
597
  let n = e.authorization ?? e.Authorization;
@@ -604,7 +605,7 @@ __installPublicEnv(publicEnvValues)
604
605
  ok: !1,
605
606
  reason: "missing Authorization header"
606
607
  };
607
- }, bt = (e) => {
608
+ }, St = (e) => {
608
609
  if (!Array.isArray(e) || e.length === 0) return;
609
610
  let t = [];
610
611
  for (let n of e) {
@@ -626,25 +627,25 @@ __installPublicEnv(publicEnvValues)
626
627
  });
627
628
  }
628
629
  return t.length > 0 ? t : void 0;
629
- }, W = (e, t, n = {}) => ({
630
+ }, U = (e, t, n = {}) => ({
630
631
  status: e,
631
632
  contentType: "application/json; charset=utf-8",
632
633
  body: JSON.stringify(t),
633
634
  headers: n
634
- }), G = (e) => !e || e.length === 0 ? {} : {
635
+ }), W = (e) => !e || e.length === 0 ? {} : {
635
636
  "access-control-allow-origin": e,
636
637
  "access-control-allow-credentials": "true",
637
638
  "access-control-allow-methods": "GET, POST, OPTIONS",
638
639
  "access-control-allow-headers": "authorization, content-type, accept",
639
640
  "access-control-expose-headers": "content-type, content-length",
640
641
  vary: "Origin"
641
- }, K = (e) => {
642
+ }, G = (e) => {
642
643
  let t = e.indexOf("?");
643
644
  return t === -1 ? e : e.slice(0, t);
644
- }, xt = (e) => {
645
+ }, Ct = (e) => {
645
646
  let t = e.indexOf("?");
646
647
  return t === -1 ? new URLSearchParams() : new URLSearchParams(e.slice(t + 1));
647
- }, St = (e) => e === "/_voltro/inspect" || e.startsWith("/_voltro/inspect/"), Ct = [
648
+ }, wt = (e) => e === "/_voltro/inspect" || e.startsWith("/_voltro/inspect/"), Tt = [
648
649
  "text",
649
650
  "textarea",
650
651
  "number",
@@ -660,7 +661,7 @@ __installPublicEnv(publicEnvValues)
660
661
  "file",
661
662
  "hidden",
662
663
  "custom"
663
- ], wt = (e, t, n = []) => ({
664
+ ], Et = (e, t, n = []) => ({
664
665
  version: 2,
665
666
  procedures: [...e].sort((e, t) => e.tag.localeCompare(t.tag)).map((e) => ({
666
667
  tag: e.tag,
@@ -674,7 +675,7 @@ __installPublicEnv(publicEnvValues)
674
675
  ...e.exposeAsTool === void 0 ? {} : { exposeAsTool: e.exposeAsTool }
675
676
  })),
676
677
  workflows: [...t].sort((e, t) => e.tag.localeCompare(t.tag)).map((e) => ({ name: e.tag })),
677
- widgets: Ct,
678
+ widgets: Tt,
678
679
  tables: [...n].filter((e) => !e.isFrameworkTable).sort((e, t) => e.name.localeCompare(t.name)).map((e) => ({
679
680
  name: e.name,
680
681
  reactive: e.isReactive,
@@ -687,58 +688,58 @@ __installPublicEnv(publicEnvValues)
687
688
  ...e.oneOf === void 0 ? {} : { enum: e.oneOf }
688
689
  }))
689
690
  }))
690
- }), Tt = (e, t, n = {}, r = {}) => {
691
- let i = K(e);
692
- if (!St(i)) return null;
693
- let a = G(n.origin ?? n.Origin);
691
+ }), Dt = (e, t, n = {}, r = {}) => {
692
+ let i = G(e);
693
+ if (!wt(i)) return null;
694
+ let a = W(n.origin ?? n.Origin);
694
695
  if ((r.method ?? "GET").toUpperCase() === "OPTIONS") return {
695
696
  status: 204,
696
697
  contentType: "text/plain",
697
698
  body: "",
698
699
  headers: a
699
700
  };
700
- if (H()) return W(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, a);
701
- let o = (r.authResolver ?? U)(n);
702
- if (!o.ok) return W(401, {
701
+ if (V()) return U(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, a);
702
+ let o = (r.authResolver ?? H)(n);
703
+ if (!o.ok) return U(401, {
703
704
  error: "unauthorized",
704
705
  reason: o.reason
705
706
  }, a);
706
- if (i === "/_voltro/inspect" || i === "/_voltro/inspect/" || i === "/_voltro/inspect/app") return W(200, {
707
+ if (i === "/_voltro/inspect" || i === "/_voltro/inspect/" || i === "/_voltro/inspect/app") return U(200, {
707
708
  kind: t.kind,
708
709
  ...t.meta
709
710
  }, a);
710
- if (i === "/_voltro/inspect/routes") return t.kind === "web" ? W(200, {
711
+ if (i === "/_voltro/inspect/routes") return t.kind === "web" ? U(200, {
711
712
  pages: t.routes,
712
713
  dirs: t.dirs
713
- }, a) : W(404, { error: "routes endpoint is web-only" }, a);
714
- if (i === "/_voltro/inspect/cache") return t.kind === "web" ? W(200, t.cache(), a) : W(404, { error: "cache endpoint is web-only" }, a);
715
- if (i === "/_voltro/inspect/rpc") return t.kind === "api" ? W(200, {
714
+ }, a) : U(404, { error: "routes endpoint is web-only" }, a);
715
+ if (i === "/_voltro/inspect/cache") return t.kind === "web" ? U(200, t.cache(), a) : U(404, { error: "cache endpoint is web-only" }, a);
716
+ if (i === "/_voltro/inspect/rpc") return t.kind === "api" ? U(200, {
716
717
  procedures: t.rpc,
717
718
  workflows: t.workflows
718
- }, a) : W(404, { error: "rpc endpoint is api-only" }, a);
719
+ }, a) : U(404, { error: "rpc endpoint is api-only" }, a);
719
720
  if (i === "/_voltro/inspect/manifest") {
720
- if (t.kind !== "api") return W(404, { error: "manifest endpoint is api-only" }, a);
721
+ if (t.kind !== "api") return U(404, { error: "manifest endpoint is api-only" }, a);
721
722
  let e = t.inspectTables?.().tables ?? [];
722
- return W(200, wt(t.rpc, t.workflows, e), a);
723
+ return U(200, Et(t.rpc, t.workflows, e), a);
723
724
  }
724
- return i === "/_voltro/inspect/metrics" ? t.metrics === void 0 ? W(200, [], a) : W(200, t.metrics(), a) : i === "/_voltro/inspect/subscriptions" ? t.kind === "api" ? t.subscriptions === void 0 ? W(200, {
725
+ return i === "/_voltro/inspect/metrics" ? t.metrics === void 0 ? U(200, [], a) : U(200, t.metrics(), a) : i === "/_voltro/inspect/subscriptions" ? t.kind === "api" ? t.subscriptions === void 0 ? U(200, {
725
726
  subscriptions: [],
726
727
  matcherStats: [],
727
728
  capturedAt: Date.now()
728
- }, a) : W(200, t.subscriptions(), a) : W(404, { error: "subscriptions endpoint is api-only" }, a) : i === "/_voltro/inspect/data-cache" ? t.kind === "api" ? t.dataCache === void 0 ? W(200, {
729
+ }, a) : U(200, t.subscriptions(), a) : U(404, { error: "subscriptions endpoint is api-only" }, a) : i === "/_voltro/inspect/data-cache" ? t.kind === "api" ? t.dataCache === void 0 ? U(200, {
729
730
  backend: "memory",
730
731
  engine: "memory",
731
732
  driver: "resp",
732
733
  hits: 0,
733
734
  misses: 0,
734
735
  hitRate: 0
735
- }, a) : W(200, t.dataCache(), a) : W(404, { error: "data-cache endpoint is api-only" }, a) : i === "/_voltro/inspect/database" ? t.kind === "api" ? t.database === void 0 ? W(200, {
736
+ }, a) : U(200, t.dataCache(), a) : U(404, { error: "data-cache endpoint is api-only" }, a) : i === "/_voltro/inspect/database" ? t.kind === "api" ? t.database === void 0 ? U(200, {
736
737
  migrations: [],
737
738
  seeds: []
738
- }, a) : W(200, t.database(), a) : W(404, { error: "database endpoint is api-only" }, a) : i === "/_voltro/inspect/plugins" ? t.kind === "api" ? t.plugins === void 0 ? W(200, {
739
+ }, a) : U(200, t.database(), a) : U(404, { error: "database endpoint is api-only" }, a) : i === "/_voltro/inspect/plugins" ? t.kind === "api" ? t.plugins === void 0 ? U(200, {
739
740
  plugins: [],
740
741
  capturedAt: Date.now()
741
- }, a) : W(200, t.plugins(), a) : W(404, { error: "plugins endpoint is api-only" }, a) : i === "/_voltro/inspect/env" ? t.env === void 0 ? W(200, {
742
+ }, a) : U(200, t.plugins(), a) : U(404, { error: "plugins endpoint is api-only" }, a) : i === "/_voltro/inspect/env" ? t.env === void 0 ? U(200, {
742
743
  app: t.meta.name ?? "app",
743
744
  entries: [],
744
745
  summary: {
@@ -746,34 +747,34 @@ __installPublicEnv(publicEnvValues)
746
747
  set: 0,
747
748
  missingRequired: 0
748
749
  }
749
- }, a) : W(200, t.env(), a) : i === "/_voltro/inspect/data/tables" ? t.kind === "api" ? t.inspectTables === void 0 ? W(200, { tables: [] }, a) : W(200, t.inspectTables(), a) : W(404, { error: "data viewer is api-only" }, a) : i === "/_voltro/inspect/invoke" ? W(404, { error: "invoke not enabled here — use POST handler" }, a) : W(404, {
750
+ }, a) : U(200, t.env(), a) : i === "/_voltro/inspect/data/tables" ? t.kind === "api" ? t.inspectTables === void 0 ? U(200, { tables: [] }, a) : U(200, t.inspectTables(), a) : U(404, { error: "data viewer is api-only" }, a) : i === "/_voltro/inspect/invoke" ? U(404, { error: "invoke not enabled here — use POST handler" }, a) : U(404, {
750
751
  error: "unknown inspect endpoint",
751
752
  path: i
752
753
  }, a);
753
- }, Et = async (e, t, n, r = {}) => {
754
- let i = G(t.origin ?? t.Origin);
755
- if (H()) return W(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, i);
756
- if ((r.method ?? "POST").toUpperCase() !== "POST") return W(405, {
754
+ }, Ot = async (e, t, n, r = {}) => {
755
+ let i = W(t.origin ?? t.Origin);
756
+ if (V()) return U(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, i);
757
+ if ((r.method ?? "POST").toUpperCase() !== "POST") return U(405, {
757
758
  error: "method not allowed",
758
759
  expected: "POST"
759
760
  }, i);
760
- let a = (r.authResolver ?? U)(t);
761
- if (!a.ok) return W(401, {
761
+ let a = (r.authResolver ?? H)(t);
762
+ if (!a.ok) return U(401, {
762
763
  error: "unauthorized",
763
764
  reason: a.reason
764
765
  }, i);
765
- if (e.kind !== "api") return W(404, { error: "invoke endpoint is api-only" }, i);
766
- if (!e.invokers || e.invokers.size === 0) return W(404, { error: "invoke not configured" }, i);
766
+ if (e.kind !== "api") return U(404, { error: "invoke endpoint is api-only" }, i);
767
+ if (!e.invokers || e.invokers.size === 0) return U(404, { error: "invoke not configured" }, i);
767
768
  let o;
768
769
  try {
769
770
  o = JSON.parse(n || "{}");
770
771
  } catch {
771
- return W(400, { error: "body must be JSON" }, i);
772
+ return U(400, { error: "body must be JSON" }, i);
772
773
  }
773
774
  let s = o;
774
- if (typeof s.tag != "string") return W(400, { error: "body.tag must be a string" }, i);
775
+ if (typeof s.tag != "string") return U(400, { error: "body.tag must be a string" }, i);
775
776
  let c = e.invokers.get(s.tag);
776
- if (!c) return W(404, {
777
+ if (!c) return U(404, {
777
778
  error: "unknown tag",
778
779
  tag: s.tag
779
780
  }, i);
@@ -783,167 +784,167 @@ __installPublicEnv(publicEnvValues)
783
784
  let n = e.toLowerCase();
784
785
  n !== "cookie" && (u[n] = t);
785
786
  }
786
- return W(200, await c(s.input, u), i);
787
- }, Dt = async (e, t, n, r, i = {}) => {
788
- let a = K(e);
789
- if (!St(a) || !a.startsWith("/_voltro/inspect/webhooks/")) return null;
790
- let o = G(n.origin ?? n.Origin);
787
+ return U(200, await c(s.input, u), i);
788
+ }, kt = async (e, t, n, r, i = {}) => {
789
+ let a = G(e);
790
+ if (!wt(a) || !a.startsWith("/_voltro/inspect/webhooks/")) return null;
791
+ let o = W(n.origin ?? n.Origin);
791
792
  if ((i.method ?? "POST").toUpperCase() !== "POST") return null;
792
- if (H()) return W(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, o);
793
- let s = (i.authResolver ?? U)(n);
794
- if (!s.ok) return W(401, {
793
+ if (V()) return U(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, o);
794
+ let s = (i.authResolver ?? H)(n);
795
+ if (!s.ok) return U(401, {
795
796
  error: "unauthorized",
796
797
  reason: s.reason
797
798
  }, o);
798
- if (t.kind !== "api") return W(404, { error: "webhook actions are api-only" }, o);
799
- if (!t.webhookActions) return W(404, { error: "webhook actions not configured — is @voltro/plugin-webhooks active?" }, o);
799
+ if (t.kind !== "api") return U(404, { error: "webhook actions are api-only" }, o);
800
+ if (!t.webhookActions) return U(404, { error: "webhook actions not configured — is @voltro/plugin-webhooks active?" }, o);
800
801
  let c;
801
802
  try {
802
803
  c = JSON.parse(r || "{}");
803
804
  } catch {
804
- return W(400, { error: "body must be JSON" }, o);
805
+ return U(400, { error: "body must be JSON" }, o);
805
806
  }
806
- let l = a.slice(`${V}/webhooks/`.length);
807
+ let l = a.slice(`${B}/webhooks/`.length);
807
808
  try {
808
809
  switch (l) {
809
810
  case "subscribe": {
810
811
  let e = c;
811
- return typeof e.event != "string" || e.event.length === 0 ? W(400, { error: "event required" }, o) : typeof e.url != "string" || e.url.length === 0 ? W(400, { error: "url required" }, o) : W(200, await t.webhookActions.subscribe(e), o);
812
+ return typeof e.event != "string" || e.event.length === 0 ? U(400, { error: "event required" }, o) : typeof e.url != "string" || e.url.length === 0 ? U(400, { error: "url required" }, o) : U(200, await t.webhookActions.subscribe(e), o);
812
813
  }
813
814
  case "pause": {
814
815
  let e = c.targetId;
815
- return typeof e != "string" || e.length === 0 ? W(400, { error: "targetId required" }, o) : (await t.webhookActions.pause(e), W(200, { ok: !0 }, o));
816
+ return typeof e != "string" || e.length === 0 ? U(400, { error: "targetId required" }, o) : (await t.webhookActions.pause(e), U(200, { ok: !0 }, o));
816
817
  }
817
818
  case "resume": {
818
819
  let e = c.targetId;
819
- return typeof e != "string" || e.length === 0 ? W(400, { error: "targetId required" }, o) : (await t.webhookActions.resume(e), W(200, { ok: !0 }, o));
820
+ return typeof e != "string" || e.length === 0 ? U(400, { error: "targetId required" }, o) : (await t.webhookActions.resume(e), U(200, { ok: !0 }, o));
820
821
  }
821
822
  case "delete": {
822
823
  let e = c.targetId;
823
- return typeof e != "string" || e.length === 0 ? W(400, { error: "targetId required" }, o) : (await t.webhookActions.delete(e), W(200, { ok: !0 }, o));
824
+ return typeof e != "string" || e.length === 0 ? U(400, { error: "targetId required" }, o) : (await t.webhookActions.delete(e), U(200, { ok: !0 }, o));
824
825
  }
825
826
  case "rotateSecret": {
826
827
  let e = c.targetId;
827
- return typeof e != "string" || e.length === 0 ? W(400, { error: "targetId required" }, o) : W(200, await t.webhookActions.rotateSecret(e), o);
828
+ return typeof e != "string" || e.length === 0 ? U(400, { error: "targetId required" }, o) : U(200, await t.webhookActions.rotateSecret(e), o);
828
829
  }
829
830
  case "replay": {
830
831
  let e = c.deliveryId;
831
- return typeof e != "string" || e.length === 0 ? W(400, { error: "deliveryId required" }, o) : (await t.webhookActions.replay(e), W(200, { ok: !0 }, o));
832
+ return typeof e != "string" || e.length === 0 ? U(400, { error: "deliveryId required" }, o) : (await t.webhookActions.replay(e), U(200, { ok: !0 }, o));
832
833
  }
833
834
  case "repinVersion": {
834
835
  let e = c.targetId, n = c.version;
835
- return typeof e != "string" || e.length === 0 ? W(400, { error: "targetId required" }, o) : typeof n != "number" || !Number.isInteger(n) || n < 1 ? W(400, { error: "version must be a positive integer" }, o) : (await t.webhookActions.updateTargetPayloadVersion(e, n), W(200, { ok: !0 }, o));
836
+ return typeof e != "string" || e.length === 0 ? U(400, { error: "targetId required" }, o) : typeof n != "number" || !Number.isInteger(n) || n < 1 ? U(400, { error: "version must be a positive integer" }, o) : (await t.webhookActions.updateTargetPayloadVersion(e, n), U(200, { ok: !0 }, o));
836
837
  }
837
- default: return W(404, { error: `unknown webhook action: ${l}` }, o);
838
+ default: return U(404, { error: `unknown webhook action: ${l}` }, o);
838
839
  }
839
840
  } catch (e) {
840
- return W(500, {
841
+ return U(500, {
841
842
  error: "webhook action failed",
842
843
  message: e?.message ?? String(e)
843
844
  }, o);
844
845
  }
845
- }, Ot = async (e, t, n, r, i = {}) => {
846
- let a = K(e);
847
- if (!St(a)) return null;
848
- let o = G(n.origin ?? n.Origin);
846
+ }, At = async (e, t, n, r, i = {}) => {
847
+ let a = G(e);
848
+ if (!wt(a)) return null;
849
+ let o = W(n.origin ?? n.Origin);
849
850
  if ((i.method ?? "POST").toUpperCase() !== "POST") return null;
850
- if (H()) return W(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, o);
851
- let s = (i.authResolver ?? U)(n);
852
- if (!s.ok) return W(401, {
851
+ if (V()) return U(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, o);
852
+ let s = (i.authResolver ?? H)(n);
853
+ if (!s.ok) return U(401, {
853
854
  error: "unauthorized",
854
855
  reason: s.reason
855
856
  }, o);
856
- if (t.kind !== "api") return W(404, { error: "framework-action endpoints are api-only" }, o);
857
- let c = `${V}/seeds/run`, l = `${V}/migrations/rollback`, u = `${V}/migrations/squash`, d = `${V}/migrations/restore-snapshot`;
857
+ if (t.kind !== "api") return U(404, { error: "framework-action endpoints are api-only" }, o);
858
+ let c = `${B}/seeds/run`, l = `${B}/migrations/rollback`, u = `${B}/migrations/squash`, d = `${B}/migrations/restore-snapshot`;
858
859
  if (a !== c && a !== l && a !== u && a !== d && a !== "/_voltro/inspect/migrations/compare-env") return null;
859
860
  let f;
860
861
  try {
861
862
  f = JSON.parse(r || "{}");
862
863
  } catch {
863
- return W(400, { error: "body must be JSON" }, o);
864
+ return U(400, { error: "body must be JSON" }, o);
864
865
  }
865
866
  try {
866
- if (a === c) return typeof f.id != "string" || f.id.length === 0 ? W(400, { error: "body.id must be a non-empty string" }, o) : t.runSeed ? W(200, await t.runSeed(f.id), o) : W(404, { error: "runSeed not configured" }, o);
867
- if (a === l) return typeof f.id != "string" || f.id.length === 0 ? W(400, { error: "body.id must be a non-empty string" }, o) : t.rollbackMigration ? W(200, await t.rollbackMigration(f.id), o) : W(404, { error: "rollbackMigration not configured" }, o);
867
+ if (a === c) return typeof f.id != "string" || f.id.length === 0 ? U(400, { error: "body.id must be a non-empty string" }, o) : t.runSeed ? U(200, await t.runSeed(f.id), o) : U(404, { error: "runSeed not configured" }, o);
868
+ if (a === l) return typeof f.id != "string" || f.id.length === 0 ? U(400, { error: "body.id must be a non-empty string" }, o) : t.rollbackMigration ? U(200, await t.rollbackMigration(f.id), o) : U(404, { error: "rollbackMigration not configured" }, o);
868
869
  if (a === u) {
869
- if (typeof f.before != "string" || f.before.length === 0) return W(400, { error: "body.before must be a non-empty ISO date string" }, o);
870
- if (!t.squashMigrationHistory) return W(404, { error: "squashMigrationHistory not configured" }, o);
870
+ if (typeof f.before != "string" || f.before.length === 0) return U(400, { error: "body.before must be a non-empty ISO date string" }, o);
871
+ if (!t.squashMigrationHistory) return U(404, { error: "squashMigrationHistory not configured" }, o);
871
872
  let e = typeof f.note == "string" ? f.note : void 0;
872
- return W(200, await t.squashMigrationHistory({
873
+ return U(200, await t.squashMigrationHistory({
873
874
  before: f.before,
874
875
  note: e
875
876
  }), o);
876
877
  }
877
- return a === d ? typeof f.planId != "string" || f.planId.length === 0 ? W(400, { error: "body.planId must be a non-empty string" }, o) : t.restoreSnapshot ? W(200, await t.restoreSnapshot({ planId: f.planId }), o) : W(404, { error: "restoreSnapshot not configured" }, o) : typeof f.url != "string" || f.url.length === 0 ? W(400, { error: "body.url must be a non-empty URL string" }, o) : t.compareCrossEnv ? (await t.compareCrossEnv({
878
+ return a === d ? typeof f.planId != "string" || f.planId.length === 0 ? U(400, { error: "body.planId must be a non-empty string" }, o) : t.restoreSnapshot ? U(200, await t.restoreSnapshot({ planId: f.planId }), o) : U(404, { error: "restoreSnapshot not configured" }, o) : typeof f.url != "string" || f.url.length === 0 ? U(400, { error: "body.url must be a non-empty URL string" }, o) : t.compareCrossEnv ? (await t.compareCrossEnv({
878
879
  url: f.url,
879
880
  label: typeof f.label == "string" ? f.label : void 0,
880
881
  token: typeof f.token == "string" ? f.token : void 0
881
- }), W(200, { ok: !0 }, o)) : W(404, { error: "compareCrossEnv not configured" }, o);
882
+ }), U(200, { ok: !0 }, o)) : U(404, { error: "compareCrossEnv not configured" }, o);
882
883
  } catch (e) {
883
- return W(500, {
884
+ return U(500, {
884
885
  error: "framework action failed",
885
886
  message: e?.message ?? String(e)
886
887
  }, o);
887
888
  }
888
- }, kt = async (e, t, n, r = {}) => {
889
- if (K(e) !== "/_voltro/inspect/data/rows") return null;
890
- let i = G(n.origin ?? n.Origin);
891
- if ((r.method ?? "GET").toUpperCase() !== "GET") return W(405, {
889
+ }, jt = async (e, t, n, r = {}) => {
890
+ if (G(e) !== "/_voltro/inspect/data/rows") return null;
891
+ let i = W(n.origin ?? n.Origin);
892
+ if ((r.method ?? "GET").toUpperCase() !== "GET") return U(405, {
892
893
  error: "method not allowed",
893
894
  expected: "GET"
894
895
  }, i);
895
- if (H()) return W(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, i);
896
- let a = (r.authResolver ?? U)(n);
897
- if (!a.ok) return W(401, {
896
+ if (V()) return U(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, i);
897
+ let a = (r.authResolver ?? H)(n);
898
+ if (!a.ok) return U(401, {
898
899
  error: "unauthorized",
899
900
  reason: a.reason
900
901
  }, i);
901
- if (t.kind !== "api") return W(404, { error: "data viewer is api-only" }, i);
902
- if (t.inspectRows === void 0) return W(404, { error: "inspectRows not configured" }, i);
903
- let o = q(e), s = o.get("table");
904
- if (!s) return W(400, { error: "query.table is required" }, i);
905
- let c = J(o.get("offset")) ?? 0, l = J(o.get("limit")) ?? 50, u = {}, d = o.get("q");
902
+ if (t.kind !== "api") return U(404, { error: "data viewer is api-only" }, i);
903
+ if (t.inspectRows === void 0) return U(404, { error: "inspectRows not configured" }, i);
904
+ let o = K(e), s = o.get("table");
905
+ if (!s) return U(400, { error: "query.table is required" }, i);
906
+ let c = q(o.get("offset")) ?? 0, l = q(o.get("limit")) ?? 50, u = {}, d = o.get("q");
906
907
  if (d) {
907
- if (d.length > 8192) return W(400, { error: "query.q too large" }, i);
908
+ if (d.length > 8192) return U(400, { error: "query.q too large" }, i);
908
909
  try {
909
910
  u = JSON.parse(Buffer.from(d, "base64url").toString("utf8"));
910
911
  } catch {
911
- return W(400, { error: "query.q is not valid base64url JSON" }, i);
912
+ return U(400, { error: "query.q is not valid base64url JSON" }, i);
912
913
  }
913
914
  }
914
915
  try {
915
- return W(200, await t.inspectRows({
916
+ return U(200, await t.inspectRows({
916
917
  table: s,
917
918
  offset: c,
918
919
  limit: l,
919
920
  ...u
920
921
  }), i);
921
922
  } catch (e) {
922
- return e?.name === "InspectQueryError" ? W(400, {
923
+ return e?.name === "InspectQueryError" ? U(400, {
923
924
  error: "invalid query",
924
925
  message: e.message
925
- }, i) : W(500, {
926
+ }, i) : U(500, {
926
927
  error: "data-rows query failed",
927
928
  message: e?.message ?? String(e)
928
929
  }, i);
929
930
  }
930
- }, At = async (e, t, n, r = {}) => {
931
- if (K(e) !== "/_voltro/inspect/provenance") return null;
932
- let i = G(n.origin ?? n.Origin);
933
- if ((r.method ?? "GET").toUpperCase() !== "GET") return W(405, {
931
+ }, Mt = async (e, t, n, r = {}) => {
932
+ if (G(e) !== "/_voltro/inspect/provenance") return null;
933
+ let i = W(n.origin ?? n.Origin);
934
+ if ((r.method ?? "GET").toUpperCase() !== "GET") return U(405, {
934
935
  error: "method not allowed",
935
936
  expected: "GET"
936
937
  }, i);
937
- if (H()) return W(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, i);
938
- let a = (r.authResolver ?? U)(n);
939
- if (!a.ok) return W(401, {
938
+ if (V()) return U(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, i);
939
+ let a = (r.authResolver ?? H)(n);
940
+ if (!a.ok) return U(401, {
940
941
  error: "unauthorized",
941
942
  reason: a.reason
942
943
  }, i);
943
- if (t.kind !== "api") return W(404, { error: "provenance is api-only" }, i);
944
- if (t.inspectRows === void 0) return W(404, { error: "inspectRows not configured" }, i);
945
- let o = q(e), s = o.get("table"), c = o.get("id"), l = o.get("column") ?? void 0;
946
- if (!s || !c) return W(400, { error: "query.table and query.id are required" }, i);
944
+ if (t.kind !== "api") return U(404, { error: "provenance is api-only" }, i);
945
+ if (t.inspectRows === void 0) return U(404, { error: "inspectRows not configured" }, i);
946
+ let o = K(e), s = o.get("table"), c = o.get("id"), l = o.get("column") ?? void 0;
947
+ if (!s || !c) return U(400, { error: "query.table and query.id are required" }, i);
947
948
  try {
948
949
  let e = (await t.inspectRows({
949
950
  table: s,
@@ -955,175 +956,175 @@ __installPublicEnv(publicEnvValues)
955
956
  value: c
956
957
  }
957
958
  })).rows[0];
958
- return W(200, ne(e, {
959
+ return U(200, te(e, {
959
960
  table: s,
960
961
  id: c,
961
962
  ...l === void 0 ? {} : { column: l }
962
963
  }), i);
963
964
  } catch (e) {
964
- return e?.name === "InspectQueryError" ? W(400, {
965
+ return e?.name === "InspectQueryError" ? U(400, {
965
966
  error: "invalid query",
966
967
  message: e.message
967
- }, i) : W(500, {
968
+ }, i) : U(500, {
968
969
  error: "provenance query failed",
969
970
  message: e?.message ?? String(e)
970
971
  }, i);
971
972
  }
972
- }, q = (e) => {
973
+ }, K = (e) => {
973
974
  let t = e.indexOf("?");
974
975
  return t < 0 ? new URLSearchParams() : new URLSearchParams(e.slice(t + 1));
975
- }, J = (e) => {
976
+ }, q = (e) => {
976
977
  if (e === null || e === "") return;
977
978
  let t = Number(e);
978
979
  return Number.isFinite(t) && t >= 0 ? Math.floor(t) : void 0;
979
- }, jt = async (e, t, n, r = {}) => {
980
- if (K(e) !== "/_voltro/inspect/workflows/runs") return null;
981
- let i = G(n.origin ?? n.Origin);
982
- if ((r.method ?? "GET").toUpperCase() !== "GET") return W(405, {
980
+ }, Nt = async (e, t, n, r = {}) => {
981
+ if (G(e) !== "/_voltro/inspect/workflows/runs") return null;
982
+ let i = W(n.origin ?? n.Origin);
983
+ if ((r.method ?? "GET").toUpperCase() !== "GET") return U(405, {
983
984
  error: "method not allowed",
984
985
  expected: "GET"
985
986
  }, i);
986
- if (H()) return W(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, i);
987
- let a = (r.authResolver ?? U)(n);
988
- if (!a.ok) return W(401, {
987
+ if (V()) return U(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, i);
988
+ let a = (r.authResolver ?? H)(n);
989
+ if (!a.ok) return U(401, {
989
990
  error: "unauthorized",
990
991
  reason: a.reason
991
992
  }, i);
992
- if (t.kind !== "api") return W(404, { error: "workflows endpoint is api-only" }, i);
993
- if (t.inspectWorkflowRuns === void 0) return W(200, {
993
+ if (t.kind !== "api") return U(404, { error: "workflows endpoint is api-only" }, i);
994
+ if (t.inspectWorkflowRuns === void 0) return U(200, {
994
995
  runs: [],
995
996
  total: 0,
996
997
  offset: 0,
997
998
  limit: 50
998
999
  }, i);
999
- let o = q(e);
1000
+ let o = K(e);
1000
1001
  try {
1001
- return W(200, await t.inspectWorkflowRuns({
1002
+ return U(200, await t.inspectWorkflowRuns({
1002
1003
  ...o.get("tag") === null ? {} : { tag: o.get("tag") },
1003
1004
  ...o.get("status") === null ? {} : { status: o.get("status") },
1004
- offset: J(o.get("offset")) ?? 0,
1005
- limit: J(o.get("limit")) ?? 50
1005
+ offset: q(o.get("offset")) ?? 0,
1006
+ limit: q(o.get("limit")) ?? 50
1006
1007
  }), i);
1007
1008
  } catch (e) {
1008
- return W(500, {
1009
+ return U(500, {
1009
1010
  error: "workflow-runs query failed",
1010
1011
  message: e?.message ?? String(e)
1011
1012
  }, i);
1012
1013
  }
1013
- }, Mt = async (e, t, n, r, i = {}) => {
1014
- let a = K(e).match(/^\/_voltro\/inspect\/workflows\/start\/([^/]+)$/);
1014
+ }, Pt = async (e, t, n, r, i = {}) => {
1015
+ let a = G(e).match(/^\/_voltro\/inspect\/workflows\/start\/([^/]+)$/);
1015
1016
  if (!a) return null;
1016
- let o = decodeURIComponent(a[1] ?? ""), s = G(n.origin ?? n.Origin);
1017
- if ((i.method ?? "POST").toUpperCase() !== "POST") return W(405, {
1017
+ let o = decodeURIComponent(a[1] ?? ""), s = W(n.origin ?? n.Origin);
1018
+ if ((i.method ?? "POST").toUpperCase() !== "POST") return U(405, {
1018
1019
  error: "method not allowed",
1019
1020
  expected: "POST"
1020
1021
  }, s);
1021
- if (H()) return W(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, s);
1022
- let c = (i.authResolver ?? U)(n);
1023
- if (!c.ok) return W(401, {
1022
+ if (V()) return U(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, s);
1023
+ let c = (i.authResolver ?? H)(n);
1024
+ if (!c.ok) return U(401, {
1024
1025
  error: "unauthorized",
1025
1026
  reason: c.reason
1026
1027
  }, s);
1027
- if (t.kind !== "api") return W(404, { error: "workflow start is api-only" }, s);
1028
- if (t.inspectStartWorkflow === void 0) return W(404, { error: "inspectStartWorkflow not configured" }, s);
1028
+ if (t.kind !== "api") return U(404, { error: "workflow start is api-only" }, s);
1029
+ if (t.inspectStartWorkflow === void 0) return U(404, { error: "inspectStartWorkflow not configured" }, s);
1029
1030
  let l = {};
1030
1031
  if (r.length > 0) try {
1031
1032
  l = JSON.parse(r).payload ?? {};
1032
1033
  } catch {
1033
- return W(400, { error: "start requires JSON body `{ payload?: unknown }`" }, s);
1034
+ return U(400, { error: "start requires JSON body `{ payload?: unknown }`" }, s);
1034
1035
  }
1035
1036
  try {
1036
- return W(200, await t.inspectStartWorkflow({
1037
+ return U(200, await t.inspectStartWorkflow({
1037
1038
  name: o,
1038
1039
  payload: l
1039
1040
  }), s);
1040
1041
  } catch (e) {
1041
- return W(500, {
1042
+ return U(500, {
1042
1043
  error: "workflow start failed",
1043
1044
  message: e?.message ?? String(e)
1044
1045
  }, s);
1045
1046
  }
1046
- }, Nt = async (e, t, n, r = {}) => {
1047
- let i = K(e);
1047
+ }, Ft = async (e, t, n, r = {}) => {
1048
+ let i = G(e);
1048
1049
  if (!i.startsWith("/_voltro/inspect/schedules")) return null;
1049
- let a = G(n.origin ?? n.Origin);
1050
- if (H()) return W(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, a);
1051
- let o = (r.authResolver ?? U)(n);
1052
- if (!o.ok) return W(401, {
1050
+ let a = W(n.origin ?? n.Origin);
1051
+ if (V()) return U(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, a);
1052
+ let o = (r.authResolver ?? H)(n);
1053
+ if (!o.ok) return U(401, {
1053
1054
  error: "unauthorized",
1054
1055
  reason: o.reason
1055
1056
  }, a);
1056
- if (t.kind !== "api") return W(404, { error: "schedules are api-only" }, a);
1057
+ if (t.kind !== "api") return U(404, { error: "schedules are api-only" }, a);
1057
1058
  let s = (r.method ?? "GET").toUpperCase(), c = i.match(/^\/_voltro\/inspect\/schedules\/([^/]+)\/fire$/);
1058
1059
  if (c) {
1059
- if (s !== "POST") return W(405, {
1060
+ if (s !== "POST") return U(405, {
1060
1061
  error: "method not allowed",
1061
1062
  expected: "POST"
1062
1063
  }, a);
1063
- if (!t.inspectFireSchedule) return W(404, { error: "inspectFireSchedule not configured" }, a);
1064
- let n = decodeURIComponent(c[1] ?? ""), r = q(e).get("trigger") === "external" ? "external" : "manual";
1064
+ if (!t.inspectFireSchedule) return U(404, { error: "inspectFireSchedule not configured" }, a);
1065
+ let n = decodeURIComponent(c[1] ?? ""), r = K(e).get("trigger") === "external" ? "external" : "manual";
1065
1066
  try {
1066
- return W(200, await t.inspectFireSchedule({
1067
+ return U(200, await t.inspectFireSchedule({
1067
1068
  name: n,
1068
1069
  trigger: r
1069
1070
  }), a);
1070
1071
  } catch (e) {
1071
- return W(500, {
1072
+ return U(500, {
1072
1073
  error: "fire failed",
1073
1074
  message: e?.message ?? String(e)
1074
1075
  }, a);
1075
1076
  }
1076
1077
  }
1077
1078
  if (i === "/_voltro/inspect/schedules/runs") {
1078
- if (s !== "GET") return W(405, {
1079
+ if (s !== "GET") return U(405, {
1079
1080
  error: "method not allowed",
1080
1081
  expected: "GET"
1081
1082
  }, a);
1082
- if (!t.inspectScheduleRuns) return W(200, {
1083
+ if (!t.inspectScheduleRuns) return U(200, {
1083
1084
  runs: [],
1084
1085
  total: 0,
1085
1086
  offset: 0,
1086
1087
  limit: 50
1087
1088
  }, a);
1088
- let n = q(e);
1089
+ let n = K(e);
1089
1090
  try {
1090
- return W(200, await t.inspectScheduleRuns({
1091
+ return U(200, await t.inspectScheduleRuns({
1091
1092
  ...n.get("name") === null ? {} : { name: n.get("name") },
1092
- offset: J(n.get("offset")) ?? 0,
1093
- limit: J(n.get("limit")) ?? 50
1093
+ offset: q(n.get("offset")) ?? 0,
1094
+ limit: q(n.get("limit")) ?? 50
1094
1095
  }), a);
1095
1096
  } catch (e) {
1096
- return W(500, {
1097
+ return U(500, {
1097
1098
  error: "schedule-runs query failed",
1098
1099
  message: e?.message ?? String(e)
1099
1100
  }, a);
1100
1101
  }
1101
1102
  }
1102
- return i === "/_voltro/inspect/schedules" ? s === "GET" ? t.inspectSchedules ? W(200, t.inspectSchedules(), a) : W(200, {
1103
+ return i === "/_voltro/inspect/schedules" ? s === "GET" ? t.inspectSchedules ? U(200, t.inspectSchedules(), a) : U(200, {
1103
1104
  schedules: [],
1104
1105
  coordination: "single"
1105
- }, a) : W(405, {
1106
+ }, a) : U(405, {
1106
1107
  error: "method not allowed",
1107
1108
  expected: "GET"
1108
- }, a) : W(404, {
1109
+ }, a) : U(404, {
1109
1110
  error: "unknown schedules endpoint",
1110
1111
  path: i
1111
1112
  }, a);
1112
- }, Pt = async (e, t, n, r = {}) => {
1113
- if (K(e) !== "/_voltro/inspect/cluster") return null;
1114
- let i = G(n.origin ?? n.Origin);
1115
- if (H()) return W(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, i);
1116
- let a = (r.authResolver ?? U)(n);
1117
- if (!a.ok) return W(401, {
1113
+ }, It = async (e, t, n, r = {}) => {
1114
+ if (G(e) !== "/_voltro/inspect/cluster") return null;
1115
+ let i = W(n.origin ?? n.Origin);
1116
+ if (V()) return U(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, i);
1117
+ let a = (r.authResolver ?? H)(n);
1118
+ if (!a.ok) return U(401, {
1118
1119
  error: "unauthorized",
1119
1120
  reason: a.reason
1120
1121
  }, i);
1121
- if (t.kind !== "api") return W(404, { error: "cluster is api-only" }, i);
1122
- if ((r.method ?? "GET").toUpperCase() !== "GET") return W(405, {
1122
+ if (t.kind !== "api") return U(404, { error: "cluster is api-only" }, i);
1123
+ if ((r.method ?? "GET").toUpperCase() !== "GET") return U(405, {
1123
1124
  error: "method not allowed",
1124
1125
  expected: "GET"
1125
1126
  }, i);
1126
- if (!t.cluster) return W(200, {
1127
+ if (!t.cluster) return U(200, {
1127
1128
  instance: {
1128
1129
  replicaId: process.env.POD_NAME ?? process.env.HOSTNAME ?? `dev-${process.pid}`,
1129
1130
  dialect: "memory",
@@ -1148,163 +1149,163 @@ __installPublicEnv(publicEnvValues)
1148
1149
  capturedAt: Date.now()
1149
1150
  }, i);
1150
1151
  try {
1151
- return W(200, await t.cluster(), i);
1152
+ return U(200, await t.cluster(), i);
1152
1153
  } catch (e) {
1153
- return W(500, {
1154
+ return U(500, {
1154
1155
  error: "cluster snapshot failed",
1155
1156
  message: e?.message ?? String(e)
1156
1157
  }, i);
1157
1158
  }
1158
- }, Ft = async (e, t, n, r = {}) => {
1159
- let i = K(e).match(/^\/_voltro\/inspect\/workflows\/runs\/([^/]+)\/steps$/);
1159
+ }, Lt = async (e, t, n, r = {}) => {
1160
+ let i = G(e).match(/^\/_voltro\/inspect\/workflows\/runs\/([^/]+)\/steps$/);
1160
1161
  if (!i) return null;
1161
- let a = decodeURIComponent(i[1] ?? ""), o = G(n.origin ?? n.Origin);
1162
- if ((r.method ?? "GET").toUpperCase() !== "GET") return W(405, {
1162
+ let a = decodeURIComponent(i[1] ?? ""), o = W(n.origin ?? n.Origin);
1163
+ if ((r.method ?? "GET").toUpperCase() !== "GET") return U(405, {
1163
1164
  error: "method not allowed",
1164
1165
  expected: "GET"
1165
1166
  }, o);
1166
- if (H()) return W(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, o);
1167
- let s = (r.authResolver ?? U)(n);
1168
- if (!s.ok) return W(401, {
1167
+ if (V()) return U(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, o);
1168
+ let s = (r.authResolver ?? H)(n);
1169
+ if (!s.ok) return U(401, {
1169
1170
  error: "unauthorized",
1170
1171
  reason: s.reason
1171
1172
  }, o);
1172
- if (t.kind !== "api") return W(404, { error: "workflow steps are api-only" }, o);
1173
- if (t.inspectWorkflowRunSteps === void 0) return W(200, { steps: [] }, o);
1173
+ if (t.kind !== "api") return U(404, { error: "workflow steps are api-only" }, o);
1174
+ if (t.inspectWorkflowRunSteps === void 0) return U(200, { steps: [] }, o);
1174
1175
  try {
1175
- return W(200, await t.inspectWorkflowRunSteps({ runId: a }), o);
1176
+ return U(200, await t.inspectWorkflowRunSteps({ runId: a }), o);
1176
1177
  } catch (e) {
1177
- return W(500, {
1178
+ return U(500, {
1178
1179
  error: "steps query failed",
1179
1180
  message: e?.message ?? String(e)
1180
1181
  }, o);
1181
1182
  }
1182
- }, It = async (e, t, n, r = {}) => {
1183
- let i = K(e).match(/^\/_voltro\/inspect\/workflows\/runs\/([^/]+)\/events$/);
1183
+ }, Rt = async (e, t, n, r = {}) => {
1184
+ let i = G(e).match(/^\/_voltro\/inspect\/workflows\/runs\/([^/]+)\/events$/);
1184
1185
  if (!i) return null;
1185
- let a = decodeURIComponent(i[1] ?? ""), o = G(n.origin ?? n.Origin);
1186
- if ((r.method ?? "GET").toUpperCase() !== "GET") return W(405, {
1186
+ let a = decodeURIComponent(i[1] ?? ""), o = W(n.origin ?? n.Origin);
1187
+ if ((r.method ?? "GET").toUpperCase() !== "GET") return U(405, {
1187
1188
  error: "method not allowed",
1188
1189
  expected: "GET"
1189
1190
  }, o);
1190
- if (H()) return W(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, o);
1191
- let s = (r.authResolver ?? U)(n);
1192
- if (!s.ok) return W(401, {
1191
+ if (V()) return U(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, o);
1192
+ let s = (r.authResolver ?? H)(n);
1193
+ if (!s.ok) return U(401, {
1193
1194
  error: "unauthorized",
1194
1195
  reason: s.reason
1195
1196
  }, o);
1196
- if (t.kind !== "api") return W(404, { error: "workflow events are api-only" }, o);
1197
- if (t.inspectWorkflowRunEvents === void 0) return W(200, { events: [] }, o);
1197
+ if (t.kind !== "api") return U(404, { error: "workflow events are api-only" }, o);
1198
+ if (t.inspectWorkflowRunEvents === void 0) return U(200, { events: [] }, o);
1198
1199
  try {
1199
- return W(200, await t.inspectWorkflowRunEvents({ runId: a }), o);
1200
+ return U(200, await t.inspectWorkflowRunEvents({ runId: a }), o);
1200
1201
  } catch (e) {
1201
- return W(500, {
1202
+ return U(500, {
1202
1203
  error: "events query failed",
1203
1204
  message: e?.message ?? String(e)
1204
1205
  }, o);
1205
1206
  }
1206
- }, Lt = async (e, t, n, r = {}) => {
1207
- if (K(t) !== "/_voltro/inspect/workflows/events") return null;
1208
- let i = G(n.origin ?? n.Origin);
1209
- if ((r.method ?? "GET").toUpperCase() !== "GET") return W(405, {
1207
+ }, zt = async (e, t, n, r = {}) => {
1208
+ if (G(t) !== "/_voltro/inspect/workflows/events") return null;
1209
+ let i = W(n.origin ?? n.Origin);
1210
+ if ((r.method ?? "GET").toUpperCase() !== "GET") return U(405, {
1210
1211
  error: "method not allowed",
1211
1212
  expected: "GET"
1212
1213
  }, i);
1213
- if (H()) return W(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, i);
1214
- let a = (r.authResolver ?? U)(n);
1215
- if (!a.ok) return W(401, {
1214
+ if (V()) return U(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, i);
1215
+ let a = (r.authResolver ?? H)(n);
1216
+ if (!a.ok) return U(401, {
1216
1217
  error: "unauthorized",
1217
1218
  reason: a.reason
1218
1219
  }, i);
1219
- if (e.kind !== "api") return W(404, { error: "workflow domain events are api-only" }, i);
1220
- if (e.inspectWorkflowDomainEvents === void 0) return W(200, {
1220
+ if (e.kind !== "api") return U(404, { error: "workflow domain events are api-only" }, i);
1221
+ if (e.inspectWorkflowDomainEvents === void 0) return U(200, {
1221
1222
  events: [],
1222
1223
  total: 0,
1223
1224
  offset: 0,
1224
1225
  limit: 100
1225
1226
  }, i);
1226
- let o = xt(t), s = o.get("name") ?? void 0, c = Number(o.get("offset") ?? "0"), l = Number(o.get("limit") ?? "100");
1227
+ let o = Ct(t), s = o.get("name") ?? void 0, c = Number(o.get("offset") ?? "0"), l = Number(o.get("limit") ?? "100");
1227
1228
  try {
1228
- return W(200, await e.inspectWorkflowDomainEvents({
1229
+ return U(200, await e.inspectWorkflowDomainEvents({
1229
1230
  ...s !== void 0 && s !== "" ? { name: s } : {},
1230
1231
  offset: Number.isFinite(c) ? c : 0,
1231
1232
  limit: Number.isFinite(l) ? l : 100
1232
1233
  }), i);
1233
1234
  } catch (e) {
1234
- return W(500, {
1235
+ return U(500, {
1235
1236
  error: "workflow domain events query failed",
1236
1237
  message: e?.message ?? String(e)
1237
1238
  }, i);
1238
1239
  }
1239
- }, Rt = async (e, t, n, r = {}) => {
1240
- let i = K(t).match(/^\/_voltro\/inspect\/workflows\/events\/([^/]+)\/deliveries$/);
1240
+ }, Bt = async (e, t, n, r = {}) => {
1241
+ let i = G(t).match(/^\/_voltro\/inspect\/workflows\/events\/([^/]+)\/deliveries$/);
1241
1242
  if (!i) return null;
1242
- let a = decodeURIComponent(i[1] ?? ""), o = G(n.origin ?? n.Origin);
1243
- if ((r.method ?? "GET").toUpperCase() !== "GET") return W(405, {
1243
+ let a = decodeURIComponent(i[1] ?? ""), o = W(n.origin ?? n.Origin);
1244
+ if ((r.method ?? "GET").toUpperCase() !== "GET") return U(405, {
1244
1245
  error: "method not allowed",
1245
1246
  expected: "GET"
1246
1247
  }, o);
1247
- if (H()) return W(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, o);
1248
- let s = (r.authResolver ?? U)(n);
1249
- if (!s.ok) return W(401, {
1248
+ if (V()) return U(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, o);
1249
+ let s = (r.authResolver ?? H)(n);
1250
+ if (!s.ok) return U(401, {
1250
1251
  error: "unauthorized",
1251
1252
  reason: s.reason
1252
1253
  }, o);
1253
- if (e.kind !== "api") return W(404, { error: "workflow event deliveries are api-only" }, o);
1254
- if (e.inspectWorkflowEventDeliveries === void 0) return W(200, { deliveries: [] }, o);
1254
+ if (e.kind !== "api") return U(404, { error: "workflow event deliveries are api-only" }, o);
1255
+ if (e.inspectWorkflowEventDeliveries === void 0) return U(200, { deliveries: [] }, o);
1255
1256
  try {
1256
- return W(200, await e.inspectWorkflowEventDeliveries({ eventId: a }), o);
1257
+ return U(200, await e.inspectWorkflowEventDeliveries({ eventId: a }), o);
1257
1258
  } catch (e) {
1258
- return W(500, {
1259
+ return U(500, {
1259
1260
  error: "workflow event deliveries query failed",
1260
1261
  message: e?.message ?? String(e)
1261
1262
  }, o);
1262
1263
  }
1263
- }, zt = async (e, t, n, r = {}) => {
1264
- if (K(e) !== "/_voltro/inspect/workflows/children") return null;
1265
- let i = G(n.origin ?? n.Origin);
1266
- if ((r.method ?? "GET").toUpperCase() !== "GET") return W(405, {
1264
+ }, Vt = async (e, t, n, r = {}) => {
1265
+ if (G(e) !== "/_voltro/inspect/workflows/children") return null;
1266
+ let i = W(n.origin ?? n.Origin);
1267
+ if ((r.method ?? "GET").toUpperCase() !== "GET") return U(405, {
1267
1268
  error: "method not allowed",
1268
1269
  expected: "GET"
1269
1270
  }, i);
1270
- if (H()) return W(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, i);
1271
- let a = (r.authResolver ?? U)(n);
1272
- if (!a.ok) return W(401, {
1271
+ if (V()) return U(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, i);
1272
+ let a = (r.authResolver ?? H)(n);
1273
+ if (!a.ok) return U(401, {
1273
1274
  error: "unauthorized",
1274
1275
  reason: a.reason
1275
1276
  }, i);
1276
- if (t.kind !== "api") return W(404, { error: "workflow children are api-only" }, i);
1277
- let o = q(e).get("parentExecutionId");
1278
- if (o === null || o === "") return W(400, { error: "parentExecutionId query param required" }, i);
1279
- if (t.inspectWorkflowChildren === void 0) return W(200, {
1277
+ if (t.kind !== "api") return U(404, { error: "workflow children are api-only" }, i);
1278
+ let o = K(e).get("parentExecutionId");
1279
+ if (o === null || o === "") return U(400, { error: "parentExecutionId query param required" }, i);
1280
+ if (t.inspectWorkflowChildren === void 0) return U(200, {
1280
1281
  runs: [],
1281
1282
  total: 0,
1282
1283
  offset: 0,
1283
1284
  limit: 200
1284
1285
  }, i);
1285
1286
  try {
1286
- return W(200, await t.inspectWorkflowChildren({ parentExecutionId: o }), i);
1287
+ return U(200, await t.inspectWorkflowChildren({ parentExecutionId: o }), i);
1287
1288
  } catch (e) {
1288
- return W(500, {
1289
+ return U(500, {
1289
1290
  error: "children query failed",
1290
1291
  message: e?.message ?? String(e)
1291
1292
  }, i);
1292
1293
  }
1293
- }, Bt = async (e, t, n, r, i = {}) => {
1294
- let a = K(e).match(/^\/_voltro\/inspect\/workflows\/runs\/([^/]+)\/(cancel|retry|suspend|resume|signal|update)$/);
1294
+ }, Ht = async (e, t, n, r, i = {}) => {
1295
+ let a = G(e).match(/^\/_voltro\/inspect\/workflows\/runs\/([^/]+)\/(cancel|retry|suspend|resume|signal|update)$/);
1295
1296
  if (!a) return null;
1296
- let o = decodeURIComponent(a[1] ?? ""), s = a[2], c = G(n.origin ?? n.Origin);
1297
- if ((i.method ?? "POST").toUpperCase() !== "POST") return W(405, {
1297
+ let o = decodeURIComponent(a[1] ?? ""), s = a[2], c = W(n.origin ?? n.Origin);
1298
+ if ((i.method ?? "POST").toUpperCase() !== "POST") return U(405, {
1298
1299
  error: "method not allowed",
1299
1300
  expected: "POST"
1300
1301
  }, c);
1301
- if (H()) return W(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, c);
1302
- let l = (i.authResolver ?? U)(n);
1303
- if (!l.ok) return W(401, {
1302
+ if (V()) return U(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, c);
1303
+ let l = (i.authResolver ?? H)(n);
1304
+ if (!l.ok) return U(401, {
1304
1305
  error: "unauthorized",
1305
1306
  reason: l.reason
1306
1307
  }, c);
1307
- if (t.kind !== "api") return W(404, { error: "workflow actions are api-only" }, c);
1308
+ if (t.kind !== "api") return U(404, { error: "workflow actions are api-only" }, c);
1308
1309
  let u = {
1309
1310
  cancel: t.inspectCancelWorkflowRun,
1310
1311
  retry: t.inspectRetryWorkflowRun,
@@ -1313,16 +1314,16 @@ __installPublicEnv(publicEnvValues)
1313
1314
  signal: t.inspectSignalWorkflowRun,
1314
1315
  update: t.inspectUpdateWorkflowRun
1315
1316
  }[s];
1316
- if (!u) return W(404, { error: `inspect${s[0]?.toUpperCase() ?? ""}${s.slice(1)}WorkflowRun not configured` }, c);
1317
+ if (!u) return U(404, { error: `inspect${s[0]?.toUpperCase() ?? ""}${s.slice(1)}WorkflowRun not configured` }, c);
1317
1318
  let d, f, p, m, h, g;
1318
1319
  if (r.length > 0) try {
1319
1320
  let e = JSON.parse(r);
1320
1321
  s === "retry" && (d = e.payloadOverride), s === "signal" && (typeof e.signalName == "string" && e.signalName.length > 0 && (f = e.signalName), p = e.payload), s === "update" && (typeof e.updateName == "string" && e.updateName.length > 0 && (m = e.updateName), h = e.payload, typeof e.timeoutMs == "number" && Number.isFinite(e.timeoutMs) && (g = e.timeoutMs));
1321
1322
  } catch {}
1322
- if (s === "signal" && f === void 0) return W(400, { error: "signal requires JSON body `{ signalName: string, payload?: unknown }`" }, c);
1323
- if (s === "update" && m === void 0) return W(400, { error: "update requires JSON body `{ updateName: string, payload?: unknown, timeoutMs?: number }`" }, c);
1323
+ if (s === "signal" && f === void 0) return U(400, { error: "signal requires JSON body `{ signalName: string, payload?: unknown }`" }, c);
1324
+ if (s === "update" && m === void 0) return U(400, { error: "update requires JSON body `{ updateName: string, payload?: unknown, timeoutMs?: number }`" }, c);
1324
1325
  try {
1325
- return W(200, s === "retry" && d !== void 0 ? await u({
1326
+ return U(200, s === "retry" && d !== void 0 ? await u({
1326
1327
  runId: o,
1327
1328
  payloadOverride: d
1328
1329
  }) : s === "signal" ? await u({
@@ -1336,71 +1337,71 @@ __installPublicEnv(publicEnvValues)
1336
1337
  ...g === void 0 ? {} : { timeoutMs: g }
1337
1338
  }) : await u({ runId: o }), c);
1338
1339
  } catch (e) {
1339
- return W(500, {
1340
+ return U(500, {
1340
1341
  error: `${s} failed`,
1341
1342
  message: e?.message ?? String(e)
1342
1343
  }, c);
1343
1344
  }
1344
- }, Vt = async (e, t, n, r, i = {}) => {
1345
- if (K(e) !== "/_voltro/inspect/data/import" || (i.method ?? "POST").toUpperCase() !== "POST") return null;
1346
- let a = G(n.origin ?? n.Origin);
1347
- if (H()) return W(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, a);
1348
- let o = (i.authResolver ?? U)(n);
1349
- if (!o.ok) return W(401, {
1345
+ }, Ut = async (e, t, n, r, i = {}) => {
1346
+ if (G(e) !== "/_voltro/inspect/data/import" || (i.method ?? "POST").toUpperCase() !== "POST") return null;
1347
+ let a = W(n.origin ?? n.Origin);
1348
+ if (V()) return U(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, a);
1349
+ let o = (i.authResolver ?? H)(n);
1350
+ if (!o.ok) return U(401, {
1350
1351
  error: "unauthorized",
1351
1352
  reason: o.reason
1352
1353
  }, a);
1353
- if (t.kind !== "api") return W(404, { error: "data import is api-only" }, a);
1354
- if (!t.inspectImport) return W(404, { error: "inspectImport not configured" }, a);
1354
+ if (t.kind !== "api") return U(404, { error: "data import is api-only" }, a);
1355
+ if (!t.inspectImport) return U(404, { error: "inspectImport not configured" }, a);
1355
1356
  let s;
1356
1357
  try {
1357
1358
  s = JSON.parse(r || "{}");
1358
1359
  } catch {
1359
- return W(400, { error: "body must be JSON" }, a);
1360
+ return U(400, { error: "body must be JSON" }, a);
1360
1361
  }
1361
- if (typeof s.bundleDir != "string" || !s.bundleDir) return W(400, { error: "body.bundleDir (string) is required" }, a);
1362
+ if (typeof s.bundleDir != "string" || !s.bundleDir) return U(400, { error: "body.bundleDir (string) is required" }, a);
1362
1363
  try {
1363
- return W(200, await t.inspectImport({
1364
+ return U(200, await t.inspectImport({
1364
1365
  bundleDir: s.bundleDir,
1365
1366
  ...s.mode === "upsert" || s.mode === "append" || s.mode === "replace" ? { mode: s.mode } : {},
1366
1367
  ...s.onConflict === "skip" || s.onConflict === "fail" ? { onConflict: s.onConflict } : {},
1367
1368
  ...typeof s.atomic == "boolean" ? { atomic: s.atomic } : {}
1368
1369
  }), a);
1369
1370
  } catch (e) {
1370
- return W(500, {
1371
+ return U(500, {
1371
1372
  error: "import failed",
1372
1373
  message: e?.message ?? String(e)
1373
1374
  }, a);
1374
1375
  }
1375
- }, Ht = async (e, t, n, r, i = {}) => {
1376
- let a = K(e);
1376
+ }, Wt = async (e, t, n, r, i = {}) => {
1377
+ let a = G(e);
1377
1378
  if (!a.startsWith("/_voltro/inspect/data/rows")) return null;
1378
1379
  let o = (i.method ?? "POST").toUpperCase();
1379
1380
  if (o === "GET" && a === "/_voltro/inspect/data/rows") return null;
1380
- let s = G(n.origin ?? n.Origin);
1381
- if (H()) return W(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, s);
1382
- let c = (i.authResolver ?? U)(n);
1383
- if (!c.ok) return W(401, {
1381
+ let s = W(n.origin ?? n.Origin);
1382
+ if (V()) return U(503, { error: "inspect disabled (VOLTRO_INSPECT=off)" }, s);
1383
+ let c = (i.authResolver ?? H)(n);
1384
+ if (!c.ok) return U(401, {
1384
1385
  error: "unauthorized",
1385
1386
  reason: c.reason
1386
1387
  }, s);
1387
- if (t.kind !== "api") return W(404, { error: "data viewer is api-only" }, s);
1388
+ if (t.kind !== "api") return U(404, { error: "data viewer is api-only" }, s);
1388
1389
  if (o === "POST" && a === "/_voltro/inspect/data/rows") {
1389
- if (!t.inspectInsertRow) return W(404, { error: "inspectInsertRow not configured" }, s);
1390
+ if (!t.inspectInsertRow) return U(404, { error: "inspectInsertRow not configured" }, s);
1390
1391
  let e;
1391
1392
  try {
1392
1393
  e = JSON.parse(r || "{}");
1393
1394
  } catch {
1394
- return W(400, { error: "body must be JSON" }, s);
1395
+ return U(400, { error: "body must be JSON" }, s);
1395
1396
  }
1396
- if (typeof e.table != "string" || !e.row || typeof e.row != "object") return W(400, { error: "body must be { table: string, row: object }" }, s);
1397
+ if (typeof e.table != "string" || !e.row || typeof e.row != "object") return U(400, { error: "body must be { table: string, row: object }" }, s);
1397
1398
  try {
1398
- return W(200, await t.inspectInsertRow({
1399
+ return U(200, await t.inspectInsertRow({
1399
1400
  table: e.table,
1400
1401
  row: e.row
1401
1402
  }), s);
1402
1403
  } catch (e) {
1403
- return W(500, {
1404
+ return U(500, {
1404
1405
  error: "insert failed",
1405
1406
  message: e?.message ?? String(e)
1406
1407
  }, s);
@@ -1409,50 +1410,50 @@ __installPublicEnv(publicEnvValues)
1409
1410
  let l = a.match(/^\/_voltro\/inspect\/data\/rows\/([^/]+)$/);
1410
1411
  if (!l) return null;
1411
1412
  let u = decodeURIComponent(l[1] ?? "");
1412
- if (!u) return W(400, { error: "row id is required in URL" }, s);
1413
- let d = q(e).get("table") ?? "";
1414
- if (!d) return W(400, { error: "query.table is required" }, s);
1413
+ if (!u) return U(400, { error: "row id is required in URL" }, s);
1414
+ let d = K(e).get("table") ?? "";
1415
+ if (!d) return U(400, { error: "query.table is required" }, s);
1415
1416
  if (o === "PATCH") {
1416
- if (!t.inspectUpdateRow) return W(404, { error: "inspectUpdateRow not configured" }, s);
1417
+ if (!t.inspectUpdateRow) return U(404, { error: "inspectUpdateRow not configured" }, s);
1417
1418
  let e;
1418
1419
  try {
1419
1420
  e = JSON.parse(r || "{}");
1420
1421
  } catch {
1421
- return W(400, { error: "body must be JSON" }, s);
1422
+ return U(400, { error: "body must be JSON" }, s);
1422
1423
  }
1423
- if (!e.patch || typeof e.patch != "object") return W(400, { error: "body.patch must be an object" }, s);
1424
+ if (!e.patch || typeof e.patch != "object") return U(400, { error: "body.patch must be an object" }, s);
1424
1425
  try {
1425
- return W(200, await t.inspectUpdateRow({
1426
+ return U(200, await t.inspectUpdateRow({
1426
1427
  table: d,
1427
1428
  id: u,
1428
1429
  patch: e.patch
1429
1430
  }), s);
1430
1431
  } catch (e) {
1431
- return W(500, {
1432
+ return U(500, {
1432
1433
  error: "update failed",
1433
1434
  message: e?.message ?? String(e)
1434
1435
  }, s);
1435
1436
  }
1436
1437
  }
1437
1438
  if (o === "DELETE") {
1438
- if (!t.inspectDeleteRow) return W(404, { error: "inspectDeleteRow not configured" }, s);
1439
+ if (!t.inspectDeleteRow) return U(404, { error: "inspectDeleteRow not configured" }, s);
1439
1440
  try {
1440
- return W(200, await t.inspectDeleteRow({
1441
+ return U(200, await t.inspectDeleteRow({
1441
1442
  table: d,
1442
1443
  id: u
1443
1444
  }), s);
1444
1445
  } catch (e) {
1445
- return W(500, {
1446
+ return U(500, {
1446
1447
  error: "delete failed",
1447
1448
  message: e?.message ?? String(e)
1448
1449
  }, s);
1449
1450
  }
1450
1451
  }
1451
- return W(405, {
1452
+ return U(405, {
1452
1453
  error: "method not allowed",
1453
1454
  expected: "POST | PATCH | DELETE"
1454
1455
  }, s);
1455
- }, Ut = 256, Wt = (e = Ut) => {
1456
+ }, Gt = 256, Kt = (e = Gt) => {
1456
1457
  let t = [], n = /* @__PURE__ */ new Set();
1457
1458
  return {
1458
1459
  emit(r, i) {
@@ -1475,27 +1476,27 @@ __installPublicEnv(publicEnvValues)
1475
1476
  return t.slice();
1476
1477
  }
1477
1478
  };
1478
- }, Gt = (e) => `event: ${e.channel}\ndata: ${JSON.stringify(e)}\n\n`, Kt = () => `: keep-alive ${Date.now()}\n\n`, qt = {
1479
+ }, qt = (e) => `event: ${e.channel}\ndata: ${JSON.stringify(e)}\n\n`, Jt = () => `: keep-alive ${Date.now()}\n\n`, Yt = {
1479
1480
  trace: 0,
1480
1481
  debug: 1,
1481
1482
  info: 2,
1482
1483
  warn: 3,
1483
1484
  error: 4,
1484
1485
  fatal: 5
1485
- }, Jt = 2e3, Yt = 200, Xt = class {
1486
+ }, Xt = 2e3, Zt = 200, Qt = class {
1486
1487
  capacity;
1487
1488
  buffer = [];
1488
- constructor(e = Jt) {
1489
+ constructor(e = Xt) {
1489
1490
  this.capacity = e;
1490
1491
  }
1491
1492
  append(e) {
1492
1493
  this.buffer.push(e), this.buffer.length > this.capacity && this.buffer.shift();
1493
1494
  }
1494
1495
  query(e = {}) {
1495
- let t = e.since ?? 0, n = e.until ?? Date.now(), r = Math.min(e.max ?? Yt, this.capacity), i = e.minLevel === void 0 ? qt.trace : qt[e.minLevel], a = e.scope?.toLowerCase(), o = e.source, s = e.filter?.toLowerCase(), c = e.traceId, l = [];
1496
+ let t = e.since ?? 0, n = e.until ?? Date.now(), r = Math.min(e.max ?? Zt, this.capacity), i = e.minLevel === void 0 ? Yt.trace : Yt[e.minLevel], a = e.scope?.toLowerCase(), o = e.source, s = e.filter?.toLowerCase(), c = e.traceId, l = [];
1496
1497
  for (let e = this.buffer.length - 1; e >= 0 && l.length < r; e--) {
1497
1498
  let r = this.buffer[e];
1498
- r.ts < t || r.ts > n || qt[r.level] < i || o !== void 0 && r.source !== o || a !== void 0 && (r.scope === void 0 || !r.scope.toLowerCase().includes(a)) || s !== void 0 && !r.message.toLowerCase().includes(s) || c !== void 0 && r.fields.traceId !== c || l.push(r);
1499
+ r.ts < t || r.ts > n || Yt[r.level] < i || o !== void 0 && r.source !== o || a !== void 0 && (r.scope === void 0 || !r.scope.toLowerCase().includes(a)) || s !== void 0 && !r.message.toLowerCase().includes(s) || c !== void 0 && r.fields.traceId !== c || l.push(r);
1499
1500
  }
1500
1501
  return l.reverse();
1501
1502
  }
@@ -1508,7 +1509,7 @@ __installPublicEnv(publicEnvValues)
1508
1509
  clear() {
1509
1510
  this.buffer = [];
1510
1511
  }
1511
- }, Zt = null, Qt = () => (Zt === null && (Zt = new Xt()), Zt), $t = (e) => {
1512
+ }, $t = null, en = () => ($t === null && ($t = new Qt()), $t), tn = (e) => {
1512
1513
  if (typeof e == "string") return e;
1513
1514
  if (e instanceof Error) return e.message;
1514
1515
  try {
@@ -1516,18 +1517,18 @@ __installPublicEnv(publicEnvValues)
1516
1517
  } catch {
1517
1518
  return String(e);
1518
1519
  }
1519
- }, en = (e) => {
1520
+ }, nn = (e) => {
1520
1521
  let t = {
1521
1522
  log: console.log.bind(console),
1522
1523
  info: console.info.bind(console),
1523
1524
  warn: console.warn.bind(console),
1524
1525
  error: console.error.bind(console),
1525
1526
  debug: console.debug.bind(console)
1526
- }, n = Qt(), r = !1, i = (i) => (...a) => {
1527
+ }, n = en(), r = !1, i = (i) => (...a) => {
1527
1528
  if (t[i](...a), !r) {
1528
1529
  r = !0;
1529
1530
  try {
1530
- let t = a.length > 0 ? $t(a[0]) : "", r = t.length > 500 ? t.slice(0, 500) + "…" : t, o = O();
1531
+ let t = a.length > 0 ? tn(a[0]) : "", r = t.length > 500 ? t.slice(0, 500) + "…" : t, o = k();
1531
1532
  e.emit("log", {
1532
1533
  level: i,
1533
1534
  message: r,
@@ -1565,7 +1566,7 @@ __installPublicEnv(publicEnvValues)
1565
1566
  argsCount: 1,
1566
1567
  ...t.scope === void 0 ? {} : { scope: t.scope }
1567
1568
  });
1568
- let a = O(), o = a !== void 0 && t.fields.traceId === void 0 ? {
1569
+ let a = k(), o = a !== void 0 && t.fields.traceId === void 0 ? {
1569
1570
  ...t.fields,
1570
1571
  traceId: a.traceId
1571
1572
  } : t.fields;
@@ -1585,24 +1586,24 @@ __installPublicEnv(publicEnvValues)
1585
1586
  return () => {
1586
1587
  console.log = t.log, console.info = t.info, console.warn = t.warn, console.error = t.error, console.debug = t.debug, a();
1587
1588
  };
1588
- }, tn = 2e3, nn = 8, rn = 1e3, an = 200, Y = (e, t) => e.length > t ? `${e.slice(0, t)}…` : e, on = (e) => {
1589
+ }, rn = 2e3, an = 8, on = 1e3, sn = 200, J = (e, t) => e.length > t ? `${e.slice(0, t)}…` : e, cn = (e) => {
1589
1590
  switch (e) {
1590
1591
  case "error": return "error";
1591
1592
  case "warn": return "warn";
1592
1593
  case "debug": return "debug";
1593
1594
  default: return "info";
1594
1595
  }
1595
- }, sn = g({ scope: "client" }), cn = (e, t) => {
1596
+ }, ln = g({ scope: "client" }), un = (e, t) => {
1596
1597
  let n;
1597
1598
  try {
1598
1599
  n = JSON.parse(e);
1599
1600
  } catch {
1600
- return ln(400, { error: "invalid JSON body" });
1601
+ return dn(400, { error: "invalid JSON body" });
1601
1602
  }
1602
- if (typeof n != "object" || !n) return ln(400, { error: "body must be a JSON object" });
1603
+ if (typeof n != "object" || !n) return dn(400, { error: "body must be a JSON object" });
1603
1604
  let r = n;
1604
- if (!Array.isArray(r.entries)) return ln(400, { error: "entries must be an array" });
1605
- let i = typeof r.app == "string" ? Y(r.app, 120) : void 0, a = typeof r.page == "string" ? Y(r.page, 200) : void 0, o = typeof r.ua == "string" ? Y(r.ua, 200) : void 0, s = r.entries.slice(0, an), c = 0;
1605
+ if (!Array.isArray(r.entries)) return dn(400, { error: "entries must be an array" });
1606
+ let i = typeof r.app == "string" ? J(r.app, 120) : void 0, a = typeof r.page == "string" ? J(r.page, 200) : void 0, o = typeof r.ua == "string" ? J(r.ua, 200) : void 0, s = r.entries.slice(0, sn), c = 0;
1606
1607
  for (let e of s) {
1607
1608
  if (typeof e != "object" || !e) continue;
1608
1609
  let n = e;
@@ -1613,7 +1614,7 @@ __installPublicEnv(publicEnvValues)
1613
1614
  "warn",
1614
1615
  "error",
1615
1616
  "debug"
1616
- ].includes(n.level) ? n.level : "log", s = typeof n.ts == "number" && Number.isFinite(n.ts) ? n.ts : Date.now(), l = Y(n.message, tn), u = Array.isArray(n.args) ? n.args.slice(0, nn).filter((e) => typeof e == "string").map((e) => Y(e, rn)) : void 0, d = typeof n.stack == "string" ? Y(n.stack, tn) : void 0;
1617
+ ].includes(n.level) ? n.level : "log", s = typeof n.ts == "number" && Number.isFinite(n.ts) ? n.ts : Date.now(), l = J(n.message, rn), u = Array.isArray(n.args) ? n.args.slice(0, an).filter((e) => typeof e == "string").map((e) => J(e, on)) : void 0, d = typeof n.stack == "string" ? J(n.stack, rn) : void 0;
1617
1618
  t.emit("clientLog", {
1618
1619
  ts: s,
1619
1620
  level: r,
@@ -1628,35 +1629,35 @@ __installPublicEnv(publicEnvValues)
1628
1629
  ...i === void 0 ? {} : { app: i },
1629
1630
  ...a === void 0 ? {} : { page: a },
1630
1631
  ...u !== void 0 && u.length > 0 ? { args: u } : {}
1631
- }, p = on(r);
1632
- (p === "error" || p === "warn") && d !== void 0 ? sn[p](l, f, { stack: d }) : sn[p](l, {
1632
+ }, p = cn(r);
1633
+ (p === "error" || p === "warn") && d !== void 0 ? ln[p](l, f, { stack: d }) : ln[p](l, {
1633
1634
  ...f,
1634
1635
  ...d === void 0 ? {} : { stack: d }
1635
1636
  }), c++;
1636
1637
  }
1637
- return ln(202, {
1638
+ return dn(202, {
1638
1639
  accepted: c,
1639
1640
  dropped: r.entries.length - c
1640
1641
  });
1641
- }, ln = (e, t) => ({
1642
+ }, dn = (e, t) => ({
1642
1643
  status: e,
1643
1644
  contentType: "application/json; charset=utf-8",
1644
1645
  body: JSON.stringify(t)
1645
- }), un = "/_voltro/inspect/clientLog", dn = [
1646
+ }), fn = "/_voltro/inspect/clientLog", pn = [
1646
1647
  "trace",
1647
1648
  "debug",
1648
1649
  "info",
1649
1650
  "warn",
1650
1651
  "error",
1651
1652
  "fatal"
1652
- ], fn = {
1653
+ ], mn = {
1653
1654
  trace: "TRACE",
1654
1655
  debug: "DEBUG",
1655
1656
  info: "INFO ",
1656
1657
  warn: "WARN ",
1657
1658
  error: "ERROR",
1658
1659
  fatal: "FATAL"
1659
- }, pn = (e) => dn.includes(e), mn = (e, t) => {
1660
+ }, hn = (e) => pn.includes(e), gn = (e, t) => {
1660
1661
  let n = e.indexOf("?"), r = n === -1 ? new URLSearchParams() : new URLSearchParams(e.slice(n + 1)), i = {}, a = r.get("since");
1661
1662
  if (a !== null) {
1662
1663
  let e = Number(a);
@@ -1673,7 +1674,7 @@ __installPublicEnv(publicEnvValues)
1673
1674
  Number.isFinite(e) && e > 0 && (i.max = Math.floor(e));
1674
1675
  }
1675
1676
  let c = r.get("level");
1676
- c !== null && pn(c) && (i.minLevel = c);
1677
+ c !== null && hn(c) && (i.minLevel = c);
1677
1678
  let l = r.get("source");
1678
1679
  (l === "server" || l === "client") && (i.source = l);
1679
1680
  let u = r.get("scope");
@@ -1686,7 +1687,7 @@ __installPublicEnv(publicEnvValues)
1686
1687
  if ((r.get("format") ?? "json") === "text") return {
1687
1688
  status: 200,
1688
1689
  contentType: "text/plain; charset=utf-8",
1689
- body: p.map(hn).join("\n") + (p.length > 0 ? "\n" : "")
1690
+ body: p.map(_n).join("\n") + (p.length > 0 ? "\n" : "")
1690
1691
  };
1691
1692
  let m = {
1692
1693
  capturedAt: Date.now(),
@@ -1700,34 +1701,34 @@ __installPublicEnv(publicEnvValues)
1700
1701
  contentType: "application/json; charset=utf-8",
1701
1702
  body: JSON.stringify(m)
1702
1703
  };
1703
- }, hn = (e) => {
1704
- let t = new Date(e.ts), n = String(t.getHours()).padStart(2, "0"), r = String(t.getMinutes()).padStart(2, "0"), i = String(t.getSeconds()).padStart(2, "0"), a = String(t.getMilliseconds()).padStart(3, "0"), o = `[${e.scope ?? "?"}/${e.source}]`, s = _n(e.fields);
1705
- return `${n}:${r}:${i}.${a} ${fn[e.level]} ${o} ${e.message}${s}`;
1706
- }, gn = 80, _n = (e) => {
1704
+ }, _n = (e) => {
1705
+ let t = new Date(e.ts), n = String(t.getHours()).padStart(2, "0"), r = String(t.getMinutes()).padStart(2, "0"), i = String(t.getSeconds()).padStart(2, "0"), a = String(t.getMilliseconds()).padStart(3, "0"), o = `[${e.scope ?? "?"}/${e.source}]`, s = yn(e.fields);
1706
+ return `${n}:${r}:${i}.${a} ${mn[e.level]} ${o} ${e.message}${s}`;
1707
+ }, vn = 80, yn = (e) => {
1707
1708
  let t = Object.entries(e);
1708
1709
  if (t.length === 0) return "";
1709
1710
  let n = [];
1710
1711
  for (let [e, r] of t) {
1711
1712
  if (r === void 0) continue;
1712
- let t = vn(r);
1713
+ let t = bn(r);
1713
1714
  n.push(`${e}=${t}`);
1714
1715
  }
1715
1716
  return n.length > 0 ? " " + n.join(" ") : "";
1716
- }, vn = (e) => {
1717
+ }, bn = (e) => {
1717
1718
  if (typeof e == "string") {
1718
- let t = e.length > gn ? e.slice(0, gn) + "…" : e;
1719
+ let t = e.length > vn ? e.slice(0, vn) + "…" : e;
1719
1720
  return /[\s=]/.test(t) ? `"${t.replace(/"/g, "\\\"")}"` : t;
1720
1721
  }
1721
1722
  if (e === null) return "null";
1722
1723
  if (typeof e == "number" || typeof e == "boolean") return String(e);
1723
1724
  try {
1724
1725
  let t = JSON.stringify(e);
1725
- return t.length > gn ? t.slice(0, gn) + "…" : t;
1726
+ return t.length > vn ? t.slice(0, vn) + "…" : t;
1726
1727
  } catch {
1727
1728
  return "[unserialisable]";
1728
1729
  }
1729
- }, yn = "/_voltro/inspect/logs", bn = g({ scope: "voltro:cli" }), xn = [], Sn = (e) => {
1730
- xn.length = 0;
1730
+ }, xn = "/_voltro/inspect/logs", Sn = g({ scope: "voltro:cli" }), Cn = [], wn = (e) => {
1731
+ Cn.length = 0;
1731
1732
  let r = e[1] && !e[1].startsWith("-") ? e[1] : void 0, i = r ? n(r) ? r : a(process.cwd(), r) : process.cwd(), o = [], s = i;
1732
1733
  for (;;) {
1733
1734
  o.push(s);
@@ -1738,7 +1739,7 @@ __installPublicEnv(publicEnvValues)
1738
1739
  for (let e of o) for (let t of [".env.local", ".env"]) {
1739
1740
  let n = a(e, t);
1740
1741
  if (y(n)) {
1741
- xn.push(n);
1742
+ Cn.push(n);
1742
1743
  try {
1743
1744
  let e = C(n, "utf8");
1744
1745
  for (let t of e.split(/\r?\n/)) {
@@ -1750,11 +1751,11 @@ __installPublicEnv(publicEnvValues)
1750
1751
  (i.startsWith("\"") && i.endsWith("\"") || i.startsWith("'") && i.endsWith("'")) && (i = i.slice(1, -1)), process.env[r] === void 0 && (process.env[r] = i);
1751
1752
  }
1752
1753
  } catch (e) {
1753
- bn.warn("failed to load env file (continuing)", { path: n }, e);
1754
+ Sn.warn("failed to load env file (continuing)", { path: n }, e);
1754
1755
  }
1755
1756
  }
1756
1757
  }
1757
- }, Cn = 500, wn = (e, t, n = {}) => {
1758
+ }, Tn = 500, En = (e, t, n = {}) => {
1758
1759
  if (e.length === 0) return () => {};
1759
1760
  let r = (e) => n.root ? i(n.root, e) : e, a = !1, o = (e) => {
1760
1761
  a || (a = !0, t.warn(`.env changed (${r(e)}) — hard-restarting: process.env is read once at boot, a reload would keep stale values`, { file: r(e) }), Promise.resolve().then(() => n.onBeforeRestart?.()).catch((e) => t.warn(".env restart: onBeforeRestart failed (continuing)", {}, e)).finally(() => {
@@ -1772,16 +1773,16 @@ __installPublicEnv(publicEnvValues)
1772
1773
  });
1773
1774
  }));
1774
1775
  };
1775
- for (let t of e) D(t, { interval: Cn }, (e, n) => {
1776
+ for (let t of e) D(t, { interval: Tn }, (e, n) => {
1776
1777
  e.mtimeMs !== n.mtimeMs && o(t);
1777
1778
  });
1778
1779
  return t.info("watching .env files for changes", {
1779
1780
  files: e.map(r),
1780
- intervalMs: Cn
1781
+ intervalMs: Tn
1781
1782
  }), () => {
1782
1783
  for (let t of e) ee(t);
1783
1784
  };
1784
- }, Tn = [{
1785
+ }, Dn = [{
1785
1786
  match: (e) => typeof e == "string" && e.startsWith("[BABEL] Note: The code generator has deoptimised"),
1786
1787
  handle: (e, t) => {
1787
1788
  let n = e[0], r = n.match(/deoptimised the styling of (.+?) as it exceeds the max of (\d+\w*B)\.?/);
@@ -1793,13 +1794,13 @@ __installPublicEnv(publicEnvValues)
1793
1794
  });
1794
1795
  } else t.info(n);
1795
1796
  }
1796
- }], En = () => {
1797
+ }], On = () => {
1797
1798
  let e = {
1798
1799
  warn: console.warn.bind(console),
1799
1800
  error: console.error.bind(console)
1800
1801
  }, t = g({ scope: "babel" }), n = !1, r = (r) => (...i) => {
1801
1802
  if (!n) {
1802
- for (let e of Tn) if (e.match(i[0])) {
1803
+ for (let e of Dn) if (e.match(i[0])) {
1803
1804
  n = !0;
1804
1805
  try {
1805
1806
  e.handle(i, t);
@@ -1814,7 +1815,50 @@ __installPublicEnv(publicEnvValues)
1814
1815
  return console.warn = r("warn"), console.error = r("error"), () => {
1815
1816
  console.warn = e.warn, console.error = e.error;
1816
1817
  };
1817
- }, Dn = () => {
1818
+ }, kn = "virtual:voltro-route-refresh", An = `\0${kn}`, jn = /(?:^|&)(raw|url|inline|worker|sharedworker|direct)(?:&|=|$)/, Mn = () => "\n// GENERATED by @voltro/cli — the `voltro dev` route Fast Refresh runtime.\n\n/** Mirrors react-refresh's own `isLikelyComponentType` closely enough for the\n * decision we make with it: an uppercase-named function, or a React element\n * type object (memo / forwardRef / lazy carry `$$typeof`). */\nconst isComponentLike = (value) => {\n if (typeof value === 'function') {\n const name = value.displayName ?? value.name\n return typeof name === 'string' && /^[A-Z]/.test(name)\n }\n return typeof value === 'object' && value !== null && '$$typeof' in value\n}\n\n/** Value identity that survives module re-evaluation. A function is compared by\n * SOURCE TEXT — a re-evaluated but unedited `loader` is a brand-new object\n * with identical text — and everything else by its JSON form, so a `meta`\n * object literal does not read as changed on every edit. */\nconst stableForm = (value) => {\n if (typeof value === 'function') return 'fn:' + String(value)\n try { return 'js:' + JSON.stringify(value) } catch { return 'st:' + String(value) }\n}\n\n/** id (absolute file path, as react-refresh spells it) → export names that\n * react-refresh must NOT judge. */\nconst ignoredExports = new Map()\n\nexport const registerRouteModule = (id, moduleExports) => {\n const names = []\n for (const key of Object.keys(moduleExports)) {\n if (key === 'default') continue\n if (isComponentLike(moduleExports[key])) continue\n names.push(key)\n }\n ignoredExports.set(id, names)\n}\n\n/** The name of the first non-component export whose VALUE changed, or null when\n * this update is a pure component edit that Fast Refresh can apply in place. */\nexport const routeUpdateNeedsReload = (prevExports, nextExports) => {\n const keys = new Set([...Object.keys(prevExports), ...Object.keys(nextExports)])\n for (const key of keys) {\n if (key === 'default') continue\n const prev = prevExports[key]\n const next = nextExports[key]\n if (isComponentLike(prev) && isComponentLike(next)) continue\n if (stableForm(prev) !== stableForm(next)) return key\n }\n return null\n}\n\n// `globalThis`, not `window`: identical in the browser (which is the only place\n// this module is ever loaded) and it keeps the runtime evaluatable by the unit\n// test, which is what lets the test read the REAL source instead of a copy.\n// Chained rather than overwritten — another plugin may own the hook for its own\n// modules, and ours only answers for ids it registered.\nconst previousHook = globalThis.__getReactRefreshIgnoredExports\nglobalThis.__getReactRefreshIgnoredExports = (args) =>\n ignoredExports.get(args.id) ?? previousHook?.(args) ?? []\n", Nn = (e) => `
1819
+ if (import.meta.hot) {
1820
+ // Self-import to read our OWN exports, the same technique the react plugin
1821
+ // uses; the namespace is only complete after evaluation, hence the promise.
1822
+ import(/* @vite-ignore */ import.meta.url).then((__voltro_exports) => {
1823
+ __voltro_registerRouteModule(${JSON.stringify(e)}, __voltro_exports)
1824
+ import.meta.hot.accept((__voltro_next) => {
1825
+ if (!__voltro_next) return
1826
+ const changed = __voltro_routeUpdateNeedsReload(__voltro_exports, __voltro_next)
1827
+ if (changed === null) {
1828
+ __voltro_registerRouteModule(${JSON.stringify(e)}, __voltro_next)
1829
+ return
1830
+ }
1831
+ console.info(
1832
+ '[voltro] full reload: non-component export \`' + changed + '\` changed in ' +
1833
+ ${JSON.stringify(e)} + ' (a loader runs on the server too, so its result must be re-rendered)',
1834
+ )
1835
+ window.location.reload()
1836
+ })
1837
+ })
1838
+ }
1839
+ import {
1840
+ registerRouteModule as __voltro_registerRouteModule,
1841
+ routeUpdateNeedsReload as __voltro_routeUpdateNeedsReload,
1842
+ } from '${kn}'
1843
+ `, Pn = (e) => e.replace(/\\/g, "/"), Fn = (e, t) => {
1844
+ let [n = "", r] = Pn(e).split("?");
1845
+ if (!n.endsWith(".tsx") || r !== void 0 && jn.test(r)) return !1;
1846
+ let i = Pn(t).replace(/\/$/, "");
1847
+ return n.startsWith(`${i}/`);
1848
+ }, In = (e, t, n) => Fn(t, n) ? `${e}${Nn(Pn(t).split("?")[0] ?? t)}` : null, Ln = (e) => ({
1849
+ name: "voltro:route-fast-refresh",
1850
+ enforce: "pre",
1851
+ resolveId: (e) => e === "virtual:voltro-route-refresh" ? An : void 0,
1852
+ load: (e) => e === An ? Mn() : void 0,
1853
+ transform: (t, n, r) => {
1854
+ if (r?.ssr === !0) return null;
1855
+ let i = In(t, n, e);
1856
+ return i === null ? null : {
1857
+ code: i,
1858
+ map: null
1859
+ };
1860
+ }
1861
+ }), Rn = () => {
1818
1862
  let e = /* @__PURE__ */ new Map();
1819
1863
  return {
1820
1864
  get(t) {
@@ -1841,7 +1885,7 @@ __installPublicEnv(publicEnvValues)
1841
1885
  return Array.from(e.entries());
1842
1886
  }
1843
1887
  };
1844
- }, On = (e) => {
1888
+ }, zn = (e) => {
1845
1889
  if (typeof e == "number" && Number.isFinite(e) && e > 0) return e * 1e3;
1846
1890
  if (typeof e != "string") return null;
1847
1891
  let t = /^\s*(\d+)\s*(s|seconds?|m|minutes?|h|hours?|d|days?)\s*$/i.exec(e);
@@ -1850,17 +1894,17 @@ __installPublicEnv(publicEnvValues)
1850
1894
  if (!Number.isFinite(n) || n <= 0) return null;
1851
1895
  let r = t[2].toLowerCase();
1852
1896
  return r === "s" || r.startsWith("second") ? n * 1e3 : r === "m" || r.startsWith("minute") ? n * 6e4 : r === "h" || r.startsWith("hour") ? n * 36e5 : r === "d" || r.startsWith("day") ? n * 864e5 : null;
1853
- }, kn = (e, t = {}) => {
1897
+ }, Bn = (e, t = {}) => {
1854
1898
  let n = [e];
1855
1899
  return t.tenant !== void 0 && t.tenant !== "" && n.push(`tenant=${t.tenant}`), t.locale !== void 0 && t.locale !== "" && n.push(`lang=${t.locale}`), n.join("|");
1856
- }, An = (e, t) => e.expiresAt > t, jn = (e, t) => e.expiresAt <= t && e.servableUntil > t, Mn = r(F(), ".voltro"), Nn = r(Mn, "runtime-registry.json"), Pn = 3e4, Fn = () => {
1900
+ }, Vn = (e, t) => e.expiresAt > t, Hn = (e, t) => e.expiresAt <= t && e.servableUntil > t, Un = r(me(), ".voltro"), Wn = r(Un, "runtime-registry.json"), Gn = 3e4, Kn = () => {
1857
1901
  let e = Math.random().toString(36).slice(2, 10);
1858
- return `${Nn}.${process.pid}.${Date.now()}.${e}.tmp`;
1859
- }, In = async () => {
1860
- await S.mkdir(Mn, { recursive: !0 });
1861
- }, Ln = async () => {
1902
+ return `${Wn}.${process.pid}.${Date.now()}.${e}.tmp`;
1903
+ }, qn = async () => {
1904
+ await S.mkdir(Un, { recursive: !0 });
1905
+ }, Jn = async () => {
1862
1906
  try {
1863
- let e = await S.readFile(Nn, "utf8"), t = JSON.parse(e);
1907
+ let e = await S.readFile(Wn, "utf8"), t = JSON.parse(e);
1864
1908
  return t.version !== 1 || !Array.isArray(t.apps) ? {
1865
1909
  version: 1,
1866
1910
  apps: []
@@ -1871,31 +1915,31 @@ __installPublicEnv(publicEnvValues)
1871
1915
  apps: []
1872
1916
  };
1873
1917
  }
1874
- }, Rn = async (e) => {
1875
- await In();
1876
- let t = Fn();
1918
+ }, Yn = async (e) => {
1919
+ await qn();
1920
+ let t = Kn();
1877
1921
  try {
1878
- await S.writeFile(t, JSON.stringify(e, null, 2), "utf8"), await S.rename(t, Nn);
1922
+ await S.writeFile(t, JSON.stringify(e, null, 2), "utf8"), await S.rename(t, Wn);
1879
1923
  } catch (e) {
1880
1924
  try {
1881
1925
  await S.unlink(t);
1882
1926
  } catch {}
1883
1927
  throw e;
1884
1928
  }
1885
- }, zn = (e) => {
1929
+ }, Xn = (e) => {
1886
1930
  try {
1887
1931
  return process.kill(e, 0), !0;
1888
1932
  } catch {
1889
1933
  return !1;
1890
1934
  }
1891
- }, Bn = (e) => {
1935
+ }, Zn = (e) => {
1892
1936
  let t = Date.now();
1893
- return e.filter((e) => zn(e.pid) ? t - new Date(e.heartbeatAt).getTime() < Pn : !1);
1894
- }, Vn = async () => {
1895
- let e = await Ln(), t = Bn(e.apps);
1937
+ return e.filter((e) => Xn(e.pid) ? t - new Date(e.heartbeatAt).getTime() < Gn : !1);
1938
+ }, Qn = async () => {
1939
+ let e = await Jn(), t = Zn(e.apps);
1896
1940
  if (t.length === e.apps.length) return e;
1897
1941
  try {
1898
- await Rn({
1942
+ await Yn({
1899
1943
  version: 1,
1900
1944
  apps: t
1901
1945
  });
@@ -1904,48 +1948,48 @@ __installPublicEnv(publicEnvValues)
1904
1948
  version: 1,
1905
1949
  apps: t
1906
1950
  };
1907
- }, Hn = async (e) => {
1908
- let t = await Ln(), n = (/* @__PURE__ */ new Date()).toISOString(), r = t.apps.findIndex((t) => t.id === e.id), i = {
1951
+ }, $n = async (e) => {
1952
+ let t = await Jn(), n = (/* @__PURE__ */ new Date()).toISOString(), r = t.apps.findIndex((t) => t.id === e.id), i = {
1909
1953
  ...e,
1910
1954
  registeredAt: r >= 0 ? t.apps[r].registeredAt : n,
1911
1955
  heartbeatAt: n
1912
1956
  };
1913
- await Rn({
1957
+ await Yn({
1914
1958
  version: 1,
1915
1959
  apps: r >= 0 ? t.apps.map((e, t) => t === r ? i : e) : [...t.apps, i]
1916
1960
  });
1917
- }, Un = async (e) => {
1961
+ }, er = async (e) => {
1918
1962
  try {
1919
- let t = await Ln(), n = t.apps.filter((t) => t.id !== e);
1963
+ let t = await Jn(), n = t.apps.filter((t) => t.id !== e);
1920
1964
  if (n.length === t.apps.length) return;
1921
- await Rn({
1965
+ await Yn({
1922
1966
  version: 1,
1923
1967
  apps: n
1924
1968
  });
1925
1969
  } catch {}
1926
- }, Wn = (e, t, n) => `${e}:${t}:${n}`, X = r(F(), ".voltro", "logs"), Gn = () => {
1970
+ }, tr = (e, t, n) => `${e}:${t}:${n}`, Y = r(me(), ".voltro", "logs"), nr = () => {
1927
1971
  let e = Number(process.env.VOLTRO_LOG_FILE_TTL_MS);
1928
1972
  return Number.isFinite(e) && e > 0 ? e : 3600 * 1e3;
1929
- }, Kn = !1, qn = () => {
1930
- if (Kn) return;
1931
- Kn = !0;
1932
- let e = Date.now() - Gn(), t = [];
1973
+ }, rr = !1, ir = () => {
1974
+ if (rr) return;
1975
+ rr = !0;
1976
+ let e = Date.now() - nr(), t = [];
1933
1977
  try {
1934
- t = w(X);
1978
+ t = w(Y);
1935
1979
  } catch {
1936
1980
  return;
1937
1981
  }
1938
1982
  for (let n of t) {
1939
1983
  if (!n.endsWith(".log")) continue;
1940
- let t = r(X, n);
1984
+ let t = r(Y, n);
1941
1985
  try {
1942
1986
  T(t).mtimeMs < e && E(t);
1943
1987
  } catch {}
1944
1988
  }
1945
- }, Jn = (e) => e.replace(/[^a-zA-Z0-9._-]/g, "_").slice(0, 80), Yn = (e, t) => r(X, `${Jn(e)}-${t}.log`), Xn = (e) => {
1946
- let t = Jn(e), n = [];
1989
+ }, ar = (e) => e.replace(/[^a-zA-Z0-9._-]/g, "_").slice(0, 80), or = (e, t) => r(Y, `${ar(e)}-${t}.log`), sr = (e) => {
1990
+ let t = ar(e), n = [];
1947
1991
  try {
1948
- n = w(X);
1992
+ n = w(Y);
1949
1993
  } catch {
1950
1994
  return;
1951
1995
  }
@@ -1953,19 +1997,19 @@ __installPublicEnv(publicEnvValues)
1953
1997
  if (i.length === 0) return;
1954
1998
  let a, o = -1;
1955
1999
  for (let e of i) {
1956
- let t = r(X, e);
2000
+ let t = r(Y, e);
1957
2001
  try {
1958
2002
  let e = T(t);
1959
2003
  e.mtimeMs > o && (o = e.mtimeMs, a = t);
1960
2004
  } catch {}
1961
2005
  }
1962
2006
  return a;
1963
- }, Zn = (e) => {
2007
+ }, cr = (e) => {
1964
2008
  try {
1965
- b(X, { recursive: !0 });
2009
+ b(Y, { recursive: !0 });
1966
2010
  } catch {}
1967
- qn();
1968
- let t = Yn(e, process.pid), n = x(t, "w"), r = (e) => {
2011
+ ir();
2012
+ let t = or(e, process.pid), n = x(t, "w"), r = (e) => {
1969
2013
  let t = {
1970
2014
  ts: e.ts.getTime(),
1971
2015
  level: e.level,
@@ -1988,7 +2032,7 @@ __installPublicEnv(publicEnvValues)
1988
2032
  }
1989
2033
  }, i = !1, a = h((e) => {
1990
2034
  if (!i) try {
1991
- te(n, r(e));
2035
+ O(n, r(e));
1992
2036
  } catch {}
1993
2037
  }), o = () => {
1994
2038
  if (!i) {
@@ -2006,7 +2050,7 @@ __installPublicEnv(publicEnvValues)
2006
2050
  a(), o(), process.off("exit", o), process.off("uncaughtException", s), process.off("unhandledRejection", s);
2007
2051
  }
2008
2052
  };
2009
- }, Qn = async (e, t) => {
2053
+ }, lr = async (e, t) => {
2010
2054
  let n;
2011
2055
  try {
2012
2056
  n = await S.readFile(e, "utf8");
@@ -2020,11 +2064,11 @@ __installPublicEnv(publicEnvValues)
2020
2064
  i.push(t);
2021
2065
  } catch {}
2022
2066
  return t?.max !== void 0 && i.length > t.max ? i.slice(i.length - t.max) : i;
2023
- }, $n = g({ scope: "voltro:dashboard" }), er = he(import.meta.url), tr = 5179, nr = (e) => {
2067
+ }, ur = g({ scope: "voltro:dashboard" }), dr = ge(import.meta.url), fr = 5179, pr = (e) => {
2024
2068
  let n = process.env.VOLTRO_DASHBOARD_PATH;
2025
2069
  if (n && y(r(a(n), "app.config.ts"))) return a(n);
2026
2070
  try {
2027
- let e = t(er.resolve("@voltro/dashboard/package.json"));
2071
+ let e = t(dr.resolve("@voltro/dashboard/package.json"));
2028
2072
  if (y(r(e, "app.config.ts"))) return e;
2029
2073
  } catch {}
2030
2074
  let i = r("voltro-devtools", "apps", "dashboard"), o = a(e);
@@ -2036,53 +2080,53 @@ __installPublicEnv(publicEnvValues)
2036
2080
  o = n;
2037
2081
  }
2038
2082
  return null;
2039
- }, rr = "VOLTRO_IS_DASHBOARD", ir = (e, t = "127.0.0.1", n = 250) => new Promise((r) => {
2040
- let i = me({
2083
+ }, mr = "VOLTRO_IS_DASHBOARD", hr = (e, t = "127.0.0.1", n = 250) => new Promise((r) => {
2084
+ let i = he({
2041
2085
  port: e,
2042
2086
  host: t
2043
2087
  }), a = !1, o = (e) => {
2044
2088
  a || (a = !0, i.destroy(), r(e));
2045
2089
  };
2046
2090
  i.once("connect", () => o(!0)), i.once("error", () => o(!1)), setTimeout(() => o(!1), n);
2047
- }), ar = () => !!(process.env.VOLTRO_DASHBOARD === "off" || process.argv.includes("--disable-dashboard")), or = () => process.env[rr] === "1", sr = () => process.stdout.isTTY === !0, cr = r(F(), ".voltro", "dashboard-launch.lock"), lr = 1e4, ur = async () => {
2091
+ }), gr = () => !!(process.env.VOLTRO_DASHBOARD === "off" || process.argv.includes("--disable-dashboard")), _r = () => process.env[mr] === "1", vr = () => process.stdout.isTTY === !0, X = r(me(), ".voltro", "dashboard-launch.lock"), yr = 1e4, br = async () => {
2048
2092
  try {
2049
- await S.mkdir(t(cr), { recursive: !0 });
2050
- let e = await S.open(cr, "wx");
2093
+ await S.mkdir(t(X), { recursive: !0 });
2094
+ let e = await S.open(X, "wx");
2051
2095
  return await e.write(`${process.pid}\n${Date.now()}\n`), await e.close(), !0;
2052
2096
  } catch {
2053
2097
  try {
2054
- let e = await S.stat(cr);
2055
- if (Date.now() - e.mtimeMs > lr) return await S.unlink(cr).catch(() => void 0), ur();
2098
+ let e = await S.stat(X);
2099
+ if (Date.now() - e.mtimeMs > yr) return await S.unlink(X).catch(() => void 0), br();
2056
2100
  } catch {}
2057
2101
  return !1;
2058
2102
  }
2059
- }, dr = async () => {
2103
+ }, xr = async () => {
2060
2104
  try {
2061
- await S.unlink(cr);
2105
+ await S.unlink(X);
2062
2106
  } catch {}
2063
- }, fr = async (e) => {
2107
+ }, Sr = async (e) => {
2064
2108
  let n = e.port ?? 5179;
2065
- if (ar()) return {
2109
+ if (gr()) return {
2066
2110
  status: "skipped",
2067
2111
  reason: "disabled by flag/env",
2068
2112
  port: n
2069
2113
  };
2070
- if (or()) return {
2114
+ if (_r()) return {
2071
2115
  status: "skipped",
2072
2116
  reason: "this process IS the dashboard",
2073
2117
  port: n
2074
2118
  };
2075
- if (!sr()) return {
2119
+ if (!vr()) return {
2076
2120
  status: "skipped",
2077
2121
  reason: "stdout is not a TTY (CI/smoke)",
2078
2122
  port: n
2079
2123
  };
2080
- if (!await ur()) return {
2124
+ if (!await br()) return {
2081
2125
  status: "skipped",
2082
2126
  reason: "another voltro process is currently launching the dashboard",
2083
2127
  port: n
2084
2128
  };
2085
- if (await ir(n)) return await dr(), {
2129
+ if (await hr(n)) return await xr(), {
2086
2130
  status: "already-running",
2087
2131
  port: n
2088
2132
  };
@@ -2099,7 +2143,7 @@ __installPublicEnv(publicEnvValues)
2099
2143
  stdio: "ignore",
2100
2144
  env: {
2101
2145
  ...process.env,
2102
- [rr]: "1",
2146
+ [mr]: "1",
2103
2147
  VOLTRO_DASHBOARD_PORT: String(n)
2104
2148
  }
2105
2149
  });
@@ -2107,24 +2151,105 @@ __installPublicEnv(publicEnvValues)
2107
2151
  if (s.exitCode === null && s.signalCode === null) try {
2108
2152
  s.kill("SIGTERM");
2109
2153
  } catch {}
2110
- }), $n.info(`auto-launching dashboard at http://localhost:${n}`, {
2154
+ }), ur.info(`auto-launching dashboard at http://localhost:${n}`, {
2111
2155
  port: n,
2112
2156
  mode: o,
2113
2157
  prebuilt: a
2114
- }), a || $n.debug("no pre-built dashboard — running `voltro dev`. Build with `cd voltro-devtools && pnpm build` for a fast prod boot."), $n.debug("disable via --disable-dashboard or VOLTRO_DASHBOARD=off"), setTimeout(() => {
2115
- dr();
2158
+ }), a || ur.debug("no pre-built dashboard — running `voltro dev`. Build with `cd voltro-devtools && pnpm build` for a fast prod boot."), ur.debug("disable via --disable-dashboard or VOLTRO_DASHBOARD=off"), setTimeout(() => {
2159
+ xr();
2116
2160
  }, 4e3).unref(), {
2117
2161
  status: "launched",
2118
2162
  port: n
2119
2163
  };
2120
- }, Z = g({ scope: "voltro:dev:web" }), pr = g({ scope: "vite" }), mr = await (async () => {
2164
+ }, Cr = class extends Error {
2165
+ _voltroDeferral = !0;
2166
+ constructor(e) {
2167
+ super(e), this.name = "DeferralNotSupportedError";
2168
+ }
2169
+ }, wr = (e) => typeof e == "object" && !!e && e._voltroDeferral === !0, Tr = (e) => {
2170
+ let { helpers: t } = e, n = t.prepareDeferredLoaderData(e.loaderData, "page"), r = {}, i = {}, a = {};
2171
+ for (let [n, o] of Object.entries(e.segmentLoaderData)) {
2172
+ let e = Number(n), s = t.prepareDeferredLoaderData(o, e);
2173
+ r[e] = s.renderData, i[e] = s.stateData, s.deferredIds && (a[e] = s.deferredIds);
2174
+ }
2175
+ let o = n.deferredIds !== void 0 || Object.keys(a).length > 0;
2176
+ if (o) try {
2177
+ t.assertDeferralSupported({
2178
+ page: e.page,
2179
+ renderMode: e.renderMode,
2180
+ interactive: e.interactive
2181
+ });
2182
+ } catch (e) {
2183
+ throw new Cr(e instanceof Error ? e.message : String(e));
2184
+ }
2185
+ return {
2186
+ loaderData: n.renderData,
2187
+ segmentLoaderData: r,
2188
+ hasDeferred: o,
2189
+ stateInput: {
2190
+ loaderData: n.stateData,
2191
+ segmentLoaderData: i,
2192
+ pageLoaderRan: e.pageLoaderRan,
2193
+ ...n.deferredIds ? { deferredPageIds: n.deferredIds } : {},
2194
+ ...Object.keys(a).length > 0 ? { deferredSegmentIds: a } : {}
2195
+ }
2196
+ };
2197
+ }, Er = "<div id=\"root\"></div>", Dr = "<div id=\"root\">", Or = "</div>", kr = /<script\b[^>]*\btype=["']module["'][^>]*><\/script>[ \t]*\n?/gi, Ar = /\bsrc=["']([^"']+)["']/i, jr = /<script(?![^>]*\basync\b)([^>]*\btype=["']module["'][^>]*)>/gi, Mr = (e) => {
2198
+ let t = e.keepScriptInHead ?? ((e) => e.startsWith("/@")), n = [], r = e.shell.replace(kr, (e) => {
2199
+ let r = Ar.exec(e)?.[1];
2200
+ return r === void 0 || t(r) ? e : (n.push(r), "");
2201
+ });
2202
+ e.inlineModuleScriptsAsync && (r = r.replace(jr, "<script async$1>"));
2203
+ let i = r.indexOf(Er);
2204
+ if (i === -1) throw Error(`[voltro] the generated shell has no \`${Er}\` element, so a streamed response cannot be split around the page body. This is a framework bug unless the app overrode \`.framework/index.html\` by hand.`);
2205
+ return {
2206
+ head: `${r.slice(0, i)}${Dr}`,
2207
+ tail: `${Or}${r.slice(i + 21)}`,
2208
+ bootstrapModules: n
2209
+ };
2210
+ }, Nr = (e) => e.head.replace("</head>", ` ${e.headInjection}\n </head>`).replace(/<html(\s+lang="[^"]*")?/i, `<html lang="${e.htmlLang}"`), Pr = (e) => {
2211
+ let { res: t, shell: n, htmlLang: r, headInjection: i } = e, a = null, o = !1, s = !1, c = () => {
2212
+ if (s || !o || a === null) return;
2213
+ s = !0, t.statusCode = e.statusCode ?? 200;
2214
+ for (let [n, r] of Object.entries(e.headers ?? {})) t.setHeader(n, r);
2215
+ t.flushHeaders?.(), t.write(Nr({
2216
+ head: n.head,
2217
+ headInjection: i(a.meta),
2218
+ htmlLang: r
2219
+ }));
2220
+ let c = new _e();
2221
+ c.pipe(t, { end: !1 }), c.on("end", () => {
2222
+ t.end(n.tail);
2223
+ }), a.stream.pipe(c);
2224
+ }, l = () => {
2225
+ a?.stream.abort();
2226
+ };
2227
+ t.once("close", l), t.once("finish", () => {
2228
+ t.off("close", l);
2229
+ });
2230
+ try {
2231
+ a = e.render({
2232
+ bootstrapModules: n.bootstrapModules,
2233
+ onShellReady: () => {
2234
+ o = !0, c();
2235
+ },
2236
+ onShellError: (t) => {
2237
+ s || e.onShellError(t);
2238
+ }
2239
+ });
2240
+ } catch (t) {
2241
+ e.onShellError(t);
2242
+ return;
2243
+ }
2244
+ c();
2245
+ }, Z = g({ scope: "voltro:dev:web" }), Fr = g({ scope: "vite" }), Ir = await (async () => {
2121
2246
  try {
2122
2247
  let e = r(t(o(import.meta.url)), "..", "package.json"), n = await S.readFile(e, "utf8");
2123
2248
  return JSON.parse(n).version ?? "0.0.0";
2124
2249
  } catch {
2125
2250
  return "0.0.0";
2126
2251
  }
2127
- })(), hr = async () => {
2252
+ })(), Lr = async () => {
2128
2253
  try {
2129
2254
  let e = t(o(import.meta.url)), n = a(e, "..", "..", "devtools");
2130
2255
  if (y(r(n, "package.json"))) return n;
@@ -2133,7 +2258,7 @@ __installPublicEnv(publicEnvValues)
2133
2258
  } catch {
2134
2259
  return null;
2135
2260
  }
2136
- }, gr = (e, t) => e.disableDevtools || !t ? [] : [
2261
+ }, Rr = (e, t) => e.disableDevtools || !t ? [] : [
2137
2262
  "",
2138
2263
  "// Dev-only in-page devtools overlay. The `import.meta.env.DEV` guard is a",
2139
2264
  "// compile-time constant, so prod builds strip this whole `if` block — the",
@@ -2143,12 +2268,12 @@ __installPublicEnv(publicEnvValues)
2143
2268
  " await import('@voltro/devtools/styles.css')",
2144
2269
  " Devtools = (await import('@voltro/devtools')).VoltroDevtools",
2145
2270
  "}"
2146
- ], _r = (e, t) => e.disableDevtools || !t ? [] : [" ...(Devtools ? { Devtools } : {}),"], vr = (e) => e.sentry ? ["import { initSentryBrowser } from '@voltro/plugin-sentry/web'"] : [], yr = (e) => e.sentry ? [
2271
+ ], zr = (e, t) => e.disableDevtools || !t ? [] : [" ...(Devtools ? { Devtools } : {}),"], Br = (e) => e.sentry ? ["import { initSentryBrowser } from '@voltro/plugin-sentry/web'"] : [], Vr = (e) => e.sentry ? [
2147
2272
  "",
2148
2273
  "// Browser-side Sentry (frontend half of the deep integration). Errors +",
2149
2274
  "// browser rpc spans flow to Sentry, sharing the server transactions' trace.",
2150
2275
  `await initSentryBrowser(${JSON.stringify(e.sentry)})`
2151
- ] : [], br = (e) => e.env ? ["import './env.public'"] : [], xr = (e) => {
2276
+ ] : [], Hr = (e) => e.env ? ["import './env.public'"] : [], Ur = (e) => {
2152
2277
  let n = [], i = a(e);
2153
2278
  for (;;) {
2154
2279
  y(r(i, "pnpm-workspace.yaml")) && n.push(i);
@@ -2157,19 +2282,19 @@ __installPublicEnv(publicEnvValues)
2157
2282
  i = e;
2158
2283
  }
2159
2284
  return n;
2160
- }, Sr = /* @__PURE__ */ new Set([
2285
+ }, Wr = /* @__PURE__ */ new Set([
2161
2286
  "layout.tsx",
2162
2287
  "error.tsx",
2163
2288
  "loading.tsx",
2164
2289
  "not-found.tsx"
2165
- ]), Cr = (e) => /\.(test|spec)\.tsx$/.test(e), wr = (e) => {
2290
+ ]), Gr = (e) => /\.(test|spec)\.tsx$/.test(e), Kr = (e) => {
2166
2291
  if (/\/node_modules\/(?:\.pnpm\/[^/]+\/node_modules\/)?(?:react|react-dom|scheduler)\//.test(e)) return "react";
2167
2292
  let t = /\/([^/]+)\.island\.tsx?$/.exec(e);
2168
2293
  if (t) return `island-${t[1]}`;
2169
- }, Tr = /export\s+(?:async\s+)?(?:const|function|let|var)\s+loader\b/, Er = (e) => e.startsWith("(") && e.endsWith(")"), Dr = (e) => e.filter((e) => !Er(e)), Or = (e) => {
2170
- let t = e.replace(/\.tsx$/, "").split("/").filter(Boolean).filter((e) => !Er(e)), n = t.length > 0 && t[t.length - 1] === "index" ? t.slice(0, -1) : t;
2294
+ }, qr = /export\s+(?:async\s+)?(?:const|function|let|var)\s+loader\b/, Jr = (e) => e.startsWith("(") && e.endsWith(")"), Yr = (e) => e.filter((e) => !Jr(e)), Xr = (e) => {
2295
+ let t = e.replace(/\.tsx$/, "").split("/").filter(Boolean).filter((e) => !Jr(e)), n = t.length > 0 && t[t.length - 1] === "index" ? t.slice(0, -1) : t;
2171
2296
  return n.length === 0 ? "/" : "/" + n.join("/");
2172
- }, kr = (e) => `${e.replace(/\.tsx$/, "").split("/").filter(Boolean).map((e) => e.replace(/[()]/g, "").replace(/\[\.\.\./g, "_rest_").replace(/[[\]]/g, "_")).map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join("").replace(/[^A-Za-z0-9_]/g, "_") || "Index"}Page`, Q = (e, t) => e === "" ? `Root${t}` : `${e.split("/").filter(Boolean).map((e) => e.replace(/[()]/g, "").replace(/\[\.\.\./g, "_rest_").replace(/[[\]]/g, "_")).map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join("").replace(/[^A-Za-z0-9_]/g, "_") || "Root"}${t}`, $ = async (e) => {
2297
+ }, Zr = (e) => `${e.replace(/\.tsx$/, "").split("/").filter(Boolean).map((e) => e.replace(/[()]/g, "").replace(/\[\.\.\./g, "_rest_").replace(/[[\]]/g, "_")).map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join("").replace(/[^A-Za-z0-9_]/g, "_") || "Index"}Page`, Q = (e, t) => e === "" ? `Root${t}` : `${e.split("/").filter(Boolean).map((e) => e.replace(/[()]/g, "").replace(/\[\.\.\./g, "_rest_").replace(/[[\]]/g, "_")).map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join("").replace(/[^A-Za-z0-9_]/g, "_") || "Root"}${t}`, $ = async (e) => {
2173
2298
  let t = [], n = [], i = async (e, a) => {
2174
2299
  let o = [];
2175
2300
  try {
@@ -2177,17 +2302,17 @@ __installPublicEnv(publicEnvValues)
2177
2302
  } catch {
2178
2303
  return;
2179
2304
  }
2180
- let s = o.filter((e) => e.isDirectory()).map((e) => e.name).sort(), c = o.filter((e) => e.isFile() && e.name.endsWith(".tsx") && !Cr(e.name)).map((e) => e.name).sort(), l = new Set(c), u = a.join("/");
2181
- if (c.some((e) => Sr.has(e))) {
2305
+ let s = o.filter((e) => e.isDirectory()).map((e) => e.name).sort(), c = o.filter((e) => e.isFile() && e.name.endsWith(".tsx") && !Gr(e.name)).map((e) => e.name).sort(), l = new Set(c), u = a.join("/");
2306
+ if (c.some((e) => Wr.has(e))) {
2182
2307
  let t = l.has("layout.tsx"), i = !1;
2183
2308
  if (t) try {
2184
2309
  let t = await S.readFile(r(e, "layout.tsx"), "utf8");
2185
- i = Tr.test(t);
2310
+ i = qr.test(t);
2186
2311
  } catch {}
2187
2312
  n.push({
2188
2313
  dir: u,
2189
2314
  chain: a,
2190
- contributesToUrl: a.length === 0 || !Er(a[a.length - 1]),
2315
+ contributesToUrl: a.length === 0 || !Jr(a[a.length - 1]),
2191
2316
  hasLayout: t,
2192
2317
  hasLayoutLoader: i,
2193
2318
  hasError: l.has("error.tsx"),
@@ -2196,12 +2321,12 @@ __installPublicEnv(publicEnvValues)
2196
2321
  });
2197
2322
  }
2198
2323
  for (let e of c) {
2199
- if (Sr.has(e)) continue;
2324
+ if (Wr.has(e)) continue;
2200
2325
  let n = u ? `${u}/${e}` : e;
2201
2326
  t.push({
2202
2327
  file: n,
2203
- pattern: Or(n),
2204
- ident: kr(n),
2328
+ pattern: Xr(n),
2329
+ ident: Zr(n),
2205
2330
  dirChain: a
2206
2331
  });
2207
2332
  }
@@ -2211,17 +2336,39 @@ __installPublicEnv(publicEnvValues)
2211
2336
  pages: t,
2212
2337
  dirs: n
2213
2338
  };
2214
- }, Ar = (e, t) => {
2339
+ }, Qr = (e, t) => {
2215
2340
  let n = [];
2216
2341
  for (let r = 0; r <= t.length; r++) {
2217
2342
  let i = t.slice(0, r).join("/"), a = e.find((e) => e.dir === i);
2218
2343
  a && n.push(a);
2219
2344
  }
2220
2345
  return n;
2221
- }, jr = (e) => {
2222
- let t = Dr(e);
2346
+ }, $r = async (e) => {
2347
+ let { entries: t, loadLayout: n, loadError: r, loadPending: i, ctx: a } = e, o = {};
2348
+ return {
2349
+ chain: await Promise.all(t.map(async (e, t) => {
2350
+ let s = {};
2351
+ if (e.hasLayout) {
2352
+ let r = await n(e);
2353
+ s.Layout = r.default, typeof r.loader == "function" && (s.loader = r.loader, o[t] = await r.loader({
2354
+ params: a.params,
2355
+ pathname: a.pathname,
2356
+ signal: a.signal,
2357
+ headers: a.headers,
2358
+ query: a.query
2359
+ }));
2360
+ }
2361
+ return e.hasError && (s.Error = (await r(e)).default), e.hasPending && (s.Pending = (await i(e)).default), {
2362
+ id: e.dir || "/",
2363
+ ...s
2364
+ };
2365
+ })),
2366
+ segmentLoaderData: o
2367
+ };
2368
+ }, ei = (e) => {
2369
+ let t = Yr(e);
2223
2370
  return t.length === 0 ? "" : "/" + t.join("/");
2224
- }, Mr = [
2371
+ }, ti = [
2225
2372
  "// Hot-reload bridge: keep SSR-injected <link rel=\"stylesheet\"> tags",
2226
2373
  "// in sync with Vite's CSS HMR. Without this, edits to .css files",
2227
2374
  "// only update the JS-injected <style> overlay; the underlying <link>",
@@ -2314,7 +2461,7 @@ __installPublicEnv(publicEnvValues)
2314
2461
  " _vdtErrorStart('Build error')",
2315
2462
  " })",
2316
2463
  "}"
2317
- ].join("\n"), Nr = (e) => {
2464
+ ].join("\n"), ni = (e) => {
2318
2465
  let t = [], n = 0, r = e.split("/").filter(Boolean), i = [];
2319
2466
  for (let e of r) e.startsWith("[[...") && e.endsWith("]]") ? (i.push("(.*)"), t.push(e.slice(5, -2)), n += 2) : e.startsWith("[...") && e.endsWith("]") ? (i.push("(.+)"), t.push(e.slice(4, -1)), n += 3) : e.startsWith("[") && e.endsWith("]") ? (i.push("([^/]+)"), t.push(e.slice(1, -1)), n += 1) : i.push(e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
2320
2467
  let a = i.join("/");
@@ -2323,8 +2470,8 @@ __installPublicEnv(publicEnvValues)
2323
2470
  paramNames: t,
2324
2471
  priority: n
2325
2472
  };
2326
- }, Pr = (e) => e.map((e) => {
2327
- let { regex: t, paramNames: n, priority: r } = Nr(e.pattern);
2473
+ }, ri = (e) => e.map((e) => {
2474
+ let { regex: t, paramNames: n, priority: r } = ni(e.pattern);
2328
2475
  return {
2329
2476
  pattern: e.pattern,
2330
2477
  file: e.file,
@@ -2333,7 +2480,7 @@ __installPublicEnv(publicEnvValues)
2333
2480
  paramNames: n,
2334
2481
  priority: r
2335
2482
  };
2336
- }).slice().sort((e, t) => e.priority - t.priority), Fr = (e, t) => {
2483
+ }).slice().sort((e, t) => e.priority - t.priority), ii = (e, t) => {
2337
2484
  for (let n of t) {
2338
2485
  let t = n.regex.exec(e);
2339
2486
  if (!t) continue;
@@ -2345,7 +2492,7 @@ __installPublicEnv(publicEnvValues)
2345
2492
  };
2346
2493
  }
2347
2494
  return null;
2348
- }, Ir = async (e, n) => {
2495
+ }, ai = async (e, n) => {
2349
2496
  let i = e;
2350
2497
  for (;;) {
2351
2498
  let e = r(i, "node_modules", n);
@@ -2359,7 +2506,7 @@ __installPublicEnv(publicEnvValues)
2359
2506
  if (a === i) return null;
2360
2507
  i = a;
2361
2508
  }
2362
- }, Lr = async (e) => {
2509
+ }, oi = async (e) => {
2363
2510
  try {
2364
2511
  let t = await import(s(r(e, "app.config.ts")).href), n = t.default?.port, i = typeof n == "number" ? n : 4e3, a = t.default?.transport?.wsPath, o = typeof a == "string" && a.startsWith("/") ? a : void 0;
2365
2512
  return o ? {
@@ -2368,13 +2515,13 @@ __installPublicEnv(publicEnvValues)
2368
2515
  } : { port: i };
2369
2516
  } catch {}
2370
2517
  return { port: 4e3 };
2371
- }, Rr = (e, t) => ({
2518
+ }, si = (e, t) => ({
2372
2519
  name: e,
2373
2520
  pkg: t.package,
2374
2521
  browserWsUrl: t.url,
2375
2522
  proxyTarget: void 0,
2376
2523
  ...t.headers ? { headers: t.headers } : {}
2377
- }), zr = (e, t, n) => {
2524
+ }), ci = (e, t, n) => {
2378
2525
  let r = t.transport?.wsPath ?? n.wsPath;
2379
2526
  return {
2380
2527
  name: e,
@@ -2384,7 +2531,7 @@ __installPublicEnv(publicEnvValues)
2384
2531
  ...r ? { wsPath: r } : {},
2385
2532
  ...t.headers ? { headers: t.headers } : {}
2386
2533
  };
2387
- }, Br = (e) => {
2534
+ }, li = (e) => {
2388
2535
  let t = /* @__PURE__ */ new Map();
2389
2536
  for (let n of e) {
2390
2537
  if (n.proxyTarget === void 0) continue;
@@ -2392,19 +2539,19 @@ __installPublicEnv(publicEnvValues)
2392
2539
  if (e) throw Error(`[voltro] api ${JSON.stringify(n.name)} and ${JSON.stringify(e)} both resolve the same-origin WS path ${JSON.stringify(n.browserWsUrl)}. A custom transport.wsPath must be unique per origin (one api per origin may use a fixed path). Give each a distinct wsPath, or drop the override to use the default /ws/<name>.`);
2393
2540
  t.set(n.browserWsUrl, n.name);
2394
2541
  }
2395
- }, Vr = async (e, t) => {
2542
+ }, ui = async (e, t) => {
2396
2543
  let n = Object.entries(t.apis ?? {}), r = [];
2397
2544
  for (let [t, i] of n) {
2398
2545
  if (i.url) {
2399
- r.push(Rr(t, i));
2546
+ r.push(si(t, i));
2400
2547
  continue;
2401
2548
  }
2402
- let n = await Ir(e, i.package);
2549
+ let n = await ai(e, i.package);
2403
2550
  if (!n) throw Error(`[voltro dev] api ${JSON.stringify(t)} (package ${JSON.stringify(i.package)}) is not a workspace dep and has no \`url\` set in app.config.ts. External apis need an explicit \`url\` because the framework can't discover their dev port.`);
2404
- r.push(zr(t, i, await Lr(n)));
2551
+ r.push(ci(t, i, await oi(n)));
2405
2552
  }
2406
- return Br(r), r;
2407
- }, Hr = (e) => {
2553
+ return li(r), r;
2554
+ }, di = (e) => {
2408
2555
  if (!e) return;
2409
2556
  let t = e.proxyTarget ?? e.browserWsUrl;
2410
2557
  if (t && !(!/^wss?:\/\//.test(t) && !/^https?:\/\//.test(t))) try {
@@ -2413,7 +2560,7 @@ __installPublicEnv(publicEnvValues)
2413
2560
  } catch {
2414
2561
  return;
2415
2562
  }
2416
- }, Ur = (e, t) => {
2563
+ }, fi = (e, t) => {
2417
2564
  if (e) return async (n, r) => {
2418
2565
  let i = {
2419
2566
  _tag: "Request",
@@ -2445,8 +2592,8 @@ __installPublicEnv(publicEnvValues)
2445
2592
  }
2446
2593
  if (l) return c;
2447
2594
  };
2448
- }, Wr = async (e, t, n, i = {}) => {
2449
- let a = t.title ?? t.name ?? "app", o = t.theme === "dark" ? " class=\"dark\"" : t.theme === "light" ? " class=\"light\"" : "", s = y(r(e, "node_modules", "@voltro", "devtools", "package.json")) || await hr() !== null, c = t.theme === "system" ? [
2595
+ }, pi = async (e, t, n, i = {}) => {
2596
+ let a = t.title ?? t.name ?? "app", o = t.theme === "dark" ? " class=\"dark\"" : t.theme === "light" ? " class=\"light\"" : "", s = y(r(e, "node_modules", "@voltro", "devtools", "package.json")) || await Lr() !== null, c = t.theme === "system" ? [
2450
2597
  " <script>",
2451
2598
  " (function () {",
2452
2599
  " var root = document.documentElement",
@@ -2487,7 +2634,7 @@ __installPublicEnv(publicEnvValues)
2487
2634
  ].join("\n"), { pages: u, dirs: d } = await $(r(e, "src", "pages")), f = (e) => `${e.replace(/[^a-zA-Z0-9]/g, "_")}AppGroup`, p = (e) => `${e.replace(/[^a-zA-Z0-9]/g, "_")}AppDescriptors`, m = n.map((e) => `import { appGroup as ${f(e.name)}, appDescriptors as ${p(e.name)} } from '${e.pkg}/rpcGroup'`), h = n.map((e) => {
2488
2635
  let t = [`group: ${f(e.name)}`];
2489
2636
  return t.push(`descriptors: ${p(e.name)}`), t.push(`wsUrl: ${JSON.stringify(e.browserWsUrl)}`), e.headers && t.push(`headers: ${JSON.stringify(e.headers)}`), ` ${JSON.stringify(e.name)}: { ${t.join(", ")} },`;
2490
- }), g, _;
2637
+ }), g, _, v;
2491
2638
  if (u.length > 0) {
2492
2639
  let e = u.map((e) => ` ${JSON.stringify(e.pattern)}: () => import('../src/pages/${e.file}'),`), n = [];
2493
2640
  for (let e of d) {
@@ -2495,13 +2642,13 @@ __installPublicEnv(publicEnvValues)
2495
2642
  e.hasLayout && e.hasLayoutLoader ? n.push(`import * as ${Q(e.dir, "Layout")}Mod from '${t}/layout.tsx'`) : e.hasLayout && n.push(`import ${Q(e.dir, "Layout")} from '${t}/layout.tsx'`), e.hasError && n.push(`import ${Q(e.dir, "Error")} from '${t}/error.tsx'`), e.hasPending && n.push(`import ${Q(e.dir, "Pending")} from '${t}/loading.tsx'`), e.hasNotFound && n.push(`import ${Q(e.dir, "NotFound")} from '${t}/not-found.tsx'`);
2496
2643
  }
2497
2644
  let r = u.map((e) => {
2498
- let t = Ar(d, e.dirChain).map((e) => {
2645
+ let t = Qr(d, e.dirChain).map((e) => {
2499
2646
  let t = [`id: ${JSON.stringify(e.dir || "/")}`], n = JSON.stringify(e.dir);
2500
2647
  return e.hasLayout && t.push(`Layout: refs.layouts[${n}]`), e.hasLayoutLoader && t.push(`loader: refs.layoutLoaders[${n}]`), e.hasError && t.push(`Error: refs.errors[${n}]`), e.hasPending && t.push(`Pending: refs.pendings[${n}]`), ` { ${t.join(", ")} }`;
2501
2648
  }).join(",\n");
2502
2649
  return ` makePageRoute(${JSON.stringify(e.pattern)}, ${t.length > 0 ? `[\n${t},\n ]` : "undefined"}),`;
2503
2650
  }), i = d.filter((e) => e.hasNotFound).map((e) => {
2504
- let t = jr(e.chain), n = Ar(d, e.chain).map((e) => {
2651
+ let t = ei(e.chain), n = Qr(d, e.chain).map((e) => {
2505
2652
  let t = [`id: ${JSON.stringify(e.dir || "/")}`], n = JSON.stringify(e.dir);
2506
2653
  return e.hasLayout && t.push(`Layout: refs.layouts[${n}]`), e.hasError && t.push(`Error: refs.errors[${n}]`), ` { ${t.join(", ")} }`;
2507
2654
  }).join(",\n"), r = n.length > 0 ? `\n chain: [\n${n},\n ],` : "";
@@ -2536,35 +2683,38 @@ __installPublicEnv(publicEnvValues)
2536
2683
  kind: "page",
2537
2684
  slotKey: e.pattern
2538
2685
  });
2539
- let v = a.map((e) => ` ${JSON.stringify(e.relPath)},`), y = a.map((e, t) => {
2686
+ let y = a.map((e) => ` ${JSON.stringify(e.relPath)},`), b = a.map((e, t) => {
2540
2687
  let n = JSON.stringify(e.slotKey);
2541
2688
  return e.kind === "page" ? ` if (newMods[${t}] && refs.pages[${n}] !== undefined) { refs.pages[${n}] = newMods[${t}]; changed = true }` : ` if (newMods[${t}]?.default) { refs.${e.kind === "layout" ? "layouts" : e.kind === "error" ? "errors" : e.kind === "pending" ? "pendings" : "notFounds"}[${n}] = newMods[${t}].default;${e.kind === "layout" ? ` refs.layoutLoaders[${n}] = newMods[${t}].loader;` : ""} changed = true }`;
2542
- }), b = t.locales ?? [], x = b.length > 0, S = t.defaultLocale ?? b[0] ?? "en";
2543
- if (x && !b.includes(S)) throw Error(`[voltro dev] app.config.ts: defaultLocale '${S}' must be one of locales [${b.join(", ")}]`);
2544
- g = [
2689
+ }), x = t.locales ?? [], S = x.length > 0, C = t.defaultLocale ?? x[0] ?? "en";
2690
+ if (S && !x.includes(C)) throw Error(`[voltro dev] app.config.ts: defaultLocale '${C}' must be one of locales [${x.join(", ")}]`);
2691
+ let w = S ? [
2692
+ "import { I18nProvider } from '@voltro/i18n'",
2693
+ "import { resolveLocale } from '@voltro/i18n/server'",
2694
+ "import { useServerRequest } from '@voltro/web'",
2695
+ ...x.map((e) => `import i18nCatalog_${e} from '../src/locales/${e}'`)
2696
+ ] : [];
2697
+ _ = [
2545
2698
  "// GENERATED BY `voltro dev` — do not edit; will be overwritten on next boot.",
2546
2699
  "// Routes + per-page chain + not-found scopes assembled from src/pages/.",
2547
- "// Exported as a single React component so vite-plugin-react treats this file",
2548
- "// as a clean HMR boundary.",
2549
2700
  "//",
2550
- "// HMR architecture (option C server-pushed re-render with living React tree):",
2551
- "// Page + layout module references live in the `refs` registry below. The",
2552
- "// generated route array reads from `refs` on every `buildRoutes()` call",
2553
- "// never from the static imports directly. On HMR Vite delivers the new",
2554
- "// module to the multi-dep `accept` callback below, which patches the",
2555
- "// matching slot in `refs` and bumps the version counter. The `App`'s",
2556
- "// `useSyncExternalStore` subscription picks up the bump `useMemo`",
2557
- "// rebuilds the routes array Router rebuilds its compiled match → React",
2558
- "// renders with the new module without unmounting the surrounding tree.",
2701
+ "// This is a plain `.ts` module on purpose: it declares NO component, so",
2702
+ "// react-refresh never treats it as a boundary and never re-executes it on a",
2703
+ "// component edit. The mutable `refs` registry therefore OUTLIVES a refresh",
2704
+ "// of `app.tsx` a refreshed `App` keeps every already-loaded page module.",
2705
+ "//",
2706
+ "// HMR architecture (server-pushed re-render with a living React tree):",
2707
+ "// page + layout module references live in the `refs` registry below, and",
2708
+ "// the generated route array reads from `refs` on every `buildRoutes()`",
2709
+ "// call never from the static imports directly. When a route module is",
2710
+ "// NOT a valid react-refresh boundary Vite delivers the new module to the",
2711
+ "// multi-dep `accept` callback below, which patches the matching slot in",
2712
+ "// `refs` and bumps the version counter; `App`'s `useSyncExternalStore`",
2713
+ "// subscription picks up the bump → `useMemo` rebuilds the routes array →",
2714
+ "// the Router rebuilds its compiled match → React renders the new module",
2715
+ "// without unmounting the surrounding tree.",
2559
2716
  "",
2560
- "import { useMemo, useSyncExternalStore } from 'react'",
2561
- "import { Router, pageRoute, lazyPageRoute, preloadRouteModule, type PageDescriptor, type NotFoundDescriptor } from '@voltro/web'",
2562
- ...x ? [
2563
- "import { I18nProvider } from '@voltro/i18n'",
2564
- "import { resolveLocale } from '@voltro/i18n/server'",
2565
- "import { useServerRequest } from '@voltro/web'",
2566
- ...b.map((e) => `import i18nCatalog_${e} from '../src/locales/${e}'`)
2567
- ] : [],
2717
+ "import { pageRoute, lazyPageRoute, preloadRouteModule, type PageDescriptor, type NotFoundDescriptor } from '@voltro/web'",
2568
2718
  ...n,
2569
2719
  "",
2570
2720
  "// Mutable module registry. Initial values come from the static",
@@ -2603,11 +2753,11 @@ __installPublicEnv(publicEnvValues)
2603
2753
  "",
2604
2754
  "let version = 0",
2605
2755
  "const listeners = new Set<() => void>()",
2606
- "const subscribe = (cb: () => void): (() => void) => {",
2756
+ "export const subscribe = (cb: () => void): (() => void) => {",
2607
2757
  " listeners.add(cb)",
2608
2758
  " return () => { listeners.delete(cb) }",
2609
2759
  "}",
2610
- "const getVersion = (): number => version",
2760
+ "export const getVersion = (): number => version",
2611
2761
  "const bump = (): void => {",
2612
2762
  " version++",
2613
2763
  " for (const cb of listeners) cb()",
@@ -2631,7 +2781,7 @@ __installPublicEnv(publicEnvValues)
2631
2781
  " return mod",
2632
2782
  " }, { chain })",
2633
2783
  "",
2634
- "const buildRoutes = (): PageDescriptor[] => [",
2784
+ "export const buildRoutes = (): PageDescriptor[] => [",
2635
2785
  ...r,
2636
2786
  "]",
2637
2787
  "",
@@ -2639,22 +2789,53 @@ __installPublicEnv(publicEnvValues)
2639
2789
  "// this pre-mount so the lazy page module is in `refs.pages` (→ an EAGER",
2640
2790
  "// route) for the first client render — matching the SSG/SSR-prerendered",
2641
2791
  "// HTML instead of a null leaf that would trip a hydration mismatch.",
2792
+ "//",
2793
+ "// Lives HERE and not in app.tsx: app.tsx must export the `App` component",
2794
+ "// and nothing else, or react-refresh rejects it as a boundary and every",
2795
+ "// edit in the app ends in a full page reload.",
2642
2796
  "export const preloadCurrentRoute = async (): Promise<void> => {",
2643
2797
  " if (typeof window === 'undefined') return",
2644
2798
  " await preloadRouteModule(buildRoutes(), window.location.pathname)",
2645
2799
  "}",
2646
2800
  "",
2647
- "const buildNotFounds = (): NotFoundDescriptor[] => [",
2801
+ "export const buildNotFounds = (): NotFoundDescriptor[] => [",
2648
2802
  ...i,
2649
2803
  "]",
2650
2804
  "",
2651
- ...x ? [
2652
- `// i18n auto-wiring (config.locales = [${b.map((e) => JSON.stringify(e)).join(", ")}]).`,
2805
+ "if (import.meta.hot) {",
2806
+ " import.meta.hot.accept(",
2807
+ " [",
2808
+ ...y,
2809
+ " ],",
2810
+ " (newMods: Array<Record<string, unknown> | undefined>) => {",
2811
+ " let changed = false",
2812
+ ...b,
2813
+ " if (changed) bump()",
2814
+ " },",
2815
+ " )",
2816
+ "}",
2817
+ ""
2818
+ ].join("\n"), g = [
2819
+ "// GENERATED BY `voltro dev` — do not edit; will be overwritten on next boot.",
2820
+ "// The app's root component. It exports `App` and NOTHING ELSE: react-refresh",
2821
+ "// only accepts a module whose every export is a component, and a module it",
2822
+ "// rejects invalidates upward until something accepts — which for this graph",
2823
+ "// means main.tsx, which accepts nothing, i.e. a FULL PAGE RELOAD.",
2824
+ "// The route table (and the mutable module registry HMR patches) lives in",
2825
+ "// ./routeTable so that a refresh of THIS file cannot reset it.",
2826
+ "",
2827
+ "import { useMemo, useSyncExternalStore } from 'react'",
2828
+ "import { Router } from '@voltro/web'",
2829
+ ...w,
2830
+ "import { subscribe, getVersion, buildRoutes, buildNotFounds } from './routeTable'",
2831
+ "",
2832
+ ...S ? [
2833
+ `// i18n auto-wiring (config.locales = [${x.map((e) => JSON.stringify(e)).join(", ")}]).`,
2653
2834
  "const I18N_CATALOGS: Record<string, import('@voltro/i18n').MessageCatalog> = {",
2654
- ...b.map((e) => ` ${JSON.stringify(e)}: i18nCatalog_${e},`),
2835
+ ...x.map((e) => ` ${JSON.stringify(e)}: i18nCatalog_${e},`),
2655
2836
  "}",
2656
- `const I18N_SUPPORTED: ReadonlyArray<string> = [${b.map((e) => JSON.stringify(e)).join(", ")}]`,
2657
- `const I18N_DEFAULT = ${JSON.stringify(S)}`,
2837
+ `const I18N_SUPPORTED: ReadonlyArray<string> = [${x.map((e) => JSON.stringify(e)).join(", ")}]`,
2838
+ `const I18N_DEFAULT = ${JSON.stringify(C)}`,
2658
2839
  "",
2659
2840
  "const pickI18nLocale = (ssr: ReturnType<typeof useServerRequest>): string => {",
2660
2841
  " if (ssr) {",
@@ -2688,7 +2869,7 @@ __installPublicEnv(publicEnvValues)
2688
2869
  " const v = useSyncExternalStore(subscribe, getVersion, getVersion)",
2689
2870
  " const routes = useMemo(() => buildRoutes(), [v])",
2690
2871
  " const notFounds = useMemo(() => buildNotFounds(), [v])",
2691
- ...x ? [
2872
+ ...S ? [
2692
2873
  " const ssr = useServerRequest()",
2693
2874
  " const locale = pickI18nLocale(ssr)",
2694
2875
  " const messages = I18N_CATALOGS[locale] ?? I18N_CATALOGS[I18N_DEFAULT]!",
@@ -2699,33 +2880,21 @@ __installPublicEnv(publicEnvValues)
2699
2880
  " )"
2700
2881
  ] : [" return <Router routes={routes} notFounds={notFounds} />"],
2701
2882
  "}",
2702
- "",
2703
- "if (import.meta.hot) {",
2704
- " import.meta.hot.accept(",
2705
- " [",
2706
- ...v,
2707
- " ],",
2708
- " (newMods: Array<Record<string, unknown> | undefined>) => {",
2709
- " let changed = false",
2710
- ...y,
2711
- " if (changed) bump()",
2712
- " },",
2713
- " )",
2714
- "}",
2715
2883
  ""
2716
- ].join("\n"), _ = [
2884
+ ].join("\n"), v = [
2717
2885
  "// GENERATED BY `voltro dev` — do not edit; will be overwritten on next boot.",
2718
2886
  "// Entry: imports the generated App component and calls mount() with the",
2719
2887
  "// resolved apis map. Side-effect only — no local component definitions —",
2720
2888
  "// so downstream invalidations (user page edits) terminate at app.tsx.",
2721
2889
  "",
2722
- ...br(t),
2890
+ ...Hr(t),
2723
2891
  "import { mount } from '@voltro/web'",
2724
2892
  ...m,
2725
- "import { App, preloadCurrentRoute } from './app'",
2726
- ...vr(t),
2727
- ...gr(t, s),
2728
- ...yr(t),
2893
+ "import { App } from './app'",
2894
+ "import { preloadCurrentRoute } from './routeTable'",
2895
+ ...Br(t),
2896
+ ...Rr(t, s),
2897
+ ...Vr(t),
2729
2898
  "",
2730
2899
  "// Preload the current route's page chunk BEFORE hydration so the first",
2731
2900
  "// client render matches the SSG/SSR-prerendered HTML. Without it, a lazy",
@@ -2742,44 +2911,44 @@ __installPublicEnv(publicEnvValues)
2742
2911
  " apis: {",
2743
2912
  ...h,
2744
2913
  " },",
2745
- ..._r(t, s),
2914
+ ...zr(t, s),
2746
2915
  "})",
2747
2916
  "",
2748
- Mr
2917
+ ti
2749
2918
  ].join("\n");
2750
- } else g = "", _ = [
2919
+ } else g = "", _ = "", v = [
2751
2920
  "// GENERATED BY `voltro dev` — do not edit; will be overwritten on next boot.",
2752
2921
  "// The user's root component lives at ../src/App.tsx; this file imports it",
2753
2922
  "// and calls mount(). Side-effect only, no component definitions, so the",
2754
2923
  "// user's component file remains the Fast Refresh boundary.",
2755
2924
  "",
2756
- ...br(t),
2925
+ ...Hr(t),
2757
2926
  "import { mount } from '@voltro/web'",
2758
2927
  ...m,
2759
2928
  "import App from '../src/App'",
2760
- ...vr(t),
2761
- ...gr(t, s),
2762
- ...yr(t),
2929
+ ...Br(t),
2930
+ ...Rr(t, s),
2931
+ ...Vr(t),
2763
2932
  "",
2764
2933
  "mount(App, {",
2765
2934
  " apis: {",
2766
2935
  ...h,
2767
2936
  " },",
2768
- ..._r(t, s),
2937
+ ...zr(t, s),
2769
2938
  "})",
2770
2939
  "",
2771
- Mr
2940
+ ti
2772
2941
  ].join("\n");
2773
- let v = r(e, ".framework");
2774
- await S.mkdir(v, { recursive: !0 }), t.env ? await Ze(v, i) : await S.rm(r(v, "env.public.ts"), { force: !0 }), await S.writeFile(r(v, "index.html"), l, "utf8"), await S.writeFile(r(v, "main.tsx"), _, "utf8"), g ? await S.writeFile(r(v, "app.tsx"), g, "utf8") : await S.rm(r(v, "app.tsx"), { force: !0 });
2775
- let b = r(e, ".gitignore"), x = "";
2942
+ let b = r(e, ".framework");
2943
+ await S.mkdir(b, { recursive: !0 }), t.env ? await Qe(b, i) : await S.rm(r(b, "env.public.ts"), { force: !0 }), await S.writeFile(r(b, "index.html"), l, "utf8"), await S.writeFile(r(b, "main.tsx"), v, "utf8"), g ? (await S.writeFile(r(b, "app.tsx"), g, "utf8"), await S.writeFile(r(b, "routeTable.ts"), _, "utf8")) : (await S.rm(r(b, "app.tsx"), { force: !0 }), await S.rm(r(b, "routeTable.ts"), { force: !0 }));
2944
+ let x = r(e, ".gitignore"), C = "";
2776
2945
  try {
2777
- x = await S.readFile(b, "utf8");
2946
+ C = await S.readFile(x, "utf8");
2778
2947
  } catch {}
2779
- let C = ["/.framework/"], w = x.split("\n").filter((e) => e.trim() !== "");
2780
- for (let e of C) w.includes(e) || w.push(e);
2781
- await S.writeFile(b, w.join("\n") + "\n", "utf8");
2782
- }, Gr = async (e, n) => {
2948
+ let w = ["/.framework/"], T = C.split("\n").filter((e) => e.trim() !== "");
2949
+ for (let e of w) T.includes(e) || T.push(e);
2950
+ await S.writeFile(x, T.join("\n") + "\n", "utf8");
2951
+ }, mi = async (e, n) => {
2783
2952
  try {
2784
2953
  let i = r(t(e), "project.json");
2785
2954
  if (!y(i)) return;
@@ -2792,49 +2961,49 @@ __installPublicEnv(publicEnvValues)
2792
2961
  projectJson: i
2793
2962
  });
2794
2963
  } catch {}
2795
- }, Kr = (e) => r(e, ".framework", "dist", "server", "appConfig.js"), qr = async (e) => {
2796
- let t = Kr(e), n = y(t) ? t : r(e, "app.config.ts");
2964
+ }, hi = (e) => r(e, ".framework", "dist", "server", "appConfig.js"), gi = async (e) => {
2965
+ let t = hi(e), n = y(t) ? t : r(e, "app.config.ts");
2797
2966
  try {
2798
2967
  let e = (await import(s(n).href)).default;
2799
2968
  return typeof e == "object" && e && "type" in e && e.type === "web" ? e : null;
2800
2969
  } catch {
2801
2970
  return null;
2802
2971
  }
2803
- }, Jr = async (t) => {
2804
- let n = await qr(t);
2972
+ }, _i = async (t) => {
2973
+ let n = await gi(t);
2805
2974
  if (!n) return {
2806
2975
  ran: !1,
2807
2976
  exitCode: 0
2808
2977
  };
2809
- En();
2810
- let o = Wt();
2811
- en(o), Z.info("booting voltro dev (web)", { app: n.name ?? "(unnamed)" });
2812
- let s = await Vr(t, n);
2978
+ On();
2979
+ let o = Kt();
2980
+ nn(o), Z.info("booting voltro dev (web)", { app: n.name ?? "(unnamed)" });
2981
+ let s = await ui(t, n);
2813
2982
  for (let e of s) Z.info("api wired", {
2814
2983
  name: e.name,
2815
2984
  pkg: e.pkg,
2816
2985
  ...e.proxyTarget ? { proxyTo: e.proxyTarget } : { directWs: e.browserWsUrl }
2817
2986
  });
2818
- Be(t).then((e) => {
2987
+ Ve(t).then((e) => {
2819
2988
  for (let t of e.files) if (t.action === "created") {
2820
2989
  let e = t.path.split("/").pop() ?? t.path;
2821
2990
  Z.info(`${e} seeded`, { path: t.path });
2822
2991
  }
2823
2992
  }).catch(() => {});
2824
- let { resolved: c } = await Qe({
2993
+ let { resolved: c } = await $e({
2825
2994
  rawEnv: n.env,
2826
2995
  appType: "web",
2827
2996
  root: t,
2828
2997
  log: Z,
2829
2998
  generateTypes: !0
2830
2999
  }), l = c.publicValues;
2831
- await Wr(t, n, s, l), Z.debug("generated framework entry files", { files: [
3000
+ await pi(t, n, s, l), Z.debug("generated framework entry files", { files: [
2832
3001
  "index.html",
2833
3002
  ".framework/main.tsx",
2834
3003
  ...n.env ? [".framework/env.public.ts"] : []
2835
3004
  ] });
2836
- let u = process.env.VOLTRO_IS_DASHBOARD === "1" && process.env.VOLTRO_DASHBOARD_PORT ? Number(process.env.VOLTRO_DASHBOARD_PORT) : n.port ?? 5173, d = n.name ?? "unnamed", f = Wn("web", d, u), p = Zn(d);
2837
- await Hn({
3005
+ let u = process.env.VOLTRO_IS_DASHBOARD === "1" && process.env.VOLTRO_DASHBOARD_PORT ? Number(process.env.VOLTRO_DASHBOARD_PORT) : n.port ?? 5173, d = n.name ?? "unnamed", f = tr("web", d, u), p = cr(d);
3006
+ await $n({
2838
3007
  id: f,
2839
3008
  name: d,
2840
3009
  kind: "web",
@@ -2842,19 +3011,19 @@ __installPublicEnv(publicEnvValues)
2842
3011
  pid: process.pid,
2843
3012
  status: "booting",
2844
3013
  logFile: p.path
2845
- }).catch(() => {}), await Gr(t, u);
3014
+ }).catch(() => {}), await mi(t, u);
2846
3015
  let { pages: m, dirs: h } = await $(r(t, "src", "pages")), g = h.map((e) => ({
2847
3016
  dir: e.dir,
2848
3017
  hasLayout: e.hasLayout,
2849
3018
  hasError: e.hasError,
2850
3019
  hasPending: e.hasPending,
2851
3020
  hasNotFound: e.hasNotFound
2852
- })), v = await gt({
3021
+ })), v = await vt({
2853
3022
  appRoot: t,
2854
3023
  pages: m
2855
3024
  });
2856
3025
  v.wrote && Z.debug("routes codegen wrote", { path: i(t, v.path) });
2857
- let b = await Ge("vite", () => import("vite")), x = (await import("@vitejs/plugin-react")).default, C = (await import("@tailwindcss/vite")).default, w = r(t, ".framework"), T = r(t, "src"), E = /* @__PURE__ */ new Set([
3026
+ let b = await Ke("vite", () => import("vite")), x = (await import("@vitejs/plugin-react")).default, C = (await import("@tailwindcss/vite")).default, w = r(t, ".framework"), T = r(t, "src"), E = /* @__PURE__ */ new Set([
2858
3027
  ".framework",
2859
3028
  "node_modules",
2860
3029
  "dist",
@@ -2878,7 +3047,7 @@ __installPublicEnv(publicEnvValues)
2878
3047
  ...i.devDependencies
2879
3048
  });
2880
3049
  await Promise.all(a.map(async (n) => {
2881
- let i = await Ir(t, n);
3050
+ let i = await ai(t, n);
2882
3051
  if (!i) return;
2883
3052
  let a = r(i, "src");
2884
3053
  try {
@@ -2887,12 +3056,12 @@ __installPublicEnv(publicEnvValues)
2887
3056
  }));
2888
3057
  } catch {}
2889
3058
  }
2890
- }, D = r(t, "src", "pages"), te = (e) => e.endsWith(".tsx") && (e === D || e.startsWith(D + "/")), O = (e) => e === D || e.startsWith(D + "/"), ne = async (e) => {
3059
+ }, D = r(t, "src", "pages"), O = (e) => e.endsWith(".tsx") && (e === D || e.startsWith(D + "/")), k = (e) => e === D || e.startsWith(D + "/"), te = async (e) => {
2891
3060
  try {
2892
3061
  let r = Date.now();
2893
- await Wr(t, n, s, l);
3062
+ await pi(t, n, s, l);
2894
3063
  let { pages: i } = await $(D);
2895
- await gt({
3064
+ await vt({
2896
3065
  appRoot: t,
2897
3066
  pages: i
2898
3067
  }), Z.info("page tree regenerated", {
@@ -2902,44 +3071,44 @@ __installPublicEnv(publicEnvValues)
2902
3071
  } catch (t) {
2903
3072
  Z.error("page tree regen failed", { reason: e }, t);
2904
3073
  }
2905
- }, re = {
3074
+ }, ne = {
2906
3075
  name: "framework:regenerate-on-page-tree-change",
2907
3076
  configureServer(e) {
2908
3077
  let n = null, r = [], a = (e) => {
2909
3078
  r.push(e), n && clearTimeout(n), n = setTimeout(() => {
2910
3079
  n = null;
2911
3080
  let e = r.length === 1 ? r[0] : `${r.length} events (${r[0]}, …)`;
2912
- r.length = 0, ne(e);
3081
+ r.length = 0, te(e);
2913
3082
  }, 50);
2914
3083
  };
2915
3084
  e.watcher.on("add", (e) => {
2916
- te(e) && a(`add ${i(t, e)}`);
3085
+ O(e) && a(`add ${i(t, e)}`);
2917
3086
  }), e.watcher.on("unlink", (e) => {
2918
- te(e) && a(`unlink ${i(t, e)}`);
3087
+ O(e) && a(`unlink ${i(t, e)}`);
2919
3088
  }), e.watcher.on("addDir", (e) => {
2920
- O(e) && a(`addDir ${i(t, e)}`);
3089
+ k(e) && a(`addDir ${i(t, e)}`);
2921
3090
  }), e.watcher.on("unlinkDir", (e) => {
2922
- O(e) && a(`unlinkDir ${i(t, e)}`);
3091
+ k(e) && a(`unlinkDir ${i(t, e)}`);
2923
3092
  });
2924
3093
  }
2925
- }, k = r(t, "app.config.ts"), A = (e) => {
3094
+ }, A = r(t, "app.config.ts"), re = (e) => {
2926
3095
  if (!se(e.env)) return "";
2927
3096
  let t = Object.entries(e.env.vars).map(([e, t]) => `${e}:${t.access}`).sort();
2928
3097
  return `${String(e.env.publicPrefix)}|${t.join(",")}`;
2929
3098
  }, j = (e, t) => {
2930
3099
  let n = [];
2931
- return e.port !== t.port && n.push(`port ${e.port ?? "(default)"} → ${t.port ?? "(default)"}`), JSON.stringify(e.proxies) !== JSON.stringify(t.proxies) && n.push("proxies"), JSON.stringify(e.allowedHosts) !== JSON.stringify(t.allowedHosts) && n.push("allowedHosts"), JSON.stringify(e.apis) !== JSON.stringify(t.apis) && n.push("apis"), A(e) !== A(t) && n.push("env"), n;
2932
- }, M = n, N = a(k), ie = {
3100
+ return e.port !== t.port && n.push(`port ${e.port ?? "(default)"} → ${t.port ?? "(default)"}`), JSON.stringify(e.proxies) !== JSON.stringify(t.proxies) && n.push("proxies"), JSON.stringify(e.allowedHosts) !== JSON.stringify(t.allowedHosts) && n.push("allowedHosts"), JSON.stringify(e.apis) !== JSON.stringify(t.apis) && n.push("apis"), re(e) !== re(t) && n.push("env"), n;
3101
+ }, M = n, ie = a(A), ae = {
2933
3102
  name: "framework:watch-app-config",
2934
3103
  async configureServer(n) {
2935
- n.watcher.add(k), Z.info("watching app.config.ts for changes", { path: i(t, k) });
3104
+ n.watcher.add(A), Z.info("watching app.config.ts for changes", { path: i(t, A) });
2936
3105
  let r = async () => {
2937
3106
  try {
2938
3107
  try {
2939
- let e = n.moduleGraph.getModuleById(k);
3108
+ let e = n.moduleGraph.getModuleById(A);
2940
3109
  e && n.moduleGraph.invalidateModule(e);
2941
3110
  } catch {}
2942
- let e = (await n.ssrLoadModule(k, { fixStacktrace: !0 })).default;
3111
+ let e = (await n.ssrLoadModule(A, { fixStacktrace: !0 })).default;
2943
3112
  return typeof e == "object" && e && "type" in e && e.type === "web" ? e : (Z.warn("app.config.ts re-load returned wrong shape", { hasDefault: e !== void 0 }), null);
2944
3113
  } catch (e) {
2945
3114
  return Z.warn("app.config.ts re-load failed — ignoring this change", {}, e), null;
@@ -2984,7 +3153,7 @@ __installPublicEnv(publicEnvValues)
2984
3153
  }
2985
3154
  try {
2986
3155
  let r = Date.now();
2987
- await Wr(t, e, await Vr(t, e)), M = e, n.ws && n.ws.send({
3156
+ await pi(t, e, await ui(t, e)), M = e, n.ws && n.ws.send({
2988
3157
  type: "full-reload",
2989
3158
  path: "*"
2990
3159
  }), Z.info("app.config.ts soft-regen", {
@@ -2994,7 +3163,7 @@ __installPublicEnv(publicEnvValues)
2994
3163
  } catch (e) {
2995
3164
  Z.error("app.config.ts soft-regen failed", {}, e);
2996
3165
  }
2997
- }, l = (t) => e(t) === "app.config.ts" ? t === k || a(t) === N : !1;
3166
+ }, l = (t) => e(t) === "app.config.ts" ? t === A || a(t) === ie : !1;
2998
3167
  n.watcher.on("change", (e) => {
2999
3168
  l(e) && (Z.info("app.config.ts change event (chokidar)", { file: e }), s());
3000
3169
  }), n.watcher.on("add", (e) => {
@@ -3002,21 +3171,21 @@ __installPublicEnv(publicEnvValues)
3002
3171
  });
3003
3172
  try {
3004
3173
  let { watchFile: e } = await import("node:fs");
3005
- e(k, { interval: 500 }, (e, t) => {
3174
+ e(A, { interval: 500 }, (e, t) => {
3006
3175
  e.mtimeMs !== t.mtimeMs && (Z.info("app.config.ts change event (poll)", { mtime: e.mtimeMs }), s());
3007
3176
  }), Z.info("app.config.ts polling watcher attached", { intervalMs: 500 });
3008
3177
  } catch (e) {
3009
3178
  Z.warn("app.config.ts polling watcher could not attach", {}, e);
3010
3179
  }
3011
- wn(xn, Z, {
3180
+ En(Cn, Z, {
3012
3181
  root: t,
3013
3182
  onBeforeRestart: () => n.close()
3014
3183
  });
3015
3184
  }
3016
- }, ae = /\/apps\/[^/]+\/.*\.(route|mutation|workflow|schema)\.tsx?$/, oe = {
3185
+ }, N = /\/apps\/[^/]+\/.*\.(route|mutation|workflow|schema)\.tsx?$/, oe = {
3017
3186
  name: "framework:suppress-api-hmr",
3018
3187
  handleHotUpdate(e) {
3019
- if (ae.test(e.file)) return [];
3188
+ if (N.test(e.file)) return [];
3020
3189
  }
3021
3190
  }, ce = {
3022
3191
  name: "framework:reoptimize-on-rpcgroup-change",
@@ -3024,7 +3193,7 @@ __installPublicEnv(publicEnvValues)
3024
3193
  let n = /* @__PURE__ */ new Map();
3025
3194
  for (let i of s) {
3026
3195
  if (!i.proxyTarget) continue;
3027
- let a = await Ir(t, i.pkg);
3196
+ let a = await ai(t, i.pkg);
3028
3197
  if (!a) continue;
3029
3198
  let o = r(a, "rpcGroup.generated.ts");
3030
3199
  try {
@@ -3113,8 +3282,8 @@ __installPublicEnv(publicEnvValues)
3113
3282
  renderMode: a.renderMode ?? "static",
3114
3283
  interactive: a.interactive ?? "full",
3115
3284
  tenantAware: a.tenantAware === !0,
3116
- revalidateMs: On(a.revalidate),
3117
- staleWhileRevalidateMs: On(a.staleWhileRevalidate) ?? 0,
3285
+ revalidateMs: zn(a.revalidate),
3286
+ staleWhileRevalidateMs: zn(a.staleWhileRevalidate) ?? 0,
3118
3287
  cacheInvalidatesOn: Array.isArray(a.cacheInvalidatesOn) ? a.cacheInvalidatesOn : [],
3119
3288
  hasLoader: typeof a.loader == "function",
3120
3289
  hasMeta: a.meta != null,
@@ -3219,22 +3388,22 @@ __installPublicEnv(publicEnvValues)
3219
3388
  for (let [t, n] of Object.entries(e.headers ?? {})) n !== void 0 && (s[String(t).toLowerCase()] = Array.isArray(n) ? n.join(", ") : String(n));
3220
3389
  let c = i.split("?")[0];
3221
3390
  if (e.method === "GET" && (c === "/_voltro/inspect/logs" || i.startsWith("/_voltro/inspect/logs?"))) {
3222
- let e = G(s.origin);
3223
- if (H()) {
3391
+ let e = W(s.origin);
3392
+ if (V()) {
3224
3393
  t.statusCode = 503, t.setHeader("content-type", "application/json");
3225
3394
  for (let [n, r] of Object.entries(e)) t.setHeader(n, r);
3226
3395
  t.end(JSON.stringify({ error: "inspect disabled (VOLTRO_INSPECT=off)" }));
3227
3396
  return;
3228
3397
  }
3229
- let n = mn(i, Qt());
3398
+ let n = gn(i, en());
3230
3399
  t.statusCode = n.status, t.setHeader("content-type", n.contentType);
3231
3400
  for (let [n, r] of Object.entries(e)) t.setHeader(n, r);
3232
3401
  t.end(n.body);
3233
3402
  return;
3234
3403
  }
3235
3404
  if (e.method === "POST" && c === "/_voltro/inspect/clientLog") {
3236
- let n = G(s.origin);
3237
- if (H()) {
3405
+ let n = W(s.origin);
3406
+ if (V()) {
3238
3407
  t.statusCode = 503, t.setHeader("content-type", "application/json");
3239
3408
  for (let [e, r] of Object.entries(n)) t.setHeader(e, r);
3240
3409
  t.end(JSON.stringify({ error: "inspect disabled (VOLTRO_INSPECT=off)" }));
@@ -3244,7 +3413,7 @@ __installPublicEnv(publicEnvValues)
3244
3413
  e.setEncoding("utf-8"), e.on("data", (e) => {
3245
3414
  r += e;
3246
3415
  }), e.on("end", () => {
3247
- let e = cn(r, o);
3416
+ let e = un(r, o);
3248
3417
  t.statusCode = e.status, t.setHeader("content-type", e.contentType);
3249
3418
  for (let [e, r] of Object.entries(n)) t.setHeader(e, r);
3250
3419
  t.end(e.body);
@@ -3254,14 +3423,14 @@ __installPublicEnv(publicEnvValues)
3254
3423
  return;
3255
3424
  }
3256
3425
  if (c === "/_voltro/inspect/stream") {
3257
- let n = G(s.origin);
3258
- if (H()) {
3426
+ let n = W(s.origin);
3427
+ if (V()) {
3259
3428
  t.statusCode = 503, t.setHeader("content-type", "application/json");
3260
3429
  for (let [e, r] of Object.entries(n)) t.setHeader(e, r);
3261
3430
  t.end(JSON.stringify({ error: "inspect disabled (VOLTRO_INSPECT=off)" }));
3262
3431
  return;
3263
3432
  }
3264
- let r = U(s);
3433
+ let r = H(s);
3265
3434
  if (!r.ok) {
3266
3435
  t.statusCode = 401, t.setHeader("content-type", "application/json");
3267
3436
  for (let [e, r] of Object.entries(n)) t.setHeader(e, r);
@@ -3275,14 +3444,14 @@ __installPublicEnv(publicEnvValues)
3275
3444
  for (let [e, r] of Object.entries(n)) t.setHeader(e, r);
3276
3445
  t.flushHeaders?.(), t.write("retry: 5000\n\n");
3277
3446
  let a = i.indexOf("?");
3278
- if (!(a !== -1 && new URLSearchParams(i.slice(a + 1)).get("live") === "1")) for (let e of o.buffered()) t.write(Gt(e));
3447
+ if (!(a !== -1 && new URLSearchParams(i.slice(a + 1)).get("live") === "1")) for (let e of o.buffered()) t.write(qt(e));
3279
3448
  let c = o.subscribe((e) => {
3280
3449
  try {
3281
- t.write(Gt(e));
3450
+ t.write(qt(e));
3282
3451
  } catch {}
3283
3452
  }), l = setInterval(() => {
3284
3453
  try {
3285
- t.write(Kt());
3454
+ t.write(Jt());
3286
3455
  } catch {}
3287
3456
  }, 15e3), u = () => {
3288
3457
  clearInterval(l), c();
@@ -3291,11 +3460,11 @@ __installPublicEnv(publicEnvValues)
3291
3460
  return;
3292
3461
  }
3293
3462
  try {
3294
- let o = Tt(i, {
3463
+ let o = Dt(i, {
3295
3464
  kind: "web",
3296
3465
  meta: {
3297
3466
  name: n.name ?? "(unnamed)",
3298
- voltroVersion: mr,
3467
+ voltroVersion: Ir,
3299
3468
  port: u,
3300
3469
  mode: "dev",
3301
3470
  apis: Object.entries(n.apis ?? {}).map(([e, t]) => {
@@ -3313,7 +3482,7 @@ __installPublicEnv(publicEnvValues)
3313
3482
  size: 0,
3314
3483
  entries: []
3315
3484
  }),
3316
- env: () => vt(n.name ?? "app", { contract: se(n.env) ? n.env : void 0 })
3485
+ env: () => bt(n.name ?? "app", { contract: se(n.env) ? n.env : void 0 })
3317
3486
  }, s, { method: e.method ?? "GET" });
3318
3487
  if (o === null) return r();
3319
3488
  t.statusCode = o.status, t.setHeader("content-type", o.contentType);
@@ -3330,23 +3499,23 @@ __installPublicEnv(publicEnvValues)
3330
3499
  e.middlewares.use(async (e, t, n) => {
3331
3500
  if (!(e.url ?? "").startsWith("/api/dashboard/registry")) return n();
3332
3501
  try {
3333
- let e = await Vn();
3502
+ let e = await Qn();
3334
3503
  t.statusCode = 200, t.setHeader("content-type", "application/json; charset=utf-8"), t.end(JSON.stringify(e));
3335
3504
  } catch (e) {
3336
3505
  t.statusCode = 500, t.setHeader("content-type", "text/plain"), t.end(`registry read error: ${e.message}`);
3337
3506
  }
3338
3507
  });
3339
3508
  }
3340
- } : null, pe = Pr(m), F = /* @__PURE__ */ new Set(), me = null, he = async () => (me === null && (me = await S.readFile(r(t, ".framework", "index.html"), "utf8")), me), ge = {
3509
+ } : null, pe = ri(m), me = /* @__PURE__ */ new Set(), he = null, ge = async () => (he === null && (he = await S.readFile(r(t, ".framework", "index.html"), "utf8")), he), _e = {
3341
3510
  name: "framework:ssr",
3342
3511
  configureServer(e) {
3343
3512
  e.middlewares.use(async (n, i, a) => {
3344
3513
  if (n.method !== "GET" && n.method !== "HEAD") return a();
3345
3514
  let o = n.url ?? "/", c = o.indexOf("?"), l = (c === -1 ? o : o.slice(0, c)) || "/";
3346
3515
  if (l.startsWith("/@") || l.startsWith("/node_modules/") || l.startsWith("/.framework/") || l.startsWith("/_voltro/") || l === "/main.tsx" || l === "/index.html" || l === "/sw.js" || l === "/favicon.ico" || l === "/robots.txt" || /\.[a-z0-9]+$/i.test(l)) return a();
3347
- let u = Fr(l, pe);
3516
+ let u = ii(l, pe);
3348
3517
  if (!u) return a();
3349
- let d = !F.has(u.route.pattern), f = Date.now();
3518
+ let d = !me.has(u.route.pattern), f = Date.now();
3350
3519
  d && Z.info(`ssr compiling ${u.route.pattern}`, {
3351
3520
  pattern: u.route.pattern,
3352
3521
  pathname: l
@@ -3368,31 +3537,37 @@ __installPublicEnv(publicEnvValues)
3368
3537
  try {
3369
3538
  let c = await m("loadPage", async () => await e.ssrLoadModule(r(t, "src", "pages", u.route.file))), _ = c.renderMode ?? "static";
3370
3539
  if (_ !== "ssr" && _ !== "isr") return a();
3371
- let v = Ar(h, u.route.dirChain), y = await m("loadChain", () => Promise.all(v.map(async (n) => {
3372
- let i = {};
3373
- return n.hasLayout && (i.Layout = (await e.ssrLoadModule(r(t, "src", "pages", n.dir, "layout.tsx"))).default), n.hasError && (i.Error = (await e.ssrLoadModule(r(t, "src", "pages", n.dir, "error.tsx"))).default), n.hasPending && (i.Pending = (await e.ssrLoadModule(r(t, "src", "pages", n.dir, "loading.tsx"))).default), {
3374
- id: n.dir || "/",
3375
- ...i
3376
- };
3377
- }))), b = {};
3378
- for (let [e, t] of Object.entries(n.headers ?? {})) typeof t == "string" ? b[e] = t : Array.isArray(t) && (b[e] = t.join(", "));
3379
- let x = Ur(Hr(s[0]), b.cookie), S = null, C = c.loader;
3380
- if (typeof C == "function") {
3381
- let e = new AbortController(), t = () => e.abort();
3382
- i.once("close", t);
3383
- try {
3384
- S = await m("loader", () => C({
3540
+ let v = {};
3541
+ for (let [e, t] of Object.entries(n.headers ?? {})) typeof t == "string" ? v[e] = t : Array.isArray(t) && (v[e] = t.join(", "));
3542
+ let y = fi(di(s[0]), v.cookie), b = new AbortController(), x = () => b.abort();
3543
+ i.once("close", x);
3544
+ let S = null, C = [], w = {}, T = Qr(h, u.route.dirChain);
3545
+ try {
3546
+ ({chain: C, segmentLoaderData: w} = await m("loadChain", () => $r({
3547
+ entries: T,
3548
+ loadLayout: (n) => e.ssrLoadModule(r(t, "src", "pages", n.dir, "layout.tsx")),
3549
+ loadError: (n) => e.ssrLoadModule(r(t, "src", "pages", n.dir, "error.tsx")),
3550
+ loadPending: (n) => e.ssrLoadModule(r(t, "src", "pages", n.dir, "loading.tsx")),
3551
+ ctx: {
3385
3552
  params: u.params,
3386
3553
  pathname: l,
3387
- signal: e.signal,
3388
- headers: b,
3389
- query: x
3390
- }));
3391
- } finally {
3392
- i.off("close", t);
3393
- }
3554
+ signal: b.signal,
3555
+ headers: v,
3556
+ query: y
3557
+ }
3558
+ })));
3559
+ let n = c.loader;
3560
+ typeof n == "function" && (S = await m("loader", () => n({
3561
+ params: u.params,
3562
+ pathname: l,
3563
+ signal: b.signal,
3564
+ headers: v,
3565
+ query: y
3566
+ })));
3567
+ } finally {
3568
+ i.off("close", x);
3394
3569
  }
3395
- let w = await m("loadSsrHelpers", async () => await e.ssrLoadModule("@voltro/web/ssr")), T = {
3570
+ let E = await m("loadSsrHelpers", async () => await e.ssrLoadModule("@voltro/web/ssr")), ee = {
3396
3571
  pattern: u.route.pattern,
3397
3572
  Component: c.default,
3398
3573
  meta: c.meta,
@@ -3400,41 +3575,76 @@ __installPublicEnv(publicEnvValues)
3400
3575
  ErrorBoundary: c.ErrorBoundary,
3401
3576
  Pending: c.Pending,
3402
3577
  renderMode: _,
3403
- chain: y
3404
- }, E = {
3405
- cookies: w.parseCookieHeader(b.cookie),
3406
- headers: b,
3578
+ chain: C
3579
+ }, D = {
3580
+ cookies: E.parseCookieHeader(v.cookie),
3581
+ headers: v,
3407
3582
  url: o
3408
- }, ee = Date.now(), { html: D, meta: te } = w.renderPageToHtml({
3409
- descriptor: T,
3410
- params: u.params,
3411
- pathname: l,
3583
+ }, O = c.interactive ?? "full", k = Tr({
3584
+ helpers: E,
3585
+ page: `src/pages/${u.route.file}`,
3586
+ renderMode: _,
3587
+ interactive: O,
3412
3588
  loaderData: S,
3413
- requestContext: E
3414
- });
3415
- p.render = Date.now() - ee;
3416
- let O = c.interactive ?? "full", ne = [];
3589
+ segmentLoaderData: w,
3590
+ pageLoaderRan: typeof c.loader == "function"
3591
+ }), te = [];
3417
3592
  await m("collectCss", async () => {
3418
3593
  let e = /* @__PURE__ */ new Set(), n = [
3419
3594
  r(t, "src", "pages", u.route.file),
3420
- ...v.flatMap((e) => [
3595
+ ...T.flatMap((e) => [
3421
3596
  ...e.hasLayout ? [r(t, "src", "pages", e.dir, "layout.tsx")] : [],
3422
3597
  ...e.hasError ? [r(t, "src", "pages", e.dir, "error.tsx")] : [],
3423
3598
  ...e.hasPending ? [r(t, "src", "pages", e.dir, "loading.tsx")] : []
3424
3599
  ]),
3425
3600
  r(t, ".framework", "main.tsx")
3426
3601
  ];
3427
- for (let t of n) await g(t, e, ne);
3602
+ for (let t of n) await g(t, e, te);
3428
3603
  });
3429
- let re = await m("readShell", he), k = await m("transformShell", () => e.transformIndexHtml(o, re)), A = [
3430
- ne.map((e) => `<link rel="stylesheet" href="${e}?direct" />`).join("\n "),
3431
- w.renderMetaToHtml(te),
3604
+ let ne = await m("readShell", ge), A = await m("transformShell", () => e.transformIndexHtml(o, ne)), re = te.map((e) => `<link rel="stylesheet" href="${e}?direct" />`).join("\n "), j = (e) => [
3605
+ re,
3606
+ E.renderMetaToHtml(e),
3432
3607
  `<meta name="voltro-interactive" content="${O}" />`,
3433
- `<script type="application/json" id="__voltro_state__">${w.serialiseStateForInlining(S)}<\/script>`
3434
- ].filter((e) => e.length > 0).join("\n "), j = E.cookies["voltro:locale"], M = k.replace("<div id=\"root\"></div>", `<div id="root">${D}</div>`).replace("</head>", ` ${A}\n </head>`).replace(/<html(\s+lang="[^"]*")?/i, j ? `<html lang="${j}"` : "<html lang=\"en\"");
3435
- i.statusCode = 200, i.setHeader("content-type", "text/html; charset=utf-8"), i.setHeader("x-voltro-rendered-by", "ssr-dev"), i.end(M);
3608
+ ...k.hasDeferred ? [E.renderDeferredRegistryScript()] : [],
3609
+ E.renderRouterStateScript(k.stateInput)
3610
+ ].filter((e) => e.length > 0).join("\n "), M = D.cookies["voltro:locale"] ?? "en", ie = Date.now(), ae = {
3611
+ descriptor: ee,
3612
+ params: u.params,
3613
+ pathname: l,
3614
+ loaderData: k.loaderData,
3615
+ segmentLoaderData: k.segmentLoaderData,
3616
+ requestContext: D
3617
+ };
3618
+ if (_ === "ssr" && O === "full") Pr({
3619
+ res: i,
3620
+ shell: Mr({
3621
+ shell: A,
3622
+ inlineModuleScriptsAsync: !0
3623
+ }),
3624
+ htmlLang: M,
3625
+ headers: {
3626
+ "content-type": "text/html; charset=utf-8",
3627
+ "x-voltro-rendered-by": "ssr-dev"
3628
+ },
3629
+ headInjection: j,
3630
+ render: (e) => E.renderPageToStream({
3631
+ ...ae,
3632
+ ...e
3633
+ }),
3634
+ onShellError: (e) => {
3635
+ Z.warn("ssr-dev shell render failed; falling back to SPA shell", {
3636
+ pathname: l,
3637
+ pattern: u.route.pattern
3638
+ }, e), a();
3639
+ }
3640
+ });
3641
+ else {
3642
+ let { html: e, meta: t } = E.renderPageToHtml(ae), n = A.replace("<div id=\"root\"></div>", `<div id="root">${e}</div>`).replace("</head>", ` ${j(t)}\n </head>`).replace(/<html(\s+lang="[^"]*")?/i, `<html lang="${M}"`);
3643
+ i.statusCode = 200, i.setHeader("content-type", "text/html; charset=utf-8"), i.setHeader("x-voltro-rendered-by", "ssr-dev"), i.end(n);
3644
+ }
3645
+ p.render = Date.now() - ie;
3436
3646
  let N = Date.now() - f;
3437
- d ? (F.add(u.route.pattern), Z.info(`ssr compiled ${u.route.pattern} in ${N}ms`, {
3647
+ d ? (me.add(u.route.pattern), Z.info(`ssr compiled ${u.route.pattern} in ${N}ms`, {
3438
3648
  pattern: u.route.pattern,
3439
3649
  pathname: l,
3440
3650
  elapsedMs: N,
@@ -3448,6 +3658,13 @@ __installPublicEnv(publicEnvValues)
3448
3658
  phases: p
3449
3659
  });
3450
3660
  } catch (e) {
3661
+ if (wr(e)) {
3662
+ Z.error("ssr-dev render refused", {
3663
+ pathname: l,
3664
+ pattern: u.route.pattern
3665
+ }, e), i.statusCode = 500, i.setHeader("content-type", "text/plain; charset=utf-8"), i.end(e.message);
3666
+ return;
3667
+ }
3451
3668
  Z.warn("ssr-dev render failed; falling back to SPA shell", {
3452
3669
  pathname: l,
3453
3670
  pattern: u.route.pattern
@@ -3455,11 +3672,11 @@ __installPublicEnv(publicEnvValues)
3455
3672
  }
3456
3673
  });
3457
3674
  }
3458
- }, I = Date.now(), _e = b.version ?? "?", ve = await hr(), ye = r(t, "node_modules", "@voltro", "ui-shadcn"), L = y(r(ye, "package.json")) ? ye : null, be = [], xe = await (async () => {
3675
+ }, ve = Date.now(), ye = b.version ?? "?", F = await Lr(), be = r(t, "node_modules", "@voltro", "ui-shadcn"), I = y(r(be, "package.json")) ? be : null, xe = [], L = await (async () => {
3459
3676
  let e = [];
3460
3677
  for (let n of s) {
3461
3678
  if (!n.proxyTarget) continue;
3462
- let i = await Ir(t, n.pkg);
3679
+ let i = await ai(t, n.pkg);
3463
3680
  if (i) try {
3464
3681
  e.push(await S.readFile(r(i, "rpcGroup.generated.ts"), "utf8"));
3465
3682
  } catch {}
@@ -3475,56 +3692,57 @@ __installPublicEnv(publicEnvValues)
3475
3692
  } catch {}
3476
3693
  return !0;
3477
3694
  })();
3478
- xe && Z.info("rpcGroup changed since last boot — forcing a dep re-optimize so the browser loads the current api client"), await (await b.createServer({
3695
+ L && Z.info("rpcGroup changed since last boot — forcing a dep re-optimize so the browser loads the current api client"), await (await b.createServer({
3479
3696
  root: w,
3480
3697
  envPrefix: "__VOLTRO_VITE_ENV_DISABLED__",
3481
3698
  ssr: { noExternal: ["react-intl"] },
3482
3699
  resolve: {
3483
3700
  dedupe: ["react", "react-dom"],
3484
3701
  alias: [
3485
- ...ve ? [{
3702
+ ...F ? [{
3486
3703
  find: "@voltro/devtools/styles.css",
3487
- replacement: r(ve, "src/styles.css")
3704
+ replacement: r(F, "src/styles.css")
3488
3705
  }, {
3489
3706
  find: "@voltro/devtools",
3490
- replacement: r(ve, "src/index.ts")
3707
+ replacement: r(F, "src/index.ts")
3491
3708
  }] : [],
3492
- ...L ? [
3709
+ ...I ? [
3493
3710
  {
3494
3711
  find: "@voltro/ui-shadcn/tokens.css",
3495
- replacement: r(L, "src/tokens.css")
3712
+ replacement: r(I, "src/tokens.css")
3496
3713
  },
3497
3714
  {
3498
3715
  find: "@voltro/ui-shadcn/cn",
3499
- replacement: r(L, "src/cn.ts")
3716
+ replacement: r(I, "src/cn.ts")
3500
3717
  },
3501
3718
  {
3502
3719
  find: "@voltro/ui-shadcn/brand",
3503
- replacement: r(L, "src/brand/voltroLogo.tsx")
3720
+ replacement: r(I, "src/brand/voltroLogo.tsx")
3504
3721
  },
3505
3722
  {
3506
3723
  find: "@voltro/ui-shadcn",
3507
- replacement: r(L, "src/index.ts")
3724
+ replacement: r(I, "src/index.ts")
3508
3725
  }
3509
3726
  ] : [],
3510
- ...Ue(t)
3727
+ ...We(t)
3511
3728
  ]
3512
3729
  },
3513
3730
  optimizeDeps: {
3514
- include: [...s.map((e) => `${e.pkg}/rpcGroup`), ...be],
3515
- force: xe
3731
+ include: [...s.map((e) => `${e.pkg}/rpcGroup`), ...xe],
3732
+ force: L
3516
3733
  },
3517
- customLogger: ot(),
3734
+ customLogger: ct(),
3518
3735
  plugins: [
3736
+ Ln(r(t, "src", "pages")),
3519
3737
  x(),
3520
3738
  C(),
3521
3739
  ee,
3522
- re,
3523
- ie,
3740
+ ne,
3741
+ ae,
3524
3742
  oe,
3525
3743
  ce,
3526
3744
  le,
3527
- ge,
3745
+ _e,
3528
3746
  ...ue ? [ue] : []
3529
3747
  ],
3530
3748
  server: {
@@ -3533,14 +3751,14 @@ __installPublicEnv(publicEnvValues)
3533
3751
  host: !0,
3534
3752
  allowedHosts: n.allowedHosts === !0 || [...n.allowedHosts ?? []],
3535
3753
  proxy: P,
3536
- fs: { allow: [t, ...xr(t)] }
3754
+ fs: { allow: [t, ...Ur(t)] }
3537
3755
  },
3538
3756
  appType: "spa",
3539
3757
  cacheDir: r(w, ".vite"),
3540
3758
  publicDir: r(t, "public")
3541
- })).listen(), pr.info(`v${_e} ready in ${Date.now() - I}ms`, {
3542
- version: _e,
3543
- bootMs: Date.now() - I
3759
+ })).listen(), Fr.info(`v${ye} ready in ${Date.now() - ve}ms`, {
3760
+ version: ye,
3761
+ bootMs: Date.now() - ve
3544
3762
  }), Z.info(`listening on http://localhost:${u}`, {
3545
3763
  port: u,
3546
3764
  app: n.name ?? "(unnamed)"
@@ -3550,7 +3768,7 @@ __installPublicEnv(publicEnvValues)
3550
3768
  target: e.proxyTarget
3551
3769
  }), Z.info(`proxy /_voltro/api/${e.name} → ${e.proxyTarget.replace(/^ws/, "http")}/_voltro/inspect`, { api: e.name }));
3552
3770
  try {
3553
- await Hn({
3771
+ await $n({
3554
3772
  id: f,
3555
3773
  name: d,
3556
3774
  kind: "web",
@@ -3559,13 +3777,13 @@ __installPublicEnv(publicEnvValues)
3559
3777
  status: "live",
3560
3778
  logFile: p.path
3561
3779
  });
3562
- let e = nr(t);
3780
+ let e = pr(t);
3563
3781
  if (e) {
3564
- let t = await fr({ dashboardAppPath: e });
3782
+ let t = await Sr({ dashboardAppPath: e });
3565
3783
  t.status === "launched" ? Z.info(`dashboard launched at http://localhost:${t.port}`, { port: t.port }) : t.status === "already-running" && Z.debug(`dashboard already running on :${t.port}`, { port: t.port });
3566
3784
  }
3567
3785
  setInterval(() => {
3568
- Hn({
3786
+ $n({
3569
3787
  id: f,
3570
3788
  name: d,
3571
3789
  kind: "web",
@@ -3576,7 +3794,7 @@ __installPublicEnv(publicEnvValues)
3576
3794
  }).catch(() => {});
3577
3795
  }, 1e4).unref();
3578
3796
  let n = () => {
3579
- Un(f), p.dispose();
3797
+ er(f), p.dispose();
3580
3798
  };
3581
3799
  process.on("SIGINT", n), process.on("SIGTERM", n);
3582
3800
  } catch (e) {
@@ -3586,40 +3804,40 @@ __installPublicEnv(publicEnvValues)
3586
3804
  app: n.name ?? "unnamed",
3587
3805
  kind: "web",
3588
3806
  url: `http://localhost:${u}`,
3589
- bootMs: Date.now() - I
3807
+ bootMs: Date.now() - ve
3590
3808
  }), new Promise(() => {});
3591
- }, Yr = async (e) => {
3809
+ }, vi = async (e) => {
3592
3810
  process.env.NODE_ENV || (process.env.NODE_ENV = "production");
3593
- let t = await qr(e);
3811
+ let t = await gi(e);
3594
3812
  if (!t) return {
3595
3813
  ran: !1,
3596
3814
  exitCode: 0
3597
3815
  };
3598
3816
  let n = Date.now(), i = Z.child("serve");
3599
3817
  i.info("booting voltro serve (preview)", { app: t.name ?? "(unnamed)" });
3600
- let a = await Vr(e, t);
3818
+ let a = await ui(e, t);
3601
3819
  for (let e of a) i.info("api wired", {
3602
3820
  name: e.name,
3603
3821
  pkg: e.pkg
3604
3822
  });
3605
- await Wr(e, t, a);
3823
+ await pi(e, t, a);
3606
3824
  {
3607
3825
  let { pages: t } = await $(r(e, "src", "pages"));
3608
- await gt({
3826
+ await vt({
3609
3827
  appRoot: e,
3610
3828
  pages: t
3611
3829
  });
3612
3830
  }
3613
- let o = t.port ?? 5173, s = await Ge("vite", () => import("vite")), c = (await import("@vitejs/plugin-react")).default, l = r(e, ".framework");
3831
+ let o = t.port ?? 5173, s = await Ke("vite", () => import("vite")), c = (await import("@vitejs/plugin-react")).default, l = r(e, ".framework");
3614
3832
  Z.info("running production build"), await s.build({
3615
3833
  root: l,
3616
3834
  envPrefix: "__VOLTRO_VITE_ENV_DISABLED__",
3617
3835
  plugins: [c()],
3618
- customLogger: ot(),
3836
+ customLogger: ct(),
3619
3837
  resolve: { dedupe: ["react", "react-dom"] },
3620
3838
  build: {
3621
3839
  outDir: "dist",
3622
- rollupOptions: { output: { manualChunks: wr } }
3840
+ rollupOptions: { output: { manualChunks: Kr } }
3623
3841
  },
3624
3842
  publicDir: r(e, "public")
3625
3843
  });
@@ -3639,14 +3857,14 @@ __installPublicEnv(publicEnvValues)
3639
3857
  extras: f,
3640
3858
  bootMs: Date.now() - n
3641
3859
  }), new Promise(() => {});
3642
- }, Xr = 5e3, Zr = 6e4, Qr = (e, t) => {
3860
+ }, yi = 5e3, bi = 6e4, xi = (e, t) => {
3643
3861
  if (e.length === 0) return 0;
3644
3862
  if (e.length === 1) return e[0];
3645
3863
  let n = t * (e.length - 1), r = Math.floor(n), i = Math.ceil(n);
3646
3864
  if (r === i) return e[r];
3647
3865
  let a = n - r;
3648
3866
  return e[r] * (1 - a) + e[i] * a;
3649
- }, $r = (e) => {
3867
+ }, Si = (e) => {
3650
3868
  if (e.length === 0) return {
3651
3869
  p50: 0,
3652
3870
  p95: 0,
@@ -3658,18 +3876,18 @@ __installPublicEnv(publicEnvValues)
3658
3876
  let t = e.slice().sort((e, t) => e - t), n = 0;
3659
3877
  for (let e of t) n += e;
3660
3878
  return {
3661
- p50: Qr(t, .5),
3662
- p95: Qr(t, .95),
3663
- p99: Qr(t, .99),
3879
+ p50: xi(t, .5),
3880
+ p95: xi(t, .95),
3881
+ p99: xi(t, .99),
3664
3882
  mean: n / t.length,
3665
3883
  min: t[0],
3666
3884
  max: t[t.length - 1]
3667
3885
  };
3668
- }, ei = (e = {}) => {
3669
- let t = e.maxSamples ?? Xr, n = e.defaultWindowMs ?? Zr, r = [];
3886
+ }, Ci = (e = {}) => {
3887
+ let t = e.maxSamples ?? yi, n = e.defaultWindowMs ?? bi, r = [];
3670
3888
  return {
3671
3889
  record(e) {
3672
- re(e), r.push({
3890
+ ne(e), r.push({
3673
3891
  ...e,
3674
3892
  ts: Date.now()
3675
3893
  }), r.length > t && r.shift();
@@ -3695,7 +3913,7 @@ __installPublicEnv(publicEnvValues)
3695
3913
  tag: e.tag,
3696
3914
  count: e.samples.length,
3697
3915
  errorCount: n,
3698
- latencyMs: $r(t)
3916
+ latencyMs: Si(t)
3699
3917
  });
3700
3918
  }
3701
3919
  return c.sort((e, t) => t.count - e.count), {
@@ -3708,4 +3926,4 @@ __installPublicEnv(publicEnvValues)
3708
3926
  };
3709
3927
  };
3710
3928
  //#endregion
3711
- export { Bt as $, xn as A, V as B, kn as C, On as D, Dn as E, en as F, kt as G, U as H, Qt as I, Et as J, Ht as K, Gt as L, mn as M, un as N, wn as O, cn as P, Dt as Q, Wt as R, Hn as S, jn as T, Pt as U, wt as V, Vt as W, Tt as X, At as Y, Nt as Z, Zn as _, Ue as _t, qr as a, jt as at, Vn as b, ve as bt, Yr as c, H as ct, Wr as d, yt as dt, zt as et, rr as f, gt as ft, Xn as g, Ge as gt, nr as h, Ye as ht, Ar as i, Ft as it, yn as j, Sn as k, wr as l, bt as lt, fr as m, Xe as mt, Hr as n, Rt as nt, Vr as o, Mt as ot, tr as p, Qe as pt, Ot as q, Ur as r, It as rt, Jr as s, G as st, ei as t, Lt as tt, $ as u, vt as ut, Qn as v, Be as vt, An as w, Un as x, ye as xt, Wn as y, Ve as yt, Kt as z };
3929
+ export { Ot as $, Hn as A, nn as B, lr as C, Ve as Ct, $n as D, er as E, I as Et, Cn as F, B as G, qt as H, xn as I, It as J, Et as K, gn as L, zn as M, En as N, Bn as O, wn as P, At as Q, fn as R, cr as S, We as St, Qn as T, be as Tt, Kt as U, en as V, Jt as W, jt as X, Ut as Y, Wt as Z, mr as _, vt as _t, Qr as a, Vt as at, pr as b, Xe as bt, _i as c, Rt as ct, $ as d, Pt as dt, Mt as et, pi as f, W as ft, Tr as g, xt as gt, wr as h, bt as ht, $r as i, Ht as it, Rn as j, Vn as k, vi as l, Lt as lt, Pr as m, St as mt, di as n, Ft as nt, gi as o, zt as ot, Mr as p, V as pt, H as q, fi as r, kt as rt, ui as s, Bt as st, Ci as t, Dt as tt, Kr as u, Nt as ut, fr as v, $e as vt, tr as w, He as wt, sr as x, Ke as xt, Sr as y, Ze as yt, un as z };