tina4-nodejs 3.13.164 → 3.13.165

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.
@@ -368,8 +368,8 @@ var init_modelCollection = __esm({
368
368
 
369
369
  // src/databaseUrl.ts
370
370
  import { inspect } from "node:util";
371
- function stripOneSlash(path10) {
372
- return path10.startsWith("/") ? path10.slice(1) : path10;
371
+ function stripOneSlash(path9) {
372
+ return path9.startsWith("/") ? path9.slice(1) : path9;
373
373
  }
374
374
  function decode(value) {
375
375
  if (value === void 0 || value === "") return null;
@@ -1839,16 +1839,16 @@ function parseEnvContent(content) {
1839
1839
  }
1840
1840
  return result;
1841
1841
  }
1842
- function loadEnv(path10, override = false) {
1842
+ function loadEnv(path9, override = false) {
1843
1843
  const fromEnv = (process.env.TINA4_ENV_FILE ?? "").trim();
1844
- if (path10 === void 0 && fromEnv.length > 0) {
1844
+ if (path9 === void 0 && fromEnv.length > 0) {
1845
1845
  const named = resolve(fromEnv);
1846
1846
  return mergeFirstWins(
1847
1847
  loadEnvFile(join(dirname(named), ".env.local"), override),
1848
1848
  loadEnvFile(named, override)
1849
1849
  );
1850
1850
  }
1851
- const target = resolve(path10 ?? ".");
1851
+ const target = resolve(path9 ?? ".");
1852
1852
  if (existsSync(target) && statSync(target).isDirectory()) {
1853
1853
  return mergeFirstWins(
1854
1854
  loadEnvFile(join(target, ".env.local"), override),
@@ -2085,12 +2085,12 @@ function resolveCallerName() {
2085
2085
  return void 0;
2086
2086
  }
2087
2087
  }
2088
- function targetIsFile(path10) {
2088
+ function targetIsFile(path9) {
2089
2089
  try {
2090
- if (existsSync2(path10) && statSync2(path10).isDirectory()) return false;
2090
+ if (existsSync2(path9) && statSync2(path9).isDirectory()) return false;
2091
2091
  } catch {
2092
2092
  }
2093
- const base = basename(path10);
2093
+ const base = basename(path9);
2094
2094
  return base.includes(".") && !base.startsWith(".");
2095
2095
  }
2096
2096
  function resolveBool(explicit, envName, fallback) {
@@ -2414,8 +2414,8 @@ var init_logger = __esm({
2414
2414
  rotateSize;
2415
2415
  rotateKeep;
2416
2416
  lock;
2417
- constructor(path10, rotateSize, rotateKeep, lockBuffer) {
2418
- this.path = path10;
2417
+ constructor(path9, rotateSize, rotateKeep, lockBuffer) {
2418
+ this.path = path9;
2419
2419
  this.rotateSize = rotateSize;
2420
2420
  this.rotateKeep = rotateKeep;
2421
2421
  this.lock = new SinkLock(lockBuffer);
@@ -2936,8 +2936,8 @@ function hashPassword(password, salt, iterations = 26e4) {
2936
2936
  }
2937
2937
  function checkPassword(password, hash) {
2938
2938
  try {
2939
- const delimiter2 = hash.includes("$") ? "$" : ":";
2940
- const parts = hash.split(delimiter2);
2939
+ const delimiter3 = hash.includes("$") ? "$" : ":";
2940
+ const parts = hash.split(delimiter3);
2941
2941
  if (parts.length !== 4 || parts[0] !== "pbkdf2_sha256") return false;
2942
2942
  const iterations = parseInt(parts[1], 10);
2943
2943
  const salt = parts[2];
@@ -4585,8 +4585,8 @@ function coerceParam(raw, type2) {
4585
4585
  return raw;
4586
4586
  }
4587
4587
  }
4588
- function joinGroupPath(prefix, path10) {
4589
- const full = `${prefix}/${path10.replace(/^\/+/, "")}`;
4588
+ function joinGroupPath(prefix, path9) {
4589
+ const full = `${prefix}/${path9.replace(/^\/+/, "")}`;
4590
4590
  const trimmed = `/${trimSlashes(full)}`;
4591
4591
  return trimmed.replace(/\/+/g, "/");
4592
4592
  }
@@ -4627,26 +4627,26 @@ async function runRouteMiddlewares(middlewares, req2, res) {
4627
4627
  }
4628
4628
  return true;
4629
4629
  }
4630
- function get(path10, handler, middlewares, meta) {
4631
- return defaultRouter.get(path10, handler, middlewares, meta);
4630
+ function get(path9, handler, middlewares, meta) {
4631
+ return defaultRouter.get(path9, handler, middlewares, meta);
4632
4632
  }
4633
- function post(path10, handler, middlewares, meta) {
4634
- return defaultRouter.post(path10, handler, middlewares, meta);
4633
+ function post(path9, handler, middlewares, meta) {
4634
+ return defaultRouter.post(path9, handler, middlewares, meta);
4635
4635
  }
4636
- function put(path10, handler, middlewares, meta) {
4637
- return defaultRouter.put(path10, handler, middlewares, meta);
4636
+ function put(path9, handler, middlewares, meta) {
4637
+ return defaultRouter.put(path9, handler, middlewares, meta);
4638
4638
  }
4639
- function patch(path10, handler, middlewares, meta) {
4640
- return defaultRouter.patch(path10, handler, middlewares, meta);
4639
+ function patch(path9, handler, middlewares, meta) {
4640
+ return defaultRouter.patch(path9, handler, middlewares, meta);
4641
4641
  }
4642
- function del(path10, handler, middlewares, meta) {
4643
- return defaultRouter.delete(path10, handler, middlewares, meta);
4642
+ function del(path9, handler, middlewares, meta) {
4643
+ return defaultRouter.delete(path9, handler, middlewares, meta);
4644
4644
  }
4645
- function any(path10, handler, middlewares, meta) {
4646
- return defaultRouter.any(path10, handler, middlewares, meta);
4645
+ function any(path9, handler, middlewares, meta) {
4646
+ return defaultRouter.any(path9, handler, middlewares, meta);
4647
4647
  }
4648
- function websocket(path10, handler, options) {
4649
- return defaultRouter.websocket(path10, handler, options);
4648
+ function websocket(path9, handler, options) {
4649
+ return defaultRouter.websocket(path9, handler, options);
4650
4650
  }
4651
4651
  var WsRouteRef, RouteRef, Router, RouteGroup, TINA4_DEFAULT_ROUTER, globalRouterHost, defaultRouter;
4652
4652
  var init_router = __esm({
@@ -4794,32 +4794,32 @@ var init_router = __esm({
4794
4794
  /**
4795
4795
  * Register a GET route programmatically.
4796
4796
  */
4797
- get(path10, handler, middlewares, meta) {
4798
- return this.addRoute({ method: "GET", pattern: path10, handler, middlewares, meta });
4797
+ get(path9, handler, middlewares, meta) {
4798
+ return this.addRoute({ method: "GET", pattern: path9, handler, middlewares, meta });
4799
4799
  }
4800
4800
  /**
4801
4801
  * Register a POST route programmatically.
4802
4802
  */
4803
- post(path10, handler, middlewares, meta) {
4804
- return this.addRoute({ method: "POST", pattern: path10, handler, middlewares, meta });
4803
+ post(path9, handler, middlewares, meta) {
4804
+ return this.addRoute({ method: "POST", pattern: path9, handler, middlewares, meta });
4805
4805
  }
4806
4806
  /**
4807
4807
  * Register a PUT route programmatically.
4808
4808
  */
4809
- put(path10, handler, middlewares, meta) {
4810
- return this.addRoute({ method: "PUT", pattern: path10, handler, middlewares, meta });
4809
+ put(path9, handler, middlewares, meta) {
4810
+ return this.addRoute({ method: "PUT", pattern: path9, handler, middlewares, meta });
4811
4811
  }
4812
4812
  /**
4813
4813
  * Register a PATCH route programmatically.
4814
4814
  */
4815
- patch(path10, handler, middlewares, meta) {
4816
- return this.addRoute({ method: "PATCH", pattern: path10, handler, middlewares, meta });
4815
+ patch(path9, handler, middlewares, meta) {
4816
+ return this.addRoute({ method: "PATCH", pattern: path9, handler, middlewares, meta });
4817
4817
  }
4818
4818
  /**
4819
4819
  * Register a DELETE route programmatically.
4820
4820
  */
4821
- delete(path10, handler, middlewares, meta) {
4822
- return this.addRoute({ method: "DELETE", pattern: path10, handler, middlewares, meta });
4821
+ delete(path9, handler, middlewares, meta) {
4822
+ return this.addRoute({ method: "DELETE", pattern: path9, handler, middlewares, meta });
4823
4823
  }
4824
4824
  /**
4825
4825
  * Register an explicit HEAD route. By default the framework auto-handles
@@ -4829,8 +4829,8 @@ var init_router = __esm({
4829
4829
  * logic, custom validator headers without the cost of building the body.
4830
4830
  * The framework still strips the response body for you on the way out.
4831
4831
  */
4832
- head(path10, handler, middlewares, meta) {
4833
- return this.addRoute({ method: "HEAD", pattern: path10, handler, middlewares, meta });
4832
+ head(path9, handler, middlewares, meta) {
4833
+ return this.addRoute({ method: "HEAD", pattern: path9, handler, middlewares, meta });
4834
4834
  }
4835
4835
  /**
4836
4836
  * Register an explicit OPTIONS route. By default the framework auto-
@@ -4838,16 +4838,16 @@ var init_router = __esm({
4838
4838
  * registered for the path and returning 204 (RFC 9110 §9.3.7). Use
4839
4839
  * this to take over that behaviour.
4840
4840
  */
4841
- options(path10, handler, middlewares, meta) {
4842
- return this.addRoute({ method: "OPTIONS", pattern: path10, handler, middlewares, meta });
4841
+ options(path9, handler, middlewares, meta) {
4842
+ return this.addRoute({ method: "OPTIONS", pattern: path9, handler, middlewares, meta });
4843
4843
  }
4844
4844
  /**
4845
4845
  * Register a route that matches ANY HTTP method.
4846
4846
  */
4847
- any(path10, handler, middlewares, meta) {
4847
+ any(path9, handler, middlewares, meta) {
4848
4848
  let lastRef;
4849
4849
  for (const method of ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"]) {
4850
- lastRef = this.addRoute({ method, pattern: path10, handler, middlewares, meta });
4850
+ lastRef = this.addRoute({ method, pattern: path9, handler, middlewares, meta });
4851
4851
  }
4852
4852
  return lastRef;
4853
4853
  }
@@ -4866,14 +4866,14 @@ var init_router = __esm({
4866
4866
  * the trailing slash. Returning the de-slashed pattern lets callers issue
4867
4867
  * a 308 redirect instead of a hard 404 — Python parity.
4868
4868
  */
4869
- match(method, path10) {
4869
+ match(method, path9) {
4870
4870
  const upperMethod = method.toUpperCase();
4871
4871
  const routes = this.routes.get(upperMethod);
4872
4872
  if (routes) {
4873
- const direct = this.matchRoute(routes, path10);
4873
+ const direct = this.matchRoute(routes, path9);
4874
4874
  if (direct) return direct;
4875
- if (isTrailingSlashRedirectEnabled() && path10.length > 1 && path10.endsWith("/")) {
4876
- const stripped = rtrimSlashes(path10);
4875
+ if (isTrailingSlashRedirectEnabled() && path9.length > 1 && path9.endsWith("/")) {
4876
+ const stripped = rtrimSlashes(path9);
4877
4877
  if (stripped.length > 0) {
4878
4878
  const retry = this.matchRoute(routes, stripped);
4879
4879
  if (retry) return retry;
@@ -4883,7 +4883,7 @@ var init_router = __esm({
4883
4883
  if (upperMethod === "HEAD") {
4884
4884
  const getRoutes = this.routes.get("GET");
4885
4885
  if (getRoutes) {
4886
- return this.matchRoute(getRoutes, path10);
4886
+ return this.matchRoute(getRoutes, path9);
4887
4887
  }
4888
4888
  }
4889
4889
  return null;
@@ -4898,13 +4898,13 @@ var init_router = __esm({
4898
4898
  * OPTIONS is appended whenever any method exists for the path (the
4899
4899
  * framework auto-handles OPTIONS).
4900
4900
  */
4901
- methodsAllowedForPath(path10) {
4901
+ methodsAllowedForPath(path9) {
4902
4902
  const order = ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"];
4903
4903
  const seen = /* @__PURE__ */ new Set();
4904
4904
  for (const m of order) {
4905
4905
  const routes = this.routes.get(m);
4906
4906
  if (!routes) continue;
4907
- if (this.matchRoute(routes, path10)) {
4907
+ if (this.matchRoute(routes, path9)) {
4908
4908
  seen.add(m);
4909
4909
  }
4910
4910
  }
@@ -4915,9 +4915,9 @@ var init_router = __esm({
4915
4915
  return order.filter((m) => seen.has(m));
4916
4916
  }
4917
4917
  /** Inner match against a list of compiled routes, no trailing-slash logic. */
4918
- matchRoute(routes, path10) {
4918
+ matchRoute(routes, path9) {
4919
4919
  for (const route of routes) {
4920
- const match = route.regex.exec(path10);
4920
+ const match = route.regex.exec(path9);
4921
4921
  if (match) {
4922
4922
  const params = {};
4923
4923
  for (let i = 0; i < route.paramNames.length; i++) {
@@ -5005,10 +5005,10 @@ var init_router = __esm({
5005
5005
  * When secured, the upgrade handshake requires a valid JWT (Authorization
5006
5006
  * header / `bearer` subprotocol / `?token=`) or the upgrade is rejected.
5007
5007
  */
5008
- websocket(path10, handler, options) {
5009
- this.wsRoutes = this.wsRoutes.filter((r) => r.pattern !== path10);
5008
+ websocket(path9, handler, options) {
5009
+ this.wsRoutes = this.wsRoutes.filter((r) => r.pattern !== path9);
5010
5010
  const route = {
5011
- pattern: path10,
5011
+ pattern: path9,
5012
5012
  handler,
5013
5013
  // Public unless explicitly secured via options OR a handler `_secured` flag.
5014
5014
  authRequired: Boolean(options?.secured ?? handler._secured ?? false)
@@ -5065,54 +5065,54 @@ var init_router = __esm({
5065
5065
  * Register a route for a specific HTTP method.
5066
5066
  * Core registration method — all convenience methods delegate here.
5067
5067
  */
5068
- static add(method, path10, handler, middleware, swaggerMeta, template) {
5068
+ static add(method, path9, handler, middleware, swaggerMeta, template) {
5069
5069
  const m = method.toUpperCase();
5070
5070
  if (m === "ANY") {
5071
- return defaultRouter.any(path10, handler, middleware, swaggerMeta);
5071
+ return defaultRouter.any(path9, handler, middleware, swaggerMeta);
5072
5072
  }
5073
- return defaultRouter.addRoute({ method: m, pattern: path10, handler, middlewares: middleware, meta: swaggerMeta, template });
5073
+ return defaultRouter.addRoute({ method: m, pattern: path9, handler, middlewares: middleware, meta: swaggerMeta, template });
5074
5074
  }
5075
5075
  /**
5076
5076
  * Register a GET route on the default global router.
5077
5077
  */
5078
- static get(path10, handler, middleware, swaggerMeta, template) {
5079
- return defaultRouter.get(path10, handler, middleware, swaggerMeta);
5078
+ static get(path9, handler, middleware, swaggerMeta, template) {
5079
+ return defaultRouter.get(path9, handler, middleware, swaggerMeta);
5080
5080
  }
5081
5081
  /**
5082
5082
  * Register a POST route on the default global router.
5083
5083
  */
5084
- static post(path10, handler, middleware, swaggerMeta, template) {
5085
- return defaultRouter.post(path10, handler, middleware, swaggerMeta);
5084
+ static post(path9, handler, middleware, swaggerMeta, template) {
5085
+ return defaultRouter.post(path9, handler, middleware, swaggerMeta);
5086
5086
  }
5087
5087
  /**
5088
5088
  * Register a PUT route on the default global router.
5089
5089
  */
5090
- static put(path10, handler, middleware, swaggerMeta, template) {
5091
- return defaultRouter.put(path10, handler, middleware, swaggerMeta);
5090
+ static put(path9, handler, middleware, swaggerMeta, template) {
5091
+ return defaultRouter.put(path9, handler, middleware, swaggerMeta);
5092
5092
  }
5093
5093
  /**
5094
5094
  * Register a PATCH route on the default global router.
5095
5095
  */
5096
- static patch(path10, handler, middleware, swaggerMeta, template) {
5097
- return defaultRouter.patch(path10, handler, middleware, swaggerMeta);
5096
+ static patch(path9, handler, middleware, swaggerMeta, template) {
5097
+ return defaultRouter.patch(path9, handler, middleware, swaggerMeta);
5098
5098
  }
5099
5099
  /**
5100
5100
  * Register a DELETE route on the default global router.
5101
5101
  */
5102
- static delete(path10, handler, middleware, swaggerMeta, template) {
5103
- return defaultRouter.delete(path10, handler, middleware, swaggerMeta);
5102
+ static delete(path9, handler, middleware, swaggerMeta, template) {
5103
+ return defaultRouter.delete(path9, handler, middleware, swaggerMeta);
5104
5104
  }
5105
5105
  /**
5106
5106
  * Register a route that matches ANY HTTP method on the default global router.
5107
5107
  */
5108
- static any(path10, handler, middleware, swaggerMeta, template) {
5109
- return defaultRouter.any(path10, handler, middleware, swaggerMeta);
5108
+ static any(path9, handler, middleware, swaggerMeta, template) {
5109
+ return defaultRouter.any(path9, handler, middleware, swaggerMeta);
5110
5110
  }
5111
5111
  /**
5112
5112
  * Register a WebSocket route on the default global router.
5113
5113
  */
5114
- static websocket(path10, handler, options) {
5115
- return defaultRouter.websocket(path10, handler, options);
5114
+ static websocket(path9, handler, options) {
5115
+ return defaultRouter.websocket(path9, handler, options);
5116
5116
  }
5117
5117
  /**
5118
5118
  * Match a WebSocket upgrade path against routes on the default global router.
@@ -5228,57 +5228,57 @@ var init_router = __esm({
5228
5228
  const merged = [...group, ...route];
5229
5229
  return merged.length > 0 ? merged : void 0;
5230
5230
  }
5231
- get(path10, handler, middlewares, meta) {
5231
+ get(path9, handler, middlewares, meta) {
5232
5232
  return this.router.addRoute({
5233
5233
  method: "GET",
5234
- pattern: joinGroupPath(this.prefix, path10),
5234
+ pattern: joinGroupPath(this.prefix, path9),
5235
5235
  handler,
5236
5236
  middlewares: this.mergeMiddlewares(middlewares),
5237
5237
  meta
5238
5238
  });
5239
5239
  }
5240
- post(path10, handler, middlewares, meta) {
5240
+ post(path9, handler, middlewares, meta) {
5241
5241
  return this.router.addRoute({
5242
5242
  method: "POST",
5243
- pattern: joinGroupPath(this.prefix, path10),
5243
+ pattern: joinGroupPath(this.prefix, path9),
5244
5244
  handler,
5245
5245
  middlewares: this.mergeMiddlewares(middlewares),
5246
5246
  meta
5247
5247
  });
5248
5248
  }
5249
- put(path10, handler, middlewares, meta) {
5249
+ put(path9, handler, middlewares, meta) {
5250
5250
  return this.router.addRoute({
5251
5251
  method: "PUT",
5252
- pattern: joinGroupPath(this.prefix, path10),
5252
+ pattern: joinGroupPath(this.prefix, path9),
5253
5253
  handler,
5254
5254
  middlewares: this.mergeMiddlewares(middlewares),
5255
5255
  meta
5256
5256
  });
5257
5257
  }
5258
- patch(path10, handler, middlewares, meta) {
5258
+ patch(path9, handler, middlewares, meta) {
5259
5259
  return this.router.addRoute({
5260
5260
  method: "PATCH",
5261
- pattern: joinGroupPath(this.prefix, path10),
5261
+ pattern: joinGroupPath(this.prefix, path9),
5262
5262
  handler,
5263
5263
  middlewares: this.mergeMiddlewares(middlewares),
5264
5264
  meta
5265
5265
  });
5266
5266
  }
5267
- delete(path10, handler, middlewares, meta) {
5267
+ delete(path9, handler, middlewares, meta) {
5268
5268
  return this.router.addRoute({
5269
5269
  method: "DELETE",
5270
- pattern: joinGroupPath(this.prefix, path10),
5270
+ pattern: joinGroupPath(this.prefix, path9),
5271
5271
  handler,
5272
5272
  middlewares: this.mergeMiddlewares(middlewares),
5273
5273
  meta
5274
5274
  });
5275
5275
  }
5276
- any(path10, handler, middlewares, meta) {
5276
+ any(path9, handler, middlewares, meta) {
5277
5277
  let lastRef;
5278
5278
  for (const method of ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"]) {
5279
5279
  lastRef = this.router.addRoute({
5280
5280
  method,
5281
- pattern: joinGroupPath(this.prefix, path10),
5281
+ pattern: joinGroupPath(this.prefix, path9),
5282
5282
  handler,
5283
5283
  middlewares: this.mergeMiddlewares(middlewares),
5284
5284
  meta
@@ -5937,15 +5937,15 @@ function findOutsideQuotes(expr, needle) {
5937
5937
  }
5938
5938
  return -1;
5939
5939
  }
5940
- function splitOutsideQuotes(expr, sep9) {
5941
- if (!expr.includes(sep9)) return [expr];
5940
+ function splitOutsideQuotes(expr, sep10) {
5941
+ if (!expr.includes(sep10)) return [expr];
5942
5942
  const parts = [];
5943
5943
  let currentStart = 0;
5944
5944
  let inQuote = null;
5945
5945
  let depth = 0;
5946
5946
  let bracketDepth = 0;
5947
5947
  let i = 0;
5948
- const sepLen = sep9.length;
5948
+ const sepLen = sep10.length;
5949
5949
  const lastStart = expr.length - sepLen;
5950
5950
  while (i <= lastStart) {
5951
5951
  const ch = expr[i];
@@ -5966,7 +5966,7 @@ function splitOutsideQuotes(expr, sep9) {
5966
5966
  else if (ch === ")") depth--;
5967
5967
  else if (ch === "[") bracketDepth++;
5968
5968
  else if (ch === "]") bracketDepth--;
5969
- if (depth === 0 && bracketDepth === 0 && expr.startsWith(sep9, i)) {
5969
+ if (depth === 0 && bracketDepth === 0 && expr.startsWith(sep10, i)) {
5970
5970
  parts.push(expr.slice(currentStart, i));
5971
5971
  i += sepLen;
5972
5972
  currentStart = i;
@@ -7144,8 +7144,8 @@ var init_engine = __esm({
7144
7144
  },
7145
7145
  first: (v) => Array.isArray(v) ? v[0] ?? null : null,
7146
7146
  last: (v) => Array.isArray(v) ? v[v.length - 1] ?? null : null,
7147
- join: (v, sep9) => Array.isArray(v) ? v.map(String).join(sep9 !== void 0 ? String(sep9) : ", ") : String(v),
7148
- split: (v, sep9) => String(v).split(sep9 !== void 0 ? String(sep9) : " "),
7147
+ join: (v, sep10) => Array.isArray(v) ? v.map(String).join(sep10 !== void 0 ? String(sep10) : ", ") : String(v),
7148
+ split: (v, sep10) => String(v).split(sep10 !== void 0 ? String(sep10) : " "),
7149
7149
  replace: (v, from, to) => {
7150
7150
  const s = String(v);
7151
7151
  if (from !== void 0 && typeof from === "object" && from !== null && !Array.isArray(from)) {
@@ -8714,6 +8714,7 @@ var init_engine = __esm({
8714
8714
  // ../core/src/response.ts
8715
8715
  import fs2 from "node:fs";
8716
8716
  import nodePath from "node:path";
8717
+ import { fileURLToPath } from "node:url";
8717
8718
  import { once } from "node:events";
8718
8719
  async function closeSource(source) {
8719
8720
  const s = source;
@@ -8756,7 +8757,7 @@ async function getFrond() {
8756
8757
  return engine;
8757
8758
  }
8758
8759
  async function getFrameworkFrond() {
8759
- const frameworkDir = nodePath.resolve(nodePath.dirname(import.meta.url.replace("file://", "")), "..", "templates");
8760
+ const frameworkDir = nodePath.resolve(nodePath.dirname(fileURLToPath(import.meta.url)), "..", "templates");
8760
8761
  if (!_frameworkFrond && fs2.existsSync(frameworkDir)) {
8761
8762
  try {
8762
8763
  const { Frond: Frond2, setCspNonceProvider: setCspNonceProvider2 } = await Promise.resolve().then(() => (init_engine(), engine_exports));
@@ -9791,9 +9792,9 @@ var init_middleware = __esm({
9791
9792
  const duration = Date.now() - (req2.startTime ?? Date.now());
9792
9793
  const status2 = res.raw.statusCode;
9793
9794
  const method = req2.method ?? "?";
9794
- const path10 = logPath(req2);
9795
+ const path9 = logPath(req2);
9795
9796
  const color = status2 >= 400 ? "\x1B[31m" : status2 >= 300 ? "\x1B[33m" : "\x1B[32m";
9796
- console.log(` ${color}${status2}\x1B[0m ${method} ${path10} \x1B[90m${duration}ms\x1B[0m`);
9797
+ console.log(` ${color}${status2}\x1B[0m ${method} ${path9} \x1B[90m${duration}ms\x1B[0m`);
9797
9798
  return [req2, res];
9798
9799
  }
9799
9800
  };
@@ -9958,7 +9959,7 @@ function createRequest(req2) {
9958
9959
  const xfHost = trustedPeer ? req2.headers["x-forwarded-host"] : void 0;
9959
9960
  const host = (Array.isArray(xfHost) ? xfHost[0] : xfHost) ?? (req2.headers.host ?? "localhost");
9960
9961
  const query = {};
9961
- let path10;
9962
+ let path9;
9962
9963
  let queryString;
9963
9964
  let fullUrl;
9964
9965
  try {
@@ -9967,13 +9968,13 @@ function createRequest(req2) {
9967
9968
  if (isUnsafeFieldName(key)) continue;
9968
9969
  Reflect.set(query, key, value);
9969
9970
  }
9970
- path10 = url.pathname;
9971
+ path9 = url.pathname;
9971
9972
  queryString = url.search.replace(/^\?/, "");
9972
9973
  fullUrl = url.toString();
9973
9974
  } catch {
9974
9975
  const rawTarget = req2.url ?? "/";
9975
9976
  const questionIdx = rawTarget.indexOf("?");
9976
- path10 = questionIdx >= 0 ? rawTarget.slice(0, questionIdx) : rawTarget;
9977
+ path9 = questionIdx >= 0 ? rawTarget.slice(0, questionIdx) : rawTarget;
9977
9978
  queryString = questionIdx >= 0 ? rawTarget.slice(questionIdx + 1) : "";
9978
9979
  try {
9979
9980
  for (const [key, value] of new URLSearchParams(queryString)) {
@@ -9986,7 +9987,7 @@ function createRequest(req2) {
9986
9987
  }
9987
9988
  tReq.params = {};
9988
9989
  w.query = query;
9989
- w.path = path10;
9990
+ w.path = path9;
9990
9991
  w.queryString = queryString;
9991
9992
  w.url = fullUrl;
9992
9993
  tReq.body = void 0;
@@ -10101,14 +10102,14 @@ function extractBoundary(contentType) {
10101
10102
  function parseMultipart(body, boundary) {
10102
10103
  const pairs = [];
10103
10104
  const files = {};
10104
- const delimiter2 = Buffer.from(`--${boundary}`);
10105
+ const delimiter3 = Buffer.from(`--${boundary}`);
10105
10106
  const closeDelimiter = Buffer.from(`--${boundary}--`);
10106
10107
  const crlf = Buffer.from("\r\n");
10107
10108
  const doubleCrlf = Buffer.from("\r\n\r\n");
10108
10109
  let offset = 0;
10109
- const firstIdx = bufferIndexOf(body, delimiter2, offset);
10110
+ const firstIdx = bufferIndexOf(body, delimiter3, offset);
10110
10111
  if (firstIdx === -1) return { fields: {}, files };
10111
- offset = firstIdx + delimiter2.length;
10112
+ offset = firstIdx + delimiter3.length;
10112
10113
  if (body[offset] === 13 && body[offset + 1] === 10) {
10113
10114
  offset += 2;
10114
10115
  }
@@ -10117,7 +10118,7 @@ function parseMultipart(body, boundary) {
10117
10118
  if (headersEnd === -1) break;
10118
10119
  const headersStr = body.subarray(offset, headersEnd).toString("utf-8");
10119
10120
  offset = headersEnd + doubleCrlf.length;
10120
- const nextDelimIdx = bufferIndexOf(body, delimiter2, offset);
10121
+ const nextDelimIdx = bufferIndexOf(body, delimiter3, offset);
10121
10122
  if (nextDelimIdx === -1) break;
10122
10123
  const contentEnd = nextDelimIdx - crlf.length;
10123
10124
  const content = body.subarray(offset, contentEnd);
@@ -10141,7 +10142,7 @@ function parseMultipart(body, boundary) {
10141
10142
  } else if (disposition.name) {
10142
10143
  pairs.push([disposition.name, content.toString("utf-8")]);
10143
10144
  }
10144
- offset = nextDelimIdx + delimiter2.length;
10145
+ offset = nextDelimIdx + delimiter3.length;
10145
10146
  if (body[offset] === 45 && body[offset + 1] === 45) {
10146
10147
  break;
10147
10148
  }
@@ -10701,6 +10702,7 @@ __export(routeDiscovery_exports, {
10701
10702
  });
10702
10703
  import { readdirSync as readdirSync2, statSync as statSync5, mkdirSync as mkdirSync4, writeFileSync as writeFileSync3, existsSync as existsSync6 } from "node:fs";
10703
10704
  import { join as join7, relative, basename as basename2, extname } from "node:path";
10705
+ import { pathToFileURL } from "node:url";
10704
10706
  function boolExport(value) {
10705
10707
  return typeof value === "boolean" ? value : void 0;
10706
10708
  }
@@ -10722,7 +10724,7 @@ async function discoverRoutes(routesDir) {
10722
10724
  const relativePath2 = relative(routesDir, filePath);
10723
10725
  const pattern = filePathToPattern(relativePath2);
10724
10726
  try {
10725
- const moduleUrl = `file://${filePath}?t=${currentMtime}`;
10727
+ const moduleUrl = `${pathToFileURL(filePath).href}?t=${currentMtime}`;
10726
10728
  const mod = await import(moduleUrl);
10727
10729
  const handler = mod.default ?? mod.handler;
10728
10730
  if (typeof handler !== "function") {
@@ -10763,7 +10765,7 @@ function recordBrokenImport(filePath, error2) {
10763
10765
  try {
10764
10766
  const brokenDir = join7(process.cwd(), "data", ".broken");
10765
10767
  if (!existsSync6(brokenDir)) mkdirSync4(brokenDir, { recursive: true });
10766
- const slug = filePath.replace(/[/\\]/g, "_");
10768
+ const slug = filePath.replace(/[/\\:]/g, "_");
10767
10769
  const payload = JSON.stringify({
10768
10770
  type: "auto_discover_failure",
10769
10771
  file: filePath,
@@ -10903,17 +10905,17 @@ function sleepSync(ms) {
10903
10905
  if (ms <= 0) return;
10904
10906
  Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
10905
10907
  }
10906
- function bindable(host, port) {
10908
+ function probeBind(host, port, timeout = 5e3) {
10907
10909
  try {
10908
- execFileSync(process.execPath, ["-e", BIND_PROBE, host, String(port)], { stdio: "ignore", timeout: 5e3 });
10909
- return true;
10910
- } catch {
10911
- return false;
10910
+ execFileSync(process.execPath, ["-e", BIND_PROBE, host, String(port)], { stdio: "ignore", timeout });
10911
+ return "free";
10912
+ } catch (err) {
10913
+ return err.status === PROBE_HELD ? "held" : "unknown";
10912
10914
  }
10913
10915
  }
10914
10916
  function refusal(port, dev, noTakeover, host) {
10915
10917
  if (dev && !noTakeover) return null;
10916
- if (host !== void 0 && bindable(host, port)) {
10918
+ if (host !== void 0 && probeBind(host, port) !== "held") {
10917
10919
  return { status: TAKEOVER_NOTHING, port, killed: [], message: "" };
10918
10920
  }
10919
10921
  if (noTakeover) {
@@ -10961,7 +10963,7 @@ function takeOverPort(port, dev, noTakeover, baseDir, grace = 500, host) {
10961
10963
  `Reclaimed port ${port} from Tina4 dev server (PID: ${killed.join(", ")}).`
10962
10964
  );
10963
10965
  }
10964
- var TAKEOVER_NOTHING, TAKEOVER_KILLED, TAKEOVER_REFUSED_FOREIGN, TAKEOVER_REFUSED_OPTOUT, TAKEOVER_REFUSED_PROD, TAKEOVER_SKIPPED_CONTAINER, TAKEOVER_REFUSALS, BIND_PROBE;
10966
+ var TAKEOVER_NOTHING, TAKEOVER_KILLED, TAKEOVER_REFUSED_FOREIGN, TAKEOVER_REFUSED_OPTOUT, TAKEOVER_REFUSED_PROD, TAKEOVER_SKIPPED_CONTAINER, TAKEOVER_REFUSALS, PROBE_HELD, PROBE_OTHER, BIND_PROBE;
10965
10967
  var init_portTakeover = __esm({
10966
10968
  "../core/src/portTakeover.ts"() {
10967
10969
  "use strict";
@@ -10976,7 +10978,9 @@ var init_portTakeover = __esm({
10976
10978
  TAKEOVER_REFUSED_OPTOUT,
10977
10979
  TAKEOVER_REFUSED_PROD
10978
10980
  ];
10979
- BIND_PROBE = 'const s = require("node:net").createServer();s.on("error", () => process.exit(1));s.listen({ host: process.argv[1], port: Number(process.argv[2]) }, () => s.close(() => process.exit(0)));';
10981
+ PROBE_HELD = 3;
10982
+ PROBE_OTHER = 4;
10983
+ BIND_PROBE = `const s = require("node:net").createServer();s.on("error", (e) => process.exit(e && e.code === "EADDRINUSE" ? ${PROBE_HELD} : ${PROBE_OTHER}));s.listen({ host: process.argv[1], port: Number(process.argv[2]) }, () => s.close(() => process.exit(0)));`;
10980
10984
  }
10981
10985
  });
10982
10986
 
@@ -12154,6 +12158,21 @@ var init_databaseHandler = __esm({
12154
12158
  }
12155
12159
  return this.sqliteHandle;
12156
12160
  }
12161
+ /**
12162
+ * Release the SQLite connection this handler opened, so its file (and the
12163
+ * WAL's -wal / -shm side files) is no longer held open: on Windows an open
12164
+ * file cannot be deleted or replaced. Idempotent, and the next read or write
12165
+ * reopens the connection. A server engine needs nothing here - each call goes
12166
+ * through the sync bridge, which holds no connection between calls.
12167
+ */
12168
+ close() {
12169
+ if (this.sqliteHandle === null) return;
12170
+ try {
12171
+ this.sqliteHandle.close();
12172
+ } finally {
12173
+ this.sqliteHandle = null;
12174
+ }
12175
+ }
12157
12176
  get engine() {
12158
12177
  return this.target === null ? "sqlite" : this.target.engine;
12159
12178
  }
@@ -13354,8 +13373,8 @@ function tryServeStatic(staticDir, req2, res) {
13354
13373
  }
13355
13374
  return false;
13356
13375
  }
13357
- function hasHiddenSegment(path10, separator = "/") {
13358
- return path10.split(separator).some((segment) => segment.length > 0 && segment.startsWith("."));
13376
+ function hasHiddenSegment(path9, separator = "/") {
13377
+ return path9.split(separator).some((segment) => segment.length > 0 && segment.startsWith("."));
13359
13378
  }
13360
13379
  function conditionalHeader(req2, name) {
13361
13380
  const headers = req2.headers;
@@ -13679,10 +13698,10 @@ function createHealthRoute(version = "3.0.0") {
13679
13698
  function createHealthRoutes(version = "3.0.0") {
13680
13699
  startTime = Date.now();
13681
13700
  const routes = [];
13682
- const path10 = healthPath();
13701
+ const path9 = healthPath();
13683
13702
  routes.push({
13684
13703
  method: "GET",
13685
- pattern: path10,
13704
+ pattern: path9,
13686
13705
  handler: buildHandler(version),
13687
13706
  meta: {
13688
13707
  summary: "Health check",
@@ -13690,7 +13709,7 @@ function createHealthRoutes(version = "3.0.0") {
13690
13709
  tags: ["System"]
13691
13710
  }
13692
13711
  });
13693
- if (path10 !== "/health") {
13712
+ if (path9 !== "/health") {
13694
13713
  routes.push({
13695
13714
  method: "GET",
13696
13715
  pattern: "/health",
@@ -13768,9 +13787,72 @@ var init_rateLimiter = __esm({
13768
13787
  }
13769
13788
  });
13770
13789
 
13790
+ // ../core/src/batchSpawn.ts
13791
+ import { spawnSync } from "node:child_process";
13792
+ import { existsSync as existsSync9, statSync as statSync8 } from "node:fs";
13793
+ import { delimiter, extname as extname3, join as join11 } from "node:path";
13794
+ function isBatchFile(file, platform = process.platform) {
13795
+ return platform === "win32" && /\.(cmd|bat)$/i.test(file);
13796
+ }
13797
+ function escapeBatchArgument(arg) {
13798
+ let quoted = String(arg).replace(/(\\*)"/g, '$1$1\\"').replace(/(\\*)$/, "$1$1");
13799
+ quoted = `"${quoted}"`;
13800
+ return quoted.replace(CMD_META, "^$1").replace(CMD_META, "^$1");
13801
+ }
13802
+ function escapeBatchCommand(file) {
13803
+ return file.replace(CMD_META, "^$1");
13804
+ }
13805
+ function findExecutable(name, platform = process.platform) {
13806
+ if (platform !== "win32" || /[\\/]/.test(name) || extname3(name) !== "") return name;
13807
+ const exts = (process.env.PATHEXT || ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean);
13808
+ const dirs = (process.env.PATH || "").split(delimiter).filter(Boolean);
13809
+ const candidates = dirs.flatMap((dir) => exts.map((ext) => join11(dir, name + ext.toLowerCase())));
13810
+ return candidates.find(isRegularFile) ?? name;
13811
+ }
13812
+ function isRegularFile(path9) {
13813
+ try {
13814
+ return existsSync9(path9) && statSync8(path9).isFile();
13815
+ } catch {
13816
+ return false;
13817
+ }
13818
+ }
13819
+ function spawnSyncAllowingBatch(file, args, options = {}) {
13820
+ if (!isBatchFile(file)) return spawnSync(file, args, options);
13821
+ const line = [escapeBatchCommand(file), ...args.map(escapeBatchArgument)].join(" ");
13822
+ const shell = process.env.comspec || "cmd.exe";
13823
+ return spawnSync(shell, ["/d", "/s", "/c", `"${line}"`], {
13824
+ ...options,
13825
+ windowsVerbatimArguments: true
13826
+ });
13827
+ }
13828
+ function execFileSyncAllowingBatch(name, args, options = {}) {
13829
+ const result = spawnSyncAllowingBatch(findExecutable(name), args, { encoding: "utf-8", ...options });
13830
+ if (result.error) throw result.error;
13831
+ const stdout = String(result.stdout ?? "");
13832
+ const stderr = String(result.stderr ?? "");
13833
+ if (result.status !== 0) {
13834
+ const err = new Error(
13835
+ `Command failed: ${name} ${args.join(" ")} (exit ${result.status ?? result.signal})
13836
+ ${stderr}`.trim()
13837
+ );
13838
+ err.status = result.status;
13839
+ err.stdout = stdout;
13840
+ err.stderr = stderr;
13841
+ throw err;
13842
+ }
13843
+ return stdout;
13844
+ }
13845
+ var CMD_META;
13846
+ var init_batchSpawn = __esm({
13847
+ "../core/src/batchSpawn.ts"() {
13848
+ "use strict";
13849
+ CMD_META = /([()\][%!^"`<>&|;, *?])/g;
13850
+ }
13851
+ });
13852
+
13771
13853
  // ../core/src/devMailbox.ts
13772
- import { mkdirSync as mkdirSync7, readdirSync as readdirSync4, readFileSync as readFileSync9, writeFileSync as writeFileSync6, unlinkSync as unlinkSync6, existsSync as existsSync9 } from "node:fs";
13773
- import { join as join11 } from "node:path";
13854
+ import { mkdirSync as mkdirSync7, readdirSync as readdirSync4, readFileSync as readFileSync9, writeFileSync as writeFileSync6, unlinkSync as unlinkSync6, existsSync as existsSync10 } from "node:fs";
13855
+ import { join as join12 } from "node:path";
13774
13856
  import { randomUUID } from "node:crypto";
13775
13857
  var DevMailbox;
13776
13858
  var init_devMailbox = __esm({
@@ -13785,7 +13867,7 @@ var init_devMailbox = __esm({
13785
13867
  * Ensure a folder directory exists.
13786
13868
  */
13787
13869
  ensureFolder(folder) {
13788
- const dir = join11(this.mailboxDir, folder);
13870
+ const dir = join12(this.mailboxDir, folder);
13789
13871
  mkdirSync7(dir, { recursive: true });
13790
13872
  return dir;
13791
13873
  }
@@ -13824,10 +13906,10 @@ var init_devMailbox = __esm({
13824
13906
  read: false
13825
13907
  };
13826
13908
  const outboxDir = this.ensureFolder("outbox");
13827
- writeFileSync6(join11(outboxDir, `${id}.json`), JSON.stringify(message, null, 2));
13909
+ writeFileSync6(join12(outboxDir, `${id}.json`), JSON.stringify(message, null, 2));
13828
13910
  const inboxDir = this.ensureFolder("inbox");
13829
13911
  const inboxMessage = { ...message, type: "inbox" };
13830
- writeFileSync6(join11(inboxDir, `${id}.json`), JSON.stringify(inboxMessage, null, 2));
13912
+ writeFileSync6(join12(inboxDir, `${id}.json`), JSON.stringify(inboxMessage, null, 2));
13831
13913
  return { success: true, message: "Email captured to dev mailbox", id };
13832
13914
  }
13833
13915
  /**
@@ -13845,7 +13927,7 @@ var init_devMailbox = __esm({
13845
13927
  const sliced = files.slice(offset, offset + limit);
13846
13928
  for (const file of sliced) {
13847
13929
  try {
13848
- const msg = JSON.parse(readFileSync9(join11(dir, file), "utf-8"));
13930
+ const msg = JSON.parse(readFileSync9(join12(dir, file), "utf-8"));
13849
13931
  results.push(msg);
13850
13932
  } catch {
13851
13933
  }
@@ -13858,8 +13940,8 @@ var init_devMailbox = __esm({
13858
13940
  read(msgId) {
13859
13941
  const folders = ["inbox", "outbox"];
13860
13942
  for (const folder of folders) {
13861
- const filePath = join11(this.mailboxDir, folder, `${msgId}.json`);
13862
- if (existsSync9(filePath)) {
13943
+ const filePath = join12(this.mailboxDir, folder, `${msgId}.json`);
13944
+ if (existsSync10(filePath)) {
13863
13945
  try {
13864
13946
  const msg = JSON.parse(readFileSync9(filePath, "utf-8"));
13865
13947
  msg.read = true;
@@ -13882,7 +13964,7 @@ var init_devMailbox = __esm({
13882
13964
  const files = readdirSync4(dir).filter((f) => f.endsWith(".json"));
13883
13965
  for (const file of files) {
13884
13966
  try {
13885
- const msg = JSON.parse(readFileSync9(join11(dir, file), "utf-8"));
13967
+ const msg = JSON.parse(readFileSync9(join12(dir, file), "utf-8"));
13886
13968
  if (!msg.read) count++;
13887
13969
  } catch {
13888
13970
  }
@@ -13898,8 +13980,8 @@ var init_devMailbox = __esm({
13898
13980
  let deleted = false;
13899
13981
  const folders = ["inbox", "outbox"];
13900
13982
  for (const folder of folders) {
13901
- const filePath = join11(this.mailboxDir, folder, `${msgId}.json`);
13902
- if (existsSync9(filePath)) {
13983
+ const filePath = join12(this.mailboxDir, folder, `${msgId}.json`);
13984
+ if (existsSync10(filePath)) {
13903
13985
  try {
13904
13986
  unlinkSync6(filePath);
13905
13987
  deleted = true;
@@ -13915,12 +13997,12 @@ var init_devMailbox = __esm({
13915
13997
  clear(folder) {
13916
13998
  const folders = folder ? [folder] : ["inbox", "outbox"];
13917
13999
  for (const f of folders) {
13918
- const dir = join11(this.mailboxDir, f);
14000
+ const dir = join12(this.mailboxDir, f);
13919
14001
  try {
13920
- if (existsSync9(dir)) {
14002
+ if (existsSync10(dir)) {
13921
14003
  const files = readdirSync4(dir).filter((file) => file.endsWith(".json"));
13922
14004
  for (const file of files) {
13923
- unlinkSync6(join11(dir, file));
14005
+ unlinkSync6(join12(dir, file));
13924
14006
  }
13925
14007
  }
13926
14008
  } catch {
@@ -13973,7 +14055,7 @@ Generated by DevMailbox.seed() for development purposes.`,
13973
14055
  // first two are unread
13974
14056
  };
13975
14057
  const dir = this.ensureFolder("inbox");
13976
- writeFileSync6(join11(dir, `${id}.json`), JSON.stringify(message, null, 2));
14058
+ writeFileSync6(join12(dir, `${id}.json`), JSON.stringify(message, null, 2));
13977
14059
  }
13978
14060
  }
13979
14061
  /**
@@ -13981,9 +14063,9 @@ Generated by DevMailbox.seed() for development purposes.`,
13981
14063
  */
13982
14064
  count(folder) {
13983
14065
  const countDir = (f) => {
13984
- const dir = join11(this.mailboxDir, f);
14066
+ const dir = join12(this.mailboxDir, f);
13985
14067
  try {
13986
- if (existsSync9(dir)) {
14068
+ if (existsSync10(dir)) {
13987
14069
  return readdirSync4(dir).filter((file) => file.endsWith(".json")).length;
13988
14070
  }
13989
14071
  } catch {
@@ -14024,8 +14106,8 @@ var init_upstreamResponse = __esm({
14024
14106
  // ../core/src/metrics.ts
14025
14107
  import * as fs3 from "node:fs";
14026
14108
  import * as path2 from "node:path";
14027
- import { spawnSync } from "node:child_process";
14028
- import { fileURLToPath } from "node:url";
14109
+ import { spawnSync as spawnSync2 } from "node:child_process";
14110
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
14029
14111
  function containsTypeScript(directory) {
14030
14112
  if (!fs3.existsSync(directory) || !fs3.statSync(directory).isDirectory()) return false;
14031
14113
  for (const entry of fs3.readdirSync(directory, { withFileTypes: true })) {
@@ -14036,7 +14118,7 @@ function containsTypeScript(directory) {
14036
14118
  return false;
14037
14119
  }
14038
14120
  function resolveTarget(root = "src") {
14039
- const resolved = containsTypeScript(root) ? path2.resolve(root) : path2.dirname(fileURLToPath(import.meta.url));
14121
+ const resolved = containsTypeScript(root) ? path2.resolve(root) : path2.dirname(fileURLToPath2(import.meta.url));
14040
14122
  const mode = containsTypeScript(root) ? "project" : "framework";
14041
14123
  lastScanRoot = resolved;
14042
14124
  return [resolved, mode];
@@ -14064,7 +14146,7 @@ function enginePath() {
14064
14146
  function runEngine(target) {
14065
14147
  const binary = enginePath();
14066
14148
  if (!binary) throw new MetricsEngineError(`tina4 not found on PATH - ${INSTALL_HINT}`);
14067
- const processResult = spawnSync(binary, ["metrics", "--path", target, "--json", "--no-history"], {
14149
+ const processResult = spawnSync2(binary, ["metrics", "--path", target, "--json", "--no-history"], {
14068
14150
  encoding: "utf8",
14069
14151
  timeout: 6e4,
14070
14152
  maxBuffer: 64 * 1024 * 1024
@@ -14157,9 +14239,9 @@ var init_metrics = __esm({
14157
14239
  });
14158
14240
 
14159
14241
  // ../core/src/feedback.ts
14160
- import { readFileSync as readFileSync10, existsSync as existsSync11 } from "node:fs";
14161
- import { dirname as dirname5, join as join13, resolve as resolve5 } from "node:path";
14162
- import { fileURLToPath as fileURLToPath2 } from "node:url";
14242
+ import { readFileSync as readFileSync10, existsSync as existsSync12 } from "node:fs";
14243
+ import { dirname as dirname5, join as join14, resolve as resolve5 } from "node:path";
14244
+ import { fileURLToPath as fileURLToPath3 } from "node:url";
14163
14245
  function feedbackEnabled() {
14164
14246
  const raw = (process.env.TINA4_ENABLE_FEEDBACK ?? "").trim().toLowerCase();
14165
14247
  return raw === "1" || raw === "true" || raw === "yes" || raw === "on";
@@ -14208,8 +14290,8 @@ function feedbackRateLimitOk(user) {
14208
14290
  }
14209
14291
  function injectFeedbackWidget(request, html) {
14210
14292
  if (!html) return html;
14211
- const path10 = (request.path ?? "") || "";
14212
- if (path10.startsWith("/__dev") || path10.startsWith("/__feedback")) return html;
14293
+ const path9 = (request.path ?? "") || "";
14294
+ if (path9.startsWith("/__dev") || path9.startsWith("/__feedback")) return html;
14213
14295
  if (html.includes("data-tina4-feedback")) return html;
14214
14296
  const [allowed] = feedbackIsWhitelisted(request);
14215
14297
  if (!allowed) return html;
@@ -14285,11 +14367,11 @@ var init_feedback = __esm({
14285
14367
  clearTimeout(timer);
14286
14368
  await relayUpstreamResponse(res, upstream);
14287
14369
  };
14288
- __feedbackDirname = dirname5(fileURLToPath2(import.meta.url));
14370
+ __feedbackDirname = dirname5(fileURLToPath3(import.meta.url));
14289
14371
  WIDGET_BUNDLE_PATH = resolve5(__feedbackDirname, "__feedback", "widget.js");
14290
14372
  handleFeedbackWidgetJs = (_req, res) => {
14291
14373
  let body;
14292
- if (existsSync11(WIDGET_BUNDLE_PATH)) {
14374
+ if (existsSync12(WIDGET_BUNDLE_PATH)) {
14293
14375
  body = readFileSync10(WIDGET_BUNDLE_PATH);
14294
14376
  } else {
14295
14377
  body = "console.warn('tina4-feedback-widget bundle not built yet');";
@@ -14305,14 +14387,14 @@ var init_feedback = __esm({
14305
14387
  });
14306
14388
 
14307
14389
  // ../core/src/version.ts
14308
- import { existsSync as existsSync12, readFileSync as readFileSync11 } from "node:fs";
14309
- import { dirname as dirname6, join as join14 } from "node:path";
14310
- import { fileURLToPath as fileURLToPath3 } from "node:url";
14390
+ import { existsSync as existsSync13, readFileSync as readFileSync11 } from "node:fs";
14391
+ import { dirname as dirname6, join as join15 } from "node:path";
14392
+ import { fileURLToPath as fileURLToPath4 } from "node:url";
14311
14393
  function resolveFrameworkVersion() {
14312
- let dir = dirname6(fileURLToPath3(import.meta.url));
14394
+ let dir = dirname6(fileURLToPath4(import.meta.url));
14313
14395
  for (let i = 0; i < 6; i++) {
14314
- const pkgPath = join14(dir, "package.json");
14315
- if (existsSync12(pkgPath)) {
14396
+ const pkgPath = join15(dir, "package.json");
14397
+ if (existsSync13(pkgPath)) {
14316
14398
  try {
14317
14399
  const pkg = JSON.parse(readFileSync11(pkgPath, "utf-8"));
14318
14400
  if (typeof pkg.version === "string" && pkg.version) return pkg.version;
@@ -14394,27 +14476,27 @@ __export(generate_exports, {
14394
14476
  toSnake: () => toSnake,
14395
14477
  toTableName: () => toTableName
14396
14478
  });
14397
- import { existsSync as existsSync13, mkdirSync as mkdirSync8, writeFileSync as writeFileSync7, readdirSync as readdirSync6, copyFileSync } from "node:fs";
14398
- import { join as join15, relative as relative2, resolve as resolve6, sep as sep3, dirname as dirname7 } from "node:path";
14399
- import { fileURLToPath as fileURLToPath4 } from "node:url";
14479
+ import { existsSync as existsSync14, mkdirSync as mkdirSync8, writeFileSync as writeFileSync7, readdirSync as readdirSync6, copyFileSync } from "node:fs";
14480
+ import { join as join16, relative as relative2, resolve as resolve6, sep as sep3, dirname as dirname7 } from "node:path";
14481
+ import { fileURLToPath as fileURLToPath5 } from "node:url";
14400
14482
  function ensureDir(dir) {
14401
14483
  if (__resolution.dryRun) return;
14402
- if (!existsSync13(dir)) {
14484
+ if (!existsSync14(dir)) {
14403
14485
  mkdirSync8(dir, { recursive: true });
14404
14486
  }
14405
14487
  }
14406
- function writeFileSafe(path10, content) {
14407
- captureEditHints(path10, content);
14488
+ function writeFileSafe(path9, content) {
14489
+ captureEditHints(path9, content);
14408
14490
  if (__resolution.dryRun) {
14409
14491
  return;
14410
14492
  }
14411
- if (existsSync13(path10)) {
14412
- if (!__resolution.jsonMode) console.log(` File already exists: ${path10}`);
14493
+ if (existsSync14(path9)) {
14494
+ if (!__resolution.jsonMode) console.log(` File already exists: ${path9}`);
14413
14495
  return;
14414
14496
  }
14415
- writeFileSync7(path10, content, "utf-8");
14416
- __resolution.actionsTaken.push(`wrote ${path10}`);
14417
- if (!__resolution.jsonMode) console.log(` Created ${path10}`);
14497
+ writeFileSync7(path9, content, "utf-8");
14498
+ __resolution.actionsTaken.push(`wrote ${path9}`);
14499
+ if (!__resolution.jsonMode) console.log(` Created ${path9}`);
14418
14500
  }
14419
14501
  function toSnake(name) {
14420
14502
  return name.replace(/([A-Z]+)([A-Z][a-z])/g, "$1_$2").replace(/([a-z0-9])([A-Z])/g, "$1_$2").toLowerCase();
@@ -14506,9 +14588,9 @@ function pushRoute(routePattern) {
14506
14588
  if (!__resolution.body.routes) __resolution.body.routes = [];
14507
14589
  __resolution.body.routes.push(routePattern);
14508
14590
  }
14509
- function pushTestPath(path10) {
14591
+ function pushTestPath(path9) {
14510
14592
  if (!__resolution.body.test_paths) __resolution.body.test_paths = [];
14511
- __resolution.body.test_paths.push(path10);
14593
+ __resolution.body.test_paths.push(path9);
14512
14594
  }
14513
14595
  function pushEditHint(hint) {
14514
14596
  if (!__resolution.body.edit_hints) __resolution.body.edit_hints = [];
@@ -14739,7 +14821,7 @@ function generateModel(name, flags, emitTest = true) {
14739
14821
  const table2 = resolveTable(name, flags, { announce: true });
14740
14822
  const dir = resolve6("src/models");
14741
14823
  ensureDir(dir);
14742
- const path10 = join15(dir, `${name}.ts`);
14824
+ const path9 = join16(dir, `${name}.ts`);
14743
14825
  setResolutionField("class_name", name);
14744
14826
  setResolutionField("table_name", table2);
14745
14827
  setResolutionField("file_path", `src/models/${name}.ts`);
@@ -14762,7 +14844,7 @@ ${fieldLines.join("\n")}
14762
14844
  };
14763
14845
  }
14764
14846
  `;
14765
- writeFileSafe(path10, content);
14847
+ writeFileSafe(path9, content);
14766
14848
  if (!flags["no-migration"]) {
14767
14849
  generateMigration(`create_${table2}`, flags, fields, table2, false);
14768
14850
  }
@@ -14779,7 +14861,7 @@ function generateRoute(name, flags, emitTest = true) {
14779
14861
  const model = flags.model;
14780
14862
  const isPublic = Boolean(flags.public);
14781
14863
  const base = resolve6("src/routes/api", routePath);
14782
- const idDir = join15(base, "[id]");
14864
+ const idDir = join16(base, "[id]");
14783
14865
  ensureDir(base);
14784
14866
  ensureDir(idDir);
14785
14867
  pushRoute(`/api/${routePath}`);
@@ -14795,7 +14877,7 @@ function generateRoute(name, flags, emitTest = true) {
14795
14877
  const writeDoc = isPublic ? "Public (--public): no token required." : "Secure by default: requires a Bearer token (use --public to open).";
14796
14878
  if (model) {
14797
14879
  writeFileSafe(
14798
- join15(base, "get.ts"),
14880
+ join16(base, "get.ts"),
14799
14881
  `import type { Tina4Request, Tina4Response } from "tina4-nodejs";
14800
14882
  ${modelImportBase}
14801
14883
  export const meta = { summary: "List all ${routePath}", tags: ["${routePath}"] };
@@ -14812,7 +14894,7 @@ export default async function (req: Tina4Request, res: Tina4Response) {
14812
14894
  );
14813
14895
  } else {
14814
14896
  writeFileSafe(
14815
- join15(base, "get.ts"),
14897
+ join16(base, "get.ts"),
14816
14898
  `import type { Tina4Request, Tina4Response } from "tina4-nodejs";
14817
14899
 
14818
14900
  export const meta = { summary: "List all ${routePath}", tags: ["${routePath}"] };
@@ -14831,7 +14913,7 @@ ${aiFill(`list_${routePath}`, {
14831
14913
  }
14832
14914
  if (model) {
14833
14915
  writeFileSafe(
14834
- join15(base, "post.ts"),
14916
+ join16(base, "post.ts"),
14835
14917
  `import type { Tina4Request, Tina4Response } from "tina4-nodejs";
14836
14918
  ${modelImportBase}${secureOptOut(isPublic)}export const meta = { summary: "Create a new ${singular}", tags: ["${routePath}"] };
14837
14919
 
@@ -14854,7 +14936,7 @@ ${extend(
14854
14936
  );
14855
14937
  } else {
14856
14938
  writeFileSafe(
14857
- join15(base, "post.ts"),
14939
+ join16(base, "post.ts"),
14858
14940
  `import type { Tina4Request, Tina4Response } from "tina4-nodejs";
14859
14941
 
14860
14942
  ${secureOptOut(isPublic)}export const meta = { summary: "Create a new ${singular}", tags: ["${routePath}"] };
@@ -14875,7 +14957,7 @@ ${aiFill(`create_${singular}`, {
14875
14957
  }
14876
14958
  if (model) {
14877
14959
  writeFileSafe(
14878
- join15(idDir, "get.ts"),
14960
+ join16(idDir, "get.ts"),
14879
14961
  `import type { Tina4Request, Tina4Response } from "tina4-nodejs";
14880
14962
  ${modelImportId}
14881
14963
  export const meta = { summary: "Get a ${singular} by ID", tags: ["${routePath}"] };
@@ -14893,7 +14975,7 @@ export default async function (req: Tina4Request, res: Tina4Response) {
14893
14975
  );
14894
14976
  } else {
14895
14977
  writeFileSafe(
14896
- join15(idDir, "get.ts"),
14978
+ join16(idDir, "get.ts"),
14897
14979
  `import type { Tina4Request, Tina4Response } from "tina4-nodejs";
14898
14980
 
14899
14981
  export const meta = { summary: "Get a ${singular} by ID", tags: ["${routePath}"] };
@@ -14912,7 +14994,7 @@ ${aiFill(`get_${singular}`, {
14912
14994
  }
14913
14995
  if (model) {
14914
14996
  writeFileSafe(
14915
- join15(idDir, "put.ts"),
14997
+ join16(idDir, "put.ts"),
14916
14998
  `import type { Tina4Request, Tina4Response } from "tina4-nodejs";
14917
14999
  ${modelImportId}${secureOptOut(isPublic)}export const meta = { summary: "Update a ${singular} by ID", tags: ["${routePath}"] };
14918
15000
 
@@ -14941,7 +15023,7 @@ ${extend(
14941
15023
  );
14942
15024
  } else {
14943
15025
  writeFileSafe(
14944
- join15(idDir, "put.ts"),
15026
+ join16(idDir, "put.ts"),
14945
15027
  `import type { Tina4Request, Tina4Response } from "tina4-nodejs";
14946
15028
 
14947
15029
  ${secureOptOut(isPublic)}export const meta = { summary: "Update a ${singular} by ID", tags: ["${routePath}"] };
@@ -14962,7 +15044,7 @@ ${aiFill(`update_${singular}`, {
14962
15044
  }
14963
15045
  if (model) {
14964
15046
  writeFileSafe(
14965
- join15(idDir, "delete.ts"),
15047
+ join16(idDir, "delete.ts"),
14966
15048
  `import type { Tina4Request, Tina4Response } from "tina4-nodejs";
14967
15049
  ${modelImportId}${secureOptOut(isPublic)}export const meta = { summary: "Delete a ${singular} by ID", tags: ["${routePath}"] };
14968
15050
 
@@ -14981,7 +15063,7 @@ export default async function (req: Tina4Request, res: Tina4Response) {
14981
15063
  );
14982
15064
  } else {
14983
15065
  writeFileSafe(
14984
- join15(idDir, "delete.ts"),
15066
+ join16(idDir, "delete.ts"),
14985
15067
  `import type { Tina4Request, Tina4Response } from "tina4-nodejs";
14986
15068
 
14987
15069
  ${secureOptOut(isPublic)}export const meta = { summary: "Delete a ${singular} by ID", tags: ["${routePath}"] };
@@ -15058,10 +15140,10 @@ export default async function (req: Tina4Request, res: Tina4Response) {
15058
15140
  return res.html(await Crud.toCrud(req, { model: ${model}, title: "${model} Admin"${publicOpt} }));
15059
15141
  }
15060
15142
  `;
15061
- writeFileSafe(join15(dir, "get.ts"), content);
15143
+ writeFileSafe(join16(dir, "get.ts"), content);
15062
15144
  }
15063
15145
  function frameworkCrudTemplatesDir() {
15064
- const here = dirname7(fileURLToPath4(import.meta.url));
15146
+ const here = dirname7(fileURLToPath5(import.meta.url));
15065
15147
  const candidates = [
15066
15148
  resolve6(here, "../../../core/templates/crud"),
15067
15149
  // monorepo: packages/cli/src/commands -> packages/core/templates/crud
@@ -15070,7 +15152,7 @@ function frameworkCrudTemplatesDir() {
15070
15152
  resolve6(here, "../templates/crud")
15071
15153
  // flattened publish fallback
15072
15154
  ];
15073
- return candidates.find((c) => existsSync13(c)) ?? null;
15155
+ return candidates.find((c) => existsSync14(c)) ?? null;
15074
15156
  }
15075
15157
  function copyCrudTemplates() {
15076
15158
  const sourceDir = frameworkCrudTemplatesDir();
@@ -15081,13 +15163,13 @@ function copyCrudTemplates() {
15081
15163
  const targetDir = resolve6("src/templates/crud");
15082
15164
  ensureDir(targetDir);
15083
15165
  for (const file of readdirSync6(sourceDir).filter((f) => f.endsWith(".twig")).sort()) {
15084
- const dest = join15(targetDir, file);
15085
- if (existsSync13(dest)) {
15166
+ const dest = join16(targetDir, file);
15167
+ if (existsSync14(dest)) {
15086
15168
  if (!__resolution.jsonMode) console.log(` File already exists: ${dest}`);
15087
15169
  continue;
15088
15170
  }
15089
15171
  if (__resolution.dryRun) continue;
15090
- copyFileSync(join15(sourceDir, file), dest);
15172
+ copyFileSync(join16(sourceDir, file), dest);
15091
15173
  __resolution.actionsTaken.push(`wrote ${dest}`);
15092
15174
  if (!__resolution.jsonMode) console.log(` Created ${dest}`);
15093
15175
  }
@@ -15145,7 +15227,7 @@ ${writeCase}
15145
15227
  console.log(\`\\nResults: \${pass} passed, \${fail} failed\`);
15146
15228
  process.exit(fail > 0 ? 1 : 0);
15147
15229
  `;
15148
- writeFileSafe(join15(dir, `${table2}.test.ts`), content);
15230
+ writeFileSafe(join16(dir, `${table2}.test.ts`), content);
15149
15231
  }
15150
15232
  function generateMigration(name, flags, fieldsOverride, tableOverride, emitTest = true) {
15151
15233
  const ts = timestamp();
@@ -15165,7 +15247,7 @@ function generateMigration(name, flags, fieldsOverride, tableOverride, emitTest
15165
15247
  const isCreate = name.startsWith("create_") || fieldsOverride !== void 0;
15166
15248
  const isView = isCreate && fieldsOverride === void 0 && table2.endsWith("_view");
15167
15249
  const fileName = `${ts}_${name}.sql`;
15168
- const path10 = join15(dir, fileName);
15250
+ const path9 = join16(dir, fileName);
15169
15251
  setResolutionField("migration_path", `migrations/${fileName}`);
15170
15252
  if (__resolution.target === "migration") {
15171
15253
  setResolutionField("file_path", `migrations/${fileName}`);
@@ -15206,8 +15288,8 @@ DROP TABLE IF EXISTS ${table2};`;
15206
15288
  -- UP
15207
15289
  ${upSql}
15208
15290
  `;
15209
- writeFileSafe(path10, content);
15210
- const downPath = join15(dir, `${ts}_${name}.down.sql`);
15291
+ writeFileSafe(path9, content);
15292
+ const downPath = join16(dir, `${ts}_${name}.down.sql`);
15211
15293
  const downContent = `-- Rollback: ${name}
15212
15294
  -- Created: ${now}
15213
15295
 
@@ -15220,7 +15302,7 @@ function generateMiddleware(name, _flags) {
15220
15302
  const snake = toSnake(name);
15221
15303
  const dir = resolve6("src/middleware");
15222
15304
  ensureDir(dir);
15223
- const path10 = join15(dir, `${snake}.ts`);
15305
+ const path9 = join16(dir, `${snake}.ts`);
15224
15306
  if (__resolution.target === "middleware") {
15225
15307
  setResolutionField("class_name", name);
15226
15308
  setResolutionField("file_path", `src/middleware/${snake}.ts`);
@@ -15258,7 +15340,7 @@ export async function after${name}(
15258
15340
  await next();
15259
15341
  }
15260
15342
  `;
15261
- writeFileSafe(path10, content);
15343
+ writeFileSafe(path9, content);
15262
15344
  emitMiddlewareTest(name, snake);
15263
15345
  }
15264
15346
  function generateTest(name, flags) {
@@ -15267,7 +15349,7 @@ function generateTest(name, flags) {
15267
15349
  const model = flags.model;
15268
15350
  const dir = resolve6("tests");
15269
15351
  ensureDir(dir);
15270
- const path10 = join15(dir, `${snake}.test.ts`);
15352
+ const path9 = join16(dir, `${snake}.test.ts`);
15271
15353
  if (model && flags["secure-writes"]) {
15272
15354
  const isPublic = Boolean(flags.public);
15273
15355
  const posture = isPublic ? "open (--public)" : "gated";
@@ -15316,7 +15398,7 @@ ${writeCase}
15316
15398
  console.log(\`\\nResults: \${pass} passed, \${fail} failed\`);
15317
15399
  process.exit(fail > 0 ? 1 : 0);
15318
15400
  `;
15319
- writeFileSafe(path10, content2);
15401
+ writeFileSafe(path9, content2);
15320
15402
  return;
15321
15403
  }
15322
15404
  let content;
@@ -15382,7 +15464,7 @@ const test${titleName} = tests(
15382
15464
  void test${titleName};
15383
15465
  `;
15384
15466
  }
15385
- writeFileSafe(path10, content);
15467
+ writeFileSafe(path9, content);
15386
15468
  void singular;
15387
15469
  }
15388
15470
  function generateForm(name, flags) {
@@ -15405,7 +15487,7 @@ function generateForm(name, flags) {
15405
15487
  };
15406
15488
  const dir = resolve6("src/templates/forms");
15407
15489
  ensureDir(dir);
15408
- const path10 = join15(dir, `${table2}.twig`);
15490
+ const path9 = join16(dir, `${table2}.twig`);
15409
15491
  let fieldHtml = "";
15410
15492
  for (const [fname, ftype] of fields) {
15411
15493
  const itype = inputTypes[ftype] || "text";
@@ -15449,7 +15531,7 @@ function generateForm(name, flags) {
15449
15531
  </div>
15450
15532
  {% endblock %}
15451
15533
  `;
15452
- writeFileSafe(path10, content);
15534
+ writeFileSafe(path9, content);
15453
15535
  }
15454
15536
  function generateView(name, flags) {
15455
15537
  const fields = fieldsOrDefault(flags.fields || "");
@@ -15458,7 +15540,7 @@ function generateView(name, flags) {
15458
15540
  const cols = fields.map(([f]) => f);
15459
15541
  const dir = resolve6("src/templates/pages");
15460
15542
  ensureDir(dir);
15461
- const listPath = join15(dir, `${routeName}.twig`);
15543
+ const listPath = join16(dir, `${routeName}.twig`);
15462
15544
  const th = cols.map((c) => ` <th>${c.replace(/_/g, " ").replace(/\b\w/g, (ch) => ch.toUpperCase())}</th>`).join("\n");
15463
15545
  const td = cols.map((c) => ` <td>{{ item.${c} }}</td>`).join("\n");
15464
15546
  const listContent = `{% extends "base.twig" %}
@@ -15495,7 +15577,7 @@ ${td}
15495
15577
  {% endblock %}
15496
15578
  `;
15497
15579
  writeFileSafe(listPath, listContent);
15498
- const detailPath = join15(dir, `${table2}.twig`);
15580
+ const detailPath = join16(dir, `${table2}.twig`);
15499
15581
  const detailFields = cols.map((c) => ` <div class="mb-3"><strong>${c.replace(/_/g, " ").replace(/\b\w/g, (ch) => ch.toUpperCase())}:</strong> {{ item.${c} }}</div>`).join("\n");
15500
15582
  const detailContent = `{% extends "base.twig" %}
15501
15583
  {% block title %}${name} Detail{% endblock %}
@@ -15525,7 +15607,7 @@ function generateAuth(_flags) {
15525
15607
  ensureDir(loginDir);
15526
15608
  ensureDir(meDir);
15527
15609
  writeFileSafe(
15528
- join15(registerDir, "post.ts"),
15610
+ join16(registerDir, "post.ts"),
15529
15611
  `import type { Tina4Request, Tina4Response } from "tina4-nodejs";
15530
15612
  import { hashPassword } from "tina4-nodejs";
15531
15613
  import User from "../../../../models/User.js";
@@ -15557,7 +15639,7 @@ export default async function (req: Tina4Request, res: Tina4Response) {
15557
15639
  `
15558
15640
  );
15559
15641
  writeFileSafe(
15560
- join15(loginDir, "post.ts"),
15642
+ join16(loginDir, "post.ts"),
15561
15643
  `import type { Tina4Request, Tina4Response } from "tina4-nodejs";
15562
15644
  import { checkPassword, getToken } from "tina4-nodejs";
15563
15645
  import User from "../../../../models/User.js";
@@ -15590,7 +15672,7 @@ export default async function (req: Tina4Request, res: Tina4Response) {
15590
15672
  `
15591
15673
  );
15592
15674
  writeFileSafe(
15593
- join15(meDir, "get.ts"),
15675
+ join16(meDir, "get.ts"),
15594
15676
  `import type { Tina4Request, Tina4Response } from "tina4-nodejs";
15595
15677
  import { authenticateRequest } from "tina4-nodejs";
15596
15678
 
@@ -15609,7 +15691,7 @@ export default async function (req: Tina4Request, res: Tina4Response) {
15609
15691
  const formsDir = resolve6("src/templates/forms");
15610
15692
  ensureDir(formsDir);
15611
15693
  writeFileSafe(
15612
- join15(formsDir, "login.twig"),
15694
+ join16(formsDir, "login.twig"),
15613
15695
  `{% extends "base.twig" %}
15614
15696
  {% block title %}Login{% endblock %}
15615
15697
  {% block content %}
@@ -15637,7 +15719,7 @@ export default async function (req: Tina4Request, res: Tina4Response) {
15637
15719
  `
15638
15720
  );
15639
15721
  writeFileSafe(
15640
- join15(formsDir, "register.twig"),
15722
+ join16(formsDir, "register.twig"),
15641
15723
  `{% extends "base.twig" %}
15642
15724
  {% block title %}Register{% endblock %}
15643
15725
  {% block content %}
@@ -15676,7 +15758,7 @@ function generateService(name, flags) {
15676
15758
  const cron = flags.cron;
15677
15759
  const dir = resolve6("src/services");
15678
15760
  ensureDir(dir);
15679
- const path10 = join15(dir, `${snake}.ts`);
15761
+ const path9 = join16(dir, `${snake}.ts`);
15680
15762
  let scheduleField;
15681
15763
  let note;
15682
15764
  if (cron && cron !== true) {
@@ -15719,7 +15801,7 @@ export default {
15719
15801
  ${scheduleField}
15720
15802
  };
15721
15803
  `;
15722
- writeFileSafe(path10, content);
15804
+ writeFileSafe(path9, content);
15723
15805
  emitServiceTest(name, snake, camel);
15724
15806
  }
15725
15807
  function generateQueue(name, _flags) {
@@ -15728,7 +15810,7 @@ function generateQueue(name, _flags) {
15728
15810
  const pascal = toPascal(topic) || "Topic";
15729
15811
  const dir = resolve6("src/services");
15730
15812
  ensureDir(dir);
15731
- const path10 = join15(dir, `${slug}_consumer.ts`);
15813
+ const path9 = join16(dir, `${slug}_consumer.ts`);
15732
15814
  const body = aiFill(`handle${pascal}`, {
15733
15815
  intent: `process ONE ${topic} job payload`,
15734
15816
  given: "payload -> the produced job data (job.payload)",
@@ -15783,13 +15865,13 @@ export default {
15783
15865
  daemon: true,
15784
15866
  };
15785
15867
  `;
15786
- writeFileSafe(path10, content);
15868
+ writeFileSafe(path9, content);
15787
15869
  emitQueueTest(topic, slug, pascal);
15788
15870
  }
15789
15871
  function generateValidator(name, _flags) {
15790
15872
  const dir = resolve6("src/validators");
15791
15873
  ensureDir(dir);
15792
- const path10 = join15(dir, `${toSnake(name)}.ts`);
15874
+ const path9 = join16(dir, `${toSnake(name)}.ts`);
15793
15875
  const rules = extend(
15794
15876
  "add / adjust the validation rules for this payload",
15795
15877
  `e.g. .email("email").minLength("name", 2).integer("age"); ground: tina4_context("validate request body with Validator", "nodejs")`
@@ -15810,14 +15892,14 @@ ${rules} validator.required("name"); // starter rule (matches the model's def
15810
15892
  return validator;
15811
15893
  }
15812
15894
  `;
15813
- writeFileSafe(path10, content);
15895
+ writeFileSafe(path9, content);
15814
15896
  emitValidatorTest(name, toSnake(name), toPascal(name));
15815
15897
  }
15816
15898
  function generateSeeder(name, flags) {
15817
15899
  const table2 = resolveTable(name, flags, { announce: false });
15818
15900
  const dir = resolve6("src/seeds");
15819
15901
  ensureDir(dir);
15820
- const path10 = join15(dir, `${table2}_seeder.ts`);
15902
+ const path9 = join16(dir, `${table2}_seeder.ts`);
15821
15903
  const overrides = extend(
15822
15904
  "override fields that need a specific shape (seedOrm auto-fills the rest)",
15823
15905
  `e.g. return { email: (f) => f.email(), status: "active" }; ground: tina4_context("seed ORM model with FakeData", "nodejs")`
@@ -15851,7 +15933,7 @@ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href)
15851
15933
  await run();
15852
15934
  }
15853
15935
  `;
15854
- writeFileSafe(path10, content);
15936
+ writeFileSafe(path9, content);
15855
15937
  emitSeederTest(name, table2);
15856
15938
  }
15857
15939
  function generateWebsocket(name, _flags) {
@@ -15862,7 +15944,7 @@ function generateWebsocket(name, _flags) {
15862
15944
  const handlerName = `${toCamel(toPascal(base))}Ws`;
15863
15945
  const dir = resolve6("src/routes");
15864
15946
  ensureDir(dir);
15865
- const path10 = join15(dir, `ws_${base}.ts`);
15947
+ const path9 = join16(dir, `ws_${base}.ts`);
15866
15948
  const body = aiFill(handlerName, {
15867
15949
  intent: `handle an inbound "message" frame on ${wsPath}`,
15868
15950
  given: "data -> the message payload (string); connection -> WebSocketConnection",
@@ -15904,7 +15986,7 @@ ${body}}
15904
15986
 
15905
15987
  websocket("${wsPath}", ${handlerName});
15906
15988
  `;
15907
- writeFileSafe(path10, content);
15989
+ writeFileSafe(path9, content);
15908
15990
  emitWebsocketTest(wsPath, base, handlerName);
15909
15991
  }
15910
15992
  function generateListener(name, _flags) {
@@ -15913,7 +15995,7 @@ function generateListener(name, _flags) {
15913
15995
  const handlerName = `on${toPascal(slug)}`;
15914
15996
  const dir = resolve6("src/listeners");
15915
15997
  ensureDir(dir);
15916
- const path10 = join15(dir, `${slug}.ts`);
15998
+ const path9 = join16(dir, `${slug}.ts`);
15917
15999
  const body = aiFill(handlerName, {
15918
16000
  intent: `react to the '${event}' event`,
15919
16001
  given: `args -> whatever Events.emit("${event}", ...args) passed`,
@@ -15939,13 +16021,13 @@ ${body}}
15939
16021
 
15940
16022
  Events.on("${event}", ${handlerName});
15941
16023
  `;
15942
- writeFileSafe(path10, content);
16024
+ writeFileSafe(path9, content);
15943
16025
  emitListenerTest(event, slug);
15944
16026
  }
15945
16027
  function writeTest(testName, content) {
15946
16028
  const dir = resolve6("tests");
15947
16029
  ensureDir(dir);
15948
- writeFileSafe(join15(dir, `${testName}.test.ts`), content);
16030
+ writeFileSafe(join16(dir, `${testName}.test.ts`), content);
15949
16031
  }
15950
16032
  function standaloneTest(doc, body) {
15951
16033
  return `${doc}
@@ -16611,7 +16693,6 @@ __export(mcp_exports, {
16611
16693
  import * as fs4 from "node:fs";
16612
16694
  import * as path3 from "node:path";
16613
16695
  import * as os from "node:os";
16614
- import { spawnSync as spawnSync2 } from "node:child_process";
16615
16696
  import { createRequire as createRequire2 } from "node:module";
16616
16697
  import { randomBytes as randomBytes5 } from "node:crypto";
16617
16698
  function reqSibling(pkg) {
@@ -16940,7 +17021,7 @@ function verifyNodeSyntax(absPath, relPath) {
16940
17021
  if (!target) return null;
16941
17022
  const { cmd, args } = syntaxCheckCommand(absPath, target.ext);
16942
17023
  try {
16943
- const proc = spawnSync2(cmd, args, {
17024
+ const proc = spawnSyncAllowingBatch(findExecutable(cmd), args, {
16944
17025
  encoding: "utf-8",
16945
17026
  timeout: 5e3,
16946
17027
  cwd: path3.dirname(path3.dirname(absPath))
@@ -17821,13 +17902,13 @@ function registerDevTools(server) {
17821
17902
  "git_status",
17822
17903
  () => {
17823
17904
  try {
17824
- const { execFileSync: execFileSync6 } = req("node:child_process");
17905
+ const { execFileSync: execFileSync5 } = req("node:child_process");
17825
17906
  const cwd = path3.resolve(process.cwd());
17826
17907
  const run = (args) => {
17827
- return execFileSync6("git", args, { cwd, timeout: 3e3, encoding: "utf-8" }).toString().trim();
17908
+ return execFileSync5("git", args, { cwd, timeout: 3e3, encoding: "utf-8" }).toString().trim();
17828
17909
  };
17829
17910
  try {
17830
- execFileSync6("git", ["rev-parse", "--is-inside-work-tree"], { cwd, timeout: 3e3 });
17911
+ execFileSync5("git", ["rev-parse", "--is-inside-work-tree"], { cwd, timeout: 3e3 });
17831
17912
  } catch {
17832
17913
  return { error: "Not a git repository" };
17833
17914
  }
@@ -17955,6 +18036,7 @@ var init_mcp = __esm({
17955
18036
  "../core/src/mcp.ts"() {
17956
18037
  "use strict";
17957
18038
  init_slashTrim();
18039
+ init_batchSpawn();
17958
18040
  init_version();
17959
18041
  req = createRequire2(import.meta.url);
17960
18042
  PARSE_ERROR = -32700;
@@ -19416,7 +19498,7 @@ function pack(segments, maxLines) {
19416
19498
  }
19417
19499
  return chunks;
19418
19500
  }
19419
- function chunkCode(text, path10 = "", maxLines = 60) {
19501
+ function chunkCode(text, path9 = "", maxLines = 60) {
19420
19502
  const lines = splitLines(text);
19421
19503
  let bounds = [];
19422
19504
  for (let i = 0; i < lines.length; i++) {
@@ -19430,7 +19512,7 @@ function chunkCode(text, path10 = "", maxLines = 60) {
19430
19512
  for (let k = 0; k < bounds.length; k++) {
19431
19513
  segments.push(lines.slice(bounds[k], ends[k]));
19432
19514
  }
19433
- const header = path10 ? `# file: ${path10}` : null;
19515
+ const header = path9 ? `# file: ${path9}` : null;
19434
19516
  const packed = pack(segments, maxLines);
19435
19517
  const out = [];
19436
19518
  for (let i = 0; i < packed.length; i++) {
@@ -19481,8 +19563,8 @@ __export(context_exports, {
19481
19563
  fts5Supported: () => fts5Supported
19482
19564
  });
19483
19565
  import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
19484
- import { existsSync as existsSync15, mkdirSync as mkdirSync10, readFileSync as readFileSync13, readdirSync as readdirSync8, realpathSync as realpathSync5 } from "node:fs";
19485
- import { basename as basename4, dirname as dirname9, extname as extname4, isAbsolute as isAbsolute4, join as join17, relative as relative4, resolve as resolve8 } from "node:path";
19566
+ import { existsSync as existsSync16, mkdirSync as mkdirSync10, readFileSync as readFileSync13, readdirSync as readdirSync8, realpathSync as realpathSync5 } from "node:fs";
19567
+ import { basename as basename4, dirname as dirname9, extname as extname5, isAbsolute as isAbsolute4, join as join18, relative as relative4, resolve as resolve8 } from "node:path";
19486
19568
  function fts5Supported() {
19487
19569
  try {
19488
19570
  const conn = new DatabaseSync2(":memory:");
@@ -19505,13 +19587,13 @@ function realResolve(abs) {
19505
19587
  } catch {
19506
19588
  }
19507
19589
  try {
19508
- return join17(realpathSync5(dirname9(abs)), basename4(abs));
19590
+ return join18(realpathSync5(dirname9(abs)), basename4(abs));
19509
19591
  } catch {
19510
19592
  return abs;
19511
19593
  }
19512
19594
  }
19513
19595
  function dbKey(db) {
19514
- return resolve8(db ? String(db) : join17(process.cwd(), ".tina4", "context.db"));
19596
+ return resolve8(db ? String(db) : join18(process.cwd(), ".tina4", "context.db"));
19515
19597
  }
19516
19598
  function defaultContext(root, db) {
19517
19599
  const key = dbKey(db);
@@ -19617,7 +19699,7 @@ var init_context = __esm({
19617
19699
  }
19618
19700
  // ── indexing ───────────────────────────────────────────────
19619
19701
  static chunksFor(label, text) {
19620
- const ext = extname4(label).toLowerCase();
19702
+ const ext = extname5(label).toLowerCase();
19621
19703
  const special = SPECIAL_FILES.has(basename4(label).toLowerCase());
19622
19704
  if (CODE_EXTS.has(ext) || CONFIG_EXTS.has(ext) || special) {
19623
19705
  return chunkCode(text, label);
@@ -19656,7 +19738,7 @@ var init_context = __esm({
19656
19738
  static eligible(filename) {
19657
19739
  const fn = filename.toLowerCase();
19658
19740
  if (fn.endsWith(".min.js")) return false;
19659
- const ext = extname4(fn);
19741
+ const ext = extname5(fn);
19660
19742
  return CODE_EXTS.has(ext) || DOC_EXTS.has(ext) || CONFIG_EXTS.has(ext) || SPECIAL_FILES.has(fn);
19661
19743
  }
19662
19744
  /**
@@ -19684,11 +19766,11 @@ var init_context = __esm({
19684
19766
  files.sort();
19685
19767
  for (const fn of files) {
19686
19768
  if (!_Context.eligible(fn)) continue;
19687
- const full = join17(dir, fn);
19769
+ const full = join18(dir, fn);
19688
19770
  const rel = relative4(rootAbs, full);
19689
19771
  total += this.indexPath(full, rel);
19690
19772
  }
19691
- for (const d of subdirs) walk2(join17(dir, d));
19773
+ for (const d of subdirs) walk2(join18(dir, d));
19692
19774
  };
19693
19775
  walk2(rootAbs);
19694
19776
  return total;
@@ -19704,7 +19786,7 @@ var init_context = __esm({
19704
19786
  reindexFile(changedPath) {
19705
19787
  if (!this.available || this.root === null) return -1;
19706
19788
  const raw = String(changedPath);
19707
- const abs = isAbsolute4(raw) ? raw : join17(process.cwd(), raw);
19789
+ const abs = isAbsolute4(raw) ? raw : join18(process.cwd(), raw);
19708
19790
  const resolved = realResolve(resolve8(abs));
19709
19791
  const rel = relative4(this.root, resolved);
19710
19792
  if (rel === "" || rel.startsWith("..") || isAbsolute4(rel)) {
@@ -19717,7 +19799,7 @@ var init_context = __esm({
19717
19799
  }
19718
19800
  if (!_Context.eligible(basename4(rel))) return -1;
19719
19801
  const stored = rel;
19720
- if (!existsSync15(abs)) {
19802
+ if (!existsSync16(abs)) {
19721
19803
  this.conn.prepare("DELETE FROM chunks WHERE path = ?").run(stored);
19722
19804
  return 0;
19723
19805
  }
@@ -19735,8 +19817,8 @@ var init_context = __esm({
19735
19817
  const expr = [...toks].sort().map((t) => `"${t}"`).join(" OR ");
19736
19818
  return { expr, toks };
19737
19819
  }
19738
- static isTestlike(path10) {
19739
- const s = (path10 || "").toLowerCase();
19820
+ static isTestlike(path9) {
19821
+ const s = (path9 || "").toLowerCase();
19740
19822
  return ["/test", "test/", "test_", "_test.", ".test.", "/example", "example/"].some((p) => s.includes(p));
19741
19823
  }
19742
19824
  static defines(foldedBody, symbols) {
@@ -20200,7 +20282,7 @@ function parseFrame(data) {
20200
20282
  const payload = data.subarray(offset, offset + payloadLen);
20201
20283
  return { fin: !!fin, opcode, payload: Buffer.from(payload), bytesConsumed: offset + payloadLen };
20202
20284
  }
20203
- function createRouteConnection(socket, path10, headers, params, auth) {
20285
+ function createRouteConnection(socket, path9, headers, params, auth) {
20204
20286
  const id = randomUUID3().slice(0, 8);
20205
20287
  const send = (message) => {
20206
20288
  try {
@@ -20210,14 +20292,14 @@ function createRouteConnection(socket, path10, headers, params, auth) {
20210
20292
  };
20211
20293
  const conn = {
20212
20294
  id,
20213
- path: path10,
20295
+ path: path9,
20214
20296
  ip: socket.remoteAddress ?? "unknown",
20215
20297
  headers,
20216
20298
  params,
20217
20299
  auth,
20218
20300
  send,
20219
20301
  sendJson: (data) => send(JSON.stringify(data)),
20220
- broadcast: (message) => wsRouteManager.broadcastPath(path10, message),
20302
+ broadcast: (message) => wsRouteManager.broadcastPath(path9, message),
20221
20303
  broadcastToRoom: (room, message, excludeSelf = false) => wsRouteManager.broadcastToRoom(room, message, excludeSelf ? id : void 0),
20222
20304
  getRoomConnections: (room) => wsRouteManager.getRoomConnections(room),
20223
20305
  joinRoom: (room) => wsRouteManager.joinRoom(id, room),
@@ -20426,8 +20508,8 @@ var init_websocket = __esm({
20426
20508
  * to the Router's `(conn, event, data)` style and registers it via
20427
20509
  * `Router.websocket()`.
20428
20510
  */
20429
- route(path10, handler, options) {
20430
- this._routeHandlers.set(path10, handler);
20511
+ route(path9, handler, options) {
20512
+ this._routeHandlers.set(path9, handler);
20431
20513
  const adapter = async (conn, event, data) => {
20432
20514
  if (event === "open") {
20433
20515
  const result = handler(conn);
@@ -20450,7 +20532,7 @@ var init_websocket = __esm({
20450
20532
  }
20451
20533
  }
20452
20534
  };
20453
- Router.websocket(path10, adapter, options);
20535
+ Router.websocket(path9, adapter, options);
20454
20536
  }
20455
20537
  /**
20456
20538
  * Broadcast a message to all connected clients.
@@ -20460,18 +20542,18 @@ var init_websocket = __esm({
20460
20542
  * When `path` is omitted/undefined, all clients receive the message
20461
20543
  * (backward compatible).
20462
20544
  */
20463
- broadcast(message, excludeIds, path10) {
20545
+ broadcast(message, excludeIds, path9) {
20464
20546
  this.ensureBackplane();
20465
20547
  const exclude = new Set(excludeIds ?? []);
20466
20548
  for (const [id, client] of Array.from(this.clients)) {
20467
20549
  if (exclude.has(id)) continue;
20468
- if (path10 !== void 0 && client.path !== path10) continue;
20550
+ if (path9 !== void 0 && client.path !== path9) continue;
20469
20551
  this.safeSend(client, message);
20470
20552
  }
20471
20553
  this.backplane.publish(
20472
- path10 !== void 0 ? "path" : "all",
20554
+ path9 !== void 0 ? "path" : "all",
20473
20555
  message,
20474
- { path: path10 ?? null, exclude: excludeIds?.[0] ?? null },
20556
+ { path: path9 ?? null, exclude: excludeIds?.[0] ?? null },
20475
20557
  Log
20476
20558
  );
20477
20559
  }
@@ -20947,10 +21029,10 @@ var init_websocket = __esm({
20947
21029
  }
20948
21030
  }
20949
21031
  /** Broadcast a text frame to every connection on the same path. */
20950
- broadcastPath(path10, message) {
21032
+ broadcastPath(path9, message) {
20951
21033
  const frame = buildFrame(OP_TEXT, Buffer.from(message, "utf-8"));
20952
21034
  for (const state of this.connections.values()) {
20953
- if (state.path !== path10 || state.closed) continue;
21035
+ if (state.path !== path9 || state.closed) continue;
20954
21036
  try {
20955
21037
  state.socket.write(frame);
20956
21038
  } catch {
@@ -22563,8 +22645,8 @@ var init_job = __esm({
22563
22645
  });
22564
22646
 
22565
22647
  // ../core/src/queueBackends/liteBackend.ts
22566
- import { mkdirSync as mkdirSync11, readdirSync as readdirSync9, readFileSync as readFileSync14, writeFileSync as writeFileSync9, unlinkSync as unlinkSync7, existsSync as existsSync16 } from "node:fs";
22567
- import { join as join18 } from "node:path";
22648
+ import { mkdirSync as mkdirSync11, readdirSync as readdirSync9, readFileSync as readFileSync14, writeFileSync as writeFileSync9, unlinkSync as unlinkSync7, existsSync as existsSync17 } from "node:fs";
22649
+ import { join as join19 } from "node:path";
22568
22650
  import { randomUUID as randomUUID6 } from "node:crypto";
22569
22651
  var LiteBackend;
22570
22652
  var init_liteBackend = __esm({
@@ -22588,22 +22670,22 @@ var init_liteBackend = __esm({
22588
22670
  this.visibilityTimeout = visibilityTimeout;
22589
22671
  }
22590
22672
  ensureDir(queue) {
22591
- const dir = join18(this.basePath, queue);
22673
+ const dir = join19(this.basePath, queue);
22592
22674
  mkdirSync11(dir, { recursive: true });
22593
22675
  return dir;
22594
22676
  }
22595
22677
  ensureFailedDir(queue) {
22596
- const dir = join18(this.basePath, queue, "failed");
22678
+ const dir = join19(this.basePath, queue, "failed");
22597
22679
  mkdirSync11(dir, { recursive: true });
22598
22680
  return dir;
22599
22681
  }
22600
22682
  ensureReservedDir(queue) {
22601
- const dir = join18(this.basePath, queue, "reserved");
22683
+ const dir = join19(this.basePath, queue, "reserved");
22602
22684
  mkdirSync11(dir, { recursive: true });
22603
22685
  return dir;
22604
22686
  }
22605
22687
  reservedPath(queue, jobId) {
22606
- return join18(this.ensureReservedDir(queue), `${jobId}.queue-data`);
22688
+ return join19(this.ensureReservedDir(queue), `${jobId}.queue-data`);
22607
22689
  }
22608
22690
  nowIso() {
22609
22691
  return (/* @__PURE__ */ new Date()).toISOString();
@@ -22646,7 +22728,7 @@ var init_liteBackend = __esm({
22646
22728
  error: void 0
22647
22729
  };
22648
22730
  const prefix = this.nextPrefix();
22649
- writeFileSync9(join18(dir, `${prefix}_${id}.queue-data`), JSON.stringify(job, null, 2));
22731
+ writeFileSync9(join19(dir, `${prefix}_${id}.queue-data`), JSON.stringify(job, null, 2));
22650
22732
  return id;
22651
22733
  }
22652
22734
  /**
@@ -22665,7 +22747,7 @@ var init_liteBackend = __esm({
22665
22747
  }
22666
22748
  const candidates = [];
22667
22749
  for (const filename of filenames) {
22668
- const filePath = join18(dir, filename);
22750
+ const filePath = join19(dir, filename);
22669
22751
  let job;
22670
22752
  try {
22671
22753
  job = JSON.parse(readFileSync14(filePath, "utf-8"));
@@ -22729,7 +22811,7 @@ var init_liteBackend = __esm({
22729
22811
  return;
22730
22812
  }
22731
22813
  for (const filename of filenames) {
22732
- const filePath = join18(reservedDir, filename);
22814
+ const filePath = join19(reservedDir, filename);
22733
22815
  let record2;
22734
22816
  try {
22735
22817
  record2 = JSON.parse(readFileSync14(filePath, "utf-8"));
@@ -22767,7 +22849,7 @@ var init_liteBackend = __esm({
22767
22849
  this.reclaimExpired(queue, bridge.getMaxRetries(), this.nowIso());
22768
22850
  const now = this.nowIso();
22769
22851
  for (const [filename, job] of this.availableCandidates(queue, now)) {
22770
- const filePath = join18(dir, filename);
22852
+ const filePath = join19(dir, filename);
22771
22853
  job.topic = queue;
22772
22854
  job.priority = job.priority ?? 0;
22773
22855
  this.writeReserved(queue, job);
@@ -22792,7 +22874,7 @@ var init_liteBackend = __esm({
22792
22874
  const results = [];
22793
22875
  for (const [filename, job] of this.availableCandidates(queue, now)) {
22794
22876
  if (results.length >= count) break;
22795
- const filePath = join18(dir, filename);
22877
+ const filePath = join19(dir, filename);
22796
22878
  job.topic = queue;
22797
22879
  job.priority = job.priority ?? 0;
22798
22880
  this.writeReserved(queue, job);
@@ -22845,7 +22927,7 @@ var init_liteBackend = __esm({
22845
22927
  let count = 0;
22846
22928
  for (const file of files) {
22847
22929
  try {
22848
- const job = JSON.parse(readFileSync14(join18(scanDir, file), "utf-8"));
22930
+ const job = JSON.parse(readFileSync14(join19(scanDir, file), "utf-8"));
22849
22931
  if (job.status === status2) count++;
22850
22932
  } catch {
22851
22933
  }
@@ -22858,28 +22940,28 @@ var init_liteBackend = __esm({
22858
22940
  try {
22859
22941
  const files = readdirSync9(dir).filter((f) => f.endsWith(".queue-data"));
22860
22942
  for (const file of files) {
22861
- unlinkSync7(join18(dir, file));
22943
+ unlinkSync7(join19(dir, file));
22862
22944
  count++;
22863
22945
  }
22864
22946
  } catch {
22865
22947
  }
22866
- const failedDir = join18(dir, "failed");
22948
+ const failedDir = join19(dir, "failed");
22867
22949
  try {
22868
- if (existsSync16(failedDir)) {
22950
+ if (existsSync17(failedDir)) {
22869
22951
  const files = readdirSync9(failedDir).filter((f) => f.endsWith(".queue-data"));
22870
22952
  for (const file of files) {
22871
- unlinkSync7(join18(failedDir, file));
22953
+ unlinkSync7(join19(failedDir, file));
22872
22954
  count++;
22873
22955
  }
22874
22956
  }
22875
22957
  } catch {
22876
22958
  }
22877
- const reservedDir = join18(dir, "reserved");
22959
+ const reservedDir = join19(dir, "reserved");
22878
22960
  try {
22879
- if (existsSync16(reservedDir)) {
22961
+ if (existsSync17(reservedDir)) {
22880
22962
  const files = readdirSync9(reservedDir).filter((f) => f.endsWith(".queue-data"));
22881
22963
  for (const file of files) {
22882
- unlinkSync7(join18(reservedDir, file));
22964
+ unlinkSync7(join19(reservedDir, file));
22883
22965
  count++;
22884
22966
  }
22885
22967
  }
@@ -22902,7 +22984,7 @@ var init_liteBackend = __esm({
22902
22984
  const files = readdirSync9(dir).filter((f) => f.endsWith(".queue-data")).sort();
22903
22985
  for (const file of files) {
22904
22986
  try {
22905
- const job = JSON.parse(readFileSync14(join18(dir, file), "utf-8"));
22987
+ const job = JSON.parse(readFileSync14(join19(dir, file), "utf-8"));
22906
22988
  const attempts = job.attempts || 0;
22907
22989
  if (attempts > 0 && attempts < maxRetries) {
22908
22990
  results.push(job);
@@ -22925,9 +23007,9 @@ var init_liteBackend = __esm({
22925
23007
  try {
22926
23008
  const queues = readdirSync9(this.basePath);
22927
23009
  for (const q of queues) {
22928
- const failedDir = join18(this.basePath, q, "failed");
22929
- const filePath = join18(failedDir, `${jobId}.queue-data`);
22930
- if (existsSync16(filePath)) {
23010
+ const failedDir = join19(this.basePath, q, "failed");
23011
+ const filePath = join19(failedDir, `${jobId}.queue-data`);
23012
+ if (existsSync17(filePath)) {
22931
23013
  const job = JSON.parse(readFileSync14(filePath, "utf-8"));
22932
23014
  job.status = "pending";
22933
23015
  job.attempts = (job.attempts || 0) + 1;
@@ -22935,8 +23017,8 @@ var init_liteBackend = __esm({
22935
23017
  job.createdAt = (/* @__PURE__ */ new Date()).toISOString();
22936
23018
  job.delayUntil = delaySeconds ? new Date(Date.now() + delaySeconds * 1e3).toISOString() : null;
22937
23019
  const prefix = this.nextPrefix();
22938
- const queueDir = join18(this.basePath, q);
22939
- writeFileSync9(join18(queueDir, `${prefix}_${jobId}.queue-data`), JSON.stringify(job, null, 2));
23020
+ const queueDir = join19(this.basePath, q);
23021
+ writeFileSync9(join19(queueDir, `${prefix}_${jobId}.queue-data`), JSON.stringify(job, null, 2));
22940
23022
  unlinkSync7(filePath);
22941
23023
  return true;
22942
23024
  }
@@ -22952,7 +23034,7 @@ var init_liteBackend = __esm({
22952
23034
  const files = readdirSync9(failedDir).filter((f) => f.endsWith(".queue-data")).sort();
22953
23035
  for (const file of files) {
22954
23036
  try {
22955
- const job = JSON.parse(readFileSync14(join18(failedDir, file), "utf-8"));
23037
+ const job = JSON.parse(readFileSync14(join19(failedDir, file), "utf-8"));
22956
23038
  if ((job.attempts || 0) >= maxRetries) {
22957
23039
  job.status = "dead";
22958
23040
  results.push(job);
@@ -22973,7 +23055,7 @@ var init_liteBackend = __esm({
22973
23055
  const files = readdirSync9(failedDir).filter((f) => f.endsWith(".queue-data"));
22974
23056
  for (const file of files) {
22975
23057
  try {
22976
- unlinkSync7(join18(failedDir, file));
23058
+ unlinkSync7(join19(failedDir, file));
22977
23059
  count++;
22978
23060
  } catch {
22979
23061
  }
@@ -22986,9 +23068,9 @@ var init_liteBackend = __esm({
22986
23068
  const files = readdirSync9(dir).filter((f) => f.endsWith(".queue-data"));
22987
23069
  for (const file of files) {
22988
23070
  try {
22989
- const job = JSON.parse(readFileSync14(join18(dir, file), "utf-8"));
23071
+ const job = JSON.parse(readFileSync14(join19(dir, file), "utf-8"));
22990
23072
  if (job.status === status2) {
22991
- unlinkSync7(join18(dir, file));
23073
+ unlinkSync7(join19(dir, file));
22992
23074
  count++;
22993
23075
  }
22994
23076
  } catch {
@@ -23012,7 +23094,7 @@ var init_liteBackend = __esm({
23012
23094
  const files = readdirSync9(failedDir).filter((f) => f.endsWith(".queue-data"));
23013
23095
  for (const file of files) {
23014
23096
  try {
23015
- const filePath = join18(failedDir, file);
23097
+ const filePath = join19(failedDir, file);
23016
23098
  const job = JSON.parse(readFileSync14(filePath, "utf-8"));
23017
23099
  if ((job.attempts || 0) >= maxRetries) {
23018
23100
  continue;
@@ -23022,7 +23104,7 @@ var init_liteBackend = __esm({
23022
23104
  job.createdAt = (/* @__PURE__ */ new Date()).toISOString();
23023
23105
  job.delayUntil = null;
23024
23106
  const prefix = this.nextPrefix();
23025
- writeFileSync9(join18(queueDir, `${prefix}_${job.id}.queue-data`), JSON.stringify(job, null, 2));
23107
+ writeFileSync9(join19(queueDir, `${prefix}_${job.id}.queue-data`), JSON.stringify(job, null, 2));
23026
23108
  unlinkSync7(filePath);
23027
23109
  count++;
23028
23110
  } catch {
@@ -23042,7 +23124,7 @@ var init_liteBackend = __esm({
23042
23124
  }
23043
23125
  for (const file of files) {
23044
23126
  if (!file.includes(id)) continue;
23045
- const filePath = join18(dir, file);
23127
+ const filePath = join19(dir, file);
23046
23128
  let job;
23047
23129
  try {
23048
23130
  job = JSON.parse(readFileSync14(filePath, "utf-8"));
@@ -23090,7 +23172,7 @@ var init_liteBackend = __esm({
23090
23172
  error: error2
23091
23173
  };
23092
23174
  const prefix = this.nextPrefix();
23093
- writeFileSync9(join18(dir, `${prefix}_${job.id}.queue-data`), JSON.stringify(jobData, null, 2));
23175
+ writeFileSync9(join19(dir, `${prefix}_${job.id}.queue-data`), JSON.stringify(jobData, null, 2));
23094
23176
  }
23095
23177
  /**
23096
23178
  * Move the job to the dead-letter (failed/) directory. Terminal until a
@@ -23110,7 +23192,7 @@ var init_liteBackend = __esm({
23110
23192
  error: error2,
23111
23193
  failedAt: (/* @__PURE__ */ new Date()).toISOString()
23112
23194
  };
23113
- writeFileSync9(join18(failedDir, `${job.id}.queue-data`), JSON.stringify(jobData, null, 2));
23195
+ writeFileSync9(join19(failedDir, `${job.id}.queue-data`), JSON.stringify(jobData, null, 2));
23114
23196
  }
23115
23197
  /**
23116
23198
  * Record a failed attempt.
@@ -23160,7 +23242,7 @@ var init_liteBackend = __esm({
23160
23242
  retryJob(queue, job, delaySeconds) {
23161
23243
  this.clearReservation(queue, job.id);
23162
23244
  try {
23163
- unlinkSync7(join18(this.ensureFailedDir(queue), `${job.id}.queue-data`));
23245
+ unlinkSync7(join19(this.ensureFailedDir(queue), `${job.id}.queue-data`));
23164
23246
  } catch {
23165
23247
  }
23166
23248
  job.attempts = (job.attempts || 0) + 1;
@@ -24300,6 +24382,9 @@ var init_projectIndexExtractors = __esm({
24300
24382
  import * as fs6 from "node:fs";
24301
24383
  import * as path6 from "node:path";
24302
24384
  import * as crypto2 from "node:crypto";
24385
+ function indexKey(root, fullPath) {
24386
+ return path6.relative(root, fullPath).split(path6.sep).join("/");
24387
+ }
24303
24388
  function projectRoot2() {
24304
24389
  return path6.resolve(process.cwd());
24305
24390
  }
@@ -24334,7 +24419,7 @@ function extract(fullPath) {
24334
24419
  return {};
24335
24420
  }
24336
24421
  const entry = {
24337
- path: path6.relative(projectRoot2(), fullPath),
24422
+ path: indexKey(projectRoot2(), fullPath),
24338
24423
  size: st.size,
24339
24424
  mtime: Math.floor(st.mtimeMs / 1e3),
24340
24425
  language: languageFor(fullPath)
@@ -24441,7 +24526,6 @@ var projectIndex_exports = {};
24441
24526
  __export(projectIndex_exports, {
24442
24527
  ProjectIndex: () => ProjectIndex
24443
24528
  });
24444
- import * as path7 from "node:path";
24445
24529
  import * as fs7 from "node:fs";
24446
24530
  function scoreSearchEntry(query, rel, entry) {
24447
24531
  let score = rel.toLowerCase().includes(query) ? 10 : 0;
@@ -24474,7 +24558,7 @@ var init_projectIndex = __esm({
24474
24558
  const found = [];
24475
24559
  walk(root, found);
24476
24560
  for (const fp of found) {
24477
- const rel = path7.relative(root, fp);
24561
+ const rel = indexKey(root, fp);
24478
24562
  seen.add(rel);
24479
24563
  let mtime;
24480
24564
  try {
@@ -24500,7 +24584,7 @@ var init_projectIndex = __esm({
24500
24584
  updated,
24501
24585
  removed: removed.length,
24502
24586
  total: Object.keys(files).length,
24503
- path: path7.relative(root, indexPath())
24587
+ path: indexKey(root, indexPath())
24504
24588
  };
24505
24589
  },
24506
24590
  search(query, limit = 20) {
@@ -25052,23 +25136,23 @@ __export(docs_exports, {
25052
25136
  returnFromSignature: () => returnFromSignature
25053
25137
  });
25054
25138
  import * as fs8 from "node:fs";
25055
- import * as path8 from "node:path";
25056
- import { fileURLToPath as fileURLToPath5 } from "node:url";
25139
+ import * as path7 from "node:path";
25140
+ import { fileURLToPath as fileURLToPath6 } from "node:url";
25057
25141
  function detectFrameworkRoots() {
25058
- const corePackageRoot = path8.resolve(__DIRNAME, "..");
25059
- const packagesRoot = path8.resolve(corePackageRoot, "..");
25142
+ const corePackageRoot = path7.resolve(__DIRNAME, "..");
25143
+ const packagesRoot = path7.resolve(corePackageRoot, "..");
25060
25144
  const roots = [];
25061
25145
  for (const pkg of ["core", "orm", "swagger", "frond"]) {
25062
- const dir = path8.join(packagesRoot, pkg, "src");
25146
+ const dir = path7.join(packagesRoot, pkg, "src");
25063
25147
  if (fs8.existsSync(dir)) roots.push(dir);
25064
25148
  }
25065
25149
  return roots;
25066
25150
  }
25067
25151
  function detectVersion(projectRoot3) {
25068
25152
  for (const candidate of [
25069
- path8.join(projectRoot3, "package.json"),
25070
- path8.resolve(__DIRNAME, "..", "..", "..", "package.json"),
25071
- path8.resolve(__DIRNAME, "..", "package.json")
25153
+ path7.join(projectRoot3, "package.json"),
25154
+ path7.resolve(__DIRNAME, "..", "..", "..", "package.json"),
25155
+ path7.resolve(__DIRNAME, "..", "package.json")
25072
25156
  ]) {
25073
25157
  try {
25074
25158
  const pkg = JSON.parse(fs8.readFileSync(candidate, "utf-8"));
@@ -25079,16 +25163,16 @@ function detectVersion(projectRoot3) {
25079
25163
  return "0.0.0";
25080
25164
  }
25081
25165
  function relativePath(absPath, projectRoot3, frameworkRoots) {
25082
- const norm = path8.resolve(absPath);
25166
+ const norm = path7.resolve(absPath);
25083
25167
  for (const fw of frameworkRoots) {
25084
- const parent = path8.dirname(fw);
25085
- if (norm.startsWith(parent + path8.sep)) {
25086
- const monorepo = path8.resolve(parent, "..", "..");
25087
- if (norm.startsWith(monorepo + path8.sep)) return path8.relative(monorepo, norm);
25088
- return path8.relative(parent, norm);
25168
+ const parent = path7.dirname(fw);
25169
+ if (norm.startsWith(parent + path7.sep)) {
25170
+ const monorepo = path7.resolve(parent, "..", "..");
25171
+ if (norm.startsWith(monorepo + path7.sep)) return path7.relative(monorepo, norm);
25172
+ return path7.relative(parent, norm);
25089
25173
  }
25090
25174
  }
25091
- if (norm.startsWith(projectRoot3 + path8.sep)) return path8.relative(projectRoot3, norm);
25175
+ if (norm.startsWith(projectRoot3 + path7.sep)) return path7.relative(projectRoot3, norm);
25092
25176
  return norm;
25093
25177
  }
25094
25178
  function tokenise(text) {
@@ -25128,12 +25212,12 @@ function walkTsFiles(root) {
25128
25212
  if (e.name.startsWith(".")) continue;
25129
25213
  if (e.isDirectory()) {
25130
25214
  if (e.name === "node_modules" || e.name === "tests" || e.name === "test" || e.name === "dist" || e.name === "build") continue;
25131
- visit(path8.join(dir, e.name));
25215
+ visit(path7.join(dir, e.name));
25132
25216
  } else if (e.isFile()) {
25133
25217
  if (!e.name.endsWith(".ts") && !e.name.endsWith(".js") && !e.name.endsWith(".mjs")) continue;
25134
25218
  if (e.name.endsWith(".test.ts") || e.name.endsWith(".test.js")) continue;
25135
25219
  if (e.name.endsWith(".d.ts")) continue;
25136
- found.push(path8.join(dir, e.name));
25220
+ found.push(path7.join(dir, e.name));
25137
25221
  }
25138
25222
  }
25139
25223
  }
@@ -25460,8 +25544,8 @@ var init_docs = __esm({
25460
25544
  "hash"
25461
25545
  ]);
25462
25546
  _DOCS_CACHE = /* @__PURE__ */ new Map();
25463
- __FILENAME = fileURLToPath5(import.meta.url);
25464
- __DIRNAME = path8.dirname(__FILENAME);
25547
+ __FILENAME = fileURLToPath6(import.meta.url);
25548
+ __DIRNAME = path7.dirname(__FILENAME);
25465
25549
  USER_DIRS = ["src/orm", "src/routes", "src/app", "src/services", "src/models"];
25466
25550
  FENCE_RE = new RegExp(
25467
25551
  String.fromCharCode(96, 96, 96) + "[a-zA-Z0-9_+-]*\\n([\\s\\S]*?)\\n" + String.fromCharCode(96, 96, 96),
@@ -25479,7 +25563,7 @@ var init_docs = __esm({
25479
25563
  userMtime = 0;
25480
25564
  frameworkMtime = 0;
25481
25565
  constructor(projectRoot3) {
25482
- this.projectRoot = path8.resolve(projectRoot3);
25566
+ this.projectRoot = path7.resolve(projectRoot3);
25483
25567
  this.frameworkRoots = detectFrameworkRoots();
25484
25568
  this.version = detectVersion(this.projectRoot);
25485
25569
  }
@@ -25671,7 +25755,7 @@ var init_docs = __esm({
25671
25755
  // ── Drift detector + sync ────────────────────────────────────────
25672
25756
  static checkDocs(mdPath, projectRoot3) {
25673
25757
  if (!fs8.existsSync(mdPath)) return { drift: [] };
25674
- const docs = _Docs.cached(projectRoot3 ?? path8.dirname(mdPath));
25758
+ const docs = _Docs.cached(projectRoot3 ?? path7.dirname(mdPath));
25675
25759
  const idx = docs.index();
25676
25760
  const known = /* @__PURE__ */ new Set();
25677
25761
  for (const e of idx) known.add(e.name.toLowerCase());
@@ -25698,7 +25782,7 @@ var init_docs = __esm({
25698
25782
  return { drift };
25699
25783
  }
25700
25784
  static syncDocs(mdPath, projectRoot3) {
25701
- const docs = _Docs.cached(projectRoot3 ?? (fs8.existsSync(mdPath) ? path8.dirname(mdPath) : process.cwd()));
25785
+ const docs = _Docs.cached(projectRoot3 ?? (fs8.existsSync(mdPath) ? path7.dirname(mdPath) : process.cwd()));
25702
25786
  const generated = docs.renderGeneratedBlock();
25703
25787
  const begin = "<!-- BEGIN GENERATED API -->";
25704
25788
  const end = "<!-- END GENERATED API -->";
@@ -25722,7 +25806,7 @@ ${end}
25722
25806
  }
25723
25807
  // ── Internals ────────────────────────────────────────────────────
25724
25808
  static cached(projectRoot3) {
25725
- const key = path8.resolve(projectRoot3 ?? process.cwd());
25809
+ const key = path7.resolve(projectRoot3 ?? process.cwd());
25726
25810
  let inst = _DOCS_CACHE.get(key);
25727
25811
  if (!inst) {
25728
25812
  inst = new _Docs(key);
@@ -25749,11 +25833,11 @@ ${end}
25749
25833
  this.frameworkMtime = shared.mtime;
25750
25834
  this.indexCache = null;
25751
25835
  }
25752
- const userMtime = this.maxMtime(USER_DIRS.map((d) => path8.join(this.projectRoot, d)));
25836
+ const userMtime = this.maxMtime(USER_DIRS.map((d) => path7.join(this.projectRoot, d)));
25753
25837
  if (this.indexCache === null || userMtime !== this.userMtime) {
25754
25838
  this.userEntries = /* @__PURE__ */ new Map();
25755
25839
  for (const sub of USER_DIRS) {
25756
- const dir = path8.join(this.projectRoot, sub);
25840
+ const dir = path7.join(this.projectRoot, sub);
25757
25841
  if (!fs8.existsSync(dir)) continue;
25758
25842
  for (const f of walkTsFiles(dir)) {
25759
25843
  buildEntriesForFile(f, "user", this.frameworkRoots, this.projectRoot, this.version, this.userEntries);
@@ -25836,9 +25920,9 @@ ${end}
25836
25920
 
25837
25921
  // ../core/src/devAdmin.ts
25838
25922
  import { cpus as osCpus } from "node:os";
25839
- import { readFileSync as readFileSync18, writeFileSync as writeFileSync13, existsSync as existsSync20, readdirSync as readdirSync13, mkdirSync as mkdirSync14, copyFileSync as copyFileSync2, statSync as statSync15, openSync as openSync5, closeSync as closeSync5, fstatSync as fstatSync3, fchmodSync as fchmodSync2, ftruncateSync as ftruncateSync2, constants as constants4, realpathSync as realpathSync6, lstatSync as lstatSync3 } from "node:fs";
25840
- import { join as join22, dirname as dirname11, resolve as resolve12, relative as relative9, sep as sep6, basename as basename5 } from "node:path";
25841
- import { fileURLToPath as fileURLToPath6 } from "node:url";
25923
+ import { readFileSync as readFileSync18, writeFileSync as writeFileSync13, existsSync as existsSync21, readdirSync as readdirSync13, mkdirSync as mkdirSync14, copyFileSync as copyFileSync2, statSync as statSync16, openSync as openSync5, closeSync as closeSync5, fstatSync as fstatSync3, fchmodSync as fchmodSync2, ftruncateSync as ftruncateSync2, constants as constants4, realpathSync as realpathSync6, lstatSync as lstatSync3 } from "node:fs";
25924
+ import { join as join23, dirname as dirname11, resolve as resolve12, relative as relative8, sep as sep7, basename as basename5 } from "node:path";
25925
+ import { fileURLToPath as fileURLToPath7 } from "node:url";
25842
25926
  import { timingSafeEqual as timingSafeEqual2 } from "node:crypto";
25843
25927
  import net2 from "node:net";
25844
25928
  function escapeHtml2(value) {
@@ -25916,15 +26000,15 @@ function devToolbarAllowed(req2) {
25916
26000
  return devPeerAllowed(peer);
25917
26001
  }
25918
26002
  function devRequestDenial(req2) {
25919
- const path10 = (req2.path ?? "").replace(/\/+/g, "/");
25920
- const isMcp = DEV_MCP_PREFIXES.some((prefix) => path10 === prefix || path10.startsWith(prefix + "/"));
26003
+ const path9 = (req2.path ?? "").replace(/\/+/g, "/");
26004
+ const isMcp = DEV_MCP_PREFIXES.some((prefix) => path9 === prefix || path9.startsWith(prefix + "/"));
25921
26005
  if (!devHostAllowed(req2.header("host"))) {
25922
26006
  return { status: 403, error: "dev-admin: refused (host not allowed)" };
25923
26007
  }
25924
26008
  if (!devSameOriginOk(req2)) {
25925
26009
  return { status: 403, error: "dev-admin: refused (cross-origin request)" };
25926
26010
  }
25927
- if (DEV_PUBLIC_ASSETS.has(path10)) {
26011
+ if (DEV_PUBLIC_ASSETS.has(path9)) {
25928
26012
  return null;
25929
26013
  }
25930
26014
  if (!isMcp) {
@@ -26016,12 +26100,12 @@ function mapQueueJob(job, topic, status2) {
26016
26100
  };
26017
26101
  }
26018
26102
  function readQueueDir(dir, topic, status2) {
26019
- if (!existsSync20(dir)) return [];
26103
+ if (!existsSync21(dir)) return [];
26020
26104
  const jobs = [];
26021
26105
  for (const filename of readdirSync13(dir).sort()) {
26022
26106
  if (!filename.endsWith(".queue-data")) continue;
26023
26107
  try {
26024
- jobs.push(mapQueueJob(JSON.parse(readFileSync18(join22(dir, filename), "utf-8")), topic, status2));
26108
+ jobs.push(mapQueueJob(JSON.parse(readFileSync18(join23(dir, filename), "utf-8")), topic, status2));
26025
26109
  } catch {
26026
26110
  }
26027
26111
  }
@@ -26158,8 +26242,8 @@ async function proxyToSupervisor(req2, res, downstreamPath) {
26158
26242
  function resolveDevEnvVar(key) {
26159
26243
  const live = process.env[key];
26160
26244
  if (live !== void 0 && live !== "") return live;
26161
- const envPath = join22(process.cwd(), ".env");
26162
- if (!existsSync20(envPath)) return "";
26245
+ const envPath = join23(process.cwd(), ".env");
26246
+ if (!existsSync21(envPath)) return "";
26163
26247
  for (const line of readFileSync18(envPath, "utf-8").split("\n")) {
26164
26248
  const t = line.trim();
26165
26249
  if (!t || t.startsWith("#") || !t.includes("=")) continue;
@@ -26169,8 +26253,8 @@ function resolveDevEnvVar(key) {
26169
26253
  return "";
26170
26254
  }
26171
26255
  function upsertDevEnvVar(key, value) {
26172
- const envPath = join22(process.cwd(), ".env");
26173
- const lines = existsSync20(envPath) ? readFileSync18(envPath, "utf-8").split("\n") : [];
26256
+ const envPath = join23(process.cwd(), ".env");
26257
+ const lines = existsSync21(envPath) ? readFileSync18(envPath, "utf-8").split("\n") : [];
26174
26258
  let found = false;
26175
26259
  const out = [];
26176
26260
  for (const line of lines) {
@@ -26200,9 +26284,9 @@ function formatUptime(seconds) {
26200
26284
  return parts.join(" ");
26201
26285
  }
26202
26286
  function parseEnvFile() {
26203
- const envPath = join22(process.cwd(), ".env");
26287
+ const envPath = join23(process.cwd(), ".env");
26204
26288
  const result = {};
26205
- if (!existsSync20(envPath)) return result;
26289
+ if (!existsSync21(envPath)) return result;
26206
26290
  const lines = readFileSync18(envPath, "utf-8").split("\n");
26207
26291
  for (const line of lines) {
26208
26292
  const trimmed = line.trim();
@@ -26214,10 +26298,10 @@ function parseEnvFile() {
26214
26298
  }
26215
26299
  function walkDirRecursive(dir) {
26216
26300
  const results = [];
26217
- if (!existsSync20(dir)) return results;
26301
+ if (!existsSync21(dir)) return results;
26218
26302
  for (const entry of readdirSync13(dir)) {
26219
- const full = join22(dir, entry);
26220
- if (statSync15(full).isDirectory()) {
26303
+ const full = join23(dir, entry);
26304
+ if (statSync16(full).isDirectory()) {
26221
26305
  results.push(...walkDirRecursive(full));
26222
26306
  } else {
26223
26307
  results.push(full);
@@ -26234,8 +26318,8 @@ function handleGalleryDeploy(router) {
26234
26318
  return;
26235
26319
  }
26236
26320
  const galleryDir = resolve12(__devAdminDirname, "..", "gallery");
26237
- const gallerySrc = join22(galleryDir, name, "src");
26238
- if (!existsSync20(gallerySrc)) {
26321
+ const gallerySrc = join23(galleryDir, name, "src");
26322
+ if (!existsSync21(gallerySrc)) {
26239
26323
  res.json({ error: `Gallery item '${name}' not found` }, 404);
26240
26324
  return;
26241
26325
  }
@@ -26243,15 +26327,15 @@ function handleGalleryDeploy(router) {
26243
26327
  const copied = [];
26244
26328
  const allFiles = walkDirRecursive(gallerySrc);
26245
26329
  for (const srcFile of allFiles) {
26246
- const rel = relative9(gallerySrc, srcFile);
26247
- const dest = join22(projectSrc, rel);
26330
+ const rel = relative8(gallerySrc, srcFile);
26331
+ const dest = join23(projectSrc, rel);
26248
26332
  mkdirSync14(dirname11(dest), { recursive: true });
26249
26333
  copyFileSync2(srcFile, dest);
26250
26334
  copied.push(rel);
26251
26335
  }
26252
26336
  try {
26253
26337
  const routesDir = resolve12(process.cwd(), "src", "routes");
26254
- if (existsSync20(routesDir)) {
26338
+ if (existsSync21(routesDir)) {
26255
26339
  const { discoverRoutes: discoverRoutes2 } = await Promise.resolve().then(() => (init_routeDiscovery(), routeDiscovery_exports));
26256
26340
  const routes = await discoverRoutes2(routesDir);
26257
26341
  for (const route of routes) {
@@ -26280,7 +26364,7 @@ function realPathOf2(target) {
26280
26364
  tail.unshift(basename5(existing));
26281
26365
  existing = dirname11(existing);
26282
26366
  }
26283
- return join22(realpathSync6(existing), ...tail);
26367
+ return join23(realpathSync6(existing), ...tail);
26284
26368
  }
26285
26369
  function safeJoin(projectRoot3, rel, extraRoots = []) {
26286
26370
  try {
@@ -26288,14 +26372,14 @@ function safeJoin(projectRoot3, rel, extraRoots = []) {
26288
26372
  const resolved = realPathOf2(resolve12(root, rel));
26289
26373
  const roots = [root, ...extraRoots.filter(Boolean).map((r) => realPathOf2(resolve12(r)))];
26290
26374
  for (const r of roots) {
26291
- if (resolved === r || resolved.startsWith(r.endsWith(sep6) ? r : r + sep6)) return resolved;
26375
+ if (resolved === r || resolved.startsWith(r.endsWith(sep7) ? r : r + sep7)) return resolved;
26292
26376
  }
26293
26377
  } catch {
26294
26378
  }
26295
26379
  return null;
26296
26380
  }
26297
26381
  function resolvedRelative(projectRoot3, resolvedPath) {
26298
- return relative9(realPathOf2(resolve12(projectRoot3)), resolvedPath);
26382
+ return relative8(realPathOf2(resolve12(projectRoot3)), resolvedPath);
26299
26383
  }
26300
26384
  function devFilesHidden(name) {
26301
26385
  if (DEV_FILES_IGNORED.has(name)) return true;
@@ -26311,10 +26395,10 @@ function devGitStatusLabel(code) {
26311
26395
  async function devGitInfo(root) {
26312
26396
  const empty = { branch: "", gitRoot: null, status: /* @__PURE__ */ new Map() };
26313
26397
  try {
26314
- const { execFileSync: execFileSync6 } = await import("node:child_process");
26398
+ const { execFileSync: execFileSync5 } = await import("node:child_process");
26315
26399
  const git = (args) => {
26316
26400
  try {
26317
- return execFileSync6("git", args, { cwd: root, timeout: 3e3, encoding: "utf-8" }).toString();
26401
+ return execFileSync5("git", args, { cwd: root, timeout: 3e3, encoding: "utf-8" }).toString();
26318
26402
  } catch {
26319
26403
  return null;
26320
26404
  }
@@ -26366,7 +26450,7 @@ function buildFileEntry(name, full, entryRel, cwdInGit, gitStatus) {
26366
26450
  let isDir = false;
26367
26451
  let size = null;
26368
26452
  try {
26369
- const st = statSync15(full);
26453
+ const st = statSync16(full);
26370
26454
  isDir = st.isDirectory();
26371
26455
  if (!isDir) size = st.size;
26372
26456
  } catch {
@@ -26441,7 +26525,7 @@ function applyMcpOutcome(res, outcome) {
26441
26525
  function renderToolbarHtml(ctx) {
26442
26526
  const nodeVersion = process.version;
26443
26527
  const method = escapeHtml2(ctx.method);
26444
- const path10 = escapeHtml2(ctx.path);
26528
+ const path9 = escapeHtml2(ctx.path);
26445
26529
  const matchedPattern = escapeHtml2(ctx.matchedPattern);
26446
26530
  const reload = ctx.reload === false ? "0" : "1";
26447
26531
  return `<link rel="stylesheet" href="/__dev/toolbar.css">
@@ -26458,7 +26542,7 @@ function renderToolbarHtml(ctx) {
26458
26542
  </div>
26459
26543
  </div>
26460
26544
  <span class="t4-green">${method}</span>
26461
- <span>${path10}</span>
26545
+ <span>${path9}</span>
26462
26546
  <span class="t4-arrow">&rarr; ${matchedPattern}</span>
26463
26547
  <span class="t4-yellow">req:${ctx.requestId}</span>
26464
26548
  <span class="t4-blue">${ctx.routeCount} routes</span>
@@ -26633,6 +26717,7 @@ var init_devAdmin = __esm({
26633
26717
  "../core/src/devAdmin.ts"() {
26634
26718
  "use strict";
26635
26719
  init_slashTrim();
26720
+ init_batchSpawn();
26636
26721
  init_devMailbox();
26637
26722
  init_upstreamResponse();
26638
26723
  init_dotenv();
@@ -26694,12 +26779,12 @@ var init_devAdmin = __esm({
26694
26779
  RequestInspector = class {
26695
26780
  static requests = [];
26696
26781
  static maxRequests = 200;
26697
- static capture(method, path10, status2, duration) {
26782
+ static capture(method, path9, status2, duration) {
26698
26783
  const entry = {
26699
26784
  id: `${Date.now()}_${this.requests.length}`,
26700
26785
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
26701
26786
  method,
26702
- path: path10,
26787
+ path: path9,
26703
26788
  status: status2,
26704
26789
  durationMs: Math.round(duration * 100) / 100
26705
26790
  };
@@ -26888,12 +26973,12 @@ var init_devAdmin = __esm({
26888
26973
  };
26889
26974
  WsTracker = class {
26890
26975
  static connections = [];
26891
- static add(remoteAddress, path10) {
26976
+ static add(remoteAddress, path9) {
26892
26977
  const conn = {
26893
26978
  id: `ws_${Date.now()}_${this.connections.length}`,
26894
26979
  connectedAt: (/* @__PURE__ */ new Date()).toISOString(),
26895
26980
  remoteAddress,
26896
- path: path10
26981
+ path: path9
26897
26982
  };
26898
26983
  this.connections.push(conn);
26899
26984
  return conn.id;
@@ -27003,7 +27088,7 @@ var init_devAdmin = __esm({
27003
27088
  const p = (url.searchParams.get("path") || "").toString();
27004
27089
  const scanRoot = metricsScanRoot();
27005
27090
  let target = p ? safeJoin(process.cwd(), p, [scanRoot]) : "";
27006
- if (target === null && scanRoot) target = safeJoin(process.cwd(), join22(scanRoot, p), [scanRoot]);
27091
+ if (target === null && scanRoot) target = safeJoin(process.cwd(), join23(scanRoot, p), [scanRoot]);
27007
27092
  if (target === null) {
27008
27093
  res.status(403).json({ error: "Path outside project" });
27009
27094
  return;
@@ -27324,16 +27409,16 @@ var init_devAdmin = __esm({
27324
27409
  failed: queue.size("failed"),
27325
27410
  reserved: queue.size("reserved")
27326
27411
  };
27327
- const topicDir = join22(queueBasePath2(), topic);
27412
+ const topicDir = join23(queueBasePath2(), topic);
27328
27413
  const jobs = [];
27329
27414
  if (!statusFilter || statusFilter === "pending") {
27330
27415
  jobs.push(...readQueueDir(topicDir, topic, "pending"));
27331
27416
  }
27332
27417
  if (!statusFilter || statusFilter === "reserved") {
27333
- jobs.push(...readQueueDir(join22(topicDir, "reserved"), topic, "reserved"));
27418
+ jobs.push(...readQueueDir(join23(topicDir, "reserved"), topic, "reserved"));
27334
27419
  }
27335
27420
  if (!statusFilter || statusFilter === "failed" || statusFilter === "dead") {
27336
- jobs.push(...readQueueDir(join22(topicDir, "failed"), topic, "dead_letter"));
27421
+ jobs.push(...readQueueDir(join23(topicDir, "failed"), topic, "dead_letter"));
27337
27422
  }
27338
27423
  res.json({ stats, jobs });
27339
27424
  } catch (e) {
@@ -27349,10 +27434,10 @@ var init_devAdmin = __esm({
27349
27434
  const { queueBasePath: queueBasePath2 } = await Promise.resolve().then(() => (init_queue(), queue_exports));
27350
27435
  const queueDir = queueBasePath2();
27351
27436
  let topics = [];
27352
- if (existsSync20(queueDir)) {
27437
+ if (existsSync21(queueDir)) {
27353
27438
  topics = readdirSync13(queueDir).filter((d) => {
27354
27439
  try {
27355
- return statSync15(join22(queueDir, d)).isDirectory();
27440
+ return statSync16(join23(queueDir, d)).isDirectory();
27356
27441
  } catch {
27357
27442
  return false;
27358
27443
  }
@@ -27637,7 +27722,7 @@ var init_devAdmin = __esm({
27637
27722
  const count = parseInt(String(body.count ?? "10"), 10) || 10;
27638
27723
  try {
27639
27724
  const orm = await Promise.resolve().then(() => (init_index(), index_exports));
27640
- const dirs = ["src/orm", "src/models"].map((d) => resolve12(process.cwd(), d)).filter((d) => existsSync20(d));
27725
+ const dirs = ["src/orm", "src/models"].map((d) => resolve12(process.cwd(), d)).filter((d) => existsSync21(d));
27641
27726
  const classes = [];
27642
27727
  for (const dir of dirs) {
27643
27728
  for (const m of await orm.discoverModels(dir)) classes.push(m.modelClass);
@@ -27778,7 +27863,7 @@ var init_devAdmin = __esm({
27778
27863
  return;
27779
27864
  }
27780
27865
  try {
27781
- const envPath = join22(process.cwd(), ".env");
27866
+ const envPath = join23(process.cwd(), ".env");
27782
27867
  const fd = openSync5(envPath, constants4.O_RDWR | constants4.O_APPEND | constants4.O_CREAT | (constants4.O_NOFOLLOW ?? 0) | (constants4.O_NONBLOCK ?? 0), 384);
27783
27868
  try {
27784
27869
  const info = fstatSync3(fd);
@@ -27822,29 +27907,29 @@ var init_devAdmin = __esm({
27822
27907
  res.json({ success: false, error: msg });
27823
27908
  }
27824
27909
  };
27825
- __devAdminFilename = fileURLToPath6(import.meta.url);
27910
+ __devAdminFilename = fileURLToPath7(import.meta.url);
27826
27911
  __devAdminDirname = dirname11(__devAdminFilename);
27827
27912
  handleGalleryList = (_req, res) => {
27828
27913
  const galleryDir = resolve12(__devAdminDirname, "..", "gallery");
27829
27914
  const items = [];
27830
- if (existsSync20(galleryDir)) {
27915
+ if (existsSync21(galleryDir)) {
27831
27916
  const entries = readdirSync13(galleryDir).sort();
27832
27917
  for (const entry of entries) {
27833
- const entryPath = join22(galleryDir, entry);
27834
- const metaFile = join22(entryPath, "meta.json");
27835
- if (statSync15(entryPath).isDirectory() && existsSync20(metaFile)) {
27918
+ const entryPath = join23(galleryDir, entry);
27919
+ const metaFile = join23(entryPath, "meta.json");
27920
+ if (statSync16(entryPath).isDirectory() && existsSync21(metaFile)) {
27836
27921
  try {
27837
27922
  const meta = JSON.parse(readFileSync18(metaFile, "utf-8"));
27838
27923
  meta.id = entry;
27839
- const srcDir = join22(entryPath, "src");
27840
- if (existsSync20(srcDir)) {
27924
+ const srcDir = join23(entryPath, "src");
27925
+ if (existsSync21(srcDir)) {
27841
27926
  const allFiles = walkDirRecursive(srcDir);
27842
- meta.files = allFiles.map((f) => relative9(srcDir, f));
27927
+ meta.files = allFiles.map((f) => relative8(srcDir, f));
27843
27928
  }
27844
27929
  const projectSrc = resolve12(process.cwd(), "src");
27845
- if (existsSync20(srcDir) && meta.files) {
27930
+ if (existsSync21(srcDir) && meta.files) {
27846
27931
  meta.deployed = meta.files.every(
27847
- (f) => existsSync20(join22(projectSrc, f))
27932
+ (f) => existsSync21(join23(projectSrc, f))
27848
27933
  );
27849
27934
  } else {
27850
27935
  meta.deployed = false;
@@ -27921,7 +28006,7 @@ var init_devAdmin = __esm({
27921
28006
  const root = resolve12(process.cwd());
27922
28007
  const target = safeJoin(root, rel);
27923
28008
  const { branch, gitRoot, status: gitStatus } = await devGitInfo(root);
27924
- if (!target || !existsSync20(target) || !statSync15(target).isDirectory()) {
28009
+ if (!target || !existsSync21(target) || !statSync16(target).isDirectory()) {
27925
28010
  res.json({ path: rel, branch, entries: [], error: "not a directory" });
27926
28011
  return;
27927
28012
  }
@@ -27934,12 +28019,12 @@ var init_devAdmin = __esm({
27934
28019
  const entries = [];
27935
28020
  for (const name of readdirSync13(target).sort()) {
27936
28021
  if (devFilesHidden(name)) continue;
27937
- const full = join22(target, name);
27938
- const entryRel = relative9(root, full).replace(/\\/g, "/");
28022
+ const full = join23(target, name);
28023
+ const entryRel = relative8(root, full).replace(/\\/g, "/");
27939
28024
  if (isSecretPath(entryRel)) continue;
27940
28025
  entries.push(buildFileEntry(name, full, entryRel, cwdInGit, gitStatus));
27941
28026
  }
27942
- res.json({ path: relative9(root, target).replace(/\\/g, "/") || ".", branch, entries });
28027
+ res.json({ path: relative8(root, target).replace(/\\/g, "/") || ".", branch, entries });
27943
28028
  };
27944
28029
  DEV_ADMIN_LANG_MAP = {
27945
28030
  ".py": "python",
@@ -27997,8 +28082,8 @@ var init_devAdmin = __esm({
27997
28082
  return;
27998
28083
  }
27999
28084
  const content = data.toString("utf-8");
28000
- const path10 = relative9(root, target);
28001
- res.json({ path: path10, content, language: devAdminLanguage(path10), bytes: Buffer.byteLength(content, "utf-8") });
28085
+ const path9 = relative8(root, target);
28086
+ res.json({ path: path9, content, language: devAdminLanguage(path9), bytes: Buffer.byteLength(content, "utf-8") });
28002
28087
  } catch (e) {
28003
28088
  res.json({ error: e.message }, 500);
28004
28089
  }
@@ -28015,14 +28100,14 @@ var init_devAdmin = __esm({
28015
28100
  }
28016
28101
  try {
28017
28102
  mkdirSync14(dirname11(target), { recursive: true });
28018
- const existed = existsSync20(target);
28103
+ const existed = existsSync21(target);
28019
28104
  writeFileSync13(target, content, "utf-8");
28020
28105
  try {
28021
28106
  const { Plan: Plan2 } = await Promise.resolve().then(() => (init_plan(), plan_exports));
28022
- Plan2.recordAction(existed ? "patched" : "created", relative9(root, target));
28107
+ Plan2.recordAction(existed ? "patched" : "created", relative8(root, target));
28023
28108
  } catch {
28024
28109
  }
28025
- res.json({ ok: true, path: relative9(root, target), bytes: Buffer.byteLength(content, "utf-8") });
28110
+ res.json({ ok: true, path: relative8(root, target), bytes: Buffer.byteLength(content, "utf-8") });
28026
28111
  } catch (e) {
28027
28112
  res.json({ error: e.message }, 500);
28028
28113
  }
@@ -28080,7 +28165,7 @@ var init_devAdmin = __esm({
28080
28165
  res.json({ error: "Invalid path" }, 400);
28081
28166
  return;
28082
28167
  }
28083
- if (!existsSync20(src)) {
28168
+ if (!existsSync21(src)) {
28084
28169
  res.json({ error: `Source not found: ${from}` }, 404);
28085
28170
  return;
28086
28171
  }
@@ -28088,7 +28173,7 @@ var init_devAdmin = __esm({
28088
28173
  const { renameSync: renameSync3 } = await import("node:fs");
28089
28174
  mkdirSync14(dirname11(dst), { recursive: true });
28090
28175
  renameSync3(src, dst);
28091
- res.json({ ok: true, from: relative9(root, src), to: relative9(root, dst) });
28176
+ res.json({ ok: true, from: relative8(root, src), to: relative8(root, dst) });
28092
28177
  } catch (e) {
28093
28178
  res.json({ error: e.message }, 500);
28094
28179
  }
@@ -28102,14 +28187,14 @@ var init_devAdmin = __esm({
28102
28187
  res.json({ error: "Invalid path" }, 400);
28103
28188
  return;
28104
28189
  }
28105
- if (!existsSync20(target)) {
28190
+ if (!existsSync21(target)) {
28106
28191
  res.json({ error: `Not found: ${rel}` }, 404);
28107
28192
  return;
28108
28193
  }
28109
28194
  try {
28110
28195
  const { rmSync: rmSync2 } = await import("node:fs");
28111
28196
  rmSync2(target, { recursive: true, force: true });
28112
- res.json({ ok: true, deleted: relative9(root, target) });
28197
+ res.json({ ok: true, deleted: relative8(root, target) });
28113
28198
  } catch (e) {
28114
28199
  res.json({ error: e.message }, 500);
28115
28200
  }
@@ -28144,13 +28229,11 @@ var init_devAdmin = __esm({
28144
28229
  return;
28145
28230
  }
28146
28231
  try {
28147
- const { execFileSync: execFileSync6 } = await import("node:child_process");
28148
28232
  const args = ["install", dev ? "--save-dev" : "--save", pkg];
28149
- const output = execFileSync6("npm", args, {
28233
+ const output = execFileSyncAllowingBatch("npm", args, {
28150
28234
  cwd: resolve12(process.cwd()),
28151
- timeout: 12e4,
28152
- encoding: "utf-8"
28153
- }).toString();
28235
+ timeout: 12e4
28236
+ });
28154
28237
  res.json({ ok: true, package: pkg, output });
28155
28238
  } catch (e) {
28156
28239
  res.json({ error: e.message }, 500);
@@ -28158,15 +28241,15 @@ var init_devAdmin = __esm({
28158
28241
  };
28159
28242
  handleGitStatus = async (_req, res) => {
28160
28243
  try {
28161
- const { execFileSync: execFileSync6 } = await import("node:child_process");
28244
+ const { execFileSync: execFileSync5 } = await import("node:child_process");
28162
28245
  const cwd = resolve12(process.cwd());
28163
28246
  try {
28164
- execFileSync6("git", ["rev-parse", "--is-inside-work-tree"], { cwd, timeout: 3e3 });
28247
+ execFileSync5("git", ["rev-parse", "--is-inside-work-tree"], { cwd, timeout: 3e3 });
28165
28248
  } catch {
28166
28249
  res.json({ error: "Not a git repository" }, 400);
28167
28250
  return;
28168
28251
  }
28169
- const run = (args) => execFileSync6("git", args, { cwd, timeout: 3e3, encoding: "utf-8" }).toString().trim();
28252
+ const run = (args) => execFileSync5("git", args, { cwd, timeout: 3e3, encoding: "utf-8" }).toString().trim();
28170
28253
  res.json({
28171
28254
  branch: run(["branch", "--show-current"]),
28172
28255
  status: run(["status", "--porcelain"]).split(/\r?\n/).filter((l) => l),
@@ -28296,12 +28379,10 @@ var init_devAdmin = __esm({
28296
28379
  return;
28297
28380
  }
28298
28381
  try {
28299
- const { execFileSync: execFileSync6 } = await import("node:child_process");
28300
- const output = execFileSync6("npx", ["tina4nodejs", "generate", kind, name], {
28382
+ const output = execFileSyncAllowingBatch("npx", ["tina4nodejs", "generate", kind, name], {
28301
28383
  cwd: resolve12(process.cwd()),
28302
- timeout: 3e4,
28303
- encoding: "utf-8"
28304
- }).toString();
28384
+ timeout: 3e4
28385
+ });
28305
28386
  res.json({ ok: true, kind, name, output });
28306
28387
  } catch (e) {
28307
28388
  res.json({ error: e.message }, 500);
@@ -28443,21 +28524,21 @@ var init_devAdmin = __esm({
28443
28524
  });
28444
28525
  };
28445
28526
  handleDevAdminJs = async (_req, res) => {
28446
- const { readFileSync: readFileSync27, existsSync: existsSync29 } = await import("node:fs");
28447
- const { dirname: dirname17, join: join33, resolve: resolve21 } = await import("node:path");
28448
- const { fileURLToPath: fileURLToPath10 } = await import("node:url");
28449
- const dir = dirname17(fileURLToPath10(import.meta.url));
28527
+ const { readFileSync: readFileSync27, existsSync: existsSync30 } = await import("node:fs");
28528
+ const { dirname: dirname17, join: join34, resolve: resolve21 } = await import("node:path");
28529
+ const { fileURLToPath: fileURLToPath11 } = await import("node:url");
28530
+ const dir = dirname17(fileURLToPath11(import.meta.url));
28450
28531
  const candidates = [
28451
- join33(dir, "..", "public", "js", "tina4-dev-admin.min.js"),
28532
+ join34(dir, "..", "public", "js", "tina4-dev-admin.min.js"),
28452
28533
  // src/../public/js/
28453
- join33(dir, "..", "..", "public", "js", "tina4-dev-admin.min.js"),
28534
+ join34(dir, "..", "..", "public", "js", "tina4-dev-admin.min.js"),
28454
28535
  // deeper nesting
28455
28536
  resolve21(process.cwd(), "node_modules", "tina4-nodejs", "packages", "core", "public", "js", "tina4-dev-admin.min.js"),
28456
28537
  resolve21(process.cwd(), "public", "js", "tina4-dev-admin.min.js")
28457
28538
  // project public/
28458
28539
  ];
28459
28540
  for (const jsPath of candidates) {
28460
- if (existsSync29(jsPath)) {
28541
+ if (existsSync30(jsPath)) {
28461
28542
  try {
28462
28543
  const content = readFileSync27(jsPath, "utf-8");
28463
28544
  res.raw.writeHead(200, { "Content-Type": "application/javascript; charset=utf-8", "Cache-Control": "no-cache" });
@@ -28471,20 +28552,20 @@ var init_devAdmin = __esm({
28471
28552
  res.raw.end("tina4-dev-admin.min.js not found");
28472
28553
  };
28473
28554
  handleDevAdminSplit = async (_req, res) => {
28474
- const { readFileSync: readFileSync27, existsSync: existsSync29 } = await import("node:fs");
28475
- const { dirname: dirname17, join: join33, resolve: resolve21 } = await import("node:path");
28476
- const { fileURLToPath: fileURLToPath10 } = await import("node:url");
28477
- const dir = dirname17(fileURLToPath10(import.meta.url));
28555
+ const { readFileSync: readFileSync27, existsSync: existsSync30 } = await import("node:fs");
28556
+ const { dirname: dirname17, join: join34, resolve: resolve21 } = await import("node:path");
28557
+ const { fileURLToPath: fileURLToPath11 } = await import("node:url");
28558
+ const dir = dirname17(fileURLToPath11(import.meta.url));
28478
28559
  const candidates = [
28479
- join33(dir, "..", "public", "js", "tina4-dev-admin-split.html"),
28480
- join33(dir, "..", "..", "public", "js", "tina4-dev-admin-split.html"),
28560
+ join34(dir, "..", "public", "js", "tina4-dev-admin-split.html"),
28561
+ join34(dir, "..", "..", "public", "js", "tina4-dev-admin-split.html"),
28481
28562
  resolve21(process.cwd(), "node_modules", "tina4-nodejs", "packages", "core", "public", "js", "tina4-dev-admin-split.html"),
28482
28563
  resolve21(process.cwd(), "public", "js", "tina4-dev-admin-split.html")
28483
28564
  ];
28484
- for (const path10 of candidates) {
28485
- if (existsSync29(path10)) {
28565
+ for (const path9 of candidates) {
28566
+ if (existsSync30(path9)) {
28486
28567
  try {
28487
- const content = readFileSync27(path10, "utf-8");
28568
+ const content = readFileSync27(path9, "utf-8");
28488
28569
  res.raw.writeHead(200, { "Content-Type": "text/html; charset=utf-8", "Cache-Control": "no-cache" });
28489
28570
  res.raw.end(content);
28490
28571
  return;
@@ -28507,8 +28588,8 @@ var init_devAdmin = __esm({
28507
28588
  });
28508
28589
 
28509
28590
  // ../core/src/i18n.ts
28510
- import { readFileSync as readFileSync19, readdirSync as readdirSync14, existsSync as existsSync21 } from "node:fs";
28511
- import { join as join23, resolve as resolve13 } from "node:path";
28591
+ import { readFileSync as readFileSync19, readdirSync as readdirSync14, existsSync as existsSync22 } from "node:fs";
28592
+ import { join as join24, resolve as resolve13 } from "node:path";
28512
28593
  var I18n;
28513
28594
  var init_i18n = __esm({
28514
28595
  "../core/src/i18n.ts"() {
@@ -28527,9 +28608,9 @@ var init_i18n = __esm({
28527
28608
  * Arg order is (locale, path) to match the Python master `I18n(locale, path)`
28528
28609
  * (BUG-7, BREAKING in 3.13.x — was previously (localeDir, defaultLocale)).
28529
28610
  */
28530
- constructor(locale, path10) {
28611
+ constructor(locale, path9) {
28531
28612
  this._localeDir = resolve13(
28532
- path10 ?? process.env.TINA4_LOCALE_DIR ?? "src/locales"
28613
+ path9 ?? process.env.TINA4_LOCALE_DIR ?? "src/locales"
28533
28614
  );
28534
28615
  this._defaultLocale = locale ?? process.env.TINA4_LOCALE ?? "en";
28535
28616
  this._currentLocale = this._defaultLocale;
@@ -28585,7 +28666,7 @@ var init_i18n = __esm({
28585
28666
  }
28586
28667
  /** List available locale codes based on JSON files in the locale directory. */
28587
28668
  availableLocales() {
28588
- if (!existsSync21(this._localeDir)) {
28669
+ if (!existsSync22(this._localeDir)) {
28589
28670
  return [this._defaultLocale];
28590
28671
  }
28591
28672
  try {
@@ -28601,8 +28682,8 @@ var init_i18n = __esm({
28601
28682
  if (this._translations.has(locale)) {
28602
28683
  return;
28603
28684
  }
28604
- const filePath = join23(this._localeDir, `${locale}.json`);
28605
- if (existsSync21(filePath)) {
28685
+ const filePath = join24(this._localeDir, `${locale}.json`);
28686
+ if (existsSync22(filePath)) {
28606
28687
  try {
28607
28688
  const raw = readFileSync19(filePath, "utf-8");
28608
28689
  const data = JSON.parse(raw);
@@ -28614,8 +28695,8 @@ var init_i18n = __esm({
28614
28695
  }
28615
28696
  }
28616
28697
  for (const ext of [".yml", ".yaml"]) {
28617
- const yamlPath = join23(this._localeDir, `${locale}${ext}`);
28618
- if (existsSync21(yamlPath)) {
28698
+ const yamlPath = join24(this._localeDir, `${locale}${ext}`);
28699
+ if (existsSync22(yamlPath)) {
28619
28700
  try {
28620
28701
  const raw = readFileSync19(yamlPath, "utf-8");
28621
28702
  const data = _I18n._parseSimpleYaml(raw);
@@ -30140,11 +30221,11 @@ __export(docsAutoDiscovery_exports, {
30140
30221
  writeMcpDiscovery: () => writeMcpDiscovery
30141
30222
  });
30142
30223
  import * as fs9 from "node:fs";
30143
- import * as path9 from "node:path";
30224
+ import * as path8 from "node:path";
30144
30225
  function writeMcpDiscovery(projectRoot3, port) {
30145
- const root = path9.resolve(projectRoot3);
30146
- const tinaDir = path9.join(root, TINA4_DIR);
30147
- const mcpPath = path9.join(tinaDir, MCP_FILE);
30226
+ const root = path8.resolve(projectRoot3);
30227
+ const tinaDir = path8.join(root, TINA4_DIR);
30228
+ const mcpPath = path8.join(tinaDir, MCP_FILE);
30148
30229
  const portStr = String(
30149
30230
  port || Number(process.env.TINA4_PORT) || Number(process.env.PORT) || 7148
30150
30231
  );
@@ -30171,9 +30252,9 @@ function writeMcpDiscovery(projectRoot3, port) {
30171
30252
  fs9.writeFileSync(mcpPath, desiredJson, "utf-8");
30172
30253
  wrote = true;
30173
30254
  }
30174
- const gitDir = path9.join(root, ".git");
30255
+ const gitDir = path8.join(root, ".git");
30175
30256
  if (fs9.existsSync(gitDir)) {
30176
- const gitignorePath = path9.join(root, ".gitignore");
30257
+ const gitignorePath = path8.join(root, ".gitignore");
30177
30258
  let contents = "";
30178
30259
  if (fs9.existsSync(gitignorePath)) {
30179
30260
  try {
@@ -30184,8 +30265,8 @@ function writeMcpDiscovery(projectRoot3, port) {
30184
30265
  const lines = contents.split(/\r?\n/);
30185
30266
  const already = lines.some((l) => l.trim() === GITIGNORE_LINE || l.trim() === ".tina4");
30186
30267
  if (!already) {
30187
- const sep9 = contents.endsWith("\n") || contents === "" ? "" : "\n";
30188
- fs9.writeFileSync(gitignorePath, `${contents}${sep9}${GITIGNORE_LINE}
30268
+ const sep10 = contents.endsWith("\n") || contents === "" ? "" : "\n";
30269
+ fs9.writeFileSync(gitignorePath, `${contents}${sep10}${GITIGNORE_LINE}
30189
30270
  `, "utf-8");
30190
30271
  }
30191
30272
  }
@@ -30203,11 +30284,11 @@ var init_docsAutoDiscovery = __esm({
30203
30284
 
30204
30285
  // ../core/src/server.ts
30205
30286
  import { randomBytes as randomBytes7 } from "node:crypto";
30206
- import { resolve as resolve15, dirname as dirname12, join as join25, relative as relative10 } from "node:path";
30207
- import { existsSync as existsSync23, readdirSync as readdirSync15, readFileSync as readFileSync21, statSync as statSync16 } from "node:fs";
30287
+ import { resolve as resolve15, dirname as dirname12, join as join26, relative as relative9 } from "node:path";
30288
+ import { existsSync as existsSync24, readdirSync as readdirSync15, readFileSync as readFileSync21, statSync as statSync17 } from "node:fs";
30208
30289
  import { isatty } from "node:tty";
30209
- import { fileURLToPath as fileURLToPath7 } from "node:url";
30210
- import { execFileSync as execFileSync3, execFile } from "node:child_process";
30290
+ import { fileURLToPath as fileURLToPath8 } from "node:url";
30291
+ import { execFile } from "node:child_process";
30211
30292
  import cluster from "node:cluster";
30212
30293
  import os2 from "node:os";
30213
30294
  function isSwaggerAssetPath(pathname) {
@@ -30269,7 +30350,7 @@ function reportOrmBootFailure(stage, err, dbConfig) {
30269
30350
  }
30270
30351
  async function autoMigrateOnStartup(migrationDir = "migrations", base = process.cwd()) {
30271
30352
  const dir = resolve15(base, migrationDir);
30272
- if (!existsSync23(dir)) return;
30353
+ if (!existsSync24(dir)) return;
30273
30354
  let hasSql = false;
30274
30355
  try {
30275
30356
  hasSql = readdirSync15(dir).some((f) => f.endsWith(".sql") && !f.endsWith(".down.sql"));
@@ -30359,17 +30440,8 @@ function killPort(port) {
30359
30440
  }
30360
30441
  }
30361
30442
  function findAvailablePort(start2) {
30362
- try {
30363
- execFileSync3(process.execPath, ["-e", `
30364
- const s = require("net").createServer();
30365
- s.listen(${start2}, "0.0.0.0", () => { s.close(); process.exit(0); });
30366
- s.on("error", () => process.exit(1));
30367
- `], { timeout: 1e3 });
30368
- return start2;
30369
- } catch {
30370
- killPort(start2);
30371
- return start2;
30372
- }
30443
+ if (probeBind("0.0.0.0", start2) === "held") killPort(start2);
30444
+ return start2;
30373
30445
  }
30374
30446
  function shouldOpenBrowser(isDevelopment, noBrowser = false) {
30375
30447
  if (!isDevelopment || isTruthy(process.env.TINA4_PRODUCTION) || cluster.isWorker) return false;
@@ -30431,12 +30503,12 @@ async function renderErrorPage(code, data, templatesDir) {
30431
30503
  }
30432
30504
  return instance;
30433
30505
  };
30434
- const userTemplatePath = join25(templatesDir, templateFile);
30435
- if (existsSync23(userTemplatePath)) {
30506
+ const userTemplatePath = join26(templatesDir, templateFile);
30507
+ if (existsSync24(userTemplatePath)) {
30436
30508
  return getCachedFrond(templatesDir).render(templateFile, data);
30437
30509
  }
30438
- const builtinTemplatePath = join25(BUILTIN_ERROR_TEMPLATES_DIR, templateFile);
30439
- if (existsSync23(builtinTemplatePath)) {
30510
+ const builtinTemplatePath = join26(BUILTIN_ERROR_TEMPLATES_DIR, templateFile);
30511
+ if (existsSync24(builtinTemplatePath)) {
30440
30512
  return getCachedFrond(BUILTIN_ERROR_TEMPLATES_DIR).render(templateFile, data);
30441
30513
  }
30442
30514
  return null;
@@ -30453,10 +30525,10 @@ function injectDevToolbar(html, ctx) {
30453
30525
  }
30454
30526
  function walkGalleryFiles(dir) {
30455
30527
  const results = [];
30456
- if (!existsSync23(dir)) return results;
30528
+ if (!existsSync24(dir)) return results;
30457
30529
  for (const f of readdirSync15(dir)) {
30458
- const full = join25(dir, f);
30459
- if (statSync16(full).isDirectory()) results.push(...walkGalleryFiles(full));
30530
+ const full = join26(dir, f);
30531
+ if (statSync17(full).isDirectory()) results.push(...walkGalleryFiles(full));
30460
30532
  else results.push(full);
30461
30533
  }
30462
30534
  return results;
@@ -30464,18 +30536,18 @@ function walkGalleryFiles(dir) {
30464
30536
  function getGalleryDeployedState() {
30465
30537
  const galleryDir = resolve15(__dirname, "..", "gallery");
30466
30538
  const state = {};
30467
- if (!existsSync23(galleryDir)) return state;
30539
+ if (!existsSync24(galleryDir)) return state;
30468
30540
  try {
30469
30541
  const entries = readdirSync15(galleryDir).sort();
30470
30542
  for (const entry of entries) {
30471
- const entryPath = join25(galleryDir, entry);
30472
- const metaFile = join25(entryPath, "meta.json");
30473
- if (statSync16(entryPath).isDirectory() && existsSync23(metaFile)) {
30474
- const srcDir = join25(entryPath, "src");
30475
- if (existsSync23(srcDir)) {
30543
+ const entryPath = join26(galleryDir, entry);
30544
+ const metaFile = join26(entryPath, "meta.json");
30545
+ if (statSync17(entryPath).isDirectory() && existsSync24(metaFile)) {
30546
+ const srcDir = join26(entryPath, "src");
30547
+ if (existsSync24(srcDir)) {
30476
30548
  const files = walkGalleryFiles(srcDir);
30477
30549
  const projectSrc = resolve15(process.cwd(), "src");
30478
- state[entry] = files.every((f) => existsSync23(join25(projectSrc, relative10(srcDir, f))));
30550
+ state[entry] = files.every((f) => existsSync24(join26(projectSrc, relative9(srcDir, f))));
30479
30551
  } else {
30480
30552
  state[entry] = false;
30481
30553
  }
@@ -30506,7 +30578,7 @@ function resolveTemplate(pathname, templatesDir) {
30506
30578
  if (cleanPath.includes("\\") || cleanPath.split("/").some((seg) => seg === "" || seg === "." || seg === "..")) return null;
30507
30579
  const pagesDir = resolve15(templatesDir, TEMPLATE_PAGES_DIR);
30508
30580
  for (const ext of [".twig", ".html"]) {
30509
- if (existsSync23(resolve15(pagesDir, cleanPath + ext))) {
30581
+ if (existsSync24(resolve15(pagesDir, cleanPath + ext))) {
30510
30582
  return `${TEMPLATE_PAGES_DIR}/${cleanPath}${ext}`;
30511
30583
  }
30512
30584
  }
@@ -30515,7 +30587,7 @@ function resolveTemplate(pathname, templatesDir) {
30515
30587
  if (!templateCache) {
30516
30588
  templateCache = /* @__PURE__ */ new Map();
30517
30589
  const pagesDir = resolve15(templatesDir, TEMPLATE_PAGES_DIR);
30518
- if (existsSync23(pagesDir)) {
30590
+ if (existsSync24(pagesDir)) {
30519
30591
  const scan = (dir, prefix) => {
30520
30592
  for (const entry of readdirSync15(dir, { withFileTypes: true })) {
30521
30593
  if (entry.name.startsWith("_")) continue;
@@ -30983,9 +31055,9 @@ function serveMethodNotAllowed(ctx) {
30983
31055
  }
30984
31056
  function serveStaticAsset(ctx) {
30985
31057
  const custom = process.env.TINA4_PUBLIC_DIR;
30986
- if (custom && existsSync23(custom) && tryServeStatic(custom, ctx.req, ctx.res)) return true;
30987
- if (existsSync23(ctx.staticDir) && tryServeStatic(ctx.staticDir, ctx.req, ctx.res)) return true;
30988
- if (existsSync23(ctx.srcPublicDir) && tryServeStatic(ctx.srcPublicDir, ctx.req, ctx.res)) return true;
31058
+ if (custom && existsSync24(custom) && tryServeStatic(custom, ctx.req, ctx.res)) return true;
31059
+ if (existsSync24(ctx.staticDir) && tryServeStatic(ctx.staticDir, ctx.req, ctx.res)) return true;
31060
+ if (existsSync24(ctx.srcPublicDir) && tryServeStatic(ctx.srcPublicDir, ctx.req, ctx.res)) return true;
30989
31061
  if (ctx.swaggerAssetsEnabled || !isSwaggerAssetPath(ctx.pathname)) {
30990
31062
  if (tryServeStatic(BUILTIN_PUBLIC_DIR, ctx.req, ctx.res)) return true;
30991
31063
  }
@@ -31199,6 +31271,9 @@ function startProductionCluster(port, host) {
31199
31271
  Debug: OFF (Log level: ${logLevel})
31200
31272
  ${reset2}`);
31201
31273
  }
31274
+ if (process.env.NODE_CLUSTER_SCHED_POLICY === void 0) {
31275
+ cluster.schedulingPolicy = cluster.SCHED_RR;
31276
+ }
31202
31277
  for (let i = 0; i < numCPUs; i++) cluster.fork();
31203
31278
  cluster.on("exit", (worker, code) => {
31204
31279
  if (code !== 0) {
@@ -31218,7 +31293,7 @@ ${reset2}`);
31218
31293
  function wireLocaleGlobal(frondEngine, base) {
31219
31294
  if (!frondEngine) return;
31220
31295
  const localeDir = resolve15(base, process.env.TINA4_LOCALE_DIR ?? "src/locales");
31221
- if (!existsSync23(localeDir)) return;
31296
+ if (!existsSync24(localeDir)) return;
31222
31297
  try {
31223
31298
  const localeFiles = readdirSync15(localeDir).filter((file) => file.endsWith(".json"));
31224
31299
  const FrondClass = frondEngine.constructor;
@@ -31291,7 +31366,7 @@ async function startServer(config) {
31291
31366
  middleware.use(requestLogger());
31292
31367
  middleware.use(rateLimiter());
31293
31368
  MiddlewareRunner.use(SecurityHeadersMiddleware);
31294
- if (existsSync23(routesDir)) {
31369
+ if (existsSync24(routesDir)) {
31295
31370
  const routes = await discoverRoutes(routesDir);
31296
31371
  for (const route of routes) {
31297
31372
  router.addRoute(route);
@@ -31554,8 +31629,8 @@ ${reset2}
31554
31629
  });
31555
31630
  }
31556
31631
  async function initializeOrm(config, router, base, ormDir, modelsDir) {
31557
- const hasOrmDir = existsSync23(ormDir);
31558
- const hasModelsDir = existsSync23(modelsDir);
31632
+ const hasOrmDir = existsSync24(ormDir);
31633
+ const hasModelsDir = existsSync24(modelsDir);
31559
31634
  if (hasOrmDir || hasModelsDir) {
31560
31635
  let ormStage = "import";
31561
31636
  const dbConfig = config?.database ?? {};
@@ -31618,7 +31693,7 @@ async function configureSwagger(router, ormDir, modelsDir) {
31618
31693
  let modelDefs = [];
31619
31694
  try {
31620
31695
  const orm = await Promise.resolve().then(() => (init_index(), index_exports));
31621
- const allModelDirs = [ormDir, modelsDir].filter((d) => existsSync23(d));
31696
+ const allModelDirs = [ormDir, modelsDir].filter((d) => existsSync24(d));
31622
31697
  const seenTables = /* @__PURE__ */ new Set();
31623
31698
  for (const dir of allModelDirs) {
31624
31699
  const discovered = await orm.discoverModels(dir);
@@ -31669,7 +31744,7 @@ var init_server = __esm({
31669
31744
  init_background();
31670
31745
  init_tcp();
31671
31746
  init_version();
31672
- __filename = fileURLToPath7(import.meta.url);
31747
+ __filename = fileURLToPath8(import.meta.url);
31673
31748
  __dirname = dirname12(__filename);
31674
31749
  BUILTIN_ERROR_TEMPLATES_DIR = resolve15(__dirname, "..", "templates");
31675
31750
  BUILTIN_PUBLIC_DIR = resolve15(__dirname, "..", "public");
@@ -31833,8 +31908,9 @@ var init_env = __esm({
31833
31908
 
31834
31909
  // ../core/src/fakeData.ts
31835
31910
  import { randomInt, randomUUID as randomUUID7 } from "node:crypto";
31836
- import { existsSync as existsSync24, readdirSync as readdirSync16 } from "node:fs";
31837
- import { resolve as resolve16, join as join26 } from "node:path";
31911
+ import { existsSync as existsSync25, readdirSync as readdirSync16 } from "node:fs";
31912
+ import { resolve as resolve16, join as join27 } from "node:path";
31913
+ import { pathToFileURL as pathToFileURL2 } from "node:url";
31838
31914
  function mulberry32(seed) {
31839
31915
  let s = seed | 0;
31840
31916
  return () => {
@@ -32332,13 +32408,13 @@ var init_fakeData = __esm({
32332
32408
  */
32333
32409
  async seedDir(seedDir) {
32334
32410
  const dir = resolve16(seedDir ?? "src/seeds");
32335
- if (!existsSync24(dir)) return [];
32411
+ if (!existsSync25(dir)) return [];
32336
32412
  const files = readdirSync16(dir).filter((f) => f.endsWith(".ts") || f.endsWith(".js")).sort();
32337
32413
  const executed = [];
32338
32414
  for (const file of files) {
32339
- const fullPath = join26(dir, file);
32415
+ const fullPath = join27(dir, file);
32340
32416
  try {
32341
- const mod = await import(fullPath);
32417
+ const mod = await import(pathToFileURL2(fullPath).href);
32342
32418
  if (typeof mod.default === "function") {
32343
32419
  await mod.default();
32344
32420
  }
@@ -32442,7 +32518,7 @@ var init_mqttMessage = __esm({
32442
32518
  import net3 from "node:net";
32443
32519
  import tls from "node:tls";
32444
32520
  import { randomBytes as randomBytes8 } from "node:crypto";
32445
- import { existsSync as existsSync25, readFileSync as readFileSync22 } from "node:fs";
32521
+ import { existsSync as existsSync26, readFileSync as readFileSync22 } from "node:fs";
32446
32522
  var MqttError, MqttTimeoutError, CONNECT, CONNACK, PUBLISH, PUBACK, SUBSCRIBE, SUBACK, PINGREQ, PINGRESP, DISCONNECT, PROTOCOL_LEVEL, DEFAULT_PORT, DEFAULT_TLS_PORT, DEFAULT_URL, DEFAULT_KEEPALIVE, SUBSCRIPTION_REFUSED, MAX_REMAINING_LENGTH, QOS2_REFUSED_MESSAGE, CONNACK_RETURN_CODES, Mqtt;
32447
32523
  var init_mqtt = __esm({
32448
32524
  "../core/src/mqtt.ts"() {
@@ -32645,7 +32721,7 @@ var init_mqtt = __esm({
32645
32721
  */
32646
32722
  async connect() {
32647
32723
  this.closeSocket();
32648
- if (this.secure && this.tlsVerify && this.caFile && !existsSync25(this.caFile)) {
32724
+ if (this.secure && this.tlsVerify && this.caFile && !existsSync26(this.caFile)) {
32649
32725
  throw new MqttError(
32650
32726
  `MQTT CA file not found: ${this.caFile} -- TINA4_MQTT_CA_FILE (or caFile) must point at the broker's CA certificate in PEM form`
32651
32727
  );
@@ -33127,9 +33203,9 @@ var init_mqtt = __esm({
33127
33203
  });
33128
33204
 
33129
33205
  // ../core/src/service.ts
33130
- import { readdirSync as readdirSync17, statSync as statSync17, watchFile, unwatchFile } from "node:fs";
33131
- import { join as join27, extname as extname7 } from "node:path";
33132
- import { pathToFileURL } from "node:url";
33206
+ import { readdirSync as readdirSync17, statSync as statSync18, watchFile, unwatchFile } from "node:fs";
33207
+ import { join as join28, extname as extname8 } from "node:path";
33208
+ import { pathToFileURL as pathToFileURL3 } from "node:url";
33133
33209
  function matchCronField(field, value) {
33134
33210
  if (field === "*") return true;
33135
33211
  if (field.includes("/")) {
@@ -33300,13 +33376,13 @@ var init_service = __esm({
33300
33376
  return discovered;
33301
33377
  }
33302
33378
  for (const entry of entries) {
33303
- const ext = extname7(entry);
33379
+ const ext = extname8(entry);
33304
33380
  if (ext !== ".ts" && ext !== ".js") continue;
33305
- const fullPath = join27(dir, entry);
33306
- const stat = statSync17(fullPath);
33381
+ const fullPath = join28(dir, entry);
33382
+ const stat = statSync18(fullPath);
33307
33383
  if (!stat.isFile()) continue;
33308
33384
  try {
33309
- const fileUrl = pathToFileURL(fullPath).href;
33385
+ const fileUrl = pathToFileURL3(fullPath).href;
33310
33386
  const mod = await import(fileUrl);
33311
33387
  const exp = mod.default ?? mod;
33312
33388
  if (exp.name && typeof exp.handler === "function") {
@@ -33427,13 +33503,13 @@ var init_service = __esm({
33427
33503
  return;
33428
33504
  }
33429
33505
  for (const entry of entries) {
33430
- const ext = extname7(entry);
33506
+ const ext = extname8(entry);
33431
33507
  if (ext !== ".ts" && ext !== ".js") continue;
33432
- const fullPath = join27(dir, entry);
33508
+ const fullPath = join28(dir, entry);
33433
33509
  if (watchedFiles.has(fullPath)) continue;
33434
33510
  watchedFiles.add(fullPath);
33435
33511
  watchFile(fullPath, { interval: 1e3 }, async () => {
33436
- const fileUrl = pathToFileURL(fullPath).href;
33512
+ const fileUrl = pathToFileURL3(fullPath).href;
33437
33513
  try {
33438
33514
  const mod = await import(fileUrl + "?t=" + Date.now());
33439
33515
  const exp = mod.default ?? mod;
@@ -33696,23 +33772,23 @@ function guessContentType(filename) {
33696
33772
  }
33697
33773
  function buildMultipartBody(boundary, fieldName, filename, fileContent, contentType, extraFields) {
33698
33774
  const crlf = "\r\n";
33699
- const delimiter2 = `--${boundary}`;
33775
+ const delimiter3 = `--${boundary}`;
33700
33776
  const parts = [];
33701
33777
  if (extraFields) {
33702
33778
  for (const [key, value] of Object.entries(extraFields)) {
33703
- parts.push(Buffer.from(delimiter2 + crlf, "utf-8"));
33779
+ parts.push(Buffer.from(delimiter3 + crlf, "utf-8"));
33704
33780
  parts.push(Buffer.from(`Content-Disposition: form-data; name="${key}"` + crlf + crlf, "utf-8"));
33705
33781
  parts.push(Buffer.from(String(value) + crlf, "utf-8"));
33706
33782
  }
33707
33783
  }
33708
- parts.push(Buffer.from(delimiter2 + crlf, "utf-8"));
33784
+ parts.push(Buffer.from(delimiter3 + crlf, "utf-8"));
33709
33785
  parts.push(
33710
33786
  Buffer.from(`Content-Disposition: form-data; name="${fieldName}"; filename="${filename}"` + crlf, "utf-8")
33711
33787
  );
33712
33788
  parts.push(Buffer.from(`Content-Type: ${contentType}` + crlf + crlf, "utf-8"));
33713
33789
  parts.push(fileContent);
33714
33790
  parts.push(Buffer.from(crlf, "utf-8"));
33715
- parts.push(Buffer.from(delimiter2 + "--" + crlf, "utf-8"));
33791
+ parts.push(Buffer.from(delimiter3 + "--" + crlf, "utf-8"));
33716
33792
  return Buffer.concat(parts);
33717
33793
  }
33718
33794
  async function* parseLineStream(chunks) {
@@ -33959,8 +34035,8 @@ var init_api = __esm({
33959
34035
  /**
33960
34036
  * HTTP GET request.
33961
34037
  */
33962
- async get(path10, params) {
33963
- let url = this.buildUrl(path10);
34038
+ async get(path9, params) {
34039
+ let url = this.buildUrl(path9);
33964
34040
  if (params && Object.keys(params).length > 0) {
33965
34041
  const qs = new URLSearchParams(params).toString();
33966
34042
  url += (url.includes("?") ? "&" : "?") + qs;
@@ -33970,32 +34046,32 @@ var init_api = __esm({
33970
34046
  /**
33971
34047
  * HTTP POST request.
33972
34048
  */
33973
- async post(path10, body, contentType = "application/json") {
33974
- return this.sendRequest("POST", path10, body, contentType);
34049
+ async post(path9, body, contentType = "application/json") {
34050
+ return this.sendRequest("POST", path9, body, contentType);
33975
34051
  }
33976
34052
  /**
33977
34053
  * HTTP PUT request.
33978
34054
  */
33979
- async put(path10, body, contentType = "application/json") {
33980
- return this.sendRequest("PUT", path10, body, contentType);
34055
+ async put(path9, body, contentType = "application/json") {
34056
+ return this.sendRequest("PUT", path9, body, contentType);
33981
34057
  }
33982
34058
  /**
33983
34059
  * HTTP PATCH request.
33984
34060
  */
33985
- async patch(path10, body, contentType = "application/json") {
33986
- return this.sendRequest("PATCH", path10, body, contentType);
34061
+ async patch(path9, body, contentType = "application/json") {
34062
+ return this.sendRequest("PATCH", path9, body, contentType);
33987
34063
  }
33988
34064
  /**
33989
34065
  * HTTP DELETE request.
33990
34066
  */
33991
- async delete(path10, body) {
33992
- return this.sendRequest("DELETE", path10, body);
34067
+ async delete(path9, body) {
34068
+ return this.sendRequest("DELETE", path9, body);
33993
34069
  }
33994
34070
  /**
33995
34071
  * Generic request method — public entry point for any HTTP method.
33996
34072
  */
33997
- async sendRequest(method, path10, body, contentType = "application/json") {
33998
- const url = this.buildUrl(path10);
34073
+ async sendRequest(method, path9, body, contentType = "application/json") {
34074
+ const url = this.buildUrl(path9);
33999
34075
  return this.execute(method.toUpperCase(), url, body, contentType);
34000
34076
  }
34001
34077
  /**
@@ -34019,7 +34095,7 @@ var init_api = __esm({
34019
34095
  * await api.upload("/avatars", { fileBytes: raw, filename: "me.png",
34020
34096
  * extraFields: { user_id: "42" } });
34021
34097
  */
34022
- async upload(path10, opts = {}) {
34098
+ async upload(path9, opts = {}) {
34023
34099
  const { filePath, fieldName = "file", extraFields, headers, fileBytes, filename } = opts;
34024
34100
  let content;
34025
34101
  let uploadName;
@@ -34054,7 +34130,7 @@ var init_api = __esm({
34054
34130
  const boundary = "----Tina4Boundary" + randomBytes9(16).toString("hex");
34055
34131
  const bodyBuffer = buildMultipartBody(boundary, fieldName, uploadName, content, partContentType, extraFields);
34056
34132
  const contentType = `multipart/form-data; boundary=${boundary}`;
34057
- return this.execute("POST", this.buildUrl(path10), bodyBuffer, contentType, headers);
34133
+ return this.execute("POST", this.buildUrl(path9), bodyBuffer, contentType, headers);
34058
34134
  }
34059
34135
  /**
34060
34136
  * Stream a GET response body to `destPath` in chunks.
@@ -34069,11 +34145,11 @@ var init_api = __esm({
34069
34145
  * dest, HTTP error status, or a transport failure); the destination file is
34070
34146
  * not written on error.
34071
34147
  */
34072
- async download(path10, destPath, params) {
34148
+ async download(path9, destPath, params) {
34073
34149
  if (!destPath) {
34074
34150
  return { http_code: null, headers: {}, error: "download requires destPath", path: null };
34075
34151
  }
34076
- let url = this.buildUrl(path10);
34152
+ let url = this.buildUrl(path9);
34077
34153
  if (params && Object.keys(params).length > 0) {
34078
34154
  const qs = new URLSearchParams(params).toString();
34079
34155
  url += (url.includes("?") ? "&" : "?") + qs;
@@ -34157,8 +34233,8 @@ var init_api = __esm({
34157
34233
  * bounds just the connect + headers phase (default
34158
34234
  * `TINA4_API_CONNECT_TIMEOUT` or 10s).
34159
34235
  */
34160
- async *streamBytes(path10, opts = {}) {
34161
- const url = this.buildUrl(path10);
34236
+ async *streamBytes(path9, opts = {}) {
34237
+ const url = this.buildUrl(path9);
34162
34238
  const method = (opts.method ?? "GET").toUpperCase();
34163
34239
  const contentType = opts.contentType ?? "application/json";
34164
34240
  const { headers, data } = this.buildRequest(method, contentType, opts.body, opts.headers, url);
@@ -34193,8 +34269,8 @@ var init_api = __esm({
34193
34269
  * yields a trailing line without a terminator on EOF. Built on
34194
34270
  * {@link streamBytes} plus the shared {@link parseLineStream}.
34195
34271
  */
34196
- async *streamLines(path10, opts = {}) {
34197
- yield* parseLineStream(this.streamBytes(path10, opts));
34272
+ async *streamLines(path9, opts = {}) {
34273
+ yield* parseLineStream(this.streamBytes(path9, opts));
34198
34274
  }
34199
34275
  /**
34200
34276
  * Stream the response as SSE (Server-Sent Events). Yields one
@@ -34203,8 +34279,8 @@ var init_api = __esm({
34203
34279
  * with `data === "[DONE]"` and the iterator ends on the next EOF.
34204
34280
  * Built on {@link streamLines} plus the shared {@link parseSseStream}.
34205
34281
  */
34206
- async *streamSse(path10, opts = {}) {
34207
- yield* parseSseStream(this.streamLines(path10, opts));
34282
+ async *streamSse(path9, opts = {}) {
34283
+ yield* parseSseStream(this.streamLines(path9, opts));
34208
34284
  }
34209
34285
  // ── Internal helpers ──────────────────────────────────────────────
34210
34286
  /**
@@ -34270,14 +34346,14 @@ var init_api = __esm({
34270
34346
  req2.end();
34271
34347
  });
34272
34348
  }
34273
- buildUrl(path10) {
34274
- if (path10.startsWith("http://") || path10.startsWith("https://")) {
34275
- return path10;
34349
+ buildUrl(path9) {
34350
+ if (path9.startsWith("http://") || path9.startsWith("https://")) {
34351
+ return path9;
34276
34352
  }
34277
- if (!path10) {
34353
+ if (!path9) {
34278
34354
  return this.baseUrl;
34279
34355
  }
34280
- return `${this.baseUrl}/${path10.replace(/^\/+/, "")}`;
34356
+ return `${this.baseUrl}/${path9.replace(/^\/+/, "")}`;
34281
34357
  }
34282
34358
  /**
34283
34359
  * The headers configured on the client, as they may go to `targetUrl`.
@@ -36217,15 +36293,15 @@ var init_htmlElement = __esm({
36217
36293
  });
36218
36294
 
36219
36295
  // ../core/src/ai.ts
36220
- import { existsSync as existsSync26, mkdirSync as mkdirSync17, writeFileSync as writeFileSync16, readFileSync as readFileSync24 } from "node:fs";
36296
+ import { existsSync as existsSync27, mkdirSync as mkdirSync17, writeFileSync as writeFileSync16, readFileSync as readFileSync24 } from "node:fs";
36221
36297
  import { homedir } from "node:os";
36222
- import { join as join28, resolve as resolve17, relative as relative11, dirname as dirname13 } from "node:path";
36223
- import { fileURLToPath as fileURLToPath8 } from "node:url";
36224
- import { execSync, execFileSync as execFileSync4 } from "node:child_process";
36298
+ import { join as join29, resolve as resolve17, relative as relative10, dirname as dirname13 } from "node:path";
36299
+ import { fileURLToPath as fileURLToPath9 } from "node:url";
36300
+ import { execSync, execFileSync as execFileSync3 } from "node:child_process";
36225
36301
  import { createInterface } from "node:readline";
36226
36302
  function readVersion() {
36227
36303
  try {
36228
- const thisDir = dirname13(fileURLToPath8(import.meta.url));
36304
+ const thisDir = dirname13(fileURLToPath9(import.meta.url));
36229
36305
  const rootPkg = resolve17(thisDir, "..", "..", "..", "package.json");
36230
36306
  const pkg = JSON.parse(readFileSync24(rootPkg, "utf-8"));
36231
36307
  return pkg.version ?? "0.0.0";
@@ -36277,7 +36353,7 @@ function downloadSkillsSync(jobs) {
36277
36353
  })();
36278
36354
  `;
36279
36355
  try {
36280
- const out = execFileSync4(process.execPath, ["-e", child, JSON.stringify(jobs)], {
36356
+ const out = execFileSync3(process.execPath, ["-e", child, JSON.stringify(jobs)], {
36281
36357
  encoding: "utf-8",
36282
36358
  timeout: 5e4,
36283
36359
  maxBuffer: 8 * 1024 * 1024
@@ -36290,8 +36366,8 @@ function downloadSkillsSync(jobs) {
36290
36366
  function installSkills(root = ".", targets) {
36291
36367
  const ref = skillsRef();
36292
36368
  const dests = targets ?? [
36293
- join28(resolve17(root), ".claude", "skills"),
36294
- join28(homedir(), ".claude", "skills")
36369
+ join29(resolve17(root), ".claude", "skills"),
36370
+ join29(homedir(), ".claude", "skills")
36295
36371
  ];
36296
36372
  const jobs = [];
36297
36373
  const index = /* @__PURE__ */ new Map();
@@ -36309,9 +36385,9 @@ function installSkills(root = ".", targets) {
36309
36385
  const base = `https://raw.githubusercontent.com/tina4stack/${spec.repo}/${ref}/.claude/skills/${skill}`;
36310
36386
  skillMdUrl[skill] = `${base}/SKILL.md`;
36311
36387
  for (const dest of dests) {
36312
- add(`${base}/SKILL.md`, join28(dest, skill, "SKILL.md"));
36388
+ add(`${base}/SKILL.md`, join29(dest, skill, "SKILL.md"));
36313
36389
  for (const r of spec.references) {
36314
- add(`${base}/references/${r}`, join28(dest, skill, "references", r));
36390
+ add(`${base}/references/${r}`, join29(dest, skill, "references", r));
36315
36391
  }
36316
36392
  }
36317
36393
  }
@@ -36323,7 +36399,7 @@ function installSkills(root = ".", targets) {
36323
36399
  return installed;
36324
36400
  }
36325
36401
  function isInstalled(root, tool) {
36326
- return existsSync26(join28(resolve17(root), tool.contextFile));
36402
+ return existsSync27(join29(resolve17(root), tool.contextFile));
36327
36403
  }
36328
36404
  function showMenu(root = ".") {
36329
36405
  const r = resolve17(root);
@@ -36446,7 +36522,7 @@ function looksLikeOldFrameworkInstall(existing) {
36446
36522
  function writeOrMerge(contextPath, contextFile, frameworkGuide) {
36447
36523
  const block = skillBlock(contextFile);
36448
36524
  const [start2, end] = markersFor(contextFile);
36449
- if (!existsSync26(contextPath)) {
36525
+ if (!existsSync27(contextPath)) {
36450
36526
  writeFileSync16(contextPath, frameworkGuide.replace(/\s+$/, "") + "\n\n" + block + "\n", "utf-8");
36451
36527
  return "Installed";
36452
36528
  }
@@ -36467,14 +36543,14 @@ function writeOrMerge(contextPath, contextFile, frameworkGuide) {
36467
36543
  }
36468
36544
  function installForTool(root, tool, context) {
36469
36545
  const created = [];
36470
- const contextPath = join28(root, tool.contextFile);
36546
+ const contextPath = join29(root, tool.contextFile);
36471
36547
  if (tool.configDir) {
36472
- mkdirSync17(join28(root, tool.configDir), { recursive: true });
36548
+ mkdirSync17(join29(root, tool.configDir), { recursive: true });
36473
36549
  }
36474
36550
  const parentDir = dirname13(contextPath);
36475
36551
  mkdirSync17(parentDir, { recursive: true });
36476
36552
  const action = writeOrMerge(contextPath, tool.contextFile, context);
36477
- const rel = relative11(root, contextPath);
36553
+ const rel = relative10(root, contextPath);
36478
36554
  created.push(rel);
36479
36555
  console.log(` ${GREEN2}\u2713${RESET2} ${action} ${rel}`);
36480
36556
  if (tool.name === "claude-code") {
@@ -36507,7 +36583,7 @@ function installTina4Ai() {
36507
36583
  function installClaudeSkills(root) {
36508
36584
  const created = [];
36509
36585
  for (const skill of installSkills(root)) {
36510
- created.push(join28(".claude", "skills", skill));
36586
+ created.push(join29(".claude", "skills", skill));
36511
36587
  console.log(` ${GREEN2}\u2713${RESET2} Installed .claude/skills/${skill} (project + global)`);
36512
36588
  }
36513
36589
  return created;
@@ -36848,10 +36924,10 @@ import { tests, assertEqual, runAll } from "tina4-nodejs";
36848
36924
  }
36849
36925
  function generateClaudeCodeContext() {
36850
36926
  try {
36851
- const thisDir = dirname13(fileURLToPath8(import.meta.url));
36927
+ const thisDir = dirname13(fileURLToPath9(import.meta.url));
36852
36928
  const repoRoot = resolve17(thisDir, "..", "..", "..");
36853
- const claudeMdPath = join28(repoRoot, "CLAUDE.md");
36854
- if (existsSync26(claudeMdPath)) {
36929
+ const claudeMdPath = join29(repoRoot, "CLAUDE.md");
36930
+ if (existsSync27(claudeMdPath)) {
36855
36931
  return readFileSync24(claudeMdPath, "utf-8");
36856
36932
  }
36857
36933
  } catch {
@@ -37512,10 +37588,10 @@ var init_aiClient = __esm({
37512
37588
  throw new AiConfigError("AI URL must be an http or https URL");
37513
37589
  }
37514
37590
  if (url.protocol !== "http:" && url.protocol !== "https:") throw new AiConfigError("AI URL must be an http or https URL");
37515
- const path10 = rtrimSlashes(url.pathname);
37516
- if (path10 === "" || path10 === "/v1" || path10 === "/api" || path10 === "/v1beta/openai") {
37591
+ const path9 = rtrimSlashes(url.pathname);
37592
+ if (path9 === "" || path9 === "/v1" || path9 === "/api" || path9 === "/v1beta/openai") {
37517
37593
  const suffix = provider === "anthropic" ? "/messages" : capability === "embed" ? "/embeddings" : "/chat/completions";
37518
- url.pathname = (path10 || "/v1") + suffix;
37594
+ url.pathname = (path9 || "/v1") + suffix;
37519
37595
  }
37520
37596
  return url.toString();
37521
37597
  }
@@ -38031,7 +38107,7 @@ var init_aiClient = __esm({
38031
38107
  });
38032
38108
 
38033
38109
  // ../core/src/queueBackends/rabbitmqBackend.ts
38034
- import { execFileSync as execFileSync5 } from "node:child_process";
38110
+ import { execFileSync as execFileSync4 } from "node:child_process";
38035
38111
  import { randomUUID as randomUUID9 } from "node:crypto";
38036
38112
  function parseAmqpUrl(url) {
38037
38113
  const config = {};
@@ -38452,7 +38528,7 @@ var init_rabbitmqBackend = __esm({
38452
38528
  setTimeout(() => { sock.destroy(); process.exit(1); }, 10000).unref();
38453
38529
  `;
38454
38530
  try {
38455
- const result = execFileSync5(process.execPath, ["-e", script], {
38531
+ const result = execFileSync4(process.execPath, ["-e", script], {
38456
38532
  encoding: "utf-8",
38457
38533
  timeout: 15e3,
38458
38534
  stdio: ["pipe", "pipe", "pipe"]
@@ -38828,27 +38904,27 @@ var init_testClient = __esm({
38828
38904
  return this.ctxPromise;
38829
38905
  }
38830
38906
  /** Send a GET request. */
38831
- async get(path10, options) {
38832
- return this._request("GET", path10, options);
38907
+ async get(path9, options) {
38908
+ return this._request("GET", path9, options);
38833
38909
  }
38834
38910
  /** Send a POST request. */
38835
- async post(path10, options) {
38836
- return this._request("POST", path10, options);
38911
+ async post(path9, options) {
38912
+ return this._request("POST", path9, options);
38837
38913
  }
38838
38914
  /** Send a PUT request. */
38839
- async put(path10, options) {
38840
- return this._request("PUT", path10, options);
38915
+ async put(path9, options) {
38916
+ return this._request("PUT", path9, options);
38841
38917
  }
38842
38918
  /** Send a PATCH request. */
38843
- async patch(path10, options) {
38844
- return this._request("PATCH", path10, options);
38919
+ async patch(path9, options) {
38920
+ return this._request("PATCH", path9, options);
38845
38921
  }
38846
38922
  /** Send a DELETE request. */
38847
- async delete(path10, options) {
38848
- return this._request("DELETE", path10, options);
38923
+ async delete(path9, options) {
38924
+ return this._request("DELETE", path9, options);
38849
38925
  }
38850
38926
  /** Build a mock request/response pair and dispatch it through the REAL pipeline (runDispatch). */
38851
- async _request(method, path10, options) {
38927
+ async _request(method, path9, options) {
38852
38928
  const { json, body, headers } = options ?? {};
38853
38929
  let rawBody = "";
38854
38930
  let contentType = "";
@@ -38874,7 +38950,7 @@ var init_testClient = __esm({
38874
38950
  Object.defineProperty(socket, "remoteAddress", { value: "127.0.0.1" });
38875
38951
  const rawReq = new IncomingMessage2(socket);
38876
38952
  rawReq.method = method.toUpperCase();
38877
- rawReq.url = path10;
38953
+ rawReq.url = path9;
38878
38954
  rawReq.headers = { ...reqHeaders, host: "localhost:7148" };
38879
38955
  if (rawBody) {
38880
38956
  rawReq.push(Buffer.from(rawBody));
@@ -38945,20 +39021,20 @@ var init_test = __esm({
38945
39021
  if (this._client === null) this._client = new TestClient();
38946
39022
  return this._client;
38947
39023
  }
38948
- async get(path10, options) {
38949
- return this.client.get(path10, options);
39024
+ async get(path9, options) {
39025
+ return this.client.get(path9, options);
38950
39026
  }
38951
- async post(path10, options) {
38952
- return this.client.post(path10, options);
39027
+ async post(path9, options) {
39028
+ return this.client.post(path9, options);
38953
39029
  }
38954
- async put(path10, options) {
38955
- return this.client.put(path10, options);
39030
+ async put(path9, options) {
39031
+ return this.client.put(path9, options);
38956
39032
  }
38957
- async patch(path10, options) {
38958
- return this.client.patch(path10, options);
39033
+ async patch(path9, options) {
39034
+ return this.client.patch(path9, options);
38959
39035
  }
38960
- async delete(path10, options) {
38961
- return this.client.delete(path10, options);
39036
+ async delete(path9, options) {
39037
+ return this.client.delete(path9, options);
38962
39038
  }
38963
39039
  // ── Positional assertions — (actual, expected, message) shape ────────
38964
39040
  assertEqual(actual, expected, message) {
@@ -40281,7 +40357,7 @@ __export(sqlite_exports, {
40281
40357
  });
40282
40358
  import { DatabaseSync as DatabaseSync3 } from "node:sqlite";
40283
40359
  import { mkdirSync as mkdirSync18 } from "node:fs";
40284
- import { dirname as dirname14, isAbsolute as isAbsolute5, join as join29, resolve as resolve18, sep as sep7 } from "node:path";
40360
+ import { dirname as dirname14, isAbsolute as isAbsolute5, join as join30, resolve as resolve18, sep as sep8 } from "node:path";
40285
40361
  function isIdentifier(str) {
40286
40362
  return /^[A-Za-z_][A-Za-z0-9_]*$/.test(str);
40287
40363
  }
@@ -40317,16 +40393,16 @@ function resolveSqlitePath(dbPath) {
40317
40393
  return dbPath;
40318
40394
  }
40319
40395
  const cwd = resolve18(process.cwd());
40320
- const path10 = join29(cwd, dbPath);
40321
- const parent = dirname14(path10);
40396
+ const path9 = join30(cwd, dbPath);
40397
+ const parent = dirname14(path9);
40322
40398
  const absParent = resolve18(parent);
40323
- if (absParent !== cwd && !absParent.startsWith(cwd + sep7)) {
40399
+ if (absParent !== cwd && !absParent.startsWith(cwd + sep8)) {
40324
40400
  throw new Error(
40325
40401
  `SQLite path "${dbPath}" resolves outside the project directory: "${absParent}" is not within "${cwd}". Tina4 refuses to create directories outside the project (ADR-0086). Use an absolute path for a database that lives outside the project.`
40326
40402
  );
40327
40403
  }
40328
40404
  mkdirSync18(parent, { recursive: true, mode: 509 });
40329
- return path10;
40405
+ return path9;
40330
40406
  }
40331
40407
  function fieldTypeToSQLite(def) {
40332
40408
  switch (def.type) {
@@ -44205,9 +44281,9 @@ async function initDatabase(config) {
44205
44281
  const rawType = config?.type ?? "sqlite";
44206
44282
  const type2 = rawType === "sqlserver" ? "mssql" : rawType;
44207
44283
  if (config === void 0 && !process.env.TINA4_DATABASE_URL) {
44208
- const path10 = "./data/tina4.db";
44284
+ const path9 = "./data/tina4.db";
44209
44285
  console.warn(
44210
- `[tina4] No TINA4_DATABASE_URL set \u2014 falling back to SQLite at ${path10}. If you meant to use Postgres/MySQL/etc., set TINA4_DATABASE_URL in your .env and re-run. (Was the .env loaded? CLI commands must call loadEnv() first.)`
44286
+ `[tina4] No TINA4_DATABASE_URL set \u2014 falling back to SQLite at ${path9}. If you meant to use Postgres/MySQL/etc., set TINA4_DATABASE_URL in your .env and re-run. (Was the .env loaded? CLI commands must call loadEnv() first.)`
44211
44287
  );
44212
44288
  }
44213
44289
  const finished = (adapter) => {
@@ -45420,8 +45496,9 @@ var init_database = __esm({
45420
45496
  });
45421
45497
 
45422
45498
  // src/model.ts
45423
- import { readdirSync as readdirSync18, statSync as statSync18 } from "node:fs";
45424
- import { join as join30, extname as extname8 } from "node:path";
45499
+ import { readdirSync as readdirSync18, statSync as statSync19 } from "node:fs";
45500
+ import { join as join31, extname as extname9 } from "node:path";
45501
+ import { pathToFileURL as pathToFileURL4 } from "node:url";
45425
45502
  async function discoverModels(modelsDir) {
45426
45503
  const models = [];
45427
45504
  let files;
@@ -45431,13 +45508,13 @@ async function discoverModels(modelsDir) {
45431
45508
  return models;
45432
45509
  }
45433
45510
  for (const file of files) {
45434
- const filePath = join30(modelsDir, file);
45435
- const stat = statSync18(filePath);
45511
+ const filePath = join31(modelsDir, file);
45512
+ const stat = statSync19(filePath);
45436
45513
  if (!stat.isFile()) continue;
45437
- const ext = extname8(file);
45514
+ const ext = extname9(file);
45438
45515
  if (ext !== ".ts" && ext !== ".js") continue;
45439
45516
  try {
45440
- const moduleUrl = `file://${filePath}?t=${Date.now()}`;
45517
+ const moduleUrl = `${pathToFileURL4(filePath).href}?t=${Date.now()}`;
45441
45518
  const mod = await import(moduleUrl);
45442
45519
  const ModelClass = mod.default ?? mod;
45443
45520
  if (!ModelClass.tableName || !ModelClass.fields) {
@@ -45473,8 +45550,8 @@ var init_model = __esm({
45473
45550
  });
45474
45551
 
45475
45552
  // src/migration.ts
45476
- import { existsSync as existsSync27, readdirSync as readdirSync19, readFileSync as readFileSync25, mkdirSync as mkdirSync19, writeFileSync as writeFileSync17, rmSync } from "node:fs";
45477
- import { join as join31, resolve as resolve19 } from "node:path";
45553
+ import { existsSync as existsSync28, readdirSync as readdirSync19, readFileSync as readFileSync25, mkdirSync as mkdirSync19, writeFileSync as writeFileSync17, rmSync } from "node:fs";
45554
+ import { join as join32, resolve as resolve19 } from "node:path";
45478
45555
  import { tmpdir } from "node:os";
45479
45556
  import { createHash as createHash10 } from "node:crypto";
45480
45557
  function unwrapAdapter(db) {
@@ -45778,7 +45855,7 @@ async function removeMigrationRecord(name) {
45778
45855
  [name]
45779
45856
  );
45780
45857
  }
45781
- async function rollback(migrationsDir, delimiter2) {
45858
+ async function rollback(migrationsDir, delimiter3) {
45782
45859
  if (migrationsDir instanceof Map) {
45783
45860
  const downFunctions = migrationsDir;
45784
45861
  const migrations2 = await getLastBatchMigrations();
@@ -45797,14 +45874,14 @@ async function rollback(migrationsDir, delimiter2) {
45797
45874
  return rolledBack2;
45798
45875
  }
45799
45876
  const dir = resolve19(migrationsDir ?? "migrations");
45800
- const delim = delimiter2 ?? ";";
45877
+ const delim = delimiter3 ?? ";";
45801
45878
  const db = getAdapter();
45802
45879
  const migrations = await getLastBatchMigrations();
45803
45880
  const rolledBack = [];
45804
45881
  for (const migration of migrations) {
45805
45882
  const downFile = `${migration.migration_name}.down.sql`;
45806
- const downPath = join31(dir, downFile);
45807
- if (!existsSync27(downPath)) {
45883
+ const downPath = join32(dir, downFile);
45884
+ if (!existsSync28(downPath)) {
45808
45885
  throw new Error(
45809
45886
  `Cannot rollback ${migration.migration_name}: no .down.sql file found`
45810
45887
  );
@@ -45920,13 +45997,13 @@ function hasExecutableSql(sql) {
45920
45997
  function isUnappliedScaffold(sql) {
45921
45998
  return TINA4_EDIT_MARKER_RE.test(sql) && !hasExecutableSql(sql);
45922
45999
  }
45923
- function splitStatements(sql, delimiter2 = ";") {
46000
+ function splitStatements(sql, delimiter3 = ";") {
45924
46001
  const state = {
45925
46002
  sql: normalizeQuotes(sql),
45926
46003
  statements: [],
45927
46004
  current: "",
45928
- delimiter: delimiter2,
45929
- dlen: delimiter2.length,
46005
+ delimiter: delimiter3,
46006
+ dlen: delimiter3.length,
45930
46007
  i: 0,
45931
46008
  inDollarBlock: false,
45932
46009
  inSlashBlock: false
@@ -45991,7 +46068,7 @@ async function acquireMigrationLock(db, dir) {
45991
46068
  return acquireFileLock(dir);
45992
46069
  }
45993
46070
  async function acquireFileLock(dir) {
45994
- const lockFile = join31(tmpdir(), `tina4-migration-${createHash10("sha256").update(resolve19(dir)).digest("hex")}.lock`);
46071
+ const lockFile = join32(tmpdir(), `tina4-migration-${createHash10("sha256").update(resolve19(dir)).digest("hex")}.lock`);
45995
46072
  const deadline = Date.now() + 6e4;
45996
46073
  for (; ; ) {
45997
46074
  try {
@@ -46053,18 +46130,18 @@ async function releaseMigrationLock(db, lock) {
46053
46130
  async function migrate(adapter, options) {
46054
46131
  const db = adapter ?? getAdapter();
46055
46132
  const dir = resolve19(options?.migrationsDir ?? "migrations");
46056
- const delimiter2 = options?.delimiter ?? ";";
46057
- if (!existsSync27(dir)) {
46133
+ const delimiter3 = options?.delimiter ?? ";";
46134
+ if (!existsSync28(dir)) {
46058
46135
  return { applied: [], skipped: [], failed: [] };
46059
46136
  }
46060
46137
  const lock = await acquireMigrationLock(db, dir);
46061
46138
  try {
46062
- return await runPendingMigrations(db, dir, delimiter2);
46139
+ return await runPendingMigrations(db, dir, delimiter3);
46063
46140
  } finally {
46064
46141
  await releaseMigrationLock(db, lock);
46065
46142
  }
46066
46143
  }
46067
- async function runPendingMigrations(db, dir, delimiter2) {
46144
+ async function runPendingMigrations(db, dir, delimiter3) {
46068
46145
  const result = { applied: [], skipped: [], failed: [] };
46069
46146
  await ensureMigrationTableOn(db);
46070
46147
  const files = sortMigrationFiles(
@@ -46099,7 +46176,7 @@ async function runPendingMigrations(db, dir, delimiter2) {
46099
46176
  result.skipped.push(file);
46100
46177
  continue;
46101
46178
  }
46102
- const sqlContent = readFileSync25(join31(dir, file), "utf-8").trim();
46179
+ const sqlContent = readFileSync25(join32(dir, file), "utf-8").trim();
46103
46180
  if (!sqlContent) {
46104
46181
  result.skipped.push(file);
46105
46182
  continue;
@@ -46110,7 +46187,7 @@ async function runPendingMigrations(db, dir, delimiter2) {
46110
46187
  );
46111
46188
  continue;
46112
46189
  }
46113
- const statements = splitStatements(sqlContent, delimiter2);
46190
+ const statements = splitStatements(sqlContent, delimiter3);
46114
46191
  try {
46115
46192
  await adapterStartTransaction(db);
46116
46193
  for (const stmt of statements) {
@@ -46142,7 +46219,7 @@ async function status(adapter, options) {
46142
46219
  const db = adapter ?? getAdapter();
46143
46220
  const dir = resolve19(options?.migrationsDir ?? "migrations");
46144
46221
  const result = { completed: [], pending: [] };
46145
- if (!existsSync27(dir)) {
46222
+ if (!existsSync28(dir)) {
46146
46223
  return result;
46147
46224
  }
46148
46225
  if (!await adapterTableExists(db, MIGRATION_TABLE)) {
@@ -46189,7 +46266,7 @@ async function createMigration(description, options) {
46189
46266
  return createClassMigration(description, options);
46190
46267
  }
46191
46268
  const dir = resolve19(options?.migrationsDir ?? "migrations");
46192
- if (!existsSync27(dir)) {
46269
+ if (!existsSync28(dir)) {
46193
46270
  mkdirSync19(dir, { recursive: true });
46194
46271
  }
46195
46272
  const safeName = description.toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_|_$/g, "");
@@ -46204,8 +46281,8 @@ async function createMigration(description, options) {
46204
46281
  ].join("");
46205
46282
  const upFileName = `${timestamp2}_${safeName}.sql`;
46206
46283
  const downFileName = `${timestamp2}_${safeName}.down.sql`;
46207
- const upPath = join31(dir, upFileName);
46208
- const downPath = join31(dir, downFileName);
46284
+ const upPath = join32(dir, upFileName);
46285
+ const downPath = join32(dir, downFileName);
46209
46286
  const upTemplate = `-- Migration: ${description}
46210
46287
  -- Created: ${now.toISOString()}
46211
46288
 
@@ -46220,7 +46297,7 @@ async function createMigration(description, options) {
46220
46297
  }
46221
46298
  async function createClassMigration(description, options) {
46222
46299
  const dir = resolve19(options?.migrationsDir ?? "migrations");
46223
- if (!existsSync27(dir)) {
46300
+ if (!existsSync28(dir)) {
46224
46301
  mkdirSync19(dir, { recursive: true });
46225
46302
  }
46226
46303
  const safeName = description.toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_|_$/g, "");
@@ -46235,7 +46312,7 @@ async function createClassMigration(description, options) {
46235
46312
  String(now.getSeconds()).padStart(2, "0")
46236
46313
  ].join("");
46237
46314
  const fileName = `${timestamp2}_${safeName}.ts`;
46238
- const filePath = join31(dir, fileName);
46315
+ const filePath = join32(dir, fileName);
46239
46316
  const content = `// Migration: ${description}
46240
46317
  // Created: ${now.toISOString()}
46241
46318
 
@@ -46340,7 +46417,7 @@ var init_migration = __esm({
46340
46417
  /** Return sorted list of all migration files on disk (excludes .down.sql). */
46341
46418
  getFiles() {
46342
46419
  const dir = resolve19(this.dir);
46343
- if (!existsSync27(dir)) return [];
46420
+ if (!existsSync28(dir)) return [];
46344
46421
  return sortMigrationFiles(
46345
46422
  readdirSync19(dir).filter((f) => f.endsWith(".sql") && !f.endsWith(".down.sql"))
46346
46423
  );
@@ -47121,9 +47198,9 @@ var init_crudTable = __esm({
47121
47198
  });
47122
47199
 
47123
47200
  // src/crudRender.ts
47124
- import { existsSync as existsSync28 } from "node:fs";
47201
+ import { existsSync as existsSync29 } from "node:fs";
47125
47202
  import { resolve as pathResolve, join as pathJoin, dirname as dirname15 } from "node:path";
47126
- import { fileURLToPath as fileURLToPath9 } from "node:url";
47203
+ import { fileURLToPath as fileURLToPath10 } from "node:url";
47127
47204
  function frondFor(dir) {
47128
47205
  let engine = frondCache2.get(dir);
47129
47206
  if (!engine) {
@@ -47136,7 +47213,7 @@ function frondFor(dir) {
47136
47213
  function renderCrudTemplate(name, data) {
47137
47214
  const templateFile = `crud/${name}.twig`;
47138
47215
  const userDir = pathResolve(process.cwd(), "src", "templates");
47139
- if (existsSync28(pathJoin(userDir, templateFile))) {
47216
+ if (existsSync29(pathJoin(userDir, templateFile))) {
47140
47217
  return frondFor(userDir).render(templateFile, data);
47141
47218
  }
47142
47219
  return frondFor(FRAMEWORK_TEMPLATES_DIR).render(templateFile, data);
@@ -47264,7 +47341,7 @@ var init_crudRender = __esm({
47264
47341
  init_crudHelpers();
47265
47342
  init_crudTable();
47266
47343
  FRAMEWORK_TEMPLATES_DIR = pathResolve(
47267
- dirname15(fileURLToPath9(import.meta.url)),
47344
+ dirname15(fileURLToPath10(import.meta.url)),
47268
47345
  "..",
47269
47346
  "..",
47270
47347
  "core",
@@ -49848,7 +49925,7 @@ var init_seeder = __esm({
49848
49925
  import { DatabaseSync as DatabaseSync4 } from "node:sqlite";
49849
49926
  import { randomBytes as randomBytes11 } from "node:crypto";
49850
49927
  import { mkdirSync as mkdirSync20 } from "node:fs";
49851
- import { dirname as dirname16, isAbsolute as isAbsolute6, join as join32 } from "node:path";
49928
+ import { dirname as dirname16, isAbsolute as isAbsolute6, join as join33 } from "node:path";
49852
49929
  function iso(d) {
49853
49930
  return d.toISOString();
49854
49931
  }
@@ -50123,12 +50200,12 @@ function regexpFn(pattern, value) {
50123
50200
  }
50124
50201
  function resolveStorePath(dbPath) {
50125
50202
  if (dbPath === ":memory:") return dbPath;
50126
- let path10 = dbPath;
50127
- if (!isAbsolute6(path10)) {
50128
- path10 = join32(process.cwd(), path10);
50129
- mkdirSync20(dirname16(path10), { recursive: true });
50203
+ let path9 = dbPath;
50204
+ if (!isAbsolute6(path9)) {
50205
+ path9 = join33(process.cwd(), path9);
50206
+ mkdirSync20(dirname16(path9), { recursive: true });
50130
50207
  }
50131
- return path10;
50208
+ return path9;
50132
50209
  }
50133
50210
  function mongoUriSource() {
50134
50211
  return MONGO_URI_VARS.find((name) => (process.env[name] ?? "").trim() !== "") ?? "";
@@ -50507,8 +50584,8 @@ var init_docstore = __esm({
50507
50584
  path;
50508
50585
  conn;
50509
50586
  collections = /* @__PURE__ */ new Map();
50510
- constructor(path10) {
50511
- this.path = path10 || process.env.TINA4_DOC_STORE_PATH || "data/tina4_docstore.db";
50587
+ constructor(path9) {
50588
+ this.path = path9 || process.env.TINA4_DOC_STORE_PATH || "data/tina4_docstore.db";
50512
50589
  const resolved = resolveStorePath(this.path);
50513
50590
  this.conn = new DatabaseSync4(resolved);
50514
50591
  this.conn.function("regexp", regexpFn);
@@ -50597,8 +50674,8 @@ var init_graphUrl = __esm({
50597
50674
  this.engine = engine;
50598
50675
  this.host = parsed.hostname || "localhost";
50599
50676
  this.port = parsed.port ? parseInt(parsed.port, 10) : ENGINE_DEFAULT_PORT[engine];
50600
- const path10 = (parsed.pathname || "").replace(/^\//, "");
50601
- this.graph = path10 === "" ? null : path10;
50677
+ const path9 = (parsed.pathname || "").replace(/^\//, "");
50678
+ this.graph = path9 === "" ? null : path9;
50602
50679
  this.username = parsed.username ? decodeURIComponent(parsed.username) : null;
50603
50680
  this.password = parsed.password ? decodeURIComponent(parsed.password) : null;
50604
50681
  this.params = {};
@@ -51609,8 +51686,8 @@ var init_s3Client = __esm({
51609
51686
 
51610
51687
  // src/realtime/storage.ts
51611
51688
  import { randomBytes as randomBytes12 } from "node:crypto";
51612
- import { mkdirSync as mkdirSync21, readFileSync as readFileSync26, writeFileSync as writeFileSync18, unlinkSync as unlinkSync9, statSync as statSync19 } from "node:fs";
51613
- import { resolve as resolve20, sep as sep8 } from "node:path";
51689
+ import { mkdirSync as mkdirSync21, readFileSync as readFileSync26, writeFileSync as writeFileSync18, unlinkSync as unlinkSync9, statSync as statSync20 } from "node:fs";
51690
+ import { resolve as resolve20, sep as sep9 } from "node:path";
51614
51691
  function storageKey(filename = "") {
51615
51692
  let ext = "";
51616
51693
  if (filename && filename.includes(".")) {
@@ -51651,7 +51728,7 @@ var init_storage = __esm({
51651
51728
  // Resolve inside the root and reject any traversal attempt.
51652
51729
  pathFor(key) {
51653
51730
  const target = resolve20(this.directory, key);
51654
- if (target !== this.directory && !target.startsWith(this.directory + sep8)) {
51731
+ if (target !== this.directory && !target.startsWith(this.directory + sep9)) {
51655
51732
  throw new Error(`unsafe storage key: ${JSON.stringify(key)}`);
51656
51733
  }
51657
51734
  return target;
@@ -51678,7 +51755,7 @@ var init_storage = __esm({
51678
51755
  }
51679
51756
  exists(key) {
51680
51757
  try {
51681
- return statSync19(this.pathFor(key)).isFile();
51758
+ return statSync20(this.pathFor(key)).isFile();
51682
51759
  } catch {
51683
51760
  return false;
51684
51761
  }