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.
@@ -148,16 +148,16 @@ function parseEnvContent(content) {
148
148
  }
149
149
  return result;
150
150
  }
151
- function loadEnv(path10, override = false) {
151
+ function loadEnv(path9, override = false) {
152
152
  const fromEnv = (process.env.TINA4_ENV_FILE ?? "").trim();
153
- if (path10 === void 0 && fromEnv.length > 0) {
153
+ if (path9 === void 0 && fromEnv.length > 0) {
154
154
  const named = resolve2(fromEnv);
155
155
  return mergeFirstWins(
156
156
  loadEnvFile(join2(dirname2(named), ".env.local"), override),
157
157
  loadEnvFile(named, override)
158
158
  );
159
159
  }
160
- const target = resolve2(path10 ?? ".");
160
+ const target = resolve2(path9 ?? ".");
161
161
  if (existsSync2(target) && statSync(target).isDirectory()) {
162
162
  return mergeFirstWins(
163
163
  loadEnvFile(join2(target, ".env.local"), override),
@@ -394,12 +394,12 @@ function resolveCallerName() {
394
394
  return void 0;
395
395
  }
396
396
  }
397
- function targetIsFile(path10) {
397
+ function targetIsFile(path9) {
398
398
  try {
399
- if (existsSync3(path10) && statSync2(path10).isDirectory()) return false;
399
+ if (existsSync3(path9) && statSync2(path9).isDirectory()) return false;
400
400
  } catch {
401
401
  }
402
- const base = basename2(path10);
402
+ const base = basename2(path9);
403
403
  return base.includes(".") && !base.startsWith(".");
404
404
  }
405
405
  function resolveBool(explicit, envName, fallback) {
@@ -723,8 +723,8 @@ var init_logger = __esm({
723
723
  rotateSize;
724
724
  rotateKeep;
725
725
  lock;
726
- constructor(path10, rotateSize, rotateKeep, lockBuffer) {
727
- this.path = path10;
726
+ constructor(path9, rotateSize, rotateKeep, lockBuffer) {
727
+ this.path = path9;
728
728
  this.rotateSize = rotateSize;
729
729
  this.rotateKeep = rotateKeep;
730
730
  this.lock = new SinkLock(lockBuffer);
@@ -1245,8 +1245,8 @@ function hashPassword(password, salt, iterations = 26e4) {
1245
1245
  }
1246
1246
  function checkPassword(password, hash) {
1247
1247
  try {
1248
- const delimiter4 = hash.includes("$") ? "$" : ":";
1249
- const parts = hash.split(delimiter4);
1248
+ const delimiter5 = hash.includes("$") ? "$" : ":";
1249
+ const parts = hash.split(delimiter5);
1250
1250
  if (parts.length !== 4 || parts[0] !== "pbkdf2_sha256") return false;
1251
1251
  const iterations = parseInt(parts[1], 10);
1252
1252
  const salt = parts[2];
@@ -1722,8 +1722,8 @@ var init_modelCollection = __esm({
1722
1722
 
1723
1723
  // ../orm/src/databaseUrl.ts
1724
1724
  import { inspect } from "node:util";
1725
- function stripOneSlash(path10) {
1726
- return path10.startsWith("/") ? path10.slice(1) : path10;
1725
+ function stripOneSlash(path9) {
1726
+ return path9.startsWith("/") ? path9.slice(1) : path9;
1727
1727
  }
1728
1728
  function decode(value) {
1729
1729
  if (value === void 0 || value === "") return null;
@@ -3730,8 +3730,8 @@ function resolveSqlitePath(dbPath) {
3730
3730
  return dbPath;
3731
3731
  }
3732
3732
  const cwd = resolve3(process.cwd());
3733
- const path10 = join5(cwd, dbPath);
3734
- const parent = dirname4(path10);
3733
+ const path9 = join5(cwd, dbPath);
3734
+ const parent = dirname4(path9);
3735
3735
  const absParent = resolve3(parent);
3736
3736
  if (absParent !== cwd && !absParent.startsWith(cwd + sep)) {
3737
3737
  throw new Error(
@@ -3739,7 +3739,7 @@ function resolveSqlitePath(dbPath) {
3739
3739
  );
3740
3740
  }
3741
3741
  mkdirSync3(parent, { recursive: true, mode: 509 });
3742
- return path10;
3742
+ return path9;
3743
3743
  }
3744
3744
  function fieldTypeToSQLite(def) {
3745
3745
  switch (def.type) {
@@ -7618,9 +7618,9 @@ async function initDatabase(config) {
7618
7618
  const rawType = config?.type ?? "sqlite";
7619
7619
  const type2 = rawType === "sqlserver" ? "mssql" : rawType;
7620
7620
  if (config === void 0 && !process.env.TINA4_DATABASE_URL) {
7621
- const path10 = "./data/tina4.db";
7621
+ const path9 = "./data/tina4.db";
7622
7622
  console.warn(
7623
- `[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.)`
7623
+ `[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.)`
7624
7624
  );
7625
7625
  }
7626
7626
  const finished = (adapter) => {
@@ -8835,6 +8835,7 @@ var init_database = __esm({
8835
8835
  // ../orm/src/model.ts
8836
8836
  import { readdirSync, statSync as statSync3 } from "node:fs";
8837
8837
  import { join as join6, extname } from "node:path";
8838
+ import { pathToFileURL } from "node:url";
8838
8839
  async function discoverModels(modelsDir) {
8839
8840
  const models = [];
8840
8841
  let files;
@@ -8850,7 +8851,7 @@ async function discoverModels(modelsDir) {
8850
8851
  const ext = extname(file);
8851
8852
  if (ext !== ".ts" && ext !== ".js") continue;
8852
8853
  try {
8853
- const moduleUrl = `file://${filePath}?t=${Date.now()}`;
8854
+ const moduleUrl = `${pathToFileURL(filePath).href}?t=${Date.now()}`;
8854
8855
  const mod = await import(moduleUrl);
8855
8856
  const ModelClass = mod.default ?? mod;
8856
8857
  if (!ModelClass.tableName || !ModelClass.fields) {
@@ -9191,7 +9192,7 @@ async function removeMigrationRecord(name) {
9191
9192
  [name]
9192
9193
  );
9193
9194
  }
9194
- async function rollback(migrationsDir, delimiter4) {
9195
+ async function rollback(migrationsDir, delimiter5) {
9195
9196
  if (migrationsDir instanceof Map) {
9196
9197
  const downFunctions = migrationsDir;
9197
9198
  const migrations2 = await getLastBatchMigrations();
@@ -9210,7 +9211,7 @@ async function rollback(migrationsDir, delimiter4) {
9210
9211
  return rolledBack2;
9211
9212
  }
9212
9213
  const dir = resolve4(migrationsDir ?? "migrations");
9213
- const delim = delimiter4 ?? ";";
9214
+ const delim = delimiter5 ?? ";";
9214
9215
  const db = getAdapter();
9215
9216
  const migrations = await getLastBatchMigrations();
9216
9217
  const rolledBack = [];
@@ -9333,13 +9334,13 @@ function hasExecutableSql(sql) {
9333
9334
  function isUnappliedScaffold(sql) {
9334
9335
  return TINA4_EDIT_MARKER_RE.test(sql) && !hasExecutableSql(sql);
9335
9336
  }
9336
- function splitStatements(sql, delimiter4 = ";") {
9337
+ function splitStatements(sql, delimiter5 = ";") {
9337
9338
  const state = {
9338
9339
  sql: normalizeQuotes(sql),
9339
9340
  statements: [],
9340
9341
  current: "",
9341
- delimiter: delimiter4,
9342
- dlen: delimiter4.length,
9342
+ delimiter: delimiter5,
9343
+ dlen: delimiter5.length,
9343
9344
  i: 0,
9344
9345
  inDollarBlock: false,
9345
9346
  inSlashBlock: false
@@ -9466,18 +9467,18 @@ async function releaseMigrationLock(db, lock) {
9466
9467
  async function migrate(adapter, options) {
9467
9468
  const db = adapter ?? getAdapter();
9468
9469
  const dir = resolve4(options?.migrationsDir ?? "migrations");
9469
- const delimiter4 = options?.delimiter ?? ";";
9470
+ const delimiter5 = options?.delimiter ?? ";";
9470
9471
  if (!existsSync5(dir)) {
9471
9472
  return { applied: [], skipped: [], failed: [] };
9472
9473
  }
9473
9474
  const lock = await acquireMigrationLock(db, dir);
9474
9475
  try {
9475
- return await runPendingMigrations(db, dir, delimiter4);
9476
+ return await runPendingMigrations(db, dir, delimiter5);
9476
9477
  } finally {
9477
9478
  await releaseMigrationLock(db, lock);
9478
9479
  }
9479
9480
  }
9480
- async function runPendingMigrations(db, dir, delimiter4) {
9481
+ async function runPendingMigrations(db, dir, delimiter5) {
9481
9482
  const result = { applied: [], skipped: [], failed: [] };
9482
9483
  await ensureMigrationTableOn(db);
9483
9484
  const files = sortMigrationFiles(
@@ -9523,7 +9524,7 @@ async function runPendingMigrations(db, dir, delimiter4) {
9523
9524
  );
9524
9525
  continue;
9525
9526
  }
9526
- const statements = splitStatements(sqlContent, delimiter4);
9527
+ const statements = splitStatements(sqlContent, delimiter5);
9527
9528
  try {
9528
9529
  await adapterStartTransaction(db);
9529
9530
  for (const stmt of statements) {
@@ -10703,15 +10704,15 @@ function findOutsideQuotes(expr, needle) {
10703
10704
  }
10704
10705
  return -1;
10705
10706
  }
10706
- function splitOutsideQuotes(expr, sep9) {
10707
- if (!expr.includes(sep9)) return [expr];
10707
+ function splitOutsideQuotes(expr, sep10) {
10708
+ if (!expr.includes(sep10)) return [expr];
10708
10709
  const parts = [];
10709
10710
  let currentStart = 0;
10710
10711
  let inQuote = null;
10711
10712
  let depth = 0;
10712
10713
  let bracketDepth = 0;
10713
10714
  let i = 0;
10714
- const sepLen = sep9.length;
10715
+ const sepLen = sep10.length;
10715
10716
  const lastStart = expr.length - sepLen;
10716
10717
  while (i <= lastStart) {
10717
10718
  const ch = expr[i];
@@ -10732,7 +10733,7 @@ function splitOutsideQuotes(expr, sep9) {
10732
10733
  else if (ch === ")") depth--;
10733
10734
  else if (ch === "[") bracketDepth++;
10734
10735
  else if (ch === "]") bracketDepth--;
10735
- if (depth === 0 && bracketDepth === 0 && expr.startsWith(sep9, i)) {
10736
+ if (depth === 0 && bracketDepth === 0 && expr.startsWith(sep10, i)) {
10736
10737
  parts.push(expr.slice(currentStart, i));
10737
10738
  i += sepLen;
10738
10739
  currentStart = i;
@@ -11910,8 +11911,8 @@ var init_engine = __esm({
11910
11911
  },
11911
11912
  first: (v) => Array.isArray(v) ? v[0] ?? null : null,
11912
11913
  last: (v) => Array.isArray(v) ? v[v.length - 1] ?? null : null,
11913
- join: (v, sep9) => Array.isArray(v) ? v.map(String).join(sep9 !== void 0 ? String(sep9) : ", ") : String(v),
11914
- split: (v, sep9) => String(v).split(sep9 !== void 0 ? String(sep9) : " "),
11914
+ join: (v, sep10) => Array.isArray(v) ? v.map(String).join(sep10 !== void 0 ? String(sep10) : ", ") : String(v),
11915
+ split: (v, sep10) => String(v).split(sep10 !== void 0 ? String(sep10) : " "),
11915
11916
  replace: (v, from, to) => {
11916
11917
  const s = String(v);
11917
11918
  if (from !== void 0 && typeof from === "object" && from !== null && !Array.isArray(from)) {
@@ -16073,6 +16074,7 @@ var init_baseModel = __esm({
16073
16074
  import { randomInt, randomUUID } from "node:crypto";
16074
16075
  import { existsSync as existsSync8, readdirSync as readdirSync3 } from "node:fs";
16075
16076
  import { resolve as resolve6, join as join9 } from "node:path";
16077
+ import { pathToFileURL as pathToFileURL2 } from "node:url";
16076
16078
  function mulberry32(seed) {
16077
16079
  let s = seed | 0;
16078
16080
  return () => {
@@ -16576,7 +16578,7 @@ var init_fakeData = __esm({
16576
16578
  for (const file of files) {
16577
16579
  const fullPath = join9(dir, file);
16578
16580
  try {
16579
- const mod = await import(fullPath);
16581
+ const mod = await import(pathToFileURL2(fullPath).href);
16580
16582
  if (typeof mod.default === "function") {
16581
16583
  await mod.default();
16582
16584
  }
@@ -17301,12 +17303,12 @@ function regexpFn(pattern, value) {
17301
17303
  }
17302
17304
  function resolveStorePath(dbPath) {
17303
17305
  if (dbPath === ":memory:") return dbPath;
17304
- let path10 = dbPath;
17305
- if (!isAbsolute4(path10)) {
17306
- path10 = join10(process.cwd(), path10);
17307
- mkdirSync5(dirname6(path10), { recursive: true });
17306
+ let path9 = dbPath;
17307
+ if (!isAbsolute4(path9)) {
17308
+ path9 = join10(process.cwd(), path9);
17309
+ mkdirSync5(dirname6(path9), { recursive: true });
17308
17310
  }
17309
- return path10;
17311
+ return path9;
17310
17312
  }
17311
17313
  function mongoUriSource() {
17312
17314
  return MONGO_URI_VARS.find((name) => (process.env[name] ?? "").trim() !== "") ?? "";
@@ -17685,8 +17687,8 @@ var init_docstore = __esm({
17685
17687
  path;
17686
17688
  conn;
17687
17689
  collections = /* @__PURE__ */ new Map();
17688
- constructor(path10) {
17689
- this.path = path10 || process.env.TINA4_DOC_STORE_PATH || "data/tina4_docstore.db";
17690
+ constructor(path9) {
17691
+ this.path = path9 || process.env.TINA4_DOC_STORE_PATH || "data/tina4_docstore.db";
17690
17692
  const resolved = resolveStorePath(this.path);
17691
17693
  this.conn = new DatabaseSync2(resolved);
17692
17694
  this.conn.function("regexp", regexpFn);
@@ -17775,8 +17777,8 @@ var init_graphUrl = __esm({
17775
17777
  this.engine = engine;
17776
17778
  this.host = parsed.hostname || "localhost";
17777
17779
  this.port = parsed.port ? parseInt(parsed.port, 10) : ENGINE_DEFAULT_PORT[engine];
17778
- const path10 = (parsed.pathname || "").replace(/^\//, "");
17779
- this.graph = path10 === "" ? null : path10;
17780
+ const path9 = (parsed.pathname || "").replace(/^\//, "");
17781
+ this.graph = path9 === "" ? null : path9;
17780
17782
  this.username = parsed.username ? decodeURIComponent(parsed.username) : null;
17781
17783
  this.password = parsed.password ? decodeURIComponent(parsed.password) : null;
17782
17784
  this.params = {};
@@ -20937,8 +20939,8 @@ function coerceParam(raw, type2) {
20937
20939
  return raw;
20938
20940
  }
20939
20941
  }
20940
- function joinGroupPath(prefix, path10) {
20941
- const full = `${prefix}/${path10.replace(/^\/+/, "")}`;
20942
+ function joinGroupPath(prefix, path9) {
20943
+ const full = `${prefix}/${path9.replace(/^\/+/, "")}`;
20942
20944
  const trimmed = `/${trimSlashes(full)}`;
20943
20945
  return trimmed.replace(/\/+/g, "/");
20944
20946
  }
@@ -20979,26 +20981,26 @@ async function runRouteMiddlewares(middlewares, req2, res) {
20979
20981
  }
20980
20982
  return true;
20981
20983
  }
20982
- function get(path10, handler, middlewares, meta) {
20983
- return defaultRouter.get(path10, handler, middlewares, meta);
20984
+ function get(path9, handler, middlewares, meta) {
20985
+ return defaultRouter.get(path9, handler, middlewares, meta);
20984
20986
  }
20985
- function post(path10, handler, middlewares, meta) {
20986
- return defaultRouter.post(path10, handler, middlewares, meta);
20987
+ function post(path9, handler, middlewares, meta) {
20988
+ return defaultRouter.post(path9, handler, middlewares, meta);
20987
20989
  }
20988
- function put(path10, handler, middlewares, meta) {
20989
- return defaultRouter.put(path10, handler, middlewares, meta);
20990
+ function put(path9, handler, middlewares, meta) {
20991
+ return defaultRouter.put(path9, handler, middlewares, meta);
20990
20992
  }
20991
- function patch(path10, handler, middlewares, meta) {
20992
- return defaultRouter.patch(path10, handler, middlewares, meta);
20993
+ function patch(path9, handler, middlewares, meta) {
20994
+ return defaultRouter.patch(path9, handler, middlewares, meta);
20993
20995
  }
20994
- function del(path10, handler, middlewares, meta) {
20995
- return defaultRouter.delete(path10, handler, middlewares, meta);
20996
+ function del(path9, handler, middlewares, meta) {
20997
+ return defaultRouter.delete(path9, handler, middlewares, meta);
20996
20998
  }
20997
- function any(path10, handler, middlewares, meta) {
20998
- return defaultRouter.any(path10, handler, middlewares, meta);
20999
+ function any(path9, handler, middlewares, meta) {
21000
+ return defaultRouter.any(path9, handler, middlewares, meta);
20999
21001
  }
21000
- function websocket(path10, handler, options) {
21001
- return defaultRouter.websocket(path10, handler, options);
21002
+ function websocket(path9, handler, options) {
21003
+ return defaultRouter.websocket(path9, handler, options);
21002
21004
  }
21003
21005
  var WsRouteRef, RouteRef, Router, RouteGroup, TINA4_DEFAULT_ROUTER, globalRouterHost, defaultRouter;
21004
21006
  var init_router = __esm({
@@ -21146,32 +21148,32 @@ var init_router = __esm({
21146
21148
  /**
21147
21149
  * Register a GET route programmatically.
21148
21150
  */
21149
- get(path10, handler, middlewares, meta) {
21150
- return this.addRoute({ method: "GET", pattern: path10, handler, middlewares, meta });
21151
+ get(path9, handler, middlewares, meta) {
21152
+ return this.addRoute({ method: "GET", pattern: path9, handler, middlewares, meta });
21151
21153
  }
21152
21154
  /**
21153
21155
  * Register a POST route programmatically.
21154
21156
  */
21155
- post(path10, handler, middlewares, meta) {
21156
- return this.addRoute({ method: "POST", pattern: path10, handler, middlewares, meta });
21157
+ post(path9, handler, middlewares, meta) {
21158
+ return this.addRoute({ method: "POST", pattern: path9, handler, middlewares, meta });
21157
21159
  }
21158
21160
  /**
21159
21161
  * Register a PUT route programmatically.
21160
21162
  */
21161
- put(path10, handler, middlewares, meta) {
21162
- return this.addRoute({ method: "PUT", pattern: path10, handler, middlewares, meta });
21163
+ put(path9, handler, middlewares, meta) {
21164
+ return this.addRoute({ method: "PUT", pattern: path9, handler, middlewares, meta });
21163
21165
  }
21164
21166
  /**
21165
21167
  * Register a PATCH route programmatically.
21166
21168
  */
21167
- patch(path10, handler, middlewares, meta) {
21168
- return this.addRoute({ method: "PATCH", pattern: path10, handler, middlewares, meta });
21169
+ patch(path9, handler, middlewares, meta) {
21170
+ return this.addRoute({ method: "PATCH", pattern: path9, handler, middlewares, meta });
21169
21171
  }
21170
21172
  /**
21171
21173
  * Register a DELETE route programmatically.
21172
21174
  */
21173
- delete(path10, handler, middlewares, meta) {
21174
- return this.addRoute({ method: "DELETE", pattern: path10, handler, middlewares, meta });
21175
+ delete(path9, handler, middlewares, meta) {
21176
+ return this.addRoute({ method: "DELETE", pattern: path9, handler, middlewares, meta });
21175
21177
  }
21176
21178
  /**
21177
21179
  * Register an explicit HEAD route. By default the framework auto-handles
@@ -21181,8 +21183,8 @@ var init_router = __esm({
21181
21183
  * logic, custom validator headers without the cost of building the body.
21182
21184
  * The framework still strips the response body for you on the way out.
21183
21185
  */
21184
- head(path10, handler, middlewares, meta) {
21185
- return this.addRoute({ method: "HEAD", pattern: path10, handler, middlewares, meta });
21186
+ head(path9, handler, middlewares, meta) {
21187
+ return this.addRoute({ method: "HEAD", pattern: path9, handler, middlewares, meta });
21186
21188
  }
21187
21189
  /**
21188
21190
  * Register an explicit OPTIONS route. By default the framework auto-
@@ -21190,16 +21192,16 @@ var init_router = __esm({
21190
21192
  * registered for the path and returning 204 (RFC 9110 §9.3.7). Use
21191
21193
  * this to take over that behaviour.
21192
21194
  */
21193
- options(path10, handler, middlewares, meta) {
21194
- return this.addRoute({ method: "OPTIONS", pattern: path10, handler, middlewares, meta });
21195
+ options(path9, handler, middlewares, meta) {
21196
+ return this.addRoute({ method: "OPTIONS", pattern: path9, handler, middlewares, meta });
21195
21197
  }
21196
21198
  /**
21197
21199
  * Register a route that matches ANY HTTP method.
21198
21200
  */
21199
- any(path10, handler, middlewares, meta) {
21201
+ any(path9, handler, middlewares, meta) {
21200
21202
  let lastRef;
21201
21203
  for (const method of ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"]) {
21202
- lastRef = this.addRoute({ method, pattern: path10, handler, middlewares, meta });
21204
+ lastRef = this.addRoute({ method, pattern: path9, handler, middlewares, meta });
21203
21205
  }
21204
21206
  return lastRef;
21205
21207
  }
@@ -21218,14 +21220,14 @@ var init_router = __esm({
21218
21220
  * the trailing slash. Returning the de-slashed pattern lets callers issue
21219
21221
  * a 308 redirect instead of a hard 404 — Python parity.
21220
21222
  */
21221
- match(method, path10) {
21223
+ match(method, path9) {
21222
21224
  const upperMethod = method.toUpperCase();
21223
21225
  const routes = this.routes.get(upperMethod);
21224
21226
  if (routes) {
21225
- const direct = this.matchRoute(routes, path10);
21227
+ const direct = this.matchRoute(routes, path9);
21226
21228
  if (direct) return direct;
21227
- if (isTrailingSlashRedirectEnabled() && path10.length > 1 && path10.endsWith("/")) {
21228
- const stripped = rtrimSlashes(path10);
21229
+ if (isTrailingSlashRedirectEnabled() && path9.length > 1 && path9.endsWith("/")) {
21230
+ const stripped = rtrimSlashes(path9);
21229
21231
  if (stripped.length > 0) {
21230
21232
  const retry = this.matchRoute(routes, stripped);
21231
21233
  if (retry) return retry;
@@ -21235,7 +21237,7 @@ var init_router = __esm({
21235
21237
  if (upperMethod === "HEAD") {
21236
21238
  const getRoutes = this.routes.get("GET");
21237
21239
  if (getRoutes) {
21238
- return this.matchRoute(getRoutes, path10);
21240
+ return this.matchRoute(getRoutes, path9);
21239
21241
  }
21240
21242
  }
21241
21243
  return null;
@@ -21250,13 +21252,13 @@ var init_router = __esm({
21250
21252
  * OPTIONS is appended whenever any method exists for the path (the
21251
21253
  * framework auto-handles OPTIONS).
21252
21254
  */
21253
- methodsAllowedForPath(path10) {
21255
+ methodsAllowedForPath(path9) {
21254
21256
  const order = ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"];
21255
21257
  const seen = /* @__PURE__ */ new Set();
21256
21258
  for (const m of order) {
21257
21259
  const routes = this.routes.get(m);
21258
21260
  if (!routes) continue;
21259
- if (this.matchRoute(routes, path10)) {
21261
+ if (this.matchRoute(routes, path9)) {
21260
21262
  seen.add(m);
21261
21263
  }
21262
21264
  }
@@ -21267,9 +21269,9 @@ var init_router = __esm({
21267
21269
  return order.filter((m) => seen.has(m));
21268
21270
  }
21269
21271
  /** Inner match against a list of compiled routes, no trailing-slash logic. */
21270
- matchRoute(routes, path10) {
21272
+ matchRoute(routes, path9) {
21271
21273
  for (const route of routes) {
21272
- const match = route.regex.exec(path10);
21274
+ const match = route.regex.exec(path9);
21273
21275
  if (match) {
21274
21276
  const params = {};
21275
21277
  for (let i = 0; i < route.paramNames.length; i++) {
@@ -21357,10 +21359,10 @@ var init_router = __esm({
21357
21359
  * When secured, the upgrade handshake requires a valid JWT (Authorization
21358
21360
  * header / `bearer` subprotocol / `?token=`) or the upgrade is rejected.
21359
21361
  */
21360
- websocket(path10, handler, options) {
21361
- this.wsRoutes = this.wsRoutes.filter((r) => r.pattern !== path10);
21362
+ websocket(path9, handler, options) {
21363
+ this.wsRoutes = this.wsRoutes.filter((r) => r.pattern !== path9);
21362
21364
  const route = {
21363
- pattern: path10,
21365
+ pattern: path9,
21364
21366
  handler,
21365
21367
  // Public unless explicitly secured via options OR a handler `_secured` flag.
21366
21368
  authRequired: Boolean(options?.secured ?? handler._secured ?? false)
@@ -21417,54 +21419,54 @@ var init_router = __esm({
21417
21419
  * Register a route for a specific HTTP method.
21418
21420
  * Core registration method — all convenience methods delegate here.
21419
21421
  */
21420
- static add(method, path10, handler, middleware, swaggerMeta, template) {
21422
+ static add(method, path9, handler, middleware, swaggerMeta, template) {
21421
21423
  const m = method.toUpperCase();
21422
21424
  if (m === "ANY") {
21423
- return defaultRouter.any(path10, handler, middleware, swaggerMeta);
21425
+ return defaultRouter.any(path9, handler, middleware, swaggerMeta);
21424
21426
  }
21425
- return defaultRouter.addRoute({ method: m, pattern: path10, handler, middlewares: middleware, meta: swaggerMeta, template });
21427
+ return defaultRouter.addRoute({ method: m, pattern: path9, handler, middlewares: middleware, meta: swaggerMeta, template });
21426
21428
  }
21427
21429
  /**
21428
21430
  * Register a GET route on the default global router.
21429
21431
  */
21430
- static get(path10, handler, middleware, swaggerMeta, template) {
21431
- return defaultRouter.get(path10, handler, middleware, swaggerMeta);
21432
+ static get(path9, handler, middleware, swaggerMeta, template) {
21433
+ return defaultRouter.get(path9, handler, middleware, swaggerMeta);
21432
21434
  }
21433
21435
  /**
21434
21436
  * Register a POST route on the default global router.
21435
21437
  */
21436
- static post(path10, handler, middleware, swaggerMeta, template) {
21437
- return defaultRouter.post(path10, handler, middleware, swaggerMeta);
21438
+ static post(path9, handler, middleware, swaggerMeta, template) {
21439
+ return defaultRouter.post(path9, handler, middleware, swaggerMeta);
21438
21440
  }
21439
21441
  /**
21440
21442
  * Register a PUT route on the default global router.
21441
21443
  */
21442
- static put(path10, handler, middleware, swaggerMeta, template) {
21443
- return defaultRouter.put(path10, handler, middleware, swaggerMeta);
21444
+ static put(path9, handler, middleware, swaggerMeta, template) {
21445
+ return defaultRouter.put(path9, handler, middleware, swaggerMeta);
21444
21446
  }
21445
21447
  /**
21446
21448
  * Register a PATCH route on the default global router.
21447
21449
  */
21448
- static patch(path10, handler, middleware, swaggerMeta, template) {
21449
- return defaultRouter.patch(path10, handler, middleware, swaggerMeta);
21450
+ static patch(path9, handler, middleware, swaggerMeta, template) {
21451
+ return defaultRouter.patch(path9, handler, middleware, swaggerMeta);
21450
21452
  }
21451
21453
  /**
21452
21454
  * Register a DELETE route on the default global router.
21453
21455
  */
21454
- static delete(path10, handler, middleware, swaggerMeta, template) {
21455
- return defaultRouter.delete(path10, handler, middleware, swaggerMeta);
21456
+ static delete(path9, handler, middleware, swaggerMeta, template) {
21457
+ return defaultRouter.delete(path9, handler, middleware, swaggerMeta);
21456
21458
  }
21457
21459
  /**
21458
21460
  * Register a route that matches ANY HTTP method on the default global router.
21459
21461
  */
21460
- static any(path10, handler, middleware, swaggerMeta, template) {
21461
- return defaultRouter.any(path10, handler, middleware, swaggerMeta);
21462
+ static any(path9, handler, middleware, swaggerMeta, template) {
21463
+ return defaultRouter.any(path9, handler, middleware, swaggerMeta);
21462
21464
  }
21463
21465
  /**
21464
21466
  * Register a WebSocket route on the default global router.
21465
21467
  */
21466
- static websocket(path10, handler, options) {
21467
- return defaultRouter.websocket(path10, handler, options);
21468
+ static websocket(path9, handler, options) {
21469
+ return defaultRouter.websocket(path9, handler, options);
21468
21470
  }
21469
21471
  /**
21470
21472
  * Match a WebSocket upgrade path against routes on the default global router.
@@ -21580,57 +21582,57 @@ var init_router = __esm({
21580
21582
  const merged = [...group, ...route];
21581
21583
  return merged.length > 0 ? merged : void 0;
21582
21584
  }
21583
- get(path10, handler, middlewares, meta) {
21585
+ get(path9, handler, middlewares, meta) {
21584
21586
  return this.router.addRoute({
21585
21587
  method: "GET",
21586
- pattern: joinGroupPath(this.prefix, path10),
21588
+ pattern: joinGroupPath(this.prefix, path9),
21587
21589
  handler,
21588
21590
  middlewares: this.mergeMiddlewares(middlewares),
21589
21591
  meta
21590
21592
  });
21591
21593
  }
21592
- post(path10, handler, middlewares, meta) {
21594
+ post(path9, handler, middlewares, meta) {
21593
21595
  return this.router.addRoute({
21594
21596
  method: "POST",
21595
- pattern: joinGroupPath(this.prefix, path10),
21597
+ pattern: joinGroupPath(this.prefix, path9),
21596
21598
  handler,
21597
21599
  middlewares: this.mergeMiddlewares(middlewares),
21598
21600
  meta
21599
21601
  });
21600
21602
  }
21601
- put(path10, handler, middlewares, meta) {
21603
+ put(path9, handler, middlewares, meta) {
21602
21604
  return this.router.addRoute({
21603
21605
  method: "PUT",
21604
- pattern: joinGroupPath(this.prefix, path10),
21606
+ pattern: joinGroupPath(this.prefix, path9),
21605
21607
  handler,
21606
21608
  middlewares: this.mergeMiddlewares(middlewares),
21607
21609
  meta
21608
21610
  });
21609
21611
  }
21610
- patch(path10, handler, middlewares, meta) {
21612
+ patch(path9, handler, middlewares, meta) {
21611
21613
  return this.router.addRoute({
21612
21614
  method: "PATCH",
21613
- pattern: joinGroupPath(this.prefix, path10),
21615
+ pattern: joinGroupPath(this.prefix, path9),
21614
21616
  handler,
21615
21617
  middlewares: this.mergeMiddlewares(middlewares),
21616
21618
  meta
21617
21619
  });
21618
21620
  }
21619
- delete(path10, handler, middlewares, meta) {
21621
+ delete(path9, handler, middlewares, meta) {
21620
21622
  return this.router.addRoute({
21621
21623
  method: "DELETE",
21622
- pattern: joinGroupPath(this.prefix, path10),
21624
+ pattern: joinGroupPath(this.prefix, path9),
21623
21625
  handler,
21624
21626
  middlewares: this.mergeMiddlewares(middlewares),
21625
21627
  meta
21626
21628
  });
21627
21629
  }
21628
- any(path10, handler, middlewares, meta) {
21630
+ any(path9, handler, middlewares, meta) {
21629
21631
  let lastRef;
21630
21632
  for (const method of ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"]) {
21631
21633
  lastRef = this.router.addRoute({
21632
21634
  method,
21633
- pattern: joinGroupPath(this.prefix, path10),
21635
+ pattern: joinGroupPath(this.prefix, path9),
21634
21636
  handler,
21635
21637
  middlewares: this.mergeMiddlewares(middlewares),
21636
21638
  meta
@@ -21832,6 +21834,7 @@ var init_trustedProxy = __esm({
21832
21834
  // ../core/src/response.ts
21833
21835
  import fs2 from "node:fs";
21834
21836
  import nodePath from "node:path";
21837
+ import { fileURLToPath as fileURLToPath3 } from "node:url";
21835
21838
  import { once } from "node:events";
21836
21839
  async function closeSource(source) {
21837
21840
  const s = source;
@@ -21874,7 +21877,7 @@ async function getFrond() {
21874
21877
  return engine;
21875
21878
  }
21876
21879
  async function getFrameworkFrond() {
21877
- const frameworkDir = nodePath.resolve(nodePath.dirname(import.meta.url.replace("file://", "")), "..", "templates");
21880
+ const frameworkDir = nodePath.resolve(nodePath.dirname(fileURLToPath3(import.meta.url)), "..", "templates");
21878
21881
  if (!_frameworkFrond && fs2.existsSync(frameworkDir)) {
21879
21882
  try {
21880
21883
  const { Frond: Frond2, setCspNonceProvider: setCspNonceProvider2 } = await Promise.resolve().then(() => (init_engine(), engine_exports));
@@ -22909,9 +22912,9 @@ var init_middleware = __esm({
22909
22912
  const duration = Date.now() - (req2.startTime ?? Date.now());
22910
22913
  const status2 = res.raw.statusCode;
22911
22914
  const method = req2.method ?? "?";
22912
- const path10 = logPath(req2);
22915
+ const path9 = logPath(req2);
22913
22916
  const color = status2 >= 400 ? "\x1B[31m" : status2 >= 300 ? "\x1B[33m" : "\x1B[32m";
22914
- console.log(` ${color}${status2}\x1B[0m ${method} ${path10} \x1B[90m${duration}ms\x1B[0m`);
22917
+ console.log(` ${color}${status2}\x1B[0m ${method} ${path9} \x1B[90m${duration}ms\x1B[0m`);
22915
22918
  return [req2, res];
22916
22919
  }
22917
22920
  };
@@ -23076,7 +23079,7 @@ function createRequest(req2) {
23076
23079
  const xfHost = trustedPeer ? req2.headers["x-forwarded-host"] : void 0;
23077
23080
  const host = (Array.isArray(xfHost) ? xfHost[0] : xfHost) ?? (req2.headers.host ?? "localhost");
23078
23081
  const query = {};
23079
- let path10;
23082
+ let path9;
23080
23083
  let queryString;
23081
23084
  let fullUrl;
23082
23085
  try {
@@ -23085,13 +23088,13 @@ function createRequest(req2) {
23085
23088
  if (isUnsafeFieldName(key)) continue;
23086
23089
  Reflect.set(query, key, value);
23087
23090
  }
23088
- path10 = url.pathname;
23091
+ path9 = url.pathname;
23089
23092
  queryString = url.search.replace(/^\?/, "");
23090
23093
  fullUrl = url.toString();
23091
23094
  } catch {
23092
23095
  const rawTarget = req2.url ?? "/";
23093
23096
  const questionIdx = rawTarget.indexOf("?");
23094
- path10 = questionIdx >= 0 ? rawTarget.slice(0, questionIdx) : rawTarget;
23097
+ path9 = questionIdx >= 0 ? rawTarget.slice(0, questionIdx) : rawTarget;
23095
23098
  queryString = questionIdx >= 0 ? rawTarget.slice(questionIdx + 1) : "";
23096
23099
  try {
23097
23100
  for (const [key, value] of new URLSearchParams(queryString)) {
@@ -23104,7 +23107,7 @@ function createRequest(req2) {
23104
23107
  }
23105
23108
  tReq.params = {};
23106
23109
  w.query = query;
23107
- w.path = path10;
23110
+ w.path = path9;
23108
23111
  w.queryString = queryString;
23109
23112
  w.url = fullUrl;
23110
23113
  tReq.body = void 0;
@@ -23219,14 +23222,14 @@ function extractBoundary(contentType) {
23219
23222
  function parseMultipart(body, boundary) {
23220
23223
  const pairs = [];
23221
23224
  const files = {};
23222
- const delimiter4 = Buffer.from(`--${boundary}`);
23225
+ const delimiter5 = Buffer.from(`--${boundary}`);
23223
23226
  const closeDelimiter = Buffer.from(`--${boundary}--`);
23224
23227
  const crlf = Buffer.from("\r\n");
23225
23228
  const doubleCrlf = Buffer.from("\r\n\r\n");
23226
23229
  let offset = 0;
23227
- const firstIdx = bufferIndexOf(body, delimiter4, offset);
23230
+ const firstIdx = bufferIndexOf(body, delimiter5, offset);
23228
23231
  if (firstIdx === -1) return { fields: {}, files };
23229
- offset = firstIdx + delimiter4.length;
23232
+ offset = firstIdx + delimiter5.length;
23230
23233
  if (body[offset] === 13 && body[offset + 1] === 10) {
23231
23234
  offset += 2;
23232
23235
  }
@@ -23235,7 +23238,7 @@ function parseMultipart(body, boundary) {
23235
23238
  if (headersEnd === -1) break;
23236
23239
  const headersStr = body.subarray(offset, headersEnd).toString("utf-8");
23237
23240
  offset = headersEnd + doubleCrlf.length;
23238
- const nextDelimIdx = bufferIndexOf(body, delimiter4, offset);
23241
+ const nextDelimIdx = bufferIndexOf(body, delimiter5, offset);
23239
23242
  if (nextDelimIdx === -1) break;
23240
23243
  const contentEnd = nextDelimIdx - crlf.length;
23241
23244
  const content = body.subarray(offset, contentEnd);
@@ -23259,7 +23262,7 @@ function parseMultipart(body, boundary) {
23259
23262
  } else if (disposition.name) {
23260
23263
  pairs.push([disposition.name, content.toString("utf-8")]);
23261
23264
  }
23262
- offset = nextDelimIdx + delimiter4.length;
23265
+ offset = nextDelimIdx + delimiter5.length;
23263
23266
  if (body[offset] === 45 && body[offset + 1] === 45) {
23264
23267
  break;
23265
23268
  }
@@ -23819,6 +23822,7 @@ __export(routeDiscovery_exports, {
23819
23822
  });
23820
23823
  import { readdirSync as readdirSync5, statSync as statSync7, mkdirSync as mkdirSync9, writeFileSync as writeFileSync6, existsSync as existsSync10 } from "node:fs";
23821
23824
  import { join as join13, relative, basename as basename3, extname as extname2 } from "node:path";
23825
+ import { pathToFileURL as pathToFileURL3 } from "node:url";
23822
23826
  function boolExport(value) {
23823
23827
  return typeof value === "boolean" ? value : void 0;
23824
23828
  }
@@ -23840,7 +23844,7 @@ async function discoverRoutes(routesDir) {
23840
23844
  const relativePath2 = relative(routesDir, filePath);
23841
23845
  const pattern = filePathToPattern(relativePath2);
23842
23846
  try {
23843
- const moduleUrl = `file://${filePath}?t=${currentMtime}`;
23847
+ const moduleUrl = `${pathToFileURL3(filePath).href}?t=${currentMtime}`;
23844
23848
  const mod = await import(moduleUrl);
23845
23849
  const handler = mod.default ?? mod.handler;
23846
23850
  if (typeof handler !== "function") {
@@ -23881,7 +23885,7 @@ function recordBrokenImport(filePath, error2) {
23881
23885
  try {
23882
23886
  const brokenDir = join13(process.cwd(), "data", ".broken");
23883
23887
  if (!existsSync10(brokenDir)) mkdirSync9(brokenDir, { recursive: true });
23884
- const slug = filePath.replace(/[/\\]/g, "_");
23888
+ const slug = filePath.replace(/[/\\:]/g, "_");
23885
23889
  const payload = JSON.stringify({
23886
23890
  type: "auto_discover_failure",
23887
23891
  file: filePath,
@@ -23948,6 +23952,7 @@ __export(portTakeover_exports, {
23948
23952
  isDev: () => isDev,
23949
23953
  noTakeoverOptedOut: () => noTakeoverOptedOut,
23950
23954
  pidfilePath: () => pidfilePath,
23955
+ probeBind: () => probeBind,
23951
23956
  readPidfile: () => readPidfile,
23952
23957
  removePidfile: () => removePidfile,
23953
23958
  runtimeDir: () => runtimeDir,
@@ -24041,17 +24046,17 @@ function sleepSync(ms) {
24041
24046
  if (ms <= 0) return;
24042
24047
  Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
24043
24048
  }
24044
- function bindable(host, port) {
24049
+ function probeBind(host, port, timeout = 5e3) {
24045
24050
  try {
24046
- execFileSync(process.execPath, ["-e", BIND_PROBE, host, String(port)], { stdio: "ignore", timeout: 5e3 });
24047
- return true;
24048
- } catch {
24049
- return false;
24051
+ execFileSync(process.execPath, ["-e", BIND_PROBE, host, String(port)], { stdio: "ignore", timeout });
24052
+ return "free";
24053
+ } catch (err) {
24054
+ return err.status === PROBE_HELD ? "held" : "unknown";
24050
24055
  }
24051
24056
  }
24052
24057
  function refusal(port, dev, noTakeover, host) {
24053
24058
  if (dev && !noTakeover) return null;
24054
- if (host !== void 0 && bindable(host, port)) {
24059
+ if (host !== void 0 && probeBind(host, port) !== "held") {
24055
24060
  return { status: TAKEOVER_NOTHING, port, killed: [], message: "" };
24056
24061
  }
24057
24062
  if (noTakeover) {
@@ -24099,7 +24104,7 @@ function takeOverPort(port, dev, noTakeover, baseDir, grace = 500, host) {
24099
24104
  `Reclaimed port ${port} from Tina4 dev server (PID: ${killed.join(", ")}).`
24100
24105
  );
24101
24106
  }
24102
- var TAKEOVER_NOTHING, TAKEOVER_KILLED, TAKEOVER_REFUSED_FOREIGN, TAKEOVER_REFUSED_OPTOUT, TAKEOVER_REFUSED_PROD, TAKEOVER_SKIPPED_CONTAINER, TAKEOVER_REFUSALS, BIND_PROBE;
24107
+ 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;
24103
24108
  var init_portTakeover = __esm({
24104
24109
  "../core/src/portTakeover.ts"() {
24105
24110
  "use strict";
@@ -24114,7 +24119,9 @@ var init_portTakeover = __esm({
24114
24119
  TAKEOVER_REFUSED_OPTOUT,
24115
24120
  TAKEOVER_REFUSED_PROD
24116
24121
  ];
24117
- 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)));';
24122
+ PROBE_HELD = 3;
24123
+ PROBE_OTHER = 4;
24124
+ 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)));`;
24118
24125
  }
24119
24126
  });
24120
24127
 
@@ -25292,6 +25299,21 @@ var init_databaseHandler = __esm({
25292
25299
  }
25293
25300
  return this.sqliteHandle;
25294
25301
  }
25302
+ /**
25303
+ * Release the SQLite connection this handler opened, so its file (and the
25304
+ * WAL's -wal / -shm side files) is no longer held open: on Windows an open
25305
+ * file cannot be deleted or replaced. Idempotent, and the next read or write
25306
+ * reopens the connection. A server engine needs nothing here - each call goes
25307
+ * through the sync bridge, which holds no connection between calls.
25308
+ */
25309
+ close() {
25310
+ if (this.sqliteHandle === null) return;
25311
+ try {
25312
+ this.sqliteHandle.close();
25313
+ } finally {
25314
+ this.sqliteHandle = null;
25315
+ }
25316
+ }
25295
25317
  get engine() {
25296
25318
  return this.target === null ? "sqlite" : this.target.engine;
25297
25319
  }
@@ -26492,8 +26514,8 @@ function tryServeStatic(staticDir, req2, res) {
26492
26514
  }
26493
26515
  return false;
26494
26516
  }
26495
- function hasHiddenSegment(path10, separator = "/") {
26496
- return path10.split(separator).some((segment) => segment.length > 0 && segment.startsWith("."));
26517
+ function hasHiddenSegment(path9, separator = "/") {
26518
+ return path9.split(separator).some((segment) => segment.length > 0 && segment.startsWith("."));
26497
26519
  }
26498
26520
  function conditionalHeader(req2, name) {
26499
26521
  const headers = req2.headers;
@@ -26817,10 +26839,10 @@ function createHealthRoute(version = "3.0.0") {
26817
26839
  function createHealthRoutes(version = "3.0.0") {
26818
26840
  startTime = Date.now();
26819
26841
  const routes = [];
26820
- const path10 = healthPath();
26842
+ const path9 = healthPath();
26821
26843
  routes.push({
26822
26844
  method: "GET",
26823
- pattern: path10,
26845
+ pattern: path9,
26824
26846
  handler: buildHandler(version),
26825
26847
  meta: {
26826
26848
  summary: "Health check",
@@ -26828,7 +26850,7 @@ function createHealthRoutes(version = "3.0.0") {
26828
26850
  tags: ["System"]
26829
26851
  }
26830
26852
  });
26831
- if (path10 !== "/health") {
26853
+ if (path9 !== "/health") {
26832
26854
  routes.push({
26833
26855
  method: "GET",
26834
26856
  pattern: "/health",
@@ -26906,9 +26928,72 @@ var init_rateLimiter = __esm({
26906
26928
  }
26907
26929
  });
26908
26930
 
26931
+ // ../core/src/batchSpawn.ts
26932
+ import { spawnSync } from "node:child_process";
26933
+ import { existsSync as existsSync13, statSync as statSync10 } from "node:fs";
26934
+ import { delimiter, extname as extname4, join as join17 } from "node:path";
26935
+ function isBatchFile(file, platform = process.platform) {
26936
+ return platform === "win32" && /\.(cmd|bat)$/i.test(file);
26937
+ }
26938
+ function escapeBatchArgument(arg) {
26939
+ let quoted = String(arg).replace(/(\\*)"/g, '$1$1\\"').replace(/(\\*)$/, "$1$1");
26940
+ quoted = `"${quoted}"`;
26941
+ return quoted.replace(CMD_META, "^$1").replace(CMD_META, "^$1");
26942
+ }
26943
+ function escapeBatchCommand(file) {
26944
+ return file.replace(CMD_META, "^$1");
26945
+ }
26946
+ function findExecutable(name, platform = process.platform) {
26947
+ if (platform !== "win32" || /[\\/]/.test(name) || extname4(name) !== "") return name;
26948
+ const exts = (process.env.PATHEXT || ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean);
26949
+ const dirs = (process.env.PATH || "").split(delimiter).filter(Boolean);
26950
+ const candidates = dirs.flatMap((dir) => exts.map((ext) => join17(dir, name + ext.toLowerCase())));
26951
+ return candidates.find(isRegularFile) ?? name;
26952
+ }
26953
+ function isRegularFile(path9) {
26954
+ try {
26955
+ return existsSync13(path9) && statSync10(path9).isFile();
26956
+ } catch {
26957
+ return false;
26958
+ }
26959
+ }
26960
+ function spawnSyncAllowingBatch(file, args, options = {}) {
26961
+ if (!isBatchFile(file)) return spawnSync(file, args, options);
26962
+ const line = [escapeBatchCommand(file), ...args.map(escapeBatchArgument)].join(" ");
26963
+ const shell = process.env.comspec || "cmd.exe";
26964
+ return spawnSync(shell, ["/d", "/s", "/c", `"${line}"`], {
26965
+ ...options,
26966
+ windowsVerbatimArguments: true
26967
+ });
26968
+ }
26969
+ function execFileSyncAllowingBatch(name, args, options = {}) {
26970
+ const result = spawnSyncAllowingBatch(findExecutable(name), args, { encoding: "utf-8", ...options });
26971
+ if (result.error) throw result.error;
26972
+ const stdout = String(result.stdout ?? "");
26973
+ const stderr = String(result.stderr ?? "");
26974
+ if (result.status !== 0) {
26975
+ const err = new Error(
26976
+ `Command failed: ${name} ${args.join(" ")} (exit ${result.status ?? result.signal})
26977
+ ${stderr}`.trim()
26978
+ );
26979
+ err.status = result.status;
26980
+ err.stdout = stdout;
26981
+ err.stderr = stderr;
26982
+ throw err;
26983
+ }
26984
+ return stdout;
26985
+ }
26986
+ var CMD_META;
26987
+ var init_batchSpawn = __esm({
26988
+ "../core/src/batchSpawn.ts"() {
26989
+ "use strict";
26990
+ CMD_META = /([()\][%!^"`<>&|;, *?])/g;
26991
+ }
26992
+ });
26993
+
26909
26994
  // ../core/src/devMailbox.ts
26910
- import { mkdirSync as mkdirSync12, readdirSync as readdirSync7, readFileSync as readFileSync11, writeFileSync as writeFileSync9, unlinkSync as unlinkSync7, existsSync as existsSync13 } from "node:fs";
26911
- import { join as join17 } from "node:path";
26995
+ import { mkdirSync as mkdirSync12, readdirSync as readdirSync7, readFileSync as readFileSync11, writeFileSync as writeFileSync9, unlinkSync as unlinkSync7, existsSync as existsSync14 } from "node:fs";
26996
+ import { join as join18 } from "node:path";
26912
26997
  import { randomUUID as randomUUID2 } from "node:crypto";
26913
26998
  var DevMailbox;
26914
26999
  var init_devMailbox = __esm({
@@ -26923,7 +27008,7 @@ var init_devMailbox = __esm({
26923
27008
  * Ensure a folder directory exists.
26924
27009
  */
26925
27010
  ensureFolder(folder) {
26926
- const dir = join17(this.mailboxDir, folder);
27011
+ const dir = join18(this.mailboxDir, folder);
26927
27012
  mkdirSync12(dir, { recursive: true });
26928
27013
  return dir;
26929
27014
  }
@@ -26962,10 +27047,10 @@ var init_devMailbox = __esm({
26962
27047
  read: false
26963
27048
  };
26964
27049
  const outboxDir = this.ensureFolder("outbox");
26965
- writeFileSync9(join17(outboxDir, `${id}.json`), JSON.stringify(message, null, 2));
27050
+ writeFileSync9(join18(outboxDir, `${id}.json`), JSON.stringify(message, null, 2));
26966
27051
  const inboxDir = this.ensureFolder("inbox");
26967
27052
  const inboxMessage = { ...message, type: "inbox" };
26968
- writeFileSync9(join17(inboxDir, `${id}.json`), JSON.stringify(inboxMessage, null, 2));
27053
+ writeFileSync9(join18(inboxDir, `${id}.json`), JSON.stringify(inboxMessage, null, 2));
26969
27054
  return { success: true, message: "Email captured to dev mailbox", id };
26970
27055
  }
26971
27056
  /**
@@ -26983,7 +27068,7 @@ var init_devMailbox = __esm({
26983
27068
  const sliced = files.slice(offset, offset + limit);
26984
27069
  for (const file of sliced) {
26985
27070
  try {
26986
- const msg = JSON.parse(readFileSync11(join17(dir, file), "utf-8"));
27071
+ const msg = JSON.parse(readFileSync11(join18(dir, file), "utf-8"));
26987
27072
  results.push(msg);
26988
27073
  } catch {
26989
27074
  }
@@ -26996,8 +27081,8 @@ var init_devMailbox = __esm({
26996
27081
  read(msgId) {
26997
27082
  const folders = ["inbox", "outbox"];
26998
27083
  for (const folder of folders) {
26999
- const filePath = join17(this.mailboxDir, folder, `${msgId}.json`);
27000
- if (existsSync13(filePath)) {
27084
+ const filePath = join18(this.mailboxDir, folder, `${msgId}.json`);
27085
+ if (existsSync14(filePath)) {
27001
27086
  try {
27002
27087
  const msg = JSON.parse(readFileSync11(filePath, "utf-8"));
27003
27088
  msg.read = true;
@@ -27020,7 +27105,7 @@ var init_devMailbox = __esm({
27020
27105
  const files = readdirSync7(dir).filter((f) => f.endsWith(".json"));
27021
27106
  for (const file of files) {
27022
27107
  try {
27023
- const msg = JSON.parse(readFileSync11(join17(dir, file), "utf-8"));
27108
+ const msg = JSON.parse(readFileSync11(join18(dir, file), "utf-8"));
27024
27109
  if (!msg.read) count++;
27025
27110
  } catch {
27026
27111
  }
@@ -27036,8 +27121,8 @@ var init_devMailbox = __esm({
27036
27121
  let deleted = false;
27037
27122
  const folders = ["inbox", "outbox"];
27038
27123
  for (const folder of folders) {
27039
- const filePath = join17(this.mailboxDir, folder, `${msgId}.json`);
27040
- if (existsSync13(filePath)) {
27124
+ const filePath = join18(this.mailboxDir, folder, `${msgId}.json`);
27125
+ if (existsSync14(filePath)) {
27041
27126
  try {
27042
27127
  unlinkSync7(filePath);
27043
27128
  deleted = true;
@@ -27053,12 +27138,12 @@ var init_devMailbox = __esm({
27053
27138
  clear(folder) {
27054
27139
  const folders = folder ? [folder] : ["inbox", "outbox"];
27055
27140
  for (const f of folders) {
27056
- const dir = join17(this.mailboxDir, f);
27141
+ const dir = join18(this.mailboxDir, f);
27057
27142
  try {
27058
- if (existsSync13(dir)) {
27143
+ if (existsSync14(dir)) {
27059
27144
  const files = readdirSync7(dir).filter((file) => file.endsWith(".json"));
27060
27145
  for (const file of files) {
27061
- unlinkSync7(join17(dir, file));
27146
+ unlinkSync7(join18(dir, file));
27062
27147
  }
27063
27148
  }
27064
27149
  } catch {
@@ -27111,7 +27196,7 @@ Generated by DevMailbox.seed() for development purposes.`,
27111
27196
  // first two are unread
27112
27197
  };
27113
27198
  const dir = this.ensureFolder("inbox");
27114
- writeFileSync9(join17(dir, `${id}.json`), JSON.stringify(message, null, 2));
27199
+ writeFileSync9(join18(dir, `${id}.json`), JSON.stringify(message, null, 2));
27115
27200
  }
27116
27201
  }
27117
27202
  /**
@@ -27119,9 +27204,9 @@ Generated by DevMailbox.seed() for development purposes.`,
27119
27204
  */
27120
27205
  count(folder) {
27121
27206
  const countDir = (f) => {
27122
- const dir = join17(this.mailboxDir, f);
27207
+ const dir = join18(this.mailboxDir, f);
27123
27208
  try {
27124
- if (existsSync13(dir)) {
27209
+ if (existsSync14(dir)) {
27125
27210
  return readdirSync7(dir).filter((file) => file.endsWith(".json")).length;
27126
27211
  }
27127
27212
  } catch {
@@ -27162,8 +27247,8 @@ var init_upstreamResponse = __esm({
27162
27247
  // ../core/src/metrics.ts
27163
27248
  import * as fs3 from "node:fs";
27164
27249
  import * as path2 from "node:path";
27165
- import { spawnSync } from "node:child_process";
27166
- import { fileURLToPath as fileURLToPath3 } from "node:url";
27250
+ import { spawnSync as spawnSync2 } from "node:child_process";
27251
+ import { fileURLToPath as fileURLToPath4 } from "node:url";
27167
27252
  function containsTypeScript(directory) {
27168
27253
  if (!fs3.existsSync(directory) || !fs3.statSync(directory).isDirectory()) return false;
27169
27254
  for (const entry of fs3.readdirSync(directory, { withFileTypes: true })) {
@@ -27174,7 +27259,7 @@ function containsTypeScript(directory) {
27174
27259
  return false;
27175
27260
  }
27176
27261
  function resolveTarget(root = "src") {
27177
- const resolved = containsTypeScript(root) ? path2.resolve(root) : path2.dirname(fileURLToPath3(import.meta.url));
27262
+ const resolved = containsTypeScript(root) ? path2.resolve(root) : path2.dirname(fileURLToPath4(import.meta.url));
27178
27263
  const mode = containsTypeScript(root) ? "project" : "framework";
27179
27264
  lastScanRoot = resolved;
27180
27265
  return [resolved, mode];
@@ -27202,7 +27287,7 @@ function enginePath() {
27202
27287
  function runEngine(target) {
27203
27288
  const binary = enginePath();
27204
27289
  if (!binary) throw new MetricsEngineError(`tina4 not found on PATH - ${INSTALL_HINT}`);
27205
- const processResult = spawnSync(binary, ["metrics", "--path", target, "--json", "--no-history"], {
27290
+ const processResult = spawnSync2(binary, ["metrics", "--path", target, "--json", "--no-history"], {
27206
27291
  encoding: "utf8",
27207
27292
  timeout: 6e4,
27208
27293
  maxBuffer: 64 * 1024 * 1024
@@ -27295,9 +27380,9 @@ var init_metrics = __esm({
27295
27380
  });
27296
27381
 
27297
27382
  // ../core/src/feedback.ts
27298
- import { readFileSync as readFileSync12, existsSync as existsSync15 } from "node:fs";
27299
- import { dirname as dirname9, join as join19, resolve as resolve10 } from "node:path";
27300
- import { fileURLToPath as fileURLToPath4 } from "node:url";
27383
+ import { readFileSync as readFileSync12, existsSync as existsSync16 } from "node:fs";
27384
+ import { dirname as dirname9, join as join20, resolve as resolve10 } from "node:path";
27385
+ import { fileURLToPath as fileURLToPath5 } from "node:url";
27301
27386
  function feedbackEnabled() {
27302
27387
  const raw = (process.env.TINA4_ENABLE_FEEDBACK ?? "").trim().toLowerCase();
27303
27388
  return raw === "1" || raw === "true" || raw === "yes" || raw === "on";
@@ -27346,8 +27431,8 @@ function feedbackRateLimitOk(user) {
27346
27431
  }
27347
27432
  function injectFeedbackWidget(request, html) {
27348
27433
  if (!html) return html;
27349
- const path10 = (request.path ?? "") || "";
27350
- if (path10.startsWith("/__dev") || path10.startsWith("/__feedback")) return html;
27434
+ const path9 = (request.path ?? "") || "";
27435
+ if (path9.startsWith("/__dev") || path9.startsWith("/__feedback")) return html;
27351
27436
  if (html.includes("data-tina4-feedback")) return html;
27352
27437
  const [allowed] = feedbackIsWhitelisted(request);
27353
27438
  if (!allowed) return html;
@@ -27423,11 +27508,11 @@ var init_feedback = __esm({
27423
27508
  clearTimeout(timer);
27424
27509
  await relayUpstreamResponse(res, upstream);
27425
27510
  };
27426
- __feedbackDirname = dirname9(fileURLToPath4(import.meta.url));
27511
+ __feedbackDirname = dirname9(fileURLToPath5(import.meta.url));
27427
27512
  WIDGET_BUNDLE_PATH = resolve10(__feedbackDirname, "__feedback", "widget.js");
27428
27513
  handleFeedbackWidgetJs = (_req, res) => {
27429
27514
  let body;
27430
- if (existsSync15(WIDGET_BUNDLE_PATH)) {
27515
+ if (existsSync16(WIDGET_BUNDLE_PATH)) {
27431
27516
  body = readFileSync12(WIDGET_BUNDLE_PATH);
27432
27517
  } else {
27433
27518
  body = "console.warn('tina4-feedback-widget bundle not built yet');";
@@ -27443,14 +27528,14 @@ var init_feedback = __esm({
27443
27528
  });
27444
27529
 
27445
27530
  // ../core/src/version.ts
27446
- import { existsSync as existsSync16, readFileSync as readFileSync13 } from "node:fs";
27447
- import { dirname as dirname10, join as join20 } from "node:path";
27448
- import { fileURLToPath as fileURLToPath5 } from "node:url";
27531
+ import { existsSync as existsSync17, readFileSync as readFileSync13 } from "node:fs";
27532
+ import { dirname as dirname10, join as join21 } from "node:path";
27533
+ import { fileURLToPath as fileURLToPath6 } from "node:url";
27449
27534
  function resolveFrameworkVersion() {
27450
- let dir = dirname10(fileURLToPath5(import.meta.url));
27535
+ let dir = dirname10(fileURLToPath6(import.meta.url));
27451
27536
  for (let i = 0; i < 6; i++) {
27452
- const pkgPath = join20(dir, "package.json");
27453
- if (existsSync16(pkgPath)) {
27537
+ const pkgPath = join21(dir, "package.json");
27538
+ if (existsSync17(pkgPath)) {
27454
27539
  try {
27455
27540
  const pkg = JSON.parse(readFileSync13(pkgPath, "utf-8"));
27456
27541
  if (typeof pkg.version === "string" && pkg.version) return pkg.version;
@@ -27472,8 +27557,8 @@ var init_version = __esm({
27472
27557
  });
27473
27558
 
27474
27559
  // src/util.ts
27475
- import { delimiter as delimiter2, join as join21 } from "node:path";
27476
- import { statSync as statSync11 } from "node:fs";
27560
+ import { delimiter as delimiter3, join as join22 } from "node:path";
27561
+ import { statSync as statSync12 } from "node:fs";
27477
27562
  function parseFlags(args, booleanFlags) {
27478
27563
  const flags = {};
27479
27564
  const positional = [];
@@ -27505,12 +27590,12 @@ function readFlag(args, i, flags, booleanFlags) {
27505
27590
  return 1;
27506
27591
  }
27507
27592
  function findOnPath(names) {
27508
- for (const dir of (process.env.PATH ?? "").split(delimiter2)) {
27593
+ for (const dir of (process.env.PATH ?? "").split(delimiter3)) {
27509
27594
  if (!dir) continue;
27510
27595
  for (const name of names) {
27511
- const candidate = join21(dir, name);
27596
+ const candidate = join22(dir, name);
27512
27597
  try {
27513
- if (statSync11(candidate).isFile()) return candidate;
27598
+ if (statSync12(candidate).isFile()) return candidate;
27514
27599
  } catch {
27515
27600
  }
27516
27601
  }
@@ -27555,27 +27640,27 @@ __export(generate_exports, {
27555
27640
  toSnake: () => toSnake,
27556
27641
  toTableName: () => toTableName
27557
27642
  });
27558
- import { existsSync as existsSync17, mkdirSync as mkdirSync13, writeFileSync as writeFileSync10, readdirSync as readdirSync9, copyFileSync as copyFileSync2 } from "node:fs";
27559
- import { join as join22, relative as relative2, resolve as resolve11, sep as sep5, dirname as dirname11 } from "node:path";
27560
- import { fileURLToPath as fileURLToPath6 } from "node:url";
27643
+ import { existsSync as existsSync18, mkdirSync as mkdirSync13, writeFileSync as writeFileSync10, readdirSync as readdirSync9, copyFileSync as copyFileSync2 } from "node:fs";
27644
+ import { join as join23, relative as relative2, resolve as resolve11, sep as sep5, dirname as dirname11 } from "node:path";
27645
+ import { fileURLToPath as fileURLToPath7 } from "node:url";
27561
27646
  function ensureDir(dir) {
27562
27647
  if (__resolution.dryRun) return;
27563
- if (!existsSync17(dir)) {
27648
+ if (!existsSync18(dir)) {
27564
27649
  mkdirSync13(dir, { recursive: true });
27565
27650
  }
27566
27651
  }
27567
- function writeFileSafe(path10, content) {
27568
- captureEditHints(path10, content);
27652
+ function writeFileSafe(path9, content) {
27653
+ captureEditHints(path9, content);
27569
27654
  if (__resolution.dryRun) {
27570
27655
  return;
27571
27656
  }
27572
- if (existsSync17(path10)) {
27573
- if (!__resolution.jsonMode) console.log(` File already exists: ${path10}`);
27657
+ if (existsSync18(path9)) {
27658
+ if (!__resolution.jsonMode) console.log(` File already exists: ${path9}`);
27574
27659
  return;
27575
27660
  }
27576
- writeFileSync10(path10, content, "utf-8");
27577
- __resolution.actionsTaken.push(`wrote ${path10}`);
27578
- if (!__resolution.jsonMode) console.log(` Created ${path10}`);
27661
+ writeFileSync10(path9, content, "utf-8");
27662
+ __resolution.actionsTaken.push(`wrote ${path9}`);
27663
+ if (!__resolution.jsonMode) console.log(` Created ${path9}`);
27579
27664
  }
27580
27665
  function toSnake(name) {
27581
27666
  return name.replace(/([A-Z]+)([A-Z][a-z])/g, "$1_$2").replace(/([a-z0-9])([A-Z])/g, "$1_$2").toLowerCase();
@@ -27667,9 +27752,9 @@ function pushRoute(routePattern) {
27667
27752
  if (!__resolution.body.routes) __resolution.body.routes = [];
27668
27753
  __resolution.body.routes.push(routePattern);
27669
27754
  }
27670
- function pushTestPath(path10) {
27755
+ function pushTestPath(path9) {
27671
27756
  if (!__resolution.body.test_paths) __resolution.body.test_paths = [];
27672
- __resolution.body.test_paths.push(path10);
27757
+ __resolution.body.test_paths.push(path9);
27673
27758
  }
27674
27759
  function pushEditHint(hint) {
27675
27760
  if (!__resolution.body.edit_hints) __resolution.body.edit_hints = [];
@@ -27900,7 +27985,7 @@ function generateModel(name, flags, emitTest = true) {
27900
27985
  const table2 = resolveTable(name, flags, { announce: true });
27901
27986
  const dir = resolve11("src/models");
27902
27987
  ensureDir(dir);
27903
- const path10 = join22(dir, `${name}.ts`);
27988
+ const path9 = join23(dir, `${name}.ts`);
27904
27989
  setResolutionField("class_name", name);
27905
27990
  setResolutionField("table_name", table2);
27906
27991
  setResolutionField("file_path", `src/models/${name}.ts`);
@@ -27923,7 +28008,7 @@ ${fieldLines.join("\n")}
27923
28008
  };
27924
28009
  }
27925
28010
  `;
27926
- writeFileSafe(path10, content);
28011
+ writeFileSafe(path9, content);
27927
28012
  if (!flags["no-migration"]) {
27928
28013
  generateMigration(`create_${table2}`, flags, fields, table2, false);
27929
28014
  }
@@ -27940,7 +28025,7 @@ function generateRoute(name, flags, emitTest = true) {
27940
28025
  const model = flags.model;
27941
28026
  const isPublic = Boolean(flags.public);
27942
28027
  const base = resolve11("src/routes/api", routePath);
27943
- const idDir = join22(base, "[id]");
28028
+ const idDir = join23(base, "[id]");
27944
28029
  ensureDir(base);
27945
28030
  ensureDir(idDir);
27946
28031
  pushRoute(`/api/${routePath}`);
@@ -27956,7 +28041,7 @@ function generateRoute(name, flags, emitTest = true) {
27956
28041
  const writeDoc = isPublic ? "Public (--public): no token required." : "Secure by default: requires a Bearer token (use --public to open).";
27957
28042
  if (model) {
27958
28043
  writeFileSafe(
27959
- join22(base, "get.ts"),
28044
+ join23(base, "get.ts"),
27960
28045
  `import type { Tina4Request, Tina4Response } from "tina4-nodejs";
27961
28046
  ${modelImportBase}
27962
28047
  export const meta = { summary: "List all ${routePath}", tags: ["${routePath}"] };
@@ -27973,7 +28058,7 @@ export default async function (req: Tina4Request, res: Tina4Response) {
27973
28058
  );
27974
28059
  } else {
27975
28060
  writeFileSafe(
27976
- join22(base, "get.ts"),
28061
+ join23(base, "get.ts"),
27977
28062
  `import type { Tina4Request, Tina4Response } from "tina4-nodejs";
27978
28063
 
27979
28064
  export const meta = { summary: "List all ${routePath}", tags: ["${routePath}"] };
@@ -27992,7 +28077,7 @@ ${aiFill(`list_${routePath}`, {
27992
28077
  }
27993
28078
  if (model) {
27994
28079
  writeFileSafe(
27995
- join22(base, "post.ts"),
28080
+ join23(base, "post.ts"),
27996
28081
  `import type { Tina4Request, Tina4Response } from "tina4-nodejs";
27997
28082
  ${modelImportBase}${secureOptOut(isPublic)}export const meta = { summary: "Create a new ${singular}", tags: ["${routePath}"] };
27998
28083
 
@@ -28015,7 +28100,7 @@ ${extend(
28015
28100
  );
28016
28101
  } else {
28017
28102
  writeFileSafe(
28018
- join22(base, "post.ts"),
28103
+ join23(base, "post.ts"),
28019
28104
  `import type { Tina4Request, Tina4Response } from "tina4-nodejs";
28020
28105
 
28021
28106
  ${secureOptOut(isPublic)}export const meta = { summary: "Create a new ${singular}", tags: ["${routePath}"] };
@@ -28036,7 +28121,7 @@ ${aiFill(`create_${singular}`, {
28036
28121
  }
28037
28122
  if (model) {
28038
28123
  writeFileSafe(
28039
- join22(idDir, "get.ts"),
28124
+ join23(idDir, "get.ts"),
28040
28125
  `import type { Tina4Request, Tina4Response } from "tina4-nodejs";
28041
28126
  ${modelImportId}
28042
28127
  export const meta = { summary: "Get a ${singular} by ID", tags: ["${routePath}"] };
@@ -28054,7 +28139,7 @@ export default async function (req: Tina4Request, res: Tina4Response) {
28054
28139
  );
28055
28140
  } else {
28056
28141
  writeFileSafe(
28057
- join22(idDir, "get.ts"),
28142
+ join23(idDir, "get.ts"),
28058
28143
  `import type { Tina4Request, Tina4Response } from "tina4-nodejs";
28059
28144
 
28060
28145
  export const meta = { summary: "Get a ${singular} by ID", tags: ["${routePath}"] };
@@ -28073,7 +28158,7 @@ ${aiFill(`get_${singular}`, {
28073
28158
  }
28074
28159
  if (model) {
28075
28160
  writeFileSafe(
28076
- join22(idDir, "put.ts"),
28161
+ join23(idDir, "put.ts"),
28077
28162
  `import type { Tina4Request, Tina4Response } from "tina4-nodejs";
28078
28163
  ${modelImportId}${secureOptOut(isPublic)}export const meta = { summary: "Update a ${singular} by ID", tags: ["${routePath}"] };
28079
28164
 
@@ -28102,7 +28187,7 @@ ${extend(
28102
28187
  );
28103
28188
  } else {
28104
28189
  writeFileSafe(
28105
- join22(idDir, "put.ts"),
28190
+ join23(idDir, "put.ts"),
28106
28191
  `import type { Tina4Request, Tina4Response } from "tina4-nodejs";
28107
28192
 
28108
28193
  ${secureOptOut(isPublic)}export const meta = { summary: "Update a ${singular} by ID", tags: ["${routePath}"] };
@@ -28123,7 +28208,7 @@ ${aiFill(`update_${singular}`, {
28123
28208
  }
28124
28209
  if (model) {
28125
28210
  writeFileSafe(
28126
- join22(idDir, "delete.ts"),
28211
+ join23(idDir, "delete.ts"),
28127
28212
  `import type { Tina4Request, Tina4Response } from "tina4-nodejs";
28128
28213
  ${modelImportId}${secureOptOut(isPublic)}export const meta = { summary: "Delete a ${singular} by ID", tags: ["${routePath}"] };
28129
28214
 
@@ -28142,7 +28227,7 @@ export default async function (req: Tina4Request, res: Tina4Response) {
28142
28227
  );
28143
28228
  } else {
28144
28229
  writeFileSafe(
28145
- join22(idDir, "delete.ts"),
28230
+ join23(idDir, "delete.ts"),
28146
28231
  `import type { Tina4Request, Tina4Response } from "tina4-nodejs";
28147
28232
 
28148
28233
  ${secureOptOut(isPublic)}export const meta = { summary: "Delete a ${singular} by ID", tags: ["${routePath}"] };
@@ -28219,10 +28304,10 @@ export default async function (req: Tina4Request, res: Tina4Response) {
28219
28304
  return res.html(await Crud.toCrud(req, { model: ${model}, title: "${model} Admin"${publicOpt} }));
28220
28305
  }
28221
28306
  `;
28222
- writeFileSafe(join22(dir, "get.ts"), content);
28307
+ writeFileSafe(join23(dir, "get.ts"), content);
28223
28308
  }
28224
28309
  function frameworkCrudTemplatesDir() {
28225
- const here = dirname11(fileURLToPath6(import.meta.url));
28310
+ const here = dirname11(fileURLToPath7(import.meta.url));
28226
28311
  const candidates = [
28227
28312
  resolve11(here, "../../../core/templates/crud"),
28228
28313
  // monorepo: packages/cli/src/commands -> packages/core/templates/crud
@@ -28231,7 +28316,7 @@ function frameworkCrudTemplatesDir() {
28231
28316
  resolve11(here, "../templates/crud")
28232
28317
  // flattened publish fallback
28233
28318
  ];
28234
- return candidates.find((c) => existsSync17(c)) ?? null;
28319
+ return candidates.find((c) => existsSync18(c)) ?? null;
28235
28320
  }
28236
28321
  function copyCrudTemplates() {
28237
28322
  const sourceDir = frameworkCrudTemplatesDir();
@@ -28242,13 +28327,13 @@ function copyCrudTemplates() {
28242
28327
  const targetDir = resolve11("src/templates/crud");
28243
28328
  ensureDir(targetDir);
28244
28329
  for (const file of readdirSync9(sourceDir).filter((f) => f.endsWith(".twig")).sort()) {
28245
- const dest = join22(targetDir, file);
28246
- if (existsSync17(dest)) {
28330
+ const dest = join23(targetDir, file);
28331
+ if (existsSync18(dest)) {
28247
28332
  if (!__resolution.jsonMode) console.log(` File already exists: ${dest}`);
28248
28333
  continue;
28249
28334
  }
28250
28335
  if (__resolution.dryRun) continue;
28251
- copyFileSync2(join22(sourceDir, file), dest);
28336
+ copyFileSync2(join23(sourceDir, file), dest);
28252
28337
  __resolution.actionsTaken.push(`wrote ${dest}`);
28253
28338
  if (!__resolution.jsonMode) console.log(` Created ${dest}`);
28254
28339
  }
@@ -28306,7 +28391,7 @@ ${writeCase}
28306
28391
  console.log(\`\\nResults: \${pass} passed, \${fail} failed\`);
28307
28392
  process.exit(fail > 0 ? 1 : 0);
28308
28393
  `;
28309
- writeFileSafe(join22(dir, `${table2}.test.ts`), content);
28394
+ writeFileSafe(join23(dir, `${table2}.test.ts`), content);
28310
28395
  }
28311
28396
  function generateMigration(name, flags, fieldsOverride, tableOverride, emitTest = true) {
28312
28397
  const ts = timestamp();
@@ -28326,7 +28411,7 @@ function generateMigration(name, flags, fieldsOverride, tableOverride, emitTest
28326
28411
  const isCreate = name.startsWith("create_") || fieldsOverride !== void 0;
28327
28412
  const isView = isCreate && fieldsOverride === void 0 && table2.endsWith("_view");
28328
28413
  const fileName = `${ts}_${name}.sql`;
28329
- const path10 = join22(dir, fileName);
28414
+ const path9 = join23(dir, fileName);
28330
28415
  setResolutionField("migration_path", `migrations/${fileName}`);
28331
28416
  if (__resolution.target === "migration") {
28332
28417
  setResolutionField("file_path", `migrations/${fileName}`);
@@ -28367,8 +28452,8 @@ DROP TABLE IF EXISTS ${table2};`;
28367
28452
  -- UP
28368
28453
  ${upSql}
28369
28454
  `;
28370
- writeFileSafe(path10, content);
28371
- const downPath = join22(dir, `${ts}_${name}.down.sql`);
28455
+ writeFileSafe(path9, content);
28456
+ const downPath = join23(dir, `${ts}_${name}.down.sql`);
28372
28457
  const downContent = `-- Rollback: ${name}
28373
28458
  -- Created: ${now}
28374
28459
 
@@ -28381,7 +28466,7 @@ function generateMiddleware(name, _flags) {
28381
28466
  const snake = toSnake(name);
28382
28467
  const dir = resolve11("src/middleware");
28383
28468
  ensureDir(dir);
28384
- const path10 = join22(dir, `${snake}.ts`);
28469
+ const path9 = join23(dir, `${snake}.ts`);
28385
28470
  if (__resolution.target === "middleware") {
28386
28471
  setResolutionField("class_name", name);
28387
28472
  setResolutionField("file_path", `src/middleware/${snake}.ts`);
@@ -28419,7 +28504,7 @@ export async function after${name}(
28419
28504
  await next();
28420
28505
  }
28421
28506
  `;
28422
- writeFileSafe(path10, content);
28507
+ writeFileSafe(path9, content);
28423
28508
  emitMiddlewareTest(name, snake);
28424
28509
  }
28425
28510
  function generateTest(name, flags) {
@@ -28428,7 +28513,7 @@ function generateTest(name, flags) {
28428
28513
  const model = flags.model;
28429
28514
  const dir = resolve11("tests");
28430
28515
  ensureDir(dir);
28431
- const path10 = join22(dir, `${snake}.test.ts`);
28516
+ const path9 = join23(dir, `${snake}.test.ts`);
28432
28517
  if (model && flags["secure-writes"]) {
28433
28518
  const isPublic = Boolean(flags.public);
28434
28519
  const posture = isPublic ? "open (--public)" : "gated";
@@ -28477,7 +28562,7 @@ ${writeCase}
28477
28562
  console.log(\`\\nResults: \${pass} passed, \${fail} failed\`);
28478
28563
  process.exit(fail > 0 ? 1 : 0);
28479
28564
  `;
28480
- writeFileSafe(path10, content2);
28565
+ writeFileSafe(path9, content2);
28481
28566
  return;
28482
28567
  }
28483
28568
  let content;
@@ -28543,7 +28628,7 @@ const test${titleName} = tests(
28543
28628
  void test${titleName};
28544
28629
  `;
28545
28630
  }
28546
- writeFileSafe(path10, content);
28631
+ writeFileSafe(path9, content);
28547
28632
  void singular;
28548
28633
  }
28549
28634
  function generateForm2(name, flags) {
@@ -28566,7 +28651,7 @@ function generateForm2(name, flags) {
28566
28651
  };
28567
28652
  const dir = resolve11("src/templates/forms");
28568
28653
  ensureDir(dir);
28569
- const path10 = join22(dir, `${table2}.twig`);
28654
+ const path9 = join23(dir, `${table2}.twig`);
28570
28655
  let fieldHtml = "";
28571
28656
  for (const [fname, ftype] of fields) {
28572
28657
  const itype = inputTypes[ftype] || "text";
@@ -28610,7 +28695,7 @@ function generateForm2(name, flags) {
28610
28695
  </div>
28611
28696
  {% endblock %}
28612
28697
  `;
28613
- writeFileSafe(path10, content);
28698
+ writeFileSafe(path9, content);
28614
28699
  }
28615
28700
  function generateView(name, flags) {
28616
28701
  const fields = fieldsOrDefault(flags.fields || "");
@@ -28619,7 +28704,7 @@ function generateView(name, flags) {
28619
28704
  const cols = fields.map(([f]) => f);
28620
28705
  const dir = resolve11("src/templates/pages");
28621
28706
  ensureDir(dir);
28622
- const listPath = join22(dir, `${routeName}.twig`);
28707
+ const listPath = join23(dir, `${routeName}.twig`);
28623
28708
  const th = cols.map((c) => ` <th>${c.replace(/_/g, " ").replace(/\b\w/g, (ch) => ch.toUpperCase())}</th>`).join("\n");
28624
28709
  const td = cols.map((c) => ` <td>{{ item.${c} }}</td>`).join("\n");
28625
28710
  const listContent = `{% extends "base.twig" %}
@@ -28656,7 +28741,7 @@ ${td}
28656
28741
  {% endblock %}
28657
28742
  `;
28658
28743
  writeFileSafe(listPath, listContent);
28659
- const detailPath = join22(dir, `${table2}.twig`);
28744
+ const detailPath = join23(dir, `${table2}.twig`);
28660
28745
  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");
28661
28746
  const detailContent = `{% extends "base.twig" %}
28662
28747
  {% block title %}${name} Detail{% endblock %}
@@ -28686,7 +28771,7 @@ function generateAuth(_flags) {
28686
28771
  ensureDir(loginDir);
28687
28772
  ensureDir(meDir);
28688
28773
  writeFileSafe(
28689
- join22(registerDir, "post.ts"),
28774
+ join23(registerDir, "post.ts"),
28690
28775
  `import type { Tina4Request, Tina4Response } from "tina4-nodejs";
28691
28776
  import { hashPassword } from "tina4-nodejs";
28692
28777
  import User from "../../../../models/User.js";
@@ -28718,7 +28803,7 @@ export default async function (req: Tina4Request, res: Tina4Response) {
28718
28803
  `
28719
28804
  );
28720
28805
  writeFileSafe(
28721
- join22(loginDir, "post.ts"),
28806
+ join23(loginDir, "post.ts"),
28722
28807
  `import type { Tina4Request, Tina4Response } from "tina4-nodejs";
28723
28808
  import { checkPassword, getToken } from "tina4-nodejs";
28724
28809
  import User from "../../../../models/User.js";
@@ -28751,7 +28836,7 @@ export default async function (req: Tina4Request, res: Tina4Response) {
28751
28836
  `
28752
28837
  );
28753
28838
  writeFileSafe(
28754
- join22(meDir, "get.ts"),
28839
+ join23(meDir, "get.ts"),
28755
28840
  `import type { Tina4Request, Tina4Response } from "tina4-nodejs";
28756
28841
  import { authenticateRequest } from "tina4-nodejs";
28757
28842
 
@@ -28770,7 +28855,7 @@ export default async function (req: Tina4Request, res: Tina4Response) {
28770
28855
  const formsDir = resolve11("src/templates/forms");
28771
28856
  ensureDir(formsDir);
28772
28857
  writeFileSafe(
28773
- join22(formsDir, "login.twig"),
28858
+ join23(formsDir, "login.twig"),
28774
28859
  `{% extends "base.twig" %}
28775
28860
  {% block title %}Login{% endblock %}
28776
28861
  {% block content %}
@@ -28798,7 +28883,7 @@ export default async function (req: Tina4Request, res: Tina4Response) {
28798
28883
  `
28799
28884
  );
28800
28885
  writeFileSafe(
28801
- join22(formsDir, "register.twig"),
28886
+ join23(formsDir, "register.twig"),
28802
28887
  `{% extends "base.twig" %}
28803
28888
  {% block title %}Register{% endblock %}
28804
28889
  {% block content %}
@@ -28837,7 +28922,7 @@ function generateService(name, flags) {
28837
28922
  const cron = flags.cron;
28838
28923
  const dir = resolve11("src/services");
28839
28924
  ensureDir(dir);
28840
- const path10 = join22(dir, `${snake}.ts`);
28925
+ const path9 = join23(dir, `${snake}.ts`);
28841
28926
  let scheduleField;
28842
28927
  let note;
28843
28928
  if (cron && cron !== true) {
@@ -28880,7 +28965,7 @@ export default {
28880
28965
  ${scheduleField}
28881
28966
  };
28882
28967
  `;
28883
- writeFileSafe(path10, content);
28968
+ writeFileSafe(path9, content);
28884
28969
  emitServiceTest(name, snake, camel);
28885
28970
  }
28886
28971
  function generateQueue(name, _flags) {
@@ -28889,7 +28974,7 @@ function generateQueue(name, _flags) {
28889
28974
  const pascal = toPascal(topic) || "Topic";
28890
28975
  const dir = resolve11("src/services");
28891
28976
  ensureDir(dir);
28892
- const path10 = join22(dir, `${slug}_consumer.ts`);
28977
+ const path9 = join23(dir, `${slug}_consumer.ts`);
28893
28978
  const body = aiFill(`handle${pascal}`, {
28894
28979
  intent: `process ONE ${topic} job payload`,
28895
28980
  given: "payload -> the produced job data (job.payload)",
@@ -28944,13 +29029,13 @@ export default {
28944
29029
  daemon: true,
28945
29030
  };
28946
29031
  `;
28947
- writeFileSafe(path10, content);
29032
+ writeFileSafe(path9, content);
28948
29033
  emitQueueTest(topic, slug, pascal);
28949
29034
  }
28950
29035
  function generateValidator(name, _flags) {
28951
29036
  const dir = resolve11("src/validators");
28952
29037
  ensureDir(dir);
28953
- const path10 = join22(dir, `${toSnake(name)}.ts`);
29038
+ const path9 = join23(dir, `${toSnake(name)}.ts`);
28954
29039
  const rules = extend(
28955
29040
  "add / adjust the validation rules for this payload",
28956
29041
  `e.g. .email("email").minLength("name", 2).integer("age"); ground: tina4_context("validate request body with Validator", "nodejs")`
@@ -28971,14 +29056,14 @@ ${rules} validator.required("name"); // starter rule (matches the model's def
28971
29056
  return validator;
28972
29057
  }
28973
29058
  `;
28974
- writeFileSafe(path10, content);
29059
+ writeFileSafe(path9, content);
28975
29060
  emitValidatorTest(name, toSnake(name), toPascal(name));
28976
29061
  }
28977
29062
  function generateSeeder(name, flags) {
28978
29063
  const table2 = resolveTable(name, flags, { announce: false });
28979
29064
  const dir = resolve11("src/seeds");
28980
29065
  ensureDir(dir);
28981
- const path10 = join22(dir, `${table2}_seeder.ts`);
29066
+ const path9 = join23(dir, `${table2}_seeder.ts`);
28982
29067
  const overrides = extend(
28983
29068
  "override fields that need a specific shape (seedOrm auto-fills the rest)",
28984
29069
  `e.g. return { email: (f) => f.email(), status: "active" }; ground: tina4_context("seed ORM model with FakeData", "nodejs")`
@@ -29012,7 +29097,7 @@ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href)
29012
29097
  await run();
29013
29098
  }
29014
29099
  `;
29015
- writeFileSafe(path10, content);
29100
+ writeFileSafe(path9, content);
29016
29101
  emitSeederTest(name, table2);
29017
29102
  }
29018
29103
  function generateWebsocket(name, _flags) {
@@ -29023,7 +29108,7 @@ function generateWebsocket(name, _flags) {
29023
29108
  const handlerName = `${toCamel(toPascal(base))}Ws`;
29024
29109
  const dir = resolve11("src/routes");
29025
29110
  ensureDir(dir);
29026
- const path10 = join22(dir, `ws_${base}.ts`);
29111
+ const path9 = join23(dir, `ws_${base}.ts`);
29027
29112
  const body = aiFill(handlerName, {
29028
29113
  intent: `handle an inbound "message" frame on ${wsPath}`,
29029
29114
  given: "data -> the message payload (string); connection -> WebSocketConnection",
@@ -29065,7 +29150,7 @@ ${body}}
29065
29150
 
29066
29151
  websocket("${wsPath}", ${handlerName});
29067
29152
  `;
29068
- writeFileSafe(path10, content);
29153
+ writeFileSafe(path9, content);
29069
29154
  emitWebsocketTest(wsPath, base, handlerName);
29070
29155
  }
29071
29156
  function generateListener(name, _flags) {
@@ -29074,7 +29159,7 @@ function generateListener(name, _flags) {
29074
29159
  const handlerName = `on${toPascal(slug)}`;
29075
29160
  const dir = resolve11("src/listeners");
29076
29161
  ensureDir(dir);
29077
- const path10 = join22(dir, `${slug}.ts`);
29162
+ const path9 = join23(dir, `${slug}.ts`);
29078
29163
  const body = aiFill(handlerName, {
29079
29164
  intent: `react to the '${event}' event`,
29080
29165
  given: `args -> whatever Events.emit("${event}", ...args) passed`,
@@ -29100,13 +29185,13 @@ ${body}}
29100
29185
 
29101
29186
  Events.on("${event}", ${handlerName});
29102
29187
  `;
29103
- writeFileSafe(path10, content);
29188
+ writeFileSafe(path9, content);
29104
29189
  emitListenerTest(event, slug);
29105
29190
  }
29106
29191
  function writeTest(testName, content) {
29107
29192
  const dir = resolve11("tests");
29108
29193
  ensureDir(dir);
29109
- writeFileSafe(join22(dir, `${testName}.test.ts`), content);
29194
+ writeFileSafe(join23(dir, `${testName}.test.ts`), content);
29110
29195
  }
29111
29196
  function standaloneTest(doc, body) {
29112
29197
  return `${doc}
@@ -29772,7 +29857,6 @@ __export(mcp_exports, {
29772
29857
  import * as fs4 from "node:fs";
29773
29858
  import * as path3 from "node:path";
29774
29859
  import * as os from "node:os";
29775
- import { spawnSync as spawnSync2 } from "node:child_process";
29776
29860
  import { createRequire as createRequire7 } from "node:module";
29777
29861
  import { randomBytes as randomBytes7 } from "node:crypto";
29778
29862
  function reqSibling(pkg) {
@@ -30101,7 +30185,7 @@ function verifyNodeSyntax(absPath, relPath) {
30101
30185
  if (!target) return null;
30102
30186
  const { cmd, args } = syntaxCheckCommand(absPath, target.ext);
30103
30187
  try {
30104
- const proc = spawnSync2(cmd, args, {
30188
+ const proc = spawnSyncAllowingBatch(findExecutable(cmd), args, {
30105
30189
  encoding: "utf-8",
30106
30190
  timeout: 5e3,
30107
30191
  cwd: path3.dirname(path3.dirname(absPath))
@@ -30982,13 +31066,13 @@ function registerDevTools(server) {
30982
31066
  "git_status",
30983
31067
  () => {
30984
31068
  try {
30985
- const { execFileSync: execFileSync6 } = req("node:child_process");
31069
+ const { execFileSync: execFileSync5 } = req("node:child_process");
30986
31070
  const cwd = path3.resolve(process.cwd());
30987
31071
  const run = (args) => {
30988
- return execFileSync6("git", args, { cwd, timeout: 3e3, encoding: "utf-8" }).toString().trim();
31072
+ return execFileSync5("git", args, { cwd, timeout: 3e3, encoding: "utf-8" }).toString().trim();
30989
31073
  };
30990
31074
  try {
30991
- execFileSync6("git", ["rev-parse", "--is-inside-work-tree"], { cwd, timeout: 3e3 });
31075
+ execFileSync5("git", ["rev-parse", "--is-inside-work-tree"], { cwd, timeout: 3e3 });
30992
31076
  } catch {
30993
31077
  return { error: "Not a git repository" };
30994
31078
  }
@@ -31116,6 +31200,7 @@ var init_mcp = __esm({
31116
31200
  "../core/src/mcp.ts"() {
31117
31201
  "use strict";
31118
31202
  init_slashTrim();
31203
+ init_batchSpawn();
31119
31204
  init_version();
31120
31205
  req = createRequire7(import.meta.url);
31121
31206
  PARSE_ERROR = -32700;
@@ -32577,7 +32662,7 @@ function pack(segments, maxLines) {
32577
32662
  }
32578
32663
  return chunks;
32579
32664
  }
32580
- function chunkCode(text, path10 = "", maxLines = 60) {
32665
+ function chunkCode(text, path9 = "", maxLines = 60) {
32581
32666
  const lines = splitLines(text);
32582
32667
  let bounds = [];
32583
32668
  for (let i = 0; i < lines.length; i++) {
@@ -32591,7 +32676,7 @@ function chunkCode(text, path10 = "", maxLines = 60) {
32591
32676
  for (let k = 0; k < bounds.length; k++) {
32592
32677
  segments.push(lines.slice(bounds[k], ends[k]));
32593
32678
  }
32594
- const header = path10 ? `# file: ${path10}` : null;
32679
+ const header = path9 ? `# file: ${path9}` : null;
32595
32680
  const packed = pack(segments, maxLines);
32596
32681
  const out = [];
32597
32682
  for (let i = 0; i < packed.length; i++) {
@@ -32642,8 +32727,8 @@ __export(context_exports, {
32642
32727
  fts5Supported: () => fts5Supported
32643
32728
  });
32644
32729
  import { DatabaseSync as DatabaseSync4 } from "node:sqlite";
32645
- import { existsSync as existsSync19, mkdirSync as mkdirSync15, readFileSync as readFileSync15, readdirSync as readdirSync11, realpathSync as realpathSync5 } from "node:fs";
32646
- import { basename as basename5, dirname as dirname13, extname as extname5, isAbsolute as isAbsolute6, join as join24, relative as relative4, resolve as resolve13 } from "node:path";
32730
+ import { existsSync as existsSync20, mkdirSync as mkdirSync15, readFileSync as readFileSync15, readdirSync as readdirSync11, realpathSync as realpathSync5 } from "node:fs";
32731
+ import { basename as basename5, dirname as dirname13, extname as extname6, isAbsolute as isAbsolute6, join as join25, relative as relative4, resolve as resolve13 } from "node:path";
32647
32732
  function fts5Supported() {
32648
32733
  try {
32649
32734
  const conn = new DatabaseSync4(":memory:");
@@ -32666,13 +32751,13 @@ function realResolve(abs) {
32666
32751
  } catch {
32667
32752
  }
32668
32753
  try {
32669
- return join24(realpathSync5(dirname13(abs)), basename5(abs));
32754
+ return join25(realpathSync5(dirname13(abs)), basename5(abs));
32670
32755
  } catch {
32671
32756
  return abs;
32672
32757
  }
32673
32758
  }
32674
32759
  function dbKey(db) {
32675
- return resolve13(db ? String(db) : join24(process.cwd(), ".tina4", "context.db"));
32760
+ return resolve13(db ? String(db) : join25(process.cwd(), ".tina4", "context.db"));
32676
32761
  }
32677
32762
  function defaultContext(root, db) {
32678
32763
  const key = dbKey(db);
@@ -32778,7 +32863,7 @@ var init_context = __esm({
32778
32863
  }
32779
32864
  // ── indexing ───────────────────────────────────────────────
32780
32865
  static chunksFor(label, text) {
32781
- const ext = extname5(label).toLowerCase();
32866
+ const ext = extname6(label).toLowerCase();
32782
32867
  const special = SPECIAL_FILES.has(basename5(label).toLowerCase());
32783
32868
  if (CODE_EXTS.has(ext) || CONFIG_EXTS.has(ext) || special) {
32784
32869
  return chunkCode(text, label);
@@ -32817,7 +32902,7 @@ var init_context = __esm({
32817
32902
  static eligible(filename) {
32818
32903
  const fn = filename.toLowerCase();
32819
32904
  if (fn.endsWith(".min.js")) return false;
32820
- const ext = extname5(fn);
32905
+ const ext = extname6(fn);
32821
32906
  return CODE_EXTS.has(ext) || DOC_EXTS.has(ext) || CONFIG_EXTS.has(ext) || SPECIAL_FILES.has(fn);
32822
32907
  }
32823
32908
  /**
@@ -32845,11 +32930,11 @@ var init_context = __esm({
32845
32930
  files.sort();
32846
32931
  for (const fn of files) {
32847
32932
  if (!_Context.eligible(fn)) continue;
32848
- const full = join24(dir, fn);
32933
+ const full = join25(dir, fn);
32849
32934
  const rel = relative4(rootAbs, full);
32850
32935
  total += this.indexPath(full, rel);
32851
32936
  }
32852
- for (const d of subdirs) walk2(join24(dir, d));
32937
+ for (const d of subdirs) walk2(join25(dir, d));
32853
32938
  };
32854
32939
  walk2(rootAbs);
32855
32940
  return total;
@@ -32865,7 +32950,7 @@ var init_context = __esm({
32865
32950
  reindexFile(changedPath) {
32866
32951
  if (!this.available || this.root === null) return -1;
32867
32952
  const raw = String(changedPath);
32868
- const abs = isAbsolute6(raw) ? raw : join24(process.cwd(), raw);
32953
+ const abs = isAbsolute6(raw) ? raw : join25(process.cwd(), raw);
32869
32954
  const resolved = realResolve(resolve13(abs));
32870
32955
  const rel = relative4(this.root, resolved);
32871
32956
  if (rel === "" || rel.startsWith("..") || isAbsolute6(rel)) {
@@ -32878,7 +32963,7 @@ var init_context = __esm({
32878
32963
  }
32879
32964
  if (!_Context.eligible(basename5(rel))) return -1;
32880
32965
  const stored = rel;
32881
- if (!existsSync19(abs)) {
32966
+ if (!existsSync20(abs)) {
32882
32967
  this.conn.prepare("DELETE FROM chunks WHERE path = ?").run(stored);
32883
32968
  return 0;
32884
32969
  }
@@ -32896,8 +32981,8 @@ var init_context = __esm({
32896
32981
  const expr = [...toks].sort().map((t) => `"${t}"`).join(" OR ");
32897
32982
  return { expr, toks };
32898
32983
  }
32899
- static isTestlike(path10) {
32900
- const s = (path10 || "").toLowerCase();
32984
+ static isTestlike(path9) {
32985
+ const s = (path9 || "").toLowerCase();
32901
32986
  return ["/test", "test/", "test_", "_test.", ".test.", "/example", "example/"].some((p) => s.includes(p));
32902
32987
  }
32903
32988
  static defines(foldedBody, symbols) {
@@ -33361,7 +33446,7 @@ function parseFrame(data) {
33361
33446
  const payload = data.subarray(offset, offset + payloadLen);
33362
33447
  return { fin: !!fin, opcode, payload: Buffer.from(payload), bytesConsumed: offset + payloadLen };
33363
33448
  }
33364
- function createRouteConnection(socket, path10, headers, params, auth) {
33449
+ function createRouteConnection(socket, path9, headers, params, auth) {
33365
33450
  const id = randomUUID4().slice(0, 8);
33366
33451
  const send = (message) => {
33367
33452
  try {
@@ -33371,14 +33456,14 @@ function createRouteConnection(socket, path10, headers, params, auth) {
33371
33456
  };
33372
33457
  const conn = {
33373
33458
  id,
33374
- path: path10,
33459
+ path: path9,
33375
33460
  ip: socket.remoteAddress ?? "unknown",
33376
33461
  headers,
33377
33462
  params,
33378
33463
  auth,
33379
33464
  send,
33380
33465
  sendJson: (data) => send(JSON.stringify(data)),
33381
- broadcast: (message) => wsRouteManager.broadcastPath(path10, message),
33466
+ broadcast: (message) => wsRouteManager.broadcastPath(path9, message),
33382
33467
  broadcastToRoom: (room, message, excludeSelf = false) => wsRouteManager.broadcastToRoom(room, message, excludeSelf ? id : void 0),
33383
33468
  getRoomConnections: (room) => wsRouteManager.getRoomConnections(room),
33384
33469
  joinRoom: (room) => wsRouteManager.joinRoom(id, room),
@@ -33587,8 +33672,8 @@ var init_websocket = __esm({
33587
33672
  * to the Router's `(conn, event, data)` style and registers it via
33588
33673
  * `Router.websocket()`.
33589
33674
  */
33590
- route(path10, handler, options) {
33591
- this._routeHandlers.set(path10, handler);
33675
+ route(path9, handler, options) {
33676
+ this._routeHandlers.set(path9, handler);
33592
33677
  const adapter = async (conn, event, data) => {
33593
33678
  if (event === "open") {
33594
33679
  const result = handler(conn);
@@ -33611,7 +33696,7 @@ var init_websocket = __esm({
33611
33696
  }
33612
33697
  }
33613
33698
  };
33614
- Router.websocket(path10, adapter, options);
33699
+ Router.websocket(path9, adapter, options);
33615
33700
  }
33616
33701
  /**
33617
33702
  * Broadcast a message to all connected clients.
@@ -33621,18 +33706,18 @@ var init_websocket = __esm({
33621
33706
  * When `path` is omitted/undefined, all clients receive the message
33622
33707
  * (backward compatible).
33623
33708
  */
33624
- broadcast(message, excludeIds, path10) {
33709
+ broadcast(message, excludeIds, path9) {
33625
33710
  this.ensureBackplane();
33626
33711
  const exclude = new Set(excludeIds ?? []);
33627
33712
  for (const [id, client] of Array.from(this.clients)) {
33628
33713
  if (exclude.has(id)) continue;
33629
- if (path10 !== void 0 && client.path !== path10) continue;
33714
+ if (path9 !== void 0 && client.path !== path9) continue;
33630
33715
  this.safeSend(client, message);
33631
33716
  }
33632
33717
  this.backplane.publish(
33633
- path10 !== void 0 ? "path" : "all",
33718
+ path9 !== void 0 ? "path" : "all",
33634
33719
  message,
33635
- { path: path10 ?? null, exclude: excludeIds?.[0] ?? null },
33720
+ { path: path9 ?? null, exclude: excludeIds?.[0] ?? null },
33636
33721
  Log
33637
33722
  );
33638
33723
  }
@@ -34108,10 +34193,10 @@ var init_websocket = __esm({
34108
34193
  }
34109
34194
  }
34110
34195
  /** Broadcast a text frame to every connection on the same path. */
34111
- broadcastPath(path10, message) {
34196
+ broadcastPath(path9, message) {
34112
34197
  const frame = buildFrame(OP_TEXT, Buffer.from(message, "utf-8"));
34113
34198
  for (const state of this.connections.values()) {
34114
- if (state.path !== path10 || state.closed) continue;
34199
+ if (state.path !== path9 || state.closed) continue;
34115
34200
  try {
34116
34201
  state.socket.write(frame);
34117
34202
  } catch {
@@ -35724,8 +35809,8 @@ var init_job = __esm({
35724
35809
  });
35725
35810
 
35726
35811
  // ../core/src/queueBackends/liteBackend.ts
35727
- import { mkdirSync as mkdirSync16, readdirSync as readdirSync12, readFileSync as readFileSync16, writeFileSync as writeFileSync12, unlinkSync as unlinkSync8, existsSync as existsSync20 } from "node:fs";
35728
- import { join as join25 } from "node:path";
35812
+ import { mkdirSync as mkdirSync16, readdirSync as readdirSync12, readFileSync as readFileSync16, writeFileSync as writeFileSync12, unlinkSync as unlinkSync8, existsSync as existsSync21 } from "node:fs";
35813
+ import { join as join26 } from "node:path";
35729
35814
  import { randomUUID as randomUUID7 } from "node:crypto";
35730
35815
  var LiteBackend;
35731
35816
  var init_liteBackend = __esm({
@@ -35749,22 +35834,22 @@ var init_liteBackend = __esm({
35749
35834
  this.visibilityTimeout = visibilityTimeout;
35750
35835
  }
35751
35836
  ensureDir(queue) {
35752
- const dir = join25(this.basePath, queue);
35837
+ const dir = join26(this.basePath, queue);
35753
35838
  mkdirSync16(dir, { recursive: true });
35754
35839
  return dir;
35755
35840
  }
35756
35841
  ensureFailedDir(queue) {
35757
- const dir = join25(this.basePath, queue, "failed");
35842
+ const dir = join26(this.basePath, queue, "failed");
35758
35843
  mkdirSync16(dir, { recursive: true });
35759
35844
  return dir;
35760
35845
  }
35761
35846
  ensureReservedDir(queue) {
35762
- const dir = join25(this.basePath, queue, "reserved");
35847
+ const dir = join26(this.basePath, queue, "reserved");
35763
35848
  mkdirSync16(dir, { recursive: true });
35764
35849
  return dir;
35765
35850
  }
35766
35851
  reservedPath(queue, jobId) {
35767
- return join25(this.ensureReservedDir(queue), `${jobId}.queue-data`);
35852
+ return join26(this.ensureReservedDir(queue), `${jobId}.queue-data`);
35768
35853
  }
35769
35854
  nowIso() {
35770
35855
  return (/* @__PURE__ */ new Date()).toISOString();
@@ -35807,7 +35892,7 @@ var init_liteBackend = __esm({
35807
35892
  error: void 0
35808
35893
  };
35809
35894
  const prefix = this.nextPrefix();
35810
- writeFileSync12(join25(dir, `${prefix}_${id}.queue-data`), JSON.stringify(job, null, 2));
35895
+ writeFileSync12(join26(dir, `${prefix}_${id}.queue-data`), JSON.stringify(job, null, 2));
35811
35896
  return id;
35812
35897
  }
35813
35898
  /**
@@ -35826,7 +35911,7 @@ var init_liteBackend = __esm({
35826
35911
  }
35827
35912
  const candidates = [];
35828
35913
  for (const filename of filenames) {
35829
- const filePath = join25(dir, filename);
35914
+ const filePath = join26(dir, filename);
35830
35915
  let job;
35831
35916
  try {
35832
35917
  job = JSON.parse(readFileSync16(filePath, "utf-8"));
@@ -35890,7 +35975,7 @@ var init_liteBackend = __esm({
35890
35975
  return;
35891
35976
  }
35892
35977
  for (const filename of filenames) {
35893
- const filePath = join25(reservedDir, filename);
35978
+ const filePath = join26(reservedDir, filename);
35894
35979
  let record2;
35895
35980
  try {
35896
35981
  record2 = JSON.parse(readFileSync16(filePath, "utf-8"));
@@ -35928,7 +36013,7 @@ var init_liteBackend = __esm({
35928
36013
  this.reclaimExpired(queue, bridge.getMaxRetries(), this.nowIso());
35929
36014
  const now = this.nowIso();
35930
36015
  for (const [filename, job] of this.availableCandidates(queue, now)) {
35931
- const filePath = join25(dir, filename);
36016
+ const filePath = join26(dir, filename);
35932
36017
  job.topic = queue;
35933
36018
  job.priority = job.priority ?? 0;
35934
36019
  this.writeReserved(queue, job);
@@ -35953,7 +36038,7 @@ var init_liteBackend = __esm({
35953
36038
  const results = [];
35954
36039
  for (const [filename, job] of this.availableCandidates(queue, now)) {
35955
36040
  if (results.length >= count) break;
35956
- const filePath = join25(dir, filename);
36041
+ const filePath = join26(dir, filename);
35957
36042
  job.topic = queue;
35958
36043
  job.priority = job.priority ?? 0;
35959
36044
  this.writeReserved(queue, job);
@@ -36006,7 +36091,7 @@ var init_liteBackend = __esm({
36006
36091
  let count = 0;
36007
36092
  for (const file of files) {
36008
36093
  try {
36009
- const job = JSON.parse(readFileSync16(join25(scanDir, file), "utf-8"));
36094
+ const job = JSON.parse(readFileSync16(join26(scanDir, file), "utf-8"));
36010
36095
  if (job.status === status2) count++;
36011
36096
  } catch {
36012
36097
  }
@@ -36019,28 +36104,28 @@ var init_liteBackend = __esm({
36019
36104
  try {
36020
36105
  const files = readdirSync12(dir).filter((f) => f.endsWith(".queue-data"));
36021
36106
  for (const file of files) {
36022
- unlinkSync8(join25(dir, file));
36107
+ unlinkSync8(join26(dir, file));
36023
36108
  count++;
36024
36109
  }
36025
36110
  } catch {
36026
36111
  }
36027
- const failedDir = join25(dir, "failed");
36112
+ const failedDir = join26(dir, "failed");
36028
36113
  try {
36029
- if (existsSync20(failedDir)) {
36114
+ if (existsSync21(failedDir)) {
36030
36115
  const files = readdirSync12(failedDir).filter((f) => f.endsWith(".queue-data"));
36031
36116
  for (const file of files) {
36032
- unlinkSync8(join25(failedDir, file));
36117
+ unlinkSync8(join26(failedDir, file));
36033
36118
  count++;
36034
36119
  }
36035
36120
  }
36036
36121
  } catch {
36037
36122
  }
36038
- const reservedDir = join25(dir, "reserved");
36123
+ const reservedDir = join26(dir, "reserved");
36039
36124
  try {
36040
- if (existsSync20(reservedDir)) {
36125
+ if (existsSync21(reservedDir)) {
36041
36126
  const files = readdirSync12(reservedDir).filter((f) => f.endsWith(".queue-data"));
36042
36127
  for (const file of files) {
36043
- unlinkSync8(join25(reservedDir, file));
36128
+ unlinkSync8(join26(reservedDir, file));
36044
36129
  count++;
36045
36130
  }
36046
36131
  }
@@ -36063,7 +36148,7 @@ var init_liteBackend = __esm({
36063
36148
  const files = readdirSync12(dir).filter((f) => f.endsWith(".queue-data")).sort();
36064
36149
  for (const file of files) {
36065
36150
  try {
36066
- const job = JSON.parse(readFileSync16(join25(dir, file), "utf-8"));
36151
+ const job = JSON.parse(readFileSync16(join26(dir, file), "utf-8"));
36067
36152
  const attempts = job.attempts || 0;
36068
36153
  if (attempts > 0 && attempts < maxRetries) {
36069
36154
  results.push(job);
@@ -36086,9 +36171,9 @@ var init_liteBackend = __esm({
36086
36171
  try {
36087
36172
  const queues = readdirSync12(this.basePath);
36088
36173
  for (const q of queues) {
36089
- const failedDir = join25(this.basePath, q, "failed");
36090
- const filePath = join25(failedDir, `${jobId}.queue-data`);
36091
- if (existsSync20(filePath)) {
36174
+ const failedDir = join26(this.basePath, q, "failed");
36175
+ const filePath = join26(failedDir, `${jobId}.queue-data`);
36176
+ if (existsSync21(filePath)) {
36092
36177
  const job = JSON.parse(readFileSync16(filePath, "utf-8"));
36093
36178
  job.status = "pending";
36094
36179
  job.attempts = (job.attempts || 0) + 1;
@@ -36096,8 +36181,8 @@ var init_liteBackend = __esm({
36096
36181
  job.createdAt = (/* @__PURE__ */ new Date()).toISOString();
36097
36182
  job.delayUntil = delaySeconds ? new Date(Date.now() + delaySeconds * 1e3).toISOString() : null;
36098
36183
  const prefix = this.nextPrefix();
36099
- const queueDir = join25(this.basePath, q);
36100
- writeFileSync12(join25(queueDir, `${prefix}_${jobId}.queue-data`), JSON.stringify(job, null, 2));
36184
+ const queueDir = join26(this.basePath, q);
36185
+ writeFileSync12(join26(queueDir, `${prefix}_${jobId}.queue-data`), JSON.stringify(job, null, 2));
36101
36186
  unlinkSync8(filePath);
36102
36187
  return true;
36103
36188
  }
@@ -36113,7 +36198,7 @@ var init_liteBackend = __esm({
36113
36198
  const files = readdirSync12(failedDir).filter((f) => f.endsWith(".queue-data")).sort();
36114
36199
  for (const file of files) {
36115
36200
  try {
36116
- const job = JSON.parse(readFileSync16(join25(failedDir, file), "utf-8"));
36201
+ const job = JSON.parse(readFileSync16(join26(failedDir, file), "utf-8"));
36117
36202
  if ((job.attempts || 0) >= maxRetries) {
36118
36203
  job.status = "dead";
36119
36204
  results.push(job);
@@ -36134,7 +36219,7 @@ var init_liteBackend = __esm({
36134
36219
  const files = readdirSync12(failedDir).filter((f) => f.endsWith(".queue-data"));
36135
36220
  for (const file of files) {
36136
36221
  try {
36137
- unlinkSync8(join25(failedDir, file));
36222
+ unlinkSync8(join26(failedDir, file));
36138
36223
  count++;
36139
36224
  } catch {
36140
36225
  }
@@ -36147,9 +36232,9 @@ var init_liteBackend = __esm({
36147
36232
  const files = readdirSync12(dir).filter((f) => f.endsWith(".queue-data"));
36148
36233
  for (const file of files) {
36149
36234
  try {
36150
- const job = JSON.parse(readFileSync16(join25(dir, file), "utf-8"));
36235
+ const job = JSON.parse(readFileSync16(join26(dir, file), "utf-8"));
36151
36236
  if (job.status === status2) {
36152
- unlinkSync8(join25(dir, file));
36237
+ unlinkSync8(join26(dir, file));
36153
36238
  count++;
36154
36239
  }
36155
36240
  } catch {
@@ -36173,7 +36258,7 @@ var init_liteBackend = __esm({
36173
36258
  const files = readdirSync12(failedDir).filter((f) => f.endsWith(".queue-data"));
36174
36259
  for (const file of files) {
36175
36260
  try {
36176
- const filePath = join25(failedDir, file);
36261
+ const filePath = join26(failedDir, file);
36177
36262
  const job = JSON.parse(readFileSync16(filePath, "utf-8"));
36178
36263
  if ((job.attempts || 0) >= maxRetries) {
36179
36264
  continue;
@@ -36183,7 +36268,7 @@ var init_liteBackend = __esm({
36183
36268
  job.createdAt = (/* @__PURE__ */ new Date()).toISOString();
36184
36269
  job.delayUntil = null;
36185
36270
  const prefix = this.nextPrefix();
36186
- writeFileSync12(join25(queueDir, `${prefix}_${job.id}.queue-data`), JSON.stringify(job, null, 2));
36271
+ writeFileSync12(join26(queueDir, `${prefix}_${job.id}.queue-data`), JSON.stringify(job, null, 2));
36187
36272
  unlinkSync8(filePath);
36188
36273
  count++;
36189
36274
  } catch {
@@ -36203,7 +36288,7 @@ var init_liteBackend = __esm({
36203
36288
  }
36204
36289
  for (const file of files) {
36205
36290
  if (!file.includes(id)) continue;
36206
- const filePath = join25(dir, file);
36291
+ const filePath = join26(dir, file);
36207
36292
  let job;
36208
36293
  try {
36209
36294
  job = JSON.parse(readFileSync16(filePath, "utf-8"));
@@ -36251,7 +36336,7 @@ var init_liteBackend = __esm({
36251
36336
  error: error2
36252
36337
  };
36253
36338
  const prefix = this.nextPrefix();
36254
- writeFileSync12(join25(dir, `${prefix}_${job.id}.queue-data`), JSON.stringify(jobData, null, 2));
36339
+ writeFileSync12(join26(dir, `${prefix}_${job.id}.queue-data`), JSON.stringify(jobData, null, 2));
36255
36340
  }
36256
36341
  /**
36257
36342
  * Move the job to the dead-letter (failed/) directory. Terminal until a
@@ -36271,7 +36356,7 @@ var init_liteBackend = __esm({
36271
36356
  error: error2,
36272
36357
  failedAt: (/* @__PURE__ */ new Date()).toISOString()
36273
36358
  };
36274
- writeFileSync12(join25(failedDir, `${job.id}.queue-data`), JSON.stringify(jobData, null, 2));
36359
+ writeFileSync12(join26(failedDir, `${job.id}.queue-data`), JSON.stringify(jobData, null, 2));
36275
36360
  }
36276
36361
  /**
36277
36362
  * Record a failed attempt.
@@ -36321,7 +36406,7 @@ var init_liteBackend = __esm({
36321
36406
  retryJob(queue, job, delaySeconds) {
36322
36407
  this.clearReservation(queue, job.id);
36323
36408
  try {
36324
- unlinkSync8(join25(this.ensureFailedDir(queue), `${job.id}.queue-data`));
36409
+ unlinkSync8(join26(this.ensureFailedDir(queue), `${job.id}.queue-data`));
36325
36410
  } catch {
36326
36411
  }
36327
36412
  job.attempts = (job.attempts || 0) + 1;
@@ -37461,6 +37546,9 @@ var init_projectIndexExtractors = __esm({
37461
37546
  import * as fs6 from "node:fs";
37462
37547
  import * as path6 from "node:path";
37463
37548
  import * as crypto2 from "node:crypto";
37549
+ function indexKey(root, fullPath) {
37550
+ return path6.relative(root, fullPath).split(path6.sep).join("/");
37551
+ }
37464
37552
  function projectRoot2() {
37465
37553
  return path6.resolve(process.cwd());
37466
37554
  }
@@ -37495,7 +37583,7 @@ function extract2(fullPath) {
37495
37583
  return {};
37496
37584
  }
37497
37585
  const entry = {
37498
- path: path6.relative(projectRoot2(), fullPath),
37586
+ path: indexKey(projectRoot2(), fullPath),
37499
37587
  size: st.size,
37500
37588
  mtime: Math.floor(st.mtimeMs / 1e3),
37501
37589
  language: languageFor(fullPath)
@@ -37602,7 +37690,6 @@ var projectIndex_exports = {};
37602
37690
  __export(projectIndex_exports, {
37603
37691
  ProjectIndex: () => ProjectIndex
37604
37692
  });
37605
- import * as path7 from "node:path";
37606
37693
  import * as fs7 from "node:fs";
37607
37694
  function scoreSearchEntry(query, rel, entry) {
37608
37695
  let score = rel.toLowerCase().includes(query) ? 10 : 0;
@@ -37635,7 +37722,7 @@ var init_projectIndex = __esm({
37635
37722
  const found = [];
37636
37723
  walk(root, found);
37637
37724
  for (const fp of found) {
37638
- const rel = path7.relative(root, fp);
37725
+ const rel = indexKey(root, fp);
37639
37726
  seen.add(rel);
37640
37727
  let mtime;
37641
37728
  try {
@@ -37661,7 +37748,7 @@ var init_projectIndex = __esm({
37661
37748
  updated,
37662
37749
  removed: removed.length,
37663
37750
  total: Object.keys(files).length,
37664
- path: path7.relative(root, indexPath())
37751
+ path: indexKey(root, indexPath())
37665
37752
  };
37666
37753
  },
37667
37754
  search(query, limit = 20) {
@@ -38213,23 +38300,23 @@ __export(docs_exports, {
38213
38300
  returnFromSignature: () => returnFromSignature
38214
38301
  });
38215
38302
  import * as fs8 from "node:fs";
38216
- import * as path8 from "node:path";
38217
- import { fileURLToPath as fileURLToPath7 } from "node:url";
38303
+ import * as path7 from "node:path";
38304
+ import { fileURLToPath as fileURLToPath8 } from "node:url";
38218
38305
  function detectFrameworkRoots() {
38219
- const corePackageRoot = path8.resolve(__DIRNAME, "..");
38220
- const packagesRoot = path8.resolve(corePackageRoot, "..");
38306
+ const corePackageRoot = path7.resolve(__DIRNAME, "..");
38307
+ const packagesRoot = path7.resolve(corePackageRoot, "..");
38221
38308
  const roots = [];
38222
38309
  for (const pkg of ["core", "orm", "swagger", "frond"]) {
38223
- const dir = path8.join(packagesRoot, pkg, "src");
38310
+ const dir = path7.join(packagesRoot, pkg, "src");
38224
38311
  if (fs8.existsSync(dir)) roots.push(dir);
38225
38312
  }
38226
38313
  return roots;
38227
38314
  }
38228
38315
  function detectVersion(projectRoot3) {
38229
38316
  for (const candidate of [
38230
- path8.join(projectRoot3, "package.json"),
38231
- path8.resolve(__DIRNAME, "..", "..", "..", "package.json"),
38232
- path8.resolve(__DIRNAME, "..", "package.json")
38317
+ path7.join(projectRoot3, "package.json"),
38318
+ path7.resolve(__DIRNAME, "..", "..", "..", "package.json"),
38319
+ path7.resolve(__DIRNAME, "..", "package.json")
38233
38320
  ]) {
38234
38321
  try {
38235
38322
  const pkg = JSON.parse(fs8.readFileSync(candidate, "utf-8"));
@@ -38240,16 +38327,16 @@ function detectVersion(projectRoot3) {
38240
38327
  return "0.0.0";
38241
38328
  }
38242
38329
  function relativePath(absPath, projectRoot3, frameworkRoots) {
38243
- const norm = path8.resolve(absPath);
38330
+ const norm = path7.resolve(absPath);
38244
38331
  for (const fw of frameworkRoots) {
38245
- const parent = path8.dirname(fw);
38246
- if (norm.startsWith(parent + path8.sep)) {
38247
- const monorepo = path8.resolve(parent, "..", "..");
38248
- if (norm.startsWith(monorepo + path8.sep)) return path8.relative(monorepo, norm);
38249
- return path8.relative(parent, norm);
38332
+ const parent = path7.dirname(fw);
38333
+ if (norm.startsWith(parent + path7.sep)) {
38334
+ const monorepo = path7.resolve(parent, "..", "..");
38335
+ if (norm.startsWith(monorepo + path7.sep)) return path7.relative(monorepo, norm);
38336
+ return path7.relative(parent, norm);
38250
38337
  }
38251
38338
  }
38252
- if (norm.startsWith(projectRoot3 + path8.sep)) return path8.relative(projectRoot3, norm);
38339
+ if (norm.startsWith(projectRoot3 + path7.sep)) return path7.relative(projectRoot3, norm);
38253
38340
  return norm;
38254
38341
  }
38255
38342
  function tokenise(text) {
@@ -38289,12 +38376,12 @@ function walkTsFiles(root) {
38289
38376
  if (e.name.startsWith(".")) continue;
38290
38377
  if (e.isDirectory()) {
38291
38378
  if (e.name === "node_modules" || e.name === "tests" || e.name === "test" || e.name === "dist" || e.name === "build") continue;
38292
- visit(path8.join(dir, e.name));
38379
+ visit(path7.join(dir, e.name));
38293
38380
  } else if (e.isFile()) {
38294
38381
  if (!e.name.endsWith(".ts") && !e.name.endsWith(".js") && !e.name.endsWith(".mjs")) continue;
38295
38382
  if (e.name.endsWith(".test.ts") || e.name.endsWith(".test.js")) continue;
38296
38383
  if (e.name.endsWith(".d.ts")) continue;
38297
- found.push(path8.join(dir, e.name));
38384
+ found.push(path7.join(dir, e.name));
38298
38385
  }
38299
38386
  }
38300
38387
  }
@@ -38621,8 +38708,8 @@ var init_docs = __esm({
38621
38708
  "hash"
38622
38709
  ]);
38623
38710
  _DOCS_CACHE = /* @__PURE__ */ new Map();
38624
- __FILENAME = fileURLToPath7(import.meta.url);
38625
- __DIRNAME = path8.dirname(__FILENAME);
38711
+ __FILENAME = fileURLToPath8(import.meta.url);
38712
+ __DIRNAME = path7.dirname(__FILENAME);
38626
38713
  USER_DIRS = ["src/orm", "src/routes", "src/app", "src/services", "src/models"];
38627
38714
  FENCE_RE = new RegExp(
38628
38715
  String.fromCharCode(96, 96, 96) + "[a-zA-Z0-9_+-]*\\n([\\s\\S]*?)\\n" + String.fromCharCode(96, 96, 96),
@@ -38640,7 +38727,7 @@ var init_docs = __esm({
38640
38727
  userMtime = 0;
38641
38728
  frameworkMtime = 0;
38642
38729
  constructor(projectRoot3) {
38643
- this.projectRoot = path8.resolve(projectRoot3);
38730
+ this.projectRoot = path7.resolve(projectRoot3);
38644
38731
  this.frameworkRoots = detectFrameworkRoots();
38645
38732
  this.version = detectVersion(this.projectRoot);
38646
38733
  }
@@ -38832,7 +38919,7 @@ var init_docs = __esm({
38832
38919
  // ── Drift detector + sync ────────────────────────────────────────
38833
38920
  static checkDocs(mdPath, projectRoot3) {
38834
38921
  if (!fs8.existsSync(mdPath)) return { drift: [] };
38835
- const docs = _Docs.cached(projectRoot3 ?? path8.dirname(mdPath));
38922
+ const docs = _Docs.cached(projectRoot3 ?? path7.dirname(mdPath));
38836
38923
  const idx = docs.index();
38837
38924
  const known = /* @__PURE__ */ new Set();
38838
38925
  for (const e of idx) known.add(e.name.toLowerCase());
@@ -38859,7 +38946,7 @@ var init_docs = __esm({
38859
38946
  return { drift };
38860
38947
  }
38861
38948
  static syncDocs(mdPath, projectRoot3) {
38862
- const docs = _Docs.cached(projectRoot3 ?? (fs8.existsSync(mdPath) ? path8.dirname(mdPath) : process.cwd()));
38949
+ const docs = _Docs.cached(projectRoot3 ?? (fs8.existsSync(mdPath) ? path7.dirname(mdPath) : process.cwd()));
38863
38950
  const generated = docs.renderGeneratedBlock();
38864
38951
  const begin = "<!-- BEGIN GENERATED API -->";
38865
38952
  const end = "<!-- END GENERATED API -->";
@@ -38883,7 +38970,7 @@ ${end}
38883
38970
  }
38884
38971
  // ── Internals ────────────────────────────────────────────────────
38885
38972
  static cached(projectRoot3) {
38886
- const key = path8.resolve(projectRoot3 ?? process.cwd());
38973
+ const key = path7.resolve(projectRoot3 ?? process.cwd());
38887
38974
  let inst = _DOCS_CACHE.get(key);
38888
38975
  if (!inst) {
38889
38976
  inst = new _Docs(key);
@@ -38910,11 +38997,11 @@ ${end}
38910
38997
  this.frameworkMtime = shared.mtime;
38911
38998
  this.indexCache = null;
38912
38999
  }
38913
- const userMtime = this.maxMtime(USER_DIRS.map((d) => path8.join(this.projectRoot, d)));
39000
+ const userMtime = this.maxMtime(USER_DIRS.map((d) => path7.join(this.projectRoot, d)));
38914
39001
  if (this.indexCache === null || userMtime !== this.userMtime) {
38915
39002
  this.userEntries = /* @__PURE__ */ new Map();
38916
39003
  for (const sub of USER_DIRS) {
38917
- const dir = path8.join(this.projectRoot, sub);
39004
+ const dir = path7.join(this.projectRoot, sub);
38918
39005
  if (!fs8.existsSync(dir)) continue;
38919
39006
  for (const f of walkTsFiles(dir)) {
38920
39007
  buildEntriesForFile(f, "user", this.frameworkRoots, this.projectRoot, this.version, this.userEntries);
@@ -38997,9 +39084,9 @@ ${end}
38997
39084
 
38998
39085
  // ../core/src/devAdmin.ts
38999
39086
  import { cpus as osCpus } from "node:os";
39000
- import { readFileSync as readFileSync20, writeFileSync as writeFileSync16, existsSync as existsSync24, readdirSync as readdirSync16, mkdirSync as mkdirSync19, copyFileSync as copyFileSync3, statSync as statSync18, 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";
39001
- import { join as join29, dirname as dirname15, resolve as resolve17, relative as relative9, sep as sep8, basename as basename6 } from "node:path";
39002
- import { fileURLToPath as fileURLToPath8 } from "node:url";
39087
+ import { readFileSync as readFileSync20, writeFileSync as writeFileSync16, existsSync as existsSync25, readdirSync as readdirSync16, mkdirSync as mkdirSync19, copyFileSync as copyFileSync3, statSync as statSync19, 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";
39088
+ import { join as join30, dirname as dirname15, resolve as resolve17, relative as relative8, sep as sep9, basename as basename6 } from "node:path";
39089
+ import { fileURLToPath as fileURLToPath9 } from "node:url";
39003
39090
  import { timingSafeEqual as timingSafeEqual2 } from "node:crypto";
39004
39091
  import net2 from "node:net";
39005
39092
  function escapeHtml2(value) {
@@ -39077,15 +39164,15 @@ function devToolbarAllowed(req2) {
39077
39164
  return devPeerAllowed(peer);
39078
39165
  }
39079
39166
  function devRequestDenial(req2) {
39080
- const path10 = (req2.path ?? "").replace(/\/+/g, "/");
39081
- const isMcp = DEV_MCP_PREFIXES.some((prefix) => path10 === prefix || path10.startsWith(prefix + "/"));
39167
+ const path9 = (req2.path ?? "").replace(/\/+/g, "/");
39168
+ const isMcp = DEV_MCP_PREFIXES.some((prefix) => path9 === prefix || path9.startsWith(prefix + "/"));
39082
39169
  if (!devHostAllowed(req2.header("host"))) {
39083
39170
  return { status: 403, error: "dev-admin: refused (host not allowed)" };
39084
39171
  }
39085
39172
  if (!devSameOriginOk(req2)) {
39086
39173
  return { status: 403, error: "dev-admin: refused (cross-origin request)" };
39087
39174
  }
39088
- if (DEV_PUBLIC_ASSETS.has(path10)) {
39175
+ if (DEV_PUBLIC_ASSETS.has(path9)) {
39089
39176
  return null;
39090
39177
  }
39091
39178
  if (!isMcp) {
@@ -39177,12 +39264,12 @@ function mapQueueJob(job, topic, status2) {
39177
39264
  };
39178
39265
  }
39179
39266
  function readQueueDir(dir, topic, status2) {
39180
- if (!existsSync24(dir)) return [];
39267
+ if (!existsSync25(dir)) return [];
39181
39268
  const jobs = [];
39182
39269
  for (const filename of readdirSync16(dir).sort()) {
39183
39270
  if (!filename.endsWith(".queue-data")) continue;
39184
39271
  try {
39185
- jobs.push(mapQueueJob(JSON.parse(readFileSync20(join29(dir, filename), "utf-8")), topic, status2));
39272
+ jobs.push(mapQueueJob(JSON.parse(readFileSync20(join30(dir, filename), "utf-8")), topic, status2));
39186
39273
  } catch {
39187
39274
  }
39188
39275
  }
@@ -39319,8 +39406,8 @@ async function proxyToSupervisor(req2, res, downstreamPath) {
39319
39406
  function resolveDevEnvVar(key) {
39320
39407
  const live = process.env[key];
39321
39408
  if (live !== void 0 && live !== "") return live;
39322
- const envPath = join29(process.cwd(), ".env");
39323
- if (!existsSync24(envPath)) return "";
39409
+ const envPath = join30(process.cwd(), ".env");
39410
+ if (!existsSync25(envPath)) return "";
39324
39411
  for (const line of readFileSync20(envPath, "utf-8").split("\n")) {
39325
39412
  const t = line.trim();
39326
39413
  if (!t || t.startsWith("#") || !t.includes("=")) continue;
@@ -39330,8 +39417,8 @@ function resolveDevEnvVar(key) {
39330
39417
  return "";
39331
39418
  }
39332
39419
  function upsertDevEnvVar(key, value) {
39333
- const envPath = join29(process.cwd(), ".env");
39334
- const lines = existsSync24(envPath) ? readFileSync20(envPath, "utf-8").split("\n") : [];
39420
+ const envPath = join30(process.cwd(), ".env");
39421
+ const lines = existsSync25(envPath) ? readFileSync20(envPath, "utf-8").split("\n") : [];
39335
39422
  let found = false;
39336
39423
  const out = [];
39337
39424
  for (const line of lines) {
@@ -39361,9 +39448,9 @@ function formatUptime(seconds) {
39361
39448
  return parts.join(" ");
39362
39449
  }
39363
39450
  function parseEnvFile() {
39364
- const envPath = join29(process.cwd(), ".env");
39451
+ const envPath = join30(process.cwd(), ".env");
39365
39452
  const result = {};
39366
- if (!existsSync24(envPath)) return result;
39453
+ if (!existsSync25(envPath)) return result;
39367
39454
  const lines = readFileSync20(envPath, "utf-8").split("\n");
39368
39455
  for (const line of lines) {
39369
39456
  const trimmed = line.trim();
@@ -39375,10 +39462,10 @@ function parseEnvFile() {
39375
39462
  }
39376
39463
  function walkDirRecursive(dir) {
39377
39464
  const results = [];
39378
- if (!existsSync24(dir)) return results;
39465
+ if (!existsSync25(dir)) return results;
39379
39466
  for (const entry of readdirSync16(dir)) {
39380
- const full = join29(dir, entry);
39381
- if (statSync18(full).isDirectory()) {
39467
+ const full = join30(dir, entry);
39468
+ if (statSync19(full).isDirectory()) {
39382
39469
  results.push(...walkDirRecursive(full));
39383
39470
  } else {
39384
39471
  results.push(full);
@@ -39395,8 +39482,8 @@ function handleGalleryDeploy(router) {
39395
39482
  return;
39396
39483
  }
39397
39484
  const galleryDir = resolve17(__devAdminDirname, "..", "gallery");
39398
- const gallerySrc = join29(galleryDir, name, "src");
39399
- if (!existsSync24(gallerySrc)) {
39485
+ const gallerySrc = join30(galleryDir, name, "src");
39486
+ if (!existsSync25(gallerySrc)) {
39400
39487
  res.json({ error: `Gallery item '${name}' not found` }, 404);
39401
39488
  return;
39402
39489
  }
@@ -39404,15 +39491,15 @@ function handleGalleryDeploy(router) {
39404
39491
  const copied = [];
39405
39492
  const allFiles = walkDirRecursive(gallerySrc);
39406
39493
  for (const srcFile of allFiles) {
39407
- const rel = relative9(gallerySrc, srcFile);
39408
- const dest = join29(projectSrc, rel);
39494
+ const rel = relative8(gallerySrc, srcFile);
39495
+ const dest = join30(projectSrc, rel);
39409
39496
  mkdirSync19(dirname15(dest), { recursive: true });
39410
39497
  copyFileSync3(srcFile, dest);
39411
39498
  copied.push(rel);
39412
39499
  }
39413
39500
  try {
39414
39501
  const routesDir = resolve17(process.cwd(), "src", "routes");
39415
- if (existsSync24(routesDir)) {
39502
+ if (existsSync25(routesDir)) {
39416
39503
  const { discoverRoutes: discoverRoutes2 } = await Promise.resolve().then(() => (init_routeDiscovery(), routeDiscovery_exports));
39417
39504
  const routes = await discoverRoutes2(routesDir);
39418
39505
  for (const route of routes) {
@@ -39441,7 +39528,7 @@ function realPathOf2(target) {
39441
39528
  tail.unshift(basename6(existing));
39442
39529
  existing = dirname15(existing);
39443
39530
  }
39444
- return join29(realpathSync6(existing), ...tail);
39531
+ return join30(realpathSync6(existing), ...tail);
39445
39532
  }
39446
39533
  function safeJoin(projectRoot3, rel, extraRoots = []) {
39447
39534
  try {
@@ -39449,14 +39536,14 @@ function safeJoin(projectRoot3, rel, extraRoots = []) {
39449
39536
  const resolved = realPathOf2(resolve17(root, rel));
39450
39537
  const roots = [root, ...extraRoots.filter(Boolean).map((r) => realPathOf2(resolve17(r)))];
39451
39538
  for (const r of roots) {
39452
- if (resolved === r || resolved.startsWith(r.endsWith(sep8) ? r : r + sep8)) return resolved;
39539
+ if (resolved === r || resolved.startsWith(r.endsWith(sep9) ? r : r + sep9)) return resolved;
39453
39540
  }
39454
39541
  } catch {
39455
39542
  }
39456
39543
  return null;
39457
39544
  }
39458
39545
  function resolvedRelative(projectRoot3, resolvedPath) {
39459
- return relative9(realPathOf2(resolve17(projectRoot3)), resolvedPath);
39546
+ return relative8(realPathOf2(resolve17(projectRoot3)), resolvedPath);
39460
39547
  }
39461
39548
  function devFilesHidden(name) {
39462
39549
  if (DEV_FILES_IGNORED.has(name)) return true;
@@ -39472,10 +39559,10 @@ function devGitStatusLabel(code) {
39472
39559
  async function devGitInfo(root) {
39473
39560
  const empty = { branch: "", gitRoot: null, status: /* @__PURE__ */ new Map() };
39474
39561
  try {
39475
- const { execFileSync: execFileSync6 } = await import("node:child_process");
39562
+ const { execFileSync: execFileSync5 } = await import("node:child_process");
39476
39563
  const git = (args) => {
39477
39564
  try {
39478
- return execFileSync6("git", args, { cwd: root, timeout: 3e3, encoding: "utf-8" }).toString();
39565
+ return execFileSync5("git", args, { cwd: root, timeout: 3e3, encoding: "utf-8" }).toString();
39479
39566
  } catch {
39480
39567
  return null;
39481
39568
  }
@@ -39527,7 +39614,7 @@ function buildFileEntry(name, full, entryRel, cwdInGit, gitStatus) {
39527
39614
  let isDir = false;
39528
39615
  let size = null;
39529
39616
  try {
39530
- const st = statSync18(full);
39617
+ const st = statSync19(full);
39531
39618
  isDir = st.isDirectory();
39532
39619
  if (!isDir) size = st.size;
39533
39620
  } catch {
@@ -39602,7 +39689,7 @@ function applyMcpOutcome(res, outcome) {
39602
39689
  function renderToolbarHtml(ctx) {
39603
39690
  const nodeVersion = process.version;
39604
39691
  const method = escapeHtml2(ctx.method);
39605
- const path10 = escapeHtml2(ctx.path);
39692
+ const path9 = escapeHtml2(ctx.path);
39606
39693
  const matchedPattern = escapeHtml2(ctx.matchedPattern);
39607
39694
  const reload = ctx.reload === false ? "0" : "1";
39608
39695
  return `<link rel="stylesheet" href="/__dev/toolbar.css">
@@ -39619,7 +39706,7 @@ function renderToolbarHtml(ctx) {
39619
39706
  </div>
39620
39707
  </div>
39621
39708
  <span class="t4-green">${method}</span>
39622
- <span>${path10}</span>
39709
+ <span>${path9}</span>
39623
39710
  <span class="t4-arrow">&rarr; ${matchedPattern}</span>
39624
39711
  <span class="t4-yellow">req:${ctx.requestId}</span>
39625
39712
  <span class="t4-blue">${ctx.routeCount} routes</span>
@@ -39794,6 +39881,7 @@ var init_devAdmin = __esm({
39794
39881
  "../core/src/devAdmin.ts"() {
39795
39882
  "use strict";
39796
39883
  init_slashTrim();
39884
+ init_batchSpawn();
39797
39885
  init_devMailbox();
39798
39886
  init_upstreamResponse();
39799
39887
  init_dotenv();
@@ -39855,12 +39943,12 @@ var init_devAdmin = __esm({
39855
39943
  RequestInspector = class {
39856
39944
  static requests = [];
39857
39945
  static maxRequests = 200;
39858
- static capture(method, path10, status2, duration) {
39946
+ static capture(method, path9, status2, duration) {
39859
39947
  const entry = {
39860
39948
  id: `${Date.now()}_${this.requests.length}`,
39861
39949
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
39862
39950
  method,
39863
- path: path10,
39951
+ path: path9,
39864
39952
  status: status2,
39865
39953
  durationMs: Math.round(duration * 100) / 100
39866
39954
  };
@@ -40049,12 +40137,12 @@ var init_devAdmin = __esm({
40049
40137
  };
40050
40138
  WsTracker = class {
40051
40139
  static connections = [];
40052
- static add(remoteAddress, path10) {
40140
+ static add(remoteAddress, path9) {
40053
40141
  const conn = {
40054
40142
  id: `ws_${Date.now()}_${this.connections.length}`,
40055
40143
  connectedAt: (/* @__PURE__ */ new Date()).toISOString(),
40056
40144
  remoteAddress,
40057
- path: path10
40145
+ path: path9
40058
40146
  };
40059
40147
  this.connections.push(conn);
40060
40148
  return conn.id;
@@ -40164,7 +40252,7 @@ var init_devAdmin = __esm({
40164
40252
  const p = (url.searchParams.get("path") || "").toString();
40165
40253
  const scanRoot = metricsScanRoot();
40166
40254
  let target = p ? safeJoin(process.cwd(), p, [scanRoot]) : "";
40167
- if (target === null && scanRoot) target = safeJoin(process.cwd(), join29(scanRoot, p), [scanRoot]);
40255
+ if (target === null && scanRoot) target = safeJoin(process.cwd(), join30(scanRoot, p), [scanRoot]);
40168
40256
  if (target === null) {
40169
40257
  res.status(403).json({ error: "Path outside project" });
40170
40258
  return;
@@ -40485,16 +40573,16 @@ var init_devAdmin = __esm({
40485
40573
  failed: queue.size("failed"),
40486
40574
  reserved: queue.size("reserved")
40487
40575
  };
40488
- const topicDir = join29(queueBasePath2(), topic);
40576
+ const topicDir = join30(queueBasePath2(), topic);
40489
40577
  const jobs = [];
40490
40578
  if (!statusFilter || statusFilter === "pending") {
40491
40579
  jobs.push(...readQueueDir(topicDir, topic, "pending"));
40492
40580
  }
40493
40581
  if (!statusFilter || statusFilter === "reserved") {
40494
- jobs.push(...readQueueDir(join29(topicDir, "reserved"), topic, "reserved"));
40582
+ jobs.push(...readQueueDir(join30(topicDir, "reserved"), topic, "reserved"));
40495
40583
  }
40496
40584
  if (!statusFilter || statusFilter === "failed" || statusFilter === "dead") {
40497
- jobs.push(...readQueueDir(join29(topicDir, "failed"), topic, "dead_letter"));
40585
+ jobs.push(...readQueueDir(join30(topicDir, "failed"), topic, "dead_letter"));
40498
40586
  }
40499
40587
  res.json({ stats, jobs });
40500
40588
  } catch (e) {
@@ -40510,10 +40598,10 @@ var init_devAdmin = __esm({
40510
40598
  const { queueBasePath: queueBasePath2 } = await Promise.resolve().then(() => (init_queue(), queue_exports));
40511
40599
  const queueDir = queueBasePath2();
40512
40600
  let topics = [];
40513
- if (existsSync24(queueDir)) {
40601
+ if (existsSync25(queueDir)) {
40514
40602
  topics = readdirSync16(queueDir).filter((d) => {
40515
40603
  try {
40516
- return statSync18(join29(queueDir, d)).isDirectory();
40604
+ return statSync19(join30(queueDir, d)).isDirectory();
40517
40605
  } catch {
40518
40606
  return false;
40519
40607
  }
@@ -40798,7 +40886,7 @@ var init_devAdmin = __esm({
40798
40886
  const count = parseInt(String(body.count ?? "10"), 10) || 10;
40799
40887
  try {
40800
40888
  const orm = await Promise.resolve().then(() => (init_src(), src_exports));
40801
- const dirs = ["src/orm", "src/models"].map((d) => resolve17(process.cwd(), d)).filter((d) => existsSync24(d));
40889
+ const dirs = ["src/orm", "src/models"].map((d) => resolve17(process.cwd(), d)).filter((d) => existsSync25(d));
40802
40890
  const classes = [];
40803
40891
  for (const dir of dirs) {
40804
40892
  for (const m of await orm.discoverModels(dir)) classes.push(m.modelClass);
@@ -40939,7 +41027,7 @@ var init_devAdmin = __esm({
40939
41027
  return;
40940
41028
  }
40941
41029
  try {
40942
- const envPath = join29(process.cwd(), ".env");
41030
+ const envPath = join30(process.cwd(), ".env");
40943
41031
  const fd = openSync5(envPath, constants4.O_RDWR | constants4.O_APPEND | constants4.O_CREAT | (constants4.O_NOFOLLOW ?? 0) | (constants4.O_NONBLOCK ?? 0), 384);
40944
41032
  try {
40945
41033
  const info = fstatSync3(fd);
@@ -40983,29 +41071,29 @@ var init_devAdmin = __esm({
40983
41071
  res.json({ success: false, error: msg });
40984
41072
  }
40985
41073
  };
40986
- __devAdminFilename = fileURLToPath8(import.meta.url);
41074
+ __devAdminFilename = fileURLToPath9(import.meta.url);
40987
41075
  __devAdminDirname = dirname15(__devAdminFilename);
40988
41076
  handleGalleryList = (_req, res) => {
40989
41077
  const galleryDir = resolve17(__devAdminDirname, "..", "gallery");
40990
41078
  const items = [];
40991
- if (existsSync24(galleryDir)) {
41079
+ if (existsSync25(galleryDir)) {
40992
41080
  const entries = readdirSync16(galleryDir).sort();
40993
41081
  for (const entry of entries) {
40994
- const entryPath = join29(galleryDir, entry);
40995
- const metaFile = join29(entryPath, "meta.json");
40996
- if (statSync18(entryPath).isDirectory() && existsSync24(metaFile)) {
41082
+ const entryPath = join30(galleryDir, entry);
41083
+ const metaFile = join30(entryPath, "meta.json");
41084
+ if (statSync19(entryPath).isDirectory() && existsSync25(metaFile)) {
40997
41085
  try {
40998
41086
  const meta = JSON.parse(readFileSync20(metaFile, "utf-8"));
40999
41087
  meta.id = entry;
41000
- const srcDir = join29(entryPath, "src");
41001
- if (existsSync24(srcDir)) {
41088
+ const srcDir = join30(entryPath, "src");
41089
+ if (existsSync25(srcDir)) {
41002
41090
  const allFiles = walkDirRecursive(srcDir);
41003
- meta.files = allFiles.map((f) => relative9(srcDir, f));
41091
+ meta.files = allFiles.map((f) => relative8(srcDir, f));
41004
41092
  }
41005
41093
  const projectSrc = resolve17(process.cwd(), "src");
41006
- if (existsSync24(srcDir) && meta.files) {
41094
+ if (existsSync25(srcDir) && meta.files) {
41007
41095
  meta.deployed = meta.files.every(
41008
- (f) => existsSync24(join29(projectSrc, f))
41096
+ (f) => existsSync25(join30(projectSrc, f))
41009
41097
  );
41010
41098
  } else {
41011
41099
  meta.deployed = false;
@@ -41082,7 +41170,7 @@ var init_devAdmin = __esm({
41082
41170
  const root = resolve17(process.cwd());
41083
41171
  const target = safeJoin(root, rel);
41084
41172
  const { branch, gitRoot, status: gitStatus } = await devGitInfo(root);
41085
- if (!target || !existsSync24(target) || !statSync18(target).isDirectory()) {
41173
+ if (!target || !existsSync25(target) || !statSync19(target).isDirectory()) {
41086
41174
  res.json({ path: rel, branch, entries: [], error: "not a directory" });
41087
41175
  return;
41088
41176
  }
@@ -41095,12 +41183,12 @@ var init_devAdmin = __esm({
41095
41183
  const entries = [];
41096
41184
  for (const name of readdirSync16(target).sort()) {
41097
41185
  if (devFilesHidden(name)) continue;
41098
- const full = join29(target, name);
41099
- const entryRel = relative9(root, full).replace(/\\/g, "/");
41186
+ const full = join30(target, name);
41187
+ const entryRel = relative8(root, full).replace(/\\/g, "/");
41100
41188
  if (isSecretPath(entryRel)) continue;
41101
41189
  entries.push(buildFileEntry(name, full, entryRel, cwdInGit, gitStatus));
41102
41190
  }
41103
- res.json({ path: relative9(root, target).replace(/\\/g, "/") || ".", branch, entries });
41191
+ res.json({ path: relative8(root, target).replace(/\\/g, "/") || ".", branch, entries });
41104
41192
  };
41105
41193
  DEV_ADMIN_LANG_MAP = {
41106
41194
  ".py": "python",
@@ -41158,8 +41246,8 @@ var init_devAdmin = __esm({
41158
41246
  return;
41159
41247
  }
41160
41248
  const content = data.toString("utf-8");
41161
- const path10 = relative9(root, target);
41162
- res.json({ path: path10, content, language: devAdminLanguage(path10), bytes: Buffer.byteLength(content, "utf-8") });
41249
+ const path9 = relative8(root, target);
41250
+ res.json({ path: path9, content, language: devAdminLanguage(path9), bytes: Buffer.byteLength(content, "utf-8") });
41163
41251
  } catch (e) {
41164
41252
  res.json({ error: e.message }, 500);
41165
41253
  }
@@ -41176,14 +41264,14 @@ var init_devAdmin = __esm({
41176
41264
  }
41177
41265
  try {
41178
41266
  mkdirSync19(dirname15(target), { recursive: true });
41179
- const existed = existsSync24(target);
41267
+ const existed = existsSync25(target);
41180
41268
  writeFileSync16(target, content, "utf-8");
41181
41269
  try {
41182
41270
  const { Plan: Plan2 } = await Promise.resolve().then(() => (init_plan(), plan_exports));
41183
- Plan2.recordAction(existed ? "patched" : "created", relative9(root, target));
41271
+ Plan2.recordAction(existed ? "patched" : "created", relative8(root, target));
41184
41272
  } catch {
41185
41273
  }
41186
- res.json({ ok: true, path: relative9(root, target), bytes: Buffer.byteLength(content, "utf-8") });
41274
+ res.json({ ok: true, path: relative8(root, target), bytes: Buffer.byteLength(content, "utf-8") });
41187
41275
  } catch (e) {
41188
41276
  res.json({ error: e.message }, 500);
41189
41277
  }
@@ -41241,7 +41329,7 @@ var init_devAdmin = __esm({
41241
41329
  res.json({ error: "Invalid path" }, 400);
41242
41330
  return;
41243
41331
  }
41244
- if (!existsSync24(src)) {
41332
+ if (!existsSync25(src)) {
41245
41333
  res.json({ error: `Source not found: ${from}` }, 404);
41246
41334
  return;
41247
41335
  }
@@ -41249,7 +41337,7 @@ var init_devAdmin = __esm({
41249
41337
  const { renameSync: renameSync3 } = await import("node:fs");
41250
41338
  mkdirSync19(dirname15(dst), { recursive: true });
41251
41339
  renameSync3(src, dst);
41252
- res.json({ ok: true, from: relative9(root, src), to: relative9(root, dst) });
41340
+ res.json({ ok: true, from: relative8(root, src), to: relative8(root, dst) });
41253
41341
  } catch (e) {
41254
41342
  res.json({ error: e.message }, 500);
41255
41343
  }
@@ -41263,14 +41351,14 @@ var init_devAdmin = __esm({
41263
41351
  res.json({ error: "Invalid path" }, 400);
41264
41352
  return;
41265
41353
  }
41266
- if (!existsSync24(target)) {
41354
+ if (!existsSync25(target)) {
41267
41355
  res.json({ error: `Not found: ${rel}` }, 404);
41268
41356
  return;
41269
41357
  }
41270
41358
  try {
41271
41359
  const { rmSync: rmSync2 } = await import("node:fs");
41272
41360
  rmSync2(target, { recursive: true, force: true });
41273
- res.json({ ok: true, deleted: relative9(root, target) });
41361
+ res.json({ ok: true, deleted: relative8(root, target) });
41274
41362
  } catch (e) {
41275
41363
  res.json({ error: e.message }, 500);
41276
41364
  }
@@ -41305,13 +41393,11 @@ var init_devAdmin = __esm({
41305
41393
  return;
41306
41394
  }
41307
41395
  try {
41308
- const { execFileSync: execFileSync6 } = await import("node:child_process");
41309
41396
  const args = ["install", dev ? "--save-dev" : "--save", pkg];
41310
- const output = execFileSync6("npm", args, {
41397
+ const output = execFileSyncAllowingBatch("npm", args, {
41311
41398
  cwd: resolve17(process.cwd()),
41312
- timeout: 12e4,
41313
- encoding: "utf-8"
41314
- }).toString();
41399
+ timeout: 12e4
41400
+ });
41315
41401
  res.json({ ok: true, package: pkg, output });
41316
41402
  } catch (e) {
41317
41403
  res.json({ error: e.message }, 500);
@@ -41319,15 +41405,15 @@ var init_devAdmin = __esm({
41319
41405
  };
41320
41406
  handleGitStatus = async (_req, res) => {
41321
41407
  try {
41322
- const { execFileSync: execFileSync6 } = await import("node:child_process");
41408
+ const { execFileSync: execFileSync5 } = await import("node:child_process");
41323
41409
  const cwd = resolve17(process.cwd());
41324
41410
  try {
41325
- execFileSync6("git", ["rev-parse", "--is-inside-work-tree"], { cwd, timeout: 3e3 });
41411
+ execFileSync5("git", ["rev-parse", "--is-inside-work-tree"], { cwd, timeout: 3e3 });
41326
41412
  } catch {
41327
41413
  res.json({ error: "Not a git repository" }, 400);
41328
41414
  return;
41329
41415
  }
41330
- const run = (args) => execFileSync6("git", args, { cwd, timeout: 3e3, encoding: "utf-8" }).toString().trim();
41416
+ const run = (args) => execFileSync5("git", args, { cwd, timeout: 3e3, encoding: "utf-8" }).toString().trim();
41331
41417
  res.json({
41332
41418
  branch: run(["branch", "--show-current"]),
41333
41419
  status: run(["status", "--porcelain"]).split(/\r?\n/).filter((l) => l),
@@ -41457,12 +41543,10 @@ var init_devAdmin = __esm({
41457
41543
  return;
41458
41544
  }
41459
41545
  try {
41460
- const { execFileSync: execFileSync6 } = await import("node:child_process");
41461
- const output = execFileSync6("npx", ["tina4nodejs", "generate", kind, name], {
41546
+ const output = execFileSyncAllowingBatch("npx", ["tina4nodejs", "generate", kind, name], {
41462
41547
  cwd: resolve17(process.cwd()),
41463
- timeout: 3e4,
41464
- encoding: "utf-8"
41465
- }).toString();
41548
+ timeout: 3e4
41549
+ });
41466
41550
  res.json({ ok: true, kind, name, output });
41467
41551
  } catch (e) {
41468
41552
  res.json({ error: e.message }, 500);
@@ -41604,21 +41688,21 @@ var init_devAdmin = __esm({
41604
41688
  });
41605
41689
  };
41606
41690
  handleDevAdminJs = async (_req, res) => {
41607
- const { readFileSync: readFileSync30, existsSync: existsSync38 } = await import("node:fs");
41608
- const { dirname: dirname20, join: join41, resolve: resolve29 } = await import("node:path");
41609
- const { fileURLToPath: fileURLToPath12 } = await import("node:url");
41610
- const dir = dirname20(fileURLToPath12(import.meta.url));
41691
+ const { readFileSync: readFileSync30, existsSync: existsSync39 } = await import("node:fs");
41692
+ const { dirname: dirname20, join: join42, resolve: resolve29 } = await import("node:path");
41693
+ const { fileURLToPath: fileURLToPath13 } = await import("node:url");
41694
+ const dir = dirname20(fileURLToPath13(import.meta.url));
41611
41695
  const candidates = [
41612
- join41(dir, "..", "public", "js", "tina4-dev-admin.min.js"),
41696
+ join42(dir, "..", "public", "js", "tina4-dev-admin.min.js"),
41613
41697
  // src/../public/js/
41614
- join41(dir, "..", "..", "public", "js", "tina4-dev-admin.min.js"),
41698
+ join42(dir, "..", "..", "public", "js", "tina4-dev-admin.min.js"),
41615
41699
  // deeper nesting
41616
41700
  resolve29(process.cwd(), "node_modules", "tina4-nodejs", "packages", "core", "public", "js", "tina4-dev-admin.min.js"),
41617
41701
  resolve29(process.cwd(), "public", "js", "tina4-dev-admin.min.js")
41618
41702
  // project public/
41619
41703
  ];
41620
41704
  for (const jsPath of candidates) {
41621
- if (existsSync38(jsPath)) {
41705
+ if (existsSync39(jsPath)) {
41622
41706
  try {
41623
41707
  const content = readFileSync30(jsPath, "utf-8");
41624
41708
  res.raw.writeHead(200, { "Content-Type": "application/javascript; charset=utf-8", "Cache-Control": "no-cache" });
@@ -41632,20 +41716,20 @@ var init_devAdmin = __esm({
41632
41716
  res.raw.end("tina4-dev-admin.min.js not found");
41633
41717
  };
41634
41718
  handleDevAdminSplit = async (_req, res) => {
41635
- const { readFileSync: readFileSync30, existsSync: existsSync38 } = await import("node:fs");
41636
- const { dirname: dirname20, join: join41, resolve: resolve29 } = await import("node:path");
41637
- const { fileURLToPath: fileURLToPath12 } = await import("node:url");
41638
- const dir = dirname20(fileURLToPath12(import.meta.url));
41719
+ const { readFileSync: readFileSync30, existsSync: existsSync39 } = await import("node:fs");
41720
+ const { dirname: dirname20, join: join42, resolve: resolve29 } = await import("node:path");
41721
+ const { fileURLToPath: fileURLToPath13 } = await import("node:url");
41722
+ const dir = dirname20(fileURLToPath13(import.meta.url));
41639
41723
  const candidates = [
41640
- join41(dir, "..", "public", "js", "tina4-dev-admin-split.html"),
41641
- join41(dir, "..", "..", "public", "js", "tina4-dev-admin-split.html"),
41724
+ join42(dir, "..", "public", "js", "tina4-dev-admin-split.html"),
41725
+ join42(dir, "..", "..", "public", "js", "tina4-dev-admin-split.html"),
41642
41726
  resolve29(process.cwd(), "node_modules", "tina4-nodejs", "packages", "core", "public", "js", "tina4-dev-admin-split.html"),
41643
41727
  resolve29(process.cwd(), "public", "js", "tina4-dev-admin-split.html")
41644
41728
  ];
41645
- for (const path10 of candidates) {
41646
- if (existsSync38(path10)) {
41729
+ for (const path9 of candidates) {
41730
+ if (existsSync39(path9)) {
41647
41731
  try {
41648
- const content = readFileSync30(path10, "utf-8");
41732
+ const content = readFileSync30(path9, "utf-8");
41649
41733
  res.raw.writeHead(200, { "Content-Type": "text/html; charset=utf-8", "Cache-Control": "no-cache" });
41650
41734
  res.raw.end(content);
41651
41735
  return;
@@ -41668,8 +41752,8 @@ var init_devAdmin = __esm({
41668
41752
  });
41669
41753
 
41670
41754
  // ../core/src/i18n.ts
41671
- import { readFileSync as readFileSync21, readdirSync as readdirSync17, existsSync as existsSync25 } from "node:fs";
41672
- import { join as join30, resolve as resolve18 } from "node:path";
41755
+ import { readFileSync as readFileSync21, readdirSync as readdirSync17, existsSync as existsSync26 } from "node:fs";
41756
+ import { join as join31, resolve as resolve18 } from "node:path";
41673
41757
  var I18n;
41674
41758
  var init_i18n = __esm({
41675
41759
  "../core/src/i18n.ts"() {
@@ -41688,9 +41772,9 @@ var init_i18n = __esm({
41688
41772
  * Arg order is (locale, path) to match the Python master `I18n(locale, path)`
41689
41773
  * (BUG-7, BREAKING in 3.13.x — was previously (localeDir, defaultLocale)).
41690
41774
  */
41691
- constructor(locale, path10) {
41775
+ constructor(locale, path9) {
41692
41776
  this._localeDir = resolve18(
41693
- path10 ?? process.env.TINA4_LOCALE_DIR ?? "src/locales"
41777
+ path9 ?? process.env.TINA4_LOCALE_DIR ?? "src/locales"
41694
41778
  );
41695
41779
  this._defaultLocale = locale ?? process.env.TINA4_LOCALE ?? "en";
41696
41780
  this._currentLocale = this._defaultLocale;
@@ -41746,7 +41830,7 @@ var init_i18n = __esm({
41746
41830
  }
41747
41831
  /** List available locale codes based on JSON files in the locale directory. */
41748
41832
  availableLocales() {
41749
- if (!existsSync25(this._localeDir)) {
41833
+ if (!existsSync26(this._localeDir)) {
41750
41834
  return [this._defaultLocale];
41751
41835
  }
41752
41836
  try {
@@ -41762,8 +41846,8 @@ var init_i18n = __esm({
41762
41846
  if (this._translations.has(locale)) {
41763
41847
  return;
41764
41848
  }
41765
- const filePath = join30(this._localeDir, `${locale}.json`);
41766
- if (existsSync25(filePath)) {
41849
+ const filePath = join31(this._localeDir, `${locale}.json`);
41850
+ if (existsSync26(filePath)) {
41767
41851
  try {
41768
41852
  const raw = readFileSync21(filePath, "utf-8");
41769
41853
  const data = JSON.parse(raw);
@@ -41775,8 +41859,8 @@ var init_i18n = __esm({
41775
41859
  }
41776
41860
  }
41777
41861
  for (const ext of [".yml", ".yaml"]) {
41778
- const yamlPath = join30(this._localeDir, `${locale}${ext}`);
41779
- if (existsSync25(yamlPath)) {
41862
+ const yamlPath = join31(this._localeDir, `${locale}${ext}`);
41863
+ if (existsSync26(yamlPath)) {
41780
41864
  try {
41781
41865
  const raw = readFileSync21(yamlPath, "utf-8");
41782
41866
  const data = _I18n._parseSimpleYaml(raw);
@@ -43301,11 +43385,11 @@ __export(docsAutoDiscovery_exports, {
43301
43385
  writeMcpDiscovery: () => writeMcpDiscovery
43302
43386
  });
43303
43387
  import * as fs9 from "node:fs";
43304
- import * as path9 from "node:path";
43388
+ import * as path8 from "node:path";
43305
43389
  function writeMcpDiscovery(projectRoot3, port) {
43306
- const root = path9.resolve(projectRoot3);
43307
- const tinaDir = path9.join(root, TINA4_DIR);
43308
- const mcpPath = path9.join(tinaDir, MCP_FILE);
43390
+ const root = path8.resolve(projectRoot3);
43391
+ const tinaDir = path8.join(root, TINA4_DIR);
43392
+ const mcpPath = path8.join(tinaDir, MCP_FILE);
43309
43393
  const portStr = String(
43310
43394
  port || Number(process.env.TINA4_PORT) || Number(process.env.PORT) || 7148
43311
43395
  );
@@ -43332,9 +43416,9 @@ function writeMcpDiscovery(projectRoot3, port) {
43332
43416
  fs9.writeFileSync(mcpPath, desiredJson, "utf-8");
43333
43417
  wrote = true;
43334
43418
  }
43335
- const gitDir = path9.join(root, ".git");
43419
+ const gitDir = path8.join(root, ".git");
43336
43420
  if (fs9.existsSync(gitDir)) {
43337
- const gitignorePath = path9.join(root, ".gitignore");
43421
+ const gitignorePath = path8.join(root, ".gitignore");
43338
43422
  let contents = "";
43339
43423
  if (fs9.existsSync(gitignorePath)) {
43340
43424
  try {
@@ -43345,8 +43429,8 @@ function writeMcpDiscovery(projectRoot3, port) {
43345
43429
  const lines = contents.split(/\r?\n/);
43346
43430
  const already = lines.some((l) => l.trim() === GITIGNORE_LINE || l.trim() === ".tina4");
43347
43431
  if (!already) {
43348
- const sep9 = contents.endsWith("\n") || contents === "" ? "" : "\n";
43349
- fs9.writeFileSync(gitignorePath, `${contents}${sep9}${GITIGNORE_LINE}
43432
+ const sep10 = contents.endsWith("\n") || contents === "" ? "" : "\n";
43433
+ fs9.writeFileSync(gitignorePath, `${contents}${sep10}${GITIGNORE_LINE}
43350
43434
  `, "utf-8");
43351
43435
  }
43352
43436
  }
@@ -43391,11 +43475,11 @@ __export(server_exports, {
43391
43475
  templateAutoRoutingEnabled: () => templateAutoRoutingEnabled
43392
43476
  });
43393
43477
  import { randomBytes as randomBytes9 } from "node:crypto";
43394
- import { resolve as resolve20, dirname as dirname16, join as join32, relative as relative10 } from "node:path";
43395
- import { existsSync as existsSync27, readdirSync as readdirSync18, readFileSync as readFileSync23, statSync as statSync19 } from "node:fs";
43478
+ import { resolve as resolve20, dirname as dirname16, join as join33, relative as relative9 } from "node:path";
43479
+ import { existsSync as existsSync28, readdirSync as readdirSync18, readFileSync as readFileSync23, statSync as statSync20 } from "node:fs";
43396
43480
  import { isatty } from "node:tty";
43397
- import { fileURLToPath as fileURLToPath9 } from "node:url";
43398
- import { execFileSync as execFileSync3, execFile } from "node:child_process";
43481
+ import { fileURLToPath as fileURLToPath10 } from "node:url";
43482
+ import { execFile } from "node:child_process";
43399
43483
  import cluster from "node:cluster";
43400
43484
  import os2 from "node:os";
43401
43485
  function isSwaggerAssetPath(pathname) {
@@ -43457,7 +43541,7 @@ function reportOrmBootFailure(stage, err, dbConfig) {
43457
43541
  }
43458
43542
  async function autoMigrateOnStartup(migrationDir = "migrations", base = process.cwd()) {
43459
43543
  const dir = resolve20(base, migrationDir);
43460
- if (!existsSync27(dir)) return;
43544
+ if (!existsSync28(dir)) return;
43461
43545
  let hasSql = false;
43462
43546
  try {
43463
43547
  hasSql = readdirSync18(dir).some((f) => f.endsWith(".sql") && !f.endsWith(".down.sql"));
@@ -43547,17 +43631,8 @@ function killPort(port) {
43547
43631
  }
43548
43632
  }
43549
43633
  function findAvailablePort(start2) {
43550
- try {
43551
- execFileSync3(process.execPath, ["-e", `
43552
- const s = require("net").createServer();
43553
- s.listen(${start2}, "0.0.0.0", () => { s.close(); process.exit(0); });
43554
- s.on("error", () => process.exit(1));
43555
- `], { timeout: 1e3 });
43556
- return start2;
43557
- } catch {
43558
- killPort(start2);
43559
- return start2;
43560
- }
43634
+ if (probeBind("0.0.0.0", start2) === "held") killPort(start2);
43635
+ return start2;
43561
43636
  }
43562
43637
  function shouldOpenBrowser(isDevelopment, noBrowser = false) {
43563
43638
  if (!isDevelopment || isTruthy(process.env.TINA4_PRODUCTION) || cluster.isWorker) return false;
@@ -43619,12 +43694,12 @@ async function renderErrorPage(code, data, templatesDir) {
43619
43694
  }
43620
43695
  return instance;
43621
43696
  };
43622
- const userTemplatePath = join32(templatesDir, templateFile);
43623
- if (existsSync27(userTemplatePath)) {
43697
+ const userTemplatePath = join33(templatesDir, templateFile);
43698
+ if (existsSync28(userTemplatePath)) {
43624
43699
  return getCachedFrond(templatesDir).render(templateFile, data);
43625
43700
  }
43626
- const builtinTemplatePath = join32(BUILTIN_ERROR_TEMPLATES_DIR, templateFile);
43627
- if (existsSync27(builtinTemplatePath)) {
43701
+ const builtinTemplatePath = join33(BUILTIN_ERROR_TEMPLATES_DIR, templateFile);
43702
+ if (existsSync28(builtinTemplatePath)) {
43628
43703
  return getCachedFrond(BUILTIN_ERROR_TEMPLATES_DIR).render(templateFile, data);
43629
43704
  }
43630
43705
  return null;
@@ -43641,10 +43716,10 @@ function injectDevToolbar(html, ctx) {
43641
43716
  }
43642
43717
  function walkGalleryFiles(dir) {
43643
43718
  const results = [];
43644
- if (!existsSync27(dir)) return results;
43719
+ if (!existsSync28(dir)) return results;
43645
43720
  for (const f of readdirSync18(dir)) {
43646
- const full = join32(dir, f);
43647
- if (statSync19(full).isDirectory()) results.push(...walkGalleryFiles(full));
43721
+ const full = join33(dir, f);
43722
+ if (statSync20(full).isDirectory()) results.push(...walkGalleryFiles(full));
43648
43723
  else results.push(full);
43649
43724
  }
43650
43725
  return results;
@@ -43652,18 +43727,18 @@ function walkGalleryFiles(dir) {
43652
43727
  function getGalleryDeployedState() {
43653
43728
  const galleryDir = resolve20(__dirname, "..", "gallery");
43654
43729
  const state = {};
43655
- if (!existsSync27(galleryDir)) return state;
43730
+ if (!existsSync28(galleryDir)) return state;
43656
43731
  try {
43657
43732
  const entries = readdirSync18(galleryDir).sort();
43658
43733
  for (const entry of entries) {
43659
- const entryPath = join32(galleryDir, entry);
43660
- const metaFile = join32(entryPath, "meta.json");
43661
- if (statSync19(entryPath).isDirectory() && existsSync27(metaFile)) {
43662
- const srcDir = join32(entryPath, "src");
43663
- if (existsSync27(srcDir)) {
43734
+ const entryPath = join33(galleryDir, entry);
43735
+ const metaFile = join33(entryPath, "meta.json");
43736
+ if (statSync20(entryPath).isDirectory() && existsSync28(metaFile)) {
43737
+ const srcDir = join33(entryPath, "src");
43738
+ if (existsSync28(srcDir)) {
43664
43739
  const files = walkGalleryFiles(srcDir);
43665
43740
  const projectSrc = resolve20(process.cwd(), "src");
43666
- state[entry] = files.every((f) => existsSync27(join32(projectSrc, relative10(srcDir, f))));
43741
+ state[entry] = files.every((f) => existsSync28(join33(projectSrc, relative9(srcDir, f))));
43667
43742
  } else {
43668
43743
  state[entry] = false;
43669
43744
  }
@@ -43694,7 +43769,7 @@ function resolveTemplate(pathname, templatesDir) {
43694
43769
  if (cleanPath.includes("\\") || cleanPath.split("/").some((seg) => seg === "" || seg === "." || seg === "..")) return null;
43695
43770
  const pagesDir = resolve20(templatesDir, TEMPLATE_PAGES_DIR);
43696
43771
  for (const ext of [".twig", ".html"]) {
43697
- if (existsSync27(resolve20(pagesDir, cleanPath + ext))) {
43772
+ if (existsSync28(resolve20(pagesDir, cleanPath + ext))) {
43698
43773
  return `${TEMPLATE_PAGES_DIR}/${cleanPath}${ext}`;
43699
43774
  }
43700
43775
  }
@@ -43703,7 +43778,7 @@ function resolveTemplate(pathname, templatesDir) {
43703
43778
  if (!templateCache) {
43704
43779
  templateCache = /* @__PURE__ */ new Map();
43705
43780
  const pagesDir = resolve20(templatesDir, TEMPLATE_PAGES_DIR);
43706
- if (existsSync27(pagesDir)) {
43781
+ if (existsSync28(pagesDir)) {
43707
43782
  const scan = (dir, prefix) => {
43708
43783
  for (const entry of readdirSync18(dir, { withFileTypes: true })) {
43709
43784
  if (entry.name.startsWith("_")) continue;
@@ -44171,9 +44246,9 @@ function serveMethodNotAllowed(ctx) {
44171
44246
  }
44172
44247
  function serveStaticAsset(ctx) {
44173
44248
  const custom = process.env.TINA4_PUBLIC_DIR;
44174
- if (custom && existsSync27(custom) && tryServeStatic(custom, ctx.req, ctx.res)) return true;
44175
- if (existsSync27(ctx.staticDir) && tryServeStatic(ctx.staticDir, ctx.req, ctx.res)) return true;
44176
- if (existsSync27(ctx.srcPublicDir) && tryServeStatic(ctx.srcPublicDir, ctx.req, ctx.res)) return true;
44249
+ if (custom && existsSync28(custom) && tryServeStatic(custom, ctx.req, ctx.res)) return true;
44250
+ if (existsSync28(ctx.staticDir) && tryServeStatic(ctx.staticDir, ctx.req, ctx.res)) return true;
44251
+ if (existsSync28(ctx.srcPublicDir) && tryServeStatic(ctx.srcPublicDir, ctx.req, ctx.res)) return true;
44177
44252
  if (ctx.swaggerAssetsEnabled || !isSwaggerAssetPath(ctx.pathname)) {
44178
44253
  if (tryServeStatic(BUILTIN_PUBLIC_DIR, ctx.req, ctx.res)) return true;
44179
44254
  }
@@ -44387,6 +44462,9 @@ function startProductionCluster(port, host) {
44387
44462
  Debug: OFF (Log level: ${logLevel})
44388
44463
  ${reset2}`);
44389
44464
  }
44465
+ if (process.env.NODE_CLUSTER_SCHED_POLICY === void 0) {
44466
+ cluster.schedulingPolicy = cluster.SCHED_RR;
44467
+ }
44390
44468
  for (let i = 0; i < numCPUs; i++) cluster.fork();
44391
44469
  cluster.on("exit", (worker, code) => {
44392
44470
  if (code !== 0) {
@@ -44406,7 +44484,7 @@ ${reset2}`);
44406
44484
  function wireLocaleGlobal(frondEngine, base) {
44407
44485
  if (!frondEngine) return;
44408
44486
  const localeDir = resolve20(base, process.env.TINA4_LOCALE_DIR ?? "src/locales");
44409
- if (!existsSync27(localeDir)) return;
44487
+ if (!existsSync28(localeDir)) return;
44410
44488
  try {
44411
44489
  const localeFiles = readdirSync18(localeDir).filter((file) => file.endsWith(".json"));
44412
44490
  const FrondClass = frondEngine.constructor;
@@ -44479,7 +44557,7 @@ async function startServer(config) {
44479
44557
  middleware.use(requestLogger());
44480
44558
  middleware.use(rateLimiter());
44481
44559
  MiddlewareRunner.use(SecurityHeadersMiddleware);
44482
- if (existsSync27(routesDir)) {
44560
+ if (existsSync28(routesDir)) {
44483
44561
  const routes = await discoverRoutes(routesDir);
44484
44562
  for (const route of routes) {
44485
44563
  router.addRoute(route);
@@ -44742,8 +44820,8 @@ ${reset2}
44742
44820
  });
44743
44821
  }
44744
44822
  async function initializeOrm(config, router, base, ormDir, modelsDir) {
44745
- const hasOrmDir = existsSync27(ormDir);
44746
- const hasModelsDir = existsSync27(modelsDir);
44823
+ const hasOrmDir = existsSync28(ormDir);
44824
+ const hasModelsDir = existsSync28(modelsDir);
44747
44825
  if (hasOrmDir || hasModelsDir) {
44748
44826
  let ormStage = "import";
44749
44827
  const dbConfig = config?.database ?? {};
@@ -44806,7 +44884,7 @@ async function configureSwagger(router, ormDir, modelsDir) {
44806
44884
  let modelDefs = [];
44807
44885
  try {
44808
44886
  const orm = await Promise.resolve().then(() => (init_src(), src_exports));
44809
- const allModelDirs = [ormDir, modelsDir].filter((d) => existsSync27(d));
44887
+ const allModelDirs = [ormDir, modelsDir].filter((d) => existsSync28(d));
44810
44888
  const seenTables = /* @__PURE__ */ new Set();
44811
44889
  for (const dir of allModelDirs) {
44812
44890
  const discovered = await orm.discoverModels(dir);
@@ -44857,7 +44935,7 @@ var init_server = __esm({
44857
44935
  init_background();
44858
44936
  init_tcp();
44859
44937
  init_version();
44860
- __filename = fileURLToPath9(import.meta.url);
44938
+ __filename = fileURLToPath10(import.meta.url);
44861
44939
  __dirname = dirname16(__filename);
44862
44940
  BUILTIN_ERROR_TEMPLATES_DIR = resolve20(__dirname, "..", "templates");
44863
44941
  BUILTIN_PUBLIC_DIR = resolve20(__dirname, "..", "public");
@@ -45099,7 +45177,7 @@ var init_mqttMessage = __esm({
45099
45177
  import net3 from "node:net";
45100
45178
  import tls from "node:tls";
45101
45179
  import { randomBytes as randomBytes10 } from "node:crypto";
45102
- import { existsSync as existsSync28, readFileSync as readFileSync24 } from "node:fs";
45180
+ import { existsSync as existsSync29, readFileSync as readFileSync24 } from "node:fs";
45103
45181
  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;
45104
45182
  var init_mqtt = __esm({
45105
45183
  "../core/src/mqtt.ts"() {
@@ -45302,7 +45380,7 @@ var init_mqtt = __esm({
45302
45380
  */
45303
45381
  async connect() {
45304
45382
  this.closeSocket();
45305
- if (this.secure && this.tlsVerify && this.caFile && !existsSync28(this.caFile)) {
45383
+ if (this.secure && this.tlsVerify && this.caFile && !existsSync29(this.caFile)) {
45306
45384
  throw new MqttError(
45307
45385
  `MQTT CA file not found: ${this.caFile} -- TINA4_MQTT_CA_FILE (or caFile) must point at the broker's CA certificate in PEM form`
45308
45386
  );
@@ -45784,9 +45862,9 @@ var init_mqtt = __esm({
45784
45862
  });
45785
45863
 
45786
45864
  // ../core/src/service.ts
45787
- import { readdirSync as readdirSync19, statSync as statSync20, watchFile, unwatchFile } from "node:fs";
45788
- import { join as join33, extname as extname8 } from "node:path";
45789
- import { pathToFileURL } from "node:url";
45865
+ import { readdirSync as readdirSync19, statSync as statSync21, watchFile, unwatchFile } from "node:fs";
45866
+ import { join as join34, extname as extname9 } from "node:path";
45867
+ import { pathToFileURL as pathToFileURL4 } from "node:url";
45790
45868
  function matchCronField(field, value) {
45791
45869
  if (field === "*") return true;
45792
45870
  if (field.includes("/")) {
@@ -45957,13 +46035,13 @@ var init_service = __esm({
45957
46035
  return discovered;
45958
46036
  }
45959
46037
  for (const entry of entries) {
45960
- const ext = extname8(entry);
46038
+ const ext = extname9(entry);
45961
46039
  if (ext !== ".ts" && ext !== ".js") continue;
45962
- const fullPath = join33(dir, entry);
45963
- const stat = statSync20(fullPath);
46040
+ const fullPath = join34(dir, entry);
46041
+ const stat = statSync21(fullPath);
45964
46042
  if (!stat.isFile()) continue;
45965
46043
  try {
45966
- const fileUrl = pathToFileURL(fullPath).href;
46044
+ const fileUrl = pathToFileURL4(fullPath).href;
45967
46045
  const mod = await import(fileUrl);
45968
46046
  const exp = mod.default ?? mod;
45969
46047
  if (exp.name && typeof exp.handler === "function") {
@@ -46084,13 +46162,13 @@ var init_service = __esm({
46084
46162
  return;
46085
46163
  }
46086
46164
  for (const entry of entries) {
46087
- const ext = extname8(entry);
46165
+ const ext = extname9(entry);
46088
46166
  if (ext !== ".ts" && ext !== ".js") continue;
46089
- const fullPath = join33(dir, entry);
46167
+ const fullPath = join34(dir, entry);
46090
46168
  if (watchedFiles.has(fullPath)) continue;
46091
46169
  watchedFiles.add(fullPath);
46092
46170
  watchFile(fullPath, { interval: 1e3 }, async () => {
46093
- const fileUrl = pathToFileURL(fullPath).href;
46171
+ const fileUrl = pathToFileURL4(fullPath).href;
46094
46172
  try {
46095
46173
  const mod = await import(fileUrl + "?t=" + Date.now());
46096
46174
  const exp = mod.default ?? mod;
@@ -46353,23 +46431,23 @@ function guessContentType(filename) {
46353
46431
  }
46354
46432
  function buildMultipartBody(boundary, fieldName, filename, fileContent, contentType, extraFields) {
46355
46433
  const crlf = "\r\n";
46356
- const delimiter4 = `--${boundary}`;
46434
+ const delimiter5 = `--${boundary}`;
46357
46435
  const parts = [];
46358
46436
  if (extraFields) {
46359
46437
  for (const [key, value] of Object.entries(extraFields)) {
46360
- parts.push(Buffer.from(delimiter4 + crlf, "utf-8"));
46438
+ parts.push(Buffer.from(delimiter5 + crlf, "utf-8"));
46361
46439
  parts.push(Buffer.from(`Content-Disposition: form-data; name="${key}"` + crlf + crlf, "utf-8"));
46362
46440
  parts.push(Buffer.from(String(value) + crlf, "utf-8"));
46363
46441
  }
46364
46442
  }
46365
- parts.push(Buffer.from(delimiter4 + crlf, "utf-8"));
46443
+ parts.push(Buffer.from(delimiter5 + crlf, "utf-8"));
46366
46444
  parts.push(
46367
46445
  Buffer.from(`Content-Disposition: form-data; name="${fieldName}"; filename="${filename}"` + crlf, "utf-8")
46368
46446
  );
46369
46447
  parts.push(Buffer.from(`Content-Type: ${contentType}` + crlf + crlf, "utf-8"));
46370
46448
  parts.push(fileContent);
46371
46449
  parts.push(Buffer.from(crlf, "utf-8"));
46372
- parts.push(Buffer.from(delimiter4 + "--" + crlf, "utf-8"));
46450
+ parts.push(Buffer.from(delimiter5 + "--" + crlf, "utf-8"));
46373
46451
  return Buffer.concat(parts);
46374
46452
  }
46375
46453
  async function* parseLineStream(chunks) {
@@ -46616,8 +46694,8 @@ var init_api = __esm({
46616
46694
  /**
46617
46695
  * HTTP GET request.
46618
46696
  */
46619
- async get(path10, params) {
46620
- let url = this.buildUrl(path10);
46697
+ async get(path9, params) {
46698
+ let url = this.buildUrl(path9);
46621
46699
  if (params && Object.keys(params).length > 0) {
46622
46700
  const qs = new URLSearchParams(params).toString();
46623
46701
  url += (url.includes("?") ? "&" : "?") + qs;
@@ -46627,32 +46705,32 @@ var init_api = __esm({
46627
46705
  /**
46628
46706
  * HTTP POST request.
46629
46707
  */
46630
- async post(path10, body, contentType = "application/json") {
46631
- return this.sendRequest("POST", path10, body, contentType);
46708
+ async post(path9, body, contentType = "application/json") {
46709
+ return this.sendRequest("POST", path9, body, contentType);
46632
46710
  }
46633
46711
  /**
46634
46712
  * HTTP PUT request.
46635
46713
  */
46636
- async put(path10, body, contentType = "application/json") {
46637
- return this.sendRequest("PUT", path10, body, contentType);
46714
+ async put(path9, body, contentType = "application/json") {
46715
+ return this.sendRequest("PUT", path9, body, contentType);
46638
46716
  }
46639
46717
  /**
46640
46718
  * HTTP PATCH request.
46641
46719
  */
46642
- async patch(path10, body, contentType = "application/json") {
46643
- return this.sendRequest("PATCH", path10, body, contentType);
46720
+ async patch(path9, body, contentType = "application/json") {
46721
+ return this.sendRequest("PATCH", path9, body, contentType);
46644
46722
  }
46645
46723
  /**
46646
46724
  * HTTP DELETE request.
46647
46725
  */
46648
- async delete(path10, body) {
46649
- return this.sendRequest("DELETE", path10, body);
46726
+ async delete(path9, body) {
46727
+ return this.sendRequest("DELETE", path9, body);
46650
46728
  }
46651
46729
  /**
46652
46730
  * Generic request method — public entry point for any HTTP method.
46653
46731
  */
46654
- async sendRequest(method, path10, body, contentType = "application/json") {
46655
- const url = this.buildUrl(path10);
46732
+ async sendRequest(method, path9, body, contentType = "application/json") {
46733
+ const url = this.buildUrl(path9);
46656
46734
  return this.execute(method.toUpperCase(), url, body, contentType);
46657
46735
  }
46658
46736
  /**
@@ -46676,7 +46754,7 @@ var init_api = __esm({
46676
46754
  * await api.upload("/avatars", { fileBytes: raw, filename: "me.png",
46677
46755
  * extraFields: { user_id: "42" } });
46678
46756
  */
46679
- async upload(path10, opts = {}) {
46757
+ async upload(path9, opts = {}) {
46680
46758
  const { filePath, fieldName = "file", extraFields, headers, fileBytes, filename } = opts;
46681
46759
  let content;
46682
46760
  let uploadName;
@@ -46711,7 +46789,7 @@ var init_api = __esm({
46711
46789
  const boundary = "----Tina4Boundary" + randomBytes11(16).toString("hex");
46712
46790
  const bodyBuffer = buildMultipartBody(boundary, fieldName, uploadName, content, partContentType, extraFields);
46713
46791
  const contentType = `multipart/form-data; boundary=${boundary}`;
46714
- return this.execute("POST", this.buildUrl(path10), bodyBuffer, contentType, headers);
46792
+ return this.execute("POST", this.buildUrl(path9), bodyBuffer, contentType, headers);
46715
46793
  }
46716
46794
  /**
46717
46795
  * Stream a GET response body to `destPath` in chunks.
@@ -46726,11 +46804,11 @@ var init_api = __esm({
46726
46804
  * dest, HTTP error status, or a transport failure); the destination file is
46727
46805
  * not written on error.
46728
46806
  */
46729
- async download(path10, destPath, params) {
46807
+ async download(path9, destPath, params) {
46730
46808
  if (!destPath) {
46731
46809
  return { http_code: null, headers: {}, error: "download requires destPath", path: null };
46732
46810
  }
46733
- let url = this.buildUrl(path10);
46811
+ let url = this.buildUrl(path9);
46734
46812
  if (params && Object.keys(params).length > 0) {
46735
46813
  const qs = new URLSearchParams(params).toString();
46736
46814
  url += (url.includes("?") ? "&" : "?") + qs;
@@ -46814,8 +46892,8 @@ var init_api = __esm({
46814
46892
  * bounds just the connect + headers phase (default
46815
46893
  * `TINA4_API_CONNECT_TIMEOUT` or 10s).
46816
46894
  */
46817
- async *streamBytes(path10, opts = {}) {
46818
- const url = this.buildUrl(path10);
46895
+ async *streamBytes(path9, opts = {}) {
46896
+ const url = this.buildUrl(path9);
46819
46897
  const method = (opts.method ?? "GET").toUpperCase();
46820
46898
  const contentType = opts.contentType ?? "application/json";
46821
46899
  const { headers, data } = this.buildRequest(method, contentType, opts.body, opts.headers, url);
@@ -46850,8 +46928,8 @@ var init_api = __esm({
46850
46928
  * yields a trailing line without a terminator on EOF. Built on
46851
46929
  * {@link streamBytes} plus the shared {@link parseLineStream}.
46852
46930
  */
46853
- async *streamLines(path10, opts = {}) {
46854
- yield* parseLineStream(this.streamBytes(path10, opts));
46931
+ async *streamLines(path9, opts = {}) {
46932
+ yield* parseLineStream(this.streamBytes(path9, opts));
46855
46933
  }
46856
46934
  /**
46857
46935
  * Stream the response as SSE (Server-Sent Events). Yields one
@@ -46860,8 +46938,8 @@ var init_api = __esm({
46860
46938
  * with `data === "[DONE]"` and the iterator ends on the next EOF.
46861
46939
  * Built on {@link streamLines} plus the shared {@link parseSseStream}.
46862
46940
  */
46863
- async *streamSse(path10, opts = {}) {
46864
- yield* parseSseStream(this.streamLines(path10, opts));
46941
+ async *streamSse(path9, opts = {}) {
46942
+ yield* parseSseStream(this.streamLines(path9, opts));
46865
46943
  }
46866
46944
  // ── Internal helpers ──────────────────────────────────────────────
46867
46945
  /**
@@ -46927,14 +47005,14 @@ var init_api = __esm({
46927
47005
  req2.end();
46928
47006
  });
46929
47007
  }
46930
- buildUrl(path10) {
46931
- if (path10.startsWith("http://") || path10.startsWith("https://")) {
46932
- return path10;
47008
+ buildUrl(path9) {
47009
+ if (path9.startsWith("http://") || path9.startsWith("https://")) {
47010
+ return path9;
46933
47011
  }
46934
- if (!path10) {
47012
+ if (!path9) {
46935
47013
  return this.baseUrl;
46936
47014
  }
46937
- return `${this.baseUrl}/${path10.replace(/^\/+/, "")}`;
47015
+ return `${this.baseUrl}/${path9.replace(/^\/+/, "")}`;
46938
47016
  }
46939
47017
  /**
46940
47018
  * The headers configured on the client, as they may go to `targetUrl`.
@@ -48892,15 +48970,15 @@ __export(ai_exports, {
48892
48970
  skillBlock: () => skillBlock,
48893
48971
  writeOrMerge: () => writeOrMerge
48894
48972
  });
48895
- import { existsSync as existsSync29, mkdirSync as mkdirSync22, writeFileSync as writeFileSync19, readFileSync as readFileSync26 } from "node:fs";
48973
+ import { existsSync as existsSync30, mkdirSync as mkdirSync22, writeFileSync as writeFileSync19, readFileSync as readFileSync26 } from "node:fs";
48896
48974
  import { homedir } from "node:os";
48897
- import { join as join34, resolve as resolve21, relative as relative11, dirname as dirname17 } from "node:path";
48898
- import { fileURLToPath as fileURLToPath10 } from "node:url";
48899
- import { execSync as execSync2, execFileSync as execFileSync4 } from "node:child_process";
48975
+ import { join as join35, resolve as resolve21, relative as relative10, dirname as dirname17 } from "node:path";
48976
+ import { fileURLToPath as fileURLToPath11 } from "node:url";
48977
+ import { execSync as execSync2, execFileSync as execFileSync3 } from "node:child_process";
48900
48978
  import { createInterface } from "node:readline";
48901
48979
  function readVersion() {
48902
48980
  try {
48903
- const thisDir = dirname17(fileURLToPath10(import.meta.url));
48981
+ const thisDir = dirname17(fileURLToPath11(import.meta.url));
48904
48982
  const rootPkg = resolve21(thisDir, "..", "..", "..", "package.json");
48905
48983
  const pkg = JSON.parse(readFileSync26(rootPkg, "utf-8"));
48906
48984
  return pkg.version ?? "0.0.0";
@@ -48952,7 +49030,7 @@ function downloadSkillsSync(jobs) {
48952
49030
  })();
48953
49031
  `;
48954
49032
  try {
48955
- const out = execFileSync4(process.execPath, ["-e", child, JSON.stringify(jobs)], {
49033
+ const out = execFileSync3(process.execPath, ["-e", child, JSON.stringify(jobs)], {
48956
49034
  encoding: "utf-8",
48957
49035
  timeout: 5e4,
48958
49036
  maxBuffer: 8 * 1024 * 1024
@@ -48965,8 +49043,8 @@ function downloadSkillsSync(jobs) {
48965
49043
  function installSkills(root = ".", targets) {
48966
49044
  const ref = skillsRef();
48967
49045
  const dests = targets ?? [
48968
- join34(resolve21(root), ".claude", "skills"),
48969
- join34(homedir(), ".claude", "skills")
49046
+ join35(resolve21(root), ".claude", "skills"),
49047
+ join35(homedir(), ".claude", "skills")
48970
49048
  ];
48971
49049
  const jobs = [];
48972
49050
  const index = /* @__PURE__ */ new Map();
@@ -48984,9 +49062,9 @@ function installSkills(root = ".", targets) {
48984
49062
  const base = `https://raw.githubusercontent.com/tina4stack/${spec.repo}/${ref}/.claude/skills/${skill}`;
48985
49063
  skillMdUrl[skill] = `${base}/SKILL.md`;
48986
49064
  for (const dest of dests) {
48987
- add(`${base}/SKILL.md`, join34(dest, skill, "SKILL.md"));
49065
+ add(`${base}/SKILL.md`, join35(dest, skill, "SKILL.md"));
48988
49066
  for (const r of spec.references) {
48989
- add(`${base}/references/${r}`, join34(dest, skill, "references", r));
49067
+ add(`${base}/references/${r}`, join35(dest, skill, "references", r));
48990
49068
  }
48991
49069
  }
48992
49070
  }
@@ -48998,7 +49076,7 @@ function installSkills(root = ".", targets) {
48998
49076
  return installed;
48999
49077
  }
49000
49078
  function isInstalled(root, tool) {
49001
- return existsSync29(join34(resolve21(root), tool.contextFile));
49079
+ return existsSync30(join35(resolve21(root), tool.contextFile));
49002
49080
  }
49003
49081
  function showMenu(root = ".") {
49004
49082
  const r = resolve21(root);
@@ -49121,7 +49199,7 @@ function looksLikeOldFrameworkInstall(existing) {
49121
49199
  function writeOrMerge(contextPath, contextFile, frameworkGuide) {
49122
49200
  const block = skillBlock(contextFile);
49123
49201
  const [start2, end] = markersFor(contextFile);
49124
- if (!existsSync29(contextPath)) {
49202
+ if (!existsSync30(contextPath)) {
49125
49203
  writeFileSync19(contextPath, frameworkGuide.replace(/\s+$/, "") + "\n\n" + block + "\n", "utf-8");
49126
49204
  return "Installed";
49127
49205
  }
@@ -49142,14 +49220,14 @@ function writeOrMerge(contextPath, contextFile, frameworkGuide) {
49142
49220
  }
49143
49221
  function installForTool(root, tool, context) {
49144
49222
  const created = [];
49145
- const contextPath = join34(root, tool.contextFile);
49223
+ const contextPath = join35(root, tool.contextFile);
49146
49224
  if (tool.configDir) {
49147
- mkdirSync22(join34(root, tool.configDir), { recursive: true });
49225
+ mkdirSync22(join35(root, tool.configDir), { recursive: true });
49148
49226
  }
49149
49227
  const parentDir = dirname17(contextPath);
49150
49228
  mkdirSync22(parentDir, { recursive: true });
49151
49229
  const action = writeOrMerge(contextPath, tool.contextFile, context);
49152
- const rel = relative11(root, contextPath);
49230
+ const rel = relative10(root, contextPath);
49153
49231
  created.push(rel);
49154
49232
  console.log(` ${GREEN2}\u2713${RESET2} ${action} ${rel}`);
49155
49233
  if (tool.name === "claude-code") {
@@ -49182,7 +49260,7 @@ function installTina4Ai() {
49182
49260
  function installClaudeSkills(root) {
49183
49261
  const created = [];
49184
49262
  for (const skill of installSkills(root)) {
49185
- created.push(join34(".claude", "skills", skill));
49263
+ created.push(join35(".claude", "skills", skill));
49186
49264
  console.log(` ${GREEN2}\u2713${RESET2} Installed .claude/skills/${skill} (project + global)`);
49187
49265
  }
49188
49266
  return created;
@@ -49523,10 +49601,10 @@ import { tests, assertEqual, runAll } from "tina4-nodejs";
49523
49601
  }
49524
49602
  function generateClaudeCodeContext() {
49525
49603
  try {
49526
- const thisDir = dirname17(fileURLToPath10(import.meta.url));
49604
+ const thisDir = dirname17(fileURLToPath11(import.meta.url));
49527
49605
  const repoRoot = resolve21(thisDir, "..", "..", "..");
49528
- const claudeMdPath = join34(repoRoot, "CLAUDE.md");
49529
- if (existsSync29(claudeMdPath)) {
49606
+ const claudeMdPath = join35(repoRoot, "CLAUDE.md");
49607
+ if (existsSync30(claudeMdPath)) {
49530
49608
  return readFileSync26(claudeMdPath, "utf-8");
49531
49609
  }
49532
49610
  } catch {
@@ -50187,10 +50265,10 @@ var init_aiClient = __esm({
50187
50265
  throw new AiConfigError("AI URL must be an http or https URL");
50188
50266
  }
50189
50267
  if (url.protocol !== "http:" && url.protocol !== "https:") throw new AiConfigError("AI URL must be an http or https URL");
50190
- const path10 = rtrimSlashes(url.pathname);
50191
- if (path10 === "" || path10 === "/v1" || path10 === "/api" || path10 === "/v1beta/openai") {
50268
+ const path9 = rtrimSlashes(url.pathname);
50269
+ if (path9 === "" || path9 === "/v1" || path9 === "/api" || path9 === "/v1beta/openai") {
50192
50270
  const suffix = provider === "anthropic" ? "/messages" : capability === "embed" ? "/embeddings" : "/chat/completions";
50193
- url.pathname = (path10 || "/v1") + suffix;
50271
+ url.pathname = (path9 || "/v1") + suffix;
50194
50272
  }
50195
50273
  return url.toString();
50196
50274
  }
@@ -50706,7 +50784,7 @@ var init_aiClient = __esm({
50706
50784
  });
50707
50785
 
50708
50786
  // ../core/src/queueBackends/rabbitmqBackend.ts
50709
- import { execFileSync as execFileSync5 } from "node:child_process";
50787
+ import { execFileSync as execFileSync4 } from "node:child_process";
50710
50788
  import { randomUUID as randomUUID9 } from "node:crypto";
50711
50789
  function parseAmqpUrl(url) {
50712
50790
  const config = {};
@@ -51127,7 +51205,7 @@ var init_rabbitmqBackend = __esm({
51127
51205
  setTimeout(() => { sock.destroy(); process.exit(1); }, 10000).unref();
51128
51206
  `;
51129
51207
  try {
51130
- const result = execFileSync5(process.execPath, ["-e", script], {
51208
+ const result = execFileSync4(process.execPath, ["-e", script], {
51131
51209
  encoding: "utf-8",
51132
51210
  timeout: 15e3,
51133
51211
  stdio: ["pipe", "pipe", "pipe"]
@@ -51503,27 +51581,27 @@ var init_testClient = __esm({
51503
51581
  return this.ctxPromise;
51504
51582
  }
51505
51583
  /** Send a GET request. */
51506
- async get(path10, options) {
51507
- return this._request("GET", path10, options);
51584
+ async get(path9, options) {
51585
+ return this._request("GET", path9, options);
51508
51586
  }
51509
51587
  /** Send a POST request. */
51510
- async post(path10, options) {
51511
- return this._request("POST", path10, options);
51588
+ async post(path9, options) {
51589
+ return this._request("POST", path9, options);
51512
51590
  }
51513
51591
  /** Send a PUT request. */
51514
- async put(path10, options) {
51515
- return this._request("PUT", path10, options);
51592
+ async put(path9, options) {
51593
+ return this._request("PUT", path9, options);
51516
51594
  }
51517
51595
  /** Send a PATCH request. */
51518
- async patch(path10, options) {
51519
- return this._request("PATCH", path10, options);
51596
+ async patch(path9, options) {
51597
+ return this._request("PATCH", path9, options);
51520
51598
  }
51521
51599
  /** Send a DELETE request. */
51522
- async delete(path10, options) {
51523
- return this._request("DELETE", path10, options);
51600
+ async delete(path9, options) {
51601
+ return this._request("DELETE", path9, options);
51524
51602
  }
51525
51603
  /** Build a mock request/response pair and dispatch it through the REAL pipeline (runDispatch). */
51526
- async _request(method, path10, options) {
51604
+ async _request(method, path9, options) {
51527
51605
  const { json, body, headers } = options ?? {};
51528
51606
  let rawBody = "";
51529
51607
  let contentType = "";
@@ -51549,7 +51627,7 @@ var init_testClient = __esm({
51549
51627
  Object.defineProperty(socket, "remoteAddress", { value: "127.0.0.1" });
51550
51628
  const rawReq = new IncomingMessage2(socket);
51551
51629
  rawReq.method = method.toUpperCase();
51552
- rawReq.url = path10;
51630
+ rawReq.url = path9;
51553
51631
  rawReq.headers = { ...reqHeaders, host: "localhost:7148" };
51554
51632
  if (rawBody) {
51555
51633
  rawReq.push(Buffer.from(rawBody));
@@ -51620,20 +51698,20 @@ var init_test = __esm({
51620
51698
  if (this._client === null) this._client = new TestClient();
51621
51699
  return this._client;
51622
51700
  }
51623
- async get(path10, options) {
51624
- return this.client.get(path10, options);
51701
+ async get(path9, options) {
51702
+ return this.client.get(path9, options);
51625
51703
  }
51626
- async post(path10, options) {
51627
- return this.client.post(path10, options);
51704
+ async post(path9, options) {
51705
+ return this.client.post(path9, options);
51628
51706
  }
51629
- async put(path10, options) {
51630
- return this.client.put(path10, options);
51707
+ async put(path9, options) {
51708
+ return this.client.put(path9, options);
51631
51709
  }
51632
- async patch(path10, options) {
51633
- return this.client.patch(path10, options);
51710
+ async patch(path9, options) {
51711
+ return this.client.patch(path9, options);
51634
51712
  }
51635
- async delete(path10, options) {
51636
- return this.client.delete(path10, options);
51713
+ async delete(path9, options) {
51714
+ return this.client.delete(path9, options);
51637
51715
  }
51638
51716
  // ── Positional assertions — (actual, expected, message) shape ────────
51639
51717
  assertEqual(actual, expected, message) {
@@ -52559,7 +52637,7 @@ ${cdStep} npm install
52559
52637
 
52560
52638
  // src/commands/serve.ts
52561
52639
  import { resolve as resolve22 } from "node:path";
52562
- import { existsSync as existsSync30 } from "node:fs";
52640
+ import { existsSync as existsSync31 } from "node:fs";
52563
52641
  async function serveProject(options) {
52564
52642
  if (options.noReload) {
52565
52643
  process.env.TINA4_NO_RELOAD = "true";
@@ -52572,7 +52650,7 @@ async function serveProject(options) {
52572
52650
  const modelsDir = resolve22(cwd, "src/models");
52573
52651
  const templatesDir = resolve22(cwd, "src/templates");
52574
52652
  const staticDir = resolve22(cwd, "public");
52575
- if (!existsSync30(routesDir) && !existsSync30(modelsDir) && !existsSync30(ormDir)) {
52653
+ if (!existsSync31(routesDir) && !existsSync31(modelsDir) && !existsSync31(ormDir)) {
52576
52654
  console.error(" Error: Not a Tina4 project. Run this from a project created with 'tina4 init'.");
52577
52655
  process.exit(1);
52578
52656
  }
@@ -52591,12 +52669,12 @@ async function serveProject(options) {
52591
52669
  // src/commands/migrate.ts
52592
52670
  init_dotenv();
52593
52671
  init_util();
52594
- import { existsSync as existsSync31 } from "node:fs";
52672
+ import { existsSync as existsSync32 } from "node:fs";
52595
52673
  import { resolve as resolve23 } from "node:path";
52596
52674
  async function runMigrations(migrationDir) {
52597
52675
  loadEnv();
52598
52676
  const dir = resolve23(migrationDir ?? "migrations");
52599
- if (!existsSync31(dir)) {
52677
+ if (!existsSync32(dir)) {
52600
52678
  console.log(" No migrations/ directory found. Nothing to run.");
52601
52679
  return;
52602
52680
  }
@@ -52749,11 +52827,11 @@ async function migrateRollback(migrationDir) {
52749
52827
  }
52750
52828
 
52751
52829
  // src/commands/routes.ts
52752
- import { existsSync as existsSync32 } from "node:fs";
52830
+ import { existsSync as existsSync33 } from "node:fs";
52753
52831
  import { resolve as resolve26 } from "node:path";
52754
52832
  async function listRoutes() {
52755
52833
  const routesDir = resolve26("src/routes");
52756
- if (!existsSync32(routesDir)) {
52834
+ if (!existsSync33(routesDir)) {
52757
52835
  console.error(" No src/routes/ directory found. Are you in a Tina4 project?");
52758
52836
  process.exit(1);
52759
52837
  }
@@ -52783,9 +52861,9 @@ async function listRoutes() {
52783
52861
  console.log(" " + "-".repeat(70));
52784
52862
  for (const route of routes) {
52785
52863
  const method = route.method.toUpperCase().padEnd(10);
52786
- const path10 = route.pattern.padEnd(40);
52864
+ const path9 = route.pattern.padEnd(40);
52787
52865
  const summary = route.meta?.summary ?? "";
52788
- console.log(` ${method}${path10}${summary}`);
52866
+ console.log(` ${method}${path9}${summary}`);
52789
52867
  }
52790
52868
  console.log(" " + "-".repeat(70));
52791
52869
  console.log(` Total: ${routes.length} route(s)`);
@@ -52793,9 +52871,9 @@ async function listRoutes() {
52793
52871
  }
52794
52872
 
52795
52873
  // src/commands/test.ts
52796
- import { existsSync as existsSync33, readdirSync as readdirSync20, readFileSync as readFileSync27, statSync as statSync21 } from "node:fs";
52797
- import { resolve as resolve27, join as join35 } from "node:path";
52798
- import { pathToFileURL as pathToFileURL2 } from "node:url";
52874
+ import { existsSync as existsSync34, readdirSync as readdirSync20, readFileSync as readFileSync27, statSync as statSync22 } from "node:fs";
52875
+ import { resolve as resolve27, join as join36 } from "node:path";
52876
+ import { pathToFileURL as pathToFileURL5 } from "node:url";
52799
52877
  import { execSync as execSync3 } from "node:child_process";
52800
52878
  function walkSource(dir) {
52801
52879
  const out = [];
@@ -52806,10 +52884,10 @@ function walkSource(dir) {
52806
52884
  return out;
52807
52885
  }
52808
52886
  for (const name of entries) {
52809
- const full = join35(dir, name);
52887
+ const full = join36(dir, name);
52810
52888
  let st;
52811
52889
  try {
52812
- st = statSync21(full);
52890
+ st = statSync22(full);
52813
52891
  } catch {
52814
52892
  continue;
52815
52893
  }
@@ -52823,7 +52901,7 @@ function walkSource(dir) {
52823
52901
  }
52824
52902
  async function runInlineTests(cwd) {
52825
52903
  const srcDir = resolve27(cwd, "src");
52826
- if (!existsSync33(srcDir)) return false;
52904
+ if (!existsSync34(srcDir)) return false;
52827
52905
  const { runAllAsync: runAllAsync2, reset: reset2 } = await Promise.resolve().then(() => (init_src3(), src_exports3));
52828
52906
  reset2();
52829
52907
  let discovered = 0;
@@ -52837,7 +52915,7 @@ async function runInlineTests(cwd) {
52837
52915
  if (!/\btests\s*\(/.test(text)) continue;
52838
52916
  discovered++;
52839
52917
  try {
52840
- await import(pathToFileURL2(file).href);
52918
+ await import(pathToFileURL5(file).href);
52841
52919
  } catch (err) {
52842
52920
  console.log(
52843
52921
  ` ! could not import ${file}: ${err instanceof Error ? err.message : String(err)}`
@@ -52854,7 +52932,7 @@ async function runTests(testPath) {
52854
52932
  let fileFailed = false;
52855
52933
  if (testPath) {
52856
52934
  const file = resolve27(testPath);
52857
- if (!existsSync33(file)) {
52935
+ if (!existsSync34(file)) {
52858
52936
  console.error(` Error: Test file not found: ${testPath}`);
52859
52937
  process.exit(1);
52860
52938
  }
@@ -52871,13 +52949,13 @@ async function runTests(testPath) {
52871
52949
  let testFiles = [];
52872
52950
  for (const candidate of candidates) {
52873
52951
  const fullPath = resolve27(cwd, candidate);
52874
- if (!existsSync33(fullPath)) continue;
52952
+ if (!existsSync34(fullPath)) continue;
52875
52953
  if (candidate.endsWith(".ts")) {
52876
52954
  testFiles.push(fullPath);
52877
52955
  break;
52878
52956
  }
52879
52957
  try {
52880
- const files = readdirSync20(fullPath).filter((f) => f.endsWith(".ts")).map((f) => join35(fullPath, f));
52958
+ const files = readdirSync20(fullPath).filter((f) => f.endsWith(".ts")).map((f) => join36(fullPath, f));
52881
52959
  testFiles.push(...files);
52882
52960
  } catch {
52883
52961
  }
@@ -52894,8 +52972,8 @@ async function runTests(testPath) {
52894
52972
  console.log(` Found ${testFiles.length} test file(s)
52895
52973
  `);
52896
52974
  for (const file of testFiles) {
52897
- const relative13 = file.replace(cwd + "/", "");
52898
- console.log(` Running: ${relative13}`);
52975
+ const relative12 = file.replace(cwd + "/", "");
52976
+ console.log(` Running: ${relative12}`);
52899
52977
  try {
52900
52978
  execSync3(`npx tsx "${file}"`, { cwd, stdio: "inherit" });
52901
52979
  } catch {
@@ -52907,9 +52985,10 @@ async function runTests(testPath) {
52907
52985
 
52908
52986
  // src/commands/lint.ts
52909
52987
  init_util();
52910
- import { existsSync as existsSync34, readdirSync as readdirSync21, readFileSync as readFileSync28, statSync as statSync22, writeFileSync as writeFileSync20 } from "node:fs";
52988
+ init_batchSpawn();
52989
+ import { existsSync as existsSync35, readdirSync as readdirSync21, readFileSync as readFileSync28, statSync as statSync23, writeFileSync as writeFileSync20 } from "node:fs";
52911
52990
  import { createRequire as createRequire8 } from "node:module";
52912
- import { dirname as dirname18, join as join36, relative as relative12 } from "node:path";
52991
+ import { dirname as dirname18, join as join37, relative as relative11 } from "node:path";
52913
52992
  import { spawnSync as spawnSync3 } from "node:child_process";
52914
52993
  var LINT_EXTENSIONS = [".ts", ".mts", ".cts", ".js", ".mjs", ".cjs"];
52915
52994
  var JS_EXTENSIONS = [".js", ".mjs", ".cjs"];
@@ -52927,10 +53006,10 @@ function walkSource2(dir, out) {
52927
53006
  }
52928
53007
  for (const name of entries) {
52929
53008
  if (SKIP_DIRS3.has(name)) continue;
52930
- const full = join36(dir, name);
53009
+ const full = join37(dir, name);
52931
53010
  let st;
52932
53011
  try {
52933
- st = statSync22(full);
53012
+ st = statSync23(full);
52934
53013
  } catch {
52935
53014
  continue;
52936
53015
  }
@@ -52943,15 +53022,15 @@ function walkSource2(dir, out) {
52943
53022
  }
52944
53023
  function collectAppFiles(cwd) {
52945
53024
  const files = [];
52946
- const srcDir = join36(cwd, "src");
53025
+ const srcDir = join37(cwd, "src");
52947
53026
  try {
52948
- if (statSync22(srcDir).isDirectory()) walkSource2(srcDir, files);
53027
+ if (statSync23(srcDir).isDirectory()) walkSource2(srcDir, files);
52949
53028
  } catch {
52950
53029
  }
52951
53030
  for (const entry of ["app.ts", "app.mts", "app.js", "app.mjs"]) {
52952
- const p = join36(cwd, entry);
53031
+ const p = join37(cwd, entry);
52953
53032
  try {
52954
- if (statSync22(p).isFile()) files.push(p);
53033
+ if (statSync23(p).isFile()) files.push(p);
52955
53034
  } catch {
52956
53035
  }
52957
53036
  }
@@ -52972,15 +53051,15 @@ export default [js.configs.recommended, ...tseslint.configs.recommended];
52972
53051
  `;
52973
53052
  function findEslintConfig(cwd) {
52974
53053
  for (const name of ESLINT_FLAT_CONFIGS) {
52975
- const p = join36(cwd, name);
52976
- if (existsSync34(p)) return p;
53054
+ const p = join37(cwd, name);
53055
+ if (existsSync35(p)) return p;
52977
53056
  }
52978
53057
  return null;
52979
53058
  }
52980
53059
  function resolvePackageBin(cwd, pkg, binRelative) {
52981
- const direct = join36(cwd, "node_modules", pkg, binRelative);
52982
- if (existsSync34(direct)) return direct;
52983
- const require2 = createRequire8(join36(cwd, "package.json"));
53060
+ const direct = join37(cwd, "node_modules", pkg, binRelative);
53061
+ if (existsSync35(direct)) return direct;
53062
+ const require2 = createRequire8(join37(cwd, "package.json"));
52984
53063
  let entry;
52985
53064
  try {
52986
53065
  entry = require2.resolve(pkg);
@@ -52989,12 +53068,12 @@ function resolvePackageBin(cwd, pkg, binRelative) {
52989
53068
  }
52990
53069
  let dir = dirname18(entry);
52991
53070
  for (let i = 0; i < 8; i++) {
52992
- const pkgJson = join36(dir, "package.json");
52993
- if (existsSync34(pkgJson)) {
53071
+ const pkgJson = join37(dir, "package.json");
53072
+ if (existsSync35(pkgJson)) {
52994
53073
  try {
52995
53074
  if (JSON.parse(readFileSync28(pkgJson, "utf-8")).name === pkg) {
52996
- const bin = join36(dir, binRelative);
52997
- return existsSync34(bin) ? bin : null;
53075
+ const bin = join37(dir, binRelative);
53076
+ return existsSync35(bin) ? bin : null;
52998
53077
  }
52999
53078
  } catch {
53000
53079
  }
@@ -53009,7 +53088,7 @@ function resolveEslintBin(cwd) {
53009
53088
  return resolvePackageBin(cwd, "eslint", "bin/eslint.js");
53010
53089
  }
53011
53090
  function hasPackage(cwd, pkg) {
53012
- return existsSync34(join36(cwd, "node_modules", ...pkg.split("/"), "package.json"));
53091
+ return existsSync35(join37(cwd, "node_modules", ...pkg.split("/"), "package.json"));
53013
53092
  }
53014
53093
  function resolveNpm() {
53015
53094
  const windows = process.platform === "win32";
@@ -53027,12 +53106,12 @@ function bootstrapEslint(cwd, noInstall) {
53027
53106
  }
53028
53107
  if (!bin) {
53029
53108
  console.log(" \xB7 installing eslint (npm i -D eslint @eslint/js typescript-eslint)...");
53030
- const rc = spawnSync3(npm, ["install", "-D", "eslint", "@eslint/js", "typescript-eslint"], { cwd, stdio: "inherit" }).status;
53109
+ const rc = spawnSyncAllowingBatch(npm, ["install", "-D", "eslint", "@eslint/js", "typescript-eslint"], { cwd, stdio: "inherit" }).status;
53031
53110
  if (rc === 0) bin = resolveEslintBin(cwd);
53032
53111
  else console.log(" \xB7 could not install eslint \u2014 using the zero-dependency baseline.");
53033
53112
  }
53034
53113
  if (bin && !config && hasPackage(cwd, "@eslint/js") && hasPackage(cwd, "typescript-eslint")) {
53035
- const scaffold = join36(cwd, ESLINT_SCAFFOLD_FILE);
53114
+ const scaffold = join37(cwd, ESLINT_SCAFFOLD_FILE);
53036
53115
  try {
53037
53116
  writeFileSync20(scaffold, ESLINT_SCAFFOLD, "utf-8");
53038
53117
  config = scaffold;
@@ -53077,7 +53156,7 @@ function runJavaScript(cwd, files) {
53077
53156
  if ((result.status ?? 1) === 0) continue;
53078
53157
  const stderr = (result.stderr || "").trim();
53079
53158
  const detail = stderr.split("\n").reverse().find((line) => line.includes("Error:")) || "syntax error";
53080
- console.log(` \u2717 ${relative12(cwd, file)}: ${detail.trim()}`);
53159
+ console.log(` \u2717 ${relative11(cwd, file)}: ${detail.trim()}`);
53081
53160
  syntaxErrors++;
53082
53161
  }
53083
53162
  if (syntaxErrors > 0) {
@@ -53101,7 +53180,7 @@ function runLint(args) {
53101
53180
  if (fix) {
53102
53181
  console.log(" \xB7 --fix needs eslint \u2014 the baseline check has no autofix.");
53103
53182
  }
53104
- if (existsSync34(join36(cwd, "tsconfig.json")) && runTypescript(cwd, files)) return;
53183
+ if (existsSync35(join37(cwd, "tsconfig.json")) && runTypescript(cwd, files)) return;
53105
53184
  runJavaScript(cwd, files);
53106
53185
  }
53107
53186
 
@@ -53109,15 +53188,15 @@ function runLint(args) {
53109
53188
  init_generate();
53110
53189
 
53111
53190
  // src/commands/seed.ts
53112
- import { existsSync as existsSync35, readdirSync as readdirSync22 } from "node:fs";
53113
- import { resolve as resolve28, join as join37 } from "node:path";
53191
+ import { existsSync as existsSync36, readdirSync as readdirSync22 } from "node:fs";
53192
+ import { resolve as resolve28, join as join38 } from "node:path";
53114
53193
  import { execSync as execSync4 } from "node:child_process";
53115
53194
  async function runSeeds(seedPath) {
53116
53195
  const cwd = process.cwd();
53117
53196
  const seedDir = resolve28(cwd, "src/seeds");
53118
53197
  if (seedPath) {
53119
53198
  const file = resolve28(seedPath);
53120
- if (!existsSync35(file)) {
53199
+ if (!existsSync36(file)) {
53121
53200
  console.error(` Error: Seed file not found: ${seedPath}`);
53122
53201
  process.exit(1);
53123
53202
  }
@@ -53130,14 +53209,14 @@ async function runSeeds(seedPath) {
53130
53209
  }
53131
53210
  return;
53132
53211
  }
53133
- if (!existsSync35(seedDir)) {
53212
+ if (!existsSync36(seedDir)) {
53134
53213
  console.log(" No seeds directory found.");
53135
53214
  console.log(" Create seed files in src/seeds/ (e.g. src/seeds/001-users.ts)");
53136
53215
  return;
53137
53216
  }
53138
53217
  let seedFiles;
53139
53218
  try {
53140
- seedFiles = readdirSync22(seedDir).filter((f) => f.endsWith(".ts")).sort().map((f) => join37(seedDir, f));
53219
+ seedFiles = readdirSync22(seedDir).filter((f) => f.endsWith(".ts")).sort().map((f) => join38(seedDir, f));
53141
53220
  } catch {
53142
53221
  console.log(" Could not read src/seeds/ directory.");
53143
53222
  return;
@@ -53150,8 +53229,8 @@ async function runSeeds(seedPath) {
53150
53229
  `);
53151
53230
  let failed = false;
53152
53231
  for (const file of seedFiles) {
53153
- const relative13 = file.replace(cwd + "/", "");
53154
- console.log(` Seeding: ${relative13}`);
53232
+ const relative12 = file.replace(cwd + "/", "");
53233
+ console.log(` Seeding: ${relative12}`);
53155
53234
  try {
53156
53235
  execSync4(`npx tsx "${file}"`, { cwd, stdio: "inherit" });
53157
53236
  } catch {
@@ -53169,27 +53248,27 @@ async function runSeeds(seedPath) {
53169
53248
  init_dotenv();
53170
53249
  init_queue();
53171
53250
  init_util();
53172
- import { readdirSync as readdirSync23, statSync as statSync23 } from "node:fs";
53173
- import { extname as extname9, join as join38 } from "node:path";
53174
- import { pathToFileURL as pathToFileURL3 } from "node:url";
53251
+ import { readdirSync as readdirSync23, statSync as statSync24 } from "node:fs";
53252
+ import { extname as extname10, join as join39 } from "node:path";
53253
+ import { pathToFileURL as pathToFileURL6 } from "node:url";
53175
53254
  var BOOLEAN_FLAGS = /* @__PURE__ */ new Set(["once", "json"]);
53176
53255
  var parseFlags2 = (args) => parseFlags(args, BOOLEAN_FLAGS);
53177
53256
  async function resolveQueueHandler(servicesDir, topic) {
53178
53257
  let entries;
53179
53258
  try {
53180
- if (!statSync23(servicesDir).isDirectory()) return null;
53259
+ if (!statSync24(servicesDir).isDirectory()) return null;
53181
53260
  entries = readdirSync23(servicesDir);
53182
53261
  } catch {
53183
53262
  return null;
53184
53263
  }
53185
53264
  for (const entry of entries.sort()) {
53186
53265
  if (entry.startsWith("_")) continue;
53187
- const ext = extname9(entry);
53266
+ const ext = extname10(entry);
53188
53267
  if (ext !== ".ts" && ext !== ".js") continue;
53189
- const fullPath = join38(servicesDir, entry);
53268
+ const fullPath = join39(servicesDir, entry);
53190
53269
  try {
53191
- if (!statSync23(fullPath).isFile()) continue;
53192
- const mod = await import(pathToFileURL3(fullPath).href);
53270
+ if (!statSync24(fullPath).isFile()) continue;
53271
+ const mod = await import(pathToFileURL6(fullPath).href);
53193
53272
  const config = mod.default ?? mod;
53194
53273
  if (config && typeof config === "object" && config.topic === topic && typeof config.handle === "function") {
53195
53274
  return config.handle;
@@ -53345,8 +53424,8 @@ async function queueCommand(args = []) {
53345
53424
 
53346
53425
  // src/commands/build.ts
53347
53426
  init_util();
53348
- import { accessSync as accessSync2, constants as constants5, existsSync as existsSync36, statSync as statSync24 } from "node:fs";
53349
- import { basename as basename9, delimiter as delimiter3, join as join39 } from "node:path";
53427
+ import { accessSync as accessSync2, constants as constants5, existsSync as existsSync37, statSync as statSync25 } from "node:fs";
53428
+ import { basename as basename9, delimiter as delimiter4, join as join40 } from "node:path";
53350
53429
  import { spawnSync as spawnSync4 } from "node:child_process";
53351
53430
  function parseFlags3(args) {
53352
53431
  return parseFlags(args).flags;
@@ -53355,13 +53434,13 @@ function whichDocker() {
53355
53434
  const pathValue = process.env.PATH || process.env.Path || "";
53356
53435
  if (!pathValue) return null;
53357
53436
  const exts = process.platform === "win32" ? (process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM").split(";") : [""];
53358
- for (const dir of pathValue.split(delimiter3)) {
53437
+ for (const dir of pathValue.split(delimiter4)) {
53359
53438
  if (!dir) continue;
53360
53439
  for (const ext of exts) {
53361
- const candidate = join39(dir, `docker${ext}`);
53440
+ const candidate = join40(dir, `docker${ext}`);
53362
53441
  try {
53363
53442
  accessSync2(candidate, constants5.X_OK);
53364
- if (statSync24(candidate).isFile()) return candidate;
53443
+ if (statSync25(candidate).isFile()) return candidate;
53365
53444
  } catch {
53366
53445
  }
53367
53446
  }
@@ -53376,7 +53455,7 @@ function buildImage(args) {
53376
53455
  tag = `${dirName || "tina4app"}:latest`;
53377
53456
  }
53378
53457
  const dockerfile = typeof flags.file === "string" && flags.file ? flags.file : "Dockerfile";
53379
- if (!existsSync36(dockerfile) || !statSync24(dockerfile).isFile()) {
53458
+ if (!existsSync37(dockerfile) || !statSync25(dockerfile).isFile()) {
53380
53459
  console.log(` \u2717 No ${dockerfile} found.`);
53381
53460
  console.log(" A Tina4 app deploys as a container. Scaffold a Dockerfile first:");
53382
53461
  console.log(" tina4 deploy docker (or: tina4nodejs init)");
@@ -53403,16 +53482,16 @@ function buildImage(args) {
53403
53482
  }
53404
53483
 
53405
53484
  // src/bin.ts
53485
+ init_batchSpawn();
53406
53486
  init_util();
53407
- import { spawnSync as spawnSync5 } from "node:child_process";
53408
- import { existsSync as existsSync37, readFileSync as readFileSync29 } from "node:fs";
53409
- import { dirname as dirname19, join as join40 } from "node:path";
53410
- import { fileURLToPath as fileURLToPath11, pathToFileURL as pathToFileURL4 } from "node:url";
53487
+ import { existsSync as existsSync38, readFileSync as readFileSync29 } from "node:fs";
53488
+ import { dirname as dirname19, join as join41 } from "node:path";
53489
+ import { fileURLToPath as fileURLToPath12, pathToFileURL as pathToFileURL7 } from "node:url";
53411
53490
  function readCliVersion() {
53412
- let dir = dirname19(fileURLToPath11(import.meta.url));
53491
+ let dir = dirname19(fileURLToPath12(import.meta.url));
53413
53492
  for (let i = 0; i < 6; i++) {
53414
- const pkgPath = join40(dir, "package.json");
53415
- if (existsSync37(pkgPath)) {
53493
+ const pkgPath = join41(dir, "package.json");
53494
+ if (existsSync38(pkgPath)) {
53416
53495
  try {
53417
53496
  const pkg = JSON.parse(readFileSync29(pkgPath, "utf-8"));
53418
53497
  if (typeof pkg.version === "string" && pkg.version) return pkg.version;
@@ -53756,7 +53835,7 @@ ${CLIENT_INSTALL_HINT}
53756
53835
  );
53757
53836
  return EXIT_CLIENT_UNAVAILABLE;
53758
53837
  }
53759
- const result = spawnSync5(client, [command, ...args], {
53838
+ const result = spawnSyncAllowingBatch(client, [command, ...args], {
53760
53839
  stdio: "inherit",
53761
53840
  env: { ...process.env, [DELEGATION_GUARD_ENV]: command }
53762
53841
  });
@@ -53893,7 +53972,7 @@ async function main() {
53893
53972
  printHelp();
53894
53973
  process.exit(EXIT_UNKNOWN_COMMAND);
53895
53974
  }
53896
- if (process.argv[1] && import.meta.url === pathToFileURL4(process.argv[1]).href) {
53975
+ if (process.argv[1] && import.meta.url === pathToFileURL7(process.argv[1]).href) {
53897
53976
  main().catch((err) => {
53898
53977
  console.error(err);
53899
53978
  process.exit(1);